single-file-extension-editor-helper.js 451 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  3. typeof define === 'function' && define.amd ? define(['exports'], factory) :
  4. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.singlefile = {}));
  5. })(this, (function (exports) { 'use strict';
  6. /*
  7. * Copyright 2010-2022 Gildas Lormeau
  8. * contact : gildas.lormeau <at> gmail.com
  9. *
  10. * This file is part of SingleFile.
  11. *
  12. * The code in this file is free software: you can redistribute it and/or
  13. * modify it under the terms of the GNU Affero General Public License
  14. * (GNU AGPL) as published by the Free Software Foundation, either version 3
  15. * of the License, or (at your option) any later version.
  16. *
  17. * The code in this file is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
  20. * General Public License for more details.
  21. *
  22. * As additional permission under GNU AGPL version 3 section 7, you may
  23. * distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU
  24. * AGPL normally required by section 4, provided you include this license
  25. * notice and a URL through which recipients can access the Corresponding
  26. * Source.
  27. */
  28. const SELF_CLOSED_TAG_NAMES = ["AREA", "BASE", "BR", "COL", "COMMAND", "EMBED", "HR", "IMG", "INPUT", "KEYGEN", "LINK", "META", "PARAM", "SOURCE", "TRACK", "WBR"];
  29. const Node_ELEMENT_NODE$1 = 1;
  30. const Node_TEXT_NODE$1 = 3;
  31. const Node_COMMENT_NODE$1 = 8;
  32. // see https://www.w3.org/TR/html5/syntax.html#optional-tags
  33. const OMITTED_START_TAGS = [
  34. { tagName: "HEAD", accept: element => !element.childNodes.length || element.childNodes[0].nodeType == Node_ELEMENT_NODE$1 },
  35. { tagName: "BODY", accept: element => !element.childNodes.length }
  36. ];
  37. const OMITTED_END_TAGS = [
  38. { tagName: "HTML", accept: next => !next || next.nodeType != Node_COMMENT_NODE$1 },
  39. { tagName: "HEAD", accept: next => !next || (next.nodeType != Node_COMMENT_NODE$1 && (next.nodeType != Node_TEXT_NODE$1 || !startsWithSpaceChar(next.textContent))) },
  40. { tagName: "BODY", accept: next => !next || next.nodeType != Node_COMMENT_NODE$1 },
  41. { tagName: "LI", accept: (next, element) => (!next && element.parentElement && (getTagName$1(element.parentElement) == "UL" || getTagName$1(element.parentElement) == "OL")) || (next && ["LI"].includes(getTagName$1(next))) },
  42. { tagName: "DT", accept: next => !next || ["DT", "DD"].includes(getTagName$1(next)) },
  43. { tagName: "P", accept: next => next && ["ADDRESS", "ARTICLE", "ASIDE", "BLOCKQUOTE", "DETAILS", "DIV", "DL", "FIELDSET", "FIGCAPTION", "FIGURE", "FOOTER", "FORM", "H1", "H2", "H3", "H4", "H5", "H6", "HEADER", "HR", "MAIN", "NAV", "OL", "P", "PRE", "SECTION", "TABLE", "UL"].includes(getTagName$1(next)) },
  44. { tagName: "DD", accept: next => !next || ["DT", "DD"].includes(getTagName$1(next)) },
  45. { tagName: "RT", accept: next => !next || ["RT", "RP"].includes(getTagName$1(next)) },
  46. { tagName: "RP", accept: next => !next || ["RT", "RP"].includes(getTagName$1(next)) },
  47. { tagName: "OPTGROUP", accept: next => !next || ["OPTGROUP"].includes(getTagName$1(next)) },
  48. { tagName: "OPTION", accept: next => !next || ["OPTION", "OPTGROUP"].includes(getTagName$1(next)) },
  49. { tagName: "COLGROUP", accept: next => !next || (next.nodeType != Node_COMMENT_NODE$1 && (next.nodeType != Node_TEXT_NODE$1 || !startsWithSpaceChar(next.textContent))) },
  50. { tagName: "CAPTION", accept: next => !next || (next.nodeType != Node_COMMENT_NODE$1 && (next.nodeType != Node_TEXT_NODE$1 || !startsWithSpaceChar(next.textContent))) },
  51. { tagName: "THEAD", accept: next => !next || ["TBODY", "TFOOT"].includes(getTagName$1(next)) },
  52. { tagName: "TBODY", accept: next => !next || ["TBODY", "TFOOT"].includes(getTagName$1(next)) },
  53. { tagName: "TFOOT", accept: next => !next },
  54. { tagName: "TR", accept: next => !next || ["TR"].includes(getTagName$1(next)) },
  55. { tagName: "TD", accept: next => !next || ["TD", "TH"].includes(getTagName$1(next)) },
  56. { tagName: "TH", accept: next => !next || ["TD", "TH"].includes(getTagName$1(next)) }
  57. ];
  58. const TEXT_NODE_TAGS = ["STYLE", "SCRIPT", "XMP", "IFRAME", "NOEMBED", "NOFRAMES", "PLAINTEXT", "NOSCRIPT"];
  59. function process$7(doc, compressHTML) {
  60. const docType = doc.doctype;
  61. let docTypeString = "";
  62. if (docType) {
  63. docTypeString = "<!DOCTYPE " + docType.nodeName;
  64. if (docType.publicId) {
  65. docTypeString += " PUBLIC \"" + docType.publicId + "\"";
  66. if (docType.systemId)
  67. docTypeString += " \"" + docType.systemId + "\"";
  68. } else if (docType.systemId)
  69. docTypeString += " SYSTEM \"" + docType.systemId + "\"";
  70. if (docType.internalSubset)
  71. docTypeString += " [" + docType.internalSubset + "]";
  72. docTypeString += "> ";
  73. }
  74. return docTypeString + serialize(doc.documentElement, compressHTML);
  75. }
  76. function serialize(node, compressHTML, isSVG) {
  77. if (node.nodeType == Node_TEXT_NODE$1) {
  78. return serializeTextNode(node);
  79. } else if (node.nodeType == Node_COMMENT_NODE$1) {
  80. return serializeCommentNode(node);
  81. } else if (node.nodeType == Node_ELEMENT_NODE$1) {
  82. return serializeElement(node, compressHTML, isSVG);
  83. }
  84. }
  85. function serializeTextNode(textNode) {
  86. const parentNode = textNode.parentNode;
  87. let parentTagName;
  88. if (parentNode && parentNode.nodeType == Node_ELEMENT_NODE$1) {
  89. parentTagName = getTagName$1(parentNode);
  90. }
  91. if (!parentTagName || TEXT_NODE_TAGS.includes(parentTagName)) {
  92. if (parentTagName == "SCRIPT" || parentTagName == "STYLE") {
  93. return textNode.textContent.replace(/<\//gi, "<\\/").replace(/\/>/gi, "\\/>");
  94. }
  95. return textNode.textContent;
  96. } else {
  97. return textNode.textContent.replace(/&/g, "&amp;").replace(/\u00a0/g, "&nbsp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
  98. }
  99. }
  100. function serializeCommentNode(commentNode) {
  101. return "<!--" + commentNode.textContent + "-->";
  102. }
  103. function serializeElement(element, compressHTML, isSVG) {
  104. const tagName = getTagName$1(element);
  105. const omittedStartTag = compressHTML && OMITTED_START_TAGS.find(omittedStartTag => tagName == getTagName$1(omittedStartTag) && omittedStartTag.accept(element));
  106. let content = "";
  107. if (!omittedStartTag || element.attributes.length) {
  108. content = "<" + tagName.toLowerCase();
  109. Array.from(element.attributes).forEach(attribute => content += serializeAttribute(attribute, element, compressHTML));
  110. content += ">";
  111. }
  112. if (tagName == "TEMPLATE" && !element.childNodes.length) {
  113. content += element.innerHTML;
  114. } else {
  115. Array.from(element.childNodes).forEach(childNode => content += serialize(childNode, compressHTML, isSVG || tagName == "svg"));
  116. }
  117. const omittedEndTag = compressHTML && OMITTED_END_TAGS.find(omittedEndTag => tagName == getTagName$1(omittedEndTag) && omittedEndTag.accept(element.nextSibling, element));
  118. if (isSVG || (!omittedEndTag && !SELF_CLOSED_TAG_NAMES.includes(tagName))) {
  119. content += "</" + tagName.toLowerCase() + ">";
  120. }
  121. return content;
  122. }
  123. function serializeAttribute(attribute, element, compressHTML) {
  124. const name = attribute.name;
  125. let content = "";
  126. if (!name.match(/["'>/=]/)) {
  127. let value = attribute.value;
  128. if (compressHTML && name == "class") {
  129. value = Array.from(element.classList).map(className => className.trim()).join(" ");
  130. }
  131. let simpleQuotesValue;
  132. value = value.replace(/&/g, "&amp;").replace(/\u00a0/g, "&nbsp;");
  133. if (value.includes("\"")) {
  134. if (value.includes("'") || !compressHTML) {
  135. value = value.replace(/"/g, "&quot;");
  136. } else {
  137. simpleQuotesValue = true;
  138. }
  139. }
  140. const invalidUnquotedValue = !compressHTML || value.match(/[ \t\n\f\r'"`=<>]/);
  141. content += " ";
  142. if (!attribute.namespace) {
  143. content += name;
  144. } else if (attribute.namespaceURI == "http://www.w3.org/XML/1998/namespace") {
  145. content += "xml:" + name;
  146. } else if (attribute.namespaceURI == "http://www.w3.org/2000/xmlns/") {
  147. if (name !== "xmlns") {
  148. content += "xmlns:";
  149. }
  150. content += name;
  151. } else if (attribute.namespaceURI == "http://www.w3.org/1999/xlink") {
  152. content += "xlink:" + name;
  153. } else {
  154. content += name;
  155. }
  156. if (value != "") {
  157. content += "=";
  158. if (invalidUnquotedValue) {
  159. content += simpleQuotesValue ? "'" : "\"";
  160. }
  161. content += value;
  162. if (invalidUnquotedValue) {
  163. content += simpleQuotesValue ? "'" : "\"";
  164. }
  165. }
  166. }
  167. return content;
  168. }
  169. function startsWithSpaceChar(textContent) {
  170. return Boolean(textContent.match(/^[ \t\n\f\r]/));
  171. }
  172. function getTagName$1(element) {
  173. return element.tagName && element.tagName.toUpperCase();
  174. }
  175. const SINGLE_FILE_PREFIX = "single-file-";
  176. const COMMENT_HEADER = "Page saved with SingleFile";
  177. const SINGLE_FILE_SIGNATURE = "SingleFile";
  178. const WAIT_FOR_USERSCRIPT_PROPERTY_NAME = "_singleFile_waitForUserScript";
  179. const NO_SCRIPT_PROPERTY_NAME = "singleFileDisabledNoscript";
  180. /*
  181. * Copyright 2010-2022 Gildas Lormeau
  182. * contact : gildas.lormeau <at> gmail.com
  183. *
  184. * This file is part of SingleFile.
  185. *
  186. * The code in this file is free software: you can redistribute it and/or
  187. * modify it under the terms of the GNU Affero General Public License
  188. * (GNU AGPL) as published by the Free Software Foundation, either version 3
  189. * of the License, or (at your option) any later version.
  190. *
  191. * The code in this file is distributed in the hope that it will be useful,
  192. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  193. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
  194. * General Public License for more details.
  195. *
  196. * As additional permission under GNU AGPL version 3 section 7, you may
  197. * distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU
  198. * AGPL normally required by section 4, provided you include this license
  199. * notice and a URL through which recipients can access the Corresponding
  200. * Source.
  201. */
  202. const INFOBAR_TAGNAME$1 = "single-file-infobar";
  203. const INFOBAR_STYLES = `
  204. .infobar,
  205. .infobar .infobar-icon,
  206. .infobar .infobar-link-icon {
  207. min-inline-size: 28px;
  208. min-block-size: 28px;
  209. box-sizing: border-box;
  210. }
  211. .infobar,
  212. .infobar .infobar-close-icon,
  213. .infobar .infobar-link-icon {
  214. opacity: 0.7;
  215. transition: opacity 250ms;
  216. }
  217. .infobar:hover,
  218. .infobar .infobar-close-icon:hover,
  219. .infobar .infobar-link-icon:hover {
  220. opacity: 1;
  221. }
  222. .infobar,
  223. .infobar-content {
  224. display: flex;
  225. }
  226. .infobar {
  227. position: fixed;
  228. top: 16px;
  229. right: 16px;
  230. margin-inline-start: 16px;
  231. margin-block-end: 16px;
  232. color: #2d2d2d;
  233. background-color: #737373;
  234. border: 2px solid;
  235. border-color: #eee;
  236. border-radius: 16px;
  237. z-index: 2147483647;
  238. }
  239. .infobar:valid, .infobar:not(:focus-within) .infobar-content {
  240. display: none;
  241. }
  242. .infobar:focus-within {
  243. background-color: #f9f9f9;
  244. border-color: #878787;
  245. border-radius: 8px;
  246. opacity: 1;
  247. transition-property: opacity, background-color, border-color, border-radius,
  248. color;
  249. }
  250. .infobar-content {
  251. align-items: center;
  252. }
  253. .infobar-content span {
  254. font-family: Arial, Helvetica, sans-serif;
  255. font-size: 14px;
  256. line-height: 18px;
  257. word-break: break-word;
  258. white-space: pre-wrap;
  259. margin-inline: 4px;
  260. margin-block: 4px;
  261. }
  262. .infobar .infobar-icon,
  263. .infobar .infobar-close-icon,
  264. .infobar .infobar-link-icon {
  265. cursor: pointer;
  266. background-position: center;
  267. background-repeat: no-repeat;
  268. }
  269. .infobar .infobar-close-icon,
  270. .infobar .infobar-link-icon {
  271. align-self: flex-start;
  272. }
  273. .infobar .infobar-icon {
  274. position: absolute;
  275. min-inline-size: 24px;
  276. min-block-size: 24px;
  277. }
  278. .infobar:focus-within .infobar-icon {
  279. z-index: -1;
  280. background-image: none;
  281. }
  282. .infobar .infobar-close-icon {
  283. min-inline-size: 22px;
  284. min-block-size: 22px;
  285. }
  286. .infobar .infobar-icon {
  287. background-color: transparent;
  288. background-size: 70%;
  289. background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAABhmlDQ1BJQ0MgcHJvZmlsZQAAKJF9kj1Iw0AYht+mSkUrDnYQcchQnSyIijqWKhbBQmkrtOpgcukfNGlIUlwcBdeCgz+LVQcXZ10dXAVB8AfEydFJ0UVK/C4ptIjx4LiH9+59+e67A4RGhalm1wSgapaRisfEbG5VDLyiDwEAvZiVmKkn0osZeI6ve/j4ehfhWd7n/hz9St5kgE8kjjLdsIg3iGc2LZ3zPnGIlSSF+Jx43KACiR+5Lrv8xrnosMAzQ0YmNU8cIhaLHSx3MCsZKvE0cVhRNcoXsi4rnLc4q5Uaa9XJbxjMaytprtMcQRxLSCAJETJqKKMCCxFaNVJMpGg/5uEfdvxJcsnkKoORYwFVqJAcP/gb/O6tWZiadJOCMaD7xbY/RoHALtCs2/b3sW03TwD/M3Cltf3VBjD3SXq9rYWPgIFt4OK6rcl7wOUOMPSkS4bkSH6aQqEAvJ/RM+WAwVv6EGtu31r7OH0AMtSr5Rvg4BAYK1L2use9ezr79u+ZVv9+AFlNcp0UUpiqAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH5AsHADIRLMaOHwAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAAPUExURQAAAIqKioyNjY2OjvDw8L2y1DEAAAABdFJOUwBA5thmAAAAAWJLR0QB/wIt3gAAAGNJREFUSMdjYCAJsLi4OBCQx6/CBQwIGIDPCBcXAkYQUsACU+AwlBVQHg6Eg5pgZBGOboIJZugDFwRwoJECJCUOhJI1wZwzqmBUwagCuipgIqTABG9h7YIKaKGAURAFEF/6AQAO4HqSoDP8bgAAAABJRU5ErkJggg==);
  290. }
  291. .infobar .infobar-link-icon {
  292. background-size: 60%;
  293. background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAgMAAADXB5lNAAABhmlDQ1BJQ0MgcHJvZmlsZQAAKJF9kj1Iw0AYht+mSkUrDnYQcchQnSyIijqWKhbBQmkrtOpgcukfNGlIUlwcBdeCgz+LVQcXZ10dXAVB8AfEydFJ0UVK/C4ptIjx4LiH9+59+e67A4RGhalm1wSgapaRisfEbG5VDLyiDwEAvZiVmKkn0osZeI6ve/j4ehfhWd7n/hz9St5kgE8kjjLdsIg3iGc2LZ3zPnGIlSSF+Jx43KACiR+5Lrv8xrnosMAzQ0YmNU8cIhaLHSx3MCsZKvE0cVhRNcoXsi4rnLc4q5Uaa9XJbxjMaytprtMcQRxLSCAJETJqKKMCCxFaNVJMpGg/5uEfdvxJcsnkKoORYwFVqJAcP/gb/O6tWZiadJOCMaD7xbY/RoHALtCs2/b3sW03TwD/M3Cltf3VBjD3SXq9rYWPgIFt4OK6rcl7wOUOMPSkS4bkSH6aQqEAvJ/RM+WAwVv6EGtu31r7OH0AMtSr5Rvg4BAYK1L2use9ezr79u+ZVv9+AFlNcp0UUpiqAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH5AsHAB8H+DhhoQAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAAJUExURQAAAICHi4qKioTuJAkAAAABdFJOUwBA5thmAAAAAWJLR0QCZgt8ZAAAAJJJREFUOI3t070NRCEMA2CnYAOyDyPwpHj/Va7hJ3FzV7zy3ET5JIwoAF6Jk4wzAJAkzxAYG9YRTgB+24wBgKmfrGAKTcEfAY4KRlRoIeBTgKOCERVaCPgU4Khge2GqKOBTgKOCERVaAEC/4PNcnyoSWHpjqkhwKxbcig0Q6AorXYF/+A6eIYD1lVbwG/jdA6/kA2THRAURVubcAAAAAElFTkSuQmCC);
  294. }
  295. .infobar .infobar-close-icon {
  296. appearance: none;
  297. background-size: 80%;
  298. background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAgMAAADXB5lNAAABhmlDQ1BJQ0MgcHJvZmlsZQAAKJF9kj1Iw0AYht+mSkUrDnYQcchQnSyIijqWKhbBQmkrtOpgcukfNGlIUlwcBdeCgz+LVQcXZ10dXAVB8AfEydFJ0UVK/C4ptIjx4LiH9+59+e67A4RGhalm1wSgapaRisfEbG5VDLyiDwEAvZiVmKkn0osZeI6ve/j4ehfhWd7n/hz9St5kgE8kjjLdsIg3iGc2LZ3zPnGIlSSF+Jx43KACiR+5Lrv8xrnosMAzQ0YmNU8cIhaLHSx3MCsZKvE0cVhRNcoXsi4rnLc4q5Uaa9XJbxjMaytprtMcQRxLSCAJETJqKKMCCxFaNVJMpGg/5uEfdvxJcsnkKoORYwFVqJAcP/gb/O6tWZiadJOCMaD7xbY/RoHALtCs2/b3sW03TwD/M3Cltf3VBjD3SXq9rYWPgIFt4OK6rcl7wOUOMPSkS4bkSH6aQqEAvJ/RM+WAwVv6EGtu31r7OH0AMtSr5Rvg4BAYK1L2use9ezr79u+ZVv9+AFlNcp0UUpiqAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH5AsHAB8VC4EQ6QAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAAJUExURQAAAICHi4qKioTuJAkAAAABdFJOUwBA5thmAAAAAWJLR0QCZgt8ZAAAAJtJREFUOI3NkrsBgCAMRLFwBPdxBArcfxXFkO8rbKWAAJfHJ9faf9vuYX/749T5NmShm3bEwbe2SxeuM4+2oxDL1cDoKtVUjRy+tH78Cv2CS+wIiQNC1AEhk4AQeUTMWUJMfUJMSEJMSEY8kIx4IONroaYAimNxsXp1PA7PxwfVL8QnowwoVC0lig07wDDVUjAdbAnjwtow/z/bDW7eI4M2KruJAAAAAElFTkSuQmCC);
  299. }
  300. `;
  301. function appendInfobar$1(doc, options, useShadowRoot) {
  302. if (!doc.querySelector(INFOBAR_TAGNAME$1)) {
  303. let infoData;
  304. if (options.infobarContent) {
  305. infoData = options.infobarContent.replace(/\\n/g, "\n").replace(/\\t/g, "\t");
  306. } else if (options.saveDate) {
  307. infoData = options.saveDate;
  308. }
  309. infoData = infoData || "No info";
  310. const infobarElement = createElement(doc, INFOBAR_TAGNAME$1, doc.body);
  311. let infobarContainer;
  312. if (useShadowRoot) {
  313. infobarContainer = infobarElement.attachShadow({ mode: "open" });
  314. } else {
  315. const shadowRootTemplate = doc.createElement("template");
  316. shadowRootTemplate.setAttribute("shadowrootmode", "open");
  317. infobarElement.appendChild(shadowRootTemplate);
  318. infobarContainer = shadowRootTemplate;
  319. }
  320. const shadowRootContent = doc.createElement("div");
  321. const styleElement = doc.createElement("style");
  322. styleElement.textContent = INFOBAR_STYLES
  323. .replace(/ {2}/g, "")
  324. .replace(/\n/g, "")
  325. .replace(/: /g, ":")
  326. .replace(/, /g, ",");
  327. shadowRootContent.appendChild(styleElement);
  328. const infobarContent = doc.createElement("form");
  329. infobarContent.classList.add("infobar");
  330. shadowRootContent.appendChild(infobarContent);
  331. const iconElement = doc.createElement("span");
  332. iconElement.tabIndex = -1;
  333. iconElement.classList.add("infobar-icon");
  334. infobarContent.appendChild(iconElement);
  335. const contentElement = doc.createElement("span");
  336. contentElement.tabIndex = -1;
  337. contentElement.classList.add("infobar-content");
  338. const closeButtonElement = doc.createElement("input");
  339. closeButtonElement.type = "checkbox";
  340. closeButtonElement.required = true;
  341. closeButtonElement.classList.add("infobar-close-icon");
  342. closeButtonElement.title = "Close";
  343. contentElement.appendChild(closeButtonElement);
  344. const textElement = doc.createElement("span");
  345. textElement.textContent = infoData;
  346. contentElement.appendChild(textElement);
  347. const linkElement = doc.createElement("a");
  348. linkElement.classList.add("infobar-link-icon");
  349. linkElement.target = "_blank";
  350. linkElement.rel = "noopener noreferrer";
  351. linkElement.title = "Open source URL: " + options.saveUrl;
  352. linkElement.href = options.saveUrl;
  353. contentElement.appendChild(linkElement);
  354. infobarContent.appendChild(contentElement);
  355. if (useShadowRoot) {
  356. infobarContainer.appendChild(shadowRootContent);
  357. } else {
  358. const scriptElement = doc.createElement("script");
  359. let scriptContent = refreshInfobarInfo.toString();
  360. scriptContent += extractInfobarData.toString();
  361. scriptContent += "(" + initInfobar.toString() + ")(document)";
  362. scriptElement.textContent = scriptContent;
  363. shadowRootContent.appendChild(scriptElement);
  364. infobarContainer.innerHTML = shadowRootContent.outerHTML;
  365. }
  366. doc.body.appendChild(infobarElement);
  367. }
  368. }
  369. function extractInfobarData(doc) {
  370. const result = doc.evaluate("//comment()", doc, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
  371. let singleFileComment = result && result.singleNodeValue;
  372. if (singleFileComment && singleFileComment.nodeType == Node.COMMENT_NODE && singleFileComment.textContent.includes(SINGLE_FILE_SIGNATURE)) {
  373. const info = singleFileComment.textContent.split("\n");
  374. const [, , urlData, ...optionalData] = info;
  375. const urlMatch = urlData.match(/^ url: (.*) ?$/);
  376. const saveUrl = urlMatch && urlMatch[1];
  377. if (saveUrl) {
  378. let infobarContent, saveDate;
  379. if (optionalData.length) {
  380. saveDate = optionalData[0].split("saved date: ")[1];
  381. if (saveDate) {
  382. optionalData.shift();
  383. }
  384. if (optionalData.length > 1) {
  385. let content = optionalData[0].split("info: ")[1].trim();
  386. for (let indexLine = 1; indexLine < optionalData.length - 1; indexLine++) {
  387. content += "\n" + optionalData[indexLine].trim();
  388. }
  389. infobarContent = content.trim();
  390. }
  391. }
  392. return { saveUrl, infobarContent, saveDate };
  393. }
  394. }
  395. }
  396. function refreshInfobarInfo(doc, { saveUrl, infobarContent, saveDate }) {
  397. if (saveUrl) {
  398. const infobarElement = doc.querySelector("single-file-infobar");
  399. const shadowRootFragment = infobarElement.shadowRoot;
  400. const infobarContentElement = shadowRootFragment.querySelector(".infobar-content span");
  401. infobarContentElement.textContent = infobarContent || saveDate;
  402. const linkElement = shadowRootFragment.querySelector(".infobar-content .infobar-link-icon");
  403. linkElement.href = saveUrl;
  404. linkElement.title = "Open source URL: " + saveUrl;
  405. }
  406. }
  407. function displayIcon(doc, useShadowRoot) {
  408. const infoData = extractInfobarData(doc);
  409. if (infoData.saveUrl) {
  410. appendInfobar$1(doc, infoData, useShadowRoot);
  411. refreshInfobarInfo(doc, infoData);
  412. }
  413. }
  414. function initInfobar(doc) {
  415. const infoData = extractInfobarData(doc);
  416. if (infoData && infoData.saveUrl) {
  417. refreshInfobarInfo(doc, infoData);
  418. }
  419. }
  420. function createElement(doc, tagName, parentElement) {
  421. const element = doc.createElement(tagName);
  422. parentElement.appendChild(element);
  423. Array.from(getComputedStyle(element)).forEach(property => element.style.setProperty(property, "initial", "important"));
  424. return element;
  425. }
  426. const { Array: Array$1, Object: Object$1, String: String$1, Number: Number$1, BigInt, Math: Math$1, Date: Date$1, Map: Map$1, Set: Set$1, Response, URL: URL$2, Error: Error$1, Uint8Array: Uint8Array$1, Uint16Array, Uint32Array: Uint32Array$1, DataView: DataView$1, Blob: Blob$2, Promise: Promise$1, TextEncoder: TextEncoder$1, TextDecoder: TextDecoder$1, document: document$2, crypto: crypto$1, btoa, TransformStream, ReadableStream, WritableStream, CompressionStream, DecompressionStream, navigator, Worker } = globalThis;
  427. new Date$1(2107, 11, 31);
  428. new Date$1(1980, 0, 1);
  429. const UNDEFINED_VALUE = undefined;
  430. const UNDEFINED_TYPE$1 = "undefined";
  431. /*
  432. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  433. Redistribution and use in source and binary forms, with or without
  434. modification, are permitted provided that the following conditions are met:
  435. 1. Redistributions of source code must retain the above copyright notice,
  436. this list of conditions and the following disclaimer.
  437. 2. Redistributions in binary form must reproduce the above copyright
  438. notice, this list of conditions and the following disclaimer in
  439. the documentation and/or other materials provided with the distribution.
  440. 3. The names of the authors may not be used to endorse or promote products
  441. derived from this software without specific prior written permission.
  442. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  443. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  444. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  445. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  446. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  447. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  448. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  449. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  450. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  451. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  452. */
  453. class StreamAdapter {
  454. constructor(Codec) {
  455. return class extends TransformStream {
  456. constructor(_format, options) {
  457. const codec = new Codec(options);
  458. super({
  459. transform(chunk, controller) {
  460. controller.enqueue(codec.append(chunk));
  461. },
  462. flush(controller) {
  463. const chunk = codec.flush();
  464. if (chunk) {
  465. controller.enqueue(chunk);
  466. }
  467. }
  468. });
  469. }
  470. };
  471. }
  472. }
  473. let maxWorkers = 2;
  474. try {
  475. if (typeof navigator != UNDEFINED_TYPE$1 && navigator.hardwareConcurrency) {
  476. maxWorkers = navigator.hardwareConcurrency;
  477. }
  478. } catch (_error) {
  479. // ignored
  480. }
  481. const DEFAULT_CONFIGURATION = {
  482. chunkSize: 512 * 1024,
  483. maxWorkers,
  484. terminateWorkerTimeout: 5000,
  485. useWebWorkers: true,
  486. useCompressionStream: true,
  487. workerScripts: UNDEFINED_VALUE,
  488. CompressionStreamNative: typeof CompressionStream != UNDEFINED_TYPE$1 && CompressionStream,
  489. DecompressionStreamNative: typeof DecompressionStream != UNDEFINED_TYPE$1 && DecompressionStream
  490. };
  491. const config = Object$1.assign({}, DEFAULT_CONFIGURATION);
  492. function configure(configuration) {
  493. const {
  494. baseURL,
  495. chunkSize,
  496. maxWorkers,
  497. terminateWorkerTimeout,
  498. useCompressionStream,
  499. useWebWorkers,
  500. Deflate,
  501. Inflate,
  502. CompressionStream,
  503. DecompressionStream,
  504. workerScripts
  505. } = configuration;
  506. setIfDefined("baseURL", baseURL);
  507. setIfDefined("chunkSize", chunkSize);
  508. setIfDefined("maxWorkers", maxWorkers);
  509. setIfDefined("terminateWorkerTimeout", terminateWorkerTimeout);
  510. setIfDefined("useCompressionStream", useCompressionStream);
  511. setIfDefined("useWebWorkers", useWebWorkers);
  512. if (Deflate) {
  513. config.CompressionStream = new StreamAdapter(Deflate);
  514. }
  515. if (Inflate) {
  516. config.DecompressionStream = new StreamAdapter(Inflate);
  517. }
  518. setIfDefined("CompressionStream", CompressionStream);
  519. setIfDefined("DecompressionStream", DecompressionStream);
  520. if (workerScripts !== UNDEFINED_VALUE) {
  521. const { deflate, inflate } = workerScripts;
  522. if (deflate || inflate) {
  523. if (!config.workerScripts) {
  524. config.workerScripts = {};
  525. }
  526. }
  527. if (deflate) {
  528. if (!Array$1.isArray(deflate)) {
  529. throw new Error$1("workerScripts.deflate must be an array");
  530. }
  531. config.workerScripts.deflate = deflate;
  532. }
  533. if (inflate) {
  534. if (!Array$1.isArray(inflate)) {
  535. throw new Error$1("workerScripts.inflate must be an array");
  536. }
  537. config.workerScripts.inflate = inflate;
  538. }
  539. }
  540. }
  541. function setIfDefined(propertyName, propertyValue) {
  542. if (propertyValue !== UNDEFINED_VALUE) {
  543. config[propertyName] = propertyValue;
  544. }
  545. }
  546. function e(e){const t=()=>URL$2.createObjectURL(new Blob$2(['const{Array:e,Object:t,Number:n,Math:r,Error:s,Uint8Array:a,Uint16Array:i,Uint32Array:o,Int32Array:l,Map:c,DataView:h,Promise:f,TextEncoder:u,crypto:p,postMessage:d,TransformStream:g,ReadableStream:w,WritableStream:v,CompressionStream:y,DecompressionStream:b}=self;class m{constructor(e){return class extends g{constructor(t,n){const r=new e(n);super({transform(e,t){t.enqueue(r.append(e))},flush(e){const t=r.flush();t&&e.enqueue(t)}})}}}}const _=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)1&t?t=t>>>1^3988292384:t>>>=1;_[e]=t}class k{constructor(e){this.crc=e||-1}append(e){let t=0|this.crc;for(let n=0,r=0|e.length;r>n;n++)t=t>>>8^_[255&(t^e[n])];this.crc=t}get(){return~this.crc}}class S extends g{constructor(){let e;const t=new k;super({transform(e,n){t.append(e),n.enqueue(e)},flush(){const n=new a(4);new h(n.buffer).setUint32(0,t.get()),e.value=n}}),e=this}}const z={concat(e,t){if(0===e.length||0===t.length)return e.concat(t);const n=e[e.length-1],r=z.getPartial(n);return 32===r?e.concat(t):z._shiftRight(t,r,0|n,e.slice(0,e.length-1))},bitLength(e){const t=e.length;if(0===t)return 0;const n=e[t-1];return 32*(t-1)+z.getPartial(n)},clamp(e,t){if(32*e.length<t)return e;const n=(e=e.slice(0,r.ceil(t/32))).length;return t&=31,n>0&&t&&(e[n-1]=z.partial(t,e[n-1]&2147483648>>t-1,1)),e},partial:(e,t,n)=>32===e?t:(n?0|t:t<<32-e)+1099511627776*e,getPartial:e=>r.round(e/1099511627776)||32,_shiftRight(e,t,n,r){for(void 0===r&&(r=[]);t>=32;t-=32)r.push(n),n=0;if(0===t)return r.concat(e);for(let s=0;s<e.length;s++)r.push(n|e[s]>>>t),n=e[s]<<32-t;const s=e.length?e[e.length-1]:0,a=z.getPartial(s);return r.push(z.partial(t+a&31,t+a>32?n:r.pop(),1)),r}},D={bytes:{fromBits(e){const t=z.bitLength(e)/8,n=new a(t);let r;for(let s=0;t>s;s++)0==(3&s)&&(r=e[s/4]),n[s]=r>>>24,r<<=8;return n},toBits(e){const t=[];let n,r=0;for(n=0;n<e.length;n++)r=r<<8|e[n],3==(3&n)&&(t.push(r),r=0);return 3&n&&t.push(z.partial(8*(3&n),r)),t}}},C=class{constructor(e){const t=this;t.blockSize=512,t._init=[1732584193,4023233417,2562383102,271733878,3285377520],t._key=[1518500249,1859775393,2400959708,3395469782],e?(t._h=e._h.slice(0),t._buffer=e._buffer.slice(0),t._length=e._length):t.reset()}reset(){const e=this;return e._h=e._init.slice(0),e._buffer=[],e._length=0,e}update(e){const t=this;"string"==typeof e&&(e=D.utf8String.toBits(e));const n=t._buffer=z.concat(t._buffer,e),r=t._length,a=t._length=r+z.bitLength(e);if(a>9007199254740991)throw new s("Cannot hash more than 2^53 - 1 bits");const i=new o(n);let l=0;for(let e=t.blockSize+r-(t.blockSize+r&t.blockSize-1);a>=e;e+=t.blockSize)t._block(i.subarray(16*l,16*(l+1))),l+=1;return n.splice(0,16*l),t}finalize(){const e=this;let t=e._buffer;const n=e._h;t=z.concat(t,[z.partial(1,1)]);for(let e=t.length+2;15&e;e++)t.push(0);for(t.push(r.floor(e._length/4294967296)),t.push(0|e._length);t.length;)e._block(t.splice(0,16));return e.reset(),n}_f(e,t,n,r){return e>19?e>39?e>59?e>79?void 0:t^n^r:t&n|t&r|n&r:t^n^r:t&n|~t&r}_S(e,t){return t<<e|t>>>32-e}_block(t){const n=this,s=n._h,a=e(80);for(let e=0;16>e;e++)a[e]=t[e];let i=s[0],o=s[1],l=s[2],c=s[3],h=s[4];for(let e=0;79>=e;e++){16>e||(a[e]=n._S(1,a[e-3]^a[e-8]^a[e-14]^a[e-16]));const t=n._S(5,i)+n._f(e,o,l,c)+h+a[e]+n._key[r.floor(e/20)]|0;h=c,c=l,l=n._S(30,o),o=i,i=t}s[0]=s[0]+i|0,s[1]=s[1]+o|0,s[2]=s[2]+l|0,s[3]=s[3]+c|0,s[4]=s[4]+h|0}},I={getRandomValues(e){const t=new o(e.buffer),n=e=>{let t=987654321;const n=4294967295;return()=>(t=36969*(65535&t)+(t>>16)&n,(((t<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n)/4294967296+.5)*(r.random()>.5?1:-1))};for(let s,a=0;a<e.length;a+=4){const e=n(4294967296*(s||r.random()));s=987654071*e(),t[a/4]=4294967296*e()|0}return e}},x={importKey:e=>new x.hmacSha1(D.bytes.toBits(e)),pbkdf2(e,t,n,r){if(n=n||1e4,0>r||0>n)throw new s("invalid params to pbkdf2");const a=1+(r>>5)<<2;let i,o,l,c,f;const u=new ArrayBuffer(a),p=new h(u);let d=0;const g=z;for(t=D.bytes.toBits(t),f=1;(a||1)>d;f++){for(i=o=e.encrypt(g.concat(t,[f])),l=1;n>l;l++)for(o=e.encrypt(o),c=0;c<o.length;c++)i[c]^=o[c];for(l=0;(a||1)>d&&l<i.length;l++)p.setInt32(d,i[l]),d+=4}return u.slice(0,r/8)},hmacSha1:class{constructor(e){const t=this,n=t._hash=C,r=[[],[]];t._baseHash=[new n,new n];const s=t._baseHash[0].blockSize/32;e.length>s&&(e=(new n).update(e).finalize());for(let t=0;s>t;t++)r[0][t]=909522486^e[t],r[1][t]=1549556828^e[t];t._baseHash[0].update(r[0]),t._baseHash[1].update(r[1]),t._resultHash=new n(t._baseHash[0])}reset(){const e=this;e._resultHash=new e._hash(e._baseHash[0]),e._updated=!1}update(e){this._updated=!0,this._resultHash.update(e)}digest(){const e=this,t=e._resultHash.finalize(),n=new e._hash(e._baseHash[1]).update(t).finalize();return e.reset(),n}encrypt(e){if(this._updated)throw new s("encrypt on already updated hmac called!");return this.update(e),this.digest(e)}}},A=void 0!==p&&"function"==typeof p.getRandomValues,T="Invalid password",R="Invalid signature",H="zipjs-abort-check-password";function q(e){return A?p.getRandomValues(e):I.getRandomValues(e)}const B=16,K={name:"PBKDF2"},V=t.assign({hash:{name:"HMAC"}},K),P=t.assign({iterations:1e3,hash:{name:"SHA-1"}},K),E=["deriveBits"],U=[8,12,16],W=[16,24,32],M=10,N=[0,0,0,0],O="undefined",F="function",L=typeof p!=O,j=L&&p.subtle,G=L&&typeof j!=O,X=D.bytes,J=class{constructor(e){const t=this;t._tables=[[[],[],[],[],[]],[[],[],[],[],[]]],t._tables[0][0][0]||t._precompute();const n=t._tables[0][4],r=t._tables[1],a=e.length;let i,o,l,c=1;if(4!==a&&6!==a&&8!==a)throw new s("invalid aes key size");for(t._key=[o=e.slice(0),l=[]],i=a;4*a+28>i;i++){let e=o[i-1];(i%a==0||8===a&&i%a==4)&&(e=n[e>>>24]<<24^n[e>>16&255]<<16^n[e>>8&255]<<8^n[255&e],i%a==0&&(e=e<<8^e>>>24^c<<24,c=c<<1^283*(c>>7))),o[i]=o[i-a]^e}for(let e=0;i;e++,i--){const t=o[3&e?i:i-4];l[e]=4>=i||4>e?t:r[0][n[t>>>24]]^r[1][n[t>>16&255]]^r[2][n[t>>8&255]]^r[3][n[255&t]]}}encrypt(e){return this._crypt(e,0)}decrypt(e){return this._crypt(e,1)}_precompute(){const e=this._tables[0],t=this._tables[1],n=e[4],r=t[4],s=[],a=[];let i,o,l,c;for(let e=0;256>e;e++)a[(s[e]=e<<1^283*(e>>7))^e]=e;for(let h=i=0;!n[h];h^=o||1,i=a[i]||1){let a=i^i<<1^i<<2^i<<3^i<<4;a=a>>8^255&a^99,n[h]=a,r[a]=h,c=s[l=s[o=s[h]]];let f=16843009*c^65537*l^257*o^16843008*h,u=257*s[a]^16843008*a;for(let n=0;4>n;n++)e[n][h]=u=u<<24^u>>>8,t[n][a]=f=f<<24^f>>>8}for(let n=0;5>n;n++)e[n]=e[n].slice(0),t[n]=t[n].slice(0)}_crypt(e,t){if(4!==e.length)throw new s("invalid aes block size");const n=this._key[t],r=n.length/4-2,a=[0,0,0,0],i=this._tables[t],o=i[0],l=i[1],c=i[2],h=i[3],f=i[4];let u,p,d,g=e[0]^n[0],w=e[t?3:1]^n[1],v=e[2]^n[2],y=e[t?1:3]^n[3],b=4;for(let e=0;r>e;e++)u=o[g>>>24]^l[w>>16&255]^c[v>>8&255]^h[255&y]^n[b],p=o[w>>>24]^l[v>>16&255]^c[y>>8&255]^h[255&g]^n[b+1],d=o[v>>>24]^l[y>>16&255]^c[g>>8&255]^h[255&w]^n[b+2],y=o[y>>>24]^l[g>>16&255]^c[w>>8&255]^h[255&v]^n[b+3],b+=4,g=u,w=p,v=d;for(let e=0;4>e;e++)a[t?3&-e:e]=f[g>>>24]<<24^f[w>>16&255]<<16^f[v>>8&255]<<8^f[255&y]^n[b++],u=g,g=w,w=v,v=y,y=u;return a}},Q=class{constructor(e,t){this._prf=e,this._initIv=t,this._iv=t}reset(){this._iv=this._initIv}update(e){return this.calculate(this._prf,e,this._iv)}incWord(e){if(255==(e>>24&255)){let t=e>>16&255,n=e>>8&255,r=255&e;255===t?(t=0,255===n?(n=0,255===r?r=0:++r):++n):++t,e=0,e+=t<<16,e+=n<<8,e+=r}else e+=1<<24;return e}incCounter(e){0===(e[0]=this.incWord(e[0]))&&(e[1]=this.incWord(e[1]))}calculate(e,t,n){let r;if(!(r=t.length))return[];const s=z.bitLength(t);for(let s=0;r>s;s+=4){this.incCounter(n);const r=e.encrypt(n);t[s]^=r[0],t[s+1]^=r[1],t[s+2]^=r[2],t[s+3]^=r[3]}return z.clamp(t,s)}},Y=x.hmacSha1;let Z=L&&G&&typeof j.importKey==F,$=L&&G&&typeof j.deriveBits==F;class ee extends g{constructor({password:e,signed:n,encryptionStrength:r,checkPasswordOnly:i}){super({start(){t.assign(this,{ready:new f((e=>this.resolveReady=e)),password:e,signed:n,strength:r-1,pending:new a})},async transform(e,t){const n=this,{password:r,strength:o,resolveReady:l,ready:c}=n;r?(await(async(e,t,n,r)=>{const a=await re(e,t,n,ae(r,0,U[t])),i=ae(r,U[t]);if(a[0]!=i[0]||a[1]!=i[1])throw new s(T)})(n,o,r,ae(e,0,U[o]+2)),e=ae(e,U[o]+2),i?t.error(new s(H)):l()):await c;const h=new a(e.length-M-(e.length-M)%B);t.enqueue(ne(n,e,h,0,M,!0))},async flush(e){const{signed:t,ctr:n,hmac:r,pending:i,ready:o}=this;await o;const l=ae(i,0,i.length-M),c=ae(i,i.length-M);let h=new a;if(l.length){const e=oe(X,l);r.update(e);const t=n.update(e);h=ie(X,t)}if(t){const e=ae(ie(X,r.digest()),0,M);for(let t=0;M>t;t++)if(e[t]!=c[t])throw new s(R)}e.enqueue(h)}})}}class te extends g{constructor({password:e,encryptionStrength:n}){let r;super({start(){t.assign(this,{ready:new f((e=>this.resolveReady=e)),password:e,strength:n-1,pending:new a})},async transform(e,t){const n=this,{password:r,strength:s,resolveReady:i,ready:o}=n;let l=new a;r?(l=await(async(e,t,n)=>{const r=q(new a(U[t]));return se(r,await re(e,t,n,r))})(n,s,r),i()):await o;const c=new a(l.length+e.length-e.length%B);c.set(l,0),t.enqueue(ne(n,e,c,l.length,0))},async flush(e){const{ctr:t,hmac:n,pending:s,ready:i}=this;await i;let o=new a;if(s.length){const e=t.update(oe(X,s));n.update(e),o=ie(X,e)}r.signature=ie(X,n.digest()).slice(0,M),e.enqueue(se(o,r.signature))}}),r=this}}function ne(e,t,n,r,s,i){const{ctr:o,hmac:l,pending:c}=e,h=t.length-s;let f;for(c.length&&(t=se(c,t),n=((e,t)=>{if(t&&t>e.length){const n=e;(e=new a(t)).set(n,0)}return e})(n,h-h%B)),f=0;h-B>=f;f+=B){const e=oe(X,ae(t,f,f+B));i&&l.update(e);const s=o.update(e);i||l.update(s),n.set(ie(X,s),f+r)}return e.pending=ae(t,f),n}async function re(n,r,s,i){n.password=null;const o=(e=>{if(void 0===u){const t=new a((e=unescape(encodeURIComponent(e))).length);for(let n=0;n<t.length;n++)t[n]=e.charCodeAt(n);return t}return(new u).encode(e)})(s),l=await(async(e,t,n,r,s)=>{if(!Z)return x.importKey(t);try{return await j.importKey("raw",t,n,!1,s)}catch(e){return Z=!1,x.importKey(t)}})(0,o,V,0,E),c=await(async(e,t,n)=>{if(!$)return x.pbkdf2(t,e.salt,P.iterations,n);try{return await j.deriveBits(e,t,n)}catch(r){return $=!1,x.pbkdf2(t,e.salt,P.iterations,n)}})(t.assign({salt:i},P),l,8*(2*W[r]+2)),h=new a(c),f=oe(X,ae(h,0,W[r])),p=oe(X,ae(h,W[r],2*W[r])),d=ae(h,2*W[r]);return t.assign(n,{keys:{key:f,authentication:p,passwordVerification:d},ctr:new Q(new J(f),e.from(N)),hmac:new Y(p)}),d}function se(e,t){let n=e;return e.length+t.length&&(n=new a(e.length+t.length),n.set(e,0),n.set(t,e.length)),n}function ae(e,t,n){return e.subarray(t,n)}function ie(e,t){return e.fromBits(t)}function oe(e,t){return e.toBits(t)}class le extends g{constructor({password:e,passwordVerification:n,checkPasswordOnly:r}){super({start(){t.assign(this,{password:e,passwordVerification:n}),ue(this,e)},transform(e,t){const n=this;if(n.password){const t=he(n,e.subarray(0,12));if(n.password=null,t[11]!=n.passwordVerification)throw new s(T);e=e.subarray(12)}r?t.error(new s(H)):t.enqueue(he(n,e))}})}}class ce extends g{constructor({password:e,passwordVerification:n}){super({start(){t.assign(this,{password:e,passwordVerification:n}),ue(this,e)},transform(e,t){const n=this;let r,s;if(n.password){n.password=null;const t=q(new a(12));t[11]=n.passwordVerification,r=new a(e.length+t.length),r.set(fe(n,t),0),s=12}else r=new a(e.length),s=0;r.set(fe(n,e),s),t.enqueue(r)}})}}function he(e,t){const n=new a(t.length);for(let r=0;r<t.length;r++)n[r]=de(e)^t[r],pe(e,n[r]);return n}function fe(e,t){const n=new a(t.length);for(let r=0;r<t.length;r++)n[r]=de(e)^t[r],pe(e,t[r]);return n}function ue(e,n){const r=[305419896,591751049,878082192];t.assign(e,{keys:r,crcKey0:new k(r[0]),crcKey2:new k(r[2])});for(let t=0;t<n.length;t++)pe(e,n.charCodeAt(t))}function pe(e,t){let[n,s,a]=e.keys;e.crcKey0.append([t]),n=~e.crcKey0.get(),s=we(r.imul(we(s+ge(n)),134775813)+1),e.crcKey2.append([s>>>24]),a=~e.crcKey2.get(),e.keys=[n,s,a]}function de(e){const t=2|e.keys[2];return ge(r.imul(t,1^t)>>>8)}function ge(e){return 255&e}function we(e){return 4294967295&e}const ve="deflate-raw";class ye extends g{constructor(e,{chunkSize:t,CompressionStream:n,CompressionStreamNative:r}){super({});const{compressed:s,encrypted:a,useCompressionStream:i,zipCrypto:o,signed:l,level:c}=e,f=this;let u,p,d=me(super.readable);a&&!o||!l||(u=new S,d=Se(d,u)),s&&(d=ke(d,i,{level:c,chunkSize:t},r,n)),a&&(o?d=Se(d,new ce(e)):(p=new te(e),d=Se(d,p))),_e(f,d,(()=>{let e;a&&!o&&(e=p.signature),a&&!o||!l||(e=new h(u.value.buffer).getUint32(0)),f.signature=e}))}}class be extends g{constructor(e,{chunkSize:t,DecompressionStream:n,DecompressionStreamNative:r}){super({});const{zipCrypto:a,encrypted:i,signed:o,signature:l,compressed:c,useCompressionStream:f}=e;let u,p,d=me(super.readable);i&&(a?d=Se(d,new le(e)):(p=new ee(e),d=Se(d,p))),c&&(d=ke(d,f,{chunkSize:t},r,n)),i&&!a||!o||(u=new S,d=Se(d,u)),_e(this,d,(()=>{if((!i||a)&&o){const e=new h(u.value.buffer);if(l!=e.getUint32(0,!1))throw new s(R)}}))}}function me(e){return Se(e,new g({transform(e,t){e&&e.length&&t.enqueue(e)}}))}function _e(e,n,r){n=Se(n,new g({flush:r})),t.defineProperty(e,"readable",{get:()=>n})}function ke(e,t,n,r,s){try{e=Se(e,new(t&&r?r:s)(ve,n))}catch(r){if(!t)throw r;e=Se(e,new s(ve,n))}return e}function Se(e,t){return e.pipeThrough(t)}const ze="data";class De extends g{constructor(e,n){super({});const r=this,{codecType:s}=e;let a;s.startsWith("deflate")?a=ye:s.startsWith("inflate")&&(a=be);let i=0;const o=new a(e,n),l=super.readable,c=new g({transform(e,t){e&&e.length&&(i+=e.length,t.enqueue(e))},flush(){const{signature:e}=o;t.assign(r,{signature:e,size:i})}});t.defineProperty(r,"readable",{get:()=>l.pipeThrough(o).pipeThrough(c)})}}const Ce=new c,Ie=new c;let xe=0;async function Ae(e){try{const{options:t,scripts:r,config:s}=e;r&&r.length&&importScripts.apply(void 0,r),self.initCodec&&self.initCodec(),s.CompressionStreamNative=self.CompressionStream,s.DecompressionStreamNative=self.DecompressionStream,self.Deflate&&(s.CompressionStream=new m(self.Deflate)),self.Inflate&&(s.DecompressionStream=new m(self.Inflate));const a={highWaterMark:1,size:()=>s.chunkSize},i=e.readable||new w({async pull(e){const t=new f((e=>Ce.set(xe,e)));Te({type:"pull",messageId:xe}),xe=(xe+1)%n.MAX_SAFE_INTEGER;const{value:r,done:s}=await t;e.enqueue(r),s&&e.close()}},a),o=e.writable||new v({async write(e){let t;const r=new f((e=>t=e));Ie.set(xe,t),Te({type:ze,value:e,messageId:xe}),xe=(xe+1)%n.MAX_SAFE_INTEGER,await r}},a),l=new De(t,s);await i.pipeThrough(l).pipeTo(o,{preventClose:!0,preventAbort:!0});try{await o.getWriter().close()}catch(e){}const{signature:c,size:h}=l;Te({type:"close",result:{signature:c,size:h}})}catch(e){Re(e)}}function Te(e){let{value:t}=e;if(t)if(t.length)try{t=new a(t),e.value=t.buffer,d(e,[e.value])}catch(t){d(e)}else d(e);else d(e)}function Re(e=new s("Unknown error")){const{message:t,stack:n,code:r,name:a}=e;d({error:{message:t,stack:n,code:r,name:a}})}addEventListener("message",(({data:e})=>{const{type:t,messageId:n,value:r,done:s}=e;try{if("start"==t&&Ae(e),t==ze){const e=Ce.get(n);Ce.delete(n),e({value:new a(r),done:s})}if("ack"==t){const e=Ie.get(n);Ie.delete(n),e()}}catch(e){Re(e)}}));var He=a,qe=i,Be=l,Ke=new He([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Ve=new He([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Pe=new He([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ee=(e,t)=>{for(var n=new qe(31),r=0;31>r;++r)n[r]=t+=1<<e[r-1];var s=new Be(n[30]);for(r=1;30>r;++r)for(var a=n[r];a<n[r+1];++a)s[a]=a-n[r]<<5|r;return{b:n,r:s}},Ue=Ee(Ke,2),We=Ue.b,Me=Ue.r;We[28]=258,Me[258]=28;for(var Ne=Ee(Ve,0),Oe=Ne.b,Fe=Ne.r,Le=new qe(32768),je=0;32768>je;++je){var Ge=(43690&je)>>1|(21845&je)<<1;Ge=(61680&(Ge=(52428&Ge)>>2|(13107&Ge)<<2))>>4|(3855&Ge)<<4,Le[je]=((65280&Ge)>>8|(255&Ge)<<8)>>1}var Xe=(e,t,n)=>{for(var r=e.length,s=0,a=new qe(t);r>s;++s)e[s]&&++a[e[s]-1];var i,o=new qe(t);for(s=1;t>s;++s)o[s]=o[s-1]+a[s-1]<<1;if(n){i=new qe(1<<t);var l=15-t;for(s=0;r>s;++s)if(e[s])for(var c=s<<4|e[s],h=t-e[s],f=o[e[s]-1]++<<h,u=f|(1<<h)-1;u>=f;++f)i[Le[f]>>l]=c}else for(i=new qe(r),s=0;r>s;++s)e[s]&&(i[s]=Le[o[e[s]-1]++]>>15-e[s]);return i},Je=new He(288);for(je=0;144>je;++je)Je[je]=8;for(je=144;256>je;++je)Je[je]=9;for(je=256;280>je;++je)Je[je]=7;for(je=280;288>je;++je)Je[je]=8;var Qe=new He(32);for(je=0;32>je;++je)Qe[je]=5;var Ye=Xe(Je,9,0),Ze=Xe(Je,9,1),$e=Xe(Qe,5,0),et=Xe(Qe,5,1),tt=e=>{for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},nt=(e,t,n)=>{var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},rt=(e,t)=>{var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},st=e=>(e+7)/8|0,at=(e,t,n)=>{(null==t||0>t)&&(t=0),(null==n||n>e.length)&&(n=e.length);var r=new He(n-t);return r.set(e.subarray(t,n)),r},it=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],ot=(e,t,n)=>{var r=new s(t||it[e]);if(r.code=e,s.captureStackTrace&&s.captureStackTrace(r,ot),!n)throw r;return r},lt=(e,t,n)=>{n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},ct=(e,t,n)=>{n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},ht=(e,t)=>{for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var s=n.length,a=n.slice();if(!s)return{t:vt,l:0};if(1==s){var i=new He(n[0].s+1);return i[n[0].s]=1,{t:i,l:1}}n.sort(((e,t)=>e.f-t.f)),n.push({s:-1,f:25001});var o=n[0],l=n[1],c=0,h=1,f=2;for(n[0]={s:-1,f:o.f+l.f,l:o,r:l};h!=s-1;)o=n[n[c].f<n[f].f?c++:f++],l=n[c!=h&&n[c].f<n[f].f?c++:f++],n[h++]={s:-1,f:o.f+l.f,l:o,r:l};var u=a[0].s;for(r=1;s>r;++r)a[r].s>u&&(u=a[r].s);var p=new qe(u+1),d=ft(n[h-1],p,0);if(d>t){r=0;var g=0,w=d-t,v=1<<w;for(a.sort(((e,t)=>p[t.s]-p[e.s]||e.f-t.f));s>r;++r){var y=a[r].s;if(p[y]<=t)break;g+=v-(1<<d-p[y]),p[y]=t}for(g>>=w;g>0;){var b=a[r].s;p[b]<t?g-=1<<t-p[b]++-1:++r}for(;r>=0&&g;--r){var m=a[r].s;p[m]==t&&(--p[m],++g)}d=t}return{t:new He(p),l:d}},ft=(e,t,n)=>-1==e.s?r.max(ft(e.l,t,n+1),ft(e.r,t,n+1)):t[e.s]=n,ut=e=>{for(var t=e.length;t&&!e[--t];);for(var n=new qe(++t),r=0,s=e[0],a=1,i=e=>{n[r++]=e},o=1;t>=o;++o)if(e[o]==s&&o!=t)++a;else{if(!s&&a>2){for(;a>138;a-=138)i(32754);a>2&&(i(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(i(s),--a;a>6;a-=6)i(8304);a>2&&(i(a-3<<5|8208),a=0)}for(;a--;)i(s);a=1,s=e[o]}return{c:n.subarray(0,r),n:t}},pt=(e,t)=>{for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},dt=(e,t,n)=>{var r=n.length,s=st(t+2);e[s]=255&r,e[s+1]=r>>8,e[s+2]=255^e[s],e[s+3]=255^e[s+1];for(var a=0;r>a;++a)e[s+a+4]=n[a];return 8*(s+4+r)},gt=(e,t,n,r,s,a,i,o,l,c,h)=>{lt(t,h++,n),++s[256];for(var f=ht(s,15),u=f.t,p=f.l,d=ht(a,15),g=d.t,w=d.l,v=ut(u),y=v.c,b=v.n,m=ut(g),_=m.c,k=m.n,S=new qe(19),z=0;z<y.length;++z)++S[31&y[z]];for(z=0;z<_.length;++z)++S[31&_[z]];for(var D=ht(S,7),C=D.t,I=D.l,x=19;x>4&&!C[Pe[x-1]];--x);var A,T,R,H,q=c+5<<3,B=pt(s,Je)+pt(a,Qe)+i,K=pt(s,u)+pt(a,g)+i+14+3*x+pt(S,C)+2*S[16]+3*S[17]+7*S[18];if(l>=0&&B>=q&&K>=q)return dt(t,h,e.subarray(l,l+c));if(lt(t,h,1+(B>K)),h+=2,B>K){A=Xe(u,p,0),T=u,R=Xe(g,w,0),H=g;var V=Xe(C,I,0);for(lt(t,h,b-257),lt(t,h+5,k-1),lt(t,h+10,x-4),h+=14,z=0;x>z;++z)lt(t,h+3*z,C[Pe[z]]);h+=3*x;for(var P=[y,_],E=0;2>E;++E){var U=P[E];for(z=0;z<U.length;++z){var W=31&U[z];lt(t,h,V[W]),h+=C[W],W>15&&(lt(t,h,U[z]>>5&127),h+=U[z]>>12)}}}else A=Ye,T=Je,R=$e,H=Qe;for(z=0;o>z;++z){var M=r[z];if(M>255){ct(t,h,A[257+(W=M>>18&31)]),h+=T[W+257],W>7&&(lt(t,h,M>>23&31),h+=Ke[W]);var N=31&M;ct(t,h,R[N]),h+=H[N],N>3&&(ct(t,h,M>>5&8191),h+=Ve[N])}else ct(t,h,A[M]),h+=T[M]}return ct(t,h,A[256]),h+T[256]},wt=new Be([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),vt=new He(0),yt=function(){function e(e,t){if("function"==typeof e&&(t=e,e={}),this.ondata=t,this.o=e||{},this.s={l:0,i:32768,w:32768,z:32768},this.b=new He(98304),this.o.dictionary){var n=this.o.dictionary.subarray(-32768);this.b.set(n,32768-n.length),this.s.i=32768-n.length}}return e.prototype.p=function(e,t){this.ondata(((e,t,n,s,a)=>{if(!a&&(a={l:1},t.dictionary)){var i=t.dictionary.subarray(-32768),o=new He(i.length+e.length);o.set(i),o.set(e,i.length),e=o,a.w=i.length}return((e,t,n,s,a,i)=>{var o=i.z||e.length,l=new He(0+o+5*(1+r.ceil(o/7e3))+0),c=l.subarray(0,l.length-0),h=i.l,f=7&(i.r||0);if(t){f&&(c[0]=i.r>>3);for(var u=wt[t-1],p=u>>13,d=8191&u,g=(1<<n)-1,w=i.p||new qe(32768),v=i.h||new qe(g+1),y=r.ceil(n/3),b=2*y,m=t=>(e[t]^e[t+1]<<y^e[t+2]<<b)&g,_=new Be(25e3),k=new qe(288),S=new qe(32),z=0,D=0,C=i.i||0,I=0,x=i.w||0,A=0;o>C+2;++C){var T=m(C),R=32767&C,H=v[T];if(w[R]=H,v[T]=R,C>=x){var q=o-C;if((z>7e3||I>24576)&&(q>423||!h)){f=gt(e,c,0,_,k,S,D,I,A,C-A,f),I=z=D=0,A=C;for(var B=0;286>B;++B)k[B]=0;for(B=0;30>B;++B)S[B]=0}var K=2,V=0,P=d,E=R-H&32767;if(q>2&&T==m(C-E))for(var U=r.min(p,q)-1,W=r.min(32767,C),M=r.min(258,q);W>=E&&--P&&R!=H;){if(e[C+K]==e[C+K-E]){for(var N=0;M>N&&e[C+N]==e[C+N-E];++N);if(N>K){if(K=N,V=E,N>U)break;var O=r.min(E,N-2),F=0;for(B=0;O>B;++B){var L=C-E+B&32767,j=L-w[L]&32767;j>F&&(F=j,H=L)}}}E+=(R=H)-(H=w[R])&32767}if(V){_[I++]=268435456|Me[K]<<18|Fe[V];var G=31&Me[K],X=31&Fe[V];D+=Ke[G]+Ve[X],++k[257+G],++S[X],x=C+K,++z}else _[I++]=e[C],++k[e[C]]}}for(C=r.max(C,x);o>C;++C)_[I++]=e[C],++k[e[C]];f=gt(e,c,h,_,k,S,D,I,A,C-A,f),h||(i.r=7&f|c[f/8|0]<<3,f-=7,i.h=v,i.p=w,i.i=C,i.w=x)}else{for(C=i.w||0;o+h>C;C+=65535){var J=C+65535;o>J||(c[f/8|0]=h,J=o),f=dt(c,f+1,e.subarray(C,J))}i.i=o}return at(l,0,0+st(f)+0)})(e,null==t.level?6:t.level,null==t.mem?r.ceil(1.5*r.max(8,r.min(13,r.log(e.length)))):12+t.mem,0,0,a)})(e,this.o,0,0,this.s),t)},e.prototype.push=function(e,t){this.ondata||ot(5),this.s.l&&ot(4);var n=e.length+this.s.z;if(n>this.b.length){if(n>2*this.b.length-32768){var r=new He(-32768&n);r.set(this.b.subarray(0,this.s.z)),this.b=r}var s=this.b.length-this.s.z;s&&(this.b.set(e.subarray(0,s),this.s.z),this.s.z=this.b.length,this.p(this.b,!1)),this.b.set(this.b.subarray(-32768)),this.b.set(e.subarray(s),32768),this.s.z=e.length-s+32768,this.s.i=32766,this.s.w=32768}else this.b.set(e,this.s.z),this.s.z+=e.length;this.s.l=1&t,(this.s.z>this.s.w+8191||t)&&(this.p(this.b,t||!1),this.s.w=this.s.i,this.s.i-=2)},e}(),bt=function(){function e(e,t){"function"==typeof e&&(t=e,e={}),this.ondata=t;var n=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:n?n.length:0},this.o=new He(32768),this.p=new He(0),n&&this.o.set(n)}return e.prototype.e=function(e){if(this.ondata||ot(5),this.d&&ot(4),this.p.length){if(e.length){var t=new He(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}}else this.p=e},e.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,n=((e,t,n)=>{var s=e.length;if(!s||t.f&&!t.l)return n||new He(0);var a=!n||2!=t.i,i=t.i;n||(n=new He(3*s));var o=e=>{var t=n.length;if(e>t){var s=new He(r.max(2*t,e));s.set(n),n=s}},l=t.f||0,c=t.p||0,h=t.b||0,f=t.l,u=t.d,p=t.m,d=t.n,g=8*s;do{if(!f){l=nt(e,c,1);var w=nt(e,c+1,3);if(c+=3,!w){var v=e[(x=st(c)+4)-4]|e[x-3]<<8,y=x+v;if(y>s){i&&ot(0);break}a&&o(h+v),n.set(e.subarray(x,y),h),t.b=h+=v,t.p=c=8*y,t.f=l;continue}if(1==w)f=Ze,u=et,p=9,d=5;else if(2==w){var b=nt(e,c,31)+257,m=nt(e,c+10,15)+4,_=b+nt(e,c+5,31)+1;c+=14;for(var k=new He(_),S=new He(19),z=0;m>z;++z)S[Pe[z]]=nt(e,c+3*z,7);c+=3*m;var D=tt(S),C=(1<<D)-1,I=Xe(S,D,1);for(z=0;_>z;){var x,A=I[nt(e,c,C)];if(c+=15&A,16>(x=A>>4))k[z++]=x;else{var T=0,R=0;for(16==x?(R=3+nt(e,c,3),c+=2,T=k[z-1]):17==x?(R=3+nt(e,c,7),c+=3):18==x&&(R=11+nt(e,c,127),c+=7);R--;)k[z++]=T}}var H=k.subarray(0,b),q=k.subarray(b);p=tt(H),d=tt(q),f=Xe(H,p,1),u=Xe(q,d,1)}else ot(1);if(c>g){i&&ot(0);break}}a&&o(h+131072);for(var B=(1<<p)-1,K=(1<<d)-1,V=c;;V=c){var P=(T=f[rt(e,c)&B])>>4;if((c+=15&T)>g){i&&ot(0);break}if(T||ot(2),256>P)n[h++]=P;else{if(256==P){V=c,f=null;break}var E=P-254;if(P>264){var U=Ke[z=P-257];E=nt(e,c,(1<<U)-1)+We[z],c+=U}var W=u[rt(e,c)&K],M=W>>4;if(W||ot(3),c+=15&W,q=Oe[M],M>3&&(U=Ve[M],q+=rt(e,c)&(1<<U)-1,c+=U),c>g){i&&ot(0);break}a&&o(h+131072);var N=h+E;if(q>h){var O=0-q,F=r.min(q,N);for(0>O+h&&ot(3);F>h;++h)n[h]=undefined[O+h]}for(;N>h;h+=4)n[h]=n[h-q],n[h+1]=n[h+1-q],n[h+2]=n[h+2-q],n[h+3]=n[h+3-q];h=N}}t.l=f,t.p=V,t.b=h,t.f=l,f&&(l=1,t.m=p,t.d=u,t.n=d)}while(!l);return h==n.length?n:at(n,0,h)})(this.p,this.s,this.o);this.ondata(at(n,t,this.s.b),this.d),this.o=at(n,this.s.b-32768),this.s.b=this.o.length,this.p=at(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),mt="undefined"!=typeof TextDecoder&&new TextDecoder;try{mt.decode(vt,{stream:!0})}catch(e){}function _t(e,n,r){return class{constructor(s){const i=this;var o,l;o=s,l="level",("function"==typeof t.hasOwn?t.hasOwn(o,l):o.hasOwnProperty(l))&&void 0===s.level&&delete s.level,i.codec=new e(t.assign({},n,s)),r(i.codec,(e=>{if(i.pendingData){const t=i.pendingData;i.pendingData=new a(t.length+e.length);const{pendingData:n}=i;n.set(t,0),n.set(e,t.length)}else i.pendingData=new a(e)}))}append(e){return this.codec.push(e),s(this)}flush(){return this.codec.push(new a,!0),s(this)}};function s(e){if(e.pendingData){const t=e.pendingData;return e.pendingData=null,t}return new a}}const{Deflate:kt,Inflate:St}=((e,t={},n)=>({Deflate:_t(e.Deflate,t.deflate,n),Inflate:_t(e.Inflate,t.inflate,n)}))({Deflate:yt,Inflate:bt},void 0,((e,t)=>e.ondata=t));self.initCodec=()=>{self.Deflate=kt,self.Inflate=St};\n'],{type:"text/javascript"}));e({workerScripts:{inflate:[t],deflate:[t]}});}
  547. /*
  548. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  549. Redistribution and use in source and binary forms, with or without
  550. modification, are permitted provided that the following conditions are met:
  551. 1. Redistributions of source code must retain the above copyright notice,
  552. this list of conditions and the following disclaimer.
  553. 2. Redistributions in binary form must reproduce the above copyright
  554. notice, this list of conditions and the following disclaimer in
  555. the documentation and/or other materials provided with the distribution.
  556. 3. The names of the authors may not be used to endorse or promote products
  557. derived from this software without specific prior written permission.
  558. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  559. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  560. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  561. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  562. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  563. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  564. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  565. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  566. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  567. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  568. */
  569. typeof crypto$1 != "undefined" && typeof crypto$1.getRandomValues == "function";
  570. const PBKDF2_ALGORITHM = { name: "PBKDF2" };
  571. const HASH_ALGORITHM = { name: "HMAC" };
  572. const HASH_FUNCTION = "SHA-1";
  573. Object$1.assign({ hash: HASH_ALGORITHM }, PBKDF2_ALGORITHM);
  574. Object$1.assign({ iterations: 1000, hash: { name: HASH_FUNCTION } }, PBKDF2_ALGORITHM);
  575. const UNDEFINED_TYPE = "undefined";
  576. const FUNCTION_TYPE = "function";
  577. // deno-lint-ignore valid-typeof
  578. const CRYPTO_API_SUPPORTED = typeof crypto$1 != UNDEFINED_TYPE;
  579. const subtle = CRYPTO_API_SUPPORTED && crypto$1.subtle;
  580. const SUBTLE_API_SUPPORTED = CRYPTO_API_SUPPORTED && typeof subtle != UNDEFINED_TYPE;
  581. CRYPTO_API_SUPPORTED && SUBTLE_API_SUPPORTED && typeof subtle.importKey == FUNCTION_TYPE;
  582. CRYPTO_API_SUPPORTED && SUBTLE_API_SUPPORTED && typeof subtle.deriveBits == FUNCTION_TYPE;
  583. /*
  584. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  585. Redistribution and use in source and binary forms, with or without
  586. modification, are permitted provided that the following conditions are met:
  587. 1. Redistributions of source code must retain the above copyright notice,
  588. this list of conditions and the following disclaimer.
  589. 2. Redistributions in binary form must reproduce the above copyright
  590. notice, this list of conditions and the following disclaimer in
  591. the documentation and/or other materials provided with the distribution.
  592. 3. The names of the authors may not be used to endorse or promote products
  593. derived from this software without specific prior written permission.
  594. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  595. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  596. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  597. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  598. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  599. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  600. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  601. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  602. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  603. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  604. */
  605. /* global TextDecoder */
  606. const CP437 = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");
  607. CP437.length == 256;
  608. new Uint8Array$1([0x07, 0x00, 0x02, 0x00, 0x41, 0x45, 0x03, 0x00, 0x00]);
  609. /*
  610. Copyright (c) 2022 Gildas Lormeau. All rights reserved.
  611. Redistribution and use in source and binary forms, with or without
  612. modification, are permitted provided that the following conditions are met:
  613. 1. Redistributions of source code must retain the above copyright notice,
  614. this list of conditions and the following disclaimer.
  615. 2. Redistributions in binary form must reproduce the above copyright
  616. notice, this list of conditions and the following disclaimer in
  617. the documentation and/or other materials provided with the distribution.
  618. 3. The names of the authors may not be used to endorse or promote products
  619. derived from this software without specific prior written permission.
  620. THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  621. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  622. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
  623. INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
  624. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  625. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  626. OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  627. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  628. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  629. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  630. */
  631. let baseURL;
  632. try {
  633. baseURL = (typeof document === 'undefined' && typeof location === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : typeof document === 'undefined' ? location.href : (document.currentScript && document.currentScript.src || new URL('single-file-extension-editor-helper.js', document.baseURI).href));
  634. } catch (_error) {
  635. // ignored
  636. }
  637. configure({ baseURL });
  638. e(configure);
  639. // dist/csstree.esm.js from https://github.com/csstree/csstree/tree/612cc5f2922b2304869497d165a0cc65257f7a8b
  640. /*
  641. * Copyright (C) 2016-2022 by Roman Dvornov
  642. *
  643. * Permission is hereby granted, free of charge, to any person obtaining a copy
  644. * of this software and associated documentation files (the "Software"), to deal
  645. * in the Software without restriction, including without limitation the rights
  646. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  647. * copies of the Software, and to permit persons to whom the Software is
  648. * furnished to do so, subject to the following conditions:
  649. *
  650. * The above copyright notice and this permission notice shall be included in
  651. * all copies or substantial portions of the Software.
  652. *
  653. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  654. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  655. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  656. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  657. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  658. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  659. * THE SOFTWARE.
  660. */
  661. var rs=Object.create;var tr=Object.defineProperty;var ns=Object.getOwnPropertyDescriptor;var os=Object.getOwnPropertyNames;var is=Object.getPrototypeOf,as=Object.prototype.hasOwnProperty;var Oe=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),b=(e,t)=>{for(var r in t)tr(e,r,{get:t[r],enumerable:!0});},ss=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of os(t))!as.call(e,o)&&o!==r&&tr(e,o,{get:()=>t[o],enumerable:!(n=ns(t,o))||n.enumerable});return e};var ls=(e,t,r)=>(r=e!=null?rs(is(e)):{},ss(t||!e||!e.__esModule?tr(r,"default",{value:e,enumerable:!0}):r,e));var Jo=Oe(ur=>{var Zo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");ur.encode=function(e){if(0<=e&&e<Zo.length)return Zo[e];throw new TypeError("Must be between 0 and 63: "+e)};ur.decode=function(e){var t=65,r=90,n=97,o=122,i=48,s=57,u=43,c=47,a=26,l=52;return t<=e&&e<=r?e-t:n<=e&&e<=o?e-n+a:i<=e&&e<=s?e-i+l:e==u?62:e==c?63:-1};});var oi=Oe(hr=>{var ei=Jo(),pr=5,ti=1<<pr,ri=ti-1,ni=ti;function ks(e){return e<0?(-e<<1)+1:(e<<1)+0}function ws(e){var t=(e&1)===1,r=e>>1;return t?-r:r}hr.encode=function(t){var r="",n,o=ks(t);do n=o&ri,o>>>=pr,o>0&&(n|=ni),r+=ei.encode(n);while(o>0);return r};hr.decode=function(t,r,n){var o=t.length,i=0,s=0,u,c;do{if(r>=o)throw new Error("Expected more digits in base 64 VLQ value.");if(c=ei.decode(t.charCodeAt(r++)),c===-1)throw new Error("Invalid base64 digit: "+t.charAt(r-1));u=!!(c&ni),c&=ri,i=i+(c<<s),s+=pr;}while(u);n.value=ws(i),n.rest=r;};});var Et=Oe(K=>{function vs(e,t,r){if(t in e)return e[t];if(arguments.length===3)return r;throw new Error('"'+t+'" is a required argument.')}K.getArg=vs;var ii=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,Ss=/^data:.+\,.+$/;function nt(e){var t=e.match(ii);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}K.urlParse=nt;function Ue(e){var t="";return e.scheme&&(t+=e.scheme+":"),t+="//",e.auth&&(t+=e.auth+"@"),e.host&&(t+=e.host),e.port&&(t+=":"+e.port),e.path&&(t+=e.path),t}K.urlGenerate=Ue;var Cs=32;function As(e){var t=[];return function(r){for(var n=0;n<t.length;n++)if(t[n].input===r){var o=t[0];return t[0]=t[n],t[n]=o,t[0].result}var i=e(r);return t.unshift({input:r,result:i}),t.length>Cs&&t.pop(),i}}var mr=As(function(t){var r=t,n=nt(t);if(n){if(!n.path)return t;r=n.path;}for(var o=K.isAbsolute(r),i=[],s=0,u=0;;)if(s=u,u=r.indexOf("/",s),u===-1){i.push(r.slice(s));break}else for(i.push(r.slice(s,u));u<r.length&&r[u]==="/";)u++;for(var c,a=0,u=i.length-1;u>=0;u--)c=i[u],c==="."?i.splice(u,1):c===".."?a++:a>0&&(c===""?(i.splice(u+1,a),a=0):(i.splice(u,2),a--));return r=i.join("/"),r===""&&(r=o?"/":"."),n?(n.path=r,Ue(n)):r});K.normalize=mr;function ai(e,t){e===""&&(e="."),t===""&&(t=".");var r=nt(t),n=nt(e);if(n&&(e=n.path||"/"),r&&!r.scheme)return n&&(r.scheme=n.scheme),Ue(r);if(r||t.match(Ss))return t;if(n&&!n.host&&!n.path)return n.host=t,Ue(n);var o=t.charAt(0)==="/"?t:mr(e.replace(/\/+$/,"")+"/"+t);return n?(n.path=o,Ue(n)):o}K.join=ai;K.isAbsolute=function(e){return e.charAt(0)==="/"||ii.test(e)};function Ts(e,t){e===""&&(e="."),e=e.replace(/\/$/,"");for(var r=0;t.indexOf(e+"/")!==0;){var n=e.lastIndexOf("/");if(n<0||(e=e.slice(0,n),e.match(/^([^\/]+:\/)?\/*$/)))return t;++r;}return Array(r+1).join("../")+t.substr(e.length+1)}K.relative=Ts;var si=function(){var e=Object.create(null);return !("__proto__"in e)}();function li(e){return e}function Es(e){return ci(e)?"$"+e:e}K.toSetString=si?li:Es;function Ls(e){return ci(e)?e.slice(1):e}K.fromSetString=si?li:Ls;function ci(e){if(!e)return !1;var t=e.length;if(t<9||e.charCodeAt(t-1)!==95||e.charCodeAt(t-2)!==95||e.charCodeAt(t-3)!==111||e.charCodeAt(t-4)!==116||e.charCodeAt(t-5)!==111||e.charCodeAt(t-6)!==114||e.charCodeAt(t-7)!==112||e.charCodeAt(t-8)!==95||e.charCodeAt(t-9)!==95)return !1;for(var r=t-10;r>=0;r--)if(e.charCodeAt(r)!==36)return !1;return !0}function Ps(e,t,r){var n=be(e.source,t.source);return n!==0||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.originalColumn,n!==0||r)||(n=e.generatedColumn-t.generatedColumn,n!==0)||(n=e.generatedLine-t.generatedLine,n!==0)?n:be(e.name,t.name)}K.compareByOriginalPositions=Ps;function Is(e,t,r){var n;return n=e.originalLine-t.originalLine,n!==0||(n=e.originalColumn-t.originalColumn,n!==0||r)||(n=e.generatedColumn-t.generatedColumn,n!==0)||(n=e.generatedLine-t.generatedLine,n!==0)?n:be(e.name,t.name)}K.compareByOriginalPositionsNoSource=Is;function Ds(e,t,r){var n=e.generatedLine-t.generatedLine;return n!==0||(n=e.generatedColumn-t.generatedColumn,n!==0||r)||(n=be(e.source,t.source),n!==0)||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.originalColumn,n!==0)?n:be(e.name,t.name)}K.compareByGeneratedPositionsDeflated=Ds;function Os(e,t,r){var n=e.generatedColumn-t.generatedColumn;return n!==0||r||(n=be(e.source,t.source),n!==0)||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.originalColumn,n!==0)?n:be(e.name,t.name)}K.compareByGeneratedPositionsDeflatedNoLine=Os;function be(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function Ns(e,t){var r=e.generatedLine-t.generatedLine;return r!==0||(r=e.generatedColumn-t.generatedColumn,r!==0)||(r=be(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:be(e.name,t.name)}K.compareByGeneratedPositionsInflated=Ns;function zs(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))}K.parseSourceMapInput=zs;function Ms(e,t,r){if(t=t||"",e&&(e[e.length-1]!=="/"&&t[0]!=="/"&&(e+="/"),t=e+t),r){var n=nt(r);if(!n)throw new Error("sourceMapURL could not be parsed");if(n.path){var o=n.path.lastIndexOf("/");o>=0&&(n.path=n.path.substring(0,o+1));}t=ai(Ue(n),t);}return mr(t)}K.computeSourceURL=Ms;});var pi=Oe(ui=>{var fr=Et(),dr=Object.prototype.hasOwnProperty,Le=typeof Map<"u";function xe(){this._array=[],this._set=Le?new Map:Object.create(null);}xe.fromArray=function(t,r){for(var n=new xe,o=0,i=t.length;o<i;o++)n.add(t[o],r);return n};xe.prototype.size=function(){return Le?this._set.size:Object.getOwnPropertyNames(this._set).length};xe.prototype.add=function(t,r){var n=Le?t:fr.toSetString(t),o=Le?this.has(t):dr.call(this._set,n),i=this._array.length;(!o||r)&&this._array.push(t),o||(Le?this._set.set(t,i):this._set[n]=i);};xe.prototype.has=function(t){if(Le)return this._set.has(t);var r=fr.toSetString(t);return dr.call(this._set,r)};xe.prototype.indexOf=function(t){if(Le){var r=this._set.get(t);if(r>=0)return r}else {var n=fr.toSetString(t);if(dr.call(this._set,n))return this._set[n]}throw new Error('"'+t+'" is not in the set.')};xe.prototype.at=function(t){if(t>=0&&t<this._array.length)return this._array[t];throw new Error("No element indexed by "+t)};xe.prototype.toArray=function(){return this._array.slice()};ui.ArraySet=xe;});var fi=Oe(mi=>{var hi=Et();function Rs(e,t){var r=e.generatedLine,n=t.generatedLine,o=e.generatedColumn,i=t.generatedColumn;return n>r||n==r&&i>=o||hi.compareByGeneratedPositionsInflated(e,t)<=0}function Lt(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0};}Lt.prototype.unsortedForEach=function(t,r){this._array.forEach(t,r);};Lt.prototype.add=function(t){Rs(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t));};Lt.prototype.toArray=function(){return this._sorted||(this._array.sort(hi.compareByGeneratedPositionsInflated),this._sorted=!0),this._array};mi.MappingList=Lt;});var gi=Oe(di=>{var ot=oi(),q=Et(),Pt=pi().ArraySet,Fs=fi().MappingList;function oe(e){e||(e={}),this._file=q.getArg(e,"file",null),this._sourceRoot=q.getArg(e,"sourceRoot",null),this._skipValidation=q.getArg(e,"skipValidation",!1),this._sources=new Pt,this._names=new Pt,this._mappings=new Fs,this._sourcesContents=null;}oe.prototype._version=3;oe.fromSourceMap=function(t){var r=t.sourceRoot,n=new oe({file:t.file,sourceRoot:r});return t.eachMapping(function(o){var i={generated:{line:o.generatedLine,column:o.generatedColumn}};o.source!=null&&(i.source=o.source,r!=null&&(i.source=q.relative(r,i.source)),i.original={line:o.originalLine,column:o.originalColumn},o.name!=null&&(i.name=o.name)),n.addMapping(i);}),t.sources.forEach(function(o){var i=o;r!==null&&(i=q.relative(r,o)),n._sources.has(i)||n._sources.add(i);var s=t.sourceContentFor(o);s!=null&&n.setSourceContent(o,s);}),n};oe.prototype.addMapping=function(t){var r=q.getArg(t,"generated"),n=q.getArg(t,"original",null),o=q.getArg(t,"source",null),i=q.getArg(t,"name",null);this._skipValidation||this._validateMapping(r,n,o,i),o!=null&&(o=String(o),this._sources.has(o)||this._sources.add(o)),i!=null&&(i=String(i),this._names.has(i)||this._names.add(i)),this._mappings.add({generatedLine:r.line,generatedColumn:r.column,originalLine:n!=null&&n.line,originalColumn:n!=null&&n.column,source:o,name:i});};oe.prototype.setSourceContent=function(t,r){var n=t;this._sourceRoot!=null&&(n=q.relative(this._sourceRoot,n)),r!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[q.toSetString(n)]=r):this._sourcesContents&&(delete this._sourcesContents[q.toSetString(n)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null));};oe.prototype.applySourceMap=function(t,r,n){var o=r;if(r==null){if(t.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);o=t.file;}var i=this._sourceRoot;i!=null&&(o=q.relative(i,o));var s=new Pt,u=new Pt;this._mappings.unsortedForEach(function(c){if(c.source===o&&c.originalLine!=null){var a=t.originalPositionFor({line:c.originalLine,column:c.originalColumn});a.source!=null&&(c.source=a.source,n!=null&&(c.source=q.join(n,c.source)),i!=null&&(c.source=q.relative(i,c.source)),c.originalLine=a.line,c.originalColumn=a.column,a.name!=null&&(c.name=a.name));}var l=c.source;l!=null&&!s.has(l)&&s.add(l);var p=c.name;p!=null&&!u.has(p)&&u.add(p);},this),this._sources=s,this._names=u,t.sources.forEach(function(c){var a=t.sourceContentFor(c);a!=null&&(n!=null&&(c=q.join(n,c)),i!=null&&(c=q.relative(i,c)),this.setSourceContent(c,a));},this);};oe.prototype._validateMapping=function(t,r,n,o){if(r&&typeof r.line!="number"&&typeof r.column!="number")throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.");if(!(t&&"line"in t&&"column"in t&&t.line>0&&t.column>=0&&!r&&!n&&!o)){if(t&&"line"in t&&"column"in t&&r&&"line"in r&&"column"in r&&t.line>0&&t.column>=0&&r.line>0&&r.column>=0&&n)return;throw new Error("Invalid mapping: "+JSON.stringify({generated:t,source:n,original:r,name:o}))}};oe.prototype._serializeMappings=function(){for(var t=0,r=1,n=0,o=0,i=0,s=0,u="",c,a,l,p,m=this._mappings.toArray(),f=0,P=m.length;f<P;f++){if(a=m[f],c="",a.generatedLine!==r)for(t=0;a.generatedLine!==r;)c+=";",r++;else if(f>0){if(!q.compareByGeneratedPositionsInflated(a,m[f-1]))continue;c+=",";}c+=ot.encode(a.generatedColumn-t),t=a.generatedColumn,a.source!=null&&(p=this._sources.indexOf(a.source),c+=ot.encode(p-s),s=p,c+=ot.encode(a.originalLine-1-o),o=a.originalLine-1,c+=ot.encode(a.originalColumn-n),n=a.originalColumn,a.name!=null&&(l=this._names.indexOf(a.name),c+=ot.encode(l-i),i=l)),u+=c;}return u};oe.prototype._generateSourcesContent=function(t,r){return t.map(function(n){if(!this._sourcesContents)return null;r!=null&&(n=q.relative(r,n));var o=q.toSetString(n);return Object.prototype.hasOwnProperty.call(this._sourcesContents,o)?this._sourcesContents[o]:null},this)};oe.prototype.toJSON=function(){var t={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(t.file=this._file),this._sourceRoot!=null&&(t.sourceRoot=this._sourceRoot),this._sourcesContents&&(t.sourcesContent=this._generateSourcesContent(t.sources,t.sourceRoot)),t};oe.prototype.toString=function(){return JSON.stringify(this.toJSON())};di.SourceMapGenerator=oe;});var $e={};b($e,{AtKeyword:()=>I,BadString:()=>Ae,BadUrl:()=>Y,CDC:()=>j,CDO:()=>ue,Colon:()=>O,Comma:()=>G,Comment:()=>E,Delim:()=>g,Dimension:()=>y,EOF:()=>Xe,Function:()=>x,Hash:()=>v,Ident:()=>h,LeftCurlyBracket:()=>M,LeftParenthesis:()=>T,LeftSquareBracket:()=>U,Number:()=>d,Percentage:()=>A,RightCurlyBracket:()=>H,RightParenthesis:()=>w,RightSquareBracket:()=>V,Semicolon:()=>_,String:()=>W,Url:()=>F,WhiteSpace:()=>k});var Xe=0,h=1,x=2,I=3,v=4,W=5,Ae=6,F=7,Y=8,g=9,d=10,A=11,y=12,k=13,ue=14,j=15,O=16,_=17,G=18,U=19,V=20,T=21,w=22,M=23,H=24,E=25;function B(e){return e>=48&&e<=57}function ee(e){return B(e)||e>=65&&e<=70||e>=97&&e<=102}function yt(e){return e>=65&&e<=90}function cs(e){return e>=97&&e<=122}function us(e){return yt(e)||cs(e)}function ps(e){return e>=128}function xt(e){return us(e)||ps(e)||e===95}function Ne(e){return xt(e)||B(e)||e===45}function hs(e){return e>=0&&e<=8||e===11||e>=14&&e<=31||e===127}function Ze(e){return e===10||e===13||e===12}function pe(e){return Ze(e)||e===32||e===9}function $(e,t){return !(e!==92||Ze(t)||t===0)}function ze(e,t,r){return e===45?xt(t)||t===45||$(t,r):xt(e)?!0:e===92?$(e,t):!1}function kt(e,t,r){return e===43||e===45?B(t)?2:t===46&&B(r)?3:0:e===46?B(t)?2:0:B(e)?1:0}function wt(e){return e===65279||e===65534?1:0}var rr=new Array(128),ms=128,Je=130,nr=131,vt=132,or=133;for(let e=0;e<rr.length;e++)rr[e]=pe(e)&&Je||B(e)&&nr||xt(e)&&vt||hs(e)&&or||e||ms;function St(e){return e<128?rr[e]:vt}function Me(e,t){return t<e.length?e.charCodeAt(t):0}function Ct(e,t,r){return r===13&&Me(e,t+1)===10?2:1}function de(e,t,r){let n=e.charCodeAt(t);return yt(n)&&(n=n|32),n===r}function ge(e,t,r,n){if(r-t!==n.length||t<0||r>e.length)return !1;for(let o=t;o<r;o++){let i=n.charCodeAt(o-t),s=e.charCodeAt(o);if(yt(s)&&(s=s|32),s!==i)return !1}return !0}function Uo(e,t){for(;t>=0&&pe(e.charCodeAt(t));t--);return t+1}function et(e,t){for(;t<e.length&&pe(e.charCodeAt(t));t++);return t}function ir(e,t){for(;t<e.length&&B(e.charCodeAt(t));t++);return t}function se(e,t){if(t+=2,ee(Me(e,t-1))){for(let n=Math.min(e.length,t+5);t<n&&ee(Me(e,t));t++);let r=Me(e,t);pe(r)&&(t+=Ct(e,t,r));}return t}function tt(e,t){for(;t<e.length;t++){let r=e.charCodeAt(t);if(!Ne(r)){if($(r,Me(e,t+1))){t=se(e,t)-1;continue}break}}return t}function Te(e,t){let r=e.charCodeAt(t);if((r===43||r===45)&&(r=e.charCodeAt(t+=1)),B(r)&&(t=ir(e,t+1),r=e.charCodeAt(t)),r===46&&B(e.charCodeAt(t+1))&&(t+=2,t=ir(e,t)),de(e,t,101)){let n=0;r=e.charCodeAt(t+1),(r===45||r===43)&&(n=1,r=e.charCodeAt(t+2)),B(r)&&(t=ir(e,t+1+n+1));}return t}function At(e,t){for(;t<e.length;t++){let r=e.charCodeAt(t);if(r===41){t++;break}$(r,Me(e,t+1))&&(t=se(e,t));}return t}function Re(e){if(e.length===1&&!ee(e.charCodeAt(0)))return e[0];let t=parseInt(e,16);return (t===0||t>=55296&&t<=57343||t>1114111)&&(t=65533),String.fromCodePoint(t)}var Fe=["EOF-token","ident-token","function-token","at-keyword-token","hash-token","string-token","bad-string-token","url-token","bad-url-token","delim-token","number-token","percentage-token","dimension-token","whitespace-token","CDO-token","CDC-token","colon-token","semicolon-token","comma-token","[-token","]-token","(-token",")-token","{-token","}-token","comment-token"];function Be(e=null,t){return e===null||e.length<t?new Uint32Array(Math.max(t+1024,16384)):e}var jo=10,fs=12,qo=13;function Wo(e){let t=e.source,r=t.length,n=t.length>0?wt(t.charCodeAt(0)):0,o=Be(e.lines,r),i=Be(e.columns,r),s=e.startLine,u=e.startColumn;for(let c=n;c<r;c++){let a=t.charCodeAt(c);o[c]=s,i[c]=u++,(a===jo||a===qo||a===fs)&&(a===qo&&c+1<r&&t.charCodeAt(c+1)===jo&&(c++,o[c]=s,i[c]=u),s++,u=1);}o[r]=s,i[r]=u,e.lines=o,e.columns=i,e.computed=!0;}var Tt=class{constructor(){this.lines=null,this.columns=null,this.computed=!1;}setSource(t,r=0,n=1,o=1){this.source=t,this.startOffset=r,this.startLine=n,this.startColumn=o,this.computed=!1;}getLocation(t,r){return this.computed||Wo(this),{source:r,offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]}}getLocationRange(t,r,n){return this.computed||Wo(this),{source:n,start:{offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]},end:{offset:this.startOffset+r,line:this.lines[r],column:this.columns[r]}}}};var ne=16777215,we=24,ds=new Map([[2,22],[21,22],[19,20],[23,24]]),rt=class{constructor(t,r){this.setSource(t,r);}reset(){this.eof=!1,this.tokenIndex=-1,this.tokenType=0,this.tokenStart=this.firstCharOffset,this.tokenEnd=this.firstCharOffset;}setSource(t="",r=()=>{}){t=String(t||"");let n=t.length,o=Be(this.offsetAndType,t.length+1),i=Be(this.balance,t.length+1),s=0,u=0,c=0,a=-1;for(this.offsetAndType=null,this.balance=null,r(t,(l,p,m)=>{switch(l){default:i[s]=n;break;case u:{let f=c&ne;for(c=i[f],u=c>>we,i[s]=f,i[f++]=s;f<s;f++)i[f]===n&&(i[f]=s);break}case 21:case 2:case 19:case 23:i[s]=c,u=ds.get(l),c=u<<we|s;break}o[s++]=l<<we|m,a===-1&&(a=p);}),o[s]=0<<we|n,i[s]=n,i[n]=n;c!==0;){let l=c&ne;c=i[l],i[l]=n;}this.source=t,this.firstCharOffset=a===-1?0:a,this.tokenCount=s,this.offsetAndType=o,this.balance=i,this.reset(),this.next();}lookupType(t){return t+=this.tokenIndex,t<this.tokenCount?this.offsetAndType[t]>>we:0}lookupOffset(t){return t+=this.tokenIndex,t<this.tokenCount?this.offsetAndType[t-1]&ne:this.source.length}lookupValue(t,r){return t+=this.tokenIndex,t<this.tokenCount?ge(this.source,this.offsetAndType[t-1]&ne,this.offsetAndType[t]&ne,r):!1}getTokenStart(t){return t===this.tokenIndex?this.tokenStart:t>0?t<this.tokenCount?this.offsetAndType[t-1]&ne:this.offsetAndType[this.tokenCount]&ne:this.firstCharOffset}substrToCursor(t){return this.source.substring(t,this.tokenStart)}isBalanceEdge(t){return this.balance[this.tokenIndex]<t}isDelim(t,r){return r?this.lookupType(r)===9&&this.source.charCodeAt(this.lookupOffset(r))===t:this.tokenType===9&&this.source.charCodeAt(this.tokenStart)===t}skip(t){let r=this.tokenIndex+t;r<this.tokenCount?(this.tokenIndex=r,this.tokenStart=this.offsetAndType[r-1]&ne,r=this.offsetAndType[r],this.tokenType=r>>we,this.tokenEnd=r&ne):(this.tokenIndex=this.tokenCount,this.next());}next(){let t=this.tokenIndex+1;t<this.tokenCount?(this.tokenIndex=t,this.tokenStart=this.tokenEnd,t=this.offsetAndType[t],this.tokenType=t>>we,this.tokenEnd=t&ne):(this.eof=!0,this.tokenIndex=this.tokenCount,this.tokenType=0,this.tokenStart=this.tokenEnd=this.source.length);}skipSC(){for(;this.tokenType===13||this.tokenType===25;)this.next();}skipUntilBalanced(t,r){let n=t,o,i;e:for(;n<this.tokenCount;n++){if(o=this.balance[n],o<t)break e;switch(i=n>0?this.offsetAndType[n-1]&ne:this.firstCharOffset,r(this.source.charCodeAt(i))){case 1:break e;case 2:n++;break e;default:this.balance[o]===n&&(n=o);}}this.skip(n-this.tokenIndex);}forEachToken(t){for(let r=0,n=this.firstCharOffset;r<this.tokenCount;r++){let o=n,i=this.offsetAndType[r],s=i&ne,u=i>>we;n=s,t(u,o,s,r);}}dump(){let t=new Array(this.tokenCount);return this.forEachToken((r,n,o,i)=>{t[i]={idx:i,type:Fe[r],chunk:this.source.substring(n,o),balance:this.balance[i]};}),t}};function ve(e,t){function r(p){return p<u?e.charCodeAt(p):0}function n(){if(a=Te(e,a),ze(r(a),r(a+1),r(a+2))){l=12,a=tt(e,a);return}if(r(a)===37){l=11,a++;return}l=10;}function o(){let p=a;if(a=tt(e,a),ge(e,p,a,"url")&&r(a)===40){if(a=et(e,a+1),r(a)===34||r(a)===39){l=2,a=p+4;return}s();return}if(r(a)===40){l=2,a++;return}l=1;}function i(p){for(p||(p=r(a++)),l=5;a<e.length;a++){let m=e.charCodeAt(a);switch(St(m)){case p:a++;return;case Je:if(Ze(m)){a+=Ct(e,a,m),l=6;return}break;case 92:if(a===e.length-1)break;let f=r(a+1);Ze(f)?a+=Ct(e,a+1,f):$(m,f)&&(a=se(e,a)-1);break}}}function s(){for(l=7,a=et(e,a);a<e.length;a++){let p=e.charCodeAt(a);switch(St(p)){case 41:a++;return;case Je:if(a=et(e,a),r(a)===41||a>=e.length){a<e.length&&a++;return}a=At(e,a),l=8;return;case 34:case 39:case 40:case or:a=At(e,a),l=8;return;case 92:if($(p,r(a+1))){a=se(e,a)-1;break}a=At(e,a),l=8;return}}}e=String(e||"");let u=e.length,c=wt(r(0)),a=c,l;for(;a<u;){let p=e.charCodeAt(a);switch(St(p)){case Je:l=13,a=et(e,a+1);break;case 34:i();break;case 35:Ne(r(a+1))||$(r(a+1),r(a+2))?(l=4,a=tt(e,a+1)):(l=9,a++);break;case 39:i();break;case 40:l=21,a++;break;case 41:l=22,a++;break;case 43:kt(p,r(a+1),r(a+2))?n():(l=9,a++);break;case 44:l=18,a++;break;case 45:kt(p,r(a+1),r(a+2))?n():r(a+1)===45&&r(a+2)===62?(l=15,a=a+3):ze(p,r(a+1),r(a+2))?o():(l=9,a++);break;case 46:kt(p,r(a+1),r(a+2))?n():(l=9,a++);break;case 47:r(a+1)===42?(l=25,a=e.indexOf("*/",a+2),a=a===-1?e.length:a+2):(l=9,a++);break;case 58:l=16,a++;break;case 59:l=17,a++;break;case 60:r(a+1)===33&&r(a+2)===45&&r(a+3)===45?(l=14,a=a+4):(l=9,a++);break;case 64:ze(r(a+1),r(a+2),r(a+3))?(l=3,a=tt(e,a+1)):(l=9,a++);break;case 91:l=19,a++;break;case 92:$(p,r(a+1))?o():(l=9,a++);break;case 93:l=20,a++;break;case 123:l=23,a++;break;case 125:l=24,a++;break;case nr:n();break;case vt:o();break;default:l=9,a++;}t(l,c,c=a);}}var _e=null,D=class{static createItem(t){return {prev:null,next:null,data:t}}constructor(){this.head=null,this.tail=null,this.cursor=null;}createItem(t){return D.createItem(t)}allocateCursor(t,r){let n;return _e!==null?(n=_e,_e=_e.cursor,n.prev=t,n.next=r,n.cursor=this.cursor):n={prev:t,next:r,cursor:this.cursor},this.cursor=n,n}releaseCursor(){let{cursor:t}=this;this.cursor=t.cursor,t.prev=null,t.next=null,t.cursor=_e,_e=t;}updateCursors(t,r,n,o){let{cursor:i}=this;for(;i!==null;)i.prev===t&&(i.prev=r),i.next===n&&(i.next=o),i=i.cursor;}*[Symbol.iterator](){for(let t=this.head;t!==null;t=t.next)yield t.data;}get size(){let t=0;for(let r=this.head;r!==null;r=r.next)t++;return t}get isEmpty(){return this.head===null}get first(){return this.head&&this.head.data}get last(){return this.tail&&this.tail.data}fromArray(t){let r=null;this.head=null;for(let n of t){let o=D.createItem(n);r!==null?r.next=o:this.head=o,o.prev=r,r=o;}return this.tail=r,this}toArray(){return [...this]}toJSON(){return [...this]}forEach(t,r=this){let n=this.allocateCursor(null,this.head);for(;n.next!==null;){let o=n.next;n.next=o.next,t.call(r,o.data,o,this);}this.releaseCursor();}forEachRight(t,r=this){let n=this.allocateCursor(this.tail,null);for(;n.prev!==null;){let o=n.prev;n.prev=o.prev,t.call(r,o.data,o,this);}this.releaseCursor();}reduce(t,r,n=this){let o=this.allocateCursor(null,this.head),i=r,s;for(;o.next!==null;)s=o.next,o.next=s.next,i=t.call(n,i,s.data,s,this);return this.releaseCursor(),i}reduceRight(t,r,n=this){let o=this.allocateCursor(this.tail,null),i=r,s;for(;o.prev!==null;)s=o.prev,o.prev=s.prev,i=t.call(n,i,s.data,s,this);return this.releaseCursor(),i}some(t,r=this){for(let n=this.head;n!==null;n=n.next)if(t.call(r,n.data,n,this))return !0;return !1}map(t,r=this){let n=new D;for(let o=this.head;o!==null;o=o.next)n.appendData(t.call(r,o.data,o,this));return n}filter(t,r=this){let n=new D;for(let o=this.head;o!==null;o=o.next)t.call(r,o.data,o,this)&&n.appendData(o.data);return n}nextUntil(t,r,n=this){if(t===null)return;let o=this.allocateCursor(null,t);for(;o.next!==null;){let i=o.next;if(o.next=i.next,r.call(n,i.data,i,this))break}this.releaseCursor();}prevUntil(t,r,n=this){if(t===null)return;let o=this.allocateCursor(t,null);for(;o.prev!==null;){let i=o.prev;if(o.prev=i.prev,r.call(n,i.data,i,this))break}this.releaseCursor();}clear(){this.head=null,this.tail=null;}copy(){let t=new D;for(let r of this)t.appendData(r);return t}prepend(t){return this.updateCursors(null,t,this.head,t),this.head!==null?(this.head.prev=t,t.next=this.head):this.tail=t,this.head=t,this}prependData(t){return this.prepend(D.createItem(t))}append(t){return this.insert(t)}appendData(t){return this.insert(D.createItem(t))}insert(t,r=null){if(r!==null)if(this.updateCursors(r.prev,t,r,t),r.prev===null){if(this.head!==r)throw new Error("before doesn't belong to list");this.head=t,r.prev=t,t.next=r,this.updateCursors(null,t);}else r.prev.next=t,t.prev=r.prev,r.prev=t,t.next=r;else this.updateCursors(this.tail,t,null,t),this.tail!==null?(this.tail.next=t,t.prev=this.tail):this.head=t,this.tail=t;return this}insertData(t,r){return this.insert(D.createItem(t),r)}remove(t){if(this.updateCursors(t,t.prev,t,t.next),t.prev!==null)t.prev.next=t.next;else {if(this.head!==t)throw new Error("item doesn't belong to list");this.head=t.next;}if(t.next!==null)t.next.prev=t.prev;else {if(this.tail!==t)throw new Error("item doesn't belong to list");this.tail=t.prev;}return t.prev=null,t.next=null,t}push(t){this.insert(D.createItem(t));}pop(){return this.tail!==null?this.remove(this.tail):null}unshift(t){this.prepend(D.createItem(t));}shift(){return this.head!==null?this.remove(this.head):null}prependList(t){return this.insertList(t,this.head)}appendList(t){return this.insertList(t)}insertList(t,r){return t.head===null?this:(r!=null?(this.updateCursors(r.prev,t.tail,r,t.head),r.prev!==null?(r.prev.next=t.head,t.head.prev=r.prev):this.head=t.head,r.prev=t.tail,t.tail.next=r):(this.updateCursors(this.tail,t.tail,null,t.head),this.tail!==null?(this.tail.next=t.head,t.head.prev=this.tail):this.head=t.head,this.tail=t.tail),t.head=null,t.tail=null,this)}replace(t,r){"head"in r?this.insertList(r,t):this.insert(r,t),this.remove(t);}};function Ee(e,t){let r=Object.create(SyntaxError.prototype),n=new Error;return Object.assign(r,{name:e,message:t,get stack(){return (n.stack||"").replace(/^(.+\n){1,3}/,`${e}: ${t}
  662. `)}})}var ar=100,Ho=60,Yo=" ";function Go({source:e,line:t,column:r},n){function o(l,p){return i.slice(l,p).map((m,f)=>String(l+f+1).padStart(c)+" |"+m).join(`
  663. `)}let i=e.split(/\r\n?|\n|\f/),s=Math.max(1,t-n)-1,u=Math.min(t+n,i.length+1),c=Math.max(4,String(u).length)+1,a=0;r+=(Yo.length-1)*(i[t-1].substr(0,r-1).match(/\t/g)||[]).length,r>ar&&(a=r-Ho+3,r=Ho-2);for(let l=s;l<=u;l++)l>=0&&l<i.length&&(i[l]=i[l].replace(/\t/g,Yo),i[l]=(a>0&&i[l].length>a?"\u2026":"")+i[l].substr(a,ar-2)+(i[l].length>a+ar-1?"\u2026":""));return [o(s,t),new Array(r+c+2).join("-")+"^",o(t,u)].filter(Boolean).join(`
  664. `)}function sr(e,t,r,n,o){return Object.assign(Ee("SyntaxError",e),{source:t,offset:r,line:n,column:o,sourceFragment(s){return Go({source:t,line:n,column:o},isNaN(s)?0:s)},get formattedMessage(){return `Parse error: ${e}
  665. `+Go({source:t,line:n,column:o},2)}})}function Vo(e){let t=this.createList(),r=!1,n={recognizer:e};for(;!this.eof;){switch(this.tokenType){case 25:this.next();continue;case 13:r=!0,this.next();continue}let o=e.getNode.call(this,n);if(o===void 0)break;r&&(e.onWhiteSpace&&e.onWhiteSpace.call(this,o,t,n),r=!1),t.push(o);}return r&&e.onWhiteSpace&&e.onWhiteSpace.call(this,null,t,n),t}var Ko=()=>{},gs=33,bs=35,lr=59,Qo=123,Xo=0;function xs(e){return function(){return this[e]()}}function cr(e){let t=Object.create(null);for(let r in e){let n=e[r],o=n.parse||n;o&&(t[r]=o);}return t}function ys(e){let t={context:Object.create(null),scope:Object.assign(Object.create(null),e.scope),atrule:cr(e.atrule),pseudo:cr(e.pseudo),node:cr(e.node)};for(let r in e.parseContext)switch(typeof e.parseContext[r]){case"function":t.context[r]=e.parseContext[r];break;case"string":t.context[r]=xs(e.parseContext[r]);break}return {config:t,...t,...t.node}}function $o(e){let t="",r="<unknown>",n=!1,o=Ko,i=!1,s=new Tt,u=Object.assign(new rt,ys(e||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:Vo,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket(a){return a===Qo?1:0},consumeUntilLeftCurlyBracketOrSemicolon(a){return a===Qo||a===lr?1:0},consumeUntilExclamationMarkOrSemicolon(a){return a===gs||a===lr?1:0},consumeUntilSemicolonIncluded(a){return a===lr?2:0},createList(){return new D},createSingleNodeList(a){return new D().appendData(a)},getFirstListNode(a){return a&&a.first},getLastListNode(a){return a&&a.last},parseWithFallback(a,l){let p=this.tokenIndex;try{return a.call(this)}catch(m){if(i)throw m;let f=l.call(this,p);return i=!0,o(m,f),i=!1,f}},lookupNonWSType(a){let l;do if(l=this.lookupType(a++),l!==13)return l;while(l!==Xo);return Xo},charCodeAt(a){return a>=0&&a<t.length?t.charCodeAt(a):0},substring(a,l){return t.substring(a,l)},substrToCursor(a){return this.source.substring(a,this.tokenStart)},cmpChar(a,l){return de(t,a,l)},cmpStr(a,l,p){return ge(t,a,l,p)},consume(a){let l=this.tokenStart;return this.eat(a),this.substrToCursor(l)},consumeFunctionName(){let a=t.substring(this.tokenStart,this.tokenEnd-1);return this.eat(2),a},consumeNumber(a){let l=t.substring(this.tokenStart,Te(t,this.tokenStart));return this.eat(a),l},eat(a){if(this.tokenType!==a){let l=Fe[a].slice(0,-6).replace(/-/g," ").replace(/^./,f=>f.toUpperCase()),p=`${/[[\](){}]/.test(l)?`"${l}"`:l} is expected`,m=this.tokenStart;switch(a){case 1:this.tokenType===2||this.tokenType===7?(m=this.tokenEnd-1,p="Identifier is expected but function found"):p="Identifier is expected";break;case 4:this.isDelim(bs)&&(this.next(),m++,p="Name is expected");break;case 11:this.tokenType===10&&(m=this.tokenEnd,p="Percent sign is expected");break}this.error(p,m);}this.next();},eatIdent(a){(this.tokenType!==1||this.lookupValue(0,a)===!1)&&this.error(`Identifier "${a}" is expected`),this.next();},eatDelim(a){this.isDelim(a)||this.error(`Delim "${String.fromCharCode(a)}" is expected`),this.next();},getLocation(a,l){return n?s.getLocationRange(a,l,r):null},getLocationFromList(a){if(n){let l=this.getFirstListNode(a),p=this.getLastListNode(a);return s.getLocationRange(l!==null?l.loc.start.offset-s.startOffset:this.tokenStart,p!==null?p.loc.end.offset-s.startOffset:this.tokenStart,r)}return null},error(a,l){let p=typeof l<"u"&&l<t.length?s.getLocation(l):this.eof?s.getLocation(Uo(t,t.length-1)):s.getLocation(this.tokenStart);throw new sr(a||"Unexpected input",t,p.offset,p.line,p.column)}});return Object.assign(function(a,l){t=a,l=l||{},u.setSource(t,ve),s.setSource(t,l.offset,l.line,l.column),r=l.filename||"<unknown>",n=Boolean(l.positions),o=typeof l.onParseError=="function"?l.onParseError:Ko,i=!1,u.parseAtrulePrelude="parseAtrulePrelude"in l?Boolean(l.parseAtrulePrelude):!0,u.parseRulePrelude="parseRulePrelude"in l?Boolean(l.parseRulePrelude):!0,u.parseValue="parseValue"in l?Boolean(l.parseValue):!0,u.parseCustomProperty="parseCustomProperty"in l?Boolean(l.parseCustomProperty):!1;let{context:p="default",onComment:m}=l;if(!(p in u.context))throw new Error("Unknown context `"+p+"`");typeof m=="function"&&u.forEachToken((P,te,X)=>{if(P===25){let S=u.getLocation(te,X),R=ge(t,X-2,X,"*/")?t.slice(te+2,X-2):t.slice(te+2,X);m(R,S);}});let f=u.context[p].call(u,l);return u.eof||u.error(),f},{SyntaxError:sr,config:u.config})}var xi=ls(gi(),1),bi=new Set(["Atrule","Selector","Declaration"]);function yi(e){let t=new xi.SourceMapGenerator,r={line:1,column:0},n={line:0,column:0},o={line:1,column:0},i={generated:o},s=1,u=0,c=!1,a=e.node;e.node=function(m){if(m.loc&&m.loc.start&&bi.has(m.type)){let f=m.loc.start.line,P=m.loc.start.column-1;(n.line!==f||n.column!==P)&&(n.line=f,n.column=P,r.line=s,r.column=u,c&&(c=!1,(r.line!==o.line||r.column!==o.column)&&t.addMapping(i)),c=!0,t.addMapping({source:m.loc.source,original:n,generated:r}));}a.call(this,m),c&&bi.has(m.type)&&(o.line=s,o.column=u);};let l=e.emit;e.emit=function(m,f,P){for(let te=0;te<m.length;te++)m.charCodeAt(te)===10?(s++,u=0):u++;l(m,f,P);};let p=e.result;return e.result=function(){return c&&t.addMapping(i),{css:p(),map:t}},e}var It={};b(It,{safe:()=>br,spec:()=>js});var Bs=43,_s=45,gr=(e,t)=>{if(e===9&&(e=t),typeof e=="string"){let r=e.charCodeAt(0);return r>127?32768:r<<8}return e},ki=[[1,1],[1,2],[1,7],[1,8],[1,"-"],[1,10],[1,11],[1,12],[1,15],[1,21],[3,1],[3,2],[3,7],[3,8],[3,"-"],[3,10],[3,11],[3,12],[3,15],[4,1],[4,2],[4,7],[4,8],[4,"-"],[4,10],[4,11],[4,12],[4,15],[12,1],[12,2],[12,7],[12,8],[12,"-"],[12,10],[12,11],[12,12],[12,15],["#",1],["#",2],["#",7],["#",8],["#","-"],["#",10],["#",11],["#",12],["#",15],["-",1],["-",2],["-",7],["-",8],["-","-"],["-",10],["-",11],["-",12],["-",15],[10,1],[10,2],[10,7],[10,8],[10,10],[10,11],[10,12],[10,"%"],[10,15],["@",1],["@",2],["@",7],["@",8],["@","-"],["@",15],[".",10],[".",11],[".",12],["+",10],["+",11],["+",12],["/","*"]],Us=ki.concat([[1,4],[12,4],[4,4],[3,21],[3,5],[3,16],[11,11],[11,12],[11,2],[11,"-"],[22,1],[22,2],[22,11],[22,12],[22,4],[22,"-"]]);function wi(e){let t=new Set(e.map(([r,n])=>gr(r)<<16|gr(n)));return function(r,n,o){let i=gr(n,o),s=o.charCodeAt(0);return (s===_s&&n!==1&&n!==2&&n!==15||s===Bs?t.has(r<<16|s<<8):t.has(r<<16|i))&&this.emit(" ",13,!0),i}}var js=wi(ki),br=wi(Us);var qs=92;function Ws(e,t){if(typeof t=="function"){let r=null;e.children.forEach(n=>{r!==null&&t.call(this,r),this.node(n),r=n;});return}e.children.forEach(this.node,this);}function Hs(e){ve(e,(t,r,n)=>{this.token(t,e.slice(r,n));});}function vi(e){let t=new Map;for(let r in e.node){let n=e.node[r];typeof(n.generate||n)=="function"&&t.set(r,n.generate||n);}return function(r,n){let o="",i=0,s={node(c){if(t.has(c.type))t.get(c.type).call(u,c);else throw new Error("Unknown node type: "+c.type)},tokenBefore:br,token(c,a){i=this.tokenBefore(i,c,a),this.emit(a,c,!1),c===9&&a.charCodeAt(0)===qs&&this.emit(`
  666. `,13,!0);},emit(c){o+=c;},result(){return o}};n&&(typeof n.decorator=="function"&&(s=n.decorator(s)),n.sourceMap&&(s=yi(s)),n.mode in It&&(s.tokenBefore=It[n.mode]));let u={node:c=>s.node(c),children:Ws,token:(c,a)=>s.token(c,a),tokenize:Hs};return s.node(r),s.result()}}function Si(e){return {fromPlainObject(t){return e(t,{enter(r){r.children&&!(r.children instanceof D)&&(r.children=new D().fromArray(r.children));}}),t},toPlainObject(t){return e(t,{leave(r){r.children&&r.children instanceof D&&(r.children=r.children.toArray());}}),t}}}var{hasOwnProperty:xr}=Object.prototype,it=function(){};function Ci(e){return typeof e=="function"?e:it}function Ai(e,t){return function(r,n,o){r.type===t&&e.call(this,r,n,o);}}function Ys(e,t){let r=t.structure,n=[];for(let o in r){if(xr.call(r,o)===!1)continue;let i=r[o],s={name:o,type:!1,nullable:!1};Array.isArray(i)||(i=[i]);for(let u of i)u===null?s.nullable=!0:typeof u=="string"?s.type="node":Array.isArray(u)&&(s.type="list");s.type&&n.push(s);}return n.length?{context:t.walkContext,fields:n}:null}function Gs(e){let t={};for(let r in e.node)if(xr.call(e.node,r)){let n=e.node[r];if(!n.structure)throw new Error("Missed `structure` field in `"+r+"` node type definition");t[r]=Ys(r,n);}return t}function Ti(e,t){let r=e.fields.slice(),n=e.context,o=typeof n=="string";return t&&r.reverse(),function(i,s,u,c){let a;o&&(a=s[n],s[n]=i);for(let l of r){let p=i[l.name];if(!l.nullable||p){if(l.type==="list"){if(t?p.reduceRight(c,!1):p.reduce(c,!1))return !0}else if(u(p))return !0}}o&&(s[n]=a);}}function Ei({StyleSheet:e,Atrule:t,Rule:r,Block:n,DeclarationList:o}){return {Atrule:{StyleSheet:e,Atrule:t,Rule:r,Block:n},Rule:{StyleSheet:e,Atrule:t,Rule:r,Block:n},Declaration:{StyleSheet:e,Atrule:t,Rule:r,Block:n,DeclarationList:o}}}function Li(e){let t=Gs(e),r={},n={},o=Symbol("break-walk"),i=Symbol("skip-node");for(let a in t)xr.call(t,a)&&t[a]!==null&&(r[a]=Ti(t[a],!1),n[a]=Ti(t[a],!0));let s=Ei(r),u=Ei(n),c=function(a,l){function p(S,R,ke){let z=m.call(X,S,R,ke);return z===o?!0:z===i?!1:!!(P.hasOwnProperty(S.type)&&P[S.type](S,X,p,te)||f.call(X,S,R,ke)===o)}let m=it,f=it,P=r,te=(S,R,ke,z)=>S||p(R,ke,z),X={break:o,skip:i,root:a,stylesheet:null,atrule:null,atrulePrelude:null,rule:null,selector:null,block:null,declaration:null,function:null};if(typeof l=="function")m=l;else if(l&&(m=Ci(l.enter),f=Ci(l.leave),l.reverse&&(P=n),l.visit)){if(s.hasOwnProperty(l.visit))P=l.reverse?u[l.visit]:s[l.visit];else if(!t.hasOwnProperty(l.visit))throw new Error("Bad value `"+l.visit+"` for `visit` option (should be: "+Object.keys(t).sort().join(", ")+")");m=Ai(m,l.visit),f=Ai(f,l.visit);}if(m===it&&f===it)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");p(a);};return c.break=o,c.skip=i,c.find=function(a,l){let p=null;return c(a,function(m,f,P){if(l.call(this,m,f,P))return p=m,o}),p},c.findLast=function(a,l){let p=null;return c(a,{reverse:!0,enter(m,f,P){if(l.call(this,m,f,P))return p=m,o}}),p},c.findAll=function(a,l){let p=[];return c(a,function(m,f,P){l.call(this,m,f,P)&&p.push(m);}),p},c}function Vs(e){return e}function Ks(e){let{min:t,max:r,comma:n}=e;return t===0&&r===0?n?"#?":"*":t===0&&r===1?"?":t===1&&r===0?n?"#":"+":t===1&&r===1?"":(n?"#":"")+(t===r?"{"+t+"}":"{"+t+","+(r!==0?r:"")+"}")}function Qs(e){switch(e.type){case"Range":return " ["+(e.min===null?"-\u221E":e.min)+","+(e.max===null?"\u221E":e.max)+"]";default:throw new Error("Unknown node type `"+e.type+"`")}}function Xs(e,t,r,n){let o=e.combinator===" "||n?e.combinator:" "+e.combinator+" ",i=e.terms.map(s=>yr(s,t,r,n)).join(o);return e.explicit||r?(n||i[0]===","?"[":"[ ")+i+(n?"]":" ]"):i}function yr(e,t,r,n){let o;switch(e.type){case"Group":o=Xs(e,t,r,n)+(e.disallowEmpty?"!":"");break;case"Multiplier":return yr(e.term,t,r,n)+t(Ks(e),e);case"Type":o="<"+e.name+(e.opts?t(Qs(e.opts),e.opts):"")+">";break;case"Property":o="<'"+e.name+"'>";break;case"Keyword":o=e.name;break;case"AtKeyword":o="@"+e.name;break;case"Function":o=e.name+"(";break;case"String":case"Token":o=e.value;break;case"Comma":o=",";break;default:throw new Error("Unknown node type `"+e.type+"`")}return t(o,e)}function Pe(e,t){let r=Vs,n=!1,o=!1;return typeof t=="function"?r=t:t&&(n=Boolean(t.forceBraces),o=Boolean(t.compact),typeof t.decorate=="function"&&(r=t.decorate)),yr(e,r,n,o)}var Pi={offset:0,line:1,column:1};function $s(e,t){let r=e.tokens,n=e.longestMatch,o=n<r.length&&r[n].node||null,i=o!==t?o:null,s=0,u=0,c=0,a="",l,p;for(let m=0;m<r.length;m++){let f=r[m].value;m===n&&(u=f.length,s=a.length),i!==null&&r[m].node===i&&(m<=n?c++:c=0),a+=f;}return n===r.length||c>1?(l=Dt(i||t,"end")||at(Pi,a),p=at(l)):(l=Dt(i,"start")||at(Dt(t,"start")||Pi,a.slice(0,s)),p=Dt(i,"end")||at(l,a.substr(s,u))),{css:a,mismatchOffset:s,mismatchLength:u,start:l,end:p}}function Dt(e,t){let r=e&&e.loc&&e.loc[t];return r?"line"in r?at(r):r:null}function at({offset:e,line:t,column:r},n){let o={offset:e,line:t,column:r};if(n){let i=n.split(/\n|\r\n?|\f/);o.offset+=n.length,o.line+=i.length-1,o.column=i.length===1?o.column+n.length:i.pop().length+1;}return o}var je=function(e,t){let r=Ee("SyntaxReferenceError",e+(t?" `"+t+"`":""));return r.reference=t,r},Ii=function(e,t,r,n){let o=Ee("SyntaxMatchError",e),{css:i,mismatchOffset:s,mismatchLength:u,start:c,end:a}=$s(n,r);return o.rawMessage=e,o.syntax=t?Pe(t):"<generic>",o.css=i,o.mismatchOffset=s,o.mismatchLength=u,o.message=e+`
  667. syntax: `+o.syntax+`
  668. value: `+(i||"<empty string>")+`
  669. --------`+new Array(o.mismatchOffset+1).join("-")+"^",Object.assign(o,c),o.loc={source:r&&r.loc&&r.loc.source||"<unknown>",start:c,end:a},o};var Ot=new Map,qe=new Map,Nt=45,zt=Zs,kr=Js;function Mt(e,t){return t=t||0,e.length-t>=2&&e.charCodeAt(t)===Nt&&e.charCodeAt(t+1)===Nt}function wr(e,t){if(t=t||0,e.length-t>=3&&e.charCodeAt(t)===Nt&&e.charCodeAt(t+1)!==Nt){let r=e.indexOf("-",t+2);if(r!==-1)return e.substring(t,r+1)}return ""}function Zs(e){if(Ot.has(e))return Ot.get(e);let t=e.toLowerCase(),r=Ot.get(t);if(r===void 0){let n=Mt(t,0),o=n?"":wr(t,0);r=Object.freeze({basename:t.substr(o.length),name:t,prefix:o,vendor:o,custom:n});}return Ot.set(e,r),r}function Js(e){if(qe.has(e))return qe.get(e);let t=e,r=e[0];r==="/"?r=e[1]==="/"?"//":"/":r!=="_"&&r!=="*"&&r!=="$"&&r!=="#"&&r!=="+"&&r!=="&"&&(r="");let n=Mt(t,r.length);if(!n&&(t=t.toLowerCase(),qe.has(t))){let u=qe.get(t);return qe.set(e,u),u}let o=n?"":wr(t,r.length),i=t.substr(0,r.length+o.length),s=Object.freeze({basename:t.substr(i.length),name:t.substr(r.length),hack:r,vendor:o,prefix:i,custom:n});return qe.set(e,s),s}var Rt=["initial","inherit","unset","revert","revert-layer"];var lt=43,he=45,vr=110,We=!0,tl=!1;function Cr(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function st(e,t,r){for(;e!==null&&(e.type===13||e.type===25);)e=r(++t);return t}function Se(e,t,r,n){if(!e)return 0;let o=e.value.charCodeAt(t);if(o===lt||o===he){if(r)return 0;t++;}for(;t<e.value.length;t++)if(!B(e.value.charCodeAt(t)))return 0;return n+1}function Sr(e,t,r){let n=!1,o=st(e,t,r);if(e=r(o),e===null)return t;if(e.type!==10)if(Cr(e,lt)||Cr(e,he)){if(n=!0,o=st(r(++o),o,r),e=r(o),e===null||e.type!==10)return 0}else return t;if(!n){let i=e.value.charCodeAt(0);if(i!==lt&&i!==he)return 0}return Se(e,n?0:1,n,o)}function Ar(e,t){let r=0;if(!e)return 0;if(e.type===10)return Se(e,0,tl,r);if(e.type===1&&e.value.charCodeAt(0)===he){if(!de(e.value,1,vr))return 0;switch(e.value.length){case 2:return Sr(t(++r),r,t);case 3:return e.value.charCodeAt(2)!==he?0:(r=st(t(++r),r,t),e=t(r),Se(e,0,We,r));default:return e.value.charCodeAt(2)!==he?0:Se(e,3,We,r)}}else if(e.type===1||Cr(e,lt)&&t(r+1).type===1){if(e.type!==1&&(e=t(++r)),e===null||!de(e.value,0,vr))return 0;switch(e.value.length){case 1:return Sr(t(++r),r,t);case 2:return e.value.charCodeAt(1)!==he?0:(r=st(t(++r),r,t),e=t(r),Se(e,0,We,r));default:return e.value.charCodeAt(1)!==he?0:Se(e,2,We,r)}}else if(e.type===12){let n=e.value.charCodeAt(0),o=n===lt||n===he?1:0,i=o;for(;i<e.value.length&&B(e.value.charCodeAt(i));i++);return i===o||!de(e.value,i,vr)?0:i+1===e.value.length?Sr(t(++r),r,t):e.value.charCodeAt(i+1)!==he?0:i+2===e.value.length?(r=st(t(++r),r,t),e=t(r),Se(e,0,We,r)):Se(e,i+2,We,r)}return 0}var rl=43,Di=45,Oi=63,nl=117;function Tr(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function ol(e,t){return e.value.charCodeAt(0)===t}function ct(e,t,r){let n=0;for(let o=t;o<e.value.length;o++){let i=e.value.charCodeAt(o);if(i===Di&&r&&n!==0)return ct(e,t+n+1,!1),6;if(!ee(i)||++n>6)return 0}return n}function Ft(e,t,r){if(!e)return 0;for(;Tr(r(t),Oi);){if(++e>6)return 0;t++;}return t}function Er(e,t){let r=0;if(e===null||e.type!==1||!de(e.value,0,nl)||(e=t(++r),e===null))return 0;if(Tr(e,rl))return e=t(++r),e===null?0:e.type===1?Ft(ct(e,0,!0),++r,t):Tr(e,Oi)?Ft(1,++r,t):0;if(e.type===10){let n=ct(e,1,!0);return n===0?0:(e=t(++r),e===null?r:e.type===12||e.type===10?!ol(e,Di)||!ct(e,1,!1)?0:r+1:Ft(n,r,t))}return e.type===12?Ft(ct(e,1,!0),++r,t):0}var il=["calc(","-moz-calc(","-webkit-calc("],Lr=new Map([[2,22],[21,22],[19,20],[23,24]]);function le(e,t){return t<e.length?e.charCodeAt(t):0}function Ni(e,t){return ge(e,0,e.length,t)}function zi(e,t){for(let r=0;r<t.length;r++)if(Ni(e,t[r]))return !0;return !1}function Mi(e,t){return t!==e.length-2?!1:le(e,t)===92&&B(le(e,t+1))}function Bt(e,t,r){if(e&&e.type==="Range"){let n=Number(r!==void 0&&r!==t.length?t.substr(0,r):t);if(isNaN(n)||e.min!==null&&n<e.min&&typeof e.min!="string"||e.max!==null&&n>e.max&&typeof e.max!="string")return !0}return !1}function al(e,t){let r=0,n=[],o=0;e:do{switch(e.type){case 24:case 22:case 20:if(e.type!==r)break e;if(r=n.pop(),n.length===0){o++;break e}break;case 2:case 21:case 19:case 23:n.push(r),r=Lr.get(e.type);break}o++;}while(e=t(o));return o}function ie(e){return function(t,r,n){return t===null?0:t.type===2&&zi(t.value,il)?al(t,r):e(t,r,n)}}function N(e){return function(t){return t===null||t.type!==e?0:1}}function sl(e){if(e===null||e.type!==1)return 0;let t=e.value.toLowerCase();return zi(t,Rt)||Ni(t,"default")?0:1}function ll(e){return e===null||e.type!==1||le(e.value,0)!==45||le(e.value,1)!==45?0:1}function cl(e){if(e===null||e.type!==4)return 0;let t=e.value.length;if(t!==4&&t!==5&&t!==7&&t!==9)return 0;for(let r=1;r<t;r++)if(!ee(le(e.value,r)))return 0;return 1}function ul(e){return e===null||e.type!==4||!ze(le(e.value,1),le(e.value,2),le(e.value,3))?0:1}function pl(e,t){if(!e)return 0;let r=0,n=[],o=0;e:do{switch(e.type){case 6:case 8:break e;case 24:case 22:case 20:if(e.type!==r)break e;r=n.pop();break;case 17:if(r===0)break e;break;case 9:if(r===0&&e.value==="!")break e;break;case 2:case 21:case 19:case 23:n.push(r),r=Lr.get(e.type);break}o++;}while(e=t(o));return o}function hl(e,t){if(!e)return 0;let r=0,n=[],o=0;e:do{switch(e.type){case 6:case 8:break e;case 24:case 22:case 20:if(e.type!==r)break e;r=n.pop();break;case 2:case 21:case 19:case 23:n.push(r),r=Lr.get(e.type);break}o++;}while(e=t(o));return o}function ye(e){return e&&(e=new Set(e)),function(t,r,n){if(t===null||t.type!==12)return 0;let o=Te(t.value,0);if(e!==null){let i=t.value.indexOf("\\",o),s=i===-1||!Mi(t.value,i)?t.value.substr(o):t.value.substring(o,i);if(e.has(s.toLowerCase())===!1)return 0}return Bt(n,t.value,o)?0:1}}function ml(e,t,r){return e===null||e.type!==11||Bt(r,e.value,e.value.length-1)?0:1}function Ri(e){return typeof e!="function"&&(e=function(){return 0}),function(t,r,n){return t!==null&&t.type===10&&Number(t.value)===0?1:e(t,r,n)}}function fl(e,t,r){if(e===null)return 0;let n=Te(e.value,0);return !(n===e.value.length)&&!Mi(e.value,n)||Bt(r,e.value,n)?0:1}function dl(e,t,r){if(e===null||e.type!==10)return 0;let n=le(e.value,0)===43||le(e.value,0)===45?1:0;for(;n<e.value.length;n++)if(!B(le(e.value,n)))return 0;return Bt(r,e.value,n)?0:1}var gl={"ident-token":N(1),"function-token":N(2),"at-keyword-token":N(3),"hash-token":N(4),"string-token":N(5),"bad-string-token":N(6),"url-token":N(7),"bad-url-token":N(8),"delim-token":N(9),"number-token":N(10),"percentage-token":N(11),"dimension-token":N(12),"whitespace-token":N(13),"CDO-token":N(14),"CDC-token":N(15),"colon-token":N(16),"semicolon-token":N(17),"comma-token":N(18),"[-token":N(19),"]-token":N(20),"(-token":N(21),")-token":N(22),"{-token":N(23),"}-token":N(24)},bl={string:N(5),ident:N(1),percentage:ie(ml),zero:Ri(),number:ie(fl),integer:ie(dl),"custom-ident":sl,"custom-property-name":ll,"hex-color":cl,"id-selector":ul,"an-plus-b":Ar,urange:Er,"declaration-value":pl,"any-value":hl};function xl(e){let{angle:t,decibel:r,frequency:n,flex:o,length:i,resolution:s,semitones:u,time:c}=e||{};return {dimension:ie(ye(null)),angle:ie(ye(t)),decibel:ie(ye(r)),frequency:ie(ye(n)),flex:ie(ye(o)),length:ie(Ri(ye(i))),resolution:ie(ye(s)),semitones:ie(ye(u)),time:ie(ye(c))}}function Fi(e){return {...gl,...bl,...xl(e)}}var _t={};b(_t,{angle:()=>kl,decibel:()=>Al,flex:()=>Cl,frequency:()=>vl,length:()=>yl,resolution:()=>Sl,semitones:()=>Tl,time:()=>wl});var yl=["cm","mm","q","in","pt","pc","px","em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh","vw","svw","lvw","dvw","vh","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","cqw","cqh","cqi","cqb","cqmin","cqmax"],kl=["deg","grad","rad","turn"],wl=["s","ms"],vl=["hz","khz"],Sl=["dpi","dpcm","dppx","x"],Cl=["fr"],Al=["db"],Tl=["st"];var $i={};b($i,{SyntaxError:()=>Ut,generate:()=>Pe,parse:()=>Ge,walk:()=>Vt});function Ut(e,t,r){return Object.assign(Ee("SyntaxError",e),{input:t,offset:r,rawMessage:e,message:e+`
  670. `+t+`
  671. --`+new Array((r||t.length)+1).join("-")+"^"})}var El=9,Ll=10,Pl=12,Il=13,Dl=32,jt=class{constructor(t){this.str=t,this.pos=0;}charCodeAt(t){return t<this.str.length?this.str.charCodeAt(t):0}charCode(){return this.charCodeAt(this.pos)}nextCharCode(){return this.charCodeAt(this.pos+1)}nextNonWsCode(t){return this.charCodeAt(this.findWsEnd(t))}findWsEnd(t){for(;t<this.str.length;t++){let r=this.str.charCodeAt(t);if(r!==Il&&r!==Ll&&r!==Pl&&r!==Dl&&r!==El)break}return t}substringToPos(t){return this.str.substring(this.pos,this.pos=t)}eat(t){this.charCode()!==t&&this.error("Expect `"+String.fromCharCode(t)+"`"),this.pos++;}peek(){return this.pos<this.str.length?this.str.charAt(this.pos++):""}error(t){throw new Ut(t,this.str,this.pos)}};var Ol=9,Nl=10,zl=12,Ml=13,Rl=32,Yi=33,Dr=35,Bi=38,qt=39,Gi=40,Fl=41,Vi=42,Or=43,Nr=44,_i=45,zr=60,Ki=62,Ir=63,Bl=64,Gt=91,Mr=93,Wt=123,Ui=124,ji=125,qi=8734,ut=new Uint8Array(128).map((e,t)=>/[a-zA-Z0-9\-]/.test(String.fromCharCode(t))?1:0),Wi={" ":1,"&&":2,"||":3,"|":4};function Ht(e){return e.substringToPos(e.findWsEnd(e.pos))}function He(e){let t=e.pos;for(;t<e.str.length;t++){let r=e.str.charCodeAt(t);if(r>=128||ut[r]===0)break}return e.pos===t&&e.error("Expect a keyword"),e.substringToPos(t)}function Yt(e){let t=e.pos;for(;t<e.str.length;t++){let r=e.str.charCodeAt(t);if(r<48||r>57)break}return e.pos===t&&e.error("Expect a number"),e.substringToPos(t)}function _l(e){let t=e.str.indexOf("'",e.pos+1);return t===-1&&(e.pos=e.str.length,e.error("Expect an apostrophe")),e.substringToPos(t+1)}function Hi(e){let t=null,r=null;return e.eat(Wt),t=Yt(e),e.charCode()===Nr?(e.pos++,e.charCode()!==ji&&(r=Yt(e))):r=t,e.eat(ji),{min:Number(t),max:r?Number(r):0}}function Ul(e){let t=null,r=!1;switch(e.charCode()){case Vi:e.pos++,t={min:0,max:0};break;case Or:e.pos++,t={min:1,max:0};break;case Ir:e.pos++,t={min:0,max:1};break;case Dr:e.pos++,r=!0,e.charCode()===Wt?t=Hi(e):e.charCode()===Ir?(e.pos++,t={min:0,max:0}):t={min:1,max:0};break;case Wt:t=Hi(e);break;default:return null}return {type:"Multiplier",comma:r,min:t.min,max:t.max,term:null}}function Ye(e,t){let r=Ul(e);return r!==null?(r.term=t,e.charCode()===Dr&&e.charCodeAt(e.pos-1)===Or?Ye(e,r):r):t}function Pr(e){let t=e.peek();return t===""?null:{type:"Token",value:t}}function jl(e){let t;return e.eat(zr),e.eat(qt),t=He(e),e.eat(qt),e.eat(Ki),Ye(e,{type:"Property",name:t})}function ql(e){let t=null,r=null,n=1;return e.eat(Gt),e.charCode()===_i&&(e.peek(),n=-1),n==-1&&e.charCode()===qi?e.peek():(t=n*Number(Yt(e)),ut[e.charCode()]!==0&&(t+=He(e))),Ht(e),e.eat(Nr),Ht(e),e.charCode()===qi?e.peek():(n=1,e.charCode()===_i&&(e.peek(),n=-1),r=n*Number(Yt(e)),ut[e.charCode()]!==0&&(r+=He(e))),e.eat(Mr),{type:"Range",min:t,max:r}}function Wl(e){let t,r=null;return e.eat(zr),t=He(e),e.charCode()===Gi&&e.nextCharCode()===Fl&&(e.pos+=2,t+="()"),e.charCodeAt(e.findWsEnd(e.pos))===Gt&&(Ht(e),r=ql(e)),e.eat(Ki),Ye(e,{type:"Type",name:t,opts:r})}function Hl(e){let t=He(e);return e.charCode()===Gi?(e.pos++,{type:"Function",name:t}):Ye(e,{type:"Keyword",name:t})}function Yl(e,t){function r(o,i){return {type:"Group",terms:o,combinator:i,disallowEmpty:!1,explicit:!1}}let n;for(t=Object.keys(t).sort((o,i)=>Wi[o]-Wi[i]);t.length>0;){n=t.shift();let o=0,i=0;for(;o<e.length;o++){let s=e[o];s.type==="Combinator"&&(s.value===n?(i===-1&&(i=o-1),e.splice(o,1),o--):(i!==-1&&o-i>1&&(e.splice(i,o-i,r(e.slice(i,o),n)),o=i+1),i=-1));}i!==-1&&t.length&&e.splice(i,o-i,r(e.slice(i,o),n));}return n}function Qi(e){let t=[],r={},n,o=null,i=e.pos;for(;n=Vl(e);)n.type!=="Spaces"&&(n.type==="Combinator"?((o===null||o.type==="Combinator")&&(e.pos=i,e.error("Unexpected combinator")),r[n.value]=!0):o!==null&&o.type!=="Combinator"&&(r[" "]=!0,t.push({type:"Combinator",value:" "})),t.push(n),o=n,i=e.pos);return o!==null&&o.type==="Combinator"&&(e.pos-=i,e.error("Unexpected combinator")),{type:"Group",terms:t,combinator:Yl(t,r)||" ",disallowEmpty:!1,explicit:!1}}function Gl(e){let t;return e.eat(Gt),t=Qi(e),e.eat(Mr),t.explicit=!0,e.charCode()===Yi&&(e.pos++,t.disallowEmpty=!0),t}function Vl(e){let t=e.charCode();if(t<128&&ut[t]===1)return Hl(e);switch(t){case Mr:break;case Gt:return Ye(e,Gl(e));case zr:return e.nextCharCode()===qt?jl(e):Wl(e);case Ui:return {type:"Combinator",value:e.substringToPos(e.pos+(e.nextCharCode()===Ui?2:1))};case Bi:return e.pos++,e.eat(Bi),{type:"Combinator",value:"&&"};case Nr:return e.pos++,{type:"Comma"};case qt:return Ye(e,{type:"String",value:_l(e)});case Rl:case Ol:case Nl:case Ml:case zl:return {type:"Spaces",value:Ht(e)};case Bl:return t=e.nextCharCode(),t<128&&ut[t]===1?(e.pos++,{type:"AtKeyword",name:He(e)}):Pr(e);case Vi:case Or:case Ir:case Dr:case Yi:break;case Wt:if(t=e.nextCharCode(),t<48||t>57)return Pr(e);break;default:return Pr(e)}}function Ge(e){let t=new jt(e),r=Qi(t);return t.pos!==e.length&&t.error("Unexpected input"),r.terms.length===1&&r.terms[0].type==="Group"?r.terms[0]:r}var pt=function(){};function Xi(e){return typeof e=="function"?e:pt}function Vt(e,t,r){function n(s){switch(o.call(r,s),s.type){case"Group":s.terms.forEach(n);break;case"Multiplier":n(s.term);break;case"Type":case"Property":case"Keyword":case"AtKeyword":case"Function":case"String":case"Token":case"Comma":break;default:throw new Error("Unknown type: "+s.type)}i.call(r,s);}let o=pt,i=pt;if(typeof t=="function"?o=t:t&&(o=Xi(t.enter),i=Xi(t.leave)),o===pt&&i===pt)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");n(e);}var Kl={decorator(e){let t=[],r=null;return {...e,node(n){let o=r;r=n,e.node.call(this,n),r=o;},emit(n,o,i){t.push({type:o,value:n,node:i?null:r});},result(){return t}}}};function Ql(e){let t=[];return ve(e,(r,n,o)=>t.push({type:r,value:e.slice(n,o),node:null})),t}function Zi(e,t){return typeof e=="string"?Ql(e):t.generate(e,Kl)}var C={type:"Match"},L={type:"Mismatch"},Kt={type:"DisallowEmpty"},Xl=40,$l=41;function Z(e,t,r){return t===C&&r===L||e===C&&t===C&&r===C?e:(e.type==="If"&&e.else===L&&t===C&&(t=e.then,e=e.match),{type:"If",match:e,then:t,else:r})}function ea(e){return e.length>2&&e.charCodeAt(e.length-2)===Xl&&e.charCodeAt(e.length-1)===$l}function Ji(e){return e.type==="Keyword"||e.type==="AtKeyword"||e.type==="Function"||e.type==="Type"&&ea(e.name)}function Rr(e,t,r){switch(e){case" ":{let n=C;for(let o=t.length-1;o>=0;o--){let i=t[o];n=Z(i,n,L);}return n}case"|":{let n=L,o=null;for(let i=t.length-1;i>=0;i--){let s=t[i];if(Ji(s)&&(o===null&&i>0&&Ji(t[i-1])&&(o=Object.create(null),n=Z({type:"Enum",map:o},C,n)),o!==null)){let u=(ea(s.name)?s.name.slice(0,-1):s.name).toLowerCase();if(!(u in o)){o[u]=s;continue}}o=null,n=Z(s,C,n);}return n}case"&&":{if(t.length>5)return {type:"MatchOnce",terms:t,all:!0};let n=L;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=Rr(e,t.filter(function(u){return u!==i}),!1):s=C,n=Z(i,s,n);}return n}case"||":{if(t.length>5)return {type:"MatchOnce",terms:t,all:!1};let n=r?C:L;for(let o=t.length-1;o>=0;o--){let i=t[o],s;t.length>1?s=Rr(e,t.filter(function(u){return u!==i}),!0):s=C,n=Z(i,s,n);}return n}}}function Zl(e){let t=C,r=Fr(e.term);if(e.max===0)r=Z(r,Kt,L),t=Z(r,null,L),t.then=Z(C,C,t),e.comma&&(t.then.else=Z({type:"Comma",syntax:e},t,L));else for(let n=e.min||1;n<=e.max;n++)e.comma&&t!==C&&(t=Z({type:"Comma",syntax:e},t,L)),t=Z(r,Z(C,C,t),L);if(e.min===0)t=Z(C,C,t);else for(let n=0;n<e.min-1;n++)e.comma&&t!==C&&(t=Z({type:"Comma",syntax:e},t,L)),t=Z(r,t,L);return t}function Fr(e){if(typeof e=="function")return {type:"Generic",fn:e};switch(e.type){case"Group":{let t=Rr(e.combinator,e.terms.map(Fr),!1);return e.disallowEmpty&&(t=Z(t,Kt,L)),t}case"Multiplier":return Zl(e);case"Type":case"Property":return {type:e.type,name:e.name,syntax:e};case"Keyword":return {type:e.type,name:e.name.toLowerCase(),syntax:e};case"AtKeyword":return {type:e.type,name:"@"+e.name.toLowerCase(),syntax:e};case"Function":return {type:e.type,name:e.name.toLowerCase()+"(",syntax:e};case"String":return e.value.length===3?{type:"Token",value:e.value.charAt(1),syntax:e}:{type:e.type,value:e.value.substr(1,e.value.length-2).replace(/\\'/g,"'"),syntax:e};case"Token":return {type:e.type,value:e.value,syntax:e};case"Comma":return {type:e.type,syntax:e};default:throw new Error("Unknown node type:",e.type)}}function Qt(e,t){return typeof e=="string"&&(e=Ge(e)),{type:"MatchGraph",match:Fr(e),syntax:t||null,source:e}}var {hasOwnProperty:ta}=Object.prototype,Jl=0,ec=1,_r=2,aa=3,ra="Match",tc="Mismatch",rc="Maximum iteration number exceeded (please fill an issue on https://github.com/csstree/csstree/issues)",na=15e3;function oc(e){let t=null,r=null,n=e;for(;n!==null;)r=n.prev,n.prev=t,t=n,n=r;return t}function Br(e,t){if(e.length!==t.length)return !1;for(let r=0;r<e.length;r++){let n=t.charCodeAt(r),o=e.charCodeAt(r);if(o>=65&&o<=90&&(o=o|32),o!==n)return !1}return !0}function ic(e){return e.type!==9?!1:e.value!=="?"}function oa(e){return e===null?!0:e.type===18||e.type===2||e.type===21||e.type===19||e.type===23||ic(e)}function ia(e){return e===null?!0:e.type===22||e.type===20||e.type===24||e.type===9&&e.value==="/"}function ac(e,t,r){function n(){do R++,S=R<e.length?e[R]:null;while(S!==null&&(S.type===13||S.type===25))}function o(ae){let fe=R+ae;return fe<e.length?e[fe]:null}function i(ae,fe){return {nextState:ae,matchStack:z,syntaxStack:p,thenStack:m,tokenIndex:R,prev:fe}}function s(ae){m={nextState:ae,matchStack:z,syntaxStack:p,prev:m};}function u(ae){f=i(ae,f);}function c(){z={type:ec,syntax:t.syntax,token:S,prev:z},n(),P=null,R>ke&&(ke=R);}function a(){p={syntax:t.syntax,opts:t.syntax.opts||p!==null&&p.opts||null,prev:p},z={type:_r,syntax:t.syntax,token:z.token,prev:z};}function l(){z.type===_r?z=z.prev:z={type:aa,syntax:p.syntax,token:z.token,prev:z},p=p.prev;}let p=null,m=null,f=null,P=null,te=0,X=null,S=null,R=-1,ke=0,z={type:Jl,syntax:null,token:null,prev:null};for(n();X===null&&++te<na;)switch(t.type){case"Match":if(m===null){if(S!==null&&(R!==e.length-1||S.value!=="\\0"&&S.value!=="\\9")){t=L;break}X=ra;break}if(t=m.nextState,t===Kt)if(m.matchStack===z){t=L;break}else t=C;for(;m.syntaxStack!==p;)l();m=m.prev;break;case"Mismatch":if(P!==null&&P!==!1)(f===null||R>f.tokenIndex)&&(f=P,P=!1);else if(f===null){X=tc;break}t=f.nextState,m=f.thenStack,p=f.syntaxStack,z=f.matchStack,R=f.tokenIndex,S=R<e.length?e[R]:null,f=f.prev;break;case"MatchGraph":t=t.match;break;case"If":t.else!==L&&u(t.else),t.then!==C&&s(t.then),t=t.match;break;case"MatchOnce":t={type:"MatchOnceBuffer",syntax:t,index:0,mask:0};break;case"MatchOnceBuffer":{let Q=t.syntax.terms;if(t.index===Q.length){if(t.mask===0||t.syntax.all){t=L;break}t=C;break}if(t.mask===(1<<Q.length)-1){t=C;break}for(;t.index<Q.length;t.index++){let J=1<<t.index;if((t.mask&J)===0){u(t),s({type:"AddMatchOnce",syntax:t.syntax,mask:t.mask|J}),t=Q[t.index++];break}}break}case"AddMatchOnce":t={type:"MatchOnceBuffer",syntax:t.syntax,index:0,mask:t.mask};break;case"Enum":if(S!==null){let Q=S.value.toLowerCase();if(Q.indexOf("\\")!==-1&&(Q=Q.replace(/\\[09].*$/,"")),ta.call(t.map,Q)){t=t.map[Q];break}}t=L;break;case"Generic":{let Q=p!==null?p.opts:null,J=R+Math.floor(t.fn(S,o,Q));if(!isNaN(J)&&J>R){for(;R<J;)c();t=C;}else t=L;break}case"Type":case"Property":{let Q=t.type==="Type"?"types":"properties",J=ta.call(r,Q)?r[Q][t.name]:null;if(!J||!J.match)throw new Error("Bad syntax reference: "+(t.type==="Type"?"<"+t.name+">":"<'"+t.name+"'>"));if(P!==!1&&S!==null&&t.type==="Type"&&(t.name==="custom-ident"&&S.type===1||t.name==="length"&&S.value==="0")){P===null&&(P=i(t,f)),t=L;break}a(),t=J.match;break}case"Keyword":{let Q=t.name;if(S!==null){let J=S.value;if(J.indexOf("\\")!==-1&&(J=J.replace(/\\[09].*$/,"")),Br(J,Q)){c(),t=C;break}}t=L;break}case"AtKeyword":case"Function":if(S!==null&&Br(S.value,t.name)){c(),t=C;break}t=L;break;case"Token":if(S!==null&&S.value===t.value){c(),t=C;break}t=L;break;case"Comma":S!==null&&S.type===18?oa(z.token)?t=L:(c(),t=ia(S)?L:C):t=oa(z.token)||ia(S)?C:L;break;case"String":let ae="",fe=R;for(;fe<e.length&&ae.length<t.value.length;fe++)ae+=e[fe].value;if(Br(ae,t.value)){for(;R<fe;)c();t=C;}else t=L;break;default:throw new Error("Unknown node type: "+t.type)}switch(X){case null:console.warn("[csstree-match] BREAK after "+na+" iterations"),X=rc,z=null;break;case ra:for(;p!==null;)l();break;default:z=null;}return {tokens:e,reason:X,iterations:te,match:z,longestMatch:ke}}function Ur(e,t,r){let n=ac(e,t,r||{});if(n.match===null)return n;let o=n.match,i=n.match={syntax:t.syntax||null,match:[]},s=[i];for(o=oc(o).prev;o!==null;){switch(o.type){case _r:i.match.push(i={syntax:o.syntax,match:[]}),s.push(i);break;case aa:s.pop(),i=s[s.length-1];break;default:i.match.push({syntax:o.syntax||null,token:o.token.value,node:o.token.node});}o=o.prev;}return n}var qr={};b(qr,{getTrace:()=>sa,isKeyword:()=>cc,isProperty:()=>lc,isType:()=>sc});function sa(e){function t(o){return o===null?!1:o.type==="Type"||o.type==="Property"||o.type==="Keyword"}function r(o){if(Array.isArray(o.match)){for(let i=0;i<o.match.length;i++)if(r(o.match[i]))return t(o.syntax)&&n.unshift(o.syntax),!0}else if(o.node===e)return n=t(o.syntax)?[o.syntax]:[],!0;return !1}let n=null;return this.matched!==null&&r(this.matched),n}function sc(e,t){return jr(this,e,r=>r.type==="Type"&&r.name===t)}function lc(e,t){return jr(this,e,r=>r.type==="Property"&&r.name===t)}function cc(e){return jr(this,e,t=>t.type==="Keyword")}function jr(e,t,r){let n=sa.call(e,t);return n===null?!1:n.some(r)}function la(e){return "node"in e?e.node:la(e.match[0])}function ca(e){return "node"in e?e.node:ca(e.match[e.match.length-1])}function Wr(e,t,r,n,o){function i(u){if(u.syntax!==null&&u.syntax.type===n&&u.syntax.name===o){let c=la(u),a=ca(u);e.syntax.walk(t,function(l,p,m){if(l===c){let f=new D;do{if(f.appendData(p.data),p.data===a)break;p=p.next;}while(p!==null);s.push({parent:m,nodes:f});}});}Array.isArray(u.match)&&u.match.forEach(i);}let s=[];return r.matched!==null&&i(r.matched),s}var{hasOwnProperty:ht}=Object.prototype;function Hr(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e&&e>=0}function ua(e){return Boolean(e)&&Hr(e.offset)&&Hr(e.line)&&Hr(e.column)}function uc(e,t){return function(n,o){if(!n||n.constructor!==Object)return o(n,"Type of node should be an Object");for(let i in n){let s=!0;if(ht.call(n,i)!==!1){if(i==="type")n.type!==e&&o(n,"Wrong node type `"+n.type+"`, expected `"+e+"`");else if(i==="loc"){if(n.loc===null)continue;if(n.loc&&n.loc.constructor===Object)if(typeof n.loc.source!="string")i+=".source";else if(!ua(n.loc.start))i+=".start";else if(!ua(n.loc.end))i+=".end";else continue;s=!1;}else if(t.hasOwnProperty(i)){s=!1;for(let u=0;!s&&u<t[i].length;u++){let c=t[i][u];switch(c){case String:s=typeof n[i]=="string";break;case Boolean:s=typeof n[i]=="boolean";break;case null:s=n[i]===null;break;default:typeof c=="string"?s=n[i]&&n[i].type===c:Array.isArray(c)&&(s=n[i]instanceof D);}}}else o(n,"Unknown field `"+i+"` for "+e+" node type");s||o(n,"Bad value for `"+e+"."+i+"`");}}for(let i in t)ht.call(t,i)&&ht.call(n,i)===!1&&o(n,"Field `"+e+"."+i+"` is missed");}}function pc(e,t){let r=t.structure,n={type:String,loc:!0},o={type:'"'+e+'"'};for(let i in r){if(ht.call(r,i)===!1)continue;let s=[],u=n[i]=Array.isArray(r[i])?r[i].slice():[r[i]];for(let c=0;c<u.length;c++){let a=u[c];if(a===String||a===Boolean)s.push(a.name);else if(a===null)s.push("null");else if(typeof a=="string")s.push("<"+a+">");else if(Array.isArray(a))s.push("List");else throw new Error("Wrong value `"+a+"` in `"+e+"."+i+"` structure definition")}o[i]=s.join(" | ");}return {docs:o,check:uc(e,n)}}function pa(e){let t={};if(e.node){for(let r in e.node)if(ht.call(e.node,r)){let n=e.node[r];if(n.structure)t[r]=pc(r,n);else throw new Error("Missed `structure` field in `"+r+"` node type definition")}}return t}var hc=Qt(Rt.join(" | "));function Yr(e,t,r){let n={};for(let o in e)e[o].syntax&&(n[o]=r?e[o].syntax:Pe(e[o].syntax,{compact:t}));return n}function mc(e,t,r){let n={};for(let[o,i]of Object.entries(e))n[o]={prelude:i.prelude&&(r?i.prelude.syntax:Pe(i.prelude.syntax,{compact:t})),descriptors:i.descriptors&&Yr(i.descriptors,t,r)};return n}function fc(e){for(let t=0;t<e.length;t++)if(e[t].value.toLowerCase()==="var(")return !0;return !1}function ce(e,t,r){return {matched:e,iterations:r,error:t,...qr}}function Ve(e,t,r,n){let o=Zi(r,e.syntax),i;return fc(o)?ce(null,new Error("Matching for a tree with var() is not supported")):(n&&(i=Ur(o,e.cssWideKeywordsSyntax,e)),(!n||!i.match)&&(i=Ur(o,t.match,e),!i.match)?ce(null,new Ii(i.reason,t.syntax,r,i),i.iterations):ce(i.match,null,i.iterations))}var Ke=class{constructor(t,r,n){if(this.cssWideKeywordsSyntax=hc,this.syntax=r,this.generic=!1,this.units={..._t},this.atrules=Object.create(null),this.properties=Object.create(null),this.types=Object.create(null),this.structure=n||pa(t),t){if(t.units)for(let o of Object.keys(_t))Array.isArray(t.units[o])&&(this.units[o]=t.units[o]);if(t.types)for(let o in t.types)this.addType_(o,t.types[o]);if(t.generic){this.generic=!0;for(let[o,i]of Object.entries(Fi(this.units)))this.addType_(o,i);}if(t.atrules)for(let o in t.atrules)this.addAtrule_(o,t.atrules[o]);if(t.properties)for(let o in t.properties)this.addProperty_(o,t.properties[o]);}}checkStructure(t){function r(i,s){o.push({node:i,message:s});}let n=this.structure,o=[];return this.syntax.walk(t,function(i){n.hasOwnProperty(i.type)?n[i.type].check(i,r):r(i,"Unknown node type `"+i.type+"`");}),o.length?o:!1}createDescriptor(t,r,n,o=null){let i={type:r,name:n},s={type:r,name:n,parent:o,serializable:typeof t=="string"||t&&typeof t.type=="string",syntax:null,match:null};return typeof t=="function"?s.match=Qt(t,i):(typeof t=="string"?Object.defineProperty(s,"syntax",{get(){return Object.defineProperty(s,"syntax",{value:Ge(t)}),s.syntax}}):s.syntax=t,Object.defineProperty(s,"match",{get(){return Object.defineProperty(s,"match",{value:Qt(s.syntax,i)}),s.match}})),s}addAtrule_(t,r){!r||(this.atrules[t]={type:"Atrule",name:t,prelude:r.prelude?this.createDescriptor(r.prelude,"AtrulePrelude",t):null,descriptors:r.descriptors?Object.keys(r.descriptors).reduce((n,o)=>(n[o]=this.createDescriptor(r.descriptors[o],"AtruleDescriptor",o,t),n),Object.create(null)):null});}addProperty_(t,r){!r||(this.properties[t]=this.createDescriptor(r,"Property",t));}addType_(t,r){!r||(this.types[t]=this.createDescriptor(r,"Type",t));}checkAtruleName(t){if(!this.getAtrule(t))return new je("Unknown at-rule","@"+t)}checkAtrulePrelude(t,r){let n=this.checkAtruleName(t);if(n)return n;let o=this.getAtrule(t);if(!o.prelude&&r)return new SyntaxError("At-rule `@"+t+"` should not contain a prelude");if(o.prelude&&!r&&!Ve(this,o.prelude,"",!1).matched)return new SyntaxError("At-rule `@"+t+"` should contain a prelude")}checkAtruleDescriptorName(t,r){let n=this.checkAtruleName(t);if(n)return n;let o=this.getAtrule(t),i=zt(r);if(!o.descriptors)return new SyntaxError("At-rule `@"+t+"` has no known descriptors");if(!o.descriptors[i.name]&&!o.descriptors[i.basename])return new je("Unknown at-rule descriptor",r)}checkPropertyName(t){if(!this.getProperty(t))return new je("Unknown property",t)}matchAtrulePrelude(t,r){let n=this.checkAtrulePrelude(t,r);if(n)return ce(null,n);let o=this.getAtrule(t);return o.prelude?Ve(this,o.prelude,r||"",!1):ce(null,null)}matchAtruleDescriptor(t,r,n){let o=this.checkAtruleDescriptorName(t,r);if(o)return ce(null,o);let i=this.getAtrule(t),s=zt(r);return Ve(this,i.descriptors[s.name]||i.descriptors[s.basename],n,!1)}matchDeclaration(t){return t.type!=="Declaration"?ce(null,new Error("Not a Declaration node")):this.matchProperty(t.property,t.value)}matchProperty(t,r){if(kr(t).custom)return ce(null,new Error("Lexer matching doesn't applicable for custom properties"));let n=this.checkPropertyName(t);return n?ce(null,n):Ve(this,this.getProperty(t),r,!0)}matchType(t,r){let n=this.getType(t);return n?Ve(this,n,r,!1):ce(null,new je("Unknown type",t))}match(t,r){return typeof t!="string"&&(!t||!t.type)?ce(null,new je("Bad syntax")):((typeof t=="string"||!t.match)&&(t=this.createDescriptor(t,"Type","anonymous")),Ve(this,t,r,!1))}findValueFragments(t,r,n,o){return Wr(this,r,this.matchProperty(t,r),n,o)}findDeclarationValueFragments(t,r,n){return Wr(this,t.value,this.matchDeclaration(t),r,n)}findAllFragments(t,r,n){let o=[];return this.syntax.walk(t,{visit:"Declaration",enter:i=>{o.push.apply(o,this.findDeclarationValueFragments(i,r,n));}}),o}getAtrule(t,r=!0){let n=zt(t);return (n.vendor&&r?this.atrules[n.name]||this.atrules[n.basename]:this.atrules[n.name])||null}getAtrulePrelude(t,r=!0){let n=this.getAtrule(t,r);return n&&n.prelude||null}getAtruleDescriptor(t,r){return this.atrules.hasOwnProperty(t)&&this.atrules.declarators&&this.atrules[t].declarators[r]||null}getProperty(t,r=!0){let n=kr(t);return (n.vendor&&r?this.properties[n.name]||this.properties[n.basename]:this.properties[n.name])||null}getType(t){return hasOwnProperty.call(this.types,t)?this.types[t]:null}validate(){function t(o,i,s,u){if(s.has(i))return s.get(i);s.set(i,!1),u.syntax!==null&&Vt(u.syntax,function(c){if(c.type!=="Type"&&c.type!=="Property")return;let a=c.type==="Type"?o.types:o.properties,l=c.type==="Type"?r:n;(!hasOwnProperty.call(a,c.name)||t(o,c.name,l,a[c.name]))&&s.set(i,!0);},this);}let r=new Map,n=new Map;for(let o in this.types)t(this,o,r,this.types[o]);for(let o in this.properties)t(this,o,n,this.properties[o]);return r=[...r.keys()].filter(o=>r.get(o)),n=[...n.keys()].filter(o=>n.get(o)),r.length||n.length?{types:r,properties:n}:null}dump(t,r){return {generic:this.generic,units:this.units,types:Yr(this.types,!r,t),properties:Yr(this.properties,!r,t),atrules:mc(this.atrules,!r,t)}}toString(){return JSON.stringify(this.dump())}};function Gr(e,t){return typeof t=="string"&&/^\s*\|/.test(t)?typeof e=="string"?e+t:t.replace(/^\s*\|\s*/,""):t||null}function ha(e,t){let r=Object.create(null);for(let[n,o]of Object.entries(e))if(o){r[n]={};for(let i of Object.keys(o))t.includes(i)&&(r[n][i]=o[i]);}return r}function mt(e,t){let r={...e};for(let[n,o]of Object.entries(t))switch(n){case"generic":r[n]=Boolean(o);break;case"units":r[n]={...e[n]};for(let[i,s]of Object.entries(o))r[n][i]=Array.isArray(s)?s:[];break;case"atrules":r[n]={...e[n]};for(let[i,s]of Object.entries(o)){let u=r[n][i]||{},c=r[n][i]={prelude:u.prelude||null,descriptors:{...u.descriptors}};if(!!s){c.prelude=s.prelude?Gr(c.prelude,s.prelude):c.prelude||null;for(let[a,l]of Object.entries(s.descriptors||{}))c.descriptors[a]=l?Gr(c.descriptors[a],l):null;Object.keys(c.descriptors).length||(c.descriptors=null);}}break;case"types":case"properties":r[n]={...e[n]};for(let[i,s]of Object.entries(o))r[n][i]=Gr(r[n][i],s);break;case"scope":r[n]={...e[n]};for(let[i,s]of Object.entries(o))r[n][i]={...r[n][i],...s};break;case"parseContext":r[n]={...e[n],...o};break;case"atrule":case"pseudo":r[n]={...e[n],...ha(o,["parse"])};break;case"node":r[n]={...e[n],...ha(o,["name","structure","parse","generate","walkContext"])};break}return r}function ma(e){let t=$o(e),r=Li(e),n=vi(e),{fromPlainObject:o,toPlainObject:i}=Si(r),s={lexer:null,createLexer:u=>new Ke(u,s,s.lexer.structure),tokenize:ve,parse:t,generate:n,walk:r,find:r.find,findLast:r.findLast,findAll:r.findAll,fromPlainObject:o,toPlainObject:i,fork(u){let c=mt({},e);return ma(typeof u=="function"?u(c,Object.assign):mt(c,u))}};return s.lexer=new Ke({generic:!0,units:e.units,types:e.types,atrules:e.atrules,properties:e.properties,node:e.node},s),s}var Vr=e=>ma(mt({},e));var fa={generic:!0,units:{angle:["deg","grad","rad","turn"],decibel:["db"],flex:["fr"],frequency:["hz","khz"],length:["cm","mm","q","in","pt","pc","px","em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh","vw","svw","lvw","dvw","vh","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","cqw","cqh","cqi","cqb","cqmin","cqmax"],resolution:["dpi","dpcm","dppx","x"],semitones:["st"],time:["s","ms"]},types:{"abs()":"abs( <calc-sum> )","absolute-size":"xx-small|x-small|small|medium|large|x-large|xx-large|xxx-large","acos()":"acos( <calc-sum> )","alpha-value":"<number>|<percentage>","angle-percentage":"<angle>|<percentage>","angular-color-hint":"<angle-percentage>","angular-color-stop":"<color>&&<color-stop-angle>?","angular-color-stop-list":"[<angular-color-stop> [, <angular-color-hint>]?]# , <angular-color-stop>","animateable-feature":"scroll-position|contents|<custom-ident>","asin()":"asin( <calc-sum> )","atan()":"atan( <calc-sum> )","atan2()":"atan2( <calc-sum> , <calc-sum> )",attachment:"scroll|fixed|local","attr()":"attr( <attr-name> <type-or-unit>? [, <attr-fallback>]? )","attr-matcher":"['~'|'|'|'^'|'$'|'*']? '='","attr-modifier":"i|s","attribute-selector":"'[' <wq-name> ']'|'[' <wq-name> <attr-matcher> [<string-token>|<ident-token>] <attr-modifier>? ']'","auto-repeat":"repeat( [auto-fill|auto-fit] , [<line-names>? <fixed-size>]+ <line-names>? )","auto-track-list":"[<line-names>? [<fixed-size>|<fixed-repeat>]]* <line-names>? <auto-repeat> [<line-names>? [<fixed-size>|<fixed-repeat>]]* <line-names>?",axis:"block|inline|vertical|horizontal","baseline-position":"[first|last]? baseline","basic-shape":"<inset()>|<circle()>|<ellipse()>|<polygon()>|<path()>","bg-image":"none|<image>","bg-layer":"<bg-image>||<bg-position> [/ <bg-size>]?||<repeat-style>||<attachment>||<box>||<box>","bg-position":"[[left|center|right|top|bottom|<length-percentage>]|[left|center|right|<length-percentage>] [top|center|bottom|<length-percentage>]|[center|[left|right] <length-percentage>?]&&[center|[top|bottom] <length-percentage>?]]","bg-size":"[<length-percentage>|auto]{1,2}|cover|contain","blur()":"blur( <length> )","blend-mode":"normal|multiply|screen|overlay|darken|lighten|color-dodge|color-burn|hard-light|soft-light|difference|exclusion|hue|saturation|color|luminosity",box:"border-box|padding-box|content-box","brightness()":"brightness( <number-percentage> )","calc()":"calc( <calc-sum> )","calc-sum":"<calc-product> [['+'|'-'] <calc-product>]*","calc-product":"<calc-value> ['*' <calc-value>|'/' <number>]*","calc-value":"<number>|<dimension>|<percentage>|<calc-constant>|( <calc-sum> )","calc-constant":"e|pi|infinity|-infinity|NaN","cf-final-image":"<image>|<color>","cf-mixing-image":"<percentage>?&&<image>","circle()":"circle( [<shape-radius>]? [at <position>]? )","clamp()":"clamp( <calc-sum>#{3} )","class-selector":"'.' <ident-token>","clip-source":"<url>",color:"<rgb()>|<rgba()>|<hsl()>|<hsla()>|<hwb()>|<lab()>|<lch()>|<hex-color>|<named-color>|currentcolor|<deprecated-system-color>","color-stop":"<color-stop-length>|<color-stop-angle>","color-stop-angle":"<angle-percentage>{1,2}","color-stop-length":"<length-percentage>{1,2}","color-stop-list":"[<linear-color-stop> [, <linear-color-hint>]?]# , <linear-color-stop>",combinator:"'>'|'+'|'~'|['||']","common-lig-values":"[common-ligatures|no-common-ligatures]","compat-auto":"searchfield|textarea|push-button|slider-horizontal|checkbox|radio|square-button|menulist|listbox|meter|progress-bar|button","composite-style":"clear|copy|source-over|source-in|source-out|source-atop|destination-over|destination-in|destination-out|destination-atop|xor","compositing-operator":"add|subtract|intersect|exclude","compound-selector":"[<type-selector>? <subclass-selector>* [<pseudo-element-selector> <pseudo-class-selector>*]*]!","compound-selector-list":"<compound-selector>#","complex-selector":"<compound-selector> [<combinator>? <compound-selector>]*","complex-selector-list":"<complex-selector>#","conic-gradient()":"conic-gradient( [from <angle>]? [at <position>]? , <angular-color-stop-list> )","contextual-alt-values":"[contextual|no-contextual]","content-distribution":"space-between|space-around|space-evenly|stretch","content-list":"[<string>|contents|<image>|<counter>|<quote>|<target>|<leader()>|<attr()>]+","content-position":"center|start|end|flex-start|flex-end","content-replacement":"<image>","contrast()":"contrast( [<number-percentage>] )","cos()":"cos( <calc-sum> )",counter:"<counter()>|<counters()>","counter()":"counter( <counter-name> , <counter-style>? )","counter-name":"<custom-ident>","counter-style":"<counter-style-name>|symbols( )","counter-style-name":"<custom-ident>","counters()":"counters( <counter-name> , <string> , <counter-style>? )","cross-fade()":"cross-fade( <cf-mixing-image> , <cf-final-image>? )","cubic-bezier-timing-function":"ease|ease-in|ease-out|ease-in-out|cubic-bezier( <number [0,1]> , <number> , <number [0,1]> , <number> )","deprecated-system-color":"ActiveBorder|ActiveCaption|AppWorkspace|Background|ButtonFace|ButtonHighlight|ButtonShadow|ButtonText|CaptionText|GrayText|Highlight|HighlightText|InactiveBorder|InactiveCaption|InactiveCaptionText|InfoBackground|InfoText|Menu|MenuText|Scrollbar|ThreeDDarkShadow|ThreeDFace|ThreeDHighlight|ThreeDLightShadow|ThreeDShadow|Window|WindowFrame|WindowText","discretionary-lig-values":"[discretionary-ligatures|no-discretionary-ligatures]","display-box":"contents|none","display-inside":"flow|flow-root|table|flex|grid|ruby","display-internal":"table-row-group|table-header-group|table-footer-group|table-row|table-cell|table-column-group|table-column|table-caption|ruby-base|ruby-text|ruby-base-container|ruby-text-container","display-legacy":"inline-block|inline-list-item|inline-table|inline-flex|inline-grid","display-listitem":"<display-outside>?&&[flow|flow-root]?&&list-item","display-outside":"block|inline|run-in","drop-shadow()":"drop-shadow( <length>{2,3} <color>? )","east-asian-variant-values":"[jis78|jis83|jis90|jis04|simplified|traditional]","east-asian-width-values":"[full-width|proportional-width]","element()":"element( <custom-ident> , [first|start|last|first-except]? )|element( <id-selector> )","ellipse()":"ellipse( [<shape-radius>{2}]? [at <position>]? )","ending-shape":"circle|ellipse","env()":"env( <custom-ident> , <declaration-value>? )","exp()":"exp( <calc-sum> )","explicit-track-list":"[<line-names>? <track-size>]+ <line-names>?","family-name":"<string>|<custom-ident>+","feature-tag-value":"<string> [<integer>|on|off]?","feature-type":"@stylistic|@historical-forms|@styleset|@character-variant|@swash|@ornaments|@annotation","feature-value-block":"<feature-type> '{' <feature-value-declaration-list> '}'","feature-value-block-list":"<feature-value-block>+","feature-value-declaration":"<custom-ident> : <integer>+ ;","feature-value-declaration-list":"<feature-value-declaration>","feature-value-name":"<custom-ident>","fill-rule":"nonzero|evenodd","filter-function":"<blur()>|<brightness()>|<contrast()>|<drop-shadow()>|<grayscale()>|<hue-rotate()>|<invert()>|<opacity()>|<saturate()>|<sepia()>","filter-function-list":"[<filter-function>|<url>]+","final-bg-layer":"<'background-color'>||<bg-image>||<bg-position> [/ <bg-size>]?||<repeat-style>||<attachment>||<box>||<box>","fixed-breadth":"<length-percentage>","fixed-repeat":"repeat( [<integer [1,\u221E]>] , [<line-names>? <fixed-size>]+ <line-names>? )","fixed-size":"<fixed-breadth>|minmax( <fixed-breadth> , <track-breadth> )|minmax( <inflexible-breadth> , <fixed-breadth> )","font-stretch-absolute":"normal|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded|<percentage>","font-variant-css21":"[normal|small-caps]","font-weight-absolute":"normal|bold|<number [1,1000]>","frequency-percentage":"<frequency>|<percentage>","general-enclosed":"[<function-token> <any-value> )]|( <ident> <any-value> )","generic-family":"serif|sans-serif|cursive|fantasy|monospace|-apple-system","generic-name":"serif|sans-serif|cursive|fantasy|monospace","geometry-box":"<shape-box>|fill-box|stroke-box|view-box",gradient:"<linear-gradient()>|<repeating-linear-gradient()>|<radial-gradient()>|<repeating-radial-gradient()>|<conic-gradient()>|<repeating-conic-gradient()>|<-legacy-gradient>","grayscale()":"grayscale( <number-percentage> )","grid-line":"auto|<custom-ident>|[<integer>&&<custom-ident>?]|[span&&[<integer>||<custom-ident>]]","historical-lig-values":"[historical-ligatures|no-historical-ligatures]","hsl()":"hsl( <hue> <percentage> <percentage> [/ <alpha-value>]? )|hsl( <hue> , <percentage> , <percentage> , <alpha-value>? )","hsla()":"hsla( <hue> <percentage> <percentage> [/ <alpha-value>]? )|hsla( <hue> , <percentage> , <percentage> , <alpha-value>? )",hue:"<number>|<angle>","hue-rotate()":"hue-rotate( <angle> )","hwb()":"hwb( [<hue>|none] [<percentage>|none] [<percentage>|none] [/ [<alpha-value>|none]]? )","hypot()":"hypot( <calc-sum># )",image:"<url>|<image()>|<image-set()>|<element()>|<paint()>|<cross-fade()>|<gradient>","image()":"image( <image-tags>? [<image-src>? , <color>?]! )","image-set()":"image-set( <image-set-option># )","image-set-option":"[<image>|<string>] [<resolution>||type( <string> )]","image-src":"<url>|<string>","image-tags":"ltr|rtl","inflexible-breadth":"<length-percentage>|min-content|max-content|auto","inset()":"inset( <length-percentage>{1,4} [round <'border-radius'>]? )","invert()":"invert( <number-percentage> )","keyframes-name":"<custom-ident>|<string>","keyframe-block":"<keyframe-selector># { <declaration-list> }","keyframe-block-list":"<keyframe-block>+","keyframe-selector":"from|to|<percentage>","lab()":"lab( [<percentage>|<number>|none] [<percentage>|<number>|none] [<percentage>|<number>|none] [/ [<alpha-value>|none]]? )","layer()":"layer( <layer-name> )","layer-name":"<ident> ['.' <ident>]*","lch()":"lch( [<percentage>|<number>|none] [<percentage>|<number>|none] [<hue>|none] [/ [<alpha-value>|none]]? )","leader()":"leader( <leader-type> )","leader-type":"dotted|solid|space|<string>","length-percentage":"<length>|<percentage>","line-names":"'[' <custom-ident>* ']'","line-name-list":"[<line-names>|<name-repeat>]+","line-style":"none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset","line-width":"<length>|thin|medium|thick","linear-color-hint":"<length-percentage>","linear-color-stop":"<color> <color-stop-length>?","linear-gradient()":"linear-gradient( [<angle>|to <side-or-corner>]? , <color-stop-list> )","log()":"log( <calc-sum> , <calc-sum>? )","mask-layer":"<mask-reference>||<position> [/ <bg-size>]?||<repeat-style>||<geometry-box>||[<geometry-box>|no-clip]||<compositing-operator>||<masking-mode>","mask-position":"[<length-percentage>|left|center|right] [<length-percentage>|top|center|bottom]?","mask-reference":"none|<image>|<mask-source>","mask-source":"<url>","masking-mode":"alpha|luminance|match-source","matrix()":"matrix( <number>#{6} )","matrix3d()":"matrix3d( <number>#{16} )","max()":"max( <calc-sum># )","media-and":"<media-in-parens> [and <media-in-parens>]+","media-condition":"<media-not>|<media-and>|<media-or>|<media-in-parens>","media-condition-without-or":"<media-not>|<media-and>|<media-in-parens>","media-feature":"( [<mf-plain>|<mf-boolean>|<mf-range>] )","media-in-parens":"( <media-condition> )|<media-feature>|<general-enclosed>","media-not":"not <media-in-parens>","media-or":"<media-in-parens> [or <media-in-parens>]+","media-query":"<media-condition>|[not|only]? <media-type> [and <media-condition-without-or>]?","media-query-list":"<media-query>#","media-type":"<ident>","mf-boolean":"<mf-name>","mf-name":"<ident>","mf-plain":"<mf-name> : <mf-value>","mf-range":"<mf-name> ['<'|'>']? '='? <mf-value>|<mf-value> ['<'|'>']? '='? <mf-name>|<mf-value> '<' '='? <mf-name> '<' '='? <mf-value>|<mf-value> '>' '='? <mf-name> '>' '='? <mf-value>","mf-value":"<number>|<dimension>|<ident>|<ratio>","min()":"min( <calc-sum># )","minmax()":"minmax( [<length-percentage>|min-content|max-content|auto] , [<length-percentage>|<flex>|min-content|max-content|auto] )","mod()":"mod( <calc-sum> , <calc-sum> )","name-repeat":"repeat( [<integer [1,\u221E]>|auto-fill] , <line-names>+ )","named-color":"transparent|aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen|<-non-standard-color>","namespace-prefix":"<ident>","ns-prefix":"[<ident-token>|'*']? '|'","number-percentage":"<number>|<percentage>","numeric-figure-values":"[lining-nums|oldstyle-nums]","numeric-fraction-values":"[diagonal-fractions|stacked-fractions]","numeric-spacing-values":"[proportional-nums|tabular-nums]",nth:"<an-plus-b>|even|odd","opacity()":"opacity( [<number-percentage>] )","overflow-position":"unsafe|safe","outline-radius":"<length>|<percentage>","page-body":"<declaration>? [; <page-body>]?|<page-margin-box> <page-body>","page-margin-box":"<page-margin-box-type> '{' <declaration-list> '}'","page-margin-box-type":"@top-left-corner|@top-left|@top-center|@top-right|@top-right-corner|@bottom-left-corner|@bottom-left|@bottom-center|@bottom-right|@bottom-right-corner|@left-top|@left-middle|@left-bottom|@right-top|@right-middle|@right-bottom","page-selector-list":"[<page-selector>#]?","page-selector":"<pseudo-page>+|<ident> <pseudo-page>*","page-size":"A5|A4|A3|B5|B4|JIS-B5|JIS-B4|letter|legal|ledger","path()":"path( [<fill-rule> ,]? <string> )","paint()":"paint( <ident> , <declaration-value>? )","perspective()":"perspective( [<length [0,\u221E]>|none] )","polygon()":"polygon( <fill-rule>? , [<length-percentage> <length-percentage>]# )",position:"[[left|center|right]||[top|center|bottom]|[left|center|right|<length-percentage>] [top|center|bottom|<length-percentage>]?|[[left|right] <length-percentage>]&&[[top|bottom] <length-percentage>]]","pow()":"pow( <calc-sum> , <calc-sum> )","pseudo-class-selector":"':' <ident-token>|':' <function-token> <any-value> ')'","pseudo-element-selector":"':' <pseudo-class-selector>","pseudo-page":": [left|right|first|blank]",quote:"open-quote|close-quote|no-open-quote|no-close-quote","radial-gradient()":"radial-gradient( [<ending-shape>||<size>]? [at <position>]? , <color-stop-list> )",ratio:"<number [0,\u221E]> [/ <number [0,\u221E]>]?","relative-selector":"<combinator>? <complex-selector>","relative-selector-list":"<relative-selector>#","relative-size":"larger|smaller","rem()":"rem( <calc-sum> , <calc-sum> )","repeat-style":"repeat-x|repeat-y|[repeat|space|round|no-repeat]{1,2}","repeating-conic-gradient()":"repeating-conic-gradient( [from <angle>]? [at <position>]? , <angular-color-stop-list> )","repeating-linear-gradient()":"repeating-linear-gradient( [<angle>|to <side-or-corner>]? , <color-stop-list> )","repeating-radial-gradient()":"repeating-radial-gradient( [<ending-shape>||<size>]? [at <position>]? , <color-stop-list> )","reversed-counter-name":"reversed( <counter-name> )","rgb()":"rgb( <percentage>{3} [/ <alpha-value>]? )|rgb( <number>{3} [/ <alpha-value>]? )|rgb( <percentage>#{3} , <alpha-value>? )|rgb( <number>#{3} , <alpha-value>? )","rgba()":"rgba( <percentage>{3} [/ <alpha-value>]? )|rgba( <number>{3} [/ <alpha-value>]? )|rgba( <percentage>#{3} , <alpha-value>? )|rgba( <number>#{3} , <alpha-value>? )","rotate()":"rotate( [<angle>|<zero>] )","rotate3d()":"rotate3d( <number> , <number> , <number> , [<angle>|<zero>] )","rotateX()":"rotateX( [<angle>|<zero>] )","rotateY()":"rotateY( [<angle>|<zero>] )","rotateZ()":"rotateZ( [<angle>|<zero>] )","round()":"round( <rounding-strategy>? , <calc-sum> , <calc-sum> )","rounding-strategy":"nearest|up|down|to-zero","saturate()":"saturate( <number-percentage> )","scale()":"scale( [<number>|<percentage>]#{1,2} )","scale3d()":"scale3d( [<number>|<percentage>]#{3} )","scaleX()":"scaleX( [<number>|<percentage>] )","scaleY()":"scaleY( [<number>|<percentage>] )","scaleZ()":"scaleZ( [<number>|<percentage>] )",scroller:"root|nearest","self-position":"center|start|end|self-start|self-end|flex-start|flex-end","shape-radius":"<length-percentage>|closest-side|farthest-side","sign()":"sign( <calc-sum> )","skew()":"skew( [<angle>|<zero>] , [<angle>|<zero>]? )","skewX()":"skewX( [<angle>|<zero>] )","skewY()":"skewY( [<angle>|<zero>] )","sepia()":"sepia( <number-percentage> )",shadow:"inset?&&<length>{2,4}&&<color>?","shadow-t":"[<length>{2,3}&&<color>?]",shape:"rect( <top> , <right> , <bottom> , <left> )|rect( <top> <right> <bottom> <left> )","shape-box":"<box>|margin-box","side-or-corner":"[left|right]||[top|bottom]","sin()":"sin( <calc-sum> )","single-animation":"<time>||<easing-function>||<time>||<single-animation-iteration-count>||<single-animation-direction>||<single-animation-fill-mode>||<single-animation-play-state>||[none|<keyframes-name>]","single-animation-direction":"normal|reverse|alternate|alternate-reverse","single-animation-fill-mode":"none|forwards|backwards|both","single-animation-iteration-count":"infinite|<number>","single-animation-play-state":"running|paused","single-animation-timeline":"auto|none|<timeline-name>|scroll( <axis>? <scroller>? )","single-transition":"[none|<single-transition-property>]||<time>||<easing-function>||<time>","single-transition-property":"all|<custom-ident>",size:"closest-side|farthest-side|closest-corner|farthest-corner|<length>|<length-percentage>{2}","sqrt()":"sqrt( <calc-sum> )","step-position":"jump-start|jump-end|jump-none|jump-both|start|end","step-timing-function":"step-start|step-end|steps( <integer> [, <step-position>]? )","subclass-selector":"<id-selector>|<class-selector>|<attribute-selector>|<pseudo-class-selector>","supports-condition":"not <supports-in-parens>|<supports-in-parens> [and <supports-in-parens>]*|<supports-in-parens> [or <supports-in-parens>]*","supports-in-parens":"( <supports-condition> )|<supports-feature>|<general-enclosed>","supports-feature":"<supports-decl>|<supports-selector-fn>","supports-decl":"( <declaration> )","supports-selector-fn":"selector( <complex-selector> )",symbol:"<string>|<image>|<custom-ident>","tan()":"tan( <calc-sum> )",target:"<target-counter()>|<target-counters()>|<target-text()>","target-counter()":"target-counter( [<string>|<url>] , <custom-ident> , <counter-style>? )","target-counters()":"target-counters( [<string>|<url>] , <custom-ident> , <string> , <counter-style>? )","target-text()":"target-text( [<string>|<url>] , [content|before|after|first-letter]? )","time-percentage":"<time>|<percentage>","timeline-name":"<custom-ident>|<string>","easing-function":"linear|<cubic-bezier-timing-function>|<step-timing-function>","track-breadth":"<length-percentage>|<flex>|min-content|max-content|auto","track-list":"[<line-names>? [<track-size>|<track-repeat>]]+ <line-names>?","track-repeat":"repeat( [<integer [1,\u221E]>] , [<line-names>? <track-size>]+ <line-names>? )","track-size":"<track-breadth>|minmax( <inflexible-breadth> , <track-breadth> )|fit-content( <length-percentage> )","transform-function":"<matrix()>|<translate()>|<translateX()>|<translateY()>|<scale()>|<scaleX()>|<scaleY()>|<rotate()>|<skew()>|<skewX()>|<skewY()>|<matrix3d()>|<translate3d()>|<translateZ()>|<scale3d()>|<scaleZ()>|<rotate3d()>|<rotateX()>|<rotateY()>|<rotateZ()>|<perspective()>","transform-list":"<transform-function>+","translate()":"translate( <length-percentage> , <length-percentage>? )","translate3d()":"translate3d( <length-percentage> , <length-percentage> , <length> )","translateX()":"translateX( <length-percentage> )","translateY()":"translateY( <length-percentage> )","translateZ()":"translateZ( <length> )","type-or-unit":"string|color|url|integer|number|length|angle|time|frequency|cap|ch|em|ex|ic|lh|rlh|rem|vb|vi|vw|vh|vmin|vmax|mm|Q|cm|in|pt|pc|px|deg|grad|rad|turn|ms|s|Hz|kHz|%","type-selector":"<wq-name>|<ns-prefix>? '*'","var()":"var( <custom-property-name> , <declaration-value>? )","viewport-length":"auto|<length-percentage>","visual-box":"content-box|padding-box|border-box","wq-name":"<ns-prefix>? <ident-token>","-legacy-gradient":"<-webkit-gradient()>|<-legacy-linear-gradient>|<-legacy-repeating-linear-gradient>|<-legacy-radial-gradient>|<-legacy-repeating-radial-gradient>","-legacy-linear-gradient":"-moz-linear-gradient( <-legacy-linear-gradient-arguments> )|-webkit-linear-gradient( <-legacy-linear-gradient-arguments> )|-o-linear-gradient( <-legacy-linear-gradient-arguments> )","-legacy-repeating-linear-gradient":"-moz-repeating-linear-gradient( <-legacy-linear-gradient-arguments> )|-webkit-repeating-linear-gradient( <-legacy-linear-gradient-arguments> )|-o-repeating-linear-gradient( <-legacy-linear-gradient-arguments> )","-legacy-linear-gradient-arguments":"[<angle>|<side-or-corner>]? , <color-stop-list>","-legacy-radial-gradient":"-moz-radial-gradient( <-legacy-radial-gradient-arguments> )|-webkit-radial-gradient( <-legacy-radial-gradient-arguments> )|-o-radial-gradient( <-legacy-radial-gradient-arguments> )","-legacy-repeating-radial-gradient":"-moz-repeating-radial-gradient( <-legacy-radial-gradient-arguments> )|-webkit-repeating-radial-gradient( <-legacy-radial-gradient-arguments> )|-o-repeating-radial-gradient( <-legacy-radial-gradient-arguments> )","-legacy-radial-gradient-arguments":"[<position> ,]? [[[<-legacy-radial-gradient-shape>||<-legacy-radial-gradient-size>]|[<length>|<percentage>]{2}] ,]? <color-stop-list>","-legacy-radial-gradient-size":"closest-side|closest-corner|farthest-side|farthest-corner|contain|cover","-legacy-radial-gradient-shape":"circle|ellipse","-non-standard-font":"-apple-system-body|-apple-system-headline|-apple-system-subheadline|-apple-system-caption1|-apple-system-caption2|-apple-system-footnote|-apple-system-short-body|-apple-system-short-headline|-apple-system-short-subheadline|-apple-system-short-caption1|-apple-system-short-footnote|-apple-system-tall-body","-non-standard-color":"-moz-ButtonDefault|-moz-ButtonHoverFace|-moz-ButtonHoverText|-moz-CellHighlight|-moz-CellHighlightText|-moz-Combobox|-moz-ComboboxText|-moz-Dialog|-moz-DialogText|-moz-dragtargetzone|-moz-EvenTreeRow|-moz-Field|-moz-FieldText|-moz-html-CellHighlight|-moz-html-CellHighlightText|-moz-mac-accentdarkestshadow|-moz-mac-accentdarkshadow|-moz-mac-accentface|-moz-mac-accentlightesthighlight|-moz-mac-accentlightshadow|-moz-mac-accentregularhighlight|-moz-mac-accentregularshadow|-moz-mac-chrome-active|-moz-mac-chrome-inactive|-moz-mac-focusring|-moz-mac-menuselect|-moz-mac-menushadow|-moz-mac-menutextselect|-moz-MenuHover|-moz-MenuHoverText|-moz-MenuBarText|-moz-MenuBarHoverText|-moz-nativehyperlinktext|-moz-OddTreeRow|-moz-win-communicationstext|-moz-win-mediatext|-moz-activehyperlinktext|-moz-default-background-color|-moz-default-color|-moz-hyperlinktext|-moz-visitedhyperlinktext|-webkit-activelink|-webkit-focus-ring-color|-webkit-link|-webkit-text","-non-standard-image-rendering":"optimize-contrast|-moz-crisp-edges|-o-crisp-edges|-webkit-optimize-contrast","-non-standard-overflow":"-moz-scrollbars-none|-moz-scrollbars-horizontal|-moz-scrollbars-vertical|-moz-hidden-unscrollable","-non-standard-width":"fill-available|min-intrinsic|intrinsic|-moz-available|-moz-fit-content|-moz-min-content|-moz-max-content|-webkit-min-content|-webkit-max-content","-webkit-gradient()":"-webkit-gradient( <-webkit-gradient-type> , <-webkit-gradient-point> [, <-webkit-gradient-point>|, <-webkit-gradient-radius> , <-webkit-gradient-point>] [, <-webkit-gradient-radius>]? [, <-webkit-gradient-color-stop>]* )","-webkit-gradient-color-stop":"from( <color> )|color-stop( [<number-zero-one>|<percentage>] , <color> )|to( <color> )","-webkit-gradient-point":"[left|center|right|<length-percentage>] [top|center|bottom|<length-percentage>]","-webkit-gradient-radius":"<length>|<percentage>","-webkit-gradient-type":"linear|radial","-webkit-mask-box-repeat":"repeat|stretch|round","-webkit-mask-clip-style":"border|border-box|padding|padding-box|content|content-box|text","-ms-filter-function-list":"<-ms-filter-function>+","-ms-filter-function":"<-ms-filter-function-progid>|<-ms-filter-function-legacy>","-ms-filter-function-progid":"'progid:' [<ident-token> '.']* [<ident-token>|<function-token> <any-value>? )]","-ms-filter-function-legacy":"<ident-token>|<function-token> <any-value>? )","-ms-filter":"<string>",age:"child|young|old","attr-name":"<wq-name>","attr-fallback":"<any-value>","bg-clip":"<box>|border|text",bottom:"<length>|auto","generic-voice":"[<age>? <gender> <integer>?]",gender:"male|female|neutral",left:"<length>|auto","mask-image":"<mask-reference>#",paint:"none|<color>|<url> [none|<color>]?|context-fill|context-stroke",right:"<length>|auto","single-animation-composition":"replace|add|accumulate","svg-length":"<percentage>|<length>|<number>","svg-writing-mode":"lr-tb|rl-tb|tb-rl|lr|rl|tb",top:"<length>|auto",x:"<number>",y:"<number>",declaration:"<ident-token> : <declaration-value>? ['!' important]?","declaration-list":"[<declaration>? ';']* <declaration>?",url:"url( <string> <url-modifier>* )|<url-token>","url-modifier":"<ident>|<function-token> <any-value> )","number-zero-one":"<number [0,1]>","number-one-or-greater":"<number [1,\u221E]>","-non-standard-display":"-ms-inline-flexbox|-ms-grid|-ms-inline-grid|-webkit-flex|-webkit-inline-flex|-webkit-box|-webkit-inline-box|-moz-inline-stack|-moz-box|-moz-inline-box"},properties:{"--*":"<declaration-value>","-ms-accelerator":"false|true","-ms-block-progression":"tb|rl|bt|lr","-ms-content-zoom-chaining":"none|chained","-ms-content-zooming":"none|zoom","-ms-content-zoom-limit":"<'-ms-content-zoom-limit-min'> <'-ms-content-zoom-limit-max'>","-ms-content-zoom-limit-max":"<percentage>","-ms-content-zoom-limit-min":"<percentage>","-ms-content-zoom-snap":"<'-ms-content-zoom-snap-type'>||<'-ms-content-zoom-snap-points'>","-ms-content-zoom-snap-points":"snapInterval( <percentage> , <percentage> )|snapList( <percentage># )","-ms-content-zoom-snap-type":"none|proximity|mandatory","-ms-filter":"<string>","-ms-flow-from":"[none|<custom-ident>]#","-ms-flow-into":"[none|<custom-ident>]#","-ms-grid-columns":"none|<track-list>|<auto-track-list>","-ms-grid-rows":"none|<track-list>|<auto-track-list>","-ms-high-contrast-adjust":"auto|none","-ms-hyphenate-limit-chars":"auto|<integer>{1,3}","-ms-hyphenate-limit-lines":"no-limit|<integer>","-ms-hyphenate-limit-zone":"<percentage>|<length>","-ms-ime-align":"auto|after","-ms-overflow-style":"auto|none|scrollbar|-ms-autohiding-scrollbar","-ms-scrollbar-3dlight-color":"<color>","-ms-scrollbar-arrow-color":"<color>","-ms-scrollbar-base-color":"<color>","-ms-scrollbar-darkshadow-color":"<color>","-ms-scrollbar-face-color":"<color>","-ms-scrollbar-highlight-color":"<color>","-ms-scrollbar-shadow-color":"<color>","-ms-scrollbar-track-color":"<color>","-ms-scroll-chaining":"chained|none","-ms-scroll-limit":"<'-ms-scroll-limit-x-min'> <'-ms-scroll-limit-y-min'> <'-ms-scroll-limit-x-max'> <'-ms-scroll-limit-y-max'>","-ms-scroll-limit-x-max":"auto|<length>","-ms-scroll-limit-x-min":"<length>","-ms-scroll-limit-y-max":"auto|<length>","-ms-scroll-limit-y-min":"<length>","-ms-scroll-rails":"none|railed","-ms-scroll-snap-points-x":"snapInterval( <length-percentage> , <length-percentage> )|snapList( <length-percentage># )","-ms-scroll-snap-points-y":"snapInterval( <length-percentage> , <length-percentage> )|snapList( <length-percentage># )","-ms-scroll-snap-type":"none|proximity|mandatory","-ms-scroll-snap-x":"<'-ms-scroll-snap-type'> <'-ms-scroll-snap-points-x'>","-ms-scroll-snap-y":"<'-ms-scroll-snap-type'> <'-ms-scroll-snap-points-y'>","-ms-scroll-translation":"none|vertical-to-horizontal","-ms-text-autospace":"none|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space","-ms-touch-select":"grippers|none","-ms-user-select":"none|element|text","-ms-wrap-flow":"auto|both|start|end|maximum|clear","-ms-wrap-margin":"<length>","-ms-wrap-through":"wrap|none","-moz-appearance":"none|button|button-arrow-down|button-arrow-next|button-arrow-previous|button-arrow-up|button-bevel|button-focus|caret|checkbox|checkbox-container|checkbox-label|checkmenuitem|dualbutton|groupbox|listbox|listitem|menuarrow|menubar|menucheckbox|menuimage|menuitem|menuitemtext|menulist|menulist-button|menulist-text|menulist-textfield|menupopup|menuradio|menuseparator|meterbar|meterchunk|progressbar|progressbar-vertical|progresschunk|progresschunk-vertical|radio|radio-container|radio-label|radiomenuitem|range|range-thumb|resizer|resizerpanel|scale-horizontal|scalethumbend|scalethumb-horizontal|scalethumbstart|scalethumbtick|scalethumb-vertical|scale-vertical|scrollbarbutton-down|scrollbarbutton-left|scrollbarbutton-right|scrollbarbutton-up|scrollbarthumb-horizontal|scrollbarthumb-vertical|scrollbartrack-horizontal|scrollbartrack-vertical|searchfield|separator|sheet|spinner|spinner-downbutton|spinner-textfield|spinner-upbutton|splitter|statusbar|statusbarpanel|tab|tabpanel|tabpanels|tab-scroll-arrow-back|tab-scroll-arrow-forward|textfield|textfield-multiline|toolbar|toolbarbutton|toolbarbutton-dropdown|toolbargripper|toolbox|tooltip|treeheader|treeheadercell|treeheadersortarrow|treeitem|treeline|treetwisty|treetwistyopen|treeview|-moz-mac-unified-toolbar|-moz-win-borderless-glass|-moz-win-browsertabbar-toolbox|-moz-win-communicationstext|-moz-win-communications-toolbox|-moz-win-exclude-glass|-moz-win-glass|-moz-win-mediatext|-moz-win-media-toolbox|-moz-window-button-box|-moz-window-button-box-maximized|-moz-window-button-close|-moz-window-button-maximize|-moz-window-button-minimize|-moz-window-button-restore|-moz-window-frame-bottom|-moz-window-frame-left|-moz-window-frame-right|-moz-window-titlebar|-moz-window-titlebar-maximized","-moz-binding":"<url>|none","-moz-border-bottom-colors":"<color>+|none","-moz-border-left-colors":"<color>+|none","-moz-border-right-colors":"<color>+|none","-moz-border-top-colors":"<color>+|none","-moz-context-properties":"none|[fill|fill-opacity|stroke|stroke-opacity]#","-moz-float-edge":"border-box|content-box|margin-box|padding-box","-moz-force-broken-image-icon":"0|1","-moz-image-region":"<shape>|auto","-moz-orient":"inline|block|horizontal|vertical","-moz-outline-radius":"<outline-radius>{1,4} [/ <outline-radius>{1,4}]?","-moz-outline-radius-bottomleft":"<outline-radius>","-moz-outline-radius-bottomright":"<outline-radius>","-moz-outline-radius-topleft":"<outline-radius>","-moz-outline-radius-topright":"<outline-radius>","-moz-stack-sizing":"ignore|stretch-to-fit","-moz-text-blink":"none|blink","-moz-user-focus":"ignore|normal|select-after|select-before|select-menu|select-same|select-all|none","-moz-user-input":"auto|none|enabled|disabled","-moz-user-modify":"read-only|read-write|write-only","-moz-window-dragging":"drag|no-drag","-moz-window-shadow":"default|menu|tooltip|sheet|none","-webkit-appearance":"none|button|button-bevel|caps-lock-indicator|caret|checkbox|default-button|inner-spin-button|listbox|listitem|media-controls-background|media-controls-fullscreen-background|media-current-time-display|media-enter-fullscreen-button|media-exit-fullscreen-button|media-fullscreen-button|media-mute-button|media-overlay-play-button|media-play-button|media-seek-back-button|media-seek-forward-button|media-slider|media-sliderthumb|media-time-remaining-display|media-toggle-closed-captions-button|media-volume-slider|media-volume-slider-container|media-volume-sliderthumb|menulist|menulist-button|menulist-text|menulist-textfield|meter|progress-bar|progress-bar-value|push-button|radio|scrollbarbutton-down|scrollbarbutton-left|scrollbarbutton-right|scrollbarbutton-up|scrollbargripper-horizontal|scrollbargripper-vertical|scrollbarthumb-horizontal|scrollbarthumb-vertical|scrollbartrack-horizontal|scrollbartrack-vertical|searchfield|searchfield-cancel-button|searchfield-decoration|searchfield-results-button|searchfield-results-decoration|slider-horizontal|slider-vertical|sliderthumb-horizontal|sliderthumb-vertical|square-button|textarea|textfield|-apple-pay-button","-webkit-border-before":"<'border-width'>||<'border-style'>||<color>","-webkit-border-before-color":"<color>","-webkit-border-before-style":"<'border-style'>","-webkit-border-before-width":"<'border-width'>","-webkit-box-reflect":"[above|below|right|left]? <length>? <image>?","-webkit-line-clamp":"none|<integer>","-webkit-mask":"[<mask-reference>||<position> [/ <bg-size>]?||<repeat-style>||[<box>|border|padding|content|text]||[<box>|border|padding|content]]#","-webkit-mask-attachment":"<attachment>#","-webkit-mask-clip":"[<box>|border|padding|content|text]#","-webkit-mask-composite":"<composite-style>#","-webkit-mask-image":"<mask-reference>#","-webkit-mask-origin":"[<box>|border|padding|content]#","-webkit-mask-position":"<position>#","-webkit-mask-position-x":"[<length-percentage>|left|center|right]#","-webkit-mask-position-y":"[<length-percentage>|top|center|bottom]#","-webkit-mask-repeat":"<repeat-style>#","-webkit-mask-repeat-x":"repeat|no-repeat|space|round","-webkit-mask-repeat-y":"repeat|no-repeat|space|round","-webkit-mask-size":"<bg-size>#","-webkit-overflow-scrolling":"auto|touch","-webkit-tap-highlight-color":"<color>","-webkit-text-fill-color":"<color>","-webkit-text-stroke":"<length>||<color>","-webkit-text-stroke-color":"<color>","-webkit-text-stroke-width":"<length>","-webkit-touch-callout":"default|none","-webkit-user-modify":"read-only|read-write|read-write-plaintext-only","accent-color":"auto|<color>","align-content":"normal|<baseline-position>|<content-distribution>|<overflow-position>? <content-position>","align-items":"normal|stretch|<baseline-position>|[<overflow-position>? <self-position>]","align-self":"auto|normal|stretch|<baseline-position>|<overflow-position>? <self-position>","align-tracks":"[normal|<baseline-position>|<content-distribution>|<overflow-position>? <content-position>]#",all:"initial|inherit|unset|revert|revert-layer",animation:"<single-animation>#","animation-composition":"<single-animation-composition>#","animation-delay":"<time>#","animation-direction":"<single-animation-direction>#","animation-duration":"<time>#","animation-fill-mode":"<single-animation-fill-mode>#","animation-iteration-count":"<single-animation-iteration-count>#","animation-name":"[none|<keyframes-name>]#","animation-play-state":"<single-animation-play-state>#","animation-timing-function":"<easing-function>#","animation-timeline":"<single-animation-timeline>#",appearance:"none|auto|textfield|menulist-button|<compat-auto>","aspect-ratio":"auto|<ratio>",azimuth:"<angle>|[[left-side|far-left|left|center-left|center|center-right|right|far-right|right-side]||behind]|leftwards|rightwards","backdrop-filter":"none|<filter-function-list>","backface-visibility":"visible|hidden",background:"[<bg-layer> ,]* <final-bg-layer>","background-attachment":"<attachment>#","background-blend-mode":"<blend-mode>#","background-clip":"<bg-clip>#","background-color":"<color>","background-image":"<bg-image>#","background-origin":"<box>#","background-position":"<bg-position>#","background-position-x":"[center|[[left|right|x-start|x-end]? <length-percentage>?]!]#","background-position-y":"[center|[[top|bottom|y-start|y-end]? <length-percentage>?]!]#","background-repeat":"<repeat-style>#","background-size":"<bg-size>#","block-overflow":"clip|ellipsis|<string>","block-size":"<'width'>",border:"<line-width>||<line-style>||<color>","border-block":"<'border-top-width'>||<'border-top-style'>||<color>","border-block-color":"<'border-top-color'>{1,2}","border-block-style":"<'border-top-style'>","border-block-width":"<'border-top-width'>","border-block-end":"<'border-top-width'>||<'border-top-style'>||<color>","border-block-end-color":"<'border-top-color'>","border-block-end-style":"<'border-top-style'>","border-block-end-width":"<'border-top-width'>","border-block-start":"<'border-top-width'>||<'border-top-style'>||<color>","border-block-start-color":"<'border-top-color'>","border-block-start-style":"<'border-top-style'>","border-block-start-width":"<'border-top-width'>","border-bottom":"<line-width>||<line-style>||<color>","border-bottom-color":"<'border-top-color'>","border-bottom-left-radius":"<length-percentage>{1,2}","border-bottom-right-radius":"<length-percentage>{1,2}","border-bottom-style":"<line-style>","border-bottom-width":"<line-width>","border-collapse":"collapse|separate","border-color":"<color>{1,4}","border-end-end-radius":"<length-percentage>{1,2}","border-end-start-radius":"<length-percentage>{1,2}","border-image":"<'border-image-source'>||<'border-image-slice'> [/ <'border-image-width'>|/ <'border-image-width'>? / <'border-image-outset'>]?||<'border-image-repeat'>","border-image-outset":"[<length>|<number>]{1,4}","border-image-repeat":"[stretch|repeat|round|space]{1,2}","border-image-slice":"<number-percentage>{1,4}&&fill?","border-image-source":"none|<image>","border-image-width":"[<length-percentage>|<number>|auto]{1,4}","border-inline":"<'border-top-width'>||<'border-top-style'>||<color>","border-inline-end":"<'border-top-width'>||<'border-top-style'>||<color>","border-inline-color":"<'border-top-color'>{1,2}","border-inline-style":"<'border-top-style'>","border-inline-width":"<'border-top-width'>","border-inline-end-color":"<'border-top-color'>","border-inline-end-style":"<'border-top-style'>","border-inline-end-width":"<'border-top-width'>","border-inline-start":"<'border-top-width'>||<'border-top-style'>||<color>","border-inline-start-color":"<'border-top-color'>","border-inline-start-style":"<'border-top-style'>","border-inline-start-width":"<'border-top-width'>","border-left":"<line-width>||<line-style>||<color>","border-left-color":"<color>","border-left-style":"<line-style>","border-left-width":"<line-width>","border-radius":"<length-percentage>{1,4} [/ <length-percentage>{1,4}]?","border-right":"<line-width>||<line-style>||<color>","border-right-color":"<color>","border-right-style":"<line-style>","border-right-width":"<line-width>","border-spacing":"<length> <length>?","border-start-end-radius":"<length-percentage>{1,2}","border-start-start-radius":"<length-percentage>{1,2}","border-style":"<line-style>{1,4}","border-top":"<line-width>||<line-style>||<color>","border-top-color":"<color>","border-top-left-radius":"<length-percentage>{1,2}","border-top-right-radius":"<length-percentage>{1,2}","border-top-style":"<line-style>","border-top-width":"<line-width>","border-width":"<line-width>{1,4}",bottom:"<length>|<percentage>|auto","box-align":"start|center|end|baseline|stretch","box-decoration-break":"slice|clone","box-direction":"normal|reverse|inherit","box-flex":"<number>","box-flex-group":"<integer>","box-lines":"single|multiple","box-ordinal-group":"<integer>","box-orient":"horizontal|vertical|inline-axis|block-axis|inherit","box-pack":"start|center|end|justify","box-shadow":"none|<shadow>#","box-sizing":"content-box|border-box","break-after":"auto|avoid|always|all|avoid-page|page|left|right|recto|verso|avoid-column|column|avoid-region|region","break-before":"auto|avoid|always|all|avoid-page|page|left|right|recto|verso|avoid-column|column|avoid-region|region","break-inside":"auto|avoid|avoid-page|avoid-column|avoid-region","caption-side":"top|bottom|block-start|block-end|inline-start|inline-end",caret:"<'caret-color'>||<'caret-shape'>","caret-color":"auto|<color>","caret-shape":"auto|bar|block|underscore",clear:"none|left|right|both|inline-start|inline-end",clip:"<shape>|auto","clip-path":"<clip-source>|[<basic-shape>||<geometry-box>]|none",color:"<color>","print-color-adjust":"economy|exact","color-scheme":"normal|[light|dark|<custom-ident>]+&&only?","column-count":"<integer>|auto","column-fill":"auto|balance|balance-all","column-gap":"normal|<length-percentage>","column-rule":"<'column-rule-width'>||<'column-rule-style'>||<'column-rule-color'>","column-rule-color":"<color>","column-rule-style":"<'border-style'>","column-rule-width":"<'border-width'>","column-span":"none|all","column-width":"<length>|auto",columns:"<'column-width'>||<'column-count'>",contain:"none|strict|content|[[size||inline-size]||layout||style||paint]","contain-intrinsic-size":"[none|<length>|auto <length>]{1,2}","contain-intrinsic-block-size":"none|<length>|auto <length>","contain-intrinsic-height":"none|<length>|auto <length>","contain-intrinsic-inline-size":"none|<length>|auto <length>","contain-intrinsic-width":"none|<length>|auto <length>",content:"normal|none|[<content-replacement>|<content-list>] [/ [<string>|<counter>]+]?","content-visibility":"visible|auto|hidden","counter-increment":"[<counter-name> <integer>?]+|none","counter-reset":"[<counter-name> <integer>?|<reversed-counter-name> <integer>?]+|none","counter-set":"[<counter-name> <integer>?]+|none",cursor:"[[<url> [<x> <y>]? ,]* [auto|default|none|context-menu|help|pointer|progress|wait|cell|crosshair|text|vertical-text|alias|copy|move|no-drop|not-allowed|e-resize|n-resize|ne-resize|nw-resize|s-resize|se-resize|sw-resize|w-resize|ew-resize|ns-resize|nesw-resize|nwse-resize|col-resize|row-resize|all-scroll|zoom-in|zoom-out|grab|grabbing|hand|-webkit-grab|-webkit-grabbing|-webkit-zoom-in|-webkit-zoom-out|-moz-grab|-moz-grabbing|-moz-zoom-in|-moz-zoom-out]]",direction:"ltr|rtl",display:"[<display-outside>||<display-inside>]|<display-listitem>|<display-internal>|<display-box>|<display-legacy>|<-non-standard-display>","empty-cells":"show|hide",filter:"none|<filter-function-list>|<-ms-filter-function-list>",flex:"none|[<'flex-grow'> <'flex-shrink'>?||<'flex-basis'>]","flex-basis":"content|<'width'>","flex-direction":"row|row-reverse|column|column-reverse","flex-flow":"<'flex-direction'>||<'flex-wrap'>","flex-grow":"<number>","flex-shrink":"<number>","flex-wrap":"nowrap|wrap|wrap-reverse",float:"left|right|none|inline-start|inline-end",font:"[[<'font-style'>||<font-variant-css21>||<'font-weight'>||<'font-stretch'>]? <'font-size'> [/ <'line-height'>]? <'font-family'>]|caption|icon|menu|message-box|small-caption|status-bar","font-family":"[<family-name>|<generic-family>]#","font-feature-settings":"normal|<feature-tag-value>#","font-kerning":"auto|normal|none","font-language-override":"normal|<string>","font-optical-sizing":"auto|none","font-variation-settings":"normal|[<string> <number>]#","font-size":"<absolute-size>|<relative-size>|<length-percentage>","font-size-adjust":"none|[ex-height|cap-height|ch-width|ic-width|ic-height]? [from-font|<number>]","font-smooth":"auto|never|always|<absolute-size>|<length>","font-stretch":"<font-stretch-absolute>","font-style":"normal|italic|oblique <angle>?","font-synthesis":"none|[weight||style||small-caps]","font-variant":"normal|none|[<common-lig-values>||<discretionary-lig-values>||<historical-lig-values>||<contextual-alt-values>||stylistic( <feature-value-name> )||historical-forms||styleset( <feature-value-name># )||character-variant( <feature-value-name># )||swash( <feature-value-name> )||ornaments( <feature-value-name> )||annotation( <feature-value-name> )||[small-caps|all-small-caps|petite-caps|all-petite-caps|unicase|titling-caps]||<numeric-figure-values>||<numeric-spacing-values>||<numeric-fraction-values>||ordinal||slashed-zero||<east-asian-variant-values>||<east-asian-width-values>||ruby]","font-variant-alternates":"normal|[stylistic( <feature-value-name> )||historical-forms||styleset( <feature-value-name># )||character-variant( <feature-value-name># )||swash( <feature-value-name> )||ornaments( <feature-value-name> )||annotation( <feature-value-name> )]","font-variant-caps":"normal|small-caps|all-small-caps|petite-caps|all-petite-caps|unicase|titling-caps","font-variant-east-asian":"normal|[<east-asian-variant-values>||<east-asian-width-values>||ruby]","font-variant-ligatures":"normal|none|[<common-lig-values>||<discretionary-lig-values>||<historical-lig-values>||<contextual-alt-values>]","font-variant-numeric":"normal|[<numeric-figure-values>||<numeric-spacing-values>||<numeric-fraction-values>||ordinal||slashed-zero]","font-variant-position":"normal|sub|super","font-weight":"<font-weight-absolute>|bolder|lighter","forced-color-adjust":"auto|none",gap:"<'row-gap'> <'column-gap'>?",grid:"<'grid-template'>|<'grid-template-rows'> / [auto-flow&&dense?] <'grid-auto-columns'>?|[auto-flow&&dense?] <'grid-auto-rows'>? / <'grid-template-columns'>","grid-area":"<grid-line> [/ <grid-line>]{0,3}","grid-auto-columns":"<track-size>+","grid-auto-flow":"[row|column]||dense","grid-auto-rows":"<track-size>+","grid-column":"<grid-line> [/ <grid-line>]?","grid-column-end":"<grid-line>","grid-column-gap":"<length-percentage>","grid-column-start":"<grid-line>","grid-gap":"<'grid-row-gap'> <'grid-column-gap'>?","grid-row":"<grid-line> [/ <grid-line>]?","grid-row-end":"<grid-line>","grid-row-gap":"<length-percentage>","grid-row-start":"<grid-line>","grid-template":"none|[<'grid-template-rows'> / <'grid-template-columns'>]|[<line-names>? <string> <track-size>? <line-names>?]+ [/ <explicit-track-list>]?","grid-template-areas":"none|<string>+","grid-template-columns":"none|<track-list>|<auto-track-list>|subgrid <line-name-list>?","grid-template-rows":"none|<track-list>|<auto-track-list>|subgrid <line-name-list>?","hanging-punctuation":"none|[first||[force-end|allow-end]||last]",height:"auto|<length>|<percentage>|min-content|max-content|fit-content|fit-content( <length-percentage> )","hyphenate-character":"auto|<string>",hyphens:"none|manual|auto","image-orientation":"from-image|<angle>|[<angle>? flip]","image-rendering":"auto|crisp-edges|pixelated|optimizeSpeed|optimizeQuality|<-non-standard-image-rendering>","image-resolution":"[from-image||<resolution>]&&snap?","ime-mode":"auto|normal|active|inactive|disabled","initial-letter":"normal|[<number> <integer>?]","initial-letter-align":"[auto|alphabetic|hanging|ideographic]","inline-size":"<'width'>","input-security":"auto|none",inset:"<'top'>{1,4}","inset-block":"<'top'>{1,2}","inset-block-end":"<'top'>","inset-block-start":"<'top'>","inset-inline":"<'top'>{1,2}","inset-inline-end":"<'top'>","inset-inline-start":"<'top'>",isolation:"auto|isolate","justify-content":"normal|<content-distribution>|<overflow-position>? [<content-position>|left|right]","justify-items":"normal|stretch|<baseline-position>|<overflow-position>? [<self-position>|left|right]|legacy|legacy&&[left|right|center]","justify-self":"auto|normal|stretch|<baseline-position>|<overflow-position>? [<self-position>|left|right]","justify-tracks":"[normal|<content-distribution>|<overflow-position>? [<content-position>|left|right]]#",left:"<length>|<percentage>|auto","letter-spacing":"normal|<length-percentage>","line-break":"auto|loose|normal|strict|anywhere","line-clamp":"none|<integer>","line-height":"normal|<number>|<length>|<percentage>","line-height-step":"<length>","list-style":"<'list-style-type'>||<'list-style-position'>||<'list-style-image'>","list-style-image":"<image>|none","list-style-position":"inside|outside","list-style-type":"<counter-style>|<string>|none",margin:"[<length>|<percentage>|auto]{1,4}","margin-block":"<'margin-left'>{1,2}","margin-block-end":"<'margin-left'>","margin-block-start":"<'margin-left'>","margin-bottom":"<length>|<percentage>|auto","margin-inline":"<'margin-left'>{1,2}","margin-inline-end":"<'margin-left'>","margin-inline-start":"<'margin-left'>","margin-left":"<length>|<percentage>|auto","margin-right":"<length>|<percentage>|auto","margin-top":"<length>|<percentage>|auto","margin-trim":"none|in-flow|all",mask:"<mask-layer>#","mask-border":"<'mask-border-source'>||<'mask-border-slice'> [/ <'mask-border-width'>? [/ <'mask-border-outset'>]?]?||<'mask-border-repeat'>||<'mask-border-mode'>","mask-border-mode":"luminance|alpha","mask-border-outset":"[<length>|<number>]{1,4}","mask-border-repeat":"[stretch|repeat|round|space]{1,2}","mask-border-slice":"<number-percentage>{1,4} fill?","mask-border-source":"none|<image>","mask-border-width":"[<length-percentage>|<number>|auto]{1,4}","mask-clip":"[<geometry-box>|no-clip]#","mask-composite":"<compositing-operator>#","mask-image":"<mask-reference>#","mask-mode":"<masking-mode>#","mask-origin":"<geometry-box>#","mask-position":"<position>#","mask-repeat":"<repeat-style>#","mask-size":"<bg-size>#","mask-type":"luminance|alpha","masonry-auto-flow":"[pack|next]||[definite-first|ordered]","math-depth":"auto-add|add( <integer> )|<integer>","math-shift":"normal|compact","math-style":"normal|compact","max-block-size":"<'max-width'>","max-height":"none|<length-percentage>|min-content|max-content|fit-content|fit-content( <length-percentage> )","max-inline-size":"<'max-width'>","max-lines":"none|<integer>","max-width":"none|<length-percentage>|min-content|max-content|fit-content|fit-content( <length-percentage> )|<-non-standard-width>","min-block-size":"<'min-width'>","min-height":"auto|<length>|<percentage>|min-content|max-content|fit-content|fit-content( <length-percentage> )","min-inline-size":"<'min-width'>","min-width":"auto|<length>|<percentage>|min-content|max-content|fit-content|fit-content( <length-percentage> )|<-non-standard-width>","mix-blend-mode":"<blend-mode>|plus-lighter","object-fit":"fill|contain|cover|none|scale-down","object-position":"<position>",offset:"[<'offset-position'>? [<'offset-path'> [<'offset-distance'>||<'offset-rotate'>]?]?]! [/ <'offset-anchor'>]?","offset-anchor":"auto|<position>","offset-distance":"<length-percentage>","offset-path":"none|ray( [<angle>&&<size>&&contain?] )|<path()>|<url>|[<basic-shape>||<geometry-box>]","offset-position":"auto|<position>","offset-rotate":"[auto|reverse]||<angle>",opacity:"<alpha-value>",order:"<integer>",orphans:"<integer>",outline:"[<'outline-color'>||<'outline-style'>||<'outline-width'>]","outline-color":"<color>|invert","outline-offset":"<length>","outline-style":"auto|<'border-style'>","outline-width":"<line-width>",overflow:"[visible|hidden|clip|scroll|auto]{1,2}|<-non-standard-overflow>","overflow-anchor":"auto|none","overflow-block":"visible|hidden|clip|scroll|auto","overflow-clip-box":"padding-box|content-box","overflow-clip-margin":"<visual-box>||<length [0,\u221E]>","overflow-inline":"visible|hidden|clip|scroll|auto","overflow-wrap":"normal|break-word|anywhere","overflow-x":"visible|hidden|clip|scroll|auto","overflow-y":"visible|hidden|clip|scroll|auto","overscroll-behavior":"[contain|none|auto]{1,2}","overscroll-behavior-block":"contain|none|auto","overscroll-behavior-inline":"contain|none|auto","overscroll-behavior-x":"contain|none|auto","overscroll-behavior-y":"contain|none|auto",padding:"[<length>|<percentage>]{1,4}","padding-block":"<'padding-left'>{1,2}","padding-block-end":"<'padding-left'>","padding-block-start":"<'padding-left'>","padding-bottom":"<length>|<percentage>","padding-inline":"<'padding-left'>{1,2}","padding-inline-end":"<'padding-left'>","padding-inline-start":"<'padding-left'>","padding-left":"<length>|<percentage>","padding-right":"<length>|<percentage>","padding-top":"<length>|<percentage>","page-break-after":"auto|always|avoid|left|right|recto|verso","page-break-before":"auto|always|avoid|left|right|recto|verso","page-break-inside":"auto|avoid","paint-order":"normal|[fill||stroke||markers]",perspective:"none|<length>","perspective-origin":"<position>","place-content":"<'align-content'> <'justify-content'>?","place-items":"<'align-items'> <'justify-items'>?","place-self":"<'align-self'> <'justify-self'>?","pointer-events":"auto|none|visiblePainted|visibleFill|visibleStroke|visible|painted|fill|stroke|all|inherit",position:"static|relative|absolute|sticky|fixed|-webkit-sticky",quotes:"none|auto|[<string> <string>]+",resize:"none|both|horizontal|vertical|block|inline",right:"<length>|<percentage>|auto",rotate:"none|<angle>|[x|y|z|<number>{3}]&&<angle>","row-gap":"normal|<length-percentage>","ruby-align":"start|center|space-between|space-around","ruby-merge":"separate|collapse|auto","ruby-position":"[alternate||[over|under]]|inter-character",scale:"none|<number>{1,3}","scrollbar-color":"auto|<color>{2}","scrollbar-gutter":"auto|stable&&both-edges?","scrollbar-width":"auto|thin|none","scroll-behavior":"auto|smooth","scroll-margin":"<length>{1,4}","scroll-margin-block":"<length>{1,2}","scroll-margin-block-start":"<length>","scroll-margin-block-end":"<length>","scroll-margin-bottom":"<length>","scroll-margin-inline":"<length>{1,2}","scroll-margin-inline-start":"<length>","scroll-margin-inline-end":"<length>","scroll-margin-left":"<length>","scroll-margin-right":"<length>","scroll-margin-top":"<length>","scroll-padding":"[auto|<length-percentage>]{1,4}","scroll-padding-block":"[auto|<length-percentage>]{1,2}","scroll-padding-block-start":"auto|<length-percentage>","scroll-padding-block-end":"auto|<length-percentage>","scroll-padding-bottom":"auto|<length-percentage>","scroll-padding-inline":"[auto|<length-percentage>]{1,2}","scroll-padding-inline-start":"auto|<length-percentage>","scroll-padding-inline-end":"auto|<length-percentage>","scroll-padding-left":"auto|<length-percentage>","scroll-padding-right":"auto|<length-percentage>","scroll-padding-top":"auto|<length-percentage>","scroll-snap-align":"[none|start|end|center]{1,2}","scroll-snap-coordinate":"none|<position>#","scroll-snap-destination":"<position>","scroll-snap-points-x":"none|repeat( <length-percentage> )","scroll-snap-points-y":"none|repeat( <length-percentage> )","scroll-snap-stop":"normal|always","scroll-snap-type":"none|[x|y|block|inline|both] [mandatory|proximity]?","scroll-snap-type-x":"none|mandatory|proximity","scroll-snap-type-y":"none|mandatory|proximity","scroll-timeline":"[<'scroll-timeline-name'>||<'scroll-timeline-axis'>]#","scroll-timeline-axis":"[block|inline|vertical|horizontal]#","scroll-timeline-name":"none|<custom-ident>#","shape-image-threshold":"<alpha-value>","shape-margin":"<length-percentage>","shape-outside":"none|[<shape-box>||<basic-shape>]|<image>","tab-size":"<integer>|<length>","table-layout":"auto|fixed","text-align":"start|end|left|right|center|justify|match-parent","text-align-last":"auto|start|end|left|right|center|justify","text-combine-upright":"none|all|[digits <integer>?]","text-decoration":"<'text-decoration-line'>||<'text-decoration-style'>||<'text-decoration-color'>||<'text-decoration-thickness'>","text-decoration-color":"<color>","text-decoration-line":"none|[underline||overline||line-through||blink]|spelling-error|grammar-error","text-decoration-skip":"none|[objects||[spaces|[leading-spaces||trailing-spaces]]||edges||box-decoration]","text-decoration-skip-ink":"auto|all|none","text-decoration-style":"solid|double|dotted|dashed|wavy","text-decoration-thickness":"auto|from-font|<length>|<percentage>","text-emphasis":"<'text-emphasis-style'>||<'text-emphasis-color'>","text-emphasis-color":"<color>","text-emphasis-position":"[over|under]&&[right|left]","text-emphasis-style":"none|[[filled|open]||[dot|circle|double-circle|triangle|sesame]]|<string>","text-indent":"<length-percentage>&&hanging?&&each-line?","text-justify":"auto|inter-character|inter-word|none","text-orientation":"mixed|upright|sideways","text-overflow":"[clip|ellipsis|<string>]{1,2}","text-rendering":"auto|optimizeSpeed|optimizeLegibility|geometricPrecision","text-shadow":"none|<shadow-t>#","text-size-adjust":"none|auto|<percentage>","text-transform":"none|capitalize|uppercase|lowercase|full-width|full-size-kana","text-underline-offset":"auto|<length>|<percentage>","text-underline-position":"auto|from-font|[under||[left|right]]",top:"<length>|<percentage>|auto","touch-action":"auto|none|[[pan-x|pan-left|pan-right]||[pan-y|pan-up|pan-down]||pinch-zoom]|manipulation",transform:"none|<transform-list>","transform-box":"content-box|border-box|fill-box|stroke-box|view-box","transform-origin":"[<length-percentage>|left|center|right|top|bottom]|[[<length-percentage>|left|center|right]&&[<length-percentage>|top|center|bottom]] <length>?","transform-style":"flat|preserve-3d",transition:"<single-transition>#","transition-delay":"<time>#","transition-duration":"<time>#","transition-property":"none|<single-transition-property>#","transition-timing-function":"<easing-function>#",translate:"none|<length-percentage> [<length-percentage> <length>?]?","unicode-bidi":"normal|embed|isolate|bidi-override|isolate-override|plaintext|-moz-isolate|-moz-isolate-override|-moz-plaintext|-webkit-isolate|-webkit-isolate-override|-webkit-plaintext","user-select":"auto|text|none|contain|all","vertical-align":"baseline|sub|super|text-top|text-bottom|middle|top|bottom|<percentage>|<length>",visibility:"visible|hidden|collapse","white-space":"normal|pre|nowrap|pre-wrap|pre-line|break-spaces",widows:"<integer>",width:"auto|<length>|<percentage>|min-content|max-content|fit-content|fit-content( <length-percentage> )|fill|stretch|intrinsic|-moz-max-content|-webkit-max-content|-moz-fit-content|-webkit-fit-content","will-change":"auto|<animateable-feature>#","word-break":"normal|break-all|keep-all|break-word","word-spacing":"normal|<length>","word-wrap":"normal|break-word","writing-mode":"horizontal-tb|vertical-rl|vertical-lr|sideways-rl|sideways-lr|<svg-writing-mode>","z-index":"auto|<integer>",zoom:"normal|reset|<number>|<percentage>","-moz-background-clip":"padding|border","-moz-border-radius-bottomleft":"<'border-bottom-left-radius'>","-moz-border-radius-bottomright":"<'border-bottom-right-radius'>","-moz-border-radius-topleft":"<'border-top-left-radius'>","-moz-border-radius-topright":"<'border-bottom-right-radius'>","-moz-control-character-visibility":"visible|hidden","-moz-osx-font-smoothing":"auto|grayscale","-moz-user-select":"none|text|all|-moz-none","-ms-flex-align":"start|end|center|baseline|stretch","-ms-flex-item-align":"auto|start|end|center|baseline|stretch","-ms-flex-line-pack":"start|end|center|justify|distribute|stretch","-ms-flex-negative":"<'flex-shrink'>","-ms-flex-pack":"start|end|center|justify|distribute","-ms-flex-order":"<integer>","-ms-flex-positive":"<'flex-grow'>","-ms-flex-preferred-size":"<'flex-basis'>","-ms-interpolation-mode":"nearest-neighbor|bicubic","-ms-grid-column-align":"start|end|center|stretch","-ms-grid-row-align":"start|end|center|stretch","-ms-hyphenate-limit-last":"none|always|column|page|spread","-webkit-background-clip":"[<box>|border|padding|content|text]#","-webkit-column-break-after":"always|auto|avoid","-webkit-column-break-before":"always|auto|avoid","-webkit-column-break-inside":"always|auto|avoid","-webkit-font-smoothing":"auto|none|antialiased|subpixel-antialiased","-webkit-mask-box-image":"[<url>|<gradient>|none] [<length-percentage>{4} <-webkit-mask-box-repeat>{2}]?","-webkit-print-color-adjust":"economy|exact","-webkit-text-security":"none|circle|disc|square","-webkit-user-drag":"none|element|auto","-webkit-user-select":"auto|none|text|all","alignment-baseline":"auto|baseline|before-edge|text-before-edge|middle|central|after-edge|text-after-edge|ideographic|alphabetic|hanging|mathematical","baseline-shift":"baseline|sub|super|<svg-length>",behavior:"<url>+","clip-rule":"nonzero|evenodd",cue:"<'cue-before'> <'cue-after'>?","cue-after":"<url> <decibel>?|none","cue-before":"<url> <decibel>?|none","dominant-baseline":"auto|use-script|no-change|reset-size|ideographic|alphabetic|hanging|mathematical|central|middle|text-after-edge|text-before-edge",fill:"<paint>","fill-opacity":"<number-zero-one>","fill-rule":"nonzero|evenodd","glyph-orientation-horizontal":"<angle>","glyph-orientation-vertical":"<angle>",kerning:"auto|<svg-length>",marker:"none|<url>","marker-end":"none|<url>","marker-mid":"none|<url>","marker-start":"none|<url>",pause:"<'pause-before'> <'pause-after'>?","pause-after":"<time>|none|x-weak|weak|medium|strong|x-strong","pause-before":"<time>|none|x-weak|weak|medium|strong|x-strong",rest:"<'rest-before'> <'rest-after'>?","rest-after":"<time>|none|x-weak|weak|medium|strong|x-strong","rest-before":"<time>|none|x-weak|weak|medium|strong|x-strong","shape-rendering":"auto|optimizeSpeed|crispEdges|geometricPrecision",src:"[<url> [format( <string># )]?|local( <family-name> )]#",speak:"auto|none|normal","speak-as":"normal|spell-out||digits||[literal-punctuation|no-punctuation]",stroke:"<paint>","stroke-dasharray":"none|[<svg-length>+]#","stroke-dashoffset":"<svg-length>","stroke-linecap":"butt|round|square","stroke-linejoin":"miter|round|bevel","stroke-miterlimit":"<number-one-or-greater>","stroke-opacity":"<number-zero-one>","stroke-width":"<svg-length>","text-anchor":"start|middle|end","unicode-range":"<urange>#","voice-balance":"<number>|left|center|right|leftwards|rightwards","voice-duration":"auto|<time>","voice-family":"[[<family-name>|<generic-voice>] ,]* [<family-name>|<generic-voice>]|preserve","voice-pitch":"<frequency>&&absolute|[[x-low|low|medium|high|x-high]||[<frequency>|<semitones>|<percentage>]]","voice-range":"<frequency>&&absolute|[[x-low|low|medium|high|x-high]||[<frequency>|<semitones>|<percentage>]]","voice-rate":"[normal|x-slow|slow|medium|fast|x-fast]||<percentage>","voice-stress":"normal|strong|moderate|none|reduced","voice-volume":"silent|[[x-soft|soft|medium|loud|x-loud]||<decibel>]"},atrules:{charset:{prelude:"<string>",descriptors:null},"counter-style":{prelude:"<counter-style-name>",descriptors:{"additive-symbols":"[<integer>&&<symbol>]#",fallback:"<counter-style-name>",negative:"<symbol> <symbol>?",pad:"<integer>&&<symbol>",prefix:"<symbol>",range:"[[<integer>|infinite]{2}]#|auto","speak-as":"auto|bullets|numbers|words|spell-out|<counter-style-name>",suffix:"<symbol>",symbols:"<symbol>+",system:"cyclic|numeric|alphabetic|symbolic|additive|[fixed <integer>?]|[extends <counter-style-name>]"}},document:{prelude:"[<url>|url-prefix( <string> )|domain( <string> )|media-document( <string> )|regexp( <string> )]#",descriptors:null},"font-face":{prelude:null,descriptors:{"ascent-override":"normal|<percentage>","descent-override":"normal|<percentage>","font-display":"[auto|block|swap|fallback|optional]","font-family":"<family-name>","font-feature-settings":"normal|<feature-tag-value>#","font-variation-settings":"normal|[<string> <number>]#","font-stretch":"<font-stretch-absolute>{1,2}","font-style":"normal|italic|oblique <angle>{0,2}","font-weight":"<font-weight-absolute>{1,2}","font-variant":"normal|none|[<common-lig-values>||<discretionary-lig-values>||<historical-lig-values>||<contextual-alt-values>||stylistic( <feature-value-name> )||historical-forms||styleset( <feature-value-name># )||character-variant( <feature-value-name># )||swash( <feature-value-name> )||ornaments( <feature-value-name> )||annotation( <feature-value-name> )||[small-caps|all-small-caps|petite-caps|all-petite-caps|unicase|titling-caps]||<numeric-figure-values>||<numeric-spacing-values>||<numeric-fraction-values>||ordinal||slashed-zero||<east-asian-variant-values>||<east-asian-width-values>||ruby]","line-gap-override":"normal|<percentage>","size-adjust":"<percentage>",src:"[<url> [format( <string># )]?|local( <family-name> )]#","unicode-range":"<urange>#"}},"font-feature-values":{prelude:"<family-name>#",descriptors:null},import:{prelude:"[<string>|<url>] [layer|layer( <layer-name> )]? [supports( [<supports-condition>|<declaration>] )]? <media-query-list>?",descriptors:null},keyframes:{prelude:"<keyframes-name>",descriptors:null},layer:{prelude:"[<layer-name>#|<layer-name>?]",descriptors:null},media:{prelude:"<media-query-list>",descriptors:null},namespace:{prelude:"<namespace-prefix>? [<string>|<url>]",descriptors:null},page:{prelude:"<page-selector-list>",descriptors:{bleed:"auto|<length>",marks:"none|[crop||cross]",size:"<length>{1,2}|auto|[<page-size>||[portrait|landscape]]"}},property:{prelude:"<custom-property-name>",descriptors:{syntax:"<string>",inherits:"true|false","initial-value":"<string>"}},"scroll-timeline":{prelude:"<timeline-name>",descriptors:null},supports:{prelude:"<supports-condition>",descriptors:null},viewport:{prelude:null,descriptors:{height:"<viewport-length>{1,2}","max-height":"<viewport-length>","max-width":"<viewport-length>","max-zoom":"auto|<number>|<percentage>","min-height":"<viewport-length>","min-width":"<viewport-length>","min-zoom":"auto|<number>|<percentage>",orientation:"auto|portrait|landscape","user-zoom":"zoom|fixed","viewport-fit":"auto|contain|cover",width:"<viewport-length>{1,2}",zoom:"auto|<number>|<percentage>"}},nest:{prelude:"<complex-selector-list>",descriptors:null}}};var gt={};b(gt,{AnPlusB:()=>Xr,Atrule:()=>Zr,AtrulePrelude:()=>en,AttributeSelector:()=>nn,Block:()=>an,Brackets:()=>ln,CDC:()=>un,CDO:()=>hn,ClassSelector:()=>fn,Combinator:()=>gn,Comment:()=>xn,Declaration:()=>kn,DeclarationList:()=>Sn,Dimension:()=>An,Function:()=>En,Hash:()=>Pn,IdSelector:()=>Nn,Identifier:()=>Dn,MediaFeature:()=>Mn,MediaQuery:()=>Fn,MediaQueryList:()=>_n,NestingSelector:()=>jn,Nth:()=>Wn,Number:()=>Yn,Operator:()=>Vn,Parentheses:()=>Qn,Percentage:()=>$n,PseudoClassSelector:()=>Jn,PseudoElementSelector:()=>to,Ratio:()=>no,Raw:()=>io,Rule:()=>so,Selector:()=>co,SelectorList:()=>po,String:()=>bo,StyleSheet:()=>yo,TypeSelector:()=>vo,UnicodeRange:()=>Ao,Url:()=>Do,Value:()=>No,WhiteSpace:()=>Mo});var Xr={};b(Xr,{generate:()=>xc,name:()=>gc,parse:()=>Qr,structure:()=>bc});var me=43,re=45,Xt=110,Ie=!0,dc=!1;function $t(e,t){let r=this.tokenStart+e,n=this.charCodeAt(r);for((n===me||n===re)&&(t&&this.error("Number sign is not allowed"),r++);r<this.tokenEnd;r++)B(this.charCodeAt(r))||this.error("Integer is expected",r);}function Qe(e){return $t.call(this,0,e)}function Ce(e,t){if(!this.cmpChar(this.tokenStart+e,t)){let r="";switch(t){case Xt:r="N is expected";break;case re:r="HyphenMinus is expected";break}this.error(r,this.tokenStart+e);}}function Kr(){let e=0,t=0,r=this.tokenType;for(;r===13||r===25;)r=this.lookupType(++e);if(r!==10)if(this.isDelim(me,e)||this.isDelim(re,e)){t=this.isDelim(me,e)?me:re;do r=this.lookupType(++e);while(r===13||r===25);r!==10&&(this.skip(e),Qe.call(this,Ie));}else return null;return e>0&&this.skip(e),t===0&&(r=this.charCodeAt(this.tokenStart),r!==me&&r!==re&&this.error("Number sign is expected")),Qe.call(this,t!==0),t===re?"-"+this.consume(10):this.consume(10)}var gc="AnPlusB",bc={a:[String,null],b:[String,null]};function Qr(){let e=this.tokenStart,t=null,r=null;if(this.tokenType===10)Qe.call(this,dc),r=this.consume(10);else if(this.tokenType===1&&this.cmpChar(this.tokenStart,re))switch(t="-1",Ce.call(this,1,Xt),this.tokenEnd-this.tokenStart){case 2:this.next(),r=Kr.call(this);break;case 3:Ce.call(this,2,re),this.next(),this.skipSC(),Qe.call(this,Ie),r="-"+this.consume(10);break;default:Ce.call(this,2,re),$t.call(this,3,Ie),this.next(),r=this.substrToCursor(e+2);}else if(this.tokenType===1||this.isDelim(me)&&this.lookupType(1)===1){let n=0;switch(t="1",this.isDelim(me)&&(n=1,this.next()),Ce.call(this,0,Xt),this.tokenEnd-this.tokenStart){case 1:this.next(),r=Kr.call(this);break;case 2:Ce.call(this,1,re),this.next(),this.skipSC(),Qe.call(this,Ie),r="-"+this.consume(10);break;default:Ce.call(this,1,re),$t.call(this,2,Ie),this.next(),r=this.substrToCursor(e+n+1);}}else if(this.tokenType===12){let n=this.charCodeAt(this.tokenStart),o=n===me||n===re,i=this.tokenStart+o;for(;i<this.tokenEnd&&B(this.charCodeAt(i));i++);i===this.tokenStart+o&&this.error("Integer is expected",this.tokenStart+o),Ce.call(this,i-this.tokenStart,Xt),t=this.substring(e,i),i+1===this.tokenEnd?(this.next(),r=Kr.call(this)):(Ce.call(this,i-this.tokenStart+1,re),i+2===this.tokenEnd?(this.next(),this.skipSC(),Qe.call(this,Ie),r="-"+this.consume(10)):($t.call(this,i-this.tokenStart+2,Ie),this.next(),r=this.substrToCursor(i+1)));}else this.error();return t!==null&&t.charCodeAt(0)===me&&(t=t.substr(1)),r!==null&&r.charCodeAt(0)===me&&(r=r.substr(1)),{type:"AnPlusB",loc:this.getLocation(e,this.tokenStart),a:t,b:r}}function xc(e){if(e.a){let t=e.a==="+1"&&"n"||e.a==="1"&&"n"||e.a==="-1"&&"-n"||e.a+"n";if(e.b){let r=e.b[0]==="-"||e.b[0]==="+"?e.b:"+"+e.b;this.tokenize(t+r);}else this.tokenize(t);}else this.tokenize(e.b);}var Zr={};b(Zr,{generate:()=>Sc,name:()=>kc,parse:()=>$r,structure:()=>vc,walkContext:()=>wc});function da(e){return this.Raw(e,this.consumeUntilLeftCurlyBracketOrSemicolon,!0)}function yc(){for(let e=1,t;t=this.lookupType(e);e++){if(t===24)return !0;if(t===23||t===3)return !1}return !1}var kc="Atrule",wc="atrule",vc={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]};function $r(e=!1){let t=this.tokenStart,r,n,o=null,i=null;switch(this.eat(3),r=this.substrToCursor(t+1),n=r.toLowerCase(),this.skipSC(),this.eof===!1&&this.tokenType!==23&&this.tokenType!==17&&(this.parseAtrulePrelude?o=this.parseWithFallback(this.AtrulePrelude.bind(this,r,e),da):o=da.call(this,this.tokenIndex),this.skipSC()),this.tokenType){case 17:this.next();break;case 23:hasOwnProperty.call(this.atrule,n)&&typeof this.atrule[n].block=="function"?i=this.atrule[n].block.call(this,e):i=this.Block(yc.call(this));break}return {type:"Atrule",loc:this.getLocation(t,this.tokenStart),name:r,prelude:o,block:i}}function Sc(e){this.token(3,"@"+e.name),e.prelude!==null&&this.node(e.prelude),e.block?this.node(e.block):this.token(17,";");}var en={};b(en,{generate:()=>Ec,name:()=>Cc,parse:()=>Jr,structure:()=>Tc,walkContext:()=>Ac});var Cc="AtrulePrelude",Ac="atrulePrelude",Tc={children:[[]]};function Jr(e){let t=null;return e!==null&&(e=e.toLowerCase()),this.skipSC(),hasOwnProperty.call(this.atrule,e)&&typeof this.atrule[e].prelude=="function"?t=this.atrule[e].prelude.call(this):t=this.readSequence(this.scope.AtrulePrelude),this.skipSC(),this.eof!==!0&&this.tokenType!==23&&this.tokenType!==17&&this.error("Semicolon or block is expected"),{type:"AtrulePrelude",loc:this.getLocationFromList(t),children:t}}function Ec(e){this.children(e);}var nn={};b(nn,{generate:()=>Mc,name:()=>Nc,parse:()=>rn,structure:()=>zc});var Lc=36,ga=42,Zt=61,Pc=94,tn=124,Ic=126;function Dc(){this.eof&&this.error("Unexpected end of input");let e=this.tokenStart,t=!1;return this.isDelim(ga)?(t=!0,this.next()):this.isDelim(tn)||this.eat(1),this.isDelim(tn)?this.charCodeAt(this.tokenStart+1)!==Zt?(this.next(),this.eat(1)):t&&this.error("Identifier is expected",this.tokenEnd):t&&this.error("Vertical line is expected"),{type:"Identifier",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function Oc(){let e=this.tokenStart,t=this.charCodeAt(e);return t!==Zt&&t!==Ic&&t!==Pc&&t!==Lc&&t!==ga&&t!==tn&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),t!==Zt&&(this.isDelim(Zt)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(e)}var Nc="AttributeSelector",zc={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]};function rn(){let e=this.tokenStart,t,r=null,n=null,o=null;return this.eat(19),this.skipSC(),t=Dc.call(this),this.skipSC(),this.tokenType!==20&&(this.tokenType!==1&&(r=Oc.call(this),this.skipSC(),n=this.tokenType===5?this.String():this.Identifier(),this.skipSC()),this.tokenType===1&&(o=this.consume(1),this.skipSC())),this.eat(20),{type:"AttributeSelector",loc:this.getLocation(e,this.tokenStart),name:t,matcher:r,value:n,flags:o}}function Mc(e){this.token(9,"["),this.node(e.name),e.matcher!==null&&(this.tokenize(e.matcher),this.node(e.value)),e.flags!==null&&this.token(1,e.flags),this.token(9,"]");}var an={};b(an,{generate:()=>jc,name:()=>Bc,parse:()=>on,structure:()=>Uc,walkContext:()=>_c});var Rc=38;function ya(e){return this.Raw(e,null,!0)}function ba(){return this.parseWithFallback(this.Rule,ya)}function xa(e){return this.Raw(e,this.consumeUntilSemicolonIncluded,!0)}function Fc(){if(this.tokenType===17)return xa.call(this,this.tokenIndex);let e=this.parseWithFallback(this.Declaration,xa);return this.tokenType===17&&this.next(),e}var Bc="Block",_c="block",Uc={children:[["Atrule","Rule","Declaration"]]};function on(e){let t=e?Fc:ba,r=this.tokenStart,n=this.createList();this.eat(23);e:for(;!this.eof;)switch(this.tokenType){case 24:break e;case 13:case 25:this.next();break;case 3:n.push(this.parseWithFallback(this.Atrule.bind(this,e),ya));break;default:e&&this.isDelim(Rc)?n.push(ba.call(this)):n.push(t.call(this));}return this.eof||this.eat(24),{type:"Block",loc:this.getLocation(r,this.tokenStart),children:n}}function jc(e){this.token(23,"{"),this.children(e,t=>{t.type==="Declaration"&&this.token(17,";");}),this.token(24,"}");}var ln={};b(ln,{generate:()=>Hc,name:()=>qc,parse:()=>sn,structure:()=>Wc});var qc="Brackets",Wc={children:[[]]};function sn(e,t){let r=this.tokenStart,n=null;return this.eat(19),n=e.call(this,t),this.eof||this.eat(20),{type:"Brackets",loc:this.getLocation(r,this.tokenStart),children:n}}function Hc(e){this.token(9,"["),this.children(e),this.token(9,"]");}var un={};b(un,{generate:()=>Vc,name:()=>Yc,parse:()=>cn,structure:()=>Gc});var Yc="CDC",Gc=[];function cn(){let e=this.tokenStart;return this.eat(15),{type:"CDC",loc:this.getLocation(e,this.tokenStart)}}function Vc(){this.token(15,"-->");}var hn={};b(hn,{generate:()=>Xc,name:()=>Kc,parse:()=>pn,structure:()=>Qc});var Kc="CDO",Qc=[];function pn(){let e=this.tokenStart;return this.eat(14),{type:"CDO",loc:this.getLocation(e,this.tokenStart)}}function Xc(){this.token(14,"<!--");}var fn={};b(fn,{generate:()=>eu,name:()=>Zc,parse:()=>mn,structure:()=>Jc});var $c=46,Zc="ClassSelector",Jc={name:String};function mn(){return this.eatDelim($c),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(1)}}function eu(e){this.token(9,"."),this.token(1,e.name);}var gn={};b(gn,{generate:()=>au,name:()=>ou,parse:()=>dn,structure:()=>iu});var tu=43,ka=47,ru=62,nu=126,ou="Combinator",iu={name:String};function dn(){let e=this.tokenStart,t;switch(this.tokenType){case 13:t=" ";break;case 9:switch(this.charCodeAt(this.tokenStart)){case ru:case tu:case nu:this.next();break;case ka:this.next(),this.eatIdent("deep"),this.eatDelim(ka);break;default:this.error("Combinator is expected");}t=this.substrToCursor(e);break}return {type:"Combinator",loc:this.getLocation(e,this.tokenStart),name:t}}function au(e){this.tokenize(e.name);}var xn={};b(xn,{generate:()=>pu,name:()=>cu,parse:()=>bn,structure:()=>uu});var su=42,lu=47,cu="Comment",uu={value:String};function bn(){let e=this.tokenStart,t=this.tokenEnd;return this.eat(25),t-e+2>=2&&this.charCodeAt(t-2)===su&&this.charCodeAt(t-1)===lu&&(t-=2),{type:"Comment",loc:this.getLocation(e,this.tokenStart),value:this.substring(e+2,t)}}function pu(e){this.token(25,"/*"+e.value+"*/");}var kn={};b(kn,{generate:()=>Su,name:()=>ku,parse:()=>yn,structure:()=>vu,walkContext:()=>wu});var va=33,hu=35,mu=36,fu=38,du=42,gu=43,wa=47;function bu(e){return this.Raw(e,this.consumeUntilExclamationMarkOrSemicolon,!0)}function xu(e){return this.Raw(e,this.consumeUntilExclamationMarkOrSemicolon,!1)}function yu(){let e=this.tokenIndex,t=this.Value();return t.type!=="Raw"&&this.eof===!1&&this.tokenType!==17&&this.isDelim(va)===!1&&this.isBalanceEdge(e)===!1&&this.error(),t}var ku="Declaration",wu="declaration",vu={important:[Boolean,String],property:String,value:["Value","Raw"]};function yn(){let e=this.tokenStart,t=this.tokenIndex,r=Cu.call(this),n=Mt(r),o=n?this.parseCustomProperty:this.parseValue,i=n?xu:bu,s=!1,u;this.skipSC(),this.eat(16);let c=this.tokenIndex;if(n||this.skipSC(),o?u=this.parseWithFallback(yu,i):u=i.call(this,this.tokenIndex),n&&u.type==="Value"&&u.children.isEmpty){for(let a=c-this.tokenIndex;a<=0;a++)if(this.lookupType(a)===13){u.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}}return this.isDelim(va)&&(s=Au.call(this),this.skipSC()),this.eof===!1&&this.tokenType!==17&&this.isBalanceEdge(t)===!1&&this.error(),{type:"Declaration",loc:this.getLocation(e,this.tokenStart),important:s,property:r,value:u}}function Su(e){this.token(1,e.property),this.token(16,":"),this.node(e.value),e.important&&(this.token(9,"!"),this.token(1,e.important===!0?"important":e.important));}function Cu(){let e=this.tokenStart;if(this.tokenType===9)switch(this.charCodeAt(this.tokenStart)){case du:case mu:case gu:case hu:case fu:this.next();break;case wa:this.next(),this.isDelim(wa)&&this.next();break}return this.tokenType===4?this.eat(4):this.eat(1),this.substrToCursor(e)}function Au(){this.eat(9),this.skipSC();let e=this.consume(1);return e==="important"?!0:e}var Sn={};b(Sn,{generate:()=>Pu,name:()=>Eu,parse:()=>vn,structure:()=>Lu});var Tu=38;function wn(e){return this.Raw(e,this.consumeUntilSemicolonIncluded,!0)}var Eu="DeclarationList",Lu={children:[["Declaration","Atrule","Rule"]]};function vn(){let e=this.createList();for(;!this.eof;)switch(this.tokenType){case 13:case 25:case 17:this.next();break;case 3:e.push(this.parseWithFallback(this.Atrule.bind(this,!0),wn));break;default:this.isDelim(Tu)?e.push(this.parseWithFallback(this.Rule,wn)):e.push(this.parseWithFallback(this.Declaration,wn));}return {type:"DeclarationList",loc:this.getLocationFromList(e),children:e}}function Pu(e){this.children(e,t=>{t.type==="Declaration"&&this.token(17,";");});}var An={};b(An,{generate:()=>Ou,name:()=>Iu,parse:()=>Cn,structure:()=>Du});var Iu="Dimension",Du={value:String,unit:String};function Cn(){let e=this.tokenStart,t=this.consumeNumber(12);return {type:"Dimension",loc:this.getLocation(e,this.tokenStart),value:t,unit:this.substring(e+t.length,this.tokenStart)}}function Ou(e){this.token(12,e.value+e.unit);}var En={};b(En,{generate:()=>Ru,name:()=>Nu,parse:()=>Tn,structure:()=>Mu,walkContext:()=>zu});var Nu="Function",zu="function",Mu={name:String,children:[[]]};function Tn(e,t){let r=this.tokenStart,n=this.consumeFunctionName(),o=n.toLowerCase(),i;return i=t.hasOwnProperty(o)?t[o].call(this,t):e.call(this,t),this.eof||this.eat(22),{type:"Function",loc:this.getLocation(r,this.tokenStart),name:n,children:i}}function Ru(e){this.token(2,e.name+"("),this.children(e),this.token(22,")");}var Pn={};b(Pn,{generate:()=>Uu,name:()=>Bu,parse:()=>Ln,structure:()=>_u,xxx:()=>Fu});var Fu="XXX",Bu="Hash",_u={value:String};function Ln(){let e=this.tokenStart;return this.eat(4),{type:"Hash",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e+1)}}function Uu(e){this.token(4,"#"+e.value);}var Dn={};b(Dn,{generate:()=>Wu,name:()=>ju,parse:()=>In,structure:()=>qu});var ju="Identifier",qu={name:String};function In(){return {type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(1)}}function Wu(e){this.token(1,e.name);}var Nn={};b(Nn,{generate:()=>Gu,name:()=>Hu,parse:()=>On,structure:()=>Yu});var Hu="IdSelector",Yu={name:String};function On(){let e=this.tokenStart;return this.eat(4),{type:"IdSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e+1)}}function Gu(e){this.token(9,"#"+e.name);}var Mn={};b(Mn,{generate:()=>Qu,name:()=>Vu,parse:()=>zn,structure:()=>Ku});var Vu="MediaFeature",Ku={name:String,value:["Identifier","Number","Dimension","Ratio",null]};function zn(){let e=this.tokenStart,t,r=null;if(this.eat(21),this.skipSC(),t=this.consume(1),this.skipSC(),this.tokenType!==22){switch(this.eat(16),this.skipSC(),this.tokenType){case 10:this.lookupNonWSType(1)===9?r=this.Ratio():r=this.Number();break;case 12:r=this.Dimension();break;case 1:r=this.Identifier();break;default:this.error("Number, dimension, ratio or identifier is expected");}this.skipSC();}return this.eat(22),{type:"MediaFeature",loc:this.getLocation(e,this.tokenStart),name:t,value:r}}function Qu(e){this.token(21,"("),this.token(1,e.name),e.value!==null&&(this.token(16,":"),this.node(e.value)),this.token(22,")");}var Fn={};b(Fn,{generate:()=>Zu,name:()=>Xu,parse:()=>Rn,structure:()=>$u});var Xu="MediaQuery",$u={children:[["Identifier","MediaFeature","WhiteSpace"]]};function Rn(){let e=this.createList(),t=null;this.skipSC();e:for(;!this.eof;){switch(this.tokenType){case 25:case 13:this.next();continue;case 1:t=this.Identifier();break;case 21:t=this.MediaFeature();break;default:break e}e.push(t);}return t===null&&this.error("Identifier or parenthesis is expected"),{type:"MediaQuery",loc:this.getLocationFromList(e),children:e}}function Zu(e){this.children(e);}var _n={};b(_n,{generate:()=>tp,name:()=>Ju,parse:()=>Bn,structure:()=>ep});var Ju="MediaQueryList",ep={children:[["MediaQuery"]]};function Bn(){let e=this.createList();for(this.skipSC();!this.eof&&(e.push(this.MediaQuery()),this.tokenType===18);)this.next();return {type:"MediaQueryList",loc:this.getLocationFromList(e),children:e}}function tp(e){this.children(e,()=>this.token(18,","));}var jn={};b(jn,{generate:()=>ip,name:()=>np,parse:()=>Un,structure:()=>op});var rp=38,np="NestingSelector",op={};function Un(){let e=this.tokenStart;return this.eatDelim(rp),{type:"NestingSelector",loc:this.getLocation(e,this.tokenStart)}}function ip(){this.token(9,"&");}var Wn={};b(Wn,{generate:()=>lp,name:()=>ap,parse:()=>qn,structure:()=>sp});var ap="Nth",sp={nth:["AnPlusB","Identifier"],selector:["SelectorList",null]};function qn(){this.skipSC();let e=this.tokenStart,t=e,r=null,n;return this.lookupValue(0,"odd")||this.lookupValue(0,"even")?n=this.Identifier():n=this.AnPlusB(),t=this.tokenStart,this.skipSC(),this.lookupValue(0,"of")&&(this.next(),r=this.SelectorList(),t=this.tokenStart),{type:"Nth",loc:this.getLocation(e,t),nth:n,selector:r}}function lp(e){this.node(e.nth),e.selector!==null&&(this.token(1,"of"),this.node(e.selector));}var Yn={};b(Yn,{generate:()=>pp,name:()=>cp,parse:()=>Hn,structure:()=>up});var cp="Number",up={value:String};function Hn(){return {type:"Number",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consume(10)}}function pp(e){this.token(10,e.value);}var Vn={};b(Vn,{generate:()=>fp,name:()=>hp,parse:()=>Gn,structure:()=>mp});var hp="Operator",mp={value:String};function Gn(){let e=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function fp(e){this.tokenize(e.value);}var Qn={};b(Qn,{generate:()=>bp,name:()=>dp,parse:()=>Kn,structure:()=>gp});var dp="Parentheses",gp={children:[[]]};function Kn(e,t){let r=this.tokenStart,n=null;return this.eat(21),n=e.call(this,t),this.eof||this.eat(22),{type:"Parentheses",loc:this.getLocation(r,this.tokenStart),children:n}}function bp(e){this.token(21,"("),this.children(e),this.token(22,")");}var $n={};b($n,{generate:()=>kp,name:()=>xp,parse:()=>Xn,structure:()=>yp});var xp="Percentage",yp={value:String};function Xn(){return {type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(11)}}function kp(e){this.token(11,e.value+"%");}var Jn={};b(Jn,{generate:()=>Cp,name:()=>wp,parse:()=>Zn,structure:()=>Sp,walkContext:()=>vp});var wp="PseudoClassSelector",vp="function",Sp={name:String,children:[["Raw"],null]};function Zn(){let e=this.tokenStart,t=null,r,n;return this.eat(16),this.tokenType===2?(r=this.consumeFunctionName(),n=r.toLowerCase(),this.lookupNonWSType(0)==22?t=this.createList():hasOwnProperty.call(this.pseudo,n)?(this.skipSC(),t=this.pseudo[n].call(this),this.skipSC()):(t=this.createList(),t.push(this.Raw(this.tokenIndex,null,!1))),this.eat(22)):r=this.consume(1),{type:"PseudoClassSelector",loc:this.getLocation(e,this.tokenStart),name:r,children:t}}function Cp(e){this.token(16,":"),e.children===null?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"));}var to={};b(to,{generate:()=>Lp,name:()=>Ap,parse:()=>eo,structure:()=>Ep,walkContext:()=>Tp});var Ap="PseudoElementSelector",Tp="function",Ep={name:String,children:[["Raw"],null]};function eo(){let e=this.tokenStart,t=null,r,n;return this.eat(16),this.eat(16),this.tokenType===2?(r=this.consumeFunctionName(),n=r.toLowerCase(),this.lookupNonWSType(0)==22?t=this.createList():hasOwnProperty.call(this.pseudo,n)?(this.skipSC(),t=this.pseudo[n].call(this),this.skipSC()):(t=this.createList(),t.push(this.Raw(this.tokenIndex,null,!1))),this.eat(22)):r=this.consume(1),{type:"PseudoElementSelector",loc:this.getLocation(e,this.tokenStart),name:r,children:t}}function Lp(e){this.token(16,":"),this.token(16,":"),e.children===null?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"));}var no={};b(no,{generate:()=>Np,name:()=>Dp,parse:()=>ro,structure:()=>Op});var Pp=47,Ip=46;function Sa(){this.skipSC();let e=this.consume(10);for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);!B(r)&&r!==Ip&&this.error("Unsigned number is expected",this.tokenStart-e.length+t);}return Number(e)===0&&this.error("Zero number is not allowed",this.tokenStart-e.length),e}var Dp="Ratio",Op={left:String,right:String};function ro(){let e=this.tokenStart,t=Sa.call(this),r;return this.skipSC(),this.eatDelim(Pp),r=Sa.call(this),{type:"Ratio",loc:this.getLocation(e,this.tokenStart),left:t,right:r}}function Np(e){this.token(10,e.left),this.token(9,"/"),this.token(10,e.right);}var io={};b(io,{generate:()=>Fp,name:()=>Mp,parse:()=>oo,structure:()=>Rp});function zp(){return this.tokenIndex>0&&this.lookupType(-1)===13?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}var Mp="Raw",Rp={value:String};function oo(e,t,r){let n=this.getTokenStart(e),o;return this.skipUntilBalanced(e,t||this.consumeUntilBalanceEnd),r&&this.tokenStart>n?o=zp.call(this):o=this.tokenStart,{type:"Raw",loc:this.getLocation(n,o),value:this.substring(n,o)}}function Fp(e){this.tokenize(e.value);}var so={};b(so,{generate:()=>qp,name:()=>_p,parse:()=>ao,structure:()=>jp,walkContext:()=>Up});function Ca(e){return this.Raw(e,this.consumeUntilLeftCurlyBracket,!0)}function Bp(){let e=this.SelectorList();return e.type!=="Raw"&&this.eof===!1&&this.tokenType!==23&&this.error(),e}var _p="Rule",Up="rule",jp={prelude:["SelectorList","Raw"],block:["Block"]};function ao(){let e=this.tokenIndex,t=this.tokenStart,r,n;return this.parseRulePrelude?r=this.parseWithFallback(Bp,Ca):r=Ca.call(this,e),n=this.Block(!0),{type:"Rule",loc:this.getLocation(t,this.tokenStart),prelude:r,block:n}}function qp(e){this.node(e.prelude),this.node(e.block);}var co={};b(co,{generate:()=>Yp,name:()=>Wp,parse:()=>lo,structure:()=>Hp});var Wp="Selector",Hp={children:[["TypeSelector","IdSelector","ClassSelector","AttributeSelector","PseudoClassSelector","PseudoElementSelector","Combinator","WhiteSpace"]]};function lo(){let e=this.readSequence(this.scope.Selector);return this.getFirstListNode(e)===null&&this.error("Selector is expected"),{type:"Selector",loc:this.getLocationFromList(e),children:e}}function Yp(e){this.children(e);}var po={};b(po,{generate:()=>Qp,name:()=>Gp,parse:()=>uo,structure:()=>Kp,walkContext:()=>Vp});var Gp="SelectorList",Vp="selector",Kp={children:[["Selector","Raw"]]};function uo(){let e=this.createList();for(;!this.eof;){if(e.push(this.Selector()),this.tokenType===18){this.next();continue}break}return {type:"SelectorList",loc:this.getLocationFromList(e),children:e}}function Qp(e){this.children(e,()=>this.token(18,","));}var bo={};b(bo,{generate:()=>Zp,name:()=>Xp,parse:()=>go,structure:()=>$p});var fo={};b(fo,{decode:()=>ft,encode:()=>mo});var ho=92,Aa=34,Ta=39;function ft(e){let t=e.length,r=e.charCodeAt(0),n=r===Aa||r===Ta?1:0,o=n===1&&t>1&&e.charCodeAt(t-1)===r?t-2:t-1,i="";for(let s=n;s<=o;s++){let u=e.charCodeAt(s);if(u===ho){if(s===o){s!==t-1&&(i=e.substr(s+1));break}if(u=e.charCodeAt(++s),$(ho,u)){let c=s-1,a=se(e,c);s=a-1,i+=Re(e.substring(c+1,a));}else u===13&&e.charCodeAt(s+1)===10&&s++;}else i+=e[s];}return i}function mo(e,t){let r=t?"'":'"',n=t?Ta:Aa,o="",i=!1;for(let s=0;s<e.length;s++){let u=e.charCodeAt(s);if(u===0){o+="\uFFFD";continue}if(u<=31||u===127){o+="\\"+u.toString(16),i=!0;continue}u===n||u===ho?(o+="\\"+e.charAt(s),i=!1):(i&&(ee(u)||pe(u))&&(o+=" "),o+=e.charAt(s),i=!1);}return r+o+r}var Xp="String",$p={value:String};function go(){return {type:"String",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:ft(this.consume(5))}}function Zp(e){this.token(5,mo(e.value));}var yo={};b(yo,{generate:()=>nh,name:()=>eh,parse:()=>xo,structure:()=>rh,walkContext:()=>th});var Jp=33;function Ea(e){return this.Raw(e,null,!1)}var eh="StyleSheet",th="stylesheet",rh={children:[["Comment","CDO","CDC","Atrule","Rule","Raw"]]};function xo(){let e=this.tokenStart,t=this.createList(),r;for(;!this.eof;){switch(this.tokenType){case 13:this.next();continue;case 25:if(this.charCodeAt(this.tokenStart+2)!==Jp){this.next();continue}r=this.Comment();break;case 14:r=this.CDO();break;case 15:r=this.CDC();break;case 3:r=this.parseWithFallback(this.Atrule,Ea);break;default:r=this.parseWithFallback(this.Rule,Ea);}t.push(r);}return {type:"StyleSheet",loc:this.getLocation(e,this.tokenStart),children:t}}function nh(e){this.children(e);}var vo={};b(vo,{generate:()=>sh,name:()=>ih,parse:()=>wo,structure:()=>ah});var oh=42,La=124;function ko(){this.tokenType!==1&&this.isDelim(oh)===!1&&this.error("Identifier or asterisk is expected"),this.next();}var ih="TypeSelector",ah={name:String};function wo(){let e=this.tokenStart;return this.isDelim(La)?(this.next(),ko.call(this)):(ko.call(this),this.isDelim(La)&&(this.next(),ko.call(this))),{type:"TypeSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function sh(e){this.tokenize(e.name);}var Ao={};b(Ao,{generate:()=>hh,name:()=>uh,parse:()=>Co,structure:()=>ph});var Pa=43,Ia=45,So=63;function dt(e,t){let r=0;for(let n=this.tokenStart+e;n<this.tokenEnd;n++){let o=this.charCodeAt(n);if(o===Ia&&t&&r!==0)return dt.call(this,e+r+1,!1),-1;ee(o)||this.error(t&&r!==0?"Hyphen minus"+(r<6?" or hex digit":"")+" is expected":r<6?"Hex digit is expected":"Unexpected input",n),++r>6&&this.error("Too many hex digits",n);}return this.next(),r}function Jt(e){let t=0;for(;this.isDelim(So);)++t>e&&this.error("Too many question marks"),this.next();}function lh(e){this.charCodeAt(this.tokenStart)!==e&&this.error((e===Pa?"Plus sign":"Hyphen minus")+" is expected");}function ch(){let e=0;switch(this.tokenType){case 10:if(e=dt.call(this,1,!0),this.isDelim(So)){Jt.call(this,6-e);break}if(this.tokenType===12||this.tokenType===10){lh.call(this,Ia),dt.call(this,1,!1);break}break;case 12:e=dt.call(this,1,!0),e>0&&Jt.call(this,6-e);break;default:if(this.eatDelim(Pa),this.tokenType===1){e=dt.call(this,0,!0),e>0&&Jt.call(this,6-e);break}if(this.isDelim(So)){this.next(),Jt.call(this,5);break}this.error("Hex digit or question mark is expected");}}var uh="UnicodeRange",ph={value:String};function Co(){let e=this.tokenStart;return this.eatIdent("u"),ch.call(this),{type:"UnicodeRange",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function hh(e){this.tokenize(e.value);}var Do={};b(Do,{generate:()=>yh,name:()=>bh,parse:()=>Io,structure:()=>xh});var Po={};b(Po,{decode:()=>Eo,encode:()=>Lo});var mh=32,To=92,fh=34,dh=39,gh=40,Da=41;function Eo(e){let t=e.length,r=4,n=e.charCodeAt(t-1)===Da?t-2:t-1,o="";for(;r<n&&pe(e.charCodeAt(r));)r++;for(;r<n&&pe(e.charCodeAt(n));)n--;for(let i=r;i<=n;i++){let s=e.charCodeAt(i);if(s===To){if(i===n){i!==t-1&&(o=e.substr(i+1));break}if(s=e.charCodeAt(++i),$(To,s)){let u=i-1,c=se(e,u);i=c-1,o+=Re(e.substring(u+1,c));}else s===13&&e.charCodeAt(i+1)===10&&i++;}else o+=e[i];}return o}function Lo(e){let t="",r=!1;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);if(o===0){t+="\uFFFD";continue}if(o<=31||o===127){t+="\\"+o.toString(16),r=!0;continue}o===mh||o===To||o===fh||o===dh||o===gh||o===Da?(t+="\\"+e.charAt(n),r=!1):(r&&ee(o)&&(t+=" "),t+=e.charAt(n),r=!1);}return "url("+t+")"}var bh="Url",xh={value:String};function Io(){let e=this.tokenStart,t;switch(this.tokenType){case 7:t=Eo(this.consume(7));break;case 2:this.cmpStr(this.tokenStart,this.tokenEnd,"url(")||this.error("Function name must be `url`"),this.eat(2),this.skipSC(),t=ft(this.consume(5)),this.skipSC(),this.eof||this.eat(22);break;default:this.error("Url or Function is expected");}return {type:"Url",loc:this.getLocation(e,this.tokenStart),value:t}}function yh(e){this.token(7,Lo(e.value));}var No={};b(No,{generate:()=>vh,name:()=>kh,parse:()=>Oo,structure:()=>wh});var kh="Value",wh={children:[[]]};function Oo(){let e=this.tokenStart,t=this.readSequence(this.scope.Value);return {type:"Value",loc:this.getLocation(e,this.tokenStart),children:t}}function vh(e){this.children(e);}var Mo={};b(Mo,{generate:()=>Th,name:()=>Ch,parse:()=>zo,structure:()=>Ah});var Sh=Object.freeze({type:"WhiteSpace",loc:null,value:" "}),Ch="WhiteSpace",Ah={value:String};function zo(){return this.eat(13),Sh}function Th(e){this.token(13,e.value);}var Oa={generic:!0,...fa,node:gt};var Ro={};b(Ro,{AtrulePrelude:()=>za,Selector:()=>Ra,Value:()=>Ua});var Eh=35,Lh=42,Na=43,Ph=45,Ih=47,Dh=117;function bt(e){switch(this.tokenType){case 4:return this.Hash();case 18:return this.Operator();case 21:return this.Parentheses(this.readSequence,e.recognizer);case 19:return this.Brackets(this.readSequence,e.recognizer);case 5:return this.String();case 12:return this.Dimension();case 11:return this.Percentage();case 10:return this.Number();case 2:return this.cmpStr(this.tokenStart,this.tokenEnd,"url(")?this.Url():this.Function(this.readSequence,e.recognizer);case 7:return this.Url();case 1:return this.cmpChar(this.tokenStart,Dh)&&this.cmpChar(this.tokenStart+1,Na)?this.UnicodeRange():this.Identifier();case 9:{let t=this.charCodeAt(this.tokenStart);if(t===Ih||t===Lh||t===Na||t===Ph)return this.Operator();t===Eh&&this.error("Hex or identifier is expected",this.tokenStart+1);break}}}var za={getNode:bt};var Oh=35,Nh=38,zh=42,Mh=43,Rh=47,Ma=46,Fh=62,Bh=124,_h=126;function Uh(e,t){t.last!==null&&t.last.type!=="Combinator"&&e!==null&&e.type!=="Combinator"&&t.push({type:"Combinator",loc:null,name:" "});}function jh(){switch(this.tokenType){case 19:return this.AttributeSelector();case 4:return this.IdSelector();case 16:return this.lookupType(1)===16?this.PseudoElementSelector():this.PseudoClassSelector();case 1:return this.TypeSelector();case 10:case 11:return this.Percentage();case 12:this.charCodeAt(this.tokenStart)===Ma&&this.error("Identifier is expected",this.tokenStart+1);break;case 9:{switch(this.charCodeAt(this.tokenStart)){case Mh:case Fh:case _h:case Rh:return this.Combinator();case Ma:return this.ClassSelector();case zh:case Bh:return this.TypeSelector();case Oh:return this.IdSelector();case Nh:return this.NestingSelector()}break}}}var Ra={onWhiteSpace:Uh,getNode:jh};function Fa(){return this.createSingleNodeList(this.Raw(this.tokenIndex,null,!1))}function Ba(){let e=this.createList();if(this.skipSC(),e.push(this.Identifier()),this.skipSC(),this.tokenType===18){e.push(this.Operator());let t=this.tokenIndex,r=this.parseCustomProperty?this.Value(null):this.Raw(this.tokenIndex,this.consumeUntilExclamationMarkOrSemicolon,!1);if(r.type==="Value"&&r.children.isEmpty){for(let n=t-this.tokenIndex;n<=0;n++)if(this.lookupType(n)===13){r.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}}e.push(r);}return e}function _a(e){return e!==null&&e.type==="Operator"&&(e.value[e.value.length-1]==="-"||e.value[e.value.length-1]==="+")}var Ua={getNode:bt,onWhiteSpace(e,t){_a(e)&&(e.value=" "+e.value),_a(t.last)&&(t.last.value+=" ");},expression:Fa,var:Ba};var ja={parse:{prelude:null,block(){return this.Block(!0)}}};var qa={parse:{prelude(){let e=this.createList();switch(this.skipSC(),this.tokenType){case 5:e.push(this.String());break;case 7:case 2:e.push(this.Url());break;default:this.error("String or url() is expected");}return (this.lookupNonWSType(0)===1||this.lookupNonWSType(0)===21)&&e.push(this.MediaQueryList()),e},block:null}};var Wa={parse:{prelude(){return this.createSingleNodeList(this.MediaQueryList())},block(e=!1){return this.Block(e)}}};var Ha={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}};var Ya={parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}};function qh(){return this.createSingleNodeList(this.Raw(this.tokenIndex,null,!1))}function Wh(){return this.skipSC(),this.tokenType===1&&this.lookupNonWSType(1)===16?this.createSingleNodeList(this.Declaration()):Ga.call(this)}function Ga(){let e=this.createList(),t;this.skipSC();e:for(;!this.eof;){switch(this.tokenType){case 25:case 13:this.next();continue;case 2:t=this.Function(qh,this.scope.AtrulePrelude);break;case 1:t=this.Identifier();break;case 21:t=this.Parentheses(Wh,this.scope.AtrulePrelude);break;default:break e}e.push(t);}return e}var Va={parse:{prelude(){let e=Ga.call(this);return this.getFirstListNode(e)===null&&this.error("Condition is expected"),e},block(e=!1){return this.Block(e)}}};var Ka={"font-face":ja,import:qa,media:Wa,nest:Ha,page:Ya,supports:Va};var De={parse(){return this.createSingleNodeList(this.SelectorList())}},Fo={parse(){return this.createSingleNodeList(this.Selector())}},Qa={parse(){return this.createSingleNodeList(this.Identifier())}},er={parse(){return this.createSingleNodeList(this.Nth())}},Xa={dir:Qa,has:De,lang:Qa,matches:De,is:De,"-moz-any":De,"-webkit-any":De,where:De,not:De,"nth-child":er,"nth-last-child":er,"nth-last-of-type":er,"nth-of-type":er,slotted:Fo,host:Fo,"host-context":Fo};var Bo={};b(Bo,{AnPlusB:()=>Qr,Atrule:()=>$r,AtrulePrelude:()=>Jr,AttributeSelector:()=>rn,Block:()=>on,Brackets:()=>sn,CDC:()=>cn,CDO:()=>pn,ClassSelector:()=>mn,Combinator:()=>dn,Comment:()=>bn,Declaration:()=>yn,DeclarationList:()=>vn,Dimension:()=>Cn,Function:()=>Tn,Hash:()=>Ln,IdSelector:()=>On,Identifier:()=>In,MediaFeature:()=>zn,MediaQuery:()=>Rn,MediaQueryList:()=>Bn,NestingSelector:()=>Un,Nth:()=>qn,Number:()=>Hn,Operator:()=>Gn,Parentheses:()=>Kn,Percentage:()=>Xn,PseudoClassSelector:()=>Zn,PseudoElementSelector:()=>eo,Ratio:()=>ro,Raw:()=>oo,Rule:()=>ao,Selector:()=>lo,SelectorList:()=>uo,String:()=>go,StyleSheet:()=>xo,TypeSelector:()=>wo,UnicodeRange:()=>Co,Url:()=>Io,Value:()=>Oo,WhiteSpace:()=>zo});var $a={parseContext:{default:"StyleSheet",stylesheet:"StyleSheet",atrule:"Atrule",atrulePrelude(e){return this.AtrulePrelude(e.atrule?String(e.atrule):null)},mediaQueryList:"MediaQueryList",mediaQuery:"MediaQuery",rule:"Rule",selectorList:"SelectorList",selector:"Selector",block(){return this.Block(!0)},declarationList:"DeclarationList",declaration:"Declaration",value:"Value"},scope:Ro,atrule:Ka,pseudo:Xa,node:Bo};var Za={node:gt};var Ja=Vr({...Oa,...$a,...Za});var ts={};b(ts,{decode:()=>Hh,encode:()=>Yh});var es=92;function Hh(e){let t=e.length-1,r="";for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);if(o===es){if(n===t)break;if(o=e.charCodeAt(++n),$(es,o)){let i=n-1,s=se(e,i);n=s-1,r+=Re(e.substring(i+1,s));}else o===13&&e.charCodeAt(n+1)===10&&n++;}else r+=e[n];}return r}function Yh(e){let t="";if(e.length===1&&e.charCodeAt(0)===45)return "\\-";for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n===0){t+="\uFFFD";continue}if(n<=31||n===127||n>=48&&n<=57&&(r===0||r===1&&e.charCodeAt(0)===45)){t+="\\"+n.toString(16)+" ";continue}Ne(n)?t+=e.charAt(r):t+="\\"+e.charAt(r);}return t}var{tokenize:fb,parse:db,generate:gb,lexer:bb,createLexer:xb,walk:yb,find:kb,findLast:wb,findAll:vb,toPlainObject:Sb,fromPlainObject:Cb,fork:Ab}=Ja;
  672. /*
  673. * The MIT License (MIT)
  674. *
  675. * Author: Gildas Lormeau
  676. *
  677. * Permission is hereby granted, free of charge, to any person obtaining a copy
  678. * of this software and associated documentation files (the "Software"), to deal
  679. * in the Software without restriction, including without limitation the rights
  680. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  681. * copies of the Software, and to permit persons to whom the Software is
  682. * furnished to do so, subject to the following conditions:
  683. *
  684. * The above copyright notice and this permission notice shall be included in all
  685. * copies or substantial portions of the Software.
  686. *
  687. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  688. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  689. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  690. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  691. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  692. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  693. * SOFTWARE.
  694. */
  695. const REGEXP_SIMPLE_QUOTES_STRING$1 = /^'(.*?)'$/;
  696. const REGEXP_DOUBLE_QUOTES_STRING$1 = /^"(.*?)"$/;
  697. const globalKeywords = [
  698. "inherit",
  699. "initial",
  700. "unset"
  701. ];
  702. const systemFontKeywords = [
  703. "caption",
  704. "icon",
  705. "menu",
  706. "message-box",
  707. "small-caption",
  708. "status-bar"
  709. ];
  710. const fontWeightKeywords = [
  711. "normal",
  712. "bold",
  713. "bolder",
  714. "lighter",
  715. "100",
  716. "200",
  717. "300",
  718. "400",
  719. "500",
  720. "600",
  721. "700",
  722. "800",
  723. "900"
  724. ];
  725. const fontStyleKeywords = [
  726. "normal",
  727. "italic",
  728. "oblique"
  729. ];
  730. const fontStretchKeywords = [
  731. "normal",
  732. "condensed",
  733. "semi-condensed",
  734. "extra-condensed",
  735. "ultra-condensed",
  736. "expanded",
  737. "semi-expanded",
  738. "extra-expanded",
  739. "ultra-expanded"
  740. ];
  741. const errorPrefix = "[parse-css-font] ";
  742. function parse(value) {
  743. const stringValue = gb(value);
  744. if (systemFontKeywords.indexOf(stringValue) !== -1) {
  745. return { system: stringValue };
  746. }
  747. const tokens = value.children;
  748. const font = {
  749. lineHeight: "normal",
  750. stretch: "normal",
  751. style: "normal",
  752. variant: "normal",
  753. weight: "normal",
  754. };
  755. let isLocked = false;
  756. for (let tokenNode = tokens.head; tokenNode; tokenNode = tokenNode.next) {
  757. const token = gb(tokenNode.data);
  758. if (token === "normal" || globalKeywords.indexOf(token) !== -1) {
  759. ["style", "variant", "weight", "stretch"].forEach((prop) => {
  760. font[prop] = token;
  761. });
  762. isLocked = true;
  763. continue;
  764. }
  765. if (fontWeightKeywords.indexOf(token) !== -1) {
  766. if (isLocked) {
  767. continue;
  768. }
  769. font.weight = token;
  770. continue;
  771. }
  772. if (fontStyleKeywords.indexOf(token) !== -1) {
  773. if (isLocked) {
  774. continue;
  775. }
  776. font.style = token;
  777. continue;
  778. }
  779. if (fontStretchKeywords.indexOf(token) !== -1) {
  780. if (isLocked) {
  781. continue;
  782. }
  783. font.stretch = token;
  784. continue;
  785. }
  786. if (tokenNode.data.type == "Dimension") {
  787. font.size = gb(tokenNode.data);
  788. tokenNode = tokenNode.next;
  789. if (tokenNode && tokenNode.data.type == "Operator" && tokenNode.data.value == "/" && tokenNode.next) {
  790. tokenNode = tokenNode.next;
  791. font.lineHeight = gb(tokenNode.data);
  792. tokenNode = tokenNode.next;
  793. } else if (tokens.head.data.type == "Operator" && tokens.head.data.value == "/" && tokens.head.next) {
  794. font.lineHeight = gb(tokens.head.next.data);
  795. tokenNode = tokens.head.next.next;
  796. }
  797. if (!tokenNode) {
  798. throw error("Missing required font-family.");
  799. }
  800. font.family = [];
  801. let familyName = "";
  802. while (tokenNode) {
  803. while (tokenNode && tokenNode.data.type == "Operator" && tokenNode.data.value == ",") {
  804. tokenNode = tokenNode.next;
  805. }
  806. if (tokenNode) {
  807. if (tokenNode.data.type == "Identifier") {
  808. while (tokenNode && tokenNode.data.type == "Identifier") {
  809. familyName += " " + gb(tokenNode.data);
  810. tokenNode = tokenNode.next;
  811. }
  812. } else {
  813. familyName = removeQuotes$1(gb(tokenNode.data));
  814. tokenNode = tokenNode.next;
  815. }
  816. }
  817. familyName = familyName.trim();
  818. if (familyName) {
  819. font.family.push(familyName);
  820. familyName = "";
  821. }
  822. }
  823. return font;
  824. }
  825. if (font.variant !== "normal") {
  826. throw error("Unknown or unsupported font token: " + font.variant);
  827. }
  828. if (isLocked) {
  829. continue;
  830. }
  831. font.variant = token;
  832. }
  833. throw error("Missing required font-size.");
  834. }
  835. function error(message) {
  836. return new Error(errorPrefix + message);
  837. }
  838. function removeQuotes$1(string) {
  839. if (string.match(REGEXP_SIMPLE_QUOTES_STRING$1)) {
  840. string = string.replace(REGEXP_SIMPLE_QUOTES_STRING$1, "$1");
  841. } else {
  842. string = string.replace(REGEXP_DOUBLE_QUOTES_STRING$1, "$1");
  843. }
  844. return string.trim();
  845. }
  846. /*
  847. * The MIT License (MIT)
  848. *
  849. * Author: Gildas Lormeau
  850. *
  851. * Permission is hereby granted, free of charge, to any person obtaining a copy
  852. * of this software and associated documentation files (the "Software"), to deal
  853. * in the Software without restriction, including without limitation the rights
  854. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  855. * copies of the Software, and to permit persons to whom the Software is
  856. * furnished to do so, subject to the following conditions:
  857. *
  858. * The above copyright notice and this permission notice shall be included in all
  859. * copies or substantial portions of the Software.
  860. *
  861. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  862. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  863. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  864. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  865. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  866. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  867. * SOFTWARE.
  868. */
  869. // derived from https://github.com/dryoma/postcss-media-query-parser
  870. /*
  871. * The MIT License (MIT)
  872. *
  873. * Permission is hereby granted, free of charge, to any person obtaining a copy
  874. * of this software and associated documentation files (the "Software"), to deal
  875. * in the Software without restriction, including without limitation the rights
  876. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  877. * copies of the Software, and to permit persons to whom the Software is
  878. * furnished to do so, subject to the following conditions:
  879. *
  880. * The above copyright notice and this permission notice shall be included in
  881. * all copies or substantial portions of the Software.
  882. *
  883. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  884. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  885. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  886. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  887. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  888. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  889. * THE SOFTWARE.
  890. */
  891. /**
  892. * Parses a media feature expression, e.g. `max-width: 10px`, `(color)`
  893. *
  894. * @param {string} string - the source expression string, can be inside parens
  895. * @param {Number} index - the index of `string` in the overall input
  896. *
  897. * @return {Array} an array of Nodes, the first element being a media feature,
  898. * the second - its value (may be missing)
  899. */
  900. function parseMediaFeature(string, index = 0) {
  901. const modesEntered = [{
  902. mode: "normal",
  903. character: null,
  904. }];
  905. const result = [];
  906. let lastModeIndex = 0, mediaFeature = "", colon = null, mediaFeatureValue = null, indexLocal = index;
  907. let stringNormalized = string;
  908. // Strip trailing parens (if any), and correct the starting index
  909. if (string[0] === "(" && string[string.length - 1] === ")") {
  910. stringNormalized = string.substring(1, string.length - 1);
  911. indexLocal++;
  912. }
  913. for (let i = 0; i < stringNormalized.length; i++) {
  914. const character = stringNormalized[i];
  915. // If entering/exiting a string
  916. if (character === "'" || character === "\"") {
  917. if (modesEntered[lastModeIndex].isCalculationEnabled === true) {
  918. modesEntered.push({
  919. mode: "string",
  920. isCalculationEnabled: false,
  921. character,
  922. });
  923. lastModeIndex++;
  924. } else if (modesEntered[lastModeIndex].mode === "string" &&
  925. modesEntered[lastModeIndex].character === character &&
  926. stringNormalized[i - 1] !== "\\"
  927. ) {
  928. modesEntered.pop();
  929. lastModeIndex--;
  930. }
  931. }
  932. // If entering/exiting interpolation
  933. if (character === "{") {
  934. modesEntered.push({
  935. mode: "interpolation",
  936. isCalculationEnabled: true,
  937. });
  938. lastModeIndex++;
  939. } else if (character === "}") {
  940. modesEntered.pop();
  941. lastModeIndex--;
  942. }
  943. // If a : is met outside of a string, function call or interpolation, than
  944. // this : separates a media feature and a value
  945. if (modesEntered[lastModeIndex].mode === "normal" && character === ":") {
  946. const mediaFeatureValueStr = stringNormalized.substring(i + 1);
  947. mediaFeatureValue = {
  948. type: "value",
  949. before: /^(\s*)/.exec(mediaFeatureValueStr)[1],
  950. after: /(\s*)$/.exec(mediaFeatureValueStr)[1],
  951. value: mediaFeatureValueStr.trim(),
  952. };
  953. // +1 for the colon
  954. mediaFeatureValue.sourceIndex =
  955. mediaFeatureValue.before.length + i + 1 + indexLocal;
  956. colon = {
  957. type: "colon",
  958. sourceIndex: i + indexLocal,
  959. after: mediaFeatureValue.before,
  960. value: ":", // for consistency only
  961. };
  962. break;
  963. }
  964. mediaFeature += character;
  965. }
  966. // Forming a media feature node
  967. mediaFeature = {
  968. type: "media-feature",
  969. before: /^(\s*)/.exec(mediaFeature)[1],
  970. after: /(\s*)$/.exec(mediaFeature)[1],
  971. value: mediaFeature.trim(),
  972. };
  973. mediaFeature.sourceIndex = mediaFeature.before.length + indexLocal;
  974. result.push(mediaFeature);
  975. if (colon !== null) {
  976. colon.before = mediaFeature.after;
  977. result.push(colon);
  978. }
  979. if (mediaFeatureValue !== null) {
  980. result.push(mediaFeatureValue);
  981. }
  982. return result;
  983. }
  984. /**
  985. * Parses a media query, e.g. `screen and (color)`, `only tv`
  986. *
  987. * @param {string} string - the source media query string
  988. * @param {Number} index - the index of `string` in the overall input
  989. *
  990. * @return {Array} an array of Nodes and Containers
  991. */
  992. function parseMediaQuery(string, index = 0) {
  993. const result = [];
  994. // How many times the parser entered parens/curly braces
  995. let localLevel = 0;
  996. // Has any keyword, media type, media feature expression or interpolation
  997. // ('element' hereafter) started
  998. let insideSomeValue = false, node;
  999. function resetNode() {
  1000. return {
  1001. before: "",
  1002. after: "",
  1003. value: "",
  1004. };
  1005. }
  1006. node = resetNode();
  1007. for (let i = 0; i < string.length; i++) {
  1008. const character = string[i];
  1009. // If not yet entered any element
  1010. if (!insideSomeValue) {
  1011. if (character.search(/\s/) !== -1) {
  1012. // A whitespace
  1013. // Don't form 'after' yet; will do it later
  1014. node.before += character;
  1015. } else {
  1016. // Not a whitespace - entering an element
  1017. // Expression start
  1018. if (character === "(") {
  1019. node.type = "media-feature-expression";
  1020. localLevel++;
  1021. }
  1022. node.value = character;
  1023. node.sourceIndex = index + i;
  1024. insideSomeValue = true;
  1025. }
  1026. } else {
  1027. // Already in the middle of some element
  1028. node.value += character;
  1029. // Here parens just increase localLevel and don't trigger a start of
  1030. // a media feature expression (since they can't be nested)
  1031. // Interpolation start
  1032. if (character === "{" || character === "(") { localLevel++; }
  1033. // Interpolation/function call/media feature expression end
  1034. if (character === ")" || character === "}") { localLevel--; }
  1035. }
  1036. // If exited all parens/curlies and the next symbol
  1037. if (insideSomeValue && localLevel === 0 &&
  1038. (character === ")" || i === string.length - 1 ||
  1039. string[i + 1].search(/\s/) !== -1)
  1040. ) {
  1041. if (["not", "only", "and"].indexOf(node.value) !== -1) {
  1042. node.type = "keyword";
  1043. }
  1044. // if it's an expression, parse its contents
  1045. if (node.type === "media-feature-expression") {
  1046. node.nodes = parseMediaFeature(node.value, node.sourceIndex);
  1047. }
  1048. result.push(Array.isArray(node.nodes) ?
  1049. new Container(node) : new Node$1(node));
  1050. node = resetNode();
  1051. insideSomeValue = false;
  1052. }
  1053. }
  1054. // Now process the result array - to specify undefined types of the nodes
  1055. // and specify the `after` prop
  1056. for (let i = 0; i < result.length; i++) {
  1057. node = result[i];
  1058. if (i > 0) { result[i - 1].after = node.before; }
  1059. // Node types. Might not be set because contains interpolation/function
  1060. // calls or fully consists of them
  1061. if (node.type === undefined) {
  1062. if (i > 0) {
  1063. // only `and` can follow an expression
  1064. if (result[i - 1].type === "media-feature-expression") {
  1065. node.type = "keyword";
  1066. continue;
  1067. }
  1068. // Anything after 'only|not' is a media type
  1069. if (result[i - 1].value === "not" || result[i - 1].value === "only") {
  1070. node.type = "media-type";
  1071. continue;
  1072. }
  1073. // Anything after 'and' is an expression
  1074. if (result[i - 1].value === "and") {
  1075. node.type = "media-feature-expression";
  1076. continue;
  1077. }
  1078. if (result[i - 1].type === "media-type") {
  1079. // if it is the last element - it might be an expression
  1080. // or 'and' depending on what is after it
  1081. if (!result[i + 1]) {
  1082. node.type = "media-feature-expression";
  1083. } else {
  1084. node.type = result[i + 1].type === "media-feature-expression" ?
  1085. "keyword" : "media-feature-expression";
  1086. }
  1087. }
  1088. }
  1089. if (i === 0) {
  1090. // `screen`, `fn( ... )`, `#{ ... }`. Not an expression, since then
  1091. // its type would have been set by now
  1092. if (!result[i + 1]) {
  1093. node.type = "media-type";
  1094. continue;
  1095. }
  1096. // `screen and` or `#{...} (max-width: 10px)`
  1097. if (result[i + 1] &&
  1098. (result[i + 1].type === "media-feature-expression" ||
  1099. result[i + 1].type === "keyword")
  1100. ) {
  1101. node.type = "media-type";
  1102. continue;
  1103. }
  1104. if (result[i + 2]) {
  1105. // `screen and (color) ...`
  1106. if (result[i + 2].type === "media-feature-expression") {
  1107. node.type = "media-type";
  1108. result[i + 1].type = "keyword";
  1109. continue;
  1110. }
  1111. // `only screen and ...`
  1112. if (result[i + 2].type === "keyword") {
  1113. node.type = "keyword";
  1114. result[i + 1].type = "media-type";
  1115. continue;
  1116. }
  1117. }
  1118. if (result[i + 3]) {
  1119. // `screen and (color) ...`
  1120. if (result[i + 3].type === "media-feature-expression") {
  1121. node.type = "keyword";
  1122. result[i + 1].type = "media-type";
  1123. result[i + 2].type = "keyword";
  1124. continue;
  1125. }
  1126. }
  1127. }
  1128. }
  1129. }
  1130. return result;
  1131. }
  1132. /**
  1133. * Parses a media query list. Takes a possible `url()` at the start into
  1134. * account, and divides the list into media queries that are parsed separately
  1135. *
  1136. * @param {string} string - the source media query list string
  1137. *
  1138. * @return {Array} an array of Nodes/Containers
  1139. */
  1140. function parseMediaList(string) {
  1141. const result = [];
  1142. let interimIndex = 0, levelLocal = 0;
  1143. // Check for a `url(...)` part (if it is contents of an @import rule)
  1144. const doesHaveUrl = /^(\s*)url\s*\(/.exec(string);
  1145. if (doesHaveUrl !== null) {
  1146. let i = doesHaveUrl[0].length;
  1147. let parenthesesLv = 1;
  1148. while (parenthesesLv > 0) {
  1149. const character = string[i];
  1150. if (character === "(") { parenthesesLv++; }
  1151. if (character === ")") { parenthesesLv--; }
  1152. i++;
  1153. }
  1154. result.unshift(new Node$1({
  1155. type: "url",
  1156. value: string.substring(0, i).trim(),
  1157. sourceIndex: doesHaveUrl[1].length,
  1158. before: doesHaveUrl[1],
  1159. after: /^(\s*)/.exec(string.substring(i))[1],
  1160. }));
  1161. interimIndex = i;
  1162. }
  1163. // Start processing the media query list
  1164. for (let i = interimIndex; i < string.length; i++) {
  1165. const character = string[i];
  1166. // Dividing the media query list into comma-separated media queries
  1167. // Only count commas that are outside of any parens
  1168. // (i.e., not part of function call params list, etc.)
  1169. if (character === "(") { levelLocal++; }
  1170. if (character === ")") { levelLocal--; }
  1171. if (levelLocal === 0 && character === ",") {
  1172. const mediaQueryString = string.substring(interimIndex, i);
  1173. const spaceBefore = /^(\s*)/.exec(mediaQueryString)[1];
  1174. result.push(new Container({
  1175. type: "media-query",
  1176. value: mediaQueryString.trim(),
  1177. sourceIndex: interimIndex + spaceBefore.length,
  1178. nodes: parseMediaQuery(mediaQueryString, interimIndex),
  1179. before: spaceBefore,
  1180. after: /(\s*)$/.exec(mediaQueryString)[1],
  1181. }));
  1182. interimIndex = i + 1;
  1183. }
  1184. }
  1185. const mediaQueryString = string.substring(interimIndex);
  1186. const spaceBefore = /^(\s*)/.exec(mediaQueryString)[1];
  1187. result.push(new Container({
  1188. type: "media-query",
  1189. value: mediaQueryString.trim(),
  1190. sourceIndex: interimIndex + spaceBefore.length,
  1191. nodes: parseMediaQuery(mediaQueryString, interimIndex),
  1192. before: spaceBefore,
  1193. after: /(\s*)$/.exec(mediaQueryString)[1],
  1194. }));
  1195. return result;
  1196. }
  1197. function Container(opts) {
  1198. this.constructor(opts);
  1199. this.nodes = opts.nodes;
  1200. if (this.after === undefined) {
  1201. this.after = this.nodes.length > 0 ?
  1202. this.nodes[this.nodes.length - 1].after : "";
  1203. }
  1204. if (this.before === undefined) {
  1205. this.before = this.nodes.length > 0 ?
  1206. this.nodes[0].before : "";
  1207. }
  1208. if (this.sourceIndex === undefined) {
  1209. this.sourceIndex = this.before.length;
  1210. }
  1211. this.nodes.forEach(node => {
  1212. node.parent = this; // eslint-disable-line no-param-reassign
  1213. });
  1214. }
  1215. Container.prototype = Object.create(Node$1.prototype);
  1216. Container.constructor = Node$1;
  1217. /**
  1218. * Iterate over descendant nodes of the node
  1219. *
  1220. * @param {RegExp|string} filter - Optional. Only nodes with node.type that
  1221. * satisfies the filter will be traversed over
  1222. * @param {function} cb - callback to call on each node. Takes these params:
  1223. * node - the node being processed, i - it's index, nodes - the array
  1224. * of all nodes
  1225. * If false is returned, the iteration breaks
  1226. *
  1227. * @return (boolean) false, if the iteration was broken
  1228. */
  1229. Container.prototype.walk = function walk(filter, cb) {
  1230. const hasFilter = typeof filter === "string" || filter instanceof RegExp;
  1231. const callback = hasFilter ? cb : filter;
  1232. const filterReg = typeof filter === "string" ? new RegExp(filter) : filter;
  1233. for (let i = 0; i < this.nodes.length; i++) {
  1234. const node = this.nodes[i];
  1235. const filtered = hasFilter ? filterReg.test(node.type) : true;
  1236. if (filtered && callback && callback(node, i, this.nodes) === false) {
  1237. return false;
  1238. }
  1239. if (node.nodes && node.walk(filter, cb) === false) { return false; }
  1240. }
  1241. return true;
  1242. };
  1243. /**
  1244. * Iterate over immediate children of the node
  1245. *
  1246. * @param {function} cb - callback to call on each node. Takes these params:
  1247. * node - the node being processed, i - it's index, nodes - the array
  1248. * of all nodes
  1249. * If false is returned, the iteration breaks
  1250. *
  1251. * @return (boolean) false, if the iteration was broken
  1252. */
  1253. Container.prototype.each = function each(cb = () => { }) {
  1254. for (let i = 0; i < this.nodes.length; i++) {
  1255. const node = this.nodes[i];
  1256. if (cb(node, i, this.nodes) === false) { return false; }
  1257. }
  1258. return true;
  1259. };
  1260. /**
  1261. * A very generic node. Pretty much any element of a media query
  1262. */
  1263. function Node$1(opts) {
  1264. this.after = opts.after;
  1265. this.before = opts.before;
  1266. this.type = opts.type;
  1267. this.value = opts.value;
  1268. this.sourceIndex = opts.sourceIndex;
  1269. }
  1270. /*
  1271. * The MIT License (MIT)
  1272. *
  1273. * Author: Gildas Lormeau
  1274. *
  1275. * Permission is hereby granted, free of charge, to any person obtaining a copy
  1276. * of this software and associated documentation files (the "Software"), to deal
  1277. * in the Software without restriction, including without limitation the rights
  1278. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1279. * copies of the Software, and to permit persons to whom the Software is
  1280. * furnished to do so, subject to the following conditions:
  1281. *
  1282. * The above copyright notice and this permission notice shall be included in all
  1283. * copies or substantial portions of the Software.
  1284. *
  1285. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1286. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1287. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1288. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1289. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1290. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  1291. * SOFTWARE.
  1292. */
  1293. // derived from https://github.com/fmarcia/UglifyCSS
  1294. /**
  1295. * UglifyCSS
  1296. * Port of YUI CSS Compressor to NodeJS
  1297. * Author: Franck Marcia - https://github.com/fmarcia
  1298. * MIT licenced
  1299. */
  1300. /**
  1301. * cssmin.js
  1302. * Author: Stoyan Stefanov - http://phpied.com/
  1303. * This is a JavaScript port of the CSS minification tool
  1304. * distributed with YUICompressor, itself a port
  1305. * of the cssmin utility by Isaac Schlueter - http://foohack.com/
  1306. * Permission is hereby granted to use the JavaScript version under the same
  1307. * conditions as the YUICompressor (original YUICompressor note below).
  1308. */
  1309. /**
  1310. * YUI Compressor
  1311. * http://developer.yahoo.com/yui/compressor/
  1312. * Author: Julien Lecomte - http://www.julienlecomte.net/
  1313. * Copyright (c) 2011 Yahoo! Inc. All rights reserved.
  1314. * The copyrights embodied in the content of this file are licensed
  1315. * by Yahoo! Inc. under the BSD (revised) open source license.
  1316. */
  1317. /**
  1318. * @type {string} - placeholder prefix
  1319. */
  1320. const ___PRESERVED_TOKEN_ = "___PRESERVED_TOKEN_";
  1321. /**
  1322. * @typedef {object} options - UglifyCSS options
  1323. * @property {number} [maxLineLen=0] - Maximum line length of uglified CSS
  1324. * @property {boolean} [expandVars=false] - Expand variables
  1325. * @property {boolean} [uglyComments=false] - Removes newlines within preserved comments
  1326. * @property {boolean} [cuteComments=false] - Preserves newlines within and around preserved comments
  1327. * @property {boolean} [debug=false] - Prints full error stack on error
  1328. * @property {string} [output=''] - Output file name
  1329. */
  1330. /**
  1331. * @type {options} - UglifyCSS options
  1332. */
  1333. const defaultOptions = {
  1334. maxLineLen: 0,
  1335. expandVars: false,
  1336. uglyComments: false,
  1337. cuteComments: false,
  1338. debug: false,
  1339. output: ""
  1340. };
  1341. const REGEXP_DATA_URI = /url\(\s*(["']?)data:/g;
  1342. const REGEXP_WHITE_SPACES = /\s+/g;
  1343. const REGEXP_NEW_LINE = /\n/g;
  1344. /**
  1345. * extractDataUrls replaces all data urls with tokens before we start
  1346. * compressing, to avoid performance issues running some of the subsequent
  1347. * regexes against large strings chunks.
  1348. *
  1349. * @param {string} css - CSS content
  1350. * @param {string[]} preservedTokens - Global array of tokens to preserve
  1351. *
  1352. * @return {string} Processed CSS
  1353. */
  1354. function extractDataUrls(css, preservedTokens) {
  1355. // Leave data urls alone to increase parse performance.
  1356. const pattern = REGEXP_DATA_URI;
  1357. const maxIndex = css.length - 1;
  1358. const sb = [];
  1359. let appendIndex = 0, match;
  1360. // Since we need to account for non-base64 data urls, we need to handle
  1361. // ' and ) being part of the data string. Hence switching to indexOf,
  1362. // to determine whether or not we have matching string terminators and
  1363. // handling sb appends directly, instead of using matcher.append* methods.
  1364. while ((match = pattern.exec(css)) !== null) {
  1365. const startIndex = match.index + 4; // 'url('.length()
  1366. let terminator = match[1]; // ', " or empty (not quoted)
  1367. if (terminator.length === 0) {
  1368. terminator = ")";
  1369. }
  1370. let foundTerminator = false, endIndex = pattern.lastIndex - 1;
  1371. while (foundTerminator === false && endIndex + 1 <= maxIndex && endIndex != -1) {
  1372. endIndex = css.indexOf(terminator, endIndex + 1);
  1373. // endIndex == 0 doesn't really apply here
  1374. if ((endIndex > 0) && (css.charAt(endIndex - 1) !== "\\")) {
  1375. foundTerminator = true;
  1376. if (")" != terminator) {
  1377. endIndex = css.indexOf(")", endIndex);
  1378. }
  1379. }
  1380. }
  1381. // Enough searching, start moving stuff over to the buffer
  1382. sb.push(css.substring(appendIndex, match.index));
  1383. if (foundTerminator) {
  1384. let token = css.substring(startIndex, endIndex);
  1385. const parts = token.split(",");
  1386. if (parts.length > 1 && parts[0].slice(-7) == ";base64") {
  1387. token = token.replace(REGEXP_WHITE_SPACES, "");
  1388. } else {
  1389. token = token.replace(REGEXP_NEW_LINE, " ");
  1390. token = token.replace(REGEXP_WHITE_SPACES, " ");
  1391. token = token.replace(REGEXP_PRESERVE_HSLA1, "");
  1392. }
  1393. preservedTokens.push(token);
  1394. const preserver = "url(" + ___PRESERVED_TOKEN_ + (preservedTokens.length - 1) + "___)";
  1395. sb.push(preserver);
  1396. appendIndex = endIndex + 1;
  1397. } else {
  1398. // No end terminator found, re-add the whole match. Should we throw/warn here?
  1399. sb.push(css.substring(match.index, pattern.lastIndex));
  1400. appendIndex = pattern.lastIndex;
  1401. }
  1402. }
  1403. sb.push(css.substring(appendIndex));
  1404. return sb.join("");
  1405. }
  1406. const REGEXP_HEX_COLORS = /(=\s*?["']?)?#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])(\}|[^0-9a-f{][^{]*?\})/gi;
  1407. /**
  1408. * compressHexColors compresses hex color values of the form #AABBCC to #ABC.
  1409. *
  1410. * DOES NOT compress CSS ID selectors which match the above pattern (which would
  1411. * break things), like #AddressForm { ... }
  1412. *
  1413. * DOES NOT compress IE filters, which have hex color values (which would break
  1414. * things), like chroma(color='#FFFFFF');
  1415. *
  1416. * DOES NOT compress invalid hex values, like background-color: #aabbccdd
  1417. *
  1418. * @param {string} css - CSS content
  1419. *
  1420. * @return {string} Processed CSS
  1421. */
  1422. function compressHexColors(css) {
  1423. // Look for hex colors inside { ... } (to avoid IDs) and which don't have a =, or a " in front of them (to avoid filters)
  1424. const pattern = REGEXP_HEX_COLORS;
  1425. const sb = [];
  1426. let index = 0, match;
  1427. while ((match = pattern.exec(css)) !== null) {
  1428. sb.push(css.substring(index, match.index));
  1429. const isFilter = match[1];
  1430. if (isFilter) {
  1431. // Restore, maintain case, otherwise filter will break
  1432. sb.push(match[1] + "#" + (match[2] + match[3] + match[4] + match[5] + match[6] + match[7]));
  1433. } else {
  1434. if (match[2].toLowerCase() == match[3].toLowerCase() &&
  1435. match[4].toLowerCase() == match[5].toLowerCase() &&
  1436. match[6].toLowerCase() == match[7].toLowerCase()) {
  1437. // Compress.
  1438. sb.push("#" + (match[3] + match[5] + match[7]).toLowerCase());
  1439. } else {
  1440. // Non compressible color, restore but lower case.
  1441. sb.push("#" + (match[2] + match[3] + match[4] + match[5] + match[6] + match[7]).toLowerCase());
  1442. }
  1443. }
  1444. index = pattern.lastIndex = pattern.lastIndex - match[8].length;
  1445. }
  1446. sb.push(css.substring(index));
  1447. return sb.join("");
  1448. }
  1449. const REGEXP_KEYFRAMES = /@[a-z0-9-_]*keyframes\s+[a-z0-9-_]+\s*{/gi;
  1450. const REGEXP_WHITE_SPACE = /(^\s|\s$)/g;
  1451. /** keyframes preserves 0 followed by unit in keyframes steps
  1452. *
  1453. * @param {string} content - CSS content
  1454. * @param {string[]} preservedTokens - Global array of tokens to preserve
  1455. *
  1456. * @return {string} Processed CSS
  1457. */
  1458. function keyframes(content, preservedTokens) {
  1459. const pattern = REGEXP_KEYFRAMES;
  1460. let index = 0, buffer;
  1461. const preserve = (part, i) => {
  1462. part = part.replace(REGEXP_WHITE_SPACE, "");
  1463. if (part.charAt(0) === "0") {
  1464. preservedTokens.push(part);
  1465. buffer[i] = ___PRESERVED_TOKEN_ + (preservedTokens.length - 1) + "___";
  1466. }
  1467. };
  1468. while (true) { // eslint-disable-line no-constant-condition
  1469. let level = 0;
  1470. buffer = "";
  1471. let startIndex = content.slice(index).search(pattern);
  1472. if (startIndex < 0) {
  1473. break;
  1474. }
  1475. index += startIndex;
  1476. startIndex = index;
  1477. const len = content.length;
  1478. const buffers = [];
  1479. for (; index < len; ++index) {
  1480. const ch = content.charAt(index);
  1481. if (ch === "{") {
  1482. if (level === 0) {
  1483. buffers.push(buffer.replace(REGEXP_WHITE_SPACE, ""));
  1484. } else if (level === 1) {
  1485. buffer = buffer.split(",");
  1486. buffer.forEach(preserve);
  1487. buffers.push(buffer.join(",").replace(REGEXP_WHITE_SPACE, ""));
  1488. }
  1489. buffer = "";
  1490. level += 1;
  1491. } else if (ch === "}") {
  1492. if (level === 2) {
  1493. buffers.push("{" + buffer.replace(REGEXP_WHITE_SPACE, "") + "}");
  1494. buffer = "";
  1495. } else if (level === 1) {
  1496. content = content.slice(0, startIndex) +
  1497. buffers.shift() + "{" +
  1498. buffers.join("") +
  1499. content.slice(index);
  1500. break;
  1501. }
  1502. level -= 1;
  1503. }
  1504. if (level < 0) {
  1505. break;
  1506. } else if (ch !== "{" && ch !== "}") {
  1507. buffer += ch;
  1508. }
  1509. }
  1510. }
  1511. return content;
  1512. }
  1513. /**
  1514. * collectComments collects all comment blocks and return new content with comment placeholders
  1515. *
  1516. * @param {string} content - CSS content
  1517. * @param {string[]} comments - Global array of extracted comments
  1518. *
  1519. * @return {string} Processed CSS
  1520. */
  1521. function collectComments(content, comments) {
  1522. const table = [];
  1523. let from = 0, end;
  1524. while (true) { // eslint-disable-line no-constant-condition
  1525. const start = content.indexOf("/*", from);
  1526. if (start > -1) {
  1527. end = content.indexOf("*/", start + 2);
  1528. if (end > -1) {
  1529. comments.push(content.slice(start + 2, end));
  1530. table.push(content.slice(from, start));
  1531. table.push("/*___PRESERVE_CANDIDATE_COMMENT_" + (comments.length - 1) + "___*/");
  1532. from = end + 2;
  1533. } else {
  1534. // unterminated comment
  1535. end = -2;
  1536. break;
  1537. }
  1538. } else {
  1539. break;
  1540. }
  1541. }
  1542. table.push(content.slice(end + 2));
  1543. return table.join("");
  1544. }
  1545. /**
  1546. * processString uglifies a CSS string
  1547. *
  1548. * @param {string} content - CSS string
  1549. * @param {options} options - UglifyCSS options
  1550. *
  1551. * @return {string} Uglified result
  1552. */
  1553. // const REGEXP_EMPTY_RULES = /[^};{/]+\{\}/g;
  1554. const REGEXP_PRESERVE_STRING1 = /"([^\\"])*"/g;
  1555. const REGEXP_PRESERVE_STRING1_BIS = /"(\\.)*"/g;
  1556. const REGEXP_PRESERVE_STRING1_TER = /"(\\)*"/g;
  1557. const REGEXP_PRESERVE_STRING2 = /'([^\\']|\\.|\\)*'/g;
  1558. const REGEXP_MINIFY_ALPHA = /progid:DXImageTransform.Microsoft.Alpha\(Opacity=/gi;
  1559. const REGEXP_PRESERVE_TOKEN1 = /\r\n/g;
  1560. const REGEXP_PRESERVE_TOKEN2 = /[\r\n]/g;
  1561. const REGEXP_VARIABLES = /@variables\s*\{\s*([^}]+)\s*\}/g;
  1562. const REGEXP_VARIABLE = /\s*([a-z0-9-]+)\s*:\s*([^;}]+)\s*/gi;
  1563. const REGEXP_VARIABLE_VALUE = /var\s*\(\s*([^)]+)\s*\)/g;
  1564. const REGEXP_PRESERVE_CALC = /calc\(([^;}]*)\)/g;
  1565. const REGEXP_TRIM = /(^\s*|\s*$)/g;
  1566. const REGEXP_PRESERVE_CALC2 = /\( /g;
  1567. const REGEXP_PRESERVE_CALC3 = / \)/g;
  1568. const REGEXP_PRESERVE_MATRIX = /\s*filter:\s*progid:DXImageTransform.Microsoft.Matrix\(([^)]+)\);/g;
  1569. const REGEXP_REMOVE_SPACES = /(^|\})(([^{:])+:)+([^{]*{)/g;
  1570. const REGEXP_REMOVE_SPACES2 = /\s+([!{;:>+()\],])/g;
  1571. const REGEXP_REMOVE_SPACES2_BIS = /([^\\])\s+([}])/g;
  1572. const REGEXP_RESTORE_SPACE_IMPORTANT = /!important/g;
  1573. const REGEXP_PSEUDOCLASSCOLON = /___PSEUDOCLASSCOLON___/g;
  1574. const REGEXP_COLUMN = /:/g;
  1575. const REGEXP_PRESERVE_ZERO_UNIT = /\s*(animation|animation-delay|animation-duration|transition|transition-delay|transition-duration):\s*([^;}]+)/gi;
  1576. const REGEXP_PRESERVE_ZERO_UNIT1 = /(^|\D)0?\.?0(m?s)/gi;
  1577. const REGEXP_PRESERVE_FLEX = /\s*(flex|flex-basis):\s*([^;}]+)/gi;
  1578. const REGEXP_SPACES = /\s+/;
  1579. const REGEXP_PRESERVE_HSLA = /(hsla?)\(([^)]+)\)/g;
  1580. const REGEXP_PRESERVE_HSLA1 = /(^\s+|\s+$)/g;
  1581. const REGEXP_RETAIN_SPACE_IE6 = /:first-(line|letter)(\{|,)/gi;
  1582. const REGEXP_CHARSET = /^(.*)(@charset)( "[^"]*";)/gi;
  1583. const REGEXP_REMOVE_SECOND_CHARSET = /^((\s*)(@charset)( [^;]+;\s*))+/gi;
  1584. const REGEXP_LOWERCASE_DIRECTIVES = /@(font-face|import|(?:-(?:atsc|khtml|moz|ms|o|wap|webkit)-)?keyframe|media|page|namespace)/gi;
  1585. const REGEXP_LOWERCASE_PSEUDO_ELEMENTS = /:(active|after|before|checked|disabled|empty|enabled|first-(?:child|of-type)|focus|hover|last-(?:child|of-type)|link|only-(?:child|of-type)|root|:selection|target|visited)/gi;
  1586. const REGEXP_CHARSET2 = /^(.*)(@charset "[^"]*";)/g;
  1587. const REGEXP_CHARSET3 = /^(\s*@charset [^;]+;\s*)+/g;
  1588. const REGEXP_LOWERCASE_FUNCTIONS = /:(lang|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|(?:-(?:atsc|khtml|moz|ms|o|wap|webkit)-)?any)\(/gi;
  1589. const REGEXP_LOWERCASE_FUNCTIONS2 = /([:,( ]\s*)(attr|color-stop|from|rgba|to|url|(?:-(?:atsc|khtml|moz|ms|o|wap|webkit)-)?(?:calc|max|min|(?:repeating-)?(?:linear|radial)-gradient)|-webkit-gradient)/gi;
  1590. const REGEXP_NEWLINE1 = /\s*\/\*/g;
  1591. const REGEXP_NEWLINE2 = /\*\/\s*/g;
  1592. const REGEXP_RESTORE_SPACE1 = /\band\(/gi;
  1593. const REGEXP_RESTORE_SPACE2 = /([^:])not\(/gi;
  1594. const REGEXP_RESTORE_SPACE3 = /\bor\(/gi;
  1595. const REGEXP_REMOVE_SPACES3 = /([!{}:;>+([,])\s+/g;
  1596. const REGEXP_REMOVE_SEMI_COLUMNS = /;+\}/g;
  1597. // const REGEXP_REPLACE_ZERO = /(^|[^.0-9\\])(?:0?\.)?0(?:ex|ch|r?em|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|g?rad|turn|ms|k?Hz|dpi|dpcm|dppx|%)(?![a-z0-9])/gi;
  1598. const REGEXP_REPLACE_ZERO_DOT = /([0-9])\.0(ex|ch|r?em|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|g?rad|turn|m?s|k?Hz|dpi|dpcm|dppx|%| |;)/gi;
  1599. const REGEXP_REPLACE_4_ZEROS = /:0 0 0 0(;|\})/g;
  1600. const REGEXP_REPLACE_3_ZEROS = /:0 0 0(;|\})/g;
  1601. // const REGEXP_REPLACE_2_ZEROS = /:0 0(;|\})/g;
  1602. const REGEXP_REPLACE_1_ZERO = /(transform-origin|webkit-transform-origin|moz-transform-origin|o-transform-origin|ms-transform-origin|box-shadow):0(;|\})/gi;
  1603. const REGEXP_REPLACE_ZERO_DOT_DECIMAL = /(:|\s)0+\.(\d+)/g;
  1604. const REGEXP_REPLACE_RGB = /rgb\s*\(\s*([0-9,\s]+)\s*\)/gi;
  1605. const REGEXP_REPLACE_BORDER_ZERO = /(border|border-top|border-right|border-bottom|border-left|outline|background):none(;|\})/gi;
  1606. const REGEXP_REPLACE_IE_OPACITY = /progid:DXImageTransform\.Microsoft\.Alpha\(Opacity=/gi;
  1607. const REGEXP_REPLACE_QUERY_FRACTION = /\(([-A-Za-z]+):([0-9]+)\/([0-9]+)\)/g;
  1608. const REGEXP_QUERY_FRACTION = /___QUERY_FRACTION___/g;
  1609. const REGEXP_REPLACE_SEMI_COLUMNS = /;;+/g;
  1610. const REGEXP_REPLACE_HASH_COLOR = /(:|\s)(#f00)(;|})/g;
  1611. const REGEXP_PRESERVED_NEWLINE = /___PRESERVED_NEWLINE___/g;
  1612. const REGEXP_REPLACE_HASH_COLOR_SHORT1 = /(:|\s)(#000080)(;|})/g;
  1613. const REGEXP_REPLACE_HASH_COLOR_SHORT2 = /(:|\s)(#808080)(;|})/g;
  1614. const REGEXP_REPLACE_HASH_COLOR_SHORT3 = /(:|\s)(#808000)(;|})/g;
  1615. const REGEXP_REPLACE_HASH_COLOR_SHORT4 = /(:|\s)(#800080)(;|})/g;
  1616. const REGEXP_REPLACE_HASH_COLOR_SHORT5 = /(:|\s)(#c0c0c0)(;|})/g;
  1617. const REGEXP_REPLACE_HASH_COLOR_SHORT6 = /(:|\s)(#008080)(;|})/g;
  1618. const REGEXP_REPLACE_HASH_COLOR_SHORT7 = /(:|\s)(#ffa500)(;|})/g;
  1619. const REGEXP_REPLACE_HASH_COLOR_SHORT8 = /(:|\s)(#800000)(;|})/g;
  1620. function processString(content = "", options = defaultOptions) {
  1621. const comments = [];
  1622. const preservedTokens = [];
  1623. let pattern;
  1624. const originalContent = content;
  1625. content = extractDataUrls(content, preservedTokens);
  1626. content = collectComments(content, comments);
  1627. // preserve strings so their content doesn't get accidentally minified
  1628. preserveString(REGEXP_PRESERVE_STRING1);
  1629. preserveString(REGEXP_PRESERVE_STRING1_BIS);
  1630. preserveString(REGEXP_PRESERVE_STRING1_TER);
  1631. preserveString(REGEXP_PRESERVE_STRING2);
  1632. function preserveString(pattern) {
  1633. content = content.replace(pattern, token => {
  1634. const quote = token.substring(0, 1);
  1635. token = token.slice(1, -1);
  1636. // maybe the string contains a comment-like substring or more? put'em back then
  1637. if (token.indexOf("___PRESERVE_CANDIDATE_COMMENT_") >= 0) {
  1638. for (let i = 0, len = comments.length; i < len; i += 1) {
  1639. token = token.replace("___PRESERVE_CANDIDATE_COMMENT_" + i + "___", comments[i]);
  1640. }
  1641. }
  1642. // minify alpha opacity in filter strings
  1643. token = token.replace(REGEXP_MINIFY_ALPHA, "alpha(opacity=");
  1644. preservedTokens.push(token);
  1645. return quote + ___PRESERVED_TOKEN_ + (preservedTokens.length - 1) + "___" + quote;
  1646. });
  1647. }
  1648. // strings are safe, now wrestle the comments
  1649. for (let i = 0, len = comments.length; i < len; i += 1) {
  1650. const token = comments[i];
  1651. const placeholder = "___PRESERVE_CANDIDATE_COMMENT_" + i + "___";
  1652. // ! in the first position of the comment means preserve
  1653. // so push to the preserved tokens keeping the !
  1654. if (token.charAt(0) === "!") {
  1655. if (options.cuteComments) {
  1656. preservedTokens.push(token.substring(1).replace(REGEXP_PRESERVE_TOKEN1, "\n"));
  1657. } else if (options.uglyComments) {
  1658. preservedTokens.push(token.substring(1).replace(REGEXP_PRESERVE_TOKEN2, ""));
  1659. } else {
  1660. preservedTokens.push(token);
  1661. }
  1662. content = content.replace(placeholder, ___PRESERVED_TOKEN_ + (preservedTokens.length - 1) + "___");
  1663. continue;
  1664. }
  1665. // \ in the last position looks like hack for Mac/IE5
  1666. // shorten that to /*\*/ and the next one to /**/
  1667. if (token.charAt(token.length - 1) === "\\") {
  1668. preservedTokens.push("\\");
  1669. content = content.replace(placeholder, ___PRESERVED_TOKEN_ + (preservedTokens.length - 1) + "___");
  1670. i = i + 1; // attn: advancing the loop
  1671. preservedTokens.push("");
  1672. content = content.replace(
  1673. "___PRESERVE_CANDIDATE_COMMENT_" + i + "___",
  1674. ___PRESERVED_TOKEN_ + (preservedTokens.length - 1) + "___"
  1675. );
  1676. continue;
  1677. }
  1678. // keep empty comments after child selectors (IE7 hack)
  1679. // e.g. html >/**/ body
  1680. if (token.length === 0) {
  1681. const startIndex = content.indexOf(placeholder);
  1682. if (startIndex > 2) {
  1683. if (content.charAt(startIndex - 3) === ">") {
  1684. preservedTokens.push("");
  1685. content = content.replace(placeholder, ___PRESERVED_TOKEN_ + (preservedTokens.length - 1) + "___");
  1686. }
  1687. }
  1688. }
  1689. // in all other cases kill the comment
  1690. content = content.replace(`/*${placeholder}*/`, "");
  1691. }
  1692. // parse simple @variables blocks and remove them
  1693. if (options.expandVars) {
  1694. const vars = {};
  1695. pattern = REGEXP_VARIABLES;
  1696. content = content.replace(pattern, (_, f1) => {
  1697. pattern = REGEXP_VARIABLE;
  1698. f1.replace(pattern, (_, f1, f2) => {
  1699. if (f1 && f2) {
  1700. vars[f1] = f2;
  1701. }
  1702. return "";
  1703. });
  1704. return "";
  1705. });
  1706. // replace var(x) with the value of x
  1707. pattern = REGEXP_VARIABLE_VALUE;
  1708. content = content.replace(pattern, (_, f1) => {
  1709. return vars[f1] || "none";
  1710. });
  1711. }
  1712. // normalize all whitespace strings to single spaces. Easier to work with that way.
  1713. content = content.replace(REGEXP_WHITE_SPACES, " ");
  1714. // preserve formulas in calc() before removing spaces
  1715. pattern = REGEXP_PRESERVE_CALC;
  1716. content = content.replace(pattern, (_, f1) => {
  1717. preservedTokens.push(
  1718. "calc(" +
  1719. f1.replace(REGEXP_TRIM, "")
  1720. .replace(REGEXP_PRESERVE_CALC2, "(")
  1721. .replace(REGEXP_PRESERVE_CALC3, ")") +
  1722. ")"
  1723. );
  1724. return ___PRESERVED_TOKEN_ + (preservedTokens.length - 1) + "___";
  1725. });
  1726. // preserve matrix
  1727. pattern = REGEXP_PRESERVE_MATRIX;
  1728. content = content.replace(pattern, (_, f1) => {
  1729. preservedTokens.push(f1);
  1730. return "filter:progid:DXImageTransform.Microsoft.Matrix(" + ___PRESERVED_TOKEN_ + (preservedTokens.length - 1) + "___);";
  1731. });
  1732. // remove the spaces before the things that should not have spaces before them.
  1733. // but, be careful not to turn 'p :link {...}' into 'p:link{...}'
  1734. // swap out any pseudo-class colons with the token, and then swap back.
  1735. try {
  1736. pattern = REGEXP_REMOVE_SPACES;
  1737. content = content.replace(pattern, token => token.replace(REGEXP_COLUMN, "___PSEUDOCLASSCOLON___"));
  1738. } catch (_error) {
  1739. // ignored
  1740. }
  1741. // remove spaces before the things that should not have spaces before them.
  1742. content = content.replace(REGEXP_REMOVE_SPACES2, "$1");
  1743. content = content.replace(REGEXP_REMOVE_SPACES2_BIS, "$1$2");
  1744. // restore spaces for !important
  1745. content = content.replace(REGEXP_RESTORE_SPACE_IMPORTANT, " !important");
  1746. // bring back the colon
  1747. content = content.replace(REGEXP_PSEUDOCLASSCOLON, ":");
  1748. // preserve 0 followed by a time unit for properties using time units
  1749. pattern = REGEXP_PRESERVE_ZERO_UNIT;
  1750. content = content.replace(pattern, (_, f1, f2) => {
  1751. f2 = f2.replace(REGEXP_PRESERVE_ZERO_UNIT1, (_, g1, g2) => {
  1752. preservedTokens.push("0" + g2);
  1753. return g1 + ___PRESERVED_TOKEN_ + (preservedTokens.length - 1) + "___";
  1754. });
  1755. return f1 + ":" + f2;
  1756. });
  1757. // preserve unit for flex-basis within flex and flex-basis (ie10 bug)
  1758. pattern = REGEXP_PRESERVE_FLEX;
  1759. content = content.replace(pattern, (_, f1, f2) => {
  1760. let f2b = f2.split(REGEXP_SPACES);
  1761. preservedTokens.push(f2b.pop());
  1762. f2b.push(___PRESERVED_TOKEN_ + (preservedTokens.length - 1) + "___");
  1763. f2b = f2b.join(" ");
  1764. return `${f1}:${f2b}`;
  1765. });
  1766. // preserve 0% in hsl and hsla color definitions
  1767. content = content.replace(REGEXP_PRESERVE_HSLA, (_, f1, f2) => {
  1768. const f0 = [];
  1769. f2.split(",").forEach(part => {
  1770. part = part.replace(REGEXP_PRESERVE_HSLA1, "");
  1771. if (part === "0%") {
  1772. preservedTokens.push("0%");
  1773. f0.push(___PRESERVED_TOKEN_ + (preservedTokens.length - 1) + "___");
  1774. } else {
  1775. f0.push(part);
  1776. }
  1777. });
  1778. return f1 + "(" + f0.join(",") + ")";
  1779. });
  1780. // preserve 0 followed by unit in keyframes steps (WIP)
  1781. content = keyframes(content, preservedTokens);
  1782. // retain space for special IE6 cases
  1783. content = content.replace(REGEXP_RETAIN_SPACE_IE6, (_, f1, f2) => ":first-" + f1.toLowerCase() + " " + f2);
  1784. // newlines before and after the end of a preserved comment
  1785. if (options.cuteComments) {
  1786. content = content.replace(REGEXP_NEWLINE1, "___PRESERVED_NEWLINE___/*");
  1787. content = content.replace(REGEXP_NEWLINE2, "*/___PRESERVED_NEWLINE___");
  1788. // no space after the end of a preserved comment
  1789. } else {
  1790. content = content.replace(REGEXP_NEWLINE2, "*/");
  1791. }
  1792. // If there are multiple @charset directives, push them to the top of the file.
  1793. pattern = REGEXP_CHARSET;
  1794. content = content.replace(pattern, (_, f1, f2, f3) => f2.toLowerCase() + f3 + f1);
  1795. // When all @charset are at the top, remove the second and after (as they are completely ignored).
  1796. pattern = REGEXP_REMOVE_SECOND_CHARSET;
  1797. content = content.replace(pattern, (_, __, f2, f3, f4) => f2 + f3.toLowerCase() + f4);
  1798. // lowercase some popular @directives (@charset is done right above)
  1799. pattern = REGEXP_LOWERCASE_DIRECTIVES;
  1800. content = content.replace(pattern, (_, f1) => "@" + f1.toLowerCase());
  1801. // lowercase some more common pseudo-elements
  1802. pattern = REGEXP_LOWERCASE_PSEUDO_ELEMENTS;
  1803. content = content.replace(pattern, (_, f1) => ":" + f1.toLowerCase());
  1804. // if there is a @charset, then only allow one, and push to the top of the file.
  1805. content = content.replace(REGEXP_CHARSET2, "$2$1");
  1806. content = content.replace(REGEXP_CHARSET3, "$1");
  1807. // lowercase some more common functions
  1808. pattern = REGEXP_LOWERCASE_FUNCTIONS;
  1809. content = content.replace(pattern, (_, f1) => ":" + f1.toLowerCase() + "(");
  1810. // lower case some common function that can be values
  1811. // NOTE: rgb() isn't useful as we replace with #hex later, as well as and() is already done for us right after this
  1812. pattern = REGEXP_LOWERCASE_FUNCTIONS2;
  1813. content = content.replace(pattern, (_, f1, f2) => f1 + f2.toLowerCase());
  1814. // put the space back in some cases, to support stuff like
  1815. // @media screen and (-webkit-min-device-pixel-ratio:0){
  1816. content = content.replace(REGEXP_RESTORE_SPACE1, "and (");
  1817. content = content.replace(REGEXP_RESTORE_SPACE2, "$1not (");
  1818. content = content.replace(REGEXP_RESTORE_SPACE3, "or (");
  1819. // remove the spaces after the things that should not have spaces after them.
  1820. content = content.replace(REGEXP_REMOVE_SPACES3, "$1");
  1821. // remove unnecessary semicolons
  1822. content = content.replace(REGEXP_REMOVE_SEMI_COLUMNS, "}");
  1823. // replace 0(px,em,%) with 0.
  1824. // content = content.replace(REGEXP_REPLACE_ZERO, "$10");
  1825. // Replace x.0(px,em,%) with x(px,em,%).
  1826. content = content.replace(REGEXP_REPLACE_ZERO_DOT, "$1$2");
  1827. // replace 0 0 0 0; with 0.
  1828. content = content.replace(REGEXP_REPLACE_4_ZEROS, ":0$1");
  1829. content = content.replace(REGEXP_REPLACE_3_ZEROS, ":0$1");
  1830. // content = content.replace(REGEXP_REPLACE_2_ZEROS, ":0$1");
  1831. // replace background-position:0; with background-position:0 0;
  1832. // same for transform-origin and box-shadow
  1833. pattern = REGEXP_REPLACE_1_ZERO;
  1834. content = content.replace(pattern, (_, f1, f2) => f1.toLowerCase() + ":0 0" + f2);
  1835. // replace 0.6 to .6, but only when preceded by : or a white-space
  1836. content = content.replace(REGEXP_REPLACE_ZERO_DOT_DECIMAL, "$1.$2");
  1837. // shorten colors from rgb(51,102,153) to #336699
  1838. // this makes it more likely that it'll get further compressed in the next step.
  1839. pattern = REGEXP_REPLACE_RGB;
  1840. content = content.replace(pattern, (_, f1) => {
  1841. const rgbcolors = f1.split(",");
  1842. let hexcolor = "#";
  1843. for (let i = 0; i < rgbcolors.length; i += 1) {
  1844. let val = parseInt(rgbcolors[i], 10);
  1845. if (val < 16) {
  1846. hexcolor += "0";
  1847. }
  1848. if (val > 255) {
  1849. val = 255;
  1850. }
  1851. hexcolor += val.toString(16);
  1852. }
  1853. return hexcolor;
  1854. });
  1855. // Shorten colors from #AABBCC to #ABC.
  1856. content = compressHexColors(content);
  1857. // Replace #f00 -> red
  1858. content = content.replace(REGEXP_REPLACE_HASH_COLOR, "$1red$3");
  1859. // Replace other short color keywords
  1860. content = content.replace(REGEXP_REPLACE_HASH_COLOR_SHORT1, "$1navy$3");
  1861. content = content.replace(REGEXP_REPLACE_HASH_COLOR_SHORT2, "$1gray$3");
  1862. content = content.replace(REGEXP_REPLACE_HASH_COLOR_SHORT3, "$1olive$3");
  1863. content = content.replace(REGEXP_REPLACE_HASH_COLOR_SHORT4, "$1purple$3");
  1864. content = content.replace(REGEXP_REPLACE_HASH_COLOR_SHORT5, "$1silver$3");
  1865. content = content.replace(REGEXP_REPLACE_HASH_COLOR_SHORT6, "$1teal$3");
  1866. content = content.replace(REGEXP_REPLACE_HASH_COLOR_SHORT7, "$1orange$3");
  1867. content = content.replace(REGEXP_REPLACE_HASH_COLOR_SHORT8, "$1maroon$3");
  1868. // border: none -> border:0
  1869. pattern = REGEXP_REPLACE_BORDER_ZERO;
  1870. content = content.replace(pattern, (_, f1, f2) => f1.toLowerCase() + ":0" + f2);
  1871. // shorter opacity IE filter
  1872. content = content.replace(REGEXP_REPLACE_IE_OPACITY, "alpha(opacity=");
  1873. // Find a fraction that is used for Opera's -o-device-pixel-ratio query
  1874. // Add token to add the '\' back in later
  1875. content = content.replace(REGEXP_REPLACE_QUERY_FRACTION, "($1:$2___QUERY_FRACTION___$3)");
  1876. // remove empty rules.
  1877. // content = content.replace(REGEXP_EMPTY_RULES, "");
  1878. // Add '\' back to fix Opera -o-device-pixel-ratio query
  1879. content = content.replace(REGEXP_QUERY_FRACTION, "/");
  1880. // some source control tools don't like it when files containing lines longer
  1881. // than, say 8000 characters, are checked in. The linebreak option is used in
  1882. // that case to split long lines after a specific column.
  1883. if (options.maxLineLen > 0) {
  1884. const lines = [];
  1885. let line = [];
  1886. for (let i = 0, len = content.length; i < len; i += 1) {
  1887. const ch = content.charAt(i);
  1888. line.push(ch);
  1889. if (ch === "}" && line.length > options.maxLineLen) {
  1890. lines.push(line.join(""));
  1891. line = [];
  1892. }
  1893. }
  1894. if (line.length) {
  1895. lines.push(line.join(""));
  1896. }
  1897. content = lines.join("\n");
  1898. }
  1899. // replace multiple semi-colons in a row by a single one
  1900. // see SF bug #1980989
  1901. content = content.replace(REGEXP_REPLACE_SEMI_COLUMNS, ";");
  1902. // trim the final string (for any leading or trailing white spaces)
  1903. content = content.replace(REGEXP_TRIM, "");
  1904. if (preservedTokens.length > 1000) {
  1905. return originalContent;
  1906. }
  1907. // restore preserved tokens
  1908. for (let i = preservedTokens.length - 1; i >= 0; i--) {
  1909. content = content.replace(___PRESERVED_TOKEN_ + i + "___", preservedTokens[i], "g");
  1910. }
  1911. // restore preserved newlines
  1912. content = content.replace(REGEXP_PRESERVED_NEWLINE, "\n");
  1913. // return
  1914. return content;
  1915. }
  1916. /*
  1917. * The MIT License (MIT)
  1918. *
  1919. * Author: Gildas Lormeau
  1920. *
  1921. * Permission is hereby granted, free of charge, to any person obtaining a copy
  1922. * of this software and associated documentation files (the "Software"), to deal
  1923. * in the Software without restriction, including without limitation the rights
  1924. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1925. * copies of the Software, and to permit persons to whom the Software is
  1926. * furnished to do so, subject to the following conditions:
  1927. *
  1928. * The above copyright notice and this permission notice shall be included in all
  1929. * copies or substantial portions of the Software.
  1930. *
  1931. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1932. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1933. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1934. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1935. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1936. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  1937. * SOFTWARE.
  1938. */
  1939. // derived from https://github.com/postcss/postcss-selector-parser/blob/master/src/util/unesc.js
  1940. /*
  1941. * The MIT License (MIT)
  1942. * Copyright (c) Ben Briggs <beneb.info@gmail.com> (http://beneb.info)
  1943. *
  1944. * Permission is hereby granted, free of charge, to any person obtaining a copy
  1945. * of this software and associated documentation files (the "Software"), to deal
  1946. * in the Software without restriction, including without limitation the rights
  1947. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1948. * copies of the Software, and to permit persons to whom the Software is
  1949. * furnished to do so, subject to the following conditions:
  1950. *
  1951. * The above copyright notice and this permission notice shall be included in
  1952. * all copies or substantial portions of the Software.
  1953. *
  1954. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1955. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1956. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1957. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1958. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1959. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1960. * THE SOFTWARE.
  1961. */
  1962. const whitespace = "[\\x20\\t\\r\\n\\f]";
  1963. const unescapeRegExp = new RegExp("\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig");
  1964. function process$6(str) {
  1965. return str.replace(unescapeRegExp, (_, escaped, escapedWhitespace) => {
  1966. const high = "0x" + escaped - 0x10000;
  1967. // NaN means non-codepoint
  1968. // Workaround erroneous numeric interpretation of +"0x"
  1969. // eslint-disable-next-line no-self-compare
  1970. return high !== high || escapedWhitespace
  1971. ? escaped
  1972. : high < 0
  1973. ? // BMP codepoint
  1974. String.fromCharCode(high + 0x10000)
  1975. : // Supplemental Plane codepoint (surrogate pair)
  1976. String.fromCharCode((high >> 10) | 0xd800, (high & 0x3ff) | 0xdc00);
  1977. });
  1978. }
  1979. /*
  1980. * The MIT License (MIT)
  1981. *
  1982. * Author: Gildas Lormeau
  1983. *
  1984. * Permission is hereby granted, free of charge, to any person obtaining a copy
  1985. * of this software and associated documentation files (the "Software"), to deal
  1986. * in the Software without restriction, including without limitation the rights
  1987. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1988. * copies of the Software, and to permit persons to whom the Software is
  1989. * furnished to do so, subject to the following conditions:
  1990. *
  1991. * The above copyright notice and this permission notice shall be included in all
  1992. * copies or substantial portions of the Software.
  1993. *
  1994. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1995. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1996. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1997. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1998. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1999. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  2000. * SOFTWARE.
  2001. */
  2002. // 1. Let input be the value passed to this algorithm.
  2003. function process$5(input) {
  2004. // UTILITY FUNCTIONS
  2005. // Manual is faster than RegEx
  2006. // http://bjorn.tipling.com/state-and-regular-expressions-in-javascript
  2007. // http://jsperf.com/whitespace-character/5
  2008. function isSpace(c) {
  2009. return (c === "\u0020" || // space
  2010. c === "\u0009" || // horizontal tab
  2011. c === "\u000A" || // new line
  2012. c === "\u000C" || // form feed
  2013. c === "\u000D"); // carriage return
  2014. }
  2015. function collectCharacters(regEx) {
  2016. let chars;
  2017. const match = regEx.exec(input.substring(pos));
  2018. if (match) {
  2019. chars = match[0];
  2020. pos += chars.length;
  2021. return chars;
  2022. }
  2023. }
  2024. const inputLength = input.length;
  2025. // (Don"t use \s, to avoid matching non-breaking space)
  2026. /* eslint-disable no-control-regex */
  2027. const regexLeadingSpaces = /^[ \t\n\r\u000c]+/;
  2028. const regexLeadingCommasOrSpaces = /^[, \t\n\r\u000c]+/;
  2029. const regexLeadingNotSpaces = /^[^ \t\n\r\u000c]+/;
  2030. const regexTrailingCommas = /[,]+$/;
  2031. const regexNonNegativeInteger = /^\d+$/;
  2032. /* eslint-enable no-control-regex */
  2033. // ( Positive or negative or unsigned integers or decimals, without or without exponents.
  2034. // Must include at least one digit.
  2035. // According to spec tests any decimal point must be followed by a digit.
  2036. // No leading plus sign is allowed.)
  2037. // https://html.spec.whatwg.org/multipage/infrastructure.html#valid-floating-point-number
  2038. const regexFloatingPoint = /^-?(?:[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/;
  2039. let url, descriptors, currentDescriptor, state, c,
  2040. // 2. Let position be a pointer into input, initially pointing at the start
  2041. // of the string.
  2042. pos = 0;
  2043. // 3. Let candidates be an initially empty source set.
  2044. const candidates = [];
  2045. // 4. Splitting loop: Collect a sequence of characters that are space
  2046. // characters or U+002C COMMA characters. If any U+002C COMMA characters
  2047. // were collected, that is a parse error.
  2048. while (true) { // eslint-disable-line no-constant-condition
  2049. collectCharacters(regexLeadingCommasOrSpaces);
  2050. // 5. If position is past the end of input, return candidates and abort these steps.
  2051. if (pos >= inputLength) {
  2052. return candidates; // (we"re done, this is the sole return path)
  2053. }
  2054. // 6. Collect a sequence of characters that are not space characters,
  2055. // and let that be url.
  2056. url = collectCharacters(regexLeadingNotSpaces);
  2057. // 7. Let descriptors be a new empty list.
  2058. descriptors = [];
  2059. // 8. If url ends with a U+002C COMMA character (,), follow these substeps:
  2060. // (1). Remove all trailing U+002C COMMA characters from url. If this removed
  2061. // more than one character, that is a parse error.
  2062. if (url.slice(-1) === ",") {
  2063. url = url.replace(regexTrailingCommas, "");
  2064. // (Jump ahead to step 9 to skip tokenization and just push the candidate).
  2065. parseDescriptors();
  2066. // Otherwise, follow these substeps:
  2067. } else {
  2068. tokenize();
  2069. } // (close else of step 8)
  2070. // 16. Return to the step labeled splitting loop.
  2071. } // (Close of big while loop.)
  2072. /**
  2073. * Tokenizes descriptor properties prior to parsing
  2074. * Returns undefined.
  2075. */
  2076. function tokenize() {
  2077. // 8.1. Descriptor tokeniser: Skip whitespace
  2078. collectCharacters(regexLeadingSpaces);
  2079. // 8.2. Let current descriptor be the empty string.
  2080. currentDescriptor = "";
  2081. // 8.3. Let state be in descriptor.
  2082. state = "in descriptor";
  2083. while (true) { // eslint-disable-line no-constant-condition
  2084. // 8.4. Let c be the character at position.
  2085. c = input.charAt(pos);
  2086. // Do the following depending on the value of state.
  2087. // For the purpose of this step, "EOF" is a special character representing
  2088. // that position is past the end of input.
  2089. // In descriptor
  2090. if (state === "in descriptor") {
  2091. // Do the following, depending on the value of c:
  2092. // Space character
  2093. // If current descriptor is not empty, append current descriptor to
  2094. // descriptors and let current descriptor be the empty string.
  2095. // Set state to after descriptor.
  2096. if (isSpace(c)) {
  2097. if (currentDescriptor) {
  2098. descriptors.push(currentDescriptor);
  2099. currentDescriptor = "";
  2100. state = "after descriptor";
  2101. }
  2102. // U+002C COMMA (,)
  2103. // Advance position to the next character in input. If current descriptor
  2104. // is not empty, append current descriptor to descriptors. Jump to the step
  2105. // labeled descriptor parser.
  2106. } else if (c === ",") {
  2107. pos += 1;
  2108. if (currentDescriptor) {
  2109. descriptors.push(currentDescriptor);
  2110. }
  2111. parseDescriptors();
  2112. return;
  2113. // U+0028 LEFT PARENTHESIS (()
  2114. // Append c to current descriptor. Set state to in parens.
  2115. } else if (c === "\u0028") {
  2116. currentDescriptor = currentDescriptor + c;
  2117. state = "in parens";
  2118. // EOF
  2119. // If current descriptor is not empty, append current descriptor to
  2120. // descriptors. Jump to the step labeled descriptor parser.
  2121. } else if (c === "") {
  2122. if (currentDescriptor) {
  2123. descriptors.push(currentDescriptor);
  2124. }
  2125. parseDescriptors();
  2126. return;
  2127. // Anything else
  2128. // Append c to current descriptor.
  2129. } else {
  2130. currentDescriptor = currentDescriptor + c;
  2131. }
  2132. // (end "in descriptor"
  2133. // In parens
  2134. } else if (state === "in parens") {
  2135. // U+0029 RIGHT PARENTHESIS ())
  2136. // Append c to current descriptor. Set state to in descriptor.
  2137. if (c === ")") {
  2138. currentDescriptor = currentDescriptor + c;
  2139. state = "in descriptor";
  2140. // EOF
  2141. // Append current descriptor to descriptors. Jump to the step labeled
  2142. // descriptor parser.
  2143. } else if (c === "") {
  2144. descriptors.push(currentDescriptor);
  2145. parseDescriptors();
  2146. return;
  2147. // Anything else
  2148. // Append c to current descriptor.
  2149. } else {
  2150. currentDescriptor = currentDescriptor + c;
  2151. }
  2152. // After descriptor
  2153. } else if (state === "after descriptor") {
  2154. // Do the following, depending on the value of c:
  2155. // Space character: Stay in this state.
  2156. if (isSpace(c)) ; else if (c === "") {
  2157. parseDescriptors();
  2158. return;
  2159. // Anything else
  2160. // Set state to in descriptor. Set position to the previous character in input.
  2161. } else {
  2162. state = "in descriptor";
  2163. pos -= 1;
  2164. }
  2165. }
  2166. // Advance position to the next character in input.
  2167. pos += 1;
  2168. // Repeat this step.
  2169. } // (close while true loop)
  2170. }
  2171. /**
  2172. * Adds descriptor properties to a candidate, pushes to the candidates array
  2173. * @return undefined
  2174. */
  2175. // Declared outside of the while loop so that it"s only created once.
  2176. function parseDescriptors() {
  2177. // 9. Descriptor parser: Let error be no.
  2178. let pError = false,
  2179. // 10. Let width be absent.
  2180. // 11. Let density be absent.
  2181. // 12. Let future-compat-h be absent. (We"re implementing it now as h)
  2182. w, d, h, i,
  2183. desc, lastChar, value, intVal, floatVal;
  2184. const candidate = {};
  2185. // 13. For each descriptor in descriptors, run the appropriate set of steps
  2186. // from the following list:
  2187. for (i = 0; i < descriptors.length; i++) {
  2188. desc = descriptors[i];
  2189. lastChar = desc[desc.length - 1];
  2190. value = desc.substring(0, desc.length - 1);
  2191. intVal = parseInt(value, 10);
  2192. floatVal = parseFloat(value);
  2193. // If the descriptor consists of a valid non-negative integer followed by
  2194. // a U+0077 LATIN SMALL LETTER W character
  2195. if (regexNonNegativeInteger.test(value) && (lastChar === "w")) {
  2196. // If width and density are not both absent, then let error be yes.
  2197. if (w || d) { pError = true; }
  2198. // Apply the rules for parsing non-negative integers to the descriptor.
  2199. // If the result is zero, let error be yes.
  2200. // Otherwise, let width be the result.
  2201. if (intVal === 0) { pError = true; } else { w = intVal; }
  2202. // If the descriptor consists of a valid floating-point number followed by
  2203. // a U+0078 LATIN SMALL LETTER X character
  2204. } else if (regexFloatingPoint.test(value) && (lastChar === "x")) {
  2205. // If width, density and future-compat-h are not all absent, then let error
  2206. // be yes.
  2207. if (w || d || h) { pError = true; }
  2208. // Apply the rules for parsing floating-point number values to the descriptor.
  2209. // If the result is less than zero, let error be yes. Otherwise, let density
  2210. // be the result.
  2211. if (floatVal < 0) { pError = true; } else { d = floatVal; }
  2212. // If the descriptor consists of a valid non-negative integer followed by
  2213. // a U+0068 LATIN SMALL LETTER H character
  2214. } else if (regexNonNegativeInteger.test(value) && (lastChar === "h")) {
  2215. // If height and density are not both absent, then let error be yes.
  2216. if (h || d) { pError = true; }
  2217. // Apply the rules for parsing non-negative integers to the descriptor.
  2218. // If the result is zero, let error be yes. Otherwise, let future-compat-h
  2219. // be the result.
  2220. if (intVal === 0) { pError = true; } else { h = intVal; }
  2221. // Anything else, Let error be yes.
  2222. } else { pError = true; }
  2223. } // (close step 13 for loop)
  2224. // 15. If error is still no, then append a new image source to candidates whose
  2225. // URL is url, associated with a width width if not absent and a pixel
  2226. // density density if not absent. Otherwise, there is a parse error.
  2227. if (!pError) {
  2228. candidate.url = url;
  2229. if (w) { candidate.w = w; }
  2230. if (d) { candidate.d = d; }
  2231. if (h) { candidate.h = h; }
  2232. candidates.push(candidate);
  2233. } else if (console && console.log) { // eslint-disable-line no-console
  2234. console.log("Invalid srcset descriptor found in \"" + input + "\" at \"" + desc + "\"."); // eslint-disable-line no-console
  2235. }
  2236. } // (close parseDescriptors fn)
  2237. }
  2238. /*
  2239. * The MIT License (MIT)
  2240. *
  2241. * Author: Gildas Lormeau
  2242. *
  2243. * Permission is hereby granted, free of charge, to any person obtaining a copy
  2244. * of this software and associated documentation files (the "Software"), to deal
  2245. * in the Software without restriction, including without limitation the rights
  2246. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  2247. * copies of the Software, and to permit persons to whom the Software is
  2248. * furnished to do so, subject to the following conditions:
  2249. *
  2250. * The above copyright notice and this permission notice shall be included in all
  2251. * copies or substantial portions of the Software.
  2252. *
  2253. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  2254. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  2255. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  2256. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  2257. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  2258. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  2259. * SOFTWARE.
  2260. */
  2261. // derived from https://github.com/jsdom/whatwg-mimetype
  2262. /*
  2263. * Copyright © 2017–2018 Domenic Denicola <d@domenic.me>
  2264. *
  2265. * Permission is hereby granted, free of charge, to any person obtaining a copy
  2266. * of this software and associated documentation files (the "Software"), to deal
  2267. * in the Software without restriction, including without limitation the rights
  2268. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  2269. * copies of the Software, and to permit persons to whom the Software is
  2270. * furnished to do so, subject to the following conditions:
  2271. * The above copyright notice and this permission notice shall be included in all
  2272. * copies or substantial portions of the Software.
  2273. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  2274. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  2275. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  2276. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  2277. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  2278. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  2279. * SOFTWARE.
  2280. */
  2281. let utils, parser, serializer, MIMEType;
  2282. // lib/utils.js
  2283. {
  2284. utils = {};
  2285. utils.removeLeadingAndTrailingHTTPWhitespace = string => {
  2286. return string.replace(/^[ \t\n\r]+/, "").replace(/[ \t\n\r]+$/, "");
  2287. };
  2288. utils.removeTrailingHTTPWhitespace = string => {
  2289. return string.replace(/[ \t\n\r]+$/, "");
  2290. };
  2291. utils.isHTTPWhitespaceChar = char => {
  2292. return char === " " || char === "\t" || char === "\n" || char === "\r";
  2293. };
  2294. utils.solelyContainsHTTPTokenCodePoints = string => {
  2295. return /^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/.test(string);
  2296. };
  2297. utils.soleyContainsHTTPQuotedStringTokenCodePoints = string => {
  2298. return /^[\t\u0020-\u007E\u0080-\u00FF]*$/.test(string);
  2299. };
  2300. utils.asciiLowercase = string => {
  2301. return string.replace(/[A-Z]/g, l => l.toLowerCase());
  2302. };
  2303. // This variant only implements it with the extract-value flag set.
  2304. utils.collectAnHTTPQuotedString = (input, position) => {
  2305. let value = "";
  2306. position++;
  2307. // eslint-disable-next-line no-constant-condition
  2308. while (true) {
  2309. while (position < input.length && input[position] !== "\"" && input[position] !== "\\") {
  2310. value += input[position];
  2311. ++position;
  2312. }
  2313. if (position >= input.length) {
  2314. break;
  2315. }
  2316. const quoteOrBackslash = input[position];
  2317. ++position;
  2318. if (quoteOrBackslash === "\\") {
  2319. if (position >= input.length) {
  2320. value += "\\";
  2321. break;
  2322. }
  2323. value += input[position];
  2324. ++position;
  2325. } else {
  2326. break;
  2327. }
  2328. }
  2329. return [value, position];
  2330. };
  2331. }
  2332. // lib/serializer.js
  2333. {
  2334. const { solelyContainsHTTPTokenCodePoints } = utils;
  2335. serializer = mimeType => {
  2336. let serialization = `${mimeType.type}/${mimeType.subtype}`;
  2337. if (mimeType.parameters.size === 0) {
  2338. return serialization;
  2339. }
  2340. for (let [name, value] of mimeType.parameters) {
  2341. serialization += ";";
  2342. serialization += name;
  2343. serialization += "=";
  2344. if (!solelyContainsHTTPTokenCodePoints(value) || value.length === 0) {
  2345. value = value.replace(/(["\\])/g, "\\$1");
  2346. value = `"${value}"`;
  2347. }
  2348. serialization += value;
  2349. }
  2350. return serialization;
  2351. };
  2352. }
  2353. // lib/parser.js
  2354. {
  2355. const {
  2356. removeLeadingAndTrailingHTTPWhitespace,
  2357. removeTrailingHTTPWhitespace,
  2358. isHTTPWhitespaceChar,
  2359. solelyContainsHTTPTokenCodePoints,
  2360. soleyContainsHTTPQuotedStringTokenCodePoints,
  2361. asciiLowercase,
  2362. collectAnHTTPQuotedString
  2363. } = utils;
  2364. parser = input => {
  2365. input = removeLeadingAndTrailingHTTPWhitespace(input);
  2366. let position = 0;
  2367. let type = "";
  2368. while (position < input.length && input[position] !== "/") {
  2369. type += input[position];
  2370. ++position;
  2371. }
  2372. if (type.length === 0 || !solelyContainsHTTPTokenCodePoints(type)) {
  2373. return null;
  2374. }
  2375. if (position >= input.length) {
  2376. return null;
  2377. }
  2378. // Skips past "/"
  2379. ++position;
  2380. let subtype = "";
  2381. while (position < input.length && input[position] !== ";") {
  2382. subtype += input[position];
  2383. ++position;
  2384. }
  2385. subtype = removeTrailingHTTPWhitespace(subtype);
  2386. if (subtype.length === 0 || !solelyContainsHTTPTokenCodePoints(subtype)) {
  2387. return null;
  2388. }
  2389. const mimeType = {
  2390. type: asciiLowercase(type),
  2391. subtype: asciiLowercase(subtype),
  2392. parameters: new Map()
  2393. };
  2394. while (position < input.length) {
  2395. // Skip past ";"
  2396. ++position;
  2397. while (isHTTPWhitespaceChar(input[position])) {
  2398. ++position;
  2399. }
  2400. let parameterName = "";
  2401. while (position < input.length && input[position] !== ";" && input[position] !== "=") {
  2402. parameterName += input[position];
  2403. ++position;
  2404. }
  2405. parameterName = asciiLowercase(parameterName);
  2406. if (position < input.length) {
  2407. if (input[position] === ";") {
  2408. continue;
  2409. }
  2410. // Skip past "="
  2411. ++position;
  2412. }
  2413. let parameterValue = null;
  2414. if (input[position] === "\"") {
  2415. [parameterValue, position] = collectAnHTTPQuotedString(input, position);
  2416. while (position < input.length && input[position] !== ";") {
  2417. ++position;
  2418. }
  2419. } else {
  2420. parameterValue = "";
  2421. while (position < input.length && input[position] !== ";") {
  2422. parameterValue += input[position];
  2423. ++position;
  2424. }
  2425. parameterValue = removeTrailingHTTPWhitespace(parameterValue);
  2426. if (parameterValue === "") {
  2427. continue;
  2428. }
  2429. }
  2430. if (parameterName.length > 0 &&
  2431. solelyContainsHTTPTokenCodePoints(parameterName) &&
  2432. soleyContainsHTTPQuotedStringTokenCodePoints(parameterValue) &&
  2433. !mimeType.parameters.has(parameterName)) {
  2434. mimeType.parameters.set(parameterName, parameterValue);
  2435. }
  2436. }
  2437. return mimeType;
  2438. };
  2439. }
  2440. // lib/mime-type.js
  2441. {
  2442. const parse = parser;
  2443. const serialize = serializer;
  2444. const {
  2445. asciiLowercase,
  2446. solelyContainsHTTPTokenCodePoints,
  2447. soleyContainsHTTPQuotedStringTokenCodePoints
  2448. } = utils;
  2449. MIMEType = class MIMEType {
  2450. constructor(string) {
  2451. string = String(string);
  2452. const result = parse(string);
  2453. if (result === null) {
  2454. throw new Error(`Could not parse MIME type string "${string}"`);
  2455. }
  2456. this._type = result.type;
  2457. this._subtype = result.subtype;
  2458. this._parameters = new MIMETypeParameters(result.parameters);
  2459. }
  2460. static parse(string) {
  2461. try {
  2462. return new this(string);
  2463. } catch (e) {
  2464. return null;
  2465. }
  2466. }
  2467. get essence() {
  2468. return `${this.type}/${this.subtype}`;
  2469. }
  2470. get type() {
  2471. return this._type;
  2472. }
  2473. set type(value) {
  2474. value = asciiLowercase(String(value));
  2475. if (value.length === 0) {
  2476. throw new Error("Invalid type: must be a non-empty string");
  2477. }
  2478. if (!solelyContainsHTTPTokenCodePoints(value)) {
  2479. throw new Error(`Invalid type ${value}: must contain only HTTP token code points`);
  2480. }
  2481. this._type = value;
  2482. }
  2483. get subtype() {
  2484. return this._subtype;
  2485. }
  2486. set subtype(value) {
  2487. value = asciiLowercase(String(value));
  2488. if (value.length === 0) {
  2489. throw new Error("Invalid subtype: must be a non-empty string");
  2490. }
  2491. if (!solelyContainsHTTPTokenCodePoints(value)) {
  2492. throw new Error(`Invalid subtype ${value}: must contain only HTTP token code points`);
  2493. }
  2494. this._subtype = value;
  2495. }
  2496. get parameters() {
  2497. return this._parameters;
  2498. }
  2499. toString() {
  2500. // The serialize function works on both "MIME type records" (i.e. the results of parse) and on this class, since
  2501. // this class's interface is identical.
  2502. return serialize(this);
  2503. }
  2504. isJavaScript({ allowParameters = false } = {}) {
  2505. switch (this._type) {
  2506. case "text": {
  2507. switch (this._subtype) {
  2508. case "ecmascript":
  2509. case "javascript":
  2510. case "javascript1.0":
  2511. case "javascript1.1":
  2512. case "javascript1.2":
  2513. case "javascript1.3":
  2514. case "javascript1.4":
  2515. case "javascript1.5":
  2516. case "jscript":
  2517. case "livescript":
  2518. case "x-ecmascript":
  2519. case "x-javascript": {
  2520. return allowParameters || this._parameters.size === 0;
  2521. }
  2522. default: {
  2523. return false;
  2524. }
  2525. }
  2526. }
  2527. case "application": {
  2528. switch (this._subtype) {
  2529. case "ecmascript":
  2530. case "javascript":
  2531. case "x-ecmascript":
  2532. case "x-javascript": {
  2533. return allowParameters || this._parameters.size === 0;
  2534. }
  2535. default: {
  2536. return false;
  2537. }
  2538. }
  2539. }
  2540. default: {
  2541. return false;
  2542. }
  2543. }
  2544. }
  2545. isXML() {
  2546. return (this._subtype === "xml" && (this._type === "text" || this._type === "application")) ||
  2547. this._subtype.endsWith("+xml");
  2548. }
  2549. isHTML() {
  2550. return this._subtype === "html" && this._type === "text";
  2551. }
  2552. };
  2553. class MIMETypeParameters {
  2554. constructor(map) {
  2555. this._map = map;
  2556. }
  2557. get size() {
  2558. return this._map.size;
  2559. }
  2560. get(name) {
  2561. name = asciiLowercase(String(name));
  2562. return this._map.get(name);
  2563. }
  2564. has(name) {
  2565. name = asciiLowercase(String(name));
  2566. return this._map.has(name);
  2567. }
  2568. set(name, value) {
  2569. name = asciiLowercase(String(name));
  2570. value = String(value);
  2571. if (!solelyContainsHTTPTokenCodePoints(name)) {
  2572. throw new Error(`Invalid MIME type parameter name "${name}": only HTTP token code points are valid.`);
  2573. }
  2574. if (!soleyContainsHTTPQuotedStringTokenCodePoints(value)) {
  2575. throw new Error(`Invalid MIME type parameter value "${value}": only HTTP quoted-string token code points are valid.`);
  2576. }
  2577. return this._map.set(name, value);
  2578. }
  2579. clear() {
  2580. this._map.clear();
  2581. }
  2582. delete(name) {
  2583. name = asciiLowercase(String(name));
  2584. return this._map.delete(name);
  2585. }
  2586. forEach(callbackFn, thisArg) {
  2587. this._map.forEach(callbackFn, thisArg);
  2588. }
  2589. keys() {
  2590. return this._map.keys();
  2591. }
  2592. values() {
  2593. return this._map.values();
  2594. }
  2595. entries() {
  2596. return this._map.entries();
  2597. }
  2598. [Symbol.iterator]() {
  2599. return this._map[Symbol.iterator]();
  2600. }
  2601. }
  2602. }
  2603. /*
  2604. * Copyright 2010-2022 Gildas Lormeau
  2605. * contact : gildas.lormeau <at> gmail.com
  2606. *
  2607. * This file is part of SingleFile.
  2608. *
  2609. * The code in this file is free software: you can redistribute it and/or
  2610. * modify it under the terms of the GNU Affero General Public License
  2611. * (GNU AGPL) as published by the Free Software Foundation, either version 3
  2612. * of the License, or (at your option) any later version.
  2613. *
  2614. * The code in this file is distributed in the hope that it will be useful,
  2615. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  2616. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
  2617. * General Public License for more details.
  2618. *
  2619. * As additional permission under GNU AGPL version 3 section 7, you may
  2620. * distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU
  2621. * AGPL normally required by section 4, provided you include this license
  2622. * notice and a URL through which recipients can access the Corresponding
  2623. * Source.
  2624. */
  2625. const NEW_FONT_FACE_EVENT = "single-file-new-font-face";
  2626. const DELETE_FONT_EVENT = "single-file-delete-font";
  2627. const CLEAR_FONTS_EVENT = "single-file-clear-fonts";
  2628. const FONT_FACE_PROPERTY_NAME = "_singleFile_fontFaces";
  2629. const addEventListener = (type, listener, options) => globalThis.addEventListener(type, listener, options);
  2630. const document$1 = globalThis.document;
  2631. const Document = globalThis.Document;
  2632. const JSON$2 = globalThis.JSON;
  2633. let fontFaces;
  2634. if (window[FONT_FACE_PROPERTY_NAME]) {
  2635. fontFaces = window[FONT_FACE_PROPERTY_NAME];
  2636. } else {
  2637. fontFaces = window[FONT_FACE_PROPERTY_NAME] = new Map();
  2638. }
  2639. if (document$1 instanceof Document) {
  2640. addEventListener(NEW_FONT_FACE_EVENT, event => {
  2641. const detail = event.detail;
  2642. const key = Object.assign({}, detail);
  2643. delete key.src;
  2644. fontFaces.set(JSON$2.stringify(key), detail);
  2645. });
  2646. addEventListener(DELETE_FONT_EVENT, event => {
  2647. const detail = event.detail;
  2648. const key = Object.assign({}, detail);
  2649. delete key.src;
  2650. fontFaces.delete(JSON$2.stringify(key));
  2651. });
  2652. addEventListener(CLEAR_FONTS_EVENT, () => fontFaces = new Map());
  2653. }
  2654. function getFontsData$1() {
  2655. return Array.from(fontFaces.values());
  2656. }
  2657. /*
  2658. * Copyright 2010-2022 Gildas Lormeau
  2659. * contact : gildas.lormeau <at> gmail.com
  2660. *
  2661. * This file is part of SingleFile.
  2662. *
  2663. * The code in this file is free software: you can redistribute it and/or
  2664. * modify it under the terms of the GNU Affero General Public License
  2665. * (GNU AGPL) as published by the Free Software Foundation, either version 3
  2666. * of the License, or (at your option) any later version.
  2667. *
  2668. * The code in this file is distributed in the hope that it will be useful,
  2669. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  2670. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
  2671. * General Public License for more details.
  2672. *
  2673. * As additional permission under GNU AGPL version 3 section 7, you may
  2674. * distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU
  2675. * AGPL normally required by section 4, provided you include this license
  2676. * notice and a URL through which recipients can access the Corresponding
  2677. * Source.
  2678. */
  2679. const ON_BEFORE_CAPTURE_EVENT_NAME = SINGLE_FILE_PREFIX + "on-before-capture";
  2680. const ON_AFTER_CAPTURE_EVENT_NAME = SINGLE_FILE_PREFIX + "on-after-capture";
  2681. const GET_ADOPTED_STYLESHEETS_REQUEST_EVENT = SINGLE_FILE_PREFIX + "request-get-adopted-stylesheets";
  2682. const GET_ADOPTED_STYLESHEETS_RESPONSE_EVENT = SINGLE_FILE_PREFIX + "response-get-adopted-stylesheets";
  2683. const UNREGISTER_GET_ADOPTED_STYLESHEETS_REQUEST_EVENT = SINGLE_FILE_PREFIX + "unregister-request-get-adopted-stylesheets";
  2684. const REMOVED_CONTENT_ATTRIBUTE_NAME = "data-" + SINGLE_FILE_PREFIX + "removed-content";
  2685. const HIDDEN_CONTENT_ATTRIBUTE_NAME = "data-" + SINGLE_FILE_PREFIX + "hidden-content";
  2686. const KEPT_CONTENT_ATTRIBUTE_NAME = "data-" + SINGLE_FILE_PREFIX + "kept-content";
  2687. const HIDDEN_FRAME_ATTRIBUTE_NAME = "data-" + SINGLE_FILE_PREFIX + "hidden-frame";
  2688. const PRESERVED_SPACE_ELEMENT_ATTRIBUTE_NAME = "data-" + SINGLE_FILE_PREFIX + "preserved-space-element";
  2689. const SHADOW_ROOT_ATTRIBUTE_NAME = "data-" + SINGLE_FILE_PREFIX + "shadow-root-element";
  2690. const WIN_ID_ATTRIBUTE_NAME = "data-" + SINGLE_FILE_PREFIX + "win-id";
  2691. const IMAGE_ATTRIBUTE_NAME = "data-" + SINGLE_FILE_PREFIX + "image";
  2692. const POSTER_ATTRIBUTE_NAME = "data-" + SINGLE_FILE_PREFIX + "poster";
  2693. const VIDEO_ATTRIBUTE_NAME = "data-" + SINGLE_FILE_PREFIX + "video";
  2694. const CANVAS_ATTRIBUTE_NAME = "data-" + SINGLE_FILE_PREFIX + "canvas";
  2695. const STYLE_ATTRIBUTE_NAME = "data-" + SINGLE_FILE_PREFIX + "movable-style";
  2696. const INPUT_VALUE_ATTRIBUTE_NAME = "data-" + SINGLE_FILE_PREFIX + "input-value";
  2697. const LAZY_SRC_ATTRIBUTE_NAME = "data-" + SINGLE_FILE_PREFIX + "lazy-loaded-src";
  2698. const STYLESHEET_ATTRIBUTE_NAME = "data-" + SINGLE_FILE_PREFIX + "stylesheet";
  2699. const DISABLED_NOSCRIPT_ATTRIBUTE_NAME = "data-" + SINGLE_FILE_PREFIX + "disabled-noscript";
  2700. const SELECTED_CONTENT_ATTRIBUTE_NAME = "data-" + SINGLE_FILE_PREFIX + "selected-content";
  2701. const INVALID_ELEMENT_ATTRIBUTE_NAME = "data-" + SINGLE_FILE_PREFIX + "invalid-element";
  2702. const ASYNC_SCRIPT_ATTRIBUTE_NAME = "data-" + SINGLE_FILE_PREFIX + "async-script";
  2703. const FLOW_ELEMENTS_SELECTOR = "*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)";
  2704. const KEPT_TAG_NAMES = ["NOSCRIPT", "DISABLED-NOSCRIPT", "META", "LINK", "STYLE", "TITLE", "TEMPLATE", "SOURCE", "OBJECT", "SCRIPT", "HEAD", "BODY"];
  2705. const REGEXP_SIMPLE_QUOTES_STRING = /^'(.*?)'$/;
  2706. const REGEXP_DOUBLE_QUOTES_STRING = /^"(.*?)"$/;
  2707. const FONT_WEIGHTS = {
  2708. regular: "400",
  2709. normal: "400",
  2710. bold: "700",
  2711. bolder: "700",
  2712. lighter: "100"
  2713. };
  2714. const COMMENT_HEADER_LEGACY = "Archive processed by SingleFile";
  2715. const SINGLE_FILE_UI_ELEMENT_CLASS = "single-file-ui-element";
  2716. const INFOBAR_TAGNAME = INFOBAR_TAGNAME$1;
  2717. const EMPTY_RESOURCE$1 = "data:,";
  2718. const JSON$1 = globalThis.JSON;
  2719. function initDoc(doc) {
  2720. doc.querySelectorAll("meta[http-equiv=refresh]").forEach(element => {
  2721. element.removeAttribute("http-equiv");
  2722. element.setAttribute("disabled-http-equiv", "refresh");
  2723. });
  2724. }
  2725. function preProcessDoc(doc, win, options) {
  2726. doc.querySelectorAll("noscript:not([" + DISABLED_NOSCRIPT_ATTRIBUTE_NAME + "])").forEach(element => {
  2727. element.setAttribute(DISABLED_NOSCRIPT_ATTRIBUTE_NAME, element.textContent);
  2728. element.textContent = "";
  2729. });
  2730. initDoc(doc);
  2731. if (doc.head) {
  2732. doc.head.querySelectorAll(FLOW_ELEMENTS_SELECTOR).forEach(element => element.hidden = true);
  2733. }
  2734. doc.querySelectorAll("svg foreignObject").forEach(element => {
  2735. const flowElements = element.querySelectorAll("html > head > " + FLOW_ELEMENTS_SELECTOR + ", html > body > " + FLOW_ELEMENTS_SELECTOR);
  2736. if (flowElements.length) {
  2737. Array.from(element.childNodes).forEach(node => node.remove());
  2738. flowElements.forEach(flowElement => element.appendChild(flowElement));
  2739. }
  2740. });
  2741. const invalidElements = new Map();
  2742. let elementsInfo;
  2743. if (win && doc.documentElement) {
  2744. doc.querySelectorAll("button button, a a").forEach(element => {
  2745. const placeHolderElement = doc.createElement("template");
  2746. placeHolderElement.setAttribute(INVALID_ELEMENT_ATTRIBUTE_NAME, "");
  2747. placeHolderElement.content.appendChild(element.cloneNode(true));
  2748. invalidElements.set(element, placeHolderElement);
  2749. element.replaceWith(placeHolderElement);
  2750. });
  2751. elementsInfo = getElementsInfo(win, doc, doc.documentElement, options);
  2752. if (options.moveStylesInHead) {
  2753. doc.querySelectorAll("body style, body ~ style").forEach(element => {
  2754. const computedStyle = getComputedStyle$1(win, element);
  2755. if (computedStyle && testHiddenElement(element, computedStyle)) {
  2756. element.setAttribute(STYLE_ATTRIBUTE_NAME, "");
  2757. elementsInfo.markedElements.push(element);
  2758. }
  2759. });
  2760. }
  2761. } else {
  2762. elementsInfo = {
  2763. canvases: [],
  2764. images: [],
  2765. posters: [],
  2766. videos: [],
  2767. usedFonts: [],
  2768. shadowRoots: [],
  2769. markedElements: []
  2770. };
  2771. }
  2772. return {
  2773. canvases: elementsInfo.canvases,
  2774. fonts: getFontsData(),
  2775. stylesheets: getStylesheetsData(doc),
  2776. images: elementsInfo.images,
  2777. posters: elementsInfo.posters,
  2778. videos: elementsInfo.videos,
  2779. usedFonts: Array.from(elementsInfo.usedFonts.values()),
  2780. shadowRoots: elementsInfo.shadowRoots,
  2781. referrer: doc.referrer,
  2782. markedElements: elementsInfo.markedElements,
  2783. invalidElements,
  2784. scrollPosition: { x: win.scrollX, y: win.scrollY },
  2785. adoptedStyleSheets: getStylesheetsContent(doc.adoptedStyleSheets)
  2786. };
  2787. }
  2788. function getElementsInfo(win, doc, element, options, data = { usedFonts: new Map(), canvases: [], images: [], posters: [], videos: [], shadowRoots: [], markedElements: [] }, ascendantHidden) {
  2789. if (element.childNodes) {
  2790. const elements = Array.from(element.childNodes).filter(node => (node instanceof win.HTMLElement) || (node instanceof win.SVGElement));
  2791. elements.forEach(element => {
  2792. let elementHidden, elementKept, computedStyle;
  2793. if (!options.autoSaveExternalSave && (options.removeHiddenElements || options.removeUnusedFonts || options.compressHTML)) {
  2794. computedStyle = getComputedStyle$1(win, element);
  2795. if (element instanceof win.HTMLElement) {
  2796. if (options.removeHiddenElements) {
  2797. elementKept = ((ascendantHidden || element.closest("html > head")) && KEPT_TAG_NAMES.includes(element.tagName.toUpperCase())) || element.closest("details");
  2798. if (!elementKept) {
  2799. elementHidden = ascendantHidden || testHiddenElement(element, computedStyle);
  2800. if (elementHidden) {
  2801. element.setAttribute(HIDDEN_CONTENT_ATTRIBUTE_NAME, "");
  2802. data.markedElements.push(element);
  2803. }
  2804. }
  2805. }
  2806. }
  2807. if (!elementHidden) {
  2808. if (options.compressHTML && computedStyle) {
  2809. const whiteSpace = computedStyle.getPropertyValue("white-space");
  2810. if (whiteSpace && whiteSpace.startsWith("pre")) {
  2811. element.setAttribute(PRESERVED_SPACE_ELEMENT_ATTRIBUTE_NAME, "");
  2812. data.markedElements.push(element);
  2813. }
  2814. }
  2815. if (options.removeUnusedFonts) {
  2816. getUsedFont(computedStyle, options, data.usedFonts);
  2817. getUsedFont(getComputedStyle$1(win, element, ":first-letter"), options, data.usedFonts);
  2818. getUsedFont(getComputedStyle$1(win, element, ":before"), options, data.usedFonts);
  2819. getUsedFont(getComputedStyle$1(win, element, ":after"), options, data.usedFonts);
  2820. }
  2821. }
  2822. }
  2823. getResourcesInfo(win, doc, element, options, data, elementHidden, computedStyle);
  2824. const shadowRoot = !(element instanceof win.SVGElement) && getShadowRoot(element);
  2825. if (shadowRoot && !element.classList.contains(SINGLE_FILE_UI_ELEMENT_CLASS)) {
  2826. const shadowRootInfo = {};
  2827. element.setAttribute(SHADOW_ROOT_ATTRIBUTE_NAME, data.shadowRoots.length);
  2828. data.markedElements.push(element);
  2829. data.shadowRoots.push(shadowRootInfo);
  2830. try {
  2831. if (shadowRoot.adoptedStyleSheets) {
  2832. if (shadowRoot.adoptedStyleSheets.length) {
  2833. shadowRootInfo.adoptedStyleSheets = getStylesheetsContent(shadowRoot.adoptedStyleSheets);
  2834. } else if (shadowRoot.adoptedStyleSheets.length === undefined) {
  2835. const listener = event => shadowRootInfo.adoptedStyleSheets = event.detail.adoptedStyleSheets;
  2836. element.addEventListener(GET_ADOPTED_STYLESHEETS_RESPONSE_EVENT, listener);
  2837. element.dispatchEvent(new CustomEvent(GET_ADOPTED_STYLESHEETS_REQUEST_EVENT, { bubbles: true }));
  2838. element.removeEventListener(GET_ADOPTED_STYLESHEETS_RESPONSE_EVENT, listener);
  2839. }
  2840. }
  2841. } catch (error) {
  2842. // ignored
  2843. }
  2844. getElementsInfo(win, doc, shadowRoot, options, data, elementHidden);
  2845. shadowRootInfo.content = shadowRoot.innerHTML;
  2846. shadowRootInfo.mode = shadowRoot.mode;
  2847. try {
  2848. if (shadowRoot.adoptedStyleSheets && shadowRoot.adoptedStyleSheets.length === undefined) {
  2849. element.dispatchEvent(new CustomEvent(UNREGISTER_GET_ADOPTED_STYLESHEETS_REQUEST_EVENT, { bubbles: true }));
  2850. }
  2851. } catch (error) {
  2852. // ignored
  2853. }
  2854. }
  2855. getElementsInfo(win, doc, element, options, data, elementHidden);
  2856. if (!options.autoSaveExternalSave && options.removeHiddenElements && ascendantHidden) {
  2857. if (elementKept || element.getAttribute(KEPT_CONTENT_ATTRIBUTE_NAME) == "") {
  2858. if (element.parentElement) {
  2859. element.parentElement.setAttribute(KEPT_CONTENT_ATTRIBUTE_NAME, "");
  2860. data.markedElements.push(element.parentElement);
  2861. }
  2862. } else if (elementHidden) {
  2863. element.setAttribute(REMOVED_CONTENT_ATTRIBUTE_NAME, "");
  2864. data.markedElements.push(element);
  2865. }
  2866. }
  2867. });
  2868. }
  2869. return data;
  2870. }
  2871. function getStylesheetsContent(styleSheets) {
  2872. return styleSheets ? Array.from(styleSheets).map(stylesheet => Array.from(stylesheet.cssRules).map(cssRule => cssRule.cssText).join("\n")) : [];
  2873. }
  2874. function getResourcesInfo(win, doc, element, options, data, elementHidden, computedStyle) {
  2875. const tagName = element.tagName && element.tagName.toUpperCase();
  2876. if (tagName == "CANVAS") {
  2877. try {
  2878. data.canvases.push({
  2879. dataURI: element.toDataURL("image/png", ""),
  2880. backgroundColor: computedStyle.getPropertyValue("background-color")
  2881. });
  2882. element.setAttribute(CANVAS_ATTRIBUTE_NAME, data.canvases.length - 1);
  2883. data.markedElements.push(element);
  2884. } catch (error) {
  2885. // ignored
  2886. }
  2887. }
  2888. if (tagName == "IMG") {
  2889. const imageData = {
  2890. currentSrc: elementHidden ?
  2891. EMPTY_RESOURCE$1 :
  2892. (options.loadDeferredImages && element.getAttribute(LAZY_SRC_ATTRIBUTE_NAME)) || element.currentSrc
  2893. };
  2894. data.images.push(imageData);
  2895. element.setAttribute(IMAGE_ATTRIBUTE_NAME, data.images.length - 1);
  2896. data.markedElements.push(element);
  2897. element.removeAttribute(LAZY_SRC_ATTRIBUTE_NAME);
  2898. computedStyle = computedStyle || getComputedStyle$1(win, element);
  2899. if (computedStyle) {
  2900. imageData.size = getSize(win, element, computedStyle);
  2901. const boxShadow = computedStyle.getPropertyValue("box-shadow");
  2902. const backgroundImage = computedStyle.getPropertyValue("background-image");
  2903. if ((!boxShadow || boxShadow == "none") &&
  2904. (!backgroundImage || backgroundImage == "none") &&
  2905. (imageData.size.pxWidth > 1 || imageData.size.pxHeight > 1)) {
  2906. imageData.replaceable = true;
  2907. imageData.backgroundColor = computedStyle.getPropertyValue("background-color");
  2908. imageData.objectFit = computedStyle.getPropertyValue("object-fit");
  2909. imageData.boxSizing = computedStyle.getPropertyValue("box-sizing");
  2910. imageData.objectPosition = computedStyle.getPropertyValue("object-position");
  2911. }
  2912. }
  2913. }
  2914. if (tagName == "VIDEO") {
  2915. const src = element.currentSrc;
  2916. if (src && !src.startsWith("blob:") && !src.startsWith("data:")) {
  2917. const computedStyle = getComputedStyle$1(win, element.parentNode);
  2918. data.videos.push({
  2919. positionParent: computedStyle && computedStyle.getPropertyValue("position"),
  2920. src,
  2921. size: {
  2922. pxWidth: element.clientWidth,
  2923. pxHeight: element.clientHeight
  2924. },
  2925. currentTime: element.currentTime
  2926. });
  2927. element.setAttribute(VIDEO_ATTRIBUTE_NAME, data.videos.length - 1);
  2928. }
  2929. if (!element.getAttribute("poster")) {
  2930. const canvasElement = doc.createElement("canvas");
  2931. const context = canvasElement.getContext("2d");
  2932. canvasElement.width = element.clientWidth;
  2933. canvasElement.height = element.clientHeight;
  2934. try {
  2935. context.drawImage(element, 0, 0, canvasElement.width, canvasElement.height);
  2936. data.posters.push(canvasElement.toDataURL("image/png", ""));
  2937. element.setAttribute(POSTER_ATTRIBUTE_NAME, data.posters.length - 1);
  2938. data.markedElements.push(element);
  2939. } catch (error) {
  2940. // ignored
  2941. }
  2942. }
  2943. }
  2944. if (tagName == "IFRAME") {
  2945. if (elementHidden && options.removeHiddenElements) {
  2946. element.setAttribute(HIDDEN_FRAME_ATTRIBUTE_NAME, "");
  2947. data.markedElements.push(element);
  2948. }
  2949. }
  2950. if (tagName == "INPUT") {
  2951. if (element.type != "password") {
  2952. element.setAttribute(INPUT_VALUE_ATTRIBUTE_NAME, element.value);
  2953. data.markedElements.push(element);
  2954. }
  2955. if (element.type == "radio" || element.type == "checkbox") {
  2956. element.setAttribute(INPUT_VALUE_ATTRIBUTE_NAME, element.checked);
  2957. data.markedElements.push(element);
  2958. }
  2959. }
  2960. if (tagName == "TEXTAREA") {
  2961. element.setAttribute(INPUT_VALUE_ATTRIBUTE_NAME, element.value);
  2962. data.markedElements.push(element);
  2963. }
  2964. if (tagName == "SELECT") {
  2965. element.querySelectorAll("option").forEach(option => {
  2966. if (option.selected) {
  2967. option.setAttribute(INPUT_VALUE_ATTRIBUTE_NAME, "");
  2968. data.markedElements.push(option);
  2969. }
  2970. });
  2971. }
  2972. if (tagName == "SCRIPT") {
  2973. if (element.async && element.getAttribute("async") != "" && element.getAttribute("async") != "async") {
  2974. element.setAttribute(ASYNC_SCRIPT_ATTRIBUTE_NAME, "");
  2975. data.markedElements.push(element);
  2976. }
  2977. element.textContent = element.textContent.replace(/<\/script>/gi, "<\\/script>");
  2978. }
  2979. }
  2980. function getUsedFont(computedStyle, options, usedFonts) {
  2981. if (computedStyle) {
  2982. const fontStyle = computedStyle.getPropertyValue("font-style") || "normal";
  2983. computedStyle.getPropertyValue("font-family").split(",").forEach(fontFamilyName => {
  2984. fontFamilyName = normalizeFontFamily(fontFamilyName);
  2985. if (!options.loadedFonts || options.loadedFonts.find(font => normalizeFontFamily(font.family) == fontFamilyName && font.style == fontStyle)) {
  2986. const fontWeight = getFontWeight(computedStyle.getPropertyValue("font-weight"));
  2987. const fontVariant = computedStyle.getPropertyValue("font-variant") || "normal";
  2988. const value = [fontFamilyName, fontWeight, fontStyle, fontVariant];
  2989. usedFonts.set(JSON$1.stringify(value), [fontFamilyName, fontWeight, fontStyle, fontVariant]);
  2990. }
  2991. });
  2992. }
  2993. }
  2994. function getShadowRoot(element) {
  2995. const chrome = globalThis.chrome;
  2996. if (element.openOrClosedShadowRoot) {
  2997. return element.openOrClosedShadowRoot;
  2998. } else if (chrome && chrome.dom && chrome.dom.openOrClosedShadowRoot) {
  2999. try {
  3000. return chrome.dom.openOrClosedShadowRoot(element);
  3001. } catch (error) {
  3002. return element.shadowRoot;
  3003. }
  3004. } else {
  3005. return element.shadowRoot;
  3006. }
  3007. }
  3008. function appendInfobar(doc, options, useShadowRoot) {
  3009. return appendInfobar$1(doc, options, useShadowRoot);
  3010. }
  3011. function normalizeFontFamily(fontFamilyName = "") {
  3012. return removeQuotes(process$6(fontFamilyName.trim())).toLowerCase();
  3013. }
  3014. function testHiddenElement(element, computedStyle) {
  3015. let hidden = false;
  3016. if (computedStyle) {
  3017. const display = computedStyle.getPropertyValue("display");
  3018. const opacity = computedStyle.getPropertyValue("opacity");
  3019. const visibility = computedStyle.getPropertyValue("visibility");
  3020. hidden = display == "none";
  3021. if (!hidden && (opacity == "0" || visibility == "hidden") && element.getBoundingClientRect) {
  3022. const boundingRect = element.getBoundingClientRect();
  3023. hidden = !boundingRect.width && !boundingRect.height;
  3024. }
  3025. }
  3026. return Boolean(hidden);
  3027. }
  3028. function postProcessDoc(doc, markedElements, invalidElements) {
  3029. doc.querySelectorAll("[" + DISABLED_NOSCRIPT_ATTRIBUTE_NAME + "]").forEach(element => {
  3030. element.textContent = element.getAttribute(DISABLED_NOSCRIPT_ATTRIBUTE_NAME);
  3031. element.removeAttribute(DISABLED_NOSCRIPT_ATTRIBUTE_NAME);
  3032. if (doc.body.firstChild) {
  3033. doc.body.insertBefore(element, doc.body.firstChild);
  3034. } else {
  3035. doc.body.appendChild(element);
  3036. }
  3037. });
  3038. doc.querySelectorAll("meta[disabled-http-equiv]").forEach(element => {
  3039. element.setAttribute("http-equiv", element.getAttribute("disabled-http-equiv"));
  3040. element.removeAttribute("disabled-http-equiv");
  3041. });
  3042. if (doc.head) {
  3043. doc.head.querySelectorAll("*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)").forEach(element => element.removeAttribute("hidden"));
  3044. }
  3045. if (!markedElements) {
  3046. const singleFileAttributes = [REMOVED_CONTENT_ATTRIBUTE_NAME, HIDDEN_FRAME_ATTRIBUTE_NAME, HIDDEN_CONTENT_ATTRIBUTE_NAME, PRESERVED_SPACE_ELEMENT_ATTRIBUTE_NAME, IMAGE_ATTRIBUTE_NAME, POSTER_ATTRIBUTE_NAME, VIDEO_ATTRIBUTE_NAME, CANVAS_ATTRIBUTE_NAME, INPUT_VALUE_ATTRIBUTE_NAME, SHADOW_ROOT_ATTRIBUTE_NAME, STYLESHEET_ATTRIBUTE_NAME, ASYNC_SCRIPT_ATTRIBUTE_NAME];
  3047. markedElements = doc.querySelectorAll(singleFileAttributes.map(name => "[" + name + "]").join(","));
  3048. }
  3049. markedElements.forEach(element => {
  3050. element.removeAttribute(REMOVED_CONTENT_ATTRIBUTE_NAME);
  3051. element.removeAttribute(HIDDEN_CONTENT_ATTRIBUTE_NAME);
  3052. element.removeAttribute(KEPT_CONTENT_ATTRIBUTE_NAME);
  3053. element.removeAttribute(HIDDEN_FRAME_ATTRIBUTE_NAME);
  3054. element.removeAttribute(PRESERVED_SPACE_ELEMENT_ATTRIBUTE_NAME);
  3055. element.removeAttribute(IMAGE_ATTRIBUTE_NAME);
  3056. element.removeAttribute(POSTER_ATTRIBUTE_NAME);
  3057. element.removeAttribute(VIDEO_ATTRIBUTE_NAME);
  3058. element.removeAttribute(CANVAS_ATTRIBUTE_NAME);
  3059. element.removeAttribute(INPUT_VALUE_ATTRIBUTE_NAME);
  3060. element.removeAttribute(SHADOW_ROOT_ATTRIBUTE_NAME);
  3061. element.removeAttribute(STYLESHEET_ATTRIBUTE_NAME);
  3062. element.removeAttribute(ASYNC_SCRIPT_ATTRIBUTE_NAME);
  3063. element.removeAttribute(STYLE_ATTRIBUTE_NAME);
  3064. });
  3065. if (invalidElements) {
  3066. invalidElements.forEach((placeholderElement, element) => placeholderElement.replaceWith(element));
  3067. }
  3068. }
  3069. function getStylesheetsData(doc) {
  3070. if (doc) {
  3071. const contents = [];
  3072. doc.querySelectorAll("style").forEach((styleElement, styleIndex) => {
  3073. try {
  3074. const tempStyleElement = doc.createElement("style");
  3075. tempStyleElement.textContent = styleElement.textContent;
  3076. doc.body.appendChild(tempStyleElement);
  3077. const stylesheet = tempStyleElement.sheet;
  3078. tempStyleElement.remove();
  3079. if (!stylesheet || stylesheet.cssRules.length != styleElement.sheet.cssRules.length) {
  3080. styleElement.setAttribute(STYLESHEET_ATTRIBUTE_NAME, styleIndex);
  3081. contents[styleIndex] = Array.from(styleElement.sheet.cssRules).map(cssRule => cssRule.cssText).join("\n");
  3082. }
  3083. } catch (error) {
  3084. // ignored
  3085. }
  3086. });
  3087. return contents;
  3088. }
  3089. }
  3090. function getSize(win, imageElement, computedStyle) {
  3091. let pxWidth = imageElement.naturalWidth;
  3092. let pxHeight = imageElement.naturalHeight;
  3093. if (!pxWidth && !pxHeight) {
  3094. const noStyleAttribute = imageElement.getAttribute("style") == null;
  3095. computedStyle = computedStyle || getComputedStyle$1(win, imageElement);
  3096. if (computedStyle) {
  3097. let removeBorderWidth = false;
  3098. if (computedStyle.getPropertyValue("box-sizing") == "content-box") {
  3099. const boxSizingValue = imageElement.style.getPropertyValue("box-sizing");
  3100. const boxSizingPriority = imageElement.style.getPropertyPriority("box-sizing");
  3101. const clientWidth = imageElement.clientWidth;
  3102. imageElement.style.setProperty("box-sizing", "border-box", "important");
  3103. removeBorderWidth = imageElement.clientWidth != clientWidth;
  3104. if (boxSizingValue) {
  3105. imageElement.style.setProperty("box-sizing", boxSizingValue, boxSizingPriority);
  3106. } else {
  3107. imageElement.style.removeProperty("box-sizing");
  3108. }
  3109. }
  3110. let paddingLeft, paddingRight, paddingTop, paddingBottom, borderLeft, borderRight, borderTop, borderBottom;
  3111. paddingLeft = getWidth("padding-left", computedStyle);
  3112. paddingRight = getWidth("padding-right", computedStyle);
  3113. paddingTop = getWidth("padding-top", computedStyle);
  3114. paddingBottom = getWidth("padding-bottom", computedStyle);
  3115. if (removeBorderWidth) {
  3116. borderLeft = getWidth("border-left-width", computedStyle);
  3117. borderRight = getWidth("border-right-width", computedStyle);
  3118. borderTop = getWidth("border-top-width", computedStyle);
  3119. borderBottom = getWidth("border-bottom-width", computedStyle);
  3120. } else {
  3121. borderLeft = borderRight = borderTop = borderBottom = 0;
  3122. }
  3123. pxWidth = Math.max(0, imageElement.clientWidth - paddingLeft - paddingRight - borderLeft - borderRight);
  3124. pxHeight = Math.max(0, imageElement.clientHeight - paddingTop - paddingBottom - borderTop - borderBottom);
  3125. if (noStyleAttribute) {
  3126. imageElement.removeAttribute("style");
  3127. }
  3128. }
  3129. }
  3130. return { pxWidth, pxHeight };
  3131. }
  3132. function getWidth(styleName, computedStyle) {
  3133. if (computedStyle.getPropertyValue(styleName).endsWith("px")) {
  3134. return parseFloat(computedStyle.getPropertyValue(styleName));
  3135. }
  3136. }
  3137. function getFontsData() {
  3138. return getFontsData$1();
  3139. }
  3140. function removeQuotes(string) {
  3141. if (string.match(REGEXP_SIMPLE_QUOTES_STRING)) {
  3142. string = string.replace(REGEXP_SIMPLE_QUOTES_STRING, "$1");
  3143. } else {
  3144. string = string.replace(REGEXP_DOUBLE_QUOTES_STRING, "$1");
  3145. }
  3146. return string.trim();
  3147. }
  3148. function getFontWeight(weight) {
  3149. return FONT_WEIGHTS[weight.toLowerCase().trim()] || weight;
  3150. }
  3151. function flatten(array) {
  3152. return array.flat ? array.flat() : array.reduce((a, b) => a.concat(Array.isArray(b) ? flatten(b) : b), []);
  3153. }
  3154. function getComputedStyle$1(win, element, pseudoElement) {
  3155. try {
  3156. return win.getComputedStyle(element, pseudoElement);
  3157. } catch (error) {
  3158. // ignored
  3159. }
  3160. }
  3161. /*
  3162. * Copyright 2010-2022 Gildas Lormeau
  3163. * contact : gildas.lormeau <at> gmail.com
  3164. *
  3165. * This file is part of SingleFile.
  3166. *
  3167. * The code in this file is free software: you can redistribute it and/or
  3168. * modify it under the terms of the GNU Affero General Public License
  3169. * (GNU AGPL) as published by the Free Software Foundation, either version 3
  3170. * of the License, or (at your option) any later version.
  3171. *
  3172. * The code in this file is distributed in the hope that it will be useful,
  3173. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  3174. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
  3175. * General Public License for more details.
  3176. *
  3177. * As additional permission under GNU AGPL version 3 section 7, you may
  3178. * distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU
  3179. * AGPL normally required by section 4, provided you include this license
  3180. * notice and a URL through which recipients can access the Corresponding
  3181. * Source.
  3182. */
  3183. const helper$2 = {
  3184. normalizeFontFamily,
  3185. flatten,
  3186. getFontWeight,
  3187. removeQuotes
  3188. };
  3189. const REGEXP_COMMA = /\s*,\s*/;
  3190. const REGEXP_DASH = /-/;
  3191. const REGEXP_QUESTION_MARK = /\?/g;
  3192. const REGEXP_STARTS_U_PLUS = /^U\+/i;
  3193. const VALID_FONT_STYLES = [/^normal$/, /^italic$/, /^oblique$/, /^oblique\s+/];
  3194. function process$4(doc, stylesheets, styles, options) {
  3195. const stats = { rules: { processed: 0, discarded: 0 }, fonts: { processed: 0, discarded: 0 } };
  3196. const fontsInfo = { declared: [], used: [] };
  3197. const workStyleElement = doc.createElement("style");
  3198. let docContent = "";
  3199. doc.body.appendChild(workStyleElement);
  3200. stylesheets.forEach(stylesheetInfo => {
  3201. const cssRules = stylesheetInfo.stylesheet.children;
  3202. if (cssRules) {
  3203. stats.processed += cssRules.size;
  3204. stats.discarded += cssRules.size;
  3205. getFontsInfo(cssRules, fontsInfo);
  3206. docContent = getRulesTextContent(doc, cssRules, workStyleElement, docContent);
  3207. }
  3208. });
  3209. styles.forEach(declarations => {
  3210. const fontFamilyNames = getFontFamilyNames(declarations);
  3211. if (fontFamilyNames.length) {
  3212. fontsInfo.used.push(fontFamilyNames);
  3213. }
  3214. docContent = getDeclarationsTextContent(declarations.children, workStyleElement, docContent);
  3215. });
  3216. workStyleElement.remove();
  3217. docContent += doc.body.innerText;
  3218. if (globalThis.getComputedStyle && options.doc) {
  3219. fontsInfo.used = fontsInfo.used.map(fontNames => fontNames.map(familyName => {
  3220. const matchedVar = familyName.match(/^var\((--.*)\)$/);
  3221. if (matchedVar && matchedVar[1]) {
  3222. const computedFamilyName = globalThis.getComputedStyle(options.doc.body).getPropertyValue(matchedVar[1]);
  3223. return (computedFamilyName && computedFamilyName.split(",").map(name => helper$2.normalizeFontFamily(name))) || familyName;
  3224. }
  3225. return familyName;
  3226. }));
  3227. fontsInfo.used = fontsInfo.used.map(fontNames => helper$2.flatten(fontNames));
  3228. }
  3229. const variableFound = fontsInfo.used.find(fontNames => fontNames.find(fontName => fontName.match(/^var\(--/)));
  3230. let unusedFonts, filteredUsedFonts;
  3231. if (variableFound) {
  3232. unusedFonts = [];
  3233. } else {
  3234. filteredUsedFonts = new Map();
  3235. fontsInfo.used.forEach(fontNames => fontNames.forEach(familyName => {
  3236. if (fontsInfo.declared.find(fontInfo => fontInfo.fontFamily == familyName)) {
  3237. const optionalData = options.usedFonts && options.usedFonts.filter(fontInfo => fontInfo[0] == familyName);
  3238. if (optionalData && optionalData.length) {
  3239. filteredUsedFonts.set(familyName, optionalData);
  3240. }
  3241. }
  3242. }));
  3243. unusedFonts = fontsInfo.declared.filter(fontInfo => !filteredUsedFonts.has(fontInfo.fontFamily));
  3244. }
  3245. stylesheets.forEach(stylesheetInfo => {
  3246. const cssRules = stylesheetInfo.stylesheet.children;
  3247. if (cssRules) {
  3248. filterUnusedFonts(cssRules, fontsInfo.declared, unusedFonts, filteredUsedFonts, docContent);
  3249. stats.rules.discarded -= cssRules.size;
  3250. }
  3251. });
  3252. return stats;
  3253. }
  3254. function getFontsInfo(cssRules, fontsInfo) {
  3255. cssRules.forEach(ruleData => {
  3256. if (ruleData.type == "Atrule" && (ruleData.name == "media" || ruleData.name == "supports") && ruleData.block && ruleData.block.children) {
  3257. getFontsInfo(ruleData.block.children, fontsInfo);
  3258. } else if (ruleData.type == "Rule") {
  3259. const fontFamilyNames = getFontFamilyNames(ruleData.block);
  3260. if (fontFamilyNames.length) {
  3261. fontsInfo.used.push(fontFamilyNames);
  3262. }
  3263. } else {
  3264. if (ruleData.type == "Atrule" && ruleData.name == "font-face") {
  3265. const fontFamily = helper$2.normalizeFontFamily(getDeclarationValue(ruleData.block.children, "font-family"));
  3266. if (fontFamily) {
  3267. const fontWeight = getDeclarationValue(ruleData.block.children, "font-weight") || "400";
  3268. const fontStyle = getDeclarationValue(ruleData.block.children, "font-style") || "normal";
  3269. const fontVariant = getDeclarationValue(ruleData.block.children, "font-variant") || "normal";
  3270. fontWeight.split(",").forEach(weightValue =>
  3271. fontsInfo.declared.push({ fontFamily, fontWeight: helper$2.getFontWeight(helper$2.removeQuotes(weightValue)), fontStyle, fontVariant }));
  3272. }
  3273. }
  3274. }
  3275. });
  3276. }
  3277. function filterUnusedFonts(cssRules, declaredFonts, unusedFonts, filteredUsedFonts, docContent) {
  3278. const removedRules = [];
  3279. for (let cssRule = cssRules.head; cssRule; cssRule = cssRule.next) {
  3280. const ruleData = cssRule.data;
  3281. if (ruleData.type == "Atrule" && (ruleData.name == "media" || ruleData.name == "supports") && ruleData.block && ruleData.block.children) {
  3282. filterUnusedFonts(ruleData.block.children, declaredFonts, unusedFonts, filteredUsedFonts, docContent);
  3283. } else if (ruleData.type == "Atrule" && ruleData.name == "font-face") {
  3284. const fontFamily = helper$2.normalizeFontFamily(getDeclarationValue(ruleData.block.children, "font-family"));
  3285. if (fontFamily) {
  3286. const unicodeRange = getDeclarationValue(ruleData.block.children, "unicode-range");
  3287. if (unusedFonts.find(fontInfo => fontInfo.fontFamily == fontFamily) || !testUnicodeRange(docContent, unicodeRange) || !testUsedFont(ruleData, fontFamily, declaredFonts, filteredUsedFonts)) {
  3288. removedRules.push(cssRule);
  3289. }
  3290. }
  3291. const removedDeclarations = [];
  3292. for (let declaration = ruleData.block.children.head; declaration; declaration = declaration.next) {
  3293. if (declaration.data.property == "font-display") {
  3294. removedDeclarations.push(declaration);
  3295. }
  3296. }
  3297. if (removedDeclarations.length) {
  3298. removedDeclarations.forEach(removedDeclaration => ruleData.block.children.remove(removedDeclaration));
  3299. }
  3300. }
  3301. }
  3302. removedRules.forEach(cssRule => cssRules.remove(cssRule));
  3303. }
  3304. function testUsedFont(ruleData, familyName, declaredFonts, filteredUsedFonts) {
  3305. let test;
  3306. const optionalUsedFonts = filteredUsedFonts && filteredUsedFonts.get(familyName);
  3307. if (optionalUsedFonts && optionalUsedFonts.length) {
  3308. let fontStyle = getDeclarationValue(ruleData.block.children, "font-style") || "normal";
  3309. if (VALID_FONT_STYLES.find(rule => fontStyle.trim().match(rule))) {
  3310. const fontWeight = helper$2.getFontWeight(getDeclarationValue(ruleData.block.children, "font-weight") || "400");
  3311. const declaredFontsWeights = declaredFonts
  3312. .filter(fontInfo => fontInfo.fontFamily == familyName && fontInfo.fontStyle == fontStyle)
  3313. .map(fontInfo => fontInfo.fontWeight)
  3314. .sort((weight1, weight2) => Number.parseInt(weight1, 10) - Number.parseInt(weight2, 10));
  3315. let usedFontWeights = optionalUsedFonts.map(fontInfo => getUsedFontWeight(fontInfo, fontStyle, declaredFontsWeights));
  3316. test = testFontweight(fontWeight, usedFontWeights);
  3317. if (!test) {
  3318. usedFontWeights = optionalUsedFonts.map(fontInfo => {
  3319. fontInfo = Array.from(fontInfo);
  3320. fontInfo[2] = "normal";
  3321. return getUsedFontWeight(fontInfo, fontStyle, declaredFontsWeights);
  3322. });
  3323. }
  3324. test = testFontweight(fontWeight, usedFontWeights);
  3325. } else {
  3326. test = true;
  3327. }
  3328. } else {
  3329. test = true;
  3330. }
  3331. return test;
  3332. }
  3333. function testFontweight(fontWeight, usedFontWeights) {
  3334. let test;
  3335. for (const value of fontWeight.split(/[ ,]/)) {
  3336. test = test || usedFontWeights.includes(helper$2.getFontWeight(helper$2.removeQuotes(value)));
  3337. }
  3338. return test;
  3339. }
  3340. function getDeclarationValue(declarations, propertyName) {
  3341. let property;
  3342. if (declarations) {
  3343. property = declarations.filter(declaration => declaration.property == propertyName).tail;
  3344. }
  3345. if (property) {
  3346. try {
  3347. return helper$2.removeQuotes(gb(property.data.value)).toLowerCase();
  3348. } catch (error) {
  3349. // ignored
  3350. }
  3351. }
  3352. }
  3353. function getFontFamilyNames(declarations) {
  3354. let fontFamilyName = declarations.children.filter(node => node.property == "font-family").tail;
  3355. let fontFamilyNames = [];
  3356. if (fontFamilyName) {
  3357. if (fontFamilyName.data.value.children) {
  3358. parseFamilyNames(fontFamilyName.data.value, fontFamilyNames);
  3359. } else {
  3360. fontFamilyName = gb(fontFamilyName.data.value);
  3361. if (fontFamilyName) {
  3362. fontFamilyNames.push(helper$2.normalizeFontFamily(fontFamilyName));
  3363. }
  3364. }
  3365. }
  3366. const font = declarations.children.filter(node => node.property == "font").tail;
  3367. if (font && font.data && font.data.value) {
  3368. try {
  3369. const parsedFont = parse(font.data.value);
  3370. parsedFont.family.forEach(familyName => fontFamilyNames.push(helper$2.normalizeFontFamily(familyName)));
  3371. } catch (error) {
  3372. // ignored
  3373. }
  3374. }
  3375. return fontFamilyNames;
  3376. }
  3377. function parseFamilyNames(fontFamilyNameTokenData, fontFamilyNames) {
  3378. let nextToken = fontFamilyNameTokenData.children.head;
  3379. while (nextToken) {
  3380. if (nextToken.data.type == "Identifier") {
  3381. let familyName = nextToken.data.name;
  3382. let nextIdentifierToken = nextToken.next;
  3383. while (nextIdentifierToken && nextIdentifierToken.data.type != "Operator" && nextIdentifierToken.data.value != ",") {
  3384. familyName += " " + nextIdentifierToken.data.name;
  3385. nextIdentifierToken = nextIdentifierToken.next;
  3386. }
  3387. fontFamilyNames.push(helper$2.normalizeFontFamily(familyName));
  3388. nextToken = nextToken.next;
  3389. } else if (nextToken.data.type == "Function" && nextToken.data.name == "var" && nextToken.data.children) {
  3390. const varName = nextToken.data.children.head.data.name;
  3391. fontFamilyNames.push(helper$2.normalizeFontFamily("var(" + varName + ")"));
  3392. let nextValueToken = nextToken.data.children.head.next;
  3393. while (nextValueToken && nextValueToken.data.type == "Operator" && nextValueToken.data.value == ",") {
  3394. nextValueToken = nextValueToken.next;
  3395. }
  3396. const fallbackToken = nextValueToken;
  3397. if (fallbackToken) {
  3398. if (fallbackToken.data.children) {
  3399. parseFamilyNames(fallbackToken.data, fontFamilyNames);
  3400. } else {
  3401. fontFamilyNames.push(helper$2.normalizeFontFamily(fallbackToken.data.value));
  3402. }
  3403. }
  3404. nextToken = nextToken.next;
  3405. } else if (nextToken.data.type == "String") {
  3406. fontFamilyNames.push(helper$2.normalizeFontFamily(nextToken.data.value));
  3407. nextToken = nextToken.next;
  3408. } else if (nextToken.data.type == "Operator" && nextToken.data.value == ",") {
  3409. nextToken = nextToken.next;
  3410. }
  3411. }
  3412. }
  3413. function getUsedFontWeight(fontInfo, fontStyle, fontWeights) {
  3414. let foundWeight;
  3415. fontWeights = fontWeights.map(weight => String(Number.parseInt(weight, 10)));
  3416. if (fontInfo[2] == fontStyle) {
  3417. let fontWeight = Number(fontInfo[1]);
  3418. if (fontWeights.length > 1) {
  3419. if (fontWeight >= 400 && fontWeight <= 500) {
  3420. foundWeight = fontWeights.find(weight => weight >= fontWeight && weight <= 500);
  3421. if (!foundWeight) {
  3422. foundWeight = findDescendingFontWeight(fontWeight, fontWeights);
  3423. }
  3424. if (!foundWeight) {
  3425. foundWeight = findAscendingFontWeight(fontWeight, fontWeights);
  3426. }
  3427. }
  3428. if (fontWeight < 400) {
  3429. foundWeight = fontWeights.slice().reverse().find(weight => weight <= fontWeight);
  3430. if (!foundWeight) {
  3431. foundWeight = findAscendingFontWeight(fontWeight, fontWeights);
  3432. }
  3433. }
  3434. if (fontWeight > 500) {
  3435. foundWeight = fontWeights.find(weight => weight >= fontWeight);
  3436. if (!foundWeight) {
  3437. foundWeight = findDescendingFontWeight(fontWeight, fontWeights);
  3438. }
  3439. }
  3440. } else {
  3441. foundWeight = fontWeights[0];
  3442. }
  3443. }
  3444. return foundWeight;
  3445. }
  3446. function findDescendingFontWeight(fontWeight, fontWeights) {
  3447. return fontWeights.slice().reverse().find(weight => weight < fontWeight);
  3448. }
  3449. function findAscendingFontWeight(fontWeight, fontWeights) {
  3450. return fontWeights.find(weight => weight > fontWeight);
  3451. }
  3452. function getRulesTextContent(doc, cssRules, workStylesheet, content) {
  3453. cssRules.forEach(ruleData => {
  3454. if (ruleData.block && ruleData.block.children && ruleData.prelude && ruleData.prelude.children) {
  3455. if (ruleData.type == "Atrule" && (ruleData.name == "media" || ruleData.name == "supports")) {
  3456. content = getRulesTextContent(doc, ruleData.block.children, workStylesheet, content);
  3457. } else if (ruleData.type == "Rule") {
  3458. content = getDeclarationsTextContent(ruleData.block.children, workStylesheet, content);
  3459. }
  3460. }
  3461. });
  3462. return content;
  3463. }
  3464. function getDeclarationsTextContent(declarations, workStylesheet, content) {
  3465. const contentText = getDeclarationUnescapedValue(declarations, "content", workStylesheet);
  3466. const quotesText = getDeclarationUnescapedValue(declarations, "quotes", workStylesheet);
  3467. if (!content.includes(contentText)) {
  3468. content += contentText;
  3469. }
  3470. if (!content.includes(quotesText)) {
  3471. content += quotesText;
  3472. }
  3473. return content;
  3474. }
  3475. function getDeclarationUnescapedValue(declarations, property, workStylesheet) {
  3476. const rawValue = getDeclarationValue(declarations, property) || "";
  3477. if (rawValue) {
  3478. workStylesheet.textContent = "tmp { content:\"" + rawValue + "\"}";
  3479. if (workStylesheet.sheet && workStylesheet.sheet.cssRules) {
  3480. return helper$2.removeQuotes(workStylesheet.sheet.cssRules[0].style.getPropertyValue("content"));
  3481. } else {
  3482. return rawValue;
  3483. }
  3484. }
  3485. return "";
  3486. }
  3487. function testUnicodeRange(docContent, unicodeRange) {
  3488. if (unicodeRange) {
  3489. const unicodeRanges = unicodeRange.split(REGEXP_COMMA);
  3490. let invalid;
  3491. const result = unicodeRanges.filter(rangeValue => {
  3492. const range = rangeValue.split(REGEXP_DASH);
  3493. let regExpString;
  3494. if (range.length == 2) {
  3495. range[0] = transformRange(range[0]);
  3496. regExpString = "[" + range[0] + "-" + transformRange("U+" + range[1]) + "]";
  3497. }
  3498. if (range.length == 1) {
  3499. if (range[0].includes("?")) {
  3500. const firstRange = transformRange(range[0]);
  3501. const secondRange = firstRange;
  3502. regExpString = "[" + firstRange.replace(REGEXP_QUESTION_MARK, "0") + "-" + secondRange.replace(REGEXP_QUESTION_MARK, "F") + "]";
  3503. } else if (range[0]) {
  3504. regExpString = "[" + transformRange(range[0]) + "]";
  3505. }
  3506. }
  3507. if (regExpString) {
  3508. try {
  3509. return (new RegExp(regExpString, "u")).test(docContent);
  3510. } catch (error) {
  3511. invalid = true;
  3512. return false;
  3513. }
  3514. }
  3515. return true;
  3516. });
  3517. return !invalid && (!unicodeRanges.length || result.length);
  3518. }
  3519. return true;
  3520. }
  3521. function transformRange(range) {
  3522. range = range.replace(REGEXP_STARTS_U_PLUS, "");
  3523. while (range.length < 6) {
  3524. range = "0" + range;
  3525. }
  3526. return "\\u{" + range + "}";
  3527. }
  3528. /*
  3529. * Copyright 2010-2022 Gildas Lormeau
  3530. * contact : gildas.lormeau <at> gmail.com
  3531. *
  3532. * This file is part of SingleFile.
  3533. *
  3534. * The code in this file is free software: you can redistribute it and/or
  3535. * modify it under the terms of the GNU Affero General Public License
  3536. * (GNU AGPL) as published by the Free Software Foundation, either version 3
  3537. * of the License, or (at your option) any later version.
  3538. *
  3539. * The code in this file is distributed in the hope that it will be useful,
  3540. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  3541. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
  3542. * General Public License for more details.
  3543. *
  3544. * As additional permission under GNU AGPL version 3 section 7, you may
  3545. * distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU
  3546. * AGPL normally required by section 4, provided you include this license
  3547. * notice and a URL through which recipients can access the Corresponding
  3548. * Source.
  3549. */
  3550. const MEDIA_ALL$1 = "all";
  3551. const IGNORED_PSEUDO_ELEMENTS = ["after", "before", "first-letter", "first-line", "placeholder", "selection", "part", "marker"];
  3552. const SINGLE_FILE_HIDDEN_CLASS_NAME = "sf-hidden";
  3553. const DISPLAY_STYLE = "display";
  3554. const REGEXP_VENDOR_IDENTIFIER = /-(ms|webkit|moz|o)-/;
  3555. class MatchedRules {
  3556. constructor(doc, stylesheets, styles) {
  3557. this.doc = doc;
  3558. this.mediaAllInfo = createMediaInfo(MEDIA_ALL$1);
  3559. const matchedElementsCache = new Map();
  3560. let sheetIndex = 0;
  3561. const workStyleSheet = doc.createElement("style");
  3562. doc.body.appendChild(workStyleSheet);
  3563. const workStyleElement = doc.createElement("span");
  3564. doc.body.appendChild(workStyleElement);
  3565. stylesheets.forEach(stylesheetInfo => {
  3566. if (!stylesheetInfo.scoped) {
  3567. const cssRules = stylesheetInfo.stylesheet.children;
  3568. if (cssRules) {
  3569. if (stylesheetInfo.mediaText && stylesheetInfo.mediaText != MEDIA_ALL$1) {
  3570. const mediaInfo = createMediaInfo(stylesheetInfo.mediaText);
  3571. this.mediaAllInfo.medias.set("style-" + sheetIndex + "-" + stylesheetInfo.mediaText, mediaInfo);
  3572. getMatchedElementsRules(doc, cssRules, mediaInfo, sheetIndex, styles, matchedElementsCache, workStyleSheet);
  3573. } else {
  3574. getMatchedElementsRules(doc, cssRules, this.mediaAllInfo, sheetIndex, styles, matchedElementsCache, workStyleSheet);
  3575. }
  3576. }
  3577. }
  3578. sheetIndex++;
  3579. });
  3580. sortRules(this.mediaAllInfo);
  3581. computeCascade(this.mediaAllInfo, [], this.mediaAllInfo, workStyleSheet, workStyleElement);
  3582. workStyleSheet.remove();
  3583. workStyleElement.remove();
  3584. }
  3585. getMediaAllInfo() {
  3586. return this.mediaAllInfo;
  3587. }
  3588. }
  3589. function getMediaAllInfo(doc, stylesheets, styles) {
  3590. return new MatchedRules(doc, stylesheets, styles).getMediaAllInfo();
  3591. }
  3592. function createMediaInfo(media) {
  3593. const mediaInfo = { media: media, elements: new Map(), medias: new Map(), rules: new Map(), pseudoRules: new Map() };
  3594. if (media == MEDIA_ALL$1) {
  3595. mediaInfo.matchedStyles = new Map();
  3596. }
  3597. return mediaInfo;
  3598. }
  3599. function getMatchedElementsRules(doc, cssRules, mediaInfo, sheetIndex, styles, matchedElementsCache, workStylesheet) {
  3600. let mediaIndex = 0;
  3601. let ruleIndex = 0;
  3602. cssRules.forEach(ruleData => {
  3603. if (ruleData.block && ruleData.block.children && ruleData.prelude && ruleData.prelude.children) {
  3604. if (ruleData.type == "Atrule" && ruleData.name == "media") {
  3605. const mediaText = gb(ruleData.prelude);
  3606. const ruleMediaInfo = createMediaInfo(mediaText);
  3607. mediaInfo.medias.set("rule-" + sheetIndex + "-" + mediaIndex + "-" + mediaText, ruleMediaInfo);
  3608. mediaIndex++;
  3609. getMatchedElementsRules(doc, ruleData.block.children, ruleMediaInfo, sheetIndex, styles, matchedElementsCache, workStylesheet);
  3610. } else if (ruleData.type == "Rule") {
  3611. const selectors = ruleData.prelude.children.toArray();
  3612. const selectorsText = ruleData.prelude.children.toArray().map(selector => gb(selector));
  3613. const ruleInfo = { ruleData, mediaInfo, ruleIndex, sheetIndex, matchedSelectors: new Set(), declarations: new Set(), selectors, selectorsText };
  3614. if (!invalidSelector(selectorsText.join(","), workStylesheet) || selectorsText.find(selectorText => selectorText.includes("|"))) {
  3615. for (let selector = ruleData.prelude.children.head, selectorIndex = 0; selector; selector = selector.next, selectorIndex++) {
  3616. const selectorText = selectorsText[selectorIndex];
  3617. const selectorInfo = { selector, selectorText, ruleInfo };
  3618. getMatchedElementsSelector(doc, selectorInfo, styles, matchedElementsCache);
  3619. }
  3620. }
  3621. ruleIndex++;
  3622. }
  3623. }
  3624. });
  3625. }
  3626. function invalidSelector(selectorText, workStylesheet) {
  3627. workStylesheet.textContent = selectorText + "{}";
  3628. return workStylesheet.sheet ? !workStylesheet.sheet.cssRules.length : workStylesheet.sheet;
  3629. }
  3630. function getMatchedElementsSelector(doc, selectorInfo, styles, matchedElementsCache) {
  3631. const filteredSelectorText = getFilteredSelector(selectorInfo.selector, selectorInfo.selectorText);
  3632. const selectorText = filteredSelectorText != selectorInfo.selectorText ? filteredSelectorText : selectorInfo.selectorText;
  3633. const cachedMatchedElements = matchedElementsCache.get(selectorText);
  3634. let matchedElements = cachedMatchedElements;
  3635. if (!matchedElements) {
  3636. try {
  3637. matchedElements = doc.querySelectorAll(selectorText);
  3638. if (selectorText != "." + SINGLE_FILE_HIDDEN_CLASS_NAME) {
  3639. matchedElements = Array.from(doc.querySelectorAll(selectorText)).filter(matchedElement =>
  3640. !matchedElement.classList.contains(SINGLE_FILE_HIDDEN_CLASS_NAME) &&
  3641. (matchedElement.style.getPropertyValue(DISPLAY_STYLE) != "none" || matchedElement.style.getPropertyPriority("display") != "important")
  3642. );
  3643. }
  3644. } catch (error) {
  3645. // ignored
  3646. }
  3647. }
  3648. if (matchedElements) {
  3649. if (!cachedMatchedElements) {
  3650. matchedElementsCache.set(selectorText, matchedElements);
  3651. }
  3652. if (matchedElements.length) {
  3653. if (filteredSelectorText == selectorInfo.selectorText) {
  3654. matchedElements.forEach(element => addRule(element, selectorInfo, styles));
  3655. } else {
  3656. let pseudoSelectors = selectorInfo.ruleInfo.mediaInfo.pseudoRules.get(selectorInfo.ruleInfo.ruleData);
  3657. if (!pseudoSelectors) {
  3658. pseudoSelectors = new Set();
  3659. selectorInfo.ruleInfo.mediaInfo.pseudoRules.set(selectorInfo.ruleInfo.ruleData, pseudoSelectors);
  3660. }
  3661. pseudoSelectors.add(selectorInfo.selectorText);
  3662. }
  3663. }
  3664. }
  3665. }
  3666. function getFilteredSelector(selector, selectorText) {
  3667. const removedSelectors = [];
  3668. let namespaceFound;
  3669. selector = { data: db(gb(selector.data), { context: "selector" }) };
  3670. filterNamespace(selector);
  3671. if (namespaceFound) {
  3672. selectorText = gb(selector.data).trim();
  3673. }
  3674. filterPseudoClasses(selector);
  3675. if (removedSelectors.length) {
  3676. removedSelectors.forEach(({ parentSelector, selector }) => {
  3677. if (parentSelector.data.children.size == 0 || !selector.prev || selector.prev.data.type == "Combinator" || selector.prev.data.type == "WhiteSpace") {
  3678. parentSelector.data.children.replace(selector, db("*", { context: "selector" }).children.head);
  3679. } else {
  3680. parentSelector.data.children.remove(selector);
  3681. }
  3682. });
  3683. selectorText = gb(selector.data).trim();
  3684. }
  3685. return selectorText;
  3686. function filterPseudoClasses(selector, parentSelector) {
  3687. if (selector.data.children) {
  3688. for (let childSelector = selector.data.children.head; childSelector; childSelector = childSelector.next) {
  3689. filterPseudoClasses(childSelector, selector);
  3690. }
  3691. }
  3692. if ((selector.data.type == "PseudoClassSelector") ||
  3693. (selector.data.type == "PseudoElementSelector" && (testVendorPseudo(selector) || IGNORED_PSEUDO_ELEMENTS.includes(selector.data.name)))) {
  3694. removedSelectors.push({ parentSelector, selector });
  3695. }
  3696. }
  3697. function filterNamespace(selector) {
  3698. if (selector.data.children) {
  3699. for (let childSelector = selector.data.children.head; childSelector; childSelector = childSelector.next) {
  3700. filterNamespace(childSelector);
  3701. }
  3702. }
  3703. if (selector.data.type == "TypeSelector" && selector.data.name.includes("|")) {
  3704. namespaceFound = true;
  3705. selector.data.name = selector.data.name.substring(selector.data.name.lastIndexOf("|") + 1);
  3706. }
  3707. }
  3708. function testVendorPseudo(selector) {
  3709. const name = selector.data.name;
  3710. return name.startsWith("-") || name.startsWith("\\-");
  3711. }
  3712. }
  3713. function addRule(element, selectorInfo, styles) {
  3714. const mediaInfo = selectorInfo.ruleInfo.mediaInfo;
  3715. const elementStyle = styles.get(element);
  3716. let elementInfo = mediaInfo.elements.get(element);
  3717. if (!elementInfo) {
  3718. elementInfo = [];
  3719. if (elementStyle) {
  3720. elementInfo.push({ styleInfo: { styleData: elementStyle, declarations: new Set() } });
  3721. }
  3722. mediaInfo.elements.set(element, elementInfo);
  3723. }
  3724. const specificity = computeSpecificity(selectorInfo.selector.data);
  3725. specificity.ruleIndex = selectorInfo.ruleInfo.ruleIndex;
  3726. specificity.sheetIndex = selectorInfo.ruleInfo.sheetIndex;
  3727. selectorInfo.specificity = specificity;
  3728. elementInfo.push(selectorInfo);
  3729. }
  3730. function computeCascade(mediaInfo, parentMediaInfo, mediaAllInfo, workStylesheet, workStyleElement) {
  3731. mediaInfo.elements.forEach((elementInfo/*, element*/) =>
  3732. getDeclarationsInfo(elementInfo, workStylesheet, workStyleElement/*, element*/).forEach((declarationsInfo, property) => {
  3733. if (declarationsInfo.selectorInfo.ruleInfo || mediaInfo == mediaAllInfo) {
  3734. let info;
  3735. if (declarationsInfo.selectorInfo.ruleInfo) {
  3736. info = declarationsInfo.selectorInfo.ruleInfo;
  3737. const ruleData = info.ruleData;
  3738. const ascendantMedia = [mediaInfo, ...parentMediaInfo].find(media => media.rules.get(ruleData)) || mediaInfo;
  3739. ascendantMedia.rules.set(ruleData, info);
  3740. if (ruleData) {
  3741. info.matchedSelectors.add(declarationsInfo.selectorInfo.selectorText);
  3742. }
  3743. } else {
  3744. info = declarationsInfo.selectorInfo.styleInfo;
  3745. const styleData = info.styleData;
  3746. const matchedStyleInfo = mediaAllInfo.matchedStyles.get(styleData);
  3747. if (!matchedStyleInfo) {
  3748. mediaAllInfo.matchedStyles.set(styleData, info);
  3749. }
  3750. }
  3751. if (!info.declarations.has(property)) {
  3752. info.declarations.add(property);
  3753. }
  3754. }
  3755. }));
  3756. delete mediaInfo.elements;
  3757. mediaInfo.medias.forEach(childMediaInfo => computeCascade(childMediaInfo, [mediaInfo, ...parentMediaInfo], mediaAllInfo, workStylesheet, workStyleElement));
  3758. }
  3759. function getDeclarationsInfo(elementInfo, workStylesheet, workStyleElement/*, element*/) {
  3760. const declarationsInfo = new Map();
  3761. const processedProperties = new Set();
  3762. elementInfo.forEach(selectorInfo => {
  3763. let declarations;
  3764. if (selectorInfo.styleInfo) {
  3765. declarations = selectorInfo.styleInfo.styleData.children;
  3766. } else {
  3767. declarations = selectorInfo.ruleInfo.ruleData.block.children;
  3768. }
  3769. processDeclarations(declarationsInfo, declarations, selectorInfo, processedProperties, workStylesheet, workStyleElement);
  3770. });
  3771. return declarationsInfo;
  3772. }
  3773. function processDeclarations(declarationsInfo, declarations, selectorInfo, processedProperties, workStylesheet, workStyleElement) {
  3774. for (let declaration = declarations.tail; declaration; declaration = declaration.prev) {
  3775. const declarationData = declaration.data;
  3776. const declarationText = gb(declarationData);
  3777. if (declarationData.type == "Declaration" &&
  3778. (declarationText.match(REGEXP_VENDOR_IDENTIFIER) || !processedProperties.has(declarationData.property) || declarationData.important) && !invalidDeclaration(declarationText, workStyleElement)) {
  3779. const declarationInfo = declarationsInfo.get(declarationData);
  3780. if (!declarationInfo || (declarationData.important && !declarationInfo.important)) {
  3781. declarationsInfo.set(declarationData, { selectorInfo, important: declarationData.important });
  3782. if (!declarationText.match(REGEXP_VENDOR_IDENTIFIER)) {
  3783. processedProperties.add(declarationData.property);
  3784. }
  3785. }
  3786. }
  3787. }
  3788. }
  3789. function invalidDeclaration(declarationText, workStyleElement) {
  3790. let invalidDeclaration;
  3791. workStyleElement.style = declarationText;
  3792. if (!workStyleElement.style.length) {
  3793. if (!declarationText.match(REGEXP_VENDOR_IDENTIFIER)) {
  3794. invalidDeclaration = true;
  3795. }
  3796. }
  3797. return invalidDeclaration;
  3798. }
  3799. function sortRules(media) {
  3800. media.elements.forEach(elementRules => elementRules.sort((ruleInfo1, ruleInfo2) =>
  3801. ruleInfo1.styleInfo && !ruleInfo2.styleInfo ? -1 :
  3802. !ruleInfo1.styleInfo && ruleInfo2.styleInfo ? 1 :
  3803. compareSpecificity(ruleInfo1.specificity, ruleInfo2.specificity)));
  3804. media.medias.forEach(sortRules);
  3805. }
  3806. function computeSpecificity(selector, specificity = { a: 0, b: 0, c: 0 }) {
  3807. if (selector.type == "IdSelector") {
  3808. specificity.a++;
  3809. }
  3810. if (selector.type == "ClassSelector" || selector.type == "AttributeSelector" || (selector.type == "PseudoClassSelector" && selector.name != "not")) {
  3811. specificity.b++;
  3812. }
  3813. if ((selector.type == "TypeSelector" && selector.name != "*") || selector.type == "PseudoElementSelector") {
  3814. specificity.c++;
  3815. }
  3816. if (selector.children) {
  3817. selector.children.forEach(selector => computeSpecificity(selector, specificity));
  3818. }
  3819. return specificity;
  3820. }
  3821. function compareSpecificity(specificity1, specificity2) {
  3822. if (specificity1.a > specificity2.a) {
  3823. return -1;
  3824. } else if (specificity1.a < specificity2.a) {
  3825. return 1;
  3826. } else if (specificity1.b > specificity2.b) {
  3827. return -1;
  3828. } else if (specificity1.b < specificity2.b) {
  3829. return 1;
  3830. } else if (specificity1.c > specificity2.c) {
  3831. return -1;
  3832. } else if (specificity1.c < specificity2.c) {
  3833. return 1;
  3834. } else if (specificity1.sheetIndex > specificity2.sheetIndex) {
  3835. return -1;
  3836. } else if (specificity1.sheetIndex < specificity2.sheetIndex) {
  3837. return 1;
  3838. } else if (specificity1.ruleIndex > specificity2.ruleIndex) {
  3839. return -1;
  3840. } else if (specificity1.ruleIndex < specificity2.ruleIndex) {
  3841. return 1;
  3842. } else {
  3843. return -1;
  3844. }
  3845. }
  3846. /*
  3847. * Copyright 2010-2022 Gildas Lormeau
  3848. * contact : gildas.lormeau <at> gmail.com
  3849. *
  3850. * This file is part of SingleFile.
  3851. *
  3852. * The code in this file is free software: you can redistribute it and/or
  3853. * modify it under the terms of the GNU Affero General Public License
  3854. * (GNU AGPL) as published by the Free Software Foundation, either version 3
  3855. * of the License, or (at your option) any later version.
  3856. *
  3857. * The code in this file is distributed in the hope that it will be useful,
  3858. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  3859. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
  3860. * General Public License for more details.
  3861. *
  3862. * As additional permission under GNU AGPL version 3 section 7, you may
  3863. * distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU
  3864. * AGPL normally required by section 4, provided you include this license
  3865. * notice and a URL through which recipients can access the Corresponding
  3866. * Source.
  3867. */
  3868. const helper$1 = {
  3869. flatten
  3870. };
  3871. const MEDIA_ALL = "all";
  3872. const MEDIA_SCREEN = "screen";
  3873. function process$3(stylesheets) {
  3874. const stats = { processed: 0, discarded: 0 };
  3875. stylesheets.forEach((stylesheetInfo, element) => {
  3876. if (matchesMediaType(stylesheetInfo.mediaText || MEDIA_ALL, MEDIA_SCREEN) && stylesheetInfo.stylesheet.children) {
  3877. const removedRules = processRules$1(stylesheetInfo.stylesheet.children, stats);
  3878. removedRules.forEach(({ cssRules, cssRule }) => cssRules.remove(cssRule));
  3879. } else {
  3880. stylesheets.delete(element);
  3881. }
  3882. });
  3883. return stats;
  3884. }
  3885. function processRules$1(cssRules, stats, removedRules = []) {
  3886. for (let cssRule = cssRules.head; cssRule; cssRule = cssRule.next) {
  3887. const ruleData = cssRule.data;
  3888. if (ruleData.type == "Atrule" && ruleData.name == "media" && ruleData.block && ruleData.block.children && ruleData.prelude && ruleData.prelude.children) {
  3889. stats.processed++;
  3890. if (matchesMediaType(gb(ruleData.prelude), MEDIA_SCREEN)) {
  3891. processRules$1(ruleData.block.children, stats, removedRules);
  3892. } else {
  3893. removedRules.push({ cssRules, cssRule });
  3894. stats.discarded++;
  3895. }
  3896. }
  3897. }
  3898. return removedRules;
  3899. }
  3900. function matchesMediaType(mediaText, mediaType) {
  3901. const foundMediaTypes = helper$1.flatten(parseMediaList(mediaText).map(node => getMediaTypes(node, mediaType)));
  3902. return foundMediaTypes.find(mediaTypeInfo => (!mediaTypeInfo.not && (mediaTypeInfo.value == mediaType || mediaTypeInfo.value == MEDIA_ALL))
  3903. || (mediaTypeInfo.not && (mediaTypeInfo.value == MEDIA_ALL || mediaTypeInfo.value != mediaType)));
  3904. }
  3905. function getMediaTypes(parentNode, mediaType, mediaTypes = []) {
  3906. parentNode.nodes.map((node, indexNode) => {
  3907. if (node.type == "media-query") {
  3908. return getMediaTypes(node, mediaType, mediaTypes);
  3909. } else {
  3910. if (node.type == "media-type") {
  3911. const nodeMediaType = { not: Boolean(indexNode && parentNode.nodes[0].type == "keyword" && parentNode.nodes[0].value == "not"), value: node.value };
  3912. if (!mediaTypes.find(mediaType => nodeMediaType.not == mediaType.not && nodeMediaType.value == mediaType.value)) {
  3913. mediaTypes.push(nodeMediaType);
  3914. }
  3915. }
  3916. }
  3917. });
  3918. if (!mediaTypes.length) {
  3919. mediaTypes.push({ not: false, value: MEDIA_ALL });
  3920. }
  3921. return mediaTypes;
  3922. }
  3923. /*
  3924. * Copyright 2010-2022 Gildas Lormeau
  3925. * contact : gildas.lormeau <at> gmail.com
  3926. *
  3927. * This file is part of SingleFile.
  3928. *
  3929. * The code in this file is free software: you can redistribute it and/or
  3930. * modify it under the terms of the GNU Affero General Public License
  3931. * (GNU AGPL) as published by the Free Software Foundation, either version 3
  3932. * of the License, or (at your option) any later version.
  3933. *
  3934. * The code in this file is distributed in the hope that it will be useful,
  3935. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  3936. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
  3937. * General Public License for more details.
  3938. *
  3939. * As additional permission under GNU AGPL version 3 section 7, you may
  3940. * distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU
  3941. * AGPL normally required by section 4, provided you include this license
  3942. * notice and a URL through which recipients can access the Corresponding
  3943. * Source.
  3944. */
  3945. function process$2(stylesheets, styles, mediaAllInfo) {
  3946. const stats = { processed: 0, discarded: 0 };
  3947. let sheetIndex = 0;
  3948. stylesheets.forEach(stylesheetInfo => {
  3949. if (!stylesheetInfo.scoped) {
  3950. const cssRules = stylesheetInfo.stylesheet.children;
  3951. if (cssRules) {
  3952. stats.processed += cssRules.size;
  3953. stats.discarded += cssRules.size;
  3954. let mediaInfo;
  3955. if (stylesheetInfo.mediaText && stylesheetInfo.mediaText != "all") {
  3956. mediaInfo = mediaAllInfo.medias.get("style-" + sheetIndex + "-" + stylesheetInfo.mediaText);
  3957. } else {
  3958. mediaInfo = mediaAllInfo;
  3959. }
  3960. processRules(cssRules, sheetIndex, mediaInfo);
  3961. stats.discarded -= cssRules.size;
  3962. }
  3963. }
  3964. sheetIndex++;
  3965. });
  3966. styles.forEach(style => processStyleAttribute(style, mediaAllInfo));
  3967. return stats;
  3968. }
  3969. function processRules(cssRules, sheetIndex, mediaInfo) {
  3970. let mediaRuleIndex = 0;
  3971. const removedCssRules = [];
  3972. for (let cssRule = cssRules.head; cssRule; cssRule = cssRule.next) {
  3973. const ruleData = cssRule.data;
  3974. if (ruleData.block && ruleData.block.children && ruleData.prelude && ruleData.prelude.children) {
  3975. if (ruleData.type == "Atrule" && ruleData.name == "media") {
  3976. const mediaText = gb(ruleData.prelude);
  3977. processRules(ruleData.block.children, sheetIndex, mediaInfo.medias.get("rule-" + sheetIndex + "-" + mediaRuleIndex + "-" + mediaText));
  3978. if (!ruleData.prelude.children.size || !ruleData.block.children.size) {
  3979. removedCssRules.push(cssRule);
  3980. }
  3981. mediaRuleIndex++;
  3982. } else if (ruleData.type == "Rule") {
  3983. const ruleInfo = mediaInfo.rules.get(ruleData);
  3984. const pseudoSelectors = mediaInfo.pseudoRules.get(ruleData);
  3985. if (!ruleInfo && !pseudoSelectors) {
  3986. removedCssRules.push(cssRule);
  3987. } else if (ruleInfo) {
  3988. processRuleInfo(ruleData, ruleInfo, pseudoSelectors);
  3989. if (!ruleData.prelude.children.size || !ruleData.block.children.size) {
  3990. removedCssRules.push(cssRule);
  3991. }
  3992. }
  3993. }
  3994. } else {
  3995. if (!ruleData || ruleData.type == "Raw" || (ruleData.type == "Rule" && (!ruleData.prelude || ruleData.prelude.type == "Raw"))) {
  3996. removedCssRules.push(cssRule);
  3997. }
  3998. }
  3999. }
  4000. removedCssRules.forEach(cssRule => cssRules.remove(cssRule));
  4001. }
  4002. function processRuleInfo(ruleData, ruleInfo, pseudoSelectors) {
  4003. const removedDeclarations = [];
  4004. const removedSelectors = [];
  4005. let pseudoSelectorFound;
  4006. for (let selector = ruleData.prelude.children.head; selector; selector = selector.next) {
  4007. const selectorText = gb(selector.data);
  4008. if (pseudoSelectors && pseudoSelectors.has(selectorText)) {
  4009. pseudoSelectorFound = true;
  4010. }
  4011. if (!ruleInfo.matchedSelectors.has(selectorText) && (!pseudoSelectors || !pseudoSelectors.has(selectorText))) {
  4012. removedSelectors.push(selector);
  4013. }
  4014. }
  4015. if (!pseudoSelectorFound) {
  4016. for (let declaration = ruleData.block.children.tail; declaration; declaration = declaration.prev) {
  4017. if (!ruleInfo.declarations.has(declaration.data)) {
  4018. removedDeclarations.push(declaration);
  4019. }
  4020. }
  4021. }
  4022. removedDeclarations.forEach(declaration => ruleData.block.children.remove(declaration));
  4023. removedSelectors.forEach(selector => ruleData.prelude.children.remove(selector));
  4024. }
  4025. function processStyleAttribute(styleData, mediaAllInfo) {
  4026. const removedDeclarations = [];
  4027. const styleInfo = mediaAllInfo.matchedStyles.get(styleData);
  4028. if (styleInfo) {
  4029. let propertyFound;
  4030. for (let declaration = styleData.children.head; declaration && !propertyFound; declaration = declaration.next) {
  4031. if (!styleInfo.declarations.has(declaration.data)) {
  4032. removedDeclarations.push(declaration);
  4033. }
  4034. }
  4035. removedDeclarations.forEach(declaration => styleData.children.remove(declaration));
  4036. }
  4037. }
  4038. /*
  4039. * Copyright 2010-2022 Gildas Lormeau
  4040. * contact : gildas.lormeau <at> gmail.com
  4041. *
  4042. * This file is part of SingleFile.
  4043. *
  4044. * The code in this file is free software: you can redistribute it and/or
  4045. * modify it under the terms of the GNU Affero General Public License
  4046. * (GNU AGPL) as published by the Free Software Foundation, either version 3
  4047. * of the License, or (at your option) any later version.
  4048. *
  4049. * The code in this file is distributed in the hope that it will be useful,
  4050. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  4051. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
  4052. * General Public License for more details.
  4053. *
  4054. * As additional permission under GNU AGPL version 3 section 7, you may
  4055. * distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU
  4056. * AGPL normally required by section 4, provided you include this license
  4057. * notice and a URL through which recipients can access the Corresponding
  4058. * Source.
  4059. */
  4060. const EMPTY_RESOURCE = "data:,";
  4061. function process$1(doc) {
  4062. doc.querySelectorAll("picture").forEach(pictureElement => {
  4063. const imgElement = pictureElement.querySelector("img");
  4064. if (imgElement) {
  4065. let { src, srcset } = getImgSrcData(imgElement);
  4066. if (!src) {
  4067. const data = getSourceSrcData(Array.from(pictureElement.querySelectorAll("source")).reverse());
  4068. src = data.src;
  4069. if (!srcset) {
  4070. srcset = data.srcset;
  4071. }
  4072. }
  4073. setSrc({ src, srcset }, imgElement, pictureElement);
  4074. }
  4075. });
  4076. doc.querySelectorAll(":not(picture) > img[srcset]").forEach(imgElement => setSrc(getImgSrcData(imgElement), imgElement));
  4077. }
  4078. function getImgSrcData(imgElement) {
  4079. let src = imgElement.getAttribute("src");
  4080. if (src == EMPTY_RESOURCE) {
  4081. src = null;
  4082. }
  4083. let srcset = getSourceSrc(imgElement.getAttribute("srcset"));
  4084. if (srcset == EMPTY_RESOURCE) {
  4085. srcset = null;
  4086. }
  4087. return { src, srcset };
  4088. }
  4089. function getSourceSrcData(sources) {
  4090. let source = sources.find(source => source.src);
  4091. let src = source && source.src;
  4092. let srcset = source && source.srcset;
  4093. if (!src) {
  4094. source = sources.find(source => getSourceSrc(source.src));
  4095. src = source && source.src;
  4096. if (src == EMPTY_RESOURCE) {
  4097. src = null;
  4098. }
  4099. }
  4100. if (!srcset) {
  4101. source = sources.find(source => getSourceSrc(source.srcset));
  4102. srcset = source && source.srcset;
  4103. if (srcset == EMPTY_RESOURCE) {
  4104. srcset = null;
  4105. }
  4106. }
  4107. return { src, srcset };
  4108. }
  4109. function setSrc(srcData, imgElement, pictureElement) {
  4110. if (srcData.src) {
  4111. imgElement.setAttribute("src", srcData.src);
  4112. imgElement.setAttribute("srcset", "");
  4113. imgElement.setAttribute("sizes", "");
  4114. } else {
  4115. imgElement.setAttribute("src", EMPTY_RESOURCE);
  4116. if (srcData.srcset) {
  4117. imgElement.setAttribute("srcset", srcData.srcset);
  4118. } else {
  4119. imgElement.setAttribute("srcset", "");
  4120. imgElement.setAttribute("sizes", "");
  4121. }
  4122. }
  4123. if (pictureElement) {
  4124. pictureElement.querySelectorAll("source").forEach(sourceElement => sourceElement.remove());
  4125. }
  4126. }
  4127. function getSourceSrc(sourceSrcSet) {
  4128. if (sourceSrcSet) {
  4129. try {
  4130. const srcset = process$5(sourceSrcSet);
  4131. if (srcset.length) {
  4132. return (srcset.find(srcset => srcset.url)).url;
  4133. }
  4134. } catch (error) {
  4135. // ignored
  4136. }
  4137. }
  4138. }
  4139. /*
  4140. * Copyright 2010-2022 Gildas Lormeau
  4141. * contact : gildas.lormeau <at> gmail.com
  4142. *
  4143. * This file is part of SingleFile.
  4144. *
  4145. * The code in this file is free software: you can redistribute it and/or
  4146. * modify it under the terms of the GNU Affero General Public License
  4147. * (GNU AGPL) as published by the Free Software Foundation, either version 3
  4148. * of the License, or (at your option) any later version.
  4149. *
  4150. * The code in this file is distributed in the hope that it will be useful,
  4151. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  4152. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
  4153. * General Public License for more details.
  4154. *
  4155. * As additional permission under GNU AGPL version 3 section 7, you may
  4156. * distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU
  4157. * AGPL normally required by section 4, provided you include this license
  4158. * notice and a URL through which recipients can access the Corresponding
  4159. * Source.
  4160. */
  4161. // Derived from the work of Kirill Maltsev - https://github.com/posthtml/htmlnano
  4162. // Source: https://github.com/kangax/html-minifier/issues/63
  4163. const booleanAttributes = [
  4164. "allowfullscreen",
  4165. "async",
  4166. "autofocus",
  4167. "autoplay",
  4168. "checked",
  4169. "compact",
  4170. "controls",
  4171. "declare",
  4172. "default",
  4173. "defaultchecked",
  4174. "defaultmuted",
  4175. "defaultselected",
  4176. "defer",
  4177. "disabled",
  4178. "enabled",
  4179. "formnovalidate",
  4180. "hidden",
  4181. "indeterminate",
  4182. "inert",
  4183. "ismap",
  4184. "itemscope",
  4185. "loop",
  4186. "multiple",
  4187. "muted",
  4188. "nohref",
  4189. "noresize",
  4190. "noshade",
  4191. "novalidate",
  4192. "nowrap",
  4193. "open",
  4194. "pauseonexit",
  4195. "readonly",
  4196. "required",
  4197. "reversed",
  4198. "scoped",
  4199. "seamless",
  4200. "selected",
  4201. "sortable",
  4202. "truespeed",
  4203. "typemustmatch",
  4204. "visible"
  4205. ];
  4206. const noWhitespaceCollapseElements = ["SCRIPT", "STYLE", "PRE", "TEXTAREA"];
  4207. // Source: https://www.w3.org/TR/html4/sgml/dtd.html#events (Generic Attributes)
  4208. const safeToRemoveAttrs = [
  4209. "id",
  4210. "class",
  4211. "style",
  4212. "lang",
  4213. "dir",
  4214. "onclick",
  4215. "ondblclick",
  4216. "onmousedown",
  4217. "onmouseup",
  4218. "onmouseover",
  4219. "onmousemove",
  4220. "onmouseout",
  4221. "onkeypress",
  4222. "onkeydown",
  4223. "onkeyup"
  4224. ];
  4225. const redundantAttributes = {
  4226. "FORM": {
  4227. "method": "get"
  4228. },
  4229. "SCRIPT": {
  4230. "language": "javascript",
  4231. "type": "text/javascript",
  4232. // Remove attribute if the function returns false
  4233. "charset": node => {
  4234. // The charset attribute only really makes sense on “external” SCRIPT elements:
  4235. // http://perfectionkills.com/optimizing-html/#8_script_charset
  4236. return !node.getAttribute("src");
  4237. }
  4238. },
  4239. "STYLE": {
  4240. "media": "all",
  4241. "type": "text/css"
  4242. },
  4243. "LINK": {
  4244. "media": "all"
  4245. }
  4246. };
  4247. const REGEXP_WHITESPACE = /[ \t\f\r]+/g;
  4248. const REGEXP_NEWLINE = /[\n]+/g;
  4249. const REGEXP_ENDS_WHITESPACE = /^\s+$/;
  4250. const NodeFilter_SHOW_ALL = 4294967295;
  4251. const Node_ELEMENT_NODE = 1;
  4252. const Node_TEXT_NODE = 3;
  4253. const Node_COMMENT_NODE = 8;
  4254. const modules = [
  4255. collapseBooleanAttributes,
  4256. mergeTextNodes,
  4257. collapseWhitespace,
  4258. removeComments,
  4259. removeEmptyAttributes,
  4260. removeRedundantAttributes,
  4261. compressJSONLD,
  4262. node => mergeElements(node, "style", (node, previousSibling) => node.parentElement && getTagName(node.parentElement) == "HEAD" && node.media == previousSibling.media && node.title == previousSibling.title)
  4263. ];
  4264. function process(doc, options) {
  4265. removeEmptyInlineElements(doc);
  4266. const nodesWalker = doc.createTreeWalker(doc.documentElement, NodeFilter_SHOW_ALL, null, false);
  4267. let node = nodesWalker.nextNode();
  4268. while (node) {
  4269. const deletedNode = modules.find(module => module(node, options));
  4270. const previousNode = node;
  4271. node = nodesWalker.nextNode();
  4272. if (deletedNode) {
  4273. previousNode.remove();
  4274. }
  4275. }
  4276. }
  4277. function collapseBooleanAttributes(node) {
  4278. if (node.nodeType == Node_ELEMENT_NODE) {
  4279. Array.from(node.attributes).forEach(attribute => {
  4280. if (booleanAttributes.includes(attribute.name)) {
  4281. node.setAttribute(attribute.name, "");
  4282. }
  4283. });
  4284. }
  4285. }
  4286. function mergeTextNodes(node) {
  4287. if (node.nodeType == Node_TEXT_NODE) {
  4288. if (node.previousSibling && node.previousSibling.nodeType == Node_TEXT_NODE) {
  4289. node.textContent = node.previousSibling.textContent + node.textContent;
  4290. node.previousSibling.remove();
  4291. }
  4292. }
  4293. }
  4294. function mergeElements(node, tagName, acceptMerge) {
  4295. if (node.nodeType == Node_ELEMENT_NODE && getTagName(node) == tagName.toUpperCase()) {
  4296. let previousSibling = node.previousSibling;
  4297. const previousSiblings = [];
  4298. while (previousSibling && previousSibling.nodeType == Node_TEXT_NODE && !previousSibling.textContent.trim()) {
  4299. previousSiblings.push(previousSibling);
  4300. previousSibling = previousSibling.previousSibling;
  4301. }
  4302. if (previousSibling && previousSibling.nodeType == Node_ELEMENT_NODE && previousSibling.tagName == node.tagName && acceptMerge(node, previousSibling)) {
  4303. node.textContent = previousSibling.textContent + node.textContent;
  4304. previousSiblings.forEach(node => node.remove());
  4305. previousSibling.remove();
  4306. }
  4307. }
  4308. }
  4309. function collapseWhitespace(node, options) {
  4310. if (node.nodeType == Node_TEXT_NODE) {
  4311. let element = node.parentElement;
  4312. const spacePreserved = element.getAttribute(options.PRESERVED_SPACE_ELEMENT_ATTRIBUTE_NAME) == "";
  4313. if (!spacePreserved) {
  4314. const textContent = node.textContent;
  4315. let noWhitespace = noWhitespaceCollapse(element);
  4316. while (noWhitespace) {
  4317. element = element.parentElement;
  4318. noWhitespace = element && noWhitespaceCollapse(element);
  4319. }
  4320. if ((!element || noWhitespace) && textContent.length > 1) {
  4321. node.textContent = textContent.replace(REGEXP_WHITESPACE, getWhiteSpace(node)).replace(REGEXP_NEWLINE, "\n");
  4322. }
  4323. }
  4324. }
  4325. }
  4326. function getWhiteSpace(node) {
  4327. return node.parentElement && getTagName(node.parentElement) == "HEAD" ? "\n" : " ";
  4328. }
  4329. function noWhitespaceCollapse(element) {
  4330. return element && !noWhitespaceCollapseElements.includes(getTagName(element));
  4331. }
  4332. function removeComments(node) {
  4333. if (node.nodeType == Node_COMMENT_NODE && getTagName(node.parentElement) != "HTML") {
  4334. return !node.textContent.toLowerCase().trim().startsWith("[if");
  4335. }
  4336. }
  4337. function removeEmptyAttributes(node) {
  4338. if (node.nodeType == Node_ELEMENT_NODE) {
  4339. Array.from(node.attributes).forEach(attribute => {
  4340. if (safeToRemoveAttrs.includes(attribute.name.toLowerCase())) {
  4341. const attributeValue = node.getAttribute(attribute.name);
  4342. if (attributeValue == "" || (attributeValue || "").match(REGEXP_ENDS_WHITESPACE)) {
  4343. node.removeAttribute(attribute.name);
  4344. }
  4345. }
  4346. });
  4347. }
  4348. }
  4349. function removeRedundantAttributes(node) {
  4350. if (node.nodeType == Node_ELEMENT_NODE) {
  4351. const tagRedundantAttributes = redundantAttributes[getTagName(node)];
  4352. if (tagRedundantAttributes) {
  4353. Object.keys(tagRedundantAttributes).forEach(redundantAttributeName => {
  4354. const tagRedundantAttributeValue = tagRedundantAttributes[redundantAttributeName];
  4355. if (typeof tagRedundantAttributeValue == "function" ? tagRedundantAttributeValue(node) : node.getAttribute(redundantAttributeName) == tagRedundantAttributeValue) {
  4356. node.removeAttribute(redundantAttributeName);
  4357. }
  4358. });
  4359. }
  4360. }
  4361. }
  4362. function compressJSONLD(node) {
  4363. if (node.nodeType == Node_ELEMENT_NODE && getTagName(node) == "SCRIPT" && node.type == "application/ld+json" && node.textContent.trim()) {
  4364. try {
  4365. node.textContent = JSON.stringify(JSON.parse(node.textContent));
  4366. } catch (error) {
  4367. // ignored
  4368. }
  4369. }
  4370. }
  4371. function removeEmptyInlineElements(doc) {
  4372. doc.querySelectorAll("style, script:not([src])").forEach(element => {
  4373. if (!element.textContent.trim()) {
  4374. element.remove();
  4375. }
  4376. });
  4377. }
  4378. function getTagName(element) {
  4379. return element.tagName && element.tagName.toUpperCase();
  4380. }
  4381. /*
  4382. * Copyright 2010-2022 Gildas Lormeau
  4383. * contact : gildas.lormeau <at> gmail.com
  4384. *
  4385. * This file is part of SingleFile.
  4386. *
  4387. * The code in this file is free software: you can redistribute it and/or
  4388. * modify it under the terms of the GNU Affero General Public License
  4389. * (GNU AGPL) as published by the Free Software Foundation, either version 3
  4390. * of the License, or (at your option) any later version.
  4391. *
  4392. * The code in this file is distributed in the hope that it will be useful,
  4393. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  4394. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
  4395. * General Public License for more details.
  4396. *
  4397. * As additional permission under GNU AGPL version 3 section 7, you may
  4398. * distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU
  4399. * AGPL normally required by section 4, provided you include this license
  4400. * notice and a URL through which recipients can access the Corresponding
  4401. * Source.
  4402. */
  4403. /* global Blob, FileReader, URL, URLSearchParams */
  4404. // eslint-disable-next-line quotes
  4405. const DEFAULT_REPLACED_CHARACTERS$1 = ["~", "+", "\\\\", "?", "%", "*", ":", "|", '"', "<", ">", "\x00-\x1f", "\x7F"];
  4406. const DEFAULT_REPLACEMENT_CHARACTER$1 = "_";
  4407. const EMOJI_NAMES = {
  4408. "😀": "grinning-face",
  4409. "😃": "grinning-face-with-big-eyes",
  4410. "😄": "grinning-face-with-smiling-eyes",
  4411. "😁": "beaming-face-with-smiling-eyes",
  4412. "😆": "grinning-squinting-face",
  4413. "😅": "grinning-face-with-sweat",
  4414. "🤣": "rolling-on-the-floor-laughing",
  4415. "😂": "face-with-tears-of-joy",
  4416. "🙂": "slightly-smiling-face",
  4417. "🙃": "upside-down-face",
  4418. "🫠": "melting-face",
  4419. "😉": "winking-face",
  4420. "😊": "smiling-face-with-smiling-eyes",
  4421. "😇": "smiling-face-with-halo",
  4422. "🥰": "smiling-face-with-hearts",
  4423. "😍": "smiling-face-with-heart-eyes",
  4424. "🤩": "star-struck",
  4425. "😘": "face-blowing-a-kiss",
  4426. "😗": "kissing-face",
  4427. "☺": "smiling-face",
  4428. "😚": "kissing-face-with-closed-eyes",
  4429. "😙": "kissing-face-with-smiling-eyes",
  4430. "🥲": "smiling-face-with-tear",
  4431. "😋": "face-savoring-food",
  4432. "😛": "face-with-tongue",
  4433. "😜": "winking-face-with-tongue",
  4434. "🤪": "zany-face",
  4435. "😝": "squinting-face-with-tongue",
  4436. "🤑": "money-mouth-face",
  4437. "🤗": "smiling-face-with-open-hands",
  4438. "🤭": "face-with-hand-over-mouth",
  4439. "🫢": "face-with-open-eyes-and-hand-over-mouth",
  4440. "🫣": "face-with-peeking-eye",
  4441. "🤫": "shushing-face",
  4442. "🤔": "thinking-face",
  4443. "🫡": "saluting-face",
  4444. "🤐": "zipper-mouth-face",
  4445. "🤨": "face-with-raised-eyebrow",
  4446. "😐": "neutral-face",
  4447. "😑": "expressionless-face",
  4448. "😶": "face-without-mouth",
  4449. "🫥": "dotted-line-face",
  4450. "😶‍🌫️": "face-in-clouds",
  4451. "😏": "smirking-face",
  4452. "😒": "unamused-face",
  4453. "🙄": "face-with-rolling-eyes",
  4454. "😬": "grimacing-face",
  4455. "😮‍💨": "face-exhaling",
  4456. "🤥": "lying-face",
  4457. "🫨": "⊛-shaking-face",
  4458. "😌": "relieved-face",
  4459. "😔": "pensive-face",
  4460. "😪": "sleepy-face",
  4461. "🤤": "drooling-face",
  4462. "😴": "sleeping-face",
  4463. "😷": "face-with-medical-mask",
  4464. "🤒": "face-with-thermometer",
  4465. "🤕": "face-with-head-bandage",
  4466. "🤢": "nauseated-face",
  4467. "🤮": "face-vomiting",
  4468. "🤧": "sneezing-face",
  4469. "🥵": "hot-face",
  4470. "🥶": "cold-face",
  4471. "🥴": "woozy-face",
  4472. "😵": "face-with-crossed-out-eyes",
  4473. "😵‍💫": "face-with-spiral-eyes",
  4474. "🤯": "exploding-head",
  4475. "🤠": "cowboy-hat-face",
  4476. "🥳": "partying-face",
  4477. "🥸": "disguised-face",
  4478. "😎": "smiling-face-with-sunglasses",
  4479. "🤓": "nerd-face",
  4480. "🧐": "face-with-monocle",
  4481. "😕": "confused-face",
  4482. "🫤": "face-with-diagonal-mouth",
  4483. "😟": "worried-face",
  4484. "🙁": "slightly-frowning-face",
  4485. "☹": "frowning-face",
  4486. "😮": "face-with-open-mouth",
  4487. "😯": "hushed-face",
  4488. "😲": "astonished-face",
  4489. "😳": "flushed-face",
  4490. "🥺": "pleading-face",
  4491. "🥹": "face-holding-back-tears",
  4492. "😦": "frowning-face-with-open-mouth",
  4493. "😧": "anguished-face",
  4494. "😨": "fearful-face",
  4495. "😰": "anxious-face-with-sweat",
  4496. "😥": "sad-but-relieved-face",
  4497. "😢": "crying-face",
  4498. "😭": "loudly-crying-face",
  4499. "😱": "face-screaming-in-fear",
  4500. "😖": "confounded-face",
  4501. "😣": "persevering-face",
  4502. "😞": "disappointed-face",
  4503. "😓": "downcast-face-with-sweat",
  4504. "😩": "weary-face",
  4505. "😫": "tired-face",
  4506. "🥱": "yawning-face",
  4507. "😤": "face-with-steam-from-nose",
  4508. "😡": "enraged-face",
  4509. "😠": "angry-face",
  4510. "🤬": "face-with-symbols-on-mouth",
  4511. "😈": "smiling-face-with-horns",
  4512. "👿": "angry-face-with-horns",
  4513. "💀": "skull",
  4514. "☠": "skull-and-crossbones",
  4515. "💩": "pile-of-poo",
  4516. "🤡": "clown-face",
  4517. "👹": "ogre",
  4518. "👺": "goblin",
  4519. "👻": "ghost",
  4520. "👽": "alien",
  4521. "👾": "alien-monster",
  4522. "🤖": "robot",
  4523. "😺": "grinning-cat",
  4524. "😸": "grinning-cat-with-smiling-eyes",
  4525. "😹": "cat-with-tears-of-joy",
  4526. "😻": "smiling-cat-with-heart-eyes",
  4527. "😼": "cat-with-wry-smile",
  4528. "😽": "kissing-cat",
  4529. "🙀": "weary-cat",
  4530. "😿": "crying-cat",
  4531. "😾": "pouting-cat",
  4532. "🙈": "see-no-evil-monkey",
  4533. "🙉": "hear-no-evil-monkey",
  4534. "🙊": "speak-no-evil-monkey",
  4535. "💌": "love-letter",
  4536. "💘": "heart-with-arrow",
  4537. "💝": "heart-with-ribbon",
  4538. "💖": "sparkling-heart",
  4539. "💗": "growing-heart",
  4540. "💓": "beating-heart",
  4541. "💞": "revolving-hearts",
  4542. "💕": "two-hearts",
  4543. "💟": "heart-decoration",
  4544. "❣": "heart-exclamation",
  4545. "💔": "broken-heart",
  4546. "❤️‍🔥": "heart-on-fire",
  4547. "❤️‍🩹": "mending-heart",
  4548. "❤": "red-heart",
  4549. "🩷": "⊛-pink-heart",
  4550. "🧡": "orange-heart",
  4551. "💛": "yellow-heart",
  4552. "💚": "green-heart",
  4553. "💙": "blue-heart",
  4554. "🩵": "⊛-light-blue-heart",
  4555. "💜": "purple-heart",
  4556. "🤎": "brown-heart",
  4557. "🖤": "black-heart",
  4558. "🩶": "⊛-grey-heart",
  4559. "🤍": "white-heart",
  4560. "💋": "kiss-mark",
  4561. "💯": "hundred-points",
  4562. "💢": "anger-symbol",
  4563. "💥": "collision",
  4564. "💫": "dizzy",
  4565. "💦": "sweat-droplets",
  4566. "💨": "dashing-away",
  4567. "🕳": "hole",
  4568. "💬": "speech-balloon",
  4569. "👁️‍🗨️": "eye-in-speech-bubble",
  4570. "🗨": "left-speech-bubble",
  4571. "🗯": "right-anger-bubble",
  4572. "💭": "thought-balloon",
  4573. "💤": "zzz",
  4574. "👋": "waving-hand",
  4575. "🤚": "raised-back-of-hand",
  4576. "🖐": "hand-with-fingers-splayed",
  4577. "✋": "raised-hand",
  4578. "🖖": "vulcan-salute",
  4579. "🫱": "rightwards-hand",
  4580. "🫲": "leftwards-hand",
  4581. "🫳": "palm-down-hand",
  4582. "🫴": "palm-up-hand",
  4583. "🫷": "⊛-leftwards-pushing-hand",
  4584. "🫸": "⊛-rightwards-pushing-hand",
  4585. "👌": "ok-hand",
  4586. "🤌": "pinched-fingers",
  4587. "🤏": "pinching-hand",
  4588. "✌": "victory-hand",
  4589. "🤞": "crossed-fingers",
  4590. "🫰": "hand-with-index-finger-and-thumb-crossed",
  4591. "🤟": "love-you-gesture",
  4592. "🤘": "sign-of-the-horns",
  4593. "🤙": "call-me-hand",
  4594. "👈": "backhand-index-pointing-left",
  4595. "👉": "backhand-index-pointing-right",
  4596. "👆": "backhand-index-pointing-up",
  4597. "🖕": "middle-finger",
  4598. "👇": "backhand-index-pointing-down",
  4599. "☝": "index-pointing-up",
  4600. "🫵": "index-pointing-at-the-viewer",
  4601. "👍": "thumbs-up",
  4602. "👎": "thumbs-down",
  4603. "✊": "raised-fist",
  4604. "👊": "oncoming-fist",
  4605. "🤛": "left-facing-fist",
  4606. "🤜": "right-facing-fist",
  4607. "👏": "clapping-hands",
  4608. "🙌": "raising-hands",
  4609. "🫶": "heart-hands",
  4610. "👐": "open-hands",
  4611. "🤲": "palms-up-together",
  4612. "🤝": "handshake",
  4613. "🙏": "folded-hands",
  4614. "✍": "writing-hand",
  4615. "💅": "nail-polish",
  4616. "🤳": "selfie",
  4617. "💪": "flexed-biceps",
  4618. "🦾": "mechanical-arm",
  4619. "🦿": "mechanical-leg",
  4620. "🦵": "leg",
  4621. "🦶": "foot",
  4622. "👂": "ear",
  4623. "🦻": "ear-with-hearing-aid",
  4624. "👃": "nose",
  4625. "🧠": "brain",
  4626. "🫀": "anatomical-heart",
  4627. "🫁": "lungs",
  4628. "🦷": "tooth",
  4629. "🦴": "bone",
  4630. "👀": "eyes",
  4631. "👁": "eye",
  4632. "👅": "tongue",
  4633. "👄": "mouth",
  4634. "🫦": "biting-lip",
  4635. "👶": "baby",
  4636. "🧒": "child",
  4637. "👦": "boy",
  4638. "👧": "girl",
  4639. "🧑": "person",
  4640. "👱": "person-blond-hair",
  4641. "👨": "man",
  4642. "🧔": "person-beard",
  4643. "🧔‍♂️": "man-beard",
  4644. "🧔‍♀️": "woman-beard",
  4645. "👨‍🦰": "man-red-hair",
  4646. "👨‍🦱": "man-curly-hair",
  4647. "👨‍🦳": "man-white-hair",
  4648. "👨‍🦲": "man-bald",
  4649. "👩": "woman",
  4650. "👩‍🦰": "woman-red-hair",
  4651. "🧑‍🦰": "person-red-hair",
  4652. "👩‍🦱": "woman-curly-hair",
  4653. "🧑‍🦱": "person-curly-hair",
  4654. "👩‍🦳": "woman-white-hair",
  4655. "🧑‍🦳": "person-white-hair",
  4656. "👩‍🦲": "woman-bald",
  4657. "🧑‍🦲": "person-bald",
  4658. "👱‍♀️": "woman-blond-hair",
  4659. "👱‍♂️": "man-blond-hair",
  4660. "🧓": "older-person",
  4661. "👴": "old-man",
  4662. "👵": "old-woman",
  4663. "🙍": "person-frowning",
  4664. "🙍‍♂️": "man-frowning",
  4665. "🙍‍♀️": "woman-frowning",
  4666. "🙎": "person-pouting",
  4667. "🙎‍♂️": "man-pouting",
  4668. "🙎‍♀️": "woman-pouting",
  4669. "🙅": "person-gesturing-no",
  4670. "🙅‍♂️": "man-gesturing-no",
  4671. "🙅‍♀️": "woman-gesturing-no",
  4672. "🙆": "person-gesturing-ok",
  4673. "🙆‍♂️": "man-gesturing-ok",
  4674. "🙆‍♀️": "woman-gesturing-ok",
  4675. "💁": "person-tipping-hand",
  4676. "💁‍♂️": "man-tipping-hand",
  4677. "💁‍♀️": "woman-tipping-hand",
  4678. "🙋": "person-raising-hand",
  4679. "🙋‍♂️": "man-raising-hand",
  4680. "🙋‍♀️": "woman-raising-hand",
  4681. "🧏": "deaf-person",
  4682. "🧏‍♂️": "deaf-man",
  4683. "🧏‍♀️": "deaf-woman",
  4684. "🙇": "person-bowing",
  4685. "🙇‍♂️": "man-bowing",
  4686. "🙇‍♀️": "woman-bowing",
  4687. "🤦": "person-facepalming",
  4688. "🤦‍♂️": "man-facepalming",
  4689. "🤦‍♀️": "woman-facepalming",
  4690. "🤷": "person-shrugging",
  4691. "🤷‍♂️": "man-shrugging",
  4692. "🤷‍♀️": "woman-shrugging",
  4693. "🧑‍⚕️": "health-worker",
  4694. "👨‍⚕️": "man-health-worker",
  4695. "👩‍⚕️": "woman-health-worker",
  4696. "🧑‍🎓": "student",
  4697. "👨‍🎓": "man-student",
  4698. "👩‍🎓": "woman-student",
  4699. "🧑‍🏫": "teacher",
  4700. "👨‍🏫": "man-teacher",
  4701. "👩‍🏫": "woman-teacher",
  4702. "🧑‍⚖️": "judge",
  4703. "👨‍⚖️": "man-judge",
  4704. "👩‍⚖️": "woman-judge",
  4705. "🧑‍🌾": "farmer",
  4706. "👨‍🌾": "man-farmer",
  4707. "👩‍🌾": "woman-farmer",
  4708. "🧑‍🍳": "cook",
  4709. "👨‍🍳": "man-cook",
  4710. "👩‍🍳": "woman-cook",
  4711. "🧑‍🔧": "mechanic",
  4712. "👨‍🔧": "man-mechanic",
  4713. "👩‍🔧": "woman-mechanic",
  4714. "🧑‍🏭": "factory-worker",
  4715. "👨‍🏭": "man-factory-worker",
  4716. "👩‍🏭": "woman-factory-worker",
  4717. "🧑‍💼": "office-worker",
  4718. "👨‍💼": "man-office-worker",
  4719. "👩‍💼": "woman-office-worker",
  4720. "🧑‍🔬": "scientist",
  4721. "👨‍🔬": "man-scientist",
  4722. "👩‍🔬": "woman-scientist",
  4723. "🧑‍💻": "technologist",
  4724. "👨‍💻": "man-technologist",
  4725. "👩‍💻": "woman-technologist",
  4726. "🧑‍🎤": "singer",
  4727. "👨‍🎤": "man-singer",
  4728. "👩‍🎤": "woman-singer",
  4729. "🧑‍🎨": "artist",
  4730. "👨‍🎨": "man-artist",
  4731. "👩‍🎨": "woman-artist",
  4732. "🧑‍✈️": "pilot",
  4733. "👨‍✈️": "man-pilot",
  4734. "👩‍✈️": "woman-pilot",
  4735. "🧑‍🚀": "astronaut",
  4736. "👨‍🚀": "man-astronaut",
  4737. "👩‍🚀": "woman-astronaut",
  4738. "🧑‍🚒": "firefighter",
  4739. "👨‍🚒": "man-firefighter",
  4740. "👩‍🚒": "woman-firefighter",
  4741. "👮": "police-officer",
  4742. "👮‍♂️": "man-police-officer",
  4743. "👮‍♀️": "woman-police-officer",
  4744. "🕵": "detective",
  4745. "🕵️‍♂️": "man-detective",
  4746. "🕵️‍♀️": "woman-detective",
  4747. "💂": "guard",
  4748. "💂‍♂️": "man-guard",
  4749. "💂‍♀️": "woman-guard",
  4750. "🥷": "ninja",
  4751. "👷": "construction-worker",
  4752. "👷‍♂️": "man-construction-worker",
  4753. "👷‍♀️": "woman-construction-worker",
  4754. "🫅": "person-with-crown",
  4755. "🤴": "prince",
  4756. "👸": "princess",
  4757. "👳": "person-wearing-turban",
  4758. "👳‍♂️": "man-wearing-turban",
  4759. "👳‍♀️": "woman-wearing-turban",
  4760. "👲": "person-with-skullcap",
  4761. "🧕": "woman-with-headscarf",
  4762. "🤵": "person-in-tuxedo",
  4763. "🤵‍♂️": "man-in-tuxedo",
  4764. "🤵‍♀️": "woman-in-tuxedo",
  4765. "👰": "person-with-veil",
  4766. "👰‍♂️": "man-with-veil",
  4767. "👰‍♀️": "woman-with-veil",
  4768. "🤰": "pregnant-woman",
  4769. "🫃": "pregnant-man",
  4770. "🫄": "pregnant-person",
  4771. "🤱": "breast-feeding",
  4772. "👩‍🍼": "woman-feeding-baby",
  4773. "👨‍🍼": "man-feeding-baby",
  4774. "🧑‍🍼": "person-feeding-baby",
  4775. "👼": "baby-angel",
  4776. "🎅": "santa-claus",
  4777. "🤶": "mrs-claus",
  4778. "🧑‍🎄": "mx-claus",
  4779. "🦸": "superhero",
  4780. "🦸‍♂️": "man-superhero",
  4781. "🦸‍♀️": "woman-superhero",
  4782. "🦹": "supervillain",
  4783. "🦹‍♂️": "man-supervillain",
  4784. "🦹‍♀️": "woman-supervillain",
  4785. "🧙": "mage",
  4786. "🧙‍♂️": "man-mage",
  4787. "🧙‍♀️": "woman-mage",
  4788. "🧚": "fairy",
  4789. "🧚‍♂️": "man-fairy",
  4790. "🧚‍♀️": "woman-fairy",
  4791. "🧛": "vampire",
  4792. "🧛‍♂️": "man-vampire",
  4793. "🧛‍♀️": "woman-vampire",
  4794. "🧜": "merperson",
  4795. "🧜‍♂️": "merman",
  4796. "🧜‍♀️": "mermaid",
  4797. "🧝": "elf",
  4798. "🧝‍♂️": "man-elf",
  4799. "🧝‍♀️": "woman-elf",
  4800. "🧞": "genie",
  4801. "🧞‍♂️": "man-genie",
  4802. "🧞‍♀️": "woman-genie",
  4803. "🧟": "zombie",
  4804. "🧟‍♂️": "man-zombie",
  4805. "🧟‍♀️": "woman-zombie",
  4806. "🧌": "troll",
  4807. "💆": "person-getting-massage",
  4808. "💆‍♂️": "man-getting-massage",
  4809. "💆‍♀️": "woman-getting-massage",
  4810. "💇": "person-getting-haircut",
  4811. "💇‍♂️": "man-getting-haircut",
  4812. "💇‍♀️": "woman-getting-haircut",
  4813. "🚶": "person-walking",
  4814. "🚶‍♂️": "man-walking",
  4815. "🚶‍♀️": "woman-walking",
  4816. "🧍": "person-standing",
  4817. "🧍‍♂️": "man-standing",
  4818. "🧍‍♀️": "woman-standing",
  4819. "🧎": "person-kneeling",
  4820. "🧎‍♂️": "man-kneeling",
  4821. "🧎‍♀️": "woman-kneeling",
  4822. "🧑‍🦯": "person-with-white-cane",
  4823. "👨‍🦯": "man-with-white-cane",
  4824. "👩‍🦯": "woman-with-white-cane",
  4825. "🧑‍🦼": "person-in-motorized-wheelchair",
  4826. "👨‍🦼": "man-in-motorized-wheelchair",
  4827. "👩‍🦼": "woman-in-motorized-wheelchair",
  4828. "🧑‍🦽": "person-in-manual-wheelchair",
  4829. "👨‍🦽": "man-in-manual-wheelchair",
  4830. "👩‍🦽": "woman-in-manual-wheelchair",
  4831. "🏃": "person-running",
  4832. "🏃‍♂️": "man-running",
  4833. "🏃‍♀️": "woman-running",
  4834. "💃": "woman-dancing",
  4835. "🕺": "man-dancing",
  4836. "🕴": "person-in-suit-levitating",
  4837. "👯": "people-with-bunny-ears",
  4838. "👯‍♂️": "men-with-bunny-ears",
  4839. "👯‍♀️": "women-with-bunny-ears",
  4840. "🧖": "person-in-steamy-room",
  4841. "🧖‍♂️": "man-in-steamy-room",
  4842. "🧖‍♀️": "woman-in-steamy-room",
  4843. "🧗": "person-climbing",
  4844. "🧗‍♂️": "man-climbing",
  4845. "🧗‍♀️": "woman-climbing",
  4846. "🤺": "person-fencing",
  4847. "🏇": "horse-racing",
  4848. "⛷": "skier",
  4849. "🏂": "snowboarder",
  4850. "🏌": "person-golfing",
  4851. "🏌️‍♂️": "man-golfing",
  4852. "🏌️‍♀️": "woman-golfing",
  4853. "🏄": "person-surfing",
  4854. "🏄‍♂️": "man-surfing",
  4855. "🏄‍♀️": "woman-surfing",
  4856. "🚣": "person-rowing-boat",
  4857. "🚣‍♂️": "man-rowing-boat",
  4858. "🚣‍♀️": "woman-rowing-boat",
  4859. "🏊": "person-swimming",
  4860. "🏊‍♂️": "man-swimming",
  4861. "🏊‍♀️": "woman-swimming",
  4862. "⛹": "person-bouncing-ball",
  4863. "⛹️‍♂️": "man-bouncing-ball",
  4864. "⛹️‍♀️": "woman-bouncing-ball",
  4865. "🏋": "person-lifting-weights",
  4866. "🏋️‍♂️": "man-lifting-weights",
  4867. "🏋️‍♀️": "woman-lifting-weights",
  4868. "🚴": "person-biking",
  4869. "🚴‍♂️": "man-biking",
  4870. "🚴‍♀️": "woman-biking",
  4871. "🚵": "person-mountain-biking",
  4872. "🚵‍♂️": "man-mountain-biking",
  4873. "🚵‍♀️": "woman-mountain-biking",
  4874. "🤸": "person-cartwheeling",
  4875. "🤸‍♂️": "man-cartwheeling",
  4876. "🤸‍♀️": "woman-cartwheeling",
  4877. "🤼": "people-wrestling",
  4878. "🤼‍♂️": "men-wrestling",
  4879. "🤼‍♀️": "women-wrestling",
  4880. "🤽": "person-playing-water-polo",
  4881. "🤽‍♂️": "man-playing-water-polo",
  4882. "🤽‍♀️": "woman-playing-water-polo",
  4883. "🤾": "person-playing-handball",
  4884. "🤾‍♂️": "man-playing-handball",
  4885. "🤾‍♀️": "woman-playing-handball",
  4886. "🤹": "person-juggling",
  4887. "🤹‍♂️": "man-juggling",
  4888. "🤹‍♀️": "woman-juggling",
  4889. "🧘": "person-in-lotus-position",
  4890. "🧘‍♂️": "man-in-lotus-position",
  4891. "🧘‍♀️": "woman-in-lotus-position",
  4892. "🛀": "person-taking-bath",
  4893. "🛌": "person-in-bed",
  4894. "🧑‍🤝‍🧑": "people-holding-hands",
  4895. "👭": "women-holding-hands",
  4896. "👫": "woman-and-man-holding-hands",
  4897. "👬": "men-holding-hands",
  4898. "💏": "kiss",
  4899. "👩‍❤️‍💋‍👨": "kiss-woman,-man",
  4900. "👨‍❤️‍💋‍👨": "kiss-man,-man",
  4901. "👩‍❤️‍💋‍👩": "kiss-woman,-woman",
  4902. "💑": "couple-with-heart",
  4903. "👩‍❤️‍👨": "couple-with-heart-woman,-man",
  4904. "👨‍❤️‍👨": "couple-with-heart-man,-man",
  4905. "👩‍❤️‍👩": "couple-with-heart-woman,-woman",
  4906. "👪": "family",
  4907. "👨‍👩‍👦": "family-man,-woman,-boy",
  4908. "👨‍👩‍👧": "family-man,-woman,-girl",
  4909. "👨‍👩‍👧‍👦": "family-man,-woman,-girl,-boy",
  4910. "👨‍👩‍👦‍👦": "family-man,-woman,-boy,-boy",
  4911. "👨‍👩‍👧‍👧": "family-man,-woman,-girl,-girl",
  4912. "👨‍👨‍👦": "family-man,-man,-boy",
  4913. "👨‍👨‍👧": "family-man,-man,-girl",
  4914. "👨‍👨‍👧‍👦": "family-man,-man,-girl,-boy",
  4915. "👨‍👨‍👦‍👦": "family-man,-man,-boy,-boy",
  4916. "👨‍👨‍👧‍👧": "family-man,-man,-girl,-girl",
  4917. "👩‍👩‍👦": "family-woman,-woman,-boy",
  4918. "👩‍👩‍👧": "family-woman,-woman,-girl",
  4919. "👩‍👩‍👧‍👦": "family-woman,-woman,-girl,-boy",
  4920. "👩‍👩‍👦‍👦": "family-woman,-woman,-boy,-boy",
  4921. "👩‍👩‍👧‍👧": "family-woman,-woman,-girl,-girl",
  4922. "👨‍👦": "family-man,-boy",
  4923. "👨‍👦‍👦": "family-man,-boy,-boy",
  4924. "👨‍👧": "family-man,-girl",
  4925. "👨‍👧‍👦": "family-man,-girl,-boy",
  4926. "👨‍👧‍👧": "family-man,-girl,-girl",
  4927. "👩‍👦": "family-woman,-boy",
  4928. "👩‍👦‍👦": "family-woman,-boy,-boy",
  4929. "👩‍👧": "family-woman,-girl",
  4930. "👩‍👧‍👦": "family-woman,-girl,-boy",
  4931. "👩‍👧‍👧": "family-woman,-girl,-girl",
  4932. "🗣": "speaking-head",
  4933. "👤": "bust-in-silhouette",
  4934. "👥": "busts-in-silhouette",
  4935. "🫂": "people-hugging",
  4936. "👣": "footprints",
  4937. "🦰": "red-hair",
  4938. "🦱": "curly-hair",
  4939. "🦳": "white-hair",
  4940. "🦲": "bald",
  4941. "🐵": "monkey-face",
  4942. "🐒": "monkey",
  4943. "🦍": "gorilla",
  4944. "🦧": "orangutan",
  4945. "🐶": "dog-face",
  4946. "🐕": "dog",
  4947. "🦮": "guide-dog",
  4948. "🐕‍🦺": "service-dog",
  4949. "🐩": "poodle",
  4950. "🐺": "wolf",
  4951. "🦊": "fox",
  4952. "🦝": "raccoon",
  4953. "🐱": "cat-face",
  4954. "🐈": "cat",
  4955. "🐈‍⬛": "black-cat",
  4956. "🦁": "lion",
  4957. "🐯": "tiger-face",
  4958. "🐅": "tiger",
  4959. "🐆": "leopard",
  4960. "🐴": "horse-face",
  4961. "🫎": "⊛-moose",
  4962. "🫏": "⊛-donkey",
  4963. "🐎": "horse",
  4964. "🦄": "unicorn",
  4965. "🦓": "zebra",
  4966. "🦌": "deer",
  4967. "🦬": "bison",
  4968. "🐮": "cow-face",
  4969. "🐂": "ox",
  4970. "🐃": "water-buffalo",
  4971. "🐄": "cow",
  4972. "🐷": "pig-face",
  4973. "🐖": "pig",
  4974. "🐗": "boar",
  4975. "🐽": "pig-nose",
  4976. "🐏": "ram",
  4977. "🐑": "ewe",
  4978. "🐐": "goat",
  4979. "🐪": "camel",
  4980. "🐫": "two-hump-camel",
  4981. "🦙": "llama",
  4982. "🦒": "giraffe",
  4983. "🐘": "elephant",
  4984. "🦣": "mammoth",
  4985. "🦏": "rhinoceros",
  4986. "🦛": "hippopotamus",
  4987. "🐭": "mouse-face",
  4988. "🐁": "mouse",
  4989. "🐀": "rat",
  4990. "🐹": "hamster",
  4991. "🐰": "rabbit-face",
  4992. "🐇": "rabbit",
  4993. "🐿": "chipmunk",
  4994. "🦫": "beaver",
  4995. "🦔": "hedgehog",
  4996. "🦇": "bat",
  4997. "🐻": "bear",
  4998. "🐻‍❄️": "polar-bear",
  4999. "🐨": "koala",
  5000. "🐼": "panda",
  5001. "🦥": "sloth",
  5002. "🦦": "otter",
  5003. "🦨": "skunk",
  5004. "🦘": "kangaroo",
  5005. "🦡": "badger",
  5006. "🐾": "paw-prints",
  5007. "🦃": "turkey",
  5008. "🐔": "chicken",
  5009. "🐓": "rooster",
  5010. "🐣": "hatching-chick",
  5011. "🐤": "baby-chick",
  5012. "🐥": "front-facing-baby-chick",
  5013. "🐦": "bird",
  5014. "🐧": "penguin",
  5015. "🕊": "dove",
  5016. "🦅": "eagle",
  5017. "🦆": "duck",
  5018. "🦢": "swan",
  5019. "🦉": "owl",
  5020. "🦤": "dodo",
  5021. "🪶": "feather",
  5022. "🦩": "flamingo",
  5023. "🦚": "peacock",
  5024. "🦜": "parrot",
  5025. "🪽": "⊛-wing",
  5026. "🐦‍⬛": "⊛-black-bird",
  5027. "🪿": "⊛-goose",
  5028. "🐸": "frog",
  5029. "🐊": "crocodile",
  5030. "🐢": "turtle",
  5031. "🦎": "lizard",
  5032. "🐍": "snake",
  5033. "🐲": "dragon-face",
  5034. "🐉": "dragon",
  5035. "🦕": "sauropod",
  5036. "🦖": "t-rex",
  5037. "🐳": "spouting-whale",
  5038. "🐋": "whale",
  5039. "🐬": "dolphin",
  5040. "🦭": "seal",
  5041. "🐟": "fish",
  5042. "🐠": "tropical-fish",
  5043. "🐡": "blowfish",
  5044. "🦈": "shark",
  5045. "🐙": "octopus",
  5046. "🐚": "spiral-shell",
  5047. "🪸": "coral",
  5048. "🪼": "⊛-jellyfish",
  5049. "🐌": "snail",
  5050. "🦋": "butterfly",
  5051. "🐛": "bug",
  5052. "🐜": "ant",
  5053. "🐝": "honeybee",
  5054. "🪲": "beetle",
  5055. "🐞": "lady-beetle",
  5056. "🦗": "cricket",
  5057. "🪳": "cockroach",
  5058. "🕷": "spider",
  5059. "🕸": "spider-web",
  5060. "🦂": "scorpion",
  5061. "🦟": "mosquito",
  5062. "🪰": "fly",
  5063. "🪱": "worm",
  5064. "🦠": "microbe",
  5065. "💐": "bouquet",
  5066. "🌸": "cherry-blossom",
  5067. "💮": "white-flower",
  5068. "🪷": "lotus",
  5069. "🏵": "rosette",
  5070. "🌹": "rose",
  5071. "🥀": "wilted-flower",
  5072. "🌺": "hibiscus",
  5073. "🌻": "sunflower",
  5074. "🌼": "blossom",
  5075. "🌷": "tulip",
  5076. "🪻": "⊛-hyacinth",
  5077. "🌱": "seedling",
  5078. "🪴": "potted-plant",
  5079. "🌲": "evergreen-tree",
  5080. "🌳": "deciduous-tree",
  5081. "🌴": "palm-tree",
  5082. "🌵": "cactus",
  5083. "🌾": "sheaf-of-rice",
  5084. "🌿": "herb",
  5085. "☘": "shamrock",
  5086. "🍀": "four-leaf-clover",
  5087. "🍁": "maple-leaf",
  5088. "🍂": "fallen-leaf",
  5089. "🍃": "leaf-fluttering-in-wind",
  5090. "🪹": "empty-nest",
  5091. "🪺": "nest-with-eggs",
  5092. "🍄": "mushroom",
  5093. "🍇": "grapes",
  5094. "🍈": "melon",
  5095. "🍉": "watermelon",
  5096. "🍊": "tangerine",
  5097. "🍋": "lemon",
  5098. "🍌": "banana",
  5099. "🍍": "pineapple",
  5100. "🥭": "mango",
  5101. "🍎": "red-apple",
  5102. "🍏": "green-apple",
  5103. "🍐": "pear",
  5104. "🍑": "peach",
  5105. "🍒": "cherries",
  5106. "🍓": "strawberry",
  5107. "🫐": "blueberries",
  5108. "🥝": "kiwi-fruit",
  5109. "🍅": "tomato",
  5110. "🫒": "olive",
  5111. "🥥": "coconut",
  5112. "🥑": "avocado",
  5113. "🍆": "eggplant",
  5114. "🥔": "potato",
  5115. "🥕": "carrot",
  5116. "🌽": "ear-of-corn",
  5117. "🌶": "hot-pepper",
  5118. "🫑": "bell-pepper",
  5119. "🥒": "cucumber",
  5120. "🥬": "leafy-green",
  5121. "🥦": "broccoli",
  5122. "🧄": "garlic",
  5123. "🧅": "onion",
  5124. "🥜": "peanuts",
  5125. "🫘": "beans",
  5126. "🌰": "chestnut",
  5127. "🫚": "⊛-ginger-root",
  5128. "🫛": "⊛-pea-pod",
  5129. "🍞": "bread",
  5130. "🥐": "croissant",
  5131. "🥖": "baguette-bread",
  5132. "🫓": "flatbread",
  5133. "🥨": "pretzel",
  5134. "🥯": "bagel",
  5135. "🥞": "pancakes",
  5136. "🧇": "waffle",
  5137. "🧀": "cheese-wedge",
  5138. "🍖": "meat-on-bone",
  5139. "🍗": "poultry-leg",
  5140. "🥩": "cut-of-meat",
  5141. "🥓": "bacon",
  5142. "🍔": "hamburger",
  5143. "🍟": "french-fries",
  5144. "🍕": "pizza",
  5145. "🌭": "hot-dog",
  5146. "🥪": "sandwich",
  5147. "🌮": "taco",
  5148. "🌯": "burrito",
  5149. "🫔": "tamale",
  5150. "🥙": "stuffed-flatbread",
  5151. "🧆": "falafel",
  5152. "🥚": "egg",
  5153. "🍳": "cooking",
  5154. "🥘": "shallow-pan-of-food",
  5155. "🍲": "pot-of-food",
  5156. "🫕": "fondue",
  5157. "🥣": "bowl-with-spoon",
  5158. "🥗": "green-salad",
  5159. "🍿": "popcorn",
  5160. "🧈": "butter",
  5161. "🧂": "salt",
  5162. "🥫": "canned-food",
  5163. "🍱": "bento-box",
  5164. "🍘": "rice-cracker",
  5165. "🍙": "rice-ball",
  5166. "🍚": "cooked-rice",
  5167. "🍛": "curry-rice",
  5168. "🍜": "steaming-bowl",
  5169. "🍝": "spaghetti",
  5170. "🍠": "roasted-sweet-potato",
  5171. "🍢": "oden",
  5172. "🍣": "sushi",
  5173. "🍤": "fried-shrimp",
  5174. "🍥": "fish-cake-with-swirl",
  5175. "🥮": "moon-cake",
  5176. "🍡": "dango",
  5177. "🥟": "dumpling",
  5178. "🥠": "fortune-cookie",
  5179. "🥡": "takeout-box",
  5180. "🦀": "crab",
  5181. "🦞": "lobster",
  5182. "🦐": "shrimp",
  5183. "🦑": "squid",
  5184. "🦪": "oyster",
  5185. "🍦": "soft-ice-cream",
  5186. "🍧": "shaved-ice",
  5187. "🍨": "ice-cream",
  5188. "🍩": "doughnut",
  5189. "🍪": "cookie",
  5190. "🎂": "birthday-cake",
  5191. "🍰": "shortcake",
  5192. "🧁": "cupcake",
  5193. "🥧": "pie",
  5194. "🍫": "chocolate-bar",
  5195. "🍬": "candy",
  5196. "🍭": "lollipop",
  5197. "🍮": "custard",
  5198. "🍯": "honey-pot",
  5199. "🍼": "baby-bottle",
  5200. "🥛": "glass-of-milk",
  5201. "☕": "hot-beverage",
  5202. "🫖": "teapot",
  5203. "🍵": "teacup-without-handle",
  5204. "🍶": "sake",
  5205. "🍾": "bottle-with-popping-cork",
  5206. "🍷": "wine-glass",
  5207. "🍸": "cocktail-glass",
  5208. "🍹": "tropical-drink",
  5209. "🍺": "beer-mug",
  5210. "🍻": "clinking-beer-mugs",
  5211. "🥂": "clinking-glasses",
  5212. "🥃": "tumbler-glass",
  5213. "🫗": "pouring-liquid",
  5214. "🥤": "cup-with-straw",
  5215. "🧋": "bubble-tea",
  5216. "🧃": "beverage-box",
  5217. "🧉": "mate",
  5218. "🧊": "ice",
  5219. "🥢": "chopsticks",
  5220. "🍽": "fork-and-knife-with-plate",
  5221. "🍴": "fork-and-knife",
  5222. "🥄": "spoon",
  5223. "🔪": "kitchen-knife",
  5224. "🫙": "jar",
  5225. "🏺": "amphora",
  5226. "🌍": "globe-showing-europe-africa",
  5227. "🌎": "globe-showing-americas",
  5228. "🌏": "globe-showing-asia-australia",
  5229. "🌐": "globe-with-meridians",
  5230. "🗺": "world-map",
  5231. "🗾": "map-of-japan",
  5232. "🧭": "compass",
  5233. "🏔": "snow-capped-mountain",
  5234. "⛰": "mountain",
  5235. "🌋": "volcano",
  5236. "🗻": "mount-fuji",
  5237. "🏕": "camping",
  5238. "🏖": "beach-with-umbrella",
  5239. "🏜": "desert",
  5240. "🏝": "desert-island",
  5241. "🏞": "national-park",
  5242. "🏟": "stadium",
  5243. "🏛": "classical-building",
  5244. "🏗": "building-construction",
  5245. "🧱": "brick",
  5246. "🪨": "rock",
  5247. "🪵": "wood",
  5248. "🛖": "hut",
  5249. "🏘": "houses",
  5250. "🏚": "derelict-house",
  5251. "🏠": "house",
  5252. "🏡": "house-with-garden",
  5253. "🏢": "office-building",
  5254. "🏣": "japanese-post-office",
  5255. "🏤": "post-office",
  5256. "🏥": "hospital",
  5257. "🏦": "bank",
  5258. "🏨": "hotel",
  5259. "🏩": "love-hotel",
  5260. "🏪": "convenience-store",
  5261. "🏫": "school",
  5262. "🏬": "department-store",
  5263. "🏭": "factory",
  5264. "🏯": "japanese-castle",
  5265. "🏰": "castle",
  5266. "💒": "wedding",
  5267. "🗼": "tokyo-tower",
  5268. "🗽": "statue-of-liberty",
  5269. "⛪": "church",
  5270. "🕌": "mosque",
  5271. "🛕": "hindu-temple",
  5272. "🕍": "synagogue",
  5273. "⛩": "shinto-shrine",
  5274. "🕋": "kaaba",
  5275. "⛲": "fountain",
  5276. "⛺": "tent",
  5277. "🌁": "foggy",
  5278. "🌃": "night-with-stars",
  5279. "🏙": "cityscape",
  5280. "🌄": "sunrise-over-mountains",
  5281. "🌅": "sunrise",
  5282. "🌆": "cityscape-at-dusk",
  5283. "🌇": "sunset",
  5284. "🌉": "bridge-at-night",
  5285. "♨": "hot-springs",
  5286. "🎠": "carousel-horse",
  5287. "🛝": "playground-slide",
  5288. "🎡": "ferris-wheel",
  5289. "🎢": "roller-coaster",
  5290. "💈": "barber-pole",
  5291. "🎪": "circus-tent",
  5292. "🚂": "locomotive",
  5293. "🚃": "railway-car",
  5294. "🚄": "high-speed-train",
  5295. "🚅": "bullet-train",
  5296. "🚆": "train",
  5297. "🚇": "metro",
  5298. "🚈": "light-rail",
  5299. "🚉": "station",
  5300. "🚊": "tram",
  5301. "🚝": "monorail",
  5302. "🚞": "mountain-railway",
  5303. "🚋": "tram-car",
  5304. "🚌": "bus",
  5305. "🚍": "oncoming-bus",
  5306. "🚎": "trolleybus",
  5307. "🚐": "minibus",
  5308. "🚑": "ambulance",
  5309. "🚒": "fire-engine",
  5310. "🚓": "police-car",
  5311. "🚔": "oncoming-police-car",
  5312. "🚕": "taxi",
  5313. "🚖": "oncoming-taxi",
  5314. "🚗": "automobile",
  5315. "🚘": "oncoming-automobile",
  5316. "🚙": "sport-utility-vehicle",
  5317. "🛻": "pickup-truck",
  5318. "🚚": "delivery-truck",
  5319. "🚛": "articulated-lorry",
  5320. "🚜": "tractor",
  5321. "🏎": "racing-car",
  5322. "🏍": "motorcycle",
  5323. "🛵": "motor-scooter",
  5324. "🦽": "manual-wheelchair",
  5325. "🦼": "motorized-wheelchair",
  5326. "🛺": "auto-rickshaw",
  5327. "🚲": "bicycle",
  5328. "🛴": "kick-scooter",
  5329. "🛹": "skateboard",
  5330. "🛼": "roller-skate",
  5331. "🚏": "bus-stop",
  5332. "🛣": "motorway",
  5333. "🛤": "railway-track",
  5334. "🛢": "oil-drum",
  5335. "⛽": "fuel-pump",
  5336. "🛞": "wheel",
  5337. "🚨": "police-car-light",
  5338. "🚥": "horizontal-traffic-light",
  5339. "🚦": "vertical-traffic-light",
  5340. "🛑": "stop-sign",
  5341. "🚧": "construction",
  5342. "⚓": "anchor",
  5343. "🛟": "ring-buoy",
  5344. "⛵": "sailboat",
  5345. "🛶": "canoe",
  5346. "🚤": "speedboat",
  5347. "🛳": "passenger-ship",
  5348. "⛴": "ferry",
  5349. "🛥": "motor-boat",
  5350. "🚢": "ship",
  5351. "✈": "airplane",
  5352. "🛩": "small-airplane",
  5353. "🛫": "airplane-departure",
  5354. "🛬": "airplane-arrival",
  5355. "🪂": "parachute",
  5356. "💺": "seat",
  5357. "🚁": "helicopter",
  5358. "🚟": "suspension-railway",
  5359. "🚠": "mountain-cableway",
  5360. "🚡": "aerial-tramway",
  5361. "🛰": "satellite",
  5362. "🚀": "rocket",
  5363. "🛸": "flying-saucer",
  5364. "🛎": "bellhop-bell",
  5365. "🧳": "luggage",
  5366. "⌛": "hourglass-done",
  5367. "⏳": "hourglass-not-done",
  5368. "⌚": "watch",
  5369. "⏰": "alarm-clock",
  5370. "⏱": "stopwatch",
  5371. "⏲": "timer-clock",
  5372. "🕰": "mantelpiece-clock",
  5373. "🕛": "twelve-o-clock",
  5374. "🕧": "twelve-thirty",
  5375. "🕐": "one-o-clock",
  5376. "🕜": "one-thirty",
  5377. "🕑": "two-o-clock",
  5378. "🕝": "two-thirty",
  5379. "🕒": "three-o-clock",
  5380. "🕞": "three-thirty",
  5381. "🕓": "four-o-clock",
  5382. "🕟": "four-thirty",
  5383. "🕔": "five-o-clock",
  5384. "🕠": "five-thirty",
  5385. "🕕": "six-o-clock",
  5386. "🕡": "six-thirty",
  5387. "🕖": "seven-o-clock",
  5388. "🕢": "seven-thirty",
  5389. "🕗": "eight-o-clock",
  5390. "🕣": "eight-thirty",
  5391. "🕘": "nine-o-clock",
  5392. "🕤": "nine-thirty",
  5393. "🕙": "ten-o-clock",
  5394. "🕥": "ten-thirty",
  5395. "🕚": "eleven-o-clock",
  5396. "🕦": "eleven-thirty",
  5397. "🌑": "new-moon",
  5398. "🌒": "waxing-crescent-moon",
  5399. "🌓": "first-quarter-moon",
  5400. "🌔": "waxing-gibbous-moon",
  5401. "🌕": "full-moon",
  5402. "🌖": "waning-gibbous-moon",
  5403. "🌗": "last-quarter-moon",
  5404. "🌘": "waning-crescent-moon",
  5405. "🌙": "crescent-moon",
  5406. "🌚": "new-moon-face",
  5407. "🌛": "first-quarter-moon-face",
  5408. "🌜": "last-quarter-moon-face",
  5409. "🌡": "thermometer",
  5410. "☀": "sun",
  5411. "🌝": "full-moon-face",
  5412. "🌞": "sun-with-face",
  5413. "🪐": "ringed-planet",
  5414. "⭐": "star",
  5415. "🌟": "glowing-star",
  5416. "🌠": "shooting-star",
  5417. "🌌": "milky-way",
  5418. "☁": "cloud",
  5419. "⛅": "sun-behind-cloud",
  5420. "⛈": "cloud-with-lightning-and-rain",
  5421. "🌤": "sun-behind-small-cloud",
  5422. "🌥": "sun-behind-large-cloud",
  5423. "🌦": "sun-behind-rain-cloud",
  5424. "🌧": "cloud-with-rain",
  5425. "🌨": "cloud-with-snow",
  5426. "🌩": "cloud-with-lightning",
  5427. "🌪": "tornado",
  5428. "🌫": "fog",
  5429. "🌬": "wind-face",
  5430. "🌀": "cyclone",
  5431. "🌈": "rainbow",
  5432. "🌂": "closed-umbrella",
  5433. "☂": "umbrella",
  5434. "☔": "umbrella-with-rain-drops",
  5435. "⛱": "umbrella-on-ground",
  5436. "⚡": "high-voltage",
  5437. "❄": "snowflake",
  5438. "☃": "snowman",
  5439. "⛄": "snowman-without-snow",
  5440. "☄": "comet",
  5441. "🔥": "fire",
  5442. "💧": "droplet",
  5443. "🌊": "water-wave",
  5444. "🎃": "jack-o-lantern",
  5445. "🎄": "christmas-tree",
  5446. "🎆": "fireworks",
  5447. "🎇": "sparkler",
  5448. "🧨": "firecracker",
  5449. "✨": "sparkles",
  5450. "🎈": "balloon",
  5451. "🎉": "party-popper",
  5452. "🎊": "confetti-ball",
  5453. "🎋": "tanabata-tree",
  5454. "🎍": "pine-decoration",
  5455. "🎎": "japanese-dolls",
  5456. "🎏": "carp-streamer",
  5457. "🎐": "wind-chime",
  5458. "🎑": "moon-viewing-ceremony",
  5459. "🧧": "red-envelope",
  5460. "🎀": "ribbon",
  5461. "🎁": "wrapped-gift",
  5462. "🎗": "reminder-ribbon",
  5463. "🎟": "admission-tickets",
  5464. "🎫": "ticket",
  5465. "🎖": "military-medal",
  5466. "🏆": "trophy",
  5467. "🏅": "sports-medal",
  5468. "🥇": "1st-place-medal",
  5469. "🥈": "2nd-place-medal",
  5470. "🥉": "3rd-place-medal",
  5471. "⚽": "soccer-ball",
  5472. "⚾": "baseball",
  5473. "🥎": "softball",
  5474. "🏀": "basketball",
  5475. "🏐": "volleyball",
  5476. "🏈": "american-football",
  5477. "🏉": "rugby-football",
  5478. "🎾": "tennis",
  5479. "🥏": "flying-disc",
  5480. "🎳": "bowling",
  5481. "🏏": "cricket-game",
  5482. "🏑": "field-hockey",
  5483. "🏒": "ice-hockey",
  5484. "🥍": "lacrosse",
  5485. "🏓": "ping-pong",
  5486. "🏸": "badminton",
  5487. "🥊": "boxing-glove",
  5488. "🥋": "martial-arts-uniform",
  5489. "🥅": "goal-net",
  5490. "⛳": "flag-in-hole",
  5491. "⛸": "ice-skate",
  5492. "🎣": "fishing-pole",
  5493. "🤿": "diving-mask",
  5494. "🎽": "running-shirt",
  5495. "🎿": "skis",
  5496. "🛷": "sled",
  5497. "🥌": "curling-stone",
  5498. "🎯": "bullseye",
  5499. "🪀": "yo-yo",
  5500. "🪁": "kite",
  5501. "🔫": "water-pistol",
  5502. "🎱": "pool-8-ball",
  5503. "🔮": "crystal-ball",
  5504. "🪄": "magic-wand",
  5505. "🎮": "video-game",
  5506. "🕹": "joystick",
  5507. "🎰": "slot-machine",
  5508. "🎲": "game-die",
  5509. "🧩": "puzzle-piece",
  5510. "🧸": "teddy-bear",
  5511. "🪅": "piñata",
  5512. "🪩": "mirror-ball",
  5513. "🪆": "nesting-dolls",
  5514. "♠": "spade-suit",
  5515. "♥": "heart-suit",
  5516. "♦": "diamond-suit",
  5517. "♣": "club-suit",
  5518. "♟": "chess-pawn",
  5519. "🃏": "joker",
  5520. "🀄": "mahjong-red-dragon",
  5521. "🎴": "flower-playing-cards",
  5522. "🎭": "performing-arts",
  5523. "🖼": "framed-picture",
  5524. "🎨": "artist-palette",
  5525. "🧵": "thread",
  5526. "🪡": "sewing-needle",
  5527. "🧶": "yarn",
  5528. "🪢": "knot",
  5529. "👓": "glasses",
  5530. "🕶": "sunglasses",
  5531. "🥽": "goggles",
  5532. "🥼": "lab-coat",
  5533. "🦺": "safety-vest",
  5534. "👔": "necktie",
  5535. "👕": "t-shirt",
  5536. "👖": "jeans",
  5537. "🧣": "scarf",
  5538. "🧤": "gloves",
  5539. "🧥": "coat",
  5540. "🧦": "socks",
  5541. "👗": "dress",
  5542. "👘": "kimono",
  5543. "🥻": "sari",
  5544. "🩱": "one-piece-swimsuit",
  5545. "🩲": "briefs",
  5546. "🩳": "shorts",
  5547. "👙": "bikini",
  5548. "👚": "woman-s-clothes",
  5549. "🪭": "⊛-folding-hand-fan",
  5550. "👛": "purse",
  5551. "👜": "handbag",
  5552. "👝": "clutch-bag",
  5553. "🛍": "shopping-bags",
  5554. "🎒": "backpack",
  5555. "🩴": "thong-sandal",
  5556. "👞": "man-s-shoe",
  5557. "👟": "running-shoe",
  5558. "🥾": "hiking-boot",
  5559. "🥿": "flat-shoe",
  5560. "👠": "high-heeled-shoe",
  5561. "👡": "woman-s-sandal",
  5562. "🩰": "ballet-shoes",
  5563. "👢": "woman-s-boot",
  5564. "🪮": "⊛-hair-pick",
  5565. "👑": "crown",
  5566. "👒": "woman-s-hat",
  5567. "🎩": "top-hat",
  5568. "🎓": "graduation-cap",
  5569. "🧢": "billed-cap",
  5570. "🪖": "military-helmet",
  5571. "⛑": "rescue-worker-s-helmet",
  5572. "📿": "prayer-beads",
  5573. "💄": "lipstick",
  5574. "💍": "ring",
  5575. "💎": "gem-stone",
  5576. "🔇": "muted-speaker",
  5577. "🔈": "speaker-low-volume",
  5578. "🔉": "speaker-medium-volume",
  5579. "🔊": "speaker-high-volume",
  5580. "📢": "loudspeaker",
  5581. "📣": "megaphone",
  5582. "📯": "postal-horn",
  5583. "🔔": "bell",
  5584. "🔕": "bell-with-slash",
  5585. "🎼": "musical-score",
  5586. "🎵": "musical-note",
  5587. "🎶": "musical-notes",
  5588. "🎙": "studio-microphone",
  5589. "🎚": "level-slider",
  5590. "🎛": "control-knobs",
  5591. "🎤": "microphone",
  5592. "🎧": "headphone",
  5593. "📻": "radio",
  5594. "🎷": "saxophone",
  5595. "🪗": "accordion",
  5596. "🎸": "guitar",
  5597. "🎹": "musical-keyboard",
  5598. "🎺": "trumpet",
  5599. "🎻": "violin",
  5600. "🪕": "banjo",
  5601. "🥁": "drum",
  5602. "🪘": "long-drum",
  5603. "🪇": "maracas",
  5604. "🪈": "flute",
  5605. "📱": "mobile-phone",
  5606. "📲": "mobile-phone-with-arrow",
  5607. "☎": "telephone",
  5608. "📞": "telephone-receiver",
  5609. "📟": "pager",
  5610. "📠": "fax-machine",
  5611. "🔋": "battery",
  5612. "🪫": "low-battery",
  5613. "🔌": "electric-plug",
  5614. "💻": "laptop",
  5615. "🖥": "desktop-computer",
  5616. "🖨": "printer",
  5617. "⌨": "keyboard",
  5618. "🖱": "computer-mouse",
  5619. "🖲": "trackball",
  5620. "💽": "computer-disk",
  5621. "💾": "floppy-disk",
  5622. "💿": "optical-disk",
  5623. "📀": "dvd",
  5624. "🧮": "abacus",
  5625. "🎥": "movie-camera",
  5626. "🎞": "film-frames",
  5627. "📽": "film-projector",
  5628. "🎬": "clapper-board",
  5629. "📺": "television",
  5630. "📷": "camera",
  5631. "📸": "camera-with-flash",
  5632. "📹": "video-camera",
  5633. "📼": "videocassette",
  5634. "🔍": "magnifying-glass-tilted-left",
  5635. "🔎": "magnifying-glass-tilted-right",
  5636. "🕯": "candle",
  5637. "💡": "light-bulb",
  5638. "🔦": "flashlight",
  5639. "🏮": "red-paper-lantern",
  5640. "🪔": "diya-lamp",
  5641. "📔": "notebook-with-decorative-cover",
  5642. "📕": "closed-book",
  5643. "📖": "open-book",
  5644. "📗": "green-book",
  5645. "📘": "blue-book",
  5646. "📙": "orange-book",
  5647. "📚": "books",
  5648. "📓": "notebook",
  5649. "📒": "ledger",
  5650. "📃": "page-with-curl",
  5651. "📜": "scroll",
  5652. "📄": "page-facing-up",
  5653. "📰": "newspaper",
  5654. "🗞": "rolled-up-newspaper",
  5655. "📑": "bookmark-tabs",
  5656. "🔖": "bookmark",
  5657. "🏷": "label",
  5658. "💰": "money-bag",
  5659. "🪙": "coin",
  5660. "💴": "yen-banknote",
  5661. "💵": "dollar-banknote",
  5662. "💶": "euro-banknote",
  5663. "💷": "pound-banknote",
  5664. "💸": "money-with-wings",
  5665. "💳": "credit-card",
  5666. "🧾": "receipt",
  5667. "💹": "chart-increasing-with-yen",
  5668. "✉": "envelope",
  5669. "📧": "e-mail",
  5670. "📨": "incoming-envelope",
  5671. "📩": "envelope-with-arrow",
  5672. "📤": "outbox-tray",
  5673. "📥": "inbox-tray",
  5674. "📦": "package",
  5675. "📫": "closed-mailbox-with-raised-flag",
  5676. "📪": "closed-mailbox-with-lowered-flag",
  5677. "📬": "open-mailbox-with-raised-flag",
  5678. "📭": "open-mailbox-with-lowered-flag",
  5679. "📮": "postbox",
  5680. "🗳": "ballot-box-with-ballot",
  5681. "✏": "pencil",
  5682. "✒": "black-nib",
  5683. "🖋": "fountain-pen",
  5684. "🖊": "pen",
  5685. "🖌": "paintbrush",
  5686. "🖍": "crayon",
  5687. "📝": "memo",
  5688. "💼": "briefcase",
  5689. "📁": "file-folder",
  5690. "📂": "open-file-folder",
  5691. "🗂": "card-index-dividers",
  5692. "📅": "calendar",
  5693. "📆": "tear-off-calendar",
  5694. "🗒": "spiral-notepad",
  5695. "🗓": "spiral-calendar",
  5696. "📇": "card-index",
  5697. "📈": "chart-increasing",
  5698. "📉": "chart-decreasing",
  5699. "📊": "bar-chart",
  5700. "📋": "clipboard",
  5701. "📌": "pushpin",
  5702. "📍": "round-pushpin",
  5703. "📎": "paperclip",
  5704. "🖇": "linked-paperclips",
  5705. "📏": "straight-ruler",
  5706. "📐": "triangular-ruler",
  5707. "✂": "scissors",
  5708. "🗃": "card-file-box",
  5709. "🗄": "file-cabinet",
  5710. "🗑": "wastebasket",
  5711. "🔒": "locked",
  5712. "🔓": "unlocked",
  5713. "🔏": "locked-with-pen",
  5714. "🔐": "locked-with-key",
  5715. "🔑": "key",
  5716. "🗝": "old-key",
  5717. "🔨": "hammer",
  5718. "🪓": "axe",
  5719. "⛏": "pick",
  5720. "⚒": "hammer-and-pick",
  5721. "🛠": "hammer-and-wrench",
  5722. "🗡": "dagger",
  5723. "⚔": "crossed-swords",
  5724. "💣": "bomb",
  5725. "🪃": "boomerang",
  5726. "🏹": "bow-and-arrow",
  5727. "🛡": "shield",
  5728. "🪚": "carpentry-saw",
  5729. "🔧": "wrench",
  5730. "🪛": "screwdriver",
  5731. "🔩": "nut-and-bolt",
  5732. "⚙": "gear",
  5733. "🗜": "clamp",
  5734. "⚖": "balance-scale",
  5735. "🦯": "white-cane",
  5736. "🔗": "link",
  5737. "⛓": "chains",
  5738. "🪝": "hook",
  5739. "🧰": "toolbox",
  5740. "🧲": "magnet",
  5741. "🪜": "ladder",
  5742. "⚗": "alembic",
  5743. "🧪": "test-tube",
  5744. "🧫": "petri-dish",
  5745. "🧬": "dna",
  5746. "🔬": "microscope",
  5747. "🔭": "telescope",
  5748. "📡": "satellite-antenna",
  5749. "💉": "syringe",
  5750. "🩸": "drop-of-blood",
  5751. "💊": "pill",
  5752. "🩹": "adhesive-bandage",
  5753. "🩼": "crutch",
  5754. "🩺": "stethoscope",
  5755. "🩻": "x-ray",
  5756. "🚪": "door",
  5757. "🛗": "elevator",
  5758. "🪞": "mirror",
  5759. "🪟": "window",
  5760. "🛏": "bed",
  5761. "🛋": "couch-and-lamp",
  5762. "🪑": "chair",
  5763. "🚽": "toilet",
  5764. "🪠": "plunger",
  5765. "🚿": "shower",
  5766. "🛁": "bathtub",
  5767. "🪤": "mouse-trap",
  5768. "🪒": "razor",
  5769. "🧴": "lotion-bottle",
  5770. "🧷": "safety-pin",
  5771. "🧹": "broom",
  5772. "🧺": "basket",
  5773. "🧻": "roll-of-paper",
  5774. "🪣": "bucket",
  5775. "🧼": "soap",
  5776. "🫧": "bubbles",
  5777. "🪥": "toothbrush",
  5778. "🧽": "sponge",
  5779. "🧯": "fire-extinguisher",
  5780. "🛒": "shopping-cart",
  5781. "🚬": "cigarette",
  5782. "⚰": "coffin",
  5783. "🪦": "headstone",
  5784. "⚱": "funeral-urn",
  5785. "🧿": "nazar-amulet",
  5786. "🪬": "hamsa",
  5787. "🗿": "moai",
  5788. "🪧": "placard",
  5789. "🪪": "identification-card",
  5790. "🏧": "atm-sign",
  5791. "🚮": "litter-in-bin-sign",
  5792. "🚰": "potable-water",
  5793. "♿": "wheelchair-symbol",
  5794. "🚹": "men-s-room",
  5795. "🚺": "women-s-room",
  5796. "🚻": "restroom",
  5797. "🚼": "baby-symbol",
  5798. "🚾": "water-closet",
  5799. "🛂": "passport-control",
  5800. "🛃": "customs",
  5801. "🛄": "baggage-claim",
  5802. "🛅": "left-luggage",
  5803. "⚠": "warning",
  5804. "🚸": "children-crossing",
  5805. "⛔": "no-entry",
  5806. "🚫": "prohibited",
  5807. "🚳": "no-bicycles",
  5808. "🚭": "no-smoking",
  5809. "🚯": "no-littering",
  5810. "🚱": "non-potable-water",
  5811. "🚷": "no-pedestrians",
  5812. "📵": "no-mobile-phones",
  5813. "🔞": "no-one-under-eighteen",
  5814. "☢": "radioactive",
  5815. "☣": "biohazard",
  5816. "⬆": "up-arrow",
  5817. "↗": "up-right-arrow",
  5818. "➡": "right-arrow",
  5819. "↘": "down-right-arrow",
  5820. "⬇": "down-arrow",
  5821. "↙": "down-left-arrow",
  5822. "⬅": "left-arrow",
  5823. "↖": "up-left-arrow",
  5824. "↕": "up-down-arrow",
  5825. "↔": "left-right-arrow",
  5826. "↩": "right-arrow-curving-left",
  5827. "↪": "left-arrow-curving-right",
  5828. "⤴": "right-arrow-curving-up",
  5829. "⤵": "right-arrow-curving-down",
  5830. "🔃": "clockwise-vertical-arrows",
  5831. "🔄": "counterclockwise-arrows-button",
  5832. "🔙": "back-arrow",
  5833. "🔚": "end-arrow",
  5834. "🔛": "on!-arrow",
  5835. "🔜": "soon-arrow",
  5836. "🔝": "top-arrow",
  5837. "🛐": "place-of-worship",
  5838. "⚛": "atom-symbol",
  5839. "🕉": "om",
  5840. "✡": "star-of-david",
  5841. "☸": "wheel-of-dharma",
  5842. "☯": "yin-yang",
  5843. "✝": "latin-cross",
  5844. "☦": "orthodox-cross",
  5845. "☪": "star-and-crescent",
  5846. "☮": "peace-symbol",
  5847. "🕎": "menorah",
  5848. "🔯": "dotted-six-pointed-star",
  5849. "🪯": "⊛-khanda",
  5850. "♈": "aries",
  5851. "♉": "taurus",
  5852. "♊": "gemini",
  5853. "♋": "cancer",
  5854. "♌": "leo",
  5855. "♍": "virgo",
  5856. "♎": "libra",
  5857. "♏": "scorpio",
  5858. "♐": "sagittarius",
  5859. "♑": "capricorn",
  5860. "♒": "aquarius",
  5861. "♓": "pisces",
  5862. "⛎": "ophiuchus",
  5863. "🔀": "shuffle-tracks-button",
  5864. "🔁": "repeat-button",
  5865. "🔂": "repeat-single-button",
  5866. "▶": "play-button",
  5867. "⏩": "fast-forward-button",
  5868. "⏭": "next-track-button",
  5869. "⏯": "play-or-pause-button",
  5870. "◀": "reverse-button",
  5871. "⏪": "fast-reverse-button",
  5872. "⏮": "last-track-button",
  5873. "🔼": "upwards-button",
  5874. "⏫": "fast-up-button",
  5875. "🔽": "downwards-button",
  5876. "⏬": "fast-down-button",
  5877. "⏸": "pause-button",
  5878. "⏹": "stop-button",
  5879. "⏺": "record-button",
  5880. "⏏": "eject-button",
  5881. "🎦": "cinema",
  5882. "🔅": "dim-button",
  5883. "🔆": "bright-button",
  5884. "📶": "antenna-bars",
  5885. "🛜": "⊛-wireless",
  5886. "📳": "vibration-mode",
  5887. "📴": "mobile-phone-off",
  5888. "♀": "female-sign",
  5889. "♂": "male-sign",
  5890. "⚧": "transgender-symbol",
  5891. "✖": "multiply",
  5892. "➕": "plus",
  5893. "➖": "minus",
  5894. "➗": "divide",
  5895. "🟰": "heavy-equals-sign",
  5896. "♾": "infinity",
  5897. "‼": "double-exclamation-mark",
  5898. "⁉": "exclamation-question-mark",
  5899. "❓": "red-question-mark",
  5900. "❔": "white-question-mark",
  5901. "❕": "white-exclamation-mark",
  5902. "❗": "red-exclamation-mark",
  5903. "〰": "wavy-dash",
  5904. "💱": "currency-exchange",
  5905. "💲": "heavy-dollar-sign",
  5906. "⚕": "medical-symbol",
  5907. "♻": "recycling-symbol",
  5908. "⚜": "fleur-de-lis",
  5909. "🔱": "trident-emblem",
  5910. "📛": "name-badge",
  5911. "🔰": "japanese-symbol-for-beginner",
  5912. "⭕": "hollow-red-circle",
  5913. "✅": "check-mark-button",
  5914. "☑": "check-box-with-check",
  5915. "✔": "check-mark",
  5916. "❌": "cross-mark",
  5917. "❎": "cross-mark-button",
  5918. "➰": "curly-loop",
  5919. "➿": "double-curly-loop",
  5920. "〽": "part-alternation-mark",
  5921. "✳": "eight-spoked-asterisk",
  5922. "✴": "eight-pointed-star",
  5923. "❇": "sparkle",
  5924. "©": "copyright",
  5925. "®": "registered",
  5926. "™": "trade-mark",
  5927. "#️⃣": "keycap-#",
  5928. "*️⃣": "keycap-*",
  5929. "0️⃣": "keycap-0",
  5930. "1️⃣": "keycap-1",
  5931. "2️⃣": "keycap-2",
  5932. "3️⃣": "keycap-3",
  5933. "4️⃣": "keycap-4",
  5934. "5️⃣": "keycap-5",
  5935. "6️⃣": "keycap-6",
  5936. "7️⃣": "keycap-7",
  5937. "8️⃣": "keycap-8",
  5938. "9️⃣": "keycap-9",
  5939. "🔟": "keycap-10",
  5940. "🔠": "input-latin-uppercase",
  5941. "🔡": "input-latin-lowercase",
  5942. "🔢": "input-numbers",
  5943. "🔣": "input-symbols",
  5944. "🔤": "input-latin-letters",
  5945. "🅰": "a-button-(blood-type)",
  5946. "🆎": "ab-button-(blood-type)",
  5947. "🅱": "b-button-(blood-type)",
  5948. "🆑": "cl-button",
  5949. "🆒": "cool-button",
  5950. "🆓": "free-button",
  5951. ℹ: "information",
  5952. "🆔": "id-button",
  5953. "Ⓜ": "circled-m",
  5954. "🆕": "new-button",
  5955. "🆖": "ng-button",
  5956. "🅾": "o-button-(blood-type)",
  5957. "🆗": "ok-button",
  5958. "🅿": "p-button",
  5959. "🆘": "sos-button",
  5960. "🆙": "up!-button",
  5961. "🆚": "vs-button",
  5962. "🈁": "japanese-here-button",
  5963. "🈂": "japanese-service-charge-button",
  5964. "🈷": "japanese-monthly-amount-button",
  5965. "🈶": "japanese-not-free-of-charge-button",
  5966. "🈯": "japanese-reserved-button",
  5967. "🉐": "japanese-bargain-button",
  5968. "🈹": "japanese-discount-button",
  5969. "🈚": "japanese-free-of-charge-button",
  5970. "🈲": "japanese-prohibited-button",
  5971. "🉑": "japanese-acceptable-button",
  5972. "🈸": "japanese-application-button",
  5973. "🈴": "japanese-passing-grade-button",
  5974. "🈳": "japanese-vacancy-button",
  5975. "㊗": "japanese-congratulations-button",
  5976. "㊙": "japanese-secret-button",
  5977. "🈺": "japanese-open-for-business-button",
  5978. "🈵": "japanese-no-vacancy-button",
  5979. "🔴": "red-circle",
  5980. "🟠": "orange-circle",
  5981. "🟡": "yellow-circle",
  5982. "🟢": "green-circle",
  5983. "🔵": "blue-circle",
  5984. "🟣": "purple-circle",
  5985. "🟤": "brown-circle",
  5986. "⚫": "black-circle",
  5987. "⚪": "white-circle",
  5988. "🟥": "red-square",
  5989. "🟧": "orange-square",
  5990. "🟨": "yellow-square",
  5991. "🟩": "green-square",
  5992. "🟦": "blue-square",
  5993. "🟪": "purple-square",
  5994. "🟫": "brown-square",
  5995. "⬛": "black-large-square",
  5996. "⬜": "white-large-square",
  5997. "◼": "black-medium-square",
  5998. "◻": "white-medium-square",
  5999. "◾": "black-medium-small-square",
  6000. "◽": "white-medium-small-square",
  6001. "▪": "black-small-square",
  6002. "▫": "white-small-square",
  6003. "🔶": "large-orange-diamond",
  6004. "🔷": "large-blue-diamond",
  6005. "🔸": "small-orange-diamond",
  6006. "🔹": "small-blue-diamond",
  6007. "🔺": "red-triangle-pointed-up",
  6008. "🔻": "red-triangle-pointed-down",
  6009. "💠": "diamond-with-a-dot",
  6010. "🔘": "radio-button",
  6011. "🔳": "white-square-button",
  6012. "🔲": "black-square-button",
  6013. "🏁": "chequered-flag",
  6014. "🚩": "triangular-flag",
  6015. "🎌": "crossed-flags",
  6016. "🏴": "black-flag",
  6017. "🏳": "white-flag",
  6018. "🏳️‍🌈": "rainbow-flag",
  6019. "🏳️‍⚧️": "transgender-flag",
  6020. "🏴‍☠️": "pirate-flag",
  6021. "🇦🇨": "flag-ascension-island",
  6022. "🇦🇩": "flag-andorra",
  6023. "🇦🇪": "flag-united-arab-emirates",
  6024. "🇦🇫": "flag-afghanistan",
  6025. "🇦🇬": "flag-antigua-and-barbuda",
  6026. "🇦🇮": "flag-anguilla",
  6027. "🇦🇱": "flag-albania",
  6028. "🇦🇲": "flag-armenia",
  6029. "🇦🇴": "flag-angola",
  6030. "🇦🇶": "flag-antarctica",
  6031. "🇦🇷": "flag-argentina",
  6032. "🇦🇸": "flag-american-samoa",
  6033. "🇦🇹": "flag-austria",
  6034. "🇦🇺": "flag-australia",
  6035. "🇦🇼": "flag-aruba",
  6036. "🇦🇽": "flag-åland-islands",
  6037. "🇦🇿": "flag-azerbaijan",
  6038. "🇧🇦": "flag-bosnia-and-herzegovina",
  6039. "🇧🇧": "flag-barbados",
  6040. "🇧🇩": "flag-bangladesh",
  6041. "🇧🇪": "flag-belgium",
  6042. "🇧🇫": "flag-burkina-faso",
  6043. "🇧🇬": "flag-bulgaria",
  6044. "🇧🇭": "flag-bahrain",
  6045. "🇧🇮": "flag-burundi",
  6046. "🇧🇯": "flag-benin",
  6047. "🇧🇱": "flag-st-barthelemy",
  6048. "🇧🇲": "flag-bermuda",
  6049. "🇧🇳": "flag-brunei",
  6050. "🇧🇴": "flag-bolivia",
  6051. "🇧🇶": "flag-caribbean-netherlands",
  6052. "🇧🇷": "flag-brazil",
  6053. "🇧🇸": "flag-bahamas",
  6054. "🇧🇹": "flag-bhutan",
  6055. "🇧🇻": "flag-bouvet-island",
  6056. "🇧🇼": "flag-botswana",
  6057. "🇧🇾": "flag-belarus",
  6058. "🇧🇿": "flag-belize",
  6059. "🇨🇦": "flag-canada",
  6060. "🇨🇨": "flag-cocos-(keeling)-islands",
  6061. "🇨🇩": "flag-congo---kinshasa",
  6062. "🇨🇫": "flag-central-african-republic",
  6063. "🇨🇬": "flag-congo---brazzaville",
  6064. "🇨🇭": "flag-switzerland",
  6065. "🇨🇮": "flag-côte-d-ivoire",
  6066. "🇨🇰": "flag-cook-islands",
  6067. "🇨🇱": "flag-chile",
  6068. "🇨🇲": "flag-cameroon",
  6069. "🇨🇳": "flag-china",
  6070. "🇨🇴": "flag-colombia",
  6071. "🇨🇵": "flag-clipperton-island",
  6072. "🇨🇷": "flag-costa-rica",
  6073. "🇨🇺": "flag-cuba",
  6074. "🇨🇻": "flag-cape-verde",
  6075. "🇨🇼": "flag-curaçao",
  6076. "🇨🇽": "flag-christmas-island",
  6077. "🇨🇾": "flag-cyprus",
  6078. "🇨🇿": "flag-czechia",
  6079. "🇩🇪": "flag-germany",
  6080. "🇩🇬": "flag-diego-garcia",
  6081. "🇩🇯": "flag-djibouti",
  6082. "🇩🇰": "flag-denmark",
  6083. "🇩🇲": "flag-dominica",
  6084. "🇩🇴": "flag-dominican-republic",
  6085. "🇩🇿": "flag-algeria",
  6086. "🇪🇦": "flag-ceuta-and-melilla",
  6087. "🇪🇨": "flag-ecuador",
  6088. "🇪🇪": "flag-estonia",
  6089. "🇪🇬": "flag-egypt",
  6090. "🇪🇭": "flag-western-sahara",
  6091. "🇪🇷": "flag-eritrea",
  6092. "🇪🇸": "flag-spain",
  6093. "🇪🇹": "flag-ethiopia",
  6094. "🇪🇺": "flag-european-union",
  6095. "🇫🇮": "flag-finland",
  6096. "🇫🇯": "flag-fiji",
  6097. "🇫🇰": "flag-falkland-islands",
  6098. "🇫🇲": "flag-micronesia",
  6099. "🇫🇴": "flag-faroe-islands",
  6100. "🇫🇷": "flag-france",
  6101. "🇬🇦": "flag-gabon",
  6102. "🇬🇧": "flag-united-kingdom",
  6103. "🇬🇩": "flag-grenada",
  6104. "🇬🇪": "flag-georgia",
  6105. "🇬🇫": "flag-french-guiana",
  6106. "🇬🇬": "flag-guernsey",
  6107. "🇬🇭": "flag-ghana",
  6108. "🇬🇮": "flag-gibraltar",
  6109. "🇬🇱": "flag-greenland",
  6110. "🇬🇲": "flag-gambia",
  6111. "🇬🇳": "flag-guinea",
  6112. "🇬🇵": "flag-guadeloupe",
  6113. "🇬🇶": "flag-equatorial-guinea",
  6114. "🇬🇷": "flag-greece",
  6115. "🇬🇸": "flag-south-georgia-and-south-sandwich-islands",
  6116. "🇬🇹": "flag-guatemala",
  6117. "🇬🇺": "flag-guam",
  6118. "🇬🇼": "flag-guinea-bissau",
  6119. "🇬🇾": "flag-guyana",
  6120. "🇭🇰": "flag-hong-kong-sar-china",
  6121. "🇭🇲": "flag-heard-and-mcdonald-islands",
  6122. "🇭🇳": "flag-honduras",
  6123. "🇭🇷": "flag-croatia",
  6124. "🇭🇹": "flag-haiti",
  6125. "🇭🇺": "flag-hungary",
  6126. "🇮🇨": "flag-canary-islands",
  6127. "🇮🇩": "flag-indonesia",
  6128. "🇮🇪": "flag-ireland",
  6129. "🇮🇱": "flag-israel",
  6130. "🇮🇲": "flag-isle-of-man",
  6131. "🇮🇳": "flag-india",
  6132. "🇮🇴": "flag-british-indian-ocean-territory",
  6133. "🇮🇶": "flag-iraq",
  6134. "🇮🇷": "flag-iran",
  6135. "🇮🇸": "flag-iceland",
  6136. "🇮🇹": "flag-italy",
  6137. "🇯🇪": "flag-jersey",
  6138. "🇯🇲": "flag-jamaica",
  6139. "🇯🇴": "flag-jordan",
  6140. "🇯🇵": "flag-japan",
  6141. "🇰🇪": "flag-kenya",
  6142. "🇰🇬": "flag-kyrgyzstan",
  6143. "🇰🇭": "flag-cambodia",
  6144. "🇰🇮": "flag-kiribati",
  6145. "🇰🇲": "flag-comoros",
  6146. "🇰🇳": "flag-st-kitts-and-nevis",
  6147. "🇰🇵": "flag-north-korea",
  6148. "🇰🇷": "flag-south-korea",
  6149. "🇰🇼": "flag-kuwait",
  6150. "🇰🇾": "flag-cayman-islands",
  6151. "🇰🇿": "flag-kazakhstan",
  6152. "🇱🇦": "flag-laos",
  6153. "🇱🇧": "flag-lebanon",
  6154. "🇱🇨": "flag-st-lucia",
  6155. "🇱🇮": "flag-liechtenstein",
  6156. "🇱🇰": "flag-sri-lanka",
  6157. "🇱🇷": "flag-liberia",
  6158. "🇱🇸": "flag-lesotho",
  6159. "🇱🇹": "flag-lithuania",
  6160. "🇱🇺": "flag-luxembourg",
  6161. "🇱🇻": "flag-latvia",
  6162. "🇱🇾": "flag-libya",
  6163. "🇲🇦": "flag-morocco",
  6164. "🇲🇨": "flag-monaco",
  6165. "🇲🇩": "flag-moldova",
  6166. "🇲🇪": "flag-montenegro",
  6167. "🇲🇫": "flag-st-martin",
  6168. "🇲🇬": "flag-madagascar",
  6169. "🇲🇭": "flag-marshall-islands",
  6170. "🇲🇰": "flag-north-macedonia",
  6171. "🇲🇱": "flag-mali",
  6172. "🇲🇲": "flag-myanmar-(burma)",
  6173. "🇲🇳": "flag-mongolia",
  6174. "🇲🇴": "flag-macao-sar-china",
  6175. "🇲🇵": "flag-northern-mariana-islands",
  6176. "🇲🇶": "flag-martinique",
  6177. "🇲🇷": "flag-mauritania",
  6178. "🇲🇸": "flag-montserrat",
  6179. "🇲🇹": "flag-malta",
  6180. "🇲🇺": "flag-mauritius",
  6181. "🇲🇻": "flag-maldives",
  6182. "🇲🇼": "flag-malawi",
  6183. "🇲🇽": "flag-mexico",
  6184. "🇲🇾": "flag-malaysia",
  6185. "🇲🇿": "flag-mozambique",
  6186. "🇳🇦": "flag-namibia",
  6187. "🇳🇨": "flag-new-caledonia",
  6188. "🇳🇪": "flag-niger",
  6189. "🇳🇫": "flag-norfolk-island",
  6190. "🇳🇬": "flag-nigeria",
  6191. "🇳🇮": "flag-nicaragua",
  6192. "🇳🇱": "flag-netherlands",
  6193. "🇳🇴": "flag-norway",
  6194. "🇳🇵": "flag-nepal",
  6195. "🇳🇷": "flag-nauru",
  6196. "🇳🇺": "flag-niue",
  6197. "🇳🇿": "flag-new-zealand",
  6198. "🇴🇲": "flag-oman",
  6199. "🇵🇦": "flag-panama",
  6200. "🇵🇪": "flag-peru",
  6201. "🇵🇫": "flag-french-polynesia",
  6202. "🇵🇬": "flag-papua-new-guinea",
  6203. "🇵🇭": "flag-philippines",
  6204. "🇵🇰": "flag-pakistan",
  6205. "🇵🇱": "flag-poland",
  6206. "🇵🇲": "flag-st-pierre-and-miquelon",
  6207. "🇵🇳": "flag-pitcairn-islands",
  6208. "🇵🇷": "flag-puerto-rico",
  6209. "🇵🇸": "flag-palestinian-territories",
  6210. "🇵🇹": "flag-portugal",
  6211. "🇵🇼": "flag-palau",
  6212. "🇵🇾": "flag-paraguay",
  6213. "🇶🇦": "flag-qatar",
  6214. "🇷🇪": "flag-reunion",
  6215. "🇷🇴": "flag-romania",
  6216. "🇷🇸": "flag-serbia",
  6217. "🇷🇺": "flag-russia",
  6218. "🇷🇼": "flag-rwanda",
  6219. "🇸🇦": "flag-saudi-arabia",
  6220. "🇸🇧": "flag-solomon-islands",
  6221. "🇸🇨": "flag-seychelles",
  6222. "🇸🇩": "flag-sudan",
  6223. "🇸🇪": "flag-sweden",
  6224. "🇸🇬": "flag-singapore",
  6225. "🇸🇭": "flag-st-helena",
  6226. "🇸🇮": "flag-slovenia",
  6227. "🇸🇯": "flag-svalbard-and-jan-mayen",
  6228. "🇸🇰": "flag-slovakia",
  6229. "🇸🇱": "flag-sierra-leone",
  6230. "🇸🇲": "flag-san-marino",
  6231. "🇸🇳": "flag-senegal",
  6232. "🇸🇴": "flag-somalia",
  6233. "🇸🇷": "flag-suriname",
  6234. "🇸🇸": "flag-south-sudan",
  6235. "🇸🇹": "flag-são-tome-and-príncipe",
  6236. "🇸🇻": "flag-el-salvador",
  6237. "🇸🇽": "flag-sint-maarten",
  6238. "🇸🇾": "flag-syria",
  6239. "🇸🇿": "flag-eswatini",
  6240. "🇹🇦": "flag-tristan-da-cunha",
  6241. "🇹🇨": "flag-turks-and-caicos-islands",
  6242. "🇹🇩": "flag-chad",
  6243. "🇹🇫": "flag-french-southern-territories",
  6244. "🇹🇬": "flag-togo",
  6245. "🇹🇭": "flag-thailand",
  6246. "🇹🇯": "flag-tajikistan",
  6247. "🇹🇰": "flag-tokelau",
  6248. "🇹🇱": "flag-timor-leste",
  6249. "🇹🇲": "flag-turkmenistan",
  6250. "🇹🇳": "flag-tunisia",
  6251. "🇹🇴": "flag-tonga",
  6252. "🇹🇷": "flag-turkey",
  6253. "🇹🇹": "flag-trinidad-and-tobago",
  6254. "🇹🇻": "flag-tuvalu",
  6255. "🇹🇼": "flag-taiwan",
  6256. "🇹🇿": "flag-tanzania",
  6257. "🇺🇦": "flag-ukraine",
  6258. "🇺🇬": "flag-uganda",
  6259. "🇺🇲": "flag-us-outlying-islands",
  6260. "🇺🇳": "flag-united-nations",
  6261. "🇺🇸": "flag-united-states",
  6262. "🇺🇾": "flag-uruguay",
  6263. "🇺🇿": "flag-uzbekistan",
  6264. "🇻🇦": "flag-vatican-city",
  6265. "🇻🇨": "flag-st-vincent-and-grenadines",
  6266. "🇻🇪": "flag-venezuela",
  6267. "🇻🇬": "flag-british-virgin-islands",
  6268. "🇻🇮": "flag-us-virgin-islands",
  6269. "🇻🇳": "flag-vietnam",
  6270. "🇻🇺": "flag-vanuatu",
  6271. "🇼🇫": "flag-wallis-and-futuna",
  6272. "🇼🇸": "flag-samoa",
  6273. "🇽🇰": "flag-kosovo",
  6274. "🇾🇪": "flag-yemen",
  6275. "🇾🇹": "flag-mayotte",
  6276. "🇿🇦": "flag-south-africa",
  6277. "🇿🇲": "flag-zambia",
  6278. "🇿🇼": "flag-zimbabwe",
  6279. "🏴󠁧󠁢󠁥󠁮󠁧󠁿": "flag-england",
  6280. "🏴󠁧󠁢󠁳󠁣󠁴󠁿": "flag-scotland",
  6281. "🏴󠁧󠁢󠁷󠁬󠁳󠁿": "flag-wales"
  6282. };
  6283. const EMOJIS = Object.keys(EMOJI_NAMES);
  6284. async function formatFilename(content, options, util) {
  6285. let filename = (await evalTemplate(options.filenameTemplate, options, util, content)) || "";
  6286. if (options.replaceEmojisInFilename) {
  6287. EMOJIS.forEach(emoji => (filename = filename.replaceAll(emoji, " _" + EMOJI_NAMES[emoji] + "_ ")));
  6288. }
  6289. const replacementCharacter = options.filenameReplacementCharacter;
  6290. filename = getValidFilename(filename, options.filenameReplacedCharacters, replacementCharacter);
  6291. if (!options.backgroundSave) {
  6292. filename = filename.replace(/\//g, replacementCharacter);
  6293. }
  6294. if (!options.keepFilename && ((options.filenameMaxLengthUnit == "bytes" && util.getContentSize(filename) > options.filenameMaxLength) || filename.length > options.filenameMaxLength)) {
  6295. const extensionMatch = filename.match(/(\.[^.]{3,4})$/);
  6296. const extension = extensionMatch && extensionMatch[0] && extensionMatch[0].length > 1 ? extensionMatch[0] : "";
  6297. filename = options.filenameMaxLengthUnit == "bytes" ? await truncateText(filename, options.filenameMaxLength - extension.length) : filename.substring(0, options.filenameMaxLength - extension.length);
  6298. filename = filename + "…" + extension;
  6299. }
  6300. if (!filename) {
  6301. filename = "Unnamed page";
  6302. }
  6303. return filename;
  6304. }
  6305. async function evalTemplate(template = "", options, util, content, dontReplaceSlash) {
  6306. const url = new URL(options.saveUrl);
  6307. template = await evalTemplateVariable(template, "page-title", () => options.title || "No title", dontReplaceSlash, options.filenameReplacementCharacter);
  6308. template = await evalTemplateVariable(template, "page-heading", () => options.info.heading || "No heading", dontReplaceSlash, options.filenameReplacementCharacter);
  6309. template = await evalTemplateVariable(template, "page-language", () => options.info.lang || "No language", dontReplaceSlash, options.filenameReplacementCharacter);
  6310. template = await evalTemplateVariable(template, "page-description", () => options.info.description || "No description", dontReplaceSlash, options.filenameReplacementCharacter);
  6311. template = await evalTemplateVariable(template, "page-author", () => options.info.author || "No author", dontReplaceSlash, options.filenameReplacementCharacter);
  6312. template = await evalTemplateVariable(template, "page-creator", () => options.info.creator || "No creator", dontReplaceSlash, options.filenameReplacementCharacter);
  6313. template = await evalTemplateVariable(template, "page-publisher", () => options.info.publisher || "No publisher", dontReplaceSlash, options.filenameReplacementCharacter);
  6314. await evalDate(options.saveDate);
  6315. await evalDate(options.visitDate, "visit-");
  6316. template = await evalTemplateVariable(template, "url-hash", () => url.hash.substring(1) || "No hash", dontReplaceSlash, options.filenameReplacementCharacter);
  6317. template = await evalTemplateVariable(template, "url-host", () => url.host.replace(/\/$/, "") || "No host", dontReplaceSlash, options.filenameReplacementCharacter);
  6318. template = await evalTemplateVariable(template, "url-hostname", () => url.hostname.replace(/\/$/, "") || "No hostname", dontReplaceSlash, options.filenameReplacementCharacter);
  6319. const urlHref = decode(url.href);
  6320. template = await evalTemplateVariable(template, "url-href", () => urlHref || "No href", dontReplaceSlash === undefined ? true : dontReplaceSlash, options.filenameReplacementCharacter);
  6321. template = await evalTemplateVariable(template, "url-href-digest-sha-1", urlHref ? async () => util.digest("SHA-1", urlHref) : "No href", dontReplaceSlash, options.filenameReplacementCharacter);
  6322. template = await evalTemplateVariable(template, "url-href-flat", () => decode(url.href) || "No href", false, options.filenameReplacementCharacter);
  6323. template = await evalTemplateVariable(template, "url-referrer", () => decode(options.referrer) || "No referrer", dontReplaceSlash === undefined ? true : dontReplaceSlash, options.filenameReplacementCharacter);
  6324. template = await evalTemplateVariable(template, "url-referrer-flat", () => decode(options.referrer) || "No referrer", false, options.filenameReplacementCharacter);
  6325. template = await evalTemplateVariable(template, "url-password", () => url.password || "No password", dontReplaceSlash, options.filenameReplacementCharacter);
  6326. template = await evalTemplateVariable(template, "url-pathname", () => decode(url.pathname).replace(/^\//, "").replace(/\/$/, "") || "No pathname", dontReplaceSlash === undefined ? true : dontReplaceSlash, options.filenameReplacementCharacter);
  6327. template = await evalTemplateVariable(template, "url-pathname-flat", () => decode(url.pathname) || "No pathname", false, options.filenameReplacementCharacter);
  6328. template = await evalTemplateVariable(template, "url-port", () => url.port || "No port", dontReplaceSlash, options.filenameReplacementCharacter);
  6329. template = await evalTemplateVariable(template, "url-protocol", () => url.protocol || "No protocol", dontReplaceSlash, options.filenameReplacementCharacter);
  6330. template = await evalTemplateVariable(template, "url-search", () => url.search.substring(1) || "No search", dontReplaceSlash, options.filenameReplacementCharacter);
  6331. const params = Array.from(new URLSearchParams(url.search));
  6332. for (const [name, value] of params) {
  6333. template = await evalTemplateVariable(template, "url-search-" + name, () => value || "", dontReplaceSlash, options.filenameReplacementCharacter);
  6334. }
  6335. template = template.replace(/{\s*url-search-[^}\s]*\s*}/gi, "");
  6336. template = await evalTemplateVariable(template, "url-username", () => url.username || "No username", dontReplaceSlash, options.filenameReplacementCharacter);
  6337. template = await evalTemplateVariable(template, "tab-id", () => String(options.tabId || "No tab id"), dontReplaceSlash, options.filenameReplacementCharacter);
  6338. template = await evalTemplateVariable(template, "tab-index", () => String(options.tabIndex || "No tab index"), dontReplaceSlash, options.filenameReplacementCharacter);
  6339. template = await evalTemplateVariable(template, "url-last-segment", () => decode(getLastSegment(url, options.filenameReplacementCharacter)) || "No last segment", dontReplaceSlash, options.filenameReplacementCharacter);
  6340. if (content) {
  6341. template = await evalTemplateVariable(template, "digest-sha-256", async () => util.digest("SHA-256", content), dontReplaceSlash, options.filenameReplacementCharacter);
  6342. template = await evalTemplateVariable(template, "digest-sha-384", async () => util.digest("SHA-384", content), dontReplaceSlash, options.filenameReplacementCharacter);
  6343. template = await evalTemplateVariable(template, "digest-sha-512", async () => util.digest("SHA-512", content), dontReplaceSlash, options.filenameReplacementCharacter);
  6344. }
  6345. const bookmarkFolder = (options.bookmarkFolders && options.bookmarkFolders.join("/")) || "";
  6346. template = await evalTemplateVariable(template, "bookmark-pathname", () => bookmarkFolder, dontReplaceSlash === undefined ? true : dontReplaceSlash, options.filenameReplacementCharacter);
  6347. template = await evalTemplateVariable(template, "bookmark-pathname-flat", () => bookmarkFolder, false, options.filenameReplacementCharacter);
  6348. template = await evalTemplateVariable(template, "profile-name", () => options.profileName, dontReplaceSlash, options.filenameReplacementCharacter);
  6349. return template.trim();
  6350. function decode(value) {
  6351. try {
  6352. return decodeURI(value);
  6353. } catch (error) {
  6354. return value;
  6355. }
  6356. }
  6357. async function evalDate(date, prefix = "") {
  6358. if (date) {
  6359. template = await evalTemplateVariable(template, prefix + "datetime-iso", () => date.toISOString(), dontReplaceSlash, options.filenameReplacementCharacter);
  6360. template = await evalTemplateVariable(template, prefix + "date-iso", () => date.toISOString().split("T")[0], dontReplaceSlash, options.filenameReplacementCharacter);
  6361. template = await evalTemplateVariable(template, prefix + "time-iso", () => date.toISOString().split("T")[1].split("Z")[0], dontReplaceSlash, options.filenameReplacementCharacter);
  6362. template = await evalTemplateVariable(template, prefix + "date-locale", () => date.toLocaleDateString(), dontReplaceSlash, options.filenameReplacementCharacter);
  6363. template = await evalTemplateVariable(template, prefix + "time-locale", () => date.toLocaleTimeString(), dontReplaceSlash, options.filenameReplacementCharacter);
  6364. template = await evalTemplateVariable(template, prefix + "day-locale", () => String(date.getDate()).padStart(2, "0"), dontReplaceSlash, options.filenameReplacementCharacter);
  6365. template = await evalTemplateVariable(template, prefix + "month-locale", () => String(date.getMonth() + 1).padStart(2, "0"), dontReplaceSlash, options.filenameReplacementCharacter);
  6366. template = await evalTemplateVariable(template, prefix + "year-locale", () => String(date.getFullYear()), dontReplaceSlash, options.filenameReplacementCharacter);
  6367. template = await evalTemplateVariable(template, prefix + "datetime-locale", () => date.toLocaleString(), dontReplaceSlash, options.filenameReplacementCharacter);
  6368. template = await evalTemplateVariable(template, prefix + "datetime-utc", () => date.toUTCString(), dontReplaceSlash, options.filenameReplacementCharacter);
  6369. template = await evalTemplateVariable(template, prefix + "day-utc", () => String(date.getUTCDate()).padStart(2, "0"), dontReplaceSlash, options.filenameReplacementCharacter);
  6370. template = await evalTemplateVariable(template, prefix + "month-utc", () => String(date.getUTCMonth() + 1).padStart(2, "0"), dontReplaceSlash, options.filenameReplacementCharacter);
  6371. template = await evalTemplateVariable(template, prefix + "year-utc", () => String(date.getUTCFullYear()), dontReplaceSlash, options.filenameReplacementCharacter);
  6372. template = await evalTemplateVariable(template, prefix + "hours-locale", () => String(date.getHours()).padStart(2, "0"), dontReplaceSlash, options.filenameReplacementCharacter);
  6373. template = await evalTemplateVariable(template, prefix + "minutes-locale", () => String(date.getMinutes()).padStart(2, "0"), dontReplaceSlash, options.filenameReplacementCharacter);
  6374. template = await evalTemplateVariable(template, prefix + "seconds-locale", () => String(date.getSeconds()).padStart(2, "0"), dontReplaceSlash, options.filenameReplacementCharacter);
  6375. template = await evalTemplateVariable(template, prefix + "hours-utc", () => String(date.getUTCHours()).padStart(2, "0"), dontReplaceSlash, options.filenameReplacementCharacter);
  6376. template = await evalTemplateVariable(template, prefix + "minutes-utc", () => String(date.getUTCMinutes()).padStart(2, "0"), dontReplaceSlash, options.filenameReplacementCharacter);
  6377. template = await evalTemplateVariable(template, prefix + "seconds-utc", () => String(date.getUTCSeconds()).padStart(2, "0"), dontReplaceSlash, options.filenameReplacementCharacter);
  6378. template = await evalTemplateVariable(template, prefix + "time-ms", () => String(date.getTime()), dontReplaceSlash, options.filenameReplacementCharacter);
  6379. }
  6380. }
  6381. async function evalTemplateVariable(template, variableName, valueGetter, dontReplaceSlash, replacementCharacter) {
  6382. let maxLength, maxCharLength;
  6383. if (template) {
  6384. const regExpVariable = "{\\s*" + variableName.replace(/\W|_/g, "[$&]") + "\\s*}";
  6385. let replaceRegExp = new RegExp(regExpVariable + "\\[\\d+(ch)?\\]", "g");
  6386. if (template.match(replaceRegExp)) {
  6387. const matchedLength = template.match(replaceRegExp)[0];
  6388. if (matchedLength.match(/\[(\d+)\]$/)) {
  6389. maxLength = Number(matchedLength.match(/\[(\d+)\]$/)[1]);
  6390. if (isNaN(maxLength) || maxLength <= 0) {
  6391. maxLength = null;
  6392. }
  6393. } else {
  6394. maxCharLength = Number(matchedLength.match(/\[(\d+)ch\]$/)[1]);
  6395. if (isNaN(maxCharLength) || maxCharLength <= 0) {
  6396. maxCharLength = null;
  6397. }
  6398. }
  6399. } else {
  6400. replaceRegExp = new RegExp(regExpVariable, "g");
  6401. }
  6402. if (template.match(replaceRegExp)) {
  6403. let value = await valueGetter();
  6404. if (!dontReplaceSlash) {
  6405. value = value.replace(/\/+/g, replacementCharacter);
  6406. }
  6407. if (maxLength) {
  6408. value = await truncateText(value, maxLength);
  6409. } else if (maxCharLength) {
  6410. value = value.substring(0, maxCharLength);
  6411. }
  6412. return template.replace(replaceRegExp, value);
  6413. }
  6414. }
  6415. return template;
  6416. }
  6417. }
  6418. function getLastSegment(url, replacementCharacter) {
  6419. let lastSegmentMatch = url.pathname.match(/\/([^/]+)$/),
  6420. lastSegment = lastSegmentMatch && lastSegmentMatch[0];
  6421. if (!lastSegment) {
  6422. lastSegmentMatch = url.href.match(/([^/]+)\/?$/);
  6423. lastSegment = lastSegmentMatch && lastSegmentMatch[0];
  6424. }
  6425. if (!lastSegment) {
  6426. lastSegmentMatch = lastSegment.match(/(.*)\.[^.]+$/);
  6427. lastSegment = lastSegmentMatch && lastSegmentMatch[0];
  6428. }
  6429. if (!lastSegment) {
  6430. lastSegment = url.hostname.replace(/\/+/g, replacementCharacter).replace(/\/$/, "");
  6431. }
  6432. lastSegmentMatch = lastSegment.match(/(.*)\.[^.]+$/);
  6433. if (lastSegmentMatch && lastSegmentMatch[1]) {
  6434. lastSegment = lastSegmentMatch[1];
  6435. }
  6436. lastSegment = lastSegment.replace(/\/$/, "").replace(/^\//, "");
  6437. return lastSegment;
  6438. }
  6439. function getValidFilename(filename, replacedCharacters = DEFAULT_REPLACED_CHARACTERS$1, replacementCharacter = DEFAULT_REPLACEMENT_CHARACTER$1) {
  6440. replacedCharacters.forEach(replacedCharacter => (filename = filename.replace(new RegExp("[" + replacedCharacter + "]+", "g"), replacementCharacter)));
  6441. filename = filename
  6442. .replace(/\.\.\//g, "")
  6443. .replace(/^\/+/, "")
  6444. .replace(/\/+/g, "/")
  6445. .replace(/\/$/, "")
  6446. .replace(/\.$/, "")
  6447. .replace(/\.\//g, "." + replacementCharacter)
  6448. .replace(/\/\./g, "/" + replacementCharacter);
  6449. return filename;
  6450. }
  6451. function truncateText(content, maxSize) {
  6452. const blob = new Blob([content]);
  6453. const reader = new FileReader();
  6454. reader.readAsText(blob.slice(0, maxSize));
  6455. return new Promise((resolve, reject) => {
  6456. reader.addEventListener(
  6457. "load",
  6458. () => {
  6459. if (content.startsWith(reader.result)) {
  6460. resolve(reader.result);
  6461. } else {
  6462. truncateText(content, maxSize - 1)
  6463. .then(resolve)
  6464. .catch(reject);
  6465. }
  6466. },
  6467. false
  6468. );
  6469. reader.addEventListener("error", reject, false);
  6470. });
  6471. }
  6472. /*
  6473. * Copyright 2010-2022 Gildas Lormeau
  6474. * contact : gildas.lormeau <at> gmail.com
  6475. *
  6476. * This file is part of SingleFile.
  6477. *
  6478. * The code in this file is free software: you can redistribute it and/or
  6479. * modify it under the terms of the GNU Affero General Public License
  6480. * (GNU AGPL) as published by the Free Software Foundation, either version 3
  6481. * of the License, or (at your option) any later version.
  6482. *
  6483. * The code in this file is distributed in the hope that it will be useful,
  6484. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  6485. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
  6486. * General Public License for more details.
  6487. *
  6488. * As additional permission under GNU AGPL version 3 section 7, you may
  6489. * distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU
  6490. * AGPL normally required by section 4, provided you include this license
  6491. * notice and a URL through which recipients can access the Corresponding
  6492. * Source.
  6493. */
  6494. const DEBUG = false;
  6495. const ONE_MB = 1024 * 1024;
  6496. const PREFIX_CONTENT_TYPE_TEXT = "text/";
  6497. const DEFAULT_REPLACED_CHARACTERS = ["~", "+", "\\\\", "?", "%", "*", ":", "|", "\"", "<", ">", "\x00-\x1f", "\x7F"];
  6498. const DEFAULT_REPLACEMENT_CHARACTER = "_";
  6499. const CONTENT_TYPE_EXTENSIONS = {
  6500. "image/svg+xml": ".svg",
  6501. "image/png": ".png",
  6502. "image/jpeg": ".jpg",
  6503. "image/gif": ".gif",
  6504. "image/webp": ".webp"
  6505. };
  6506. const URL$1 = globalThis.URL;
  6507. const DOMParser = globalThis.DOMParser;
  6508. const Blob$1 = globalThis.Blob;
  6509. const FileReader$1 = globalThis.FileReader;
  6510. const fetch = (url, options) => globalThis.fetch(url, options);
  6511. const crypto = globalThis.crypto;
  6512. const TextDecoder = globalThis.TextDecoder;
  6513. const TextEncoder = globalThis.TextEncoder;
  6514. function getInstance(utilOptions) {
  6515. utilOptions = utilOptions || {};
  6516. utilOptions.fetch = utilOptions.fetch || fetch;
  6517. utilOptions.frameFetch = utilOptions.frameFetch || utilOptions.fetch || fetch;
  6518. return {
  6519. getDoctypeString,
  6520. getFilenameExtension(resourceURL, replacedCharacters, replacementCharacter) {
  6521. const matchExtension = new URL$1(resourceURL).pathname.match(/(\.[^\\/.]*)$/);
  6522. return ((matchExtension && matchExtension[1] && this.getValidFilename(matchExtension[1], replacedCharacters, replacementCharacter)) || "").toLowerCase();
  6523. },
  6524. getContentTypeExtension(contentType) {
  6525. return CONTENT_TYPE_EXTENSIONS[contentType] || "";
  6526. },
  6527. getContent,
  6528. parseURL(resourceURL, baseURI) {
  6529. if (baseURI === undefined) {
  6530. return new URL$1(resourceURL);
  6531. } else {
  6532. return new URL$1(resourceURL, baseURI);
  6533. }
  6534. },
  6535. resolveURL(resourceURL, baseURI) {
  6536. return this.parseURL(resourceURL, baseURI).href;
  6537. },
  6538. getSearchParams(searchParams) {
  6539. return Array.from(new URLSearchParams(searchParams));
  6540. },
  6541. getValidFilename(filename, replacedCharacters = DEFAULT_REPLACED_CHARACTERS, replacementCharacter = DEFAULT_REPLACEMENT_CHARACTER) {
  6542. replacedCharacters.forEach(replacedCharacter => filename = filename.replace(new RegExp("[" + replacedCharacter + "]+", "g"), replacementCharacter));
  6543. filename = filename
  6544. .replace(/\.\.\//g, "")
  6545. .replace(/^\/+/, "")
  6546. .replace(/\/+/g, "/")
  6547. .replace(/\/$/, "")
  6548. .replace(/\.$/, "")
  6549. .replace(/\.\//g, "." + replacementCharacter)
  6550. .replace(/\/\./g, "/" + replacementCharacter);
  6551. return filename;
  6552. },
  6553. parseDocContent(content, baseURI) {
  6554. const doc = (new DOMParser()).parseFromString(content, "text/html");
  6555. if (!doc.head) {
  6556. doc.documentElement.insertBefore(doc.createElement("HEAD"), doc.body);
  6557. }
  6558. let baseElement = doc.querySelector("base");
  6559. if (!baseElement || !baseElement.getAttribute("href")) {
  6560. if (baseElement) {
  6561. baseElement.remove();
  6562. }
  6563. baseElement = doc.createElement("base");
  6564. baseElement.setAttribute("href", baseURI);
  6565. doc.head.insertBefore(baseElement, doc.head.firstChild);
  6566. }
  6567. return doc;
  6568. },
  6569. parseXMLContent(content) {
  6570. return (new DOMParser()).parseFromString(content, "text/xml");
  6571. },
  6572. parseSVGContent(content) {
  6573. const doc = (new DOMParser()).parseFromString(content, "image/svg+xml");
  6574. if (doc.querySelector("parsererror")) {
  6575. return (new DOMParser()).parseFromString(content, "text/html");
  6576. } else {
  6577. return doc;
  6578. }
  6579. },
  6580. async digest(algo, text) {
  6581. try {
  6582. const hash = await crypto.subtle.digest(algo, new TextEncoder("utf-8").encode(text));
  6583. return hex(hash);
  6584. } catch (error) {
  6585. return "";
  6586. }
  6587. },
  6588. getContentSize(content) {
  6589. return new Blob$1([content]).size;
  6590. },
  6591. formatFilename(content, options) {
  6592. return formatFilename(content, options, this);
  6593. },
  6594. evalTemplate(template, options, content, dontReplaceSlash) {
  6595. return evalTemplate(template, options, this, content, dontReplaceSlash);
  6596. },
  6597. minifyHTML(doc, options) {
  6598. return process(doc, options);
  6599. },
  6600. minifyCSSRules(stylesheets, styles, mediaAllInfo) {
  6601. return process$2(stylesheets, styles, mediaAllInfo);
  6602. },
  6603. removeUnusedFonts(doc, stylesheets, styles, options) {
  6604. return process$4(doc, stylesheets, styles, options);
  6605. },
  6606. getMediaAllInfo(doc, stylesheets, styles) {
  6607. return getMediaAllInfo(doc, stylesheets, styles);
  6608. },
  6609. compressCSS(content, options) {
  6610. return processString(content, options);
  6611. },
  6612. minifyMedias(stylesheets) {
  6613. return process$3(stylesheets);
  6614. },
  6615. removeAlternativeImages(doc) {
  6616. return process$1(doc);
  6617. },
  6618. parseSrcset(srcset) {
  6619. return process$5(srcset);
  6620. },
  6621. preProcessDoc(doc, win, options) {
  6622. return preProcessDoc(doc, win, options);
  6623. },
  6624. postProcessDoc(doc, markedElements, invalidElements) {
  6625. postProcessDoc(doc, markedElements, invalidElements);
  6626. },
  6627. serialize(doc, compressHTML) {
  6628. return process$7(doc, compressHTML);
  6629. },
  6630. removeQuotes(string) {
  6631. return removeQuotes(string);
  6632. },
  6633. appendInfobar(doc, options) {
  6634. return appendInfobar(doc, options);
  6635. },
  6636. ON_BEFORE_CAPTURE_EVENT_NAME: ON_BEFORE_CAPTURE_EVENT_NAME,
  6637. ON_AFTER_CAPTURE_EVENT_NAME: ON_AFTER_CAPTURE_EVENT_NAME,
  6638. WIN_ID_ATTRIBUTE_NAME: WIN_ID_ATTRIBUTE_NAME,
  6639. REMOVED_CONTENT_ATTRIBUTE_NAME: REMOVED_CONTENT_ATTRIBUTE_NAME,
  6640. HIDDEN_CONTENT_ATTRIBUTE_NAME: HIDDEN_CONTENT_ATTRIBUTE_NAME,
  6641. HIDDEN_FRAME_ATTRIBUTE_NAME: HIDDEN_FRAME_ATTRIBUTE_NAME,
  6642. IMAGE_ATTRIBUTE_NAME: IMAGE_ATTRIBUTE_NAME,
  6643. POSTER_ATTRIBUTE_NAME: POSTER_ATTRIBUTE_NAME,
  6644. VIDEO_ATTRIBUTE_NAME: VIDEO_ATTRIBUTE_NAME,
  6645. CANVAS_ATTRIBUTE_NAME: CANVAS_ATTRIBUTE_NAME,
  6646. STYLE_ATTRIBUTE_NAME: STYLE_ATTRIBUTE_NAME,
  6647. INPUT_VALUE_ATTRIBUTE_NAME: INPUT_VALUE_ATTRIBUTE_NAME,
  6648. SHADOW_ROOT_ATTRIBUTE_NAME: SHADOW_ROOT_ATTRIBUTE_NAME,
  6649. PRESERVED_SPACE_ELEMENT_ATTRIBUTE_NAME: PRESERVED_SPACE_ELEMENT_ATTRIBUTE_NAME,
  6650. STYLESHEET_ATTRIBUTE_NAME: STYLESHEET_ATTRIBUTE_NAME,
  6651. SELECTED_CONTENT_ATTRIBUTE_NAME: SELECTED_CONTENT_ATTRIBUTE_NAME,
  6652. INVALID_ELEMENT_ATTRIBUTE_NAME: INVALID_ELEMENT_ATTRIBUTE_NAME,
  6653. COMMENT_HEADER: COMMENT_HEADER,
  6654. COMMENT_HEADER_LEGACY: COMMENT_HEADER_LEGACY,
  6655. SINGLE_FILE_UI_ELEMENT_CLASS: SINGLE_FILE_UI_ELEMENT_CLASS,
  6656. EMPTY_RESOURCE: EMPTY_RESOURCE$1,
  6657. INFOBAR_TAGNAME: INFOBAR_TAGNAME,
  6658. WAIT_FOR_USERSCRIPT_PROPERTY_NAME: WAIT_FOR_USERSCRIPT_PROPERTY_NAME,
  6659. NO_SCRIPT_PROPERTY_NAME: NO_SCRIPT_PROPERTY_NAME
  6660. };
  6661. async function getContent(resourceURL, options) {
  6662. let response, startTime, networkTimeoutId, networkTimeoutPromise, resolveNetworkTimeoutPromise;
  6663. const fetchResource = utilOptions.fetch;
  6664. const fetchFrameResource = utilOptions.frameFetch;
  6665. if (options.blockMixedContent && /^https:/i.test(options.baseURI) && !/^https:/i.test(resourceURL)) {
  6666. return getFetchResponse(resourceURL, options);
  6667. }
  6668. if (options.networkTimeout) {
  6669. networkTimeoutPromise = new Promise((resolve, reject) => {
  6670. resolveNetworkTimeoutPromise = resolve;
  6671. networkTimeoutId = globalThis.setTimeout(() => reject(new Error("network timeout")), options.networkTimeout);
  6672. });
  6673. } else {
  6674. networkTimeoutPromise = new Promise(resolve => {
  6675. resolveNetworkTimeoutPromise = resolve;
  6676. });
  6677. }
  6678. try {
  6679. const accept = options.acceptHeaders ? options.acceptHeaders[options.expectedType] : "*/*";
  6680. if (options.frameId) {
  6681. try {
  6682. response = await Promise.race([
  6683. fetchFrameResource(resourceURL, { frameId: options.frameId, referrer: options.resourceReferrer, headers: { accept } }),
  6684. networkTimeoutPromise
  6685. ]);
  6686. } catch (error) {
  6687. response = await Promise.race([
  6688. fetchResource(resourceURL, { headers: { accept } }),
  6689. networkTimeoutPromise
  6690. ]);
  6691. }
  6692. } else {
  6693. response = await Promise.race([
  6694. fetchResource(resourceURL, { referrer: options.resourceReferrer, headers: { accept } }),
  6695. networkTimeoutPromise
  6696. ]);
  6697. }
  6698. } catch (error) {
  6699. return getFetchResponse(resourceURL, options);
  6700. } finally {
  6701. resolveNetworkTimeoutPromise();
  6702. if (options.networkTimeout) {
  6703. globalThis.clearTimeout(networkTimeoutId);
  6704. }
  6705. }
  6706. let buffer;
  6707. try {
  6708. buffer = await response.arrayBuffer();
  6709. } catch (error) {
  6710. return options.inline ? { data: options.asBinary ? EMPTY_RESOURCE$1 : "", resourceURL } : { resourceURL };
  6711. }
  6712. resourceURL = response.url || resourceURL;
  6713. let contentType = "", charset;
  6714. try {
  6715. const mimeType = new MIMEType(response.headers.get("content-type"));
  6716. contentType = mimeType.type + "/" + mimeType.subtype;
  6717. charset = mimeType.parameters.get("charset");
  6718. } catch (error) {
  6719. // ignored
  6720. }
  6721. if (!contentType) {
  6722. contentType = guessMIMEType(options.expectedType, buffer);
  6723. }
  6724. if (!charset && options.charset) {
  6725. charset = options.charset;
  6726. }
  6727. if (options.asBinary) {
  6728. if (response.status >= 400) {
  6729. return getFetchResponse(resourceURL, options);
  6730. }
  6731. try {
  6732. if (DEBUG) ;
  6733. if (options.maxResourceSizeEnabled && buffer.byteLength > options.maxResourceSize * ONE_MB) {
  6734. return getFetchResponse(resourceURL, options);
  6735. } else {
  6736. return getFetchResponse(resourceURL, options, buffer, null, contentType);
  6737. }
  6738. } catch (error) {
  6739. return getFetchResponse(resourceURL, options);
  6740. }
  6741. } else {
  6742. if (response.status >= 400 || (options.validateTextContentType && contentType && !contentType.startsWith(PREFIX_CONTENT_TYPE_TEXT))) {
  6743. return getFetchResponse(resourceURL, options);
  6744. }
  6745. if (!charset) {
  6746. charset = "utf-8";
  6747. }
  6748. if (options.maxResourceSizeEnabled && buffer.byteLength > options.maxResourceSize * ONE_MB) {
  6749. return getFetchResponse(resourceURL, options, null, charset);
  6750. } else {
  6751. try {
  6752. return getFetchResponse(resourceURL, options, buffer, charset, contentType);
  6753. } catch (error) {
  6754. return getFetchResponse(resourceURL, options, null, charset);
  6755. }
  6756. }
  6757. }
  6758. }
  6759. }
  6760. async function getFetchResponse(resourceURL, options, data, charset, contentType) {
  6761. if (data) {
  6762. if (options.asBinary) {
  6763. if (options.inline) {
  6764. const reader = new FileReader$1();
  6765. reader.readAsDataURL(new Blob$1([data], { type: contentType + (options.charset ? ";charset=" + options.charset : "") }));
  6766. data = await new Promise((resolve, reject) => {
  6767. reader.addEventListener("load", () => resolve(reader.result), false);
  6768. reader.addEventListener("error", reject, false);
  6769. });
  6770. } else {
  6771. data = new Uint8Array(data);
  6772. }
  6773. } else {
  6774. const firstBytes = new Uint8Array(data.slice(0, 4));
  6775. if (firstBytes[0] == 132 && firstBytes[1] == 49 && firstBytes[2] == 149 && firstBytes[3] == 51) {
  6776. charset = "gb18030";
  6777. } else if (firstBytes[0] == 255 && firstBytes[1] == 254) {
  6778. charset = "utf-16le";
  6779. } else if (firstBytes[0] == 254 && firstBytes[1] == 255) {
  6780. charset = "utf-16be";
  6781. }
  6782. try {
  6783. data = new TextDecoder(charset).decode(data);
  6784. } catch (error) {
  6785. charset = "utf-8";
  6786. data = new TextDecoder(charset).decode(data);
  6787. }
  6788. data = data.replace(/\ufeff/gi, "");
  6789. }
  6790. } else if (options.inline) {
  6791. data = options.asBinary ? EMPTY_RESOURCE$1 : "";
  6792. }
  6793. return { data, resourceURL, charset, contentType };
  6794. }
  6795. function guessMIMEType(expectedType, buffer) {
  6796. if (expectedType == "image") {
  6797. if (compareBytes([255, 255, 255, 255], [0, 0, 1, 0])) {
  6798. return "image/x-icon";
  6799. }
  6800. if (compareBytes([255, 255, 255, 255], [0, 0, 2, 0])) {
  6801. return "image/x-icon";
  6802. }
  6803. if (compareBytes([255, 255], [78, 77])) {
  6804. return "image/bmp";
  6805. }
  6806. if (compareBytes([255, 255, 255, 255, 255, 255], [71, 73, 70, 56, 57, 97])) {
  6807. return "image/gif";
  6808. }
  6809. if (compareBytes([255, 255, 255, 255, 255, 255], [71, 73, 70, 56, 59, 97])) {
  6810. return "image/gif";
  6811. }
  6812. if (compareBytes([255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255], [82, 73, 70, 70, 0, 0, 0, 0, 87, 69, 66, 80, 86, 80])) {
  6813. return "image/webp";
  6814. }
  6815. if (compareBytes([255, 255, 255, 255, 255, 255, 255, 255], [137, 80, 78, 71, 13, 10, 26, 10])) {
  6816. return "image/png";
  6817. }
  6818. if (compareBytes([255, 255, 255], [255, 216, 255])) {
  6819. return "image/jpeg";
  6820. }
  6821. }
  6822. if (expectedType == "font") {
  6823. if (compareBytes([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255],
  6824. [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 76, 80])) {
  6825. return "application/vnd.ms-fontobject";
  6826. }
  6827. if (compareBytes([255, 255, 255, 255], [0, 1, 0, 0])) {
  6828. return "font/ttf";
  6829. }
  6830. if (compareBytes([255, 255, 255, 255], [79, 84, 84, 79])) {
  6831. return "font/otf";
  6832. }
  6833. if (compareBytes([255, 255, 255, 255], [116, 116, 99, 102])) {
  6834. return "font/collection";
  6835. }
  6836. if (compareBytes([255, 255, 255, 255], [119, 79, 70, 70])) {
  6837. return "font/woff";
  6838. }
  6839. if (compareBytes([255, 255, 255, 255], [119, 79, 70, 50])) {
  6840. return "font/woff2";
  6841. }
  6842. }
  6843. function compareBytes(mask, pattern) {
  6844. let patternMatch = true, index = 0;
  6845. if (buffer.byteLength >= pattern.length) {
  6846. const value = new Uint8Array(buffer, 0, mask.length);
  6847. for (index = 0; index < mask.length && patternMatch; index++) {
  6848. patternMatch = patternMatch && ((value[index] & mask[index]) == pattern[index]);
  6849. }
  6850. return patternMatch;
  6851. }
  6852. }
  6853. }
  6854. // https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
  6855. function hex(buffer) {
  6856. const hexCodes = [];
  6857. const view = new DataView(buffer);
  6858. for (let i = 0; i < view.byteLength; i += 4) {
  6859. const value = view.getUint32(i);
  6860. const stringValue = value.toString(16);
  6861. const padding = "00000000";
  6862. const paddedValue = (padding + stringValue).slice(-padding.length);
  6863. hexCodes.push(paddedValue);
  6864. }
  6865. return hexCodes.join("");
  6866. }
  6867. function getDoctypeString(doc) {
  6868. const docType = doc.doctype;
  6869. let docTypeString = "";
  6870. if (docType) {
  6871. docTypeString = "<!DOCTYPE " + docType.nodeName;
  6872. if (docType.publicId) {
  6873. docTypeString += " PUBLIC \"" + docType.publicId + "\"";
  6874. if (docType.systemId)
  6875. docTypeString += " \"" + docType.systemId + "\"";
  6876. } else if (docType.systemId)
  6877. docTypeString += " SYSTEM \"" + docType.systemId + "\"";
  6878. if (docType.internalSubset)
  6879. docTypeString += " [" + docType.internalSubset + "]";
  6880. docTypeString += "> ";
  6881. }
  6882. return docTypeString;
  6883. }
  6884. function log(...args) {
  6885. console.log("S-File <browser>", ...args); // eslint-disable-line no-console
  6886. }
  6887. /*
  6888. * Copyright 2010-2020 Gildas Lormeau
  6889. * contact : gildas.lormeau <at> gmail.com
  6890. *
  6891. * This file is part of SingleFile.
  6892. *
  6893. * The code in this file is free software: you can redistribute it and/or
  6894. * modify it under the terms of the GNU Affero General Public License
  6895. * (GNU AGPL) as published by the Free Software Foundation, either version 3
  6896. * of the License, or (at your option) any later version.
  6897. *
  6898. * The code in this file is distributed in the hope that it will be useful,
  6899. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  6900. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
  6901. * General Public License for more details.
  6902. *
  6903. * As additional permission under GNU AGPL version 3 section 7, you may
  6904. * distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU
  6905. * AGPL normally required by section 4, provided you include this license
  6906. * notice and a URL through which recipients can access the Corresponding
  6907. * Source.
  6908. */
  6909. const util = getInstance();
  6910. const helper = {
  6911. serialize(doc, compressHTML) {
  6912. return process$7(doc, compressHTML);
  6913. },
  6914. getDoctypeString(doc) {
  6915. return util.getDoctypeString(doc);
  6916. },
  6917. appendInfobar(doc, options, useShadowRoot) {
  6918. return appendInfobar$1(doc, options, useShadowRoot);
  6919. },
  6920. extractInfobarData(doc) {
  6921. return extractInfobarData(doc);
  6922. },
  6923. displayIcon(doc, useShadowRoot) {
  6924. return displayIcon(doc, useShadowRoot);
  6925. },
  6926. INFOBAR_TAGNAME: INFOBAR_TAGNAME$1
  6927. };
  6928. exports.helper = helper;
  6929. Object.defineProperty(exports, '__esModule', { value: true });
  6930. }));