mdc.slider.js 295 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969
  1. /**
  2. * @license
  3. * Copyright Google LLC All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://github.com/material-components/material-components-web/blob/master/LICENSE
  7. */
  8. (function webpackUniversalModuleDefinition(root, factory) {
  9. if(typeof exports === 'object' && typeof module === 'object')
  10. module.exports = factory();
  11. else if(typeof define === 'function' && define.amd)
  12. define("@material/slider", [], factory);
  13. else if(typeof exports === 'object')
  14. exports["slider"] = factory();
  15. else
  16. root["mdc"] = root["mdc"] || {}, root["mdc"]["slider"] = factory();
  17. })(this, function() {
  18. return /******/ (function(modules) { // webpackBootstrap
  19. /******/ // The module cache
  20. /******/ var installedModules = {};
  21. /******/
  22. /******/ // The require function
  23. /******/ function __webpack_require__(moduleId) {
  24. /******/
  25. /******/ // Check if module is in cache
  26. /******/ if(installedModules[moduleId]) {
  27. /******/ return installedModules[moduleId].exports;
  28. /******/ }
  29. /******/ // Create a new module (and put it into the cache)
  30. /******/ var module = installedModules[moduleId] = {
  31. /******/ i: moduleId,
  32. /******/ l: false,
  33. /******/ exports: {}
  34. /******/ };
  35. /******/
  36. /******/ // Execute the module function
  37. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  38. /******/
  39. /******/ // Flag the module as loaded
  40. /******/ module.l = true;
  41. /******/
  42. /******/ // Return the exports of the module
  43. /******/ return module.exports;
  44. /******/ }
  45. /******/
  46. /******/
  47. /******/ // expose the modules object (__webpack_modules__)
  48. /******/ __webpack_require__.m = modules;
  49. /******/
  50. /******/ // expose the module cache
  51. /******/ __webpack_require__.c = installedModules;
  52. /******/
  53. /******/ // define getter function for harmony exports
  54. /******/ __webpack_require__.d = function(exports, name, getter) {
  55. /******/ if(!__webpack_require__.o(exports, name)) {
  56. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  57. /******/ }
  58. /******/ };
  59. /******/
  60. /******/ // define __esModule on exports
  61. /******/ __webpack_require__.r = function(exports) {
  62. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  63. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  64. /******/ }
  65. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  66. /******/ };
  67. /******/
  68. /******/ // create a fake namespace object
  69. /******/ // mode & 1: value is a module id, require it
  70. /******/ // mode & 2: merge all properties of value into the ns
  71. /******/ // mode & 4: return value when already ns object
  72. /******/ // mode & 8|1: behave like require
  73. /******/ __webpack_require__.t = function(value, mode) {
  74. /******/ if(mode & 1) value = __webpack_require__(value);
  75. /******/ if(mode & 8) return value;
  76. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  77. /******/ var ns = Object.create(null);
  78. /******/ __webpack_require__.r(ns);
  79. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  80. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  81. /******/ return ns;
  82. /******/ };
  83. /******/
  84. /******/ // getDefaultExport function for compatibility with non-harmony modules
  85. /******/ __webpack_require__.n = function(module) {
  86. /******/ var getter = module && module.__esModule ?
  87. /******/ function getDefault() { return module['default']; } :
  88. /******/ function getModuleExports() { return module; };
  89. /******/ __webpack_require__.d(getter, 'a', getter);
  90. /******/ return getter;
  91. /******/ };
  92. /******/
  93. /******/ // Object.prototype.hasOwnProperty.call
  94. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  95. /******/
  96. /******/ // __webpack_public_path__
  97. /******/ __webpack_require__.p = "";
  98. /******/
  99. /******/
  100. /******/ // Load entry module and return exports
  101. /******/ return __webpack_require__(__webpack_require__.s = "./packages/mdc-slider/index.ts");
  102. /******/ })
  103. /************************************************************************/
  104. /******/ ({
  105. /***/ "./node_modules/process/browser.js":
  106. /*!*****************************************!*\
  107. !*** ./node_modules/process/browser.js ***!
  108. \*****************************************/
  109. /*! no static exports found */
  110. /***/ (function(module, exports) {
  111. // shim for using process in browser
  112. var process = module.exports = {};
  113. // cached from whatever global is present so that test runners that stub it
  114. // don't break things. But we need to wrap it in a try catch in case it is
  115. // wrapped in strict mode code which doesn't define any globals. It's inside a
  116. // function because try/catches deoptimize in certain engines.
  117. var cachedSetTimeout;
  118. var cachedClearTimeout;
  119. function defaultSetTimout() {
  120. throw new Error('setTimeout has not been defined');
  121. }
  122. function defaultClearTimeout () {
  123. throw new Error('clearTimeout has not been defined');
  124. }
  125. (function () {
  126. try {
  127. if (typeof setTimeout === 'function') {
  128. cachedSetTimeout = setTimeout;
  129. } else {
  130. cachedSetTimeout = defaultSetTimout;
  131. }
  132. } catch (e) {
  133. cachedSetTimeout = defaultSetTimout;
  134. }
  135. try {
  136. if (typeof clearTimeout === 'function') {
  137. cachedClearTimeout = clearTimeout;
  138. } else {
  139. cachedClearTimeout = defaultClearTimeout;
  140. }
  141. } catch (e) {
  142. cachedClearTimeout = defaultClearTimeout;
  143. }
  144. } ())
  145. function runTimeout(fun) {
  146. if (cachedSetTimeout === setTimeout) {
  147. //normal enviroments in sane situations
  148. return setTimeout(fun, 0);
  149. }
  150. // if setTimeout wasn't available but was latter defined
  151. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  152. cachedSetTimeout = setTimeout;
  153. return setTimeout(fun, 0);
  154. }
  155. try {
  156. // when when somebody has screwed with setTimeout but no I.E. maddness
  157. return cachedSetTimeout(fun, 0);
  158. } catch(e){
  159. try {
  160. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  161. return cachedSetTimeout.call(null, fun, 0);
  162. } catch(e){
  163. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  164. return cachedSetTimeout.call(this, fun, 0);
  165. }
  166. }
  167. }
  168. function runClearTimeout(marker) {
  169. if (cachedClearTimeout === clearTimeout) {
  170. //normal enviroments in sane situations
  171. return clearTimeout(marker);
  172. }
  173. // if clearTimeout wasn't available but was latter defined
  174. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  175. cachedClearTimeout = clearTimeout;
  176. return clearTimeout(marker);
  177. }
  178. try {
  179. // when when somebody has screwed with setTimeout but no I.E. maddness
  180. return cachedClearTimeout(marker);
  181. } catch (e){
  182. try {
  183. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  184. return cachedClearTimeout.call(null, marker);
  185. } catch (e){
  186. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  187. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  188. return cachedClearTimeout.call(this, marker);
  189. }
  190. }
  191. }
  192. var queue = [];
  193. var draining = false;
  194. var currentQueue;
  195. var queueIndex = -1;
  196. function cleanUpNextTick() {
  197. if (!draining || !currentQueue) {
  198. return;
  199. }
  200. draining = false;
  201. if (currentQueue.length) {
  202. queue = currentQueue.concat(queue);
  203. } else {
  204. queueIndex = -1;
  205. }
  206. if (queue.length) {
  207. drainQueue();
  208. }
  209. }
  210. function drainQueue() {
  211. if (draining) {
  212. return;
  213. }
  214. var timeout = runTimeout(cleanUpNextTick);
  215. draining = true;
  216. var len = queue.length;
  217. while(len) {
  218. currentQueue = queue;
  219. queue = [];
  220. while (++queueIndex < len) {
  221. if (currentQueue) {
  222. currentQueue[queueIndex].run();
  223. }
  224. }
  225. queueIndex = -1;
  226. len = queue.length;
  227. }
  228. currentQueue = null;
  229. draining = false;
  230. runClearTimeout(timeout);
  231. }
  232. process.nextTick = function (fun) {
  233. var args = new Array(arguments.length - 1);
  234. if (arguments.length > 1) {
  235. for (var i = 1; i < arguments.length; i++) {
  236. args[i - 1] = arguments[i];
  237. }
  238. }
  239. queue.push(new Item(fun, args));
  240. if (queue.length === 1 && !draining) {
  241. runTimeout(drainQueue);
  242. }
  243. };
  244. // v8 likes predictible objects
  245. function Item(fun, array) {
  246. this.fun = fun;
  247. this.array = array;
  248. }
  249. Item.prototype.run = function () {
  250. this.fun.apply(null, this.array);
  251. };
  252. process.title = 'browser';
  253. process.browser = true;
  254. process.env = {};
  255. process.argv = [];
  256. process.version = ''; // empty string to avoid regexp issues
  257. process.versions = {};
  258. function noop() {}
  259. process.on = noop;
  260. process.addListener = noop;
  261. process.once = noop;
  262. process.off = noop;
  263. process.removeListener = noop;
  264. process.removeAllListeners = noop;
  265. process.emit = noop;
  266. process.prependListener = noop;
  267. process.prependOnceListener = noop;
  268. process.listeners = function (name) { return [] }
  269. process.binding = function (name) {
  270. throw new Error('process.binding is not supported');
  271. };
  272. process.cwd = function () { return '/' };
  273. process.chdir = function (dir) {
  274. throw new Error('process.chdir is not supported');
  275. };
  276. process.umask = function() { return 0; };
  277. /***/ }),
  278. /***/ "./node_modules/safevalues/builders/attribute_builders.js":
  279. /*!****************************************************************!*\
  280. !*** ./node_modules/safevalues/builders/attribute_builders.js ***!
  281. \****************************************************************/
  282. /*! no static exports found */
  283. /***/ (function(module, exports, __webpack_require__) {
  284. "use strict";
  285. /**
  286. * @license
  287. * SPDX-License-Identifier: Apache-2.0
  288. */
  289. Object.defineProperty(exports, "__esModule", { value: true });
  290. exports.safeAttrPrefix = void 0;
  291. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  292. var attribute_impl_1 = __webpack_require__(/*! ../internals/attribute_impl */ "./node_modules/safevalues/internals/attribute_impl.js");
  293. var string_literal_1 = __webpack_require__(/*! ../internals/string_literal */ "./node_modules/safevalues/internals/string_literal.js");
  294. var sensitive_attributes_1 = __webpack_require__(/*! ./sensitive_attributes */ "./node_modules/safevalues/builders/sensitive_attributes.js");
  295. /**
  296. * Creates a SafeAttributePrefix object from a template literal with no
  297. * interpolations for attributes that share a common prefix guaranteed to be not
  298. * security sensitive.
  299. *
  300. * The template literal is a prefix that makes it obvious this attribute is not
  301. * security sensitive. If it doesn't, this function will throw.
  302. */
  303. function safeAttrPrefix(templ) {
  304. if (true) {
  305. (0, string_literal_1.assertIsTemplateObject)(templ, true, 'safeAttr is a template literal tag function ' +
  306. 'and should be called using the tagged template syntax. ' +
  307. 'For example, safeAttr`foo`;');
  308. }
  309. var attrPrefix = templ[0].toLowerCase();
  310. if (true) {
  311. if (attrPrefix.indexOf('on') === 0 || 'on'.indexOf(attrPrefix) === 0) {
  312. throw new Error("Prefix '".concat(templ[0], "' does not guarantee the attribute ") +
  313. "to be safe as it is also a prefix for event handler attributes" +
  314. "Please use 'addEventListener' to set event handlers.");
  315. }
  316. sensitive_attributes_1.SECURITY_SENSITIVE_ATTRIBUTES.forEach(function (sensitiveAttr) {
  317. if (sensitiveAttr.indexOf(attrPrefix) === 0) {
  318. throw new Error("Prefix '".concat(templ[0], "' does not guarantee the attribute ") +
  319. "to be safe as it is also a prefix for " +
  320. "the security sensitive attribute '".concat(sensitiveAttr, "'. ") +
  321. "Please use native or safe DOM APIs to set the attribute.");
  322. }
  323. });
  324. }
  325. return (0, attribute_impl_1.createAttributePrefix)(attrPrefix);
  326. }
  327. exports.safeAttrPrefix = safeAttrPrefix;
  328. /***/ }),
  329. /***/ "./node_modules/safevalues/builders/html_builders.js":
  330. /*!***********************************************************!*\
  331. !*** ./node_modules/safevalues/builders/html_builders.js ***!
  332. \***********************************************************/
  333. /*! no static exports found */
  334. /***/ (function(module, exports, __webpack_require__) {
  335. "use strict";
  336. /**
  337. * @license
  338. * SPDX-License-Identifier: Apache-2.0
  339. */
  340. Object.defineProperty(exports, "__esModule", { value: true });
  341. exports.concatHtmls = exports.createScriptSrc = exports.createScript = exports.htmlEscape = void 0;
  342. var html_impl_1 = __webpack_require__(/*! ../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  343. var resource_url_impl_1 = __webpack_require__(/*! ../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  344. var script_impl_1 = __webpack_require__(/*! ../internals/script_impl */ "./node_modules/safevalues/internals/script_impl.js");
  345. /**
  346. * Returns HTML-escaped text as a `SafeHtml` object.
  347. *
  348. * Available options:
  349. * - `preserveSpaces` turns every second consecutive space character into its
  350. * HTML entity representation (`&#160;`).
  351. * - `preserveNewlines` turns newline characters into breaks (`<br>`).
  352. * - `preserveTabs` wraps tab characters in a span with style=white-space:pre.
  353. */
  354. function htmlEscape(text, options) {
  355. if (options === void 0) { options = {}; }
  356. var htmlEscapedString = htmlEscapeToString(text);
  357. if (options.preserveSpaces) {
  358. // Do this first to ensure we preserve spaces after newlines and tabs.
  359. htmlEscapedString =
  360. htmlEscapedString.replace(/(^|[\r\n\t ]) /g, '$1&#160;');
  361. }
  362. if (options.preserveNewlines) {
  363. htmlEscapedString = htmlEscapedString.replace(/(\r\n|\n|\r)/g, '<br>');
  364. }
  365. if (options.preserveTabs) {
  366. htmlEscapedString = htmlEscapedString.replace(/(\t+)/g, '<span style="white-space:pre">$1</span>');
  367. }
  368. return (0, html_impl_1.createHtml)(htmlEscapedString);
  369. }
  370. exports.htmlEscape = htmlEscape;
  371. /**
  372. * Creates a `SafeHtml` representing a script tag with inline script content.
  373. */
  374. function createScript(script, options) {
  375. if (options === void 0) { options = {}; }
  376. var unwrappedScript = (0, script_impl_1.unwrapScript)(script).toString();
  377. var stringTag = "<script";
  378. if (options.id) {
  379. stringTag += " id=\"".concat(htmlEscapeToString(options.id), "\"");
  380. }
  381. if (options.nonce) {
  382. stringTag += " nonce=\"".concat(htmlEscapeToString(options.nonce), "\"");
  383. }
  384. if (options.type) {
  385. stringTag += " type=\"".concat(htmlEscapeToString(options.type), "\"");
  386. }
  387. stringTag += ">".concat(unwrappedScript, "</script>");
  388. return (0, html_impl_1.createHtml)(stringTag);
  389. }
  390. exports.createScript = createScript;
  391. /**
  392. * Creates a `SafeHtml` representing a script tag with the src attribute.
  393. * This also supports CSP nonces and async loading.
  394. */
  395. function createScriptSrc(src, async, nonce) {
  396. var unwrappedSrc = (0, resource_url_impl_1.unwrapResourceUrl)(src).toString();
  397. var stringTag = "<script src=\"".concat(htmlEscapeToString(unwrappedSrc), "\"");
  398. if (async) {
  399. stringTag += ' async';
  400. }
  401. if (nonce) {
  402. stringTag += " nonce=\"".concat(htmlEscapeToString(nonce), "\"");
  403. }
  404. stringTag += '>\x3c/script>';
  405. return (0, html_impl_1.createHtml)(stringTag);
  406. }
  407. exports.createScriptSrc = createScriptSrc;
  408. /**
  409. * HTML-escapes the given text (`&`, `<`, `>`, `"` and `'`).
  410. */
  411. function htmlEscapeToString(text) {
  412. var escaped = text.replace(/&/g, '&amp;')
  413. .replace(/</g, '&lt;')
  414. .replace(/>/g, '&gt;')
  415. .replace(/"/g, '&quot;')
  416. .replace(/'/g, '&apos;');
  417. return escaped;
  418. }
  419. /** Creates a `SafeHtml` value by concatenating multiple `SafeHtml`s. */
  420. function concatHtmls(htmls) {
  421. return (0, html_impl_1.createHtml)(htmls.map(html_impl_1.unwrapHtml).join(''));
  422. }
  423. exports.concatHtmls = concatHtmls;
  424. /***/ }),
  425. /***/ "./node_modules/safevalues/builders/html_sanitizer/html_sanitizer.js":
  426. /*!***************************************************************************!*\
  427. !*** ./node_modules/safevalues/builders/html_sanitizer/html_sanitizer.js ***!
  428. \***************************************************************************/
  429. /*! no static exports found */
  430. /***/ (function(module, exports, __webpack_require__) {
  431. "use strict";
  432. /**
  433. * @license
  434. * SPDX-License-Identifier: Apache-2.0
  435. */
  436. var __values = (this && this.__values) || function(o) {
  437. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  438. if (m) return m.call(o);
  439. if (o && typeof o.length === "number") return {
  440. next: function () {
  441. if (o && i >= o.length) o = void 0;
  442. return { value: o && o[i++], done: !o };
  443. }
  444. };
  445. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  446. };
  447. var __read = (this && this.__read) || function (o, n) {
  448. var m = typeof Symbol === "function" && o[Symbol.iterator];
  449. if (!m) return o;
  450. var i = m.call(o), r, ar = [], e;
  451. try {
  452. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  453. }
  454. catch (error) { e = { error: error }; }
  455. finally {
  456. try {
  457. if (r && !r.done && (m = i["return"])) m.call(i);
  458. }
  459. finally { if (e) throw e.error; }
  460. }
  461. return ar;
  462. };
  463. Object.defineProperty(exports, "__esModule", { value: true });
  464. exports.sanitizeHtmlToFragment = exports.sanitizeHtmlAssertUnchanged = exports.sanitizeHtml = exports.HtmlSanitizerImpl = void 0;
  465. __webpack_require__(/*! ../../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  466. var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  467. /* g3_import_pure from '../../internals/pure' */
  468. var secrets_1 = __webpack_require__(/*! ../../internals/secrets */ "./node_modules/safevalues/internals/secrets.js");
  469. var url_sanitizer_1 = __webpack_require__(/*! ../url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  470. var inert_fragment_1 = __webpack_require__(/*! ./inert_fragment */ "./node_modules/safevalues/builders/html_sanitizer/inert_fragment.js");
  471. var no_clobber_1 = __webpack_require__(/*! ./no_clobber */ "./node_modules/safevalues/builders/html_sanitizer/no_clobber.js");
  472. var default_sanitizer_table_1 = __webpack_require__(/*! ./sanitizer_table/default_sanitizer_table */ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/default_sanitizer_table.js");
  473. var sanitizer_table_1 = __webpack_require__(/*! ./sanitizer_table/sanitizer_table */ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/sanitizer_table.js");
  474. /** Implementation for `HtmlSanitizer` */
  475. var HtmlSanitizerImpl = /** @class */ (function () {
  476. function HtmlSanitizerImpl(sanitizerTable, token) {
  477. this.sanitizerTable = sanitizerTable;
  478. this.changes = [];
  479. (0, secrets_1.ensureTokenIsValid)(token);
  480. }
  481. HtmlSanitizerImpl.prototype.sanitizeAssertUnchanged = function (html) {
  482. this.changes = [];
  483. var sanitizedHtml = this.sanitize(html);
  484. if (this.changes.length !== 0) {
  485. var message = '';
  486. if (true) {
  487. message =
  488. "Unexpected change to HTML value as a result of sanitization. " +
  489. "Input: \"".concat(html, "\", sanitized output: \"").concat(sanitizedHtml, "\"\n") +
  490. "List of changes:".concat(this.changes.join('\n'));
  491. }
  492. throw new Error(message);
  493. }
  494. return sanitizedHtml;
  495. };
  496. HtmlSanitizerImpl.prototype.sanitize = function (html) {
  497. var fakeRoot = document.createElement('span');
  498. fakeRoot.appendChild(this.sanitizeToFragment(html));
  499. // XML serialization is preferred over HTML serialization as it is
  500. // stricter and makes sure all attributes are properly escaped, avoiding
  501. // cases where the tree might mutate when parsed again later due to the
  502. // complexities of the HTML parsing algorithm
  503. var serializedNewTree = new XMLSerializer().serializeToString(fakeRoot);
  504. // We remove the outer most element as this is the span node created as
  505. // the root for the sanitized tree and contains a spurious xmlns attribute
  506. // from the XML serialization step.
  507. serializedNewTree = serializedNewTree.slice(serializedNewTree.indexOf('>') + 1, serializedNewTree.lastIndexOf('</'));
  508. return (0, html_impl_1.createHtml)(serializedNewTree);
  509. };
  510. HtmlSanitizerImpl.prototype.sanitizeToFragment = function (html) {
  511. var _this = this;
  512. var dirtyFragment = (0, inert_fragment_1.createInertFragment)(html);
  513. var treeWalker = document.createTreeWalker(dirtyFragment, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT,
  514. // IE10 and IE11 won't accept a proper `NodeFilter` interface, and
  515. // expect the filtering function to be passed directly. It seems that
  516. // other browsers also do not mind getting the function directly. see
  517. // https://stackoverflow.com/q/38245898
  518. (function (n) { return _this.nodeFilter(n); }),
  519. // @ts-ignore: error TS2554: Expected 1-3 arguments, but got 4.
  520. false);
  521. // `nextNode` is called so we skip the root `DocumentFragment`.
  522. var currentNode = treeWalker.nextNode();
  523. // We create a root element to attach all the children of the body to. We
  524. // use div as it as a semantic-free, generic container and does not
  525. // represent anything. This is removed when we serialize the tree back
  526. // into a string.
  527. var sanitizedFragment = document.createDocumentFragment();
  528. var sanitizedParent = sanitizedFragment;
  529. while (currentNode !== null) {
  530. var sanitizedNode = void 0;
  531. if ((0, no_clobber_1.isText)(currentNode)) {
  532. sanitizedNode = this.sanitizeTextNode(currentNode);
  533. }
  534. else if ((0, no_clobber_1.isElement)(currentNode)) {
  535. sanitizedNode = this.sanitizeElementNode(currentNode);
  536. }
  537. else {
  538. throw new Error('Node is not of type text or element');
  539. }
  540. sanitizedParent.appendChild(sanitizedNode);
  541. // Advance iterator while keeping track of the sanitized parent for the
  542. // current node
  543. currentNode = treeWalker.firstChild();
  544. if (currentNode) {
  545. sanitizedParent = sanitizedNode;
  546. }
  547. else {
  548. while (!(currentNode = treeWalker.nextSibling())) {
  549. if (!(currentNode = treeWalker.parentNode())) {
  550. break;
  551. }
  552. sanitizedParent = sanitizedParent.parentNode;
  553. }
  554. }
  555. }
  556. return sanitizedFragment;
  557. };
  558. HtmlSanitizerImpl.prototype.sanitizeTextNode = function (textNode) {
  559. return document.createTextNode(textNode.data);
  560. };
  561. HtmlSanitizerImpl.prototype.sanitizeElementNode = function (elementNode) {
  562. var e_1, _a;
  563. var elementName = (0, no_clobber_1.getNodeName)(elementNode);
  564. var newNode = document.createElement(elementName);
  565. var dirtyAttributes = elementNode.attributes;
  566. try {
  567. for (var dirtyAttributes_1 = __values(dirtyAttributes), dirtyAttributes_1_1 = dirtyAttributes_1.next(); !dirtyAttributes_1_1.done; dirtyAttributes_1_1 = dirtyAttributes_1.next()) {
  568. var _b = dirtyAttributes_1_1.value, name_1 = _b.name, value = _b.value;
  569. var policy = this.sanitizerTable.getAttributePolicy(name_1, elementName);
  570. if (!this.satisfiesAllConditions(policy.conditions, dirtyAttributes)) {
  571. this.recordChange("Not all conditions satisfied for attribute: ".concat(name_1, "."));
  572. continue;
  573. }
  574. switch (policy.policyAction) {
  575. case sanitizer_table_1.AttributePolicyAction.KEEP:
  576. newNode.setAttribute(name_1, value);
  577. break;
  578. case sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL:
  579. var sanitizedAttrUrl = (0, url_sanitizer_1.restrictivelySanitizeUrl)(value);
  580. if (sanitizedAttrUrl !== value) {
  581. this.recordChange("Url in attribute ".concat(name_1, " was modified during sanitization. Original url:\"").concat(value, "\" was sanitized to: \"").concat(sanitizedAttrUrl, "\""));
  582. }
  583. newNode.setAttribute(name_1, sanitizedAttrUrl);
  584. break;
  585. case sanitizer_table_1.AttributePolicyAction.KEEP_AND_NORMALIZE:
  586. // We don't consider changing the case of an attribute value to be a
  587. // semantic change
  588. newNode.setAttribute(name_1, value.toLowerCase());
  589. break;
  590. case sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_STYLE:
  591. newNode.setAttribute(name_1, value);
  592. break;
  593. case sanitizer_table_1.AttributePolicyAction.DROP:
  594. this.recordChange("Attribute: ".concat(name_1, " was dropped"));
  595. break;
  596. default:
  597. checkExhaustive(policy.policyAction, 'Unhandled AttributePolicyAction case');
  598. }
  599. }
  600. }
  601. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  602. finally {
  603. try {
  604. if (dirtyAttributes_1_1 && !dirtyAttributes_1_1.done && (_a = dirtyAttributes_1.return)) _a.call(dirtyAttributes_1);
  605. }
  606. finally { if (e_1) throw e_1.error; }
  607. }
  608. return newNode;
  609. };
  610. HtmlSanitizerImpl.prototype.nodeFilter = function (node) {
  611. if ((0, no_clobber_1.isText)(node)) {
  612. return NodeFilter.FILTER_ACCEPT;
  613. }
  614. else if (!(0, no_clobber_1.isElement)(node)) {
  615. // Getting a node that is neither an `Element` or a `Text` node. This is
  616. // likely due to something that is not supposed to be an element in user
  617. // code but recognized as such by the TreeWalker (e.g. a polyfill for
  618. // other kind of nodes). Since we can't recognize it as an element, we
  619. // drop the node, but we don't record it as a meaningful change.
  620. return NodeFilter.FILTER_REJECT;
  621. }
  622. var nodeName = (0, no_clobber_1.getNodeName)(node);
  623. if (nodeName === null) {
  624. this.recordChange("Node name was null for node: ".concat(node));
  625. return NodeFilter.FILTER_REJECT;
  626. }
  627. if (this.sanitizerTable.isAllowedElement(nodeName)) {
  628. return NodeFilter.FILTER_ACCEPT;
  629. }
  630. this.recordChange("Element: ".concat(nodeName, " was dropped"));
  631. return NodeFilter.FILTER_REJECT;
  632. };
  633. HtmlSanitizerImpl.prototype.recordChange = function (errorMessage) {
  634. if (true) {
  635. this.changes.push(errorMessage);
  636. }
  637. else {}
  638. };
  639. HtmlSanitizerImpl.prototype.satisfiesAllConditions = function (conditions, attrs) {
  640. var e_2, _a;
  641. var _b;
  642. if (!conditions) {
  643. return true;
  644. }
  645. try {
  646. for (var conditions_1 = __values(conditions), conditions_1_1 = conditions_1.next(); !conditions_1_1.done; conditions_1_1 = conditions_1.next()) {
  647. var _c = __read(conditions_1_1.value, 2), attrName = _c[0], expectedValues = _c[1];
  648. var value = (_b = attrs.getNamedItem(attrName)) === null || _b === void 0 ? void 0 : _b.value;
  649. if (value && !expectedValues.has(value)) {
  650. return false;
  651. }
  652. }
  653. }
  654. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  655. finally {
  656. try {
  657. if (conditions_1_1 && !conditions_1_1.done && (_a = conditions_1.return)) _a.call(conditions_1);
  658. }
  659. finally { if (e_2) throw e_2.error; }
  660. }
  661. return true;
  662. };
  663. return HtmlSanitizerImpl;
  664. }());
  665. exports.HtmlSanitizerImpl = HtmlSanitizerImpl;
  666. var defaultHtmlSanitizer =
  667. /* #__PURE__ */ (function () { return new HtmlSanitizerImpl(default_sanitizer_table_1.defaultSanitizerTable, secrets_1.secretToken); })();
  668. /** Sanitizes untrusted html using the default sanitizer configuration. */
  669. function sanitizeHtml(html) {
  670. return defaultHtmlSanitizer.sanitize(html);
  671. }
  672. exports.sanitizeHtml = sanitizeHtml;
  673. /**
  674. * Sanitizes untrusted html using the default sanitizer configuration. Throws
  675. * an error if the html was changed.
  676. */
  677. function sanitizeHtmlAssertUnchanged(html) {
  678. return defaultHtmlSanitizer.sanitizeAssertUnchanged(html);
  679. }
  680. exports.sanitizeHtmlAssertUnchanged = sanitizeHtmlAssertUnchanged;
  681. /**
  682. * Sanitizes untrusted html using the default sanitizer configuration. Throws
  683. * an error if the html was changed.
  684. */
  685. function sanitizeHtmlToFragment(html) {
  686. return defaultHtmlSanitizer.sanitizeToFragment(html);
  687. }
  688. exports.sanitizeHtmlToFragment = sanitizeHtmlToFragment;
  689. function checkExhaustive(value, msg) {
  690. if (msg === void 0) { msg = "unexpected value ".concat(value, "!"); }
  691. throw new Error(msg);
  692. }
  693. /***/ }),
  694. /***/ "./node_modules/safevalues/builders/html_sanitizer/html_sanitizer_builder.js":
  695. /*!***********************************************************************************!*\
  696. !*** ./node_modules/safevalues/builders/html_sanitizer/html_sanitizer_builder.js ***!
  697. \***********************************************************************************/
  698. /*! no static exports found */
  699. /***/ (function(module, exports, __webpack_require__) {
  700. "use strict";
  701. /**
  702. * @license
  703. * SPDX-License-Identifier: Apache-2.0
  704. */
  705. var __values = (this && this.__values) || function(o) {
  706. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  707. if (m) return m.call(o);
  708. if (o && typeof o.length === "number") return {
  709. next: function () {
  710. if (o && i >= o.length) o = void 0;
  711. return { value: o && o[i++], done: !o };
  712. }
  713. };
  714. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  715. };
  716. var __read = (this && this.__read) || function (o, n) {
  717. var m = typeof Symbol === "function" && o[Symbol.iterator];
  718. if (!m) return o;
  719. var i = m.call(o), r, ar = [], e;
  720. try {
  721. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  722. }
  723. catch (error) { e = { error: error }; }
  724. finally {
  725. try {
  726. if (r && !r.done && (m = i["return"])) m.call(i);
  727. }
  728. finally { if (e) throw e.error; }
  729. }
  730. return ar;
  731. };
  732. Object.defineProperty(exports, "__esModule", { value: true });
  733. exports.HtmlSanitizerBuilder = void 0;
  734. var secrets_1 = __webpack_require__(/*! ../../internals/secrets */ "./node_modules/safevalues/internals/secrets.js");
  735. var html_sanitizer_1 = __webpack_require__(/*! ./html_sanitizer */ "./node_modules/safevalues/builders/html_sanitizer/html_sanitizer.js");
  736. var default_sanitizer_table_1 = __webpack_require__(/*! ./sanitizer_table/default_sanitizer_table */ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/default_sanitizer_table.js");
  737. var sanitizer_table_1 = __webpack_require__(/*! ./sanitizer_table/sanitizer_table */ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/sanitizer_table.js");
  738. /** This class allows modifications to the default sanitizer configuration. */
  739. var HtmlSanitizerBuilder = /** @class */ (function () {
  740. function HtmlSanitizerBuilder() {
  741. // To denote if the builder has called build() and therefore should make no
  742. // further changes to the sanitizer table.
  743. this.calledBuild = false;
  744. this.sanitizerTable = default_sanitizer_table_1.defaultSanitizerTable;
  745. }
  746. /** Builder option to restrict allowed elements to a smaller subset. */
  747. HtmlSanitizerBuilder.prototype.onlyAllowElements = function (elementSet) {
  748. var e_1, _a;
  749. var allowedElements = new Set();
  750. var allowedElementPolicies = new Map();
  751. try {
  752. for (var elementSet_1 = __values(elementSet), elementSet_1_1 = elementSet_1.next(); !elementSet_1_1.done; elementSet_1_1 = elementSet_1.next()) {
  753. var element = elementSet_1_1.value;
  754. element = element.toUpperCase();
  755. if (!this.sanitizerTable.isAllowedElement(element)) {
  756. throw new Error("Element: ".concat(element, ", is not allowed by html5_contract.textpb"));
  757. }
  758. var elementPolicy = this.sanitizerTable.elementPolicies.get(element);
  759. if (elementPolicy !== undefined) {
  760. allowedElementPolicies.set(element, elementPolicy);
  761. }
  762. else {
  763. allowedElements.add(element);
  764. }
  765. }
  766. }
  767. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  768. finally {
  769. try {
  770. if (elementSet_1_1 && !elementSet_1_1.done && (_a = elementSet_1.return)) _a.call(elementSet_1);
  771. }
  772. finally { if (e_1) throw e_1.error; }
  773. }
  774. this.sanitizerTable = new sanitizer_table_1.SanitizerTable(allowedElements, allowedElementPolicies, this.sanitizerTable.allowedGlobalAttributes, this.sanitizerTable.globalAttributePolicies);
  775. return this;
  776. };
  777. /**
  778. * Builder option to restrict allowed attributes to a smaller subset.
  779. *
  780. * If the attribute isn't currently allowed then it won't be added.
  781. */
  782. HtmlSanitizerBuilder.prototype.onlyAllowAttributes = function (attributeSet) {
  783. var e_2, _a, e_3, _b, e_4, _c;
  784. var allowedGlobalAttributes = new Set();
  785. var globalAttributePolicies = new Map();
  786. var elementPolicies = new Map();
  787. try {
  788. for (var attributeSet_1 = __values(attributeSet), attributeSet_1_1 = attributeSet_1.next(); !attributeSet_1_1.done; attributeSet_1_1 = attributeSet_1.next()) {
  789. var attribute = attributeSet_1_1.value;
  790. if (this.sanitizerTable.allowedGlobalAttributes.has(attribute)) {
  791. allowedGlobalAttributes.add(attribute);
  792. }
  793. if (this.sanitizerTable.globalAttributePolicies.has(attribute)) {
  794. globalAttributePolicies.set(attribute, this.sanitizerTable.globalAttributePolicies.get(attribute));
  795. }
  796. }
  797. }
  798. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  799. finally {
  800. try {
  801. if (attributeSet_1_1 && !attributeSet_1_1.done && (_a = attributeSet_1.return)) _a.call(attributeSet_1);
  802. }
  803. finally { if (e_2) throw e_2.error; }
  804. }
  805. try {
  806. for (var _d = __values(this.sanitizerTable
  807. .elementPolicies.entries()), _e = _d.next(); !_e.done; _e = _d.next()) {
  808. var _f = __read(_e.value, 2), elementName = _f[0], originalElementPolicy = _f[1];
  809. var newElementPolicy = new Map();
  810. try {
  811. for (var _g = (e_4 = void 0, __values(originalElementPolicy
  812. .entries())), _h = _g.next(); !_h.done; _h = _g.next()) {
  813. var _j = __read(_h.value, 2), attribute = _j[0], attributePolicy = _j[1];
  814. if (attributeSet.has(attribute)) {
  815. newElementPolicy.set(attribute, attributePolicy);
  816. }
  817. }
  818. }
  819. catch (e_4_1) { e_4 = { error: e_4_1 }; }
  820. finally {
  821. try {
  822. if (_h && !_h.done && (_c = _g.return)) _c.call(_g);
  823. }
  824. finally { if (e_4) throw e_4.error; }
  825. }
  826. elementPolicies.set(elementName, newElementPolicy);
  827. }
  828. }
  829. catch (e_3_1) { e_3 = { error: e_3_1 }; }
  830. finally {
  831. try {
  832. if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
  833. }
  834. finally { if (e_3) throw e_3.error; }
  835. }
  836. this.sanitizerTable = new sanitizer_table_1.SanitizerTable(this.sanitizerTable.allowedElements, elementPolicies, allowedGlobalAttributes, globalAttributePolicies);
  837. return this;
  838. };
  839. /**
  840. * Allows the set of data attributes passed.
  841. *
  842. * These values must be prefixed with "data-"
  843. *
  844. * If called with onlyAllowElements or onlyAllowAttributes, those methods must
  845. * be called first.
  846. */
  847. HtmlSanitizerBuilder.prototype.allowDataAttributes = function (attributes) {
  848. var e_5, _a;
  849. var allowedGlobalAttributes = new Set(this.sanitizerTable.allowedGlobalAttributes);
  850. try {
  851. for (var attributes_1 = __values(attributes), attributes_1_1 = attributes_1.next(); !attributes_1_1.done; attributes_1_1 = attributes_1.next()) {
  852. var attribute = attributes_1_1.value;
  853. if (attribute.indexOf('data-') !== 0) {
  854. throw new Error("data attribute: ".concat(attribute, " does not begin with the prefix \"data-\""));
  855. }
  856. allowedGlobalAttributes.add(attribute);
  857. }
  858. }
  859. catch (e_5_1) { e_5 = { error: e_5_1 }; }
  860. finally {
  861. try {
  862. if (attributes_1_1 && !attributes_1_1.done && (_a = attributes_1.return)) _a.call(attributes_1);
  863. }
  864. finally { if (e_5) throw e_5.error; }
  865. }
  866. this.sanitizerTable = new sanitizer_table_1.SanitizerTable(this.sanitizerTable.allowedElements, this.sanitizerTable.elementPolicies, allowedGlobalAttributes, this.sanitizerTable.globalAttributePolicies);
  867. return this;
  868. };
  869. /**
  870. * Preserves style attributes. Note that the sanitizer won't parse and
  871. * sanitize the values but keep them as they are. In particular this means
  872. * that the code will be able to call functions that could do undesirable
  873. * things (e.g. `url` to trigger a network request), as well as any custom
  874. * properties or functions defined by the application.
  875. */
  876. HtmlSanitizerBuilder.prototype.allowStyleAttributes = function () {
  877. var globalAttributePolicies = new Map(this.sanitizerTable.globalAttributePolicies);
  878. globalAttributePolicies.set('style', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_STYLE });
  879. this.sanitizerTable = new sanitizer_table_1.SanitizerTable(this.sanitizerTable.allowedElements, this.sanitizerTable.elementPolicies, this.sanitizerTable.allowedGlobalAttributes, globalAttributePolicies);
  880. return this;
  881. };
  882. /**
  883. * Preserves the class attribute on all elements. This means contents can
  884. * adopt CSS styles from other page elements and possibly mask themselves as
  885. * legitimate UI elements, which can lead to phishing.
  886. */
  887. HtmlSanitizerBuilder.prototype.allowClassAttributes = function () {
  888. var globalAttributePolicies = new Map(this.sanitizerTable.globalAttributePolicies);
  889. globalAttributePolicies.set('class', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP });
  890. this.sanitizerTable = new sanitizer_table_1.SanitizerTable(this.sanitizerTable.allowedElements, this.sanitizerTable.elementPolicies, this.sanitizerTable.allowedGlobalAttributes, globalAttributePolicies);
  891. return this;
  892. };
  893. /**
  894. * Preserves id attributes. This carries moderate risk as it allows an
  895. * element to override other elements with the same ID.
  896. */
  897. HtmlSanitizerBuilder.prototype.allowIdAttributes = function () {
  898. var globalAttributePolicies = new Map(this.sanitizerTable.globalAttributePolicies);
  899. globalAttributePolicies.set('id', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP });
  900. this.sanitizerTable = new sanitizer_table_1.SanitizerTable(this.sanitizerTable.allowedElements, this.sanitizerTable.elementPolicies, this.sanitizerTable.allowedGlobalAttributes, globalAttributePolicies);
  901. return this;
  902. };
  903. HtmlSanitizerBuilder.prototype.build = function () {
  904. if (this.calledBuild) {
  905. throw new Error('this sanitizer has already called build');
  906. }
  907. this.calledBuild = true;
  908. return new html_sanitizer_1.HtmlSanitizerImpl(this.sanitizerTable, secrets_1.secretToken);
  909. };
  910. return HtmlSanitizerBuilder;
  911. }());
  912. exports.HtmlSanitizerBuilder = HtmlSanitizerBuilder;
  913. /***/ }),
  914. /***/ "./node_modules/safevalues/builders/html_sanitizer/inert_fragment.js":
  915. /*!***************************************************************************!*\
  916. !*** ./node_modules/safevalues/builders/html_sanitizer/inert_fragment.js ***!
  917. \***************************************************************************/
  918. /*! no static exports found */
  919. /***/ (function(module, exports, __webpack_require__) {
  920. "use strict";
  921. /**
  922. * @license
  923. * SPDX-License-Identifier: Apache-2.0
  924. */
  925. Object.defineProperty(exports, "__esModule", { value: true });
  926. exports.createInertFragment = void 0;
  927. var element_1 = __webpack_require__(/*! ../../dom/elements/element */ "./node_modules/safevalues/dom/elements/element.js");
  928. var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  929. /**
  930. * Returns a fragment that contains the parsed HTML for `dirtyHtml` without
  931. * executing any of the potential payload.
  932. */
  933. function createInertFragment(dirtyHtml) {
  934. var template = document.createElement('template');
  935. // This call is only used to create an inert tree for the sanitizer to
  936. // further process and is never returned directly to the caller. We can't use
  937. // a reviewed conversion in order to avoid an import loop.
  938. var temporarySafeHtml = (0, html_impl_1.createHtml)(dirtyHtml);
  939. (0, element_1.setInnerHtml)(template, temporarySafeHtml);
  940. return template.content;
  941. }
  942. exports.createInertFragment = createInertFragment;
  943. /***/ }),
  944. /***/ "./node_modules/safevalues/builders/html_sanitizer/no_clobber.js":
  945. /*!***********************************************************************!*\
  946. !*** ./node_modules/safevalues/builders/html_sanitizer/no_clobber.js ***!
  947. \***********************************************************************/
  948. /*! no static exports found */
  949. /***/ (function(module, exports, __webpack_require__) {
  950. "use strict";
  951. /**
  952. * @license
  953. * SPDX-License-Identifier: Apache-2.0
  954. */
  955. Object.defineProperty(exports, "__esModule", { value: true });
  956. exports.isElement = exports.isText = exports.getNodeName = void 0;
  957. /**
  958. * Library that provides safe getters for different node properties and
  959. * checks for clobbering.
  960. */
  961. /** Gets a reasonable nodeName, even for clobbered nodes. */
  962. function getNodeName(node) {
  963. var nodeName = node.nodeName;
  964. // If the property is clobbered, assume it is an `HTMLFormElement`.
  965. return (typeof nodeName === 'string') ? nodeName : 'FORM';
  966. }
  967. exports.getNodeName = getNodeName;
  968. /** Returns true if the object passed is a Text node. */
  969. function isText(node) {
  970. // The property cannot get clobbered on Text nodes.
  971. return node.nodeType === Node.TEXT_NODE;
  972. }
  973. exports.isText = isText;
  974. /** Returns true if the object passed is an Element node. */
  975. function isElement(node) {
  976. var nodeType = node.nodeType;
  977. // If the property is clobbered, we can assume it is an `HTMLFormElement`, and
  978. // thus an `Element`.
  979. return (nodeType === Node.ELEMENT_NODE) || (typeof nodeType !== 'number');
  980. }
  981. exports.isElement = isElement;
  982. /***/ }),
  983. /***/ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/default_sanitizer_table.js":
  984. /*!****************************************************************************************************!*\
  985. !*** ./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/default_sanitizer_table.js ***!
  986. \****************************************************************************************************/
  987. /*! no static exports found */
  988. /***/ (function(module, exports, __webpack_require__) {
  989. "use strict";
  990. /**
  991. * @license
  992. * SPDX-License-Identifier: Apache-2.0
  993. */
  994. Object.defineProperty(exports, "__esModule", { value: true });
  995. exports.defaultSanitizerTable = void 0;
  996. var sanitizer_table_1 = __webpack_require__(/*! ./sanitizer_table */ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/sanitizer_table.js");
  997. /**
  998. * GENERATED CODE, DO NOT MODIFY
  999. * This SanitizerTable was generated from the checked in html contract:
  1000. * webutil/html/types/codegen/html5_contract.textpb
  1001. *
  1002. * You can regenerate this file with:
  1003. * webutil/html/types/codegen/update_generated_source_files.sh
  1004. */
  1005. exports.defaultSanitizerTable = new sanitizer_table_1.SanitizerTable(new Set([
  1006. 'ARTICLE', 'SECTION', 'NAV', 'ASIDE', 'H1', 'H2',
  1007. 'H3', 'H4', 'H5', 'H6', 'HEADER', 'FOOTER',
  1008. 'ADDRESS', 'P', 'HR', 'PRE', 'BLOCKQUOTE', 'OL',
  1009. 'UL', 'LH', 'LI', 'DL', 'DT', 'DD',
  1010. 'FIGURE', 'FIGCAPTION', 'MAIN', 'DIV', 'EM', 'STRONG',
  1011. 'SMALL', 'S', 'CITE', 'Q', 'DFN', 'ABBR',
  1012. 'RUBY', 'RB', 'RT', 'RTC', 'RP', 'DATA',
  1013. 'TIME', 'CODE', 'VAR', 'SAMP', 'KBD', 'SUB',
  1014. 'SUP', 'I', 'B', 'U', 'MARK', 'BDI',
  1015. 'BDO', 'SPAN', 'BR', 'WBR', 'INS', 'DEL',
  1016. 'PICTURE', 'PARAM', 'TRACK', 'MAP', 'TABLE', 'CAPTION',
  1017. 'COLGROUP', 'COL', 'TBODY', 'THEAD', 'TFOOT', 'TR',
  1018. 'TD', 'TH', 'SELECT', 'DATALIST', 'OPTGROUP', 'OPTION',
  1019. 'OUTPUT', 'PROGRESS', 'METER', 'FIELDSET', 'LEGEND', 'DETAILS',
  1020. 'SUMMARY', 'MENU', 'DIALOG', 'SLOT', 'CANVAS', 'FONT',
  1021. 'CENTER',
  1022. ]), new Map([
  1023. [
  1024. 'A', new Map([
  1025. ['href', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
  1026. ])
  1027. ],
  1028. [
  1029. 'AREA', new Map([
  1030. ['href', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
  1031. ])
  1032. ],
  1033. [
  1034. 'LINK', new Map([
  1035. [
  1036. 'href', {
  1037. policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL,
  1038. conditions: new Map([[
  1039. 'rel', new Set([
  1040. 'alternate',
  1041. 'author',
  1042. 'bookmark',
  1043. 'canonical',
  1044. 'cite',
  1045. 'help',
  1046. 'icon',
  1047. 'license',
  1048. 'next',
  1049. 'prefetch',
  1050. 'dns-prefetch',
  1051. 'prerender',
  1052. 'preconnect',
  1053. 'preload',
  1054. 'prev',
  1055. 'search',
  1056. 'subresource',
  1057. ])
  1058. ]])
  1059. }
  1060. ],
  1061. ])
  1062. ],
  1063. [
  1064. 'SOURCE', new Map([
  1065. ['src', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
  1066. ])
  1067. ],
  1068. [
  1069. 'IMG', new Map([
  1070. ['src', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
  1071. ])
  1072. ],
  1073. [
  1074. 'VIDEO', new Map([
  1075. ['src', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
  1076. ])
  1077. ],
  1078. [
  1079. 'AUDIO', new Map([
  1080. ['src', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
  1081. ])
  1082. ],
  1083. ]), new Set([
  1084. 'title',
  1085. 'aria-atomic',
  1086. 'aria-autocomplete',
  1087. 'aria-busy',
  1088. 'aria-checked',
  1089. 'aria-current',
  1090. 'aria-disabled',
  1091. 'aria-dropeffect',
  1092. 'aria-expanded',
  1093. 'aria-haspopup',
  1094. 'aria-hidden',
  1095. 'aria-invalid',
  1096. 'aria-label',
  1097. 'aria-level',
  1098. 'aria-live',
  1099. 'aria-multiline',
  1100. 'aria-multiselectable',
  1101. 'aria-orientation',
  1102. 'aria-posinset',
  1103. 'aria-pressed',
  1104. 'aria-readonly',
  1105. 'aria-relevant',
  1106. 'aria-required',
  1107. 'aria-selected',
  1108. 'aria-setsize',
  1109. 'aria-sort',
  1110. 'aria-valuemax',
  1111. 'aria-valuemin',
  1112. 'aria-valuenow',
  1113. 'aria-valuetext',
  1114. 'alt',
  1115. 'align',
  1116. 'autocapitalize',
  1117. 'autocomplete',
  1118. 'autocorrect',
  1119. 'autofocus',
  1120. 'autoplay',
  1121. 'bgcolor',
  1122. 'border',
  1123. 'cellpadding',
  1124. 'cellspacing',
  1125. 'checked',
  1126. 'color',
  1127. 'cols',
  1128. 'colspan',
  1129. 'controls',
  1130. 'datetime',
  1131. 'disabled',
  1132. 'download',
  1133. 'draggable',
  1134. 'enctype',
  1135. 'face',
  1136. 'formenctype',
  1137. 'frameborder',
  1138. 'height',
  1139. 'hreflang',
  1140. 'hidden',
  1141. 'ismap',
  1142. 'label',
  1143. 'lang',
  1144. 'loop',
  1145. 'max',
  1146. 'maxlength',
  1147. 'media',
  1148. 'minlength',
  1149. 'min',
  1150. 'multiple',
  1151. 'muted',
  1152. 'nonce',
  1153. 'open',
  1154. 'placeholder',
  1155. 'preload',
  1156. 'rel',
  1157. 'required',
  1158. 'reversed',
  1159. 'role',
  1160. 'rows',
  1161. 'rowspan',
  1162. 'selected',
  1163. 'shape',
  1164. 'size',
  1165. 'sizes',
  1166. 'slot',
  1167. 'span',
  1168. 'spellcheck',
  1169. 'start',
  1170. 'step',
  1171. 'summary',
  1172. 'translate',
  1173. 'type',
  1174. 'valign',
  1175. 'value',
  1176. 'width',
  1177. 'wrap',
  1178. 'itemscope',
  1179. 'itemtype',
  1180. 'itemid',
  1181. 'itemprop',
  1182. 'itemref',
  1183. ]), new Map([
  1184. [
  1185. 'dir', {
  1186. policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_NORMALIZE,
  1187. conditions: new Map([[
  1188. 'dir', new Set([
  1189. 'auto',
  1190. 'ltr',
  1191. 'rtl',
  1192. ])
  1193. ]])
  1194. }
  1195. ],
  1196. [
  1197. 'async', {
  1198. policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_NORMALIZE,
  1199. conditions: new Map([[
  1200. 'async', new Set([
  1201. 'async',
  1202. ])
  1203. ]])
  1204. }
  1205. ],
  1206. ['cite', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
  1207. [
  1208. 'loading', {
  1209. policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_NORMALIZE,
  1210. conditions: new Map([[
  1211. 'loading', new Set([
  1212. 'eager',
  1213. 'lazy',
  1214. ])
  1215. ]])
  1216. }
  1217. ],
  1218. ['poster', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
  1219. [
  1220. 'target', {
  1221. policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_NORMALIZE,
  1222. conditions: new Map([[
  1223. 'target', new Set([
  1224. '_self',
  1225. '_blank',
  1226. ])
  1227. ]])
  1228. }
  1229. ],
  1230. ]));
  1231. /***/ }),
  1232. /***/ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/sanitizer_table.js":
  1233. /*!********************************************************************************************!*\
  1234. !*** ./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/sanitizer_table.js ***!
  1235. \********************************************************************************************/
  1236. /*! no static exports found */
  1237. /***/ (function(module, exports, __webpack_require__) {
  1238. "use strict";
  1239. /**
  1240. * @license
  1241. * SPDX-License-Identifier: Apache-2.0
  1242. */
  1243. Object.defineProperty(exports, "__esModule", { value: true });
  1244. exports.AttributePolicyAction = exports.SanitizerTable = void 0;
  1245. /** Class for holding element and attribute policies used for sanitization. */
  1246. var SanitizerTable = /** @class */ (function () {
  1247. function SanitizerTable(allowedElements, elementPolicies, allowedGlobalAttributes, globalAttributePolicies) {
  1248. this.allowedElements = allowedElements;
  1249. this.elementPolicies = elementPolicies;
  1250. this.allowedGlobalAttributes = allowedGlobalAttributes;
  1251. this.globalAttributePolicies = globalAttributePolicies;
  1252. }
  1253. SanitizerTable.prototype.isAllowedElement = function (elementName) {
  1254. // Note: `HTMLFormElement`s are always dropped, supporting them is very
  1255. // costly because of the DOM clobberring they can cause. The additional code
  1256. // size required to properly work around DOM clobberring issues is large and
  1257. // shouldn't be put on every user of the sanitizer. Thoroughly review
  1258. // b/210975025 and the CLs linked there before you start allowing form
  1259. // elements.
  1260. return elementName.toLowerCase() !== 'form' &&
  1261. (this.allowedElements.has(elementName) ||
  1262. this.elementPolicies.has(elementName));
  1263. };
  1264. SanitizerTable.prototype.getAttributePolicy = function (attributeName, elementName) {
  1265. var elementPolicy = this.elementPolicies.get(elementName);
  1266. if (elementPolicy === null || elementPolicy === void 0 ? void 0 : elementPolicy.has(attributeName)) {
  1267. return elementPolicy.get(attributeName);
  1268. }
  1269. if (this.allowedGlobalAttributes.has(attributeName)) {
  1270. return { policyAction: AttributePolicyAction.KEEP };
  1271. }
  1272. var globalPolicy = this.globalAttributePolicies.get(attributeName);
  1273. return globalPolicy || { policyAction: AttributePolicyAction.DROP };
  1274. };
  1275. return SanitizerTable;
  1276. }());
  1277. exports.SanitizerTable = SanitizerTable;
  1278. /**
  1279. * Values derived from
  1280. * https://godoc.corp.google.com/pkg/google3/third_party/safehtml/sanitizer/policy#AttributePolicy
  1281. */
  1282. var AttributePolicyAction;
  1283. (function (AttributePolicyAction) {
  1284. AttributePolicyAction[AttributePolicyAction["DROP"] = 0] = "DROP";
  1285. AttributePolicyAction[AttributePolicyAction["KEEP"] = 1] = "KEEP";
  1286. AttributePolicyAction[AttributePolicyAction["KEEP_AND_SANITIZE_URL"] = 2] = "KEEP_AND_SANITIZE_URL";
  1287. AttributePolicyAction[AttributePolicyAction["KEEP_AND_NORMALIZE"] = 3] = "KEEP_AND_NORMALIZE";
  1288. AttributePolicyAction[AttributePolicyAction["KEEP_AND_SANITIZE_STYLE"] = 4] = "KEEP_AND_SANITIZE_STYLE";
  1289. })(AttributePolicyAction = exports.AttributePolicyAction || (exports.AttributePolicyAction = {}));
  1290. /***/ }),
  1291. /***/ "./node_modules/safevalues/builders/resource_url_builders.js":
  1292. /*!*******************************************************************!*\
  1293. !*** ./node_modules/safevalues/builders/resource_url_builders.js ***!
  1294. \*******************************************************************/
  1295. /*! no static exports found */
  1296. /***/ (function(module, exports, __webpack_require__) {
  1297. "use strict";
  1298. /**
  1299. * @license
  1300. * SPDX-License-Identifier: Apache-2.0
  1301. */
  1302. Object.defineProperty(exports, "__esModule", { value: true });
  1303. exports.blobUrlFromScript = exports.replaceFragment = exports.appendParams = exports.trustedResourceUrl = void 0;
  1304. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  1305. var resource_url_impl_1 = __webpack_require__(/*! ../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  1306. var script_impl_1 = __webpack_require__(/*! ../internals/script_impl */ "./node_modules/safevalues/internals/script_impl.js");
  1307. var string_literal_1 = __webpack_require__(/*! ../internals/string_literal */ "./node_modules/safevalues/internals/string_literal.js");
  1308. /**
  1309. * Check whether the base url contains a valid origin,
  1310. *
  1311. * A string for an origin must contain only alphanumeric or any of the
  1312. * following: `-.:`, and must not be an IP address. Remember that, as per the
  1313. * documentation for TrustedResourceUrl, the origin must be trustworthy.
  1314. *
  1315. * @param base The base url that contains an origin.
  1316. */
  1317. function hasValidOrigin(base) {
  1318. if (!(/^https:\/\//.test(base) || /^\/\//.test(base))) {
  1319. return false;
  1320. }
  1321. var originStart = base.indexOf('//') + 2;
  1322. var originEnd = base.indexOf('/', originStart);
  1323. // If the base url only contains the prefix (e.g. //), or the slash
  1324. // for the origin is right after the prefix (e.g. ///), the origin is
  1325. // missing.
  1326. if (originEnd <= originStart) {
  1327. throw new Error("Can't interpolate data in a url's origin, " +
  1328. "Please make sure to fully specify the origin, terminated with '/'.");
  1329. }
  1330. var origin = base.substring(originStart, originEnd);
  1331. if (!/^[0-9a-z.:-]+$/i.test(origin)) {
  1332. throw new Error('The origin contains unsupported characters.');
  1333. }
  1334. if (!/^[^:]*(:[0-9]+)?$/i.test(origin)) {
  1335. throw new Error('Invalid port number.');
  1336. }
  1337. if (!/(^|\.)[a-z][^.]*$/i.test(origin)) {
  1338. throw new Error('The top-level domain must start with a letter.');
  1339. }
  1340. return true;
  1341. }
  1342. /**
  1343. * Check whether the base url contains a valid about url at its beginning.
  1344. *
  1345. * An about url is either exactly 'about:blank' or 'about:blank#<str>' where
  1346. * <str> can be an arbitrary string.
  1347. *
  1348. * @param base The base url.
  1349. */
  1350. function isValidAboutUrl(base) {
  1351. if (!/^about:blank/.test(base)) {
  1352. return false;
  1353. }
  1354. if (base !== 'about:blank' && !/^about:blank#/.test(base)) {
  1355. throw new Error('The about url is invalid.');
  1356. }
  1357. return true;
  1358. }
  1359. /**
  1360. * Check whether the base url contains a valid path start at its beginning.
  1361. *
  1362. * A valid path start is either a '/' or a '/' followed by at least one
  1363. * character that is not '/' or '\'.
  1364. *
  1365. * @param base The base url.
  1366. */
  1367. function isValidPathStart(base) {
  1368. if (!/^\//.test(base)) {
  1369. return false;
  1370. }
  1371. if ((base === '/') ||
  1372. (base.length > 1 && base[1] !== '/' && base[1] !== '\\')) {
  1373. return true;
  1374. }
  1375. throw new Error('The path start in the url is invalid.');
  1376. }
  1377. /**
  1378. * Builds TrustedResourceUrl from a template literal.
  1379. *
  1380. * This factory is a template literal tag function. It should be called with
  1381. * a template literal, with or without embedded expressions. For example,
  1382. * trustedResourceUrl`//example.com/${bar}`;
  1383. * or
  1384. * trustedResourceUrl`//example.com`;
  1385. *
  1386. * When this function is called with a template literal without any embedded
  1387. * expressions, the template string may contain anything as the whole URL is
  1388. * a compile-time string constant.
  1389. *
  1390. * When this function is called with a template literal that contains embedded
  1391. * expressions, the template must start with one of the following:
  1392. * - `https://<origin>/`
  1393. * - `//<origin>/`
  1394. * - `/<pathStart>`
  1395. * - `about:blank`
  1396. * - `data:`
  1397. *
  1398. * `<origin>` must contain only alphanumeric or any of the following: `-.:`.
  1399. * Remember that, as per the documentation for TrustedResourceUrl, the origin
  1400. * must be trustworthy. An origin of "example.com" could be set with this
  1401. * method, but would tie the security of your site to the security of
  1402. * example.com. Similarly, formats that potentially cover redirects hosted
  1403. * on a trusted origin are problematic, since that could lead to untrusted
  1404. * origins.
  1405. *
  1406. * `<pathStart>` is either an empty string, or a non empty string that does not
  1407. * start with '/' or '\'.
  1408. * In other words, `/<pathStart>` is either a '/' or a
  1409. * '/' followed by at least one character that is not '/' or '\'.
  1410. *
  1411. * `data:` (data URL) does not allow embedded expressions in the template
  1412. * literal input.
  1413. *
  1414. * All embedded expressions are URL encoded when they are interpolated. Do not
  1415. * embed expressions that are already URL encoded as they will be double encoded
  1416. * by the builder.
  1417. *
  1418. * @param templateObj This contains the literal part of the template literal.
  1419. * @param rest This represents the template's embedded expressions.
  1420. */
  1421. function trustedResourceUrl(templateObj) {
  1422. var rest = [];
  1423. for (var _i = 1; _i < arguments.length; _i++) {
  1424. rest[_i - 1] = arguments[_i];
  1425. }
  1426. // Check if templateObj is actually from a template literal.
  1427. if (true) {
  1428. (0, string_literal_1.assertIsTemplateObject)(templateObj, true, 'trustedResourceUrl is a template literal tag function and ' +
  1429. 'can only be called as such (e.g. trustedResourceUrl`/somepath.js`)');
  1430. }
  1431. if (rest.length === 0) {
  1432. return (0, resource_url_impl_1.createResourceUrl)(templateObj[0]);
  1433. }
  1434. var base = templateObj[0].toLowerCase();
  1435. if (true) {
  1436. if (/^data:/.test(base)) {
  1437. throw new Error('Data URLs cannot have expressions in the template literal input.');
  1438. }
  1439. if (!hasValidOrigin(base) && !isValidPathStart(base) &&
  1440. !isValidAboutUrl(base)) {
  1441. throw new Error('Trying to interpolate expressions in an unsupported url format.');
  1442. }
  1443. }
  1444. var urlParts = [templateObj[0]];
  1445. for (var i = 0; i < rest.length; i++) {
  1446. urlParts.push(encodeURIComponent(rest[i]));
  1447. urlParts.push(templateObj[i + 1]);
  1448. }
  1449. return (0, resource_url_impl_1.createResourceUrl)(urlParts.join(''));
  1450. }
  1451. exports.trustedResourceUrl = trustedResourceUrl;
  1452. /**
  1453. * Creates a new TrustedResourceUrl with params added to the URL's search
  1454. * parameters.
  1455. *
  1456. * @param params What to add to the URL. Parameters with value `null` or
  1457. * `undefined` are skipped. Both keys and values will be encoded. Do not pass
  1458. * pre-encoded values as this will result them being double encoded. If the
  1459. * value is an array then the same parameter is added for every element in the
  1460. * array.
  1461. */
  1462. function appendParams(trustedUrl, params) {
  1463. var url = (0, resource_url_impl_1.unwrapResourceUrl)(trustedUrl).toString();
  1464. if (/#/.test(url)) {
  1465. var message = '';
  1466. if (true) {
  1467. message = "Found a hash in url (".concat(url, "), appending not supported");
  1468. }
  1469. throw new Error(message);
  1470. }
  1471. var separator = /\?/.test(url) ? '&' : '?';
  1472. // for-of has a big polyfill.
  1473. // tslint:disable-next-line:ban-iterable-foreach
  1474. params.forEach(function (value, key) {
  1475. var values = (value instanceof Array) ? value : [value];
  1476. for (var i = 0; i < values.length; i++) {
  1477. var v = values[i];
  1478. if (v === null || v === undefined) {
  1479. continue;
  1480. }
  1481. url += separator + encodeURIComponent(key) + '=' +
  1482. encodeURIComponent(String(v));
  1483. separator = '&';
  1484. }
  1485. });
  1486. return (0, resource_url_impl_1.createResourceUrl)(url);
  1487. }
  1488. exports.appendParams = appendParams;
  1489. var BEFORE_FRAGMENT_REGEXP = /[^#]*/;
  1490. /**
  1491. * Creates a new TrustedResourceUrl based on an existing one but with the
  1492. * addition of a fragment (the part after `#`). If the URL already has a
  1493. * fragment, it is replaced with the new one.
  1494. * @param fragment The fragment to add to the URL, verbatim, without the leading
  1495. * `#`. No additional escaping is applied.
  1496. */
  1497. function replaceFragment(trustedUrl, fragment) {
  1498. var urlString = (0, resource_url_impl_1.unwrapResourceUrl)(trustedUrl).toString();
  1499. return (0, resource_url_impl_1.createResourceUrl)(BEFORE_FRAGMENT_REGEXP.exec(urlString)[0] + '#' + fragment);
  1500. }
  1501. exports.replaceFragment = replaceFragment;
  1502. /**
  1503. * Creates a `TrustedResourceUrl` by generating a `Blob` from a
  1504. * `SafeScript` and then calling `URL.createObjectURL` with that `Blob`.
  1505. *
  1506. * Caller must call `URL.revokeObjectUrl()` on the stringified url to
  1507. * release the underlying `Blob`.
  1508. */
  1509. function blobUrlFromScript(safeScript) {
  1510. var scriptContent = (0, script_impl_1.unwrapScript)(safeScript).toString();
  1511. var blob = new Blob([scriptContent], { type: 'text/javascript' });
  1512. return (0, resource_url_impl_1.createResourceUrl)(URL.createObjectURL(blob));
  1513. }
  1514. exports.blobUrlFromScript = blobUrlFromScript;
  1515. /***/ }),
  1516. /***/ "./node_modules/safevalues/builders/script_builders.js":
  1517. /*!*************************************************************!*\
  1518. !*** ./node_modules/safevalues/builders/script_builders.js ***!
  1519. \*************************************************************/
  1520. /*! no static exports found */
  1521. /***/ (function(module, exports, __webpack_require__) {
  1522. "use strict";
  1523. /**
  1524. * @license
  1525. * SPDX-License-Identifier: Apache-2.0
  1526. */
  1527. Object.defineProperty(exports, "__esModule", { value: true });
  1528. exports.safeScriptWithArgs = exports.scriptFromJson = exports.concatScripts = exports.safeScript = void 0;
  1529. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  1530. var script_impl_1 = __webpack_require__(/*! ../internals/script_impl */ "./node_modules/safevalues/internals/script_impl.js");
  1531. var string_literal_1 = __webpack_require__(/*! ../internals/string_literal */ "./node_modules/safevalues/internals/string_literal.js");
  1532. /**
  1533. * Creates a SafeScript object from a template literal (without any embedded
  1534. * expressions).
  1535. *
  1536. * This function is a template literal tag function. It should be called with
  1537. * a template literal that does not contain any expressions. For example,
  1538. * safeScript`foo`;
  1539. *
  1540. * @param templateObj This contains the literal part of the template literal.
  1541. */
  1542. function safeScript(templateObj) {
  1543. if (true) {
  1544. (0, string_literal_1.assertIsTemplateObject)(templateObj, false, 'safeScript is a template literal tag function ' +
  1545. 'that only accepts template literals without expressions. ' +
  1546. 'For example, safeScript`foo`;');
  1547. }
  1548. return (0, script_impl_1.createScript)(templateObj[0]);
  1549. }
  1550. exports.safeScript = safeScript;
  1551. /** Creates a `SafeScript` value by concatenating multiple `SafeScript`s. */
  1552. function concatScripts(scripts) {
  1553. return (0, script_impl_1.createScript)(scripts.map(script_impl_1.unwrapScript).join(''));
  1554. }
  1555. exports.concatScripts = concatScripts;
  1556. /**
  1557. * Converts a serializable value into JSON that is safe to interpolate into a
  1558. * script context. In particular it escapes < characters so that a value of
  1559. * "</script>" doesn't break out of the context.
  1560. * @param value The value to serialize.
  1561. */
  1562. function scriptFromJson(value) {
  1563. return (0, script_impl_1.createScript)(JSON.stringify(value).replace(/</g, '\\x3c'));
  1564. }
  1565. exports.scriptFromJson = scriptFromJson;
  1566. /**
  1567. * Creates a `SafeScript` object from a template literal (without any embedded
  1568. * expressions) along with additional arguments that the script should have
  1569. * access to. These arguments will be JSON-encoded and passed to the script as
  1570. * a function call.
  1571. * @example
  1572. * ```ts
  1573. * safeScriptWithArgs`function (name, props) {
  1574. * console.log(name + ' is ' + props.age);
  1575. * }`('Bob', { 'age': 42 })
  1576. * ```
  1577. * would return a `SafeScript` that represents the following code:
  1578. * ```js
  1579. * (function (name, props) {
  1580. * console.log(name + ' is ' + props.age);
  1581. * })("Bob",{"age":42})
  1582. * ```
  1583. * @note Be careful when passing objects as arguments, as unquoted property
  1584. * names may be changed during compilation.
  1585. * @param templateObj This contains the literal part of the template literal.
  1586. * @param emptyArgs Expressions that evaluate to the empty string to enable
  1587. * inline comments.
  1588. */
  1589. function safeScriptWithArgs(templateObj) {
  1590. var emptyArgs = [];
  1591. for (var _i = 1; _i < arguments.length; _i++) {
  1592. emptyArgs[_i - 1] = arguments[_i];
  1593. }
  1594. if (true) {
  1595. if (emptyArgs.some(function (a) { return a !== ''; })) {
  1596. throw new Error('safeScriptWithArgs only allows empty string expressions ' +
  1597. 'to enable inline comments.');
  1598. }
  1599. (0, string_literal_1.assertIsTemplateObject)(templateObj, true, 'safeScriptWithArgs is a template literal tag function ' +
  1600. 'that only accepts template literals. ' +
  1601. 'For example, safeScriptWithArgs`foo`;');
  1602. }
  1603. return function () {
  1604. var argValues = [];
  1605. for (var _i = 0; _i < arguments.length; _i++) {
  1606. argValues[_i] = arguments[_i];
  1607. }
  1608. var values = argValues.map(function (v) { return scriptFromJson(v).toString(); });
  1609. return (0, script_impl_1.createScript)("(".concat(templateObj.join(''), ")(").concat(values.join(','), ")"));
  1610. };
  1611. }
  1612. exports.safeScriptWithArgs = safeScriptWithArgs;
  1613. /***/ }),
  1614. /***/ "./node_modules/safevalues/builders/sensitive_attributes.js":
  1615. /*!******************************************************************!*\
  1616. !*** ./node_modules/safevalues/builders/sensitive_attributes.js ***!
  1617. \******************************************************************/
  1618. /*! no static exports found */
  1619. /***/ (function(module, exports, __webpack_require__) {
  1620. "use strict";
  1621. /**
  1622. * @license
  1623. * SPDX-License-Identifier: Apache-2.0
  1624. */
  1625. Object.defineProperty(exports, "__esModule", { value: true });
  1626. exports.SECURITY_SENSITIVE_ATTRIBUTES = void 0;
  1627. // AUTOGENERATED. DO NOT EDIT.
  1628. /**
  1629. * Security sensitive attribute names that should not be set through
  1630. * `setAttribute` or similar functions.
  1631. */
  1632. exports.SECURITY_SENSITIVE_ATTRIBUTES = [
  1633. 'href',
  1634. 'rel',
  1635. 'src',
  1636. 'srcdoc',
  1637. 'action',
  1638. 'formaction',
  1639. 'sandbox',
  1640. 'cite',
  1641. 'poster',
  1642. 'icon',
  1643. ];
  1644. /***/ }),
  1645. /***/ "./node_modules/safevalues/builders/style_builders.js":
  1646. /*!************************************************************!*\
  1647. !*** ./node_modules/safevalues/builders/style_builders.js ***!
  1648. \************************************************************/
  1649. /*! no static exports found */
  1650. /***/ (function(module, exports, __webpack_require__) {
  1651. "use strict";
  1652. /**
  1653. * @license
  1654. * SPDX-License-Identifier: Apache-2.0
  1655. */
  1656. Object.defineProperty(exports, "__esModule", { value: true });
  1657. exports.concatStyles = exports.safeStyle = void 0;
  1658. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  1659. var string_literal_1 = __webpack_require__(/*! ../internals/string_literal */ "./node_modules/safevalues/internals/string_literal.js");
  1660. var style_impl_1 = __webpack_require__(/*! ../internals/style_impl */ "./node_modules/safevalues/internals/style_impl.js");
  1661. /**
  1662. * Creates a SafeStyle object from a template literal (without any embedded
  1663. * expressions).
  1664. *
  1665. * ` style` should be in the format
  1666. * ` name: value; [name: value; ...]` and must not have any < or >
  1667. * characters in it. This is so that SafeStyle's contract is preserved,
  1668. * allowing the SafeStyle to correctly be interpreted as a sequence of CSS
  1669. * declarations and without affecting the syntactic structure of any
  1670. * surrounding CSS and HTML.
  1671. *
  1672. * This function is a template literal tag function. It should be called with
  1673. * a template literal that does not contain any expressions. For example,
  1674. * safeStyle`foo`;
  1675. * This function first checks if it is called with a literal template, and
  1676. * then performs basic sanity checks on the format of ` style`
  1677. * but does not constrain the format of ` name} and {@code value`, except
  1678. * for disallowing tag characters.
  1679. *
  1680. * @param templateObj This contains the literal part of the template literal.
  1681. */
  1682. function safeStyle(templateObj) {
  1683. if (true) {
  1684. (0, string_literal_1.assertIsTemplateObject)(templateObj, false, 'safeStyle is a template literal tag function ' +
  1685. 'that only accepts template literals without expressions. ' +
  1686. 'For example, safeStyle`foo`;');
  1687. }
  1688. var style = templateObj[0];
  1689. if (true) {
  1690. if (/[<>]/.test(style)) {
  1691. throw new Error('Forbidden characters in style string: ' + style);
  1692. }
  1693. if (!/;$/.test(style)) {
  1694. throw new Error('Style string does not end with ";": ' + style);
  1695. }
  1696. if (!/:/.test(style)) {
  1697. throw new Error('Style string should contain one or more ":": ' + style);
  1698. }
  1699. }
  1700. return (0, style_impl_1.createStyle)(style);
  1701. }
  1702. exports.safeStyle = safeStyle;
  1703. /** Creates a `SafeStyle` value by concatenating multiple `SafeStyle`s. */
  1704. function concatStyles(styles) {
  1705. return (0, style_impl_1.createStyle)(styles.map(style_impl_1.unwrapStyle).join(''));
  1706. }
  1707. exports.concatStyles = concatStyles;
  1708. /***/ }),
  1709. /***/ "./node_modules/safevalues/builders/style_sheet_builders.js":
  1710. /*!******************************************************************!*\
  1711. !*** ./node_modules/safevalues/builders/style_sheet_builders.js ***!
  1712. \******************************************************************/
  1713. /*! no static exports found */
  1714. /***/ (function(module, exports, __webpack_require__) {
  1715. "use strict";
  1716. /**
  1717. * @license
  1718. * SPDX-License-Identifier: Apache-2.0
  1719. */
  1720. Object.defineProperty(exports, "__esModule", { value: true });
  1721. exports.concatStyleSheets = exports.safeStyleSheet = void 0;
  1722. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  1723. var string_literal_1 = __webpack_require__(/*! ../internals/string_literal */ "./node_modules/safevalues/internals/string_literal.js");
  1724. var style_sheet_impl_1 = __webpack_require__(/*! ../internals/style_sheet_impl */ "./node_modules/safevalues/internals/style_sheet_impl.js");
  1725. /**
  1726. * Creates a SafeStyleSheet object from a template literal (without any
  1727. * embedded expressions).
  1728. *
  1729. * This function is a template literal tag function. It should be called with
  1730. * a template literal that does not contain any expressions. For example,
  1731. * safeStyleSheet`foo`;
  1732. * The argument must not have any < or > characters in it. This is so that
  1733. * SafeStyleSheet's contract is preserved, allowing the SafeStyleSheet to
  1734. * correctly be interpreted as a sequence of CSS declarations and without
  1735. * affecting the syntactic structure of any surrounding CSS and HTML.
  1736. *
  1737. * @param templateObj This contains the literal part of the template literal.
  1738. */
  1739. function safeStyleSheet(templateObj) {
  1740. if (true) {
  1741. (0, string_literal_1.assertIsTemplateObject)(templateObj, false, 'safeStyleSheet is a template literal tag ' +
  1742. 'function that only accepts template literals without ' +
  1743. 'expressions. For example, safeStyleSheet`foo`;');
  1744. }
  1745. var styleSheet = templateObj[0];
  1746. if (true) {
  1747. if (/[<>]/.test(styleSheet)) {
  1748. throw new Error('Forbidden characters in styleSheet string: ' + styleSheet);
  1749. }
  1750. }
  1751. return (0, style_sheet_impl_1.createStyleSheet)(styleSheet);
  1752. }
  1753. exports.safeStyleSheet = safeStyleSheet;
  1754. /**
  1755. * Creates a `SafeStyleSheet` value by concatenating multiple `SafeStyleSheet`s.
  1756. */
  1757. function concatStyleSheets(sheets) {
  1758. return (0, style_sheet_impl_1.createStyleSheet)(sheets.map(style_sheet_impl_1.unwrapStyleSheet).join(''));
  1759. }
  1760. exports.concatStyleSheets = concatStyleSheets;
  1761. /***/ }),
  1762. /***/ "./node_modules/safevalues/builders/url_sanitizer.js":
  1763. /*!***********************************************************!*\
  1764. !*** ./node_modules/safevalues/builders/url_sanitizer.js ***!
  1765. \***********************************************************/
  1766. /*! no static exports found */
  1767. /***/ (function(module, exports, __webpack_require__) {
  1768. "use strict";
  1769. /**
  1770. * @license
  1771. * SPDX-License-Identifier: Apache-2.0
  1772. */
  1773. Object.defineProperty(exports, "__esModule", { value: true });
  1774. exports.restrictivelySanitizeUrl = exports.unwrapUrlOrSanitize = exports.sanitizeJavascriptUrl = void 0;
  1775. /**
  1776. * @fileoverview Provides functions to enforce the SafeUrl contract at the sink
  1777. * level.
  1778. */
  1779. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  1780. function extractScheme(url) {
  1781. var parsedUrl;
  1782. try {
  1783. parsedUrl = new URL(url);
  1784. }
  1785. catch (e) {
  1786. // According to https://url.spec.whatwg.org/#constructors, the URL
  1787. // constructor with one parameter throws if `url` is not absolute. In this
  1788. // case, we are sure that no explicit scheme (javascript: ) is set.
  1789. // This can also be a URL parsing error, but in this case the URL won't be
  1790. // run anyway.
  1791. return 'https:';
  1792. }
  1793. return parsedUrl.protocol;
  1794. }
  1795. // We can't use an ES6 Set here because gws somehow depends on this code and
  1796. // doesn't want to pay the cost of a polyfill.
  1797. var ALLOWED_SCHEMES = ['data:', 'http:', 'https:', 'mailto:', 'ftp:'];
  1798. /**
  1799. * Checks that the URL scheme is not javascript.
  1800. * The URL parsing relies on the URL API in browsers that support it.
  1801. * @param url The URL to sanitize for a SafeUrl sink.
  1802. * @return undefined if url has a javascript: scheme, the original URL
  1803. * otherwise.
  1804. */
  1805. function sanitizeJavascriptUrl(url) {
  1806. var parsedScheme = extractScheme(url);
  1807. if (parsedScheme === 'javascript:') {
  1808. if (true) {
  1809. console.error("A URL with content '".concat(url, "' was sanitized away."));
  1810. }
  1811. return undefined;
  1812. }
  1813. return url;
  1814. }
  1815. exports.sanitizeJavascriptUrl = sanitizeJavascriptUrl;
  1816. /**
  1817. * Adapter to sanitize string URLs in DOM sink wrappers.
  1818. * @return undefined if the URL was sanitized.
  1819. */
  1820. function unwrapUrlOrSanitize(url) {
  1821. return sanitizeJavascriptUrl(url);
  1822. }
  1823. exports.unwrapUrlOrSanitize = unwrapUrlOrSanitize;
  1824. /**
  1825. * Sanitizes a URL restrictively.
  1826. * This sanitizer protects against XSS and potentially other uncommon and
  1827. * undesirable schemes that an attacker could use for e.g. phishing (tel:,
  1828. * callto: ssh: etc schemes). This sanitizer is primarily meant to be used by
  1829. * the HTML sanitizer.
  1830. */
  1831. function restrictivelySanitizeUrl(url) {
  1832. var parsedScheme = extractScheme(url);
  1833. if (parsedScheme !== undefined &&
  1834. ALLOWED_SCHEMES.indexOf(parsedScheme.toLowerCase()) !== -1) {
  1835. return url;
  1836. }
  1837. return 'about:invalid#zClosurez';
  1838. }
  1839. exports.restrictivelySanitizeUrl = restrictivelySanitizeUrl;
  1840. /***/ }),
  1841. /***/ "./node_modules/safevalues/dom/elements/anchor.js":
  1842. /*!********************************************************!*\
  1843. !*** ./node_modules/safevalues/dom/elements/anchor.js ***!
  1844. \********************************************************/
  1845. /*! no static exports found */
  1846. /***/ (function(module, exports, __webpack_require__) {
  1847. "use strict";
  1848. /**
  1849. * @license
  1850. * SPDX-License-Identifier: Apache-2.0
  1851. */
  1852. Object.defineProperty(exports, "__esModule", { value: true });
  1853. exports.setHref = void 0;
  1854. var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  1855. /**
  1856. * Sets the Href attribute from the given Url.
  1857. */
  1858. function setHref(anchor, url) {
  1859. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  1860. if (sanitizedUrl !== undefined) {
  1861. anchor.href = sanitizedUrl;
  1862. }
  1863. }
  1864. exports.setHref = setHref;
  1865. /***/ }),
  1866. /***/ "./node_modules/safevalues/dom/elements/area.js":
  1867. /*!******************************************************!*\
  1868. !*** ./node_modules/safevalues/dom/elements/area.js ***!
  1869. \******************************************************/
  1870. /*! no static exports found */
  1871. /***/ (function(module, exports, __webpack_require__) {
  1872. "use strict";
  1873. /**
  1874. * @license
  1875. * SPDX-License-Identifier: Apache-2.0
  1876. */
  1877. Object.defineProperty(exports, "__esModule", { value: true });
  1878. exports.setHref = void 0;
  1879. var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  1880. /**
  1881. * Sets the Href attribute from the given Url.
  1882. */
  1883. function setHref(area, url) {
  1884. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  1885. if (sanitizedUrl !== undefined) {
  1886. area.href = sanitizedUrl;
  1887. }
  1888. }
  1889. exports.setHref = setHref;
  1890. /***/ }),
  1891. /***/ "./node_modules/safevalues/dom/elements/button.js":
  1892. /*!********************************************************!*\
  1893. !*** ./node_modules/safevalues/dom/elements/button.js ***!
  1894. \********************************************************/
  1895. /*! no static exports found */
  1896. /***/ (function(module, exports, __webpack_require__) {
  1897. "use strict";
  1898. /**
  1899. * @license
  1900. * SPDX-License-Identifier: Apache-2.0
  1901. */
  1902. Object.defineProperty(exports, "__esModule", { value: true });
  1903. exports.setFormaction = void 0;
  1904. var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  1905. /**
  1906. * Sets the Formaction attribute from the given Url.
  1907. */
  1908. function setFormaction(button, url) {
  1909. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  1910. if (sanitizedUrl !== undefined) {
  1911. button.formAction = sanitizedUrl;
  1912. }
  1913. }
  1914. exports.setFormaction = setFormaction;
  1915. /***/ }),
  1916. /***/ "./node_modules/safevalues/dom/elements/element.js":
  1917. /*!*********************************************************!*\
  1918. !*** ./node_modules/safevalues/dom/elements/element.js ***!
  1919. \*********************************************************/
  1920. /*! no static exports found */
  1921. /***/ (function(module, exports, __webpack_require__) {
  1922. "use strict";
  1923. /**
  1924. * @license
  1925. * SPDX-License-Identifier: Apache-2.0
  1926. */
  1927. var __read = (this && this.__read) || function (o, n) {
  1928. var m = typeof Symbol === "function" && o[Symbol.iterator];
  1929. if (!m) return o;
  1930. var i = m.call(o), r, ar = [], e;
  1931. try {
  1932. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  1933. }
  1934. catch (error) { e = { error: error }; }
  1935. finally {
  1936. try {
  1937. if (r && !r.done && (m = i["return"])) m.call(i);
  1938. }
  1939. finally { if (e) throw e.error; }
  1940. }
  1941. return ar;
  1942. };
  1943. var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
  1944. if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
  1945. if (ar || !(i in from)) {
  1946. if (!ar) ar = Array.prototype.slice.call(from, 0, i);
  1947. ar[i] = from[i];
  1948. }
  1949. }
  1950. return to.concat(ar || Array.prototype.slice.call(from));
  1951. };
  1952. Object.defineProperty(exports, "__esModule", { value: true });
  1953. exports.setPrefixedAttribute = exports.buildPrefixedAttributeSetter = exports.insertAdjacentHtml = exports.setCssText = exports.setOuterHtml = exports.setInnerHtml = void 0;
  1954. /**
  1955. * @fileoverview This contains safe wrappers for properties that aren't specific
  1956. * to one kind of HTMLElement (like innerHTML), plus other setters and functions
  1957. * that are not tied to elements (like location.href or Worker constructor).
  1958. */
  1959. var attribute_impl_1 = __webpack_require__(/*! ../../internals/attribute_impl */ "./node_modules/safevalues/internals/attribute_impl.js");
  1960. var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  1961. var style_impl_1 = __webpack_require__(/*! ../../internals/style_impl */ "./node_modules/safevalues/internals/style_impl.js");
  1962. /**
  1963. * Safely set {@link Element.innerHTML} on a given ShadowRoot or Element which
  1964. * may not be a `<script>` element or a `<style>` element.
  1965. */
  1966. function setInnerHtml(elOrRoot, v) {
  1967. if (isElement(elOrRoot)) {
  1968. throwIfScriptOrStyle(elOrRoot);
  1969. }
  1970. elOrRoot.innerHTML = (0, html_impl_1.unwrapHtml)(v);
  1971. }
  1972. exports.setInnerHtml = setInnerHtml;
  1973. /**
  1974. * Safely set {@link Element.outerHTML} for the given Element.
  1975. */
  1976. function setOuterHtml(e, v) {
  1977. var parent = e.parentElement;
  1978. if (parent !== null) {
  1979. throwIfScriptOrStyle(parent);
  1980. }
  1981. e.outerHTML = (0, html_impl_1.unwrapHtml)(v);
  1982. }
  1983. exports.setOuterHtml = setOuterHtml;
  1984. /**
  1985. * Set `ElementCSSInlineStyle.cssText` for the given `ElementCSSInlineStyle`.
  1986. */
  1987. function setCssText(e, v) {
  1988. e.style.cssText = (0, style_impl_1.unwrapStyle)(v);
  1989. }
  1990. exports.setCssText = setCssText;
  1991. /**
  1992. * Safely call {@link Element.insertAdjacentHTML} for the given Element.
  1993. */
  1994. function insertAdjacentHtml(element, position, v) {
  1995. var tagContext = (position === 'beforebegin' || position === 'afterend') ?
  1996. element.parentElement :
  1997. element;
  1998. if (tagContext !== null) {
  1999. throwIfScriptOrStyle(tagContext);
  2000. }
  2001. element.insertAdjacentHTML(position, (0, html_impl_1.unwrapHtml)(v));
  2002. }
  2003. exports.insertAdjacentHtml = insertAdjacentHtml;
  2004. /**
  2005. * Given a set of known-to-be-safe prefixes (e.g., "data-", "aria-", "js"),
  2006. * return a setter function that allows you to set attributes on an element,
  2007. * as long as the names of the attributes to be set has one of the prefixes.
  2008. *
  2009. * The returned setter ensures that setting any dangerous attribute, e.g.,
  2010. * "src", "href" will cause an exception. This is intended to be used as the
  2011. * safe alterantive of `Element#setAttribute`, when applications need to set
  2012. * attributes that do not have security implications and do not have a
  2013. * corresponding DOM property.
  2014. */
  2015. function buildPrefixedAttributeSetter(prefix) {
  2016. var otherPrefixes = [];
  2017. for (var _i = 1; _i < arguments.length; _i++) {
  2018. otherPrefixes[_i - 1] = arguments[_i];
  2019. }
  2020. var prefixes = __spreadArray([prefix], __read(otherPrefixes), false);
  2021. return function (e, attr, value) {
  2022. setPrefixedAttribute(prefixes, e, attr, value);
  2023. };
  2024. }
  2025. exports.buildPrefixedAttributeSetter = buildPrefixedAttributeSetter;
  2026. /**
  2027. * The safe alternative to Element#setAttribute. The function takes a list of
  2028. * `SafeAttributePrefix`, making developer intention explicit. The attribute
  2029. * to be set must has one of the safe prefixes, otherwise the function throws
  2030. * an Error.
  2031. */
  2032. function setPrefixedAttribute(attrPrefixes, e, attr, value) {
  2033. if (attrPrefixes.length === 0) {
  2034. throw new Error('No prefixes are provided');
  2035. }
  2036. var prefixes = attrPrefixes.map(function (s) { return (0, attribute_impl_1.unwrapAttributePrefix)(s); });
  2037. var attrLower = attr.toLowerCase();
  2038. if (prefixes.every(function (p) { return attrLower.indexOf(p) !== 0; })) {
  2039. throw new Error("Attribute \"".concat(attr, "\" does not match any of the allowed prefixes."));
  2040. }
  2041. e.setAttribute(attr, value);
  2042. }
  2043. exports.setPrefixedAttribute = setPrefixedAttribute;
  2044. function throwIfScriptOrStyle(element) {
  2045. if (element.tagName.toLowerCase() === 'script') {
  2046. throw new Error('Use setTextContent with a SafeScript.');
  2047. }
  2048. else if (element.tagName.toLowerCase() === 'style') {
  2049. throw new Error('Use setTextContent with a SafeStyleSheet.');
  2050. }
  2051. }
  2052. function isElement(elOrRoot) {
  2053. return elOrRoot.tagName !== undefined;
  2054. }
  2055. /***/ }),
  2056. /***/ "./node_modules/safevalues/dom/elements/embed.js":
  2057. /*!*******************************************************!*\
  2058. !*** ./node_modules/safevalues/dom/elements/embed.js ***!
  2059. \*******************************************************/
  2060. /*! no static exports found */
  2061. /***/ (function(module, exports, __webpack_require__) {
  2062. "use strict";
  2063. /**
  2064. * @license
  2065. * SPDX-License-Identifier: Apache-2.0
  2066. */
  2067. Object.defineProperty(exports, "__esModule", { value: true });
  2068. exports.setSrc = void 0;
  2069. var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  2070. /**
  2071. * Sets the Src attribute from the given SafeUrl.
  2072. */
  2073. function setSrc(embedEl, url) {
  2074. embedEl.src = (0, resource_url_impl_1.unwrapResourceUrl)(url);
  2075. }
  2076. exports.setSrc = setSrc;
  2077. /***/ }),
  2078. /***/ "./node_modules/safevalues/dom/elements/form.js":
  2079. /*!******************************************************!*\
  2080. !*** ./node_modules/safevalues/dom/elements/form.js ***!
  2081. \******************************************************/
  2082. /*! no static exports found */
  2083. /***/ (function(module, exports, __webpack_require__) {
  2084. "use strict";
  2085. /**
  2086. * @license
  2087. * SPDX-License-Identifier: Apache-2.0
  2088. */
  2089. Object.defineProperty(exports, "__esModule", { value: true });
  2090. exports.setAction = void 0;
  2091. var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  2092. /**
  2093. * Sets the Action attribute from the given Url.
  2094. */
  2095. function setAction(form, url) {
  2096. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  2097. if (sanitizedUrl !== undefined) {
  2098. form.action = sanitizedUrl;
  2099. }
  2100. }
  2101. exports.setAction = setAction;
  2102. /***/ }),
  2103. /***/ "./node_modules/safevalues/dom/elements/iframe.js":
  2104. /*!********************************************************!*\
  2105. !*** ./node_modules/safevalues/dom/elements/iframe.js ***!
  2106. \********************************************************/
  2107. /*! no static exports found */
  2108. /***/ (function(module, exports, __webpack_require__) {
  2109. "use strict";
  2110. /**
  2111. * @license
  2112. * SPDX-License-Identifier: Apache-2.0
  2113. */
  2114. Object.defineProperty(exports, "__esModule", { value: true });
  2115. exports.setSrcdoc = exports.setSrc = void 0;
  2116. /**
  2117. * @fileoverview Safe iframe helpers and go/intents-for-iframes-for-closure
  2118. */
  2119. var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  2120. var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  2121. /** Sets the Src attribute using a TrustedResourceUrl */
  2122. function setSrc(iframe, v) {
  2123. iframe.src = (0, resource_url_impl_1.unwrapResourceUrl)(v).toString();
  2124. }
  2125. exports.setSrc = setSrc;
  2126. /** Sets the Srcdoc attribute using a SafeHtml */
  2127. function setSrcdoc(iframe, v) {
  2128. iframe.srcdoc = (0, html_impl_1.unwrapHtml)(v);
  2129. }
  2130. exports.setSrcdoc = setSrcdoc;
  2131. /***/ }),
  2132. /***/ "./node_modules/safevalues/dom/elements/input.js":
  2133. /*!*******************************************************!*\
  2134. !*** ./node_modules/safevalues/dom/elements/input.js ***!
  2135. \*******************************************************/
  2136. /*! no static exports found */
  2137. /***/ (function(module, exports, __webpack_require__) {
  2138. "use strict";
  2139. /**
  2140. * @license
  2141. * SPDX-License-Identifier: Apache-2.0
  2142. */
  2143. Object.defineProperty(exports, "__esModule", { value: true });
  2144. exports.setFormaction = void 0;
  2145. var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  2146. /**
  2147. * Sets the Formaction attribute from the given Url.
  2148. */
  2149. function setFormaction(input, url) {
  2150. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  2151. if (sanitizedUrl !== undefined) {
  2152. input.formAction = sanitizedUrl;
  2153. }
  2154. }
  2155. exports.setFormaction = setFormaction;
  2156. /***/ }),
  2157. /***/ "./node_modules/safevalues/dom/elements/link.js":
  2158. /*!******************************************************!*\
  2159. !*** ./node_modules/safevalues/dom/elements/link.js ***!
  2160. \******************************************************/
  2161. /*! no static exports found */
  2162. /***/ (function(module, exports, __webpack_require__) {
  2163. "use strict";
  2164. /**
  2165. * @license
  2166. * SPDX-License-Identifier: Apache-2.0
  2167. */
  2168. Object.defineProperty(exports, "__esModule", { value: true });
  2169. exports.setHrefAndRel = void 0;
  2170. var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  2171. var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  2172. var SAFE_URL_REL_VALUES = [
  2173. 'alternate',
  2174. 'author',
  2175. 'bookmark',
  2176. 'canonical',
  2177. 'cite',
  2178. 'help',
  2179. 'icon',
  2180. 'license',
  2181. 'next',
  2182. 'prefetch',
  2183. 'dns-prefetch',
  2184. 'prerender',
  2185. 'preconnect',
  2186. 'preload',
  2187. 'prev',
  2188. 'search',
  2189. 'subresource',
  2190. ];
  2191. function setHrefAndRel(link, url, rel) {
  2192. if (url instanceof resource_url_impl_1.TrustedResourceUrl) {
  2193. link.href = (0, resource_url_impl_1.unwrapResourceUrl)(url).toString();
  2194. }
  2195. else {
  2196. if (SAFE_URL_REL_VALUES.indexOf(rel) === -1) {
  2197. throw new Error("TrustedResourceUrl href attribute required with rel=\"".concat(rel, "\""));
  2198. }
  2199. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  2200. if (sanitizedUrl === undefined) {
  2201. return;
  2202. }
  2203. link.href = sanitizedUrl;
  2204. }
  2205. link.rel = rel;
  2206. }
  2207. exports.setHrefAndRel = setHrefAndRel;
  2208. /***/ }),
  2209. /***/ "./node_modules/safevalues/dom/elements/object.js":
  2210. /*!********************************************************!*\
  2211. !*** ./node_modules/safevalues/dom/elements/object.js ***!
  2212. \********************************************************/
  2213. /*! no static exports found */
  2214. /***/ (function(module, exports, __webpack_require__) {
  2215. "use strict";
  2216. /**
  2217. * @license
  2218. * SPDX-License-Identifier: Apache-2.0
  2219. */
  2220. Object.defineProperty(exports, "__esModule", { value: true });
  2221. exports.setData = void 0;
  2222. var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  2223. /** Sets the data attribute using a TrustedResourceUrl */
  2224. function setData(obj, v) {
  2225. obj.data = (0, resource_url_impl_1.unwrapResourceUrl)(v);
  2226. }
  2227. exports.setData = setData;
  2228. /***/ }),
  2229. /***/ "./node_modules/safevalues/dom/elements/script.js":
  2230. /*!********************************************************!*\
  2231. !*** ./node_modules/safevalues/dom/elements/script.js ***!
  2232. \********************************************************/
  2233. /*! no static exports found */
  2234. /***/ (function(module, exports, __webpack_require__) {
  2235. "use strict";
  2236. /**
  2237. * @license
  2238. * SPDX-License-Identifier: Apache-2.0
  2239. */
  2240. Object.defineProperty(exports, "__esModule", { value: true });
  2241. exports.setSrc = exports.setTextContent = void 0;
  2242. var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  2243. var script_impl_1 = __webpack_require__(/*! ../../internals/script_impl */ "./node_modules/safevalues/internals/script_impl.js");
  2244. /** Returns CSP nonce, if set for any script tag. */
  2245. function getScriptNonceFromWindow(win) {
  2246. var _a;
  2247. var doc = win.document;
  2248. // document.querySelector can be undefined in non-browser environments.
  2249. var script = (_a = doc.querySelector) === null || _a === void 0 ? void 0 : _a.call(doc, 'script[nonce]');
  2250. if (script) {
  2251. // Try to get the nonce from the IDL property first, because browsers that
  2252. // implement additional nonce protection features (currently only Chrome) to
  2253. // prevent nonce stealing via CSS do not expose the nonce via attributes.
  2254. // See https://github.com/whatwg/html/issues/2369
  2255. return script['nonce'] || script.getAttribute('nonce') || '';
  2256. }
  2257. return '';
  2258. }
  2259. /** Propagates CSP nonce to dynamically created scripts. */
  2260. function setNonceForScriptElement(script) {
  2261. var win = script.ownerDocument && script.ownerDocument.defaultView;
  2262. var nonce = getScriptNonceFromWindow(win || window);
  2263. if (nonce) {
  2264. script.setAttribute('nonce', nonce);
  2265. }
  2266. }
  2267. /** Sets textContent from the given SafeScript. */
  2268. function setTextContent(script, v) {
  2269. script.textContent = (0, script_impl_1.unwrapScript)(v);
  2270. setNonceForScriptElement(script);
  2271. }
  2272. exports.setTextContent = setTextContent;
  2273. /** Sets the Src attribute using a TrustedResourceUrl */
  2274. function setSrc(script, v) {
  2275. script.src = (0, resource_url_impl_1.unwrapResourceUrl)(v);
  2276. setNonceForScriptElement(script);
  2277. }
  2278. exports.setSrc = setSrc;
  2279. /***/ }),
  2280. /***/ "./node_modules/safevalues/dom/elements/style.js":
  2281. /*!*******************************************************!*\
  2282. !*** ./node_modules/safevalues/dom/elements/style.js ***!
  2283. \*******************************************************/
  2284. /*! no static exports found */
  2285. /***/ (function(module, exports, __webpack_require__) {
  2286. "use strict";
  2287. /**
  2288. * @license
  2289. * SPDX-License-Identifier: Apache-2.0
  2290. */
  2291. Object.defineProperty(exports, "__esModule", { value: true });
  2292. exports.setTextContent = void 0;
  2293. var style_sheet_impl_1 = __webpack_require__(/*! ../../internals/style_sheet_impl */ "./node_modules/safevalues/internals/style_sheet_impl.js");
  2294. /** Safe setters for `HTMLStyleElement`s. */
  2295. function setTextContent(elem, safeStyleSheet) {
  2296. elem.textContent = (0, style_sheet_impl_1.unwrapStyleSheet)(safeStyleSheet);
  2297. }
  2298. exports.setTextContent = setTextContent;
  2299. /***/ }),
  2300. /***/ "./node_modules/safevalues/dom/globals/document.js":
  2301. /*!*********************************************************!*\
  2302. !*** ./node_modules/safevalues/dom/globals/document.js ***!
  2303. \*********************************************************/
  2304. /*! no static exports found */
  2305. /***/ (function(module, exports, __webpack_require__) {
  2306. "use strict";
  2307. /**
  2308. * @license
  2309. * SPDX-License-Identifier: Apache-2.0
  2310. */
  2311. Object.defineProperty(exports, "__esModule", { value: true });
  2312. exports.execCommandInsertHtml = exports.execCommand = exports.write = void 0;
  2313. var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  2314. /**
  2315. * write safely calls {@link Document.write} on the given {@link Document} with
  2316. * the given {@link SafeHtml}.
  2317. */
  2318. function write(doc, text) {
  2319. doc.write((0, html_impl_1.unwrapHtml)(text));
  2320. }
  2321. exports.write = write;
  2322. /**
  2323. * Safely calls {@link Document.execCommand}. When command is insertHtml, a
  2324. * SafeHtml must be passed in as value.
  2325. */
  2326. function execCommand(doc, command, value) {
  2327. var commandString = String(command);
  2328. var valueArgument = value;
  2329. if (commandString.toLowerCase() === 'inserthtml') {
  2330. valueArgument = (0, html_impl_1.unwrapHtml)(value);
  2331. }
  2332. return doc.execCommand(commandString, /* showUi= */ false, valueArgument);
  2333. }
  2334. exports.execCommand = execCommand;
  2335. /**
  2336. * Safely calls {@link Document.execCommand}('insertHtml').
  2337. * @deprecated Use safeDocument.execCommand.
  2338. */
  2339. function execCommandInsertHtml(doc, html) {
  2340. return doc.execCommand('insertHTML', /* showUi= */ false, (0, html_impl_1.unwrapHtml)(html));
  2341. }
  2342. exports.execCommandInsertHtml = execCommandInsertHtml;
  2343. /***/ }),
  2344. /***/ "./node_modules/safevalues/dom/globals/dom_parser.js":
  2345. /*!***********************************************************!*\
  2346. !*** ./node_modules/safevalues/dom/globals/dom_parser.js ***!
  2347. \***********************************************************/
  2348. /*! no static exports found */
  2349. /***/ (function(module, exports, __webpack_require__) {
  2350. "use strict";
  2351. /**
  2352. * @license
  2353. * SPDX-License-Identifier: Apache-2.0
  2354. */
  2355. Object.defineProperty(exports, "__esModule", { value: true });
  2356. exports.parseFromString = exports.parseHtml = void 0;
  2357. var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  2358. /** Safely parses a string using the HTML parser. */
  2359. function parseHtml(parser, html) {
  2360. return parseFromString(parser, html, 'text/html');
  2361. }
  2362. exports.parseHtml = parseHtml;
  2363. /** Safely parses a string using the HTML or XML parser. */
  2364. function parseFromString(parser, content, contentType) {
  2365. return parser.parseFromString((0, html_impl_1.unwrapHtml)(content), contentType);
  2366. }
  2367. exports.parseFromString = parseFromString;
  2368. /***/ }),
  2369. /***/ "./node_modules/safevalues/dom/globals/global.js":
  2370. /*!*******************************************************!*\
  2371. !*** ./node_modules/safevalues/dom/globals/global.js ***!
  2372. \*******************************************************/
  2373. /*! no static exports found */
  2374. /***/ (function(module, exports, __webpack_require__) {
  2375. "use strict";
  2376. /**
  2377. * @license
  2378. * SPDX-License-Identifier: Apache-2.0
  2379. */
  2380. Object.defineProperty(exports, "__esModule", { value: true });
  2381. exports.globalEval = void 0;
  2382. var script_impl_1 = __webpack_require__(/*! ../../internals/script_impl */ "./node_modules/safevalues/internals/script_impl.js");
  2383. /**
  2384. * Evaluates a SafeScript value in the given scope using eval.
  2385. *
  2386. * Strongly consider avoiding this, as eval blocks CSP adoption and does not
  2387. * benefit from compiler optimizations.
  2388. */
  2389. function globalEval(win, script) {
  2390. var trustedScript = (0, script_impl_1.unwrapScript)(script);
  2391. var result = win.eval(trustedScript);
  2392. if (result === trustedScript) {
  2393. // https://crbug.com/1024786 manifesting in workers.
  2394. result = win.eval(trustedScript.toString());
  2395. }
  2396. return result;
  2397. }
  2398. exports.globalEval = globalEval;
  2399. /***/ }),
  2400. /***/ "./node_modules/safevalues/dom/globals/location.js":
  2401. /*!*********************************************************!*\
  2402. !*** ./node_modules/safevalues/dom/globals/location.js ***!
  2403. \*********************************************************/
  2404. /*! no static exports found */
  2405. /***/ (function(module, exports, __webpack_require__) {
  2406. "use strict";
  2407. /**
  2408. * @license
  2409. * SPDX-License-Identifier: Apache-2.0
  2410. */
  2411. Object.defineProperty(exports, "__esModule", { value: true });
  2412. exports.assign = exports.replace = exports.setHref = void 0;
  2413. var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  2414. /**
  2415. * setHref safely sets {@link Location.href} on the given {@link Location} with
  2416. * given {@link Url}.
  2417. */
  2418. function setHref(loc, url) {
  2419. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  2420. if (sanitizedUrl !== undefined) {
  2421. loc.href = sanitizedUrl;
  2422. }
  2423. }
  2424. exports.setHref = setHref;
  2425. /**
  2426. * replace safely calls {@link Location.replace} on the given {@link Location}
  2427. * with given {@link Url}.
  2428. */
  2429. function replace(loc, url) {
  2430. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  2431. if (sanitizedUrl !== undefined) {
  2432. loc.replace(sanitizedUrl);
  2433. }
  2434. }
  2435. exports.replace = replace;
  2436. /**
  2437. * assign safely calls {@link Location.assign} on the given {@link Location}
  2438. * with given {@link Url}.
  2439. */
  2440. function assign(loc, url) {
  2441. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  2442. if (sanitizedUrl !== undefined) {
  2443. loc.assign(sanitizedUrl);
  2444. }
  2445. }
  2446. exports.assign = assign;
  2447. /***/ }),
  2448. /***/ "./node_modules/safevalues/dom/globals/range.js":
  2449. /*!******************************************************!*\
  2450. !*** ./node_modules/safevalues/dom/globals/range.js ***!
  2451. \******************************************************/
  2452. /*! no static exports found */
  2453. /***/ (function(module, exports, __webpack_require__) {
  2454. "use strict";
  2455. /**
  2456. * @license
  2457. * SPDX-License-Identifier: Apache-2.0
  2458. */
  2459. Object.defineProperty(exports, "__esModule", { value: true });
  2460. exports.createContextualFragment = void 0;
  2461. var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  2462. /** Safely creates a contextualFragment. */
  2463. function createContextualFragment(range, html) {
  2464. return range.createContextualFragment((0, html_impl_1.unwrapHtml)(html));
  2465. }
  2466. exports.createContextualFragment = createContextualFragment;
  2467. /***/ }),
  2468. /***/ "./node_modules/safevalues/dom/globals/service_worker_container.js":
  2469. /*!*************************************************************************!*\
  2470. !*** ./node_modules/safevalues/dom/globals/service_worker_container.js ***!
  2471. \*************************************************************************/
  2472. /*! no static exports found */
  2473. /***/ (function(module, exports, __webpack_require__) {
  2474. "use strict";
  2475. /**
  2476. * @license
  2477. * SPDX-License-Identifier: Apache-2.0
  2478. */
  2479. Object.defineProperty(exports, "__esModule", { value: true });
  2480. exports.register = void 0;
  2481. var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  2482. /** Safely registers a service worker by URL */
  2483. function register(container, scriptURL, options) {
  2484. return container.register((0, resource_url_impl_1.unwrapResourceUrl)(scriptURL), options);
  2485. }
  2486. exports.register = register;
  2487. /***/ }),
  2488. /***/ "./node_modules/safevalues/dom/globals/window.js":
  2489. /*!*******************************************************!*\
  2490. !*** ./node_modules/safevalues/dom/globals/window.js ***!
  2491. \*******************************************************/
  2492. /*! no static exports found */
  2493. /***/ (function(module, exports, __webpack_require__) {
  2494. "use strict";
  2495. /**
  2496. * @license
  2497. * SPDX-License-Identifier: Apache-2.0
  2498. */
  2499. Object.defineProperty(exports, "__esModule", { value: true });
  2500. exports.open = void 0;
  2501. var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  2502. /**
  2503. * open calls {@link Window.open} on the given {@link Window}, given a
  2504. * target {@link Url}.
  2505. */
  2506. function open(win, url, target, features) {
  2507. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  2508. if (sanitizedUrl !== undefined) {
  2509. return win.open(sanitizedUrl, target, features);
  2510. }
  2511. return null;
  2512. }
  2513. exports.open = open;
  2514. /***/ }),
  2515. /***/ "./node_modules/safevalues/dom/globals/worker.js":
  2516. /*!*******************************************************!*\
  2517. !*** ./node_modules/safevalues/dom/globals/worker.js ***!
  2518. \*******************************************************/
  2519. /*! no static exports found */
  2520. /***/ (function(module, exports, __webpack_require__) {
  2521. "use strict";
  2522. /**
  2523. * @license
  2524. * SPDX-License-Identifier: Apache-2.0
  2525. */
  2526. var __read = (this && this.__read) || function (o, n) {
  2527. var m = typeof Symbol === "function" && o[Symbol.iterator];
  2528. if (!m) return o;
  2529. var i = m.call(o), r, ar = [], e;
  2530. try {
  2531. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  2532. }
  2533. catch (error) { e = { error: error }; }
  2534. finally {
  2535. try {
  2536. if (r && !r.done && (m = i["return"])) m.call(i);
  2537. }
  2538. finally { if (e) throw e.error; }
  2539. }
  2540. return ar;
  2541. };
  2542. var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
  2543. if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
  2544. if (ar || !(i in from)) {
  2545. if (!ar) ar = Array.prototype.slice.call(from, 0, i);
  2546. ar[i] = from[i];
  2547. }
  2548. }
  2549. return to.concat(ar || Array.prototype.slice.call(from));
  2550. };
  2551. Object.defineProperty(exports, "__esModule", { value: true });
  2552. exports.importScripts = exports.createShared = exports.create = void 0;
  2553. var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  2554. /**
  2555. * Safely creates a Web Worker.
  2556. *
  2557. * Example usage:
  2558. * const trustedResourceUrl = trustedResourceUrl`/safe_script.js`;
  2559. * safedom.safeWorker.create(trustedResourceUrl);
  2560. * which is a safe alternative to
  2561. * new Worker(url);
  2562. * The latter can result in loading untrusted code.
  2563. */
  2564. function create(url, options) {
  2565. return new Worker((0, resource_url_impl_1.unwrapResourceUrl)(url), options);
  2566. }
  2567. exports.create = create;
  2568. /** Safely creates a shared Web Worker. */
  2569. function createShared(url, options) {
  2570. return new SharedWorker((0, resource_url_impl_1.unwrapResourceUrl)(url), options);
  2571. }
  2572. exports.createShared = createShared;
  2573. /** Safely calls importScripts */
  2574. function importScripts(scope) {
  2575. var urls = [];
  2576. for (var _i = 1; _i < arguments.length; _i++) {
  2577. urls[_i - 1] = arguments[_i];
  2578. }
  2579. scope.importScripts.apply(scope, __spreadArray([], __read(urls.map(function (url) { return (0, resource_url_impl_1.unwrapResourceUrl)(url); })), false));
  2580. }
  2581. exports.importScripts = importScripts;
  2582. /***/ }),
  2583. /***/ "./node_modules/safevalues/dom/index.js":
  2584. /*!**********************************************!*\
  2585. !*** ./node_modules/safevalues/dom/index.js ***!
  2586. \**********************************************/
  2587. /*! no static exports found */
  2588. /***/ (function(module, exports, __webpack_require__) {
  2589. "use strict";
  2590. /**
  2591. * @license
  2592. * SPDX-License-Identifier: Apache-2.0
  2593. */
  2594. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  2595. if (k2 === undefined) k2 = k;
  2596. var desc = Object.getOwnPropertyDescriptor(m, k);
  2597. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  2598. desc = { enumerable: true, get: function() { return m[k]; } };
  2599. }
  2600. Object.defineProperty(o, k2, desc);
  2601. }) : (function(o, m, k, k2) {
  2602. if (k2 === undefined) k2 = k;
  2603. o[k2] = m[k];
  2604. }));
  2605. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  2606. Object.defineProperty(o, "default", { enumerable: true, value: v });
  2607. }) : function(o, v) {
  2608. o["default"] = v;
  2609. });
  2610. var __importStar = (this && this.__importStar) || function (mod) {
  2611. if (mod && mod.__esModule) return mod;
  2612. var result = {};
  2613. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  2614. __setModuleDefault(result, mod);
  2615. return result;
  2616. };
  2617. Object.defineProperty(exports, "__esModule", { value: true });
  2618. exports.safeWorker = exports.safeWindow = exports.safeServiceWorkerContainer = exports.safeRange = exports.safeLocation = exports.safeGlobal = exports.safeDomParser = exports.safeDocument = exports.safeStyleEl = exports.safeScriptEl = exports.safeObjectEl = exports.safeLinkEl = exports.safeInputEl = exports.safeIframeEl = exports.safeFormEl = exports.safeEmbedEl = exports.safeElement = exports.safeButtonEl = exports.safeAreaEl = exports.safeAnchorEl = void 0;
  2619. /**
  2620. * @fileoverview This file re-exports all of the wrappers to ensure that we have
  2621. * a clearly defined interface.
  2622. */
  2623. exports.safeAnchorEl = __importStar(__webpack_require__(/*! ./elements/anchor */ "./node_modules/safevalues/dom/elements/anchor.js"));
  2624. exports.safeAreaEl = __importStar(__webpack_require__(/*! ./elements/area */ "./node_modules/safevalues/dom/elements/area.js"));
  2625. exports.safeButtonEl = __importStar(__webpack_require__(/*! ./elements/button */ "./node_modules/safevalues/dom/elements/button.js"));
  2626. exports.safeElement = __importStar(__webpack_require__(/*! ./elements/element */ "./node_modules/safevalues/dom/elements/element.js"));
  2627. exports.safeEmbedEl = __importStar(__webpack_require__(/*! ./elements/embed */ "./node_modules/safevalues/dom/elements/embed.js"));
  2628. exports.safeFormEl = __importStar(__webpack_require__(/*! ./elements/form */ "./node_modules/safevalues/dom/elements/form.js"));
  2629. exports.safeIframeEl = __importStar(__webpack_require__(/*! ./elements/iframe */ "./node_modules/safevalues/dom/elements/iframe.js"));
  2630. exports.safeInputEl = __importStar(__webpack_require__(/*! ./elements/input */ "./node_modules/safevalues/dom/elements/input.js"));
  2631. exports.safeLinkEl = __importStar(__webpack_require__(/*! ./elements/link */ "./node_modules/safevalues/dom/elements/link.js"));
  2632. exports.safeObjectEl = __importStar(__webpack_require__(/*! ./elements/object */ "./node_modules/safevalues/dom/elements/object.js"));
  2633. exports.safeScriptEl = __importStar(__webpack_require__(/*! ./elements/script */ "./node_modules/safevalues/dom/elements/script.js"));
  2634. exports.safeStyleEl = __importStar(__webpack_require__(/*! ./elements/style */ "./node_modules/safevalues/dom/elements/style.js"));
  2635. exports.safeDocument = __importStar(__webpack_require__(/*! ./globals/document */ "./node_modules/safevalues/dom/globals/document.js"));
  2636. exports.safeDomParser = __importStar(__webpack_require__(/*! ./globals/dom_parser */ "./node_modules/safevalues/dom/globals/dom_parser.js"));
  2637. exports.safeGlobal = __importStar(__webpack_require__(/*! ./globals/global */ "./node_modules/safevalues/dom/globals/global.js"));
  2638. exports.safeLocation = __importStar(__webpack_require__(/*! ./globals/location */ "./node_modules/safevalues/dom/globals/location.js"));
  2639. exports.safeRange = __importStar(__webpack_require__(/*! ./globals/range */ "./node_modules/safevalues/dom/globals/range.js"));
  2640. exports.safeServiceWorkerContainer = __importStar(__webpack_require__(/*! ./globals/service_worker_container */ "./node_modules/safevalues/dom/globals/service_worker_container.js"));
  2641. exports.safeWindow = __importStar(__webpack_require__(/*! ./globals/window */ "./node_modules/safevalues/dom/globals/window.js"));
  2642. exports.safeWorker = __importStar(__webpack_require__(/*! ./globals/worker */ "./node_modules/safevalues/dom/globals/worker.js"));
  2643. /***/ }),
  2644. /***/ "./node_modules/safevalues/environment/dev.js":
  2645. /*!****************************************************!*\
  2646. !*** ./node_modules/safevalues/environment/dev.js ***!
  2647. \****************************************************/
  2648. /*! no static exports found */
  2649. /***/ (function(module, exports, __webpack_require__) {
  2650. "use strict";
  2651. /* WEBPACK VAR INJECTION */(function(process) {
  2652. /**
  2653. * @license
  2654. * SPDX-License-Identifier: Apache-2.0
  2655. */
  2656. /**
  2657. * Ensure process.env.NODE_ENV is set even when not running under Webpack or
  2658. * Node. Terser will strip this out of production binaries.
  2659. */
  2660. /*#__PURE__*/ (function () {
  2661. if (typeof process === 'undefined') {
  2662. window.process = { env: { NODE_ENV: 'development' } };
  2663. }
  2664. })();
  2665. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "./node_modules/process/browser.js")))
  2666. /***/ }),
  2667. /***/ "./node_modules/safevalues/index.js":
  2668. /*!******************************************!*\
  2669. !*** ./node_modules/safevalues/index.js ***!
  2670. \******************************************/
  2671. /*! no static exports found */
  2672. /***/ (function(module, exports, __webpack_require__) {
  2673. "use strict";
  2674. /**
  2675. * @license
  2676. * SPDX-License-Identifier: Apache-2.0
  2677. */
  2678. Object.defineProperty(exports, "__esModule", { value: true });
  2679. exports.unwrapStyleSheet = exports.SafeStyleSheet = exports.isStyleSheet = exports.unwrapStyle = exports.SafeStyle = exports.isStyle = exports.unwrapScript = exports.SafeScript = exports.isScript = exports.EMPTY_SCRIPT = exports.unwrapResourceUrl = exports.TrustedResourceUrl = exports.isResourceUrl = exports.unwrapHtml = exports.SafeHtml = exports.isHtml = exports.EMPTY_HTML = exports.unwrapAttributePrefix = exports.SafeAttributePrefix = exports.safeStyleSheet = exports.concatStyleSheets = exports.safeStyle = exports.concatStyles = exports.scriptFromJson = exports.safeScriptWithArgs = exports.safeScript = exports.concatScripts = exports.trustedResourceUrl = exports.replaceFragment = exports.blobUrlFromScript = exports.appendParams = exports.HtmlSanitizerBuilder = exports.sanitizeHtmlToFragment = exports.sanitizeHtmlAssertUnchanged = exports.sanitizeHtml = exports.htmlEscape = exports.createScriptSrc = exports.createScript = exports.concatHtmls = exports.safeAttrPrefix = void 0;
  2680. /** Safe builders */
  2681. var attribute_builders_1 = __webpack_require__(/*! ./builders/attribute_builders */ "./node_modules/safevalues/builders/attribute_builders.js");
  2682. Object.defineProperty(exports, "safeAttrPrefix", { enumerable: true, get: function () { return attribute_builders_1.safeAttrPrefix; } });
  2683. var html_builders_1 = __webpack_require__(/*! ./builders/html_builders */ "./node_modules/safevalues/builders/html_builders.js");
  2684. Object.defineProperty(exports, "concatHtmls", { enumerable: true, get: function () { return html_builders_1.concatHtmls; } });
  2685. Object.defineProperty(exports, "createScript", { enumerable: true, get: function () { return html_builders_1.createScript; } });
  2686. Object.defineProperty(exports, "createScriptSrc", { enumerable: true, get: function () { return html_builders_1.createScriptSrc; } });
  2687. Object.defineProperty(exports, "htmlEscape", { enumerable: true, get: function () { return html_builders_1.htmlEscape; } });
  2688. var html_sanitizer_1 = __webpack_require__(/*! ./builders/html_sanitizer/html_sanitizer */ "./node_modules/safevalues/builders/html_sanitizer/html_sanitizer.js");
  2689. Object.defineProperty(exports, "sanitizeHtml", { enumerable: true, get: function () { return html_sanitizer_1.sanitizeHtml; } });
  2690. Object.defineProperty(exports, "sanitizeHtmlAssertUnchanged", { enumerable: true, get: function () { return html_sanitizer_1.sanitizeHtmlAssertUnchanged; } });
  2691. Object.defineProperty(exports, "sanitizeHtmlToFragment", { enumerable: true, get: function () { return html_sanitizer_1.sanitizeHtmlToFragment; } });
  2692. var html_sanitizer_builder_1 = __webpack_require__(/*! ./builders/html_sanitizer/html_sanitizer_builder */ "./node_modules/safevalues/builders/html_sanitizer/html_sanitizer_builder.js");
  2693. Object.defineProperty(exports, "HtmlSanitizerBuilder", { enumerable: true, get: function () { return html_sanitizer_builder_1.HtmlSanitizerBuilder; } });
  2694. var resource_url_builders_1 = __webpack_require__(/*! ./builders/resource_url_builders */ "./node_modules/safevalues/builders/resource_url_builders.js");
  2695. Object.defineProperty(exports, "appendParams", { enumerable: true, get: function () { return resource_url_builders_1.appendParams; } });
  2696. Object.defineProperty(exports, "blobUrlFromScript", { enumerable: true, get: function () { return resource_url_builders_1.blobUrlFromScript; } });
  2697. Object.defineProperty(exports, "replaceFragment", { enumerable: true, get: function () { return resource_url_builders_1.replaceFragment; } });
  2698. Object.defineProperty(exports, "trustedResourceUrl", { enumerable: true, get: function () { return resource_url_builders_1.trustedResourceUrl; } });
  2699. var script_builders_1 = __webpack_require__(/*! ./builders/script_builders */ "./node_modules/safevalues/builders/script_builders.js");
  2700. Object.defineProperty(exports, "concatScripts", { enumerable: true, get: function () { return script_builders_1.concatScripts; } });
  2701. Object.defineProperty(exports, "safeScript", { enumerable: true, get: function () { return script_builders_1.safeScript; } });
  2702. Object.defineProperty(exports, "safeScriptWithArgs", { enumerable: true, get: function () { return script_builders_1.safeScriptWithArgs; } });
  2703. Object.defineProperty(exports, "scriptFromJson", { enumerable: true, get: function () { return script_builders_1.scriptFromJson; } });
  2704. var style_builders_1 = __webpack_require__(/*! ./builders/style_builders */ "./node_modules/safevalues/builders/style_builders.js");
  2705. Object.defineProperty(exports, "concatStyles", { enumerable: true, get: function () { return style_builders_1.concatStyles; } });
  2706. Object.defineProperty(exports, "safeStyle", { enumerable: true, get: function () { return style_builders_1.safeStyle; } });
  2707. var style_sheet_builders_1 = __webpack_require__(/*! ./builders/style_sheet_builders */ "./node_modules/safevalues/builders/style_sheet_builders.js");
  2708. Object.defineProperty(exports, "concatStyleSheets", { enumerable: true, get: function () { return style_sheet_builders_1.concatStyleSheets; } });
  2709. Object.defineProperty(exports, "safeStyleSheet", { enumerable: true, get: function () { return style_sheet_builders_1.safeStyleSheet; } });
  2710. /** Types, constants and unwrappers */
  2711. var attribute_impl_1 = __webpack_require__(/*! ./internals/attribute_impl */ "./node_modules/safevalues/internals/attribute_impl.js");
  2712. Object.defineProperty(exports, "SafeAttributePrefix", { enumerable: true, get: function () { return attribute_impl_1.SafeAttributePrefix; } });
  2713. Object.defineProperty(exports, "unwrapAttributePrefix", { enumerable: true, get: function () { return attribute_impl_1.unwrapAttributePrefix; } });
  2714. var html_impl_1 = __webpack_require__(/*! ./internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  2715. Object.defineProperty(exports, "EMPTY_HTML", { enumerable: true, get: function () { return html_impl_1.EMPTY_HTML; } });
  2716. Object.defineProperty(exports, "isHtml", { enumerable: true, get: function () { return html_impl_1.isHtml; } });
  2717. Object.defineProperty(exports, "SafeHtml", { enumerable: true, get: function () { return html_impl_1.SafeHtml; } });
  2718. Object.defineProperty(exports, "unwrapHtml", { enumerable: true, get: function () { return html_impl_1.unwrapHtml; } });
  2719. var resource_url_impl_1 = __webpack_require__(/*! ./internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  2720. Object.defineProperty(exports, "isResourceUrl", { enumerable: true, get: function () { return resource_url_impl_1.isResourceUrl; } });
  2721. Object.defineProperty(exports, "TrustedResourceUrl", { enumerable: true, get: function () { return resource_url_impl_1.TrustedResourceUrl; } });
  2722. Object.defineProperty(exports, "unwrapResourceUrl", { enumerable: true, get: function () { return resource_url_impl_1.unwrapResourceUrl; } });
  2723. var script_impl_1 = __webpack_require__(/*! ./internals/script_impl */ "./node_modules/safevalues/internals/script_impl.js");
  2724. Object.defineProperty(exports, "EMPTY_SCRIPT", { enumerable: true, get: function () { return script_impl_1.EMPTY_SCRIPT; } });
  2725. Object.defineProperty(exports, "isScript", { enumerable: true, get: function () { return script_impl_1.isScript; } });
  2726. Object.defineProperty(exports, "SafeScript", { enumerable: true, get: function () { return script_impl_1.SafeScript; } });
  2727. Object.defineProperty(exports, "unwrapScript", { enumerable: true, get: function () { return script_impl_1.unwrapScript; } });
  2728. var style_impl_1 = __webpack_require__(/*! ./internals/style_impl */ "./node_modules/safevalues/internals/style_impl.js");
  2729. Object.defineProperty(exports, "isStyle", { enumerable: true, get: function () { return style_impl_1.isStyle; } });
  2730. Object.defineProperty(exports, "SafeStyle", { enumerable: true, get: function () { return style_impl_1.SafeStyle; } });
  2731. Object.defineProperty(exports, "unwrapStyle", { enumerable: true, get: function () { return style_impl_1.unwrapStyle; } });
  2732. var style_sheet_impl_1 = __webpack_require__(/*! ./internals/style_sheet_impl */ "./node_modules/safevalues/internals/style_sheet_impl.js");
  2733. Object.defineProperty(exports, "isStyleSheet", { enumerable: true, get: function () { return style_sheet_impl_1.isStyleSheet; } });
  2734. Object.defineProperty(exports, "SafeStyleSheet", { enumerable: true, get: function () { return style_sheet_impl_1.SafeStyleSheet; } });
  2735. Object.defineProperty(exports, "unwrapStyleSheet", { enumerable: true, get: function () { return style_sheet_impl_1.unwrapStyleSheet; } });
  2736. /***/ }),
  2737. /***/ "./node_modules/safevalues/internals/attribute_impl.js":
  2738. /*!*************************************************************!*\
  2739. !*** ./node_modules/safevalues/internals/attribute_impl.js ***!
  2740. \*************************************************************/
  2741. /*! no static exports found */
  2742. /***/ (function(module, exports, __webpack_require__) {
  2743. "use strict";
  2744. /**
  2745. * @license
  2746. * SPDX-License-Identifier: Apache-2.0
  2747. */
  2748. var __extends = (this && this.__extends) || (function () {
  2749. var extendStatics = function (d, b) {
  2750. extendStatics = Object.setPrototypeOf ||
  2751. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2752. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  2753. return extendStatics(d, b);
  2754. };
  2755. return function (d, b) {
  2756. if (typeof b !== "function" && b !== null)
  2757. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  2758. extendStatics(d, b);
  2759. function __() { this.constructor = d; }
  2760. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2761. };
  2762. })();
  2763. Object.defineProperty(exports, "__esModule", { value: true });
  2764. exports.unwrapAttributePrefix = exports.createAttributePrefix = exports.SafeAttributePrefix = void 0;
  2765. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  2766. var secrets_1 = __webpack_require__(/*! ./secrets */ "./node_modules/safevalues/internals/secrets.js");
  2767. /** A prefix with which an attribute is safe to set using plain strings. */
  2768. var SafeAttributePrefix = /** @class */ (function () {
  2769. function SafeAttributePrefix() {
  2770. }
  2771. return SafeAttributePrefix;
  2772. }());
  2773. exports.SafeAttributePrefix = SafeAttributePrefix;
  2774. /** Implementation for `SafeAttributePrefix` */
  2775. var AttributePrefixImpl = /** @class */ (function (_super) {
  2776. __extends(AttributePrefixImpl, _super);
  2777. function AttributePrefixImpl(attrPrefix, token) {
  2778. var _this = _super.call(this) || this;
  2779. if (true) {
  2780. (0, secrets_1.ensureTokenIsValid)(token);
  2781. }
  2782. _this.privateDoNotAccessOrElseWrappedAttrPrefix = attrPrefix;
  2783. return _this;
  2784. }
  2785. AttributePrefixImpl.prototype.toString = function () {
  2786. return this.privateDoNotAccessOrElseWrappedAttrPrefix;
  2787. };
  2788. return AttributePrefixImpl;
  2789. }(SafeAttributePrefix));
  2790. /**
  2791. * Builds a new `SafeAttribute` from the given string, without enforcing
  2792. * safety guarantees. This shouldn't be exposed to application developers, and
  2793. * must only be used as a step towards safe builders or safe constants.
  2794. */
  2795. function createAttributePrefix(attrPrefix) {
  2796. return new AttributePrefixImpl(attrPrefix, secrets_1.secretToken);
  2797. }
  2798. exports.createAttributePrefix = createAttributePrefix;
  2799. /**
  2800. * Returns the string value of the passed `SafeAttributePrefix` object while
  2801. * ensuring it has the correct type.
  2802. */
  2803. function unwrapAttributePrefix(value) {
  2804. if (value instanceof AttributePrefixImpl) {
  2805. return value.privateDoNotAccessOrElseWrappedAttrPrefix;
  2806. }
  2807. else {
  2808. var message = '';
  2809. if (true) {
  2810. message = 'Unexpected type when unwrapping SafeAttributePrefix';
  2811. }
  2812. throw new Error(message);
  2813. }
  2814. }
  2815. exports.unwrapAttributePrefix = unwrapAttributePrefix;
  2816. /***/ }),
  2817. /***/ "./node_modules/safevalues/internals/html_impl.js":
  2818. /*!********************************************************!*\
  2819. !*** ./node_modules/safevalues/internals/html_impl.js ***!
  2820. \********************************************************/
  2821. /*! no static exports found */
  2822. /***/ (function(module, exports, __webpack_require__) {
  2823. "use strict";
  2824. /**
  2825. * @license
  2826. * SPDX-License-Identifier: Apache-2.0
  2827. */
  2828. Object.defineProperty(exports, "__esModule", { value: true });
  2829. exports.unwrapHtml = exports.isHtml = exports.EMPTY_HTML = exports.createHtml = exports.SafeHtml = void 0;
  2830. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  2831. /* g3_import_pure from './pure' */
  2832. var secrets_1 = __webpack_require__(/*! ./secrets */ "./node_modules/safevalues/internals/secrets.js");
  2833. var trusted_types_1 = __webpack_require__(/*! ./trusted_types */ "./node_modules/safevalues/internals/trusted_types.js");
  2834. /**
  2835. * Runtime implementation of `TrustedHTML` in browsers that don't support it.
  2836. */
  2837. var HtmlImpl = /** @class */ (function () {
  2838. function HtmlImpl(html, token) {
  2839. if (true) {
  2840. (0, secrets_1.ensureTokenIsValid)(token);
  2841. }
  2842. this.privateDoNotAccessOrElseWrappedHtml = html;
  2843. }
  2844. HtmlImpl.prototype.toString = function () {
  2845. return this.privateDoNotAccessOrElseWrappedHtml.toString();
  2846. };
  2847. return HtmlImpl;
  2848. }());
  2849. function createHtmlInternal(html, trusted) {
  2850. return (trusted !== null && trusted !== void 0 ? trusted : new HtmlImpl(html, secrets_1.secretToken));
  2851. }
  2852. var GlobalTrustedHTML = (typeof window !== undefined) ? window.TrustedHTML : undefined;
  2853. /**
  2854. * Also exports the constructor so that instanceof checks work.
  2855. */
  2856. exports.SafeHtml = (GlobalTrustedHTML !== null && GlobalTrustedHTML !== void 0 ? GlobalTrustedHTML : HtmlImpl);
  2857. /**
  2858. * Builds a new `SafeHtml` from the given string, without enforcing safety
  2859. * guarantees. It may cause side effects by creating a Trusted Types policy.
  2860. * This shouldn't be exposed to application developers, and must only be used as
  2861. * a step towards safe builders or safe constants.
  2862. */
  2863. function createHtml(html) {
  2864. var _a;
  2865. /** @noinline */
  2866. var noinlineHtml = html;
  2867. return createHtmlInternal(noinlineHtml, (_a = (0, trusted_types_1.getTrustedTypesPolicy)()) === null || _a === void 0 ? void 0 : _a.createHTML(noinlineHtml));
  2868. }
  2869. exports.createHtml = createHtml;
  2870. /**
  2871. * An empty `SafeHtml` constant.
  2872. * Unlike the function above, using this will not create a policy.
  2873. */
  2874. exports.EMPTY_HTML =
  2875. /* #__PURE__ */ (function () { var _a; return createHtmlInternal('', (_a = (0, trusted_types_1.getTrustedTypes)()) === null || _a === void 0 ? void 0 : _a.emptyHTML); })();
  2876. /**
  2877. * Checks if the given value is a `SafeHtml` instance.
  2878. */
  2879. function isHtml(value) {
  2880. return value instanceof exports.SafeHtml;
  2881. }
  2882. exports.isHtml = isHtml;
  2883. /**
  2884. * Returns the value of the passed `SafeHtml` object while ensuring it
  2885. * has the correct type.
  2886. *
  2887. * Returns a native `TrustedHTML` or a string if Trusted Types are disabled.
  2888. */
  2889. function unwrapHtml(value) {
  2890. var _a;
  2891. if ((_a = (0, trusted_types_1.getTrustedTypes)()) === null || _a === void 0 ? void 0 : _a.isHTML(value)) {
  2892. return value;
  2893. }
  2894. else if (value instanceof HtmlImpl) {
  2895. return value.privateDoNotAccessOrElseWrappedHtml;
  2896. }
  2897. else {
  2898. var message = '';
  2899. if (true) {
  2900. message = 'Unexpected type when unwrapping SafeHtml';
  2901. }
  2902. throw new Error(message);
  2903. }
  2904. }
  2905. exports.unwrapHtml = unwrapHtml;
  2906. /***/ }),
  2907. /***/ "./node_modules/safevalues/internals/resource_url_impl.js":
  2908. /*!****************************************************************!*\
  2909. !*** ./node_modules/safevalues/internals/resource_url_impl.js ***!
  2910. \****************************************************************/
  2911. /*! no static exports found */
  2912. /***/ (function(module, exports, __webpack_require__) {
  2913. "use strict";
  2914. /**
  2915. * @license
  2916. * SPDX-License-Identifier: Apache-2.0
  2917. */
  2918. Object.defineProperty(exports, "__esModule", { value: true });
  2919. exports.unwrapResourceUrl = exports.isResourceUrl = exports.createResourceUrl = exports.TrustedResourceUrl = void 0;
  2920. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  2921. var secrets_1 = __webpack_require__(/*! ./secrets */ "./node_modules/safevalues/internals/secrets.js");
  2922. var trusted_types_1 = __webpack_require__(/*! ./trusted_types */ "./node_modules/safevalues/internals/trusted_types.js");
  2923. /**
  2924. * Runtime implementation of `TrustedScriptURL` in browsers that don't support
  2925. * it.
  2926. */
  2927. var ResourceUrlImpl = /** @class */ (function () {
  2928. function ResourceUrlImpl(url, token) {
  2929. if (true) {
  2930. (0, secrets_1.ensureTokenIsValid)(token);
  2931. }
  2932. this.privateDoNotAccessOrElseWrappedResourceUrl = url;
  2933. }
  2934. ResourceUrlImpl.prototype.toString = function () {
  2935. return this.privateDoNotAccessOrElseWrappedResourceUrl.toString();
  2936. };
  2937. return ResourceUrlImpl;
  2938. }());
  2939. var GlobalTrustedScriptURL = (typeof window !== undefined) ? window.TrustedScriptURL : undefined;
  2940. /**
  2941. * Also exports the constructor so that instanceof checks work.
  2942. */
  2943. exports.TrustedResourceUrl = (GlobalTrustedScriptURL !== null && GlobalTrustedScriptURL !== void 0 ? GlobalTrustedScriptURL : ResourceUrlImpl);
  2944. /**
  2945. * Builds a new `TrustedResourceUrl` from the given string, without
  2946. * enforcing safety guarantees. It may cause side effects by creating a Trusted
  2947. * Types policy. This shouldn't be exposed to application developers, and must
  2948. * only be used as a step towards safe builders or safe constants.
  2949. */
  2950. function createResourceUrl(url) {
  2951. var _a;
  2952. /** @noinline */
  2953. var noinlineUrl = url;
  2954. var trustedScriptURL = (_a = (0, trusted_types_1.getTrustedTypesPolicy)()) === null || _a === void 0 ? void 0 : _a.createScriptURL(noinlineUrl);
  2955. return (trustedScriptURL !== null && trustedScriptURL !== void 0 ? trustedScriptURL : new ResourceUrlImpl(noinlineUrl, secrets_1.secretToken));
  2956. }
  2957. exports.createResourceUrl = createResourceUrl;
  2958. /**
  2959. * Checks if the given value is a `TrustedResourceUrl` instance.
  2960. */
  2961. function isResourceUrl(value) {
  2962. return value instanceof exports.TrustedResourceUrl;
  2963. }
  2964. exports.isResourceUrl = isResourceUrl;
  2965. /**
  2966. * Returns the value of the passed `TrustedResourceUrl` object while ensuring it
  2967. * has the correct type.
  2968. *
  2969. * Returns a native `TrustedScriptURL` or a string if Trusted Types are
  2970. * disabled.
  2971. */
  2972. function unwrapResourceUrl(value) {
  2973. var _a;
  2974. if ((_a = (0, trusted_types_1.getTrustedTypes)()) === null || _a === void 0 ? void 0 : _a.isScriptURL(value)) {
  2975. return value;
  2976. }
  2977. else if (value instanceof ResourceUrlImpl) {
  2978. return value.privateDoNotAccessOrElseWrappedResourceUrl;
  2979. }
  2980. else {
  2981. var message = '';
  2982. if (true) {
  2983. message = 'Unexpected type when unwrapping TrustedResourceUrl';
  2984. }
  2985. throw new Error(message);
  2986. }
  2987. }
  2988. exports.unwrapResourceUrl = unwrapResourceUrl;
  2989. /***/ }),
  2990. /***/ "./node_modules/safevalues/internals/script_impl.js":
  2991. /*!**********************************************************!*\
  2992. !*** ./node_modules/safevalues/internals/script_impl.js ***!
  2993. \**********************************************************/
  2994. /*! no static exports found */
  2995. /***/ (function(module, exports, __webpack_require__) {
  2996. "use strict";
  2997. /**
  2998. * @license
  2999. * SPDX-License-Identifier: Apache-2.0
  3000. */
  3001. Object.defineProperty(exports, "__esModule", { value: true });
  3002. exports.unwrapScript = exports.isScript = exports.EMPTY_SCRIPT = exports.createScript = exports.SafeScript = void 0;
  3003. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  3004. /* g3_import_pure from './pure' */
  3005. var secrets_1 = __webpack_require__(/*! ./secrets */ "./node_modules/safevalues/internals/secrets.js");
  3006. var trusted_types_1 = __webpack_require__(/*! ./trusted_types */ "./node_modules/safevalues/internals/trusted_types.js");
  3007. /**
  3008. * Runtime implementation of `TrustedScript` in browswers that don't support it.
  3009. * script element.
  3010. */
  3011. var ScriptImpl = /** @class */ (function () {
  3012. function ScriptImpl(script, token) {
  3013. if (true) {
  3014. (0, secrets_1.ensureTokenIsValid)(token);
  3015. }
  3016. this.privateDoNotAccessOrElseWrappedScript = script;
  3017. }
  3018. ScriptImpl.prototype.toString = function () {
  3019. return this.privateDoNotAccessOrElseWrappedScript.toString();
  3020. };
  3021. return ScriptImpl;
  3022. }());
  3023. function createScriptInternal(script, trusted) {
  3024. return (trusted !== null && trusted !== void 0 ? trusted : new ScriptImpl(script, secrets_1.secretToken));
  3025. }
  3026. var GlobalTrustedScript = (typeof window !== undefined) ? window.TrustedScript : undefined;
  3027. /**
  3028. * Also exports the constructor so that instanceof checks work.
  3029. */
  3030. exports.SafeScript = (GlobalTrustedScript !== null && GlobalTrustedScript !== void 0 ? GlobalTrustedScript : ScriptImpl);
  3031. /**
  3032. * Builds a new `SafeScript` from the given string, without enforcing
  3033. * safety guarantees. It may cause side effects by creating a Trusted Types
  3034. * policy. This shouldn't be exposed to application developers, and must only be
  3035. * used as a step towards safe builders or safe constants.
  3036. */
  3037. function createScript(script) {
  3038. var _a;
  3039. /** @noinline */
  3040. var noinlineScript = script;
  3041. return createScriptInternal(noinlineScript, (_a = (0, trusted_types_1.getTrustedTypesPolicy)()) === null || _a === void 0 ? void 0 : _a.createScript(noinlineScript));
  3042. }
  3043. exports.createScript = createScript;
  3044. /**
  3045. * An empty `SafeScript` constant.
  3046. * Unlike the functions above, using this will not create a policy.
  3047. */
  3048. exports.EMPTY_SCRIPT =
  3049. /* #__PURE__ */ (function () { var _a; return createScriptInternal('', (_a = (0, trusted_types_1.getTrustedTypes)()) === null || _a === void 0 ? void 0 : _a.emptyScript); })();
  3050. /**
  3051. * Checks if the given value is a `SafeScript` instance.
  3052. */
  3053. function isScript(value) {
  3054. return value instanceof exports.SafeScript;
  3055. }
  3056. exports.isScript = isScript;
  3057. /**
  3058. * Returns the value of the passed `SafeScript` object while ensuring it
  3059. * has the correct type.
  3060. *
  3061. * Returns a native `TrustedScript` or a string if Trusted Types are disabled.
  3062. */
  3063. function unwrapScript(value) {
  3064. var _a;
  3065. if ((_a = (0, trusted_types_1.getTrustedTypes)()) === null || _a === void 0 ? void 0 : _a.isScript(value)) {
  3066. return value;
  3067. }
  3068. else if (value instanceof ScriptImpl) {
  3069. return value.privateDoNotAccessOrElseWrappedScript;
  3070. }
  3071. else {
  3072. var message = '';
  3073. if (true) {
  3074. message = 'Unexpected type when unwrapping SafeScript';
  3075. }
  3076. throw new Error(message);
  3077. }
  3078. }
  3079. exports.unwrapScript = unwrapScript;
  3080. /***/ }),
  3081. /***/ "./node_modules/safevalues/internals/secrets.js":
  3082. /*!******************************************************!*\
  3083. !*** ./node_modules/safevalues/internals/secrets.js ***!
  3084. \******************************************************/
  3085. /*! no static exports found */
  3086. /***/ (function(module, exports, __webpack_require__) {
  3087. "use strict";
  3088. /**
  3089. * @license
  3090. * SPDX-License-Identifier: Apache-2.0
  3091. */
  3092. Object.defineProperty(exports, "__esModule", { value: true });
  3093. exports.ensureTokenIsValid = exports.secretToken = void 0;
  3094. /**
  3095. * A secret token that must be passed to safe type constructors. It is only
  3096. * accessible from within safevalues, ensuring that unrestricted safe type
  3097. * creation is only possible within safevalues. In particular, this prevents
  3098. * forgery such as `safeHtmlValue.constructor('javascript:evil')`.
  3099. */
  3100. exports.secretToken = {};
  3101. /**
  3102. * Asserts that the given token matches the secret safevalues token. An
  3103. * exception is thrown if that is not the case.
  3104. */
  3105. function ensureTokenIsValid(token) {
  3106. if (token !== exports.secretToken) {
  3107. throw new Error('Bad secret');
  3108. }
  3109. }
  3110. exports.ensureTokenIsValid = ensureTokenIsValid;
  3111. /***/ }),
  3112. /***/ "./node_modules/safevalues/internals/string_literal.js":
  3113. /*!*************************************************************!*\
  3114. !*** ./node_modules/safevalues/internals/string_literal.js ***!
  3115. \*************************************************************/
  3116. /*! no static exports found */
  3117. /***/ (function(module, exports, __webpack_require__) {
  3118. "use strict";
  3119. /**
  3120. * @license
  3121. * SPDX-License-Identifier: Apache-2.0
  3122. */
  3123. Object.defineProperty(exports, "__esModule", { value: true });
  3124. exports.assertIsTemplateObject = void 0;
  3125. /**
  3126. * An object of type TemplateStringsArray represents the literal part(s) of a
  3127. * template literal. This function checks if a TemplateStringsArray object is
  3128. * actually from a template literal.
  3129. *
  3130. * @param templateObj This contains the literal part of the template literal.
  3131. * @param hasExprs If true, the input template may contain embedded expressions.
  3132. * @param errorMsg The custom error message in case any checks fail.
  3133. */
  3134. function assertIsTemplateObject(templateObj, hasExprs, errorMsg) {
  3135. if (!Array.isArray(templateObj) || !Array.isArray(templateObj.raw) ||
  3136. (!hasExprs && templateObj.length !== 1)) {
  3137. throw new TypeError(errorMsg);
  3138. }
  3139. }
  3140. exports.assertIsTemplateObject = assertIsTemplateObject;
  3141. /***/ }),
  3142. /***/ "./node_modules/safevalues/internals/style_impl.js":
  3143. /*!*********************************************************!*\
  3144. !*** ./node_modules/safevalues/internals/style_impl.js ***!
  3145. \*********************************************************/
  3146. /*! no static exports found */
  3147. /***/ (function(module, exports, __webpack_require__) {
  3148. "use strict";
  3149. /**
  3150. * @license
  3151. * SPDX-License-Identifier: Apache-2.0
  3152. */
  3153. var __extends = (this && this.__extends) || (function () {
  3154. var extendStatics = function (d, b) {
  3155. extendStatics = Object.setPrototypeOf ||
  3156. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3157. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  3158. return extendStatics(d, b);
  3159. };
  3160. return function (d, b) {
  3161. if (typeof b !== "function" && b !== null)
  3162. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  3163. extendStatics(d, b);
  3164. function __() { this.constructor = d; }
  3165. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3166. };
  3167. })();
  3168. Object.defineProperty(exports, "__esModule", { value: true });
  3169. exports.unwrapStyle = exports.isStyle = exports.createStyle = exports.SafeStyle = void 0;
  3170. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  3171. var secrets_1 = __webpack_require__(/*! ./secrets */ "./node_modules/safevalues/internals/secrets.js");
  3172. /**
  3173. * Sequence of CSS declarations safe to use in style contexts in an HTML
  3174. * document or in DOM APIs.
  3175. */
  3176. var SafeStyle = /** @class */ (function () {
  3177. function SafeStyle() {
  3178. }
  3179. return SafeStyle;
  3180. }());
  3181. exports.SafeStyle = SafeStyle;
  3182. /** Implementation for `SafeStyle` */
  3183. var StyleImpl = /** @class */ (function (_super) {
  3184. __extends(StyleImpl, _super);
  3185. function StyleImpl(style, token) {
  3186. var _this = _super.call(this) || this;
  3187. if (true) {
  3188. (0, secrets_1.ensureTokenIsValid)(token);
  3189. }
  3190. _this.privateDoNotAccessOrElseWrappedStyle = style;
  3191. return _this;
  3192. }
  3193. StyleImpl.prototype.toString = function () {
  3194. return this.privateDoNotAccessOrElseWrappedStyle;
  3195. };
  3196. return StyleImpl;
  3197. }(SafeStyle));
  3198. /**
  3199. * Builds a new `SafeStyle` from the given string, without enforcing
  3200. * safety guarantees. This shouldn't be exposed to application developers, and
  3201. * must only be used as a step towards safe builders or safe constants.
  3202. */
  3203. function createStyle(style) {
  3204. return new StyleImpl(style, secrets_1.secretToken);
  3205. }
  3206. exports.createStyle = createStyle;
  3207. /**
  3208. * Checks if the given value is a `SafeStyle` instance.
  3209. */
  3210. function isStyle(value) {
  3211. return value instanceof StyleImpl;
  3212. }
  3213. exports.isStyle = isStyle;
  3214. /**
  3215. * Returns the string value of the passed `SafeStyle` object while ensuring it
  3216. * has the correct type.
  3217. */
  3218. function unwrapStyle(value) {
  3219. if (value instanceof StyleImpl) {
  3220. return value.privateDoNotAccessOrElseWrappedStyle;
  3221. }
  3222. else {
  3223. var message = '';
  3224. if (true) {
  3225. message = 'Unexpected type when unwrapping SafeStyle';
  3226. }
  3227. throw new Error(message);
  3228. }
  3229. }
  3230. exports.unwrapStyle = unwrapStyle;
  3231. /***/ }),
  3232. /***/ "./node_modules/safevalues/internals/style_sheet_impl.js":
  3233. /*!***************************************************************!*\
  3234. !*** ./node_modules/safevalues/internals/style_sheet_impl.js ***!
  3235. \***************************************************************/
  3236. /*! no static exports found */
  3237. /***/ (function(module, exports, __webpack_require__) {
  3238. "use strict";
  3239. /**
  3240. * @license
  3241. * SPDX-License-Identifier: Apache-2.0
  3242. */
  3243. var __extends = (this && this.__extends) || (function () {
  3244. var extendStatics = function (d, b) {
  3245. extendStatics = Object.setPrototypeOf ||
  3246. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3247. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  3248. return extendStatics(d, b);
  3249. };
  3250. return function (d, b) {
  3251. if (typeof b !== "function" && b !== null)
  3252. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  3253. extendStatics(d, b);
  3254. function __() { this.constructor = d; }
  3255. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3256. };
  3257. })();
  3258. Object.defineProperty(exports, "__esModule", { value: true });
  3259. exports.unwrapStyleSheet = exports.isStyleSheet = exports.createStyleSheet = exports.SafeStyleSheet = void 0;
  3260. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  3261. var secrets_1 = __webpack_require__(/*! ./secrets */ "./node_modules/safevalues/internals/secrets.js");
  3262. /**
  3263. * A complete CSS style sheet, safe to use in style contexts in an HTML document
  3264. * or DOM APIs.
  3265. */
  3266. var SafeStyleSheet = /** @class */ (function () {
  3267. function SafeStyleSheet() {
  3268. }
  3269. return SafeStyleSheet;
  3270. }());
  3271. exports.SafeStyleSheet = SafeStyleSheet;
  3272. /** Implementation for `SafeStyleSheet` */
  3273. var StyleSheetImpl = /** @class */ (function (_super) {
  3274. __extends(StyleSheetImpl, _super);
  3275. function StyleSheetImpl(styleSheet, token) {
  3276. var _this = _super.call(this) || this;
  3277. if (true) {
  3278. (0, secrets_1.ensureTokenIsValid)(token);
  3279. }
  3280. _this.privateDoNotAccessOrElseWrappedStyleSheet = styleSheet;
  3281. return _this;
  3282. }
  3283. StyleSheetImpl.prototype.toString = function () {
  3284. return this.privateDoNotAccessOrElseWrappedStyleSheet;
  3285. };
  3286. return StyleSheetImpl;
  3287. }(SafeStyleSheet));
  3288. /**
  3289. * Builds a new `SafeStyleSheet` from the given string, without enforcing
  3290. * safety guarantees. This shouldn't be exposed to application developers, and
  3291. * must only be used as a step towards safe builders or safe constants.
  3292. */
  3293. function createStyleSheet(styleSheet) {
  3294. return new StyleSheetImpl(styleSheet, secrets_1.secretToken);
  3295. }
  3296. exports.createStyleSheet = createStyleSheet;
  3297. /**
  3298. * Checks if the given value is a `SafeStyleSheet` instance.
  3299. */
  3300. function isStyleSheet(value) {
  3301. return value instanceof StyleSheetImpl;
  3302. }
  3303. exports.isStyleSheet = isStyleSheet;
  3304. /**
  3305. * Returns the string value of the passed `SafeStyleSheet` object while
  3306. * ensuring it has the correct type.
  3307. */
  3308. function unwrapStyleSheet(value) {
  3309. if (value instanceof StyleSheetImpl) {
  3310. return value.privateDoNotAccessOrElseWrappedStyleSheet;
  3311. }
  3312. else {
  3313. var message = '';
  3314. if (true) {
  3315. message = 'Unexpected type when unwrapping SafeStyleSheet';
  3316. }
  3317. throw new Error(message);
  3318. }
  3319. }
  3320. exports.unwrapStyleSheet = unwrapStyleSheet;
  3321. /***/ }),
  3322. /***/ "./node_modules/safevalues/internals/trusted_types.js":
  3323. /*!************************************************************!*\
  3324. !*** ./node_modules/safevalues/internals/trusted_types.js ***!
  3325. \************************************************************/
  3326. /*! no static exports found */
  3327. /***/ (function(module, exports, __webpack_require__) {
  3328. "use strict";
  3329. /**
  3330. * @license
  3331. * SPDX-License-Identifier: Apache-2.0
  3332. */
  3333. Object.defineProperty(exports, "__esModule", { value: true });
  3334. exports.TEST_ONLY = exports.getTrustedTypesPolicy = exports.getTrustedTypes = void 0;
  3335. /**
  3336. * The name of the Trusted Types policy used by TS safevalues, or empty
  3337. * to disable Trusted Types. This duplicates the 'google#safe', but
  3338. * can be overridden in tests.
  3339. */
  3340. var trustedTypesPolicyName = 'google#safe';
  3341. /** Helper to retrieve the value of `window.trustedTypes`. */
  3342. function trustedTypes() {
  3343. if (typeof window !== 'undefined') {
  3344. return window.trustedTypes;
  3345. }
  3346. return undefined;
  3347. }
  3348. /**
  3349. * Returns window.trustedTypes if Trusted Types are enabled and supported, or
  3350. * null otherwise.
  3351. */
  3352. function getTrustedTypes() {
  3353. var _a;
  3354. return (trustedTypesPolicyName !== '') ? ((_a = trustedTypes()) !== null && _a !== void 0 ? _a : null) : null;
  3355. }
  3356. exports.getTrustedTypes = getTrustedTypes;
  3357. /**
  3358. * The Trusted Types policy used by TS safevalues, or null if Trusted Types
  3359. * are not enabled/supported, or undefined if the policy has not been created
  3360. * yet.
  3361. */
  3362. var trustedTypesPolicy;
  3363. /**
  3364. * Returns the Trusted Types policy used by TS safevalues, or null if Trusted
  3365. * Types are not enabled/supported. The first call to this function will
  3366. * create the policy.
  3367. */
  3368. function getTrustedTypesPolicy() {
  3369. var _a, _b;
  3370. if (trustedTypesPolicy === undefined) {
  3371. try {
  3372. trustedTypesPolicy =
  3373. (_b = (_a = getTrustedTypes()) === null || _a === void 0 ? void 0 : _a.createPolicy(trustedTypesPolicyName, {
  3374. createHTML: function (s) { return s; },
  3375. createScript: function (s) { return s; },
  3376. createScriptURL: function (s) { return s; }
  3377. })) !== null && _b !== void 0 ? _b : null;
  3378. }
  3379. catch (_c) {
  3380. // In Chromium versions before 81, trustedTypes.createPolicy throws if
  3381. // called with a name that is already registered, even if no CSP is set.
  3382. // Until users have largely migrated to 81 or above, catch the error not
  3383. // to break the applications functionally. In such case, the code will
  3384. // fall back to using regular Safe Types.
  3385. trustedTypesPolicy = null;
  3386. }
  3387. }
  3388. return trustedTypesPolicy;
  3389. }
  3390. exports.getTrustedTypesPolicy = getTrustedTypesPolicy;
  3391. /** Helpers for tests. */
  3392. exports.TEST_ONLY = {
  3393. resetDefaults: function () {
  3394. trustedTypesPolicy = undefined;
  3395. trustedTypesPolicyName = 'google#safe';
  3396. },
  3397. setTrustedTypesPolicyName: function (name) {
  3398. trustedTypesPolicyName = name;
  3399. },
  3400. };
  3401. /***/ }),
  3402. /***/ "./packages/mdc-animation/animationframe.ts":
  3403. /*!**************************************************!*\
  3404. !*** ./packages/mdc-animation/animationframe.ts ***!
  3405. \**************************************************/
  3406. /*! no static exports found */
  3407. /***/ (function(module, exports, __webpack_require__) {
  3408. "use strict";
  3409. /**
  3410. * @license
  3411. * Copyright 2020 Google Inc.
  3412. *
  3413. * Permission is hereby granted, free of charge, to any person obtaining a copy
  3414. * of this software and associated documentation files (the "Software"), to deal
  3415. * in the Software without restriction, including without limitation the rights
  3416. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3417. * copies of the Software, and to permit persons to whom the Software is
  3418. * furnished to do so, subject to the following conditions:
  3419. *
  3420. * The above copyright notice and this permission notice shall be included in
  3421. * all copies or substantial portions of the Software.
  3422. *
  3423. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3424. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3425. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3426. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3427. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3428. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3429. * THE SOFTWARE.
  3430. */
  3431. Object.defineProperty(exports, "__esModule", { value: true });
  3432. exports.AnimationFrame = void 0;
  3433. /**
  3434. * AnimationFrame provides a user-friendly abstraction around requesting
  3435. * and canceling animation frames.
  3436. */
  3437. var AnimationFrame = /** @class */function () {
  3438. function AnimationFrame() {
  3439. this.rafIDs = new Map();
  3440. }
  3441. /**
  3442. * Requests an animation frame. Cancels any existing frame with the same key.
  3443. * @param {string} key The key for this callback.
  3444. * @param {FrameRequestCallback} callback The callback to be executed.
  3445. */
  3446. AnimationFrame.prototype.request = function (key, callback) {
  3447. var _this = this;
  3448. this.cancel(key);
  3449. var frameID = requestAnimationFrame(function (frame) {
  3450. _this.rafIDs.delete(key);
  3451. // Callback must come *after* the key is deleted so that nested calls to
  3452. // request with the same key are not deleted.
  3453. callback(frame);
  3454. });
  3455. this.rafIDs.set(key, frameID);
  3456. };
  3457. /**
  3458. * Cancels a queued callback with the given key.
  3459. * @param {string} key The key for this callback.
  3460. */
  3461. AnimationFrame.prototype.cancel = function (key) {
  3462. var rafID = this.rafIDs.get(key);
  3463. if (rafID) {
  3464. cancelAnimationFrame(rafID);
  3465. this.rafIDs.delete(key);
  3466. }
  3467. };
  3468. /**
  3469. * Cancels all queued callback.
  3470. */
  3471. AnimationFrame.prototype.cancelAll = function () {
  3472. var _this = this;
  3473. // Need to use forEach because it's the only iteration method supported
  3474. // by IE11. Suppress the underscore because we don't need it.
  3475. // tslint:disable-next-line:enforce-name-casing
  3476. this.rafIDs.forEach(function (_, key) {
  3477. _this.cancel(key);
  3478. });
  3479. };
  3480. /**
  3481. * Returns the queue of unexecuted callback keys.
  3482. */
  3483. AnimationFrame.prototype.getQueue = function () {
  3484. var queue = [];
  3485. // Need to use forEach because it's the only iteration method supported
  3486. // by IE11. Suppress the underscore because we don't need it.
  3487. // tslint:disable-next-line:enforce-name-casing
  3488. this.rafIDs.forEach(function (_, key) {
  3489. queue.push(key);
  3490. });
  3491. return queue;
  3492. };
  3493. return AnimationFrame;
  3494. }();
  3495. exports.AnimationFrame = AnimationFrame;
  3496. /***/ }),
  3497. /***/ "./packages/mdc-animation/util.ts":
  3498. /*!****************************************!*\
  3499. !*** ./packages/mdc-animation/util.ts ***!
  3500. \****************************************/
  3501. /*! no static exports found */
  3502. /***/ (function(module, exports, __webpack_require__) {
  3503. "use strict";
  3504. /**
  3505. * @license
  3506. * Copyright 2016 Google Inc.
  3507. *
  3508. * Permission is hereby granted, free of charge, to any person obtaining a copy
  3509. * of this software and associated documentation files (the "Software"), to deal
  3510. * in the Software without restriction, including without limitation the rights
  3511. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3512. * copies of the Software, and to permit persons to whom the Software is
  3513. * furnished to do so, subject to the following conditions:
  3514. *
  3515. * The above copyright notice and this permission notice shall be included in
  3516. * all copies or substantial portions of the Software.
  3517. *
  3518. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3519. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3520. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3521. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3522. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3523. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3524. * THE SOFTWARE.
  3525. */
  3526. Object.defineProperty(exports, "__esModule", { value: true });
  3527. exports.getCorrectEventName = exports.getCorrectPropertyName = void 0;
  3528. var cssPropertyNameMap = {
  3529. animation: {
  3530. prefixed: '-webkit-animation',
  3531. standard: 'animation'
  3532. },
  3533. transform: {
  3534. prefixed: '-webkit-transform',
  3535. standard: 'transform'
  3536. },
  3537. transition: {
  3538. prefixed: '-webkit-transition',
  3539. standard: 'transition'
  3540. }
  3541. };
  3542. var jsEventTypeMap = {
  3543. animationend: {
  3544. cssProperty: 'animation',
  3545. prefixed: 'webkitAnimationEnd',
  3546. standard: 'animationend'
  3547. },
  3548. animationiteration: {
  3549. cssProperty: 'animation',
  3550. prefixed: 'webkitAnimationIteration',
  3551. standard: 'animationiteration'
  3552. },
  3553. animationstart: {
  3554. cssProperty: 'animation',
  3555. prefixed: 'webkitAnimationStart',
  3556. standard: 'animationstart'
  3557. },
  3558. transitionend: {
  3559. cssProperty: 'transition',
  3560. prefixed: 'webkitTransitionEnd',
  3561. standard: 'transitionend'
  3562. }
  3563. };
  3564. function isWindow(windowObj) {
  3565. return Boolean(windowObj.document) && typeof windowObj.document.createElement === 'function';
  3566. }
  3567. function getCorrectPropertyName(windowObj, cssProperty) {
  3568. if (isWindow(windowObj) && cssProperty in cssPropertyNameMap) {
  3569. var el = windowObj.document.createElement('div');
  3570. var _a = cssPropertyNameMap[cssProperty],
  3571. standard = _a.standard,
  3572. prefixed = _a.prefixed;
  3573. var isStandard = standard in el.style;
  3574. return isStandard ? standard : prefixed;
  3575. }
  3576. return cssProperty;
  3577. }
  3578. exports.getCorrectPropertyName = getCorrectPropertyName;
  3579. function getCorrectEventName(windowObj, eventType) {
  3580. if (isWindow(windowObj) && eventType in jsEventTypeMap) {
  3581. var el = windowObj.document.createElement('div');
  3582. var _a = jsEventTypeMap[eventType],
  3583. standard = _a.standard,
  3584. prefixed = _a.prefixed,
  3585. cssProperty = _a.cssProperty;
  3586. var isStandard = cssProperty in el.style;
  3587. return isStandard ? standard : prefixed;
  3588. }
  3589. return eventType;
  3590. }
  3591. exports.getCorrectEventName = getCorrectEventName;
  3592. /***/ }),
  3593. /***/ "./packages/mdc-base/component.ts":
  3594. /*!****************************************!*\
  3595. !*** ./packages/mdc-base/component.ts ***!
  3596. \****************************************/
  3597. /*! no static exports found */
  3598. /***/ (function(module, exports, __webpack_require__) {
  3599. "use strict";
  3600. /**
  3601. * @license
  3602. * Copyright 2016 Google Inc.
  3603. *
  3604. * Permission is hereby granted, free of charge, to any person obtaining a copy
  3605. * of this software and associated documentation files (the "Software"), to deal
  3606. * in the Software without restriction, including without limitation the rights
  3607. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3608. * copies of the Software, and to permit persons to whom the Software is
  3609. * furnished to do so, subject to the following conditions:
  3610. *
  3611. * The above copyright notice and this permission notice shall be included in
  3612. * all copies or substantial portions of the Software.
  3613. *
  3614. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3615. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3616. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3617. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3618. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3619. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3620. * THE SOFTWARE.
  3621. */
  3622. var __makeTemplateObject = this && this.__makeTemplateObject || function (cooked, raw) {
  3623. if (Object.defineProperty) {
  3624. Object.defineProperty(cooked, "raw", { value: raw });
  3625. } else {
  3626. cooked.raw = raw;
  3627. }
  3628. return cooked;
  3629. };
  3630. var __read = this && this.__read || function (o, n) {
  3631. var m = typeof Symbol === "function" && o[Symbol.iterator];
  3632. if (!m) return o;
  3633. var i = m.call(o),
  3634. r,
  3635. ar = [],
  3636. e;
  3637. try {
  3638. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
  3639. ar.push(r.value);
  3640. }
  3641. } catch (error) {
  3642. e = { error: error };
  3643. } finally {
  3644. try {
  3645. if (r && !r.done && (m = i["return"])) m.call(i);
  3646. } finally {
  3647. if (e) throw e.error;
  3648. }
  3649. }
  3650. return ar;
  3651. };
  3652. var __spreadArray = this && this.__spreadArray || function (to, from) {
  3653. for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) {
  3654. to[j] = from[i];
  3655. }return to;
  3656. };
  3657. Object.defineProperty(exports, "__esModule", { value: true });
  3658. exports.MDCComponent = void 0;
  3659. var safevalues_1 = __webpack_require__(/*! safevalues */ "./node_modules/safevalues/index.js");
  3660. var dom_1 = __webpack_require__(/*! safevalues/dom */ "./node_modules/safevalues/dom/index.js");
  3661. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-base/foundation.ts");
  3662. function toCamelCase(str) {
  3663. // tslint:disable-next-line:enforce-name-casing
  3664. return String(str).replace(/\-([a-z])/g, function (_, match) {
  3665. return match.toUpperCase();
  3666. });
  3667. }
  3668. /** MDC Component base */
  3669. var MDCComponent = /** @class */function () {
  3670. function MDCComponent(root, foundation) {
  3671. var args = [];
  3672. for (var _i = 2; _i < arguments.length; _i++) {
  3673. args[_i - 2] = arguments[_i];
  3674. }
  3675. this.root = root;
  3676. this.initialize.apply(this, __spreadArray([], __read(args)));
  3677. // Note that we initialize foundation here and not within the constructor's
  3678. // default param so that this.root is defined and can be used within the
  3679. // foundation class.
  3680. this.foundation = foundation === undefined ? this.getDefaultFoundation() : foundation;
  3681. this.foundation.init();
  3682. this.initialSyncWithDOM();
  3683. }
  3684. MDCComponent.attachTo = function (root) {
  3685. // Subclasses which extend MDCBase should provide an attachTo() method that
  3686. // takes a root element and returns an instantiated component with its root
  3687. // set to that element. Also note that in the cases of subclasses, an
  3688. // explicit foundation class will not have to be passed in; it will simply
  3689. // be initialized from getDefaultFoundation().
  3690. return new MDCComponent(root, new foundation_1.MDCFoundation({}));
  3691. };
  3692. /* istanbul ignore next: method param only exists for typing purposes; it does
  3693. * not need to be unit tested */
  3694. // tslint:disable-next-line:enforce-name-casing
  3695. MDCComponent.prototype.initialize = function () {
  3696. var _args = [];
  3697. for (var _i = 0; _i < arguments.length; _i++) {
  3698. _args[_i] = arguments[_i];
  3699. }
  3700. // Subclasses can override this to do any additional setup work that would
  3701. // be considered part of a "constructor". Essentially, it is a hook into the
  3702. // parent constructor before the foundation is initialized. Any additional
  3703. // arguments besides root and foundation will be passed in here.
  3704. };
  3705. MDCComponent.prototype.getDefaultFoundation = function () {
  3706. // Subclasses must override this method to return a properly configured
  3707. // foundation class for the component.
  3708. throw new Error('Subclasses must override getDefaultFoundation to return a properly configured ' + 'foundation class');
  3709. };
  3710. MDCComponent.prototype.initialSyncWithDOM = function () {
  3711. // Subclasses should override this method if they need to perform work to
  3712. // synchronize with a host DOM object. An example of this would be a form
  3713. // control wrapper that needs to synchronize its internal state to some
  3714. // property or attribute of the host DOM. Please note: this is *not* the
  3715. // place to perform DOM reads/writes that would cause layout / paint, as
  3716. // this is called synchronously from within the constructor.
  3717. };
  3718. MDCComponent.prototype.destroy = function () {
  3719. // Subclasses may implement this method to release any resources /
  3720. // deregister any listeners they have attached. An example of this might be
  3721. // deregistering a resize event from the window object.
  3722. this.foundation.destroy();
  3723. };
  3724. MDCComponent.prototype.listen = function (evtType, handler, options) {
  3725. this.root.addEventListener(evtType, handler, options);
  3726. };
  3727. MDCComponent.prototype.unlisten = function (evtType, handler, options) {
  3728. this.root.removeEventListener(evtType, handler, options);
  3729. };
  3730. /**
  3731. * Fires a cross-browser-compatible custom event from the component root of
  3732. * the given type, with the given data.
  3733. */
  3734. MDCComponent.prototype.emit = function (evtType, evtData, shouldBubble) {
  3735. if (shouldBubble === void 0) {
  3736. shouldBubble = false;
  3737. }
  3738. var evt;
  3739. if (typeof CustomEvent === 'function') {
  3740. evt = new CustomEvent(evtType, {
  3741. bubbles: shouldBubble,
  3742. detail: evtData
  3743. });
  3744. } else {
  3745. evt = document.createEvent('CustomEvent');
  3746. evt.initCustomEvent(evtType, shouldBubble, false, evtData);
  3747. }
  3748. this.root.dispatchEvent(evt);
  3749. };
  3750. /**
  3751. * This is a intermediate fix to allow components to use safevalues. This
  3752. * limits setAttribute to setting tabindex, data attributes, and aria
  3753. * attributes.
  3754. *
  3755. * TODO(b/263990206): remove this method and add these directly in each
  3756. * component. This will remove this abstraction and make it clear that the
  3757. * caller can't set any attribute.
  3758. */
  3759. MDCComponent.prototype.safeSetAttribute = function (element, attribute, value) {
  3760. if (attribute.toLowerCase() === 'tabindex') {
  3761. element.tabIndex = Number(value);
  3762. } else if (attribute.indexOf('data-') === 0) {
  3763. var dataKey = toCamelCase(attribute.replace(/^data-/, ''));
  3764. element.dataset[dataKey] = value;
  3765. } else {
  3766. dom_1.safeElement.setPrefixedAttribute([safevalues_1.safeAttrPrefix(templateObject_1 || (templateObject_1 = __makeTemplateObject(["aria-"], ["aria-"]))), safevalues_1.safeAttrPrefix(templateObject_2 || (templateObject_2 = __makeTemplateObject(["role"], ["role"])))], element, attribute, value);
  3767. }
  3768. };
  3769. return MDCComponent;
  3770. }();
  3771. exports.MDCComponent = MDCComponent;
  3772. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  3773. exports.default = MDCComponent;
  3774. var templateObject_1, templateObject_2;
  3775. /***/ }),
  3776. /***/ "./packages/mdc-base/foundation.ts":
  3777. /*!*****************************************!*\
  3778. !*** ./packages/mdc-base/foundation.ts ***!
  3779. \*****************************************/
  3780. /*! no static exports found */
  3781. /***/ (function(module, exports, __webpack_require__) {
  3782. "use strict";
  3783. /**
  3784. * @license
  3785. * Copyright 2016 Google Inc.
  3786. *
  3787. * Permission is hereby granted, free of charge, to any person obtaining a copy
  3788. * of this software and associated documentation files (the "Software"), to deal
  3789. * in the Software without restriction, including without limitation the rights
  3790. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3791. * copies of the Software, and to permit persons to whom the Software is
  3792. * furnished to do so, subject to the following conditions:
  3793. *
  3794. * The above copyright notice and this permission notice shall be included in
  3795. * all copies or substantial portions of the Software.
  3796. *
  3797. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3798. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3799. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3800. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3801. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3802. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3803. * THE SOFTWARE.
  3804. */
  3805. Object.defineProperty(exports, "__esModule", { value: true });
  3806. exports.MDCFoundation = void 0;
  3807. /** MDC Foundation */
  3808. var MDCFoundation = /** @class */function () {
  3809. function MDCFoundation(adapter) {
  3810. if (adapter === void 0) {
  3811. adapter = {};
  3812. }
  3813. this.adapter = adapter;
  3814. }
  3815. Object.defineProperty(MDCFoundation, "cssClasses", {
  3816. get: function get() {
  3817. // Classes extending MDCFoundation should implement this method to return an
  3818. // object which exports every CSS class the foundation class needs as a
  3819. // property. e.g. {ACTIVE: 'mdc-component--active'}
  3820. return {};
  3821. },
  3822. enumerable: false,
  3823. configurable: true
  3824. });
  3825. Object.defineProperty(MDCFoundation, "strings", {
  3826. get: function get() {
  3827. // Classes extending MDCFoundation should implement this method to return an
  3828. // object which exports all semantic strings as constants. e.g. {ARIA_ROLE:
  3829. // 'tablist'}
  3830. return {};
  3831. },
  3832. enumerable: false,
  3833. configurable: true
  3834. });
  3835. Object.defineProperty(MDCFoundation, "numbers", {
  3836. get: function get() {
  3837. // Classes extending MDCFoundation should implement this method to return an
  3838. // object which exports all of its semantic numbers as constants.
  3839. // e.g. {ANIMATION_DELAY_MS: 350}
  3840. return {};
  3841. },
  3842. enumerable: false,
  3843. configurable: true
  3844. });
  3845. Object.defineProperty(MDCFoundation, "defaultAdapter", {
  3846. get: function get() {
  3847. // Classes extending MDCFoundation may choose to implement this getter in
  3848. // order to provide a convenient way of viewing the necessary methods of an
  3849. // adapter. In the future, this could also be used for adapter validation.
  3850. return {};
  3851. },
  3852. enumerable: false,
  3853. configurable: true
  3854. });
  3855. MDCFoundation.prototype.init = function () {
  3856. // Subclasses should override this method to perform initialization routines
  3857. // (registering events, etc.)
  3858. };
  3859. MDCFoundation.prototype.destroy = function () {
  3860. // Subclasses should override this method to perform de-initialization
  3861. // routines (de-registering events, etc.)
  3862. };
  3863. return MDCFoundation;
  3864. }();
  3865. exports.MDCFoundation = MDCFoundation;
  3866. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  3867. exports.default = MDCFoundation;
  3868. /***/ }),
  3869. /***/ "./packages/mdc-dom/events.ts":
  3870. /*!************************************!*\
  3871. !*** ./packages/mdc-dom/events.ts ***!
  3872. \************************************/
  3873. /*! no static exports found */
  3874. /***/ (function(module, exports, __webpack_require__) {
  3875. "use strict";
  3876. /**
  3877. * @license
  3878. * Copyright 2019 Google Inc.
  3879. *
  3880. * Permission is hereby granted, free of charge, to any person obtaining a copy
  3881. * of this software and associated documentation files (the "Software"), to deal
  3882. * in the Software without restriction, including without limitation the rights
  3883. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3884. * copies of the Software, and to permit persons to whom the Software is
  3885. * furnished to do so, subject to the following conditions:
  3886. *
  3887. * The above copyright notice and this permission notice shall be included in
  3888. * all copies or substantial portions of the Software.
  3889. *
  3890. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3891. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3892. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3893. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3894. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3895. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3896. * THE SOFTWARE.
  3897. */
  3898. Object.defineProperty(exports, "__esModule", { value: true });
  3899. exports.applyPassive = void 0;
  3900. /**
  3901. * Determine whether the current browser supports passive event listeners, and
  3902. * if so, use them.
  3903. */
  3904. function applyPassive(globalObj) {
  3905. if (globalObj === void 0) {
  3906. globalObj = window;
  3907. }
  3908. return supportsPassiveOption(globalObj) ? { passive: true } : false;
  3909. }
  3910. exports.applyPassive = applyPassive;
  3911. function supportsPassiveOption(globalObj) {
  3912. if (globalObj === void 0) {
  3913. globalObj = window;
  3914. }
  3915. // See
  3916. // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
  3917. var passiveSupported = false;
  3918. try {
  3919. var options = {
  3920. // This function will be called when the browser
  3921. // attempts to access the passive property.
  3922. get passive() {
  3923. passiveSupported = true;
  3924. return false;
  3925. }
  3926. };
  3927. var handler = function handler() {};
  3928. globalObj.document.addEventListener('test', handler, options);
  3929. globalObj.document.removeEventListener('test', handler, options);
  3930. } catch (err) {
  3931. passiveSupported = false;
  3932. }
  3933. return passiveSupported;
  3934. }
  3935. /***/ }),
  3936. /***/ "./packages/mdc-dom/ponyfill.ts":
  3937. /*!**************************************!*\
  3938. !*** ./packages/mdc-dom/ponyfill.ts ***!
  3939. \**************************************/
  3940. /*! no static exports found */
  3941. /***/ (function(module, exports, __webpack_require__) {
  3942. "use strict";
  3943. /**
  3944. * @license
  3945. * Copyright 2018 Google Inc.
  3946. *
  3947. * Permission is hereby granted, free of charge, to any person obtaining a copy
  3948. * of this software and associated documentation files (the "Software"), to deal
  3949. * in the Software without restriction, including without limitation the rights
  3950. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3951. * copies of the Software, and to permit persons to whom the Software is
  3952. * furnished to do so, subject to the following conditions:
  3953. *
  3954. * The above copyright notice and this permission notice shall be included in
  3955. * all copies or substantial portions of the Software.
  3956. *
  3957. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3958. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3959. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3960. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3961. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3962. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3963. * THE SOFTWARE.
  3964. */
  3965. Object.defineProperty(exports, "__esModule", { value: true });
  3966. exports.estimateScrollWidth = exports.matches = exports.closest = void 0;
  3967. /**
  3968. * @fileoverview A "ponyfill" is a polyfill that doesn't modify the global
  3969. * prototype chain. This makes ponyfills safer than traditional polyfills,
  3970. * especially for libraries like MDC.
  3971. */
  3972. function closest(element, selector) {
  3973. if (element.closest) {
  3974. return element.closest(selector);
  3975. }
  3976. var el = element;
  3977. while (el) {
  3978. if (matches(el, selector)) {
  3979. return el;
  3980. }
  3981. el = el.parentElement;
  3982. }
  3983. return null;
  3984. }
  3985. exports.closest = closest;
  3986. /** Element.matches with support for webkit and IE. */
  3987. function matches(element, selector) {
  3988. var nativeMatches = element.matches || element.webkitMatchesSelector || element.msMatchesSelector;
  3989. return nativeMatches.call(element, selector);
  3990. }
  3991. exports.matches = matches;
  3992. /**
  3993. * Used to compute the estimated scroll width of elements. When an element is
  3994. * hidden due to display: none; being applied to a parent element, the width is
  3995. * returned as 0. However, the element will have a true width once no longer
  3996. * inside a display: none context. This method computes an estimated width when
  3997. * the element is hidden or returns the true width when the element is visble.
  3998. * @param {Element} element the element whose width to estimate
  3999. */
  4000. function estimateScrollWidth(element) {
  4001. // Check the offsetParent. If the element inherits display: none from any
  4002. // parent, the offsetParent property will be null (see
  4003. // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent).
  4004. // This check ensures we only clone the node when necessary.
  4005. var htmlEl = element;
  4006. if (htmlEl.offsetParent !== null) {
  4007. return htmlEl.scrollWidth;
  4008. }
  4009. var clone = htmlEl.cloneNode(true);
  4010. clone.style.setProperty('position', 'absolute');
  4011. clone.style.setProperty('transform', 'translate(-9999px, -9999px)');
  4012. document.documentElement.appendChild(clone);
  4013. var scrollWidth = clone.scrollWidth;
  4014. document.documentElement.removeChild(clone);
  4015. return scrollWidth;
  4016. }
  4017. exports.estimateScrollWidth = estimateScrollWidth;
  4018. /***/ }),
  4019. /***/ "./packages/mdc-ripple/component.ts":
  4020. /*!******************************************!*\
  4021. !*** ./packages/mdc-ripple/component.ts ***!
  4022. \******************************************/
  4023. /*! no static exports found */
  4024. /***/ (function(module, exports, __webpack_require__) {
  4025. "use strict";
  4026. /**
  4027. * @license
  4028. * Copyright 2016 Google Inc.
  4029. *
  4030. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4031. * of this software and associated documentation files (the "Software"), to deal
  4032. * in the Software without restriction, including without limitation the rights
  4033. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4034. * copies of the Software, and to permit persons to whom the Software is
  4035. * furnished to do so, subject to the following conditions:
  4036. *
  4037. * The above copyright notice and this permission notice shall be included in
  4038. * all copies or substantial portions of the Software.
  4039. *
  4040. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4041. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4042. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4043. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4044. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4045. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4046. * THE SOFTWARE.
  4047. */
  4048. var __extends = this && this.__extends || function () {
  4049. var _extendStatics = function extendStatics(d, b) {
  4050. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  4051. d.__proto__ = b;
  4052. } || function (d, b) {
  4053. for (var p in b) {
  4054. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  4055. }
  4056. };
  4057. return _extendStatics(d, b);
  4058. };
  4059. return function (d, b) {
  4060. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  4061. _extendStatics(d, b);
  4062. function __() {
  4063. this.constructor = d;
  4064. }
  4065. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4066. };
  4067. }();
  4068. var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
  4069. if (k2 === undefined) k2 = k;
  4070. Object.defineProperty(o, k2, { enumerable: true, get: function get() {
  4071. return m[k];
  4072. } });
  4073. } : function (o, m, k, k2) {
  4074. if (k2 === undefined) k2 = k;
  4075. o[k2] = m[k];
  4076. });
  4077. var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
  4078. Object.defineProperty(o, "default", { enumerable: true, value: v });
  4079. } : function (o, v) {
  4080. o["default"] = v;
  4081. });
  4082. var __importStar = this && this.__importStar || function (mod) {
  4083. if (mod && mod.__esModule) return mod;
  4084. var result = {};
  4085. if (mod != null) for (var k in mod) {
  4086. if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  4087. }__setModuleDefault(result, mod);
  4088. return result;
  4089. };
  4090. Object.defineProperty(exports, "__esModule", { value: true });
  4091. exports.MDCRipple = void 0;
  4092. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  4093. var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
  4094. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  4095. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-ripple/foundation.ts");
  4096. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts"));
  4097. /** MDC Ripple */
  4098. var MDCRipple = /** @class */function (_super) {
  4099. __extends(MDCRipple, _super);
  4100. function MDCRipple() {
  4101. var _this = _super !== null && _super.apply(this, arguments) || this;
  4102. _this.disabled = false;
  4103. return _this;
  4104. }
  4105. MDCRipple.attachTo = function (root, opts) {
  4106. if (opts === void 0) {
  4107. opts = {
  4108. isUnbounded: undefined
  4109. };
  4110. }
  4111. var ripple = new MDCRipple(root);
  4112. // Only override unbounded behavior if option is explicitly specified
  4113. if (opts.isUnbounded !== undefined) {
  4114. ripple.unbounded = opts.isUnbounded;
  4115. }
  4116. return ripple;
  4117. };
  4118. MDCRipple.createAdapter = function (instance) {
  4119. return {
  4120. addClass: function addClass(className) {
  4121. instance.root.classList.add(className);
  4122. },
  4123. browserSupportsCssVars: function browserSupportsCssVars() {
  4124. return util.supportsCssVariables(window);
  4125. },
  4126. computeBoundingRect: function computeBoundingRect() {
  4127. return instance.root.getBoundingClientRect();
  4128. },
  4129. containsEventTarget: function containsEventTarget(target) {
  4130. return instance.root.contains(target);
  4131. },
  4132. deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler(evtType, handler) {
  4133. document.documentElement.removeEventListener(evtType, handler, events_1.applyPassive());
  4134. },
  4135. deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  4136. instance.root.removeEventListener(evtType, handler, events_1.applyPassive());
  4137. },
  4138. deregisterResizeHandler: function deregisterResizeHandler(handler) {
  4139. window.removeEventListener('resize', handler);
  4140. },
  4141. getWindowPageOffset: function getWindowPageOffset() {
  4142. return { x: window.pageXOffset, y: window.pageYOffset };
  4143. },
  4144. isSurfaceActive: function isSurfaceActive() {
  4145. return ponyfill_1.matches(instance.root, ':active');
  4146. },
  4147. isSurfaceDisabled: function isSurfaceDisabled() {
  4148. return Boolean(instance.disabled);
  4149. },
  4150. isUnbounded: function isUnbounded() {
  4151. return Boolean(instance.unbounded);
  4152. },
  4153. registerDocumentInteractionHandler: function registerDocumentInteractionHandler(evtType, handler) {
  4154. document.documentElement.addEventListener(evtType, handler, events_1.applyPassive());
  4155. },
  4156. registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  4157. instance.root.addEventListener(evtType, handler, events_1.applyPassive());
  4158. },
  4159. registerResizeHandler: function registerResizeHandler(handler) {
  4160. window.addEventListener('resize', handler);
  4161. },
  4162. removeClass: function removeClass(className) {
  4163. instance.root.classList.remove(className);
  4164. },
  4165. updateCssVariable: function updateCssVariable(varName, value) {
  4166. instance.root.style.setProperty(varName, value);
  4167. }
  4168. };
  4169. };
  4170. Object.defineProperty(MDCRipple.prototype, "unbounded", {
  4171. get: function get() {
  4172. return Boolean(this.isUnbounded);
  4173. },
  4174. set: function set(unbounded) {
  4175. this.isUnbounded = Boolean(unbounded);
  4176. this.setUnbounded();
  4177. },
  4178. enumerable: false,
  4179. configurable: true
  4180. });
  4181. MDCRipple.prototype.activate = function () {
  4182. this.foundation.activate();
  4183. };
  4184. MDCRipple.prototype.deactivate = function () {
  4185. this.foundation.deactivate();
  4186. };
  4187. MDCRipple.prototype.layout = function () {
  4188. this.foundation.layout();
  4189. };
  4190. MDCRipple.prototype.getDefaultFoundation = function () {
  4191. return new foundation_1.MDCRippleFoundation(MDCRipple.createAdapter(this));
  4192. };
  4193. MDCRipple.prototype.initialSyncWithDOM = function () {
  4194. var root = this.root;
  4195. this.isUnbounded = 'mdcRippleIsUnbounded' in root.dataset;
  4196. };
  4197. /**
  4198. * Closure Compiler throws an access control error when directly accessing a
  4199. * protected or private property inside a getter/setter, like unbounded above.
  4200. * By accessing the protected property inside a method, we solve that problem.
  4201. * That's why this function exists.
  4202. */
  4203. MDCRipple.prototype.setUnbounded = function () {
  4204. this.foundation.setUnbounded(Boolean(this.isUnbounded));
  4205. };
  4206. return MDCRipple;
  4207. }(component_1.MDCComponent);
  4208. exports.MDCRipple = MDCRipple;
  4209. /***/ }),
  4210. /***/ "./packages/mdc-ripple/constants.ts":
  4211. /*!******************************************!*\
  4212. !*** ./packages/mdc-ripple/constants.ts ***!
  4213. \******************************************/
  4214. /*! no static exports found */
  4215. /***/ (function(module, exports, __webpack_require__) {
  4216. "use strict";
  4217. /**
  4218. * @license
  4219. * Copyright 2016 Google Inc.
  4220. *
  4221. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4222. * of this software and associated documentation files (the "Software"), to deal
  4223. * in the Software without restriction, including without limitation the rights
  4224. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4225. * copies of the Software, and to permit persons to whom the Software is
  4226. * furnished to do so, subject to the following conditions:
  4227. *
  4228. * The above copyright notice and this permission notice shall be included in
  4229. * all copies or substantial portions of the Software.
  4230. *
  4231. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4232. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4233. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4234. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4235. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4236. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4237. * THE SOFTWARE.
  4238. */
  4239. Object.defineProperty(exports, "__esModule", { value: true });
  4240. exports.numbers = exports.strings = exports.cssClasses = void 0;
  4241. exports.cssClasses = {
  4242. // Ripple is a special case where the "root" component is really a "mixin" of
  4243. // sorts,
  4244. // given that it's an 'upgrade' to an existing component. That being said it
  4245. // is the root
  4246. // CSS class that all other CSS classes derive from.
  4247. BG_FOCUSED: 'mdc-ripple-upgraded--background-focused',
  4248. FG_ACTIVATION: 'mdc-ripple-upgraded--foreground-activation',
  4249. FG_DEACTIVATION: 'mdc-ripple-upgraded--foreground-deactivation',
  4250. ROOT: 'mdc-ripple-upgraded',
  4251. UNBOUNDED: 'mdc-ripple-upgraded--unbounded'
  4252. };
  4253. exports.strings = {
  4254. VAR_FG_SCALE: '--mdc-ripple-fg-scale',
  4255. VAR_FG_SIZE: '--mdc-ripple-fg-size',
  4256. VAR_FG_TRANSLATE_END: '--mdc-ripple-fg-translate-end',
  4257. VAR_FG_TRANSLATE_START: '--mdc-ripple-fg-translate-start',
  4258. VAR_LEFT: '--mdc-ripple-left',
  4259. VAR_TOP: '--mdc-ripple-top'
  4260. };
  4261. exports.numbers = {
  4262. DEACTIVATION_TIMEOUT_MS: 225,
  4263. // animation duration)
  4264. FG_DEACTIVATION_MS: 150,
  4265. // (i.e. deactivation animation duration)
  4266. INITIAL_ORIGIN_SCALE: 0.6,
  4267. PADDING: 10,
  4268. TAP_DELAY_MS: 300 };
  4269. /***/ }),
  4270. /***/ "./packages/mdc-ripple/foundation.ts":
  4271. /*!*******************************************!*\
  4272. !*** ./packages/mdc-ripple/foundation.ts ***!
  4273. \*******************************************/
  4274. /*! no static exports found */
  4275. /***/ (function(module, exports, __webpack_require__) {
  4276. "use strict";
  4277. /**
  4278. * @license
  4279. * Copyright 2016 Google Inc.
  4280. *
  4281. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4282. * of this software and associated documentation files (the "Software"), to deal
  4283. * in the Software without restriction, including without limitation the rights
  4284. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4285. * copies of the Software, and to permit persons to whom the Software is
  4286. * furnished to do so, subject to the following conditions:
  4287. *
  4288. * The above copyright notice and this permission notice shall be included in
  4289. * all copies or substantial portions of the Software.
  4290. *
  4291. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4292. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4293. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4294. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4295. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4296. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4297. * THE SOFTWARE.
  4298. */
  4299. var __extends = this && this.__extends || function () {
  4300. var _extendStatics = function extendStatics(d, b) {
  4301. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  4302. d.__proto__ = b;
  4303. } || function (d, b) {
  4304. for (var p in b) {
  4305. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  4306. }
  4307. };
  4308. return _extendStatics(d, b);
  4309. };
  4310. return function (d, b) {
  4311. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  4312. _extendStatics(d, b);
  4313. function __() {
  4314. this.constructor = d;
  4315. }
  4316. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4317. };
  4318. }();
  4319. var __assign = this && this.__assign || function () {
  4320. __assign = Object.assign || function (t) {
  4321. for (var s, i = 1, n = arguments.length; i < n; i++) {
  4322. s = arguments[i];
  4323. for (var p in s) {
  4324. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  4325. }
  4326. }
  4327. return t;
  4328. };
  4329. return __assign.apply(this, arguments);
  4330. };
  4331. var __values = this && this.__values || function (o) {
  4332. var s = typeof Symbol === "function" && Symbol.iterator,
  4333. m = s && o[s],
  4334. i = 0;
  4335. if (m) return m.call(o);
  4336. if (o && typeof o.length === "number") return {
  4337. next: function next() {
  4338. if (o && i >= o.length) o = void 0;
  4339. return { value: o && o[i++], done: !o };
  4340. }
  4341. };
  4342. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  4343. };
  4344. Object.defineProperty(exports, "__esModule", { value: true });
  4345. exports.MDCRippleFoundation = void 0;
  4346. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  4347. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-ripple/constants.ts");
  4348. var util_1 = __webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts");
  4349. // Activation events registered on the root element of each instance for
  4350. // activation
  4351. var ACTIVATION_EVENT_TYPES = ['touchstart', 'pointerdown', 'mousedown', 'keydown'];
  4352. // Deactivation events registered on documentElement when a pointer-related down
  4353. // event occurs
  4354. var POINTER_DEACTIVATION_EVENT_TYPES = ['touchend', 'pointerup', 'mouseup', 'contextmenu'];
  4355. // simultaneous nested activations
  4356. var activatedTargets = [];
  4357. /** MDC Ripple Foundation */
  4358. var MDCRippleFoundation = /** @class */function (_super) {
  4359. __extends(MDCRippleFoundation, _super);
  4360. function MDCRippleFoundation(adapter) {
  4361. var _this = _super.call(this, __assign(__assign({}, MDCRippleFoundation.defaultAdapter), adapter)) || this;
  4362. _this.activationAnimationHasEnded = false;
  4363. _this.activationTimer = 0;
  4364. _this.fgDeactivationRemovalTimer = 0;
  4365. _this.fgScale = '0';
  4366. _this.frame = { width: 0, height: 0 };
  4367. _this.initialSize = 0;
  4368. _this.layoutFrame = 0;
  4369. _this.maxRadius = 0;
  4370. _this.unboundedCoords = { left: 0, top: 0 };
  4371. _this.activationState = _this.defaultActivationState();
  4372. _this.activationTimerCallback = function () {
  4373. _this.activationAnimationHasEnded = true;
  4374. _this.runDeactivationUXLogicIfReady();
  4375. };
  4376. _this.activateHandler = function (e) {
  4377. _this.activateImpl(e);
  4378. };
  4379. _this.deactivateHandler = function () {
  4380. _this.deactivateImpl();
  4381. };
  4382. _this.focusHandler = function () {
  4383. _this.handleFocus();
  4384. };
  4385. _this.blurHandler = function () {
  4386. _this.handleBlur();
  4387. };
  4388. _this.resizeHandler = function () {
  4389. _this.layout();
  4390. };
  4391. return _this;
  4392. }
  4393. Object.defineProperty(MDCRippleFoundation, "cssClasses", {
  4394. get: function get() {
  4395. return constants_1.cssClasses;
  4396. },
  4397. enumerable: false,
  4398. configurable: true
  4399. });
  4400. Object.defineProperty(MDCRippleFoundation, "strings", {
  4401. get: function get() {
  4402. return constants_1.strings;
  4403. },
  4404. enumerable: false,
  4405. configurable: true
  4406. });
  4407. Object.defineProperty(MDCRippleFoundation, "numbers", {
  4408. get: function get() {
  4409. return constants_1.numbers;
  4410. },
  4411. enumerable: false,
  4412. configurable: true
  4413. });
  4414. Object.defineProperty(MDCRippleFoundation, "defaultAdapter", {
  4415. get: function get() {
  4416. return {
  4417. addClass: function addClass() {
  4418. return undefined;
  4419. },
  4420. browserSupportsCssVars: function browserSupportsCssVars() {
  4421. return true;
  4422. },
  4423. computeBoundingRect: function computeBoundingRect() {
  4424. return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
  4425. },
  4426. containsEventTarget: function containsEventTarget() {
  4427. return true;
  4428. },
  4429. deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler() {
  4430. return undefined;
  4431. },
  4432. deregisterInteractionHandler: function deregisterInteractionHandler() {
  4433. return undefined;
  4434. },
  4435. deregisterResizeHandler: function deregisterResizeHandler() {
  4436. return undefined;
  4437. },
  4438. getWindowPageOffset: function getWindowPageOffset() {
  4439. return { x: 0, y: 0 };
  4440. },
  4441. isSurfaceActive: function isSurfaceActive() {
  4442. return true;
  4443. },
  4444. isSurfaceDisabled: function isSurfaceDisabled() {
  4445. return true;
  4446. },
  4447. isUnbounded: function isUnbounded() {
  4448. return true;
  4449. },
  4450. registerDocumentInteractionHandler: function registerDocumentInteractionHandler() {
  4451. return undefined;
  4452. },
  4453. registerInteractionHandler: function registerInteractionHandler() {
  4454. return undefined;
  4455. },
  4456. registerResizeHandler: function registerResizeHandler() {
  4457. return undefined;
  4458. },
  4459. removeClass: function removeClass() {
  4460. return undefined;
  4461. },
  4462. updateCssVariable: function updateCssVariable() {
  4463. return undefined;
  4464. }
  4465. };
  4466. },
  4467. enumerable: false,
  4468. configurable: true
  4469. });
  4470. MDCRippleFoundation.prototype.init = function () {
  4471. var _this = this;
  4472. var supportsPressRipple = this.supportsPressRipple();
  4473. this.registerRootHandlers(supportsPressRipple);
  4474. if (supportsPressRipple) {
  4475. var _a = MDCRippleFoundation.cssClasses,
  4476. ROOT_1 = _a.ROOT,
  4477. UNBOUNDED_1 = _a.UNBOUNDED;
  4478. requestAnimationFrame(function () {
  4479. _this.adapter.addClass(ROOT_1);
  4480. if (_this.adapter.isUnbounded()) {
  4481. _this.adapter.addClass(UNBOUNDED_1);
  4482. // Unbounded ripples need layout logic applied immediately to set
  4483. // coordinates for both shade and ripple
  4484. _this.layoutInternal();
  4485. }
  4486. });
  4487. }
  4488. };
  4489. MDCRippleFoundation.prototype.destroy = function () {
  4490. var _this = this;
  4491. if (this.supportsPressRipple()) {
  4492. if (this.activationTimer) {
  4493. clearTimeout(this.activationTimer);
  4494. this.activationTimer = 0;
  4495. this.adapter.removeClass(MDCRippleFoundation.cssClasses.FG_ACTIVATION);
  4496. }
  4497. if (this.fgDeactivationRemovalTimer) {
  4498. clearTimeout(this.fgDeactivationRemovalTimer);
  4499. this.fgDeactivationRemovalTimer = 0;
  4500. this.adapter.removeClass(MDCRippleFoundation.cssClasses.FG_DEACTIVATION);
  4501. }
  4502. var _a = MDCRippleFoundation.cssClasses,
  4503. ROOT_2 = _a.ROOT,
  4504. UNBOUNDED_2 = _a.UNBOUNDED;
  4505. requestAnimationFrame(function () {
  4506. _this.adapter.removeClass(ROOT_2);
  4507. _this.adapter.removeClass(UNBOUNDED_2);
  4508. _this.removeCssVars();
  4509. });
  4510. }
  4511. this.deregisterRootHandlers();
  4512. this.deregisterDeactivationHandlers();
  4513. };
  4514. /**
  4515. * @param evt Optional event containing position information.
  4516. */
  4517. MDCRippleFoundation.prototype.activate = function (evt) {
  4518. this.activateImpl(evt);
  4519. };
  4520. MDCRippleFoundation.prototype.deactivate = function () {
  4521. this.deactivateImpl();
  4522. };
  4523. MDCRippleFoundation.prototype.layout = function () {
  4524. var _this = this;
  4525. if (this.layoutFrame) {
  4526. cancelAnimationFrame(this.layoutFrame);
  4527. }
  4528. this.layoutFrame = requestAnimationFrame(function () {
  4529. _this.layoutInternal();
  4530. _this.layoutFrame = 0;
  4531. });
  4532. };
  4533. MDCRippleFoundation.prototype.setUnbounded = function (unbounded) {
  4534. var UNBOUNDED = MDCRippleFoundation.cssClasses.UNBOUNDED;
  4535. if (unbounded) {
  4536. this.adapter.addClass(UNBOUNDED);
  4537. } else {
  4538. this.adapter.removeClass(UNBOUNDED);
  4539. }
  4540. };
  4541. MDCRippleFoundation.prototype.handleFocus = function () {
  4542. var _this = this;
  4543. requestAnimationFrame(function () {
  4544. _this.adapter.addClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
  4545. });
  4546. };
  4547. MDCRippleFoundation.prototype.handleBlur = function () {
  4548. var _this = this;
  4549. requestAnimationFrame(function () {
  4550. _this.adapter.removeClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
  4551. });
  4552. };
  4553. /**
  4554. * We compute this property so that we are not querying information about the
  4555. * client until the point in time where the foundation requests it. This
  4556. * prevents scenarios where client-side feature-detection may happen too
  4557. * early, such as when components are rendered on the server and then
  4558. * initialized at mount time on the client.
  4559. */
  4560. MDCRippleFoundation.prototype.supportsPressRipple = function () {
  4561. return this.adapter.browserSupportsCssVars();
  4562. };
  4563. MDCRippleFoundation.prototype.defaultActivationState = function () {
  4564. return {
  4565. activationEvent: undefined,
  4566. hasDeactivationUXRun: false,
  4567. isActivated: false,
  4568. isProgrammatic: false,
  4569. wasActivatedByPointer: false,
  4570. wasElementMadeActive: false
  4571. };
  4572. };
  4573. /**
  4574. * supportsPressRipple Passed from init to save a redundant function call
  4575. */
  4576. MDCRippleFoundation.prototype.registerRootHandlers = function (supportsPressRipple) {
  4577. var e_1, _a;
  4578. if (supportsPressRipple) {
  4579. try {
  4580. for (var ACTIVATION_EVENT_TYPES_1 = __values(ACTIVATION_EVENT_TYPES), ACTIVATION_EVENT_TYPES_1_1 = ACTIVATION_EVENT_TYPES_1.next(); !ACTIVATION_EVENT_TYPES_1_1.done; ACTIVATION_EVENT_TYPES_1_1 = ACTIVATION_EVENT_TYPES_1.next()) {
  4581. var evtType = ACTIVATION_EVENT_TYPES_1_1.value;
  4582. this.adapter.registerInteractionHandler(evtType, this.activateHandler);
  4583. }
  4584. } catch (e_1_1) {
  4585. e_1 = { error: e_1_1 };
  4586. } finally {
  4587. try {
  4588. if (ACTIVATION_EVENT_TYPES_1_1 && !ACTIVATION_EVENT_TYPES_1_1.done && (_a = ACTIVATION_EVENT_TYPES_1.return)) _a.call(ACTIVATION_EVENT_TYPES_1);
  4589. } finally {
  4590. if (e_1) throw e_1.error;
  4591. }
  4592. }
  4593. if (this.adapter.isUnbounded()) {
  4594. this.adapter.registerResizeHandler(this.resizeHandler);
  4595. }
  4596. }
  4597. this.adapter.registerInteractionHandler('focus', this.focusHandler);
  4598. this.adapter.registerInteractionHandler('blur', this.blurHandler);
  4599. };
  4600. MDCRippleFoundation.prototype.registerDeactivationHandlers = function (evt) {
  4601. var e_2, _a;
  4602. if (evt.type === 'keydown') {
  4603. this.adapter.registerInteractionHandler('keyup', this.deactivateHandler);
  4604. } else {
  4605. try {
  4606. for (var POINTER_DEACTIVATION_EVENT_TYPES_1 = __values(POINTER_DEACTIVATION_EVENT_TYPES), POINTER_DEACTIVATION_EVENT_TYPES_1_1 = POINTER_DEACTIVATION_EVENT_TYPES_1.next(); !POINTER_DEACTIVATION_EVENT_TYPES_1_1.done; POINTER_DEACTIVATION_EVENT_TYPES_1_1 = POINTER_DEACTIVATION_EVENT_TYPES_1.next()) {
  4607. var evtType = POINTER_DEACTIVATION_EVENT_TYPES_1_1.value;
  4608. this.adapter.registerDocumentInteractionHandler(evtType, this.deactivateHandler);
  4609. }
  4610. } catch (e_2_1) {
  4611. e_2 = { error: e_2_1 };
  4612. } finally {
  4613. try {
  4614. if (POINTER_DEACTIVATION_EVENT_TYPES_1_1 && !POINTER_DEACTIVATION_EVENT_TYPES_1_1.done && (_a = POINTER_DEACTIVATION_EVENT_TYPES_1.return)) _a.call(POINTER_DEACTIVATION_EVENT_TYPES_1);
  4615. } finally {
  4616. if (e_2) throw e_2.error;
  4617. }
  4618. }
  4619. }
  4620. };
  4621. MDCRippleFoundation.prototype.deregisterRootHandlers = function () {
  4622. var e_3, _a;
  4623. try {
  4624. for (var ACTIVATION_EVENT_TYPES_2 = __values(ACTIVATION_EVENT_TYPES), ACTIVATION_EVENT_TYPES_2_1 = ACTIVATION_EVENT_TYPES_2.next(); !ACTIVATION_EVENT_TYPES_2_1.done; ACTIVATION_EVENT_TYPES_2_1 = ACTIVATION_EVENT_TYPES_2.next()) {
  4625. var evtType = ACTIVATION_EVENT_TYPES_2_1.value;
  4626. this.adapter.deregisterInteractionHandler(evtType, this.activateHandler);
  4627. }
  4628. } catch (e_3_1) {
  4629. e_3 = { error: e_3_1 };
  4630. } finally {
  4631. try {
  4632. if (ACTIVATION_EVENT_TYPES_2_1 && !ACTIVATION_EVENT_TYPES_2_1.done && (_a = ACTIVATION_EVENT_TYPES_2.return)) _a.call(ACTIVATION_EVENT_TYPES_2);
  4633. } finally {
  4634. if (e_3) throw e_3.error;
  4635. }
  4636. }
  4637. this.adapter.deregisterInteractionHandler('focus', this.focusHandler);
  4638. this.adapter.deregisterInteractionHandler('blur', this.blurHandler);
  4639. if (this.adapter.isUnbounded()) {
  4640. this.adapter.deregisterResizeHandler(this.resizeHandler);
  4641. }
  4642. };
  4643. MDCRippleFoundation.prototype.deregisterDeactivationHandlers = function () {
  4644. var e_4, _a;
  4645. this.adapter.deregisterInteractionHandler('keyup', this.deactivateHandler);
  4646. try {
  4647. for (var POINTER_DEACTIVATION_EVENT_TYPES_2 = __values(POINTER_DEACTIVATION_EVENT_TYPES), POINTER_DEACTIVATION_EVENT_TYPES_2_1 = POINTER_DEACTIVATION_EVENT_TYPES_2.next(); !POINTER_DEACTIVATION_EVENT_TYPES_2_1.done; POINTER_DEACTIVATION_EVENT_TYPES_2_1 = POINTER_DEACTIVATION_EVENT_TYPES_2.next()) {
  4648. var evtType = POINTER_DEACTIVATION_EVENT_TYPES_2_1.value;
  4649. this.adapter.deregisterDocumentInteractionHandler(evtType, this.deactivateHandler);
  4650. }
  4651. } catch (e_4_1) {
  4652. e_4 = { error: e_4_1 };
  4653. } finally {
  4654. try {
  4655. if (POINTER_DEACTIVATION_EVENT_TYPES_2_1 && !POINTER_DEACTIVATION_EVENT_TYPES_2_1.done && (_a = POINTER_DEACTIVATION_EVENT_TYPES_2.return)) _a.call(POINTER_DEACTIVATION_EVENT_TYPES_2);
  4656. } finally {
  4657. if (e_4) throw e_4.error;
  4658. }
  4659. }
  4660. };
  4661. MDCRippleFoundation.prototype.removeCssVars = function () {
  4662. var _this = this;
  4663. var rippleStrings = MDCRippleFoundation.strings;
  4664. var keys = Object.keys(rippleStrings);
  4665. keys.forEach(function (key) {
  4666. if (key.indexOf('VAR_') === 0) {
  4667. _this.adapter.updateCssVariable(rippleStrings[key], null);
  4668. }
  4669. });
  4670. };
  4671. MDCRippleFoundation.prototype.activateImpl = function (evt) {
  4672. var _this = this;
  4673. if (this.adapter.isSurfaceDisabled()) {
  4674. return;
  4675. }
  4676. var activationState = this.activationState;
  4677. if (activationState.isActivated) {
  4678. return;
  4679. }
  4680. // Avoid reacting to follow-on events fired by touch device after an
  4681. // already-processed user interaction
  4682. var previousActivationEvent = this.previousActivationEvent;
  4683. var isSameInteraction = previousActivationEvent && evt !== undefined && previousActivationEvent.type !== evt.type;
  4684. if (isSameInteraction) {
  4685. return;
  4686. }
  4687. activationState.isActivated = true;
  4688. activationState.isProgrammatic = evt === undefined;
  4689. activationState.activationEvent = evt;
  4690. activationState.wasActivatedByPointer = activationState.isProgrammatic ? false : evt !== undefined && (evt.type === 'mousedown' || evt.type === 'touchstart' || evt.type === 'pointerdown');
  4691. var hasActivatedChild = evt !== undefined && activatedTargets.length > 0 && activatedTargets.some(function (target) {
  4692. return _this.adapter.containsEventTarget(target);
  4693. });
  4694. if (hasActivatedChild) {
  4695. // Immediately reset activation state, while preserving logic that
  4696. // prevents touch follow-on events
  4697. this.resetActivationState();
  4698. return;
  4699. }
  4700. if (evt !== undefined) {
  4701. activatedTargets.push(evt.target);
  4702. this.registerDeactivationHandlers(evt);
  4703. }
  4704. activationState.wasElementMadeActive = this.checkElementMadeActive(evt);
  4705. if (activationState.wasElementMadeActive) {
  4706. this.animateActivation();
  4707. }
  4708. requestAnimationFrame(function () {
  4709. // Reset array on next frame after the current event has had a chance to
  4710. // bubble to prevent ancestor ripples
  4711. activatedTargets = [];
  4712. if (!activationState.wasElementMadeActive && evt !== undefined && (evt.key === ' ' || evt.keyCode === 32)) {
  4713. // If space was pressed, try again within an rAF call to detect :active,
  4714. // because different UAs report active states inconsistently when
  4715. // they're called within event handling code:
  4716. // - https://bugs.chromium.org/p/chromium/issues/detail?id=635971
  4717. // - https://bugzilla.mozilla.org/show_bug.cgi?id=1293741
  4718. // We try first outside rAF to support Edge, which does not exhibit this
  4719. // problem, but will crash if a CSS variable is set within a rAF
  4720. // callback for a submit button interaction (#2241).
  4721. activationState.wasElementMadeActive = _this.checkElementMadeActive(evt);
  4722. if (activationState.wasElementMadeActive) {
  4723. _this.animateActivation();
  4724. }
  4725. }
  4726. if (!activationState.wasElementMadeActive) {
  4727. // Reset activation state immediately if element was not made active.
  4728. _this.activationState = _this.defaultActivationState();
  4729. }
  4730. });
  4731. };
  4732. MDCRippleFoundation.prototype.checkElementMadeActive = function (evt) {
  4733. return evt !== undefined && evt.type === 'keydown' ? this.adapter.isSurfaceActive() : true;
  4734. };
  4735. MDCRippleFoundation.prototype.animateActivation = function () {
  4736. var _this = this;
  4737. var _a = MDCRippleFoundation.strings,
  4738. VAR_FG_TRANSLATE_START = _a.VAR_FG_TRANSLATE_START,
  4739. VAR_FG_TRANSLATE_END = _a.VAR_FG_TRANSLATE_END;
  4740. var _b = MDCRippleFoundation.cssClasses,
  4741. FG_DEACTIVATION = _b.FG_DEACTIVATION,
  4742. FG_ACTIVATION = _b.FG_ACTIVATION;
  4743. var DEACTIVATION_TIMEOUT_MS = MDCRippleFoundation.numbers.DEACTIVATION_TIMEOUT_MS;
  4744. this.layoutInternal();
  4745. var translateStart = '';
  4746. var translateEnd = '';
  4747. if (!this.adapter.isUnbounded()) {
  4748. var _c = this.getFgTranslationCoordinates(),
  4749. startPoint = _c.startPoint,
  4750. endPoint = _c.endPoint;
  4751. translateStart = startPoint.x + "px, " + startPoint.y + "px";
  4752. translateEnd = endPoint.x + "px, " + endPoint.y + "px";
  4753. }
  4754. this.adapter.updateCssVariable(VAR_FG_TRANSLATE_START, translateStart);
  4755. this.adapter.updateCssVariable(VAR_FG_TRANSLATE_END, translateEnd);
  4756. // Cancel any ongoing activation/deactivation animations
  4757. clearTimeout(this.activationTimer);
  4758. clearTimeout(this.fgDeactivationRemovalTimer);
  4759. this.rmBoundedActivationClasses();
  4760. this.adapter.removeClass(FG_DEACTIVATION);
  4761. // Force layout in order to re-trigger the animation.
  4762. this.adapter.computeBoundingRect();
  4763. this.adapter.addClass(FG_ACTIVATION);
  4764. this.activationTimer = setTimeout(function () {
  4765. _this.activationTimerCallback();
  4766. }, DEACTIVATION_TIMEOUT_MS);
  4767. };
  4768. MDCRippleFoundation.prototype.getFgTranslationCoordinates = function () {
  4769. var _a = this.activationState,
  4770. activationEvent = _a.activationEvent,
  4771. wasActivatedByPointer = _a.wasActivatedByPointer;
  4772. var startPoint;
  4773. if (wasActivatedByPointer) {
  4774. startPoint = util_1.getNormalizedEventCoords(activationEvent, this.adapter.getWindowPageOffset(), this.adapter.computeBoundingRect());
  4775. } else {
  4776. startPoint = {
  4777. x: this.frame.width / 2,
  4778. y: this.frame.height / 2
  4779. };
  4780. }
  4781. // Center the element around the start point.
  4782. startPoint = {
  4783. x: startPoint.x - this.initialSize / 2,
  4784. y: startPoint.y - this.initialSize / 2
  4785. };
  4786. var endPoint = {
  4787. x: this.frame.width / 2 - this.initialSize / 2,
  4788. y: this.frame.height / 2 - this.initialSize / 2
  4789. };
  4790. return { startPoint: startPoint, endPoint: endPoint };
  4791. };
  4792. MDCRippleFoundation.prototype.runDeactivationUXLogicIfReady = function () {
  4793. var _this = this;
  4794. // This method is called both when a pointing device is released, and when
  4795. // the activation animation ends. The deactivation animation should only run
  4796. // after both of those occur.
  4797. var FG_DEACTIVATION = MDCRippleFoundation.cssClasses.FG_DEACTIVATION;
  4798. var _a = this.activationState,
  4799. hasDeactivationUXRun = _a.hasDeactivationUXRun,
  4800. isActivated = _a.isActivated;
  4801. var activationHasEnded = hasDeactivationUXRun || !isActivated;
  4802. if (activationHasEnded && this.activationAnimationHasEnded) {
  4803. this.rmBoundedActivationClasses();
  4804. this.adapter.addClass(FG_DEACTIVATION);
  4805. this.fgDeactivationRemovalTimer = setTimeout(function () {
  4806. _this.adapter.removeClass(FG_DEACTIVATION);
  4807. }, constants_1.numbers.FG_DEACTIVATION_MS);
  4808. }
  4809. };
  4810. MDCRippleFoundation.prototype.rmBoundedActivationClasses = function () {
  4811. var FG_ACTIVATION = MDCRippleFoundation.cssClasses.FG_ACTIVATION;
  4812. this.adapter.removeClass(FG_ACTIVATION);
  4813. this.activationAnimationHasEnded = false;
  4814. this.adapter.computeBoundingRect();
  4815. };
  4816. MDCRippleFoundation.prototype.resetActivationState = function () {
  4817. var _this = this;
  4818. this.previousActivationEvent = this.activationState.activationEvent;
  4819. this.activationState = this.defaultActivationState();
  4820. // Touch devices may fire additional events for the same interaction within
  4821. // a short time. Store the previous event until it's safe to assume that
  4822. // subsequent events are for new interactions.
  4823. setTimeout(function () {
  4824. return _this.previousActivationEvent = undefined;
  4825. }, MDCRippleFoundation.numbers.TAP_DELAY_MS);
  4826. };
  4827. MDCRippleFoundation.prototype.deactivateImpl = function () {
  4828. var _this = this;
  4829. var activationState = this.activationState;
  4830. // This can happen in scenarios such as when you have a keyup event that
  4831. // blurs the element.
  4832. if (!activationState.isActivated) {
  4833. return;
  4834. }
  4835. var state = __assign({}, activationState);
  4836. if (activationState.isProgrammatic) {
  4837. requestAnimationFrame(function () {
  4838. _this.animateDeactivation(state);
  4839. });
  4840. this.resetActivationState();
  4841. } else {
  4842. this.deregisterDeactivationHandlers();
  4843. requestAnimationFrame(function () {
  4844. _this.activationState.hasDeactivationUXRun = true;
  4845. _this.animateDeactivation(state);
  4846. _this.resetActivationState();
  4847. });
  4848. }
  4849. };
  4850. MDCRippleFoundation.prototype.animateDeactivation = function (_a) {
  4851. var wasActivatedByPointer = _a.wasActivatedByPointer,
  4852. wasElementMadeActive = _a.wasElementMadeActive;
  4853. if (wasActivatedByPointer || wasElementMadeActive) {
  4854. this.runDeactivationUXLogicIfReady();
  4855. }
  4856. };
  4857. MDCRippleFoundation.prototype.layoutInternal = function () {
  4858. var _this = this;
  4859. this.frame = this.adapter.computeBoundingRect();
  4860. var maxDim = Math.max(this.frame.height, this.frame.width);
  4861. // Surface diameter is treated differently for unbounded vs. bounded
  4862. // ripples. Unbounded ripple diameter is calculated smaller since the
  4863. // surface is expected to already be padded appropriately to extend the
  4864. // hitbox, and the ripple is expected to meet the edges of the padded hitbox
  4865. // (which is typically square). Bounded ripples, on the other hand, are
  4866. // fully expected to expand beyond the surface's longest diameter
  4867. // (calculated based on the diagonal plus a constant padding), and are
  4868. // clipped at the surface's border via `overflow: hidden`.
  4869. var getBoundedRadius = function getBoundedRadius() {
  4870. var hypotenuse = Math.sqrt(Math.pow(_this.frame.width, 2) + Math.pow(_this.frame.height, 2));
  4871. return hypotenuse + MDCRippleFoundation.numbers.PADDING;
  4872. };
  4873. this.maxRadius = this.adapter.isUnbounded() ? maxDim : getBoundedRadius();
  4874. // Ripple is sized as a fraction of the largest dimension of the surface,
  4875. // then scales up using a CSS scale transform
  4876. var initialSize = Math.floor(maxDim * MDCRippleFoundation.numbers.INITIAL_ORIGIN_SCALE);
  4877. // Unbounded ripple size should always be even number to equally center
  4878. // align.
  4879. if (this.adapter.isUnbounded() && initialSize % 2 !== 0) {
  4880. this.initialSize = initialSize - 1;
  4881. } else {
  4882. this.initialSize = initialSize;
  4883. }
  4884. this.fgScale = "" + this.maxRadius / this.initialSize;
  4885. this.updateLayoutCssVars();
  4886. };
  4887. MDCRippleFoundation.prototype.updateLayoutCssVars = function () {
  4888. var _a = MDCRippleFoundation.strings,
  4889. VAR_FG_SIZE = _a.VAR_FG_SIZE,
  4890. VAR_LEFT = _a.VAR_LEFT,
  4891. VAR_TOP = _a.VAR_TOP,
  4892. VAR_FG_SCALE = _a.VAR_FG_SCALE;
  4893. this.adapter.updateCssVariable(VAR_FG_SIZE, this.initialSize + "px");
  4894. this.adapter.updateCssVariable(VAR_FG_SCALE, this.fgScale);
  4895. if (this.adapter.isUnbounded()) {
  4896. this.unboundedCoords = {
  4897. left: Math.round(this.frame.width / 2 - this.initialSize / 2),
  4898. top: Math.round(this.frame.height / 2 - this.initialSize / 2)
  4899. };
  4900. this.adapter.updateCssVariable(VAR_LEFT, this.unboundedCoords.left + "px");
  4901. this.adapter.updateCssVariable(VAR_TOP, this.unboundedCoords.top + "px");
  4902. }
  4903. };
  4904. return MDCRippleFoundation;
  4905. }(foundation_1.MDCFoundation);
  4906. exports.MDCRippleFoundation = MDCRippleFoundation;
  4907. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  4908. exports.default = MDCRippleFoundation;
  4909. /***/ }),
  4910. /***/ "./packages/mdc-ripple/util.ts":
  4911. /*!*************************************!*\
  4912. !*** ./packages/mdc-ripple/util.ts ***!
  4913. \*************************************/
  4914. /*! no static exports found */
  4915. /***/ (function(module, exports, __webpack_require__) {
  4916. "use strict";
  4917. Object.defineProperty(exports, "__esModule", { value: true });
  4918. exports.getNormalizedEventCoords = exports.supportsCssVariables = void 0;
  4919. /**
  4920. * Stores result from supportsCssVariables to avoid redundant processing to
  4921. * detect CSS custom variable support.
  4922. */
  4923. var supportsCssVariables_;
  4924. function supportsCssVariables(windowObj, forceRefresh) {
  4925. if (forceRefresh === void 0) {
  4926. forceRefresh = false;
  4927. }
  4928. var CSS = windowObj.CSS;
  4929. var supportsCssVars = supportsCssVariables_;
  4930. if (typeof supportsCssVariables_ === 'boolean' && !forceRefresh) {
  4931. return supportsCssVariables_;
  4932. }
  4933. var supportsFunctionPresent = CSS && typeof CSS.supports === 'function';
  4934. if (!supportsFunctionPresent) {
  4935. return false;
  4936. }
  4937. var explicitlySupportsCssVars = CSS.supports('--css-vars', 'yes');
  4938. // See: https://bugs.webkit.org/show_bug.cgi?id=154669
  4939. // See: README section on Safari
  4940. var weAreFeatureDetectingSafari10plus = CSS.supports('(--css-vars: yes)') && CSS.supports('color', '#00000000');
  4941. supportsCssVars = explicitlySupportsCssVars || weAreFeatureDetectingSafari10plus;
  4942. if (!forceRefresh) {
  4943. supportsCssVariables_ = supportsCssVars;
  4944. }
  4945. return supportsCssVars;
  4946. }
  4947. exports.supportsCssVariables = supportsCssVariables;
  4948. function getNormalizedEventCoords(evt, pageOffset, clientRect) {
  4949. if (!evt) {
  4950. return { x: 0, y: 0 };
  4951. }
  4952. var x = pageOffset.x,
  4953. y = pageOffset.y;
  4954. var documentX = x + clientRect.left;
  4955. var documentY = y + clientRect.top;
  4956. var normalizedX;
  4957. var normalizedY;
  4958. // Determine touch point relative to the ripple container.
  4959. if (evt.type === 'touchstart') {
  4960. var touchEvent = evt;
  4961. normalizedX = touchEvent.changedTouches[0].pageX - documentX;
  4962. normalizedY = touchEvent.changedTouches[0].pageY - documentY;
  4963. } else {
  4964. var mouseEvent = evt;
  4965. normalizedX = mouseEvent.pageX - documentX;
  4966. normalizedY = mouseEvent.pageY - documentY;
  4967. }
  4968. return { x: normalizedX, y: normalizedY };
  4969. }
  4970. exports.getNormalizedEventCoords = getNormalizedEventCoords;
  4971. /***/ }),
  4972. /***/ "./packages/mdc-slider/adapter.ts":
  4973. /*!****************************************!*\
  4974. !*** ./packages/mdc-slider/adapter.ts ***!
  4975. \****************************************/
  4976. /*! no static exports found */
  4977. /***/ (function(module, exports, __webpack_require__) {
  4978. "use strict";
  4979. /**
  4980. * @license
  4981. * Copyright 2020 Google Inc.
  4982. *
  4983. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4984. * of this software and associated documentation files (the "Software"), to deal
  4985. * in the Software without restriction, including without limitation the rights
  4986. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4987. * copies of the Software, and to permit persons to whom the Software is
  4988. * furnished to do so, subject to the following conditions:
  4989. *
  4990. * The above copyright notice and this permission notice shall be included in
  4991. * all copies or substantial portions of the Software.
  4992. *
  4993. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4994. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4995. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4996. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4997. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4998. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4999. * THE SOFTWARE.
  5000. */
  5001. Object.defineProperty(exports, "__esModule", { value: true });
  5002. /***/ }),
  5003. /***/ "./packages/mdc-slider/component.ts":
  5004. /*!******************************************!*\
  5005. !*** ./packages/mdc-slider/component.ts ***!
  5006. \******************************************/
  5007. /*! no static exports found */
  5008. /***/ (function(module, exports, __webpack_require__) {
  5009. "use strict";
  5010. /**
  5011. * @license
  5012. * Copyright 2020 Google Inc.
  5013. *
  5014. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5015. * of this software and associated documentation files (the "Software"), to deal
  5016. * in the Software without restriction, including without limitation the rights
  5017. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  5018. * copies of the Software, and to permit persons to whom the Software is
  5019. * furnished to do so, subject to the following conditions:
  5020. *
  5021. * The above copyright notice and this permission notice shall be included in
  5022. * all copies or substantial portions of the Software.
  5023. *
  5024. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  5025. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  5026. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  5027. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  5028. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  5029. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  5030. * THE SOFTWARE.
  5031. */
  5032. var __extends = this && this.__extends || function () {
  5033. var _extendStatics = function extendStatics(d, b) {
  5034. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  5035. d.__proto__ = b;
  5036. } || function (d, b) {
  5037. for (var p in b) {
  5038. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  5039. }
  5040. };
  5041. return _extendStatics(d, b);
  5042. };
  5043. return function (d, b) {
  5044. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  5045. _extendStatics(d, b);
  5046. function __() {
  5047. this.constructor = d;
  5048. }
  5049. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5050. };
  5051. }();
  5052. var __assign = this && this.__assign || function () {
  5053. __assign = Object.assign || function (t) {
  5054. for (var s, i = 1, n = arguments.length; i < n; i++) {
  5055. s = arguments[i];
  5056. for (var p in s) {
  5057. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  5058. }
  5059. }
  5060. return t;
  5061. };
  5062. return __assign.apply(this, arguments);
  5063. };
  5064. Object.defineProperty(exports, "__esModule", { value: true });
  5065. exports.MDCSlider = void 0;
  5066. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  5067. var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
  5068. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  5069. var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
  5070. var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
  5071. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-slider/constants.ts");
  5072. var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-slider/foundation.ts");
  5073. var types_1 = __webpack_require__(/*! ./types */ "./packages/mdc-slider/types.ts");
  5074. /** Vanilla implementation of slider component. */
  5075. var MDCSlider = /** @class */function (_super) {
  5076. __extends(MDCSlider, _super);
  5077. function MDCSlider() {
  5078. var _this = _super !== null && _super.apply(this, arguments) || this;
  5079. _this.skipInitialUIUpdate = false;
  5080. // Function that maps a slider value to the value of the `aria-valuetext`
  5081. // attribute on the thumb element.
  5082. _this.valueToAriaValueTextFn = null;
  5083. return _this;
  5084. }
  5085. MDCSlider.attachTo = function (root, options) {
  5086. if (options === void 0) {
  5087. options = {};
  5088. }
  5089. return new MDCSlider(root, undefined, options);
  5090. };
  5091. MDCSlider.prototype.getDefaultFoundation = function () {
  5092. var _this = this;
  5093. // tslint:disable:object-literal-sort-keys Methods should be in the same
  5094. // order as the adapter interface.
  5095. var adapter = {
  5096. hasClass: function hasClass(className) {
  5097. return _this.root.classList.contains(className);
  5098. },
  5099. addClass: function addClass(className) {
  5100. _this.root.classList.add(className);
  5101. },
  5102. removeClass: function removeClass(className) {
  5103. _this.root.classList.remove(className);
  5104. },
  5105. addThumbClass: function addThumbClass(className, thumb) {
  5106. _this.getThumbEl(thumb).classList.add(className);
  5107. },
  5108. removeThumbClass: function removeThumbClass(className, thumb) {
  5109. _this.getThumbEl(thumb).classList.remove(className);
  5110. },
  5111. getAttribute: function getAttribute(attribute) {
  5112. return _this.root.getAttribute(attribute);
  5113. },
  5114. getInputValue: function getInputValue(thumb) {
  5115. return _this.getInput(thumb).value;
  5116. },
  5117. setInputValue: function setInputValue(value, thumb) {
  5118. _this.getInput(thumb).value = value;
  5119. },
  5120. getInputAttribute: function getInputAttribute(attribute, thumb) {
  5121. return _this.getInput(thumb).getAttribute(attribute);
  5122. },
  5123. setInputAttribute: function setInputAttribute(attribute, value, thumb) {
  5124. _this.getInput(thumb).setAttribute(attribute, value);
  5125. },
  5126. removeInputAttribute: function removeInputAttribute(attribute, thumb) {
  5127. _this.getInput(thumb).removeAttribute(attribute);
  5128. },
  5129. focusInput: function focusInput(thumb) {
  5130. _this.getInput(thumb).focus();
  5131. },
  5132. isInputFocused: function isInputFocused(thumb) {
  5133. return _this.getInput(thumb) === document.activeElement;
  5134. },
  5135. shouldHideFocusStylesForPointerEvents: function shouldHideFocusStylesForPointerEvents() {
  5136. return false;
  5137. },
  5138. getThumbKnobWidth: function getThumbKnobWidth(thumb) {
  5139. return _this.getThumbEl(thumb).querySelector("." + constants_1.cssClasses.THUMB_KNOB).getBoundingClientRect().width;
  5140. },
  5141. getThumbBoundingClientRect: function getThumbBoundingClientRect(thumb) {
  5142. return _this.getThumbEl(thumb).getBoundingClientRect();
  5143. },
  5144. getBoundingClientRect: function getBoundingClientRect() {
  5145. return _this.root.getBoundingClientRect();
  5146. },
  5147. getValueIndicatorContainerWidth: function getValueIndicatorContainerWidth(thumb) {
  5148. return _this.getThumbEl(thumb).querySelector("." + constants_1.cssClasses.VALUE_INDICATOR_CONTAINER).getBoundingClientRect().width;
  5149. },
  5150. isRTL: function isRTL() {
  5151. return getComputedStyle(_this.root).direction === 'rtl';
  5152. },
  5153. setThumbStyleProperty: function setThumbStyleProperty(propertyName, value, thumb) {
  5154. _this.getThumbEl(thumb).style.setProperty(propertyName, value);
  5155. },
  5156. removeThumbStyleProperty: function removeThumbStyleProperty(propertyName, thumb) {
  5157. _this.getThumbEl(thumb).style.removeProperty(propertyName);
  5158. },
  5159. setTrackActiveStyleProperty: function setTrackActiveStyleProperty(propertyName, value) {
  5160. _this.trackActive.style.setProperty(propertyName, value);
  5161. },
  5162. removeTrackActiveStyleProperty: function removeTrackActiveStyleProperty(propertyName) {
  5163. _this.trackActive.style.removeProperty(propertyName);
  5164. },
  5165. setValueIndicatorText: function setValueIndicatorText(value, thumb) {
  5166. var valueIndicatorEl = _this.getThumbEl(thumb).querySelector("." + constants_1.cssClasses.VALUE_INDICATOR_TEXT);
  5167. valueIndicatorEl.textContent = String(value);
  5168. },
  5169. getValueToAriaValueTextFn: function getValueToAriaValueTextFn() {
  5170. return _this.valueToAriaValueTextFn;
  5171. },
  5172. updateTickMarks: function updateTickMarks(tickMarks) {
  5173. var tickMarksContainer = _this.root.querySelector("." + constants_1.cssClasses.TICK_MARKS_CONTAINER);
  5174. if (!tickMarksContainer) {
  5175. tickMarksContainer = document.createElement('div');
  5176. tickMarksContainer.classList.add(constants_1.cssClasses.TICK_MARKS_CONTAINER);
  5177. var track = _this.root.querySelector("." + constants_1.cssClasses.TRACK);
  5178. track.appendChild(tickMarksContainer);
  5179. }
  5180. if (tickMarks.length !== tickMarksContainer.children.length) {
  5181. while (tickMarksContainer.firstChild) {
  5182. tickMarksContainer.removeChild(tickMarksContainer.firstChild);
  5183. }
  5184. _this.addTickMarks(tickMarksContainer, tickMarks);
  5185. } else {
  5186. _this.updateTickMarks(tickMarksContainer, tickMarks);
  5187. }
  5188. },
  5189. setPointerCapture: function setPointerCapture(pointerId) {
  5190. _this.root.setPointerCapture(pointerId);
  5191. },
  5192. emitChangeEvent: function emitChangeEvent(value, thumb) {
  5193. _this.emit(constants_1.events.CHANGE, { value: value, thumb: thumb });
  5194. },
  5195. emitInputEvent: function emitInputEvent(value, thumb) {
  5196. _this.emit(constants_1.events.INPUT, { value: value, thumb: thumb });
  5197. },
  5198. // tslint:disable-next-line:enforce-name-casing
  5199. emitDragStartEvent: function emitDragStartEvent(_, thumb) {
  5200. // Emitting event is not yet implemented. See issue:
  5201. // https://github.com/material-components/material-components-web/issues/6448
  5202. _this.getRipple(thumb).activate();
  5203. },
  5204. // tslint:disable-next-line:enforce-name-casing
  5205. emitDragEndEvent: function emitDragEndEvent(_, thumb) {
  5206. // Emitting event is not yet implemented. See issue:
  5207. // https://github.com/material-components/material-components-web/issues/6448
  5208. _this.getRipple(thumb).deactivate();
  5209. },
  5210. registerEventHandler: function registerEventHandler(evtType, handler) {
  5211. _this.listen(evtType, handler);
  5212. },
  5213. deregisterEventHandler: function deregisterEventHandler(evtType, handler) {
  5214. _this.unlisten(evtType, handler);
  5215. },
  5216. registerThumbEventHandler: function registerThumbEventHandler(thumb, evtType, handler) {
  5217. _this.getThumbEl(thumb).addEventListener(evtType, handler);
  5218. },
  5219. deregisterThumbEventHandler: function deregisterThumbEventHandler(thumb, evtType, handler) {
  5220. _this.getThumbEl(thumb).removeEventListener(evtType, handler);
  5221. },
  5222. registerInputEventHandler: function registerInputEventHandler(thumb, evtType, handler) {
  5223. _this.getInput(thumb).addEventListener(evtType, handler);
  5224. },
  5225. deregisterInputEventHandler: function deregisterInputEventHandler(thumb, evtType, handler) {
  5226. _this.getInput(thumb).removeEventListener(evtType, handler);
  5227. },
  5228. registerBodyEventHandler: function registerBodyEventHandler(evtType, handler) {
  5229. document.body.addEventListener(evtType, handler);
  5230. },
  5231. deregisterBodyEventHandler: function deregisterBodyEventHandler(evtType, handler) {
  5232. document.body.removeEventListener(evtType, handler);
  5233. },
  5234. registerWindowEventHandler: function registerWindowEventHandler(evtType, handler) {
  5235. window.addEventListener(evtType, handler);
  5236. },
  5237. deregisterWindowEventHandler: function deregisterWindowEventHandler(evtType, handler) {
  5238. window.removeEventListener(evtType, handler);
  5239. }
  5240. };
  5241. return new foundation_2.MDCSliderFoundation(adapter);
  5242. };
  5243. /**
  5244. * Initializes component, with the following options:
  5245. * - `skipInitialUIUpdate`: Whether to skip updating the UI when initially
  5246. * syncing with the DOM. This should be enabled when the slider position
  5247. * is set before component initialization.
  5248. */
  5249. MDCSlider.prototype.initialize = function (_a) {
  5250. var _b = _a === void 0 ? {} : _a,
  5251. skipInitialUIUpdate = _b.skipInitialUIUpdate;
  5252. this.inputs = Array.from(this.root.querySelectorAll("." + constants_1.cssClasses.INPUT));
  5253. this.thumbs = Array.from(this.root.querySelectorAll("." + constants_1.cssClasses.THUMB));
  5254. this.trackActive = this.root.querySelector("." + constants_1.cssClasses.TRACK_ACTIVE);
  5255. this.ripples = this.createRipples();
  5256. if (skipInitialUIUpdate) {
  5257. this.skipInitialUIUpdate = true;
  5258. }
  5259. };
  5260. MDCSlider.prototype.initialSyncWithDOM = function () {
  5261. this.foundation.layout({ skipUpdateUI: this.skipInitialUIUpdate });
  5262. };
  5263. /** Redraws UI based on DOM (e.g. element dimensions, RTL). */
  5264. MDCSlider.prototype.layout = function () {
  5265. this.foundation.layout();
  5266. };
  5267. MDCSlider.prototype.getValueStart = function () {
  5268. return this.foundation.getValueStart();
  5269. };
  5270. MDCSlider.prototype.setValueStart = function (valueStart) {
  5271. this.foundation.setValueStart(valueStart);
  5272. };
  5273. MDCSlider.prototype.getValue = function () {
  5274. return this.foundation.getValue();
  5275. };
  5276. MDCSlider.prototype.setValue = function (value) {
  5277. this.foundation.setValue(value);
  5278. };
  5279. /** @return Slider disabled state. */
  5280. MDCSlider.prototype.getDisabled = function () {
  5281. return this.foundation.getDisabled();
  5282. };
  5283. /** Sets slider disabled state. */
  5284. MDCSlider.prototype.setDisabled = function (disabled) {
  5285. this.foundation.setDisabled(disabled);
  5286. };
  5287. /**
  5288. * Sets a function that maps the slider value to the value of the
  5289. * `aria-valuetext` attribute on the thumb element.
  5290. */
  5291. MDCSlider.prototype.setValueToAriaValueTextFn = function (mapFn) {
  5292. this.valueToAriaValueTextFn = mapFn;
  5293. };
  5294. MDCSlider.prototype.getThumbEl = function (thumb) {
  5295. return thumb === types_1.Thumb.END ? this.thumbs[this.thumbs.length - 1] : this.thumbs[0];
  5296. };
  5297. MDCSlider.prototype.getInput = function (thumb) {
  5298. return thumb === types_1.Thumb.END ? this.inputs[this.inputs.length - 1] : this.inputs[0];
  5299. };
  5300. MDCSlider.prototype.getRipple = function (thumb) {
  5301. return thumb === types_1.Thumb.END ? this.ripples[this.ripples.length - 1] : this.ripples[0];
  5302. };
  5303. /** Adds tick mark elements to the given container. */
  5304. MDCSlider.prototype.addTickMarks = function (tickMarkContainer, tickMarks) {
  5305. var fragment = document.createDocumentFragment();
  5306. for (var i = 0; i < tickMarks.length; i++) {
  5307. var div = document.createElement('div');
  5308. var tickMarkClass = tickMarks[i] === types_1.TickMark.ACTIVE ? constants_1.cssClasses.TICK_MARK_ACTIVE : constants_1.cssClasses.TICK_MARK_INACTIVE;
  5309. div.classList.add(tickMarkClass);
  5310. fragment.appendChild(div);
  5311. }
  5312. tickMarkContainer.appendChild(fragment);
  5313. };
  5314. /** Updates tick mark elements' classes in the given container. */
  5315. MDCSlider.prototype.updateTickMarks = function (tickMarkContainer, tickMarks) {
  5316. var tickMarkEls = Array.from(tickMarkContainer.children);
  5317. for (var i = 0; i < tickMarkEls.length; i++) {
  5318. if (tickMarks[i] === types_1.TickMark.ACTIVE) {
  5319. tickMarkEls[i].classList.add(constants_1.cssClasses.TICK_MARK_ACTIVE);
  5320. tickMarkEls[i].classList.remove(constants_1.cssClasses.TICK_MARK_INACTIVE);
  5321. } else {
  5322. tickMarkEls[i].classList.add(constants_1.cssClasses.TICK_MARK_INACTIVE);
  5323. tickMarkEls[i].classList.remove(constants_1.cssClasses.TICK_MARK_ACTIVE);
  5324. }
  5325. }
  5326. };
  5327. /** Initializes thumb ripples. */
  5328. MDCSlider.prototype.createRipples = function () {
  5329. var ripples = [];
  5330. var rippleSurfaces = Array.from(this.root.querySelectorAll("." + constants_1.cssClasses.THUMB));
  5331. var _loop_1 = function _loop_1(i) {
  5332. var rippleSurface = rippleSurfaces[i];
  5333. // Use the corresponding input as the focus source for the ripple (i.e.
  5334. // when the input is focused, the ripple is in the focused state).
  5335. var input = this_1.inputs[i];
  5336. var adapter = __assign(__assign({}, component_2.MDCRipple.createAdapter(this_1)), { addClass: function addClass(className) {
  5337. rippleSurface.classList.add(className);
  5338. }, computeBoundingRect: function computeBoundingRect() {
  5339. return rippleSurface.getBoundingClientRect();
  5340. }, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  5341. input.removeEventListener(evtType, handler);
  5342. }, isSurfaceActive: function isSurfaceActive() {
  5343. return ponyfill_1.matches(input, ':active');
  5344. }, isUnbounded: function isUnbounded() {
  5345. return true;
  5346. }, registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  5347. input.addEventListener(evtType, handler, events_1.applyPassive());
  5348. }, removeClass: function removeClass(className) {
  5349. rippleSurface.classList.remove(className);
  5350. }, updateCssVariable: function updateCssVariable(varName, value) {
  5351. rippleSurface.style.setProperty(varName, value);
  5352. } });
  5353. var ripple = new component_2.MDCRipple(rippleSurface, new foundation_1.MDCRippleFoundation(adapter));
  5354. ripple.unbounded = true;
  5355. ripples.push(ripple);
  5356. };
  5357. var this_1 = this;
  5358. for (var i = 0; i < rippleSurfaces.length; i++) {
  5359. _loop_1(i);
  5360. }
  5361. return ripples;
  5362. };
  5363. return MDCSlider;
  5364. }(component_1.MDCComponent);
  5365. exports.MDCSlider = MDCSlider;
  5366. /***/ }),
  5367. /***/ "./packages/mdc-slider/constants.ts":
  5368. /*!******************************************!*\
  5369. !*** ./packages/mdc-slider/constants.ts ***!
  5370. \******************************************/
  5371. /*! no static exports found */
  5372. /***/ (function(module, exports, __webpack_require__) {
  5373. "use strict";
  5374. /**
  5375. * @license
  5376. * Copyright 2020 Google Inc.
  5377. *
  5378. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5379. * of this software and associated documentation files (the "Software"), to deal
  5380. * in the Software without restriction, including without limitation the rights
  5381. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  5382. * copies of the Software, and to permit persons to whom the Software is
  5383. * furnished to do so, subject to the following conditions:
  5384. *
  5385. * The above copyright notice and this permission notice shall be included in
  5386. * all copies or substantial portions of the Software.
  5387. *
  5388. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  5389. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  5390. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  5391. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  5392. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  5393. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  5394. * THE SOFTWARE.
  5395. */
  5396. Object.defineProperty(exports, "__esModule", { value: true });
  5397. exports.strings = exports.events = exports.attributes = exports.numbers = exports.cssClasses = void 0;
  5398. /** Slider element classes. */
  5399. exports.cssClasses = {
  5400. DISABLED: 'mdc-slider--disabled',
  5401. DISCRETE: 'mdc-slider--discrete',
  5402. INPUT: 'mdc-slider__input',
  5403. RANGE: 'mdc-slider--range',
  5404. THUMB: 'mdc-slider__thumb',
  5405. // Applied when thumb is in the focused state.
  5406. THUMB_FOCUSED: 'mdc-slider__thumb--focused',
  5407. THUMB_KNOB: 'mdc-slider__thumb-knob',
  5408. // Class added to the top thumb (for overlapping thumbs in range slider).
  5409. THUMB_TOP: 'mdc-slider__thumb--top',
  5410. THUMB_WITH_INDICATOR: 'mdc-slider__thumb--with-indicator',
  5411. TICK_MARKS: 'mdc-slider--tick-marks',
  5412. TICK_MARKS_CONTAINER: 'mdc-slider__tick-marks',
  5413. TICK_MARK_ACTIVE: 'mdc-slider__tick-mark--active',
  5414. TICK_MARK_INACTIVE: 'mdc-slider__tick-mark--inactive',
  5415. TRACK: 'mdc-slider__track',
  5416. // The active track fill element that will be scaled as the value changes.
  5417. TRACK_ACTIVE: 'mdc-slider__track--active_fill',
  5418. VALUE_INDICATOR_CONTAINER: 'mdc-slider__value-indicator-container',
  5419. VALUE_INDICATOR_TEXT: 'mdc-slider__value-indicator-text'
  5420. };
  5421. /** Slider numbers. */
  5422. exports.numbers = {
  5423. // Default step size.
  5424. STEP_SIZE: 1,
  5425. // Default minimum difference between the start and end values.
  5426. MIN_RANGE: 0,
  5427. // Minimum absolute difference between clientX of move event / down event
  5428. // for which to update thumb, in the case of overlapping thumbs.
  5429. // This is needed to reduce chances of choosing the thumb based on
  5430. // pointer jitter.
  5431. THUMB_UPDATE_MIN_PX: 5
  5432. };
  5433. /** Slider attributes. */
  5434. exports.attributes = {
  5435. ARIA_VALUETEXT: 'aria-valuetext',
  5436. INPUT_DISABLED: 'disabled',
  5437. INPUT_MIN: 'min',
  5438. INPUT_MAX: 'max',
  5439. INPUT_VALUE: 'value',
  5440. INPUT_STEP: 'step',
  5441. DATA_MIN_RANGE: 'data-min-range'
  5442. };
  5443. /** Slider events. */
  5444. exports.events = {
  5445. CHANGE: 'MDCSlider:change',
  5446. INPUT: 'MDCSlider:input'
  5447. };
  5448. /** Slider strings. */
  5449. exports.strings = {
  5450. VAR_VALUE_INDICATOR_CARET_LEFT: '--slider-value-indicator-caret-left',
  5451. VAR_VALUE_INDICATOR_CARET_RIGHT: '--slider-value-indicator-caret-right',
  5452. VAR_VALUE_INDICATOR_CARET_TRANSFORM: '--slider-value-indicator-caret-transform',
  5453. VAR_VALUE_INDICATOR_CONTAINER_LEFT: '--slider-value-indicator-container-left',
  5454. VAR_VALUE_INDICATOR_CONTAINER_RIGHT: '--slider-value-indicator-container-right',
  5455. VAR_VALUE_INDICATOR_CONTAINER_TRANSFORM: '--slider-value-indicator-container-transform'
  5456. };
  5457. /***/ }),
  5458. /***/ "./packages/mdc-slider/foundation.ts":
  5459. /*!*******************************************!*\
  5460. !*** ./packages/mdc-slider/foundation.ts ***!
  5461. \*******************************************/
  5462. /*! no static exports found */
  5463. /***/ (function(module, exports, __webpack_require__) {
  5464. "use strict";
  5465. /**
  5466. * @license
  5467. * Copyright 2020 Google Inc.
  5468. *
  5469. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5470. * of this software and associated documentation files (the "Software"), to deal
  5471. * in the Software without restriction, including without limitation the rights
  5472. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  5473. * copies of the Software, and to permit persons to whom the Software is
  5474. * furnished to do so, subject to the following conditions:
  5475. *
  5476. * The above copyright notice and this permission notice shall be included in
  5477. * all copies or substantial portions of the Software.
  5478. *
  5479. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  5480. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  5481. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  5482. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  5483. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  5484. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  5485. * THE SOFTWARE.
  5486. */
  5487. var __extends = this && this.__extends || function () {
  5488. var _extendStatics = function extendStatics(d, b) {
  5489. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  5490. d.__proto__ = b;
  5491. } || function (d, b) {
  5492. for (var p in b) {
  5493. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  5494. }
  5495. };
  5496. return _extendStatics(d, b);
  5497. };
  5498. return function (d, b) {
  5499. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  5500. _extendStatics(d, b);
  5501. function __() {
  5502. this.constructor = d;
  5503. }
  5504. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5505. };
  5506. }();
  5507. var __assign = this && this.__assign || function () {
  5508. __assign = Object.assign || function (t) {
  5509. for (var s, i = 1, n = arguments.length; i < n; i++) {
  5510. s = arguments[i];
  5511. for (var p in s) {
  5512. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  5513. }
  5514. }
  5515. return t;
  5516. };
  5517. return __assign.apply(this, arguments);
  5518. };
  5519. Object.defineProperty(exports, "__esModule", { value: true });
  5520. exports.MDCSliderFoundation = void 0;
  5521. var animationframe_1 = __webpack_require__(/*! @material/animation/animationframe */ "./packages/mdc-animation/animationframe.ts");
  5522. var util_1 = __webpack_require__(/*! @material/animation/util */ "./packages/mdc-animation/util.ts");
  5523. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  5524. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-slider/constants.ts");
  5525. var types_1 = __webpack_require__(/*! ./types */ "./packages/mdc-slider/types.ts");
  5526. var AnimationKeys;
  5527. (function (AnimationKeys) {
  5528. AnimationKeys["SLIDER_UPDATE"] = "slider_update";
  5529. })(AnimationKeys || (AnimationKeys = {}));
  5530. // Accessing `window` without a `typeof` check will throw on Node environments.
  5531. var HAS_WINDOW = typeof window !== 'undefined';
  5532. /**
  5533. * Foundation class for slider. Responsibilities include:
  5534. * - Updating slider values (internal state and DOM updates) based on client
  5535. * 'x' position.
  5536. * - Updating DOM after slider property updates (e.g. min, max).
  5537. */
  5538. var MDCSliderFoundation = /** @class */function (_super) {
  5539. __extends(MDCSliderFoundation, _super);
  5540. function MDCSliderFoundation(adapter) {
  5541. var _this = _super.call(this, __assign(__assign({}, MDCSliderFoundation.defaultAdapter), adapter)) || this;
  5542. // Whether the initial styles (to position the thumb, before component
  5543. // initialization) have been removed.
  5544. _this.initialStylesRemoved = false;
  5545. _this.isDisabled = false;
  5546. _this.isDiscrete = false;
  5547. _this.step = constants_1.numbers.STEP_SIZE;
  5548. _this.minRange = constants_1.numbers.MIN_RANGE;
  5549. _this.hasTickMarks = false;
  5550. // The following properties are only set for range sliders.
  5551. _this.isRange = false;
  5552. // Tracks the thumb being moved across a slider pointer interaction (down,
  5553. // move event).
  5554. _this.thumb = null;
  5555. // `clientX` from the most recent down event. Used in subsequent move
  5556. // events to determine which thumb to move (in the case of
  5557. // overlapping thumbs).
  5558. _this.downEventClientX = null;
  5559. // Width of the start thumb knob.
  5560. _this.startThumbKnobWidth = 0;
  5561. // Width of the end thumb knob.
  5562. _this.endThumbKnobWidth = 0;
  5563. _this.animFrame = new animationframe_1.AnimationFrame();
  5564. return _this;
  5565. }
  5566. Object.defineProperty(MDCSliderFoundation, "defaultAdapter", {
  5567. get: function get() {
  5568. // tslint:disable:object-literal-sort-keys Methods should be in the same
  5569. // order as the adapter interface.
  5570. return {
  5571. hasClass: function hasClass() {
  5572. return false;
  5573. },
  5574. addClass: function addClass() {
  5575. return undefined;
  5576. },
  5577. removeClass: function removeClass() {
  5578. return undefined;
  5579. },
  5580. addThumbClass: function addThumbClass() {
  5581. return undefined;
  5582. },
  5583. removeThumbClass: function removeThumbClass() {
  5584. return undefined;
  5585. },
  5586. getAttribute: function getAttribute() {
  5587. return null;
  5588. },
  5589. getInputValue: function getInputValue() {
  5590. return '';
  5591. },
  5592. setInputValue: function setInputValue() {
  5593. return undefined;
  5594. },
  5595. getInputAttribute: function getInputAttribute() {
  5596. return null;
  5597. },
  5598. setInputAttribute: function setInputAttribute() {
  5599. return null;
  5600. },
  5601. removeInputAttribute: function removeInputAttribute() {
  5602. return null;
  5603. },
  5604. focusInput: function focusInput() {
  5605. return undefined;
  5606. },
  5607. isInputFocused: function isInputFocused() {
  5608. return false;
  5609. },
  5610. shouldHideFocusStylesForPointerEvents: function shouldHideFocusStylesForPointerEvents() {
  5611. return false;
  5612. },
  5613. getThumbKnobWidth: function getThumbKnobWidth() {
  5614. return 0;
  5615. },
  5616. getValueIndicatorContainerWidth: function getValueIndicatorContainerWidth() {
  5617. return 0;
  5618. },
  5619. getThumbBoundingClientRect: function getThumbBoundingClientRect() {
  5620. return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
  5621. },
  5622. getBoundingClientRect: function getBoundingClientRect() {
  5623. return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
  5624. },
  5625. isRTL: function isRTL() {
  5626. return false;
  5627. },
  5628. setThumbStyleProperty: function setThumbStyleProperty() {
  5629. return undefined;
  5630. },
  5631. removeThumbStyleProperty: function removeThumbStyleProperty() {
  5632. return undefined;
  5633. },
  5634. setTrackActiveStyleProperty: function setTrackActiveStyleProperty() {
  5635. return undefined;
  5636. },
  5637. removeTrackActiveStyleProperty: function removeTrackActiveStyleProperty() {
  5638. return undefined;
  5639. },
  5640. setValueIndicatorText: function setValueIndicatorText() {
  5641. return undefined;
  5642. },
  5643. getValueToAriaValueTextFn: function getValueToAriaValueTextFn() {
  5644. return null;
  5645. },
  5646. updateTickMarks: function updateTickMarks() {
  5647. return undefined;
  5648. },
  5649. setPointerCapture: function setPointerCapture() {
  5650. return undefined;
  5651. },
  5652. emitChangeEvent: function emitChangeEvent() {
  5653. return undefined;
  5654. },
  5655. emitInputEvent: function emitInputEvent() {
  5656. return undefined;
  5657. },
  5658. emitDragStartEvent: function emitDragStartEvent() {
  5659. return undefined;
  5660. },
  5661. emitDragEndEvent: function emitDragEndEvent() {
  5662. return undefined;
  5663. },
  5664. registerEventHandler: function registerEventHandler() {
  5665. return undefined;
  5666. },
  5667. deregisterEventHandler: function deregisterEventHandler() {
  5668. return undefined;
  5669. },
  5670. registerThumbEventHandler: function registerThumbEventHandler() {
  5671. return undefined;
  5672. },
  5673. deregisterThumbEventHandler: function deregisterThumbEventHandler() {
  5674. return undefined;
  5675. },
  5676. registerInputEventHandler: function registerInputEventHandler() {
  5677. return undefined;
  5678. },
  5679. deregisterInputEventHandler: function deregisterInputEventHandler() {
  5680. return undefined;
  5681. },
  5682. registerBodyEventHandler: function registerBodyEventHandler() {
  5683. return undefined;
  5684. },
  5685. deregisterBodyEventHandler: function deregisterBodyEventHandler() {
  5686. return undefined;
  5687. },
  5688. registerWindowEventHandler: function registerWindowEventHandler() {
  5689. return undefined;
  5690. },
  5691. deregisterWindowEventHandler: function deregisterWindowEventHandler() {
  5692. return undefined;
  5693. }
  5694. };
  5695. // tslint:enable:object-literal-sort-keys
  5696. },
  5697. enumerable: false,
  5698. configurable: true
  5699. });
  5700. MDCSliderFoundation.prototype.init = function () {
  5701. var _this = this;
  5702. this.isDisabled = this.adapter.hasClass(constants_1.cssClasses.DISABLED);
  5703. this.isDiscrete = this.adapter.hasClass(constants_1.cssClasses.DISCRETE);
  5704. this.hasTickMarks = this.adapter.hasClass(constants_1.cssClasses.TICK_MARKS);
  5705. this.isRange = this.adapter.hasClass(constants_1.cssClasses.RANGE);
  5706. var min = this.convertAttributeValueToNumber(this.adapter.getInputAttribute(constants_1.attributes.INPUT_MIN, this.isRange ? types_1.Thumb.START : types_1.Thumb.END), constants_1.attributes.INPUT_MIN);
  5707. var max = this.convertAttributeValueToNumber(this.adapter.getInputAttribute(constants_1.attributes.INPUT_MAX, types_1.Thumb.END), constants_1.attributes.INPUT_MAX);
  5708. var value = this.convertAttributeValueToNumber(this.adapter.getInputAttribute(constants_1.attributes.INPUT_VALUE, types_1.Thumb.END), constants_1.attributes.INPUT_VALUE);
  5709. var valueStart = this.isRange ? this.convertAttributeValueToNumber(this.adapter.getInputAttribute(constants_1.attributes.INPUT_VALUE, types_1.Thumb.START), constants_1.attributes.INPUT_VALUE) : min;
  5710. var stepAttr = this.adapter.getInputAttribute(constants_1.attributes.INPUT_STEP, types_1.Thumb.END);
  5711. var step = stepAttr ? this.convertAttributeValueToNumber(stepAttr, constants_1.attributes.INPUT_STEP) : this.step;
  5712. var minRangeAttr = this.adapter.getAttribute(constants_1.attributes.DATA_MIN_RANGE);
  5713. var minRange = minRangeAttr ? this.convertAttributeValueToNumber(minRangeAttr, constants_1.attributes.DATA_MIN_RANGE) : this.minRange;
  5714. this.validateProperties({ min: min, max: max, value: value, valueStart: valueStart, step: step, minRange: minRange });
  5715. this.min = min;
  5716. this.max = max;
  5717. this.value = value;
  5718. this.valueStart = valueStart;
  5719. this.step = step;
  5720. this.minRange = minRange;
  5721. this.numDecimalPlaces = getNumDecimalPlaces(this.step);
  5722. this.valueBeforeDownEvent = value;
  5723. this.valueStartBeforeDownEvent = valueStart;
  5724. this.mousedownOrTouchstartListener = this.handleMousedownOrTouchstart.bind(this);
  5725. this.moveListener = this.handleMove.bind(this);
  5726. this.pointerdownListener = this.handlePointerdown.bind(this);
  5727. this.pointerupListener = this.handlePointerup.bind(this);
  5728. this.thumbMouseenterListener = this.handleThumbMouseenter.bind(this);
  5729. this.thumbMouseleaveListener = this.handleThumbMouseleave.bind(this);
  5730. this.inputStartChangeListener = function () {
  5731. _this.handleInputChange(types_1.Thumb.START);
  5732. };
  5733. this.inputEndChangeListener = function () {
  5734. _this.handleInputChange(types_1.Thumb.END);
  5735. };
  5736. this.inputStartFocusListener = function () {
  5737. _this.handleInputFocus(types_1.Thumb.START);
  5738. };
  5739. this.inputEndFocusListener = function () {
  5740. _this.handleInputFocus(types_1.Thumb.END);
  5741. };
  5742. this.inputStartBlurListener = function () {
  5743. _this.handleInputBlur(types_1.Thumb.START);
  5744. };
  5745. this.inputEndBlurListener = function () {
  5746. _this.handleInputBlur(types_1.Thumb.END);
  5747. };
  5748. this.resizeListener = this.handleResize.bind(this);
  5749. this.registerEventHandlers();
  5750. };
  5751. MDCSliderFoundation.prototype.destroy = function () {
  5752. this.deregisterEventHandlers();
  5753. };
  5754. MDCSliderFoundation.prototype.setMin = function (value) {
  5755. this.min = value;
  5756. if (!this.isRange) {
  5757. this.valueStart = value;
  5758. }
  5759. this.updateUI();
  5760. };
  5761. MDCSliderFoundation.prototype.setMax = function (value) {
  5762. this.max = value;
  5763. this.updateUI();
  5764. };
  5765. MDCSliderFoundation.prototype.getMin = function () {
  5766. return this.min;
  5767. };
  5768. MDCSliderFoundation.prototype.getMax = function () {
  5769. return this.max;
  5770. };
  5771. /**
  5772. * - For single point sliders, returns the thumb value.
  5773. * - For range (two-thumb) sliders, returns the end thumb's value.
  5774. */
  5775. MDCSliderFoundation.prototype.getValue = function () {
  5776. return this.value;
  5777. };
  5778. /**
  5779. * - For single point sliders, sets the thumb value.
  5780. * - For range (two-thumb) sliders, sets the end thumb's value.
  5781. */
  5782. MDCSliderFoundation.prototype.setValue = function (value) {
  5783. if (this.isRange && value < this.valueStart + this.minRange) {
  5784. throw new Error("end thumb value (" + value + ") must be >= start thumb " + ("value (" + this.valueStart + ") + min range (" + this.minRange + ")"));
  5785. }
  5786. this.updateValue(value, types_1.Thumb.END);
  5787. };
  5788. /**
  5789. * Only applicable for range sliders.
  5790. * @return The start thumb's value.
  5791. */
  5792. MDCSliderFoundation.prototype.getValueStart = function () {
  5793. if (!this.isRange) {
  5794. throw new Error('`valueStart` is only applicable for range sliders.');
  5795. }
  5796. return this.valueStart;
  5797. };
  5798. /**
  5799. * Only applicable for range sliders. Sets the start thumb's value.
  5800. */
  5801. MDCSliderFoundation.prototype.setValueStart = function (valueStart) {
  5802. if (!this.isRange) {
  5803. throw new Error('`valueStart` is only applicable for range sliders.');
  5804. }
  5805. if (this.isRange && valueStart > this.value - this.minRange) {
  5806. throw new Error("start thumb value (" + valueStart + ") must be <= end thumb " + ("value (" + this.value + ") - min range (" + this.minRange + ")"));
  5807. }
  5808. this.updateValue(valueStart, types_1.Thumb.START);
  5809. };
  5810. MDCSliderFoundation.prototype.setStep = function (value) {
  5811. this.step = value;
  5812. this.numDecimalPlaces = getNumDecimalPlaces(value);
  5813. this.updateUI();
  5814. };
  5815. /**
  5816. * Only applicable for range sliders. Sets the minimum difference between the
  5817. * start and end values.
  5818. */
  5819. MDCSliderFoundation.prototype.setMinRange = function (value) {
  5820. if (!this.isRange) {
  5821. throw new Error('`minRange` is only applicable for range sliders.');
  5822. }
  5823. if (value < 0) {
  5824. throw new Error('`minRange` must be non-negative. ' + ("Current value: " + value));
  5825. }
  5826. if (this.value - this.valueStart < value) {
  5827. throw new Error("start thumb value (" + this.valueStart + ") and end thumb value " + ("(" + this.value + ") must differ by at least " + value + "."));
  5828. }
  5829. this.minRange = value;
  5830. };
  5831. MDCSliderFoundation.prototype.setIsDiscrete = function (value) {
  5832. this.isDiscrete = value;
  5833. this.updateValueIndicatorUI();
  5834. this.updateTickMarksUI();
  5835. };
  5836. MDCSliderFoundation.prototype.getStep = function () {
  5837. return this.step;
  5838. };
  5839. MDCSliderFoundation.prototype.getMinRange = function () {
  5840. if (!this.isRange) {
  5841. throw new Error('`minRange` is only applicable for range sliders.');
  5842. }
  5843. return this.minRange;
  5844. };
  5845. MDCSliderFoundation.prototype.setHasTickMarks = function (value) {
  5846. this.hasTickMarks = value;
  5847. this.updateTickMarksUI();
  5848. };
  5849. MDCSliderFoundation.prototype.getDisabled = function () {
  5850. return this.isDisabled;
  5851. };
  5852. /**
  5853. * Sets disabled state, including updating styles and thumb tabindex.
  5854. */
  5855. MDCSliderFoundation.prototype.setDisabled = function (disabled) {
  5856. this.isDisabled = disabled;
  5857. if (disabled) {
  5858. this.adapter.addClass(constants_1.cssClasses.DISABLED);
  5859. if (this.isRange) {
  5860. this.adapter.setInputAttribute(constants_1.attributes.INPUT_DISABLED, '', types_1.Thumb.START);
  5861. }
  5862. this.adapter.setInputAttribute(constants_1.attributes.INPUT_DISABLED, '', types_1.Thumb.END);
  5863. } else {
  5864. this.adapter.removeClass(constants_1.cssClasses.DISABLED);
  5865. if (this.isRange) {
  5866. this.adapter.removeInputAttribute(constants_1.attributes.INPUT_DISABLED, types_1.Thumb.START);
  5867. }
  5868. this.adapter.removeInputAttribute(constants_1.attributes.INPUT_DISABLED, types_1.Thumb.END);
  5869. }
  5870. };
  5871. /** @return Whether the slider is a range slider. */
  5872. MDCSliderFoundation.prototype.getIsRange = function () {
  5873. return this.isRange;
  5874. };
  5875. /**
  5876. * - Syncs slider boundingClientRect with the current DOM.
  5877. * - Updates UI based on internal state.
  5878. */
  5879. MDCSliderFoundation.prototype.layout = function (_a) {
  5880. var _b = _a === void 0 ? {} : _a,
  5881. skipUpdateUI = _b.skipUpdateUI;
  5882. this.rect = this.adapter.getBoundingClientRect();
  5883. if (this.isRange) {
  5884. this.startThumbKnobWidth = this.adapter.getThumbKnobWidth(types_1.Thumb.START);
  5885. this.endThumbKnobWidth = this.adapter.getThumbKnobWidth(types_1.Thumb.END);
  5886. }
  5887. if (!skipUpdateUI) {
  5888. this.updateUI();
  5889. }
  5890. };
  5891. /** Handles resize events on the window. */
  5892. MDCSliderFoundation.prototype.handleResize = function () {
  5893. this.layout();
  5894. };
  5895. /**
  5896. * Handles pointer down events on the slider root element.
  5897. */
  5898. MDCSliderFoundation.prototype.handleDown = function (event) {
  5899. if (this.isDisabled) return;
  5900. this.valueStartBeforeDownEvent = this.valueStart;
  5901. this.valueBeforeDownEvent = this.value;
  5902. var clientX = event.clientX != null ? event.clientX : event.targetTouches[0].clientX;
  5903. this.downEventClientX = clientX;
  5904. var value = this.mapClientXOnSliderScale(clientX);
  5905. this.thumb = this.getThumbFromDownEvent(clientX, value);
  5906. if (this.thumb === null) return;
  5907. this.handleDragStart(event, value, this.thumb);
  5908. this.updateValue(value, this.thumb, { emitInputEvent: true });
  5909. };
  5910. /**
  5911. * Handles pointer move events on the slider root element.
  5912. */
  5913. MDCSliderFoundation.prototype.handleMove = function (event) {
  5914. if (this.isDisabled) return;
  5915. // Prevent scrolling.
  5916. event.preventDefault();
  5917. var clientX = event.clientX != null ? event.clientX : event.targetTouches[0].clientX;
  5918. var dragAlreadyStarted = this.thumb != null;
  5919. this.thumb = this.getThumbFromMoveEvent(clientX);
  5920. if (this.thumb === null) return;
  5921. var value = this.mapClientXOnSliderScale(clientX);
  5922. if (!dragAlreadyStarted) {
  5923. this.handleDragStart(event, value, this.thumb);
  5924. this.adapter.emitDragStartEvent(value, this.thumb);
  5925. }
  5926. this.updateValue(value, this.thumb, { emitInputEvent: true });
  5927. };
  5928. /**
  5929. * Handles pointer up events on the slider root element.
  5930. */
  5931. MDCSliderFoundation.prototype.handleUp = function () {
  5932. var _a, _b;
  5933. if (this.isDisabled || this.thumb === null) return;
  5934. // Remove the focused state and hide the value indicator(s) (if present)
  5935. // if focus state is meant to be hidden.
  5936. if ((_b = (_a = this.adapter).shouldHideFocusStylesForPointerEvents) === null || _b === void 0 ? void 0 : _b.call(_a)) {
  5937. this.handleInputBlur(this.thumb);
  5938. }
  5939. var oldValue = this.thumb === types_1.Thumb.START ? this.valueStartBeforeDownEvent : this.valueBeforeDownEvent;
  5940. var newValue = this.thumb === types_1.Thumb.START ? this.valueStart : this.value;
  5941. if (oldValue !== newValue) {
  5942. this.adapter.emitChangeEvent(newValue, this.thumb);
  5943. }
  5944. this.adapter.emitDragEndEvent(newValue, this.thumb);
  5945. this.thumb = null;
  5946. };
  5947. /**
  5948. * For range, discrete slider, shows the value indicator on both thumbs.
  5949. */
  5950. MDCSliderFoundation.prototype.handleThumbMouseenter = function () {
  5951. if (!this.isDiscrete || !this.isRange) return;
  5952. this.adapter.addThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, types_1.Thumb.START);
  5953. this.adapter.addThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, types_1.Thumb.END);
  5954. };
  5955. /**
  5956. * For range, discrete slider, hides the value indicator on both thumbs.
  5957. */
  5958. MDCSliderFoundation.prototype.handleThumbMouseleave = function () {
  5959. var _a, _b;
  5960. if (!this.isDiscrete || !this.isRange) return;
  5961. if (!((_b = (_a = this.adapter).shouldHideFocusStylesForPointerEvents) === null || _b === void 0 ? void 0 : _b.call(_a)) && (this.adapter.isInputFocused(types_1.Thumb.START) || this.adapter.isInputFocused(types_1.Thumb.END)) || this.thumb) {
  5962. // Leave value indicator shown if either input is focused or the thumb is
  5963. // being dragged.
  5964. return;
  5965. }
  5966. this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, types_1.Thumb.START);
  5967. this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, types_1.Thumb.END);
  5968. };
  5969. MDCSliderFoundation.prototype.handleMousedownOrTouchstart = function (event) {
  5970. var _this = this;
  5971. var moveEventType = event.type === 'mousedown' ? 'mousemove' : 'touchmove';
  5972. // After a down event on the slider root, listen for move events on
  5973. // body (so the slider value is updated for events outside of the
  5974. // slider root).
  5975. this.adapter.registerBodyEventHandler(moveEventType, this.moveListener);
  5976. var upHandler = function upHandler() {
  5977. _this.handleUp();
  5978. // Once the drag is finished (up event on body), remove the move
  5979. // handler.
  5980. _this.adapter.deregisterBodyEventHandler(moveEventType, _this.moveListener);
  5981. // Also stop listening for subsequent up events.
  5982. _this.adapter.deregisterEventHandler('mouseup', upHandler);
  5983. _this.adapter.deregisterEventHandler('touchend', upHandler);
  5984. };
  5985. this.adapter.registerBodyEventHandler('mouseup', upHandler);
  5986. this.adapter.registerBodyEventHandler('touchend', upHandler);
  5987. this.handleDown(event);
  5988. };
  5989. MDCSliderFoundation.prototype.handlePointerdown = function (event) {
  5990. var isPrimaryButton = event.button === 0;
  5991. if (!isPrimaryButton) return;
  5992. if (event.pointerId != null) {
  5993. this.adapter.setPointerCapture(event.pointerId);
  5994. }
  5995. this.adapter.registerEventHandler('pointermove', this.moveListener);
  5996. this.handleDown(event);
  5997. };
  5998. /**
  5999. * Handles input `change` event by setting internal slider value to match
  6000. * input's new value.
  6001. */
  6002. MDCSliderFoundation.prototype.handleInputChange = function (thumb) {
  6003. var value = Number(this.adapter.getInputValue(thumb));
  6004. if (thumb === types_1.Thumb.START) {
  6005. this.setValueStart(value);
  6006. } else {
  6007. this.setValue(value);
  6008. }
  6009. this.adapter.emitChangeEvent(thumb === types_1.Thumb.START ? this.valueStart : this.value, thumb);
  6010. this.adapter.emitInputEvent(thumb === types_1.Thumb.START ? this.valueStart : this.value, thumb);
  6011. };
  6012. /** Shows activated state and value indicator on thumb(s). */
  6013. MDCSliderFoundation.prototype.handleInputFocus = function (thumb) {
  6014. this.adapter.addThumbClass(constants_1.cssClasses.THUMB_FOCUSED, thumb);
  6015. if (!this.isDiscrete) return;
  6016. this.adapter.addThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, thumb);
  6017. if (this.isRange) {
  6018. var otherThumb = thumb === types_1.Thumb.START ? types_1.Thumb.END : types_1.Thumb.START;
  6019. this.adapter.addThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, otherThumb);
  6020. }
  6021. };
  6022. /** Removes activated state and value indicator from thumb(s). */
  6023. MDCSliderFoundation.prototype.handleInputBlur = function (thumb) {
  6024. this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_FOCUSED, thumb);
  6025. if (!this.isDiscrete) return;
  6026. this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, thumb);
  6027. if (this.isRange) {
  6028. var otherThumb = thumb === types_1.Thumb.START ? types_1.Thumb.END : types_1.Thumb.START;
  6029. this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, otherThumb);
  6030. }
  6031. };
  6032. /**
  6033. * Emits custom dragStart event, along with focusing the underlying input.
  6034. */
  6035. MDCSliderFoundation.prototype.handleDragStart = function (event, value, thumb) {
  6036. var _a, _b;
  6037. this.adapter.emitDragStartEvent(value, thumb);
  6038. this.adapter.focusInput(thumb);
  6039. // Restore focused state and show the value indicator(s) (if present)
  6040. // in case they were previously hidden on dragEnd.
  6041. // This is needed if the input is already focused, in which case
  6042. // #focusInput above wouldn't actually trigger #handleInputFocus,
  6043. // which is why we need to invoke it manually here.
  6044. if ((_b = (_a = this.adapter).shouldHideFocusStylesForPointerEvents) === null || _b === void 0 ? void 0 : _b.call(_a)) {
  6045. this.handleInputFocus(thumb);
  6046. }
  6047. // Prevent the input (that we just focused) from losing focus.
  6048. event.preventDefault();
  6049. };
  6050. /**
  6051. * @return The thumb to be moved based on initial down event.
  6052. */
  6053. MDCSliderFoundation.prototype.getThumbFromDownEvent = function (clientX, value) {
  6054. // For single point slider, thumb to be moved is always the END (only)
  6055. // thumb.
  6056. if (!this.isRange) return types_1.Thumb.END;
  6057. // Check if event press point is in the bounds of any thumb.
  6058. var thumbStartRect = this.adapter.getThumbBoundingClientRect(types_1.Thumb.START);
  6059. var thumbEndRect = this.adapter.getThumbBoundingClientRect(types_1.Thumb.END);
  6060. var inThumbStartBounds = clientX >= thumbStartRect.left && clientX <= thumbStartRect.right;
  6061. var inThumbEndBounds = clientX >= thumbEndRect.left && clientX <= thumbEndRect.right;
  6062. if (inThumbStartBounds && inThumbEndBounds) {
  6063. // Thumbs overlapping. Thumb to be moved cannot be determined yet.
  6064. return null;
  6065. }
  6066. // If press is in bounds for either thumb on down event, that's the thumb
  6067. // to be moved.
  6068. if (inThumbStartBounds) {
  6069. return types_1.Thumb.START;
  6070. }
  6071. if (inThumbEndBounds) {
  6072. return types_1.Thumb.END;
  6073. }
  6074. // For presses outside the range, return whichever thumb is closer.
  6075. if (value < this.valueStart) {
  6076. return types_1.Thumb.START;
  6077. }
  6078. if (value > this.value) {
  6079. return types_1.Thumb.END;
  6080. }
  6081. // For presses inside the range, return whichever thumb is closer.
  6082. return value - this.valueStart <= this.value - value ? types_1.Thumb.START : types_1.Thumb.END;
  6083. };
  6084. /**
  6085. * @return The thumb to be moved based on move event (based on drag
  6086. * direction from original down event). Only applicable if thumbs
  6087. * were overlapping in the down event.
  6088. */
  6089. MDCSliderFoundation.prototype.getThumbFromMoveEvent = function (clientX) {
  6090. // Thumb has already been chosen.
  6091. if (this.thumb !== null) return this.thumb;
  6092. if (this.downEventClientX === null) {
  6093. throw new Error('`downEventClientX` is null after move event.');
  6094. }
  6095. var moveDistanceUnderThreshold = Math.abs(this.downEventClientX - clientX) < constants_1.numbers.THUMB_UPDATE_MIN_PX;
  6096. if (moveDistanceUnderThreshold) return this.thumb;
  6097. var draggedThumbToLeft = clientX < this.downEventClientX;
  6098. if (draggedThumbToLeft) {
  6099. return this.adapter.isRTL() ? types_1.Thumb.END : types_1.Thumb.START;
  6100. } else {
  6101. return this.adapter.isRTL() ? types_1.Thumb.START : types_1.Thumb.END;
  6102. }
  6103. };
  6104. /**
  6105. * Updates UI based on internal state.
  6106. * @param thumb Thumb whose value is being updated. If undefined, UI is
  6107. * updated for both thumbs based on current internal state.
  6108. */
  6109. MDCSliderFoundation.prototype.updateUI = function (thumb) {
  6110. if (thumb) {
  6111. this.updateThumbAndInputAttributes(thumb);
  6112. } else {
  6113. this.updateThumbAndInputAttributes(types_1.Thumb.START);
  6114. this.updateThumbAndInputAttributes(types_1.Thumb.END);
  6115. }
  6116. this.updateThumbAndTrackUI(thumb);
  6117. this.updateValueIndicatorUI(thumb);
  6118. this.updateTickMarksUI();
  6119. };
  6120. /**
  6121. * Updates thumb and input attributes based on current value.
  6122. * @param thumb Thumb whose aria attributes to update.
  6123. */
  6124. MDCSliderFoundation.prototype.updateThumbAndInputAttributes = function (thumb) {
  6125. if (!thumb) return;
  6126. var value = this.isRange && thumb === types_1.Thumb.START ? this.valueStart : this.value;
  6127. var valueStr = String(value);
  6128. this.adapter.setInputAttribute(constants_1.attributes.INPUT_VALUE, valueStr, thumb);
  6129. if (this.isRange && thumb === types_1.Thumb.START) {
  6130. this.adapter.setInputAttribute(constants_1.attributes.INPUT_MIN, String(value + this.minRange), types_1.Thumb.END);
  6131. } else if (this.isRange && thumb === types_1.Thumb.END) {
  6132. this.adapter.setInputAttribute(constants_1.attributes.INPUT_MAX, String(value - this.minRange), types_1.Thumb.START);
  6133. }
  6134. // Sync attribute with property.
  6135. if (this.adapter.getInputValue(thumb) !== valueStr) {
  6136. this.adapter.setInputValue(valueStr, thumb);
  6137. }
  6138. var valueToAriaValueTextFn = this.adapter.getValueToAriaValueTextFn();
  6139. if (valueToAriaValueTextFn) {
  6140. this.adapter.setInputAttribute(constants_1.attributes.ARIA_VALUETEXT, valueToAriaValueTextFn(value, thumb), thumb);
  6141. }
  6142. };
  6143. /**
  6144. * Updates value indicator UI based on current value.
  6145. * @param thumb Thumb whose value indicator to update. If undefined, all
  6146. * thumbs' value indicators are updated.
  6147. */
  6148. MDCSliderFoundation.prototype.updateValueIndicatorUI = function (thumb) {
  6149. if (!this.isDiscrete) return;
  6150. var value = this.isRange && thumb === types_1.Thumb.START ? this.valueStart : this.value;
  6151. this.adapter.setValueIndicatorText(value, thumb === types_1.Thumb.START ? types_1.Thumb.START : types_1.Thumb.END);
  6152. if (!thumb && this.isRange) {
  6153. this.adapter.setValueIndicatorText(this.valueStart, types_1.Thumb.START);
  6154. }
  6155. };
  6156. /**
  6157. * Updates tick marks UI within slider, based on current min, max, and step.
  6158. */
  6159. MDCSliderFoundation.prototype.updateTickMarksUI = function () {
  6160. if (!this.isDiscrete || !this.hasTickMarks) return;
  6161. var numTickMarksInactiveStart = (this.valueStart - this.min) / this.step;
  6162. var numTickMarksActive = (this.value - this.valueStart) / this.step + 1;
  6163. var numTickMarksInactiveEnd = (this.max - this.value) / this.step;
  6164. var tickMarksInactiveStart = Array.from({ length: numTickMarksInactiveStart }).fill(types_1.TickMark.INACTIVE);
  6165. var tickMarksActive = Array.from({ length: numTickMarksActive }).fill(types_1.TickMark.ACTIVE);
  6166. var tickMarksInactiveEnd = Array.from({ length: numTickMarksInactiveEnd }).fill(types_1.TickMark.INACTIVE);
  6167. this.adapter.updateTickMarks(tickMarksInactiveStart.concat(tickMarksActive).concat(tickMarksInactiveEnd));
  6168. };
  6169. /** Maps clientX to a value on the slider scale. */
  6170. MDCSliderFoundation.prototype.mapClientXOnSliderScale = function (clientX) {
  6171. var xPos = clientX - this.rect.left;
  6172. var pctComplete = xPos / this.rect.width;
  6173. if (this.adapter.isRTL()) {
  6174. pctComplete = 1 - pctComplete;
  6175. }
  6176. // Fit the percentage complete between the range [min,max]
  6177. // by remapping from [0, 1] to [min, min+(max-min)].
  6178. var value = this.min + pctComplete * (this.max - this.min);
  6179. if (value === this.max || value === this.min) {
  6180. return value;
  6181. }
  6182. return Number(this.quantize(value).toFixed(this.numDecimalPlaces));
  6183. };
  6184. /** Calculates the quantized value based on step value. */
  6185. MDCSliderFoundation.prototype.quantize = function (value) {
  6186. var numSteps = Math.round((value - this.min) / this.step);
  6187. return this.min + numSteps * this.step;
  6188. };
  6189. /**
  6190. * Updates slider value (internal state and UI) based on the given value.
  6191. */
  6192. MDCSliderFoundation.prototype.updateValue = function (value, thumb, _a) {
  6193. var _b = _a === void 0 ? {} : _a,
  6194. emitInputEvent = _b.emitInputEvent;
  6195. value = this.clampValue(value, thumb);
  6196. if (this.isRange && thumb === types_1.Thumb.START) {
  6197. // Exit early if current value is the same as the new value.
  6198. if (this.valueStart === value) return;
  6199. this.valueStart = value;
  6200. } else {
  6201. // Exit early if current value is the same as the new value.
  6202. if (this.value === value) return;
  6203. this.value = value;
  6204. }
  6205. this.updateUI(thumb);
  6206. if (emitInputEvent) {
  6207. this.adapter.emitInputEvent(thumb === types_1.Thumb.START ? this.valueStart : this.value, thumb);
  6208. }
  6209. };
  6210. /**
  6211. * Clamps the given value for the given thumb based on slider properties:
  6212. * - Restricts value within [min, max].
  6213. * - If range slider, clamp start value <= end value - min range, and
  6214. * end value >= start value + min range.
  6215. */
  6216. MDCSliderFoundation.prototype.clampValue = function (value, thumb) {
  6217. // Clamp value to [min, max] range.
  6218. value = Math.min(Math.max(value, this.min), this.max);
  6219. var thumbStartMovedPastThumbEnd = this.isRange && thumb === types_1.Thumb.START && value > this.value - this.minRange;
  6220. if (thumbStartMovedPastThumbEnd) {
  6221. return this.value - this.minRange;
  6222. }
  6223. var thumbEndMovedPastThumbStart = this.isRange && thumb === types_1.Thumb.END && value < this.valueStart + this.minRange;
  6224. if (thumbEndMovedPastThumbStart) {
  6225. return this.valueStart + this.minRange;
  6226. }
  6227. return value;
  6228. };
  6229. /**
  6230. * Updates the active track and thumb style properties to reflect current
  6231. * value.
  6232. */
  6233. MDCSliderFoundation.prototype.updateThumbAndTrackUI = function (thumb) {
  6234. var _this = this;
  6235. var _a = this,
  6236. max = _a.max,
  6237. min = _a.min;
  6238. var pctComplete = (this.value - this.valueStart) / (max - min);
  6239. var rangePx = pctComplete * this.rect.width;
  6240. var isRtl = this.adapter.isRTL();
  6241. var transformProp = HAS_WINDOW ? util_1.getCorrectPropertyName(window, 'transform') : 'transform';
  6242. if (this.isRange) {
  6243. var thumbLeftPos_1 = this.adapter.isRTL() ? (max - this.value) / (max - min) * this.rect.width : (this.valueStart - min) / (max - min) * this.rect.width;
  6244. var thumbRightPos_1 = thumbLeftPos_1 + rangePx;
  6245. this.animFrame.request(AnimationKeys.SLIDER_UPDATE, function () {
  6246. // Set active track styles, accounting for animation direction by
  6247. // setting `transform-origin`.
  6248. var trackAnimatesFromRight = !isRtl && thumb === types_1.Thumb.START || isRtl && thumb !== types_1.Thumb.START;
  6249. if (trackAnimatesFromRight) {
  6250. _this.adapter.setTrackActiveStyleProperty('transform-origin', 'right');
  6251. _this.adapter.setTrackActiveStyleProperty('left', 'auto');
  6252. _this.adapter.setTrackActiveStyleProperty('right', _this.rect.width - thumbRightPos_1 + "px");
  6253. } else {
  6254. _this.adapter.setTrackActiveStyleProperty('transform-origin', 'left');
  6255. _this.adapter.setTrackActiveStyleProperty('right', 'auto');
  6256. _this.adapter.setTrackActiveStyleProperty('left', thumbLeftPos_1 + "px");
  6257. }
  6258. _this.adapter.setTrackActiveStyleProperty(transformProp, "scaleX(" + pctComplete + ")");
  6259. // Set thumb styles.
  6260. var thumbStartPos = isRtl ? thumbRightPos_1 : thumbLeftPos_1;
  6261. var thumbEndPos = _this.adapter.isRTL() ? thumbLeftPos_1 : thumbRightPos_1;
  6262. if (thumb === types_1.Thumb.START || !thumb || !_this.initialStylesRemoved) {
  6263. _this.adapter.setThumbStyleProperty(transformProp, "translateX(" + thumbStartPos + "px)", types_1.Thumb.START);
  6264. _this.alignValueIndicator(types_1.Thumb.START, thumbStartPos);
  6265. }
  6266. if (thumb === types_1.Thumb.END || !thumb || !_this.initialStylesRemoved) {
  6267. _this.adapter.setThumbStyleProperty(transformProp, "translateX(" + thumbEndPos + "px)", types_1.Thumb.END);
  6268. _this.alignValueIndicator(types_1.Thumb.END, thumbEndPos);
  6269. }
  6270. _this.removeInitialStyles(isRtl);
  6271. _this.updateOverlappingThumbsUI(thumbStartPos, thumbEndPos, thumb);
  6272. });
  6273. } else {
  6274. this.animFrame.request(AnimationKeys.SLIDER_UPDATE, function () {
  6275. var thumbStartPos = isRtl ? _this.rect.width - rangePx : rangePx;
  6276. _this.adapter.setThumbStyleProperty(transformProp, "translateX(" + thumbStartPos + "px)", types_1.Thumb.END);
  6277. _this.alignValueIndicator(types_1.Thumb.END, thumbStartPos);
  6278. _this.adapter.setTrackActiveStyleProperty(transformProp, "scaleX(" + pctComplete + ")");
  6279. _this.removeInitialStyles(isRtl);
  6280. });
  6281. }
  6282. };
  6283. /**
  6284. * Shifts the value indicator to either side if it would otherwise stick
  6285. * beyond the slider's length while keeping the caret above the knob.
  6286. */
  6287. MDCSliderFoundation.prototype.alignValueIndicator = function (thumb, thumbPos) {
  6288. if (!this.isDiscrete) return;
  6289. var thumbHalfWidth = this.adapter.getThumbBoundingClientRect(thumb).width / 2;
  6290. var containerWidth = this.adapter.getValueIndicatorContainerWidth(thumb);
  6291. var sliderWidth = this.adapter.getBoundingClientRect().width;
  6292. if (containerWidth / 2 > thumbPos + thumbHalfWidth) {
  6293. this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CARET_LEFT, thumbHalfWidth + "px", thumb);
  6294. this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CARET_RIGHT, 'auto', thumb);
  6295. this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CARET_TRANSFORM, 'translateX(-50%)', thumb);
  6296. this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CONTAINER_LEFT, '0', thumb);
  6297. this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CONTAINER_RIGHT, 'auto', thumb);
  6298. this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CONTAINER_TRANSFORM, 'none', thumb);
  6299. } else if (containerWidth / 2 > sliderWidth - thumbPos + thumbHalfWidth) {
  6300. this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CARET_LEFT, 'auto', thumb);
  6301. this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CARET_RIGHT, thumbHalfWidth + "px", thumb);
  6302. this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CARET_TRANSFORM, 'translateX(50%)', thumb);
  6303. this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CONTAINER_LEFT, 'auto', thumb);
  6304. this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CONTAINER_RIGHT, '0', thumb);
  6305. this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CONTAINER_TRANSFORM, 'none', thumb);
  6306. } else {
  6307. this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CARET_LEFT, '50%', thumb);
  6308. this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CARET_RIGHT, 'auto', thumb);
  6309. this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CARET_TRANSFORM, 'translateX(-50%)', thumb);
  6310. this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CONTAINER_LEFT, '50%', thumb);
  6311. this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CONTAINER_RIGHT, 'auto', thumb);
  6312. this.adapter.setThumbStyleProperty(constants_1.strings.VAR_VALUE_INDICATOR_CONTAINER_TRANSFORM, 'translateX(-50%)', thumb);
  6313. }
  6314. };
  6315. /**
  6316. * Removes initial inline styles if not already removed. `left:<...>%`
  6317. * inline styles can be added to position the thumb correctly before JS
  6318. * initialization. However, they need to be removed before the JS starts
  6319. * positioning the thumb. This is because the JS uses
  6320. * `transform:translateX(<...>)px` (for performance reasons) to position
  6321. * the thumb (which is not possible for initial styles since we need the
  6322. * bounding rect measurements).
  6323. */
  6324. MDCSliderFoundation.prototype.removeInitialStyles = function (isRtl) {
  6325. if (this.initialStylesRemoved) return;
  6326. // Remove thumb position properties that were added for initial render.
  6327. var position = isRtl ? 'right' : 'left';
  6328. this.adapter.removeThumbStyleProperty(position, types_1.Thumb.END);
  6329. if (this.isRange) {
  6330. this.adapter.removeThumbStyleProperty(position, types_1.Thumb.START);
  6331. }
  6332. this.initialStylesRemoved = true;
  6333. this.resetTrackAndThumbAnimation();
  6334. };
  6335. /**
  6336. * Resets track/thumb animation to prevent animation when adding
  6337. * `transform` styles to thumb initially.
  6338. */
  6339. MDCSliderFoundation.prototype.resetTrackAndThumbAnimation = function () {
  6340. var _this = this;
  6341. if (!this.isDiscrete) return;
  6342. // Set transition properties to default (no animation), so that the
  6343. // newly added `transform` styles do not animate thumb/track from
  6344. // their default positions.
  6345. var transitionProp = HAS_WINDOW ? util_1.getCorrectPropertyName(window, 'transition') : 'transition';
  6346. var transitionDefault = 'none 0s ease 0s';
  6347. this.adapter.setThumbStyleProperty(transitionProp, transitionDefault, types_1.Thumb.END);
  6348. if (this.isRange) {
  6349. this.adapter.setThumbStyleProperty(transitionProp, transitionDefault, types_1.Thumb.START);
  6350. }
  6351. this.adapter.setTrackActiveStyleProperty(transitionProp, transitionDefault);
  6352. // In the next frame, remove the transition inline styles we just
  6353. // added, such that any animations added in the CSS can now take effect.
  6354. requestAnimationFrame(function () {
  6355. _this.adapter.removeThumbStyleProperty(transitionProp, types_1.Thumb.END);
  6356. _this.adapter.removeTrackActiveStyleProperty(transitionProp);
  6357. if (_this.isRange) {
  6358. _this.adapter.removeThumbStyleProperty(transitionProp, types_1.Thumb.START);
  6359. }
  6360. });
  6361. };
  6362. /**
  6363. * Adds THUMB_TOP class to active thumb if thumb knobs overlap; otherwise
  6364. * removes THUMB_TOP class from both thumbs.
  6365. * @param thumb Thumb that is active (being moved).
  6366. */
  6367. MDCSliderFoundation.prototype.updateOverlappingThumbsUI = function (thumbStartPos, thumbEndPos, thumb) {
  6368. var thumbsOverlap = false;
  6369. if (this.adapter.isRTL()) {
  6370. var startThumbLeftEdge = thumbStartPos - this.startThumbKnobWidth / 2;
  6371. var endThumbRightEdge = thumbEndPos + this.endThumbKnobWidth / 2;
  6372. thumbsOverlap = endThumbRightEdge >= startThumbLeftEdge;
  6373. } else {
  6374. var startThumbRightEdge = thumbStartPos + this.startThumbKnobWidth / 2;
  6375. var endThumbLeftEdge = thumbEndPos - this.endThumbKnobWidth / 2;
  6376. thumbsOverlap = startThumbRightEdge >= endThumbLeftEdge;
  6377. }
  6378. if (thumbsOverlap) {
  6379. this.adapter.addThumbClass(constants_1.cssClasses.THUMB_TOP,
  6380. // If no thumb was dragged (in the case of initial layout), end
  6381. // thumb is on top by default.
  6382. thumb || types_1.Thumb.END);
  6383. this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_TOP, thumb === types_1.Thumb.START ? types_1.Thumb.END : types_1.Thumb.START);
  6384. } else {
  6385. this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_TOP, types_1.Thumb.START);
  6386. this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_TOP, types_1.Thumb.END);
  6387. }
  6388. };
  6389. /**
  6390. * Converts attribute value to a number, e.g. '100' => 100. Throws errors
  6391. * for invalid values.
  6392. * @param attributeValue Attribute value, e.g. 100.
  6393. * @param attributeName Attribute name, e.g. `aria-valuemax`.
  6394. */
  6395. MDCSliderFoundation.prototype.convertAttributeValueToNumber = function (attributeValue, attributeName) {
  6396. if (attributeValue === null) {
  6397. throw new Error('MDCSliderFoundation: `' + attributeName + '` must be non-null.');
  6398. }
  6399. var value = Number(attributeValue);
  6400. if (isNaN(value)) {
  6401. throw new Error('MDCSliderFoundation: `' + attributeName + '` value is `' + attributeValue + '`, but must be a number.');
  6402. }
  6403. return value;
  6404. };
  6405. /** Checks that the given properties are valid slider values. */
  6406. MDCSliderFoundation.prototype.validateProperties = function (_a) {
  6407. var min = _a.min,
  6408. max = _a.max,
  6409. value = _a.value,
  6410. valueStart = _a.valueStart,
  6411. step = _a.step,
  6412. minRange = _a.minRange;
  6413. if (min >= max) {
  6414. throw new Error("MDCSliderFoundation: min must be strictly less than max. " + ("Current: [min: " + min + ", max: " + max + "]"));
  6415. }
  6416. if (step <= 0) {
  6417. throw new Error("MDCSliderFoundation: step must be a positive number. " + ("Current step: " + step));
  6418. }
  6419. if (this.isRange) {
  6420. if (value < min || value > max || valueStart < min || valueStart > max) {
  6421. throw new Error("MDCSliderFoundation: values must be in [min, max] range. " + ("Current values: [start value: " + valueStart + ", end value: ") + (value + ", min: " + min + ", max: " + max + "]"));
  6422. }
  6423. if (valueStart > value) {
  6424. throw new Error("MDCSliderFoundation: start value must be <= end value. " + ("Current values: [start value: " + valueStart + ", end value: " + value + "]"));
  6425. }
  6426. if (minRange < 0) {
  6427. throw new Error("MDCSliderFoundation: minimum range must be non-negative. " + ("Current min range: " + minRange));
  6428. }
  6429. if (value - valueStart < minRange) {
  6430. throw new Error("MDCSliderFoundation: start value and end value must differ by at least " + (minRange + ". Current values: [start value: " + valueStart + ", ") + ("end value: " + value + "]"));
  6431. }
  6432. var numStepsValueStartFromMin = (valueStart - min) / step;
  6433. var numStepsValueFromMin = (value - min) / step;
  6434. if (!Number.isInteger(parseFloat(numStepsValueStartFromMin.toFixed(6))) || !Number.isInteger(parseFloat(numStepsValueFromMin.toFixed(6)))) {
  6435. throw new Error("MDCSliderFoundation: Slider values must be valid based on the " + ("step value (" + step + "). Current values: [start value: ") + (valueStart + ", end value: " + value + ", min: " + min + "]"));
  6436. }
  6437. } else {
  6438. // Single point slider.
  6439. if (value < min || value > max) {
  6440. throw new Error("MDCSliderFoundation: value must be in [min, max] range. " + ("Current values: [value: " + value + ", min: " + min + ", max: " + max + "]"));
  6441. }
  6442. var numStepsValueFromMin = (value - min) / step;
  6443. if (!Number.isInteger(parseFloat(numStepsValueFromMin.toFixed(6)))) {
  6444. throw new Error("MDCSliderFoundation: Slider value must be valid based on the " + ("step value (" + step + "). Current value: " + value));
  6445. }
  6446. }
  6447. };
  6448. MDCSliderFoundation.prototype.registerEventHandlers = function () {
  6449. this.adapter.registerWindowEventHandler('resize', this.resizeListener);
  6450. if (MDCSliderFoundation.SUPPORTS_POINTER_EVENTS) {
  6451. // If supported, use pointer events API with #setPointerCapture.
  6452. this.adapter.registerEventHandler('pointerdown', this.pointerdownListener);
  6453. this.adapter.registerEventHandler('pointerup', this.pointerupListener);
  6454. } else {
  6455. // Otherwise, fall back to mousedown/touchstart events.
  6456. this.adapter.registerEventHandler('mousedown', this.mousedownOrTouchstartListener);
  6457. this.adapter.registerEventHandler('touchstart', this.mousedownOrTouchstartListener);
  6458. }
  6459. if (this.isRange) {
  6460. this.adapter.registerThumbEventHandler(types_1.Thumb.START, 'mouseenter', this.thumbMouseenterListener);
  6461. this.adapter.registerThumbEventHandler(types_1.Thumb.START, 'mouseleave', this.thumbMouseleaveListener);
  6462. this.adapter.registerInputEventHandler(types_1.Thumb.START, 'change', this.inputStartChangeListener);
  6463. this.adapter.registerInputEventHandler(types_1.Thumb.START, 'focus', this.inputStartFocusListener);
  6464. this.adapter.registerInputEventHandler(types_1.Thumb.START, 'blur', this.inputStartBlurListener);
  6465. }
  6466. this.adapter.registerThumbEventHandler(types_1.Thumb.END, 'mouseenter', this.thumbMouseenterListener);
  6467. this.adapter.registerThumbEventHandler(types_1.Thumb.END, 'mouseleave', this.thumbMouseleaveListener);
  6468. this.adapter.registerInputEventHandler(types_1.Thumb.END, 'change', this.inputEndChangeListener);
  6469. this.adapter.registerInputEventHandler(types_1.Thumb.END, 'focus', this.inputEndFocusListener);
  6470. this.adapter.registerInputEventHandler(types_1.Thumb.END, 'blur', this.inputEndBlurListener);
  6471. };
  6472. MDCSliderFoundation.prototype.deregisterEventHandlers = function () {
  6473. this.adapter.deregisterWindowEventHandler('resize', this.resizeListener);
  6474. if (MDCSliderFoundation.SUPPORTS_POINTER_EVENTS) {
  6475. this.adapter.deregisterEventHandler('pointerdown', this.pointerdownListener);
  6476. this.adapter.deregisterEventHandler('pointerup', this.pointerupListener);
  6477. } else {
  6478. this.adapter.deregisterEventHandler('mousedown', this.mousedownOrTouchstartListener);
  6479. this.adapter.deregisterEventHandler('touchstart', this.mousedownOrTouchstartListener);
  6480. }
  6481. if (this.isRange) {
  6482. this.adapter.deregisterThumbEventHandler(types_1.Thumb.START, 'mouseenter', this.thumbMouseenterListener);
  6483. this.adapter.deregisterThumbEventHandler(types_1.Thumb.START, 'mouseleave', this.thumbMouseleaveListener);
  6484. this.adapter.deregisterInputEventHandler(types_1.Thumb.START, 'change', this.inputStartChangeListener);
  6485. this.adapter.deregisterInputEventHandler(types_1.Thumb.START, 'focus', this.inputStartFocusListener);
  6486. this.adapter.deregisterInputEventHandler(types_1.Thumb.START, 'blur', this.inputStartBlurListener);
  6487. }
  6488. this.adapter.deregisterThumbEventHandler(types_1.Thumb.END, 'mouseenter', this.thumbMouseenterListener);
  6489. this.adapter.deregisterThumbEventHandler(types_1.Thumb.END, 'mouseleave', this.thumbMouseleaveListener);
  6490. this.adapter.deregisterInputEventHandler(types_1.Thumb.END, 'change', this.inputEndChangeListener);
  6491. this.adapter.deregisterInputEventHandler(types_1.Thumb.END, 'focus', this.inputEndFocusListener);
  6492. this.adapter.deregisterInputEventHandler(types_1.Thumb.END, 'blur', this.inputEndBlurListener);
  6493. };
  6494. MDCSliderFoundation.prototype.handlePointerup = function () {
  6495. this.handleUp();
  6496. this.adapter.deregisterEventHandler('pointermove', this.moveListener);
  6497. };
  6498. MDCSliderFoundation.SUPPORTS_POINTER_EVENTS = HAS_WINDOW && Boolean(window.PointerEvent) &&
  6499. // #setPointerCapture is buggy on iOS, so we can't use pointer events
  6500. // until the following bug is fixed:
  6501. // https://bugs.webkit.org/show_bug.cgi?id=220196
  6502. !isIOS();
  6503. return MDCSliderFoundation;
  6504. }(foundation_1.MDCFoundation);
  6505. exports.MDCSliderFoundation = MDCSliderFoundation;
  6506. function isIOS() {
  6507. // Source:
  6508. // https://stackoverflow.com/questions/9038625/detect-if-device-is-ios
  6509. return ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator.platform)
  6510. // iPad on iOS 13 detection
  6511. || navigator.userAgent.includes('Mac') && 'ontouchend' in document;
  6512. }
  6513. /**
  6514. * Given a number, returns the number of digits that appear after the
  6515. * decimal point.
  6516. * See
  6517. * https://stackoverflow.com/questions/9539513/is-there-a-reliable-way-in-javascript-to-obtain-the-number-of-decimal-places-of
  6518. */
  6519. function getNumDecimalPlaces(n) {
  6520. // Pull out the fraction and the exponent.
  6521. var match = /(?:\.(\d+))?(?:[eE]([+\-]?\d+))?$/.exec(String(n));
  6522. // NaN or Infinity or integer.
  6523. // We arbitrarily decide that Infinity is integral.
  6524. if (!match) return 0;
  6525. var fraction = match[1] || ''; // E.g. 1.234e-2 => 234
  6526. var exponent = match[2] || 0; // E.g. 1.234e-2 => -2
  6527. // Count the number of digits in the fraction and subtract the
  6528. // exponent to simulate moving the decimal point left by exponent places.
  6529. // 1.234e+2 has 1 fraction digit and '234'.length - 2 == 1
  6530. // 1.234e-2 has 5 fraction digit and '234'.length - -2 == 5
  6531. return Math.max(0, // lower limit
  6532. (fraction === '0' ? 0 : fraction.length) - Number(exponent));
  6533. }
  6534. /***/ }),
  6535. /***/ "./packages/mdc-slider/index.ts":
  6536. /*!**************************************!*\
  6537. !*** ./packages/mdc-slider/index.ts ***!
  6538. \**************************************/
  6539. /*! no static exports found */
  6540. /***/ (function(module, exports, __webpack_require__) {
  6541. "use strict";
  6542. /**
  6543. * @license
  6544. * Copyright 2020 Google Inc.
  6545. *
  6546. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6547. * of this software and associated documentation files (the "Software"), to deal
  6548. * in the Software without restriction, including without limitation the rights
  6549. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6550. * copies of the Software, and to permit persons to whom the Software is
  6551. * furnished to do so, subject to the following conditions:
  6552. *
  6553. * The above copyright notice and this permission notice shall be included in
  6554. * all copies or substantial portions of the Software.
  6555. *
  6556. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6557. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6558. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6559. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6560. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6561. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6562. * THE SOFTWARE.
  6563. */
  6564. var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
  6565. if (k2 === undefined) k2 = k;
  6566. Object.defineProperty(o, k2, { enumerable: true, get: function get() {
  6567. return m[k];
  6568. } });
  6569. } : function (o, m, k, k2) {
  6570. if (k2 === undefined) k2 = k;
  6571. o[k2] = m[k];
  6572. });
  6573. var __exportStar = this && this.__exportStar || function (m, exports) {
  6574. for (var p in m) {
  6575. if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
  6576. }
  6577. };
  6578. Object.defineProperty(exports, "__esModule", { value: true });
  6579. __exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-slider/adapter.ts"), exports);
  6580. __exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-slider/component.ts"), exports);
  6581. __exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-slider/constants.ts"), exports);
  6582. __exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-slider/foundation.ts"), exports);
  6583. __exportStar(__webpack_require__(/*! ./types */ "./packages/mdc-slider/types.ts"), exports);
  6584. /***/ }),
  6585. /***/ "./packages/mdc-slider/types.ts":
  6586. /*!**************************************!*\
  6587. !*** ./packages/mdc-slider/types.ts ***!
  6588. \**************************************/
  6589. /*! no static exports found */
  6590. /***/ (function(module, exports, __webpack_require__) {
  6591. "use strict";
  6592. /**
  6593. * @license
  6594. * Copyright 2020 Google Inc.
  6595. *
  6596. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6597. * of this software and associated documentation files (the "Software"), to deal
  6598. * in the Software without restriction, including without limitation the rights
  6599. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6600. * copies of the Software, and to permit persons to whom the Software is
  6601. * furnished to do so, subject to the following conditions:
  6602. *
  6603. * The above copyright notice and this permission notice shall be included in
  6604. * all copies or substantial portions of the Software.
  6605. *
  6606. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6607. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6608. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6609. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6610. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6611. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6612. * THE SOFTWARE.
  6613. */
  6614. Object.defineProperty(exports, "__esModule", { value: true });
  6615. exports.Thumb = exports.TickMark = void 0;
  6616. /** Tick mark enum, for discrete sliders. */
  6617. var TickMark;
  6618. (function (TickMark) {
  6619. TickMark[TickMark["ACTIVE"] = 0] = "ACTIVE";
  6620. TickMark[TickMark["INACTIVE"] = 1] = "INACTIVE";
  6621. })(TickMark = exports.TickMark || (exports.TickMark = {}));
  6622. /**
  6623. * Thumb types: range slider has two thumbs (START, END) whereas single point
  6624. * slider only has one thumb (END).
  6625. */
  6626. var Thumb;
  6627. (function (Thumb) {
  6628. // Thumb at start of slider (e.g. in LTR mode, left thumb on range slider).
  6629. Thumb[Thumb["START"] = 1] = "START";
  6630. // Thumb at end of slider (e.g. in LTR mode, right thumb on range slider,
  6631. // or only thumb on single point slider).
  6632. Thumb[Thumb["END"] = 2] = "END";
  6633. })(Thumb = exports.Thumb || (exports.Thumb = {}));
  6634. /***/ })
  6635. /******/ });
  6636. });
  6637. //# sourceMappingURL=mdc.slider.js.map