Front end of the Slack clone application.

compiler.js 1.2MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264
  1. /**
  2. * @license Angular v5.2.11
  3. * (c) 2010-2018 Google, Inc. https://angular.io/
  4. * License: MIT
  5. */
  6. import { __assign, __extends } from 'tslib';
  7. /**
  8. * @fileoverview added by tsickle
  9. * @suppress {checkTypes} checked by tsc
  10. */
  11. /**
  12. * @license
  13. * Copyright Google Inc. All Rights Reserved.
  14. *
  15. * Use of this source code is governed by an MIT-style license that can be
  16. * found in the LICENSE file at https://angular.io/license
  17. */
  18. // Attention:
  19. // This file duplicates types and values from @angular/core
  20. // so that we are able to make @angular/compiler independent of @angular/core.
  21. // This is important to prevent a build cycle, as @angular/core needs to
  22. // be compiled with the compiler.
  23. /**
  24. * @record
  25. */
  26. function Inject() { }
  27. var createInject = makeMetadataFactory('Inject', function (token) { return ({ token: token }); });
  28. var createInjectionToken = makeMetadataFactory('InjectionToken', function (desc) { return ({ _desc: desc }); });
  29. /**
  30. * @record
  31. */
  32. function Attribute() { }
  33. var createAttribute = makeMetadataFactory('Attribute', function (attributeName) { return ({ attributeName: attributeName }); });
  34. /**
  35. * @record
  36. */
  37. function Query() { }
  38. var createContentChildren = makeMetadataFactory('ContentChildren', function (selector, data) {
  39. if (data === void 0) { data = {}; }
  40. return (__assign({ selector: selector, first: false, isViewQuery: false, descendants: false }, data));
  41. });
  42. var createContentChild = makeMetadataFactory('ContentChild', function (selector, data) {
  43. if (data === void 0) { data = {}; }
  44. return (__assign({ selector: selector, first: true, isViewQuery: false, descendants: true }, data));
  45. });
  46. var createViewChildren = makeMetadataFactory('ViewChildren', function (selector, data) {
  47. if (data === void 0) { data = {}; }
  48. return (__assign({ selector: selector, first: false, isViewQuery: true, descendants: true }, data));
  49. });
  50. var createViewChild = makeMetadataFactory('ViewChild', function (selector, data) {
  51. return (__assign({ selector: selector, first: true, isViewQuery: true, descendants: true }, data));
  52. });
  53. /**
  54. * @record
  55. */
  56. function Directive() { }
  57. var createDirective = makeMetadataFactory('Directive', function (dir) {
  58. if (dir === void 0) { dir = {}; }
  59. return dir;
  60. });
  61. /**
  62. * @record
  63. */
  64. function Component() { }
  65. /** @enum {number} */
  66. var ViewEncapsulation = {
  67. Emulated: 0,
  68. Native: 1,
  69. None: 2,
  70. };
  71. ViewEncapsulation[ViewEncapsulation.Emulated] = "Emulated";
  72. ViewEncapsulation[ViewEncapsulation.Native] = "Native";
  73. ViewEncapsulation[ViewEncapsulation.None] = "None";
  74. /** @enum {number} */
  75. var ChangeDetectionStrategy = {
  76. OnPush: 0,
  77. Default: 1,
  78. };
  79. ChangeDetectionStrategy[ChangeDetectionStrategy.OnPush] = "OnPush";
  80. ChangeDetectionStrategy[ChangeDetectionStrategy.Default] = "Default";
  81. var createComponent = makeMetadataFactory('Component', function (c) {
  82. if (c === void 0) { c = {}; }
  83. return (__assign({ changeDetection: ChangeDetectionStrategy.Default }, c));
  84. });
  85. /**
  86. * @record
  87. */
  88. function Pipe() { }
  89. var createPipe = makeMetadataFactory('Pipe', function (p) { return (__assign({ pure: true }, p)); });
  90. /**
  91. * @record
  92. */
  93. function Input() { }
  94. var createInput = makeMetadataFactory('Input', function (bindingPropertyName) { return ({ bindingPropertyName: bindingPropertyName }); });
  95. /**
  96. * @record
  97. */
  98. function Output() { }
  99. var createOutput = makeMetadataFactory('Output', function (bindingPropertyName) { return ({ bindingPropertyName: bindingPropertyName }); });
  100. /**
  101. * @record
  102. */
  103. function HostBinding() { }
  104. var createHostBinding = makeMetadataFactory('HostBinding', function (hostPropertyName) { return ({ hostPropertyName: hostPropertyName }); });
  105. /**
  106. * @record
  107. */
  108. function HostListener() { }
  109. var createHostListener = makeMetadataFactory('HostListener', function (eventName, args) { return ({ eventName: eventName, args: args }); });
  110. /**
  111. * @record
  112. */
  113. function NgModule() { }
  114. var createNgModule = makeMetadataFactory('NgModule', function (ngModule) { return ngModule; });
  115. /**
  116. * @record
  117. */
  118. function ModuleWithProviders() { }
  119. /**
  120. * @record
  121. */
  122. function SchemaMetadata() { }
  123. var CUSTOM_ELEMENTS_SCHEMA = {
  124. name: 'custom-elements'
  125. };
  126. var NO_ERRORS_SCHEMA = {
  127. name: 'no-errors-schema'
  128. };
  129. var createOptional = makeMetadataFactory('Optional');
  130. var createInjectable = makeMetadataFactory('Injectable');
  131. var createSelf = makeMetadataFactory('Self');
  132. var createSkipSelf = makeMetadataFactory('SkipSelf');
  133. var createHost = makeMetadataFactory('Host');
  134. var Type = Function;
  135. /** @enum {number} */
  136. var SecurityContext = {
  137. NONE: 0,
  138. HTML: 1,
  139. STYLE: 2,
  140. SCRIPT: 3,
  141. URL: 4,
  142. RESOURCE_URL: 5,
  143. };
  144. SecurityContext[SecurityContext.NONE] = "NONE";
  145. SecurityContext[SecurityContext.HTML] = "HTML";
  146. SecurityContext[SecurityContext.STYLE] = "STYLE";
  147. SecurityContext[SecurityContext.SCRIPT] = "SCRIPT";
  148. SecurityContext[SecurityContext.URL] = "URL";
  149. SecurityContext[SecurityContext.RESOURCE_URL] = "RESOURCE_URL";
  150. /** @enum {number} */
  151. var NodeFlags = {
  152. None: 0,
  153. TypeElement: 1,
  154. TypeText: 2,
  155. ProjectedTemplate: 4,
  156. CatRenderNode: 3,
  157. TypeNgContent: 8,
  158. TypePipe: 16,
  159. TypePureArray: 32,
  160. TypePureObject: 64,
  161. TypePurePipe: 128,
  162. CatPureExpression: 224,
  163. TypeValueProvider: 256,
  164. TypeClassProvider: 512,
  165. TypeFactoryProvider: 1024,
  166. TypeUseExistingProvider: 2048,
  167. LazyProvider: 4096,
  168. PrivateProvider: 8192,
  169. TypeDirective: 16384,
  170. Component: 32768,
  171. CatProviderNoDirective: 3840,
  172. CatProvider: 20224,
  173. OnInit: 65536,
  174. OnDestroy: 131072,
  175. DoCheck: 262144,
  176. OnChanges: 524288,
  177. AfterContentInit: 1048576,
  178. AfterContentChecked: 2097152,
  179. AfterViewInit: 4194304,
  180. AfterViewChecked: 8388608,
  181. EmbeddedViews: 16777216,
  182. ComponentView: 33554432,
  183. TypeContentQuery: 67108864,
  184. TypeViewQuery: 134217728,
  185. StaticQuery: 268435456,
  186. DynamicQuery: 536870912,
  187. CatQuery: 201326592,
  188. // mutually exclusive values...
  189. Types: 201347067,
  190. };
  191. /** @enum {number} */
  192. var DepFlags = {
  193. None: 0,
  194. SkipSelf: 1,
  195. Optional: 2,
  196. Value: 8,
  197. };
  198. /** @enum {number} */
  199. var ArgumentType = { Inline: 0, Dynamic: 1, };
  200. /** @enum {number} */
  201. var BindingFlags = {
  202. TypeElementAttribute: 1,
  203. TypeElementClass: 2,
  204. TypeElementStyle: 4,
  205. TypeProperty: 8,
  206. SyntheticProperty: 16,
  207. SyntheticHostProperty: 32,
  208. CatSyntheticProperty: 48,
  209. // mutually exclusive values...
  210. Types: 15,
  211. };
  212. /** @enum {number} */
  213. var QueryBindingType = { First: 0, All: 1, };
  214. /** @enum {number} */
  215. var QueryValueType = {
  216. ElementRef: 0,
  217. RenderElement: 1,
  218. TemplateRef: 2,
  219. ViewContainerRef: 3,
  220. Provider: 4,
  221. };
  222. /** @enum {number} */
  223. var ViewFlags = {
  224. None: 0,
  225. OnPush: 2,
  226. };
  227. /** @enum {number} */
  228. var MissingTranslationStrategy = {
  229. Error: 0,
  230. Warning: 1,
  231. Ignore: 2,
  232. };
  233. MissingTranslationStrategy[MissingTranslationStrategy.Error] = "Error";
  234. MissingTranslationStrategy[MissingTranslationStrategy.Warning] = "Warning";
  235. MissingTranslationStrategy[MissingTranslationStrategy.Ignore] = "Ignore";
  236. /**
  237. * @record
  238. * @template T
  239. */
  240. function MetadataFactory() { }
  241. /**
  242. * @template T
  243. * @param {?} name
  244. * @param {?=} props
  245. * @return {?}
  246. */
  247. function makeMetadataFactory(name, props) {
  248. var /** @type {?} */ factory = function () {
  249. var args = [];
  250. for (var _i = 0; _i < arguments.length; _i++) {
  251. args[_i] = arguments[_i];
  252. }
  253. var /** @type {?} */ values = props ? props.apply(void 0, args) : {};
  254. return __assign({ ngMetadataName: name }, values);
  255. };
  256. factory.isTypeOf = function (obj) { return obj && obj.ngMetadataName === name; };
  257. factory.ngMetadataName = name;
  258. return factory;
  259. }
  260. /**
  261. * @record
  262. */
  263. function Route() { }
  264. var core = Object.freeze({
  265. Inject: Inject,
  266. createInject: createInject,
  267. createInjectionToken: createInjectionToken,
  268. Attribute: Attribute,
  269. createAttribute: createAttribute,
  270. Query: Query,
  271. createContentChildren: createContentChildren,
  272. createContentChild: createContentChild,
  273. createViewChildren: createViewChildren,
  274. createViewChild: createViewChild,
  275. Directive: Directive,
  276. createDirective: createDirective,
  277. Component: Component,
  278. ViewEncapsulation: ViewEncapsulation,
  279. ChangeDetectionStrategy: ChangeDetectionStrategy,
  280. createComponent: createComponent,
  281. Pipe: Pipe,
  282. createPipe: createPipe,
  283. Input: Input,
  284. createInput: createInput,
  285. Output: Output,
  286. createOutput: createOutput,
  287. HostBinding: HostBinding,
  288. createHostBinding: createHostBinding,
  289. HostListener: HostListener,
  290. createHostListener: createHostListener,
  291. NgModule: NgModule,
  292. createNgModule: createNgModule,
  293. ModuleWithProviders: ModuleWithProviders,
  294. SchemaMetadata: SchemaMetadata,
  295. CUSTOM_ELEMENTS_SCHEMA: CUSTOM_ELEMENTS_SCHEMA,
  296. NO_ERRORS_SCHEMA: NO_ERRORS_SCHEMA,
  297. createOptional: createOptional,
  298. createInjectable: createInjectable,
  299. createSelf: createSelf,
  300. createSkipSelf: createSkipSelf,
  301. createHost: createHost,
  302. Type: Type,
  303. SecurityContext: SecurityContext,
  304. NodeFlags: NodeFlags,
  305. DepFlags: DepFlags,
  306. ArgumentType: ArgumentType,
  307. BindingFlags: BindingFlags,
  308. QueryBindingType: QueryBindingType,
  309. QueryValueType: QueryValueType,
  310. ViewFlags: ViewFlags,
  311. MissingTranslationStrategy: MissingTranslationStrategy,
  312. MetadataFactory: MetadataFactory,
  313. Route: Route
  314. });
  315. /**
  316. * @fileoverview added by tsickle
  317. * @suppress {checkTypes} checked by tsc
  318. */
  319. /**
  320. * @license
  321. * Copyright Google Inc. All Rights Reserved.
  322. *
  323. * Use of this source code is governed by an MIT-style license that can be
  324. * found in the LICENSE file at https://angular.io/license
  325. */
  326. var DASH_CASE_REGEXP = /-+([a-z0-9])/g;
  327. /**
  328. * @param {?} input
  329. * @return {?}
  330. */
  331. function dashCaseToCamelCase(input) {
  332. return input.replace(DASH_CASE_REGEXP, function () {
  333. var m = [];
  334. for (var _i = 0; _i < arguments.length; _i++) {
  335. m[_i] = arguments[_i];
  336. }
  337. return m[1].toUpperCase();
  338. });
  339. }
  340. /**
  341. * @param {?} input
  342. * @param {?} defaultValues
  343. * @return {?}
  344. */
  345. function splitAtColon(input, defaultValues) {
  346. return _splitAt(input, ':', defaultValues);
  347. }
  348. /**
  349. * @param {?} input
  350. * @param {?} defaultValues
  351. * @return {?}
  352. */
  353. function splitAtPeriod(input, defaultValues) {
  354. return _splitAt(input, '.', defaultValues);
  355. }
  356. /**
  357. * @param {?} input
  358. * @param {?} character
  359. * @param {?} defaultValues
  360. * @return {?}
  361. */
  362. function _splitAt(input, character, defaultValues) {
  363. var /** @type {?} */ characterIndex = input.indexOf(character);
  364. if (characterIndex == -1)
  365. return defaultValues;
  366. return [input.slice(0, characterIndex).trim(), input.slice(characterIndex + 1).trim()];
  367. }
  368. /**
  369. * @param {?} value
  370. * @param {?} visitor
  371. * @param {?} context
  372. * @return {?}
  373. */
  374. function visitValue(value, visitor, context) {
  375. if (Array.isArray(value)) {
  376. return visitor.visitArray(/** @type {?} */ (value), context);
  377. }
  378. if (isStrictStringMap(value)) {
  379. return visitor.visitStringMap(/** @type {?} */ (value), context);
  380. }
  381. if (value == null || typeof value == 'string' || typeof value == 'number' ||
  382. typeof value == 'boolean') {
  383. return visitor.visitPrimitive(value, context);
  384. }
  385. return visitor.visitOther(value, context);
  386. }
  387. /**
  388. * @param {?} val
  389. * @return {?}
  390. */
  391. function isDefined(val) {
  392. return val !== null && val !== undefined;
  393. }
  394. /**
  395. * @template T
  396. * @param {?} val
  397. * @return {?}
  398. */
  399. function noUndefined(val) {
  400. return val === undefined ? /** @type {?} */ ((null)) : val;
  401. }
  402. /**
  403. * @record
  404. */
  405. var ValueTransformer = /** @class */ (function () {
  406. function ValueTransformer() {
  407. }
  408. /**
  409. * @param {?} arr
  410. * @param {?} context
  411. * @return {?}
  412. */
  413. ValueTransformer.prototype.visitArray = /**
  414. * @param {?} arr
  415. * @param {?} context
  416. * @return {?}
  417. */
  418. function (arr, context) {
  419. var _this = this;
  420. return arr.map(function (value) { return visitValue(value, _this, context); });
  421. };
  422. /**
  423. * @param {?} map
  424. * @param {?} context
  425. * @return {?}
  426. */
  427. ValueTransformer.prototype.visitStringMap = /**
  428. * @param {?} map
  429. * @param {?} context
  430. * @return {?}
  431. */
  432. function (map, context) {
  433. var _this = this;
  434. var /** @type {?} */ result = {};
  435. Object.keys(map).forEach(function (key) { result[key] = visitValue(map[key], _this, context); });
  436. return result;
  437. };
  438. /**
  439. * @param {?} value
  440. * @param {?} context
  441. * @return {?}
  442. */
  443. ValueTransformer.prototype.visitPrimitive = /**
  444. * @param {?} value
  445. * @param {?} context
  446. * @return {?}
  447. */
  448. function (value, context) { return value; };
  449. /**
  450. * @param {?} value
  451. * @param {?} context
  452. * @return {?}
  453. */
  454. ValueTransformer.prototype.visitOther = /**
  455. * @param {?} value
  456. * @param {?} context
  457. * @return {?}
  458. */
  459. function (value, context) { return value; };
  460. return ValueTransformer;
  461. }());
  462. var SyncAsync = {
  463. assertSync: function (value) {
  464. if (isPromise(value)) {
  465. throw new Error("Illegal state: value cannot be a promise");
  466. }
  467. return value;
  468. },
  469. then: function (value, cb) { return isPromise(value) ? value.then(cb) : cb(value); },
  470. all: function (syncAsyncValues) {
  471. return syncAsyncValues.some(isPromise) ? Promise.all(syncAsyncValues) : /** @type {?} */ (syncAsyncValues);
  472. }
  473. };
  474. /**
  475. * @param {?} msg
  476. * @param {?=} parseErrors
  477. * @return {?}
  478. */
  479. function syntaxError(msg, parseErrors) {
  480. var /** @type {?} */ error = Error(msg);
  481. (/** @type {?} */ (error))[ERROR_SYNTAX_ERROR] = true;
  482. if (parseErrors)
  483. (/** @type {?} */ (error))[ERROR_PARSE_ERRORS] = parseErrors;
  484. return error;
  485. }
  486. var ERROR_SYNTAX_ERROR = 'ngSyntaxError';
  487. var ERROR_PARSE_ERRORS = 'ngParseErrors';
  488. /**
  489. * @param {?} error
  490. * @return {?}
  491. */
  492. function isSyntaxError(error) {
  493. return (/** @type {?} */ (error))[ERROR_SYNTAX_ERROR];
  494. }
  495. /**
  496. * @param {?} error
  497. * @return {?}
  498. */
  499. function getParseErrors(error) {
  500. return (/** @type {?} */ (error))[ERROR_PARSE_ERRORS] || [];
  501. }
  502. /**
  503. * @param {?} s
  504. * @return {?}
  505. */
  506. function escapeRegExp(s) {
  507. return s.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
  508. }
  509. var STRING_MAP_PROTO = Object.getPrototypeOf({});
  510. /**
  511. * @param {?} obj
  512. * @return {?}
  513. */
  514. function isStrictStringMap(obj) {
  515. return typeof obj === 'object' && obj !== null && Object.getPrototypeOf(obj) === STRING_MAP_PROTO;
  516. }
  517. /**
  518. * @param {?} str
  519. * @return {?}
  520. */
  521. function utf8Encode(str) {
  522. var /** @type {?} */ encoded = '';
  523. for (var /** @type {?} */ index = 0; index < str.length; index++) {
  524. var /** @type {?} */ codePoint = str.charCodeAt(index);
  525. // decode surrogate
  526. // see https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  527. if (codePoint >= 0xd800 && codePoint <= 0xdbff && str.length > (index + 1)) {
  528. var /** @type {?} */ low = str.charCodeAt(index + 1);
  529. if (low >= 0xdc00 && low <= 0xdfff) {
  530. index++;
  531. codePoint = ((codePoint - 0xd800) << 10) + low - 0xdc00 + 0x10000;
  532. }
  533. }
  534. if (codePoint <= 0x7f) {
  535. encoded += String.fromCharCode(codePoint);
  536. }
  537. else if (codePoint <= 0x7ff) {
  538. encoded += String.fromCharCode(((codePoint >> 6) & 0x1F) | 0xc0, (codePoint & 0x3f) | 0x80);
  539. }
  540. else if (codePoint <= 0xffff) {
  541. encoded += String.fromCharCode((codePoint >> 12) | 0xe0, ((codePoint >> 6) & 0x3f) | 0x80, (codePoint & 0x3f) | 0x80);
  542. }
  543. else if (codePoint <= 0x1fffff) {
  544. encoded += String.fromCharCode(((codePoint >> 18) & 0x07) | 0xf0, ((codePoint >> 12) & 0x3f) | 0x80, ((codePoint >> 6) & 0x3f) | 0x80, (codePoint & 0x3f) | 0x80);
  545. }
  546. }
  547. return encoded;
  548. }
  549. /**
  550. * @record
  551. */
  552. /**
  553. * @param {?} token
  554. * @return {?}
  555. */
  556. function stringify(token) {
  557. if (typeof token === 'string') {
  558. return token;
  559. }
  560. if (token instanceof Array) {
  561. return '[' + token.map(stringify).join(', ') + ']';
  562. }
  563. if (token == null) {
  564. return '' + token;
  565. }
  566. if (token.overriddenName) {
  567. return "" + token.overriddenName;
  568. }
  569. if (token.name) {
  570. return "" + token.name;
  571. }
  572. var /** @type {?} */ res = token.toString();
  573. if (res == null) {
  574. return '' + res;
  575. }
  576. var /** @type {?} */ newLineIndex = res.indexOf('\n');
  577. return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
  578. }
  579. /**
  580. * Lazily retrieves the reference value from a forwardRef.
  581. * @param {?} type
  582. * @return {?}
  583. */
  584. function resolveForwardRef(type) {
  585. if (typeof type === 'function' && type.hasOwnProperty('__forward_ref__')) {
  586. return type();
  587. }
  588. else {
  589. return type;
  590. }
  591. }
  592. /**
  593. * Determine if the argument is shaped like a Promise
  594. * @param {?} obj
  595. * @return {?}
  596. */
  597. function isPromise(obj) {
  598. // allow any Promise/A+ compliant thenable.
  599. // It's up to the caller to ensure that obj.then conforms to the spec
  600. return !!obj && typeof obj.then === 'function';
  601. }
  602. var Version = /** @class */ (function () {
  603. function Version(full) {
  604. this.full = full;
  605. var /** @type {?} */ splits = full.split('.');
  606. this.major = splits[0];
  607. this.minor = splits[1];
  608. this.patch = splits.slice(2).join('.');
  609. }
  610. return Version;
  611. }());
  612. /**
  613. * @record
  614. */
  615. /**
  616. * @fileoverview added by tsickle
  617. * @suppress {checkTypes} checked by tsc
  618. */
  619. /**
  620. * @license
  621. * Copyright Google Inc. All Rights Reserved.
  622. *
  623. * Use of this source code is governed by an MIT-style license that can be
  624. * found in the LICENSE file at https://angular.io/license
  625. */
  626. /**
  627. * \@stable
  628. */
  629. var VERSION = new Version('5.2.11');
  630. /**
  631. * @fileoverview added by tsickle
  632. * @suppress {checkTypes} checked by tsc
  633. */
  634. /**
  635. * @license
  636. * Copyright Google Inc. All Rights Reserved.
  637. *
  638. * Use of this source code is governed by an MIT-style license that can be
  639. * found in the LICENSE file at https://angular.io/license
  640. */
  641. /**
  642. * An Abstract Syntax Tree node representing part of a parsed Angular template.
  643. * @record
  644. */
  645. /**
  646. * A segment of text within the template.
  647. */
  648. var TextAst = /** @class */ (function () {
  649. function TextAst(value, ngContentIndex, sourceSpan) {
  650. this.value = value;
  651. this.ngContentIndex = ngContentIndex;
  652. this.sourceSpan = sourceSpan;
  653. }
  654. /**
  655. * @param {?} visitor
  656. * @param {?} context
  657. * @return {?}
  658. */
  659. TextAst.prototype.visit = /**
  660. * @param {?} visitor
  661. * @param {?} context
  662. * @return {?}
  663. */
  664. function (visitor, context) { return visitor.visitText(this, context); };
  665. return TextAst;
  666. }());
  667. /**
  668. * A bound expression within the text of a template.
  669. */
  670. var BoundTextAst = /** @class */ (function () {
  671. function BoundTextAst(value, ngContentIndex, sourceSpan) {
  672. this.value = value;
  673. this.ngContentIndex = ngContentIndex;
  674. this.sourceSpan = sourceSpan;
  675. }
  676. /**
  677. * @param {?} visitor
  678. * @param {?} context
  679. * @return {?}
  680. */
  681. BoundTextAst.prototype.visit = /**
  682. * @param {?} visitor
  683. * @param {?} context
  684. * @return {?}
  685. */
  686. function (visitor, context) {
  687. return visitor.visitBoundText(this, context);
  688. };
  689. return BoundTextAst;
  690. }());
  691. /**
  692. * A plain attribute on an element.
  693. */
  694. var AttrAst = /** @class */ (function () {
  695. function AttrAst(name, value, sourceSpan) {
  696. this.name = name;
  697. this.value = value;
  698. this.sourceSpan = sourceSpan;
  699. }
  700. /**
  701. * @param {?} visitor
  702. * @param {?} context
  703. * @return {?}
  704. */
  705. AttrAst.prototype.visit = /**
  706. * @param {?} visitor
  707. * @param {?} context
  708. * @return {?}
  709. */
  710. function (visitor, context) { return visitor.visitAttr(this, context); };
  711. return AttrAst;
  712. }());
  713. /**
  714. * A binding for an element property (e.g. `[property]="expression"`) or an animation trigger (e.g.
  715. * `[\@trigger]="stateExp"`)
  716. */
  717. var BoundElementPropertyAst = /** @class */ (function () {
  718. function BoundElementPropertyAst(name, type, securityContext, value, unit, sourceSpan) {
  719. this.name = name;
  720. this.type = type;
  721. this.securityContext = securityContext;
  722. this.value = value;
  723. this.unit = unit;
  724. this.sourceSpan = sourceSpan;
  725. this.isAnimation = this.type === PropertyBindingType.Animation;
  726. }
  727. /**
  728. * @param {?} visitor
  729. * @param {?} context
  730. * @return {?}
  731. */
  732. BoundElementPropertyAst.prototype.visit = /**
  733. * @param {?} visitor
  734. * @param {?} context
  735. * @return {?}
  736. */
  737. function (visitor, context) {
  738. return visitor.visitElementProperty(this, context);
  739. };
  740. return BoundElementPropertyAst;
  741. }());
  742. /**
  743. * A binding for an element event (e.g. `(event)="handler()"`) or an animation trigger event (e.g.
  744. * `(\@trigger.phase)="callback($event)"`).
  745. */
  746. var BoundEventAst = /** @class */ (function () {
  747. function BoundEventAst(name, target, phase, handler, sourceSpan) {
  748. this.name = name;
  749. this.target = target;
  750. this.phase = phase;
  751. this.handler = handler;
  752. this.sourceSpan = sourceSpan;
  753. this.fullName = BoundEventAst.calcFullName(this.name, this.target, this.phase);
  754. this.isAnimation = !!this.phase;
  755. }
  756. /**
  757. * @param {?} name
  758. * @param {?} target
  759. * @param {?} phase
  760. * @return {?}
  761. */
  762. BoundEventAst.calcFullName = /**
  763. * @param {?} name
  764. * @param {?} target
  765. * @param {?} phase
  766. * @return {?}
  767. */
  768. function (name, target, phase) {
  769. if (target) {
  770. return target + ":" + name;
  771. }
  772. else if (phase) {
  773. return "@" + name + "." + phase;
  774. }
  775. else {
  776. return name;
  777. }
  778. };
  779. /**
  780. * @param {?} visitor
  781. * @param {?} context
  782. * @return {?}
  783. */
  784. BoundEventAst.prototype.visit = /**
  785. * @param {?} visitor
  786. * @param {?} context
  787. * @return {?}
  788. */
  789. function (visitor, context) {
  790. return visitor.visitEvent(this, context);
  791. };
  792. return BoundEventAst;
  793. }());
  794. /**
  795. * A reference declaration on an element (e.g. `let someName="expression"`).
  796. */
  797. var ReferenceAst = /** @class */ (function () {
  798. function ReferenceAst(name, value, sourceSpan) {
  799. this.name = name;
  800. this.value = value;
  801. this.sourceSpan = sourceSpan;
  802. }
  803. /**
  804. * @param {?} visitor
  805. * @param {?} context
  806. * @return {?}
  807. */
  808. ReferenceAst.prototype.visit = /**
  809. * @param {?} visitor
  810. * @param {?} context
  811. * @return {?}
  812. */
  813. function (visitor, context) {
  814. return visitor.visitReference(this, context);
  815. };
  816. return ReferenceAst;
  817. }());
  818. /**
  819. * A variable declaration on a <ng-template> (e.g. `var-someName="someLocalName"`).
  820. */
  821. var VariableAst = /** @class */ (function () {
  822. function VariableAst(name, value, sourceSpan) {
  823. this.name = name;
  824. this.value = value;
  825. this.sourceSpan = sourceSpan;
  826. }
  827. /**
  828. * @param {?} visitor
  829. * @param {?} context
  830. * @return {?}
  831. */
  832. VariableAst.prototype.visit = /**
  833. * @param {?} visitor
  834. * @param {?} context
  835. * @return {?}
  836. */
  837. function (visitor, context) {
  838. return visitor.visitVariable(this, context);
  839. };
  840. return VariableAst;
  841. }());
  842. /**
  843. * An element declaration in a template.
  844. */
  845. var ElementAst = /** @class */ (function () {
  846. function ElementAst(name, attrs, inputs, outputs, references, directives, providers, hasViewContainer, queryMatches, children, ngContentIndex, sourceSpan, endSourceSpan) {
  847. this.name = name;
  848. this.attrs = attrs;
  849. this.inputs = inputs;
  850. this.outputs = outputs;
  851. this.references = references;
  852. this.directives = directives;
  853. this.providers = providers;
  854. this.hasViewContainer = hasViewContainer;
  855. this.queryMatches = queryMatches;
  856. this.children = children;
  857. this.ngContentIndex = ngContentIndex;
  858. this.sourceSpan = sourceSpan;
  859. this.endSourceSpan = endSourceSpan;
  860. }
  861. /**
  862. * @param {?} visitor
  863. * @param {?} context
  864. * @return {?}
  865. */
  866. ElementAst.prototype.visit = /**
  867. * @param {?} visitor
  868. * @param {?} context
  869. * @return {?}
  870. */
  871. function (visitor, context) {
  872. return visitor.visitElement(this, context);
  873. };
  874. return ElementAst;
  875. }());
  876. /**
  877. * A `<ng-template>` element included in an Angular template.
  878. */
  879. var EmbeddedTemplateAst = /** @class */ (function () {
  880. function EmbeddedTemplateAst(attrs, outputs, references, variables, directives, providers, hasViewContainer, queryMatches, children, ngContentIndex, sourceSpan) {
  881. this.attrs = attrs;
  882. this.outputs = outputs;
  883. this.references = references;
  884. this.variables = variables;
  885. this.directives = directives;
  886. this.providers = providers;
  887. this.hasViewContainer = hasViewContainer;
  888. this.queryMatches = queryMatches;
  889. this.children = children;
  890. this.ngContentIndex = ngContentIndex;
  891. this.sourceSpan = sourceSpan;
  892. }
  893. /**
  894. * @param {?} visitor
  895. * @param {?} context
  896. * @return {?}
  897. */
  898. EmbeddedTemplateAst.prototype.visit = /**
  899. * @param {?} visitor
  900. * @param {?} context
  901. * @return {?}
  902. */
  903. function (visitor, context) {
  904. return visitor.visitEmbeddedTemplate(this, context);
  905. };
  906. return EmbeddedTemplateAst;
  907. }());
  908. /**
  909. * A directive property with a bound value (e.g. `*ngIf="condition").
  910. */
  911. var BoundDirectivePropertyAst = /** @class */ (function () {
  912. function BoundDirectivePropertyAst(directiveName, templateName, value, sourceSpan) {
  913. this.directiveName = directiveName;
  914. this.templateName = templateName;
  915. this.value = value;
  916. this.sourceSpan = sourceSpan;
  917. }
  918. /**
  919. * @param {?} visitor
  920. * @param {?} context
  921. * @return {?}
  922. */
  923. BoundDirectivePropertyAst.prototype.visit = /**
  924. * @param {?} visitor
  925. * @param {?} context
  926. * @return {?}
  927. */
  928. function (visitor, context) {
  929. return visitor.visitDirectiveProperty(this, context);
  930. };
  931. return BoundDirectivePropertyAst;
  932. }());
  933. /**
  934. * A directive declared on an element.
  935. */
  936. var DirectiveAst = /** @class */ (function () {
  937. function DirectiveAst(directive, inputs, hostProperties, hostEvents, contentQueryStartId, sourceSpan) {
  938. this.directive = directive;
  939. this.inputs = inputs;
  940. this.hostProperties = hostProperties;
  941. this.hostEvents = hostEvents;
  942. this.contentQueryStartId = contentQueryStartId;
  943. this.sourceSpan = sourceSpan;
  944. }
  945. /**
  946. * @param {?} visitor
  947. * @param {?} context
  948. * @return {?}
  949. */
  950. DirectiveAst.prototype.visit = /**
  951. * @param {?} visitor
  952. * @param {?} context
  953. * @return {?}
  954. */
  955. function (visitor, context) {
  956. return visitor.visitDirective(this, context);
  957. };
  958. return DirectiveAst;
  959. }());
  960. /**
  961. * A provider declared on an element
  962. */
  963. var ProviderAst = /** @class */ (function () {
  964. function ProviderAst(token, multiProvider, eager, providers, providerType, lifecycleHooks, sourceSpan) {
  965. this.token = token;
  966. this.multiProvider = multiProvider;
  967. this.eager = eager;
  968. this.providers = providers;
  969. this.providerType = providerType;
  970. this.lifecycleHooks = lifecycleHooks;
  971. this.sourceSpan = sourceSpan;
  972. }
  973. /**
  974. * @param {?} visitor
  975. * @param {?} context
  976. * @return {?}
  977. */
  978. ProviderAst.prototype.visit = /**
  979. * @param {?} visitor
  980. * @param {?} context
  981. * @return {?}
  982. */
  983. function (visitor, context) {
  984. // No visit method in the visitor for now...
  985. return null;
  986. };
  987. return ProviderAst;
  988. }());
  989. /** @enum {number} */
  990. var ProviderAstType = {
  991. PublicService: 0,
  992. PrivateService: 1,
  993. Component: 2,
  994. Directive: 3,
  995. Builtin: 4,
  996. };
  997. ProviderAstType[ProviderAstType.PublicService] = "PublicService";
  998. ProviderAstType[ProviderAstType.PrivateService] = "PrivateService";
  999. ProviderAstType[ProviderAstType.Component] = "Component";
  1000. ProviderAstType[ProviderAstType.Directive] = "Directive";
  1001. ProviderAstType[ProviderAstType.Builtin] = "Builtin";
  1002. /**
  1003. * Position where content is to be projected (instance of `<ng-content>` in a template).
  1004. */
  1005. var NgContentAst = /** @class */ (function () {
  1006. function NgContentAst(index, ngContentIndex, sourceSpan) {
  1007. this.index = index;
  1008. this.ngContentIndex = ngContentIndex;
  1009. this.sourceSpan = sourceSpan;
  1010. }
  1011. /**
  1012. * @param {?} visitor
  1013. * @param {?} context
  1014. * @return {?}
  1015. */
  1016. NgContentAst.prototype.visit = /**
  1017. * @param {?} visitor
  1018. * @param {?} context
  1019. * @return {?}
  1020. */
  1021. function (visitor, context) {
  1022. return visitor.visitNgContent(this, context);
  1023. };
  1024. return NgContentAst;
  1025. }());
  1026. /** @enum {number} */
  1027. var PropertyBindingType = {
  1028. /**
  1029. * A normal binding to a property (e.g. `[property]="expression"`).
  1030. */
  1031. Property: 0,
  1032. /**
  1033. * A binding to an element attribute (e.g. `[attr.name]="expression"`).
  1034. */
  1035. Attribute: 1,
  1036. /**
  1037. * A binding to a CSS class (e.g. `[class.name]="condition"`).
  1038. */
  1039. Class: 2,
  1040. /**
  1041. * A binding to a style rule (e.g. `[style.rule]="expression"`).
  1042. */
  1043. Style: 3,
  1044. /**
  1045. * A binding to an animation reference (e.g. `[animate.key]="expression"`).
  1046. */
  1047. Animation: 4,
  1048. };
  1049. PropertyBindingType[PropertyBindingType.Property] = "Property";
  1050. PropertyBindingType[PropertyBindingType.Attribute] = "Attribute";
  1051. PropertyBindingType[PropertyBindingType.Class] = "Class";
  1052. PropertyBindingType[PropertyBindingType.Style] = "Style";
  1053. PropertyBindingType[PropertyBindingType.Animation] = "Animation";
  1054. /**
  1055. * @record
  1056. */
  1057. /**
  1058. * A visitor for {\@link TemplateAst} trees that will process each node.
  1059. * @record
  1060. */
  1061. /**
  1062. * A visitor that accepts each node but doesn't do anything. It is intended to be used
  1063. * as the base class for a visitor that is only interested in a subset of the node types.
  1064. */
  1065. var NullTemplateVisitor = /** @class */ (function () {
  1066. function NullTemplateVisitor() {
  1067. }
  1068. /**
  1069. * @param {?} ast
  1070. * @param {?} context
  1071. * @return {?}
  1072. */
  1073. NullTemplateVisitor.prototype.visitNgContent = /**
  1074. * @param {?} ast
  1075. * @param {?} context
  1076. * @return {?}
  1077. */
  1078. function (ast, context) { };
  1079. /**
  1080. * @param {?} ast
  1081. * @param {?} context
  1082. * @return {?}
  1083. */
  1084. NullTemplateVisitor.prototype.visitEmbeddedTemplate = /**
  1085. * @param {?} ast
  1086. * @param {?} context
  1087. * @return {?}
  1088. */
  1089. function (ast, context) { };
  1090. /**
  1091. * @param {?} ast
  1092. * @param {?} context
  1093. * @return {?}
  1094. */
  1095. NullTemplateVisitor.prototype.visitElement = /**
  1096. * @param {?} ast
  1097. * @param {?} context
  1098. * @return {?}
  1099. */
  1100. function (ast, context) { };
  1101. /**
  1102. * @param {?} ast
  1103. * @param {?} context
  1104. * @return {?}
  1105. */
  1106. NullTemplateVisitor.prototype.visitReference = /**
  1107. * @param {?} ast
  1108. * @param {?} context
  1109. * @return {?}
  1110. */
  1111. function (ast, context) { };
  1112. /**
  1113. * @param {?} ast
  1114. * @param {?} context
  1115. * @return {?}
  1116. */
  1117. NullTemplateVisitor.prototype.visitVariable = /**
  1118. * @param {?} ast
  1119. * @param {?} context
  1120. * @return {?}
  1121. */
  1122. function (ast, context) { };
  1123. /**
  1124. * @param {?} ast
  1125. * @param {?} context
  1126. * @return {?}
  1127. */
  1128. NullTemplateVisitor.prototype.visitEvent = /**
  1129. * @param {?} ast
  1130. * @param {?} context
  1131. * @return {?}
  1132. */
  1133. function (ast, context) { };
  1134. /**
  1135. * @param {?} ast
  1136. * @param {?} context
  1137. * @return {?}
  1138. */
  1139. NullTemplateVisitor.prototype.visitElementProperty = /**
  1140. * @param {?} ast
  1141. * @param {?} context
  1142. * @return {?}
  1143. */
  1144. function (ast, context) { };
  1145. /**
  1146. * @param {?} ast
  1147. * @param {?} context
  1148. * @return {?}
  1149. */
  1150. NullTemplateVisitor.prototype.visitAttr = /**
  1151. * @param {?} ast
  1152. * @param {?} context
  1153. * @return {?}
  1154. */
  1155. function (ast, context) { };
  1156. /**
  1157. * @param {?} ast
  1158. * @param {?} context
  1159. * @return {?}
  1160. */
  1161. NullTemplateVisitor.prototype.visitBoundText = /**
  1162. * @param {?} ast
  1163. * @param {?} context
  1164. * @return {?}
  1165. */
  1166. function (ast, context) { };
  1167. /**
  1168. * @param {?} ast
  1169. * @param {?} context
  1170. * @return {?}
  1171. */
  1172. NullTemplateVisitor.prototype.visitText = /**
  1173. * @param {?} ast
  1174. * @param {?} context
  1175. * @return {?}
  1176. */
  1177. function (ast, context) { };
  1178. /**
  1179. * @param {?} ast
  1180. * @param {?} context
  1181. * @return {?}
  1182. */
  1183. NullTemplateVisitor.prototype.visitDirective = /**
  1184. * @param {?} ast
  1185. * @param {?} context
  1186. * @return {?}
  1187. */
  1188. function (ast, context) { };
  1189. /**
  1190. * @param {?} ast
  1191. * @param {?} context
  1192. * @return {?}
  1193. */
  1194. NullTemplateVisitor.prototype.visitDirectiveProperty = /**
  1195. * @param {?} ast
  1196. * @param {?} context
  1197. * @return {?}
  1198. */
  1199. function (ast, context) { };
  1200. return NullTemplateVisitor;
  1201. }());
  1202. /**
  1203. * Base class that can be used to build a visitor that visits each node
  1204. * in an template ast recursively.
  1205. */
  1206. var RecursiveTemplateAstVisitor = /** @class */ (function (_super) {
  1207. __extends(RecursiveTemplateAstVisitor, _super);
  1208. function RecursiveTemplateAstVisitor() {
  1209. return _super.call(this) || this;
  1210. }
  1211. // Nodes with children
  1212. /**
  1213. * @param {?} ast
  1214. * @param {?} context
  1215. * @return {?}
  1216. */
  1217. RecursiveTemplateAstVisitor.prototype.visitEmbeddedTemplate = /**
  1218. * @param {?} ast
  1219. * @param {?} context
  1220. * @return {?}
  1221. */
  1222. function (ast, context) {
  1223. return this.visitChildren(context, function (visit) {
  1224. visit(ast.attrs);
  1225. visit(ast.references);
  1226. visit(ast.variables);
  1227. visit(ast.directives);
  1228. visit(ast.providers);
  1229. visit(ast.children);
  1230. });
  1231. };
  1232. /**
  1233. * @param {?} ast
  1234. * @param {?} context
  1235. * @return {?}
  1236. */
  1237. RecursiveTemplateAstVisitor.prototype.visitElement = /**
  1238. * @param {?} ast
  1239. * @param {?} context
  1240. * @return {?}
  1241. */
  1242. function (ast, context) {
  1243. return this.visitChildren(context, function (visit) {
  1244. visit(ast.attrs);
  1245. visit(ast.inputs);
  1246. visit(ast.outputs);
  1247. visit(ast.references);
  1248. visit(ast.directives);
  1249. visit(ast.providers);
  1250. visit(ast.children);
  1251. });
  1252. };
  1253. /**
  1254. * @param {?} ast
  1255. * @param {?} context
  1256. * @return {?}
  1257. */
  1258. RecursiveTemplateAstVisitor.prototype.visitDirective = /**
  1259. * @param {?} ast
  1260. * @param {?} context
  1261. * @return {?}
  1262. */
  1263. function (ast, context) {
  1264. return this.visitChildren(context, function (visit) {
  1265. visit(ast.inputs);
  1266. visit(ast.hostProperties);
  1267. visit(ast.hostEvents);
  1268. });
  1269. };
  1270. /**
  1271. * @template T
  1272. * @param {?} context
  1273. * @param {?} cb
  1274. * @return {?}
  1275. */
  1276. RecursiveTemplateAstVisitor.prototype.visitChildren = /**
  1277. * @template T
  1278. * @param {?} context
  1279. * @param {?} cb
  1280. * @return {?}
  1281. */
  1282. function (context, cb) {
  1283. var /** @type {?} */ results = [];
  1284. var /** @type {?} */ t = this;
  1285. /**
  1286. * @template T
  1287. * @param {?} children
  1288. * @return {?}
  1289. */
  1290. function visit(children) {
  1291. if (children && children.length)
  1292. results.push(templateVisitAll(t, children, context));
  1293. }
  1294. cb(visit);
  1295. return [].concat.apply([], results);
  1296. };
  1297. return RecursiveTemplateAstVisitor;
  1298. }(NullTemplateVisitor));
  1299. /**
  1300. * Visit every node in a list of {\@link TemplateAst}s with the given {\@link TemplateAstVisitor}.
  1301. * @param {?} visitor
  1302. * @param {?} asts
  1303. * @param {?=} context
  1304. * @return {?}
  1305. */
  1306. function templateVisitAll(visitor, asts, context) {
  1307. if (context === void 0) { context = null; }
  1308. var /** @type {?} */ result = [];
  1309. var /** @type {?} */ visit = visitor.visit ?
  1310. function (ast) { return ((visitor.visit))(ast, context) || ast.visit(visitor, context); } :
  1311. function (ast) { return ast.visit(visitor, context); };
  1312. asts.forEach(function (ast) {
  1313. var /** @type {?} */ astResult = visit(ast);
  1314. if (astResult) {
  1315. result.push(astResult);
  1316. }
  1317. });
  1318. return result;
  1319. }
  1320. /**
  1321. * @fileoverview added by tsickle
  1322. * @suppress {checkTypes} checked by tsc
  1323. */
  1324. /**
  1325. * @license
  1326. * Copyright Google Inc. All Rights Reserved.
  1327. *
  1328. * Use of this source code is governed by an MIT-style license that can be
  1329. * found in the LICENSE file at https://angular.io/license
  1330. */
  1331. var CompilerConfig = /** @class */ (function () {
  1332. function CompilerConfig(_a) {
  1333. var _b = _a === void 0 ? {} : _a, _c = _b.defaultEncapsulation, defaultEncapsulation = _c === void 0 ? ViewEncapsulation.Emulated : _c, _d = _b.useJit, useJit = _d === void 0 ? true : _d, _e = _b.jitDevMode, jitDevMode = _e === void 0 ? false : _e, _f = _b.missingTranslation, missingTranslation = _f === void 0 ? null : _f, enableLegacyTemplate = _b.enableLegacyTemplate, preserveWhitespaces = _b.preserveWhitespaces, strictInjectionParameters = _b.strictInjectionParameters;
  1334. this.defaultEncapsulation = defaultEncapsulation;
  1335. this.useJit = !!useJit;
  1336. this.jitDevMode = !!jitDevMode;
  1337. this.missingTranslation = missingTranslation;
  1338. this.enableLegacyTemplate = enableLegacyTemplate === true;
  1339. this.preserveWhitespaces = preserveWhitespacesDefault(noUndefined(preserveWhitespaces));
  1340. this.strictInjectionParameters = strictInjectionParameters === true;
  1341. }
  1342. return CompilerConfig;
  1343. }());
  1344. /**
  1345. * @param {?} preserveWhitespacesOption
  1346. * @param {?=} defaultSetting
  1347. * @return {?}
  1348. */
  1349. function preserveWhitespacesDefault(preserveWhitespacesOption, defaultSetting) {
  1350. if (defaultSetting === void 0) { defaultSetting = true; }
  1351. return preserveWhitespacesOption === null ? defaultSetting : preserveWhitespacesOption;
  1352. }
  1353. /**
  1354. * @fileoverview added by tsickle
  1355. * @suppress {checkTypes} checked by tsc
  1356. */
  1357. /**
  1358. * @license
  1359. * Copyright Google Inc. All Rights Reserved.
  1360. *
  1361. * Use of this source code is governed by an MIT-style license that can be
  1362. * found in the LICENSE file at https://angular.io/license
  1363. */
  1364. /**
  1365. * A token representing the a reference to a static type.
  1366. *
  1367. * This token is unique for a filePath and name and can be used as a hash table key.
  1368. */
  1369. var StaticSymbol = /** @class */ (function () {
  1370. function StaticSymbol(filePath, name, members) {
  1371. this.filePath = filePath;
  1372. this.name = name;
  1373. this.members = members;
  1374. }
  1375. /**
  1376. * @return {?}
  1377. */
  1378. StaticSymbol.prototype.assertNoMembers = /**
  1379. * @return {?}
  1380. */
  1381. function () {
  1382. if (this.members.length) {
  1383. throw new Error("Illegal state: symbol without members expected, but got " + JSON.stringify(this) + ".");
  1384. }
  1385. };
  1386. return StaticSymbol;
  1387. }());
  1388. /**
  1389. * A cache of static symbol used by the StaticReflector to return the same symbol for the
  1390. * same symbol values.
  1391. */
  1392. var StaticSymbolCache = /** @class */ (function () {
  1393. function StaticSymbolCache() {
  1394. this.cache = new Map();
  1395. }
  1396. /**
  1397. * @param {?} declarationFile
  1398. * @param {?} name
  1399. * @param {?=} members
  1400. * @return {?}
  1401. */
  1402. StaticSymbolCache.prototype.get = /**
  1403. * @param {?} declarationFile
  1404. * @param {?} name
  1405. * @param {?=} members
  1406. * @return {?}
  1407. */
  1408. function (declarationFile, name, members) {
  1409. members = members || [];
  1410. var /** @type {?} */ memberSuffix = members.length ? "." + members.join('.') : '';
  1411. var /** @type {?} */ key = "\"" + declarationFile + "\"." + name + memberSuffix;
  1412. var /** @type {?} */ result = this.cache.get(key);
  1413. if (!result) {
  1414. result = new StaticSymbol(declarationFile, name, members);
  1415. this.cache.set(key, result);
  1416. }
  1417. return result;
  1418. };
  1419. return StaticSymbolCache;
  1420. }());
  1421. /**
  1422. * @fileoverview added by tsickle
  1423. * @suppress {checkTypes} checked by tsc
  1424. */
  1425. /**
  1426. * @license
  1427. * Copyright Google Inc. All Rights Reserved.
  1428. *
  1429. * Use of this source code is governed by an MIT-style license that can be
  1430. * found in the LICENSE file at https://angular.io/license
  1431. */
  1432. // group 0: "[prop] or (event) or @trigger"
  1433. // group 1: "prop" from "[prop]"
  1434. // group 2: "event" from "(event)"
  1435. // group 3: "@trigger" from "@trigger"
  1436. var HOST_REG_EXP = /^(?:(?:\[([^\]]+)\])|(?:\(([^\)]+)\)))|(\@[-\w]+)$/;
  1437. /**
  1438. * @param {?} name
  1439. * @return {?}
  1440. */
  1441. function _sanitizeIdentifier(name) {
  1442. return name.replace(/\W/g, '_');
  1443. }
  1444. var _anonymousTypeIndex = 0;
  1445. /**
  1446. * @param {?} compileIdentifier
  1447. * @return {?}
  1448. */
  1449. function identifierName(compileIdentifier) {
  1450. if (!compileIdentifier || !compileIdentifier.reference) {
  1451. return null;
  1452. }
  1453. var /** @type {?} */ ref = compileIdentifier.reference;
  1454. if (ref instanceof StaticSymbol) {
  1455. return ref.name;
  1456. }
  1457. if (ref['__anonymousType']) {
  1458. return ref['__anonymousType'];
  1459. }
  1460. var /** @type {?} */ identifier = stringify(ref);
  1461. if (identifier.indexOf('(') >= 0) {
  1462. // case: anonymous functions!
  1463. identifier = "anonymous_" + _anonymousTypeIndex++;
  1464. ref['__anonymousType'] = identifier;
  1465. }
  1466. else {
  1467. identifier = _sanitizeIdentifier(identifier);
  1468. }
  1469. return identifier;
  1470. }
  1471. /**
  1472. * @param {?} compileIdentifier
  1473. * @return {?}
  1474. */
  1475. function identifierModuleUrl(compileIdentifier) {
  1476. var /** @type {?} */ ref = compileIdentifier.reference;
  1477. if (ref instanceof StaticSymbol) {
  1478. return ref.filePath;
  1479. }
  1480. // Runtime type
  1481. return "./" + stringify(ref);
  1482. }
  1483. /**
  1484. * @param {?} compType
  1485. * @param {?} embeddedTemplateIndex
  1486. * @return {?}
  1487. */
  1488. function viewClassName(compType, embeddedTemplateIndex) {
  1489. return "View_" + identifierName({ reference: compType }) + "_" + embeddedTemplateIndex;
  1490. }
  1491. /**
  1492. * @param {?} compType
  1493. * @return {?}
  1494. */
  1495. function rendererTypeName(compType) {
  1496. return "RenderType_" + identifierName({ reference: compType });
  1497. }
  1498. /**
  1499. * @param {?} compType
  1500. * @return {?}
  1501. */
  1502. function hostViewClassName(compType) {
  1503. return "HostView_" + identifierName({ reference: compType });
  1504. }
  1505. /**
  1506. * @param {?} compType
  1507. * @return {?}
  1508. */
  1509. function componentFactoryName(compType) {
  1510. return identifierName({ reference: compType }) + "NgFactory";
  1511. }
  1512. /**
  1513. * @record
  1514. */
  1515. /**
  1516. * @record
  1517. */
  1518. /** @enum {number} */
  1519. var CompileSummaryKind = {
  1520. Pipe: 0,
  1521. Directive: 1,
  1522. NgModule: 2,
  1523. Injectable: 3,
  1524. };
  1525. CompileSummaryKind[CompileSummaryKind.Pipe] = "Pipe";
  1526. CompileSummaryKind[CompileSummaryKind.Directive] = "Directive";
  1527. CompileSummaryKind[CompileSummaryKind.NgModule] = "NgModule";
  1528. CompileSummaryKind[CompileSummaryKind.Injectable] = "Injectable";
  1529. /**
  1530. * A CompileSummary is the data needed to use a directive / pipe / module
  1531. * in other modules / components. However, this data is not enough to compile
  1532. * the directive / module itself.
  1533. * @record
  1534. */
  1535. /**
  1536. * @record
  1537. */
  1538. /**
  1539. * @record
  1540. */
  1541. /**
  1542. * @record
  1543. */
  1544. /**
  1545. * @param {?} token
  1546. * @return {?}
  1547. */
  1548. function tokenName(token) {
  1549. return token.value != null ? _sanitizeIdentifier(token.value) : identifierName(token.identifier);
  1550. }
  1551. /**
  1552. * @param {?} token
  1553. * @return {?}
  1554. */
  1555. function tokenReference(token) {
  1556. if (token.identifier != null) {
  1557. return token.identifier.reference;
  1558. }
  1559. else {
  1560. return token.value;
  1561. }
  1562. }
  1563. /**
  1564. * @record
  1565. */
  1566. /**
  1567. * Metadata regarding compilation of a type.
  1568. * @record
  1569. */
  1570. /**
  1571. * @record
  1572. */
  1573. /**
  1574. * Metadata about a stylesheet
  1575. */
  1576. var CompileStylesheetMetadata = /** @class */ (function () {
  1577. function CompileStylesheetMetadata(_a) {
  1578. var _b = _a === void 0 ? {} : _a, moduleUrl = _b.moduleUrl, styles = _b.styles, styleUrls = _b.styleUrls;
  1579. this.moduleUrl = moduleUrl || null;
  1580. this.styles = _normalizeArray(styles);
  1581. this.styleUrls = _normalizeArray(styleUrls);
  1582. }
  1583. return CompileStylesheetMetadata;
  1584. }());
  1585. /**
  1586. * Summary Metadata regarding compilation of a template.
  1587. * @record
  1588. */
  1589. /**
  1590. * Metadata regarding compilation of a template.
  1591. */
  1592. var CompileTemplateMetadata = /** @class */ (function () {
  1593. function CompileTemplateMetadata(_a) {
  1594. var encapsulation = _a.encapsulation, template = _a.template, templateUrl = _a.templateUrl, htmlAst = _a.htmlAst, styles = _a.styles, styleUrls = _a.styleUrls, externalStylesheets = _a.externalStylesheets, animations = _a.animations, ngContentSelectors = _a.ngContentSelectors, interpolation = _a.interpolation, isInline = _a.isInline, preserveWhitespaces = _a.preserveWhitespaces;
  1595. this.encapsulation = encapsulation;
  1596. this.template = template;
  1597. this.templateUrl = templateUrl;
  1598. this.htmlAst = htmlAst;
  1599. this.styles = _normalizeArray(styles);
  1600. this.styleUrls = _normalizeArray(styleUrls);
  1601. this.externalStylesheets = _normalizeArray(externalStylesheets);
  1602. this.animations = animations ? flatten(animations) : [];
  1603. this.ngContentSelectors = ngContentSelectors || [];
  1604. if (interpolation && interpolation.length != 2) {
  1605. throw new Error("'interpolation' should have a start and an end symbol.");
  1606. }
  1607. this.interpolation = interpolation;
  1608. this.isInline = isInline;
  1609. this.preserveWhitespaces = preserveWhitespaces;
  1610. }
  1611. /**
  1612. * @return {?}
  1613. */
  1614. CompileTemplateMetadata.prototype.toSummary = /**
  1615. * @return {?}
  1616. */
  1617. function () {
  1618. return {
  1619. ngContentSelectors: this.ngContentSelectors,
  1620. encapsulation: this.encapsulation,
  1621. };
  1622. };
  1623. return CompileTemplateMetadata;
  1624. }());
  1625. /**
  1626. * @record
  1627. */
  1628. /**
  1629. * @record
  1630. */
  1631. /**
  1632. * Metadata regarding compilation of a directive.
  1633. */
  1634. var CompileDirectiveMetadata = /** @class */ (function () {
  1635. function CompileDirectiveMetadata(_a) {
  1636. var isHost = _a.isHost, type = _a.type, isComponent = _a.isComponent, selector = _a.selector, exportAs = _a.exportAs, changeDetection = _a.changeDetection, inputs = _a.inputs, outputs = _a.outputs, hostListeners = _a.hostListeners, hostProperties = _a.hostProperties, hostAttributes = _a.hostAttributes, providers = _a.providers, viewProviders = _a.viewProviders, queries = _a.queries, guards = _a.guards, viewQueries = _a.viewQueries, entryComponents = _a.entryComponents, template = _a.template, componentViewType = _a.componentViewType, rendererType = _a.rendererType, componentFactory = _a.componentFactory;
  1637. this.isHost = !!isHost;
  1638. this.type = type;
  1639. this.isComponent = isComponent;
  1640. this.selector = selector;
  1641. this.exportAs = exportAs;
  1642. this.changeDetection = changeDetection;
  1643. this.inputs = inputs;
  1644. this.outputs = outputs;
  1645. this.hostListeners = hostListeners;
  1646. this.hostProperties = hostProperties;
  1647. this.hostAttributes = hostAttributes;
  1648. this.providers = _normalizeArray(providers);
  1649. this.viewProviders = _normalizeArray(viewProviders);
  1650. this.queries = _normalizeArray(queries);
  1651. this.guards = guards;
  1652. this.viewQueries = _normalizeArray(viewQueries);
  1653. this.entryComponents = _normalizeArray(entryComponents);
  1654. this.template = template;
  1655. this.componentViewType = componentViewType;
  1656. this.rendererType = rendererType;
  1657. this.componentFactory = componentFactory;
  1658. }
  1659. /**
  1660. * @param {?} __0
  1661. * @return {?}
  1662. */
  1663. CompileDirectiveMetadata.create = /**
  1664. * @param {?} __0
  1665. * @return {?}
  1666. */
  1667. function (_a) {
  1668. var isHost = _a.isHost, type = _a.type, isComponent = _a.isComponent, selector = _a.selector, exportAs = _a.exportAs, changeDetection = _a.changeDetection, inputs = _a.inputs, outputs = _a.outputs, host = _a.host, providers = _a.providers, viewProviders = _a.viewProviders, queries = _a.queries, guards = _a.guards, viewQueries = _a.viewQueries, entryComponents = _a.entryComponents, template = _a.template, componentViewType = _a.componentViewType, rendererType = _a.rendererType, componentFactory = _a.componentFactory;
  1669. var /** @type {?} */ hostListeners = {};
  1670. var /** @type {?} */ hostProperties = {};
  1671. var /** @type {?} */ hostAttributes = {};
  1672. if (host != null) {
  1673. Object.keys(host).forEach(function (key) {
  1674. var /** @type {?} */ value = host[key];
  1675. var /** @type {?} */ matches = key.match(HOST_REG_EXP);
  1676. if (matches === null) {
  1677. hostAttributes[key] = value;
  1678. }
  1679. else if (matches[1] != null) {
  1680. hostProperties[matches[1]] = value;
  1681. }
  1682. else if (matches[2] != null) {
  1683. hostListeners[matches[2]] = value;
  1684. }
  1685. });
  1686. }
  1687. var /** @type {?} */ inputsMap = {};
  1688. if (inputs != null) {
  1689. inputs.forEach(function (bindConfig) {
  1690. // canonical syntax: `dirProp: elProp`
  1691. // if there is no `:`, use dirProp = elProp
  1692. var /** @type {?} */ parts = splitAtColon(bindConfig, [bindConfig, bindConfig]);
  1693. inputsMap[parts[0]] = parts[1];
  1694. });
  1695. }
  1696. var /** @type {?} */ outputsMap = {};
  1697. if (outputs != null) {
  1698. outputs.forEach(function (bindConfig) {
  1699. // canonical syntax: `dirProp: elProp`
  1700. // if there is no `:`, use dirProp = elProp
  1701. var /** @type {?} */ parts = splitAtColon(bindConfig, [bindConfig, bindConfig]);
  1702. outputsMap[parts[0]] = parts[1];
  1703. });
  1704. }
  1705. return new CompileDirectiveMetadata({
  1706. isHost: isHost,
  1707. type: type,
  1708. isComponent: !!isComponent, selector: selector, exportAs: exportAs, changeDetection: changeDetection,
  1709. inputs: inputsMap,
  1710. outputs: outputsMap,
  1711. hostListeners: hostListeners,
  1712. hostProperties: hostProperties,
  1713. hostAttributes: hostAttributes,
  1714. providers: providers,
  1715. viewProviders: viewProviders,
  1716. queries: queries,
  1717. guards: guards,
  1718. viewQueries: viewQueries,
  1719. entryComponents: entryComponents,
  1720. template: template,
  1721. componentViewType: componentViewType,
  1722. rendererType: rendererType,
  1723. componentFactory: componentFactory,
  1724. });
  1725. };
  1726. /**
  1727. * @return {?}
  1728. */
  1729. CompileDirectiveMetadata.prototype.toSummary = /**
  1730. * @return {?}
  1731. */
  1732. function () {
  1733. return {
  1734. summaryKind: CompileSummaryKind.Directive,
  1735. type: this.type,
  1736. isComponent: this.isComponent,
  1737. selector: this.selector,
  1738. exportAs: this.exportAs,
  1739. inputs: this.inputs,
  1740. outputs: this.outputs,
  1741. hostListeners: this.hostListeners,
  1742. hostProperties: this.hostProperties,
  1743. hostAttributes: this.hostAttributes,
  1744. providers: this.providers,
  1745. viewProviders: this.viewProviders,
  1746. queries: this.queries,
  1747. guards: this.guards,
  1748. viewQueries: this.viewQueries,
  1749. entryComponents: this.entryComponents,
  1750. changeDetection: this.changeDetection,
  1751. template: this.template && this.template.toSummary(),
  1752. componentViewType: this.componentViewType,
  1753. rendererType: this.rendererType,
  1754. componentFactory: this.componentFactory
  1755. };
  1756. };
  1757. return CompileDirectiveMetadata;
  1758. }());
  1759. /**
  1760. * @record
  1761. */
  1762. var CompilePipeMetadata = /** @class */ (function () {
  1763. function CompilePipeMetadata(_a) {
  1764. var type = _a.type, name = _a.name, pure = _a.pure;
  1765. this.type = type;
  1766. this.name = name;
  1767. this.pure = !!pure;
  1768. }
  1769. /**
  1770. * @return {?}
  1771. */
  1772. CompilePipeMetadata.prototype.toSummary = /**
  1773. * @return {?}
  1774. */
  1775. function () {
  1776. return {
  1777. summaryKind: CompileSummaryKind.Pipe,
  1778. type: this.type,
  1779. name: this.name,
  1780. pure: this.pure
  1781. };
  1782. };
  1783. return CompilePipeMetadata;
  1784. }());
  1785. /**
  1786. * @record
  1787. */
  1788. /**
  1789. * Metadata regarding compilation of a module.
  1790. */
  1791. var CompileNgModuleMetadata = /** @class */ (function () {
  1792. function CompileNgModuleMetadata(_a) {
  1793. var type = _a.type, providers = _a.providers, declaredDirectives = _a.declaredDirectives, exportedDirectives = _a.exportedDirectives, declaredPipes = _a.declaredPipes, exportedPipes = _a.exportedPipes, entryComponents = _a.entryComponents, bootstrapComponents = _a.bootstrapComponents, importedModules = _a.importedModules, exportedModules = _a.exportedModules, schemas = _a.schemas, transitiveModule = _a.transitiveModule, id = _a.id;
  1794. this.type = type || null;
  1795. this.declaredDirectives = _normalizeArray(declaredDirectives);
  1796. this.exportedDirectives = _normalizeArray(exportedDirectives);
  1797. this.declaredPipes = _normalizeArray(declaredPipes);
  1798. this.exportedPipes = _normalizeArray(exportedPipes);
  1799. this.providers = _normalizeArray(providers);
  1800. this.entryComponents = _normalizeArray(entryComponents);
  1801. this.bootstrapComponents = _normalizeArray(bootstrapComponents);
  1802. this.importedModules = _normalizeArray(importedModules);
  1803. this.exportedModules = _normalizeArray(exportedModules);
  1804. this.schemas = _normalizeArray(schemas);
  1805. this.id = id || null;
  1806. this.transitiveModule = transitiveModule || null;
  1807. }
  1808. /**
  1809. * @return {?}
  1810. */
  1811. CompileNgModuleMetadata.prototype.toSummary = /**
  1812. * @return {?}
  1813. */
  1814. function () {
  1815. var /** @type {?} */ module = /** @type {?} */ ((this.transitiveModule));
  1816. return {
  1817. summaryKind: CompileSummaryKind.NgModule,
  1818. type: this.type,
  1819. entryComponents: module.entryComponents,
  1820. providers: module.providers,
  1821. modules: module.modules,
  1822. exportedDirectives: module.exportedDirectives,
  1823. exportedPipes: module.exportedPipes
  1824. };
  1825. };
  1826. return CompileNgModuleMetadata;
  1827. }());
  1828. var TransitiveCompileNgModuleMetadata = /** @class */ (function () {
  1829. function TransitiveCompileNgModuleMetadata() {
  1830. this.directivesSet = new Set();
  1831. this.directives = [];
  1832. this.exportedDirectivesSet = new Set();
  1833. this.exportedDirectives = [];
  1834. this.pipesSet = new Set();
  1835. this.pipes = [];
  1836. this.exportedPipesSet = new Set();
  1837. this.exportedPipes = [];
  1838. this.modulesSet = new Set();
  1839. this.modules = [];
  1840. this.entryComponentsSet = new Set();
  1841. this.entryComponents = [];
  1842. this.providers = [];
  1843. }
  1844. /**
  1845. * @param {?} provider
  1846. * @param {?} module
  1847. * @return {?}
  1848. */
  1849. TransitiveCompileNgModuleMetadata.prototype.addProvider = /**
  1850. * @param {?} provider
  1851. * @param {?} module
  1852. * @return {?}
  1853. */
  1854. function (provider, module) {
  1855. this.providers.push({ provider: provider, module: module });
  1856. };
  1857. /**
  1858. * @param {?} id
  1859. * @return {?}
  1860. */
  1861. TransitiveCompileNgModuleMetadata.prototype.addDirective = /**
  1862. * @param {?} id
  1863. * @return {?}
  1864. */
  1865. function (id) {
  1866. if (!this.directivesSet.has(id.reference)) {
  1867. this.directivesSet.add(id.reference);
  1868. this.directives.push(id);
  1869. }
  1870. };
  1871. /**
  1872. * @param {?} id
  1873. * @return {?}
  1874. */
  1875. TransitiveCompileNgModuleMetadata.prototype.addExportedDirective = /**
  1876. * @param {?} id
  1877. * @return {?}
  1878. */
  1879. function (id) {
  1880. if (!this.exportedDirectivesSet.has(id.reference)) {
  1881. this.exportedDirectivesSet.add(id.reference);
  1882. this.exportedDirectives.push(id);
  1883. }
  1884. };
  1885. /**
  1886. * @param {?} id
  1887. * @return {?}
  1888. */
  1889. TransitiveCompileNgModuleMetadata.prototype.addPipe = /**
  1890. * @param {?} id
  1891. * @return {?}
  1892. */
  1893. function (id) {
  1894. if (!this.pipesSet.has(id.reference)) {
  1895. this.pipesSet.add(id.reference);
  1896. this.pipes.push(id);
  1897. }
  1898. };
  1899. /**
  1900. * @param {?} id
  1901. * @return {?}
  1902. */
  1903. TransitiveCompileNgModuleMetadata.prototype.addExportedPipe = /**
  1904. * @param {?} id
  1905. * @return {?}
  1906. */
  1907. function (id) {
  1908. if (!this.exportedPipesSet.has(id.reference)) {
  1909. this.exportedPipesSet.add(id.reference);
  1910. this.exportedPipes.push(id);
  1911. }
  1912. };
  1913. /**
  1914. * @param {?} id
  1915. * @return {?}
  1916. */
  1917. TransitiveCompileNgModuleMetadata.prototype.addModule = /**
  1918. * @param {?} id
  1919. * @return {?}
  1920. */
  1921. function (id) {
  1922. if (!this.modulesSet.has(id.reference)) {
  1923. this.modulesSet.add(id.reference);
  1924. this.modules.push(id);
  1925. }
  1926. };
  1927. /**
  1928. * @param {?} ec
  1929. * @return {?}
  1930. */
  1931. TransitiveCompileNgModuleMetadata.prototype.addEntryComponent = /**
  1932. * @param {?} ec
  1933. * @return {?}
  1934. */
  1935. function (ec) {
  1936. if (!this.entryComponentsSet.has(ec.componentType)) {
  1937. this.entryComponentsSet.add(ec.componentType);
  1938. this.entryComponents.push(ec);
  1939. }
  1940. };
  1941. return TransitiveCompileNgModuleMetadata;
  1942. }());
  1943. /**
  1944. * @param {?} obj
  1945. * @return {?}
  1946. */
  1947. function _normalizeArray(obj) {
  1948. return obj || [];
  1949. }
  1950. var ProviderMeta = /** @class */ (function () {
  1951. function ProviderMeta(token, _a) {
  1952. var useClass = _a.useClass, useValue = _a.useValue, useExisting = _a.useExisting, useFactory = _a.useFactory, deps = _a.deps, multi = _a.multi;
  1953. this.token = token;
  1954. this.useClass = useClass || null;
  1955. this.useValue = useValue;
  1956. this.useExisting = useExisting;
  1957. this.useFactory = useFactory || null;
  1958. this.dependencies = deps || null;
  1959. this.multi = !!multi;
  1960. }
  1961. return ProviderMeta;
  1962. }());
  1963. /**
  1964. * @template T
  1965. * @param {?} list
  1966. * @return {?}
  1967. */
  1968. function flatten(list) {
  1969. return list.reduce(function (flat, item) {
  1970. var /** @type {?} */ flatItem = Array.isArray(item) ? flatten(item) : item;
  1971. return (/** @type {?} */ (flat)).concat(flatItem);
  1972. }, []);
  1973. }
  1974. /**
  1975. * @param {?} url
  1976. * @return {?}
  1977. */
  1978. function jitSourceUrl(url) {
  1979. // Note: We need 3 "/" so that ng shows up as a separate domain
  1980. // in the chrome dev tools.
  1981. return url.replace(/(\w+:\/\/[\w:-]+)?(\/+)?/, 'ng:///');
  1982. }
  1983. /**
  1984. * @param {?} ngModuleType
  1985. * @param {?} compMeta
  1986. * @param {?} templateMeta
  1987. * @return {?}
  1988. */
  1989. function templateSourceUrl(ngModuleType, compMeta, templateMeta) {
  1990. var /** @type {?} */ url;
  1991. if (templateMeta.isInline) {
  1992. if (compMeta.type.reference instanceof StaticSymbol) {
  1993. // Note: a .ts file might contain multiple components with inline templates,
  1994. // so we need to give them unique urls, as these will be used for sourcemaps.
  1995. url = compMeta.type.reference.filePath + "." + compMeta.type.reference.name + ".html";
  1996. }
  1997. else {
  1998. url = identifierName(ngModuleType) + "/" + identifierName(compMeta.type) + ".html";
  1999. }
  2000. }
  2001. else {
  2002. url = /** @type {?} */ ((templateMeta.templateUrl));
  2003. }
  2004. return compMeta.type.reference instanceof StaticSymbol ? url : jitSourceUrl(url);
  2005. }
  2006. /**
  2007. * @param {?} meta
  2008. * @param {?} id
  2009. * @return {?}
  2010. */
  2011. function sharedStylesheetJitUrl(meta, id) {
  2012. var /** @type {?} */ pathParts = /** @type {?} */ ((meta.moduleUrl)).split(/\/\\/g);
  2013. var /** @type {?} */ baseName = pathParts[pathParts.length - 1];
  2014. return jitSourceUrl("css/" + id + baseName + ".ngstyle.js");
  2015. }
  2016. /**
  2017. * @param {?} moduleMeta
  2018. * @return {?}
  2019. */
  2020. function ngModuleJitUrl(moduleMeta) {
  2021. return jitSourceUrl(identifierName(moduleMeta.type) + "/module.ngfactory.js");
  2022. }
  2023. /**
  2024. * @param {?} ngModuleType
  2025. * @param {?} compMeta
  2026. * @return {?}
  2027. */
  2028. function templateJitUrl(ngModuleType, compMeta) {
  2029. return jitSourceUrl(identifierName(ngModuleType) + "/" + identifierName(compMeta.type) + ".ngfactory.js");
  2030. }
  2031. /**
  2032. * @fileoverview added by tsickle
  2033. * @suppress {checkTypes} checked by tsc
  2034. */
  2035. /**
  2036. * @license
  2037. * Copyright Google Inc. All Rights Reserved.
  2038. *
  2039. * Use of this source code is governed by an MIT-style license that can be
  2040. * found in the LICENSE file at https://angular.io/license
  2041. */
  2042. /**
  2043. * A path is an ordered set of elements. Typically a path is to a
  2044. * particular offset in a source file. The head of the list is the top
  2045. * most node. The tail is the node that contains the offset directly.
  2046. *
  2047. * For example, the expresion `a + b + c` might have an ast that looks
  2048. * like:
  2049. * +
  2050. * / \
  2051. * a +
  2052. * / \
  2053. * b c
  2054. *
  2055. * The path to the node at offset 9 would be `['+' at 1-10, '+' at 7-10,
  2056. * 'c' at 9-10]` and the path the node at offset 1 would be
  2057. * `['+' at 1-10, 'a' at 1-2]`.
  2058. * @template T
  2059. */
  2060. var AstPath = /** @class */ (function () {
  2061. function AstPath(path, position) {
  2062. if (position === void 0) { position = -1; }
  2063. this.path = path;
  2064. this.position = position;
  2065. }
  2066. Object.defineProperty(AstPath.prototype, "empty", {
  2067. get: /**
  2068. * @return {?}
  2069. */
  2070. function () { return !this.path || !this.path.length; },
  2071. enumerable: true,
  2072. configurable: true
  2073. });
  2074. Object.defineProperty(AstPath.prototype, "head", {
  2075. get: /**
  2076. * @return {?}
  2077. */
  2078. function () { return this.path[0]; },
  2079. enumerable: true,
  2080. configurable: true
  2081. });
  2082. Object.defineProperty(AstPath.prototype, "tail", {
  2083. get: /**
  2084. * @return {?}
  2085. */
  2086. function () { return this.path[this.path.length - 1]; },
  2087. enumerable: true,
  2088. configurable: true
  2089. });
  2090. /**
  2091. * @param {?} node
  2092. * @return {?}
  2093. */
  2094. AstPath.prototype.parentOf = /**
  2095. * @param {?} node
  2096. * @return {?}
  2097. */
  2098. function (node) {
  2099. return node && this.path[this.path.indexOf(node) - 1];
  2100. };
  2101. /**
  2102. * @param {?} node
  2103. * @return {?}
  2104. */
  2105. AstPath.prototype.childOf = /**
  2106. * @param {?} node
  2107. * @return {?}
  2108. */
  2109. function (node) { return this.path[this.path.indexOf(node) + 1]; };
  2110. /**
  2111. * @template N
  2112. * @param {?} ctor
  2113. * @return {?}
  2114. */
  2115. AstPath.prototype.first = /**
  2116. * @template N
  2117. * @param {?} ctor
  2118. * @return {?}
  2119. */
  2120. function (ctor) {
  2121. for (var /** @type {?} */ i = this.path.length - 1; i >= 0; i--) {
  2122. var /** @type {?} */ item = this.path[i];
  2123. if (item instanceof ctor)
  2124. return /** @type {?} */ (item);
  2125. }
  2126. };
  2127. /**
  2128. * @param {?} node
  2129. * @return {?}
  2130. */
  2131. AstPath.prototype.push = /**
  2132. * @param {?} node
  2133. * @return {?}
  2134. */
  2135. function (node) { this.path.push(node); };
  2136. /**
  2137. * @return {?}
  2138. */
  2139. AstPath.prototype.pop = /**
  2140. * @return {?}
  2141. */
  2142. function () { return /** @type {?} */ ((this.path.pop())); };
  2143. return AstPath;
  2144. }());
  2145. /**
  2146. * @fileoverview added by tsickle
  2147. * @suppress {checkTypes} checked by tsc
  2148. */
  2149. /**
  2150. * @license
  2151. * Copyright Google Inc. All Rights Reserved.
  2152. *
  2153. * Use of this source code is governed by an MIT-style license that can be
  2154. * found in the LICENSE file at https://angular.io/license
  2155. */
  2156. /**
  2157. * @record
  2158. */
  2159. var Text = /** @class */ (function () {
  2160. function Text(value, sourceSpan) {
  2161. this.value = value;
  2162. this.sourceSpan = sourceSpan;
  2163. }
  2164. /**
  2165. * @param {?} visitor
  2166. * @param {?} context
  2167. * @return {?}
  2168. */
  2169. Text.prototype.visit = /**
  2170. * @param {?} visitor
  2171. * @param {?} context
  2172. * @return {?}
  2173. */
  2174. function (visitor, context) { return visitor.visitText(this, context); };
  2175. return Text;
  2176. }());
  2177. var Expansion = /** @class */ (function () {
  2178. function Expansion(switchValue, type, cases, sourceSpan, switchValueSourceSpan) {
  2179. this.switchValue = switchValue;
  2180. this.type = type;
  2181. this.cases = cases;
  2182. this.sourceSpan = sourceSpan;
  2183. this.switchValueSourceSpan = switchValueSourceSpan;
  2184. }
  2185. /**
  2186. * @param {?} visitor
  2187. * @param {?} context
  2188. * @return {?}
  2189. */
  2190. Expansion.prototype.visit = /**
  2191. * @param {?} visitor
  2192. * @param {?} context
  2193. * @return {?}
  2194. */
  2195. function (visitor, context) { return visitor.visitExpansion(this, context); };
  2196. return Expansion;
  2197. }());
  2198. var ExpansionCase = /** @class */ (function () {
  2199. function ExpansionCase(value, expression, sourceSpan, valueSourceSpan, expSourceSpan) {
  2200. this.value = value;
  2201. this.expression = expression;
  2202. this.sourceSpan = sourceSpan;
  2203. this.valueSourceSpan = valueSourceSpan;
  2204. this.expSourceSpan = expSourceSpan;
  2205. }
  2206. /**
  2207. * @param {?} visitor
  2208. * @param {?} context
  2209. * @return {?}
  2210. */
  2211. ExpansionCase.prototype.visit = /**
  2212. * @param {?} visitor
  2213. * @param {?} context
  2214. * @return {?}
  2215. */
  2216. function (visitor, context) { return visitor.visitExpansionCase(this, context); };
  2217. return ExpansionCase;
  2218. }());
  2219. var Attribute$1 = /** @class */ (function () {
  2220. function Attribute(name, value, sourceSpan, valueSpan) {
  2221. this.name = name;
  2222. this.value = value;
  2223. this.sourceSpan = sourceSpan;
  2224. this.valueSpan = valueSpan;
  2225. }
  2226. /**
  2227. * @param {?} visitor
  2228. * @param {?} context
  2229. * @return {?}
  2230. */
  2231. Attribute.prototype.visit = /**
  2232. * @param {?} visitor
  2233. * @param {?} context
  2234. * @return {?}
  2235. */
  2236. function (visitor, context) { return visitor.visitAttribute(this, context); };
  2237. return Attribute;
  2238. }());
  2239. var Element = /** @class */ (function () {
  2240. function Element(name, attrs, children, sourceSpan, startSourceSpan, endSourceSpan) {
  2241. if (startSourceSpan === void 0) { startSourceSpan = null; }
  2242. if (endSourceSpan === void 0) { endSourceSpan = null; }
  2243. this.name = name;
  2244. this.attrs = attrs;
  2245. this.children = children;
  2246. this.sourceSpan = sourceSpan;
  2247. this.startSourceSpan = startSourceSpan;
  2248. this.endSourceSpan = endSourceSpan;
  2249. }
  2250. /**
  2251. * @param {?} visitor
  2252. * @param {?} context
  2253. * @return {?}
  2254. */
  2255. Element.prototype.visit = /**
  2256. * @param {?} visitor
  2257. * @param {?} context
  2258. * @return {?}
  2259. */
  2260. function (visitor, context) { return visitor.visitElement(this, context); };
  2261. return Element;
  2262. }());
  2263. var Comment = /** @class */ (function () {
  2264. function Comment(value, sourceSpan) {
  2265. this.value = value;
  2266. this.sourceSpan = sourceSpan;
  2267. }
  2268. /**
  2269. * @param {?} visitor
  2270. * @param {?} context
  2271. * @return {?}
  2272. */
  2273. Comment.prototype.visit = /**
  2274. * @param {?} visitor
  2275. * @param {?} context
  2276. * @return {?}
  2277. */
  2278. function (visitor, context) { return visitor.visitComment(this, context); };
  2279. return Comment;
  2280. }());
  2281. /**
  2282. * @record
  2283. */
  2284. /**
  2285. * @param {?} visitor
  2286. * @param {?} nodes
  2287. * @param {?=} context
  2288. * @return {?}
  2289. */
  2290. function visitAll(visitor, nodes, context) {
  2291. if (context === void 0) { context = null; }
  2292. var /** @type {?} */ result = [];
  2293. var /** @type {?} */ visit = visitor.visit ?
  2294. function (ast) { return ((visitor.visit))(ast, context) || ast.visit(visitor, context); } :
  2295. function (ast) { return ast.visit(visitor, context); };
  2296. nodes.forEach(function (ast) {
  2297. var /** @type {?} */ astResult = visit(ast);
  2298. if (astResult) {
  2299. result.push(astResult);
  2300. }
  2301. });
  2302. return result;
  2303. }
  2304. var RecursiveVisitor = /** @class */ (function () {
  2305. function RecursiveVisitor() {
  2306. }
  2307. /**
  2308. * @param {?} ast
  2309. * @param {?} context
  2310. * @return {?}
  2311. */
  2312. RecursiveVisitor.prototype.visitElement = /**
  2313. * @param {?} ast
  2314. * @param {?} context
  2315. * @return {?}
  2316. */
  2317. function (ast, context) {
  2318. this.visitChildren(context, function (visit) {
  2319. visit(ast.attrs);
  2320. visit(ast.children);
  2321. });
  2322. };
  2323. /**
  2324. * @param {?} ast
  2325. * @param {?} context
  2326. * @return {?}
  2327. */
  2328. RecursiveVisitor.prototype.visitAttribute = /**
  2329. * @param {?} ast
  2330. * @param {?} context
  2331. * @return {?}
  2332. */
  2333. function (ast, context) { };
  2334. /**
  2335. * @param {?} ast
  2336. * @param {?} context
  2337. * @return {?}
  2338. */
  2339. RecursiveVisitor.prototype.visitText = /**
  2340. * @param {?} ast
  2341. * @param {?} context
  2342. * @return {?}
  2343. */
  2344. function (ast, context) { };
  2345. /**
  2346. * @param {?} ast
  2347. * @param {?} context
  2348. * @return {?}
  2349. */
  2350. RecursiveVisitor.prototype.visitComment = /**
  2351. * @param {?} ast
  2352. * @param {?} context
  2353. * @return {?}
  2354. */
  2355. function (ast, context) { };
  2356. /**
  2357. * @param {?} ast
  2358. * @param {?} context
  2359. * @return {?}
  2360. */
  2361. RecursiveVisitor.prototype.visitExpansion = /**
  2362. * @param {?} ast
  2363. * @param {?} context
  2364. * @return {?}
  2365. */
  2366. function (ast, context) {
  2367. return this.visitChildren(context, function (visit) { visit(ast.cases); });
  2368. };
  2369. /**
  2370. * @param {?} ast
  2371. * @param {?} context
  2372. * @return {?}
  2373. */
  2374. RecursiveVisitor.prototype.visitExpansionCase = /**
  2375. * @param {?} ast
  2376. * @param {?} context
  2377. * @return {?}
  2378. */
  2379. function (ast, context) { };
  2380. /**
  2381. * @template T
  2382. * @param {?} context
  2383. * @param {?} cb
  2384. * @return {?}
  2385. */
  2386. RecursiveVisitor.prototype.visitChildren = /**
  2387. * @template T
  2388. * @param {?} context
  2389. * @param {?} cb
  2390. * @return {?}
  2391. */
  2392. function (context, cb) {
  2393. var /** @type {?} */ results = [];
  2394. var /** @type {?} */ t = this;
  2395. /**
  2396. * @template T
  2397. * @param {?} children
  2398. * @return {?}
  2399. */
  2400. function visit(children) {
  2401. if (children)
  2402. results.push(visitAll(t, children, context));
  2403. }
  2404. cb(visit);
  2405. return [].concat.apply([], results);
  2406. };
  2407. return RecursiveVisitor;
  2408. }());
  2409. /**
  2410. * @param {?} ast
  2411. * @return {?}
  2412. */
  2413. function spanOf(ast) {
  2414. var /** @type {?} */ start = ast.sourceSpan.start.offset;
  2415. var /** @type {?} */ end = ast.sourceSpan.end.offset;
  2416. if (ast instanceof Element) {
  2417. if (ast.endSourceSpan) {
  2418. end = ast.endSourceSpan.end.offset;
  2419. }
  2420. else if (ast.children && ast.children.length) {
  2421. end = spanOf(ast.children[ast.children.length - 1]).end;
  2422. }
  2423. }
  2424. return { start: start, end: end };
  2425. }
  2426. /**
  2427. * @param {?} nodes
  2428. * @param {?} position
  2429. * @return {?}
  2430. */
  2431. function findNode(nodes, position) {
  2432. var /** @type {?} */ path = [];
  2433. var /** @type {?} */ visitor = new /** @class */ (function (_super) {
  2434. __extends(class_1, _super);
  2435. function class_1() {
  2436. return _super !== null && _super.apply(this, arguments) || this;
  2437. }
  2438. /**
  2439. * @param {?} ast
  2440. * @param {?} context
  2441. * @return {?}
  2442. */
  2443. class_1.prototype.visit = /**
  2444. * @param {?} ast
  2445. * @param {?} context
  2446. * @return {?}
  2447. */
  2448. function (ast, context) {
  2449. var /** @type {?} */ span = spanOf(ast);
  2450. if (span.start <= position && position < span.end) {
  2451. path.push(ast);
  2452. }
  2453. else {
  2454. // Returning a value here will result in the children being skipped.
  2455. return true;
  2456. }
  2457. };
  2458. return class_1;
  2459. }(RecursiveVisitor));
  2460. visitAll(visitor, nodes);
  2461. return new AstPath(path, position);
  2462. }
  2463. /**
  2464. * @fileoverview added by tsickle
  2465. * @suppress {checkTypes} checked by tsc
  2466. */
  2467. /**
  2468. * @license
  2469. * Copyright Google Inc. All Rights Reserved.
  2470. *
  2471. * Use of this source code is governed by an MIT-style license that can be
  2472. * found in the LICENSE file at https://angular.io/license
  2473. */
  2474. /**
  2475. * @param {?} identifier
  2476. * @param {?} value
  2477. * @return {?}
  2478. */
  2479. function assertArrayOfStrings(identifier, value) {
  2480. if (value == null) {
  2481. return;
  2482. }
  2483. if (!Array.isArray(value)) {
  2484. throw new Error("Expected '" + identifier + "' to be an array of strings.");
  2485. }
  2486. for (var /** @type {?} */ i = 0; i < value.length; i += 1) {
  2487. if (typeof value[i] !== 'string') {
  2488. throw new Error("Expected '" + identifier + "' to be an array of strings.");
  2489. }
  2490. }
  2491. }
  2492. var INTERPOLATION_BLACKLIST_REGEXPS = [
  2493. /^\s*$/,
  2494. /[<>]/,
  2495. /^[{}]$/,
  2496. /&(#|[a-z])/i,
  2497. /^\/\//,
  2498. ];
  2499. /**
  2500. * @param {?} identifier
  2501. * @param {?} value
  2502. * @return {?}
  2503. */
  2504. function assertInterpolationSymbols(identifier, value) {
  2505. if (value != null && !(Array.isArray(value) && value.length == 2)) {
  2506. throw new Error("Expected '" + identifier + "' to be an array, [start, end].");
  2507. }
  2508. else if (value != null) {
  2509. var /** @type {?} */ start_1 = /** @type {?} */ (value[0]);
  2510. var /** @type {?} */ end_1 = /** @type {?} */ (value[1]);
  2511. // black list checking
  2512. INTERPOLATION_BLACKLIST_REGEXPS.forEach(function (regexp) {
  2513. if (regexp.test(start_1) || regexp.test(end_1)) {
  2514. throw new Error("['" + start_1 + "', '" + end_1 + "'] contains unusable interpolation symbol.");
  2515. }
  2516. });
  2517. }
  2518. }
  2519. /**
  2520. * @fileoverview added by tsickle
  2521. * @suppress {checkTypes} checked by tsc
  2522. */
  2523. /**
  2524. * @license
  2525. * Copyright Google Inc. All Rights Reserved.
  2526. *
  2527. * Use of this source code is governed by an MIT-style license that can be
  2528. * found in the LICENSE file at https://angular.io/license
  2529. */
  2530. var InterpolationConfig = /** @class */ (function () {
  2531. function InterpolationConfig(start, end) {
  2532. this.start = start;
  2533. this.end = end;
  2534. }
  2535. /**
  2536. * @param {?} markers
  2537. * @return {?}
  2538. */
  2539. InterpolationConfig.fromArray = /**
  2540. * @param {?} markers
  2541. * @return {?}
  2542. */
  2543. function (markers) {
  2544. if (!markers) {
  2545. return DEFAULT_INTERPOLATION_CONFIG;
  2546. }
  2547. assertInterpolationSymbols('interpolation', markers);
  2548. return new InterpolationConfig(markers[0], markers[1]);
  2549. };
  2550. return InterpolationConfig;
  2551. }());
  2552. var DEFAULT_INTERPOLATION_CONFIG = new InterpolationConfig('{{', '}}');
  2553. /**
  2554. * @fileoverview added by tsickle
  2555. * @suppress {checkTypes} checked by tsc
  2556. */
  2557. /**
  2558. * @license
  2559. * Copyright Google Inc. All Rights Reserved.
  2560. *
  2561. * Use of this source code is governed by an MIT-style license that can be
  2562. * found in the LICENSE file at https://angular.io/license
  2563. */
  2564. var StyleWithImports = /** @class */ (function () {
  2565. function StyleWithImports(style, styleUrls) {
  2566. this.style = style;
  2567. this.styleUrls = styleUrls;
  2568. }
  2569. return StyleWithImports;
  2570. }());
  2571. /**
  2572. * @param {?} url
  2573. * @return {?}
  2574. */
  2575. function isStyleUrlResolvable(url) {
  2576. if (url == null || url.length === 0 || url[0] == '/')
  2577. return false;
  2578. var /** @type {?} */ schemeMatch = url.match(URL_WITH_SCHEMA_REGEXP);
  2579. return schemeMatch === null || schemeMatch[1] == 'package' || schemeMatch[1] == 'asset';
  2580. }
  2581. /**
  2582. * Rewrites stylesheets by resolving and removing the \@import urls that
  2583. * are either relative or don't have a `package:` scheme
  2584. * @param {?} resolver
  2585. * @param {?} baseUrl
  2586. * @param {?} cssText
  2587. * @return {?}
  2588. */
  2589. function extractStyleUrls(resolver, baseUrl, cssText) {
  2590. var /** @type {?} */ foundUrls = [];
  2591. var /** @type {?} */ modifiedCssText = cssText.replace(CSS_STRIPPABLE_COMMENT_REGEXP, '')
  2592. .replace(CSS_IMPORT_REGEXP, function () {
  2593. var m = [];
  2594. for (var _i = 0; _i < arguments.length; _i++) {
  2595. m[_i] = arguments[_i];
  2596. }
  2597. var /** @type {?} */ url = m[1] || m[2];
  2598. if (!isStyleUrlResolvable(url)) {
  2599. // Do not attempt to resolve non-package absolute URLs with URI
  2600. // scheme
  2601. return m[0];
  2602. }
  2603. foundUrls.push(resolver.resolve(baseUrl, url));
  2604. return '';
  2605. });
  2606. return new StyleWithImports(modifiedCssText, foundUrls);
  2607. }
  2608. var CSS_IMPORT_REGEXP = /@import\s+(?:url\()?\s*(?:(?:['"]([^'"]*))|([^;\)\s]*))[^;]*;?/g;
  2609. var CSS_STRIPPABLE_COMMENT_REGEXP = /\/\*(?!#\s*(?:sourceURL|sourceMappingURL)=)[\s\S]+?\*\//g;
  2610. var URL_WITH_SCHEMA_REGEXP = /^([^:/?#]+):/;
  2611. /**
  2612. * @fileoverview added by tsickle
  2613. * @suppress {checkTypes} checked by tsc
  2614. */
  2615. /**
  2616. * @license
  2617. * Copyright Google Inc. All Rights Reserved.
  2618. *
  2619. * Use of this source code is governed by an MIT-style license that can be
  2620. * found in the LICENSE file at https://angular.io/license
  2621. */
  2622. /** @enum {number} */
  2623. var TagContentType = {
  2624. RAW_TEXT: 0,
  2625. ESCAPABLE_RAW_TEXT: 1,
  2626. PARSABLE_DATA: 2,
  2627. };
  2628. TagContentType[TagContentType.RAW_TEXT] = "RAW_TEXT";
  2629. TagContentType[TagContentType.ESCAPABLE_RAW_TEXT] = "ESCAPABLE_RAW_TEXT";
  2630. TagContentType[TagContentType.PARSABLE_DATA] = "PARSABLE_DATA";
  2631. /**
  2632. * @record
  2633. */
  2634. /**
  2635. * @param {?} elementName
  2636. * @return {?}
  2637. */
  2638. function splitNsName(elementName) {
  2639. if (elementName[0] != ':') {
  2640. return [null, elementName];
  2641. }
  2642. var /** @type {?} */ colonIndex = elementName.indexOf(':', 1);
  2643. if (colonIndex == -1) {
  2644. throw new Error("Unsupported format \"" + elementName + "\" expecting \":namespace:name\"");
  2645. }
  2646. return [elementName.slice(1, colonIndex), elementName.slice(colonIndex + 1)];
  2647. }
  2648. /**
  2649. * @param {?} tagName
  2650. * @return {?}
  2651. */
  2652. function isNgContainer(tagName) {
  2653. return splitNsName(tagName)[1] === 'ng-container';
  2654. }
  2655. /**
  2656. * @param {?} tagName
  2657. * @return {?}
  2658. */
  2659. function isNgContent(tagName) {
  2660. return splitNsName(tagName)[1] === 'ng-content';
  2661. }
  2662. /**
  2663. * @param {?} tagName
  2664. * @return {?}
  2665. */
  2666. function isNgTemplate(tagName) {
  2667. return splitNsName(tagName)[1] === 'ng-template';
  2668. }
  2669. /**
  2670. * @param {?} fullName
  2671. * @return {?}
  2672. */
  2673. function getNsPrefix(fullName) {
  2674. return fullName === null ? null : splitNsName(fullName)[0];
  2675. }
  2676. /**
  2677. * @param {?} prefix
  2678. * @param {?} localName
  2679. * @return {?}
  2680. */
  2681. function mergeNsAndName(prefix, localName) {
  2682. return prefix ? ":" + prefix + ":" + localName : localName;
  2683. }
  2684. // see http://www.w3.org/TR/html51/syntax.html#named-character-references
  2685. // see https://html.spec.whatwg.org/multipage/entities.json
  2686. // This list is not exhaustive to keep the compiler footprint low.
  2687. // The `&#123;` / `&#x1ab;` syntax should be used when the named character reference does not
  2688. // exist.
  2689. var NAMED_ENTITIES = {
  2690. 'Aacute': '\u00C1',
  2691. 'aacute': '\u00E1',
  2692. 'Acirc': '\u00C2',
  2693. 'acirc': '\u00E2',
  2694. 'acute': '\u00B4',
  2695. 'AElig': '\u00C6',
  2696. 'aelig': '\u00E6',
  2697. 'Agrave': '\u00C0',
  2698. 'agrave': '\u00E0',
  2699. 'alefsym': '\u2135',
  2700. 'Alpha': '\u0391',
  2701. 'alpha': '\u03B1',
  2702. 'amp': '&',
  2703. 'and': '\u2227',
  2704. 'ang': '\u2220',
  2705. 'apos': '\u0027',
  2706. 'Aring': '\u00C5',
  2707. 'aring': '\u00E5',
  2708. 'asymp': '\u2248',
  2709. 'Atilde': '\u00C3',
  2710. 'atilde': '\u00E3',
  2711. 'Auml': '\u00C4',
  2712. 'auml': '\u00E4',
  2713. 'bdquo': '\u201E',
  2714. 'Beta': '\u0392',
  2715. 'beta': '\u03B2',
  2716. 'brvbar': '\u00A6',
  2717. 'bull': '\u2022',
  2718. 'cap': '\u2229',
  2719. 'Ccedil': '\u00C7',
  2720. 'ccedil': '\u00E7',
  2721. 'cedil': '\u00B8',
  2722. 'cent': '\u00A2',
  2723. 'Chi': '\u03A7',
  2724. 'chi': '\u03C7',
  2725. 'circ': '\u02C6',
  2726. 'clubs': '\u2663',
  2727. 'cong': '\u2245',
  2728. 'copy': '\u00A9',
  2729. 'crarr': '\u21B5',
  2730. 'cup': '\u222A',
  2731. 'curren': '\u00A4',
  2732. 'dagger': '\u2020',
  2733. 'Dagger': '\u2021',
  2734. 'darr': '\u2193',
  2735. 'dArr': '\u21D3',
  2736. 'deg': '\u00B0',
  2737. 'Delta': '\u0394',
  2738. 'delta': '\u03B4',
  2739. 'diams': '\u2666',
  2740. 'divide': '\u00F7',
  2741. 'Eacute': '\u00C9',
  2742. 'eacute': '\u00E9',
  2743. 'Ecirc': '\u00CA',
  2744. 'ecirc': '\u00EA',
  2745. 'Egrave': '\u00C8',
  2746. 'egrave': '\u00E8',
  2747. 'empty': '\u2205',
  2748. 'emsp': '\u2003',
  2749. 'ensp': '\u2002',
  2750. 'Epsilon': '\u0395',
  2751. 'epsilon': '\u03B5',
  2752. 'equiv': '\u2261',
  2753. 'Eta': '\u0397',
  2754. 'eta': '\u03B7',
  2755. 'ETH': '\u00D0',
  2756. 'eth': '\u00F0',
  2757. 'Euml': '\u00CB',
  2758. 'euml': '\u00EB',
  2759. 'euro': '\u20AC',
  2760. 'exist': '\u2203',
  2761. 'fnof': '\u0192',
  2762. 'forall': '\u2200',
  2763. 'frac12': '\u00BD',
  2764. 'frac14': '\u00BC',
  2765. 'frac34': '\u00BE',
  2766. 'frasl': '\u2044',
  2767. 'Gamma': '\u0393',
  2768. 'gamma': '\u03B3',
  2769. 'ge': '\u2265',
  2770. 'gt': '>',
  2771. 'harr': '\u2194',
  2772. 'hArr': '\u21D4',
  2773. 'hearts': '\u2665',
  2774. 'hellip': '\u2026',
  2775. 'Iacute': '\u00CD',
  2776. 'iacute': '\u00ED',
  2777. 'Icirc': '\u00CE',
  2778. 'icirc': '\u00EE',
  2779. 'iexcl': '\u00A1',
  2780. 'Igrave': '\u00CC',
  2781. 'igrave': '\u00EC',
  2782. 'image': '\u2111',
  2783. 'infin': '\u221E',
  2784. 'int': '\u222B',
  2785. 'Iota': '\u0399',
  2786. 'iota': '\u03B9',
  2787. 'iquest': '\u00BF',
  2788. 'isin': '\u2208',
  2789. 'Iuml': '\u00CF',
  2790. 'iuml': '\u00EF',
  2791. 'Kappa': '\u039A',
  2792. 'kappa': '\u03BA',
  2793. 'Lambda': '\u039B',
  2794. 'lambda': '\u03BB',
  2795. 'lang': '\u27E8',
  2796. 'laquo': '\u00AB',
  2797. 'larr': '\u2190',
  2798. 'lArr': '\u21D0',
  2799. 'lceil': '\u2308',
  2800. 'ldquo': '\u201C',
  2801. 'le': '\u2264',
  2802. 'lfloor': '\u230A',
  2803. 'lowast': '\u2217',
  2804. 'loz': '\u25CA',
  2805. 'lrm': '\u200E',
  2806. 'lsaquo': '\u2039',
  2807. 'lsquo': '\u2018',
  2808. 'lt': '<',
  2809. 'macr': '\u00AF',
  2810. 'mdash': '\u2014',
  2811. 'micro': '\u00B5',
  2812. 'middot': '\u00B7',
  2813. 'minus': '\u2212',
  2814. 'Mu': '\u039C',
  2815. 'mu': '\u03BC',
  2816. 'nabla': '\u2207',
  2817. 'nbsp': '\u00A0',
  2818. 'ndash': '\u2013',
  2819. 'ne': '\u2260',
  2820. 'ni': '\u220B',
  2821. 'not': '\u00AC',
  2822. 'notin': '\u2209',
  2823. 'nsub': '\u2284',
  2824. 'Ntilde': '\u00D1',
  2825. 'ntilde': '\u00F1',
  2826. 'Nu': '\u039D',
  2827. 'nu': '\u03BD',
  2828. 'Oacute': '\u00D3',
  2829. 'oacute': '\u00F3',
  2830. 'Ocirc': '\u00D4',
  2831. 'ocirc': '\u00F4',
  2832. 'OElig': '\u0152',
  2833. 'oelig': '\u0153',
  2834. 'Ograve': '\u00D2',
  2835. 'ograve': '\u00F2',
  2836. 'oline': '\u203E',
  2837. 'Omega': '\u03A9',
  2838. 'omega': '\u03C9',
  2839. 'Omicron': '\u039F',
  2840. 'omicron': '\u03BF',
  2841. 'oplus': '\u2295',
  2842. 'or': '\u2228',
  2843. 'ordf': '\u00AA',
  2844. 'ordm': '\u00BA',
  2845. 'Oslash': '\u00D8',
  2846. 'oslash': '\u00F8',
  2847. 'Otilde': '\u00D5',
  2848. 'otilde': '\u00F5',
  2849. 'otimes': '\u2297',
  2850. 'Ouml': '\u00D6',
  2851. 'ouml': '\u00F6',
  2852. 'para': '\u00B6',
  2853. 'permil': '\u2030',
  2854. 'perp': '\u22A5',
  2855. 'Phi': '\u03A6',
  2856. 'phi': '\u03C6',
  2857. 'Pi': '\u03A0',
  2858. 'pi': '\u03C0',
  2859. 'piv': '\u03D6',
  2860. 'plusmn': '\u00B1',
  2861. 'pound': '\u00A3',
  2862. 'prime': '\u2032',
  2863. 'Prime': '\u2033',
  2864. 'prod': '\u220F',
  2865. 'prop': '\u221D',
  2866. 'Psi': '\u03A8',
  2867. 'psi': '\u03C8',
  2868. 'quot': '\u0022',
  2869. 'radic': '\u221A',
  2870. 'rang': '\u27E9',
  2871. 'raquo': '\u00BB',
  2872. 'rarr': '\u2192',
  2873. 'rArr': '\u21D2',
  2874. 'rceil': '\u2309',
  2875. 'rdquo': '\u201D',
  2876. 'real': '\u211C',
  2877. 'reg': '\u00AE',
  2878. 'rfloor': '\u230B',
  2879. 'Rho': '\u03A1',
  2880. 'rho': '\u03C1',
  2881. 'rlm': '\u200F',
  2882. 'rsaquo': '\u203A',
  2883. 'rsquo': '\u2019',
  2884. 'sbquo': '\u201A',
  2885. 'Scaron': '\u0160',
  2886. 'scaron': '\u0161',
  2887. 'sdot': '\u22C5',
  2888. 'sect': '\u00A7',
  2889. 'shy': '\u00AD',
  2890. 'Sigma': '\u03A3',
  2891. 'sigma': '\u03C3',
  2892. 'sigmaf': '\u03C2',
  2893. 'sim': '\u223C',
  2894. 'spades': '\u2660',
  2895. 'sub': '\u2282',
  2896. 'sube': '\u2286',
  2897. 'sum': '\u2211',
  2898. 'sup': '\u2283',
  2899. 'sup1': '\u00B9',
  2900. 'sup2': '\u00B2',
  2901. 'sup3': '\u00B3',
  2902. 'supe': '\u2287',
  2903. 'szlig': '\u00DF',
  2904. 'Tau': '\u03A4',
  2905. 'tau': '\u03C4',
  2906. 'there4': '\u2234',
  2907. 'Theta': '\u0398',
  2908. 'theta': '\u03B8',
  2909. 'thetasym': '\u03D1',
  2910. 'thinsp': '\u2009',
  2911. 'THORN': '\u00DE',
  2912. 'thorn': '\u00FE',
  2913. 'tilde': '\u02DC',
  2914. 'times': '\u00D7',
  2915. 'trade': '\u2122',
  2916. 'Uacute': '\u00DA',
  2917. 'uacute': '\u00FA',
  2918. 'uarr': '\u2191',
  2919. 'uArr': '\u21D1',
  2920. 'Ucirc': '\u00DB',
  2921. 'ucirc': '\u00FB',
  2922. 'Ugrave': '\u00D9',
  2923. 'ugrave': '\u00F9',
  2924. 'uml': '\u00A8',
  2925. 'upsih': '\u03D2',
  2926. 'Upsilon': '\u03A5',
  2927. 'upsilon': '\u03C5',
  2928. 'Uuml': '\u00DC',
  2929. 'uuml': '\u00FC',
  2930. 'weierp': '\u2118',
  2931. 'Xi': '\u039E',
  2932. 'xi': '\u03BE',
  2933. 'Yacute': '\u00DD',
  2934. 'yacute': '\u00FD',
  2935. 'yen': '\u00A5',
  2936. 'yuml': '\u00FF',
  2937. 'Yuml': '\u0178',
  2938. 'Zeta': '\u0396',
  2939. 'zeta': '\u03B6',
  2940. 'zwj': '\u200D',
  2941. 'zwnj': '\u200C',
  2942. };
  2943. // The &ngsp; pseudo-entity is denoting a space. see:
  2944. // https://github.com/dart-lang/angular/blob/0bb611387d29d65b5af7f9d2515ab571fd3fbee4/_tests/test/compiler/preserve_whitespace_test.dart
  2945. var NGSP_UNICODE = '\uE500';
  2946. NAMED_ENTITIES['ngsp'] = NGSP_UNICODE;
  2947. /**
  2948. * @fileoverview added by tsickle
  2949. * @suppress {checkTypes} checked by tsc
  2950. */
  2951. /**
  2952. * @license
  2953. * Copyright Google Inc. All Rights Reserved.
  2954. *
  2955. * Use of this source code is governed by an MIT-style license that can be
  2956. * found in the LICENSE file at https://angular.io/license
  2957. */
  2958. var NG_CONTENT_SELECT_ATTR = 'select';
  2959. var LINK_ELEMENT = 'link';
  2960. var LINK_STYLE_REL_ATTR = 'rel';
  2961. var LINK_STYLE_HREF_ATTR = 'href';
  2962. var LINK_STYLE_REL_VALUE = 'stylesheet';
  2963. var STYLE_ELEMENT = 'style';
  2964. var SCRIPT_ELEMENT = 'script';
  2965. var NG_NON_BINDABLE_ATTR = 'ngNonBindable';
  2966. var NG_PROJECT_AS = 'ngProjectAs';
  2967. /**
  2968. * @param {?} ast
  2969. * @return {?}
  2970. */
  2971. function preparseElement(ast) {
  2972. var /** @type {?} */ selectAttr = /** @type {?} */ ((null));
  2973. var /** @type {?} */ hrefAttr = /** @type {?} */ ((null));
  2974. var /** @type {?} */ relAttr = /** @type {?} */ ((null));
  2975. var /** @type {?} */ nonBindable = false;
  2976. var /** @type {?} */ projectAs = /** @type {?} */ ((null));
  2977. ast.attrs.forEach(function (attr) {
  2978. var /** @type {?} */ lcAttrName = attr.name.toLowerCase();
  2979. if (lcAttrName == NG_CONTENT_SELECT_ATTR) {
  2980. selectAttr = attr.value;
  2981. }
  2982. else if (lcAttrName == LINK_STYLE_HREF_ATTR) {
  2983. hrefAttr = attr.value;
  2984. }
  2985. else if (lcAttrName == LINK_STYLE_REL_ATTR) {
  2986. relAttr = attr.value;
  2987. }
  2988. else if (attr.name == NG_NON_BINDABLE_ATTR) {
  2989. nonBindable = true;
  2990. }
  2991. else if (attr.name == NG_PROJECT_AS) {
  2992. if (attr.value.length > 0) {
  2993. projectAs = attr.value;
  2994. }
  2995. }
  2996. });
  2997. selectAttr = normalizeNgContentSelect(selectAttr);
  2998. var /** @type {?} */ nodeName = ast.name.toLowerCase();
  2999. var /** @type {?} */ type = PreparsedElementType.OTHER;
  3000. if (isNgContent(nodeName)) {
  3001. type = PreparsedElementType.NG_CONTENT;
  3002. }
  3003. else if (nodeName == STYLE_ELEMENT) {
  3004. type = PreparsedElementType.STYLE;
  3005. }
  3006. else if (nodeName == SCRIPT_ELEMENT) {
  3007. type = PreparsedElementType.SCRIPT;
  3008. }
  3009. else if (nodeName == LINK_ELEMENT && relAttr == LINK_STYLE_REL_VALUE) {
  3010. type = PreparsedElementType.STYLESHEET;
  3011. }
  3012. return new PreparsedElement(type, selectAttr, hrefAttr, nonBindable, projectAs);
  3013. }
  3014. /** @enum {number} */
  3015. var PreparsedElementType = {
  3016. NG_CONTENT: 0,
  3017. STYLE: 1,
  3018. STYLESHEET: 2,
  3019. SCRIPT: 3,
  3020. OTHER: 4,
  3021. };
  3022. PreparsedElementType[PreparsedElementType.NG_CONTENT] = "NG_CONTENT";
  3023. PreparsedElementType[PreparsedElementType.STYLE] = "STYLE";
  3024. PreparsedElementType[PreparsedElementType.STYLESHEET] = "STYLESHEET";
  3025. PreparsedElementType[PreparsedElementType.SCRIPT] = "SCRIPT";
  3026. PreparsedElementType[PreparsedElementType.OTHER] = "OTHER";
  3027. var PreparsedElement = /** @class */ (function () {
  3028. function PreparsedElement(type, selectAttr, hrefAttr, nonBindable, projectAs) {
  3029. this.type = type;
  3030. this.selectAttr = selectAttr;
  3031. this.hrefAttr = hrefAttr;
  3032. this.nonBindable = nonBindable;
  3033. this.projectAs = projectAs;
  3034. }
  3035. return PreparsedElement;
  3036. }());
  3037. /**
  3038. * @param {?} selectAttr
  3039. * @return {?}
  3040. */
  3041. function normalizeNgContentSelect(selectAttr) {
  3042. if (selectAttr === null || selectAttr.length === 0) {
  3043. return '*';
  3044. }
  3045. return selectAttr;
  3046. }
  3047. /**
  3048. * @fileoverview added by tsickle
  3049. * @suppress {checkTypes} checked by tsc
  3050. */
  3051. /**
  3052. * @license
  3053. * Copyright Google Inc. All Rights Reserved.
  3054. *
  3055. * Use of this source code is governed by an MIT-style license that can be
  3056. * found in the LICENSE file at https://angular.io/license
  3057. */
  3058. /**
  3059. * @record
  3060. */
  3061. var DirectiveNormalizer = /** @class */ (function () {
  3062. function DirectiveNormalizer(_resourceLoader, _urlResolver, _htmlParser, _config) {
  3063. this._resourceLoader = _resourceLoader;
  3064. this._urlResolver = _urlResolver;
  3065. this._htmlParser = _htmlParser;
  3066. this._config = _config;
  3067. this._resourceLoaderCache = new Map();
  3068. }
  3069. /**
  3070. * @return {?}
  3071. */
  3072. DirectiveNormalizer.prototype.clearCache = /**
  3073. * @return {?}
  3074. */
  3075. function () { this._resourceLoaderCache.clear(); };
  3076. /**
  3077. * @param {?} normalizedDirective
  3078. * @return {?}
  3079. */
  3080. DirectiveNormalizer.prototype.clearCacheFor = /**
  3081. * @param {?} normalizedDirective
  3082. * @return {?}
  3083. */
  3084. function (normalizedDirective) {
  3085. var _this = this;
  3086. if (!normalizedDirective.isComponent) {
  3087. return;
  3088. }
  3089. var /** @type {?} */ template = /** @type {?} */ ((normalizedDirective.template));
  3090. this._resourceLoaderCache.delete(/** @type {?} */ ((template.templateUrl)));
  3091. template.externalStylesheets.forEach(function (stylesheet) { _this._resourceLoaderCache.delete(/** @type {?} */ ((stylesheet.moduleUrl))); });
  3092. };
  3093. /**
  3094. * @param {?} url
  3095. * @return {?}
  3096. */
  3097. DirectiveNormalizer.prototype._fetch = /**
  3098. * @param {?} url
  3099. * @return {?}
  3100. */
  3101. function (url) {
  3102. var /** @type {?} */ result = this._resourceLoaderCache.get(url);
  3103. if (!result) {
  3104. result = this._resourceLoader.get(url);
  3105. this._resourceLoaderCache.set(url, result);
  3106. }
  3107. return result;
  3108. };
  3109. /**
  3110. * @param {?} prenormData
  3111. * @return {?}
  3112. */
  3113. DirectiveNormalizer.prototype.normalizeTemplate = /**
  3114. * @param {?} prenormData
  3115. * @return {?}
  3116. */
  3117. function (prenormData) {
  3118. var _this = this;
  3119. if (isDefined(prenormData.template)) {
  3120. if (isDefined(prenormData.templateUrl)) {
  3121. throw syntaxError("'" + stringify(prenormData.componentType) + "' component cannot define both template and templateUrl");
  3122. }
  3123. if (typeof prenormData.template !== 'string') {
  3124. throw syntaxError("The template specified for component " + stringify(prenormData.componentType) + " is not a string");
  3125. }
  3126. }
  3127. else if (isDefined(prenormData.templateUrl)) {
  3128. if (typeof prenormData.templateUrl !== 'string') {
  3129. throw syntaxError("The templateUrl specified for component " + stringify(prenormData.componentType) + " is not a string");
  3130. }
  3131. }
  3132. else {
  3133. throw syntaxError("No template specified for component " + stringify(prenormData.componentType));
  3134. }
  3135. if (isDefined(prenormData.preserveWhitespaces) &&
  3136. typeof prenormData.preserveWhitespaces !== 'boolean') {
  3137. throw syntaxError("The preserveWhitespaces option for component " + stringify(prenormData.componentType) + " must be a boolean");
  3138. }
  3139. return SyncAsync.then(this._preParseTemplate(prenormData), function (preparsedTemplate) { return _this._normalizeTemplateMetadata(prenormData, preparsedTemplate); });
  3140. };
  3141. /**
  3142. * @param {?} prenomData
  3143. * @return {?}
  3144. */
  3145. DirectiveNormalizer.prototype._preParseTemplate = /**
  3146. * @param {?} prenomData
  3147. * @return {?}
  3148. */
  3149. function (prenomData) {
  3150. var _this = this;
  3151. var /** @type {?} */ template;
  3152. var /** @type {?} */ templateUrl;
  3153. if (prenomData.template != null) {
  3154. template = prenomData.template;
  3155. templateUrl = prenomData.moduleUrl;
  3156. }
  3157. else {
  3158. templateUrl = this._urlResolver.resolve(prenomData.moduleUrl, /** @type {?} */ ((prenomData.templateUrl)));
  3159. template = this._fetch(templateUrl);
  3160. }
  3161. return SyncAsync.then(template, function (template) { return _this._preparseLoadedTemplate(prenomData, template, templateUrl); });
  3162. };
  3163. /**
  3164. * @param {?} prenormData
  3165. * @param {?} template
  3166. * @param {?} templateAbsUrl
  3167. * @return {?}
  3168. */
  3169. DirectiveNormalizer.prototype._preparseLoadedTemplate = /**
  3170. * @param {?} prenormData
  3171. * @param {?} template
  3172. * @param {?} templateAbsUrl
  3173. * @return {?}
  3174. */
  3175. function (prenormData, template, templateAbsUrl) {
  3176. var /** @type {?} */ isInline = !!prenormData.template;
  3177. var /** @type {?} */ interpolationConfig = InterpolationConfig.fromArray(/** @type {?} */ ((prenormData.interpolation)));
  3178. var /** @type {?} */ rootNodesAndErrors = this._htmlParser.parse(template, templateSourceUrl({ reference: prenormData.ngModuleType }, { type: { reference: prenormData.componentType } }, { isInline: isInline, templateUrl: templateAbsUrl }), true, interpolationConfig);
  3179. if (rootNodesAndErrors.errors.length > 0) {
  3180. var /** @type {?} */ errorString = rootNodesAndErrors.errors.join('\n');
  3181. throw syntaxError("Template parse errors:\n" + errorString);
  3182. }
  3183. var /** @type {?} */ templateMetadataStyles = this._normalizeStylesheet(new CompileStylesheetMetadata({ styles: prenormData.styles, moduleUrl: prenormData.moduleUrl }));
  3184. var /** @type {?} */ visitor = new TemplatePreparseVisitor();
  3185. visitAll(visitor, rootNodesAndErrors.rootNodes);
  3186. var /** @type {?} */ templateStyles = this._normalizeStylesheet(new CompileStylesheetMetadata({ styles: visitor.styles, styleUrls: visitor.styleUrls, moduleUrl: templateAbsUrl }));
  3187. var /** @type {?} */ styles = templateMetadataStyles.styles.concat(templateStyles.styles);
  3188. var /** @type {?} */ inlineStyleUrls = templateMetadataStyles.styleUrls.concat(templateStyles.styleUrls);
  3189. var /** @type {?} */ styleUrls = this
  3190. ._normalizeStylesheet(new CompileStylesheetMetadata({ styleUrls: prenormData.styleUrls, moduleUrl: prenormData.moduleUrl }))
  3191. .styleUrls;
  3192. return {
  3193. template: template,
  3194. templateUrl: templateAbsUrl, isInline: isInline,
  3195. htmlAst: rootNodesAndErrors, styles: styles, inlineStyleUrls: inlineStyleUrls, styleUrls: styleUrls,
  3196. ngContentSelectors: visitor.ngContentSelectors,
  3197. };
  3198. };
  3199. /**
  3200. * @param {?} prenormData
  3201. * @param {?} preparsedTemplate
  3202. * @return {?}
  3203. */
  3204. DirectiveNormalizer.prototype._normalizeTemplateMetadata = /**
  3205. * @param {?} prenormData
  3206. * @param {?} preparsedTemplate
  3207. * @return {?}
  3208. */
  3209. function (prenormData, preparsedTemplate) {
  3210. var _this = this;
  3211. return SyncAsync.then(this._loadMissingExternalStylesheets(preparsedTemplate.styleUrls.concat(preparsedTemplate.inlineStyleUrls)), function (externalStylesheets) {
  3212. return _this._normalizeLoadedTemplateMetadata(prenormData, preparsedTemplate, externalStylesheets);
  3213. });
  3214. };
  3215. /**
  3216. * @param {?} prenormData
  3217. * @param {?} preparsedTemplate
  3218. * @param {?} stylesheets
  3219. * @return {?}
  3220. */
  3221. DirectiveNormalizer.prototype._normalizeLoadedTemplateMetadata = /**
  3222. * @param {?} prenormData
  3223. * @param {?} preparsedTemplate
  3224. * @param {?} stylesheets
  3225. * @return {?}
  3226. */
  3227. function (prenormData, preparsedTemplate, stylesheets) {
  3228. var _this = this;
  3229. // Algorithm:
  3230. // - produce exactly 1 entry per original styleUrl in
  3231. // CompileTemplateMetadata.externalStylesheets whith all styles inlined
  3232. // - inline all styles that are referenced by the template into CompileTemplateMetadata.styles.
  3233. // Reason: be able to determine how many stylesheets there are even without loading
  3234. // the template nor the stylesheets, so we can create a stub for TypeScript always synchronously
  3235. // (as resouce loading may be async)
  3236. var /** @type {?} */ styles = preparsedTemplate.styles.slice();
  3237. this._inlineStyles(preparsedTemplate.inlineStyleUrls, stylesheets, styles);
  3238. var /** @type {?} */ styleUrls = preparsedTemplate.styleUrls;
  3239. var /** @type {?} */ externalStylesheets = styleUrls.map(function (styleUrl) {
  3240. var /** @type {?} */ stylesheet = /** @type {?} */ ((stylesheets.get(styleUrl)));
  3241. var /** @type {?} */ styles = stylesheet.styles.slice();
  3242. _this._inlineStyles(stylesheet.styleUrls, stylesheets, styles);
  3243. return new CompileStylesheetMetadata({ moduleUrl: styleUrl, styles: styles });
  3244. });
  3245. var /** @type {?} */ encapsulation = prenormData.encapsulation;
  3246. if (encapsulation == null) {
  3247. encapsulation = this._config.defaultEncapsulation;
  3248. }
  3249. if (encapsulation === ViewEncapsulation.Emulated && styles.length === 0 &&
  3250. styleUrls.length === 0) {
  3251. encapsulation = ViewEncapsulation.None;
  3252. }
  3253. return new CompileTemplateMetadata({
  3254. encapsulation: encapsulation,
  3255. template: preparsedTemplate.template,
  3256. templateUrl: preparsedTemplate.templateUrl,
  3257. htmlAst: preparsedTemplate.htmlAst, styles: styles, styleUrls: styleUrls,
  3258. ngContentSelectors: preparsedTemplate.ngContentSelectors,
  3259. animations: prenormData.animations,
  3260. interpolation: prenormData.interpolation,
  3261. isInline: preparsedTemplate.isInline, externalStylesheets: externalStylesheets,
  3262. preserveWhitespaces: preserveWhitespacesDefault(prenormData.preserveWhitespaces, this._config.preserveWhitespaces),
  3263. });
  3264. };
  3265. /**
  3266. * @param {?} styleUrls
  3267. * @param {?} stylesheets
  3268. * @param {?} targetStyles
  3269. * @return {?}
  3270. */
  3271. DirectiveNormalizer.prototype._inlineStyles = /**
  3272. * @param {?} styleUrls
  3273. * @param {?} stylesheets
  3274. * @param {?} targetStyles
  3275. * @return {?}
  3276. */
  3277. function (styleUrls, stylesheets, targetStyles) {
  3278. var _this = this;
  3279. styleUrls.forEach(function (styleUrl) {
  3280. var /** @type {?} */ stylesheet = /** @type {?} */ ((stylesheets.get(styleUrl)));
  3281. stylesheet.styles.forEach(function (style) { return targetStyles.push(style); });
  3282. _this._inlineStyles(stylesheet.styleUrls, stylesheets, targetStyles);
  3283. });
  3284. };
  3285. /**
  3286. * @param {?} styleUrls
  3287. * @param {?=} loadedStylesheets
  3288. * @return {?}
  3289. */
  3290. DirectiveNormalizer.prototype._loadMissingExternalStylesheets = /**
  3291. * @param {?} styleUrls
  3292. * @param {?=} loadedStylesheets
  3293. * @return {?}
  3294. */
  3295. function (styleUrls, loadedStylesheets) {
  3296. var _this = this;
  3297. if (loadedStylesheets === void 0) { loadedStylesheets = new Map(); }
  3298. return SyncAsync.then(SyncAsync.all(styleUrls.filter(function (styleUrl) { return !loadedStylesheets.has(styleUrl); })
  3299. .map(function (styleUrl) {
  3300. return SyncAsync.then(_this._fetch(styleUrl), function (loadedStyle) {
  3301. var /** @type {?} */ stylesheet = _this._normalizeStylesheet(new CompileStylesheetMetadata({ styles: [loadedStyle], moduleUrl: styleUrl }));
  3302. loadedStylesheets.set(styleUrl, stylesheet);
  3303. return _this._loadMissingExternalStylesheets(stylesheet.styleUrls, loadedStylesheets);
  3304. });
  3305. })), function (_) { return loadedStylesheets; });
  3306. };
  3307. /**
  3308. * @param {?} stylesheet
  3309. * @return {?}
  3310. */
  3311. DirectiveNormalizer.prototype._normalizeStylesheet = /**
  3312. * @param {?} stylesheet
  3313. * @return {?}
  3314. */
  3315. function (stylesheet) {
  3316. var _this = this;
  3317. var /** @type {?} */ moduleUrl = /** @type {?} */ ((stylesheet.moduleUrl));
  3318. var /** @type {?} */ allStyleUrls = stylesheet.styleUrls.filter(isStyleUrlResolvable)
  3319. .map(function (url) { return _this._urlResolver.resolve(moduleUrl, url); });
  3320. var /** @type {?} */ allStyles = stylesheet.styles.map(function (style) {
  3321. var /** @type {?} */ styleWithImports = extractStyleUrls(_this._urlResolver, moduleUrl, style);
  3322. allStyleUrls.push.apply(allStyleUrls, styleWithImports.styleUrls);
  3323. return styleWithImports.style;
  3324. });
  3325. return new CompileStylesheetMetadata({ styles: allStyles, styleUrls: allStyleUrls, moduleUrl: moduleUrl });
  3326. };
  3327. return DirectiveNormalizer;
  3328. }());
  3329. var TemplatePreparseVisitor = /** @class */ (function () {
  3330. function TemplatePreparseVisitor() {
  3331. this.ngContentSelectors = [];
  3332. this.styles = [];
  3333. this.styleUrls = [];
  3334. this.ngNonBindableStackCount = 0;
  3335. }
  3336. /**
  3337. * @param {?} ast
  3338. * @param {?} context
  3339. * @return {?}
  3340. */
  3341. TemplatePreparseVisitor.prototype.visitElement = /**
  3342. * @param {?} ast
  3343. * @param {?} context
  3344. * @return {?}
  3345. */
  3346. function (ast, context) {
  3347. var /** @type {?} */ preparsedElement = preparseElement(ast);
  3348. switch (preparsedElement.type) {
  3349. case PreparsedElementType.NG_CONTENT:
  3350. if (this.ngNonBindableStackCount === 0) {
  3351. this.ngContentSelectors.push(preparsedElement.selectAttr);
  3352. }
  3353. break;
  3354. case PreparsedElementType.STYLE:
  3355. var /** @type {?} */ textContent_1 = '';
  3356. ast.children.forEach(function (child) {
  3357. if (child instanceof Text) {
  3358. textContent_1 += child.value;
  3359. }
  3360. });
  3361. this.styles.push(textContent_1);
  3362. break;
  3363. case PreparsedElementType.STYLESHEET:
  3364. this.styleUrls.push(preparsedElement.hrefAttr);
  3365. break;
  3366. default:
  3367. break;
  3368. }
  3369. if (preparsedElement.nonBindable) {
  3370. this.ngNonBindableStackCount++;
  3371. }
  3372. visitAll(this, ast.children);
  3373. if (preparsedElement.nonBindable) {
  3374. this.ngNonBindableStackCount--;
  3375. }
  3376. return null;
  3377. };
  3378. /**
  3379. * @param {?} ast
  3380. * @param {?} context
  3381. * @return {?}
  3382. */
  3383. TemplatePreparseVisitor.prototype.visitExpansion = /**
  3384. * @param {?} ast
  3385. * @param {?} context
  3386. * @return {?}
  3387. */
  3388. function (ast, context) { visitAll(this, ast.cases); };
  3389. /**
  3390. * @param {?} ast
  3391. * @param {?} context
  3392. * @return {?}
  3393. */
  3394. TemplatePreparseVisitor.prototype.visitExpansionCase = /**
  3395. * @param {?} ast
  3396. * @param {?} context
  3397. * @return {?}
  3398. */
  3399. function (ast, context) {
  3400. visitAll(this, ast.expression);
  3401. };
  3402. /**
  3403. * @param {?} ast
  3404. * @param {?} context
  3405. * @return {?}
  3406. */
  3407. TemplatePreparseVisitor.prototype.visitComment = /**
  3408. * @param {?} ast
  3409. * @param {?} context
  3410. * @return {?}
  3411. */
  3412. function (ast, context) { return null; };
  3413. /**
  3414. * @param {?} ast
  3415. * @param {?} context
  3416. * @return {?}
  3417. */
  3418. TemplatePreparseVisitor.prototype.visitAttribute = /**
  3419. * @param {?} ast
  3420. * @param {?} context
  3421. * @return {?}
  3422. */
  3423. function (ast, context) { return null; };
  3424. /**
  3425. * @param {?} ast
  3426. * @param {?} context
  3427. * @return {?}
  3428. */
  3429. TemplatePreparseVisitor.prototype.visitText = /**
  3430. * @param {?} ast
  3431. * @param {?} context
  3432. * @return {?}
  3433. */
  3434. function (ast, context) { return null; };
  3435. return TemplatePreparseVisitor;
  3436. }());
  3437. /**
  3438. * @fileoverview added by tsickle
  3439. * @suppress {checkTypes} checked by tsc
  3440. */
  3441. /**
  3442. * @license
  3443. * Copyright Google Inc. All Rights Reserved.
  3444. *
  3445. * Use of this source code is governed by an MIT-style license that can be
  3446. * found in the LICENSE file at https://angular.io/license
  3447. */
  3448. var QUERY_METADATA_IDENTIFIERS = [
  3449. createViewChild,
  3450. createViewChildren,
  3451. createContentChild,
  3452. createContentChildren,
  3453. ];
  3454. var DirectiveResolver = /** @class */ (function () {
  3455. function DirectiveResolver(_reflector) {
  3456. this._reflector = _reflector;
  3457. }
  3458. /**
  3459. * @param {?} type
  3460. * @return {?}
  3461. */
  3462. DirectiveResolver.prototype.isDirective = /**
  3463. * @param {?} type
  3464. * @return {?}
  3465. */
  3466. function (type) {
  3467. var /** @type {?} */ typeMetadata = this._reflector.annotations(resolveForwardRef(type));
  3468. return typeMetadata && typeMetadata.some(isDirectiveMetadata);
  3469. };
  3470. /**
  3471. * @param {?} type
  3472. * @param {?=} throwIfNotFound
  3473. * @return {?}
  3474. */
  3475. DirectiveResolver.prototype.resolve = /**
  3476. * @param {?} type
  3477. * @param {?=} throwIfNotFound
  3478. * @return {?}
  3479. */
  3480. function (type, throwIfNotFound) {
  3481. if (throwIfNotFound === void 0) { throwIfNotFound = true; }
  3482. var /** @type {?} */ typeMetadata = this._reflector.annotations(resolveForwardRef(type));
  3483. if (typeMetadata) {
  3484. var /** @type {?} */ metadata = findLast(typeMetadata, isDirectiveMetadata);
  3485. if (metadata) {
  3486. var /** @type {?} */ propertyMetadata = this._reflector.propMetadata(type);
  3487. var /** @type {?} */ guards = this._reflector.guards(type);
  3488. return this._mergeWithPropertyMetadata(metadata, propertyMetadata, guards, type);
  3489. }
  3490. }
  3491. if (throwIfNotFound) {
  3492. throw new Error("No Directive annotation found on " + stringify(type));
  3493. }
  3494. return null;
  3495. };
  3496. /**
  3497. * @param {?} dm
  3498. * @param {?} propertyMetadata
  3499. * @param {?} guards
  3500. * @param {?} directiveType
  3501. * @return {?}
  3502. */
  3503. DirectiveResolver.prototype._mergeWithPropertyMetadata = /**
  3504. * @param {?} dm
  3505. * @param {?} propertyMetadata
  3506. * @param {?} guards
  3507. * @param {?} directiveType
  3508. * @return {?}
  3509. */
  3510. function (dm, propertyMetadata, guards, directiveType) {
  3511. var /** @type {?} */ inputs = [];
  3512. var /** @type {?} */ outputs = [];
  3513. var /** @type {?} */ host = {};
  3514. var /** @type {?} */ queries = {};
  3515. Object.keys(propertyMetadata).forEach(function (propName) {
  3516. var /** @type {?} */ input = findLast(propertyMetadata[propName], function (a) { return createInput.isTypeOf(a); });
  3517. if (input) {
  3518. if (input.bindingPropertyName) {
  3519. inputs.push(propName + ": " + input.bindingPropertyName);
  3520. }
  3521. else {
  3522. inputs.push(propName);
  3523. }
  3524. }
  3525. var /** @type {?} */ output = findLast(propertyMetadata[propName], function (a) { return createOutput.isTypeOf(a); });
  3526. if (output) {
  3527. if (output.bindingPropertyName) {
  3528. outputs.push(propName + ": " + output.bindingPropertyName);
  3529. }
  3530. else {
  3531. outputs.push(propName);
  3532. }
  3533. }
  3534. var /** @type {?} */ hostBindings = propertyMetadata[propName].filter(function (a) { return createHostBinding.isTypeOf(a); });
  3535. hostBindings.forEach(function (hostBinding) {
  3536. if (hostBinding.hostPropertyName) {
  3537. var /** @type {?} */ startWith = hostBinding.hostPropertyName[0];
  3538. if (startWith === '(') {
  3539. throw new Error("@HostBinding can not bind to events. Use @HostListener instead.");
  3540. }
  3541. else if (startWith === '[') {
  3542. throw new Error("@HostBinding parameter should be a property name, 'class.<name>', or 'attr.<name>'.");
  3543. }
  3544. host["[" + hostBinding.hostPropertyName + "]"] = propName;
  3545. }
  3546. else {
  3547. host["[" + propName + "]"] = propName;
  3548. }
  3549. });
  3550. var /** @type {?} */ hostListeners = propertyMetadata[propName].filter(function (a) { return createHostListener.isTypeOf(a); });
  3551. hostListeners.forEach(function (hostListener) {
  3552. var /** @type {?} */ args = hostListener.args || [];
  3553. host["(" + hostListener.eventName + ")"] = propName + "(" + args.join(',') + ")";
  3554. });
  3555. var /** @type {?} */ query = findLast(propertyMetadata[propName], function (a) { return QUERY_METADATA_IDENTIFIERS.some(function (i) { return i.isTypeOf(a); }); });
  3556. if (query) {
  3557. queries[propName] = query;
  3558. }
  3559. });
  3560. return this._merge(dm, inputs, outputs, host, queries, guards, directiveType);
  3561. };
  3562. /**
  3563. * @param {?} def
  3564. * @return {?}
  3565. */
  3566. DirectiveResolver.prototype._extractPublicName = /**
  3567. * @param {?} def
  3568. * @return {?}
  3569. */
  3570. function (def) { return splitAtColon(def, [/** @type {?} */ ((null)), def])[1].trim(); };
  3571. /**
  3572. * @param {?} bindings
  3573. * @return {?}
  3574. */
  3575. DirectiveResolver.prototype._dedupeBindings = /**
  3576. * @param {?} bindings
  3577. * @return {?}
  3578. */
  3579. function (bindings) {
  3580. var /** @type {?} */ names = new Set();
  3581. var /** @type {?} */ publicNames = new Set();
  3582. var /** @type {?} */ reversedResult = [];
  3583. // go last to first to allow later entries to overwrite previous entries
  3584. for (var /** @type {?} */ i = bindings.length - 1; i >= 0; i--) {
  3585. var /** @type {?} */ binding = bindings[i];
  3586. var /** @type {?} */ name_1 = this._extractPublicName(binding);
  3587. publicNames.add(name_1);
  3588. if (!names.has(name_1)) {
  3589. names.add(name_1);
  3590. reversedResult.push(binding);
  3591. }
  3592. }
  3593. return reversedResult.reverse();
  3594. };
  3595. /**
  3596. * @param {?} directive
  3597. * @param {?} inputs
  3598. * @param {?} outputs
  3599. * @param {?} host
  3600. * @param {?} queries
  3601. * @param {?} guards
  3602. * @param {?} directiveType
  3603. * @return {?}
  3604. */
  3605. DirectiveResolver.prototype._merge = /**
  3606. * @param {?} directive
  3607. * @param {?} inputs
  3608. * @param {?} outputs
  3609. * @param {?} host
  3610. * @param {?} queries
  3611. * @param {?} guards
  3612. * @param {?} directiveType
  3613. * @return {?}
  3614. */
  3615. function (directive, inputs, outputs, host, queries, guards, directiveType) {
  3616. var /** @type {?} */ mergedInputs = this._dedupeBindings(directive.inputs ? directive.inputs.concat(inputs) : inputs);
  3617. var /** @type {?} */ mergedOutputs = this._dedupeBindings(directive.outputs ? directive.outputs.concat(outputs) : outputs);
  3618. var /** @type {?} */ mergedHost = directive.host ? __assign({}, directive.host, host) : host;
  3619. var /** @type {?} */ mergedQueries = directive.queries ? __assign({}, directive.queries, queries) : queries;
  3620. if (createComponent.isTypeOf(directive)) {
  3621. var /** @type {?} */ comp = /** @type {?} */ (directive);
  3622. return createComponent({
  3623. selector: comp.selector,
  3624. inputs: mergedInputs,
  3625. outputs: mergedOutputs,
  3626. host: mergedHost,
  3627. exportAs: comp.exportAs,
  3628. moduleId: comp.moduleId,
  3629. queries: mergedQueries,
  3630. changeDetection: comp.changeDetection,
  3631. providers: comp.providers,
  3632. viewProviders: comp.viewProviders,
  3633. entryComponents: comp.entryComponents,
  3634. template: comp.template,
  3635. templateUrl: comp.templateUrl,
  3636. styles: comp.styles,
  3637. styleUrls: comp.styleUrls,
  3638. encapsulation: comp.encapsulation,
  3639. animations: comp.animations,
  3640. interpolation: comp.interpolation,
  3641. preserveWhitespaces: directive.preserveWhitespaces,
  3642. });
  3643. }
  3644. else {
  3645. return createDirective({
  3646. selector: directive.selector,
  3647. inputs: mergedInputs,
  3648. outputs: mergedOutputs,
  3649. host: mergedHost,
  3650. exportAs: directive.exportAs,
  3651. queries: mergedQueries,
  3652. providers: directive.providers, guards: guards
  3653. });
  3654. }
  3655. };
  3656. return DirectiveResolver;
  3657. }());
  3658. /**
  3659. * @param {?} type
  3660. * @return {?}
  3661. */
  3662. function isDirectiveMetadata(type) {
  3663. return createDirective.isTypeOf(type) || createComponent.isTypeOf(type);
  3664. }
  3665. /**
  3666. * @template T
  3667. * @param {?} arr
  3668. * @param {?} condition
  3669. * @return {?}
  3670. */
  3671. function findLast(arr, condition) {
  3672. for (var /** @type {?} */ i = arr.length - 1; i >= 0; i--) {
  3673. if (condition(arr[i])) {
  3674. return arr[i];
  3675. }
  3676. }
  3677. return null;
  3678. }
  3679. /**
  3680. * @fileoverview added by tsickle
  3681. * @suppress {checkTypes} checked by tsc
  3682. */
  3683. /**
  3684. * @license
  3685. * Copyright Google Inc. All Rights Reserved.
  3686. *
  3687. * Use of this source code is governed by an MIT-style license that can be
  3688. * found in the LICENSE file at https://angular.io/license
  3689. */
  3690. var $EOF = 0;
  3691. var $TAB = 9;
  3692. var $LF = 10;
  3693. var $VTAB = 11;
  3694. var $FF = 12;
  3695. var $CR = 13;
  3696. var $SPACE = 32;
  3697. var $BANG = 33;
  3698. var $DQ = 34;
  3699. var $HASH = 35;
  3700. var $$ = 36;
  3701. var $PERCENT = 37;
  3702. var $AMPERSAND = 38;
  3703. var $SQ = 39;
  3704. var $LPAREN = 40;
  3705. var $RPAREN = 41;
  3706. var $STAR = 42;
  3707. var $PLUS = 43;
  3708. var $COMMA = 44;
  3709. var $MINUS = 45;
  3710. var $PERIOD = 46;
  3711. var $SLASH = 47;
  3712. var $COLON = 58;
  3713. var $SEMICOLON = 59;
  3714. var $LT = 60;
  3715. var $EQ = 61;
  3716. var $GT = 62;
  3717. var $QUESTION = 63;
  3718. var $0 = 48;
  3719. var $9 = 57;
  3720. var $A = 65;
  3721. var $E = 69;
  3722. var $F = 70;
  3723. var $X = 88;
  3724. var $Z = 90;
  3725. var $LBRACKET = 91;
  3726. var $BACKSLASH = 92;
  3727. var $RBRACKET = 93;
  3728. var $CARET = 94;
  3729. var $_ = 95;
  3730. var $a = 97;
  3731. var $e = 101;
  3732. var $f = 102;
  3733. var $n = 110;
  3734. var $r = 114;
  3735. var $t = 116;
  3736. var $u = 117;
  3737. var $v = 118;
  3738. var $x = 120;
  3739. var $z = 122;
  3740. var $LBRACE = 123;
  3741. var $BAR = 124;
  3742. var $RBRACE = 125;
  3743. var $NBSP = 160;
  3744. var $BT = 96;
  3745. /**
  3746. * @param {?} code
  3747. * @return {?}
  3748. */
  3749. function isWhitespace(code) {
  3750. return (code >= $TAB && code <= $SPACE) || (code == $NBSP);
  3751. }
  3752. /**
  3753. * @param {?} code
  3754. * @return {?}
  3755. */
  3756. function isDigit(code) {
  3757. return $0 <= code && code <= $9;
  3758. }
  3759. /**
  3760. * @param {?} code
  3761. * @return {?}
  3762. */
  3763. function isAsciiLetter(code) {
  3764. return code >= $a && code <= $z || code >= $A && code <= $Z;
  3765. }
  3766. /**
  3767. * @param {?} code
  3768. * @return {?}
  3769. */
  3770. function isAsciiHexDigit(code) {
  3771. return code >= $a && code <= $f || code >= $A && code <= $F || isDigit(code);
  3772. }
  3773. /**
  3774. * @fileoverview added by tsickle
  3775. * @suppress {checkTypes} checked by tsc
  3776. */
  3777. /**
  3778. * @license
  3779. * Copyright Google Inc. All Rights Reserved.
  3780. *
  3781. * Use of this source code is governed by an MIT-style license that can be
  3782. * found in the LICENSE file at https://angular.io/license
  3783. */
  3784. /** @enum {number} */
  3785. var TokenType = {
  3786. Character: 0,
  3787. Identifier: 1,
  3788. Keyword: 2,
  3789. String: 3,
  3790. Operator: 4,
  3791. Number: 5,
  3792. Error: 6,
  3793. };
  3794. TokenType[TokenType.Character] = "Character";
  3795. TokenType[TokenType.Identifier] = "Identifier";
  3796. TokenType[TokenType.Keyword] = "Keyword";
  3797. TokenType[TokenType.String] = "String";
  3798. TokenType[TokenType.Operator] = "Operator";
  3799. TokenType[TokenType.Number] = "Number";
  3800. TokenType[TokenType.Error] = "Error";
  3801. var KEYWORDS = ['var', 'let', 'as', 'null', 'undefined', 'true', 'false', 'if', 'else', 'this'];
  3802. var Lexer = /** @class */ (function () {
  3803. function Lexer() {
  3804. }
  3805. /**
  3806. * @param {?} text
  3807. * @return {?}
  3808. */
  3809. Lexer.prototype.tokenize = /**
  3810. * @param {?} text
  3811. * @return {?}
  3812. */
  3813. function (text) {
  3814. var /** @type {?} */ scanner = new _Scanner(text);
  3815. var /** @type {?} */ tokens = [];
  3816. var /** @type {?} */ token = scanner.scanToken();
  3817. while (token != null) {
  3818. tokens.push(token);
  3819. token = scanner.scanToken();
  3820. }
  3821. return tokens;
  3822. };
  3823. return Lexer;
  3824. }());
  3825. var Token = /** @class */ (function () {
  3826. function Token(index, type, numValue, strValue) {
  3827. this.index = index;
  3828. this.type = type;
  3829. this.numValue = numValue;
  3830. this.strValue = strValue;
  3831. }
  3832. /**
  3833. * @param {?} code
  3834. * @return {?}
  3835. */
  3836. Token.prototype.isCharacter = /**
  3837. * @param {?} code
  3838. * @return {?}
  3839. */
  3840. function (code) {
  3841. return this.type == TokenType.Character && this.numValue == code;
  3842. };
  3843. /**
  3844. * @return {?}
  3845. */
  3846. Token.prototype.isNumber = /**
  3847. * @return {?}
  3848. */
  3849. function () { return this.type == TokenType.Number; };
  3850. /**
  3851. * @return {?}
  3852. */
  3853. Token.prototype.isString = /**
  3854. * @return {?}
  3855. */
  3856. function () { return this.type == TokenType.String; };
  3857. /**
  3858. * @param {?} operater
  3859. * @return {?}
  3860. */
  3861. Token.prototype.isOperator = /**
  3862. * @param {?} operater
  3863. * @return {?}
  3864. */
  3865. function (operater) {
  3866. return this.type == TokenType.Operator && this.strValue == operater;
  3867. };
  3868. /**
  3869. * @return {?}
  3870. */
  3871. Token.prototype.isIdentifier = /**
  3872. * @return {?}
  3873. */
  3874. function () { return this.type == TokenType.Identifier; };
  3875. /**
  3876. * @return {?}
  3877. */
  3878. Token.prototype.isKeyword = /**
  3879. * @return {?}
  3880. */
  3881. function () { return this.type == TokenType.Keyword; };
  3882. /**
  3883. * @return {?}
  3884. */
  3885. Token.prototype.isKeywordLet = /**
  3886. * @return {?}
  3887. */
  3888. function () { return this.type == TokenType.Keyword && this.strValue == 'let'; };
  3889. /**
  3890. * @return {?}
  3891. */
  3892. Token.prototype.isKeywordAs = /**
  3893. * @return {?}
  3894. */
  3895. function () { return this.type == TokenType.Keyword && this.strValue == 'as'; };
  3896. /**
  3897. * @return {?}
  3898. */
  3899. Token.prototype.isKeywordNull = /**
  3900. * @return {?}
  3901. */
  3902. function () { return this.type == TokenType.Keyword && this.strValue == 'null'; };
  3903. /**
  3904. * @return {?}
  3905. */
  3906. Token.prototype.isKeywordUndefined = /**
  3907. * @return {?}
  3908. */
  3909. function () {
  3910. return this.type == TokenType.Keyword && this.strValue == 'undefined';
  3911. };
  3912. /**
  3913. * @return {?}
  3914. */
  3915. Token.prototype.isKeywordTrue = /**
  3916. * @return {?}
  3917. */
  3918. function () { return this.type == TokenType.Keyword && this.strValue == 'true'; };
  3919. /**
  3920. * @return {?}
  3921. */
  3922. Token.prototype.isKeywordFalse = /**
  3923. * @return {?}
  3924. */
  3925. function () { return this.type == TokenType.Keyword && this.strValue == 'false'; };
  3926. /**
  3927. * @return {?}
  3928. */
  3929. Token.prototype.isKeywordThis = /**
  3930. * @return {?}
  3931. */
  3932. function () { return this.type == TokenType.Keyword && this.strValue == 'this'; };
  3933. /**
  3934. * @return {?}
  3935. */
  3936. Token.prototype.isError = /**
  3937. * @return {?}
  3938. */
  3939. function () { return this.type == TokenType.Error; };
  3940. /**
  3941. * @return {?}
  3942. */
  3943. Token.prototype.toNumber = /**
  3944. * @return {?}
  3945. */
  3946. function () { return this.type == TokenType.Number ? this.numValue : -1; };
  3947. /**
  3948. * @return {?}
  3949. */
  3950. Token.prototype.toString = /**
  3951. * @return {?}
  3952. */
  3953. function () {
  3954. switch (this.type) {
  3955. case TokenType.Character:
  3956. case TokenType.Identifier:
  3957. case TokenType.Keyword:
  3958. case TokenType.Operator:
  3959. case TokenType.String:
  3960. case TokenType.Error:
  3961. return this.strValue;
  3962. case TokenType.Number:
  3963. return this.numValue.toString();
  3964. default:
  3965. return null;
  3966. }
  3967. };
  3968. return Token;
  3969. }());
  3970. /**
  3971. * @param {?} index
  3972. * @param {?} code
  3973. * @return {?}
  3974. */
  3975. function newCharacterToken(index, code) {
  3976. return new Token(index, TokenType.Character, code, String.fromCharCode(code));
  3977. }
  3978. /**
  3979. * @param {?} index
  3980. * @param {?} text
  3981. * @return {?}
  3982. */
  3983. function newIdentifierToken(index, text) {
  3984. return new Token(index, TokenType.Identifier, 0, text);
  3985. }
  3986. /**
  3987. * @param {?} index
  3988. * @param {?} text
  3989. * @return {?}
  3990. */
  3991. function newKeywordToken(index, text) {
  3992. return new Token(index, TokenType.Keyword, 0, text);
  3993. }
  3994. /**
  3995. * @param {?} index
  3996. * @param {?} text
  3997. * @return {?}
  3998. */
  3999. function newOperatorToken(index, text) {
  4000. return new Token(index, TokenType.Operator, 0, text);
  4001. }
  4002. /**
  4003. * @param {?} index
  4004. * @param {?} text
  4005. * @return {?}
  4006. */
  4007. function newStringToken(index, text) {
  4008. return new Token(index, TokenType.String, 0, text);
  4009. }
  4010. /**
  4011. * @param {?} index
  4012. * @param {?} n
  4013. * @return {?}
  4014. */
  4015. function newNumberToken(index, n) {
  4016. return new Token(index, TokenType.Number, n, '');
  4017. }
  4018. /**
  4019. * @param {?} index
  4020. * @param {?} message
  4021. * @return {?}
  4022. */
  4023. function newErrorToken(index, message) {
  4024. return new Token(index, TokenType.Error, 0, message);
  4025. }
  4026. var EOF = new Token(-1, TokenType.Character, 0, '');
  4027. var _Scanner = /** @class */ (function () {
  4028. function _Scanner(input) {
  4029. this.input = input;
  4030. this.peek = 0;
  4031. this.index = -1;
  4032. this.length = input.length;
  4033. this.advance();
  4034. }
  4035. /**
  4036. * @return {?}
  4037. */
  4038. _Scanner.prototype.advance = /**
  4039. * @return {?}
  4040. */
  4041. function () {
  4042. this.peek = ++this.index >= this.length ? $EOF : this.input.charCodeAt(this.index);
  4043. };
  4044. /**
  4045. * @return {?}
  4046. */
  4047. _Scanner.prototype.scanToken = /**
  4048. * @return {?}
  4049. */
  4050. function () {
  4051. var /** @type {?} */ input = this.input, /** @type {?} */ length = this.length;
  4052. var /** @type {?} */ peek = this.peek, /** @type {?} */ index = this.index;
  4053. // Skip whitespace.
  4054. while (peek <= $SPACE) {
  4055. if (++index >= length) {
  4056. peek = $EOF;
  4057. break;
  4058. }
  4059. else {
  4060. peek = input.charCodeAt(index);
  4061. }
  4062. }
  4063. this.peek = peek;
  4064. this.index = index;
  4065. if (index >= length) {
  4066. return null;
  4067. }
  4068. // Handle identifiers and numbers.
  4069. if (isIdentifierStart(peek))
  4070. return this.scanIdentifier();
  4071. if (isDigit(peek))
  4072. return this.scanNumber(index);
  4073. var /** @type {?} */ start = index;
  4074. switch (peek) {
  4075. case $PERIOD:
  4076. this.advance();
  4077. return isDigit(this.peek) ? this.scanNumber(start) :
  4078. newCharacterToken(start, $PERIOD);
  4079. case $LPAREN:
  4080. case $RPAREN:
  4081. case $LBRACE:
  4082. case $RBRACE:
  4083. case $LBRACKET:
  4084. case $RBRACKET:
  4085. case $COMMA:
  4086. case $COLON:
  4087. case $SEMICOLON:
  4088. return this.scanCharacter(start, peek);
  4089. case $SQ:
  4090. case $DQ:
  4091. return this.scanString();
  4092. case $HASH:
  4093. case $PLUS:
  4094. case $MINUS:
  4095. case $STAR:
  4096. case $SLASH:
  4097. case $PERCENT:
  4098. case $CARET:
  4099. return this.scanOperator(start, String.fromCharCode(peek));
  4100. case $QUESTION:
  4101. return this.scanComplexOperator(start, '?', $PERIOD, '.');
  4102. case $LT:
  4103. case $GT:
  4104. return this.scanComplexOperator(start, String.fromCharCode(peek), $EQ, '=');
  4105. case $BANG:
  4106. case $EQ:
  4107. return this.scanComplexOperator(start, String.fromCharCode(peek), $EQ, '=', $EQ, '=');
  4108. case $AMPERSAND:
  4109. return this.scanComplexOperator(start, '&', $AMPERSAND, '&');
  4110. case $BAR:
  4111. return this.scanComplexOperator(start, '|', $BAR, '|');
  4112. case $NBSP:
  4113. while (isWhitespace(this.peek))
  4114. this.advance();
  4115. return this.scanToken();
  4116. }
  4117. this.advance();
  4118. return this.error("Unexpected character [" + String.fromCharCode(peek) + "]", 0);
  4119. };
  4120. /**
  4121. * @param {?} start
  4122. * @param {?} code
  4123. * @return {?}
  4124. */
  4125. _Scanner.prototype.scanCharacter = /**
  4126. * @param {?} start
  4127. * @param {?} code
  4128. * @return {?}
  4129. */
  4130. function (start, code) {
  4131. this.advance();
  4132. return newCharacterToken(start, code);
  4133. };
  4134. /**
  4135. * @param {?} start
  4136. * @param {?} str
  4137. * @return {?}
  4138. */
  4139. _Scanner.prototype.scanOperator = /**
  4140. * @param {?} start
  4141. * @param {?} str
  4142. * @return {?}
  4143. */
  4144. function (start, str) {
  4145. this.advance();
  4146. return newOperatorToken(start, str);
  4147. };
  4148. /**
  4149. * Tokenize a 2/3 char long operator
  4150. *
  4151. * @param start start index in the expression
  4152. * @param one first symbol (always part of the operator)
  4153. * @param twoCode code point for the second symbol
  4154. * @param two second symbol (part of the operator when the second code point matches)
  4155. * @param threeCode code point for the third symbol
  4156. * @param three third symbol (part of the operator when provided and matches source expression)
  4157. */
  4158. /**
  4159. * Tokenize a 2/3 char long operator
  4160. *
  4161. * @param {?} start start index in the expression
  4162. * @param {?} one first symbol (always part of the operator)
  4163. * @param {?} twoCode code point for the second symbol
  4164. * @param {?} two second symbol (part of the operator when the second code point matches)
  4165. * @param {?=} threeCode code point for the third symbol
  4166. * @param {?=} three third symbol (part of the operator when provided and matches source expression)
  4167. * @return {?}
  4168. */
  4169. _Scanner.prototype.scanComplexOperator = /**
  4170. * Tokenize a 2/3 char long operator
  4171. *
  4172. * @param {?} start start index in the expression
  4173. * @param {?} one first symbol (always part of the operator)
  4174. * @param {?} twoCode code point for the second symbol
  4175. * @param {?} two second symbol (part of the operator when the second code point matches)
  4176. * @param {?=} threeCode code point for the third symbol
  4177. * @param {?=} three third symbol (part of the operator when provided and matches source expression)
  4178. * @return {?}
  4179. */
  4180. function (start, one, twoCode, two, threeCode, three) {
  4181. this.advance();
  4182. var /** @type {?} */ str = one;
  4183. if (this.peek == twoCode) {
  4184. this.advance();
  4185. str += two;
  4186. }
  4187. if (threeCode != null && this.peek == threeCode) {
  4188. this.advance();
  4189. str += three;
  4190. }
  4191. return newOperatorToken(start, str);
  4192. };
  4193. /**
  4194. * @return {?}
  4195. */
  4196. _Scanner.prototype.scanIdentifier = /**
  4197. * @return {?}
  4198. */
  4199. function () {
  4200. var /** @type {?} */ start = this.index;
  4201. this.advance();
  4202. while (isIdentifierPart(this.peek))
  4203. this.advance();
  4204. var /** @type {?} */ str = this.input.substring(start, this.index);
  4205. return KEYWORDS.indexOf(str) > -1 ? newKeywordToken(start, str) :
  4206. newIdentifierToken(start, str);
  4207. };
  4208. /**
  4209. * @param {?} start
  4210. * @return {?}
  4211. */
  4212. _Scanner.prototype.scanNumber = /**
  4213. * @param {?} start
  4214. * @return {?}
  4215. */
  4216. function (start) {
  4217. var /** @type {?} */ simple = (this.index === start);
  4218. this.advance(); // Skip initial digit.
  4219. while (true) {
  4220. if (isDigit(this.peek)) {
  4221. // Do nothing.
  4222. }
  4223. else if (this.peek == $PERIOD) {
  4224. simple = false;
  4225. }
  4226. else if (isExponentStart(this.peek)) {
  4227. this.advance();
  4228. if (isExponentSign(this.peek))
  4229. this.advance();
  4230. if (!isDigit(this.peek))
  4231. return this.error('Invalid exponent', -1);
  4232. simple = false;
  4233. }
  4234. else {
  4235. break;
  4236. }
  4237. this.advance();
  4238. }
  4239. var /** @type {?} */ str = this.input.substring(start, this.index);
  4240. var /** @type {?} */ value = simple ? parseIntAutoRadix(str) : parseFloat(str);
  4241. return newNumberToken(start, value);
  4242. };
  4243. /**
  4244. * @return {?}
  4245. */
  4246. _Scanner.prototype.scanString = /**
  4247. * @return {?}
  4248. */
  4249. function () {
  4250. var /** @type {?} */ start = this.index;
  4251. var /** @type {?} */ quote = this.peek;
  4252. this.advance(); // Skip initial quote.
  4253. var /** @type {?} */ buffer = '';
  4254. var /** @type {?} */ marker = this.index;
  4255. var /** @type {?} */ input = this.input;
  4256. while (this.peek != quote) {
  4257. if (this.peek == $BACKSLASH) {
  4258. buffer += input.substring(marker, this.index);
  4259. this.advance();
  4260. var /** @type {?} */ unescapedCode = void 0;
  4261. // Workaround for TS2.1-introduced type strictness
  4262. this.peek = this.peek;
  4263. if (this.peek == $u) {
  4264. // 4 character hex code for unicode character.
  4265. var /** @type {?} */ hex = input.substring(this.index + 1, this.index + 5);
  4266. if (/^[0-9a-f]+$/i.test(hex)) {
  4267. unescapedCode = parseInt(hex, 16);
  4268. }
  4269. else {
  4270. return this.error("Invalid unicode escape [\\u" + hex + "]", 0);
  4271. }
  4272. for (var /** @type {?} */ i = 0; i < 5; i++) {
  4273. this.advance();
  4274. }
  4275. }
  4276. else {
  4277. unescapedCode = unescape(this.peek);
  4278. this.advance();
  4279. }
  4280. buffer += String.fromCharCode(unescapedCode);
  4281. marker = this.index;
  4282. }
  4283. else if (this.peek == $EOF) {
  4284. return this.error('Unterminated quote', 0);
  4285. }
  4286. else {
  4287. this.advance();
  4288. }
  4289. }
  4290. var /** @type {?} */ last = input.substring(marker, this.index);
  4291. this.advance(); // Skip terminating quote.
  4292. return newStringToken(start, buffer + last);
  4293. };
  4294. /**
  4295. * @param {?} message
  4296. * @param {?} offset
  4297. * @return {?}
  4298. */
  4299. _Scanner.prototype.error = /**
  4300. * @param {?} message
  4301. * @param {?} offset
  4302. * @return {?}
  4303. */
  4304. function (message, offset) {
  4305. var /** @type {?} */ position = this.index + offset;
  4306. return newErrorToken(position, "Lexer Error: " + message + " at column " + position + " in expression [" + this.input + "]");
  4307. };
  4308. return _Scanner;
  4309. }());
  4310. /**
  4311. * @param {?} code
  4312. * @return {?}
  4313. */
  4314. function isIdentifierStart(code) {
  4315. return ($a <= code && code <= $z) || ($A <= code && code <= $Z) ||
  4316. (code == $_) || (code == $$);
  4317. }
  4318. /**
  4319. * @param {?} input
  4320. * @return {?}
  4321. */
  4322. function isIdentifier(input) {
  4323. if (input.length == 0)
  4324. return false;
  4325. var /** @type {?} */ scanner = new _Scanner(input);
  4326. if (!isIdentifierStart(scanner.peek))
  4327. return false;
  4328. scanner.advance();
  4329. while (scanner.peek !== $EOF) {
  4330. if (!isIdentifierPart(scanner.peek))
  4331. return false;
  4332. scanner.advance();
  4333. }
  4334. return true;
  4335. }
  4336. /**
  4337. * @param {?} code
  4338. * @return {?}
  4339. */
  4340. function isIdentifierPart(code) {
  4341. return isAsciiLetter(code) || isDigit(code) || (code == $_) ||
  4342. (code == $$);
  4343. }
  4344. /**
  4345. * @param {?} code
  4346. * @return {?}
  4347. */
  4348. function isExponentStart(code) {
  4349. return code == $e || code == $E;
  4350. }
  4351. /**
  4352. * @param {?} code
  4353. * @return {?}
  4354. */
  4355. function isExponentSign(code) {
  4356. return code == $MINUS || code == $PLUS;
  4357. }
  4358. /**
  4359. * @param {?} code
  4360. * @return {?}
  4361. */
  4362. function isQuote(code) {
  4363. return code === $SQ || code === $DQ || code === $BT;
  4364. }
  4365. /**
  4366. * @param {?} code
  4367. * @return {?}
  4368. */
  4369. function unescape(code) {
  4370. switch (code) {
  4371. case $n:
  4372. return $LF;
  4373. case $f:
  4374. return $FF;
  4375. case $r:
  4376. return $CR;
  4377. case $t:
  4378. return $TAB;
  4379. case $v:
  4380. return $VTAB;
  4381. default:
  4382. return code;
  4383. }
  4384. }
  4385. /**
  4386. * @param {?} text
  4387. * @return {?}
  4388. */
  4389. function parseIntAutoRadix(text) {
  4390. var /** @type {?} */ result = parseInt(text);
  4391. if (isNaN(result)) {
  4392. throw new Error('Invalid integer literal when parsing ' + text);
  4393. }
  4394. return result;
  4395. }
  4396. /**
  4397. * @fileoverview added by tsickle
  4398. * @suppress {checkTypes} checked by tsc
  4399. */
  4400. /**
  4401. * @license
  4402. * Copyright Google Inc. All Rights Reserved.
  4403. *
  4404. * Use of this source code is governed by an MIT-style license that can be
  4405. * found in the LICENSE file at https://angular.io/license
  4406. */
  4407. var ParserError = /** @class */ (function () {
  4408. function ParserError(message, input, errLocation, ctxLocation) {
  4409. this.input = input;
  4410. this.errLocation = errLocation;
  4411. this.ctxLocation = ctxLocation;
  4412. this.message = "Parser Error: " + message + " " + errLocation + " [" + input + "] in " + ctxLocation;
  4413. }
  4414. return ParserError;
  4415. }());
  4416. var ParseSpan = /** @class */ (function () {
  4417. function ParseSpan(start, end) {
  4418. this.start = start;
  4419. this.end = end;
  4420. }
  4421. return ParseSpan;
  4422. }());
  4423. var AST = /** @class */ (function () {
  4424. function AST(span) {
  4425. this.span = span;
  4426. }
  4427. /**
  4428. * @param {?} visitor
  4429. * @param {?=} context
  4430. * @return {?}
  4431. */
  4432. AST.prototype.visit = /**
  4433. * @param {?} visitor
  4434. * @param {?=} context
  4435. * @return {?}
  4436. */
  4437. function (visitor, context) {
  4438. if (context === void 0) { context = null; }
  4439. return null;
  4440. };
  4441. /**
  4442. * @return {?}
  4443. */
  4444. AST.prototype.toString = /**
  4445. * @return {?}
  4446. */
  4447. function () { return 'AST'; };
  4448. return AST;
  4449. }());
  4450. /**
  4451. * Represents a quoted expression of the form:
  4452. *
  4453. * quote = prefix `:` uninterpretedExpression
  4454. * prefix = identifier
  4455. * uninterpretedExpression = arbitrary string
  4456. *
  4457. * A quoted expression is meant to be pre-processed by an AST transformer that
  4458. * converts it into another AST that no longer contains quoted expressions.
  4459. * It is meant to allow third-party developers to extend Angular template
  4460. * expression language. The `uninterpretedExpression` part of the quote is
  4461. * therefore not interpreted by the Angular's own expression parser.
  4462. */
  4463. var Quote = /** @class */ (function (_super) {
  4464. __extends(Quote, _super);
  4465. function Quote(span, prefix, uninterpretedExpression, location) {
  4466. var _this = _super.call(this, span) || this;
  4467. _this.prefix = prefix;
  4468. _this.uninterpretedExpression = uninterpretedExpression;
  4469. _this.location = location;
  4470. return _this;
  4471. }
  4472. /**
  4473. * @param {?} visitor
  4474. * @param {?=} context
  4475. * @return {?}
  4476. */
  4477. Quote.prototype.visit = /**
  4478. * @param {?} visitor
  4479. * @param {?=} context
  4480. * @return {?}
  4481. */
  4482. function (visitor, context) {
  4483. if (context === void 0) { context = null; }
  4484. return visitor.visitQuote(this, context);
  4485. };
  4486. /**
  4487. * @return {?}
  4488. */
  4489. Quote.prototype.toString = /**
  4490. * @return {?}
  4491. */
  4492. function () { return 'Quote'; };
  4493. return Quote;
  4494. }(AST));
  4495. var EmptyExpr = /** @class */ (function (_super) {
  4496. __extends(EmptyExpr, _super);
  4497. function EmptyExpr() {
  4498. return _super !== null && _super.apply(this, arguments) || this;
  4499. }
  4500. /**
  4501. * @param {?} visitor
  4502. * @param {?=} context
  4503. * @return {?}
  4504. */
  4505. EmptyExpr.prototype.visit = /**
  4506. * @param {?} visitor
  4507. * @param {?=} context
  4508. * @return {?}
  4509. */
  4510. function (visitor, context) {
  4511. if (context === void 0) { context = null; }
  4512. // do nothing
  4513. };
  4514. return EmptyExpr;
  4515. }(AST));
  4516. var ImplicitReceiver = /** @class */ (function (_super) {
  4517. __extends(ImplicitReceiver, _super);
  4518. function ImplicitReceiver() {
  4519. return _super !== null && _super.apply(this, arguments) || this;
  4520. }
  4521. /**
  4522. * @param {?} visitor
  4523. * @param {?=} context
  4524. * @return {?}
  4525. */
  4526. ImplicitReceiver.prototype.visit = /**
  4527. * @param {?} visitor
  4528. * @param {?=} context
  4529. * @return {?}
  4530. */
  4531. function (visitor, context) {
  4532. if (context === void 0) { context = null; }
  4533. return visitor.visitImplicitReceiver(this, context);
  4534. };
  4535. return ImplicitReceiver;
  4536. }(AST));
  4537. /**
  4538. * Multiple expressions separated by a semicolon.
  4539. */
  4540. var Chain = /** @class */ (function (_super) {
  4541. __extends(Chain, _super);
  4542. function Chain(span, expressions) {
  4543. var _this = _super.call(this, span) || this;
  4544. _this.expressions = expressions;
  4545. return _this;
  4546. }
  4547. /**
  4548. * @param {?} visitor
  4549. * @param {?=} context
  4550. * @return {?}
  4551. */
  4552. Chain.prototype.visit = /**
  4553. * @param {?} visitor
  4554. * @param {?=} context
  4555. * @return {?}
  4556. */
  4557. function (visitor, context) {
  4558. if (context === void 0) { context = null; }
  4559. return visitor.visitChain(this, context);
  4560. };
  4561. return Chain;
  4562. }(AST));
  4563. var Conditional = /** @class */ (function (_super) {
  4564. __extends(Conditional, _super);
  4565. function Conditional(span, condition, trueExp, falseExp) {
  4566. var _this = _super.call(this, span) || this;
  4567. _this.condition = condition;
  4568. _this.trueExp = trueExp;
  4569. _this.falseExp = falseExp;
  4570. return _this;
  4571. }
  4572. /**
  4573. * @param {?} visitor
  4574. * @param {?=} context
  4575. * @return {?}
  4576. */
  4577. Conditional.prototype.visit = /**
  4578. * @param {?} visitor
  4579. * @param {?=} context
  4580. * @return {?}
  4581. */
  4582. function (visitor, context) {
  4583. if (context === void 0) { context = null; }
  4584. return visitor.visitConditional(this, context);
  4585. };
  4586. return Conditional;
  4587. }(AST));
  4588. var PropertyRead = /** @class */ (function (_super) {
  4589. __extends(PropertyRead, _super);
  4590. function PropertyRead(span, receiver, name) {
  4591. var _this = _super.call(this, span) || this;
  4592. _this.receiver = receiver;
  4593. _this.name = name;
  4594. return _this;
  4595. }
  4596. /**
  4597. * @param {?} visitor
  4598. * @param {?=} context
  4599. * @return {?}
  4600. */
  4601. PropertyRead.prototype.visit = /**
  4602. * @param {?} visitor
  4603. * @param {?=} context
  4604. * @return {?}
  4605. */
  4606. function (visitor, context) {
  4607. if (context === void 0) { context = null; }
  4608. return visitor.visitPropertyRead(this, context);
  4609. };
  4610. return PropertyRead;
  4611. }(AST));
  4612. var PropertyWrite = /** @class */ (function (_super) {
  4613. __extends(PropertyWrite, _super);
  4614. function PropertyWrite(span, receiver, name, value) {
  4615. var _this = _super.call(this, span) || this;
  4616. _this.receiver = receiver;
  4617. _this.name = name;
  4618. _this.value = value;
  4619. return _this;
  4620. }
  4621. /**
  4622. * @param {?} visitor
  4623. * @param {?=} context
  4624. * @return {?}
  4625. */
  4626. PropertyWrite.prototype.visit = /**
  4627. * @param {?} visitor
  4628. * @param {?=} context
  4629. * @return {?}
  4630. */
  4631. function (visitor, context) {
  4632. if (context === void 0) { context = null; }
  4633. return visitor.visitPropertyWrite(this, context);
  4634. };
  4635. return PropertyWrite;
  4636. }(AST));
  4637. var SafePropertyRead = /** @class */ (function (_super) {
  4638. __extends(SafePropertyRead, _super);
  4639. function SafePropertyRead(span, receiver, name) {
  4640. var _this = _super.call(this, span) || this;
  4641. _this.receiver = receiver;
  4642. _this.name = name;
  4643. return _this;
  4644. }
  4645. /**
  4646. * @param {?} visitor
  4647. * @param {?=} context
  4648. * @return {?}
  4649. */
  4650. SafePropertyRead.prototype.visit = /**
  4651. * @param {?} visitor
  4652. * @param {?=} context
  4653. * @return {?}
  4654. */
  4655. function (visitor, context) {
  4656. if (context === void 0) { context = null; }
  4657. return visitor.visitSafePropertyRead(this, context);
  4658. };
  4659. return SafePropertyRead;
  4660. }(AST));
  4661. var KeyedRead = /** @class */ (function (_super) {
  4662. __extends(KeyedRead, _super);
  4663. function KeyedRead(span, obj, key) {
  4664. var _this = _super.call(this, span) || this;
  4665. _this.obj = obj;
  4666. _this.key = key;
  4667. return _this;
  4668. }
  4669. /**
  4670. * @param {?} visitor
  4671. * @param {?=} context
  4672. * @return {?}
  4673. */
  4674. KeyedRead.prototype.visit = /**
  4675. * @param {?} visitor
  4676. * @param {?=} context
  4677. * @return {?}
  4678. */
  4679. function (visitor, context) {
  4680. if (context === void 0) { context = null; }
  4681. return visitor.visitKeyedRead(this, context);
  4682. };
  4683. return KeyedRead;
  4684. }(AST));
  4685. var KeyedWrite = /** @class */ (function (_super) {
  4686. __extends(KeyedWrite, _super);
  4687. function KeyedWrite(span, obj, key, value) {
  4688. var _this = _super.call(this, span) || this;
  4689. _this.obj = obj;
  4690. _this.key = key;
  4691. _this.value = value;
  4692. return _this;
  4693. }
  4694. /**
  4695. * @param {?} visitor
  4696. * @param {?=} context
  4697. * @return {?}
  4698. */
  4699. KeyedWrite.prototype.visit = /**
  4700. * @param {?} visitor
  4701. * @param {?=} context
  4702. * @return {?}
  4703. */
  4704. function (visitor, context) {
  4705. if (context === void 0) { context = null; }
  4706. return visitor.visitKeyedWrite(this, context);
  4707. };
  4708. return KeyedWrite;
  4709. }(AST));
  4710. var BindingPipe = /** @class */ (function (_super) {
  4711. __extends(BindingPipe, _super);
  4712. function BindingPipe(span, exp, name, args) {
  4713. var _this = _super.call(this, span) || this;
  4714. _this.exp = exp;
  4715. _this.name = name;
  4716. _this.args = args;
  4717. return _this;
  4718. }
  4719. /**
  4720. * @param {?} visitor
  4721. * @param {?=} context
  4722. * @return {?}
  4723. */
  4724. BindingPipe.prototype.visit = /**
  4725. * @param {?} visitor
  4726. * @param {?=} context
  4727. * @return {?}
  4728. */
  4729. function (visitor, context) {
  4730. if (context === void 0) { context = null; }
  4731. return visitor.visitPipe(this, context);
  4732. };
  4733. return BindingPipe;
  4734. }(AST));
  4735. var LiteralPrimitive = /** @class */ (function (_super) {
  4736. __extends(LiteralPrimitive, _super);
  4737. function LiteralPrimitive(span, value) {
  4738. var _this = _super.call(this, span) || this;
  4739. _this.value = value;
  4740. return _this;
  4741. }
  4742. /**
  4743. * @param {?} visitor
  4744. * @param {?=} context
  4745. * @return {?}
  4746. */
  4747. LiteralPrimitive.prototype.visit = /**
  4748. * @param {?} visitor
  4749. * @param {?=} context
  4750. * @return {?}
  4751. */
  4752. function (visitor, context) {
  4753. if (context === void 0) { context = null; }
  4754. return visitor.visitLiteralPrimitive(this, context);
  4755. };
  4756. return LiteralPrimitive;
  4757. }(AST));
  4758. var LiteralArray = /** @class */ (function (_super) {
  4759. __extends(LiteralArray, _super);
  4760. function LiteralArray(span, expressions) {
  4761. var _this = _super.call(this, span) || this;
  4762. _this.expressions = expressions;
  4763. return _this;
  4764. }
  4765. /**
  4766. * @param {?} visitor
  4767. * @param {?=} context
  4768. * @return {?}
  4769. */
  4770. LiteralArray.prototype.visit = /**
  4771. * @param {?} visitor
  4772. * @param {?=} context
  4773. * @return {?}
  4774. */
  4775. function (visitor, context) {
  4776. if (context === void 0) { context = null; }
  4777. return visitor.visitLiteralArray(this, context);
  4778. };
  4779. return LiteralArray;
  4780. }(AST));
  4781. var LiteralMap = /** @class */ (function (_super) {
  4782. __extends(LiteralMap, _super);
  4783. function LiteralMap(span, keys, values) {
  4784. var _this = _super.call(this, span) || this;
  4785. _this.keys = keys;
  4786. _this.values = values;
  4787. return _this;
  4788. }
  4789. /**
  4790. * @param {?} visitor
  4791. * @param {?=} context
  4792. * @return {?}
  4793. */
  4794. LiteralMap.prototype.visit = /**
  4795. * @param {?} visitor
  4796. * @param {?=} context
  4797. * @return {?}
  4798. */
  4799. function (visitor, context) {
  4800. if (context === void 0) { context = null; }
  4801. return visitor.visitLiteralMap(this, context);
  4802. };
  4803. return LiteralMap;
  4804. }(AST));
  4805. var Interpolation = /** @class */ (function (_super) {
  4806. __extends(Interpolation, _super);
  4807. function Interpolation(span, strings, expressions) {
  4808. var _this = _super.call(this, span) || this;
  4809. _this.strings = strings;
  4810. _this.expressions = expressions;
  4811. return _this;
  4812. }
  4813. /**
  4814. * @param {?} visitor
  4815. * @param {?=} context
  4816. * @return {?}
  4817. */
  4818. Interpolation.prototype.visit = /**
  4819. * @param {?} visitor
  4820. * @param {?=} context
  4821. * @return {?}
  4822. */
  4823. function (visitor, context) {
  4824. if (context === void 0) { context = null; }
  4825. return visitor.visitInterpolation(this, context);
  4826. };
  4827. return Interpolation;
  4828. }(AST));
  4829. var Binary = /** @class */ (function (_super) {
  4830. __extends(Binary, _super);
  4831. function Binary(span, operation, left, right) {
  4832. var _this = _super.call(this, span) || this;
  4833. _this.operation = operation;
  4834. _this.left = left;
  4835. _this.right = right;
  4836. return _this;
  4837. }
  4838. /**
  4839. * @param {?} visitor
  4840. * @param {?=} context
  4841. * @return {?}
  4842. */
  4843. Binary.prototype.visit = /**
  4844. * @param {?} visitor
  4845. * @param {?=} context
  4846. * @return {?}
  4847. */
  4848. function (visitor, context) {
  4849. if (context === void 0) { context = null; }
  4850. return visitor.visitBinary(this, context);
  4851. };
  4852. return Binary;
  4853. }(AST));
  4854. var PrefixNot = /** @class */ (function (_super) {
  4855. __extends(PrefixNot, _super);
  4856. function PrefixNot(span, expression) {
  4857. var _this = _super.call(this, span) || this;
  4858. _this.expression = expression;
  4859. return _this;
  4860. }
  4861. /**
  4862. * @param {?} visitor
  4863. * @param {?=} context
  4864. * @return {?}
  4865. */
  4866. PrefixNot.prototype.visit = /**
  4867. * @param {?} visitor
  4868. * @param {?=} context
  4869. * @return {?}
  4870. */
  4871. function (visitor, context) {
  4872. if (context === void 0) { context = null; }
  4873. return visitor.visitPrefixNot(this, context);
  4874. };
  4875. return PrefixNot;
  4876. }(AST));
  4877. var NonNullAssert = /** @class */ (function (_super) {
  4878. __extends(NonNullAssert, _super);
  4879. function NonNullAssert(span, expression) {
  4880. var _this = _super.call(this, span) || this;
  4881. _this.expression = expression;
  4882. return _this;
  4883. }
  4884. /**
  4885. * @param {?} visitor
  4886. * @param {?=} context
  4887. * @return {?}
  4888. */
  4889. NonNullAssert.prototype.visit = /**
  4890. * @param {?} visitor
  4891. * @param {?=} context
  4892. * @return {?}
  4893. */
  4894. function (visitor, context) {
  4895. if (context === void 0) { context = null; }
  4896. return visitor.visitNonNullAssert(this, context);
  4897. };
  4898. return NonNullAssert;
  4899. }(AST));
  4900. var MethodCall = /** @class */ (function (_super) {
  4901. __extends(MethodCall, _super);
  4902. function MethodCall(span, receiver, name, args) {
  4903. var _this = _super.call(this, span) || this;
  4904. _this.receiver = receiver;
  4905. _this.name = name;
  4906. _this.args = args;
  4907. return _this;
  4908. }
  4909. /**
  4910. * @param {?} visitor
  4911. * @param {?=} context
  4912. * @return {?}
  4913. */
  4914. MethodCall.prototype.visit = /**
  4915. * @param {?} visitor
  4916. * @param {?=} context
  4917. * @return {?}
  4918. */
  4919. function (visitor, context) {
  4920. if (context === void 0) { context = null; }
  4921. return visitor.visitMethodCall(this, context);
  4922. };
  4923. return MethodCall;
  4924. }(AST));
  4925. var SafeMethodCall = /** @class */ (function (_super) {
  4926. __extends(SafeMethodCall, _super);
  4927. function SafeMethodCall(span, receiver, name, args) {
  4928. var _this = _super.call(this, span) || this;
  4929. _this.receiver = receiver;
  4930. _this.name = name;
  4931. _this.args = args;
  4932. return _this;
  4933. }
  4934. /**
  4935. * @param {?} visitor
  4936. * @param {?=} context
  4937. * @return {?}
  4938. */
  4939. SafeMethodCall.prototype.visit = /**
  4940. * @param {?} visitor
  4941. * @param {?=} context
  4942. * @return {?}
  4943. */
  4944. function (visitor, context) {
  4945. if (context === void 0) { context = null; }
  4946. return visitor.visitSafeMethodCall(this, context);
  4947. };
  4948. return SafeMethodCall;
  4949. }(AST));
  4950. var FunctionCall = /** @class */ (function (_super) {
  4951. __extends(FunctionCall, _super);
  4952. function FunctionCall(span, target, args) {
  4953. var _this = _super.call(this, span) || this;
  4954. _this.target = target;
  4955. _this.args = args;
  4956. return _this;
  4957. }
  4958. /**
  4959. * @param {?} visitor
  4960. * @param {?=} context
  4961. * @return {?}
  4962. */
  4963. FunctionCall.prototype.visit = /**
  4964. * @param {?} visitor
  4965. * @param {?=} context
  4966. * @return {?}
  4967. */
  4968. function (visitor, context) {
  4969. if (context === void 0) { context = null; }
  4970. return visitor.visitFunctionCall(this, context);
  4971. };
  4972. return FunctionCall;
  4973. }(AST));
  4974. var ASTWithSource = /** @class */ (function (_super) {
  4975. __extends(ASTWithSource, _super);
  4976. function ASTWithSource(ast, source, location, errors) {
  4977. var _this = _super.call(this, new ParseSpan(0, source == null ? 0 : source.length)) || this;
  4978. _this.ast = ast;
  4979. _this.source = source;
  4980. _this.location = location;
  4981. _this.errors = errors;
  4982. return _this;
  4983. }
  4984. /**
  4985. * @param {?} visitor
  4986. * @param {?=} context
  4987. * @return {?}
  4988. */
  4989. ASTWithSource.prototype.visit = /**
  4990. * @param {?} visitor
  4991. * @param {?=} context
  4992. * @return {?}
  4993. */
  4994. function (visitor, context) {
  4995. if (context === void 0) { context = null; }
  4996. return this.ast.visit(visitor, context);
  4997. };
  4998. /**
  4999. * @return {?}
  5000. */
  5001. ASTWithSource.prototype.toString = /**
  5002. * @return {?}
  5003. */
  5004. function () { return this.source + " in " + this.location; };
  5005. return ASTWithSource;
  5006. }(AST));
  5007. var TemplateBinding = /** @class */ (function () {
  5008. function TemplateBinding(span, key, keyIsVar, name, expression) {
  5009. this.span = span;
  5010. this.key = key;
  5011. this.keyIsVar = keyIsVar;
  5012. this.name = name;
  5013. this.expression = expression;
  5014. }
  5015. return TemplateBinding;
  5016. }());
  5017. /**
  5018. * @record
  5019. */
  5020. var NullAstVisitor = /** @class */ (function () {
  5021. function NullAstVisitor() {
  5022. }
  5023. /**
  5024. * @param {?} ast
  5025. * @param {?} context
  5026. * @return {?}
  5027. */
  5028. NullAstVisitor.prototype.visitBinary = /**
  5029. * @param {?} ast
  5030. * @param {?} context
  5031. * @return {?}
  5032. */
  5033. function (ast, context) { };
  5034. /**
  5035. * @param {?} ast
  5036. * @param {?} context
  5037. * @return {?}
  5038. */
  5039. NullAstVisitor.prototype.visitChain = /**
  5040. * @param {?} ast
  5041. * @param {?} context
  5042. * @return {?}
  5043. */
  5044. function (ast, context) { };
  5045. /**
  5046. * @param {?} ast
  5047. * @param {?} context
  5048. * @return {?}
  5049. */
  5050. NullAstVisitor.prototype.visitConditional = /**
  5051. * @param {?} ast
  5052. * @param {?} context
  5053. * @return {?}
  5054. */
  5055. function (ast, context) { };
  5056. /**
  5057. * @param {?} ast
  5058. * @param {?} context
  5059. * @return {?}
  5060. */
  5061. NullAstVisitor.prototype.visitFunctionCall = /**
  5062. * @param {?} ast
  5063. * @param {?} context
  5064. * @return {?}
  5065. */
  5066. function (ast, context) { };
  5067. /**
  5068. * @param {?} ast
  5069. * @param {?} context
  5070. * @return {?}
  5071. */
  5072. NullAstVisitor.prototype.visitImplicitReceiver = /**
  5073. * @param {?} ast
  5074. * @param {?} context
  5075. * @return {?}
  5076. */
  5077. function (ast, context) { };
  5078. /**
  5079. * @param {?} ast
  5080. * @param {?} context
  5081. * @return {?}
  5082. */
  5083. NullAstVisitor.prototype.visitInterpolation = /**
  5084. * @param {?} ast
  5085. * @param {?} context
  5086. * @return {?}
  5087. */
  5088. function (ast, context) { };
  5089. /**
  5090. * @param {?} ast
  5091. * @param {?} context
  5092. * @return {?}
  5093. */
  5094. NullAstVisitor.prototype.visitKeyedRead = /**
  5095. * @param {?} ast
  5096. * @param {?} context
  5097. * @return {?}
  5098. */
  5099. function (ast, context) { };
  5100. /**
  5101. * @param {?} ast
  5102. * @param {?} context
  5103. * @return {?}
  5104. */
  5105. NullAstVisitor.prototype.visitKeyedWrite = /**
  5106. * @param {?} ast
  5107. * @param {?} context
  5108. * @return {?}
  5109. */
  5110. function (ast, context) { };
  5111. /**
  5112. * @param {?} ast
  5113. * @param {?} context
  5114. * @return {?}
  5115. */
  5116. NullAstVisitor.prototype.visitLiteralArray = /**
  5117. * @param {?} ast
  5118. * @param {?} context
  5119. * @return {?}
  5120. */
  5121. function (ast, context) { };
  5122. /**
  5123. * @param {?} ast
  5124. * @param {?} context
  5125. * @return {?}
  5126. */
  5127. NullAstVisitor.prototype.visitLiteralMap = /**
  5128. * @param {?} ast
  5129. * @param {?} context
  5130. * @return {?}
  5131. */
  5132. function (ast, context) { };
  5133. /**
  5134. * @param {?} ast
  5135. * @param {?} context
  5136. * @return {?}
  5137. */
  5138. NullAstVisitor.prototype.visitLiteralPrimitive = /**
  5139. * @param {?} ast
  5140. * @param {?} context
  5141. * @return {?}
  5142. */
  5143. function (ast, context) { };
  5144. /**
  5145. * @param {?} ast
  5146. * @param {?} context
  5147. * @return {?}
  5148. */
  5149. NullAstVisitor.prototype.visitMethodCall = /**
  5150. * @param {?} ast
  5151. * @param {?} context
  5152. * @return {?}
  5153. */
  5154. function (ast, context) { };
  5155. /**
  5156. * @param {?} ast
  5157. * @param {?} context
  5158. * @return {?}
  5159. */
  5160. NullAstVisitor.prototype.visitPipe = /**
  5161. * @param {?} ast
  5162. * @param {?} context
  5163. * @return {?}
  5164. */
  5165. function (ast, context) { };
  5166. /**
  5167. * @param {?} ast
  5168. * @param {?} context
  5169. * @return {?}
  5170. */
  5171. NullAstVisitor.prototype.visitPrefixNot = /**
  5172. * @param {?} ast
  5173. * @param {?} context
  5174. * @return {?}
  5175. */
  5176. function (ast, context) { };
  5177. /**
  5178. * @param {?} ast
  5179. * @param {?} context
  5180. * @return {?}
  5181. */
  5182. NullAstVisitor.prototype.visitNonNullAssert = /**
  5183. * @param {?} ast
  5184. * @param {?} context
  5185. * @return {?}
  5186. */
  5187. function (ast, context) { };
  5188. /**
  5189. * @param {?} ast
  5190. * @param {?} context
  5191. * @return {?}
  5192. */
  5193. NullAstVisitor.prototype.visitPropertyRead = /**
  5194. * @param {?} ast
  5195. * @param {?} context
  5196. * @return {?}
  5197. */
  5198. function (ast, context) { };
  5199. /**
  5200. * @param {?} ast
  5201. * @param {?} context
  5202. * @return {?}
  5203. */
  5204. NullAstVisitor.prototype.visitPropertyWrite = /**
  5205. * @param {?} ast
  5206. * @param {?} context
  5207. * @return {?}
  5208. */
  5209. function (ast, context) { };
  5210. /**
  5211. * @param {?} ast
  5212. * @param {?} context
  5213. * @return {?}
  5214. */
  5215. NullAstVisitor.prototype.visitQuote = /**
  5216. * @param {?} ast
  5217. * @param {?} context
  5218. * @return {?}
  5219. */
  5220. function (ast, context) { };
  5221. /**
  5222. * @param {?} ast
  5223. * @param {?} context
  5224. * @return {?}
  5225. */
  5226. NullAstVisitor.prototype.visitSafeMethodCall = /**
  5227. * @param {?} ast
  5228. * @param {?} context
  5229. * @return {?}
  5230. */
  5231. function (ast, context) { };
  5232. /**
  5233. * @param {?} ast
  5234. * @param {?} context
  5235. * @return {?}
  5236. */
  5237. NullAstVisitor.prototype.visitSafePropertyRead = /**
  5238. * @param {?} ast
  5239. * @param {?} context
  5240. * @return {?}
  5241. */
  5242. function (ast, context) { };
  5243. return NullAstVisitor;
  5244. }());
  5245. var RecursiveAstVisitor = /** @class */ (function () {
  5246. function RecursiveAstVisitor() {
  5247. }
  5248. /**
  5249. * @param {?} ast
  5250. * @param {?} context
  5251. * @return {?}
  5252. */
  5253. RecursiveAstVisitor.prototype.visitBinary = /**
  5254. * @param {?} ast
  5255. * @param {?} context
  5256. * @return {?}
  5257. */
  5258. function (ast, context) {
  5259. ast.left.visit(this);
  5260. ast.right.visit(this);
  5261. return null;
  5262. };
  5263. /**
  5264. * @param {?} ast
  5265. * @param {?} context
  5266. * @return {?}
  5267. */
  5268. RecursiveAstVisitor.prototype.visitChain = /**
  5269. * @param {?} ast
  5270. * @param {?} context
  5271. * @return {?}
  5272. */
  5273. function (ast, context) { return this.visitAll(ast.expressions, context); };
  5274. /**
  5275. * @param {?} ast
  5276. * @param {?} context
  5277. * @return {?}
  5278. */
  5279. RecursiveAstVisitor.prototype.visitConditional = /**
  5280. * @param {?} ast
  5281. * @param {?} context
  5282. * @return {?}
  5283. */
  5284. function (ast, context) {
  5285. ast.condition.visit(this);
  5286. ast.trueExp.visit(this);
  5287. ast.falseExp.visit(this);
  5288. return null;
  5289. };
  5290. /**
  5291. * @param {?} ast
  5292. * @param {?} context
  5293. * @return {?}
  5294. */
  5295. RecursiveAstVisitor.prototype.visitPipe = /**
  5296. * @param {?} ast
  5297. * @param {?} context
  5298. * @return {?}
  5299. */
  5300. function (ast, context) {
  5301. ast.exp.visit(this);
  5302. this.visitAll(ast.args, context);
  5303. return null;
  5304. };
  5305. /**
  5306. * @param {?} ast
  5307. * @param {?} context
  5308. * @return {?}
  5309. */
  5310. RecursiveAstVisitor.prototype.visitFunctionCall = /**
  5311. * @param {?} ast
  5312. * @param {?} context
  5313. * @return {?}
  5314. */
  5315. function (ast, context) {
  5316. /** @type {?} */ ((ast.target)).visit(this);
  5317. this.visitAll(ast.args, context);
  5318. return null;
  5319. };
  5320. /**
  5321. * @param {?} ast
  5322. * @param {?} context
  5323. * @return {?}
  5324. */
  5325. RecursiveAstVisitor.prototype.visitImplicitReceiver = /**
  5326. * @param {?} ast
  5327. * @param {?} context
  5328. * @return {?}
  5329. */
  5330. function (ast, context) { return null; };
  5331. /**
  5332. * @param {?} ast
  5333. * @param {?} context
  5334. * @return {?}
  5335. */
  5336. RecursiveAstVisitor.prototype.visitInterpolation = /**
  5337. * @param {?} ast
  5338. * @param {?} context
  5339. * @return {?}
  5340. */
  5341. function (ast, context) {
  5342. return this.visitAll(ast.expressions, context);
  5343. };
  5344. /**
  5345. * @param {?} ast
  5346. * @param {?} context
  5347. * @return {?}
  5348. */
  5349. RecursiveAstVisitor.prototype.visitKeyedRead = /**
  5350. * @param {?} ast
  5351. * @param {?} context
  5352. * @return {?}
  5353. */
  5354. function (ast, context) {
  5355. ast.obj.visit(this);
  5356. ast.key.visit(this);
  5357. return null;
  5358. };
  5359. /**
  5360. * @param {?} ast
  5361. * @param {?} context
  5362. * @return {?}
  5363. */
  5364. RecursiveAstVisitor.prototype.visitKeyedWrite = /**
  5365. * @param {?} ast
  5366. * @param {?} context
  5367. * @return {?}
  5368. */
  5369. function (ast, context) {
  5370. ast.obj.visit(this);
  5371. ast.key.visit(this);
  5372. ast.value.visit(this);
  5373. return null;
  5374. };
  5375. /**
  5376. * @param {?} ast
  5377. * @param {?} context
  5378. * @return {?}
  5379. */
  5380. RecursiveAstVisitor.prototype.visitLiteralArray = /**
  5381. * @param {?} ast
  5382. * @param {?} context
  5383. * @return {?}
  5384. */
  5385. function (ast, context) {
  5386. return this.visitAll(ast.expressions, context);
  5387. };
  5388. /**
  5389. * @param {?} ast
  5390. * @param {?} context
  5391. * @return {?}
  5392. */
  5393. RecursiveAstVisitor.prototype.visitLiteralMap = /**
  5394. * @param {?} ast
  5395. * @param {?} context
  5396. * @return {?}
  5397. */
  5398. function (ast, context) { return this.visitAll(ast.values, context); };
  5399. /**
  5400. * @param {?} ast
  5401. * @param {?} context
  5402. * @return {?}
  5403. */
  5404. RecursiveAstVisitor.prototype.visitLiteralPrimitive = /**
  5405. * @param {?} ast
  5406. * @param {?} context
  5407. * @return {?}
  5408. */
  5409. function (ast, context) { return null; };
  5410. /**
  5411. * @param {?} ast
  5412. * @param {?} context
  5413. * @return {?}
  5414. */
  5415. RecursiveAstVisitor.prototype.visitMethodCall = /**
  5416. * @param {?} ast
  5417. * @param {?} context
  5418. * @return {?}
  5419. */
  5420. function (ast, context) {
  5421. ast.receiver.visit(this);
  5422. return this.visitAll(ast.args, context);
  5423. };
  5424. /**
  5425. * @param {?} ast
  5426. * @param {?} context
  5427. * @return {?}
  5428. */
  5429. RecursiveAstVisitor.prototype.visitPrefixNot = /**
  5430. * @param {?} ast
  5431. * @param {?} context
  5432. * @return {?}
  5433. */
  5434. function (ast, context) {
  5435. ast.expression.visit(this);
  5436. return null;
  5437. };
  5438. /**
  5439. * @param {?} ast
  5440. * @param {?} context
  5441. * @return {?}
  5442. */
  5443. RecursiveAstVisitor.prototype.visitNonNullAssert = /**
  5444. * @param {?} ast
  5445. * @param {?} context
  5446. * @return {?}
  5447. */
  5448. function (ast, context) {
  5449. ast.expression.visit(this);
  5450. return null;
  5451. };
  5452. /**
  5453. * @param {?} ast
  5454. * @param {?} context
  5455. * @return {?}
  5456. */
  5457. RecursiveAstVisitor.prototype.visitPropertyRead = /**
  5458. * @param {?} ast
  5459. * @param {?} context
  5460. * @return {?}
  5461. */
  5462. function (ast, context) {
  5463. ast.receiver.visit(this);
  5464. return null;
  5465. };
  5466. /**
  5467. * @param {?} ast
  5468. * @param {?} context
  5469. * @return {?}
  5470. */
  5471. RecursiveAstVisitor.prototype.visitPropertyWrite = /**
  5472. * @param {?} ast
  5473. * @param {?} context
  5474. * @return {?}
  5475. */
  5476. function (ast, context) {
  5477. ast.receiver.visit(this);
  5478. ast.value.visit(this);
  5479. return null;
  5480. };
  5481. /**
  5482. * @param {?} ast
  5483. * @param {?} context
  5484. * @return {?}
  5485. */
  5486. RecursiveAstVisitor.prototype.visitSafePropertyRead = /**
  5487. * @param {?} ast
  5488. * @param {?} context
  5489. * @return {?}
  5490. */
  5491. function (ast, context) {
  5492. ast.receiver.visit(this);
  5493. return null;
  5494. };
  5495. /**
  5496. * @param {?} ast
  5497. * @param {?} context
  5498. * @return {?}
  5499. */
  5500. RecursiveAstVisitor.prototype.visitSafeMethodCall = /**
  5501. * @param {?} ast
  5502. * @param {?} context
  5503. * @return {?}
  5504. */
  5505. function (ast, context) {
  5506. ast.receiver.visit(this);
  5507. return this.visitAll(ast.args, context);
  5508. };
  5509. /**
  5510. * @param {?} asts
  5511. * @param {?} context
  5512. * @return {?}
  5513. */
  5514. RecursiveAstVisitor.prototype.visitAll = /**
  5515. * @param {?} asts
  5516. * @param {?} context
  5517. * @return {?}
  5518. */
  5519. function (asts, context) {
  5520. var _this = this;
  5521. asts.forEach(function (ast) { return ast.visit(_this, context); });
  5522. return null;
  5523. };
  5524. /**
  5525. * @param {?} ast
  5526. * @param {?} context
  5527. * @return {?}
  5528. */
  5529. RecursiveAstVisitor.prototype.visitQuote = /**
  5530. * @param {?} ast
  5531. * @param {?} context
  5532. * @return {?}
  5533. */
  5534. function (ast, context) { return null; };
  5535. return RecursiveAstVisitor;
  5536. }());
  5537. var AstTransformer = /** @class */ (function () {
  5538. function AstTransformer() {
  5539. }
  5540. /**
  5541. * @param {?} ast
  5542. * @param {?} context
  5543. * @return {?}
  5544. */
  5545. AstTransformer.prototype.visitImplicitReceiver = /**
  5546. * @param {?} ast
  5547. * @param {?} context
  5548. * @return {?}
  5549. */
  5550. function (ast, context) { return ast; };
  5551. /**
  5552. * @param {?} ast
  5553. * @param {?} context
  5554. * @return {?}
  5555. */
  5556. AstTransformer.prototype.visitInterpolation = /**
  5557. * @param {?} ast
  5558. * @param {?} context
  5559. * @return {?}
  5560. */
  5561. function (ast, context) {
  5562. return new Interpolation(ast.span, ast.strings, this.visitAll(ast.expressions));
  5563. };
  5564. /**
  5565. * @param {?} ast
  5566. * @param {?} context
  5567. * @return {?}
  5568. */
  5569. AstTransformer.prototype.visitLiteralPrimitive = /**
  5570. * @param {?} ast
  5571. * @param {?} context
  5572. * @return {?}
  5573. */
  5574. function (ast, context) {
  5575. return new LiteralPrimitive(ast.span, ast.value);
  5576. };
  5577. /**
  5578. * @param {?} ast
  5579. * @param {?} context
  5580. * @return {?}
  5581. */
  5582. AstTransformer.prototype.visitPropertyRead = /**
  5583. * @param {?} ast
  5584. * @param {?} context
  5585. * @return {?}
  5586. */
  5587. function (ast, context) {
  5588. return new PropertyRead(ast.span, ast.receiver.visit(this), ast.name);
  5589. };
  5590. /**
  5591. * @param {?} ast
  5592. * @param {?} context
  5593. * @return {?}
  5594. */
  5595. AstTransformer.prototype.visitPropertyWrite = /**
  5596. * @param {?} ast
  5597. * @param {?} context
  5598. * @return {?}
  5599. */
  5600. function (ast, context) {
  5601. return new PropertyWrite(ast.span, ast.receiver.visit(this), ast.name, ast.value.visit(this));
  5602. };
  5603. /**
  5604. * @param {?} ast
  5605. * @param {?} context
  5606. * @return {?}
  5607. */
  5608. AstTransformer.prototype.visitSafePropertyRead = /**
  5609. * @param {?} ast
  5610. * @param {?} context
  5611. * @return {?}
  5612. */
  5613. function (ast, context) {
  5614. return new SafePropertyRead(ast.span, ast.receiver.visit(this), ast.name);
  5615. };
  5616. /**
  5617. * @param {?} ast
  5618. * @param {?} context
  5619. * @return {?}
  5620. */
  5621. AstTransformer.prototype.visitMethodCall = /**
  5622. * @param {?} ast
  5623. * @param {?} context
  5624. * @return {?}
  5625. */
  5626. function (ast, context) {
  5627. return new MethodCall(ast.span, ast.receiver.visit(this), ast.name, this.visitAll(ast.args));
  5628. };
  5629. /**
  5630. * @param {?} ast
  5631. * @param {?} context
  5632. * @return {?}
  5633. */
  5634. AstTransformer.prototype.visitSafeMethodCall = /**
  5635. * @param {?} ast
  5636. * @param {?} context
  5637. * @return {?}
  5638. */
  5639. function (ast, context) {
  5640. return new SafeMethodCall(ast.span, ast.receiver.visit(this), ast.name, this.visitAll(ast.args));
  5641. };
  5642. /**
  5643. * @param {?} ast
  5644. * @param {?} context
  5645. * @return {?}
  5646. */
  5647. AstTransformer.prototype.visitFunctionCall = /**
  5648. * @param {?} ast
  5649. * @param {?} context
  5650. * @return {?}
  5651. */
  5652. function (ast, context) {
  5653. return new FunctionCall(ast.span, /** @type {?} */ ((ast.target)).visit(this), this.visitAll(ast.args));
  5654. };
  5655. /**
  5656. * @param {?} ast
  5657. * @param {?} context
  5658. * @return {?}
  5659. */
  5660. AstTransformer.prototype.visitLiteralArray = /**
  5661. * @param {?} ast
  5662. * @param {?} context
  5663. * @return {?}
  5664. */
  5665. function (ast, context) {
  5666. return new LiteralArray(ast.span, this.visitAll(ast.expressions));
  5667. };
  5668. /**
  5669. * @param {?} ast
  5670. * @param {?} context
  5671. * @return {?}
  5672. */
  5673. AstTransformer.prototype.visitLiteralMap = /**
  5674. * @param {?} ast
  5675. * @param {?} context
  5676. * @return {?}
  5677. */
  5678. function (ast, context) {
  5679. return new LiteralMap(ast.span, ast.keys, this.visitAll(ast.values));
  5680. };
  5681. /**
  5682. * @param {?} ast
  5683. * @param {?} context
  5684. * @return {?}
  5685. */
  5686. AstTransformer.prototype.visitBinary = /**
  5687. * @param {?} ast
  5688. * @param {?} context
  5689. * @return {?}
  5690. */
  5691. function (ast, context) {
  5692. return new Binary(ast.span, ast.operation, ast.left.visit(this), ast.right.visit(this));
  5693. };
  5694. /**
  5695. * @param {?} ast
  5696. * @param {?} context
  5697. * @return {?}
  5698. */
  5699. AstTransformer.prototype.visitPrefixNot = /**
  5700. * @param {?} ast
  5701. * @param {?} context
  5702. * @return {?}
  5703. */
  5704. function (ast, context) {
  5705. return new PrefixNot(ast.span, ast.expression.visit(this));
  5706. };
  5707. /**
  5708. * @param {?} ast
  5709. * @param {?} context
  5710. * @return {?}
  5711. */
  5712. AstTransformer.prototype.visitNonNullAssert = /**
  5713. * @param {?} ast
  5714. * @param {?} context
  5715. * @return {?}
  5716. */
  5717. function (ast, context) {
  5718. return new NonNullAssert(ast.span, ast.expression.visit(this));
  5719. };
  5720. /**
  5721. * @param {?} ast
  5722. * @param {?} context
  5723. * @return {?}
  5724. */
  5725. AstTransformer.prototype.visitConditional = /**
  5726. * @param {?} ast
  5727. * @param {?} context
  5728. * @return {?}
  5729. */
  5730. function (ast, context) {
  5731. return new Conditional(ast.span, ast.condition.visit(this), ast.trueExp.visit(this), ast.falseExp.visit(this));
  5732. };
  5733. /**
  5734. * @param {?} ast
  5735. * @param {?} context
  5736. * @return {?}
  5737. */
  5738. AstTransformer.prototype.visitPipe = /**
  5739. * @param {?} ast
  5740. * @param {?} context
  5741. * @return {?}
  5742. */
  5743. function (ast, context) {
  5744. return new BindingPipe(ast.span, ast.exp.visit(this), ast.name, this.visitAll(ast.args));
  5745. };
  5746. /**
  5747. * @param {?} ast
  5748. * @param {?} context
  5749. * @return {?}
  5750. */
  5751. AstTransformer.prototype.visitKeyedRead = /**
  5752. * @param {?} ast
  5753. * @param {?} context
  5754. * @return {?}
  5755. */
  5756. function (ast, context) {
  5757. return new KeyedRead(ast.span, ast.obj.visit(this), ast.key.visit(this));
  5758. };
  5759. /**
  5760. * @param {?} ast
  5761. * @param {?} context
  5762. * @return {?}
  5763. */
  5764. AstTransformer.prototype.visitKeyedWrite = /**
  5765. * @param {?} ast
  5766. * @param {?} context
  5767. * @return {?}
  5768. */
  5769. function (ast, context) {
  5770. return new KeyedWrite(ast.span, ast.obj.visit(this), ast.key.visit(this), ast.value.visit(this));
  5771. };
  5772. /**
  5773. * @param {?} asts
  5774. * @return {?}
  5775. */
  5776. AstTransformer.prototype.visitAll = /**
  5777. * @param {?} asts
  5778. * @return {?}
  5779. */
  5780. function (asts) {
  5781. var /** @type {?} */ res = new Array(asts.length);
  5782. for (var /** @type {?} */ i = 0; i < asts.length; ++i) {
  5783. res[i] = asts[i].visit(this);
  5784. }
  5785. return res;
  5786. };
  5787. /**
  5788. * @param {?} ast
  5789. * @param {?} context
  5790. * @return {?}
  5791. */
  5792. AstTransformer.prototype.visitChain = /**
  5793. * @param {?} ast
  5794. * @param {?} context
  5795. * @return {?}
  5796. */
  5797. function (ast, context) {
  5798. return new Chain(ast.span, this.visitAll(ast.expressions));
  5799. };
  5800. /**
  5801. * @param {?} ast
  5802. * @param {?} context
  5803. * @return {?}
  5804. */
  5805. AstTransformer.prototype.visitQuote = /**
  5806. * @param {?} ast
  5807. * @param {?} context
  5808. * @return {?}
  5809. */
  5810. function (ast, context) {
  5811. return new Quote(ast.span, ast.prefix, ast.uninterpretedExpression, ast.location);
  5812. };
  5813. return AstTransformer;
  5814. }());
  5815. /**
  5816. * @param {?} ast
  5817. * @param {?} visitor
  5818. * @param {?=} context
  5819. * @return {?}
  5820. */
  5821. function visitAstChildren(ast, visitor, context) {
  5822. /**
  5823. * @param {?} ast
  5824. * @return {?}
  5825. */
  5826. function visit(ast) {
  5827. visitor.visit && visitor.visit(ast, context) || ast.visit(visitor, context);
  5828. }
  5829. /**
  5830. * @template T
  5831. * @param {?} asts
  5832. * @return {?}
  5833. */
  5834. function visitAll(asts) { asts.forEach(visit); }
  5835. ast.visit({
  5836. visitBinary: /**
  5837. * @param {?} ast
  5838. * @return {?}
  5839. */
  5840. function (ast) {
  5841. visit(ast.left);
  5842. visit(ast.right);
  5843. },
  5844. visitChain: /**
  5845. * @param {?} ast
  5846. * @return {?}
  5847. */
  5848. function (ast) { visitAll(ast.expressions); },
  5849. visitConditional: /**
  5850. * @param {?} ast
  5851. * @return {?}
  5852. */
  5853. function (ast) {
  5854. visit(ast.condition);
  5855. visit(ast.trueExp);
  5856. visit(ast.falseExp);
  5857. },
  5858. visitFunctionCall: /**
  5859. * @param {?} ast
  5860. * @return {?}
  5861. */
  5862. function (ast) {
  5863. if (ast.target) {
  5864. visit(ast.target);
  5865. }
  5866. visitAll(ast.args);
  5867. },
  5868. visitImplicitReceiver: /**
  5869. * @param {?} ast
  5870. * @return {?}
  5871. */
  5872. function (ast) { },
  5873. visitInterpolation: /**
  5874. * @param {?} ast
  5875. * @return {?}
  5876. */
  5877. function (ast) { visitAll(ast.expressions); },
  5878. visitKeyedRead: /**
  5879. * @param {?} ast
  5880. * @return {?}
  5881. */
  5882. function (ast) {
  5883. visit(ast.obj);
  5884. visit(ast.key);
  5885. },
  5886. visitKeyedWrite: /**
  5887. * @param {?} ast
  5888. * @return {?}
  5889. */
  5890. function (ast) {
  5891. visit(ast.obj);
  5892. visit(ast.key);
  5893. visit(ast.obj);
  5894. },
  5895. visitLiteralArray: /**
  5896. * @param {?} ast
  5897. * @return {?}
  5898. */
  5899. function (ast) { visitAll(ast.expressions); },
  5900. visitLiteralMap: /**
  5901. * @param {?} ast
  5902. * @return {?}
  5903. */
  5904. function (ast) { },
  5905. visitLiteralPrimitive: /**
  5906. * @param {?} ast
  5907. * @return {?}
  5908. */
  5909. function (ast) { },
  5910. visitMethodCall: /**
  5911. * @param {?} ast
  5912. * @return {?}
  5913. */
  5914. function (ast) {
  5915. visit(ast.receiver);
  5916. visitAll(ast.args);
  5917. },
  5918. visitPipe: /**
  5919. * @param {?} ast
  5920. * @return {?}
  5921. */
  5922. function (ast) {
  5923. visit(ast.exp);
  5924. visitAll(ast.args);
  5925. },
  5926. visitPrefixNot: /**
  5927. * @param {?} ast
  5928. * @return {?}
  5929. */
  5930. function (ast) { visit(ast.expression); },
  5931. visitNonNullAssert: /**
  5932. * @param {?} ast
  5933. * @return {?}
  5934. */
  5935. function (ast) { visit(ast.expression); },
  5936. visitPropertyRead: /**
  5937. * @param {?} ast
  5938. * @return {?}
  5939. */
  5940. function (ast) { visit(ast.receiver); },
  5941. visitPropertyWrite: /**
  5942. * @param {?} ast
  5943. * @return {?}
  5944. */
  5945. function (ast) {
  5946. visit(ast.receiver);
  5947. visit(ast.value);
  5948. },
  5949. visitQuote: /**
  5950. * @param {?} ast
  5951. * @return {?}
  5952. */
  5953. function (ast) { },
  5954. visitSafeMethodCall: /**
  5955. * @param {?} ast
  5956. * @return {?}
  5957. */
  5958. function (ast) {
  5959. visit(ast.receiver);
  5960. visitAll(ast.args);
  5961. },
  5962. visitSafePropertyRead: /**
  5963. * @param {?} ast
  5964. * @return {?}
  5965. */
  5966. function (ast) { visit(ast.receiver); },
  5967. });
  5968. }
  5969. /**
  5970. * @fileoverview added by tsickle
  5971. * @suppress {checkTypes} checked by tsc
  5972. */
  5973. /**
  5974. * @license
  5975. * Copyright Google Inc. All Rights Reserved.
  5976. *
  5977. * Use of this source code is governed by an MIT-style license that can be
  5978. * found in the LICENSE file at https://angular.io/license
  5979. */
  5980. var SplitInterpolation = /** @class */ (function () {
  5981. function SplitInterpolation(strings, expressions, offsets) {
  5982. this.strings = strings;
  5983. this.expressions = expressions;
  5984. this.offsets = offsets;
  5985. }
  5986. return SplitInterpolation;
  5987. }());
  5988. var TemplateBindingParseResult = /** @class */ (function () {
  5989. function TemplateBindingParseResult(templateBindings, warnings, errors) {
  5990. this.templateBindings = templateBindings;
  5991. this.warnings = warnings;
  5992. this.errors = errors;
  5993. }
  5994. return TemplateBindingParseResult;
  5995. }());
  5996. /**
  5997. * @param {?} config
  5998. * @return {?}
  5999. */
  6000. function _createInterpolateRegExp(config) {
  6001. var /** @type {?} */ pattern = escapeRegExp(config.start) + '([\\s\\S]*?)' + escapeRegExp(config.end);
  6002. return new RegExp(pattern, 'g');
  6003. }
  6004. var Parser = /** @class */ (function () {
  6005. function Parser(_lexer) {
  6006. this._lexer = _lexer;
  6007. this.errors = [];
  6008. }
  6009. /**
  6010. * @param {?} input
  6011. * @param {?} location
  6012. * @param {?=} interpolationConfig
  6013. * @return {?}
  6014. */
  6015. Parser.prototype.parseAction = /**
  6016. * @param {?} input
  6017. * @param {?} location
  6018. * @param {?=} interpolationConfig
  6019. * @return {?}
  6020. */
  6021. function (input, location, interpolationConfig) {
  6022. if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
  6023. this._checkNoInterpolation(input, location, interpolationConfig);
  6024. var /** @type {?} */ sourceToLex = this._stripComments(input);
  6025. var /** @type {?} */ tokens = this._lexer.tokenize(this._stripComments(input));
  6026. var /** @type {?} */ ast = new _ParseAST(input, location, tokens, sourceToLex.length, true, this.errors, input.length - sourceToLex.length)
  6027. .parseChain();
  6028. return new ASTWithSource(ast, input, location, this.errors);
  6029. };
  6030. /**
  6031. * @param {?} input
  6032. * @param {?} location
  6033. * @param {?=} interpolationConfig
  6034. * @return {?}
  6035. */
  6036. Parser.prototype.parseBinding = /**
  6037. * @param {?} input
  6038. * @param {?} location
  6039. * @param {?=} interpolationConfig
  6040. * @return {?}
  6041. */
  6042. function (input, location, interpolationConfig) {
  6043. if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
  6044. var /** @type {?} */ ast = this._parseBindingAst(input, location, interpolationConfig);
  6045. return new ASTWithSource(ast, input, location, this.errors);
  6046. };
  6047. /**
  6048. * @param {?} input
  6049. * @param {?} location
  6050. * @param {?=} interpolationConfig
  6051. * @return {?}
  6052. */
  6053. Parser.prototype.parseSimpleBinding = /**
  6054. * @param {?} input
  6055. * @param {?} location
  6056. * @param {?=} interpolationConfig
  6057. * @return {?}
  6058. */
  6059. function (input, location, interpolationConfig) {
  6060. if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
  6061. var /** @type {?} */ ast = this._parseBindingAst(input, location, interpolationConfig);
  6062. var /** @type {?} */ errors = SimpleExpressionChecker.check(ast);
  6063. if (errors.length > 0) {
  6064. this._reportError("Host binding expression cannot contain " + errors.join(' '), input, location);
  6065. }
  6066. return new ASTWithSource(ast, input, location, this.errors);
  6067. };
  6068. /**
  6069. * @param {?} message
  6070. * @param {?} input
  6071. * @param {?} errLocation
  6072. * @param {?=} ctxLocation
  6073. * @return {?}
  6074. */
  6075. Parser.prototype._reportError = /**
  6076. * @param {?} message
  6077. * @param {?} input
  6078. * @param {?} errLocation
  6079. * @param {?=} ctxLocation
  6080. * @return {?}
  6081. */
  6082. function (message, input, errLocation, ctxLocation) {
  6083. this.errors.push(new ParserError(message, input, errLocation, ctxLocation));
  6084. };
  6085. /**
  6086. * @param {?} input
  6087. * @param {?} location
  6088. * @param {?} interpolationConfig
  6089. * @return {?}
  6090. */
  6091. Parser.prototype._parseBindingAst = /**
  6092. * @param {?} input
  6093. * @param {?} location
  6094. * @param {?} interpolationConfig
  6095. * @return {?}
  6096. */
  6097. function (input, location, interpolationConfig) {
  6098. // Quotes expressions use 3rd-party expression language. We don't want to use
  6099. // our lexer or parser for that, so we check for that ahead of time.
  6100. var /** @type {?} */ quote = this._parseQuote(input, location);
  6101. if (quote != null) {
  6102. return quote;
  6103. }
  6104. this._checkNoInterpolation(input, location, interpolationConfig);
  6105. var /** @type {?} */ sourceToLex = this._stripComments(input);
  6106. var /** @type {?} */ tokens = this._lexer.tokenize(sourceToLex);
  6107. return new _ParseAST(input, location, tokens, sourceToLex.length, false, this.errors, input.length - sourceToLex.length)
  6108. .parseChain();
  6109. };
  6110. /**
  6111. * @param {?} input
  6112. * @param {?} location
  6113. * @return {?}
  6114. */
  6115. Parser.prototype._parseQuote = /**
  6116. * @param {?} input
  6117. * @param {?} location
  6118. * @return {?}
  6119. */
  6120. function (input, location) {
  6121. if (input == null)
  6122. return null;
  6123. var /** @type {?} */ prefixSeparatorIndex = input.indexOf(':');
  6124. if (prefixSeparatorIndex == -1)
  6125. return null;
  6126. var /** @type {?} */ prefix = input.substring(0, prefixSeparatorIndex).trim();
  6127. if (!isIdentifier(prefix))
  6128. return null;
  6129. var /** @type {?} */ uninterpretedExpression = input.substring(prefixSeparatorIndex + 1);
  6130. return new Quote(new ParseSpan(0, input.length), prefix, uninterpretedExpression, location);
  6131. };
  6132. /**
  6133. * @param {?} prefixToken
  6134. * @param {?} input
  6135. * @param {?} location
  6136. * @return {?}
  6137. */
  6138. Parser.prototype.parseTemplateBindings = /**
  6139. * @param {?} prefixToken
  6140. * @param {?} input
  6141. * @param {?} location
  6142. * @return {?}
  6143. */
  6144. function (prefixToken, input, location) {
  6145. var /** @type {?} */ tokens = this._lexer.tokenize(input);
  6146. if (prefixToken) {
  6147. // Prefix the tokens with the tokens from prefixToken but have them take no space (0 index).
  6148. var /** @type {?} */ prefixTokens = this._lexer.tokenize(prefixToken).map(function (t) {
  6149. t.index = 0;
  6150. return t;
  6151. });
  6152. tokens.unshift.apply(tokens, prefixTokens);
  6153. }
  6154. return new _ParseAST(input, location, tokens, input.length, false, this.errors, 0)
  6155. .parseTemplateBindings();
  6156. };
  6157. /**
  6158. * @param {?} input
  6159. * @param {?} location
  6160. * @param {?=} interpolationConfig
  6161. * @return {?}
  6162. */
  6163. Parser.prototype.parseInterpolation = /**
  6164. * @param {?} input
  6165. * @param {?} location
  6166. * @param {?=} interpolationConfig
  6167. * @return {?}
  6168. */
  6169. function (input, location, interpolationConfig) {
  6170. if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
  6171. var /** @type {?} */ split = this.splitInterpolation(input, location, interpolationConfig);
  6172. if (split == null)
  6173. return null;
  6174. var /** @type {?} */ expressions = [];
  6175. for (var /** @type {?} */ i = 0; i < split.expressions.length; ++i) {
  6176. var /** @type {?} */ expressionText = split.expressions[i];
  6177. var /** @type {?} */ sourceToLex = this._stripComments(expressionText);
  6178. var /** @type {?} */ tokens = this._lexer.tokenize(sourceToLex);
  6179. var /** @type {?} */ ast = new _ParseAST(input, location, tokens, sourceToLex.length, false, this.errors, split.offsets[i] + (expressionText.length - sourceToLex.length))
  6180. .parseChain();
  6181. expressions.push(ast);
  6182. }
  6183. return new ASTWithSource(new Interpolation(new ParseSpan(0, input == null ? 0 : input.length), split.strings, expressions), input, location, this.errors);
  6184. };
  6185. /**
  6186. * @param {?} input
  6187. * @param {?} location
  6188. * @param {?=} interpolationConfig
  6189. * @return {?}
  6190. */
  6191. Parser.prototype.splitInterpolation = /**
  6192. * @param {?} input
  6193. * @param {?} location
  6194. * @param {?=} interpolationConfig
  6195. * @return {?}
  6196. */
  6197. function (input, location, interpolationConfig) {
  6198. if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
  6199. var /** @type {?} */ regexp = _createInterpolateRegExp(interpolationConfig);
  6200. var /** @type {?} */ parts = input.split(regexp);
  6201. if (parts.length <= 1) {
  6202. return null;
  6203. }
  6204. var /** @type {?} */ strings = [];
  6205. var /** @type {?} */ expressions = [];
  6206. var /** @type {?} */ offsets = [];
  6207. var /** @type {?} */ offset = 0;
  6208. for (var /** @type {?} */ i = 0; i < parts.length; i++) {
  6209. var /** @type {?} */ part = parts[i];
  6210. if (i % 2 === 0) {
  6211. // fixed string
  6212. strings.push(part);
  6213. offset += part.length;
  6214. }
  6215. else if (part.trim().length > 0) {
  6216. offset += interpolationConfig.start.length;
  6217. expressions.push(part);
  6218. offsets.push(offset);
  6219. offset += part.length + interpolationConfig.end.length;
  6220. }
  6221. else {
  6222. this._reportError('Blank expressions are not allowed in interpolated strings', input, "at column " + this._findInterpolationErrorColumn(parts, i, interpolationConfig) + " in", location);
  6223. expressions.push('$implict');
  6224. offsets.push(offset);
  6225. }
  6226. }
  6227. return new SplitInterpolation(strings, expressions, offsets);
  6228. };
  6229. /**
  6230. * @param {?} input
  6231. * @param {?} location
  6232. * @return {?}
  6233. */
  6234. Parser.prototype.wrapLiteralPrimitive = /**
  6235. * @param {?} input
  6236. * @param {?} location
  6237. * @return {?}
  6238. */
  6239. function (input, location) {
  6240. return new ASTWithSource(new LiteralPrimitive(new ParseSpan(0, input == null ? 0 : input.length), input), input, location, this.errors);
  6241. };
  6242. /**
  6243. * @param {?} input
  6244. * @return {?}
  6245. */
  6246. Parser.prototype._stripComments = /**
  6247. * @param {?} input
  6248. * @return {?}
  6249. */
  6250. function (input) {
  6251. var /** @type {?} */ i = this._commentStart(input);
  6252. return i != null ? input.substring(0, i).trim() : input;
  6253. };
  6254. /**
  6255. * @param {?} input
  6256. * @return {?}
  6257. */
  6258. Parser.prototype._commentStart = /**
  6259. * @param {?} input
  6260. * @return {?}
  6261. */
  6262. function (input) {
  6263. var /** @type {?} */ outerQuote = null;
  6264. for (var /** @type {?} */ i = 0; i < input.length - 1; i++) {
  6265. var /** @type {?} */ char = input.charCodeAt(i);
  6266. var /** @type {?} */ nextChar = input.charCodeAt(i + 1);
  6267. if (char === $SLASH && nextChar == $SLASH && outerQuote == null)
  6268. return i;
  6269. if (outerQuote === char) {
  6270. outerQuote = null;
  6271. }
  6272. else if (outerQuote == null && isQuote(char)) {
  6273. outerQuote = char;
  6274. }
  6275. }
  6276. return null;
  6277. };
  6278. /**
  6279. * @param {?} input
  6280. * @param {?} location
  6281. * @param {?} interpolationConfig
  6282. * @return {?}
  6283. */
  6284. Parser.prototype._checkNoInterpolation = /**
  6285. * @param {?} input
  6286. * @param {?} location
  6287. * @param {?} interpolationConfig
  6288. * @return {?}
  6289. */
  6290. function (input, location, interpolationConfig) {
  6291. var /** @type {?} */ regexp = _createInterpolateRegExp(interpolationConfig);
  6292. var /** @type {?} */ parts = input.split(regexp);
  6293. if (parts.length > 1) {
  6294. this._reportError("Got interpolation (" + interpolationConfig.start + interpolationConfig.end + ") where expression was expected", input, "at column " + this._findInterpolationErrorColumn(parts, 1, interpolationConfig) + " in", location);
  6295. }
  6296. };
  6297. /**
  6298. * @param {?} parts
  6299. * @param {?} partInErrIdx
  6300. * @param {?} interpolationConfig
  6301. * @return {?}
  6302. */
  6303. Parser.prototype._findInterpolationErrorColumn = /**
  6304. * @param {?} parts
  6305. * @param {?} partInErrIdx
  6306. * @param {?} interpolationConfig
  6307. * @return {?}
  6308. */
  6309. function (parts, partInErrIdx, interpolationConfig) {
  6310. var /** @type {?} */ errLocation = '';
  6311. for (var /** @type {?} */ j = 0; j < partInErrIdx; j++) {
  6312. errLocation += j % 2 === 0 ?
  6313. parts[j] :
  6314. "" + interpolationConfig.start + parts[j] + interpolationConfig.end;
  6315. }
  6316. return errLocation.length;
  6317. };
  6318. return Parser;
  6319. }());
  6320. var _ParseAST = /** @class */ (function () {
  6321. function _ParseAST(input, location, tokens, inputLength, parseAction, errors, offset) {
  6322. this.input = input;
  6323. this.location = location;
  6324. this.tokens = tokens;
  6325. this.inputLength = inputLength;
  6326. this.parseAction = parseAction;
  6327. this.errors = errors;
  6328. this.offset = offset;
  6329. this.rparensExpected = 0;
  6330. this.rbracketsExpected = 0;
  6331. this.rbracesExpected = 0;
  6332. this.index = 0;
  6333. }
  6334. /**
  6335. * @param {?} offset
  6336. * @return {?}
  6337. */
  6338. _ParseAST.prototype.peek = /**
  6339. * @param {?} offset
  6340. * @return {?}
  6341. */
  6342. function (offset) {
  6343. var /** @type {?} */ i = this.index + offset;
  6344. return i < this.tokens.length ? this.tokens[i] : EOF;
  6345. };
  6346. Object.defineProperty(_ParseAST.prototype, "next", {
  6347. get: /**
  6348. * @return {?}
  6349. */
  6350. function () { return this.peek(0); },
  6351. enumerable: true,
  6352. configurable: true
  6353. });
  6354. Object.defineProperty(_ParseAST.prototype, "inputIndex", {
  6355. get: /**
  6356. * @return {?}
  6357. */
  6358. function () {
  6359. return (this.index < this.tokens.length) ? this.next.index + this.offset :
  6360. this.inputLength + this.offset;
  6361. },
  6362. enumerable: true,
  6363. configurable: true
  6364. });
  6365. /**
  6366. * @param {?} start
  6367. * @return {?}
  6368. */
  6369. _ParseAST.prototype.span = /**
  6370. * @param {?} start
  6371. * @return {?}
  6372. */
  6373. function (start) { return new ParseSpan(start, this.inputIndex); };
  6374. /**
  6375. * @return {?}
  6376. */
  6377. _ParseAST.prototype.advance = /**
  6378. * @return {?}
  6379. */
  6380. function () { this.index++; };
  6381. /**
  6382. * @param {?} code
  6383. * @return {?}
  6384. */
  6385. _ParseAST.prototype.optionalCharacter = /**
  6386. * @param {?} code
  6387. * @return {?}
  6388. */
  6389. function (code) {
  6390. if (this.next.isCharacter(code)) {
  6391. this.advance();
  6392. return true;
  6393. }
  6394. else {
  6395. return false;
  6396. }
  6397. };
  6398. /**
  6399. * @return {?}
  6400. */
  6401. _ParseAST.prototype.peekKeywordLet = /**
  6402. * @return {?}
  6403. */
  6404. function () { return this.next.isKeywordLet(); };
  6405. /**
  6406. * @return {?}
  6407. */
  6408. _ParseAST.prototype.peekKeywordAs = /**
  6409. * @return {?}
  6410. */
  6411. function () { return this.next.isKeywordAs(); };
  6412. /**
  6413. * @param {?} code
  6414. * @return {?}
  6415. */
  6416. _ParseAST.prototype.expectCharacter = /**
  6417. * @param {?} code
  6418. * @return {?}
  6419. */
  6420. function (code) {
  6421. if (this.optionalCharacter(code))
  6422. return;
  6423. this.error("Missing expected " + String.fromCharCode(code));
  6424. };
  6425. /**
  6426. * @param {?} op
  6427. * @return {?}
  6428. */
  6429. _ParseAST.prototype.optionalOperator = /**
  6430. * @param {?} op
  6431. * @return {?}
  6432. */
  6433. function (op) {
  6434. if (this.next.isOperator(op)) {
  6435. this.advance();
  6436. return true;
  6437. }
  6438. else {
  6439. return false;
  6440. }
  6441. };
  6442. /**
  6443. * @param {?} operator
  6444. * @return {?}
  6445. */
  6446. _ParseAST.prototype.expectOperator = /**
  6447. * @param {?} operator
  6448. * @return {?}
  6449. */
  6450. function (operator) {
  6451. if (this.optionalOperator(operator))
  6452. return;
  6453. this.error("Missing expected operator " + operator);
  6454. };
  6455. /**
  6456. * @return {?}
  6457. */
  6458. _ParseAST.prototype.expectIdentifierOrKeyword = /**
  6459. * @return {?}
  6460. */
  6461. function () {
  6462. var /** @type {?} */ n = this.next;
  6463. if (!n.isIdentifier() && !n.isKeyword()) {
  6464. this.error("Unexpected token " + n + ", expected identifier or keyword");
  6465. return '';
  6466. }
  6467. this.advance();
  6468. return /** @type {?} */ (n.toString());
  6469. };
  6470. /**
  6471. * @return {?}
  6472. */
  6473. _ParseAST.prototype.expectIdentifierOrKeywordOrString = /**
  6474. * @return {?}
  6475. */
  6476. function () {
  6477. var /** @type {?} */ n = this.next;
  6478. if (!n.isIdentifier() && !n.isKeyword() && !n.isString()) {
  6479. this.error("Unexpected token " + n + ", expected identifier, keyword, or string");
  6480. return '';
  6481. }
  6482. this.advance();
  6483. return /** @type {?} */ (n.toString());
  6484. };
  6485. /**
  6486. * @return {?}
  6487. */
  6488. _ParseAST.prototype.parseChain = /**
  6489. * @return {?}
  6490. */
  6491. function () {
  6492. var /** @type {?} */ exprs = [];
  6493. var /** @type {?} */ start = this.inputIndex;
  6494. while (this.index < this.tokens.length) {
  6495. var /** @type {?} */ expr = this.parsePipe();
  6496. exprs.push(expr);
  6497. if (this.optionalCharacter($SEMICOLON)) {
  6498. if (!this.parseAction) {
  6499. this.error('Binding expression cannot contain chained expression');
  6500. }
  6501. while (this.optionalCharacter($SEMICOLON)) {
  6502. } // read all semicolons
  6503. }
  6504. else if (this.index < this.tokens.length) {
  6505. this.error("Unexpected token '" + this.next + "'");
  6506. }
  6507. }
  6508. if (exprs.length == 0)
  6509. return new EmptyExpr(this.span(start));
  6510. if (exprs.length == 1)
  6511. return exprs[0];
  6512. return new Chain(this.span(start), exprs);
  6513. };
  6514. /**
  6515. * @return {?}
  6516. */
  6517. _ParseAST.prototype.parsePipe = /**
  6518. * @return {?}
  6519. */
  6520. function () {
  6521. var /** @type {?} */ result = this.parseExpression();
  6522. if (this.optionalOperator('|')) {
  6523. if (this.parseAction) {
  6524. this.error('Cannot have a pipe in an action expression');
  6525. }
  6526. do {
  6527. var /** @type {?} */ name_1 = this.expectIdentifierOrKeyword();
  6528. var /** @type {?} */ args = [];
  6529. while (this.optionalCharacter($COLON)) {
  6530. args.push(this.parseExpression());
  6531. }
  6532. result = new BindingPipe(this.span(result.span.start), result, name_1, args);
  6533. } while (this.optionalOperator('|'));
  6534. }
  6535. return result;
  6536. };
  6537. /**
  6538. * @return {?}
  6539. */
  6540. _ParseAST.prototype.parseExpression = /**
  6541. * @return {?}
  6542. */
  6543. function () { return this.parseConditional(); };
  6544. /**
  6545. * @return {?}
  6546. */
  6547. _ParseAST.prototype.parseConditional = /**
  6548. * @return {?}
  6549. */
  6550. function () {
  6551. var /** @type {?} */ start = this.inputIndex;
  6552. var /** @type {?} */ result = this.parseLogicalOr();
  6553. if (this.optionalOperator('?')) {
  6554. var /** @type {?} */ yes = this.parsePipe();
  6555. var /** @type {?} */ no = void 0;
  6556. if (!this.optionalCharacter($COLON)) {
  6557. var /** @type {?} */ end = this.inputIndex;
  6558. var /** @type {?} */ expression = this.input.substring(start, end);
  6559. this.error("Conditional expression " + expression + " requires all 3 expressions");
  6560. no = new EmptyExpr(this.span(start));
  6561. }
  6562. else {
  6563. no = this.parsePipe();
  6564. }
  6565. return new Conditional(this.span(start), result, yes, no);
  6566. }
  6567. else {
  6568. return result;
  6569. }
  6570. };
  6571. /**
  6572. * @return {?}
  6573. */
  6574. _ParseAST.prototype.parseLogicalOr = /**
  6575. * @return {?}
  6576. */
  6577. function () {
  6578. // '||'
  6579. var /** @type {?} */ result = this.parseLogicalAnd();
  6580. while (this.optionalOperator('||')) {
  6581. var /** @type {?} */ right = this.parseLogicalAnd();
  6582. result = new Binary(this.span(result.span.start), '||', result, right);
  6583. }
  6584. return result;
  6585. };
  6586. /**
  6587. * @return {?}
  6588. */
  6589. _ParseAST.prototype.parseLogicalAnd = /**
  6590. * @return {?}
  6591. */
  6592. function () {
  6593. // '&&'
  6594. var /** @type {?} */ result = this.parseEquality();
  6595. while (this.optionalOperator('&&')) {
  6596. var /** @type {?} */ right = this.parseEquality();
  6597. result = new Binary(this.span(result.span.start), '&&', result, right);
  6598. }
  6599. return result;
  6600. };
  6601. /**
  6602. * @return {?}
  6603. */
  6604. _ParseAST.prototype.parseEquality = /**
  6605. * @return {?}
  6606. */
  6607. function () {
  6608. // '==','!=','===','!=='
  6609. var /** @type {?} */ result = this.parseRelational();
  6610. while (this.next.type == TokenType.Operator) {
  6611. var /** @type {?} */ operator = this.next.strValue;
  6612. switch (operator) {
  6613. case '==':
  6614. case '===':
  6615. case '!=':
  6616. case '!==':
  6617. this.advance();
  6618. var /** @type {?} */ right = this.parseRelational();
  6619. result = new Binary(this.span(result.span.start), operator, result, right);
  6620. continue;
  6621. }
  6622. break;
  6623. }
  6624. return result;
  6625. };
  6626. /**
  6627. * @return {?}
  6628. */
  6629. _ParseAST.prototype.parseRelational = /**
  6630. * @return {?}
  6631. */
  6632. function () {
  6633. // '<', '>', '<=', '>='
  6634. var /** @type {?} */ result = this.parseAdditive();
  6635. while (this.next.type == TokenType.Operator) {
  6636. var /** @type {?} */ operator = this.next.strValue;
  6637. switch (operator) {
  6638. case '<':
  6639. case '>':
  6640. case '<=':
  6641. case '>=':
  6642. this.advance();
  6643. var /** @type {?} */ right = this.parseAdditive();
  6644. result = new Binary(this.span(result.span.start), operator, result, right);
  6645. continue;
  6646. }
  6647. break;
  6648. }
  6649. return result;
  6650. };
  6651. /**
  6652. * @return {?}
  6653. */
  6654. _ParseAST.prototype.parseAdditive = /**
  6655. * @return {?}
  6656. */
  6657. function () {
  6658. // '+', '-'
  6659. var /** @type {?} */ result = this.parseMultiplicative();
  6660. while (this.next.type == TokenType.Operator) {
  6661. var /** @type {?} */ operator = this.next.strValue;
  6662. switch (operator) {
  6663. case '+':
  6664. case '-':
  6665. this.advance();
  6666. var /** @type {?} */ right = this.parseMultiplicative();
  6667. result = new Binary(this.span(result.span.start), operator, result, right);
  6668. continue;
  6669. }
  6670. break;
  6671. }
  6672. return result;
  6673. };
  6674. /**
  6675. * @return {?}
  6676. */
  6677. _ParseAST.prototype.parseMultiplicative = /**
  6678. * @return {?}
  6679. */
  6680. function () {
  6681. // '*', '%', '/'
  6682. var /** @type {?} */ result = this.parsePrefix();
  6683. while (this.next.type == TokenType.Operator) {
  6684. var /** @type {?} */ operator = this.next.strValue;
  6685. switch (operator) {
  6686. case '*':
  6687. case '%':
  6688. case '/':
  6689. this.advance();
  6690. var /** @type {?} */ right = this.parsePrefix();
  6691. result = new Binary(this.span(result.span.start), operator, result, right);
  6692. continue;
  6693. }
  6694. break;
  6695. }
  6696. return result;
  6697. };
  6698. /**
  6699. * @return {?}
  6700. */
  6701. _ParseAST.prototype.parsePrefix = /**
  6702. * @return {?}
  6703. */
  6704. function () {
  6705. if (this.next.type == TokenType.Operator) {
  6706. var /** @type {?} */ start = this.inputIndex;
  6707. var /** @type {?} */ operator = this.next.strValue;
  6708. var /** @type {?} */ result = void 0;
  6709. switch (operator) {
  6710. case '+':
  6711. this.advance();
  6712. result = this.parsePrefix();
  6713. return new Binary(this.span(start), '-', result, new LiteralPrimitive(new ParseSpan(start, start), 0));
  6714. case '-':
  6715. this.advance();
  6716. result = this.parsePrefix();
  6717. return new Binary(this.span(start), operator, new LiteralPrimitive(new ParseSpan(start, start), 0), result);
  6718. case '!':
  6719. this.advance();
  6720. result = this.parsePrefix();
  6721. return new PrefixNot(this.span(start), result);
  6722. }
  6723. }
  6724. return this.parseCallChain();
  6725. };
  6726. /**
  6727. * @return {?}
  6728. */
  6729. _ParseAST.prototype.parseCallChain = /**
  6730. * @return {?}
  6731. */
  6732. function () {
  6733. var /** @type {?} */ result = this.parsePrimary();
  6734. while (true) {
  6735. if (this.optionalCharacter($PERIOD)) {
  6736. result = this.parseAccessMemberOrMethodCall(result, false);
  6737. }
  6738. else if (this.optionalOperator('?.')) {
  6739. result = this.parseAccessMemberOrMethodCall(result, true);
  6740. }
  6741. else if (this.optionalCharacter($LBRACKET)) {
  6742. this.rbracketsExpected++;
  6743. var /** @type {?} */ key = this.parsePipe();
  6744. this.rbracketsExpected--;
  6745. this.expectCharacter($RBRACKET);
  6746. if (this.optionalOperator('=')) {
  6747. var /** @type {?} */ value = this.parseConditional();
  6748. result = new KeyedWrite(this.span(result.span.start), result, key, value);
  6749. }
  6750. else {
  6751. result = new KeyedRead(this.span(result.span.start), result, key);
  6752. }
  6753. }
  6754. else if (this.optionalCharacter($LPAREN)) {
  6755. this.rparensExpected++;
  6756. var /** @type {?} */ args = this.parseCallArguments();
  6757. this.rparensExpected--;
  6758. this.expectCharacter($RPAREN);
  6759. result = new FunctionCall(this.span(result.span.start), result, args);
  6760. }
  6761. else if (this.optionalOperator('!')) {
  6762. result = new NonNullAssert(this.span(result.span.start), result);
  6763. }
  6764. else {
  6765. return result;
  6766. }
  6767. }
  6768. };
  6769. /**
  6770. * @return {?}
  6771. */
  6772. _ParseAST.prototype.parsePrimary = /**
  6773. * @return {?}
  6774. */
  6775. function () {
  6776. var /** @type {?} */ start = this.inputIndex;
  6777. if (this.optionalCharacter($LPAREN)) {
  6778. this.rparensExpected++;
  6779. var /** @type {?} */ result = this.parsePipe();
  6780. this.rparensExpected--;
  6781. this.expectCharacter($RPAREN);
  6782. return result;
  6783. }
  6784. else if (this.next.isKeywordNull()) {
  6785. this.advance();
  6786. return new LiteralPrimitive(this.span(start), null);
  6787. }
  6788. else if (this.next.isKeywordUndefined()) {
  6789. this.advance();
  6790. return new LiteralPrimitive(this.span(start), void 0);
  6791. }
  6792. else if (this.next.isKeywordTrue()) {
  6793. this.advance();
  6794. return new LiteralPrimitive(this.span(start), true);
  6795. }
  6796. else if (this.next.isKeywordFalse()) {
  6797. this.advance();
  6798. return new LiteralPrimitive(this.span(start), false);
  6799. }
  6800. else if (this.next.isKeywordThis()) {
  6801. this.advance();
  6802. return new ImplicitReceiver(this.span(start));
  6803. }
  6804. else if (this.optionalCharacter($LBRACKET)) {
  6805. this.rbracketsExpected++;
  6806. var /** @type {?} */ elements = this.parseExpressionList($RBRACKET);
  6807. this.rbracketsExpected--;
  6808. this.expectCharacter($RBRACKET);
  6809. return new LiteralArray(this.span(start), elements);
  6810. }
  6811. else if (this.next.isCharacter($LBRACE)) {
  6812. return this.parseLiteralMap();
  6813. }
  6814. else if (this.next.isIdentifier()) {
  6815. return this.parseAccessMemberOrMethodCall(new ImplicitReceiver(this.span(start)), false);
  6816. }
  6817. else if (this.next.isNumber()) {
  6818. var /** @type {?} */ value = this.next.toNumber();
  6819. this.advance();
  6820. return new LiteralPrimitive(this.span(start), value);
  6821. }
  6822. else if (this.next.isString()) {
  6823. var /** @type {?} */ literalValue = this.next.toString();
  6824. this.advance();
  6825. return new LiteralPrimitive(this.span(start), literalValue);
  6826. }
  6827. else if (this.index >= this.tokens.length) {
  6828. this.error("Unexpected end of expression: " + this.input);
  6829. return new EmptyExpr(this.span(start));
  6830. }
  6831. else {
  6832. this.error("Unexpected token " + this.next);
  6833. return new EmptyExpr(this.span(start));
  6834. }
  6835. };
  6836. /**
  6837. * @param {?} terminator
  6838. * @return {?}
  6839. */
  6840. _ParseAST.prototype.parseExpressionList = /**
  6841. * @param {?} terminator
  6842. * @return {?}
  6843. */
  6844. function (terminator) {
  6845. var /** @type {?} */ result = [];
  6846. if (!this.next.isCharacter(terminator)) {
  6847. do {
  6848. result.push(this.parsePipe());
  6849. } while (this.optionalCharacter($COMMA));
  6850. }
  6851. return result;
  6852. };
  6853. /**
  6854. * @return {?}
  6855. */
  6856. _ParseAST.prototype.parseLiteralMap = /**
  6857. * @return {?}
  6858. */
  6859. function () {
  6860. var /** @type {?} */ keys = [];
  6861. var /** @type {?} */ values = [];
  6862. var /** @type {?} */ start = this.inputIndex;
  6863. this.expectCharacter($LBRACE);
  6864. if (!this.optionalCharacter($RBRACE)) {
  6865. this.rbracesExpected++;
  6866. do {
  6867. var /** @type {?} */ quoted = this.next.isString();
  6868. var /** @type {?} */ key = this.expectIdentifierOrKeywordOrString();
  6869. keys.push({ key: key, quoted: quoted });
  6870. this.expectCharacter($COLON);
  6871. values.push(this.parsePipe());
  6872. } while (this.optionalCharacter($COMMA));
  6873. this.rbracesExpected--;
  6874. this.expectCharacter($RBRACE);
  6875. }
  6876. return new LiteralMap(this.span(start), keys, values);
  6877. };
  6878. /**
  6879. * @param {?} receiver
  6880. * @param {?=} isSafe
  6881. * @return {?}
  6882. */
  6883. _ParseAST.prototype.parseAccessMemberOrMethodCall = /**
  6884. * @param {?} receiver
  6885. * @param {?=} isSafe
  6886. * @return {?}
  6887. */
  6888. function (receiver, isSafe) {
  6889. if (isSafe === void 0) { isSafe = false; }
  6890. var /** @type {?} */ start = receiver.span.start;
  6891. var /** @type {?} */ id = this.expectIdentifierOrKeyword();
  6892. if (this.optionalCharacter($LPAREN)) {
  6893. this.rparensExpected++;
  6894. var /** @type {?} */ args = this.parseCallArguments();
  6895. this.expectCharacter($RPAREN);
  6896. this.rparensExpected--;
  6897. var /** @type {?} */ span = this.span(start);
  6898. return isSafe ? new SafeMethodCall(span, receiver, id, args) :
  6899. new MethodCall(span, receiver, id, args);
  6900. }
  6901. else {
  6902. if (isSafe) {
  6903. if (this.optionalOperator('=')) {
  6904. this.error('The \'?.\' operator cannot be used in the assignment');
  6905. return new EmptyExpr(this.span(start));
  6906. }
  6907. else {
  6908. return new SafePropertyRead(this.span(start), receiver, id);
  6909. }
  6910. }
  6911. else {
  6912. if (this.optionalOperator('=')) {
  6913. if (!this.parseAction) {
  6914. this.error('Bindings cannot contain assignments');
  6915. return new EmptyExpr(this.span(start));
  6916. }
  6917. var /** @type {?} */ value = this.parseConditional();
  6918. return new PropertyWrite(this.span(start), receiver, id, value);
  6919. }
  6920. else {
  6921. return new PropertyRead(this.span(start), receiver, id);
  6922. }
  6923. }
  6924. }
  6925. };
  6926. /**
  6927. * @return {?}
  6928. */
  6929. _ParseAST.prototype.parseCallArguments = /**
  6930. * @return {?}
  6931. */
  6932. function () {
  6933. if (this.next.isCharacter($RPAREN))
  6934. return [];
  6935. var /** @type {?} */ positionals = [];
  6936. do {
  6937. positionals.push(this.parsePipe());
  6938. } while (this.optionalCharacter($COMMA));
  6939. return /** @type {?} */ (positionals);
  6940. };
  6941. /**
  6942. * An identifier, a keyword, a string with an optional `-` inbetween.
  6943. */
  6944. /**
  6945. * An identifier, a keyword, a string with an optional `-` inbetween.
  6946. * @return {?}
  6947. */
  6948. _ParseAST.prototype.expectTemplateBindingKey = /**
  6949. * An identifier, a keyword, a string with an optional `-` inbetween.
  6950. * @return {?}
  6951. */
  6952. function () {
  6953. var /** @type {?} */ result = '';
  6954. var /** @type {?} */ operatorFound = false;
  6955. do {
  6956. result += this.expectIdentifierOrKeywordOrString();
  6957. operatorFound = this.optionalOperator('-');
  6958. if (operatorFound) {
  6959. result += '-';
  6960. }
  6961. } while (operatorFound);
  6962. return result.toString();
  6963. };
  6964. /**
  6965. * @return {?}
  6966. */
  6967. _ParseAST.prototype.parseTemplateBindings = /**
  6968. * @return {?}
  6969. */
  6970. function () {
  6971. var /** @type {?} */ bindings = [];
  6972. var /** @type {?} */ prefix = /** @type {?} */ ((null));
  6973. var /** @type {?} */ warnings = [];
  6974. while (this.index < this.tokens.length) {
  6975. var /** @type {?} */ start = this.inputIndex;
  6976. var /** @type {?} */ keyIsVar = this.peekKeywordLet();
  6977. if (keyIsVar) {
  6978. this.advance();
  6979. }
  6980. var /** @type {?} */ rawKey = this.expectTemplateBindingKey();
  6981. var /** @type {?} */ key = rawKey;
  6982. if (!keyIsVar) {
  6983. if (prefix == null) {
  6984. prefix = key;
  6985. }
  6986. else {
  6987. key = prefix + key[0].toUpperCase() + key.substring(1);
  6988. }
  6989. }
  6990. this.optionalCharacter($COLON);
  6991. var /** @type {?} */ name_2 = /** @type {?} */ ((null));
  6992. var /** @type {?} */ expression = /** @type {?} */ ((null));
  6993. if (keyIsVar) {
  6994. if (this.optionalOperator('=')) {
  6995. name_2 = this.expectTemplateBindingKey();
  6996. }
  6997. else {
  6998. name_2 = '\$implicit';
  6999. }
  7000. }
  7001. else if (this.peekKeywordAs()) {
  7002. var /** @type {?} */ letStart = this.inputIndex;
  7003. this.advance(); // consume `as`
  7004. name_2 = rawKey;
  7005. key = this.expectTemplateBindingKey(); // read local var name
  7006. keyIsVar = true;
  7007. }
  7008. else if (this.next !== EOF && !this.peekKeywordLet()) {
  7009. var /** @type {?} */ start_1 = this.inputIndex;
  7010. var /** @type {?} */ ast = this.parsePipe();
  7011. var /** @type {?} */ source = this.input.substring(start_1 - this.offset, this.inputIndex - this.offset);
  7012. expression = new ASTWithSource(ast, source, this.location, this.errors);
  7013. }
  7014. bindings.push(new TemplateBinding(this.span(start), key, keyIsVar, name_2, expression));
  7015. if (this.peekKeywordAs() && !keyIsVar) {
  7016. var /** @type {?} */ letStart = this.inputIndex;
  7017. this.advance(); // consume `as`
  7018. var /** @type {?} */ letName = this.expectTemplateBindingKey(); // read local var name
  7019. bindings.push(new TemplateBinding(this.span(letStart), letName, true, key, /** @type {?} */ ((null))));
  7020. }
  7021. if (!this.optionalCharacter($SEMICOLON)) {
  7022. this.optionalCharacter($COMMA);
  7023. }
  7024. }
  7025. return new TemplateBindingParseResult(bindings, warnings, this.errors);
  7026. };
  7027. /**
  7028. * @param {?} message
  7029. * @param {?=} index
  7030. * @return {?}
  7031. */
  7032. _ParseAST.prototype.error = /**
  7033. * @param {?} message
  7034. * @param {?=} index
  7035. * @return {?}
  7036. */
  7037. function (message, index) {
  7038. if (index === void 0) { index = null; }
  7039. this.errors.push(new ParserError(message, this.input, this.locationText(index), this.location));
  7040. this.skip();
  7041. };
  7042. /**
  7043. * @param {?=} index
  7044. * @return {?}
  7045. */
  7046. _ParseAST.prototype.locationText = /**
  7047. * @param {?=} index
  7048. * @return {?}
  7049. */
  7050. function (index) {
  7051. if (index === void 0) { index = null; }
  7052. if (index == null)
  7053. index = this.index;
  7054. return (index < this.tokens.length) ? "at column " + (this.tokens[index].index + 1) + " in" :
  7055. "at the end of the expression";
  7056. };
  7057. /**
  7058. * @return {?}
  7059. */
  7060. _ParseAST.prototype.skip = /**
  7061. * @return {?}
  7062. */
  7063. function () {
  7064. var /** @type {?} */ n = this.next;
  7065. while (this.index < this.tokens.length && !n.isCharacter($SEMICOLON) &&
  7066. (this.rparensExpected <= 0 || !n.isCharacter($RPAREN)) &&
  7067. (this.rbracesExpected <= 0 || !n.isCharacter($RBRACE)) &&
  7068. (this.rbracketsExpected <= 0 || !n.isCharacter($RBRACKET))) {
  7069. if (this.next.isError()) {
  7070. this.errors.push(new ParserError(/** @type {?} */ ((this.next.toString())), this.input, this.locationText(), this.location));
  7071. }
  7072. this.advance();
  7073. n = this.next;
  7074. }
  7075. };
  7076. return _ParseAST;
  7077. }());
  7078. var SimpleExpressionChecker = /** @class */ (function () {
  7079. function SimpleExpressionChecker() {
  7080. this.errors = [];
  7081. }
  7082. /**
  7083. * @param {?} ast
  7084. * @return {?}
  7085. */
  7086. SimpleExpressionChecker.check = /**
  7087. * @param {?} ast
  7088. * @return {?}
  7089. */
  7090. function (ast) {
  7091. var /** @type {?} */ s = new SimpleExpressionChecker();
  7092. ast.visit(s);
  7093. return s.errors;
  7094. };
  7095. /**
  7096. * @param {?} ast
  7097. * @param {?} context
  7098. * @return {?}
  7099. */
  7100. SimpleExpressionChecker.prototype.visitImplicitReceiver = /**
  7101. * @param {?} ast
  7102. * @param {?} context
  7103. * @return {?}
  7104. */
  7105. function (ast, context) { };
  7106. /**
  7107. * @param {?} ast
  7108. * @param {?} context
  7109. * @return {?}
  7110. */
  7111. SimpleExpressionChecker.prototype.visitInterpolation = /**
  7112. * @param {?} ast
  7113. * @param {?} context
  7114. * @return {?}
  7115. */
  7116. function (ast, context) { };
  7117. /**
  7118. * @param {?} ast
  7119. * @param {?} context
  7120. * @return {?}
  7121. */
  7122. SimpleExpressionChecker.prototype.visitLiteralPrimitive = /**
  7123. * @param {?} ast
  7124. * @param {?} context
  7125. * @return {?}
  7126. */
  7127. function (ast, context) { };
  7128. /**
  7129. * @param {?} ast
  7130. * @param {?} context
  7131. * @return {?}
  7132. */
  7133. SimpleExpressionChecker.prototype.visitPropertyRead = /**
  7134. * @param {?} ast
  7135. * @param {?} context
  7136. * @return {?}
  7137. */
  7138. function (ast, context) { };
  7139. /**
  7140. * @param {?} ast
  7141. * @param {?} context
  7142. * @return {?}
  7143. */
  7144. SimpleExpressionChecker.prototype.visitPropertyWrite = /**
  7145. * @param {?} ast
  7146. * @param {?} context
  7147. * @return {?}
  7148. */
  7149. function (ast, context) { };
  7150. /**
  7151. * @param {?} ast
  7152. * @param {?} context
  7153. * @return {?}
  7154. */
  7155. SimpleExpressionChecker.prototype.visitSafePropertyRead = /**
  7156. * @param {?} ast
  7157. * @param {?} context
  7158. * @return {?}
  7159. */
  7160. function (ast, context) { };
  7161. /**
  7162. * @param {?} ast
  7163. * @param {?} context
  7164. * @return {?}
  7165. */
  7166. SimpleExpressionChecker.prototype.visitMethodCall = /**
  7167. * @param {?} ast
  7168. * @param {?} context
  7169. * @return {?}
  7170. */
  7171. function (ast, context) { };
  7172. /**
  7173. * @param {?} ast
  7174. * @param {?} context
  7175. * @return {?}
  7176. */
  7177. SimpleExpressionChecker.prototype.visitSafeMethodCall = /**
  7178. * @param {?} ast
  7179. * @param {?} context
  7180. * @return {?}
  7181. */
  7182. function (ast, context) { };
  7183. /**
  7184. * @param {?} ast
  7185. * @param {?} context
  7186. * @return {?}
  7187. */
  7188. SimpleExpressionChecker.prototype.visitFunctionCall = /**
  7189. * @param {?} ast
  7190. * @param {?} context
  7191. * @return {?}
  7192. */
  7193. function (ast, context) { };
  7194. /**
  7195. * @param {?} ast
  7196. * @param {?} context
  7197. * @return {?}
  7198. */
  7199. SimpleExpressionChecker.prototype.visitLiteralArray = /**
  7200. * @param {?} ast
  7201. * @param {?} context
  7202. * @return {?}
  7203. */
  7204. function (ast, context) { this.visitAll(ast.expressions); };
  7205. /**
  7206. * @param {?} ast
  7207. * @param {?} context
  7208. * @return {?}
  7209. */
  7210. SimpleExpressionChecker.prototype.visitLiteralMap = /**
  7211. * @param {?} ast
  7212. * @param {?} context
  7213. * @return {?}
  7214. */
  7215. function (ast, context) { this.visitAll(ast.values); };
  7216. /**
  7217. * @param {?} ast
  7218. * @param {?} context
  7219. * @return {?}
  7220. */
  7221. SimpleExpressionChecker.prototype.visitBinary = /**
  7222. * @param {?} ast
  7223. * @param {?} context
  7224. * @return {?}
  7225. */
  7226. function (ast, context) { };
  7227. /**
  7228. * @param {?} ast
  7229. * @param {?} context
  7230. * @return {?}
  7231. */
  7232. SimpleExpressionChecker.prototype.visitPrefixNot = /**
  7233. * @param {?} ast
  7234. * @param {?} context
  7235. * @return {?}
  7236. */
  7237. function (ast, context) { };
  7238. /**
  7239. * @param {?} ast
  7240. * @param {?} context
  7241. * @return {?}
  7242. */
  7243. SimpleExpressionChecker.prototype.visitNonNullAssert = /**
  7244. * @param {?} ast
  7245. * @param {?} context
  7246. * @return {?}
  7247. */
  7248. function (ast, context) { };
  7249. /**
  7250. * @param {?} ast
  7251. * @param {?} context
  7252. * @return {?}
  7253. */
  7254. SimpleExpressionChecker.prototype.visitConditional = /**
  7255. * @param {?} ast
  7256. * @param {?} context
  7257. * @return {?}
  7258. */
  7259. function (ast, context) { };
  7260. /**
  7261. * @param {?} ast
  7262. * @param {?} context
  7263. * @return {?}
  7264. */
  7265. SimpleExpressionChecker.prototype.visitPipe = /**
  7266. * @param {?} ast
  7267. * @param {?} context
  7268. * @return {?}
  7269. */
  7270. function (ast, context) { this.errors.push('pipes'); };
  7271. /**
  7272. * @param {?} ast
  7273. * @param {?} context
  7274. * @return {?}
  7275. */
  7276. SimpleExpressionChecker.prototype.visitKeyedRead = /**
  7277. * @param {?} ast
  7278. * @param {?} context
  7279. * @return {?}
  7280. */
  7281. function (ast, context) { };
  7282. /**
  7283. * @param {?} ast
  7284. * @param {?} context
  7285. * @return {?}
  7286. */
  7287. SimpleExpressionChecker.prototype.visitKeyedWrite = /**
  7288. * @param {?} ast
  7289. * @param {?} context
  7290. * @return {?}
  7291. */
  7292. function (ast, context) { };
  7293. /**
  7294. * @param {?} asts
  7295. * @return {?}
  7296. */
  7297. SimpleExpressionChecker.prototype.visitAll = /**
  7298. * @param {?} asts
  7299. * @return {?}
  7300. */
  7301. function (asts) {
  7302. var _this = this;
  7303. return asts.map(function (node) { return node.visit(_this); });
  7304. };
  7305. /**
  7306. * @param {?} ast
  7307. * @param {?} context
  7308. * @return {?}
  7309. */
  7310. SimpleExpressionChecker.prototype.visitChain = /**
  7311. * @param {?} ast
  7312. * @param {?} context
  7313. * @return {?}
  7314. */
  7315. function (ast, context) { };
  7316. /**
  7317. * @param {?} ast
  7318. * @param {?} context
  7319. * @return {?}
  7320. */
  7321. SimpleExpressionChecker.prototype.visitQuote = /**
  7322. * @param {?} ast
  7323. * @param {?} context
  7324. * @return {?}
  7325. */
  7326. function (ast, context) { };
  7327. return SimpleExpressionChecker;
  7328. }());
  7329. /**
  7330. * @fileoverview added by tsickle
  7331. * @suppress {checkTypes} checked by tsc
  7332. */
  7333. var ParseLocation = /** @class */ (function () {
  7334. function ParseLocation(file, offset, line, col) {
  7335. this.file = file;
  7336. this.offset = offset;
  7337. this.line = line;
  7338. this.col = col;
  7339. }
  7340. /**
  7341. * @return {?}
  7342. */
  7343. ParseLocation.prototype.toString = /**
  7344. * @return {?}
  7345. */
  7346. function () {
  7347. return this.offset != null ? this.file.url + "@" + this.line + ":" + this.col : this.file.url;
  7348. };
  7349. /**
  7350. * @param {?} delta
  7351. * @return {?}
  7352. */
  7353. ParseLocation.prototype.moveBy = /**
  7354. * @param {?} delta
  7355. * @return {?}
  7356. */
  7357. function (delta) {
  7358. var /** @type {?} */ source = this.file.content;
  7359. var /** @type {?} */ len = source.length;
  7360. var /** @type {?} */ offset = this.offset;
  7361. var /** @type {?} */ line = this.line;
  7362. var /** @type {?} */ col = this.col;
  7363. while (offset > 0 && delta < 0) {
  7364. offset--;
  7365. delta++;
  7366. var /** @type {?} */ ch = source.charCodeAt(offset);
  7367. if (ch == $LF) {
  7368. line--;
  7369. var /** @type {?} */ priorLine = source.substr(0, offset - 1).lastIndexOf(String.fromCharCode($LF));
  7370. col = priorLine > 0 ? offset - priorLine : offset;
  7371. }
  7372. else {
  7373. col--;
  7374. }
  7375. }
  7376. while (offset < len && delta > 0) {
  7377. var /** @type {?} */ ch = source.charCodeAt(offset);
  7378. offset++;
  7379. delta--;
  7380. if (ch == $LF) {
  7381. line++;
  7382. col = 0;
  7383. }
  7384. else {
  7385. col++;
  7386. }
  7387. }
  7388. return new ParseLocation(this.file, offset, line, col);
  7389. };
  7390. // Return the source around the location
  7391. // Up to `maxChars` or `maxLines` on each side of the location
  7392. /**
  7393. * @param {?} maxChars
  7394. * @param {?} maxLines
  7395. * @return {?}
  7396. */
  7397. ParseLocation.prototype.getContext = /**
  7398. * @param {?} maxChars
  7399. * @param {?} maxLines
  7400. * @return {?}
  7401. */
  7402. function (maxChars, maxLines) {
  7403. var /** @type {?} */ content = this.file.content;
  7404. var /** @type {?} */ startOffset = this.offset;
  7405. if (startOffset != null) {
  7406. if (startOffset > content.length - 1) {
  7407. startOffset = content.length - 1;
  7408. }
  7409. var /** @type {?} */ endOffset = startOffset;
  7410. var /** @type {?} */ ctxChars = 0;
  7411. var /** @type {?} */ ctxLines = 0;
  7412. while (ctxChars < maxChars && startOffset > 0) {
  7413. startOffset--;
  7414. ctxChars++;
  7415. if (content[startOffset] == '\n') {
  7416. if (++ctxLines == maxLines) {
  7417. break;
  7418. }
  7419. }
  7420. }
  7421. ctxChars = 0;
  7422. ctxLines = 0;
  7423. while (ctxChars < maxChars && endOffset < content.length - 1) {
  7424. endOffset++;
  7425. ctxChars++;
  7426. if (content[endOffset] == '\n') {
  7427. if (++ctxLines == maxLines) {
  7428. break;
  7429. }
  7430. }
  7431. }
  7432. return {
  7433. before: content.substring(startOffset, this.offset),
  7434. after: content.substring(this.offset, endOffset + 1),
  7435. };
  7436. }
  7437. return null;
  7438. };
  7439. return ParseLocation;
  7440. }());
  7441. var ParseSourceFile = /** @class */ (function () {
  7442. function ParseSourceFile(content, url) {
  7443. this.content = content;
  7444. this.url = url;
  7445. }
  7446. return ParseSourceFile;
  7447. }());
  7448. var ParseSourceSpan = /** @class */ (function () {
  7449. function ParseSourceSpan(start, end, details) {
  7450. if (details === void 0) { details = null; }
  7451. this.start = start;
  7452. this.end = end;
  7453. this.details = details;
  7454. }
  7455. /**
  7456. * @return {?}
  7457. */
  7458. ParseSourceSpan.prototype.toString = /**
  7459. * @return {?}
  7460. */
  7461. function () {
  7462. return this.start.file.content.substring(this.start.offset, this.end.offset);
  7463. };
  7464. return ParseSourceSpan;
  7465. }());
  7466. /** @enum {number} */
  7467. var ParseErrorLevel = {
  7468. WARNING: 0,
  7469. ERROR: 1,
  7470. };
  7471. ParseErrorLevel[ParseErrorLevel.WARNING] = "WARNING";
  7472. ParseErrorLevel[ParseErrorLevel.ERROR] = "ERROR";
  7473. var ParseError = /** @class */ (function () {
  7474. function ParseError(span, msg, level) {
  7475. if (level === void 0) { level = ParseErrorLevel.ERROR; }
  7476. this.span = span;
  7477. this.msg = msg;
  7478. this.level = level;
  7479. }
  7480. /**
  7481. * @return {?}
  7482. */
  7483. ParseError.prototype.contextualMessage = /**
  7484. * @return {?}
  7485. */
  7486. function () {
  7487. var /** @type {?} */ ctx = this.span.start.getContext(100, 3);
  7488. return ctx ? this.msg + " (\"" + ctx.before + "[" + ParseErrorLevel[this.level] + " ->]" + ctx.after + "\")" :
  7489. this.msg;
  7490. };
  7491. /**
  7492. * @return {?}
  7493. */
  7494. ParseError.prototype.toString = /**
  7495. * @return {?}
  7496. */
  7497. function () {
  7498. var /** @type {?} */ details = this.span.details ? ", " + this.span.details : '';
  7499. return this.contextualMessage() + ": " + this.span.start + details;
  7500. };
  7501. return ParseError;
  7502. }());
  7503. /**
  7504. * @param {?} kind
  7505. * @param {?} type
  7506. * @return {?}
  7507. */
  7508. function typeSourceSpan(kind, type) {
  7509. var /** @type {?} */ moduleUrl = identifierModuleUrl(type);
  7510. var /** @type {?} */ sourceFileName = moduleUrl != null ? "in " + kind + " " + identifierName(type) + " in " + moduleUrl :
  7511. "in " + kind + " " + identifierName(type);
  7512. var /** @type {?} */ sourceFile = new ParseSourceFile('', sourceFileName);
  7513. return new ParseSourceSpan(new ParseLocation(sourceFile, -1, -1, -1), new ParseLocation(sourceFile, -1, -1, -1));
  7514. }
  7515. /**
  7516. * @fileoverview added by tsickle
  7517. * @suppress {checkTypes} checked by tsc
  7518. */
  7519. /**
  7520. * @license
  7521. * Copyright Google Inc. All Rights Reserved.
  7522. *
  7523. * Use of this source code is governed by an MIT-style license that can be
  7524. * found in the LICENSE file at https://angular.io/license
  7525. */
  7526. /** @enum {number} */
  7527. var TokenType$1 = {
  7528. TAG_OPEN_START: 0,
  7529. TAG_OPEN_END: 1,
  7530. TAG_OPEN_END_VOID: 2,
  7531. TAG_CLOSE: 3,
  7532. TEXT: 4,
  7533. ESCAPABLE_RAW_TEXT: 5,
  7534. RAW_TEXT: 6,
  7535. COMMENT_START: 7,
  7536. COMMENT_END: 8,
  7537. CDATA_START: 9,
  7538. CDATA_END: 10,
  7539. ATTR_NAME: 11,
  7540. ATTR_VALUE: 12,
  7541. DOC_TYPE: 13,
  7542. EXPANSION_FORM_START: 14,
  7543. EXPANSION_CASE_VALUE: 15,
  7544. EXPANSION_CASE_EXP_START: 16,
  7545. EXPANSION_CASE_EXP_END: 17,
  7546. EXPANSION_FORM_END: 18,
  7547. EOF: 19,
  7548. };
  7549. TokenType$1[TokenType$1.TAG_OPEN_START] = "TAG_OPEN_START";
  7550. TokenType$1[TokenType$1.TAG_OPEN_END] = "TAG_OPEN_END";
  7551. TokenType$1[TokenType$1.TAG_OPEN_END_VOID] = "TAG_OPEN_END_VOID";
  7552. TokenType$1[TokenType$1.TAG_CLOSE] = "TAG_CLOSE";
  7553. TokenType$1[TokenType$1.TEXT] = "TEXT";
  7554. TokenType$1[TokenType$1.ESCAPABLE_RAW_TEXT] = "ESCAPABLE_RAW_TEXT";
  7555. TokenType$1[TokenType$1.RAW_TEXT] = "RAW_TEXT";
  7556. TokenType$1[TokenType$1.COMMENT_START] = "COMMENT_START";
  7557. TokenType$1[TokenType$1.COMMENT_END] = "COMMENT_END";
  7558. TokenType$1[TokenType$1.CDATA_START] = "CDATA_START";
  7559. TokenType$1[TokenType$1.CDATA_END] = "CDATA_END";
  7560. TokenType$1[TokenType$1.ATTR_NAME] = "ATTR_NAME";
  7561. TokenType$1[TokenType$1.ATTR_VALUE] = "ATTR_VALUE";
  7562. TokenType$1[TokenType$1.DOC_TYPE] = "DOC_TYPE";
  7563. TokenType$1[TokenType$1.EXPANSION_FORM_START] = "EXPANSION_FORM_START";
  7564. TokenType$1[TokenType$1.EXPANSION_CASE_VALUE] = "EXPANSION_CASE_VALUE";
  7565. TokenType$1[TokenType$1.EXPANSION_CASE_EXP_START] = "EXPANSION_CASE_EXP_START";
  7566. TokenType$1[TokenType$1.EXPANSION_CASE_EXP_END] = "EXPANSION_CASE_EXP_END";
  7567. TokenType$1[TokenType$1.EXPANSION_FORM_END] = "EXPANSION_FORM_END";
  7568. TokenType$1[TokenType$1.EOF] = "EOF";
  7569. var Token$1 = /** @class */ (function () {
  7570. function Token(type, parts, sourceSpan) {
  7571. this.type = type;
  7572. this.parts = parts;
  7573. this.sourceSpan = sourceSpan;
  7574. }
  7575. return Token;
  7576. }());
  7577. var TokenError = /** @class */ (function (_super) {
  7578. __extends(TokenError, _super);
  7579. function TokenError(errorMsg, tokenType, span) {
  7580. var _this = _super.call(this, span, errorMsg) || this;
  7581. _this.tokenType = tokenType;
  7582. return _this;
  7583. }
  7584. return TokenError;
  7585. }(ParseError));
  7586. var TokenizeResult = /** @class */ (function () {
  7587. function TokenizeResult(tokens, errors) {
  7588. this.tokens = tokens;
  7589. this.errors = errors;
  7590. }
  7591. return TokenizeResult;
  7592. }());
  7593. /**
  7594. * @param {?} source
  7595. * @param {?} url
  7596. * @param {?} getTagDefinition
  7597. * @param {?=} tokenizeExpansionForms
  7598. * @param {?=} interpolationConfig
  7599. * @return {?}
  7600. */
  7601. function tokenize(source, url, getTagDefinition, tokenizeExpansionForms, interpolationConfig) {
  7602. if (tokenizeExpansionForms === void 0) { tokenizeExpansionForms = false; }
  7603. if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
  7604. return new _Tokenizer(new ParseSourceFile(source, url), getTagDefinition, tokenizeExpansionForms, interpolationConfig)
  7605. .tokenize();
  7606. }
  7607. var _CR_OR_CRLF_REGEXP = /\r\n?/g;
  7608. /**
  7609. * @param {?} charCode
  7610. * @return {?}
  7611. */
  7612. function _unexpectedCharacterErrorMsg(charCode) {
  7613. var /** @type {?} */ char = charCode === $EOF ? 'EOF' : String.fromCharCode(charCode);
  7614. return "Unexpected character \"" + char + "\"";
  7615. }
  7616. /**
  7617. * @param {?} entitySrc
  7618. * @return {?}
  7619. */
  7620. function _unknownEntityErrorMsg(entitySrc) {
  7621. return "Unknown entity \"" + entitySrc + "\" - use the \"&#<decimal>;\" or \"&#x<hex>;\" syntax";
  7622. }
  7623. var _ControlFlowError = /** @class */ (function () {
  7624. function _ControlFlowError(error) {
  7625. this.error = error;
  7626. }
  7627. return _ControlFlowError;
  7628. }());
  7629. var _Tokenizer = /** @class */ (function () {
  7630. /**
  7631. * @param _file The html source
  7632. * @param _getTagDefinition
  7633. * @param _tokenizeIcu Whether to tokenize ICU messages (considered as text nodes when false)
  7634. * @param _interpolationConfig
  7635. */
  7636. function _Tokenizer(_file, _getTagDefinition, _tokenizeIcu, _interpolationConfig) {
  7637. if (_interpolationConfig === void 0) { _interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
  7638. this._file = _file;
  7639. this._getTagDefinition = _getTagDefinition;
  7640. this._tokenizeIcu = _tokenizeIcu;
  7641. this._interpolationConfig = _interpolationConfig;
  7642. this._peek = -1;
  7643. this._nextPeek = -1;
  7644. this._index = -1;
  7645. this._line = 0;
  7646. this._column = -1;
  7647. this._expansionCaseStack = [];
  7648. this._inInterpolation = false;
  7649. this.tokens = [];
  7650. this.errors = [];
  7651. this._input = _file.content;
  7652. this._length = _file.content.length;
  7653. this._advance();
  7654. }
  7655. /**
  7656. * @param {?} content
  7657. * @return {?}
  7658. */
  7659. _Tokenizer.prototype._processCarriageReturns = /**
  7660. * @param {?} content
  7661. * @return {?}
  7662. */
  7663. function (content) {
  7664. // http://www.w3.org/TR/html5/syntax.html#preprocessing-the-input-stream
  7665. // In order to keep the original position in the source, we can not
  7666. // pre-process it.
  7667. // Instead CRs are processed right before instantiating the tokens.
  7668. return content.replace(_CR_OR_CRLF_REGEXP, '\n');
  7669. };
  7670. /**
  7671. * @return {?}
  7672. */
  7673. _Tokenizer.prototype.tokenize = /**
  7674. * @return {?}
  7675. */
  7676. function () {
  7677. while (this._peek !== $EOF) {
  7678. var /** @type {?} */ start = this._getLocation();
  7679. try {
  7680. if (this._attemptCharCode($LT)) {
  7681. if (this._attemptCharCode($BANG)) {
  7682. if (this._attemptCharCode($LBRACKET)) {
  7683. this._consumeCdata(start);
  7684. }
  7685. else if (this._attemptCharCode($MINUS)) {
  7686. this._consumeComment(start);
  7687. }
  7688. else {
  7689. this._consumeDocType(start);
  7690. }
  7691. }
  7692. else if (this._attemptCharCode($SLASH)) {
  7693. this._consumeTagClose(start);
  7694. }
  7695. else {
  7696. this._consumeTagOpen(start);
  7697. }
  7698. }
  7699. else if (!(this._tokenizeIcu && this._tokenizeExpansionForm())) {
  7700. this._consumeText();
  7701. }
  7702. }
  7703. catch (/** @type {?} */ e) {
  7704. if (e instanceof _ControlFlowError) {
  7705. this.errors.push(e.error);
  7706. }
  7707. else {
  7708. throw e;
  7709. }
  7710. }
  7711. }
  7712. this._beginToken(TokenType$1.EOF);
  7713. this._endToken([]);
  7714. return new TokenizeResult(mergeTextTokens(this.tokens), this.errors);
  7715. };
  7716. /**
  7717. * \@internal
  7718. * @return {?} whether an ICU token has been created
  7719. */
  7720. _Tokenizer.prototype._tokenizeExpansionForm = /**
  7721. * \@internal
  7722. * @return {?} whether an ICU token has been created
  7723. */
  7724. function () {
  7725. if (isExpansionFormStart(this._input, this._index, this._interpolationConfig)) {
  7726. this._consumeExpansionFormStart();
  7727. return true;
  7728. }
  7729. if (isExpansionCaseStart(this._peek) && this._isInExpansionForm()) {
  7730. this._consumeExpansionCaseStart();
  7731. return true;
  7732. }
  7733. if (this._peek === $RBRACE) {
  7734. if (this._isInExpansionCase()) {
  7735. this._consumeExpansionCaseEnd();
  7736. return true;
  7737. }
  7738. if (this._isInExpansionForm()) {
  7739. this._consumeExpansionFormEnd();
  7740. return true;
  7741. }
  7742. }
  7743. return false;
  7744. };
  7745. /**
  7746. * @return {?}
  7747. */
  7748. _Tokenizer.prototype._getLocation = /**
  7749. * @return {?}
  7750. */
  7751. function () {
  7752. return new ParseLocation(this._file, this._index, this._line, this._column);
  7753. };
  7754. /**
  7755. * @param {?=} start
  7756. * @param {?=} end
  7757. * @return {?}
  7758. */
  7759. _Tokenizer.prototype._getSpan = /**
  7760. * @param {?=} start
  7761. * @param {?=} end
  7762. * @return {?}
  7763. */
  7764. function (start, end) {
  7765. if (start === void 0) { start = this._getLocation(); }
  7766. if (end === void 0) { end = this._getLocation(); }
  7767. return new ParseSourceSpan(start, end);
  7768. };
  7769. /**
  7770. * @param {?} type
  7771. * @param {?=} start
  7772. * @return {?}
  7773. */
  7774. _Tokenizer.prototype._beginToken = /**
  7775. * @param {?} type
  7776. * @param {?=} start
  7777. * @return {?}
  7778. */
  7779. function (type, start) {
  7780. if (start === void 0) { start = this._getLocation(); }
  7781. this._currentTokenStart = start;
  7782. this._currentTokenType = type;
  7783. };
  7784. /**
  7785. * @param {?} parts
  7786. * @param {?=} end
  7787. * @return {?}
  7788. */
  7789. _Tokenizer.prototype._endToken = /**
  7790. * @param {?} parts
  7791. * @param {?=} end
  7792. * @return {?}
  7793. */
  7794. function (parts, end) {
  7795. if (end === void 0) { end = this._getLocation(); }
  7796. var /** @type {?} */ token = new Token$1(this._currentTokenType, parts, new ParseSourceSpan(this._currentTokenStart, end));
  7797. this.tokens.push(token);
  7798. this._currentTokenStart = /** @type {?} */ ((null));
  7799. this._currentTokenType = /** @type {?} */ ((null));
  7800. return token;
  7801. };
  7802. /**
  7803. * @param {?} msg
  7804. * @param {?} span
  7805. * @return {?}
  7806. */
  7807. _Tokenizer.prototype._createError = /**
  7808. * @param {?} msg
  7809. * @param {?} span
  7810. * @return {?}
  7811. */
  7812. function (msg, span) {
  7813. if (this._isInExpansionForm()) {
  7814. msg += " (Do you have an unescaped \"{\" in your template? Use \"{{ '{' }}\") to escape it.)";
  7815. }
  7816. var /** @type {?} */ error = new TokenError(msg, this._currentTokenType, span);
  7817. this._currentTokenStart = /** @type {?} */ ((null));
  7818. this._currentTokenType = /** @type {?} */ ((null));
  7819. return new _ControlFlowError(error);
  7820. };
  7821. /**
  7822. * @return {?}
  7823. */
  7824. _Tokenizer.prototype._advance = /**
  7825. * @return {?}
  7826. */
  7827. function () {
  7828. if (this._index >= this._length) {
  7829. throw this._createError(_unexpectedCharacterErrorMsg($EOF), this._getSpan());
  7830. }
  7831. if (this._peek === $LF) {
  7832. this._line++;
  7833. this._column = 0;
  7834. }
  7835. else if (this._peek !== $LF && this._peek !== $CR) {
  7836. this._column++;
  7837. }
  7838. this._index++;
  7839. this._peek = this._index >= this._length ? $EOF : this._input.charCodeAt(this._index);
  7840. this._nextPeek =
  7841. this._index + 1 >= this._length ? $EOF : this._input.charCodeAt(this._index + 1);
  7842. };
  7843. /**
  7844. * @param {?} charCode
  7845. * @return {?}
  7846. */
  7847. _Tokenizer.prototype._attemptCharCode = /**
  7848. * @param {?} charCode
  7849. * @return {?}
  7850. */
  7851. function (charCode) {
  7852. if (this._peek === charCode) {
  7853. this._advance();
  7854. return true;
  7855. }
  7856. return false;
  7857. };
  7858. /**
  7859. * @param {?} charCode
  7860. * @return {?}
  7861. */
  7862. _Tokenizer.prototype._attemptCharCodeCaseInsensitive = /**
  7863. * @param {?} charCode
  7864. * @return {?}
  7865. */
  7866. function (charCode) {
  7867. if (compareCharCodeCaseInsensitive(this._peek, charCode)) {
  7868. this._advance();
  7869. return true;
  7870. }
  7871. return false;
  7872. };
  7873. /**
  7874. * @param {?} charCode
  7875. * @return {?}
  7876. */
  7877. _Tokenizer.prototype._requireCharCode = /**
  7878. * @param {?} charCode
  7879. * @return {?}
  7880. */
  7881. function (charCode) {
  7882. var /** @type {?} */ location = this._getLocation();
  7883. if (!this._attemptCharCode(charCode)) {
  7884. throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan(location, location));
  7885. }
  7886. };
  7887. /**
  7888. * @param {?} chars
  7889. * @return {?}
  7890. */
  7891. _Tokenizer.prototype._attemptStr = /**
  7892. * @param {?} chars
  7893. * @return {?}
  7894. */
  7895. function (chars) {
  7896. var /** @type {?} */ len = chars.length;
  7897. if (this._index + len > this._length) {
  7898. return false;
  7899. }
  7900. var /** @type {?} */ initialPosition = this._savePosition();
  7901. for (var /** @type {?} */ i = 0; i < len; i++) {
  7902. if (!this._attemptCharCode(chars.charCodeAt(i))) {
  7903. // If attempting to parse the string fails, we want to reset the parser
  7904. // to where it was before the attempt
  7905. this._restorePosition(initialPosition);
  7906. return false;
  7907. }
  7908. }
  7909. return true;
  7910. };
  7911. /**
  7912. * @param {?} chars
  7913. * @return {?}
  7914. */
  7915. _Tokenizer.prototype._attemptStrCaseInsensitive = /**
  7916. * @param {?} chars
  7917. * @return {?}
  7918. */
  7919. function (chars) {
  7920. for (var /** @type {?} */ i = 0; i < chars.length; i++) {
  7921. if (!this._attemptCharCodeCaseInsensitive(chars.charCodeAt(i))) {
  7922. return false;
  7923. }
  7924. }
  7925. return true;
  7926. };
  7927. /**
  7928. * @param {?} chars
  7929. * @return {?}
  7930. */
  7931. _Tokenizer.prototype._requireStr = /**
  7932. * @param {?} chars
  7933. * @return {?}
  7934. */
  7935. function (chars) {
  7936. var /** @type {?} */ location = this._getLocation();
  7937. if (!this._attemptStr(chars)) {
  7938. throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan(location));
  7939. }
  7940. };
  7941. /**
  7942. * @param {?} predicate
  7943. * @return {?}
  7944. */
  7945. _Tokenizer.prototype._attemptCharCodeUntilFn = /**
  7946. * @param {?} predicate
  7947. * @return {?}
  7948. */
  7949. function (predicate) {
  7950. while (!predicate(this._peek)) {
  7951. this._advance();
  7952. }
  7953. };
  7954. /**
  7955. * @param {?} predicate
  7956. * @param {?} len
  7957. * @return {?}
  7958. */
  7959. _Tokenizer.prototype._requireCharCodeUntilFn = /**
  7960. * @param {?} predicate
  7961. * @param {?} len
  7962. * @return {?}
  7963. */
  7964. function (predicate, len) {
  7965. var /** @type {?} */ start = this._getLocation();
  7966. this._attemptCharCodeUntilFn(predicate);
  7967. if (this._index - start.offset < len) {
  7968. throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan(start, start));
  7969. }
  7970. };
  7971. /**
  7972. * @param {?} char
  7973. * @return {?}
  7974. */
  7975. _Tokenizer.prototype._attemptUntilChar = /**
  7976. * @param {?} char
  7977. * @return {?}
  7978. */
  7979. function (char) {
  7980. while (this._peek !== char) {
  7981. this._advance();
  7982. }
  7983. };
  7984. /**
  7985. * @param {?} decodeEntities
  7986. * @return {?}
  7987. */
  7988. _Tokenizer.prototype._readChar = /**
  7989. * @param {?} decodeEntities
  7990. * @return {?}
  7991. */
  7992. function (decodeEntities) {
  7993. if (decodeEntities && this._peek === $AMPERSAND) {
  7994. return this._decodeEntity();
  7995. }
  7996. else {
  7997. var /** @type {?} */ index = this._index;
  7998. this._advance();
  7999. return this._input[index];
  8000. }
  8001. };
  8002. /**
  8003. * @return {?}
  8004. */
  8005. _Tokenizer.prototype._decodeEntity = /**
  8006. * @return {?}
  8007. */
  8008. function () {
  8009. var /** @type {?} */ start = this._getLocation();
  8010. this._advance();
  8011. if (this._attemptCharCode($HASH)) {
  8012. var /** @type {?} */ isHex = this._attemptCharCode($x) || this._attemptCharCode($X);
  8013. var /** @type {?} */ numberStart = this._getLocation().offset;
  8014. this._attemptCharCodeUntilFn(isDigitEntityEnd);
  8015. if (this._peek != $SEMICOLON) {
  8016. throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan());
  8017. }
  8018. this._advance();
  8019. var /** @type {?} */ strNum = this._input.substring(numberStart, this._index - 1);
  8020. try {
  8021. var /** @type {?} */ charCode = parseInt(strNum, isHex ? 16 : 10);
  8022. return String.fromCharCode(charCode);
  8023. }
  8024. catch (/** @type {?} */ e) {
  8025. var /** @type {?} */ entity = this._input.substring(start.offset + 1, this._index - 1);
  8026. throw this._createError(_unknownEntityErrorMsg(entity), this._getSpan(start));
  8027. }
  8028. }
  8029. else {
  8030. var /** @type {?} */ startPosition = this._savePosition();
  8031. this._attemptCharCodeUntilFn(isNamedEntityEnd);
  8032. if (this._peek != $SEMICOLON) {
  8033. this._restorePosition(startPosition);
  8034. return '&';
  8035. }
  8036. this._advance();
  8037. var /** @type {?} */ name_1 = this._input.substring(start.offset + 1, this._index - 1);
  8038. var /** @type {?} */ char = NAMED_ENTITIES[name_1];
  8039. if (!char) {
  8040. throw this._createError(_unknownEntityErrorMsg(name_1), this._getSpan(start));
  8041. }
  8042. return char;
  8043. }
  8044. };
  8045. /**
  8046. * @param {?} decodeEntities
  8047. * @param {?} firstCharOfEnd
  8048. * @param {?} attemptEndRest
  8049. * @return {?}
  8050. */
  8051. _Tokenizer.prototype._consumeRawText = /**
  8052. * @param {?} decodeEntities
  8053. * @param {?} firstCharOfEnd
  8054. * @param {?} attemptEndRest
  8055. * @return {?}
  8056. */
  8057. function (decodeEntities, firstCharOfEnd, attemptEndRest) {
  8058. var /** @type {?} */ tagCloseStart;
  8059. var /** @type {?} */ textStart = this._getLocation();
  8060. this._beginToken(decodeEntities ? TokenType$1.ESCAPABLE_RAW_TEXT : TokenType$1.RAW_TEXT, textStart);
  8061. var /** @type {?} */ parts = [];
  8062. while (true) {
  8063. tagCloseStart = this._getLocation();
  8064. if (this._attemptCharCode(firstCharOfEnd) && attemptEndRest()) {
  8065. break;
  8066. }
  8067. if (this._index > tagCloseStart.offset) {
  8068. // add the characters consumed by the previous if statement to the output
  8069. parts.push(this._input.substring(tagCloseStart.offset, this._index));
  8070. }
  8071. while (this._peek !== firstCharOfEnd) {
  8072. parts.push(this._readChar(decodeEntities));
  8073. }
  8074. }
  8075. return this._endToken([this._processCarriageReturns(parts.join(''))], tagCloseStart);
  8076. };
  8077. /**
  8078. * @param {?} start
  8079. * @return {?}
  8080. */
  8081. _Tokenizer.prototype._consumeComment = /**
  8082. * @param {?} start
  8083. * @return {?}
  8084. */
  8085. function (start) {
  8086. var _this = this;
  8087. this._beginToken(TokenType$1.COMMENT_START, start);
  8088. this._requireCharCode($MINUS);
  8089. this._endToken([]);
  8090. var /** @type {?} */ textToken = this._consumeRawText(false, $MINUS, function () { return _this._attemptStr('->'); });
  8091. this._beginToken(TokenType$1.COMMENT_END, textToken.sourceSpan.end);
  8092. this._endToken([]);
  8093. };
  8094. /**
  8095. * @param {?} start
  8096. * @return {?}
  8097. */
  8098. _Tokenizer.prototype._consumeCdata = /**
  8099. * @param {?} start
  8100. * @return {?}
  8101. */
  8102. function (start) {
  8103. var _this = this;
  8104. this._beginToken(TokenType$1.CDATA_START, start);
  8105. this._requireStr('CDATA[');
  8106. this._endToken([]);
  8107. var /** @type {?} */ textToken = this._consumeRawText(false, $RBRACKET, function () { return _this._attemptStr(']>'); });
  8108. this._beginToken(TokenType$1.CDATA_END, textToken.sourceSpan.end);
  8109. this._endToken([]);
  8110. };
  8111. /**
  8112. * @param {?} start
  8113. * @return {?}
  8114. */
  8115. _Tokenizer.prototype._consumeDocType = /**
  8116. * @param {?} start
  8117. * @return {?}
  8118. */
  8119. function (start) {
  8120. this._beginToken(TokenType$1.DOC_TYPE, start);
  8121. this._attemptUntilChar($GT);
  8122. this._advance();
  8123. this._endToken([this._input.substring(start.offset + 2, this._index - 1)]);
  8124. };
  8125. /**
  8126. * @return {?}
  8127. */
  8128. _Tokenizer.prototype._consumePrefixAndName = /**
  8129. * @return {?}
  8130. */
  8131. function () {
  8132. var /** @type {?} */ nameOrPrefixStart = this._index;
  8133. var /** @type {?} */ prefix = /** @type {?} */ ((null));
  8134. while (this._peek !== $COLON && !isPrefixEnd(this._peek)) {
  8135. this._advance();
  8136. }
  8137. var /** @type {?} */ nameStart;
  8138. if (this._peek === $COLON) {
  8139. this._advance();
  8140. prefix = this._input.substring(nameOrPrefixStart, this._index - 1);
  8141. nameStart = this._index;
  8142. }
  8143. else {
  8144. nameStart = nameOrPrefixStart;
  8145. }
  8146. this._requireCharCodeUntilFn(isNameEnd, this._index === nameStart ? 1 : 0);
  8147. var /** @type {?} */ name = this._input.substring(nameStart, this._index);
  8148. return [prefix, name];
  8149. };
  8150. /**
  8151. * @param {?} start
  8152. * @return {?}
  8153. */
  8154. _Tokenizer.prototype._consumeTagOpen = /**
  8155. * @param {?} start
  8156. * @return {?}
  8157. */
  8158. function (start) {
  8159. var /** @type {?} */ savedPos = this._savePosition();
  8160. var /** @type {?} */ tagName;
  8161. var /** @type {?} */ lowercaseTagName;
  8162. try {
  8163. if (!isAsciiLetter(this._peek)) {
  8164. throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan());
  8165. }
  8166. var /** @type {?} */ nameStart = this._index;
  8167. this._consumeTagOpenStart(start);
  8168. tagName = this._input.substring(nameStart, this._index);
  8169. lowercaseTagName = tagName.toLowerCase();
  8170. this._attemptCharCodeUntilFn(isNotWhitespace);
  8171. while (this._peek !== $SLASH && this._peek !== $GT) {
  8172. this._consumeAttributeName();
  8173. this._attemptCharCodeUntilFn(isNotWhitespace);
  8174. if (this._attemptCharCode($EQ)) {
  8175. this._attemptCharCodeUntilFn(isNotWhitespace);
  8176. this._consumeAttributeValue();
  8177. }
  8178. this._attemptCharCodeUntilFn(isNotWhitespace);
  8179. }
  8180. this._consumeTagOpenEnd();
  8181. }
  8182. catch (/** @type {?} */ e) {
  8183. if (e instanceof _ControlFlowError) {
  8184. // When the start tag is invalid, assume we want a "<"
  8185. this._restorePosition(savedPos);
  8186. // Back to back text tokens are merged at the end
  8187. this._beginToken(TokenType$1.TEXT, start);
  8188. this._endToken(['<']);
  8189. return;
  8190. }
  8191. throw e;
  8192. }
  8193. var /** @type {?} */ contentTokenType = this._getTagDefinition(tagName).contentType;
  8194. if (contentTokenType === TagContentType.RAW_TEXT) {
  8195. this._consumeRawTextWithTagClose(lowercaseTagName, false);
  8196. }
  8197. else if (contentTokenType === TagContentType.ESCAPABLE_RAW_TEXT) {
  8198. this._consumeRawTextWithTagClose(lowercaseTagName, true);
  8199. }
  8200. };
  8201. /**
  8202. * @param {?} lowercaseTagName
  8203. * @param {?} decodeEntities
  8204. * @return {?}
  8205. */
  8206. _Tokenizer.prototype._consumeRawTextWithTagClose = /**
  8207. * @param {?} lowercaseTagName
  8208. * @param {?} decodeEntities
  8209. * @return {?}
  8210. */
  8211. function (lowercaseTagName, decodeEntities) {
  8212. var _this = this;
  8213. var /** @type {?} */ textToken = this._consumeRawText(decodeEntities, $LT, function () {
  8214. if (!_this._attemptCharCode($SLASH))
  8215. return false;
  8216. _this._attemptCharCodeUntilFn(isNotWhitespace);
  8217. if (!_this._attemptStrCaseInsensitive(lowercaseTagName))
  8218. return false;
  8219. _this._attemptCharCodeUntilFn(isNotWhitespace);
  8220. return _this._attemptCharCode($GT);
  8221. });
  8222. this._beginToken(TokenType$1.TAG_CLOSE, textToken.sourceSpan.end);
  8223. this._endToken([/** @type {?} */ ((null)), lowercaseTagName]);
  8224. };
  8225. /**
  8226. * @param {?} start
  8227. * @return {?}
  8228. */
  8229. _Tokenizer.prototype._consumeTagOpenStart = /**
  8230. * @param {?} start
  8231. * @return {?}
  8232. */
  8233. function (start) {
  8234. this._beginToken(TokenType$1.TAG_OPEN_START, start);
  8235. var /** @type {?} */ parts = this._consumePrefixAndName();
  8236. this._endToken(parts);
  8237. };
  8238. /**
  8239. * @return {?}
  8240. */
  8241. _Tokenizer.prototype._consumeAttributeName = /**
  8242. * @return {?}
  8243. */
  8244. function () {
  8245. this._beginToken(TokenType$1.ATTR_NAME);
  8246. var /** @type {?} */ prefixAndName = this._consumePrefixAndName();
  8247. this._endToken(prefixAndName);
  8248. };
  8249. /**
  8250. * @return {?}
  8251. */
  8252. _Tokenizer.prototype._consumeAttributeValue = /**
  8253. * @return {?}
  8254. */
  8255. function () {
  8256. this._beginToken(TokenType$1.ATTR_VALUE);
  8257. var /** @type {?} */ value;
  8258. if (this._peek === $SQ || this._peek === $DQ) {
  8259. var /** @type {?} */ quoteChar = this._peek;
  8260. this._advance();
  8261. var /** @type {?} */ parts = [];
  8262. while (this._peek !== quoteChar) {
  8263. parts.push(this._readChar(true));
  8264. }
  8265. value = parts.join('');
  8266. this._advance();
  8267. }
  8268. else {
  8269. var /** @type {?} */ valueStart = this._index;
  8270. this._requireCharCodeUntilFn(isNameEnd, 1);
  8271. value = this._input.substring(valueStart, this._index);
  8272. }
  8273. this._endToken([this._processCarriageReturns(value)]);
  8274. };
  8275. /**
  8276. * @return {?}
  8277. */
  8278. _Tokenizer.prototype._consumeTagOpenEnd = /**
  8279. * @return {?}
  8280. */
  8281. function () {
  8282. var /** @type {?} */ tokenType = this._attemptCharCode($SLASH) ? TokenType$1.TAG_OPEN_END_VOID : TokenType$1.TAG_OPEN_END;
  8283. this._beginToken(tokenType);
  8284. this._requireCharCode($GT);
  8285. this._endToken([]);
  8286. };
  8287. /**
  8288. * @param {?} start
  8289. * @return {?}
  8290. */
  8291. _Tokenizer.prototype._consumeTagClose = /**
  8292. * @param {?} start
  8293. * @return {?}
  8294. */
  8295. function (start) {
  8296. this._beginToken(TokenType$1.TAG_CLOSE, start);
  8297. this._attemptCharCodeUntilFn(isNotWhitespace);
  8298. var /** @type {?} */ prefixAndName = this._consumePrefixAndName();
  8299. this._attemptCharCodeUntilFn(isNotWhitespace);
  8300. this._requireCharCode($GT);
  8301. this._endToken(prefixAndName);
  8302. };
  8303. /**
  8304. * @return {?}
  8305. */
  8306. _Tokenizer.prototype._consumeExpansionFormStart = /**
  8307. * @return {?}
  8308. */
  8309. function () {
  8310. this._beginToken(TokenType$1.EXPANSION_FORM_START, this._getLocation());
  8311. this._requireCharCode($LBRACE);
  8312. this._endToken([]);
  8313. this._expansionCaseStack.push(TokenType$1.EXPANSION_FORM_START);
  8314. this._beginToken(TokenType$1.RAW_TEXT, this._getLocation());
  8315. var /** @type {?} */ condition = this._readUntil($COMMA);
  8316. this._endToken([condition], this._getLocation());
  8317. this._requireCharCode($COMMA);
  8318. this._attemptCharCodeUntilFn(isNotWhitespace);
  8319. this._beginToken(TokenType$1.RAW_TEXT, this._getLocation());
  8320. var /** @type {?} */ type = this._readUntil($COMMA);
  8321. this._endToken([type], this._getLocation());
  8322. this._requireCharCode($COMMA);
  8323. this._attemptCharCodeUntilFn(isNotWhitespace);
  8324. };
  8325. /**
  8326. * @return {?}
  8327. */
  8328. _Tokenizer.prototype._consumeExpansionCaseStart = /**
  8329. * @return {?}
  8330. */
  8331. function () {
  8332. this._beginToken(TokenType$1.EXPANSION_CASE_VALUE, this._getLocation());
  8333. var /** @type {?} */ value = this._readUntil($LBRACE).trim();
  8334. this._endToken([value], this._getLocation());
  8335. this._attemptCharCodeUntilFn(isNotWhitespace);
  8336. this._beginToken(TokenType$1.EXPANSION_CASE_EXP_START, this._getLocation());
  8337. this._requireCharCode($LBRACE);
  8338. this._endToken([], this._getLocation());
  8339. this._attemptCharCodeUntilFn(isNotWhitespace);
  8340. this._expansionCaseStack.push(TokenType$1.EXPANSION_CASE_EXP_START);
  8341. };
  8342. /**
  8343. * @return {?}
  8344. */
  8345. _Tokenizer.prototype._consumeExpansionCaseEnd = /**
  8346. * @return {?}
  8347. */
  8348. function () {
  8349. this._beginToken(TokenType$1.EXPANSION_CASE_EXP_END, this._getLocation());
  8350. this._requireCharCode($RBRACE);
  8351. this._endToken([], this._getLocation());
  8352. this._attemptCharCodeUntilFn(isNotWhitespace);
  8353. this._expansionCaseStack.pop();
  8354. };
  8355. /**
  8356. * @return {?}
  8357. */
  8358. _Tokenizer.prototype._consumeExpansionFormEnd = /**
  8359. * @return {?}
  8360. */
  8361. function () {
  8362. this._beginToken(TokenType$1.EXPANSION_FORM_END, this._getLocation());
  8363. this._requireCharCode($RBRACE);
  8364. this._endToken([]);
  8365. this._expansionCaseStack.pop();
  8366. };
  8367. /**
  8368. * @return {?}
  8369. */
  8370. _Tokenizer.prototype._consumeText = /**
  8371. * @return {?}
  8372. */
  8373. function () {
  8374. var /** @type {?} */ start = this._getLocation();
  8375. this._beginToken(TokenType$1.TEXT, start);
  8376. var /** @type {?} */ parts = [];
  8377. do {
  8378. if (this._interpolationConfig && this._attemptStr(this._interpolationConfig.start)) {
  8379. parts.push(this._interpolationConfig.start);
  8380. this._inInterpolation = true;
  8381. }
  8382. else if (this._interpolationConfig && this._inInterpolation &&
  8383. this._attemptStr(this._interpolationConfig.end)) {
  8384. parts.push(this._interpolationConfig.end);
  8385. this._inInterpolation = false;
  8386. }
  8387. else {
  8388. parts.push(this._readChar(true));
  8389. }
  8390. } while (!this._isTextEnd());
  8391. this._endToken([this._processCarriageReturns(parts.join(''))]);
  8392. };
  8393. /**
  8394. * @return {?}
  8395. */
  8396. _Tokenizer.prototype._isTextEnd = /**
  8397. * @return {?}
  8398. */
  8399. function () {
  8400. if (this._peek === $LT || this._peek === $EOF) {
  8401. return true;
  8402. }
  8403. if (this._tokenizeIcu && !this._inInterpolation) {
  8404. if (isExpansionFormStart(this._input, this._index, this._interpolationConfig)) {
  8405. // start of an expansion form
  8406. return true;
  8407. }
  8408. if (this._peek === $RBRACE && this._isInExpansionCase()) {
  8409. // end of and expansion case
  8410. return true;
  8411. }
  8412. }
  8413. return false;
  8414. };
  8415. /**
  8416. * @return {?}
  8417. */
  8418. _Tokenizer.prototype._savePosition = /**
  8419. * @return {?}
  8420. */
  8421. function () {
  8422. return [this._peek, this._index, this._column, this._line, this.tokens.length];
  8423. };
  8424. /**
  8425. * @param {?} char
  8426. * @return {?}
  8427. */
  8428. _Tokenizer.prototype._readUntil = /**
  8429. * @param {?} char
  8430. * @return {?}
  8431. */
  8432. function (char) {
  8433. var /** @type {?} */ start = this._index;
  8434. this._attemptUntilChar(char);
  8435. return this._input.substring(start, this._index);
  8436. };
  8437. /**
  8438. * @param {?} position
  8439. * @return {?}
  8440. */
  8441. _Tokenizer.prototype._restorePosition = /**
  8442. * @param {?} position
  8443. * @return {?}
  8444. */
  8445. function (position) {
  8446. this._peek = position[0];
  8447. this._index = position[1];
  8448. this._column = position[2];
  8449. this._line = position[3];
  8450. var /** @type {?} */ nbTokens = position[4];
  8451. if (nbTokens < this.tokens.length) {
  8452. // remove any extra tokens
  8453. this.tokens = this.tokens.slice(0, nbTokens);
  8454. }
  8455. };
  8456. /**
  8457. * @return {?}
  8458. */
  8459. _Tokenizer.prototype._isInExpansionCase = /**
  8460. * @return {?}
  8461. */
  8462. function () {
  8463. return this._expansionCaseStack.length > 0 &&
  8464. this._expansionCaseStack[this._expansionCaseStack.length - 1] ===
  8465. TokenType$1.EXPANSION_CASE_EXP_START;
  8466. };
  8467. /**
  8468. * @return {?}
  8469. */
  8470. _Tokenizer.prototype._isInExpansionForm = /**
  8471. * @return {?}
  8472. */
  8473. function () {
  8474. return this._expansionCaseStack.length > 0 &&
  8475. this._expansionCaseStack[this._expansionCaseStack.length - 1] ===
  8476. TokenType$1.EXPANSION_FORM_START;
  8477. };
  8478. return _Tokenizer;
  8479. }());
  8480. /**
  8481. * @param {?} code
  8482. * @return {?}
  8483. */
  8484. function isNotWhitespace(code) {
  8485. return !isWhitespace(code) || code === $EOF;
  8486. }
  8487. /**
  8488. * @param {?} code
  8489. * @return {?}
  8490. */
  8491. function isNameEnd(code) {
  8492. return isWhitespace(code) || code === $GT || code === $SLASH ||
  8493. code === $SQ || code === $DQ || code === $EQ;
  8494. }
  8495. /**
  8496. * @param {?} code
  8497. * @return {?}
  8498. */
  8499. function isPrefixEnd(code) {
  8500. return (code < $a || $z < code) && (code < $A || $Z < code) &&
  8501. (code < $0 || code > $9);
  8502. }
  8503. /**
  8504. * @param {?} code
  8505. * @return {?}
  8506. */
  8507. function isDigitEntityEnd(code) {
  8508. return code == $SEMICOLON || code == $EOF || !isAsciiHexDigit(code);
  8509. }
  8510. /**
  8511. * @param {?} code
  8512. * @return {?}
  8513. */
  8514. function isNamedEntityEnd(code) {
  8515. return code == $SEMICOLON || code == $EOF || !isAsciiLetter(code);
  8516. }
  8517. /**
  8518. * @param {?} input
  8519. * @param {?} offset
  8520. * @param {?} interpolationConfig
  8521. * @return {?}
  8522. */
  8523. function isExpansionFormStart(input, offset, interpolationConfig) {
  8524. var /** @type {?} */ isInterpolationStart = interpolationConfig ? input.indexOf(interpolationConfig.start, offset) == offset : false;
  8525. return input.charCodeAt(offset) == $LBRACE && !isInterpolationStart;
  8526. }
  8527. /**
  8528. * @param {?} peek
  8529. * @return {?}
  8530. */
  8531. function isExpansionCaseStart(peek) {
  8532. return peek === $EQ || isAsciiLetter(peek) || isDigit(peek);
  8533. }
  8534. /**
  8535. * @param {?} code1
  8536. * @param {?} code2
  8537. * @return {?}
  8538. */
  8539. function compareCharCodeCaseInsensitive(code1, code2) {
  8540. return toUpperCaseCharCode(code1) == toUpperCaseCharCode(code2);
  8541. }
  8542. /**
  8543. * @param {?} code
  8544. * @return {?}
  8545. */
  8546. function toUpperCaseCharCode(code) {
  8547. return code >= $a && code <= $z ? code - $a + $A : code;
  8548. }
  8549. /**
  8550. * @param {?} srcTokens
  8551. * @return {?}
  8552. */
  8553. function mergeTextTokens(srcTokens) {
  8554. var /** @type {?} */ dstTokens = [];
  8555. var /** @type {?} */ lastDstToken = undefined;
  8556. for (var /** @type {?} */ i = 0; i < srcTokens.length; i++) {
  8557. var /** @type {?} */ token = srcTokens[i];
  8558. if (lastDstToken && lastDstToken.type == TokenType$1.TEXT && token.type == TokenType$1.TEXT) {
  8559. lastDstToken.parts[0] += token.parts[0];
  8560. lastDstToken.sourceSpan.end = token.sourceSpan.end;
  8561. }
  8562. else {
  8563. lastDstToken = token;
  8564. dstTokens.push(lastDstToken);
  8565. }
  8566. }
  8567. return dstTokens;
  8568. }
  8569. /**
  8570. * @fileoverview added by tsickle
  8571. * @suppress {checkTypes} checked by tsc
  8572. */
  8573. /**
  8574. * @license
  8575. * Copyright Google Inc. All Rights Reserved.
  8576. *
  8577. * Use of this source code is governed by an MIT-style license that can be
  8578. * found in the LICENSE file at https://angular.io/license
  8579. */
  8580. var TreeError = /** @class */ (function (_super) {
  8581. __extends(TreeError, _super);
  8582. function TreeError(elementName, span, msg) {
  8583. var _this = _super.call(this, span, msg) || this;
  8584. _this.elementName = elementName;
  8585. return _this;
  8586. }
  8587. /**
  8588. * @param {?} elementName
  8589. * @param {?} span
  8590. * @param {?} msg
  8591. * @return {?}
  8592. */
  8593. TreeError.create = /**
  8594. * @param {?} elementName
  8595. * @param {?} span
  8596. * @param {?} msg
  8597. * @return {?}
  8598. */
  8599. function (elementName, span, msg) {
  8600. return new TreeError(elementName, span, msg);
  8601. };
  8602. return TreeError;
  8603. }(ParseError));
  8604. var ParseTreeResult = /** @class */ (function () {
  8605. function ParseTreeResult(rootNodes, errors) {
  8606. this.rootNodes = rootNodes;
  8607. this.errors = errors;
  8608. }
  8609. return ParseTreeResult;
  8610. }());
  8611. var Parser$1 = /** @class */ (function () {
  8612. function Parser(getTagDefinition) {
  8613. this.getTagDefinition = getTagDefinition;
  8614. }
  8615. /**
  8616. * @param {?} source
  8617. * @param {?} url
  8618. * @param {?=} parseExpansionForms
  8619. * @param {?=} interpolationConfig
  8620. * @return {?}
  8621. */
  8622. Parser.prototype.parse = /**
  8623. * @param {?} source
  8624. * @param {?} url
  8625. * @param {?=} parseExpansionForms
  8626. * @param {?=} interpolationConfig
  8627. * @return {?}
  8628. */
  8629. function (source, url, parseExpansionForms, interpolationConfig) {
  8630. if (parseExpansionForms === void 0) { parseExpansionForms = false; }
  8631. if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
  8632. var /** @type {?} */ tokensAndErrors = tokenize(source, url, this.getTagDefinition, parseExpansionForms, interpolationConfig);
  8633. var /** @type {?} */ treeAndErrors = new _TreeBuilder(tokensAndErrors.tokens, this.getTagDefinition).build();
  8634. return new ParseTreeResult(treeAndErrors.rootNodes, (/** @type {?} */ (tokensAndErrors.errors)).concat(treeAndErrors.errors));
  8635. };
  8636. return Parser;
  8637. }());
  8638. var _TreeBuilder = /** @class */ (function () {
  8639. function _TreeBuilder(tokens, getTagDefinition) {
  8640. this.tokens = tokens;
  8641. this.getTagDefinition = getTagDefinition;
  8642. this._index = -1;
  8643. this._rootNodes = [];
  8644. this._errors = [];
  8645. this._elementStack = [];
  8646. this._advance();
  8647. }
  8648. /**
  8649. * @return {?}
  8650. */
  8651. _TreeBuilder.prototype.build = /**
  8652. * @return {?}
  8653. */
  8654. function () {
  8655. while (this._peek.type !== TokenType$1.EOF) {
  8656. if (this._peek.type === TokenType$1.TAG_OPEN_START) {
  8657. this._consumeStartTag(this._advance());
  8658. }
  8659. else if (this._peek.type === TokenType$1.TAG_CLOSE) {
  8660. this._consumeEndTag(this._advance());
  8661. }
  8662. else if (this._peek.type === TokenType$1.CDATA_START) {
  8663. this._closeVoidElement();
  8664. this._consumeCdata(this._advance());
  8665. }
  8666. else if (this._peek.type === TokenType$1.COMMENT_START) {
  8667. this._closeVoidElement();
  8668. this._consumeComment(this._advance());
  8669. }
  8670. else if (this._peek.type === TokenType$1.TEXT || this._peek.type === TokenType$1.RAW_TEXT ||
  8671. this._peek.type === TokenType$1.ESCAPABLE_RAW_TEXT) {
  8672. this._closeVoidElement();
  8673. this._consumeText(this._advance());
  8674. }
  8675. else if (this._peek.type === TokenType$1.EXPANSION_FORM_START) {
  8676. this._consumeExpansion(this._advance());
  8677. }
  8678. else {
  8679. // Skip all other tokens...
  8680. this._advance();
  8681. }
  8682. }
  8683. return new ParseTreeResult(this._rootNodes, this._errors);
  8684. };
  8685. /**
  8686. * @return {?}
  8687. */
  8688. _TreeBuilder.prototype._advance = /**
  8689. * @return {?}
  8690. */
  8691. function () {
  8692. var /** @type {?} */ prev = this._peek;
  8693. if (this._index < this.tokens.length - 1) {
  8694. // Note: there is always an EOF token at the end
  8695. this._index++;
  8696. }
  8697. this._peek = this.tokens[this._index];
  8698. return prev;
  8699. };
  8700. /**
  8701. * @param {?} type
  8702. * @return {?}
  8703. */
  8704. _TreeBuilder.prototype._advanceIf = /**
  8705. * @param {?} type
  8706. * @return {?}
  8707. */
  8708. function (type) {
  8709. if (this._peek.type === type) {
  8710. return this._advance();
  8711. }
  8712. return null;
  8713. };
  8714. /**
  8715. * @param {?} startToken
  8716. * @return {?}
  8717. */
  8718. _TreeBuilder.prototype._consumeCdata = /**
  8719. * @param {?} startToken
  8720. * @return {?}
  8721. */
  8722. function (startToken) {
  8723. this._consumeText(this._advance());
  8724. this._advanceIf(TokenType$1.CDATA_END);
  8725. };
  8726. /**
  8727. * @param {?} token
  8728. * @return {?}
  8729. */
  8730. _TreeBuilder.prototype._consumeComment = /**
  8731. * @param {?} token
  8732. * @return {?}
  8733. */
  8734. function (token) {
  8735. var /** @type {?} */ text = this._advanceIf(TokenType$1.RAW_TEXT);
  8736. this._advanceIf(TokenType$1.COMMENT_END);
  8737. var /** @type {?} */ value = text != null ? text.parts[0].trim() : null;
  8738. this._addToParent(new Comment(value, token.sourceSpan));
  8739. };
  8740. /**
  8741. * @param {?} token
  8742. * @return {?}
  8743. */
  8744. _TreeBuilder.prototype._consumeExpansion = /**
  8745. * @param {?} token
  8746. * @return {?}
  8747. */
  8748. function (token) {
  8749. var /** @type {?} */ switchValue = this._advance();
  8750. var /** @type {?} */ type = this._advance();
  8751. var /** @type {?} */ cases = [];
  8752. // read =
  8753. while (this._peek.type === TokenType$1.EXPANSION_CASE_VALUE) {
  8754. var /** @type {?} */ expCase = this._parseExpansionCase();
  8755. if (!expCase)
  8756. return; // error
  8757. cases.push(expCase);
  8758. }
  8759. // read the final }
  8760. if (this._peek.type !== TokenType$1.EXPANSION_FORM_END) {
  8761. this._errors.push(TreeError.create(null, this._peek.sourceSpan, "Invalid ICU message. Missing '}'."));
  8762. return;
  8763. }
  8764. var /** @type {?} */ sourceSpan = new ParseSourceSpan(token.sourceSpan.start, this._peek.sourceSpan.end);
  8765. this._addToParent(new Expansion(switchValue.parts[0], type.parts[0], cases, sourceSpan, switchValue.sourceSpan));
  8766. this._advance();
  8767. };
  8768. /**
  8769. * @return {?}
  8770. */
  8771. _TreeBuilder.prototype._parseExpansionCase = /**
  8772. * @return {?}
  8773. */
  8774. function () {
  8775. var /** @type {?} */ value = this._advance();
  8776. // read {
  8777. if (this._peek.type !== TokenType$1.EXPANSION_CASE_EXP_START) {
  8778. this._errors.push(TreeError.create(null, this._peek.sourceSpan, "Invalid ICU message. Missing '{'."));
  8779. return null;
  8780. }
  8781. // read until }
  8782. var /** @type {?} */ start = this._advance();
  8783. var /** @type {?} */ exp = this._collectExpansionExpTokens(start);
  8784. if (!exp)
  8785. return null;
  8786. var /** @type {?} */ end = this._advance();
  8787. exp.push(new Token$1(TokenType$1.EOF, [], end.sourceSpan));
  8788. // parse everything in between { and }
  8789. var /** @type {?} */ parsedExp = new _TreeBuilder(exp, this.getTagDefinition).build();
  8790. if (parsedExp.errors.length > 0) {
  8791. this._errors = this._errors.concat(/** @type {?} */ (parsedExp.errors));
  8792. return null;
  8793. }
  8794. var /** @type {?} */ sourceSpan = new ParseSourceSpan(value.sourceSpan.start, end.sourceSpan.end);
  8795. var /** @type {?} */ expSourceSpan = new ParseSourceSpan(start.sourceSpan.start, end.sourceSpan.end);
  8796. return new ExpansionCase(value.parts[0], parsedExp.rootNodes, sourceSpan, value.sourceSpan, expSourceSpan);
  8797. };
  8798. /**
  8799. * @param {?} start
  8800. * @return {?}
  8801. */
  8802. _TreeBuilder.prototype._collectExpansionExpTokens = /**
  8803. * @param {?} start
  8804. * @return {?}
  8805. */
  8806. function (start) {
  8807. var /** @type {?} */ exp = [];
  8808. var /** @type {?} */ expansionFormStack = [TokenType$1.EXPANSION_CASE_EXP_START];
  8809. while (true) {
  8810. if (this._peek.type === TokenType$1.EXPANSION_FORM_START ||
  8811. this._peek.type === TokenType$1.EXPANSION_CASE_EXP_START) {
  8812. expansionFormStack.push(this._peek.type);
  8813. }
  8814. if (this._peek.type === TokenType$1.EXPANSION_CASE_EXP_END) {
  8815. if (lastOnStack(expansionFormStack, TokenType$1.EXPANSION_CASE_EXP_START)) {
  8816. expansionFormStack.pop();
  8817. if (expansionFormStack.length == 0)
  8818. return exp;
  8819. }
  8820. else {
  8821. this._errors.push(TreeError.create(null, start.sourceSpan, "Invalid ICU message. Missing '}'."));
  8822. return null;
  8823. }
  8824. }
  8825. if (this._peek.type === TokenType$1.EXPANSION_FORM_END) {
  8826. if (lastOnStack(expansionFormStack, TokenType$1.EXPANSION_FORM_START)) {
  8827. expansionFormStack.pop();
  8828. }
  8829. else {
  8830. this._errors.push(TreeError.create(null, start.sourceSpan, "Invalid ICU message. Missing '}'."));
  8831. return null;
  8832. }
  8833. }
  8834. if (this._peek.type === TokenType$1.EOF) {
  8835. this._errors.push(TreeError.create(null, start.sourceSpan, "Invalid ICU message. Missing '}'."));
  8836. return null;
  8837. }
  8838. exp.push(this._advance());
  8839. }
  8840. };
  8841. /**
  8842. * @param {?} token
  8843. * @return {?}
  8844. */
  8845. _TreeBuilder.prototype._consumeText = /**
  8846. * @param {?} token
  8847. * @return {?}
  8848. */
  8849. function (token) {
  8850. var /** @type {?} */ text = token.parts[0];
  8851. if (text.length > 0 && text[0] == '\n') {
  8852. var /** @type {?} */ parent_1 = this._getParentElement();
  8853. if (parent_1 != null && parent_1.children.length == 0 &&
  8854. this.getTagDefinition(parent_1.name).ignoreFirstLf) {
  8855. text = text.substring(1);
  8856. }
  8857. }
  8858. if (text.length > 0) {
  8859. this._addToParent(new Text(text, token.sourceSpan));
  8860. }
  8861. };
  8862. /**
  8863. * @return {?}
  8864. */
  8865. _TreeBuilder.prototype._closeVoidElement = /**
  8866. * @return {?}
  8867. */
  8868. function () {
  8869. var /** @type {?} */ el = this._getParentElement();
  8870. if (el && this.getTagDefinition(el.name).isVoid) {
  8871. this._elementStack.pop();
  8872. }
  8873. };
  8874. /**
  8875. * @param {?} startTagToken
  8876. * @return {?}
  8877. */
  8878. _TreeBuilder.prototype._consumeStartTag = /**
  8879. * @param {?} startTagToken
  8880. * @return {?}
  8881. */
  8882. function (startTagToken) {
  8883. var /** @type {?} */ prefix = startTagToken.parts[0];
  8884. var /** @type {?} */ name = startTagToken.parts[1];
  8885. var /** @type {?} */ attrs = [];
  8886. while (this._peek.type === TokenType$1.ATTR_NAME) {
  8887. attrs.push(this._consumeAttr(this._advance()));
  8888. }
  8889. var /** @type {?} */ fullName = this._getElementFullName(prefix, name, this._getParentElement());
  8890. var /** @type {?} */ selfClosing = false;
  8891. // Note: There could have been a tokenizer error
  8892. // so that we don't get a token for the end tag...
  8893. if (this._peek.type === TokenType$1.TAG_OPEN_END_VOID) {
  8894. this._advance();
  8895. selfClosing = true;
  8896. var /** @type {?} */ tagDef = this.getTagDefinition(fullName);
  8897. if (!(tagDef.canSelfClose || getNsPrefix(fullName) !== null || tagDef.isVoid)) {
  8898. this._errors.push(TreeError.create(fullName, startTagToken.sourceSpan, "Only void and foreign elements can be self closed \"" + startTagToken.parts[1] + "\""));
  8899. }
  8900. }
  8901. else if (this._peek.type === TokenType$1.TAG_OPEN_END) {
  8902. this._advance();
  8903. selfClosing = false;
  8904. }
  8905. var /** @type {?} */ end = this._peek.sourceSpan.start;
  8906. var /** @type {?} */ span = new ParseSourceSpan(startTagToken.sourceSpan.start, end);
  8907. var /** @type {?} */ el = new Element(fullName, attrs, [], span, span, undefined);
  8908. this._pushElement(el);
  8909. if (selfClosing) {
  8910. this._popElement(fullName);
  8911. el.endSourceSpan = span;
  8912. }
  8913. };
  8914. /**
  8915. * @param {?} el
  8916. * @return {?}
  8917. */
  8918. _TreeBuilder.prototype._pushElement = /**
  8919. * @param {?} el
  8920. * @return {?}
  8921. */
  8922. function (el) {
  8923. var /** @type {?} */ parentEl = this._getParentElement();
  8924. if (parentEl && this.getTagDefinition(parentEl.name).isClosedByChild(el.name)) {
  8925. this._elementStack.pop();
  8926. }
  8927. var /** @type {?} */ tagDef = this.getTagDefinition(el.name);
  8928. var _a = this._getParentElementSkippingContainers(), parent = _a.parent, container = _a.container;
  8929. if (parent && tagDef.requireExtraParent(parent.name)) {
  8930. var /** @type {?} */ newParent = new Element(tagDef.parentToAdd, [], [], el.sourceSpan, el.startSourceSpan, el.endSourceSpan);
  8931. this._insertBeforeContainer(parent, container, newParent);
  8932. }
  8933. this._addToParent(el);
  8934. this._elementStack.push(el);
  8935. };
  8936. /**
  8937. * @param {?} endTagToken
  8938. * @return {?}
  8939. */
  8940. _TreeBuilder.prototype._consumeEndTag = /**
  8941. * @param {?} endTagToken
  8942. * @return {?}
  8943. */
  8944. function (endTagToken) {
  8945. var /** @type {?} */ fullName = this._getElementFullName(endTagToken.parts[0], endTagToken.parts[1], this._getParentElement());
  8946. if (this._getParentElement()) {
  8947. /** @type {?} */ ((this._getParentElement())).endSourceSpan = endTagToken.sourceSpan;
  8948. }
  8949. if (this.getTagDefinition(fullName).isVoid) {
  8950. this._errors.push(TreeError.create(fullName, endTagToken.sourceSpan, "Void elements do not have end tags \"" + endTagToken.parts[1] + "\""));
  8951. }
  8952. else if (!this._popElement(fullName)) {
  8953. var /** @type {?} */ errMsg = "Unexpected closing tag \"" + fullName + "\". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags";
  8954. this._errors.push(TreeError.create(fullName, endTagToken.sourceSpan, errMsg));
  8955. }
  8956. };
  8957. /**
  8958. * @param {?} fullName
  8959. * @return {?}
  8960. */
  8961. _TreeBuilder.prototype._popElement = /**
  8962. * @param {?} fullName
  8963. * @return {?}
  8964. */
  8965. function (fullName) {
  8966. for (var /** @type {?} */ stackIndex = this._elementStack.length - 1; stackIndex >= 0; stackIndex--) {
  8967. var /** @type {?} */ el = this._elementStack[stackIndex];
  8968. if (el.name == fullName) {
  8969. this._elementStack.splice(stackIndex, this._elementStack.length - stackIndex);
  8970. return true;
  8971. }
  8972. if (!this.getTagDefinition(el.name).closedByParent) {
  8973. return false;
  8974. }
  8975. }
  8976. return false;
  8977. };
  8978. /**
  8979. * @param {?} attrName
  8980. * @return {?}
  8981. */
  8982. _TreeBuilder.prototype._consumeAttr = /**
  8983. * @param {?} attrName
  8984. * @return {?}
  8985. */
  8986. function (attrName) {
  8987. var /** @type {?} */ fullName = mergeNsAndName(attrName.parts[0], attrName.parts[1]);
  8988. var /** @type {?} */ end = attrName.sourceSpan.end;
  8989. var /** @type {?} */ value = '';
  8990. var /** @type {?} */ valueSpan = /** @type {?} */ ((undefined));
  8991. if (this._peek.type === TokenType$1.ATTR_VALUE) {
  8992. var /** @type {?} */ valueToken = this._advance();
  8993. value = valueToken.parts[0];
  8994. end = valueToken.sourceSpan.end;
  8995. valueSpan = valueToken.sourceSpan;
  8996. }
  8997. return new Attribute$1(fullName, value, new ParseSourceSpan(attrName.sourceSpan.start, end), valueSpan);
  8998. };
  8999. /**
  9000. * @return {?}
  9001. */
  9002. _TreeBuilder.prototype._getParentElement = /**
  9003. * @return {?}
  9004. */
  9005. function () {
  9006. return this._elementStack.length > 0 ? this._elementStack[this._elementStack.length - 1] : null;
  9007. };
  9008. /**
  9009. * Returns the parent in the DOM and the container.
  9010. *
  9011. * `<ng-container>` elements are skipped as they are not rendered as DOM element.
  9012. * @return {?}
  9013. */
  9014. _TreeBuilder.prototype._getParentElementSkippingContainers = /**
  9015. * Returns the parent in the DOM and the container.
  9016. *
  9017. * `<ng-container>` elements are skipped as they are not rendered as DOM element.
  9018. * @return {?}
  9019. */
  9020. function () {
  9021. var /** @type {?} */ container = null;
  9022. for (var /** @type {?} */ i = this._elementStack.length - 1; i >= 0; i--) {
  9023. if (!isNgContainer(this._elementStack[i].name)) {
  9024. return { parent: this._elementStack[i], container: container };
  9025. }
  9026. container = this._elementStack[i];
  9027. }
  9028. return { parent: null, container: container };
  9029. };
  9030. /**
  9031. * @param {?} node
  9032. * @return {?}
  9033. */
  9034. _TreeBuilder.prototype._addToParent = /**
  9035. * @param {?} node
  9036. * @return {?}
  9037. */
  9038. function (node) {
  9039. var /** @type {?} */ parent = this._getParentElement();
  9040. if (parent != null) {
  9041. parent.children.push(node);
  9042. }
  9043. else {
  9044. this._rootNodes.push(node);
  9045. }
  9046. };
  9047. /**
  9048. * Insert a node between the parent and the container.
  9049. * When no container is given, the node is appended as a child of the parent.
  9050. * Also updates the element stack accordingly.
  9051. *
  9052. * \@internal
  9053. * @param {?} parent
  9054. * @param {?} container
  9055. * @param {?} node
  9056. * @return {?}
  9057. */
  9058. _TreeBuilder.prototype._insertBeforeContainer = /**
  9059. * Insert a node between the parent and the container.
  9060. * When no container is given, the node is appended as a child of the parent.
  9061. * Also updates the element stack accordingly.
  9062. *
  9063. * \@internal
  9064. * @param {?} parent
  9065. * @param {?} container
  9066. * @param {?} node
  9067. * @return {?}
  9068. */
  9069. function (parent, container, node) {
  9070. if (!container) {
  9071. this._addToParent(node);
  9072. this._elementStack.push(node);
  9073. }
  9074. else {
  9075. if (parent) {
  9076. // replace the container with the new node in the children
  9077. var /** @type {?} */ index = parent.children.indexOf(container);
  9078. parent.children[index] = node;
  9079. }
  9080. else {
  9081. this._rootNodes.push(node);
  9082. }
  9083. node.children.push(container);
  9084. this._elementStack.splice(this._elementStack.indexOf(container), 0, node);
  9085. }
  9086. };
  9087. /**
  9088. * @param {?} prefix
  9089. * @param {?} localName
  9090. * @param {?} parentElement
  9091. * @return {?}
  9092. */
  9093. _TreeBuilder.prototype._getElementFullName = /**
  9094. * @param {?} prefix
  9095. * @param {?} localName
  9096. * @param {?} parentElement
  9097. * @return {?}
  9098. */
  9099. function (prefix, localName, parentElement) {
  9100. if (prefix == null) {
  9101. prefix = /** @type {?} */ ((this.getTagDefinition(localName).implicitNamespacePrefix));
  9102. if (prefix == null && parentElement != null) {
  9103. prefix = getNsPrefix(parentElement.name);
  9104. }
  9105. }
  9106. return mergeNsAndName(prefix, localName);
  9107. };
  9108. return _TreeBuilder;
  9109. }());
  9110. /**
  9111. * @param {?} stack
  9112. * @param {?} element
  9113. * @return {?}
  9114. */
  9115. function lastOnStack(stack, element) {
  9116. return stack.length > 0 && stack[stack.length - 1] === element;
  9117. }
  9118. /**
  9119. * @fileoverview added by tsickle
  9120. * @suppress {checkTypes} checked by tsc
  9121. */
  9122. /**
  9123. * @license
  9124. * Copyright Google Inc. All Rights Reserved.
  9125. *
  9126. * Use of this source code is governed by an MIT-style license that can be
  9127. * found in the LICENSE file at https://angular.io/license
  9128. */
  9129. /**
  9130. * @param {?} message
  9131. * @return {?}
  9132. */
  9133. function digest(message) {
  9134. return message.id || sha1(serializeNodes(message.nodes).join('') + ("[" + message.meaning + "]"));
  9135. }
  9136. /**
  9137. * @param {?} message
  9138. * @return {?}
  9139. */
  9140. function decimalDigest(message) {
  9141. if (message.id) {
  9142. return message.id;
  9143. }
  9144. var /** @type {?} */ visitor = new _SerializerIgnoreIcuExpVisitor();
  9145. var /** @type {?} */ parts = message.nodes.map(function (a) { return a.visit(visitor, null); });
  9146. return computeMsgId(parts.join(''), message.meaning);
  9147. }
  9148. /**
  9149. * Serialize the i18n ast to something xml-like in order to generate an UID.
  9150. *
  9151. * The visitor is also used in the i18n parser tests
  9152. *
  9153. * \@internal
  9154. */
  9155. var _SerializerVisitor = /** @class */ (function () {
  9156. function _SerializerVisitor() {
  9157. }
  9158. /**
  9159. * @param {?} text
  9160. * @param {?} context
  9161. * @return {?}
  9162. */
  9163. _SerializerVisitor.prototype.visitText = /**
  9164. * @param {?} text
  9165. * @param {?} context
  9166. * @return {?}
  9167. */
  9168. function (text, context) { return text.value; };
  9169. /**
  9170. * @param {?} container
  9171. * @param {?} context
  9172. * @return {?}
  9173. */
  9174. _SerializerVisitor.prototype.visitContainer = /**
  9175. * @param {?} container
  9176. * @param {?} context
  9177. * @return {?}
  9178. */
  9179. function (container, context) {
  9180. var _this = this;
  9181. return "[" + container.children.map(function (child) { return child.visit(_this); }).join(', ') + "]";
  9182. };
  9183. /**
  9184. * @param {?} icu
  9185. * @param {?} context
  9186. * @return {?}
  9187. */
  9188. _SerializerVisitor.prototype.visitIcu = /**
  9189. * @param {?} icu
  9190. * @param {?} context
  9191. * @return {?}
  9192. */
  9193. function (icu, context) {
  9194. var _this = this;
  9195. var /** @type {?} */ strCases = Object.keys(icu.cases).map(function (k) { return k + " {" + icu.cases[k].visit(_this) + "}"; });
  9196. return "{" + icu.expression + ", " + icu.type + ", " + strCases.join(', ') + "}";
  9197. };
  9198. /**
  9199. * @param {?} ph
  9200. * @param {?} context
  9201. * @return {?}
  9202. */
  9203. _SerializerVisitor.prototype.visitTagPlaceholder = /**
  9204. * @param {?} ph
  9205. * @param {?} context
  9206. * @return {?}
  9207. */
  9208. function (ph, context) {
  9209. var _this = this;
  9210. return ph.isVoid ?
  9211. "<ph tag name=\"" + ph.startName + "\"/>" :
  9212. "<ph tag name=\"" + ph.startName + "\">" + ph.children.map(function (child) { return child.visit(_this); }).join(', ') + "</ph name=\"" + ph.closeName + "\">";
  9213. };
  9214. /**
  9215. * @param {?} ph
  9216. * @param {?} context
  9217. * @return {?}
  9218. */
  9219. _SerializerVisitor.prototype.visitPlaceholder = /**
  9220. * @param {?} ph
  9221. * @param {?} context
  9222. * @return {?}
  9223. */
  9224. function (ph, context) {
  9225. return ph.value ? "<ph name=\"" + ph.name + "\">" + ph.value + "</ph>" : "<ph name=\"" + ph.name + "\"/>";
  9226. };
  9227. /**
  9228. * @param {?} ph
  9229. * @param {?=} context
  9230. * @return {?}
  9231. */
  9232. _SerializerVisitor.prototype.visitIcuPlaceholder = /**
  9233. * @param {?} ph
  9234. * @param {?=} context
  9235. * @return {?}
  9236. */
  9237. function (ph, context) {
  9238. return "<ph icu name=\"" + ph.name + "\">" + ph.value.visit(this) + "</ph>";
  9239. };
  9240. return _SerializerVisitor;
  9241. }());
  9242. var serializerVisitor = new _SerializerVisitor();
  9243. /**
  9244. * @param {?} nodes
  9245. * @return {?}
  9246. */
  9247. function serializeNodes(nodes) {
  9248. return nodes.map(function (a) { return a.visit(serializerVisitor, null); });
  9249. }
  9250. /**
  9251. * Serialize the i18n ast to something xml-like in order to generate an UID.
  9252. *
  9253. * Ignore the ICU expressions so that message IDs stays identical if only the expression changes.
  9254. *
  9255. * \@internal
  9256. */
  9257. var _SerializerIgnoreIcuExpVisitor = /** @class */ (function (_super) {
  9258. __extends(_SerializerIgnoreIcuExpVisitor, _super);
  9259. function _SerializerIgnoreIcuExpVisitor() {
  9260. return _super !== null && _super.apply(this, arguments) || this;
  9261. }
  9262. /**
  9263. * @param {?} icu
  9264. * @param {?} context
  9265. * @return {?}
  9266. */
  9267. _SerializerIgnoreIcuExpVisitor.prototype.visitIcu = /**
  9268. * @param {?} icu
  9269. * @param {?} context
  9270. * @return {?}
  9271. */
  9272. function (icu, context) {
  9273. var _this = this;
  9274. var /** @type {?} */ strCases = Object.keys(icu.cases).map(function (k) { return k + " {" + icu.cases[k].visit(_this) + "}"; });
  9275. // Do not take the expression into account
  9276. return "{" + icu.type + ", " + strCases.join(', ') + "}";
  9277. };
  9278. return _SerializerIgnoreIcuExpVisitor;
  9279. }(_SerializerVisitor));
  9280. /**
  9281. * Compute the SHA1 of the given string
  9282. *
  9283. * see http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf
  9284. *
  9285. * WARNING: this function has not been designed not tested with security in mind.
  9286. * DO NOT USE IT IN A SECURITY SENSITIVE CONTEXT.
  9287. * @param {?} str
  9288. * @return {?}
  9289. */
  9290. function sha1(str) {
  9291. var /** @type {?} */ utf8 = utf8Encode(str);
  9292. var /** @type {?} */ words32 = stringToWords32(utf8, Endian.Big);
  9293. var /** @type {?} */ len = utf8.length * 8;
  9294. var /** @type {?} */ w = new Array(80);
  9295. var _a = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0], a = _a[0], b = _a[1], c = _a[2], d = _a[3], e = _a[4];
  9296. words32[len >> 5] |= 0x80 << (24 - len % 32);
  9297. words32[((len + 64 >> 9) << 4) + 15] = len;
  9298. for (var /** @type {?} */ i = 0; i < words32.length; i += 16) {
  9299. var _b = [a, b, c, d, e], h0 = _b[0], h1 = _b[1], h2 = _b[2], h3 = _b[3], h4 = _b[4];
  9300. for (var /** @type {?} */ j = 0; j < 80; j++) {
  9301. if (j < 16) {
  9302. w[j] = words32[i + j];
  9303. }
  9304. else {
  9305. w[j] = rol32(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
  9306. }
  9307. var _c = fk(j, b, c, d), f = _c[0], k = _c[1];
  9308. var /** @type {?} */ temp = [rol32(a, 5), f, e, k, w[j]].reduce(add32);
  9309. _d = [d, c, rol32(b, 30), a, temp], e = _d[0], d = _d[1], c = _d[2], b = _d[3], a = _d[4];
  9310. }
  9311. _e = [add32(a, h0), add32(b, h1), add32(c, h2), add32(d, h3), add32(e, h4)], a = _e[0], b = _e[1], c = _e[2], d = _e[3], e = _e[4];
  9312. }
  9313. return byteStringToHexString(words32ToByteString([a, b, c, d, e]));
  9314. var _d, _e;
  9315. }
  9316. /**
  9317. * @param {?} index
  9318. * @param {?} b
  9319. * @param {?} c
  9320. * @param {?} d
  9321. * @return {?}
  9322. */
  9323. function fk(index, b, c, d) {
  9324. if (index < 20) {
  9325. return [(b & c) | (~b & d), 0x5a827999];
  9326. }
  9327. if (index < 40) {
  9328. return [b ^ c ^ d, 0x6ed9eba1];
  9329. }
  9330. if (index < 60) {
  9331. return [(b & c) | (b & d) | (c & d), 0x8f1bbcdc];
  9332. }
  9333. return [b ^ c ^ d, 0xca62c1d6];
  9334. }
  9335. /**
  9336. * Compute the fingerprint of the given string
  9337. *
  9338. * The output is 64 bit number encoded as a decimal string
  9339. *
  9340. * based on:
  9341. * https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/GoogleJsMessageIdGenerator.java
  9342. * @param {?} str
  9343. * @return {?}
  9344. */
  9345. function fingerprint(str) {
  9346. var /** @type {?} */ utf8 = utf8Encode(str);
  9347. var _a = [hash32(utf8, 0), hash32(utf8, 102072)], hi = _a[0], lo = _a[1];
  9348. if (hi == 0 && (lo == 0 || lo == 1)) {
  9349. hi = hi ^ 0x130f9bef;
  9350. lo = lo ^ -0x6b5f56d8;
  9351. }
  9352. return [hi, lo];
  9353. }
  9354. /**
  9355. * @param {?} msg
  9356. * @param {?} meaning
  9357. * @return {?}
  9358. */
  9359. function computeMsgId(msg, meaning) {
  9360. var _a = fingerprint(msg), hi = _a[0], lo = _a[1];
  9361. if (meaning) {
  9362. var _b = fingerprint(meaning), him = _b[0], lom = _b[1];
  9363. _c = add64(rol64([hi, lo], 1), [him, lom]), hi = _c[0], lo = _c[1];
  9364. }
  9365. return byteStringToDecString(words32ToByteString([hi & 0x7fffffff, lo]));
  9366. var _c;
  9367. }
  9368. /**
  9369. * @param {?} str
  9370. * @param {?} c
  9371. * @return {?}
  9372. */
  9373. function hash32(str, c) {
  9374. var _a = [0x9e3779b9, 0x9e3779b9], a = _a[0], b = _a[1];
  9375. var /** @type {?} */ i;
  9376. var /** @type {?} */ len = str.length;
  9377. for (i = 0; i + 12 <= len; i += 12) {
  9378. a = add32(a, wordAt(str, i, Endian.Little));
  9379. b = add32(b, wordAt(str, i + 4, Endian.Little));
  9380. c = add32(c, wordAt(str, i + 8, Endian.Little));
  9381. _b = mix([a, b, c]), a = _b[0], b = _b[1], c = _b[2];
  9382. }
  9383. a = add32(a, wordAt(str, i, Endian.Little));
  9384. b = add32(b, wordAt(str, i + 4, Endian.Little));
  9385. // the first byte of c is reserved for the length
  9386. c = add32(c, len);
  9387. c = add32(c, wordAt(str, i + 8, Endian.Little) << 8);
  9388. return mix([a, b, c])[2];
  9389. var _b;
  9390. }
  9391. /**
  9392. * @param {?} __0
  9393. * @return {?}
  9394. */
  9395. function mix(_a) {
  9396. var a = _a[0], b = _a[1], c = _a[2];
  9397. a = sub32(a, b);
  9398. a = sub32(a, c);
  9399. a ^= c >>> 13;
  9400. b = sub32(b, c);
  9401. b = sub32(b, a);
  9402. b ^= a << 8;
  9403. c = sub32(c, a);
  9404. c = sub32(c, b);
  9405. c ^= b >>> 13;
  9406. a = sub32(a, b);
  9407. a = sub32(a, c);
  9408. a ^= c >>> 12;
  9409. b = sub32(b, c);
  9410. b = sub32(b, a);
  9411. b ^= a << 16;
  9412. c = sub32(c, a);
  9413. c = sub32(c, b);
  9414. c ^= b >>> 5;
  9415. a = sub32(a, b);
  9416. a = sub32(a, c);
  9417. a ^= c >>> 3;
  9418. b = sub32(b, c);
  9419. b = sub32(b, a);
  9420. b ^= a << 10;
  9421. c = sub32(c, a);
  9422. c = sub32(c, b);
  9423. c ^= b >>> 15;
  9424. return [a, b, c];
  9425. }
  9426. /** @enum {number} */
  9427. var Endian = {
  9428. Little: 0,
  9429. Big: 1,
  9430. };
  9431. Endian[Endian.Little] = "Little";
  9432. Endian[Endian.Big] = "Big";
  9433. /**
  9434. * @param {?} a
  9435. * @param {?} b
  9436. * @return {?}
  9437. */
  9438. function add32(a, b) {
  9439. return add32to64(a, b)[1];
  9440. }
  9441. /**
  9442. * @param {?} a
  9443. * @param {?} b
  9444. * @return {?}
  9445. */
  9446. function add32to64(a, b) {
  9447. var /** @type {?} */ low = (a & 0xffff) + (b & 0xffff);
  9448. var /** @type {?} */ high = (a >>> 16) + (b >>> 16) + (low >>> 16);
  9449. return [high >>> 16, (high << 16) | (low & 0xffff)];
  9450. }
  9451. /**
  9452. * @param {?} __0
  9453. * @param {?} __1
  9454. * @return {?}
  9455. */
  9456. function add64(_a, _b) {
  9457. var ah = _a[0], al = _a[1];
  9458. var bh = _b[0], bl = _b[1];
  9459. var _c = add32to64(al, bl), carry = _c[0], l = _c[1];
  9460. var /** @type {?} */ h = add32(add32(ah, bh), carry);
  9461. return [h, l];
  9462. }
  9463. /**
  9464. * @param {?} a
  9465. * @param {?} b
  9466. * @return {?}
  9467. */
  9468. function sub32(a, b) {
  9469. var /** @type {?} */ low = (a & 0xffff) - (b & 0xffff);
  9470. var /** @type {?} */ high = (a >> 16) - (b >> 16) + (low >> 16);
  9471. return (high << 16) | (low & 0xffff);
  9472. }
  9473. /**
  9474. * @param {?} a
  9475. * @param {?} count
  9476. * @return {?}
  9477. */
  9478. function rol32(a, count) {
  9479. return (a << count) | (a >>> (32 - count));
  9480. }
  9481. /**
  9482. * @param {?} __0
  9483. * @param {?} count
  9484. * @return {?}
  9485. */
  9486. function rol64(_a, count) {
  9487. var hi = _a[0], lo = _a[1];
  9488. var /** @type {?} */ h = (hi << count) | (lo >>> (32 - count));
  9489. var /** @type {?} */ l = (lo << count) | (hi >>> (32 - count));
  9490. return [h, l];
  9491. }
  9492. /**
  9493. * @param {?} str
  9494. * @param {?} endian
  9495. * @return {?}
  9496. */
  9497. function stringToWords32(str, endian) {
  9498. var /** @type {?} */ words32 = Array((str.length + 3) >>> 2);
  9499. for (var /** @type {?} */ i = 0; i < words32.length; i++) {
  9500. words32[i] = wordAt(str, i * 4, endian);
  9501. }
  9502. return words32;
  9503. }
  9504. /**
  9505. * @param {?} str
  9506. * @param {?} index
  9507. * @return {?}
  9508. */
  9509. function byteAt(str, index) {
  9510. return index >= str.length ? 0 : str.charCodeAt(index) & 0xff;
  9511. }
  9512. /**
  9513. * @param {?} str
  9514. * @param {?} index
  9515. * @param {?} endian
  9516. * @return {?}
  9517. */
  9518. function wordAt(str, index, endian) {
  9519. var /** @type {?} */ word = 0;
  9520. if (endian === Endian.Big) {
  9521. for (var /** @type {?} */ i = 0; i < 4; i++) {
  9522. word += byteAt(str, index + i) << (24 - 8 * i);
  9523. }
  9524. }
  9525. else {
  9526. for (var /** @type {?} */ i = 0; i < 4; i++) {
  9527. word += byteAt(str, index + i) << 8 * i;
  9528. }
  9529. }
  9530. return word;
  9531. }
  9532. /**
  9533. * @param {?} words32
  9534. * @return {?}
  9535. */
  9536. function words32ToByteString(words32) {
  9537. return words32.reduce(function (str, word) { return str + word32ToByteString(word); }, '');
  9538. }
  9539. /**
  9540. * @param {?} word
  9541. * @return {?}
  9542. */
  9543. function word32ToByteString(word) {
  9544. var /** @type {?} */ str = '';
  9545. for (var /** @type {?} */ i = 0; i < 4; i++) {
  9546. str += String.fromCharCode((word >>> 8 * (3 - i)) & 0xff);
  9547. }
  9548. return str;
  9549. }
  9550. /**
  9551. * @param {?} str
  9552. * @return {?}
  9553. */
  9554. function byteStringToHexString(str) {
  9555. var /** @type {?} */ hex = '';
  9556. for (var /** @type {?} */ i = 0; i < str.length; i++) {
  9557. var /** @type {?} */ b = byteAt(str, i);
  9558. hex += (b >>> 4).toString(16) + (b & 0x0f).toString(16);
  9559. }
  9560. return hex.toLowerCase();
  9561. }
  9562. /**
  9563. * @param {?} str
  9564. * @return {?}
  9565. */
  9566. function byteStringToDecString(str) {
  9567. var /** @type {?} */ decimal = '';
  9568. var /** @type {?} */ toThePower = '1';
  9569. for (var /** @type {?} */ i = str.length - 1; i >= 0; i--) {
  9570. decimal = addBigInt(decimal, numberTimesBigInt(byteAt(str, i), toThePower));
  9571. toThePower = numberTimesBigInt(256, toThePower);
  9572. }
  9573. return decimal.split('').reverse().join('');
  9574. }
  9575. /**
  9576. * @param {?} x
  9577. * @param {?} y
  9578. * @return {?}
  9579. */
  9580. function addBigInt(x, y) {
  9581. var /** @type {?} */ sum = '';
  9582. var /** @type {?} */ len = Math.max(x.length, y.length);
  9583. for (var /** @type {?} */ i = 0, /** @type {?} */ carry = 0; i < len || carry; i++) {
  9584. var /** @type {?} */ tmpSum = carry + +(x[i] || 0) + +(y[i] || 0);
  9585. if (tmpSum >= 10) {
  9586. carry = 1;
  9587. sum += tmpSum - 10;
  9588. }
  9589. else {
  9590. carry = 0;
  9591. sum += tmpSum;
  9592. }
  9593. }
  9594. return sum;
  9595. }
  9596. /**
  9597. * @param {?} num
  9598. * @param {?} b
  9599. * @return {?}
  9600. */
  9601. function numberTimesBigInt(num, b) {
  9602. var /** @type {?} */ product = '';
  9603. var /** @type {?} */ bToThePower = b;
  9604. for (; num !== 0; num = num >>> 1) {
  9605. if (num & 1)
  9606. product = addBigInt(product, bToThePower);
  9607. bToThePower = addBigInt(bToThePower, bToThePower);
  9608. }
  9609. return product;
  9610. }
  9611. /**
  9612. * @fileoverview added by tsickle
  9613. * @suppress {checkTypes} checked by tsc
  9614. */
  9615. /**
  9616. * @license
  9617. * Copyright Google Inc. All Rights Reserved.
  9618. *
  9619. * Use of this source code is governed by an MIT-style license that can be
  9620. * found in the LICENSE file at https://angular.io/license
  9621. */
  9622. var Message = /** @class */ (function () {
  9623. /**
  9624. * @param nodes message AST
  9625. * @param placeholders maps placeholder names to static content
  9626. * @param placeholderToMessage maps placeholder names to messages (used for nested ICU messages)
  9627. * @param meaning
  9628. * @param description
  9629. * @param id
  9630. */
  9631. function Message(nodes, placeholders, placeholderToMessage, meaning, description, id) {
  9632. this.nodes = nodes;
  9633. this.placeholders = placeholders;
  9634. this.placeholderToMessage = placeholderToMessage;
  9635. this.meaning = meaning;
  9636. this.description = description;
  9637. this.id = id;
  9638. if (nodes.length) {
  9639. this.sources = [{
  9640. filePath: nodes[0].sourceSpan.start.file.url,
  9641. startLine: nodes[0].sourceSpan.start.line + 1,
  9642. startCol: nodes[0].sourceSpan.start.col + 1,
  9643. endLine: nodes[nodes.length - 1].sourceSpan.end.line + 1,
  9644. endCol: nodes[0].sourceSpan.start.col + 1
  9645. }];
  9646. }
  9647. else {
  9648. this.sources = [];
  9649. }
  9650. }
  9651. return Message;
  9652. }());
  9653. /**
  9654. * @record
  9655. */
  9656. /**
  9657. * @record
  9658. */
  9659. var Text$1 = /** @class */ (function () {
  9660. function Text(value, sourceSpan) {
  9661. this.value = value;
  9662. this.sourceSpan = sourceSpan;
  9663. }
  9664. /**
  9665. * @param {?} visitor
  9666. * @param {?=} context
  9667. * @return {?}
  9668. */
  9669. Text.prototype.visit = /**
  9670. * @param {?} visitor
  9671. * @param {?=} context
  9672. * @return {?}
  9673. */
  9674. function (visitor, context) { return visitor.visitText(this, context); };
  9675. return Text;
  9676. }());
  9677. var Container = /** @class */ (function () {
  9678. function Container(children, sourceSpan) {
  9679. this.children = children;
  9680. this.sourceSpan = sourceSpan;
  9681. }
  9682. /**
  9683. * @param {?} visitor
  9684. * @param {?=} context
  9685. * @return {?}
  9686. */
  9687. Container.prototype.visit = /**
  9688. * @param {?} visitor
  9689. * @param {?=} context
  9690. * @return {?}
  9691. */
  9692. function (visitor, context) { return visitor.visitContainer(this, context); };
  9693. return Container;
  9694. }());
  9695. var Icu = /** @class */ (function () {
  9696. function Icu(expression, type, cases, sourceSpan) {
  9697. this.expression = expression;
  9698. this.type = type;
  9699. this.cases = cases;
  9700. this.sourceSpan = sourceSpan;
  9701. }
  9702. /**
  9703. * @param {?} visitor
  9704. * @param {?=} context
  9705. * @return {?}
  9706. */
  9707. Icu.prototype.visit = /**
  9708. * @param {?} visitor
  9709. * @param {?=} context
  9710. * @return {?}
  9711. */
  9712. function (visitor, context) { return visitor.visitIcu(this, context); };
  9713. return Icu;
  9714. }());
  9715. var TagPlaceholder = /** @class */ (function () {
  9716. function TagPlaceholder(tag, attrs, startName, closeName, children, isVoid, sourceSpan) {
  9717. this.tag = tag;
  9718. this.attrs = attrs;
  9719. this.startName = startName;
  9720. this.closeName = closeName;
  9721. this.children = children;
  9722. this.isVoid = isVoid;
  9723. this.sourceSpan = sourceSpan;
  9724. }
  9725. /**
  9726. * @param {?} visitor
  9727. * @param {?=} context
  9728. * @return {?}
  9729. */
  9730. TagPlaceholder.prototype.visit = /**
  9731. * @param {?} visitor
  9732. * @param {?=} context
  9733. * @return {?}
  9734. */
  9735. function (visitor, context) { return visitor.visitTagPlaceholder(this, context); };
  9736. return TagPlaceholder;
  9737. }());
  9738. var Placeholder = /** @class */ (function () {
  9739. function Placeholder(value, name, sourceSpan) {
  9740. this.value = value;
  9741. this.name = name;
  9742. this.sourceSpan = sourceSpan;
  9743. }
  9744. /**
  9745. * @param {?} visitor
  9746. * @param {?=} context
  9747. * @return {?}
  9748. */
  9749. Placeholder.prototype.visit = /**
  9750. * @param {?} visitor
  9751. * @param {?=} context
  9752. * @return {?}
  9753. */
  9754. function (visitor, context) { return visitor.visitPlaceholder(this, context); };
  9755. return Placeholder;
  9756. }());
  9757. var IcuPlaceholder = /** @class */ (function () {
  9758. function IcuPlaceholder(value, name, sourceSpan) {
  9759. this.value = value;
  9760. this.name = name;
  9761. this.sourceSpan = sourceSpan;
  9762. }
  9763. /**
  9764. * @param {?} visitor
  9765. * @param {?=} context
  9766. * @return {?}
  9767. */
  9768. IcuPlaceholder.prototype.visit = /**
  9769. * @param {?} visitor
  9770. * @param {?=} context
  9771. * @return {?}
  9772. */
  9773. function (visitor, context) { return visitor.visitIcuPlaceholder(this, context); };
  9774. return IcuPlaceholder;
  9775. }());
  9776. /**
  9777. * @record
  9778. */
  9779. var CloneVisitor = /** @class */ (function () {
  9780. function CloneVisitor() {
  9781. }
  9782. /**
  9783. * @param {?} text
  9784. * @param {?=} context
  9785. * @return {?}
  9786. */
  9787. CloneVisitor.prototype.visitText = /**
  9788. * @param {?} text
  9789. * @param {?=} context
  9790. * @return {?}
  9791. */
  9792. function (text, context) { return new Text$1(text.value, text.sourceSpan); };
  9793. /**
  9794. * @param {?} container
  9795. * @param {?=} context
  9796. * @return {?}
  9797. */
  9798. CloneVisitor.prototype.visitContainer = /**
  9799. * @param {?} container
  9800. * @param {?=} context
  9801. * @return {?}
  9802. */
  9803. function (container, context) {
  9804. var _this = this;
  9805. var /** @type {?} */ children = container.children.map(function (n) { return n.visit(_this, context); });
  9806. return new Container(children, container.sourceSpan);
  9807. };
  9808. /**
  9809. * @param {?} icu
  9810. * @param {?=} context
  9811. * @return {?}
  9812. */
  9813. CloneVisitor.prototype.visitIcu = /**
  9814. * @param {?} icu
  9815. * @param {?=} context
  9816. * @return {?}
  9817. */
  9818. function (icu, context) {
  9819. var _this = this;
  9820. var /** @type {?} */ cases = {};
  9821. Object.keys(icu.cases).forEach(function (key) { return cases[key] = icu.cases[key].visit(_this, context); });
  9822. var /** @type {?} */ msg = new Icu(icu.expression, icu.type, cases, icu.sourceSpan);
  9823. msg.expressionPlaceholder = icu.expressionPlaceholder;
  9824. return msg;
  9825. };
  9826. /**
  9827. * @param {?} ph
  9828. * @param {?=} context
  9829. * @return {?}
  9830. */
  9831. CloneVisitor.prototype.visitTagPlaceholder = /**
  9832. * @param {?} ph
  9833. * @param {?=} context
  9834. * @return {?}
  9835. */
  9836. function (ph, context) {
  9837. var _this = this;
  9838. var /** @type {?} */ children = ph.children.map(function (n) { return n.visit(_this, context); });
  9839. return new TagPlaceholder(ph.tag, ph.attrs, ph.startName, ph.closeName, children, ph.isVoid, ph.sourceSpan);
  9840. };
  9841. /**
  9842. * @param {?} ph
  9843. * @param {?=} context
  9844. * @return {?}
  9845. */
  9846. CloneVisitor.prototype.visitPlaceholder = /**
  9847. * @param {?} ph
  9848. * @param {?=} context
  9849. * @return {?}
  9850. */
  9851. function (ph, context) {
  9852. return new Placeholder(ph.value, ph.name, ph.sourceSpan);
  9853. };
  9854. /**
  9855. * @param {?} ph
  9856. * @param {?=} context
  9857. * @return {?}
  9858. */
  9859. CloneVisitor.prototype.visitIcuPlaceholder = /**
  9860. * @param {?} ph
  9861. * @param {?=} context
  9862. * @return {?}
  9863. */
  9864. function (ph, context) {
  9865. return new IcuPlaceholder(ph.value, ph.name, ph.sourceSpan);
  9866. };
  9867. return CloneVisitor;
  9868. }());
  9869. var RecurseVisitor = /** @class */ (function () {
  9870. function RecurseVisitor() {
  9871. }
  9872. /**
  9873. * @param {?} text
  9874. * @param {?=} context
  9875. * @return {?}
  9876. */
  9877. RecurseVisitor.prototype.visitText = /**
  9878. * @param {?} text
  9879. * @param {?=} context
  9880. * @return {?}
  9881. */
  9882. function (text, context) { };
  9883. /**
  9884. * @param {?} container
  9885. * @param {?=} context
  9886. * @return {?}
  9887. */
  9888. RecurseVisitor.prototype.visitContainer = /**
  9889. * @param {?} container
  9890. * @param {?=} context
  9891. * @return {?}
  9892. */
  9893. function (container, context) {
  9894. var _this = this;
  9895. container.children.forEach(function (child) { return child.visit(_this); });
  9896. };
  9897. /**
  9898. * @param {?} icu
  9899. * @param {?=} context
  9900. * @return {?}
  9901. */
  9902. RecurseVisitor.prototype.visitIcu = /**
  9903. * @param {?} icu
  9904. * @param {?=} context
  9905. * @return {?}
  9906. */
  9907. function (icu, context) {
  9908. var _this = this;
  9909. Object.keys(icu.cases).forEach(function (k) { icu.cases[k].visit(_this); });
  9910. };
  9911. /**
  9912. * @param {?} ph
  9913. * @param {?=} context
  9914. * @return {?}
  9915. */
  9916. RecurseVisitor.prototype.visitTagPlaceholder = /**
  9917. * @param {?} ph
  9918. * @param {?=} context
  9919. * @return {?}
  9920. */
  9921. function (ph, context) {
  9922. var _this = this;
  9923. ph.children.forEach(function (child) { return child.visit(_this); });
  9924. };
  9925. /**
  9926. * @param {?} ph
  9927. * @param {?=} context
  9928. * @return {?}
  9929. */
  9930. RecurseVisitor.prototype.visitPlaceholder = /**
  9931. * @param {?} ph
  9932. * @param {?=} context
  9933. * @return {?}
  9934. */
  9935. function (ph, context) { };
  9936. /**
  9937. * @param {?} ph
  9938. * @param {?=} context
  9939. * @return {?}
  9940. */
  9941. RecurseVisitor.prototype.visitIcuPlaceholder = /**
  9942. * @param {?} ph
  9943. * @param {?=} context
  9944. * @return {?}
  9945. */
  9946. function (ph, context) { };
  9947. return RecurseVisitor;
  9948. }());
  9949. /**
  9950. * @fileoverview added by tsickle
  9951. * @suppress {checkTypes} checked by tsc
  9952. */
  9953. /**
  9954. * @license
  9955. * Copyright Google Inc. All Rights Reserved.
  9956. *
  9957. * Use of this source code is governed by an MIT-style license that can be
  9958. * found in the LICENSE file at https://angular.io/license
  9959. */
  9960. var HtmlTagDefinition = /** @class */ (function () {
  9961. function HtmlTagDefinition(_a) {
  9962. var _b = _a === void 0 ? {} : _a, closedByChildren = _b.closedByChildren, requiredParents = _b.requiredParents, implicitNamespacePrefix = _b.implicitNamespacePrefix, _c = _b.contentType, contentType = _c === void 0 ? TagContentType.PARSABLE_DATA : _c, _d = _b.closedByParent, closedByParent = _d === void 0 ? false : _d, _e = _b.isVoid, isVoid = _e === void 0 ? false : _e, _f = _b.ignoreFirstLf, ignoreFirstLf = _f === void 0 ? false : _f;
  9963. var _this = this;
  9964. this.closedByChildren = {};
  9965. this.closedByParent = false;
  9966. this.canSelfClose = false;
  9967. if (closedByChildren && closedByChildren.length > 0) {
  9968. closedByChildren.forEach(function (tagName) { return _this.closedByChildren[tagName] = true; });
  9969. }
  9970. this.isVoid = isVoid;
  9971. this.closedByParent = closedByParent || isVoid;
  9972. if (requiredParents && requiredParents.length > 0) {
  9973. this.requiredParents = {};
  9974. // The first parent is the list is automatically when none of the listed parents are present
  9975. this.parentToAdd = requiredParents[0];
  9976. requiredParents.forEach(function (tagName) { return _this.requiredParents[tagName] = true; });
  9977. }
  9978. this.implicitNamespacePrefix = implicitNamespacePrefix || null;
  9979. this.contentType = contentType;
  9980. this.ignoreFirstLf = ignoreFirstLf;
  9981. }
  9982. /**
  9983. * @param {?} currentParent
  9984. * @return {?}
  9985. */
  9986. HtmlTagDefinition.prototype.requireExtraParent = /**
  9987. * @param {?} currentParent
  9988. * @return {?}
  9989. */
  9990. function (currentParent) {
  9991. if (!this.requiredParents) {
  9992. return false;
  9993. }
  9994. if (!currentParent) {
  9995. return true;
  9996. }
  9997. var /** @type {?} */ lcParent = currentParent.toLowerCase();
  9998. var /** @type {?} */ isParentTemplate = lcParent === 'template' || currentParent === 'ng-template';
  9999. return !isParentTemplate && this.requiredParents[lcParent] != true;
  10000. };
  10001. /**
  10002. * @param {?} name
  10003. * @return {?}
  10004. */
  10005. HtmlTagDefinition.prototype.isClosedByChild = /**
  10006. * @param {?} name
  10007. * @return {?}
  10008. */
  10009. function (name) {
  10010. return this.isVoid || name.toLowerCase() in this.closedByChildren;
  10011. };
  10012. return HtmlTagDefinition;
  10013. }());
  10014. // see http://www.w3.org/TR/html51/syntax.html#optional-tags
  10015. // This implementation does not fully conform to the HTML5 spec.
  10016. var TAG_DEFINITIONS = {
  10017. 'base': new HtmlTagDefinition({ isVoid: true }),
  10018. 'meta': new HtmlTagDefinition({ isVoid: true }),
  10019. 'area': new HtmlTagDefinition({ isVoid: true }),
  10020. 'embed': new HtmlTagDefinition({ isVoid: true }),
  10021. 'link': new HtmlTagDefinition({ isVoid: true }),
  10022. 'img': new HtmlTagDefinition({ isVoid: true }),
  10023. 'input': new HtmlTagDefinition({ isVoid: true }),
  10024. 'param': new HtmlTagDefinition({ isVoid: true }),
  10025. 'hr': new HtmlTagDefinition({ isVoid: true }),
  10026. 'br': new HtmlTagDefinition({ isVoid: true }),
  10027. 'source': new HtmlTagDefinition({ isVoid: true }),
  10028. 'track': new HtmlTagDefinition({ isVoid: true }),
  10029. 'wbr': new HtmlTagDefinition({ isVoid: true }),
  10030. 'p': new HtmlTagDefinition({
  10031. closedByChildren: [
  10032. 'address', 'article', 'aside', 'blockquote', 'div', 'dl', 'fieldset', 'footer', 'form',
  10033. 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup', 'hr',
  10034. 'main', 'nav', 'ol', 'p', 'pre', 'section', 'table', 'ul'
  10035. ],
  10036. closedByParent: true
  10037. }),
  10038. 'thead': new HtmlTagDefinition({ closedByChildren: ['tbody', 'tfoot'] }),
  10039. 'tbody': new HtmlTagDefinition({ closedByChildren: ['tbody', 'tfoot'], closedByParent: true }),
  10040. 'tfoot': new HtmlTagDefinition({ closedByChildren: ['tbody'], closedByParent: true }),
  10041. 'tr': new HtmlTagDefinition({
  10042. closedByChildren: ['tr'],
  10043. requiredParents: ['tbody', 'tfoot', 'thead'],
  10044. closedByParent: true
  10045. }),
  10046. 'td': new HtmlTagDefinition({ closedByChildren: ['td', 'th'], closedByParent: true }),
  10047. 'th': new HtmlTagDefinition({ closedByChildren: ['td', 'th'], closedByParent: true }),
  10048. 'col': new HtmlTagDefinition({ requiredParents: ['colgroup'], isVoid: true }),
  10049. 'svg': new HtmlTagDefinition({ implicitNamespacePrefix: 'svg' }),
  10050. 'math': new HtmlTagDefinition({ implicitNamespacePrefix: 'math' }),
  10051. 'li': new HtmlTagDefinition({ closedByChildren: ['li'], closedByParent: true }),
  10052. 'dt': new HtmlTagDefinition({ closedByChildren: ['dt', 'dd'] }),
  10053. 'dd': new HtmlTagDefinition({ closedByChildren: ['dt', 'dd'], closedByParent: true }),
  10054. 'rb': new HtmlTagDefinition({ closedByChildren: ['rb', 'rt', 'rtc', 'rp'], closedByParent: true }),
  10055. 'rt': new HtmlTagDefinition({ closedByChildren: ['rb', 'rt', 'rtc', 'rp'], closedByParent: true }),
  10056. 'rtc': new HtmlTagDefinition({ closedByChildren: ['rb', 'rtc', 'rp'], closedByParent: true }),
  10057. 'rp': new HtmlTagDefinition({ closedByChildren: ['rb', 'rt', 'rtc', 'rp'], closedByParent: true }),
  10058. 'optgroup': new HtmlTagDefinition({ closedByChildren: ['optgroup'], closedByParent: true }),
  10059. 'option': new HtmlTagDefinition({ closedByChildren: ['option', 'optgroup'], closedByParent: true }),
  10060. 'pre': new HtmlTagDefinition({ ignoreFirstLf: true }),
  10061. 'listing': new HtmlTagDefinition({ ignoreFirstLf: true }),
  10062. 'style': new HtmlTagDefinition({ contentType: TagContentType.RAW_TEXT }),
  10063. 'script': new HtmlTagDefinition({ contentType: TagContentType.RAW_TEXT }),
  10064. 'title': new HtmlTagDefinition({ contentType: TagContentType.ESCAPABLE_RAW_TEXT }),
  10065. 'textarea': new HtmlTagDefinition({ contentType: TagContentType.ESCAPABLE_RAW_TEXT, ignoreFirstLf: true }),
  10066. };
  10067. var _DEFAULT_TAG_DEFINITION = new HtmlTagDefinition();
  10068. /**
  10069. * @param {?} tagName
  10070. * @return {?}
  10071. */
  10072. function getHtmlTagDefinition(tagName) {
  10073. return TAG_DEFINITIONS[tagName.toLowerCase()] || _DEFAULT_TAG_DEFINITION;
  10074. }
  10075. /**
  10076. * @fileoverview added by tsickle
  10077. * @suppress {checkTypes} checked by tsc
  10078. */
  10079. /**
  10080. * @license
  10081. * Copyright Google Inc. All Rights Reserved.
  10082. *
  10083. * Use of this source code is governed by an MIT-style license that can be
  10084. * found in the LICENSE file at https://angular.io/license
  10085. */
  10086. var TAG_TO_PLACEHOLDER_NAMES = {
  10087. 'A': 'LINK',
  10088. 'B': 'BOLD_TEXT',
  10089. 'BR': 'LINE_BREAK',
  10090. 'EM': 'EMPHASISED_TEXT',
  10091. 'H1': 'HEADING_LEVEL1',
  10092. 'H2': 'HEADING_LEVEL2',
  10093. 'H3': 'HEADING_LEVEL3',
  10094. 'H4': 'HEADING_LEVEL4',
  10095. 'H5': 'HEADING_LEVEL5',
  10096. 'H6': 'HEADING_LEVEL6',
  10097. 'HR': 'HORIZONTAL_RULE',
  10098. 'I': 'ITALIC_TEXT',
  10099. 'LI': 'LIST_ITEM',
  10100. 'LINK': 'MEDIA_LINK',
  10101. 'OL': 'ORDERED_LIST',
  10102. 'P': 'PARAGRAPH',
  10103. 'Q': 'QUOTATION',
  10104. 'S': 'STRIKETHROUGH_TEXT',
  10105. 'SMALL': 'SMALL_TEXT',
  10106. 'SUB': 'SUBSTRIPT',
  10107. 'SUP': 'SUPERSCRIPT',
  10108. 'TBODY': 'TABLE_BODY',
  10109. 'TD': 'TABLE_CELL',
  10110. 'TFOOT': 'TABLE_FOOTER',
  10111. 'TH': 'TABLE_HEADER_CELL',
  10112. 'THEAD': 'TABLE_HEADER',
  10113. 'TR': 'TABLE_ROW',
  10114. 'TT': 'MONOSPACED_TEXT',
  10115. 'U': 'UNDERLINED_TEXT',
  10116. 'UL': 'UNORDERED_LIST',
  10117. };
  10118. /**
  10119. * Creates unique names for placeholder with different content.
  10120. *
  10121. * Returns the same placeholder name when the content is identical.
  10122. */
  10123. var PlaceholderRegistry = /** @class */ (function () {
  10124. function PlaceholderRegistry() {
  10125. this._placeHolderNameCounts = {};
  10126. this._signatureToName = {};
  10127. }
  10128. /**
  10129. * @param {?} tag
  10130. * @param {?} attrs
  10131. * @param {?} isVoid
  10132. * @return {?}
  10133. */
  10134. PlaceholderRegistry.prototype.getStartTagPlaceholderName = /**
  10135. * @param {?} tag
  10136. * @param {?} attrs
  10137. * @param {?} isVoid
  10138. * @return {?}
  10139. */
  10140. function (tag, attrs, isVoid) {
  10141. var /** @type {?} */ signature = this._hashTag(tag, attrs, isVoid);
  10142. if (this._signatureToName[signature]) {
  10143. return this._signatureToName[signature];
  10144. }
  10145. var /** @type {?} */ upperTag = tag.toUpperCase();
  10146. var /** @type {?} */ baseName = TAG_TO_PLACEHOLDER_NAMES[upperTag] || "TAG_" + upperTag;
  10147. var /** @type {?} */ name = this._generateUniqueName(isVoid ? baseName : "START_" + baseName);
  10148. this._signatureToName[signature] = name;
  10149. return name;
  10150. };
  10151. /**
  10152. * @param {?} tag
  10153. * @return {?}
  10154. */
  10155. PlaceholderRegistry.prototype.getCloseTagPlaceholderName = /**
  10156. * @param {?} tag
  10157. * @return {?}
  10158. */
  10159. function (tag) {
  10160. var /** @type {?} */ signature = this._hashClosingTag(tag);
  10161. if (this._signatureToName[signature]) {
  10162. return this._signatureToName[signature];
  10163. }
  10164. var /** @type {?} */ upperTag = tag.toUpperCase();
  10165. var /** @type {?} */ baseName = TAG_TO_PLACEHOLDER_NAMES[upperTag] || "TAG_" + upperTag;
  10166. var /** @type {?} */ name = this._generateUniqueName("CLOSE_" + baseName);
  10167. this._signatureToName[signature] = name;
  10168. return name;
  10169. };
  10170. /**
  10171. * @param {?} name
  10172. * @param {?} content
  10173. * @return {?}
  10174. */
  10175. PlaceholderRegistry.prototype.getPlaceholderName = /**
  10176. * @param {?} name
  10177. * @param {?} content
  10178. * @return {?}
  10179. */
  10180. function (name, content) {
  10181. var /** @type {?} */ upperName = name.toUpperCase();
  10182. var /** @type {?} */ signature = "PH: " + upperName + "=" + content;
  10183. if (this._signatureToName[signature]) {
  10184. return this._signatureToName[signature];
  10185. }
  10186. var /** @type {?} */ uniqueName = this._generateUniqueName(upperName);
  10187. this._signatureToName[signature] = uniqueName;
  10188. return uniqueName;
  10189. };
  10190. /**
  10191. * @param {?} name
  10192. * @return {?}
  10193. */
  10194. PlaceholderRegistry.prototype.getUniquePlaceholder = /**
  10195. * @param {?} name
  10196. * @return {?}
  10197. */
  10198. function (name) {
  10199. return this._generateUniqueName(name.toUpperCase());
  10200. };
  10201. /**
  10202. * @param {?} tag
  10203. * @param {?} attrs
  10204. * @param {?} isVoid
  10205. * @return {?}
  10206. */
  10207. PlaceholderRegistry.prototype._hashTag = /**
  10208. * @param {?} tag
  10209. * @param {?} attrs
  10210. * @param {?} isVoid
  10211. * @return {?}
  10212. */
  10213. function (tag, attrs, isVoid) {
  10214. var /** @type {?} */ start = "<" + tag;
  10215. var /** @type {?} */ strAttrs = Object.keys(attrs).sort().map(function (name) { return " " + name + "=" + attrs[name]; }).join('');
  10216. var /** @type {?} */ end = isVoid ? '/>' : "></" + tag + ">";
  10217. return start + strAttrs + end;
  10218. };
  10219. /**
  10220. * @param {?} tag
  10221. * @return {?}
  10222. */
  10223. PlaceholderRegistry.prototype._hashClosingTag = /**
  10224. * @param {?} tag
  10225. * @return {?}
  10226. */
  10227. function (tag) { return this._hashTag("/" + tag, {}, false); };
  10228. /**
  10229. * @param {?} base
  10230. * @return {?}
  10231. */
  10232. PlaceholderRegistry.prototype._generateUniqueName = /**
  10233. * @param {?} base
  10234. * @return {?}
  10235. */
  10236. function (base) {
  10237. var /** @type {?} */ seen = this._placeHolderNameCounts.hasOwnProperty(base);
  10238. if (!seen) {
  10239. this._placeHolderNameCounts[base] = 1;
  10240. return base;
  10241. }
  10242. var /** @type {?} */ id = this._placeHolderNameCounts[base];
  10243. this._placeHolderNameCounts[base] = id + 1;
  10244. return base + "_" + id;
  10245. };
  10246. return PlaceholderRegistry;
  10247. }());
  10248. /**
  10249. * @fileoverview added by tsickle
  10250. * @suppress {checkTypes} checked by tsc
  10251. */
  10252. /**
  10253. * @license
  10254. * Copyright Google Inc. All Rights Reserved.
  10255. *
  10256. * Use of this source code is governed by an MIT-style license that can be
  10257. * found in the LICENSE file at https://angular.io/license
  10258. */
  10259. var _expParser = new Parser(new Lexer());
  10260. /**
  10261. * Returns a function converting html nodes to an i18n Message given an interpolationConfig
  10262. * @param {?} interpolationConfig
  10263. * @return {?}
  10264. */
  10265. function createI18nMessageFactory(interpolationConfig) {
  10266. var /** @type {?} */ visitor = new _I18nVisitor(_expParser, interpolationConfig);
  10267. return function (nodes, meaning, description, id) {
  10268. return visitor.toI18nMessage(nodes, meaning, description, id);
  10269. };
  10270. }
  10271. var _I18nVisitor = /** @class */ (function () {
  10272. function _I18nVisitor(_expressionParser, _interpolationConfig) {
  10273. this._expressionParser = _expressionParser;
  10274. this._interpolationConfig = _interpolationConfig;
  10275. }
  10276. /**
  10277. * @param {?} nodes
  10278. * @param {?} meaning
  10279. * @param {?} description
  10280. * @param {?} id
  10281. * @return {?}
  10282. */
  10283. _I18nVisitor.prototype.toI18nMessage = /**
  10284. * @param {?} nodes
  10285. * @param {?} meaning
  10286. * @param {?} description
  10287. * @param {?} id
  10288. * @return {?}
  10289. */
  10290. function (nodes, meaning, description, id) {
  10291. this._isIcu = nodes.length == 1 && nodes[0] instanceof Expansion;
  10292. this._icuDepth = 0;
  10293. this._placeholderRegistry = new PlaceholderRegistry();
  10294. this._placeholderToContent = {};
  10295. this._placeholderToMessage = {};
  10296. var /** @type {?} */ i18nodes = visitAll(this, nodes, {});
  10297. return new Message(i18nodes, this._placeholderToContent, this._placeholderToMessage, meaning, description, id);
  10298. };
  10299. /**
  10300. * @param {?} el
  10301. * @param {?} context
  10302. * @return {?}
  10303. */
  10304. _I18nVisitor.prototype.visitElement = /**
  10305. * @param {?} el
  10306. * @param {?} context
  10307. * @return {?}
  10308. */
  10309. function (el, context) {
  10310. var /** @type {?} */ children = visitAll(this, el.children);
  10311. var /** @type {?} */ attrs = {};
  10312. el.attrs.forEach(function (attr) {
  10313. // Do not visit the attributes, translatable ones are top-level ASTs
  10314. attrs[attr.name] = attr.value;
  10315. });
  10316. var /** @type {?} */ isVoid = getHtmlTagDefinition(el.name).isVoid;
  10317. var /** @type {?} */ startPhName = this._placeholderRegistry.getStartTagPlaceholderName(el.name, attrs, isVoid);
  10318. this._placeholderToContent[startPhName] = /** @type {?} */ ((el.sourceSpan)).toString();
  10319. var /** @type {?} */ closePhName = '';
  10320. if (!isVoid) {
  10321. closePhName = this._placeholderRegistry.getCloseTagPlaceholderName(el.name);
  10322. this._placeholderToContent[closePhName] = "</" + el.name + ">";
  10323. }
  10324. return new TagPlaceholder(el.name, attrs, startPhName, closePhName, children, isVoid, /** @type {?} */ ((el.sourceSpan)));
  10325. };
  10326. /**
  10327. * @param {?} attribute
  10328. * @param {?} context
  10329. * @return {?}
  10330. */
  10331. _I18nVisitor.prototype.visitAttribute = /**
  10332. * @param {?} attribute
  10333. * @param {?} context
  10334. * @return {?}
  10335. */
  10336. function (attribute, context) {
  10337. return this._visitTextWithInterpolation(attribute.value, attribute.sourceSpan);
  10338. };
  10339. /**
  10340. * @param {?} text
  10341. * @param {?} context
  10342. * @return {?}
  10343. */
  10344. _I18nVisitor.prototype.visitText = /**
  10345. * @param {?} text
  10346. * @param {?} context
  10347. * @return {?}
  10348. */
  10349. function (text, context) {
  10350. return this._visitTextWithInterpolation(text.value, /** @type {?} */ ((text.sourceSpan)));
  10351. };
  10352. /**
  10353. * @param {?} comment
  10354. * @param {?} context
  10355. * @return {?}
  10356. */
  10357. _I18nVisitor.prototype.visitComment = /**
  10358. * @param {?} comment
  10359. * @param {?} context
  10360. * @return {?}
  10361. */
  10362. function (comment, context) { return null; };
  10363. /**
  10364. * @param {?} icu
  10365. * @param {?} context
  10366. * @return {?}
  10367. */
  10368. _I18nVisitor.prototype.visitExpansion = /**
  10369. * @param {?} icu
  10370. * @param {?} context
  10371. * @return {?}
  10372. */
  10373. function (icu, context) {
  10374. var _this = this;
  10375. this._icuDepth++;
  10376. var /** @type {?} */ i18nIcuCases = {};
  10377. var /** @type {?} */ i18nIcu = new Icu(icu.switchValue, icu.type, i18nIcuCases, icu.sourceSpan);
  10378. icu.cases.forEach(function (caze) {
  10379. i18nIcuCases[caze.value] = new Container(caze.expression.map(function (node) { return node.visit(_this, {}); }), caze.expSourceSpan);
  10380. });
  10381. this._icuDepth--;
  10382. if (this._isIcu || this._icuDepth > 0) {
  10383. // Returns an ICU node when:
  10384. // - the message (vs a part of the message) is an ICU message, or
  10385. // - the ICU message is nested.
  10386. var /** @type {?} */ expPh = this._placeholderRegistry.getUniquePlaceholder("VAR_" + icu.type);
  10387. i18nIcu.expressionPlaceholder = expPh;
  10388. this._placeholderToContent[expPh] = icu.switchValue;
  10389. return i18nIcu;
  10390. }
  10391. // Else returns a placeholder
  10392. // ICU placeholders should not be replaced with their original content but with the their
  10393. // translations. We need to create a new visitor (they are not re-entrant) to compute the
  10394. // message id.
  10395. // TODO(vicb): add a html.Node -> i18n.Message cache to avoid having to re-create the msg
  10396. var /** @type {?} */ phName = this._placeholderRegistry.getPlaceholderName('ICU', icu.sourceSpan.toString());
  10397. var /** @type {?} */ visitor = new _I18nVisitor(this._expressionParser, this._interpolationConfig);
  10398. this._placeholderToMessage[phName] = visitor.toI18nMessage([icu], '', '', '');
  10399. return new IcuPlaceholder(i18nIcu, phName, icu.sourceSpan);
  10400. };
  10401. /**
  10402. * @param {?} icuCase
  10403. * @param {?} context
  10404. * @return {?}
  10405. */
  10406. _I18nVisitor.prototype.visitExpansionCase = /**
  10407. * @param {?} icuCase
  10408. * @param {?} context
  10409. * @return {?}
  10410. */
  10411. function (icuCase, context) {
  10412. throw new Error('Unreachable code');
  10413. };
  10414. /**
  10415. * @param {?} text
  10416. * @param {?} sourceSpan
  10417. * @return {?}
  10418. */
  10419. _I18nVisitor.prototype._visitTextWithInterpolation = /**
  10420. * @param {?} text
  10421. * @param {?} sourceSpan
  10422. * @return {?}
  10423. */
  10424. function (text, sourceSpan) {
  10425. var /** @type {?} */ splitInterpolation = this._expressionParser.splitInterpolation(text, sourceSpan.start.toString(), this._interpolationConfig);
  10426. if (!splitInterpolation) {
  10427. // No expression, return a single text
  10428. return new Text$1(text, sourceSpan);
  10429. }
  10430. // Return a group of text + expressions
  10431. var /** @type {?} */ nodes = [];
  10432. var /** @type {?} */ container = new Container(nodes, sourceSpan);
  10433. var _a = this._interpolationConfig, sDelimiter = _a.start, eDelimiter = _a.end;
  10434. for (var /** @type {?} */ i = 0; i < splitInterpolation.strings.length - 1; i++) {
  10435. var /** @type {?} */ expression = splitInterpolation.expressions[i];
  10436. var /** @type {?} */ baseName = _extractPlaceholderName(expression) || 'INTERPOLATION';
  10437. var /** @type {?} */ phName = this._placeholderRegistry.getPlaceholderName(baseName, expression);
  10438. if (splitInterpolation.strings[i].length) {
  10439. // No need to add empty strings
  10440. nodes.push(new Text$1(splitInterpolation.strings[i], sourceSpan));
  10441. }
  10442. nodes.push(new Placeholder(expression, phName, sourceSpan));
  10443. this._placeholderToContent[phName] = sDelimiter + expression + eDelimiter;
  10444. }
  10445. // The last index contains no expression
  10446. var /** @type {?} */ lastStringIdx = splitInterpolation.strings.length - 1;
  10447. if (splitInterpolation.strings[lastStringIdx].length) {
  10448. nodes.push(new Text$1(splitInterpolation.strings[lastStringIdx], sourceSpan));
  10449. }
  10450. return container;
  10451. };
  10452. return _I18nVisitor;
  10453. }());
  10454. var _CUSTOM_PH_EXP = /\/\/[\s\S]*i18n[\s\S]*\([\s\S]*ph[\s\S]*=[\s\S]*("|')([\s\S]*?)\1[\s\S]*\)/g;
  10455. /**
  10456. * @param {?} input
  10457. * @return {?}
  10458. */
  10459. function _extractPlaceholderName(input) {
  10460. return input.split(_CUSTOM_PH_EXP)[2];
  10461. }
  10462. /**
  10463. * @fileoverview added by tsickle
  10464. * @suppress {checkTypes} checked by tsc
  10465. */
  10466. /**
  10467. * @license
  10468. * Copyright Google Inc. All Rights Reserved.
  10469. *
  10470. * Use of this source code is governed by an MIT-style license that can be
  10471. * found in the LICENSE file at https://angular.io/license
  10472. */
  10473. /**
  10474. * An i18n error.
  10475. */
  10476. var I18nError = /** @class */ (function (_super) {
  10477. __extends(I18nError, _super);
  10478. function I18nError(span, msg) {
  10479. return _super.call(this, span, msg) || this;
  10480. }
  10481. return I18nError;
  10482. }(ParseError));
  10483. /**
  10484. * @fileoverview added by tsickle
  10485. * @suppress {checkTypes} checked by tsc
  10486. */
  10487. /**
  10488. * @license
  10489. * Copyright Google Inc. All Rights Reserved.
  10490. *
  10491. * Use of this source code is governed by an MIT-style license that can be
  10492. * found in the LICENSE file at https://angular.io/license
  10493. */
  10494. var _I18N_ATTR = 'i18n';
  10495. var _I18N_ATTR_PREFIX = 'i18n-';
  10496. var _I18N_COMMENT_PREFIX_REGEXP = /^i18n:?/;
  10497. var MEANING_SEPARATOR = '|';
  10498. var ID_SEPARATOR = '@@';
  10499. var i18nCommentsWarned = false;
  10500. /**
  10501. * Extract translatable messages from an html AST
  10502. * @param {?} nodes
  10503. * @param {?} interpolationConfig
  10504. * @param {?} implicitTags
  10505. * @param {?} implicitAttrs
  10506. * @return {?}
  10507. */
  10508. function extractMessages(nodes, interpolationConfig, implicitTags, implicitAttrs) {
  10509. var /** @type {?} */ visitor = new _Visitor(implicitTags, implicitAttrs);
  10510. return visitor.extract(nodes, interpolationConfig);
  10511. }
  10512. /**
  10513. * @param {?} nodes
  10514. * @param {?} translations
  10515. * @param {?} interpolationConfig
  10516. * @param {?} implicitTags
  10517. * @param {?} implicitAttrs
  10518. * @return {?}
  10519. */
  10520. function mergeTranslations(nodes, translations, interpolationConfig, implicitTags, implicitAttrs) {
  10521. var /** @type {?} */ visitor = new _Visitor(implicitTags, implicitAttrs);
  10522. return visitor.merge(nodes, translations, interpolationConfig);
  10523. }
  10524. var ExtractionResult = /** @class */ (function () {
  10525. function ExtractionResult(messages, errors) {
  10526. this.messages = messages;
  10527. this.errors = errors;
  10528. }
  10529. return ExtractionResult;
  10530. }());
  10531. /** @enum {number} */
  10532. var _VisitorMode = {
  10533. Extract: 0,
  10534. Merge: 1,
  10535. };
  10536. _VisitorMode[_VisitorMode.Extract] = "Extract";
  10537. _VisitorMode[_VisitorMode.Merge] = "Merge";
  10538. /**
  10539. * This Visitor is used:
  10540. * 1. to extract all the translatable strings from an html AST (see `extract()`),
  10541. * 2. to replace the translatable strings with the actual translations (see `merge()`)
  10542. *
  10543. * \@internal
  10544. */
  10545. var _Visitor = /** @class */ (function () {
  10546. function _Visitor(_implicitTags, _implicitAttrs) {
  10547. this._implicitTags = _implicitTags;
  10548. this._implicitAttrs = _implicitAttrs;
  10549. }
  10550. /**
  10551. * Extracts the messages from the tree
  10552. */
  10553. /**
  10554. * Extracts the messages from the tree
  10555. * @param {?} nodes
  10556. * @param {?} interpolationConfig
  10557. * @return {?}
  10558. */
  10559. _Visitor.prototype.extract = /**
  10560. * Extracts the messages from the tree
  10561. * @param {?} nodes
  10562. * @param {?} interpolationConfig
  10563. * @return {?}
  10564. */
  10565. function (nodes, interpolationConfig) {
  10566. var _this = this;
  10567. this._init(_VisitorMode.Extract, interpolationConfig);
  10568. nodes.forEach(function (node) { return node.visit(_this, null); });
  10569. if (this._inI18nBlock) {
  10570. this._reportError(nodes[nodes.length - 1], 'Unclosed block');
  10571. }
  10572. return new ExtractionResult(this._messages, this._errors);
  10573. };
  10574. /**
  10575. * Returns a tree where all translatable nodes are translated
  10576. */
  10577. /**
  10578. * Returns a tree where all translatable nodes are translated
  10579. * @param {?} nodes
  10580. * @param {?} translations
  10581. * @param {?} interpolationConfig
  10582. * @return {?}
  10583. */
  10584. _Visitor.prototype.merge = /**
  10585. * Returns a tree where all translatable nodes are translated
  10586. * @param {?} nodes
  10587. * @param {?} translations
  10588. * @param {?} interpolationConfig
  10589. * @return {?}
  10590. */
  10591. function (nodes, translations, interpolationConfig) {
  10592. this._init(_VisitorMode.Merge, interpolationConfig);
  10593. this._translations = translations;
  10594. // Construct a single fake root element
  10595. var /** @type {?} */ wrapper = new Element('wrapper', [], nodes, /** @type {?} */ ((undefined)), undefined, undefined);
  10596. var /** @type {?} */ translatedNode = wrapper.visit(this, null);
  10597. if (this._inI18nBlock) {
  10598. this._reportError(nodes[nodes.length - 1], 'Unclosed block');
  10599. }
  10600. return new ParseTreeResult(translatedNode.children, this._errors);
  10601. };
  10602. /**
  10603. * @param {?} icuCase
  10604. * @param {?} context
  10605. * @return {?}
  10606. */
  10607. _Visitor.prototype.visitExpansionCase = /**
  10608. * @param {?} icuCase
  10609. * @param {?} context
  10610. * @return {?}
  10611. */
  10612. function (icuCase, context) {
  10613. // Parse cases for translatable html attributes
  10614. var /** @type {?} */ expression = visitAll(this, icuCase.expression, context);
  10615. if (this._mode === _VisitorMode.Merge) {
  10616. return new ExpansionCase(icuCase.value, expression, icuCase.sourceSpan, icuCase.valueSourceSpan, icuCase.expSourceSpan);
  10617. }
  10618. };
  10619. /**
  10620. * @param {?} icu
  10621. * @param {?} context
  10622. * @return {?}
  10623. */
  10624. _Visitor.prototype.visitExpansion = /**
  10625. * @param {?} icu
  10626. * @param {?} context
  10627. * @return {?}
  10628. */
  10629. function (icu, context) {
  10630. this._mayBeAddBlockChildren(icu);
  10631. var /** @type {?} */ wasInIcu = this._inIcu;
  10632. if (!this._inIcu) {
  10633. // nested ICU messages should not be extracted but top-level translated as a whole
  10634. if (this._isInTranslatableSection) {
  10635. this._addMessage([icu]);
  10636. }
  10637. this._inIcu = true;
  10638. }
  10639. var /** @type {?} */ cases = visitAll(this, icu.cases, context);
  10640. if (this._mode === _VisitorMode.Merge) {
  10641. icu = new Expansion(icu.switchValue, icu.type, cases, icu.sourceSpan, icu.switchValueSourceSpan);
  10642. }
  10643. this._inIcu = wasInIcu;
  10644. return icu;
  10645. };
  10646. /**
  10647. * @param {?} comment
  10648. * @param {?} context
  10649. * @return {?}
  10650. */
  10651. _Visitor.prototype.visitComment = /**
  10652. * @param {?} comment
  10653. * @param {?} context
  10654. * @return {?}
  10655. */
  10656. function (comment, context) {
  10657. var /** @type {?} */ isOpening = _isOpeningComment(comment);
  10658. if (isOpening && this._isInTranslatableSection) {
  10659. this._reportError(comment, 'Could not start a block inside a translatable section');
  10660. return;
  10661. }
  10662. var /** @type {?} */ isClosing = _isClosingComment(comment);
  10663. if (isClosing && !this._inI18nBlock) {
  10664. this._reportError(comment, 'Trying to close an unopened block');
  10665. return;
  10666. }
  10667. if (!this._inI18nNode && !this._inIcu) {
  10668. if (!this._inI18nBlock) {
  10669. if (isOpening) {
  10670. // deprecated from v5 you should use <ng-container i18n> instead of i18n comments
  10671. if (!i18nCommentsWarned && /** @type {?} */ (console) && /** @type {?} */ (console.warn)) {
  10672. i18nCommentsWarned = true;
  10673. var /** @type {?} */ details = comment.sourceSpan.details ? ", " + comment.sourceSpan.details : '';
  10674. // TODO(ocombe): use a log service once there is a public one available
  10675. console.warn("I18n comments are deprecated, use an <ng-container> element instead (" + comment.sourceSpan.start + details + ")");
  10676. }
  10677. this._inI18nBlock = true;
  10678. this._blockStartDepth = this._depth;
  10679. this._blockChildren = [];
  10680. this._blockMeaningAndDesc = /** @type {?} */ ((comment.value)).replace(_I18N_COMMENT_PREFIX_REGEXP, '').trim();
  10681. this._openTranslatableSection(comment);
  10682. }
  10683. }
  10684. else {
  10685. if (isClosing) {
  10686. if (this._depth == this._blockStartDepth) {
  10687. this._closeTranslatableSection(comment, this._blockChildren);
  10688. this._inI18nBlock = false;
  10689. var /** @type {?} */ message = /** @type {?} */ ((this._addMessage(this._blockChildren, this._blockMeaningAndDesc)));
  10690. // merge attributes in sections
  10691. var /** @type {?} */ nodes = this._translateMessage(comment, message);
  10692. return visitAll(this, nodes);
  10693. }
  10694. else {
  10695. this._reportError(comment, 'I18N blocks should not cross element boundaries');
  10696. return;
  10697. }
  10698. }
  10699. }
  10700. }
  10701. };
  10702. /**
  10703. * @param {?} text
  10704. * @param {?} context
  10705. * @return {?}
  10706. */
  10707. _Visitor.prototype.visitText = /**
  10708. * @param {?} text
  10709. * @param {?} context
  10710. * @return {?}
  10711. */
  10712. function (text, context) {
  10713. if (this._isInTranslatableSection) {
  10714. this._mayBeAddBlockChildren(text);
  10715. }
  10716. return text;
  10717. };
  10718. /**
  10719. * @param {?} el
  10720. * @param {?} context
  10721. * @return {?}
  10722. */
  10723. _Visitor.prototype.visitElement = /**
  10724. * @param {?} el
  10725. * @param {?} context
  10726. * @return {?}
  10727. */
  10728. function (el, context) {
  10729. var _this = this;
  10730. this._mayBeAddBlockChildren(el);
  10731. this._depth++;
  10732. var /** @type {?} */ wasInI18nNode = this._inI18nNode;
  10733. var /** @type {?} */ wasInImplicitNode = this._inImplicitNode;
  10734. var /** @type {?} */ childNodes = [];
  10735. var /** @type {?} */ translatedChildNodes = /** @type {?} */ ((undefined));
  10736. // Extract:
  10737. // - top level nodes with the (implicit) "i18n" attribute if not already in a section
  10738. // - ICU messages
  10739. var /** @type {?} */ i18nAttr = _getI18nAttr(el);
  10740. var /** @type {?} */ i18nMeta = i18nAttr ? i18nAttr.value : '';
  10741. var /** @type {?} */ isImplicit = this._implicitTags.some(function (tag) { return el.name === tag; }) && !this._inIcu &&
  10742. !this._isInTranslatableSection;
  10743. var /** @type {?} */ isTopLevelImplicit = !wasInImplicitNode && isImplicit;
  10744. this._inImplicitNode = wasInImplicitNode || isImplicit;
  10745. if (!this._isInTranslatableSection && !this._inIcu) {
  10746. if (i18nAttr || isTopLevelImplicit) {
  10747. this._inI18nNode = true;
  10748. var /** @type {?} */ message = /** @type {?} */ ((this._addMessage(el.children, i18nMeta)));
  10749. translatedChildNodes = this._translateMessage(el, message);
  10750. }
  10751. if (this._mode == _VisitorMode.Extract) {
  10752. var /** @type {?} */ isTranslatable = i18nAttr || isTopLevelImplicit;
  10753. if (isTranslatable)
  10754. this._openTranslatableSection(el);
  10755. visitAll(this, el.children);
  10756. if (isTranslatable)
  10757. this._closeTranslatableSection(el, el.children);
  10758. }
  10759. }
  10760. else {
  10761. if (i18nAttr || isTopLevelImplicit) {
  10762. this._reportError(el, 'Could not mark an element as translatable inside a translatable section');
  10763. }
  10764. if (this._mode == _VisitorMode.Extract) {
  10765. // Descend into child nodes for extraction
  10766. visitAll(this, el.children);
  10767. }
  10768. }
  10769. if (this._mode === _VisitorMode.Merge) {
  10770. var /** @type {?} */ visitNodes = translatedChildNodes || el.children;
  10771. visitNodes.forEach(function (child) {
  10772. var /** @type {?} */ visited = child.visit(_this, context);
  10773. if (visited && !_this._isInTranslatableSection) {
  10774. // Do not add the children from translatable sections (= i18n blocks here)
  10775. // They will be added later in this loop when the block closes (i.e. on `<!-- /i18n -->`)
  10776. childNodes = childNodes.concat(visited);
  10777. }
  10778. });
  10779. }
  10780. this._visitAttributesOf(el);
  10781. this._depth--;
  10782. this._inI18nNode = wasInI18nNode;
  10783. this._inImplicitNode = wasInImplicitNode;
  10784. if (this._mode === _VisitorMode.Merge) {
  10785. var /** @type {?} */ translatedAttrs = this._translateAttributes(el);
  10786. return new Element(el.name, translatedAttrs, childNodes, el.sourceSpan, el.startSourceSpan, el.endSourceSpan);
  10787. }
  10788. return null;
  10789. };
  10790. /**
  10791. * @param {?} attribute
  10792. * @param {?} context
  10793. * @return {?}
  10794. */
  10795. _Visitor.prototype.visitAttribute = /**
  10796. * @param {?} attribute
  10797. * @param {?} context
  10798. * @return {?}
  10799. */
  10800. function (attribute, context) {
  10801. throw new Error('unreachable code');
  10802. };
  10803. /**
  10804. * @param {?} mode
  10805. * @param {?} interpolationConfig
  10806. * @return {?}
  10807. */
  10808. _Visitor.prototype._init = /**
  10809. * @param {?} mode
  10810. * @param {?} interpolationConfig
  10811. * @return {?}
  10812. */
  10813. function (mode, interpolationConfig) {
  10814. this._mode = mode;
  10815. this._inI18nBlock = false;
  10816. this._inI18nNode = false;
  10817. this._depth = 0;
  10818. this._inIcu = false;
  10819. this._msgCountAtSectionStart = undefined;
  10820. this._errors = [];
  10821. this._messages = [];
  10822. this._inImplicitNode = false;
  10823. this._createI18nMessage = createI18nMessageFactory(interpolationConfig);
  10824. };
  10825. /**
  10826. * @param {?} el
  10827. * @return {?}
  10828. */
  10829. _Visitor.prototype._visitAttributesOf = /**
  10830. * @param {?} el
  10831. * @return {?}
  10832. */
  10833. function (el) {
  10834. var _this = this;
  10835. var /** @type {?} */ explicitAttrNameToValue = {};
  10836. var /** @type {?} */ implicitAttrNames = this._implicitAttrs[el.name] || [];
  10837. el.attrs.filter(function (attr) { return attr.name.startsWith(_I18N_ATTR_PREFIX); })
  10838. .forEach(function (attr) {
  10839. return explicitAttrNameToValue[attr.name.slice(_I18N_ATTR_PREFIX.length)] =
  10840. attr.value;
  10841. });
  10842. el.attrs.forEach(function (attr) {
  10843. if (attr.name in explicitAttrNameToValue) {
  10844. _this._addMessage([attr], explicitAttrNameToValue[attr.name]);
  10845. }
  10846. else if (implicitAttrNames.some(function (name) { return attr.name === name; })) {
  10847. _this._addMessage([attr]);
  10848. }
  10849. });
  10850. };
  10851. /**
  10852. * @param {?} ast
  10853. * @param {?=} msgMeta
  10854. * @return {?}
  10855. */
  10856. _Visitor.prototype._addMessage = /**
  10857. * @param {?} ast
  10858. * @param {?=} msgMeta
  10859. * @return {?}
  10860. */
  10861. function (ast, msgMeta) {
  10862. if (ast.length == 0 ||
  10863. ast.length == 1 && ast[0] instanceof Attribute$1 && !(/** @type {?} */ (ast[0])).value) {
  10864. // Do not create empty messages
  10865. return null;
  10866. }
  10867. var _a = _parseMessageMeta(msgMeta), meaning = _a.meaning, description = _a.description, id = _a.id;
  10868. var /** @type {?} */ message = this._createI18nMessage(ast, meaning, description, id);
  10869. this._messages.push(message);
  10870. return message;
  10871. };
  10872. /**
  10873. * @param {?} el
  10874. * @param {?} message
  10875. * @return {?}
  10876. */
  10877. _Visitor.prototype._translateMessage = /**
  10878. * @param {?} el
  10879. * @param {?} message
  10880. * @return {?}
  10881. */
  10882. function (el, message) {
  10883. if (message && this._mode === _VisitorMode.Merge) {
  10884. var /** @type {?} */ nodes = this._translations.get(message);
  10885. if (nodes) {
  10886. return nodes;
  10887. }
  10888. this._reportError(el, "Translation unavailable for message id=\"" + this._translations.digest(message) + "\"");
  10889. }
  10890. return [];
  10891. };
  10892. /**
  10893. * @param {?} el
  10894. * @return {?}
  10895. */
  10896. _Visitor.prototype._translateAttributes = /**
  10897. * @param {?} el
  10898. * @return {?}
  10899. */
  10900. function (el) {
  10901. var _this = this;
  10902. var /** @type {?} */ attributes = el.attrs;
  10903. var /** @type {?} */ i18nParsedMessageMeta = {};
  10904. attributes.forEach(function (attr) {
  10905. if (attr.name.startsWith(_I18N_ATTR_PREFIX)) {
  10906. i18nParsedMessageMeta[attr.name.slice(_I18N_ATTR_PREFIX.length)] =
  10907. _parseMessageMeta(attr.value);
  10908. }
  10909. });
  10910. var /** @type {?} */ translatedAttributes = [];
  10911. attributes.forEach(function (attr) {
  10912. if (attr.name === _I18N_ATTR || attr.name.startsWith(_I18N_ATTR_PREFIX)) {
  10913. // strip i18n specific attributes
  10914. return;
  10915. }
  10916. if (attr.value && attr.value != '' && i18nParsedMessageMeta.hasOwnProperty(attr.name)) {
  10917. var _a = i18nParsedMessageMeta[attr.name], meaning = _a.meaning, description = _a.description, id = _a.id;
  10918. var /** @type {?} */ message = _this._createI18nMessage([attr], meaning, description, id);
  10919. var /** @type {?} */ nodes = _this._translations.get(message);
  10920. if (nodes) {
  10921. if (nodes.length == 0) {
  10922. translatedAttributes.push(new Attribute$1(attr.name, '', attr.sourceSpan));
  10923. }
  10924. else if (nodes[0] instanceof Text) {
  10925. var /** @type {?} */ value = (/** @type {?} */ (nodes[0])).value;
  10926. translatedAttributes.push(new Attribute$1(attr.name, value, attr.sourceSpan));
  10927. }
  10928. else {
  10929. _this._reportError(el, "Unexpected translation for attribute \"" + attr.name + "\" (id=\"" + (id || _this._translations.digest(message)) + "\")");
  10930. }
  10931. }
  10932. else {
  10933. _this._reportError(el, "Translation unavailable for attribute \"" + attr.name + "\" (id=\"" + (id || _this._translations.digest(message)) + "\")");
  10934. }
  10935. }
  10936. else {
  10937. translatedAttributes.push(attr);
  10938. }
  10939. });
  10940. return translatedAttributes;
  10941. };
  10942. /**
  10943. * Add the node as a child of the block when:
  10944. * - we are in a block,
  10945. * - we are not inside a ICU message (those are handled separately),
  10946. * - the node is a "direct child" of the block
  10947. * @param {?} node
  10948. * @return {?}
  10949. */
  10950. _Visitor.prototype._mayBeAddBlockChildren = /**
  10951. * Add the node as a child of the block when:
  10952. * - we are in a block,
  10953. * - we are not inside a ICU message (those are handled separately),
  10954. * - the node is a "direct child" of the block
  10955. * @param {?} node
  10956. * @return {?}
  10957. */
  10958. function (node) {
  10959. if (this._inI18nBlock && !this._inIcu && this._depth == this._blockStartDepth) {
  10960. this._blockChildren.push(node);
  10961. }
  10962. };
  10963. /**
  10964. * Marks the start of a section, see `_closeTranslatableSection`
  10965. * @param {?} node
  10966. * @return {?}
  10967. */
  10968. _Visitor.prototype._openTranslatableSection = /**
  10969. * Marks the start of a section, see `_closeTranslatableSection`
  10970. * @param {?} node
  10971. * @return {?}
  10972. */
  10973. function (node) {
  10974. if (this._isInTranslatableSection) {
  10975. this._reportError(node, 'Unexpected section start');
  10976. }
  10977. else {
  10978. this._msgCountAtSectionStart = this._messages.length;
  10979. }
  10980. };
  10981. Object.defineProperty(_Visitor.prototype, "_isInTranslatableSection", {
  10982. get: /**
  10983. * A translatable section could be:
  10984. * - the content of translatable element,
  10985. * - nodes between `<!-- i18n -->` and `<!-- /i18n -->` comments
  10986. * @return {?}
  10987. */
  10988. function () {
  10989. return this._msgCountAtSectionStart !== void 0;
  10990. },
  10991. enumerable: true,
  10992. configurable: true
  10993. });
  10994. /**
  10995. * Terminates a section.
  10996. *
  10997. * If a section has only one significant children (comments not significant) then we should not
  10998. * keep the message from this children:
  10999. *
  11000. * `<p i18n="meaning|description">{ICU message}</p>` would produce two messages:
  11001. * - one for the <p> content with meaning and description,
  11002. * - another one for the ICU message.
  11003. *
  11004. * In this case the last message is discarded as it contains less information (the AST is
  11005. * otherwise identical).
  11006. *
  11007. * Note that we should still keep messages extracted from attributes inside the section (ie in the
  11008. * ICU message here)
  11009. * @param {?} node
  11010. * @param {?} directChildren
  11011. * @return {?}
  11012. */
  11013. _Visitor.prototype._closeTranslatableSection = /**
  11014. * Terminates a section.
  11015. *
  11016. * If a section has only one significant children (comments not significant) then we should not
  11017. * keep the message from this children:
  11018. *
  11019. * `<p i18n="meaning|description">{ICU message}</p>` would produce two messages:
  11020. * - one for the <p> content with meaning and description,
  11021. * - another one for the ICU message.
  11022. *
  11023. * In this case the last message is discarded as it contains less information (the AST is
  11024. * otherwise identical).
  11025. *
  11026. * Note that we should still keep messages extracted from attributes inside the section (ie in the
  11027. * ICU message here)
  11028. * @param {?} node
  11029. * @param {?} directChildren
  11030. * @return {?}
  11031. */
  11032. function (node, directChildren) {
  11033. if (!this._isInTranslatableSection) {
  11034. this._reportError(node, 'Unexpected section end');
  11035. return;
  11036. }
  11037. var /** @type {?} */ startIndex = this._msgCountAtSectionStart;
  11038. var /** @type {?} */ significantChildren = directChildren.reduce(function (count, node) { return count + (node instanceof Comment ? 0 : 1); }, 0);
  11039. if (significantChildren == 1) {
  11040. for (var /** @type {?} */ i = this._messages.length - 1; i >= /** @type {?} */ ((startIndex)); i--) {
  11041. var /** @type {?} */ ast = this._messages[i].nodes;
  11042. if (!(ast.length == 1 && ast[0] instanceof Text$1)) {
  11043. this._messages.splice(i, 1);
  11044. break;
  11045. }
  11046. }
  11047. }
  11048. this._msgCountAtSectionStart = undefined;
  11049. };
  11050. /**
  11051. * @param {?} node
  11052. * @param {?} msg
  11053. * @return {?}
  11054. */
  11055. _Visitor.prototype._reportError = /**
  11056. * @param {?} node
  11057. * @param {?} msg
  11058. * @return {?}
  11059. */
  11060. function (node, msg) {
  11061. this._errors.push(new I18nError(/** @type {?} */ ((node.sourceSpan)), msg));
  11062. };
  11063. return _Visitor;
  11064. }());
  11065. /**
  11066. * @param {?} n
  11067. * @return {?}
  11068. */
  11069. function _isOpeningComment(n) {
  11070. return !!(n instanceof Comment && n.value && n.value.startsWith('i18n'));
  11071. }
  11072. /**
  11073. * @param {?} n
  11074. * @return {?}
  11075. */
  11076. function _isClosingComment(n) {
  11077. return !!(n instanceof Comment && n.value && n.value === '/i18n');
  11078. }
  11079. /**
  11080. * @param {?} p
  11081. * @return {?}
  11082. */
  11083. function _getI18nAttr(p) {
  11084. return p.attrs.find(function (attr) { return attr.name === _I18N_ATTR; }) || null;
  11085. }
  11086. /**
  11087. * @param {?=} i18n
  11088. * @return {?}
  11089. */
  11090. function _parseMessageMeta(i18n) {
  11091. if (!i18n)
  11092. return { meaning: '', description: '', id: '' };
  11093. var /** @type {?} */ idIndex = i18n.indexOf(ID_SEPARATOR);
  11094. var /** @type {?} */ descIndex = i18n.indexOf(MEANING_SEPARATOR);
  11095. var _a = (idIndex > -1) ? [i18n.slice(0, idIndex), i18n.slice(idIndex + 2)] : [i18n, ''], meaningAndDesc = _a[0], id = _a[1];
  11096. var _b = (descIndex > -1) ?
  11097. [meaningAndDesc.slice(0, descIndex), meaningAndDesc.slice(descIndex + 1)] :
  11098. ['', meaningAndDesc], meaning = _b[0], description = _b[1];
  11099. return { meaning: meaning, description: description, id: id };
  11100. }
  11101. /**
  11102. * @fileoverview added by tsickle
  11103. * @suppress {checkTypes} checked by tsc
  11104. */
  11105. /**
  11106. * @license
  11107. * Copyright Google Inc. All Rights Reserved.
  11108. *
  11109. * Use of this source code is governed by an MIT-style license that can be
  11110. * found in the LICENSE file at https://angular.io/license
  11111. */
  11112. var XmlTagDefinition = /** @class */ (function () {
  11113. function XmlTagDefinition() {
  11114. this.closedByParent = false;
  11115. this.contentType = TagContentType.PARSABLE_DATA;
  11116. this.isVoid = false;
  11117. this.ignoreFirstLf = false;
  11118. this.canSelfClose = true;
  11119. }
  11120. /**
  11121. * @param {?} currentParent
  11122. * @return {?}
  11123. */
  11124. XmlTagDefinition.prototype.requireExtraParent = /**
  11125. * @param {?} currentParent
  11126. * @return {?}
  11127. */
  11128. function (currentParent) { return false; };
  11129. /**
  11130. * @param {?} name
  11131. * @return {?}
  11132. */
  11133. XmlTagDefinition.prototype.isClosedByChild = /**
  11134. * @param {?} name
  11135. * @return {?}
  11136. */
  11137. function (name) { return false; };
  11138. return XmlTagDefinition;
  11139. }());
  11140. var _TAG_DEFINITION = new XmlTagDefinition();
  11141. /**
  11142. * @param {?} tagName
  11143. * @return {?}
  11144. */
  11145. function getXmlTagDefinition(tagName) {
  11146. return _TAG_DEFINITION;
  11147. }
  11148. /**
  11149. * @fileoverview added by tsickle
  11150. * @suppress {checkTypes} checked by tsc
  11151. */
  11152. /**
  11153. * @license
  11154. * Copyright Google Inc. All Rights Reserved.
  11155. *
  11156. * Use of this source code is governed by an MIT-style license that can be
  11157. * found in the LICENSE file at https://angular.io/license
  11158. */
  11159. var XmlParser = /** @class */ (function (_super) {
  11160. __extends(XmlParser, _super);
  11161. function XmlParser() {
  11162. return _super.call(this, getXmlTagDefinition) || this;
  11163. }
  11164. /**
  11165. * @param {?} source
  11166. * @param {?} url
  11167. * @param {?=} parseExpansionForms
  11168. * @return {?}
  11169. */
  11170. XmlParser.prototype.parse = /**
  11171. * @param {?} source
  11172. * @param {?} url
  11173. * @param {?=} parseExpansionForms
  11174. * @return {?}
  11175. */
  11176. function (source, url, parseExpansionForms) {
  11177. if (parseExpansionForms === void 0) { parseExpansionForms = false; }
  11178. return _super.prototype.parse.call(this, source, url, parseExpansionForms);
  11179. };
  11180. return XmlParser;
  11181. }(Parser$1));
  11182. /**
  11183. * @fileoverview added by tsickle
  11184. * @suppress {checkTypes} checked by tsc
  11185. */
  11186. /**
  11187. * @license
  11188. * Copyright Google Inc. All Rights Reserved.
  11189. *
  11190. * Use of this source code is governed by an MIT-style license that can be
  11191. * found in the LICENSE file at https://angular.io/license
  11192. */
  11193. /**
  11194. * @abstract
  11195. */
  11196. var Serializer = /** @class */ (function () {
  11197. function Serializer() {
  11198. }
  11199. // Creates a name mapper, see `PlaceholderMapper`
  11200. // Returning `null` means that no name mapping is used.
  11201. /**
  11202. * @param {?} message
  11203. * @return {?}
  11204. */
  11205. Serializer.prototype.createNameMapper = /**
  11206. * @param {?} message
  11207. * @return {?}
  11208. */
  11209. function (message) { return null; };
  11210. return Serializer;
  11211. }());
  11212. /**
  11213. * A `PlaceholderMapper` converts placeholder names from internal to serialized representation and
  11214. * back.
  11215. *
  11216. * It should be used for serialization format that put constraints on the placeholder names.
  11217. * @record
  11218. */
  11219. /**
  11220. * A simple mapper that take a function to transform an internal name to a public name
  11221. */
  11222. var SimplePlaceholderMapper = /** @class */ (function (_super) {
  11223. __extends(SimplePlaceholderMapper, _super);
  11224. // create a mapping from the message
  11225. function SimplePlaceholderMapper(message, mapName) {
  11226. var _this = _super.call(this) || this;
  11227. _this.mapName = mapName;
  11228. _this.internalToPublic = {};
  11229. _this.publicToNextId = {};
  11230. _this.publicToInternal = {};
  11231. message.nodes.forEach(function (node) { return node.visit(_this); });
  11232. return _this;
  11233. }
  11234. /**
  11235. * @param {?} internalName
  11236. * @return {?}
  11237. */
  11238. SimplePlaceholderMapper.prototype.toPublicName = /**
  11239. * @param {?} internalName
  11240. * @return {?}
  11241. */
  11242. function (internalName) {
  11243. return this.internalToPublic.hasOwnProperty(internalName) ?
  11244. this.internalToPublic[internalName] :
  11245. null;
  11246. };
  11247. /**
  11248. * @param {?} publicName
  11249. * @return {?}
  11250. */
  11251. SimplePlaceholderMapper.prototype.toInternalName = /**
  11252. * @param {?} publicName
  11253. * @return {?}
  11254. */
  11255. function (publicName) {
  11256. return this.publicToInternal.hasOwnProperty(publicName) ? this.publicToInternal[publicName] :
  11257. null;
  11258. };
  11259. /**
  11260. * @param {?} text
  11261. * @param {?=} context
  11262. * @return {?}
  11263. */
  11264. SimplePlaceholderMapper.prototype.visitText = /**
  11265. * @param {?} text
  11266. * @param {?=} context
  11267. * @return {?}
  11268. */
  11269. function (text, context) { return null; };
  11270. /**
  11271. * @param {?} ph
  11272. * @param {?=} context
  11273. * @return {?}
  11274. */
  11275. SimplePlaceholderMapper.prototype.visitTagPlaceholder = /**
  11276. * @param {?} ph
  11277. * @param {?=} context
  11278. * @return {?}
  11279. */
  11280. function (ph, context) {
  11281. this.visitPlaceholderName(ph.startName);
  11282. _super.prototype.visitTagPlaceholder.call(this, ph, context);
  11283. this.visitPlaceholderName(ph.closeName);
  11284. };
  11285. /**
  11286. * @param {?} ph
  11287. * @param {?=} context
  11288. * @return {?}
  11289. */
  11290. SimplePlaceholderMapper.prototype.visitPlaceholder = /**
  11291. * @param {?} ph
  11292. * @param {?=} context
  11293. * @return {?}
  11294. */
  11295. function (ph, context) { this.visitPlaceholderName(ph.name); };
  11296. /**
  11297. * @param {?} ph
  11298. * @param {?=} context
  11299. * @return {?}
  11300. */
  11301. SimplePlaceholderMapper.prototype.visitIcuPlaceholder = /**
  11302. * @param {?} ph
  11303. * @param {?=} context
  11304. * @return {?}
  11305. */
  11306. function (ph, context) {
  11307. this.visitPlaceholderName(ph.name);
  11308. };
  11309. /**
  11310. * @param {?} internalName
  11311. * @return {?}
  11312. */
  11313. SimplePlaceholderMapper.prototype.visitPlaceholderName = /**
  11314. * @param {?} internalName
  11315. * @return {?}
  11316. */
  11317. function (internalName) {
  11318. if (!internalName || this.internalToPublic.hasOwnProperty(internalName)) {
  11319. return;
  11320. }
  11321. var /** @type {?} */ publicName = this.mapName(internalName);
  11322. if (this.publicToInternal.hasOwnProperty(publicName)) {
  11323. // Create a new XMB when it has already been used
  11324. var /** @type {?} */ nextId = this.publicToNextId[publicName];
  11325. this.publicToNextId[publicName] = nextId + 1;
  11326. publicName = publicName + "_" + nextId;
  11327. }
  11328. else {
  11329. this.publicToNextId[publicName] = 1;
  11330. }
  11331. this.internalToPublic[internalName] = publicName;
  11332. this.publicToInternal[publicName] = internalName;
  11333. };
  11334. return SimplePlaceholderMapper;
  11335. }(RecurseVisitor));
  11336. /**
  11337. * @fileoverview added by tsickle
  11338. * @suppress {checkTypes} checked by tsc
  11339. */
  11340. /**
  11341. * @license
  11342. * Copyright Google Inc. All Rights Reserved.
  11343. *
  11344. * Use of this source code is governed by an MIT-style license that can be
  11345. * found in the LICENSE file at https://angular.io/license
  11346. */
  11347. /**
  11348. * @record
  11349. */
  11350. var _Visitor$1 = /** @class */ (function () {
  11351. function _Visitor() {
  11352. }
  11353. /**
  11354. * @param {?} tag
  11355. * @return {?}
  11356. */
  11357. _Visitor.prototype.visitTag = /**
  11358. * @param {?} tag
  11359. * @return {?}
  11360. */
  11361. function (tag) {
  11362. var _this = this;
  11363. var /** @type {?} */ strAttrs = this._serializeAttributes(tag.attrs);
  11364. if (tag.children.length == 0) {
  11365. return "<" + tag.name + strAttrs + "/>";
  11366. }
  11367. var /** @type {?} */ strChildren = tag.children.map(function (node) { return node.visit(_this); });
  11368. return "<" + tag.name + strAttrs + ">" + strChildren.join('') + "</" + tag.name + ">";
  11369. };
  11370. /**
  11371. * @param {?} text
  11372. * @return {?}
  11373. */
  11374. _Visitor.prototype.visitText = /**
  11375. * @param {?} text
  11376. * @return {?}
  11377. */
  11378. function (text) { return text.value; };
  11379. /**
  11380. * @param {?} decl
  11381. * @return {?}
  11382. */
  11383. _Visitor.prototype.visitDeclaration = /**
  11384. * @param {?} decl
  11385. * @return {?}
  11386. */
  11387. function (decl) {
  11388. return "<?xml" + this._serializeAttributes(decl.attrs) + " ?>";
  11389. };
  11390. /**
  11391. * @param {?} attrs
  11392. * @return {?}
  11393. */
  11394. _Visitor.prototype._serializeAttributes = /**
  11395. * @param {?} attrs
  11396. * @return {?}
  11397. */
  11398. function (attrs) {
  11399. var /** @type {?} */ strAttrs = Object.keys(attrs).map(function (name) { return name + "=\"" + attrs[name] + "\""; }).join(' ');
  11400. return strAttrs.length > 0 ? ' ' + strAttrs : '';
  11401. };
  11402. /**
  11403. * @param {?} doctype
  11404. * @return {?}
  11405. */
  11406. _Visitor.prototype.visitDoctype = /**
  11407. * @param {?} doctype
  11408. * @return {?}
  11409. */
  11410. function (doctype) {
  11411. return "<!DOCTYPE " + doctype.rootTag + " [\n" + doctype.dtd + "\n]>";
  11412. };
  11413. return _Visitor;
  11414. }());
  11415. var _visitor = new _Visitor$1();
  11416. /**
  11417. * @param {?} nodes
  11418. * @return {?}
  11419. */
  11420. function serialize(nodes) {
  11421. return nodes.map(function (node) { return node.visit(_visitor); }).join('');
  11422. }
  11423. /**
  11424. * @record
  11425. */
  11426. var Declaration = /** @class */ (function () {
  11427. function Declaration(unescapedAttrs) {
  11428. var _this = this;
  11429. this.attrs = {};
  11430. Object.keys(unescapedAttrs).forEach(function (k) {
  11431. _this.attrs[k] = escapeXml(unescapedAttrs[k]);
  11432. });
  11433. }
  11434. /**
  11435. * @param {?} visitor
  11436. * @return {?}
  11437. */
  11438. Declaration.prototype.visit = /**
  11439. * @param {?} visitor
  11440. * @return {?}
  11441. */
  11442. function (visitor) { return visitor.visitDeclaration(this); };
  11443. return Declaration;
  11444. }());
  11445. var Doctype = /** @class */ (function () {
  11446. function Doctype(rootTag, dtd) {
  11447. this.rootTag = rootTag;
  11448. this.dtd = dtd;
  11449. }
  11450. /**
  11451. * @param {?} visitor
  11452. * @return {?}
  11453. */
  11454. Doctype.prototype.visit = /**
  11455. * @param {?} visitor
  11456. * @return {?}
  11457. */
  11458. function (visitor) { return visitor.visitDoctype(this); };
  11459. return Doctype;
  11460. }());
  11461. var Tag = /** @class */ (function () {
  11462. function Tag(name, unescapedAttrs, children) {
  11463. if (unescapedAttrs === void 0) { unescapedAttrs = {}; }
  11464. if (children === void 0) { children = []; }
  11465. var _this = this;
  11466. this.name = name;
  11467. this.children = children;
  11468. this.attrs = {};
  11469. Object.keys(unescapedAttrs).forEach(function (k) {
  11470. _this.attrs[k] = escapeXml(unescapedAttrs[k]);
  11471. });
  11472. }
  11473. /**
  11474. * @param {?} visitor
  11475. * @return {?}
  11476. */
  11477. Tag.prototype.visit = /**
  11478. * @param {?} visitor
  11479. * @return {?}
  11480. */
  11481. function (visitor) { return visitor.visitTag(this); };
  11482. return Tag;
  11483. }());
  11484. var Text$2 = /** @class */ (function () {
  11485. function Text(unescapedValue) {
  11486. this.value = escapeXml(unescapedValue);
  11487. }
  11488. /**
  11489. * @param {?} visitor
  11490. * @return {?}
  11491. */
  11492. Text.prototype.visit = /**
  11493. * @param {?} visitor
  11494. * @return {?}
  11495. */
  11496. function (visitor) { return visitor.visitText(this); };
  11497. return Text;
  11498. }());
  11499. var CR = /** @class */ (function (_super) {
  11500. __extends(CR, _super);
  11501. function CR(ws) {
  11502. if (ws === void 0) { ws = 0; }
  11503. return _super.call(this, "\n" + new Array(ws + 1).join(' ')) || this;
  11504. }
  11505. return CR;
  11506. }(Text$2));
  11507. var _ESCAPED_CHARS = [
  11508. [/&/g, '&amp;'],
  11509. [/"/g, '&quot;'],
  11510. [/'/g, '&apos;'],
  11511. [/</g, '&lt;'],
  11512. [/>/g, '&gt;'],
  11513. ];
  11514. /**
  11515. * @param {?} text
  11516. * @return {?}
  11517. */
  11518. function escapeXml(text) {
  11519. return _ESCAPED_CHARS.reduce(function (text, entry) { return text.replace(entry[0], entry[1]); }, text);
  11520. }
  11521. /**
  11522. * @fileoverview added by tsickle
  11523. * @suppress {checkTypes} checked by tsc
  11524. */
  11525. /**
  11526. * @license
  11527. * Copyright Google Inc. All Rights Reserved.
  11528. *
  11529. * Use of this source code is governed by an MIT-style license that can be
  11530. * found in the LICENSE file at https://angular.io/license
  11531. */
  11532. var _VERSION = '1.2';
  11533. var _XMLNS = 'urn:oasis:names:tc:xliff:document:1.2';
  11534. // TODO(vicb): make this a param (s/_/-/)
  11535. var _DEFAULT_SOURCE_LANG = 'en';
  11536. var _PLACEHOLDER_TAG = 'x';
  11537. var _MARKER_TAG = 'mrk';
  11538. var _FILE_TAG = 'file';
  11539. var _SOURCE_TAG = 'source';
  11540. var _SEGMENT_SOURCE_TAG = 'seg-source';
  11541. var _TARGET_TAG = 'target';
  11542. var _UNIT_TAG = 'trans-unit';
  11543. var _CONTEXT_GROUP_TAG = 'context-group';
  11544. var _CONTEXT_TAG = 'context';
  11545. var Xliff = /** @class */ (function (_super) {
  11546. __extends(Xliff, _super);
  11547. function Xliff() {
  11548. return _super !== null && _super.apply(this, arguments) || this;
  11549. }
  11550. /**
  11551. * @param {?} messages
  11552. * @param {?} locale
  11553. * @return {?}
  11554. */
  11555. Xliff.prototype.write = /**
  11556. * @param {?} messages
  11557. * @param {?} locale
  11558. * @return {?}
  11559. */
  11560. function (messages, locale) {
  11561. var /** @type {?} */ visitor = new _WriteVisitor();
  11562. var /** @type {?} */ transUnits = [];
  11563. messages.forEach(function (message) {
  11564. var /** @type {?} */ contextTags = [];
  11565. message.sources.forEach(function (source) {
  11566. var /** @type {?} */ contextGroupTag = new Tag(_CONTEXT_GROUP_TAG, { purpose: 'location' });
  11567. contextGroupTag.children.push(new CR(10), new Tag(_CONTEXT_TAG, { 'context-type': 'sourcefile' }, [new Text$2(source.filePath)]), new CR(10), new Tag(_CONTEXT_TAG, { 'context-type': 'linenumber' }, [new Text$2("" + source.startLine)]), new CR(8));
  11568. contextTags.push(new CR(8), contextGroupTag);
  11569. });
  11570. var /** @type {?} */ transUnit = new Tag(_UNIT_TAG, { id: message.id, datatype: 'html' });
  11571. (_a = transUnit.children).push.apply(_a, [new CR(8), new Tag(_SOURCE_TAG, {}, visitor.serialize(message.nodes))].concat(contextTags));
  11572. if (message.description) {
  11573. transUnit.children.push(new CR(8), new Tag('note', { priority: '1', from: 'description' }, [new Text$2(message.description)]));
  11574. }
  11575. if (message.meaning) {
  11576. transUnit.children.push(new CR(8), new Tag('note', { priority: '1', from: 'meaning' }, [new Text$2(message.meaning)]));
  11577. }
  11578. transUnit.children.push(new CR(6));
  11579. transUnits.push(new CR(6), transUnit);
  11580. var _a;
  11581. });
  11582. var /** @type {?} */ body = new Tag('body', {}, transUnits.concat([new CR(4)]));
  11583. var /** @type {?} */ file = new Tag('file', {
  11584. 'source-language': locale || _DEFAULT_SOURCE_LANG,
  11585. datatype: 'plaintext',
  11586. original: 'ng2.template',
  11587. }, [new CR(4), body, new CR(2)]);
  11588. var /** @type {?} */ xliff = new Tag('xliff', { version: _VERSION, xmlns: _XMLNS }, [new CR(2), file, new CR()]);
  11589. return serialize([
  11590. new Declaration({ version: '1.0', encoding: 'UTF-8' }), new CR(), xliff, new CR()
  11591. ]);
  11592. };
  11593. /**
  11594. * @param {?} content
  11595. * @param {?} url
  11596. * @return {?}
  11597. */
  11598. Xliff.prototype.load = /**
  11599. * @param {?} content
  11600. * @param {?} url
  11601. * @return {?}
  11602. */
  11603. function (content, url) {
  11604. // xliff to xml nodes
  11605. var /** @type {?} */ xliffParser = new XliffParser();
  11606. var _a = xliffParser.parse(content, url), locale = _a.locale, msgIdToHtml = _a.msgIdToHtml, errors = _a.errors;
  11607. // xml nodes to i18n nodes
  11608. var /** @type {?} */ i18nNodesByMsgId = {};
  11609. var /** @type {?} */ converter = new XmlToI18n();
  11610. Object.keys(msgIdToHtml).forEach(function (msgId) {
  11611. var _a = converter.convert(msgIdToHtml[msgId], url), i18nNodes = _a.i18nNodes, e = _a.errors;
  11612. errors.push.apply(errors, e);
  11613. i18nNodesByMsgId[msgId] = i18nNodes;
  11614. });
  11615. if (errors.length) {
  11616. throw new Error("xliff parse errors:\n" + errors.join('\n'));
  11617. }
  11618. return { locale: /** @type {?} */ ((locale)), i18nNodesByMsgId: i18nNodesByMsgId };
  11619. };
  11620. /**
  11621. * @param {?} message
  11622. * @return {?}
  11623. */
  11624. Xliff.prototype.digest = /**
  11625. * @param {?} message
  11626. * @return {?}
  11627. */
  11628. function (message) { return digest(message); };
  11629. return Xliff;
  11630. }(Serializer));
  11631. var _WriteVisitor = /** @class */ (function () {
  11632. function _WriteVisitor() {
  11633. }
  11634. /**
  11635. * @param {?} text
  11636. * @param {?=} context
  11637. * @return {?}
  11638. */
  11639. _WriteVisitor.prototype.visitText = /**
  11640. * @param {?} text
  11641. * @param {?=} context
  11642. * @return {?}
  11643. */
  11644. function (text, context) { return [new Text$2(text.value)]; };
  11645. /**
  11646. * @param {?} container
  11647. * @param {?=} context
  11648. * @return {?}
  11649. */
  11650. _WriteVisitor.prototype.visitContainer = /**
  11651. * @param {?} container
  11652. * @param {?=} context
  11653. * @return {?}
  11654. */
  11655. function (container, context) {
  11656. var _this = this;
  11657. var /** @type {?} */ nodes = [];
  11658. container.children.forEach(function (node) { return nodes.push.apply(nodes, node.visit(_this)); });
  11659. return nodes;
  11660. };
  11661. /**
  11662. * @param {?} icu
  11663. * @param {?=} context
  11664. * @return {?}
  11665. */
  11666. _WriteVisitor.prototype.visitIcu = /**
  11667. * @param {?} icu
  11668. * @param {?=} context
  11669. * @return {?}
  11670. */
  11671. function (icu, context) {
  11672. var _this = this;
  11673. var /** @type {?} */ nodes = [new Text$2("{" + icu.expressionPlaceholder + ", " + icu.type + ", ")];
  11674. Object.keys(icu.cases).forEach(function (c) {
  11675. nodes.push.apply(nodes, [new Text$2(c + " {")].concat(icu.cases[c].visit(_this), [new Text$2("} ")]));
  11676. });
  11677. nodes.push(new Text$2("}"));
  11678. return nodes;
  11679. };
  11680. /**
  11681. * @param {?} ph
  11682. * @param {?=} context
  11683. * @return {?}
  11684. */
  11685. _WriteVisitor.prototype.visitTagPlaceholder = /**
  11686. * @param {?} ph
  11687. * @param {?=} context
  11688. * @return {?}
  11689. */
  11690. function (ph, context) {
  11691. var /** @type {?} */ ctype = getCtypeForTag(ph.tag);
  11692. if (ph.isVoid) {
  11693. // void tags have no children nor closing tags
  11694. return [new Tag(_PLACEHOLDER_TAG, { id: ph.startName, ctype: ctype, 'equiv-text': "<" + ph.tag + "/>" })];
  11695. }
  11696. var /** @type {?} */ startTagPh = new Tag(_PLACEHOLDER_TAG, { id: ph.startName, ctype: ctype, 'equiv-text': "<" + ph.tag + ">" });
  11697. var /** @type {?} */ closeTagPh = new Tag(_PLACEHOLDER_TAG, { id: ph.closeName, ctype: ctype, 'equiv-text': "</" + ph.tag + ">" });
  11698. return [startTagPh].concat(this.serialize(ph.children), [closeTagPh]);
  11699. };
  11700. /**
  11701. * @param {?} ph
  11702. * @param {?=} context
  11703. * @return {?}
  11704. */
  11705. _WriteVisitor.prototype.visitPlaceholder = /**
  11706. * @param {?} ph
  11707. * @param {?=} context
  11708. * @return {?}
  11709. */
  11710. function (ph, context) {
  11711. return [new Tag(_PLACEHOLDER_TAG, { id: ph.name, 'equiv-text': "{{" + ph.value + "}}" })];
  11712. };
  11713. /**
  11714. * @param {?} ph
  11715. * @param {?=} context
  11716. * @return {?}
  11717. */
  11718. _WriteVisitor.prototype.visitIcuPlaceholder = /**
  11719. * @param {?} ph
  11720. * @param {?=} context
  11721. * @return {?}
  11722. */
  11723. function (ph, context) {
  11724. var /** @type {?} */ equivText = "{" + ph.value.expression + ", " + ph.value.type + ", " + Object.keys(ph.value.cases).map(function (value) { return value + ' {...}'; }).join(' ') + "}";
  11725. return [new Tag(_PLACEHOLDER_TAG, { id: ph.name, 'equiv-text': equivText })];
  11726. };
  11727. /**
  11728. * @param {?} nodes
  11729. * @return {?}
  11730. */
  11731. _WriteVisitor.prototype.serialize = /**
  11732. * @param {?} nodes
  11733. * @return {?}
  11734. */
  11735. function (nodes) {
  11736. var _this = this;
  11737. return [].concat.apply([], nodes.map(function (node) { return node.visit(_this); }));
  11738. };
  11739. return _WriteVisitor;
  11740. }());
  11741. var XliffParser = /** @class */ (function () {
  11742. function XliffParser() {
  11743. this._locale = null;
  11744. }
  11745. /**
  11746. * @param {?} xliff
  11747. * @param {?} url
  11748. * @return {?}
  11749. */
  11750. XliffParser.prototype.parse = /**
  11751. * @param {?} xliff
  11752. * @param {?} url
  11753. * @return {?}
  11754. */
  11755. function (xliff, url) {
  11756. this._unitMlString = null;
  11757. this._msgIdToHtml = {};
  11758. var /** @type {?} */ xml = new XmlParser().parse(xliff, url, false);
  11759. this._errors = xml.errors;
  11760. visitAll(this, xml.rootNodes, null);
  11761. return {
  11762. msgIdToHtml: this._msgIdToHtml,
  11763. errors: this._errors,
  11764. locale: this._locale,
  11765. };
  11766. };
  11767. /**
  11768. * @param {?} element
  11769. * @param {?} context
  11770. * @return {?}
  11771. */
  11772. XliffParser.prototype.visitElement = /**
  11773. * @param {?} element
  11774. * @param {?} context
  11775. * @return {?}
  11776. */
  11777. function (element, context) {
  11778. switch (element.name) {
  11779. case _UNIT_TAG:
  11780. this._unitMlString = /** @type {?} */ ((null));
  11781. var /** @type {?} */ idAttr = element.attrs.find(function (attr) { return attr.name === 'id'; });
  11782. if (!idAttr) {
  11783. this._addError(element, "<" + _UNIT_TAG + "> misses the \"id\" attribute");
  11784. }
  11785. else {
  11786. var /** @type {?} */ id = idAttr.value;
  11787. if (this._msgIdToHtml.hasOwnProperty(id)) {
  11788. this._addError(element, "Duplicated translations for msg " + id);
  11789. }
  11790. else {
  11791. visitAll(this, element.children, null);
  11792. if (typeof this._unitMlString === 'string') {
  11793. this._msgIdToHtml[id] = this._unitMlString;
  11794. }
  11795. else {
  11796. this._addError(element, "Message " + id + " misses a translation");
  11797. }
  11798. }
  11799. }
  11800. break;
  11801. // ignore those tags
  11802. case _SOURCE_TAG:
  11803. case _SEGMENT_SOURCE_TAG:
  11804. break;
  11805. case _TARGET_TAG:
  11806. var /** @type {?} */ innerTextStart = /** @type {?} */ ((element.startSourceSpan)).end.offset;
  11807. var /** @type {?} */ innerTextEnd = /** @type {?} */ ((element.endSourceSpan)).start.offset;
  11808. var /** @type {?} */ content = /** @type {?} */ ((element.startSourceSpan)).start.file.content;
  11809. var /** @type {?} */ innerText = content.slice(innerTextStart, innerTextEnd);
  11810. this._unitMlString = innerText;
  11811. break;
  11812. case _FILE_TAG:
  11813. var /** @type {?} */ localeAttr = element.attrs.find(function (attr) { return attr.name === 'target-language'; });
  11814. if (localeAttr) {
  11815. this._locale = localeAttr.value;
  11816. }
  11817. visitAll(this, element.children, null);
  11818. break;
  11819. default:
  11820. // TODO(vicb): assert file structure, xliff version
  11821. // For now only recurse on unhandled nodes
  11822. visitAll(this, element.children, null);
  11823. }
  11824. };
  11825. /**
  11826. * @param {?} attribute
  11827. * @param {?} context
  11828. * @return {?}
  11829. */
  11830. XliffParser.prototype.visitAttribute = /**
  11831. * @param {?} attribute
  11832. * @param {?} context
  11833. * @return {?}
  11834. */
  11835. function (attribute, context) { };
  11836. /**
  11837. * @param {?} text
  11838. * @param {?} context
  11839. * @return {?}
  11840. */
  11841. XliffParser.prototype.visitText = /**
  11842. * @param {?} text
  11843. * @param {?} context
  11844. * @return {?}
  11845. */
  11846. function (text, context) { };
  11847. /**
  11848. * @param {?} comment
  11849. * @param {?} context
  11850. * @return {?}
  11851. */
  11852. XliffParser.prototype.visitComment = /**
  11853. * @param {?} comment
  11854. * @param {?} context
  11855. * @return {?}
  11856. */
  11857. function (comment, context) { };
  11858. /**
  11859. * @param {?} expansion
  11860. * @param {?} context
  11861. * @return {?}
  11862. */
  11863. XliffParser.prototype.visitExpansion = /**
  11864. * @param {?} expansion
  11865. * @param {?} context
  11866. * @return {?}
  11867. */
  11868. function (expansion, context) { };
  11869. /**
  11870. * @param {?} expansionCase
  11871. * @param {?} context
  11872. * @return {?}
  11873. */
  11874. XliffParser.prototype.visitExpansionCase = /**
  11875. * @param {?} expansionCase
  11876. * @param {?} context
  11877. * @return {?}
  11878. */
  11879. function (expansionCase, context) { };
  11880. /**
  11881. * @param {?} node
  11882. * @param {?} message
  11883. * @return {?}
  11884. */
  11885. XliffParser.prototype._addError = /**
  11886. * @param {?} node
  11887. * @param {?} message
  11888. * @return {?}
  11889. */
  11890. function (node, message) {
  11891. this._errors.push(new I18nError(/** @type {?} */ ((node.sourceSpan)), message));
  11892. };
  11893. return XliffParser;
  11894. }());
  11895. var XmlToI18n = /** @class */ (function () {
  11896. function XmlToI18n() {
  11897. }
  11898. /**
  11899. * @param {?} message
  11900. * @param {?} url
  11901. * @return {?}
  11902. */
  11903. XmlToI18n.prototype.convert = /**
  11904. * @param {?} message
  11905. * @param {?} url
  11906. * @return {?}
  11907. */
  11908. function (message, url) {
  11909. var /** @type {?} */ xmlIcu = new XmlParser().parse(message, url, true);
  11910. this._errors = xmlIcu.errors;
  11911. var /** @type {?} */ i18nNodes = this._errors.length > 0 || xmlIcu.rootNodes.length == 0 ?
  11912. [] : [].concat.apply([], visitAll(this, xmlIcu.rootNodes));
  11913. return {
  11914. i18nNodes: i18nNodes,
  11915. errors: this._errors,
  11916. };
  11917. };
  11918. /**
  11919. * @param {?} text
  11920. * @param {?} context
  11921. * @return {?}
  11922. */
  11923. XmlToI18n.prototype.visitText = /**
  11924. * @param {?} text
  11925. * @param {?} context
  11926. * @return {?}
  11927. */
  11928. function (text, context) { return new Text$1(text.value, /** @type {?} */ ((text.sourceSpan))); };
  11929. /**
  11930. * @param {?} el
  11931. * @param {?} context
  11932. * @return {?}
  11933. */
  11934. XmlToI18n.prototype.visitElement = /**
  11935. * @param {?} el
  11936. * @param {?} context
  11937. * @return {?}
  11938. */
  11939. function (el, context) {
  11940. if (el.name === _PLACEHOLDER_TAG) {
  11941. var /** @type {?} */ nameAttr = el.attrs.find(function (attr) { return attr.name === 'id'; });
  11942. if (nameAttr) {
  11943. return new Placeholder('', nameAttr.value, /** @type {?} */ ((el.sourceSpan)));
  11944. }
  11945. this._addError(el, "<" + _PLACEHOLDER_TAG + "> misses the \"id\" attribute");
  11946. return null;
  11947. }
  11948. if (el.name === _MARKER_TAG) {
  11949. return [].concat.apply([], visitAll(this, el.children));
  11950. }
  11951. this._addError(el, "Unexpected tag");
  11952. return null;
  11953. };
  11954. /**
  11955. * @param {?} icu
  11956. * @param {?} context
  11957. * @return {?}
  11958. */
  11959. XmlToI18n.prototype.visitExpansion = /**
  11960. * @param {?} icu
  11961. * @param {?} context
  11962. * @return {?}
  11963. */
  11964. function (icu, context) {
  11965. var /** @type {?} */ caseMap = {};
  11966. visitAll(this, icu.cases).forEach(function (c) {
  11967. caseMap[c.value] = new Container(c.nodes, icu.sourceSpan);
  11968. });
  11969. return new Icu(icu.switchValue, icu.type, caseMap, icu.sourceSpan);
  11970. };
  11971. /**
  11972. * @param {?} icuCase
  11973. * @param {?} context
  11974. * @return {?}
  11975. */
  11976. XmlToI18n.prototype.visitExpansionCase = /**
  11977. * @param {?} icuCase
  11978. * @param {?} context
  11979. * @return {?}
  11980. */
  11981. function (icuCase, context) {
  11982. return {
  11983. value: icuCase.value,
  11984. nodes: visitAll(this, icuCase.expression),
  11985. };
  11986. };
  11987. /**
  11988. * @param {?} comment
  11989. * @param {?} context
  11990. * @return {?}
  11991. */
  11992. XmlToI18n.prototype.visitComment = /**
  11993. * @param {?} comment
  11994. * @param {?} context
  11995. * @return {?}
  11996. */
  11997. function (comment, context) { };
  11998. /**
  11999. * @param {?} attribute
  12000. * @param {?} context
  12001. * @return {?}
  12002. */
  12003. XmlToI18n.prototype.visitAttribute = /**
  12004. * @param {?} attribute
  12005. * @param {?} context
  12006. * @return {?}
  12007. */
  12008. function (attribute, context) { };
  12009. /**
  12010. * @param {?} node
  12011. * @param {?} message
  12012. * @return {?}
  12013. */
  12014. XmlToI18n.prototype._addError = /**
  12015. * @param {?} node
  12016. * @param {?} message
  12017. * @return {?}
  12018. */
  12019. function (node, message) {
  12020. this._errors.push(new I18nError(/** @type {?} */ ((node.sourceSpan)), message));
  12021. };
  12022. return XmlToI18n;
  12023. }());
  12024. /**
  12025. * @param {?} tag
  12026. * @return {?}
  12027. */
  12028. function getCtypeForTag(tag) {
  12029. switch (tag.toLowerCase()) {
  12030. case 'br':
  12031. return 'lb';
  12032. case 'img':
  12033. return 'image';
  12034. default:
  12035. return "x-" + tag;
  12036. }
  12037. }
  12038. /**
  12039. * @fileoverview added by tsickle
  12040. * @suppress {checkTypes} checked by tsc
  12041. */
  12042. /**
  12043. * @license
  12044. * Copyright Google Inc. All Rights Reserved.
  12045. *
  12046. * Use of this source code is governed by an MIT-style license that can be
  12047. * found in the LICENSE file at https://angular.io/license
  12048. */
  12049. var _VERSION$1 = '2.0';
  12050. var _XMLNS$1 = 'urn:oasis:names:tc:xliff:document:2.0';
  12051. // TODO(vicb): make this a param (s/_/-/)
  12052. var _DEFAULT_SOURCE_LANG$1 = 'en';
  12053. var _PLACEHOLDER_TAG$1 = 'ph';
  12054. var _PLACEHOLDER_SPANNING_TAG = 'pc';
  12055. var _MARKER_TAG$1 = 'mrk';
  12056. var _XLIFF_TAG = 'xliff';
  12057. var _SOURCE_TAG$1 = 'source';
  12058. var _TARGET_TAG$1 = 'target';
  12059. var _UNIT_TAG$1 = 'unit';
  12060. var Xliff2 = /** @class */ (function (_super) {
  12061. __extends(Xliff2, _super);
  12062. function Xliff2() {
  12063. return _super !== null && _super.apply(this, arguments) || this;
  12064. }
  12065. /**
  12066. * @param {?} messages
  12067. * @param {?} locale
  12068. * @return {?}
  12069. */
  12070. Xliff2.prototype.write = /**
  12071. * @param {?} messages
  12072. * @param {?} locale
  12073. * @return {?}
  12074. */
  12075. function (messages, locale) {
  12076. var /** @type {?} */ visitor = new _WriteVisitor$1();
  12077. var /** @type {?} */ units = [];
  12078. messages.forEach(function (message) {
  12079. var /** @type {?} */ unit = new Tag(_UNIT_TAG$1, { id: message.id });
  12080. var /** @type {?} */ notes = new Tag('notes');
  12081. if (message.description || message.meaning) {
  12082. if (message.description) {
  12083. notes.children.push(new CR(8), new Tag('note', { category: 'description' }, [new Text$2(message.description)]));
  12084. }
  12085. if (message.meaning) {
  12086. notes.children.push(new CR(8), new Tag('note', { category: 'meaning' }, [new Text$2(message.meaning)]));
  12087. }
  12088. }
  12089. message.sources.forEach(function (source) {
  12090. notes.children.push(new CR(8), new Tag('note', { category: 'location' }, [
  12091. new Text$2(source.filePath + ":" + source.startLine + (source.endLine !== source.startLine ? ',' + source.endLine : ''))
  12092. ]));
  12093. });
  12094. notes.children.push(new CR(6));
  12095. unit.children.push(new CR(6), notes);
  12096. var /** @type {?} */ segment = new Tag('segment');
  12097. segment.children.push(new CR(8), new Tag(_SOURCE_TAG$1, {}, visitor.serialize(message.nodes)), new CR(6));
  12098. unit.children.push(new CR(6), segment, new CR(4));
  12099. units.push(new CR(4), unit);
  12100. });
  12101. var /** @type {?} */ file = new Tag('file', { 'original': 'ng.template', id: 'ngi18n' }, units.concat([new CR(2)]));
  12102. var /** @type {?} */ xliff = new Tag(_XLIFF_TAG, { version: _VERSION$1, xmlns: _XMLNS$1, srcLang: locale || _DEFAULT_SOURCE_LANG$1 }, [new CR(2), file, new CR()]);
  12103. return serialize([
  12104. new Declaration({ version: '1.0', encoding: 'UTF-8' }), new CR(), xliff, new CR()
  12105. ]);
  12106. };
  12107. /**
  12108. * @param {?} content
  12109. * @param {?} url
  12110. * @return {?}
  12111. */
  12112. Xliff2.prototype.load = /**
  12113. * @param {?} content
  12114. * @param {?} url
  12115. * @return {?}
  12116. */
  12117. function (content, url) {
  12118. // xliff to xml nodes
  12119. var /** @type {?} */ xliff2Parser = new Xliff2Parser();
  12120. var _a = xliff2Parser.parse(content, url), locale = _a.locale, msgIdToHtml = _a.msgIdToHtml, errors = _a.errors;
  12121. // xml nodes to i18n nodes
  12122. var /** @type {?} */ i18nNodesByMsgId = {};
  12123. var /** @type {?} */ converter = new XmlToI18n$1();
  12124. Object.keys(msgIdToHtml).forEach(function (msgId) {
  12125. var _a = converter.convert(msgIdToHtml[msgId], url), i18nNodes = _a.i18nNodes, e = _a.errors;
  12126. errors.push.apply(errors, e);
  12127. i18nNodesByMsgId[msgId] = i18nNodes;
  12128. });
  12129. if (errors.length) {
  12130. throw new Error("xliff2 parse errors:\n" + errors.join('\n'));
  12131. }
  12132. return { locale: /** @type {?} */ ((locale)), i18nNodesByMsgId: i18nNodesByMsgId };
  12133. };
  12134. /**
  12135. * @param {?} message
  12136. * @return {?}
  12137. */
  12138. Xliff2.prototype.digest = /**
  12139. * @param {?} message
  12140. * @return {?}
  12141. */
  12142. function (message) { return decimalDigest(message); };
  12143. return Xliff2;
  12144. }(Serializer));
  12145. var _WriteVisitor$1 = /** @class */ (function () {
  12146. function _WriteVisitor() {
  12147. }
  12148. /**
  12149. * @param {?} text
  12150. * @param {?=} context
  12151. * @return {?}
  12152. */
  12153. _WriteVisitor.prototype.visitText = /**
  12154. * @param {?} text
  12155. * @param {?=} context
  12156. * @return {?}
  12157. */
  12158. function (text, context) { return [new Text$2(text.value)]; };
  12159. /**
  12160. * @param {?} container
  12161. * @param {?=} context
  12162. * @return {?}
  12163. */
  12164. _WriteVisitor.prototype.visitContainer = /**
  12165. * @param {?} container
  12166. * @param {?=} context
  12167. * @return {?}
  12168. */
  12169. function (container, context) {
  12170. var _this = this;
  12171. var /** @type {?} */ nodes = [];
  12172. container.children.forEach(function (node) { return nodes.push.apply(nodes, node.visit(_this)); });
  12173. return nodes;
  12174. };
  12175. /**
  12176. * @param {?} icu
  12177. * @param {?=} context
  12178. * @return {?}
  12179. */
  12180. _WriteVisitor.prototype.visitIcu = /**
  12181. * @param {?} icu
  12182. * @param {?=} context
  12183. * @return {?}
  12184. */
  12185. function (icu, context) {
  12186. var _this = this;
  12187. var /** @type {?} */ nodes = [new Text$2("{" + icu.expressionPlaceholder + ", " + icu.type + ", ")];
  12188. Object.keys(icu.cases).forEach(function (c) {
  12189. nodes.push.apply(nodes, [new Text$2(c + " {")].concat(icu.cases[c].visit(_this), [new Text$2("} ")]));
  12190. });
  12191. nodes.push(new Text$2("}"));
  12192. return nodes;
  12193. };
  12194. /**
  12195. * @param {?} ph
  12196. * @param {?=} context
  12197. * @return {?}
  12198. */
  12199. _WriteVisitor.prototype.visitTagPlaceholder = /**
  12200. * @param {?} ph
  12201. * @param {?=} context
  12202. * @return {?}
  12203. */
  12204. function (ph, context) {
  12205. var _this = this;
  12206. var /** @type {?} */ type = getTypeForTag(ph.tag);
  12207. if (ph.isVoid) {
  12208. var /** @type {?} */ tagPh = new Tag(_PLACEHOLDER_TAG$1, {
  12209. id: (this._nextPlaceholderId++).toString(),
  12210. equiv: ph.startName,
  12211. type: type,
  12212. disp: "<" + ph.tag + "/>",
  12213. });
  12214. return [tagPh];
  12215. }
  12216. var /** @type {?} */ tagPc = new Tag(_PLACEHOLDER_SPANNING_TAG, {
  12217. id: (this._nextPlaceholderId++).toString(),
  12218. equivStart: ph.startName,
  12219. equivEnd: ph.closeName,
  12220. type: type,
  12221. dispStart: "<" + ph.tag + ">",
  12222. dispEnd: "</" + ph.tag + ">",
  12223. });
  12224. var /** @type {?} */ nodes = [].concat.apply([], ph.children.map(function (node) { return node.visit(_this); }));
  12225. if (nodes.length) {
  12226. nodes.forEach(function (node) { return tagPc.children.push(node); });
  12227. }
  12228. else {
  12229. tagPc.children.push(new Text$2(''));
  12230. }
  12231. return [tagPc];
  12232. };
  12233. /**
  12234. * @param {?} ph
  12235. * @param {?=} context
  12236. * @return {?}
  12237. */
  12238. _WriteVisitor.prototype.visitPlaceholder = /**
  12239. * @param {?} ph
  12240. * @param {?=} context
  12241. * @return {?}
  12242. */
  12243. function (ph, context) {
  12244. var /** @type {?} */ idStr = (this._nextPlaceholderId++).toString();
  12245. return [new Tag(_PLACEHOLDER_TAG$1, {
  12246. id: idStr,
  12247. equiv: ph.name,
  12248. disp: "{{" + ph.value + "}}",
  12249. })];
  12250. };
  12251. /**
  12252. * @param {?} ph
  12253. * @param {?=} context
  12254. * @return {?}
  12255. */
  12256. _WriteVisitor.prototype.visitIcuPlaceholder = /**
  12257. * @param {?} ph
  12258. * @param {?=} context
  12259. * @return {?}
  12260. */
  12261. function (ph, context) {
  12262. var /** @type {?} */ cases = Object.keys(ph.value.cases).map(function (value) { return value + ' {...}'; }).join(' ');
  12263. var /** @type {?} */ idStr = (this._nextPlaceholderId++).toString();
  12264. return [new Tag(_PLACEHOLDER_TAG$1, { id: idStr, equiv: ph.name, disp: "{" + ph.value.expression + ", " + ph.value.type + ", " + cases + "}" })];
  12265. };
  12266. /**
  12267. * @param {?} nodes
  12268. * @return {?}
  12269. */
  12270. _WriteVisitor.prototype.serialize = /**
  12271. * @param {?} nodes
  12272. * @return {?}
  12273. */
  12274. function (nodes) {
  12275. var _this = this;
  12276. this._nextPlaceholderId = 0;
  12277. return [].concat.apply([], nodes.map(function (node) { return node.visit(_this); }));
  12278. };
  12279. return _WriteVisitor;
  12280. }());
  12281. var Xliff2Parser = /** @class */ (function () {
  12282. function Xliff2Parser() {
  12283. this._locale = null;
  12284. }
  12285. /**
  12286. * @param {?} xliff
  12287. * @param {?} url
  12288. * @return {?}
  12289. */
  12290. Xliff2Parser.prototype.parse = /**
  12291. * @param {?} xliff
  12292. * @param {?} url
  12293. * @return {?}
  12294. */
  12295. function (xliff, url) {
  12296. this._unitMlString = null;
  12297. this._msgIdToHtml = {};
  12298. var /** @type {?} */ xml = new XmlParser().parse(xliff, url, false);
  12299. this._errors = xml.errors;
  12300. visitAll(this, xml.rootNodes, null);
  12301. return {
  12302. msgIdToHtml: this._msgIdToHtml,
  12303. errors: this._errors,
  12304. locale: this._locale,
  12305. };
  12306. };
  12307. /**
  12308. * @param {?} element
  12309. * @param {?} context
  12310. * @return {?}
  12311. */
  12312. Xliff2Parser.prototype.visitElement = /**
  12313. * @param {?} element
  12314. * @param {?} context
  12315. * @return {?}
  12316. */
  12317. function (element, context) {
  12318. switch (element.name) {
  12319. case _UNIT_TAG$1:
  12320. this._unitMlString = null;
  12321. var /** @type {?} */ idAttr = element.attrs.find(function (attr) { return attr.name === 'id'; });
  12322. if (!idAttr) {
  12323. this._addError(element, "<" + _UNIT_TAG$1 + "> misses the \"id\" attribute");
  12324. }
  12325. else {
  12326. var /** @type {?} */ id = idAttr.value;
  12327. if (this._msgIdToHtml.hasOwnProperty(id)) {
  12328. this._addError(element, "Duplicated translations for msg " + id);
  12329. }
  12330. else {
  12331. visitAll(this, element.children, null);
  12332. if (typeof this._unitMlString === 'string') {
  12333. this._msgIdToHtml[id] = this._unitMlString;
  12334. }
  12335. else {
  12336. this._addError(element, "Message " + id + " misses a translation");
  12337. }
  12338. }
  12339. }
  12340. break;
  12341. case _SOURCE_TAG$1:
  12342. // ignore source message
  12343. break;
  12344. case _TARGET_TAG$1:
  12345. var /** @type {?} */ innerTextStart = /** @type {?} */ ((element.startSourceSpan)).end.offset;
  12346. var /** @type {?} */ innerTextEnd = /** @type {?} */ ((element.endSourceSpan)).start.offset;
  12347. var /** @type {?} */ content = /** @type {?} */ ((element.startSourceSpan)).start.file.content;
  12348. var /** @type {?} */ innerText = content.slice(innerTextStart, innerTextEnd);
  12349. this._unitMlString = innerText;
  12350. break;
  12351. case _XLIFF_TAG:
  12352. var /** @type {?} */ localeAttr = element.attrs.find(function (attr) { return attr.name === 'trgLang'; });
  12353. if (localeAttr) {
  12354. this._locale = localeAttr.value;
  12355. }
  12356. var /** @type {?} */ versionAttr = element.attrs.find(function (attr) { return attr.name === 'version'; });
  12357. if (versionAttr) {
  12358. var /** @type {?} */ version = versionAttr.value;
  12359. if (version !== '2.0') {
  12360. this._addError(element, "The XLIFF file version " + version + " is not compatible with XLIFF 2.0 serializer");
  12361. }
  12362. else {
  12363. visitAll(this, element.children, null);
  12364. }
  12365. }
  12366. break;
  12367. default:
  12368. visitAll(this, element.children, null);
  12369. }
  12370. };
  12371. /**
  12372. * @param {?} attribute
  12373. * @param {?} context
  12374. * @return {?}
  12375. */
  12376. Xliff2Parser.prototype.visitAttribute = /**
  12377. * @param {?} attribute
  12378. * @param {?} context
  12379. * @return {?}
  12380. */
  12381. function (attribute, context) { };
  12382. /**
  12383. * @param {?} text
  12384. * @param {?} context
  12385. * @return {?}
  12386. */
  12387. Xliff2Parser.prototype.visitText = /**
  12388. * @param {?} text
  12389. * @param {?} context
  12390. * @return {?}
  12391. */
  12392. function (text, context) { };
  12393. /**
  12394. * @param {?} comment
  12395. * @param {?} context
  12396. * @return {?}
  12397. */
  12398. Xliff2Parser.prototype.visitComment = /**
  12399. * @param {?} comment
  12400. * @param {?} context
  12401. * @return {?}
  12402. */
  12403. function (comment, context) { };
  12404. /**
  12405. * @param {?} expansion
  12406. * @param {?} context
  12407. * @return {?}
  12408. */
  12409. Xliff2Parser.prototype.visitExpansion = /**
  12410. * @param {?} expansion
  12411. * @param {?} context
  12412. * @return {?}
  12413. */
  12414. function (expansion, context) { };
  12415. /**
  12416. * @param {?} expansionCase
  12417. * @param {?} context
  12418. * @return {?}
  12419. */
  12420. Xliff2Parser.prototype.visitExpansionCase = /**
  12421. * @param {?} expansionCase
  12422. * @param {?} context
  12423. * @return {?}
  12424. */
  12425. function (expansionCase, context) { };
  12426. /**
  12427. * @param {?} node
  12428. * @param {?} message
  12429. * @return {?}
  12430. */
  12431. Xliff2Parser.prototype._addError = /**
  12432. * @param {?} node
  12433. * @param {?} message
  12434. * @return {?}
  12435. */
  12436. function (node, message) {
  12437. this._errors.push(new I18nError(node.sourceSpan, message));
  12438. };
  12439. return Xliff2Parser;
  12440. }());
  12441. var XmlToI18n$1 = /** @class */ (function () {
  12442. function XmlToI18n() {
  12443. }
  12444. /**
  12445. * @param {?} message
  12446. * @param {?} url
  12447. * @return {?}
  12448. */
  12449. XmlToI18n.prototype.convert = /**
  12450. * @param {?} message
  12451. * @param {?} url
  12452. * @return {?}
  12453. */
  12454. function (message, url) {
  12455. var /** @type {?} */ xmlIcu = new XmlParser().parse(message, url, true);
  12456. this._errors = xmlIcu.errors;
  12457. var /** @type {?} */ i18nNodes = this._errors.length > 0 || xmlIcu.rootNodes.length == 0 ?
  12458. [] : [].concat.apply([], visitAll(this, xmlIcu.rootNodes));
  12459. return {
  12460. i18nNodes: i18nNodes,
  12461. errors: this._errors,
  12462. };
  12463. };
  12464. /**
  12465. * @param {?} text
  12466. * @param {?} context
  12467. * @return {?}
  12468. */
  12469. XmlToI18n.prototype.visitText = /**
  12470. * @param {?} text
  12471. * @param {?} context
  12472. * @return {?}
  12473. */
  12474. function (text, context) { return new Text$1(text.value, text.sourceSpan); };
  12475. /**
  12476. * @param {?} el
  12477. * @param {?} context
  12478. * @return {?}
  12479. */
  12480. XmlToI18n.prototype.visitElement = /**
  12481. * @param {?} el
  12482. * @param {?} context
  12483. * @return {?}
  12484. */
  12485. function (el, context) {
  12486. var _this = this;
  12487. switch (el.name) {
  12488. case _PLACEHOLDER_TAG$1:
  12489. var /** @type {?} */ nameAttr = el.attrs.find(function (attr) { return attr.name === 'equiv'; });
  12490. if (nameAttr) {
  12491. return [new Placeholder('', nameAttr.value, el.sourceSpan)];
  12492. }
  12493. this._addError(el, "<" + _PLACEHOLDER_TAG$1 + "> misses the \"equiv\" attribute");
  12494. break;
  12495. case _PLACEHOLDER_SPANNING_TAG:
  12496. var /** @type {?} */ startAttr = el.attrs.find(function (attr) { return attr.name === 'equivStart'; });
  12497. var /** @type {?} */ endAttr = el.attrs.find(function (attr) { return attr.name === 'equivEnd'; });
  12498. if (!startAttr) {
  12499. this._addError(el, "<" + _PLACEHOLDER_TAG$1 + "> misses the \"equivStart\" attribute");
  12500. }
  12501. else if (!endAttr) {
  12502. this._addError(el, "<" + _PLACEHOLDER_TAG$1 + "> misses the \"equivEnd\" attribute");
  12503. }
  12504. else {
  12505. var /** @type {?} */ startId = startAttr.value;
  12506. var /** @type {?} */ endId = endAttr.value;
  12507. var /** @type {?} */ nodes = [];
  12508. return nodes.concat.apply(nodes, [new Placeholder('', startId, el.sourceSpan)].concat(el.children.map(function (node) { return node.visit(_this, null); }), [new Placeholder('', endId, el.sourceSpan)]));
  12509. }
  12510. break;
  12511. case _MARKER_TAG$1:
  12512. return [].concat.apply([], visitAll(this, el.children));
  12513. default:
  12514. this._addError(el, "Unexpected tag");
  12515. }
  12516. return null;
  12517. };
  12518. /**
  12519. * @param {?} icu
  12520. * @param {?} context
  12521. * @return {?}
  12522. */
  12523. XmlToI18n.prototype.visitExpansion = /**
  12524. * @param {?} icu
  12525. * @param {?} context
  12526. * @return {?}
  12527. */
  12528. function (icu, context) {
  12529. var /** @type {?} */ caseMap = {};
  12530. visitAll(this, icu.cases).forEach(function (c) {
  12531. caseMap[c.value] = new Container(c.nodes, icu.sourceSpan);
  12532. });
  12533. return new Icu(icu.switchValue, icu.type, caseMap, icu.sourceSpan);
  12534. };
  12535. /**
  12536. * @param {?} icuCase
  12537. * @param {?} context
  12538. * @return {?}
  12539. */
  12540. XmlToI18n.prototype.visitExpansionCase = /**
  12541. * @param {?} icuCase
  12542. * @param {?} context
  12543. * @return {?}
  12544. */
  12545. function (icuCase, context) {
  12546. return {
  12547. value: icuCase.value,
  12548. nodes: [].concat.apply([], visitAll(this, icuCase.expression)),
  12549. };
  12550. };
  12551. /**
  12552. * @param {?} comment
  12553. * @param {?} context
  12554. * @return {?}
  12555. */
  12556. XmlToI18n.prototype.visitComment = /**
  12557. * @param {?} comment
  12558. * @param {?} context
  12559. * @return {?}
  12560. */
  12561. function (comment, context) { };
  12562. /**
  12563. * @param {?} attribute
  12564. * @param {?} context
  12565. * @return {?}
  12566. */
  12567. XmlToI18n.prototype.visitAttribute = /**
  12568. * @param {?} attribute
  12569. * @param {?} context
  12570. * @return {?}
  12571. */
  12572. function (attribute, context) { };
  12573. /**
  12574. * @param {?} node
  12575. * @param {?} message
  12576. * @return {?}
  12577. */
  12578. XmlToI18n.prototype._addError = /**
  12579. * @param {?} node
  12580. * @param {?} message
  12581. * @return {?}
  12582. */
  12583. function (node, message) {
  12584. this._errors.push(new I18nError(node.sourceSpan, message));
  12585. };
  12586. return XmlToI18n;
  12587. }());
  12588. /**
  12589. * @param {?} tag
  12590. * @return {?}
  12591. */
  12592. function getTypeForTag(tag) {
  12593. switch (tag.toLowerCase()) {
  12594. case 'br':
  12595. case 'b':
  12596. case 'i':
  12597. case 'u':
  12598. return 'fmt';
  12599. case 'img':
  12600. return 'image';
  12601. case 'a':
  12602. return 'link';
  12603. default:
  12604. return 'other';
  12605. }
  12606. }
  12607. /**
  12608. * @fileoverview added by tsickle
  12609. * @suppress {checkTypes} checked by tsc
  12610. */
  12611. /**
  12612. * @license
  12613. * Copyright Google Inc. All Rights Reserved.
  12614. *
  12615. * Use of this source code is governed by an MIT-style license that can be
  12616. * found in the LICENSE file at https://angular.io/license
  12617. */
  12618. var _MESSAGES_TAG = 'messagebundle';
  12619. var _MESSAGE_TAG = 'msg';
  12620. var _PLACEHOLDER_TAG$2 = 'ph';
  12621. var _EXEMPLE_TAG = 'ex';
  12622. var _SOURCE_TAG$2 = 'source';
  12623. var _DOCTYPE = "<!ELEMENT messagebundle (msg)*>\n<!ATTLIST messagebundle class CDATA #IMPLIED>\n\n<!ELEMENT msg (#PCDATA|ph|source)*>\n<!ATTLIST msg id CDATA #IMPLIED>\n<!ATTLIST msg seq CDATA #IMPLIED>\n<!ATTLIST msg name CDATA #IMPLIED>\n<!ATTLIST msg desc CDATA #IMPLIED>\n<!ATTLIST msg meaning CDATA #IMPLIED>\n<!ATTLIST msg obsolete (obsolete) #IMPLIED>\n<!ATTLIST msg xml:space (default|preserve) \"default\">\n<!ATTLIST msg is_hidden CDATA #IMPLIED>\n\n<!ELEMENT source (#PCDATA)>\n\n<!ELEMENT ph (#PCDATA|ex)*>\n<!ATTLIST ph name CDATA #REQUIRED>\n\n<!ELEMENT ex (#PCDATA)>";
  12624. var Xmb = /** @class */ (function (_super) {
  12625. __extends(Xmb, _super);
  12626. function Xmb() {
  12627. return _super !== null && _super.apply(this, arguments) || this;
  12628. }
  12629. /**
  12630. * @param {?} messages
  12631. * @param {?} locale
  12632. * @return {?}
  12633. */
  12634. Xmb.prototype.write = /**
  12635. * @param {?} messages
  12636. * @param {?} locale
  12637. * @return {?}
  12638. */
  12639. function (messages, locale) {
  12640. var /** @type {?} */ exampleVisitor = new ExampleVisitor();
  12641. var /** @type {?} */ visitor = new _Visitor$2();
  12642. var /** @type {?} */ rootNode = new Tag(_MESSAGES_TAG);
  12643. messages.forEach(function (message) {
  12644. var /** @type {?} */ attrs = { id: message.id };
  12645. if (message.description) {
  12646. attrs['desc'] = message.description;
  12647. }
  12648. if (message.meaning) {
  12649. attrs['meaning'] = message.meaning;
  12650. }
  12651. var /** @type {?} */ sourceTags = [];
  12652. message.sources.forEach(function (source) {
  12653. sourceTags.push(new Tag(_SOURCE_TAG$2, {}, [
  12654. new Text$2(source.filePath + ":" + source.startLine + (source.endLine !== source.startLine ? ',' + source.endLine : ''))
  12655. ]));
  12656. });
  12657. rootNode.children.push(new CR(2), new Tag(_MESSAGE_TAG, attrs, sourceTags.concat(visitor.serialize(message.nodes))));
  12658. });
  12659. rootNode.children.push(new CR());
  12660. return serialize([
  12661. new Declaration({ version: '1.0', encoding: 'UTF-8' }),
  12662. new CR(),
  12663. new Doctype(_MESSAGES_TAG, _DOCTYPE),
  12664. new CR(),
  12665. exampleVisitor.addDefaultExamples(rootNode),
  12666. new CR(),
  12667. ]);
  12668. };
  12669. /**
  12670. * @param {?} content
  12671. * @param {?} url
  12672. * @return {?}
  12673. */
  12674. Xmb.prototype.load = /**
  12675. * @param {?} content
  12676. * @param {?} url
  12677. * @return {?}
  12678. */
  12679. function (content, url) {
  12680. throw new Error('Unsupported');
  12681. };
  12682. /**
  12683. * @param {?} message
  12684. * @return {?}
  12685. */
  12686. Xmb.prototype.digest = /**
  12687. * @param {?} message
  12688. * @return {?}
  12689. */
  12690. function (message) { return digest$1(message); };
  12691. /**
  12692. * @param {?} message
  12693. * @return {?}
  12694. */
  12695. Xmb.prototype.createNameMapper = /**
  12696. * @param {?} message
  12697. * @return {?}
  12698. */
  12699. function (message) {
  12700. return new SimplePlaceholderMapper(message, toPublicName);
  12701. };
  12702. return Xmb;
  12703. }(Serializer));
  12704. var _Visitor$2 = /** @class */ (function () {
  12705. function _Visitor() {
  12706. }
  12707. /**
  12708. * @param {?} text
  12709. * @param {?=} context
  12710. * @return {?}
  12711. */
  12712. _Visitor.prototype.visitText = /**
  12713. * @param {?} text
  12714. * @param {?=} context
  12715. * @return {?}
  12716. */
  12717. function (text, context) { return [new Text$2(text.value)]; };
  12718. /**
  12719. * @param {?} container
  12720. * @param {?} context
  12721. * @return {?}
  12722. */
  12723. _Visitor.prototype.visitContainer = /**
  12724. * @param {?} container
  12725. * @param {?} context
  12726. * @return {?}
  12727. */
  12728. function (container, context) {
  12729. var _this = this;
  12730. var /** @type {?} */ nodes = [];
  12731. container.children.forEach(function (node) { return nodes.push.apply(nodes, node.visit(_this)); });
  12732. return nodes;
  12733. };
  12734. /**
  12735. * @param {?} icu
  12736. * @param {?=} context
  12737. * @return {?}
  12738. */
  12739. _Visitor.prototype.visitIcu = /**
  12740. * @param {?} icu
  12741. * @param {?=} context
  12742. * @return {?}
  12743. */
  12744. function (icu, context) {
  12745. var _this = this;
  12746. var /** @type {?} */ nodes = [new Text$2("{" + icu.expressionPlaceholder + ", " + icu.type + ", ")];
  12747. Object.keys(icu.cases).forEach(function (c) {
  12748. nodes.push.apply(nodes, [new Text$2(c + " {")].concat(icu.cases[c].visit(_this), [new Text$2("} ")]));
  12749. });
  12750. nodes.push(new Text$2("}"));
  12751. return nodes;
  12752. };
  12753. /**
  12754. * @param {?} ph
  12755. * @param {?=} context
  12756. * @return {?}
  12757. */
  12758. _Visitor.prototype.visitTagPlaceholder = /**
  12759. * @param {?} ph
  12760. * @param {?=} context
  12761. * @return {?}
  12762. */
  12763. function (ph, context) {
  12764. var /** @type {?} */ startEx = new Tag(_EXEMPLE_TAG, {}, [new Text$2("<" + ph.tag + ">")]);
  12765. var /** @type {?} */ startTagPh = new Tag(_PLACEHOLDER_TAG$2, { name: ph.startName }, [startEx]);
  12766. if (ph.isVoid) {
  12767. // void tags have no children nor closing tags
  12768. return [startTagPh];
  12769. }
  12770. var /** @type {?} */ closeEx = new Tag(_EXEMPLE_TAG, {}, [new Text$2("</" + ph.tag + ">")]);
  12771. var /** @type {?} */ closeTagPh = new Tag(_PLACEHOLDER_TAG$2, { name: ph.closeName }, [closeEx]);
  12772. return [startTagPh].concat(this.serialize(ph.children), [closeTagPh]);
  12773. };
  12774. /**
  12775. * @param {?} ph
  12776. * @param {?=} context
  12777. * @return {?}
  12778. */
  12779. _Visitor.prototype.visitPlaceholder = /**
  12780. * @param {?} ph
  12781. * @param {?=} context
  12782. * @return {?}
  12783. */
  12784. function (ph, context) {
  12785. var /** @type {?} */ exTag = new Tag(_EXEMPLE_TAG, {}, [new Text$2("{{" + ph.value + "}}")]);
  12786. return [new Tag(_PLACEHOLDER_TAG$2, { name: ph.name }, [exTag])];
  12787. };
  12788. /**
  12789. * @param {?} ph
  12790. * @param {?=} context
  12791. * @return {?}
  12792. */
  12793. _Visitor.prototype.visitIcuPlaceholder = /**
  12794. * @param {?} ph
  12795. * @param {?=} context
  12796. * @return {?}
  12797. */
  12798. function (ph, context) {
  12799. var /** @type {?} */ exTag = new Tag(_EXEMPLE_TAG, {}, [
  12800. new Text$2("{" + ph.value.expression + ", " + ph.value.type + ", " + Object.keys(ph.value.cases).map(function (value) { return value + ' {...}'; }).join(' ') + "}")
  12801. ]);
  12802. return [new Tag(_PLACEHOLDER_TAG$2, { name: ph.name }, [exTag])];
  12803. };
  12804. /**
  12805. * @param {?} nodes
  12806. * @return {?}
  12807. */
  12808. _Visitor.prototype.serialize = /**
  12809. * @param {?} nodes
  12810. * @return {?}
  12811. */
  12812. function (nodes) {
  12813. var _this = this;
  12814. return [].concat.apply([], nodes.map(function (node) { return node.visit(_this); }));
  12815. };
  12816. return _Visitor;
  12817. }());
  12818. /**
  12819. * @param {?} message
  12820. * @return {?}
  12821. */
  12822. function digest$1(message) {
  12823. return decimalDigest(message);
  12824. }
  12825. var ExampleVisitor = /** @class */ (function () {
  12826. function ExampleVisitor() {
  12827. }
  12828. /**
  12829. * @param {?} node
  12830. * @return {?}
  12831. */
  12832. ExampleVisitor.prototype.addDefaultExamples = /**
  12833. * @param {?} node
  12834. * @return {?}
  12835. */
  12836. function (node) {
  12837. node.visit(this);
  12838. return node;
  12839. };
  12840. /**
  12841. * @param {?} tag
  12842. * @return {?}
  12843. */
  12844. ExampleVisitor.prototype.visitTag = /**
  12845. * @param {?} tag
  12846. * @return {?}
  12847. */
  12848. function (tag) {
  12849. var _this = this;
  12850. if (tag.name === _PLACEHOLDER_TAG$2) {
  12851. if (!tag.children || tag.children.length == 0) {
  12852. var /** @type {?} */ exText = new Text$2(tag.attrs['name'] || '...');
  12853. tag.children = [new Tag(_EXEMPLE_TAG, {}, [exText])];
  12854. }
  12855. }
  12856. else if (tag.children) {
  12857. tag.children.forEach(function (node) { return node.visit(_this); });
  12858. }
  12859. };
  12860. /**
  12861. * @param {?} text
  12862. * @return {?}
  12863. */
  12864. ExampleVisitor.prototype.visitText = /**
  12865. * @param {?} text
  12866. * @return {?}
  12867. */
  12868. function (text) { };
  12869. /**
  12870. * @param {?} decl
  12871. * @return {?}
  12872. */
  12873. ExampleVisitor.prototype.visitDeclaration = /**
  12874. * @param {?} decl
  12875. * @return {?}
  12876. */
  12877. function (decl) { };
  12878. /**
  12879. * @param {?} doctype
  12880. * @return {?}
  12881. */
  12882. ExampleVisitor.prototype.visitDoctype = /**
  12883. * @param {?} doctype
  12884. * @return {?}
  12885. */
  12886. function (doctype) { };
  12887. return ExampleVisitor;
  12888. }());
  12889. /**
  12890. * @param {?} internalName
  12891. * @return {?}
  12892. */
  12893. function toPublicName(internalName) {
  12894. return internalName.toUpperCase().replace(/[^A-Z0-9_]/g, '_');
  12895. }
  12896. /**
  12897. * @fileoverview added by tsickle
  12898. * @suppress {checkTypes} checked by tsc
  12899. */
  12900. /**
  12901. * @license
  12902. * Copyright Google Inc. All Rights Reserved.
  12903. *
  12904. * Use of this source code is governed by an MIT-style license that can be
  12905. * found in the LICENSE file at https://angular.io/license
  12906. */
  12907. var _TRANSLATIONS_TAG = 'translationbundle';
  12908. var _TRANSLATION_TAG = 'translation';
  12909. var _PLACEHOLDER_TAG$3 = 'ph';
  12910. var Xtb = /** @class */ (function (_super) {
  12911. __extends(Xtb, _super);
  12912. function Xtb() {
  12913. return _super !== null && _super.apply(this, arguments) || this;
  12914. }
  12915. /**
  12916. * @param {?} messages
  12917. * @param {?} locale
  12918. * @return {?}
  12919. */
  12920. Xtb.prototype.write = /**
  12921. * @param {?} messages
  12922. * @param {?} locale
  12923. * @return {?}
  12924. */
  12925. function (messages, locale) { throw new Error('Unsupported'); };
  12926. /**
  12927. * @param {?} content
  12928. * @param {?} url
  12929. * @return {?}
  12930. */
  12931. Xtb.prototype.load = /**
  12932. * @param {?} content
  12933. * @param {?} url
  12934. * @return {?}
  12935. */
  12936. function (content, url) {
  12937. // xtb to xml nodes
  12938. var /** @type {?} */ xtbParser = new XtbParser();
  12939. var _a = xtbParser.parse(content, url), locale = _a.locale, msgIdToHtml = _a.msgIdToHtml, errors = _a.errors;
  12940. // xml nodes to i18n nodes
  12941. var /** @type {?} */ i18nNodesByMsgId = {};
  12942. var /** @type {?} */ converter = new XmlToI18n$2();
  12943. // Because we should be able to load xtb files that rely on features not supported by angular,
  12944. // we need to delay the conversion of html to i18n nodes so that non angular messages are not
  12945. // converted
  12946. Object.keys(msgIdToHtml).forEach(function (msgId) {
  12947. var /** @type {?} */ valueFn = function () {
  12948. var _a = converter.convert(msgIdToHtml[msgId], url), i18nNodes = _a.i18nNodes, errors = _a.errors;
  12949. if (errors.length) {
  12950. throw new Error("xtb parse errors:\n" + errors.join('\n'));
  12951. }
  12952. return i18nNodes;
  12953. };
  12954. createLazyProperty(i18nNodesByMsgId, msgId, valueFn);
  12955. });
  12956. if (errors.length) {
  12957. throw new Error("xtb parse errors:\n" + errors.join('\n'));
  12958. }
  12959. return { locale: /** @type {?} */ ((locale)), i18nNodesByMsgId: i18nNodesByMsgId };
  12960. };
  12961. /**
  12962. * @param {?} message
  12963. * @return {?}
  12964. */
  12965. Xtb.prototype.digest = /**
  12966. * @param {?} message
  12967. * @return {?}
  12968. */
  12969. function (message) { return digest$1(message); };
  12970. /**
  12971. * @param {?} message
  12972. * @return {?}
  12973. */
  12974. Xtb.prototype.createNameMapper = /**
  12975. * @param {?} message
  12976. * @return {?}
  12977. */
  12978. function (message) {
  12979. return new SimplePlaceholderMapper(message, toPublicName);
  12980. };
  12981. return Xtb;
  12982. }(Serializer));
  12983. /**
  12984. * @param {?} messages
  12985. * @param {?} id
  12986. * @param {?} valueFn
  12987. * @return {?}
  12988. */
  12989. function createLazyProperty(messages, id, valueFn) {
  12990. Object.defineProperty(messages, id, {
  12991. configurable: true,
  12992. enumerable: true,
  12993. get: function () {
  12994. var /** @type {?} */ value = valueFn();
  12995. Object.defineProperty(messages, id, { enumerable: true, value: value });
  12996. return value;
  12997. },
  12998. set: function (_) { throw new Error('Could not overwrite an XTB translation'); },
  12999. });
  13000. }
  13001. var XtbParser = /** @class */ (function () {
  13002. function XtbParser() {
  13003. this._locale = null;
  13004. }
  13005. /**
  13006. * @param {?} xtb
  13007. * @param {?} url
  13008. * @return {?}
  13009. */
  13010. XtbParser.prototype.parse = /**
  13011. * @param {?} xtb
  13012. * @param {?} url
  13013. * @return {?}
  13014. */
  13015. function (xtb, url) {
  13016. this._bundleDepth = 0;
  13017. this._msgIdToHtml = {};
  13018. // We can not parse the ICU messages at this point as some messages might not originate
  13019. // from Angular that could not be lex'd.
  13020. var /** @type {?} */ xml = new XmlParser().parse(xtb, url, false);
  13021. this._errors = xml.errors;
  13022. visitAll(this, xml.rootNodes);
  13023. return {
  13024. msgIdToHtml: this._msgIdToHtml,
  13025. errors: this._errors,
  13026. locale: this._locale,
  13027. };
  13028. };
  13029. /**
  13030. * @param {?} element
  13031. * @param {?} context
  13032. * @return {?}
  13033. */
  13034. XtbParser.prototype.visitElement = /**
  13035. * @param {?} element
  13036. * @param {?} context
  13037. * @return {?}
  13038. */
  13039. function (element, context) {
  13040. switch (element.name) {
  13041. case _TRANSLATIONS_TAG:
  13042. this._bundleDepth++;
  13043. if (this._bundleDepth > 1) {
  13044. this._addError(element, "<" + _TRANSLATIONS_TAG + "> elements can not be nested");
  13045. }
  13046. var /** @type {?} */ langAttr = element.attrs.find(function (attr) { return attr.name === 'lang'; });
  13047. if (langAttr) {
  13048. this._locale = langAttr.value;
  13049. }
  13050. visitAll(this, element.children, null);
  13051. this._bundleDepth--;
  13052. break;
  13053. case _TRANSLATION_TAG:
  13054. var /** @type {?} */ idAttr = element.attrs.find(function (attr) { return attr.name === 'id'; });
  13055. if (!idAttr) {
  13056. this._addError(element, "<" + _TRANSLATION_TAG + "> misses the \"id\" attribute");
  13057. }
  13058. else {
  13059. var /** @type {?} */ id = idAttr.value;
  13060. if (this._msgIdToHtml.hasOwnProperty(id)) {
  13061. this._addError(element, "Duplicated translations for msg " + id);
  13062. }
  13063. else {
  13064. var /** @type {?} */ innerTextStart = /** @type {?} */ ((element.startSourceSpan)).end.offset;
  13065. var /** @type {?} */ innerTextEnd = /** @type {?} */ ((element.endSourceSpan)).start.offset;
  13066. var /** @type {?} */ content = /** @type {?} */ ((element.startSourceSpan)).start.file.content;
  13067. var /** @type {?} */ innerText = content.slice(/** @type {?} */ ((innerTextStart)), /** @type {?} */ ((innerTextEnd)));
  13068. this._msgIdToHtml[id] = innerText;
  13069. }
  13070. }
  13071. break;
  13072. default:
  13073. this._addError(element, 'Unexpected tag');
  13074. }
  13075. };
  13076. /**
  13077. * @param {?} attribute
  13078. * @param {?} context
  13079. * @return {?}
  13080. */
  13081. XtbParser.prototype.visitAttribute = /**
  13082. * @param {?} attribute
  13083. * @param {?} context
  13084. * @return {?}
  13085. */
  13086. function (attribute, context) { };
  13087. /**
  13088. * @param {?} text
  13089. * @param {?} context
  13090. * @return {?}
  13091. */
  13092. XtbParser.prototype.visitText = /**
  13093. * @param {?} text
  13094. * @param {?} context
  13095. * @return {?}
  13096. */
  13097. function (text, context) { };
  13098. /**
  13099. * @param {?} comment
  13100. * @param {?} context
  13101. * @return {?}
  13102. */
  13103. XtbParser.prototype.visitComment = /**
  13104. * @param {?} comment
  13105. * @param {?} context
  13106. * @return {?}
  13107. */
  13108. function (comment, context) { };
  13109. /**
  13110. * @param {?} expansion
  13111. * @param {?} context
  13112. * @return {?}
  13113. */
  13114. XtbParser.prototype.visitExpansion = /**
  13115. * @param {?} expansion
  13116. * @param {?} context
  13117. * @return {?}
  13118. */
  13119. function (expansion, context) { };
  13120. /**
  13121. * @param {?} expansionCase
  13122. * @param {?} context
  13123. * @return {?}
  13124. */
  13125. XtbParser.prototype.visitExpansionCase = /**
  13126. * @param {?} expansionCase
  13127. * @param {?} context
  13128. * @return {?}
  13129. */
  13130. function (expansionCase, context) { };
  13131. /**
  13132. * @param {?} node
  13133. * @param {?} message
  13134. * @return {?}
  13135. */
  13136. XtbParser.prototype._addError = /**
  13137. * @param {?} node
  13138. * @param {?} message
  13139. * @return {?}
  13140. */
  13141. function (node, message) {
  13142. this._errors.push(new I18nError(/** @type {?} */ ((node.sourceSpan)), message));
  13143. };
  13144. return XtbParser;
  13145. }());
  13146. var XmlToI18n$2 = /** @class */ (function () {
  13147. function XmlToI18n() {
  13148. }
  13149. /**
  13150. * @param {?} message
  13151. * @param {?} url
  13152. * @return {?}
  13153. */
  13154. XmlToI18n.prototype.convert = /**
  13155. * @param {?} message
  13156. * @param {?} url
  13157. * @return {?}
  13158. */
  13159. function (message, url) {
  13160. var /** @type {?} */ xmlIcu = new XmlParser().parse(message, url, true);
  13161. this._errors = xmlIcu.errors;
  13162. var /** @type {?} */ i18nNodes = this._errors.length > 0 || xmlIcu.rootNodes.length == 0 ?
  13163. [] :
  13164. visitAll(this, xmlIcu.rootNodes);
  13165. return {
  13166. i18nNodes: i18nNodes,
  13167. errors: this._errors,
  13168. };
  13169. };
  13170. /**
  13171. * @param {?} text
  13172. * @param {?} context
  13173. * @return {?}
  13174. */
  13175. XmlToI18n.prototype.visitText = /**
  13176. * @param {?} text
  13177. * @param {?} context
  13178. * @return {?}
  13179. */
  13180. function (text, context) { return new Text$1(text.value, /** @type {?} */ ((text.sourceSpan))); };
  13181. /**
  13182. * @param {?} icu
  13183. * @param {?} context
  13184. * @return {?}
  13185. */
  13186. XmlToI18n.prototype.visitExpansion = /**
  13187. * @param {?} icu
  13188. * @param {?} context
  13189. * @return {?}
  13190. */
  13191. function (icu, context) {
  13192. var /** @type {?} */ caseMap = {};
  13193. visitAll(this, icu.cases).forEach(function (c) {
  13194. caseMap[c.value] = new Container(c.nodes, icu.sourceSpan);
  13195. });
  13196. return new Icu(icu.switchValue, icu.type, caseMap, icu.sourceSpan);
  13197. };
  13198. /**
  13199. * @param {?} icuCase
  13200. * @param {?} context
  13201. * @return {?}
  13202. */
  13203. XmlToI18n.prototype.visitExpansionCase = /**
  13204. * @param {?} icuCase
  13205. * @param {?} context
  13206. * @return {?}
  13207. */
  13208. function (icuCase, context) {
  13209. return {
  13210. value: icuCase.value,
  13211. nodes: visitAll(this, icuCase.expression),
  13212. };
  13213. };
  13214. /**
  13215. * @param {?} el
  13216. * @param {?} context
  13217. * @return {?}
  13218. */
  13219. XmlToI18n.prototype.visitElement = /**
  13220. * @param {?} el
  13221. * @param {?} context
  13222. * @return {?}
  13223. */
  13224. function (el, context) {
  13225. if (el.name === _PLACEHOLDER_TAG$3) {
  13226. var /** @type {?} */ nameAttr = el.attrs.find(function (attr) { return attr.name === 'name'; });
  13227. if (nameAttr) {
  13228. return new Placeholder('', nameAttr.value, /** @type {?} */ ((el.sourceSpan)));
  13229. }
  13230. this._addError(el, "<" + _PLACEHOLDER_TAG$3 + "> misses the \"name\" attribute");
  13231. }
  13232. else {
  13233. this._addError(el, "Unexpected tag");
  13234. }
  13235. return null;
  13236. };
  13237. /**
  13238. * @param {?} comment
  13239. * @param {?} context
  13240. * @return {?}
  13241. */
  13242. XmlToI18n.prototype.visitComment = /**
  13243. * @param {?} comment
  13244. * @param {?} context
  13245. * @return {?}
  13246. */
  13247. function (comment, context) { };
  13248. /**
  13249. * @param {?} attribute
  13250. * @param {?} context
  13251. * @return {?}
  13252. */
  13253. XmlToI18n.prototype.visitAttribute = /**
  13254. * @param {?} attribute
  13255. * @param {?} context
  13256. * @return {?}
  13257. */
  13258. function (attribute, context) { };
  13259. /**
  13260. * @param {?} node
  13261. * @param {?} message
  13262. * @return {?}
  13263. */
  13264. XmlToI18n.prototype._addError = /**
  13265. * @param {?} node
  13266. * @param {?} message
  13267. * @return {?}
  13268. */
  13269. function (node, message) {
  13270. this._errors.push(new I18nError(/** @type {?} */ ((node.sourceSpan)), message));
  13271. };
  13272. return XmlToI18n;
  13273. }());
  13274. /**
  13275. * @fileoverview added by tsickle
  13276. * @suppress {checkTypes} checked by tsc
  13277. */
  13278. /**
  13279. * @license
  13280. * Copyright Google Inc. All Rights Reserved.
  13281. *
  13282. * Use of this source code is governed by an MIT-style license that can be
  13283. * found in the LICENSE file at https://angular.io/license
  13284. */
  13285. var HtmlParser = /** @class */ (function (_super) {
  13286. __extends(HtmlParser, _super);
  13287. function HtmlParser() {
  13288. return _super.call(this, getHtmlTagDefinition) || this;
  13289. }
  13290. /**
  13291. * @param {?} source
  13292. * @param {?} url
  13293. * @param {?=} parseExpansionForms
  13294. * @param {?=} interpolationConfig
  13295. * @return {?}
  13296. */
  13297. HtmlParser.prototype.parse = /**
  13298. * @param {?} source
  13299. * @param {?} url
  13300. * @param {?=} parseExpansionForms
  13301. * @param {?=} interpolationConfig
  13302. * @return {?}
  13303. */
  13304. function (source, url, parseExpansionForms, interpolationConfig) {
  13305. if (parseExpansionForms === void 0) { parseExpansionForms = false; }
  13306. if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
  13307. return _super.prototype.parse.call(this, source, url, parseExpansionForms, interpolationConfig);
  13308. };
  13309. return HtmlParser;
  13310. }(Parser$1));
  13311. /**
  13312. * @fileoverview added by tsickle
  13313. * @suppress {checkTypes} checked by tsc
  13314. */
  13315. /**
  13316. * @license
  13317. * Copyright Google Inc. All Rights Reserved.
  13318. *
  13319. * Use of this source code is governed by an MIT-style license that can be
  13320. * found in the LICENSE file at https://angular.io/license
  13321. */
  13322. /**
  13323. * A container for translated messages
  13324. */
  13325. var TranslationBundle = /** @class */ (function () {
  13326. function TranslationBundle(_i18nNodesByMsgId, locale, digest, mapperFactory, missingTranslationStrategy, console) {
  13327. if (_i18nNodesByMsgId === void 0) { _i18nNodesByMsgId = {}; }
  13328. if (missingTranslationStrategy === void 0) { missingTranslationStrategy = MissingTranslationStrategy.Warning; }
  13329. this._i18nNodesByMsgId = _i18nNodesByMsgId;
  13330. this.digest = digest;
  13331. this.mapperFactory = mapperFactory;
  13332. this._i18nToHtml = new I18nToHtmlVisitor(_i18nNodesByMsgId, locale, digest, /** @type {?} */ ((mapperFactory)), missingTranslationStrategy, console);
  13333. }
  13334. // Creates a `TranslationBundle` by parsing the given `content` with the `serializer`.
  13335. /**
  13336. * @param {?} content
  13337. * @param {?} url
  13338. * @param {?} serializer
  13339. * @param {?} missingTranslationStrategy
  13340. * @param {?=} console
  13341. * @return {?}
  13342. */
  13343. TranslationBundle.load = /**
  13344. * @param {?} content
  13345. * @param {?} url
  13346. * @param {?} serializer
  13347. * @param {?} missingTranslationStrategy
  13348. * @param {?=} console
  13349. * @return {?}
  13350. */
  13351. function (content, url, serializer, missingTranslationStrategy, console) {
  13352. var _a = serializer.load(content, url), locale = _a.locale, i18nNodesByMsgId = _a.i18nNodesByMsgId;
  13353. var /** @type {?} */ digestFn = function (m) { return serializer.digest(m); };
  13354. var /** @type {?} */ mapperFactory = function (m) { return ((serializer.createNameMapper(m))); };
  13355. return new TranslationBundle(i18nNodesByMsgId, locale, digestFn, mapperFactory, missingTranslationStrategy, console);
  13356. };
  13357. // Returns the translation as HTML nodes from the given source message.
  13358. /**
  13359. * @param {?} srcMsg
  13360. * @return {?}
  13361. */
  13362. TranslationBundle.prototype.get = /**
  13363. * @param {?} srcMsg
  13364. * @return {?}
  13365. */
  13366. function (srcMsg) {
  13367. var /** @type {?} */ html = this._i18nToHtml.convert(srcMsg);
  13368. if (html.errors.length) {
  13369. throw new Error(html.errors.join('\n'));
  13370. }
  13371. return html.nodes;
  13372. };
  13373. /**
  13374. * @param {?} srcMsg
  13375. * @return {?}
  13376. */
  13377. TranslationBundle.prototype.has = /**
  13378. * @param {?} srcMsg
  13379. * @return {?}
  13380. */
  13381. function (srcMsg) { return this.digest(srcMsg) in this._i18nNodesByMsgId; };
  13382. return TranslationBundle;
  13383. }());
  13384. var I18nToHtmlVisitor = /** @class */ (function () {
  13385. function I18nToHtmlVisitor(_i18nNodesByMsgId, _locale, _digest, _mapperFactory, _missingTranslationStrategy, _console) {
  13386. if (_i18nNodesByMsgId === void 0) { _i18nNodesByMsgId = {}; }
  13387. this._i18nNodesByMsgId = _i18nNodesByMsgId;
  13388. this._locale = _locale;
  13389. this._digest = _digest;
  13390. this._mapperFactory = _mapperFactory;
  13391. this._missingTranslationStrategy = _missingTranslationStrategy;
  13392. this._console = _console;
  13393. this._contextStack = [];
  13394. this._errors = [];
  13395. }
  13396. /**
  13397. * @param {?} srcMsg
  13398. * @return {?}
  13399. */
  13400. I18nToHtmlVisitor.prototype.convert = /**
  13401. * @param {?} srcMsg
  13402. * @return {?}
  13403. */
  13404. function (srcMsg) {
  13405. this._contextStack.length = 0;
  13406. this._errors.length = 0;
  13407. // i18n to text
  13408. var /** @type {?} */ text = this._convertToText(srcMsg);
  13409. // text to html
  13410. var /** @type {?} */ url = srcMsg.nodes[0].sourceSpan.start.file.url;
  13411. var /** @type {?} */ html = new HtmlParser().parse(text, url, true);
  13412. return {
  13413. nodes: html.rootNodes,
  13414. errors: this._errors.concat(html.errors),
  13415. };
  13416. };
  13417. /**
  13418. * @param {?} text
  13419. * @param {?=} context
  13420. * @return {?}
  13421. */
  13422. I18nToHtmlVisitor.prototype.visitText = /**
  13423. * @param {?} text
  13424. * @param {?=} context
  13425. * @return {?}
  13426. */
  13427. function (text, context) {
  13428. // `convert()` uses an `HtmlParser` to return `html.Node`s
  13429. // we should then make sure that any special characters are escaped
  13430. return escapeXml(text.value);
  13431. };
  13432. /**
  13433. * @param {?} container
  13434. * @param {?=} context
  13435. * @return {?}
  13436. */
  13437. I18nToHtmlVisitor.prototype.visitContainer = /**
  13438. * @param {?} container
  13439. * @param {?=} context
  13440. * @return {?}
  13441. */
  13442. function (container, context) {
  13443. var _this = this;
  13444. return container.children.map(function (n) { return n.visit(_this); }).join('');
  13445. };
  13446. /**
  13447. * @param {?} icu
  13448. * @param {?=} context
  13449. * @return {?}
  13450. */
  13451. I18nToHtmlVisitor.prototype.visitIcu = /**
  13452. * @param {?} icu
  13453. * @param {?=} context
  13454. * @return {?}
  13455. */
  13456. function (icu, context) {
  13457. var _this = this;
  13458. var /** @type {?} */ cases = Object.keys(icu.cases).map(function (k) { return k + " {" + icu.cases[k].visit(_this) + "}"; });
  13459. // TODO(vicb): Once all format switch to using expression placeholders
  13460. // we should throw when the placeholder is not in the source message
  13461. var /** @type {?} */ exp = this._srcMsg.placeholders.hasOwnProperty(icu.expression) ?
  13462. this._srcMsg.placeholders[icu.expression] :
  13463. icu.expression;
  13464. return "{" + exp + ", " + icu.type + ", " + cases.join(' ') + "}";
  13465. };
  13466. /**
  13467. * @param {?} ph
  13468. * @param {?=} context
  13469. * @return {?}
  13470. */
  13471. I18nToHtmlVisitor.prototype.visitPlaceholder = /**
  13472. * @param {?} ph
  13473. * @param {?=} context
  13474. * @return {?}
  13475. */
  13476. function (ph, context) {
  13477. var /** @type {?} */ phName = this._mapper(ph.name);
  13478. if (this._srcMsg.placeholders.hasOwnProperty(phName)) {
  13479. return this._srcMsg.placeholders[phName];
  13480. }
  13481. if (this._srcMsg.placeholderToMessage.hasOwnProperty(phName)) {
  13482. return this._convertToText(this._srcMsg.placeholderToMessage[phName]);
  13483. }
  13484. this._addError(ph, "Unknown placeholder \"" + ph.name + "\"");
  13485. return '';
  13486. };
  13487. // Loaded message contains only placeholders (vs tag and icu placeholders).
  13488. // However when a translation can not be found, we need to serialize the source message
  13489. // which can contain tag placeholders
  13490. /**
  13491. * @param {?} ph
  13492. * @param {?=} context
  13493. * @return {?}
  13494. */
  13495. I18nToHtmlVisitor.prototype.visitTagPlaceholder = /**
  13496. * @param {?} ph
  13497. * @param {?=} context
  13498. * @return {?}
  13499. */
  13500. function (ph, context) {
  13501. var _this = this;
  13502. var /** @type {?} */ tag = "" + ph.tag;
  13503. var /** @type {?} */ attrs = Object.keys(ph.attrs).map(function (name) { return name + "=\"" + ph.attrs[name] + "\""; }).join(' ');
  13504. if (ph.isVoid) {
  13505. return "<" + tag + " " + attrs + "/>";
  13506. }
  13507. var /** @type {?} */ children = ph.children.map(function (c) { return c.visit(_this); }).join('');
  13508. return "<" + tag + " " + attrs + ">" + children + "</" + tag + ">";
  13509. };
  13510. // Loaded message contains only placeholders (vs tag and icu placeholders).
  13511. // However when a translation can not be found, we need to serialize the source message
  13512. // which can contain tag placeholders
  13513. /**
  13514. * @param {?} ph
  13515. * @param {?=} context
  13516. * @return {?}
  13517. */
  13518. I18nToHtmlVisitor.prototype.visitIcuPlaceholder = /**
  13519. * @param {?} ph
  13520. * @param {?=} context
  13521. * @return {?}
  13522. */
  13523. function (ph, context) {
  13524. // An ICU placeholder references the source message to be serialized
  13525. return this._convertToText(this._srcMsg.placeholderToMessage[ph.name]);
  13526. };
  13527. /**
  13528. * Convert a source message to a translated text string:
  13529. * - text nodes are replaced with their translation,
  13530. * - placeholders are replaced with their content,
  13531. * - ICU nodes are converted to ICU expressions.
  13532. * @param {?} srcMsg
  13533. * @return {?}
  13534. */
  13535. I18nToHtmlVisitor.prototype._convertToText = /**
  13536. * Convert a source message to a translated text string:
  13537. * - text nodes are replaced with their translation,
  13538. * - placeholders are replaced with their content,
  13539. * - ICU nodes are converted to ICU expressions.
  13540. * @param {?} srcMsg
  13541. * @return {?}
  13542. */
  13543. function (srcMsg) {
  13544. var _this = this;
  13545. var /** @type {?} */ id = this._digest(srcMsg);
  13546. var /** @type {?} */ mapper = this._mapperFactory ? this._mapperFactory(srcMsg) : null;
  13547. var /** @type {?} */ nodes;
  13548. this._contextStack.push({ msg: this._srcMsg, mapper: this._mapper });
  13549. this._srcMsg = srcMsg;
  13550. if (this._i18nNodesByMsgId.hasOwnProperty(id)) {
  13551. // When there is a translation use its nodes as the source
  13552. // And create a mapper to convert serialized placeholder names to internal names
  13553. nodes = this._i18nNodesByMsgId[id];
  13554. this._mapper = function (name) { return mapper ? /** @type {?} */ ((mapper.toInternalName(name))) : name; };
  13555. }
  13556. else {
  13557. // When no translation has been found
  13558. // - report an error / a warning / nothing,
  13559. // - use the nodes from the original message
  13560. // - placeholders are already internal and need no mapper
  13561. if (this._missingTranslationStrategy === MissingTranslationStrategy.Error) {
  13562. var /** @type {?} */ ctx = this._locale ? " for locale \"" + this._locale + "\"" : '';
  13563. this._addError(srcMsg.nodes[0], "Missing translation for message \"" + id + "\"" + ctx);
  13564. }
  13565. else if (this._console &&
  13566. this._missingTranslationStrategy === MissingTranslationStrategy.Warning) {
  13567. var /** @type {?} */ ctx = this._locale ? " for locale \"" + this._locale + "\"" : '';
  13568. this._console.warn("Missing translation for message \"" + id + "\"" + ctx);
  13569. }
  13570. nodes = srcMsg.nodes;
  13571. this._mapper = function (name) { return name; };
  13572. }
  13573. var /** @type {?} */ text = nodes.map(function (node) { return node.visit(_this); }).join('');
  13574. var /** @type {?} */ context = /** @type {?} */ ((this._contextStack.pop()));
  13575. this._srcMsg = context.msg;
  13576. this._mapper = context.mapper;
  13577. return text;
  13578. };
  13579. /**
  13580. * @param {?} el
  13581. * @param {?} msg
  13582. * @return {?}
  13583. */
  13584. I18nToHtmlVisitor.prototype._addError = /**
  13585. * @param {?} el
  13586. * @param {?} msg
  13587. * @return {?}
  13588. */
  13589. function (el, msg) {
  13590. this._errors.push(new I18nError(el.sourceSpan, msg));
  13591. };
  13592. return I18nToHtmlVisitor;
  13593. }());
  13594. /**
  13595. * @fileoverview added by tsickle
  13596. * @suppress {checkTypes} checked by tsc
  13597. */
  13598. /**
  13599. * @license
  13600. * Copyright Google Inc. All Rights Reserved.
  13601. *
  13602. * Use of this source code is governed by an MIT-style license that can be
  13603. * found in the LICENSE file at https://angular.io/license
  13604. */
  13605. var I18NHtmlParser = /** @class */ (function () {
  13606. function I18NHtmlParser(_htmlParser, translations, translationsFormat, missingTranslation, console) {
  13607. if (missingTranslation === void 0) { missingTranslation = MissingTranslationStrategy.Warning; }
  13608. this._htmlParser = _htmlParser;
  13609. if (translations) {
  13610. var /** @type {?} */ serializer = createSerializer(translationsFormat);
  13611. this._translationBundle =
  13612. TranslationBundle.load(translations, 'i18n', serializer, missingTranslation, console);
  13613. }
  13614. else {
  13615. this._translationBundle =
  13616. new TranslationBundle({}, null, digest, undefined, missingTranslation, console);
  13617. }
  13618. }
  13619. /**
  13620. * @param {?} source
  13621. * @param {?} url
  13622. * @param {?=} parseExpansionForms
  13623. * @param {?=} interpolationConfig
  13624. * @return {?}
  13625. */
  13626. I18NHtmlParser.prototype.parse = /**
  13627. * @param {?} source
  13628. * @param {?} url
  13629. * @param {?=} parseExpansionForms
  13630. * @param {?=} interpolationConfig
  13631. * @return {?}
  13632. */
  13633. function (source, url, parseExpansionForms, interpolationConfig) {
  13634. if (parseExpansionForms === void 0) { parseExpansionForms = false; }
  13635. if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
  13636. var /** @type {?} */ parseResult = this._htmlParser.parse(source, url, parseExpansionForms, interpolationConfig);
  13637. if (parseResult.errors.length) {
  13638. return new ParseTreeResult(parseResult.rootNodes, parseResult.errors);
  13639. }
  13640. return mergeTranslations(parseResult.rootNodes, this._translationBundle, interpolationConfig, [], {});
  13641. };
  13642. return I18NHtmlParser;
  13643. }());
  13644. /**
  13645. * @param {?=} format
  13646. * @return {?}
  13647. */
  13648. function createSerializer(format) {
  13649. format = (format || 'xlf').toLowerCase();
  13650. switch (format) {
  13651. case 'xmb':
  13652. return new Xmb();
  13653. case 'xtb':
  13654. return new Xtb();
  13655. case 'xliff2':
  13656. case 'xlf2':
  13657. return new Xliff2();
  13658. case 'xliff':
  13659. case 'xlf':
  13660. default:
  13661. return new Xliff();
  13662. }
  13663. }
  13664. /**
  13665. * @fileoverview added by tsickle
  13666. * @suppress {checkTypes} checked by tsc
  13667. */
  13668. /**
  13669. * @license
  13670. * Copyright Google Inc. All Rights Reserved.
  13671. *
  13672. * Use of this source code is governed by an MIT-style license that can be
  13673. * found in the LICENSE file at https://angular.io/license
  13674. */
  13675. var STRIP_SRC_FILE_SUFFIXES = /(\.ts|\.d\.ts|\.js|\.jsx|\.tsx)$/;
  13676. var GENERATED_FILE = /\.ngfactory\.|\.ngsummary\./;
  13677. var JIT_SUMMARY_FILE = /\.ngsummary\./;
  13678. var JIT_SUMMARY_NAME = /NgSummary$/;
  13679. /**
  13680. * @param {?} filePath
  13681. * @param {?=} forceSourceFile
  13682. * @return {?}
  13683. */
  13684. function ngfactoryFilePath(filePath, forceSourceFile) {
  13685. if (forceSourceFile === void 0) { forceSourceFile = false; }
  13686. var /** @type {?} */ urlWithSuffix = splitTypescriptSuffix(filePath, forceSourceFile);
  13687. return urlWithSuffix[0] + ".ngfactory" + normalizeGenFileSuffix(urlWithSuffix[1]);
  13688. }
  13689. /**
  13690. * @param {?} filePath
  13691. * @return {?}
  13692. */
  13693. function stripGeneratedFileSuffix(filePath) {
  13694. return filePath.replace(GENERATED_FILE, '.');
  13695. }
  13696. /**
  13697. * @param {?} filePath
  13698. * @return {?}
  13699. */
  13700. function isGeneratedFile(filePath) {
  13701. return GENERATED_FILE.test(filePath);
  13702. }
  13703. /**
  13704. * @param {?} path
  13705. * @param {?=} forceSourceFile
  13706. * @return {?}
  13707. */
  13708. function splitTypescriptSuffix(path, forceSourceFile) {
  13709. if (forceSourceFile === void 0) { forceSourceFile = false; }
  13710. if (path.endsWith('.d.ts')) {
  13711. return [path.slice(0, -5), forceSourceFile ? '.ts' : '.d.ts'];
  13712. }
  13713. var /** @type {?} */ lastDot = path.lastIndexOf('.');
  13714. if (lastDot !== -1) {
  13715. return [path.substring(0, lastDot), path.substring(lastDot)];
  13716. }
  13717. return [path, ''];
  13718. }
  13719. /**
  13720. * @param {?} srcFileSuffix
  13721. * @return {?}
  13722. */
  13723. function normalizeGenFileSuffix(srcFileSuffix) {
  13724. return srcFileSuffix === '.tsx' ? '.ts' : srcFileSuffix;
  13725. }
  13726. /**
  13727. * @param {?} fileName
  13728. * @return {?}
  13729. */
  13730. function summaryFileName(fileName) {
  13731. var /** @type {?} */ fileNameWithoutSuffix = fileName.replace(STRIP_SRC_FILE_SUFFIXES, '');
  13732. return fileNameWithoutSuffix + ".ngsummary.json";
  13733. }
  13734. /**
  13735. * @param {?} fileName
  13736. * @param {?=} forceSourceFile
  13737. * @return {?}
  13738. */
  13739. function summaryForJitFileName(fileName, forceSourceFile) {
  13740. if (forceSourceFile === void 0) { forceSourceFile = false; }
  13741. var /** @type {?} */ urlWithSuffix = splitTypescriptSuffix(stripGeneratedFileSuffix(fileName), forceSourceFile);
  13742. return urlWithSuffix[0] + ".ngsummary" + urlWithSuffix[1];
  13743. }
  13744. /**
  13745. * @param {?} filePath
  13746. * @return {?}
  13747. */
  13748. function stripSummaryForJitFileSuffix(filePath) {
  13749. return filePath.replace(JIT_SUMMARY_FILE, '.');
  13750. }
  13751. /**
  13752. * @param {?} symbolName
  13753. * @return {?}
  13754. */
  13755. function summaryForJitName(symbolName) {
  13756. return symbolName + "NgSummary";
  13757. }
  13758. /**
  13759. * @param {?} symbolName
  13760. * @return {?}
  13761. */
  13762. function stripSummaryForJitNameSuffix(symbolName) {
  13763. return symbolName.replace(JIT_SUMMARY_NAME, '');
  13764. }
  13765. var LOWERED_SYMBOL = /\u0275\d+/;
  13766. /**
  13767. * @param {?} name
  13768. * @return {?}
  13769. */
  13770. function isLoweredSymbol(name) {
  13771. return LOWERED_SYMBOL.test(name);
  13772. }
  13773. /**
  13774. * @param {?} id
  13775. * @return {?}
  13776. */
  13777. function createLoweredSymbol(id) {
  13778. return "\u0275" + id;
  13779. }
  13780. /**
  13781. * @fileoverview added by tsickle
  13782. * @suppress {checkTypes} checked by tsc
  13783. */
  13784. /**
  13785. * @license
  13786. * Copyright Google Inc. All Rights Reserved.
  13787. *
  13788. * Use of this source code is governed by an MIT-style license that can be
  13789. * found in the LICENSE file at https://angular.io/license
  13790. */
  13791. var CORE = '@angular/core';
  13792. var Identifiers = /** @class */ (function () {
  13793. function Identifiers() {
  13794. }
  13795. Identifiers.ANALYZE_FOR_ENTRY_COMPONENTS = {
  13796. name: 'ANALYZE_FOR_ENTRY_COMPONENTS',
  13797. moduleName: CORE,
  13798. };
  13799. Identifiers.ElementRef = { name: 'ElementRef', moduleName: CORE };
  13800. Identifiers.NgModuleRef = { name: 'NgModuleRef', moduleName: CORE };
  13801. Identifiers.ViewContainerRef = { name: 'ViewContainerRef', moduleName: CORE };
  13802. Identifiers.ChangeDetectorRef = {
  13803. name: 'ChangeDetectorRef',
  13804. moduleName: CORE,
  13805. };
  13806. Identifiers.QueryList = { name: 'QueryList', moduleName: CORE };
  13807. Identifiers.TemplateRef = { name: 'TemplateRef', moduleName: CORE };
  13808. Identifiers.CodegenComponentFactoryResolver = {
  13809. name: 'ɵCodegenComponentFactoryResolver',
  13810. moduleName: CORE,
  13811. };
  13812. Identifiers.ComponentFactoryResolver = {
  13813. name: 'ComponentFactoryResolver',
  13814. moduleName: CORE,
  13815. };
  13816. Identifiers.ComponentFactory = { name: 'ComponentFactory', moduleName: CORE };
  13817. Identifiers.ComponentRef = { name: 'ComponentRef', moduleName: CORE };
  13818. Identifiers.NgModuleFactory = { name: 'NgModuleFactory', moduleName: CORE };
  13819. Identifiers.createModuleFactory = {
  13820. name: 'ɵcmf',
  13821. moduleName: CORE,
  13822. };
  13823. Identifiers.moduleDef = {
  13824. name: 'ɵmod',
  13825. moduleName: CORE,
  13826. };
  13827. Identifiers.moduleProviderDef = {
  13828. name: 'ɵmpd',
  13829. moduleName: CORE,
  13830. };
  13831. Identifiers.RegisterModuleFactoryFn = {
  13832. name: 'ɵregisterModuleFactory',
  13833. moduleName: CORE,
  13834. };
  13835. Identifiers.Injector = { name: 'Injector', moduleName: CORE };
  13836. Identifiers.ViewEncapsulation = {
  13837. name: 'ViewEncapsulation',
  13838. moduleName: CORE,
  13839. };
  13840. Identifiers.ChangeDetectionStrategy = {
  13841. name: 'ChangeDetectionStrategy',
  13842. moduleName: CORE,
  13843. };
  13844. Identifiers.SecurityContext = {
  13845. name: 'SecurityContext',
  13846. moduleName: CORE,
  13847. };
  13848. Identifiers.LOCALE_ID = { name: 'LOCALE_ID', moduleName: CORE };
  13849. Identifiers.TRANSLATIONS_FORMAT = {
  13850. name: 'TRANSLATIONS_FORMAT',
  13851. moduleName: CORE,
  13852. };
  13853. Identifiers.inlineInterpolate = {
  13854. name: 'ɵinlineInterpolate',
  13855. moduleName: CORE,
  13856. };
  13857. Identifiers.interpolate = { name: 'ɵinterpolate', moduleName: CORE };
  13858. Identifiers.EMPTY_ARRAY = { name: 'ɵEMPTY_ARRAY', moduleName: CORE };
  13859. Identifiers.EMPTY_MAP = { name: 'ɵEMPTY_MAP', moduleName: CORE };
  13860. Identifiers.Renderer = { name: 'Renderer', moduleName: CORE };
  13861. Identifiers.viewDef = { name: 'ɵvid', moduleName: CORE };
  13862. Identifiers.elementDef = { name: 'ɵeld', moduleName: CORE };
  13863. Identifiers.anchorDef = { name: 'ɵand', moduleName: CORE };
  13864. Identifiers.textDef = { name: 'ɵted', moduleName: CORE };
  13865. Identifiers.directiveDef = { name: 'ɵdid', moduleName: CORE };
  13866. Identifiers.providerDef = { name: 'ɵprd', moduleName: CORE };
  13867. Identifiers.queryDef = { name: 'ɵqud', moduleName: CORE };
  13868. Identifiers.pureArrayDef = { name: 'ɵpad', moduleName: CORE };
  13869. Identifiers.pureObjectDef = { name: 'ɵpod', moduleName: CORE };
  13870. Identifiers.purePipeDef = { name: 'ɵppd', moduleName: CORE };
  13871. Identifiers.pipeDef = { name: 'ɵpid', moduleName: CORE };
  13872. Identifiers.nodeValue = { name: 'ɵnov', moduleName: CORE };
  13873. Identifiers.ngContentDef = { name: 'ɵncd', moduleName: CORE };
  13874. Identifiers.unwrapValue = { name: 'ɵunv', moduleName: CORE };
  13875. Identifiers.createRendererType2 = { name: 'ɵcrt', moduleName: CORE };
  13876. // type only
  13877. Identifiers.RendererType2 = {
  13878. name: 'RendererType2',
  13879. moduleName: CORE,
  13880. };
  13881. // type only
  13882. Identifiers.ViewDefinition = {
  13883. name: 'ɵViewDefinition',
  13884. moduleName: CORE,
  13885. };
  13886. Identifiers.createComponentFactory = { name: 'ɵccf', moduleName: CORE };
  13887. return Identifiers;
  13888. }());
  13889. /**
  13890. * @param {?} reference
  13891. * @return {?}
  13892. */
  13893. function createTokenForReference(reference) {
  13894. return { identifier: { reference: reference } };
  13895. }
  13896. /**
  13897. * @param {?} reflector
  13898. * @param {?} reference
  13899. * @return {?}
  13900. */
  13901. function createTokenForExternalReference(reflector, reference) {
  13902. return createTokenForReference(reflector.resolveExternalReference(reference));
  13903. }
  13904. /**
  13905. * @fileoverview added by tsickle
  13906. * @suppress {checkTypes} checked by tsc
  13907. */
  13908. /**
  13909. * @license
  13910. * Copyright Google Inc. All Rights Reserved.
  13911. *
  13912. * Use of this source code is governed by an MIT-style license that can be
  13913. * found in the LICENSE file at https://angular.io/license
  13914. */
  13915. /** @enum {number} */
  13916. var LifecycleHooks = {
  13917. OnInit: 0,
  13918. OnDestroy: 1,
  13919. DoCheck: 2,
  13920. OnChanges: 3,
  13921. AfterContentInit: 4,
  13922. AfterContentChecked: 5,
  13923. AfterViewInit: 6,
  13924. AfterViewChecked: 7,
  13925. };
  13926. LifecycleHooks[LifecycleHooks.OnInit] = "OnInit";
  13927. LifecycleHooks[LifecycleHooks.OnDestroy] = "OnDestroy";
  13928. LifecycleHooks[LifecycleHooks.DoCheck] = "DoCheck";
  13929. LifecycleHooks[LifecycleHooks.OnChanges] = "OnChanges";
  13930. LifecycleHooks[LifecycleHooks.AfterContentInit] = "AfterContentInit";
  13931. LifecycleHooks[LifecycleHooks.AfterContentChecked] = "AfterContentChecked";
  13932. LifecycleHooks[LifecycleHooks.AfterViewInit] = "AfterViewInit";
  13933. LifecycleHooks[LifecycleHooks.AfterViewChecked] = "AfterViewChecked";
  13934. var LIFECYCLE_HOOKS_VALUES = [
  13935. LifecycleHooks.OnInit, LifecycleHooks.OnDestroy, LifecycleHooks.DoCheck, LifecycleHooks.OnChanges,
  13936. LifecycleHooks.AfterContentInit, LifecycleHooks.AfterContentChecked, LifecycleHooks.AfterViewInit,
  13937. LifecycleHooks.AfterViewChecked
  13938. ];
  13939. /**
  13940. * @param {?} reflector
  13941. * @param {?} hook
  13942. * @param {?} token
  13943. * @return {?}
  13944. */
  13945. function hasLifecycleHook(reflector, hook, token) {
  13946. return reflector.hasLifecycleHook(token, getHookName(hook));
  13947. }
  13948. /**
  13949. * @param {?} reflector
  13950. * @param {?} token
  13951. * @return {?}
  13952. */
  13953. function getAllLifecycleHooks(reflector, token) {
  13954. return LIFECYCLE_HOOKS_VALUES.filter(function (hook) { return hasLifecycleHook(reflector, hook, token); });
  13955. }
  13956. /**
  13957. * @param {?} hook
  13958. * @return {?}
  13959. */
  13960. function getHookName(hook) {
  13961. switch (hook) {
  13962. case LifecycleHooks.OnInit:
  13963. return 'ngOnInit';
  13964. case LifecycleHooks.OnDestroy:
  13965. return 'ngOnDestroy';
  13966. case LifecycleHooks.DoCheck:
  13967. return 'ngDoCheck';
  13968. case LifecycleHooks.OnChanges:
  13969. return 'ngOnChanges';
  13970. case LifecycleHooks.AfterContentInit:
  13971. return 'ngAfterContentInit';
  13972. case LifecycleHooks.AfterContentChecked:
  13973. return 'ngAfterContentChecked';
  13974. case LifecycleHooks.AfterViewInit:
  13975. return 'ngAfterViewInit';
  13976. case LifecycleHooks.AfterViewChecked:
  13977. return 'ngAfterViewChecked';
  13978. }
  13979. }
  13980. /**
  13981. * @fileoverview added by tsickle
  13982. * @suppress {checkTypes} checked by tsc
  13983. */
  13984. /**
  13985. * @license
  13986. * Copyright Google Inc. All Rights Reserved.
  13987. *
  13988. * Use of this source code is governed by an MIT-style license that can be
  13989. * found in the LICENSE file at https://angular.io/license
  13990. */
  13991. var _SELECTOR_REGEXP = new RegExp('(\\:not\\()|' + //":not("
  13992. '([-\\w]+)|' + // "tag"
  13993. '(?:\\.([-\\w]+))|' + // ".class"
  13994. '(?:\\[([-.\\w*]+)(?:=([\"\']?)([^\\]\"\']*)\\5)?\\])|' + // "[name]", "[name=value]",
  13995. '(\\))|' + // ")"
  13996. '(\\s*,\\s*)', // ","
  13997. 'g');
  13998. /**
  13999. * A css selector contains an element name,
  14000. * css classes and attribute/value pairs with the purpose
  14001. * of selecting subsets out of them.
  14002. */
  14003. var CssSelector = /** @class */ (function () {
  14004. function CssSelector() {
  14005. this.element = null;
  14006. this.classNames = [];
  14007. this.attrs = [];
  14008. this.notSelectors = [];
  14009. }
  14010. /**
  14011. * @param {?} selector
  14012. * @return {?}
  14013. */
  14014. CssSelector.parse = /**
  14015. * @param {?} selector
  14016. * @return {?}
  14017. */
  14018. function (selector) {
  14019. var /** @type {?} */ results = [];
  14020. var /** @type {?} */ _addResult = function (res, cssSel) {
  14021. if (cssSel.notSelectors.length > 0 && !cssSel.element && cssSel.classNames.length == 0 &&
  14022. cssSel.attrs.length == 0) {
  14023. cssSel.element = '*';
  14024. }
  14025. res.push(cssSel);
  14026. };
  14027. var /** @type {?} */ cssSelector = new CssSelector();
  14028. var /** @type {?} */ match;
  14029. var /** @type {?} */ current = cssSelector;
  14030. var /** @type {?} */ inNot = false;
  14031. _SELECTOR_REGEXP.lastIndex = 0;
  14032. while (match = _SELECTOR_REGEXP.exec(selector)) {
  14033. if (match[1]) {
  14034. if (inNot) {
  14035. throw new Error('Nesting :not is not allowed in a selector');
  14036. }
  14037. inNot = true;
  14038. current = new CssSelector();
  14039. cssSelector.notSelectors.push(current);
  14040. }
  14041. if (match[2]) {
  14042. current.setElement(match[2]);
  14043. }
  14044. if (match[3]) {
  14045. current.addClassName(match[3]);
  14046. }
  14047. if (match[4]) {
  14048. current.addAttribute(match[4], match[6]);
  14049. }
  14050. if (match[7]) {
  14051. inNot = false;
  14052. current = cssSelector;
  14053. }
  14054. if (match[8]) {
  14055. if (inNot) {
  14056. throw new Error('Multiple selectors in :not are not supported');
  14057. }
  14058. _addResult(results, cssSelector);
  14059. cssSelector = current = new CssSelector();
  14060. }
  14061. }
  14062. _addResult(results, cssSelector);
  14063. return results;
  14064. };
  14065. /**
  14066. * @return {?}
  14067. */
  14068. CssSelector.prototype.isElementSelector = /**
  14069. * @return {?}
  14070. */
  14071. function () {
  14072. return this.hasElementSelector() && this.classNames.length == 0 && this.attrs.length == 0 &&
  14073. this.notSelectors.length === 0;
  14074. };
  14075. /**
  14076. * @return {?}
  14077. */
  14078. CssSelector.prototype.hasElementSelector = /**
  14079. * @return {?}
  14080. */
  14081. function () { return !!this.element; };
  14082. /**
  14083. * @param {?=} element
  14084. * @return {?}
  14085. */
  14086. CssSelector.prototype.setElement = /**
  14087. * @param {?=} element
  14088. * @return {?}
  14089. */
  14090. function (element) {
  14091. if (element === void 0) { element = null; }
  14092. this.element = element;
  14093. };
  14094. /** Gets a template string for an element that matches the selector. */
  14095. /**
  14096. * Gets a template string for an element that matches the selector.
  14097. * @return {?}
  14098. */
  14099. CssSelector.prototype.getMatchingElementTemplate = /**
  14100. * Gets a template string for an element that matches the selector.
  14101. * @return {?}
  14102. */
  14103. function () {
  14104. var /** @type {?} */ tagName = this.element || 'div';
  14105. var /** @type {?} */ classAttr = this.classNames.length > 0 ? " class=\"" + this.classNames.join(' ') + "\"" : '';
  14106. var /** @type {?} */ attrs = '';
  14107. for (var /** @type {?} */ i = 0; i < this.attrs.length; i += 2) {
  14108. var /** @type {?} */ attrName = this.attrs[i];
  14109. var /** @type {?} */ attrValue = this.attrs[i + 1] !== '' ? "=\"" + this.attrs[i + 1] + "\"" : '';
  14110. attrs += " " + attrName + attrValue;
  14111. }
  14112. return getHtmlTagDefinition(tagName).isVoid ? "<" + tagName + classAttr + attrs + "/>" :
  14113. "<" + tagName + classAttr + attrs + "></" + tagName + ">";
  14114. };
  14115. /**
  14116. * @param {?} name
  14117. * @param {?=} value
  14118. * @return {?}
  14119. */
  14120. CssSelector.prototype.addAttribute = /**
  14121. * @param {?} name
  14122. * @param {?=} value
  14123. * @return {?}
  14124. */
  14125. function (name, value) {
  14126. if (value === void 0) { value = ''; }
  14127. this.attrs.push(name, value && value.toLowerCase() || '');
  14128. };
  14129. /**
  14130. * @param {?} name
  14131. * @return {?}
  14132. */
  14133. CssSelector.prototype.addClassName = /**
  14134. * @param {?} name
  14135. * @return {?}
  14136. */
  14137. function (name) { this.classNames.push(name.toLowerCase()); };
  14138. /**
  14139. * @return {?}
  14140. */
  14141. CssSelector.prototype.toString = /**
  14142. * @return {?}
  14143. */
  14144. function () {
  14145. var /** @type {?} */ res = this.element || '';
  14146. if (this.classNames) {
  14147. this.classNames.forEach(function (klass) { return res += "." + klass; });
  14148. }
  14149. if (this.attrs) {
  14150. for (var /** @type {?} */ i = 0; i < this.attrs.length; i += 2) {
  14151. var /** @type {?} */ name_1 = this.attrs[i];
  14152. var /** @type {?} */ value = this.attrs[i + 1];
  14153. res += "[" + name_1 + (value ? '=' + value : '') + "]";
  14154. }
  14155. }
  14156. this.notSelectors.forEach(function (notSelector) { return res += ":not(" + notSelector + ")"; });
  14157. return res;
  14158. };
  14159. return CssSelector;
  14160. }());
  14161. /**
  14162. * Reads a list of CssSelectors and allows to calculate which ones
  14163. * are contained in a given CssSelector.
  14164. */
  14165. var SelectorMatcher = /** @class */ (function () {
  14166. function SelectorMatcher() {
  14167. this._elementMap = new Map();
  14168. this._elementPartialMap = new Map();
  14169. this._classMap = new Map();
  14170. this._classPartialMap = new Map();
  14171. this._attrValueMap = new Map();
  14172. this._attrValuePartialMap = new Map();
  14173. this._listContexts = [];
  14174. }
  14175. /**
  14176. * @param {?} notSelectors
  14177. * @return {?}
  14178. */
  14179. SelectorMatcher.createNotMatcher = /**
  14180. * @param {?} notSelectors
  14181. * @return {?}
  14182. */
  14183. function (notSelectors) {
  14184. var /** @type {?} */ notMatcher = new SelectorMatcher();
  14185. notMatcher.addSelectables(notSelectors, null);
  14186. return notMatcher;
  14187. };
  14188. /**
  14189. * @param {?} cssSelectors
  14190. * @param {?=} callbackCtxt
  14191. * @return {?}
  14192. */
  14193. SelectorMatcher.prototype.addSelectables = /**
  14194. * @param {?} cssSelectors
  14195. * @param {?=} callbackCtxt
  14196. * @return {?}
  14197. */
  14198. function (cssSelectors, callbackCtxt) {
  14199. var /** @type {?} */ listContext = /** @type {?} */ ((null));
  14200. if (cssSelectors.length > 1) {
  14201. listContext = new SelectorListContext(cssSelectors);
  14202. this._listContexts.push(listContext);
  14203. }
  14204. for (var /** @type {?} */ i = 0; i < cssSelectors.length; i++) {
  14205. this._addSelectable(cssSelectors[i], callbackCtxt, listContext);
  14206. }
  14207. };
  14208. /**
  14209. * Add an object that can be found later on by calling `match`.
  14210. * @param {?} cssSelector A css selector
  14211. * @param {?} callbackCtxt An opaque object that will be given to the callback of the `match` function
  14212. * @param {?} listContext
  14213. * @return {?}
  14214. */
  14215. SelectorMatcher.prototype._addSelectable = /**
  14216. * Add an object that can be found later on by calling `match`.
  14217. * @param {?} cssSelector A css selector
  14218. * @param {?} callbackCtxt An opaque object that will be given to the callback of the `match` function
  14219. * @param {?} listContext
  14220. * @return {?}
  14221. */
  14222. function (cssSelector, callbackCtxt, listContext) {
  14223. var /** @type {?} */ matcher = this;
  14224. var /** @type {?} */ element = cssSelector.element;
  14225. var /** @type {?} */ classNames = cssSelector.classNames;
  14226. var /** @type {?} */ attrs = cssSelector.attrs;
  14227. var /** @type {?} */ selectable = new SelectorContext(cssSelector, callbackCtxt, listContext);
  14228. if (element) {
  14229. var /** @type {?} */ isTerminal = attrs.length === 0 && classNames.length === 0;
  14230. if (isTerminal) {
  14231. this._addTerminal(matcher._elementMap, element, selectable);
  14232. }
  14233. else {
  14234. matcher = this._addPartial(matcher._elementPartialMap, element);
  14235. }
  14236. }
  14237. if (classNames) {
  14238. for (var /** @type {?} */ i = 0; i < classNames.length; i++) {
  14239. var /** @type {?} */ isTerminal = attrs.length === 0 && i === classNames.length - 1;
  14240. var /** @type {?} */ className = classNames[i];
  14241. if (isTerminal) {
  14242. this._addTerminal(matcher._classMap, className, selectable);
  14243. }
  14244. else {
  14245. matcher = this._addPartial(matcher._classPartialMap, className);
  14246. }
  14247. }
  14248. }
  14249. if (attrs) {
  14250. for (var /** @type {?} */ i = 0; i < attrs.length; i += 2) {
  14251. var /** @type {?} */ isTerminal = i === attrs.length - 2;
  14252. var /** @type {?} */ name_2 = attrs[i];
  14253. var /** @type {?} */ value = attrs[i + 1];
  14254. if (isTerminal) {
  14255. var /** @type {?} */ terminalMap = matcher._attrValueMap;
  14256. var /** @type {?} */ terminalValuesMap = terminalMap.get(name_2);
  14257. if (!terminalValuesMap) {
  14258. terminalValuesMap = new Map();
  14259. terminalMap.set(name_2, terminalValuesMap);
  14260. }
  14261. this._addTerminal(terminalValuesMap, value, selectable);
  14262. }
  14263. else {
  14264. var /** @type {?} */ partialMap = matcher._attrValuePartialMap;
  14265. var /** @type {?} */ partialValuesMap = partialMap.get(name_2);
  14266. if (!partialValuesMap) {
  14267. partialValuesMap = new Map();
  14268. partialMap.set(name_2, partialValuesMap);
  14269. }
  14270. matcher = this._addPartial(partialValuesMap, value);
  14271. }
  14272. }
  14273. }
  14274. };
  14275. /**
  14276. * @param {?} map
  14277. * @param {?} name
  14278. * @param {?} selectable
  14279. * @return {?}
  14280. */
  14281. SelectorMatcher.prototype._addTerminal = /**
  14282. * @param {?} map
  14283. * @param {?} name
  14284. * @param {?} selectable
  14285. * @return {?}
  14286. */
  14287. function (map, name, selectable) {
  14288. var /** @type {?} */ terminalList = map.get(name);
  14289. if (!terminalList) {
  14290. terminalList = [];
  14291. map.set(name, terminalList);
  14292. }
  14293. terminalList.push(selectable);
  14294. };
  14295. /**
  14296. * @param {?} map
  14297. * @param {?} name
  14298. * @return {?}
  14299. */
  14300. SelectorMatcher.prototype._addPartial = /**
  14301. * @param {?} map
  14302. * @param {?} name
  14303. * @return {?}
  14304. */
  14305. function (map, name) {
  14306. var /** @type {?} */ matcher = map.get(name);
  14307. if (!matcher) {
  14308. matcher = new SelectorMatcher();
  14309. map.set(name, matcher);
  14310. }
  14311. return matcher;
  14312. };
  14313. /**
  14314. * Find the objects that have been added via `addSelectable`
  14315. * whose css selector is contained in the given css selector.
  14316. * @param cssSelector A css selector
  14317. * @param matchedCallback This callback will be called with the object handed into `addSelectable`
  14318. * @return boolean true if a match was found
  14319. */
  14320. /**
  14321. * Find the objects that have been added via `addSelectable`
  14322. * whose css selector is contained in the given css selector.
  14323. * @param {?} cssSelector A css selector
  14324. * @param {?} matchedCallback This callback will be called with the object handed into `addSelectable`
  14325. * @return {?} boolean true if a match was found
  14326. */
  14327. SelectorMatcher.prototype.match = /**
  14328. * Find the objects that have been added via `addSelectable`
  14329. * whose css selector is contained in the given css selector.
  14330. * @param {?} cssSelector A css selector
  14331. * @param {?} matchedCallback This callback will be called with the object handed into `addSelectable`
  14332. * @return {?} boolean true if a match was found
  14333. */
  14334. function (cssSelector, matchedCallback) {
  14335. var /** @type {?} */ result = false;
  14336. var /** @type {?} */ element = /** @type {?} */ ((cssSelector.element));
  14337. var /** @type {?} */ classNames = cssSelector.classNames;
  14338. var /** @type {?} */ attrs = cssSelector.attrs;
  14339. for (var /** @type {?} */ i = 0; i < this._listContexts.length; i++) {
  14340. this._listContexts[i].alreadyMatched = false;
  14341. }
  14342. result = this._matchTerminal(this._elementMap, element, cssSelector, matchedCallback) || result;
  14343. result = this._matchPartial(this._elementPartialMap, element, cssSelector, matchedCallback) ||
  14344. result;
  14345. if (classNames) {
  14346. for (var /** @type {?} */ i = 0; i < classNames.length; i++) {
  14347. var /** @type {?} */ className = classNames[i];
  14348. result =
  14349. this._matchTerminal(this._classMap, className, cssSelector, matchedCallback) || result;
  14350. result =
  14351. this._matchPartial(this._classPartialMap, className, cssSelector, matchedCallback) ||
  14352. result;
  14353. }
  14354. }
  14355. if (attrs) {
  14356. for (var /** @type {?} */ i = 0; i < attrs.length; i += 2) {
  14357. var /** @type {?} */ name_3 = attrs[i];
  14358. var /** @type {?} */ value = attrs[i + 1];
  14359. var /** @type {?} */ terminalValuesMap = /** @type {?} */ ((this._attrValueMap.get(name_3)));
  14360. if (value) {
  14361. result =
  14362. this._matchTerminal(terminalValuesMap, '', cssSelector, matchedCallback) || result;
  14363. }
  14364. result =
  14365. this._matchTerminal(terminalValuesMap, value, cssSelector, matchedCallback) || result;
  14366. var /** @type {?} */ partialValuesMap = /** @type {?} */ ((this._attrValuePartialMap.get(name_3)));
  14367. if (value) {
  14368. result = this._matchPartial(partialValuesMap, '', cssSelector, matchedCallback) || result;
  14369. }
  14370. result =
  14371. this._matchPartial(partialValuesMap, value, cssSelector, matchedCallback) || result;
  14372. }
  14373. }
  14374. return result;
  14375. };
  14376. /** @internal */
  14377. /**
  14378. * \@internal
  14379. * @param {?} map
  14380. * @param {?} name
  14381. * @param {?} cssSelector
  14382. * @param {?} matchedCallback
  14383. * @return {?}
  14384. */
  14385. SelectorMatcher.prototype._matchTerminal = /**
  14386. * \@internal
  14387. * @param {?} map
  14388. * @param {?} name
  14389. * @param {?} cssSelector
  14390. * @param {?} matchedCallback
  14391. * @return {?}
  14392. */
  14393. function (map, name, cssSelector, matchedCallback) {
  14394. if (!map || typeof name !== 'string') {
  14395. return false;
  14396. }
  14397. var /** @type {?} */ selectables = map.get(name) || [];
  14398. var /** @type {?} */ starSelectables = /** @type {?} */ ((map.get('*')));
  14399. if (starSelectables) {
  14400. selectables = selectables.concat(starSelectables);
  14401. }
  14402. if (selectables.length === 0) {
  14403. return false;
  14404. }
  14405. var /** @type {?} */ selectable;
  14406. var /** @type {?} */ result = false;
  14407. for (var /** @type {?} */ i = 0; i < selectables.length; i++) {
  14408. selectable = selectables[i];
  14409. result = selectable.finalize(cssSelector, matchedCallback) || result;
  14410. }
  14411. return result;
  14412. };
  14413. /** @internal */
  14414. /**
  14415. * \@internal
  14416. * @param {?} map
  14417. * @param {?} name
  14418. * @param {?} cssSelector
  14419. * @param {?} matchedCallback
  14420. * @return {?}
  14421. */
  14422. SelectorMatcher.prototype._matchPartial = /**
  14423. * \@internal
  14424. * @param {?} map
  14425. * @param {?} name
  14426. * @param {?} cssSelector
  14427. * @param {?} matchedCallback
  14428. * @return {?}
  14429. */
  14430. function (map, name, cssSelector, matchedCallback) {
  14431. if (!map || typeof name !== 'string') {
  14432. return false;
  14433. }
  14434. var /** @type {?} */ nestedSelector = map.get(name);
  14435. if (!nestedSelector) {
  14436. return false;
  14437. }
  14438. // TODO(perf): get rid of recursion and measure again
  14439. // TODO(perf): don't pass the whole selector into the recursion,
  14440. // but only the not processed parts
  14441. return nestedSelector.match(cssSelector, matchedCallback);
  14442. };
  14443. return SelectorMatcher;
  14444. }());
  14445. var SelectorListContext = /** @class */ (function () {
  14446. function SelectorListContext(selectors) {
  14447. this.selectors = selectors;
  14448. this.alreadyMatched = false;
  14449. }
  14450. return SelectorListContext;
  14451. }());
  14452. var SelectorContext = /** @class */ (function () {
  14453. function SelectorContext(selector, cbContext, listContext) {
  14454. this.selector = selector;
  14455. this.cbContext = cbContext;
  14456. this.listContext = listContext;
  14457. this.notSelectors = selector.notSelectors;
  14458. }
  14459. /**
  14460. * @param {?} cssSelector
  14461. * @param {?} callback
  14462. * @return {?}
  14463. */
  14464. SelectorContext.prototype.finalize = /**
  14465. * @param {?} cssSelector
  14466. * @param {?} callback
  14467. * @return {?}
  14468. */
  14469. function (cssSelector, callback) {
  14470. var /** @type {?} */ result = true;
  14471. if (this.notSelectors.length > 0 && (!this.listContext || !this.listContext.alreadyMatched)) {
  14472. var /** @type {?} */ notMatcher = SelectorMatcher.createNotMatcher(this.notSelectors);
  14473. result = !notMatcher.match(cssSelector, null);
  14474. }
  14475. if (result && callback && (!this.listContext || !this.listContext.alreadyMatched)) {
  14476. if (this.listContext) {
  14477. this.listContext.alreadyMatched = true;
  14478. }
  14479. callback(this.selector, this.cbContext);
  14480. }
  14481. return result;
  14482. };
  14483. return SelectorContext;
  14484. }());
  14485. /**
  14486. * @fileoverview added by tsickle
  14487. * @suppress {checkTypes} checked by tsc
  14488. */
  14489. /**
  14490. * @license
  14491. * Copyright Google Inc. All Rights Reserved.
  14492. *
  14493. * Use of this source code is governed by an MIT-style license that can be
  14494. * found in the LICENSE file at https://angular.io/license
  14495. */
  14496. var ERROR_COMPONENT_TYPE = 'ngComponentType';
  14497. var CompileMetadataResolver = /** @class */ (function () {
  14498. function CompileMetadataResolver(_config, _htmlParser, _ngModuleResolver, _directiveResolver, _pipeResolver, _summaryResolver, _schemaRegistry, _directiveNormalizer, _console, _staticSymbolCache, _reflector, _errorCollector) {
  14499. this._config = _config;
  14500. this._htmlParser = _htmlParser;
  14501. this._ngModuleResolver = _ngModuleResolver;
  14502. this._directiveResolver = _directiveResolver;
  14503. this._pipeResolver = _pipeResolver;
  14504. this._summaryResolver = _summaryResolver;
  14505. this._schemaRegistry = _schemaRegistry;
  14506. this._directiveNormalizer = _directiveNormalizer;
  14507. this._console = _console;
  14508. this._staticSymbolCache = _staticSymbolCache;
  14509. this._reflector = _reflector;
  14510. this._errorCollector = _errorCollector;
  14511. this._nonNormalizedDirectiveCache = new Map();
  14512. this._directiveCache = new Map();
  14513. this._summaryCache = new Map();
  14514. this._pipeCache = new Map();
  14515. this._ngModuleCache = new Map();
  14516. this._ngModuleOfTypes = new Map();
  14517. }
  14518. /**
  14519. * @return {?}
  14520. */
  14521. CompileMetadataResolver.prototype.getReflector = /**
  14522. * @return {?}
  14523. */
  14524. function () { return this._reflector; };
  14525. /**
  14526. * @param {?} type
  14527. * @return {?}
  14528. */
  14529. CompileMetadataResolver.prototype.clearCacheFor = /**
  14530. * @param {?} type
  14531. * @return {?}
  14532. */
  14533. function (type) {
  14534. var /** @type {?} */ dirMeta = this._directiveCache.get(type);
  14535. this._directiveCache.delete(type);
  14536. this._nonNormalizedDirectiveCache.delete(type);
  14537. this._summaryCache.delete(type);
  14538. this._pipeCache.delete(type);
  14539. this._ngModuleOfTypes.delete(type);
  14540. // Clear all of the NgModule as they contain transitive information!
  14541. this._ngModuleCache.clear();
  14542. if (dirMeta) {
  14543. this._directiveNormalizer.clearCacheFor(dirMeta);
  14544. }
  14545. };
  14546. /**
  14547. * @return {?}
  14548. */
  14549. CompileMetadataResolver.prototype.clearCache = /**
  14550. * @return {?}
  14551. */
  14552. function () {
  14553. this._directiveCache.clear();
  14554. this._nonNormalizedDirectiveCache.clear();
  14555. this._summaryCache.clear();
  14556. this._pipeCache.clear();
  14557. this._ngModuleCache.clear();
  14558. this._ngModuleOfTypes.clear();
  14559. this._directiveNormalizer.clearCache();
  14560. };
  14561. /**
  14562. * @param {?} baseType
  14563. * @param {?} name
  14564. * @return {?}
  14565. */
  14566. CompileMetadataResolver.prototype._createProxyClass = /**
  14567. * @param {?} baseType
  14568. * @param {?} name
  14569. * @return {?}
  14570. */
  14571. function (baseType, name) {
  14572. var /** @type {?} */ delegate = null;
  14573. var /** @type {?} */ proxyClass = /** @type {?} */ (function () {
  14574. if (!delegate) {
  14575. throw new Error("Illegal state: Class " + name + " for type " + stringify(baseType) + " is not compiled yet!");
  14576. }
  14577. return delegate.apply(this, arguments);
  14578. });
  14579. proxyClass.setDelegate = function (d) {
  14580. delegate = d;
  14581. (/** @type {?} */ (proxyClass)).prototype = d.prototype;
  14582. };
  14583. // Make stringify work correctly
  14584. (/** @type {?} */ (proxyClass)).overriddenName = name;
  14585. return proxyClass;
  14586. };
  14587. /**
  14588. * @param {?} dirType
  14589. * @param {?} name
  14590. * @return {?}
  14591. */
  14592. CompileMetadataResolver.prototype.getGeneratedClass = /**
  14593. * @param {?} dirType
  14594. * @param {?} name
  14595. * @return {?}
  14596. */
  14597. function (dirType, name) {
  14598. if (dirType instanceof StaticSymbol) {
  14599. return this._staticSymbolCache.get(ngfactoryFilePath(dirType.filePath), name);
  14600. }
  14601. else {
  14602. return this._createProxyClass(dirType, name);
  14603. }
  14604. };
  14605. /**
  14606. * @param {?} dirType
  14607. * @return {?}
  14608. */
  14609. CompileMetadataResolver.prototype.getComponentViewClass = /**
  14610. * @param {?} dirType
  14611. * @return {?}
  14612. */
  14613. function (dirType) {
  14614. return this.getGeneratedClass(dirType, viewClassName(dirType, 0));
  14615. };
  14616. /**
  14617. * @param {?} dirType
  14618. * @return {?}
  14619. */
  14620. CompileMetadataResolver.prototype.getHostComponentViewClass = /**
  14621. * @param {?} dirType
  14622. * @return {?}
  14623. */
  14624. function (dirType) {
  14625. return this.getGeneratedClass(dirType, hostViewClassName(dirType));
  14626. };
  14627. /**
  14628. * @param {?} dirType
  14629. * @return {?}
  14630. */
  14631. CompileMetadataResolver.prototype.getHostComponentType = /**
  14632. * @param {?} dirType
  14633. * @return {?}
  14634. */
  14635. function (dirType) {
  14636. var /** @type {?} */ name = identifierName({ reference: dirType }) + "_Host";
  14637. if (dirType instanceof StaticSymbol) {
  14638. return this._staticSymbolCache.get(dirType.filePath, name);
  14639. }
  14640. else {
  14641. var /** @type {?} */ HostClass = /** @type {?} */ (function HostClass() { });
  14642. HostClass.overriddenName = name;
  14643. return HostClass;
  14644. }
  14645. };
  14646. /**
  14647. * @param {?} dirType
  14648. * @return {?}
  14649. */
  14650. CompileMetadataResolver.prototype.getRendererType = /**
  14651. * @param {?} dirType
  14652. * @return {?}
  14653. */
  14654. function (dirType) {
  14655. if (dirType instanceof StaticSymbol) {
  14656. return this._staticSymbolCache.get(ngfactoryFilePath(dirType.filePath), rendererTypeName(dirType));
  14657. }
  14658. else {
  14659. // returning an object as proxy,
  14660. // that we fill later during runtime compilation.
  14661. return /** @type {?} */ ({});
  14662. }
  14663. };
  14664. /**
  14665. * @param {?} selector
  14666. * @param {?} dirType
  14667. * @param {?} inputs
  14668. * @param {?} outputs
  14669. * @return {?}
  14670. */
  14671. CompileMetadataResolver.prototype.getComponentFactory = /**
  14672. * @param {?} selector
  14673. * @param {?} dirType
  14674. * @param {?} inputs
  14675. * @param {?} outputs
  14676. * @return {?}
  14677. */
  14678. function (selector, dirType, inputs, outputs) {
  14679. if (dirType instanceof StaticSymbol) {
  14680. return this._staticSymbolCache.get(ngfactoryFilePath(dirType.filePath), componentFactoryName(dirType));
  14681. }
  14682. else {
  14683. var /** @type {?} */ hostView = this.getHostComponentViewClass(dirType);
  14684. // Note: ngContentSelectors will be filled later once the template is
  14685. // loaded.
  14686. var /** @type {?} */ createComponentFactory = this._reflector.resolveExternalReference(Identifiers.createComponentFactory);
  14687. return createComponentFactory(selector, dirType, /** @type {?} */ (hostView), inputs, outputs, []);
  14688. }
  14689. };
  14690. /**
  14691. * @param {?} factory
  14692. * @param {?} ngContentSelectors
  14693. * @return {?}
  14694. */
  14695. CompileMetadataResolver.prototype.initComponentFactory = /**
  14696. * @param {?} factory
  14697. * @param {?} ngContentSelectors
  14698. * @return {?}
  14699. */
  14700. function (factory, ngContentSelectors) {
  14701. if (!(factory instanceof StaticSymbol)) {
  14702. (_a = (/** @type {?} */ (factory)).ngContentSelectors).push.apply(_a, ngContentSelectors);
  14703. }
  14704. var _a;
  14705. };
  14706. /**
  14707. * @param {?} type
  14708. * @param {?} kind
  14709. * @return {?}
  14710. */
  14711. CompileMetadataResolver.prototype._loadSummary = /**
  14712. * @param {?} type
  14713. * @param {?} kind
  14714. * @return {?}
  14715. */
  14716. function (type, kind) {
  14717. var /** @type {?} */ typeSummary = this._summaryCache.get(type);
  14718. if (!typeSummary) {
  14719. var /** @type {?} */ summary = this._summaryResolver.resolveSummary(type);
  14720. typeSummary = summary ? summary.type : null;
  14721. this._summaryCache.set(type, typeSummary || null);
  14722. }
  14723. return typeSummary && typeSummary.summaryKind === kind ? typeSummary : null;
  14724. };
  14725. /**
  14726. * @param {?} compMeta
  14727. * @param {?=} hostViewType
  14728. * @return {?}
  14729. */
  14730. CompileMetadataResolver.prototype.getHostComponentMetadata = /**
  14731. * @param {?} compMeta
  14732. * @param {?=} hostViewType
  14733. * @return {?}
  14734. */
  14735. function (compMeta, hostViewType) {
  14736. var /** @type {?} */ hostType = this.getHostComponentType(compMeta.type.reference);
  14737. if (!hostViewType) {
  14738. hostViewType = this.getHostComponentViewClass(hostType);
  14739. }
  14740. // Note: ! is ok here as this method should only be called with normalized directive
  14741. // metadata, which always fills in the selector.
  14742. var /** @type {?} */ template = CssSelector.parse(/** @type {?} */ ((compMeta.selector)))[0].getMatchingElementTemplate();
  14743. var /** @type {?} */ templateUrl = '';
  14744. var /** @type {?} */ htmlAst = this._htmlParser.parse(template, templateUrl);
  14745. return CompileDirectiveMetadata.create({
  14746. isHost: true,
  14747. type: { reference: hostType, diDeps: [], lifecycleHooks: [] },
  14748. template: new CompileTemplateMetadata({
  14749. encapsulation: ViewEncapsulation.None,
  14750. template: template,
  14751. templateUrl: templateUrl,
  14752. htmlAst: htmlAst,
  14753. styles: [],
  14754. styleUrls: [],
  14755. ngContentSelectors: [],
  14756. animations: [],
  14757. isInline: true,
  14758. externalStylesheets: [],
  14759. interpolation: null,
  14760. preserveWhitespaces: false,
  14761. }),
  14762. exportAs: null,
  14763. changeDetection: ChangeDetectionStrategy.Default,
  14764. inputs: [],
  14765. outputs: [],
  14766. host: {},
  14767. isComponent: true,
  14768. selector: '*',
  14769. providers: [],
  14770. viewProviders: [],
  14771. queries: [],
  14772. guards: {},
  14773. viewQueries: [],
  14774. componentViewType: hostViewType,
  14775. rendererType: /** @type {?} */ ({ id: '__Host__', encapsulation: ViewEncapsulation.None, styles: [], data: {} }),
  14776. entryComponents: [],
  14777. componentFactory: null
  14778. });
  14779. };
  14780. /**
  14781. * @param {?} ngModuleType
  14782. * @param {?} directiveType
  14783. * @param {?} isSync
  14784. * @return {?}
  14785. */
  14786. CompileMetadataResolver.prototype.loadDirectiveMetadata = /**
  14787. * @param {?} ngModuleType
  14788. * @param {?} directiveType
  14789. * @param {?} isSync
  14790. * @return {?}
  14791. */
  14792. function (ngModuleType, directiveType, isSync) {
  14793. var _this = this;
  14794. if (this._directiveCache.has(directiveType)) {
  14795. return null;
  14796. }
  14797. directiveType = resolveForwardRef(directiveType);
  14798. var _a = /** @type {?} */ ((this.getNonNormalizedDirectiveMetadata(directiveType))), annotation = _a.annotation, metadata = _a.metadata;
  14799. var /** @type {?} */ createDirectiveMetadata = function (templateMetadata) {
  14800. var /** @type {?} */ normalizedDirMeta = new CompileDirectiveMetadata({
  14801. isHost: false,
  14802. type: metadata.type,
  14803. isComponent: metadata.isComponent,
  14804. selector: metadata.selector,
  14805. exportAs: metadata.exportAs,
  14806. changeDetection: metadata.changeDetection,
  14807. inputs: metadata.inputs,
  14808. outputs: metadata.outputs,
  14809. hostListeners: metadata.hostListeners,
  14810. hostProperties: metadata.hostProperties,
  14811. hostAttributes: metadata.hostAttributes,
  14812. providers: metadata.providers,
  14813. viewProviders: metadata.viewProviders,
  14814. queries: metadata.queries,
  14815. guards: metadata.guards,
  14816. viewQueries: metadata.viewQueries,
  14817. entryComponents: metadata.entryComponents,
  14818. componentViewType: metadata.componentViewType,
  14819. rendererType: metadata.rendererType,
  14820. componentFactory: metadata.componentFactory,
  14821. template: templateMetadata
  14822. });
  14823. if (templateMetadata) {
  14824. _this.initComponentFactory(/** @type {?} */ ((metadata.componentFactory)), templateMetadata.ngContentSelectors);
  14825. }
  14826. _this._directiveCache.set(directiveType, normalizedDirMeta);
  14827. _this._summaryCache.set(directiveType, normalizedDirMeta.toSummary());
  14828. return null;
  14829. };
  14830. if (metadata.isComponent) {
  14831. var /** @type {?} */ template = /** @type {?} */ ((metadata.template));
  14832. var /** @type {?} */ templateMeta = this._directiveNormalizer.normalizeTemplate({
  14833. ngModuleType: ngModuleType,
  14834. componentType: directiveType,
  14835. moduleUrl: this._reflector.componentModuleUrl(directiveType, annotation),
  14836. encapsulation: template.encapsulation,
  14837. template: template.template,
  14838. templateUrl: template.templateUrl,
  14839. styles: template.styles,
  14840. styleUrls: template.styleUrls,
  14841. animations: template.animations,
  14842. interpolation: template.interpolation,
  14843. preserveWhitespaces: template.preserveWhitespaces
  14844. });
  14845. if (isPromise(templateMeta) && isSync) {
  14846. this._reportError(componentStillLoadingError(directiveType), directiveType);
  14847. return null;
  14848. }
  14849. return SyncAsync.then(templateMeta, createDirectiveMetadata);
  14850. }
  14851. else {
  14852. // directive
  14853. createDirectiveMetadata(null);
  14854. return null;
  14855. }
  14856. };
  14857. /**
  14858. * @param {?} directiveType
  14859. * @return {?}
  14860. */
  14861. CompileMetadataResolver.prototype.getNonNormalizedDirectiveMetadata = /**
  14862. * @param {?} directiveType
  14863. * @return {?}
  14864. */
  14865. function (directiveType) {
  14866. var _this = this;
  14867. directiveType = resolveForwardRef(directiveType);
  14868. if (!directiveType) {
  14869. return null;
  14870. }
  14871. var /** @type {?} */ cacheEntry = this._nonNormalizedDirectiveCache.get(directiveType);
  14872. if (cacheEntry) {
  14873. return cacheEntry;
  14874. }
  14875. var /** @type {?} */ dirMeta = this._directiveResolver.resolve(directiveType, false);
  14876. if (!dirMeta) {
  14877. return null;
  14878. }
  14879. var /** @type {?} */ nonNormalizedTemplateMetadata = /** @type {?} */ ((undefined));
  14880. if (createComponent.isTypeOf(dirMeta)) {
  14881. // component
  14882. var /** @type {?} */ compMeta = /** @type {?} */ (dirMeta);
  14883. assertArrayOfStrings('styles', compMeta.styles);
  14884. assertArrayOfStrings('styleUrls', compMeta.styleUrls);
  14885. assertInterpolationSymbols('interpolation', compMeta.interpolation);
  14886. var /** @type {?} */ animations = compMeta.animations;
  14887. nonNormalizedTemplateMetadata = new CompileTemplateMetadata({
  14888. encapsulation: noUndefined(compMeta.encapsulation),
  14889. template: noUndefined(compMeta.template),
  14890. templateUrl: noUndefined(compMeta.templateUrl),
  14891. htmlAst: null,
  14892. styles: compMeta.styles || [],
  14893. styleUrls: compMeta.styleUrls || [],
  14894. animations: animations || [],
  14895. interpolation: noUndefined(compMeta.interpolation),
  14896. isInline: !!compMeta.template,
  14897. externalStylesheets: [],
  14898. ngContentSelectors: [],
  14899. preserveWhitespaces: noUndefined(dirMeta.preserveWhitespaces),
  14900. });
  14901. }
  14902. var /** @type {?} */ changeDetectionStrategy = /** @type {?} */ ((null));
  14903. var /** @type {?} */ viewProviders = [];
  14904. var /** @type {?} */ entryComponentMetadata = [];
  14905. var /** @type {?} */ selector = dirMeta.selector;
  14906. if (createComponent.isTypeOf(dirMeta)) {
  14907. // Component
  14908. var /** @type {?} */ compMeta = /** @type {?} */ (dirMeta);
  14909. changeDetectionStrategy = /** @type {?} */ ((compMeta.changeDetection));
  14910. if (compMeta.viewProviders) {
  14911. viewProviders = this._getProvidersMetadata(compMeta.viewProviders, entryComponentMetadata, "viewProviders for \"" + stringifyType(directiveType) + "\"", [], directiveType);
  14912. }
  14913. if (compMeta.entryComponents) {
  14914. entryComponentMetadata = flattenAndDedupeArray(compMeta.entryComponents)
  14915. .map(function (type) { return ((_this._getEntryComponentMetadata(type))); })
  14916. .concat(entryComponentMetadata);
  14917. }
  14918. if (!selector) {
  14919. selector = this._schemaRegistry.getDefaultComponentElementName();
  14920. }
  14921. }
  14922. else {
  14923. // Directive
  14924. if (!selector) {
  14925. this._reportError(syntaxError("Directive " + stringifyType(directiveType) + " has no selector, please add it!"), directiveType);
  14926. selector = 'error';
  14927. }
  14928. }
  14929. var /** @type {?} */ providers = [];
  14930. if (dirMeta.providers != null) {
  14931. providers = this._getProvidersMetadata(dirMeta.providers, entryComponentMetadata, "providers for \"" + stringifyType(directiveType) + "\"", [], directiveType);
  14932. }
  14933. var /** @type {?} */ queries = [];
  14934. var /** @type {?} */ viewQueries = [];
  14935. if (dirMeta.queries != null) {
  14936. queries = this._getQueriesMetadata(dirMeta.queries, false, directiveType);
  14937. viewQueries = this._getQueriesMetadata(dirMeta.queries, true, directiveType);
  14938. }
  14939. var /** @type {?} */ metadata = CompileDirectiveMetadata.create({
  14940. isHost: false,
  14941. selector: selector,
  14942. exportAs: noUndefined(dirMeta.exportAs),
  14943. isComponent: !!nonNormalizedTemplateMetadata,
  14944. type: this._getTypeMetadata(directiveType),
  14945. template: nonNormalizedTemplateMetadata,
  14946. changeDetection: changeDetectionStrategy,
  14947. inputs: dirMeta.inputs || [],
  14948. outputs: dirMeta.outputs || [],
  14949. host: dirMeta.host || {},
  14950. providers: providers || [],
  14951. viewProviders: viewProviders || [],
  14952. queries: queries || [],
  14953. guards: dirMeta.guards || {},
  14954. viewQueries: viewQueries || [],
  14955. entryComponents: entryComponentMetadata,
  14956. componentViewType: nonNormalizedTemplateMetadata ? this.getComponentViewClass(directiveType) :
  14957. null,
  14958. rendererType: nonNormalizedTemplateMetadata ? this.getRendererType(directiveType) : null,
  14959. componentFactory: null
  14960. });
  14961. if (nonNormalizedTemplateMetadata) {
  14962. metadata.componentFactory =
  14963. this.getComponentFactory(selector, directiveType, metadata.inputs, metadata.outputs);
  14964. }
  14965. cacheEntry = { metadata: metadata, annotation: dirMeta };
  14966. this._nonNormalizedDirectiveCache.set(directiveType, cacheEntry);
  14967. return cacheEntry;
  14968. };
  14969. /**
  14970. * Gets the metadata for the given directive.
  14971. * This assumes `loadNgModuleDirectiveAndPipeMetadata` has been called first.
  14972. */
  14973. /**
  14974. * Gets the metadata for the given directive.
  14975. * This assumes `loadNgModuleDirectiveAndPipeMetadata` has been called first.
  14976. * @param {?} directiveType
  14977. * @return {?}
  14978. */
  14979. CompileMetadataResolver.prototype.getDirectiveMetadata = /**
  14980. * Gets the metadata for the given directive.
  14981. * This assumes `loadNgModuleDirectiveAndPipeMetadata` has been called first.
  14982. * @param {?} directiveType
  14983. * @return {?}
  14984. */
  14985. function (directiveType) {
  14986. var /** @type {?} */ dirMeta = /** @type {?} */ ((this._directiveCache.get(directiveType)));
  14987. if (!dirMeta) {
  14988. this._reportError(syntaxError("Illegal state: getDirectiveMetadata can only be called after loadNgModuleDirectiveAndPipeMetadata for a module that declares it. Directive " + stringifyType(directiveType) + "."), directiveType);
  14989. }
  14990. return dirMeta;
  14991. };
  14992. /**
  14993. * @param {?} dirType
  14994. * @return {?}
  14995. */
  14996. CompileMetadataResolver.prototype.getDirectiveSummary = /**
  14997. * @param {?} dirType
  14998. * @return {?}
  14999. */
  15000. function (dirType) {
  15001. var /** @type {?} */ dirSummary = /** @type {?} */ (this._loadSummary(dirType, CompileSummaryKind.Directive));
  15002. if (!dirSummary) {
  15003. this._reportError(syntaxError("Illegal state: Could not load the summary for directive " + stringifyType(dirType) + "."), dirType);
  15004. }
  15005. return dirSummary;
  15006. };
  15007. /**
  15008. * @param {?} type
  15009. * @return {?}
  15010. */
  15011. CompileMetadataResolver.prototype.isDirective = /**
  15012. * @param {?} type
  15013. * @return {?}
  15014. */
  15015. function (type) {
  15016. return !!this._loadSummary(type, CompileSummaryKind.Directive) ||
  15017. this._directiveResolver.isDirective(type);
  15018. };
  15019. /**
  15020. * @param {?} type
  15021. * @return {?}
  15022. */
  15023. CompileMetadataResolver.prototype.isPipe = /**
  15024. * @param {?} type
  15025. * @return {?}
  15026. */
  15027. function (type) {
  15028. return !!this._loadSummary(type, CompileSummaryKind.Pipe) ||
  15029. this._pipeResolver.isPipe(type);
  15030. };
  15031. /**
  15032. * @param {?} type
  15033. * @return {?}
  15034. */
  15035. CompileMetadataResolver.prototype.isNgModule = /**
  15036. * @param {?} type
  15037. * @return {?}
  15038. */
  15039. function (type) {
  15040. return !!this._loadSummary(type, CompileSummaryKind.NgModule) ||
  15041. this._ngModuleResolver.isNgModule(type);
  15042. };
  15043. /**
  15044. * @param {?} moduleType
  15045. * @param {?=} alreadyCollecting
  15046. * @return {?}
  15047. */
  15048. CompileMetadataResolver.prototype.getNgModuleSummary = /**
  15049. * @param {?} moduleType
  15050. * @param {?=} alreadyCollecting
  15051. * @return {?}
  15052. */
  15053. function (moduleType, alreadyCollecting) {
  15054. if (alreadyCollecting === void 0) { alreadyCollecting = null; }
  15055. var /** @type {?} */ moduleSummary = /** @type {?} */ (this._loadSummary(moduleType, CompileSummaryKind.NgModule));
  15056. if (!moduleSummary) {
  15057. var /** @type {?} */ moduleMeta = this.getNgModuleMetadata(moduleType, false, alreadyCollecting);
  15058. moduleSummary = moduleMeta ? moduleMeta.toSummary() : null;
  15059. if (moduleSummary) {
  15060. this._summaryCache.set(moduleType, moduleSummary);
  15061. }
  15062. }
  15063. return moduleSummary;
  15064. };
  15065. /**
  15066. * Loads the declared directives and pipes of an NgModule.
  15067. */
  15068. /**
  15069. * Loads the declared directives and pipes of an NgModule.
  15070. * @param {?} moduleType
  15071. * @param {?} isSync
  15072. * @param {?=} throwIfNotFound
  15073. * @return {?}
  15074. */
  15075. CompileMetadataResolver.prototype.loadNgModuleDirectiveAndPipeMetadata = /**
  15076. * Loads the declared directives and pipes of an NgModule.
  15077. * @param {?} moduleType
  15078. * @param {?} isSync
  15079. * @param {?=} throwIfNotFound
  15080. * @return {?}
  15081. */
  15082. function (moduleType, isSync, throwIfNotFound) {
  15083. var _this = this;
  15084. if (throwIfNotFound === void 0) { throwIfNotFound = true; }
  15085. var /** @type {?} */ ngModule = this.getNgModuleMetadata(moduleType, throwIfNotFound);
  15086. var /** @type {?} */ loading = [];
  15087. if (ngModule) {
  15088. ngModule.declaredDirectives.forEach(function (id) {
  15089. var /** @type {?} */ promise = _this.loadDirectiveMetadata(moduleType, id.reference, isSync);
  15090. if (promise) {
  15091. loading.push(promise);
  15092. }
  15093. });
  15094. ngModule.declaredPipes.forEach(function (id) { return _this._loadPipeMetadata(id.reference); });
  15095. }
  15096. return Promise.all(loading);
  15097. };
  15098. /**
  15099. * @param {?} moduleType
  15100. * @param {?=} throwIfNotFound
  15101. * @param {?=} alreadyCollecting
  15102. * @return {?}
  15103. */
  15104. CompileMetadataResolver.prototype.getNgModuleMetadata = /**
  15105. * @param {?} moduleType
  15106. * @param {?=} throwIfNotFound
  15107. * @param {?=} alreadyCollecting
  15108. * @return {?}
  15109. */
  15110. function (moduleType, throwIfNotFound, alreadyCollecting) {
  15111. var _this = this;
  15112. if (throwIfNotFound === void 0) { throwIfNotFound = true; }
  15113. if (alreadyCollecting === void 0) { alreadyCollecting = null; }
  15114. moduleType = resolveForwardRef(moduleType);
  15115. var /** @type {?} */ compileMeta = this._ngModuleCache.get(moduleType);
  15116. if (compileMeta) {
  15117. return compileMeta;
  15118. }
  15119. var /** @type {?} */ meta = this._ngModuleResolver.resolve(moduleType, throwIfNotFound);
  15120. if (!meta) {
  15121. return null;
  15122. }
  15123. var /** @type {?} */ declaredDirectives = [];
  15124. var /** @type {?} */ exportedNonModuleIdentifiers = [];
  15125. var /** @type {?} */ declaredPipes = [];
  15126. var /** @type {?} */ importedModules = [];
  15127. var /** @type {?} */ exportedModules = [];
  15128. var /** @type {?} */ providers = [];
  15129. var /** @type {?} */ entryComponents = [];
  15130. var /** @type {?} */ bootstrapComponents = [];
  15131. var /** @type {?} */ schemas = [];
  15132. if (meta.imports) {
  15133. flattenAndDedupeArray(meta.imports).forEach(function (importedType) {
  15134. var /** @type {?} */ importedModuleType = /** @type {?} */ ((undefined));
  15135. if (isValidType(importedType)) {
  15136. importedModuleType = importedType;
  15137. }
  15138. else if (importedType && importedType.ngModule) {
  15139. var /** @type {?} */ moduleWithProviders = importedType;
  15140. importedModuleType = moduleWithProviders.ngModule;
  15141. if (moduleWithProviders.providers) {
  15142. providers.push.apply(providers, _this._getProvidersMetadata(moduleWithProviders.providers, entryComponents, "provider for the NgModule '" + stringifyType(importedModuleType) + "'", [], importedType));
  15143. }
  15144. }
  15145. if (importedModuleType) {
  15146. if (_this._checkSelfImport(moduleType, importedModuleType))
  15147. return;
  15148. if (!alreadyCollecting)
  15149. alreadyCollecting = new Set();
  15150. if (alreadyCollecting.has(importedModuleType)) {
  15151. _this._reportError(syntaxError(_this._getTypeDescriptor(importedModuleType) + " '" + stringifyType(importedType) + "' is imported recursively by the module '" + stringifyType(moduleType) + "'."), moduleType);
  15152. return;
  15153. }
  15154. alreadyCollecting.add(importedModuleType);
  15155. var /** @type {?} */ importedModuleSummary = _this.getNgModuleSummary(importedModuleType, alreadyCollecting);
  15156. alreadyCollecting.delete(importedModuleType);
  15157. if (!importedModuleSummary) {
  15158. _this._reportError(syntaxError("Unexpected " + _this._getTypeDescriptor(importedType) + " '" + stringifyType(importedType) + "' imported by the module '" + stringifyType(moduleType) + "'. Please add a @NgModule annotation."), moduleType);
  15159. return;
  15160. }
  15161. importedModules.push(importedModuleSummary);
  15162. }
  15163. else {
  15164. _this._reportError(syntaxError("Unexpected value '" + stringifyType(importedType) + "' imported by the module '" + stringifyType(moduleType) + "'"), moduleType);
  15165. return;
  15166. }
  15167. });
  15168. }
  15169. if (meta.exports) {
  15170. flattenAndDedupeArray(meta.exports).forEach(function (exportedType) {
  15171. if (!isValidType(exportedType)) {
  15172. _this._reportError(syntaxError("Unexpected value '" + stringifyType(exportedType) + "' exported by the module '" + stringifyType(moduleType) + "'"), moduleType);
  15173. return;
  15174. }
  15175. if (!alreadyCollecting)
  15176. alreadyCollecting = new Set();
  15177. if (alreadyCollecting.has(exportedType)) {
  15178. _this._reportError(syntaxError(_this._getTypeDescriptor(exportedType) + " '" + stringify(exportedType) + "' is exported recursively by the module '" + stringifyType(moduleType) + "'"), moduleType);
  15179. return;
  15180. }
  15181. alreadyCollecting.add(exportedType);
  15182. var /** @type {?} */ exportedModuleSummary = _this.getNgModuleSummary(exportedType, alreadyCollecting);
  15183. alreadyCollecting.delete(exportedType);
  15184. if (exportedModuleSummary) {
  15185. exportedModules.push(exportedModuleSummary);
  15186. }
  15187. else {
  15188. exportedNonModuleIdentifiers.push(_this._getIdentifierMetadata(exportedType));
  15189. }
  15190. });
  15191. }
  15192. // Note: This will be modified later, so we rely on
  15193. // getting a new instance every time!
  15194. var /** @type {?} */ transitiveModule = this._getTransitiveNgModuleMetadata(importedModules, exportedModules);
  15195. if (meta.declarations) {
  15196. flattenAndDedupeArray(meta.declarations).forEach(function (declaredType) {
  15197. if (!isValidType(declaredType)) {
  15198. _this._reportError(syntaxError("Unexpected value '" + stringifyType(declaredType) + "' declared by the module '" + stringifyType(moduleType) + "'"), moduleType);
  15199. return;
  15200. }
  15201. var /** @type {?} */ declaredIdentifier = _this._getIdentifierMetadata(declaredType);
  15202. if (_this.isDirective(declaredType)) {
  15203. transitiveModule.addDirective(declaredIdentifier);
  15204. declaredDirectives.push(declaredIdentifier);
  15205. _this._addTypeToModule(declaredType, moduleType);
  15206. }
  15207. else if (_this.isPipe(declaredType)) {
  15208. transitiveModule.addPipe(declaredIdentifier);
  15209. transitiveModule.pipes.push(declaredIdentifier);
  15210. declaredPipes.push(declaredIdentifier);
  15211. _this._addTypeToModule(declaredType, moduleType);
  15212. }
  15213. else {
  15214. _this._reportError(syntaxError("Unexpected " + _this._getTypeDescriptor(declaredType) + " '" + stringifyType(declaredType) + "' declared by the module '" + stringifyType(moduleType) + "'. Please add a @Pipe/@Directive/@Component annotation."), moduleType);
  15215. return;
  15216. }
  15217. });
  15218. }
  15219. var /** @type {?} */ exportedDirectives = [];
  15220. var /** @type {?} */ exportedPipes = [];
  15221. exportedNonModuleIdentifiers.forEach(function (exportedId) {
  15222. if (transitiveModule.directivesSet.has(exportedId.reference)) {
  15223. exportedDirectives.push(exportedId);
  15224. transitiveModule.addExportedDirective(exportedId);
  15225. }
  15226. else if (transitiveModule.pipesSet.has(exportedId.reference)) {
  15227. exportedPipes.push(exportedId);
  15228. transitiveModule.addExportedPipe(exportedId);
  15229. }
  15230. else {
  15231. _this._reportError(syntaxError("Can't export " + _this._getTypeDescriptor(exportedId.reference) + " " + stringifyType(exportedId.reference) + " from " + stringifyType(moduleType) + " as it was neither declared nor imported!"), moduleType);
  15232. return;
  15233. }
  15234. });
  15235. // The providers of the module have to go last
  15236. // so that they overwrite any other provider we already added.
  15237. if (meta.providers) {
  15238. providers.push.apply(providers, this._getProvidersMetadata(meta.providers, entryComponents, "provider for the NgModule '" + stringifyType(moduleType) + "'", [], moduleType));
  15239. }
  15240. if (meta.entryComponents) {
  15241. entryComponents.push.apply(entryComponents, flattenAndDedupeArray(meta.entryComponents)
  15242. .map(function (type) { return ((_this._getEntryComponentMetadata(type))); }));
  15243. }
  15244. if (meta.bootstrap) {
  15245. flattenAndDedupeArray(meta.bootstrap).forEach(function (type) {
  15246. if (!isValidType(type)) {
  15247. _this._reportError(syntaxError("Unexpected value '" + stringifyType(type) + "' used in the bootstrap property of module '" + stringifyType(moduleType) + "'"), moduleType);
  15248. return;
  15249. }
  15250. bootstrapComponents.push(_this._getIdentifierMetadata(type));
  15251. });
  15252. }
  15253. entryComponents.push.apply(entryComponents, bootstrapComponents.map(function (type) { return ((_this._getEntryComponentMetadata(type.reference))); }));
  15254. if (meta.schemas) {
  15255. schemas.push.apply(schemas, flattenAndDedupeArray(meta.schemas));
  15256. }
  15257. compileMeta = new CompileNgModuleMetadata({
  15258. type: this._getTypeMetadata(moduleType),
  15259. providers: providers,
  15260. entryComponents: entryComponents,
  15261. bootstrapComponents: bootstrapComponents,
  15262. schemas: schemas,
  15263. declaredDirectives: declaredDirectives,
  15264. exportedDirectives: exportedDirectives,
  15265. declaredPipes: declaredPipes,
  15266. exportedPipes: exportedPipes,
  15267. importedModules: importedModules,
  15268. exportedModules: exportedModules,
  15269. transitiveModule: transitiveModule,
  15270. id: meta.id || null,
  15271. });
  15272. entryComponents.forEach(function (id) { return transitiveModule.addEntryComponent(id); });
  15273. providers.forEach(function (provider) { return transitiveModule.addProvider(provider, /** @type {?} */ ((compileMeta)).type); });
  15274. transitiveModule.addModule(compileMeta.type);
  15275. this._ngModuleCache.set(moduleType, compileMeta);
  15276. return compileMeta;
  15277. };
  15278. /**
  15279. * @param {?} moduleType
  15280. * @param {?} importedModuleType
  15281. * @return {?}
  15282. */
  15283. CompileMetadataResolver.prototype._checkSelfImport = /**
  15284. * @param {?} moduleType
  15285. * @param {?} importedModuleType
  15286. * @return {?}
  15287. */
  15288. function (moduleType, importedModuleType) {
  15289. if (moduleType === importedModuleType) {
  15290. this._reportError(syntaxError("'" + stringifyType(moduleType) + "' module can't import itself"), moduleType);
  15291. return true;
  15292. }
  15293. return false;
  15294. };
  15295. /**
  15296. * @param {?} type
  15297. * @return {?}
  15298. */
  15299. CompileMetadataResolver.prototype._getTypeDescriptor = /**
  15300. * @param {?} type
  15301. * @return {?}
  15302. */
  15303. function (type) {
  15304. if (isValidType(type)) {
  15305. if (this.isDirective(type)) {
  15306. return 'directive';
  15307. }
  15308. if (this.isPipe(type)) {
  15309. return 'pipe';
  15310. }
  15311. if (this.isNgModule(type)) {
  15312. return 'module';
  15313. }
  15314. }
  15315. if ((/** @type {?} */ (type)).provide) {
  15316. return 'provider';
  15317. }
  15318. return 'value';
  15319. };
  15320. /**
  15321. * @param {?} type
  15322. * @param {?} moduleType
  15323. * @return {?}
  15324. */
  15325. CompileMetadataResolver.prototype._addTypeToModule = /**
  15326. * @param {?} type
  15327. * @param {?} moduleType
  15328. * @return {?}
  15329. */
  15330. function (type, moduleType) {
  15331. var /** @type {?} */ oldModule = this._ngModuleOfTypes.get(type);
  15332. if (oldModule && oldModule !== moduleType) {
  15333. this._reportError(syntaxError("Type " + stringifyType(type) + " is part of the declarations of 2 modules: " + stringifyType(oldModule) + " and " + stringifyType(moduleType) + "! " +
  15334. ("Please consider moving " + stringifyType(type) + " to a higher module that imports " + stringifyType(oldModule) + " and " + stringifyType(moduleType) + ". ") +
  15335. ("You can also create a new NgModule that exports and includes " + stringifyType(type) + " then import that NgModule in " + stringifyType(oldModule) + " and " + stringifyType(moduleType) + ".")), moduleType);
  15336. return;
  15337. }
  15338. this._ngModuleOfTypes.set(type, moduleType);
  15339. };
  15340. /**
  15341. * @param {?} importedModules
  15342. * @param {?} exportedModules
  15343. * @return {?}
  15344. */
  15345. CompileMetadataResolver.prototype._getTransitiveNgModuleMetadata = /**
  15346. * @param {?} importedModules
  15347. * @param {?} exportedModules
  15348. * @return {?}
  15349. */
  15350. function (importedModules, exportedModules) {
  15351. // collect `providers` / `entryComponents` from all imported and all exported modules
  15352. var /** @type {?} */ result = new TransitiveCompileNgModuleMetadata();
  15353. var /** @type {?} */ modulesByToken = new Map();
  15354. importedModules.concat(exportedModules).forEach(function (modSummary) {
  15355. modSummary.modules.forEach(function (mod) { return result.addModule(mod); });
  15356. modSummary.entryComponents.forEach(function (comp) { return result.addEntryComponent(comp); });
  15357. var /** @type {?} */ addedTokens = new Set();
  15358. modSummary.providers.forEach(function (entry) {
  15359. var /** @type {?} */ tokenRef = tokenReference(entry.provider.token);
  15360. var /** @type {?} */ prevModules = modulesByToken.get(tokenRef);
  15361. if (!prevModules) {
  15362. prevModules = new Set();
  15363. modulesByToken.set(tokenRef, prevModules);
  15364. }
  15365. var /** @type {?} */ moduleRef = entry.module.reference;
  15366. // Note: the providers of one module may still contain multiple providers
  15367. // per token (e.g. for multi providers), and we need to preserve these.
  15368. if (addedTokens.has(tokenRef) || !prevModules.has(moduleRef)) {
  15369. prevModules.add(moduleRef);
  15370. addedTokens.add(tokenRef);
  15371. result.addProvider(entry.provider, entry.module);
  15372. }
  15373. });
  15374. });
  15375. exportedModules.forEach(function (modSummary) {
  15376. modSummary.exportedDirectives.forEach(function (id) { return result.addExportedDirective(id); });
  15377. modSummary.exportedPipes.forEach(function (id) { return result.addExportedPipe(id); });
  15378. });
  15379. importedModules.forEach(function (modSummary) {
  15380. modSummary.exportedDirectives.forEach(function (id) { return result.addDirective(id); });
  15381. modSummary.exportedPipes.forEach(function (id) { return result.addPipe(id); });
  15382. });
  15383. return result;
  15384. };
  15385. /**
  15386. * @param {?} type
  15387. * @return {?}
  15388. */
  15389. CompileMetadataResolver.prototype._getIdentifierMetadata = /**
  15390. * @param {?} type
  15391. * @return {?}
  15392. */
  15393. function (type) {
  15394. type = resolveForwardRef(type);
  15395. return { reference: type };
  15396. };
  15397. /**
  15398. * @param {?} type
  15399. * @return {?}
  15400. */
  15401. CompileMetadataResolver.prototype.isInjectable = /**
  15402. * @param {?} type
  15403. * @return {?}
  15404. */
  15405. function (type) {
  15406. var /** @type {?} */ annotations = this._reflector.annotations(type);
  15407. return annotations.some(function (ann) { return createInjectable.isTypeOf(ann); });
  15408. };
  15409. /**
  15410. * @param {?} type
  15411. * @return {?}
  15412. */
  15413. CompileMetadataResolver.prototype.getInjectableSummary = /**
  15414. * @param {?} type
  15415. * @return {?}
  15416. */
  15417. function (type) {
  15418. return {
  15419. summaryKind: CompileSummaryKind.Injectable,
  15420. type: this._getTypeMetadata(type, null, false)
  15421. };
  15422. };
  15423. /**
  15424. * @param {?} type
  15425. * @param {?=} dependencies
  15426. * @return {?}
  15427. */
  15428. CompileMetadataResolver.prototype._getInjectableMetadata = /**
  15429. * @param {?} type
  15430. * @param {?=} dependencies
  15431. * @return {?}
  15432. */
  15433. function (type, dependencies) {
  15434. if (dependencies === void 0) { dependencies = null; }
  15435. var /** @type {?} */ typeSummary = this._loadSummary(type, CompileSummaryKind.Injectable);
  15436. if (typeSummary) {
  15437. return typeSummary.type;
  15438. }
  15439. return this._getTypeMetadata(type, dependencies);
  15440. };
  15441. /**
  15442. * @param {?} type
  15443. * @param {?=} dependencies
  15444. * @param {?=} throwOnUnknownDeps
  15445. * @return {?}
  15446. */
  15447. CompileMetadataResolver.prototype._getTypeMetadata = /**
  15448. * @param {?} type
  15449. * @param {?=} dependencies
  15450. * @param {?=} throwOnUnknownDeps
  15451. * @return {?}
  15452. */
  15453. function (type, dependencies, throwOnUnknownDeps) {
  15454. if (dependencies === void 0) { dependencies = null; }
  15455. if (throwOnUnknownDeps === void 0) { throwOnUnknownDeps = true; }
  15456. var /** @type {?} */ identifier = this._getIdentifierMetadata(type);
  15457. return {
  15458. reference: identifier.reference,
  15459. diDeps: this._getDependenciesMetadata(identifier.reference, dependencies, throwOnUnknownDeps),
  15460. lifecycleHooks: getAllLifecycleHooks(this._reflector, identifier.reference),
  15461. };
  15462. };
  15463. /**
  15464. * @param {?} factory
  15465. * @param {?=} dependencies
  15466. * @return {?}
  15467. */
  15468. CompileMetadataResolver.prototype._getFactoryMetadata = /**
  15469. * @param {?} factory
  15470. * @param {?=} dependencies
  15471. * @return {?}
  15472. */
  15473. function (factory, dependencies) {
  15474. if (dependencies === void 0) { dependencies = null; }
  15475. factory = resolveForwardRef(factory);
  15476. return { reference: factory, diDeps: this._getDependenciesMetadata(factory, dependencies) };
  15477. };
  15478. /**
  15479. * Gets the metadata for the given pipe.
  15480. * This assumes `loadNgModuleDirectiveAndPipeMetadata` has been called first.
  15481. */
  15482. /**
  15483. * Gets the metadata for the given pipe.
  15484. * This assumes `loadNgModuleDirectiveAndPipeMetadata` has been called first.
  15485. * @param {?} pipeType
  15486. * @return {?}
  15487. */
  15488. CompileMetadataResolver.prototype.getPipeMetadata = /**
  15489. * Gets the metadata for the given pipe.
  15490. * This assumes `loadNgModuleDirectiveAndPipeMetadata` has been called first.
  15491. * @param {?} pipeType
  15492. * @return {?}
  15493. */
  15494. function (pipeType) {
  15495. var /** @type {?} */ pipeMeta = this._pipeCache.get(pipeType);
  15496. if (!pipeMeta) {
  15497. this._reportError(syntaxError("Illegal state: getPipeMetadata can only be called after loadNgModuleDirectiveAndPipeMetadata for a module that declares it. Pipe " + stringifyType(pipeType) + "."), pipeType);
  15498. }
  15499. return pipeMeta || null;
  15500. };
  15501. /**
  15502. * @param {?} pipeType
  15503. * @return {?}
  15504. */
  15505. CompileMetadataResolver.prototype.getPipeSummary = /**
  15506. * @param {?} pipeType
  15507. * @return {?}
  15508. */
  15509. function (pipeType) {
  15510. var /** @type {?} */ pipeSummary = /** @type {?} */ (this._loadSummary(pipeType, CompileSummaryKind.Pipe));
  15511. if (!pipeSummary) {
  15512. this._reportError(syntaxError("Illegal state: Could not load the summary for pipe " + stringifyType(pipeType) + "."), pipeType);
  15513. }
  15514. return pipeSummary;
  15515. };
  15516. /**
  15517. * @param {?} pipeType
  15518. * @return {?}
  15519. */
  15520. CompileMetadataResolver.prototype.getOrLoadPipeMetadata = /**
  15521. * @param {?} pipeType
  15522. * @return {?}
  15523. */
  15524. function (pipeType) {
  15525. var /** @type {?} */ pipeMeta = this._pipeCache.get(pipeType);
  15526. if (!pipeMeta) {
  15527. pipeMeta = this._loadPipeMetadata(pipeType);
  15528. }
  15529. return pipeMeta;
  15530. };
  15531. /**
  15532. * @param {?} pipeType
  15533. * @return {?}
  15534. */
  15535. CompileMetadataResolver.prototype._loadPipeMetadata = /**
  15536. * @param {?} pipeType
  15537. * @return {?}
  15538. */
  15539. function (pipeType) {
  15540. pipeType = resolveForwardRef(pipeType);
  15541. var /** @type {?} */ pipeAnnotation = /** @type {?} */ ((this._pipeResolver.resolve(pipeType)));
  15542. var /** @type {?} */ pipeMeta = new CompilePipeMetadata({
  15543. type: this._getTypeMetadata(pipeType),
  15544. name: pipeAnnotation.name,
  15545. pure: !!pipeAnnotation.pure
  15546. });
  15547. this._pipeCache.set(pipeType, pipeMeta);
  15548. this._summaryCache.set(pipeType, pipeMeta.toSummary());
  15549. return pipeMeta;
  15550. };
  15551. /**
  15552. * @param {?} typeOrFunc
  15553. * @param {?} dependencies
  15554. * @param {?=} throwOnUnknownDeps
  15555. * @return {?}
  15556. */
  15557. CompileMetadataResolver.prototype._getDependenciesMetadata = /**
  15558. * @param {?} typeOrFunc
  15559. * @param {?} dependencies
  15560. * @param {?=} throwOnUnknownDeps
  15561. * @return {?}
  15562. */
  15563. function (typeOrFunc, dependencies, throwOnUnknownDeps) {
  15564. var _this = this;
  15565. if (throwOnUnknownDeps === void 0) { throwOnUnknownDeps = true; }
  15566. var /** @type {?} */ hasUnknownDeps = false;
  15567. var /** @type {?} */ params = dependencies || this._reflector.parameters(typeOrFunc) || [];
  15568. var /** @type {?} */ dependenciesMetadata = params.map(function (param) {
  15569. var /** @type {?} */ isAttribute = false;
  15570. var /** @type {?} */ isHost = false;
  15571. var /** @type {?} */ isSelf = false;
  15572. var /** @type {?} */ isSkipSelf = false;
  15573. var /** @type {?} */ isOptional = false;
  15574. var /** @type {?} */ token = null;
  15575. if (Array.isArray(param)) {
  15576. param.forEach(function (paramEntry) {
  15577. if (createHost.isTypeOf(paramEntry)) {
  15578. isHost = true;
  15579. }
  15580. else if (createSelf.isTypeOf(paramEntry)) {
  15581. isSelf = true;
  15582. }
  15583. else if (createSkipSelf.isTypeOf(paramEntry)) {
  15584. isSkipSelf = true;
  15585. }
  15586. else if (createOptional.isTypeOf(paramEntry)) {
  15587. isOptional = true;
  15588. }
  15589. else if (createAttribute.isTypeOf(paramEntry)) {
  15590. isAttribute = true;
  15591. token = paramEntry.attributeName;
  15592. }
  15593. else if (createInject.isTypeOf(paramEntry)) {
  15594. token = paramEntry.token;
  15595. }
  15596. else if (createInjectionToken.isTypeOf(paramEntry) || paramEntry instanceof StaticSymbol) {
  15597. token = paramEntry;
  15598. }
  15599. else if (isValidType(paramEntry) && token == null) {
  15600. token = paramEntry;
  15601. }
  15602. });
  15603. }
  15604. else {
  15605. token = param;
  15606. }
  15607. if (token == null) {
  15608. hasUnknownDeps = true;
  15609. return /** @type {?} */ ((null));
  15610. }
  15611. return {
  15612. isAttribute: isAttribute,
  15613. isHost: isHost,
  15614. isSelf: isSelf,
  15615. isSkipSelf: isSkipSelf,
  15616. isOptional: isOptional,
  15617. token: _this._getTokenMetadata(token)
  15618. };
  15619. });
  15620. if (hasUnknownDeps) {
  15621. var /** @type {?} */ depsTokens = dependenciesMetadata.map(function (dep) { return dep ? stringifyType(dep.token) : '?'; }).join(', ');
  15622. var /** @type {?} */ message = "Can't resolve all parameters for " + stringifyType(typeOrFunc) + ": (" + depsTokens + ").";
  15623. if (throwOnUnknownDeps || this._config.strictInjectionParameters) {
  15624. this._reportError(syntaxError(message), typeOrFunc);
  15625. }
  15626. else {
  15627. this._console.warn("Warning: " + message + " This will become an error in Angular v6.x");
  15628. }
  15629. }
  15630. return dependenciesMetadata;
  15631. };
  15632. /**
  15633. * @param {?} token
  15634. * @return {?}
  15635. */
  15636. CompileMetadataResolver.prototype._getTokenMetadata = /**
  15637. * @param {?} token
  15638. * @return {?}
  15639. */
  15640. function (token) {
  15641. token = resolveForwardRef(token);
  15642. var /** @type {?} */ compileToken;
  15643. if (typeof token === 'string') {
  15644. compileToken = { value: token };
  15645. }
  15646. else {
  15647. compileToken = { identifier: { reference: token } };
  15648. }
  15649. return compileToken;
  15650. };
  15651. /**
  15652. * @param {?} providers
  15653. * @param {?} targetEntryComponents
  15654. * @param {?=} debugInfo
  15655. * @param {?=} compileProviders
  15656. * @param {?=} type
  15657. * @return {?}
  15658. */
  15659. CompileMetadataResolver.prototype._getProvidersMetadata = /**
  15660. * @param {?} providers
  15661. * @param {?} targetEntryComponents
  15662. * @param {?=} debugInfo
  15663. * @param {?=} compileProviders
  15664. * @param {?=} type
  15665. * @return {?}
  15666. */
  15667. function (providers, targetEntryComponents, debugInfo, compileProviders, type) {
  15668. var _this = this;
  15669. if (compileProviders === void 0) { compileProviders = []; }
  15670. providers.forEach(function (provider, providerIdx) {
  15671. if (Array.isArray(provider)) {
  15672. _this._getProvidersMetadata(provider, targetEntryComponents, debugInfo, compileProviders);
  15673. }
  15674. else {
  15675. provider = resolveForwardRef(provider);
  15676. var /** @type {?} */ providerMeta = /** @type {?} */ ((undefined));
  15677. if (provider && typeof provider === 'object' && provider.hasOwnProperty('provide')) {
  15678. _this._validateProvider(provider);
  15679. providerMeta = new ProviderMeta(provider.provide, provider);
  15680. }
  15681. else if (isValidType(provider)) {
  15682. providerMeta = new ProviderMeta(provider, { useClass: provider });
  15683. }
  15684. else if (provider === void 0) {
  15685. _this._reportError(syntaxError("Encountered undefined provider! Usually this means you have a circular dependencies (might be caused by using 'barrel' index.ts files."));
  15686. return;
  15687. }
  15688. else {
  15689. var /** @type {?} */ providersInfo = (/** @type {?} */ (providers.reduce(function (soFar, seenProvider, seenProviderIdx) {
  15690. if (seenProviderIdx < providerIdx) {
  15691. soFar.push("" + stringifyType(seenProvider));
  15692. }
  15693. else if (seenProviderIdx == providerIdx) {
  15694. soFar.push("?" + stringifyType(seenProvider) + "?");
  15695. }
  15696. else if (seenProviderIdx == providerIdx + 1) {
  15697. soFar.push('...');
  15698. }
  15699. return soFar;
  15700. }, [])))
  15701. .join(', ');
  15702. _this._reportError(syntaxError("Invalid " + (debugInfo ? debugInfo : 'provider') + " - only instances of Provider and Type are allowed, got: [" + providersInfo + "]"), type);
  15703. return;
  15704. }
  15705. if (providerMeta.token ===
  15706. _this._reflector.resolveExternalReference(Identifiers.ANALYZE_FOR_ENTRY_COMPONENTS)) {
  15707. targetEntryComponents.push.apply(targetEntryComponents, _this._getEntryComponentsFromProvider(providerMeta, type));
  15708. }
  15709. else {
  15710. compileProviders.push(_this.getProviderMetadata(providerMeta));
  15711. }
  15712. }
  15713. });
  15714. return compileProviders;
  15715. };
  15716. /**
  15717. * @param {?} provider
  15718. * @return {?}
  15719. */
  15720. CompileMetadataResolver.prototype._validateProvider = /**
  15721. * @param {?} provider
  15722. * @return {?}
  15723. */
  15724. function (provider) {
  15725. if (provider.hasOwnProperty('useClass') && provider.useClass == null) {
  15726. this._reportError(syntaxError("Invalid provider for " + stringifyType(provider.provide) + ". useClass cannot be " + provider.useClass + ".\n Usually it happens when:\n 1. There's a circular dependency (might be caused by using index.ts (barrel) files).\n 2. Class was used before it was declared. Use forwardRef in this case."));
  15727. }
  15728. };
  15729. /**
  15730. * @param {?} provider
  15731. * @param {?=} type
  15732. * @return {?}
  15733. */
  15734. CompileMetadataResolver.prototype._getEntryComponentsFromProvider = /**
  15735. * @param {?} provider
  15736. * @param {?=} type
  15737. * @return {?}
  15738. */
  15739. function (provider, type) {
  15740. var _this = this;
  15741. var /** @type {?} */ components = [];
  15742. var /** @type {?} */ collectedIdentifiers = [];
  15743. if (provider.useFactory || provider.useExisting || provider.useClass) {
  15744. this._reportError(syntaxError("The ANALYZE_FOR_ENTRY_COMPONENTS token only supports useValue!"), type);
  15745. return [];
  15746. }
  15747. if (!provider.multi) {
  15748. this._reportError(syntaxError("The ANALYZE_FOR_ENTRY_COMPONENTS token only supports 'multi = true'!"), type);
  15749. return [];
  15750. }
  15751. extractIdentifiers(provider.useValue, collectedIdentifiers);
  15752. collectedIdentifiers.forEach(function (identifier) {
  15753. var /** @type {?} */ entry = _this._getEntryComponentMetadata(identifier.reference, false);
  15754. if (entry) {
  15755. components.push(entry);
  15756. }
  15757. });
  15758. return components;
  15759. };
  15760. /**
  15761. * @param {?} dirType
  15762. * @param {?=} throwIfNotFound
  15763. * @return {?}
  15764. */
  15765. CompileMetadataResolver.prototype._getEntryComponentMetadata = /**
  15766. * @param {?} dirType
  15767. * @param {?=} throwIfNotFound
  15768. * @return {?}
  15769. */
  15770. function (dirType, throwIfNotFound) {
  15771. if (throwIfNotFound === void 0) { throwIfNotFound = true; }
  15772. var /** @type {?} */ dirMeta = this.getNonNormalizedDirectiveMetadata(dirType);
  15773. if (dirMeta && dirMeta.metadata.isComponent) {
  15774. return { componentType: dirType, componentFactory: /** @type {?} */ ((dirMeta.metadata.componentFactory)) };
  15775. }
  15776. var /** @type {?} */ dirSummary = /** @type {?} */ (this._loadSummary(dirType, CompileSummaryKind.Directive));
  15777. if (dirSummary && dirSummary.isComponent) {
  15778. return { componentType: dirType, componentFactory: /** @type {?} */ ((dirSummary.componentFactory)) };
  15779. }
  15780. if (throwIfNotFound) {
  15781. throw syntaxError(dirType.name + " cannot be used as an entry component.");
  15782. }
  15783. return null;
  15784. };
  15785. /**
  15786. * @param {?} provider
  15787. * @return {?}
  15788. */
  15789. CompileMetadataResolver.prototype.getProviderMetadata = /**
  15790. * @param {?} provider
  15791. * @return {?}
  15792. */
  15793. function (provider) {
  15794. var /** @type {?} */ compileDeps = /** @type {?} */ ((undefined));
  15795. var /** @type {?} */ compileTypeMetadata = /** @type {?} */ ((null));
  15796. var /** @type {?} */ compileFactoryMetadata = /** @type {?} */ ((null));
  15797. var /** @type {?} */ token = this._getTokenMetadata(provider.token);
  15798. if (provider.useClass) {
  15799. compileTypeMetadata = this._getInjectableMetadata(provider.useClass, provider.dependencies);
  15800. compileDeps = compileTypeMetadata.diDeps;
  15801. if (provider.token === provider.useClass) {
  15802. // use the compileTypeMetadata as it contains information about lifecycleHooks...
  15803. token = { identifier: compileTypeMetadata };
  15804. }
  15805. }
  15806. else if (provider.useFactory) {
  15807. compileFactoryMetadata = this._getFactoryMetadata(provider.useFactory, provider.dependencies);
  15808. compileDeps = compileFactoryMetadata.diDeps;
  15809. }
  15810. return {
  15811. token: token,
  15812. useClass: compileTypeMetadata,
  15813. useValue: provider.useValue,
  15814. useFactory: compileFactoryMetadata,
  15815. useExisting: provider.useExisting ? this._getTokenMetadata(provider.useExisting) : undefined,
  15816. deps: compileDeps,
  15817. multi: provider.multi
  15818. };
  15819. };
  15820. /**
  15821. * @param {?} queries
  15822. * @param {?} isViewQuery
  15823. * @param {?} directiveType
  15824. * @return {?}
  15825. */
  15826. CompileMetadataResolver.prototype._getQueriesMetadata = /**
  15827. * @param {?} queries
  15828. * @param {?} isViewQuery
  15829. * @param {?} directiveType
  15830. * @return {?}
  15831. */
  15832. function (queries, isViewQuery, directiveType) {
  15833. var _this = this;
  15834. var /** @type {?} */ res = [];
  15835. Object.keys(queries).forEach(function (propertyName) {
  15836. var /** @type {?} */ query = queries[propertyName];
  15837. if (query.isViewQuery === isViewQuery) {
  15838. res.push(_this._getQueryMetadata(query, propertyName, directiveType));
  15839. }
  15840. });
  15841. return res;
  15842. };
  15843. /**
  15844. * @param {?} selector
  15845. * @return {?}
  15846. */
  15847. CompileMetadataResolver.prototype._queryVarBindings = /**
  15848. * @param {?} selector
  15849. * @return {?}
  15850. */
  15851. function (selector) { return selector.split(/\s*,\s*/); };
  15852. /**
  15853. * @param {?} q
  15854. * @param {?} propertyName
  15855. * @param {?} typeOrFunc
  15856. * @return {?}
  15857. */
  15858. CompileMetadataResolver.prototype._getQueryMetadata = /**
  15859. * @param {?} q
  15860. * @param {?} propertyName
  15861. * @param {?} typeOrFunc
  15862. * @return {?}
  15863. */
  15864. function (q, propertyName, typeOrFunc) {
  15865. var _this = this;
  15866. var /** @type {?} */ selectors;
  15867. if (typeof q.selector === 'string') {
  15868. selectors =
  15869. this._queryVarBindings(q.selector).map(function (varName) { return _this._getTokenMetadata(varName); });
  15870. }
  15871. else {
  15872. if (!q.selector) {
  15873. this._reportError(syntaxError("Can't construct a query for the property \"" + propertyName + "\" of \"" + stringifyType(typeOrFunc) + "\" since the query selector wasn't defined."), typeOrFunc);
  15874. selectors = [];
  15875. }
  15876. else {
  15877. selectors = [this._getTokenMetadata(q.selector)];
  15878. }
  15879. }
  15880. return {
  15881. selectors: selectors,
  15882. first: q.first,
  15883. descendants: q.descendants, propertyName: propertyName,
  15884. read: q.read ? this._getTokenMetadata(q.read) : /** @type {?} */ ((null))
  15885. };
  15886. };
  15887. /**
  15888. * @param {?} error
  15889. * @param {?=} type
  15890. * @param {?=} otherType
  15891. * @return {?}
  15892. */
  15893. CompileMetadataResolver.prototype._reportError = /**
  15894. * @param {?} error
  15895. * @param {?=} type
  15896. * @param {?=} otherType
  15897. * @return {?}
  15898. */
  15899. function (error, type, otherType) {
  15900. if (this._errorCollector) {
  15901. this._errorCollector(error, type);
  15902. if (otherType) {
  15903. this._errorCollector(error, otherType);
  15904. }
  15905. }
  15906. else {
  15907. throw error;
  15908. }
  15909. };
  15910. return CompileMetadataResolver;
  15911. }());
  15912. /**
  15913. * @param {?} tree
  15914. * @param {?=} out
  15915. * @return {?}
  15916. */
  15917. function flattenArray(tree, out) {
  15918. if (out === void 0) { out = []; }
  15919. if (tree) {
  15920. for (var /** @type {?} */ i = 0; i < tree.length; i++) {
  15921. var /** @type {?} */ item = resolveForwardRef(tree[i]);
  15922. if (Array.isArray(item)) {
  15923. flattenArray(item, out);
  15924. }
  15925. else {
  15926. out.push(item);
  15927. }
  15928. }
  15929. }
  15930. return out;
  15931. }
  15932. /**
  15933. * @param {?} array
  15934. * @return {?}
  15935. */
  15936. function dedupeArray(array) {
  15937. if (array) {
  15938. return Array.from(new Set(array));
  15939. }
  15940. return [];
  15941. }
  15942. /**
  15943. * @param {?} tree
  15944. * @return {?}
  15945. */
  15946. function flattenAndDedupeArray(tree) {
  15947. return dedupeArray(flattenArray(tree));
  15948. }
  15949. /**
  15950. * @param {?} value
  15951. * @return {?}
  15952. */
  15953. function isValidType(value) {
  15954. return (value instanceof StaticSymbol) || (value instanceof Type);
  15955. }
  15956. /**
  15957. * @param {?} value
  15958. * @param {?} targetIdentifiers
  15959. * @return {?}
  15960. */
  15961. function extractIdentifiers(value, targetIdentifiers) {
  15962. visitValue(value, new _CompileValueConverter(), targetIdentifiers);
  15963. }
  15964. var _CompileValueConverter = /** @class */ (function (_super) {
  15965. __extends(_CompileValueConverter, _super);
  15966. function _CompileValueConverter() {
  15967. return _super !== null && _super.apply(this, arguments) || this;
  15968. }
  15969. /**
  15970. * @param {?} value
  15971. * @param {?} targetIdentifiers
  15972. * @return {?}
  15973. */
  15974. _CompileValueConverter.prototype.visitOther = /**
  15975. * @param {?} value
  15976. * @param {?} targetIdentifiers
  15977. * @return {?}
  15978. */
  15979. function (value, targetIdentifiers) {
  15980. targetIdentifiers.push({ reference: value });
  15981. };
  15982. return _CompileValueConverter;
  15983. }(ValueTransformer));
  15984. /**
  15985. * @param {?} type
  15986. * @return {?}
  15987. */
  15988. function stringifyType(type) {
  15989. if (type instanceof StaticSymbol) {
  15990. return type.name + " in " + type.filePath;
  15991. }
  15992. else {
  15993. return stringify(type);
  15994. }
  15995. }
  15996. /**
  15997. * Indicates that a component is still being loaded in a synchronous compile.
  15998. * @param {?} compType
  15999. * @return {?}
  16000. */
  16001. function componentStillLoadingError(compType) {
  16002. var /** @type {?} */ error = Error("Can't compile synchronously as " + stringify(compType) + " is still being loaded!");
  16003. (/** @type {?} */ (error))[ERROR_COMPONENT_TYPE] = compType;
  16004. return error;
  16005. }
  16006. /**
  16007. * @fileoverview added by tsickle
  16008. * @suppress {checkTypes} checked by tsc
  16009. */
  16010. /**
  16011. * @license
  16012. * Copyright Google Inc. All Rights Reserved.
  16013. *
  16014. * Use of this source code is governed by an MIT-style license that can be
  16015. * found in the LICENSE file at https://angular.io/license
  16016. */
  16017. /** @enum {number} */
  16018. var TypeModifier = {
  16019. Const: 0,
  16020. };
  16021. TypeModifier[TypeModifier.Const] = "Const";
  16022. /**
  16023. * @abstract
  16024. */
  16025. var Type$1 = /** @class */ (function () {
  16026. function Type(modifiers) {
  16027. if (modifiers === void 0) { modifiers = null; }
  16028. this.modifiers = modifiers;
  16029. if (!modifiers) {
  16030. this.modifiers = [];
  16031. }
  16032. }
  16033. /**
  16034. * @param {?} modifier
  16035. * @return {?}
  16036. */
  16037. Type.prototype.hasModifier = /**
  16038. * @param {?} modifier
  16039. * @return {?}
  16040. */
  16041. function (modifier) { return /** @type {?} */ ((this.modifiers)).indexOf(modifier) !== -1; };
  16042. return Type;
  16043. }());
  16044. /** @enum {number} */
  16045. var BuiltinTypeName = {
  16046. Dynamic: 0,
  16047. Bool: 1,
  16048. String: 2,
  16049. Int: 3,
  16050. Number: 4,
  16051. Function: 5,
  16052. Inferred: 6,
  16053. };
  16054. BuiltinTypeName[BuiltinTypeName.Dynamic] = "Dynamic";
  16055. BuiltinTypeName[BuiltinTypeName.Bool] = "Bool";
  16056. BuiltinTypeName[BuiltinTypeName.String] = "String";
  16057. BuiltinTypeName[BuiltinTypeName.Int] = "Int";
  16058. BuiltinTypeName[BuiltinTypeName.Number] = "Number";
  16059. BuiltinTypeName[BuiltinTypeName.Function] = "Function";
  16060. BuiltinTypeName[BuiltinTypeName.Inferred] = "Inferred";
  16061. var BuiltinType = /** @class */ (function (_super) {
  16062. __extends(BuiltinType, _super);
  16063. function BuiltinType(name, modifiers) {
  16064. if (modifiers === void 0) { modifiers = null; }
  16065. var _this = _super.call(this, modifiers) || this;
  16066. _this.name = name;
  16067. return _this;
  16068. }
  16069. /**
  16070. * @param {?} visitor
  16071. * @param {?} context
  16072. * @return {?}
  16073. */
  16074. BuiltinType.prototype.visitType = /**
  16075. * @param {?} visitor
  16076. * @param {?} context
  16077. * @return {?}
  16078. */
  16079. function (visitor, context) {
  16080. return visitor.visitBuiltintType(this, context);
  16081. };
  16082. return BuiltinType;
  16083. }(Type$1));
  16084. var ExpressionType = /** @class */ (function (_super) {
  16085. __extends(ExpressionType, _super);
  16086. function ExpressionType(value, modifiers) {
  16087. if (modifiers === void 0) { modifiers = null; }
  16088. var _this = _super.call(this, modifiers) || this;
  16089. _this.value = value;
  16090. return _this;
  16091. }
  16092. /**
  16093. * @param {?} visitor
  16094. * @param {?} context
  16095. * @return {?}
  16096. */
  16097. ExpressionType.prototype.visitType = /**
  16098. * @param {?} visitor
  16099. * @param {?} context
  16100. * @return {?}
  16101. */
  16102. function (visitor, context) {
  16103. return visitor.visitExpressionType(this, context);
  16104. };
  16105. return ExpressionType;
  16106. }(Type$1));
  16107. var ArrayType = /** @class */ (function (_super) {
  16108. __extends(ArrayType, _super);
  16109. function ArrayType(of, modifiers) {
  16110. if (modifiers === void 0) { modifiers = null; }
  16111. var _this = _super.call(this, modifiers) || this;
  16112. _this.of = of;
  16113. return _this;
  16114. }
  16115. /**
  16116. * @param {?} visitor
  16117. * @param {?} context
  16118. * @return {?}
  16119. */
  16120. ArrayType.prototype.visitType = /**
  16121. * @param {?} visitor
  16122. * @param {?} context
  16123. * @return {?}
  16124. */
  16125. function (visitor, context) {
  16126. return visitor.visitArrayType(this, context);
  16127. };
  16128. return ArrayType;
  16129. }(Type$1));
  16130. var MapType = /** @class */ (function (_super) {
  16131. __extends(MapType, _super);
  16132. function MapType(valueType, modifiers) {
  16133. if (modifiers === void 0) { modifiers = null; }
  16134. var _this = _super.call(this, modifiers) || this;
  16135. _this.valueType = valueType || null;
  16136. return _this;
  16137. }
  16138. /**
  16139. * @param {?} visitor
  16140. * @param {?} context
  16141. * @return {?}
  16142. */
  16143. MapType.prototype.visitType = /**
  16144. * @param {?} visitor
  16145. * @param {?} context
  16146. * @return {?}
  16147. */
  16148. function (visitor, context) { return visitor.visitMapType(this, context); };
  16149. return MapType;
  16150. }(Type$1));
  16151. var DYNAMIC_TYPE = new BuiltinType(BuiltinTypeName.Dynamic);
  16152. var INFERRED_TYPE = new BuiltinType(BuiltinTypeName.Inferred);
  16153. var BOOL_TYPE = new BuiltinType(BuiltinTypeName.Bool);
  16154. var INT_TYPE = new BuiltinType(BuiltinTypeName.Int);
  16155. var NUMBER_TYPE = new BuiltinType(BuiltinTypeName.Number);
  16156. var STRING_TYPE = new BuiltinType(BuiltinTypeName.String);
  16157. var FUNCTION_TYPE = new BuiltinType(BuiltinTypeName.Function);
  16158. /**
  16159. * @record
  16160. */
  16161. /** @enum {number} */
  16162. var BinaryOperator = {
  16163. Equals: 0,
  16164. NotEquals: 1,
  16165. Identical: 2,
  16166. NotIdentical: 3,
  16167. Minus: 4,
  16168. Plus: 5,
  16169. Divide: 6,
  16170. Multiply: 7,
  16171. Modulo: 8,
  16172. And: 9,
  16173. Or: 10,
  16174. Lower: 11,
  16175. LowerEquals: 12,
  16176. Bigger: 13,
  16177. BiggerEquals: 14,
  16178. };
  16179. BinaryOperator[BinaryOperator.Equals] = "Equals";
  16180. BinaryOperator[BinaryOperator.NotEquals] = "NotEquals";
  16181. BinaryOperator[BinaryOperator.Identical] = "Identical";
  16182. BinaryOperator[BinaryOperator.NotIdentical] = "NotIdentical";
  16183. BinaryOperator[BinaryOperator.Minus] = "Minus";
  16184. BinaryOperator[BinaryOperator.Plus] = "Plus";
  16185. BinaryOperator[BinaryOperator.Divide] = "Divide";
  16186. BinaryOperator[BinaryOperator.Multiply] = "Multiply";
  16187. BinaryOperator[BinaryOperator.Modulo] = "Modulo";
  16188. BinaryOperator[BinaryOperator.And] = "And";
  16189. BinaryOperator[BinaryOperator.Or] = "Or";
  16190. BinaryOperator[BinaryOperator.Lower] = "Lower";
  16191. BinaryOperator[BinaryOperator.LowerEquals] = "LowerEquals";
  16192. BinaryOperator[BinaryOperator.Bigger] = "Bigger";
  16193. BinaryOperator[BinaryOperator.BiggerEquals] = "BiggerEquals";
  16194. /**
  16195. * @template T
  16196. * @param {?} base
  16197. * @param {?} other
  16198. * @return {?}
  16199. */
  16200. function nullSafeIsEquivalent(base, other) {
  16201. if (base == null || other == null) {
  16202. return base == other;
  16203. }
  16204. return base.isEquivalent(other);
  16205. }
  16206. /**
  16207. * @template T
  16208. * @param {?} base
  16209. * @param {?} other
  16210. * @return {?}
  16211. */
  16212. function areAllEquivalent(base, other) {
  16213. var /** @type {?} */ len = base.length;
  16214. if (len !== other.length) {
  16215. return false;
  16216. }
  16217. for (var /** @type {?} */ i = 0; i < len; i++) {
  16218. if (!base[i].isEquivalent(other[i])) {
  16219. return false;
  16220. }
  16221. }
  16222. return true;
  16223. }
  16224. /**
  16225. * @abstract
  16226. */
  16227. var Expression = /** @class */ (function () {
  16228. function Expression(type, sourceSpan) {
  16229. this.type = type || null;
  16230. this.sourceSpan = sourceSpan || null;
  16231. }
  16232. /**
  16233. * @param {?} name
  16234. * @param {?=} sourceSpan
  16235. * @return {?}
  16236. */
  16237. Expression.prototype.prop = /**
  16238. * @param {?} name
  16239. * @param {?=} sourceSpan
  16240. * @return {?}
  16241. */
  16242. function (name, sourceSpan) {
  16243. return new ReadPropExpr(this, name, null, sourceSpan);
  16244. };
  16245. /**
  16246. * @param {?} index
  16247. * @param {?=} type
  16248. * @param {?=} sourceSpan
  16249. * @return {?}
  16250. */
  16251. Expression.prototype.key = /**
  16252. * @param {?} index
  16253. * @param {?=} type
  16254. * @param {?=} sourceSpan
  16255. * @return {?}
  16256. */
  16257. function (index, type, sourceSpan) {
  16258. return new ReadKeyExpr(this, index, type, sourceSpan);
  16259. };
  16260. /**
  16261. * @param {?} name
  16262. * @param {?} params
  16263. * @param {?=} sourceSpan
  16264. * @return {?}
  16265. */
  16266. Expression.prototype.callMethod = /**
  16267. * @param {?} name
  16268. * @param {?} params
  16269. * @param {?=} sourceSpan
  16270. * @return {?}
  16271. */
  16272. function (name, params, sourceSpan) {
  16273. return new InvokeMethodExpr(this, name, params, null, sourceSpan);
  16274. };
  16275. /**
  16276. * @param {?} params
  16277. * @param {?=} sourceSpan
  16278. * @return {?}
  16279. */
  16280. Expression.prototype.callFn = /**
  16281. * @param {?} params
  16282. * @param {?=} sourceSpan
  16283. * @return {?}
  16284. */
  16285. function (params, sourceSpan) {
  16286. return new InvokeFunctionExpr(this, params, null, sourceSpan);
  16287. };
  16288. /**
  16289. * @param {?} params
  16290. * @param {?=} type
  16291. * @param {?=} sourceSpan
  16292. * @return {?}
  16293. */
  16294. Expression.prototype.instantiate = /**
  16295. * @param {?} params
  16296. * @param {?=} type
  16297. * @param {?=} sourceSpan
  16298. * @return {?}
  16299. */
  16300. function (params, type, sourceSpan) {
  16301. return new InstantiateExpr(this, params, type, sourceSpan);
  16302. };
  16303. /**
  16304. * @param {?} trueCase
  16305. * @param {?=} falseCase
  16306. * @param {?=} sourceSpan
  16307. * @return {?}
  16308. */
  16309. Expression.prototype.conditional = /**
  16310. * @param {?} trueCase
  16311. * @param {?=} falseCase
  16312. * @param {?=} sourceSpan
  16313. * @return {?}
  16314. */
  16315. function (trueCase, falseCase, sourceSpan) {
  16316. if (falseCase === void 0) { falseCase = null; }
  16317. return new ConditionalExpr(this, trueCase, falseCase, null, sourceSpan);
  16318. };
  16319. /**
  16320. * @param {?} rhs
  16321. * @param {?=} sourceSpan
  16322. * @return {?}
  16323. */
  16324. Expression.prototype.equals = /**
  16325. * @param {?} rhs
  16326. * @param {?=} sourceSpan
  16327. * @return {?}
  16328. */
  16329. function (rhs, sourceSpan) {
  16330. return new BinaryOperatorExpr(BinaryOperator.Equals, this, rhs, null, sourceSpan);
  16331. };
  16332. /**
  16333. * @param {?} rhs
  16334. * @param {?=} sourceSpan
  16335. * @return {?}
  16336. */
  16337. Expression.prototype.notEquals = /**
  16338. * @param {?} rhs
  16339. * @param {?=} sourceSpan
  16340. * @return {?}
  16341. */
  16342. function (rhs, sourceSpan) {
  16343. return new BinaryOperatorExpr(BinaryOperator.NotEquals, this, rhs, null, sourceSpan);
  16344. };
  16345. /**
  16346. * @param {?} rhs
  16347. * @param {?=} sourceSpan
  16348. * @return {?}
  16349. */
  16350. Expression.prototype.identical = /**
  16351. * @param {?} rhs
  16352. * @param {?=} sourceSpan
  16353. * @return {?}
  16354. */
  16355. function (rhs, sourceSpan) {
  16356. return new BinaryOperatorExpr(BinaryOperator.Identical, this, rhs, null, sourceSpan);
  16357. };
  16358. /**
  16359. * @param {?} rhs
  16360. * @param {?=} sourceSpan
  16361. * @return {?}
  16362. */
  16363. Expression.prototype.notIdentical = /**
  16364. * @param {?} rhs
  16365. * @param {?=} sourceSpan
  16366. * @return {?}
  16367. */
  16368. function (rhs, sourceSpan) {
  16369. return new BinaryOperatorExpr(BinaryOperator.NotIdentical, this, rhs, null, sourceSpan);
  16370. };
  16371. /**
  16372. * @param {?} rhs
  16373. * @param {?=} sourceSpan
  16374. * @return {?}
  16375. */
  16376. Expression.prototype.minus = /**
  16377. * @param {?} rhs
  16378. * @param {?=} sourceSpan
  16379. * @return {?}
  16380. */
  16381. function (rhs, sourceSpan) {
  16382. return new BinaryOperatorExpr(BinaryOperator.Minus, this, rhs, null, sourceSpan);
  16383. };
  16384. /**
  16385. * @param {?} rhs
  16386. * @param {?=} sourceSpan
  16387. * @return {?}
  16388. */
  16389. Expression.prototype.plus = /**
  16390. * @param {?} rhs
  16391. * @param {?=} sourceSpan
  16392. * @return {?}
  16393. */
  16394. function (rhs, sourceSpan) {
  16395. return new BinaryOperatorExpr(BinaryOperator.Plus, this, rhs, null, sourceSpan);
  16396. };
  16397. /**
  16398. * @param {?} rhs
  16399. * @param {?=} sourceSpan
  16400. * @return {?}
  16401. */
  16402. Expression.prototype.divide = /**
  16403. * @param {?} rhs
  16404. * @param {?=} sourceSpan
  16405. * @return {?}
  16406. */
  16407. function (rhs, sourceSpan) {
  16408. return new BinaryOperatorExpr(BinaryOperator.Divide, this, rhs, null, sourceSpan);
  16409. };
  16410. /**
  16411. * @param {?} rhs
  16412. * @param {?=} sourceSpan
  16413. * @return {?}
  16414. */
  16415. Expression.prototype.multiply = /**
  16416. * @param {?} rhs
  16417. * @param {?=} sourceSpan
  16418. * @return {?}
  16419. */
  16420. function (rhs, sourceSpan) {
  16421. return new BinaryOperatorExpr(BinaryOperator.Multiply, this, rhs, null, sourceSpan);
  16422. };
  16423. /**
  16424. * @param {?} rhs
  16425. * @param {?=} sourceSpan
  16426. * @return {?}
  16427. */
  16428. Expression.prototype.modulo = /**
  16429. * @param {?} rhs
  16430. * @param {?=} sourceSpan
  16431. * @return {?}
  16432. */
  16433. function (rhs, sourceSpan) {
  16434. return new BinaryOperatorExpr(BinaryOperator.Modulo, this, rhs, null, sourceSpan);
  16435. };
  16436. /**
  16437. * @param {?} rhs
  16438. * @param {?=} sourceSpan
  16439. * @return {?}
  16440. */
  16441. Expression.prototype.and = /**
  16442. * @param {?} rhs
  16443. * @param {?=} sourceSpan
  16444. * @return {?}
  16445. */
  16446. function (rhs, sourceSpan) {
  16447. return new BinaryOperatorExpr(BinaryOperator.And, this, rhs, null, sourceSpan);
  16448. };
  16449. /**
  16450. * @param {?} rhs
  16451. * @param {?=} sourceSpan
  16452. * @return {?}
  16453. */
  16454. Expression.prototype.or = /**
  16455. * @param {?} rhs
  16456. * @param {?=} sourceSpan
  16457. * @return {?}
  16458. */
  16459. function (rhs, sourceSpan) {
  16460. return new BinaryOperatorExpr(BinaryOperator.Or, this, rhs, null, sourceSpan);
  16461. };
  16462. /**
  16463. * @param {?} rhs
  16464. * @param {?=} sourceSpan
  16465. * @return {?}
  16466. */
  16467. Expression.prototype.lower = /**
  16468. * @param {?} rhs
  16469. * @param {?=} sourceSpan
  16470. * @return {?}
  16471. */
  16472. function (rhs, sourceSpan) {
  16473. return new BinaryOperatorExpr(BinaryOperator.Lower, this, rhs, null, sourceSpan);
  16474. };
  16475. /**
  16476. * @param {?} rhs
  16477. * @param {?=} sourceSpan
  16478. * @return {?}
  16479. */
  16480. Expression.prototype.lowerEquals = /**
  16481. * @param {?} rhs
  16482. * @param {?=} sourceSpan
  16483. * @return {?}
  16484. */
  16485. function (rhs, sourceSpan) {
  16486. return new BinaryOperatorExpr(BinaryOperator.LowerEquals, this, rhs, null, sourceSpan);
  16487. };
  16488. /**
  16489. * @param {?} rhs
  16490. * @param {?=} sourceSpan
  16491. * @return {?}
  16492. */
  16493. Expression.prototype.bigger = /**
  16494. * @param {?} rhs
  16495. * @param {?=} sourceSpan
  16496. * @return {?}
  16497. */
  16498. function (rhs, sourceSpan) {
  16499. return new BinaryOperatorExpr(BinaryOperator.Bigger, this, rhs, null, sourceSpan);
  16500. };
  16501. /**
  16502. * @param {?} rhs
  16503. * @param {?=} sourceSpan
  16504. * @return {?}
  16505. */
  16506. Expression.prototype.biggerEquals = /**
  16507. * @param {?} rhs
  16508. * @param {?=} sourceSpan
  16509. * @return {?}
  16510. */
  16511. function (rhs, sourceSpan) {
  16512. return new BinaryOperatorExpr(BinaryOperator.BiggerEquals, this, rhs, null, sourceSpan);
  16513. };
  16514. /**
  16515. * @param {?=} sourceSpan
  16516. * @return {?}
  16517. */
  16518. Expression.prototype.isBlank = /**
  16519. * @param {?=} sourceSpan
  16520. * @return {?}
  16521. */
  16522. function (sourceSpan) {
  16523. // Note: We use equals by purpose here to compare to null and undefined in JS.
  16524. // We use the typed null to allow strictNullChecks to narrow types.
  16525. return this.equals(TYPED_NULL_EXPR, sourceSpan);
  16526. };
  16527. /**
  16528. * @param {?} type
  16529. * @param {?=} sourceSpan
  16530. * @return {?}
  16531. */
  16532. Expression.prototype.cast = /**
  16533. * @param {?} type
  16534. * @param {?=} sourceSpan
  16535. * @return {?}
  16536. */
  16537. function (type, sourceSpan) {
  16538. return new CastExpr(this, type, sourceSpan);
  16539. };
  16540. /**
  16541. * @return {?}
  16542. */
  16543. Expression.prototype.toStmt = /**
  16544. * @return {?}
  16545. */
  16546. function () { return new ExpressionStatement(this, null); };
  16547. return Expression;
  16548. }());
  16549. /** @enum {number} */
  16550. var BuiltinVar = {
  16551. This: 0,
  16552. Super: 1,
  16553. CatchError: 2,
  16554. CatchStack: 3,
  16555. };
  16556. BuiltinVar[BuiltinVar.This] = "This";
  16557. BuiltinVar[BuiltinVar.Super] = "Super";
  16558. BuiltinVar[BuiltinVar.CatchError] = "CatchError";
  16559. BuiltinVar[BuiltinVar.CatchStack] = "CatchStack";
  16560. var ReadVarExpr = /** @class */ (function (_super) {
  16561. __extends(ReadVarExpr, _super);
  16562. function ReadVarExpr(name, type, sourceSpan) {
  16563. var _this = _super.call(this, type, sourceSpan) || this;
  16564. if (typeof name === 'string') {
  16565. _this.name = name;
  16566. _this.builtin = null;
  16567. }
  16568. else {
  16569. _this.name = null;
  16570. _this.builtin = /** @type {?} */ (name);
  16571. }
  16572. return _this;
  16573. }
  16574. /**
  16575. * @param {?} e
  16576. * @return {?}
  16577. */
  16578. ReadVarExpr.prototype.isEquivalent = /**
  16579. * @param {?} e
  16580. * @return {?}
  16581. */
  16582. function (e) {
  16583. return e instanceof ReadVarExpr && this.name === e.name && this.builtin === e.builtin;
  16584. };
  16585. /**
  16586. * @param {?} visitor
  16587. * @param {?} context
  16588. * @return {?}
  16589. */
  16590. ReadVarExpr.prototype.visitExpression = /**
  16591. * @param {?} visitor
  16592. * @param {?} context
  16593. * @return {?}
  16594. */
  16595. function (visitor, context) {
  16596. return visitor.visitReadVarExpr(this, context);
  16597. };
  16598. /**
  16599. * @param {?} value
  16600. * @return {?}
  16601. */
  16602. ReadVarExpr.prototype.set = /**
  16603. * @param {?} value
  16604. * @return {?}
  16605. */
  16606. function (value) {
  16607. if (!this.name) {
  16608. throw new Error("Built in variable " + this.builtin + " can not be assigned to.");
  16609. }
  16610. return new WriteVarExpr(this.name, value, null, this.sourceSpan);
  16611. };
  16612. return ReadVarExpr;
  16613. }(Expression));
  16614. var WriteVarExpr = /** @class */ (function (_super) {
  16615. __extends(WriteVarExpr, _super);
  16616. function WriteVarExpr(name, value, type, sourceSpan) {
  16617. var _this = _super.call(this, type || value.type, sourceSpan) || this;
  16618. _this.name = name;
  16619. _this.value = value;
  16620. return _this;
  16621. }
  16622. /**
  16623. * @param {?} e
  16624. * @return {?}
  16625. */
  16626. WriteVarExpr.prototype.isEquivalent = /**
  16627. * @param {?} e
  16628. * @return {?}
  16629. */
  16630. function (e) {
  16631. return e instanceof WriteVarExpr && this.name === e.name && this.value.isEquivalent(e.value);
  16632. };
  16633. /**
  16634. * @param {?} visitor
  16635. * @param {?} context
  16636. * @return {?}
  16637. */
  16638. WriteVarExpr.prototype.visitExpression = /**
  16639. * @param {?} visitor
  16640. * @param {?} context
  16641. * @return {?}
  16642. */
  16643. function (visitor, context) {
  16644. return visitor.visitWriteVarExpr(this, context);
  16645. };
  16646. /**
  16647. * @param {?=} type
  16648. * @param {?=} modifiers
  16649. * @return {?}
  16650. */
  16651. WriteVarExpr.prototype.toDeclStmt = /**
  16652. * @param {?=} type
  16653. * @param {?=} modifiers
  16654. * @return {?}
  16655. */
  16656. function (type, modifiers) {
  16657. return new DeclareVarStmt(this.name, this.value, type, modifiers, this.sourceSpan);
  16658. };
  16659. return WriteVarExpr;
  16660. }(Expression));
  16661. var WriteKeyExpr = /** @class */ (function (_super) {
  16662. __extends(WriteKeyExpr, _super);
  16663. function WriteKeyExpr(receiver, index, value, type, sourceSpan) {
  16664. var _this = _super.call(this, type || value.type, sourceSpan) || this;
  16665. _this.receiver = receiver;
  16666. _this.index = index;
  16667. _this.value = value;
  16668. return _this;
  16669. }
  16670. /**
  16671. * @param {?} e
  16672. * @return {?}
  16673. */
  16674. WriteKeyExpr.prototype.isEquivalent = /**
  16675. * @param {?} e
  16676. * @return {?}
  16677. */
  16678. function (e) {
  16679. return e instanceof WriteKeyExpr && this.receiver.isEquivalent(e.receiver) &&
  16680. this.index.isEquivalent(e.index) && this.value.isEquivalent(e.value);
  16681. };
  16682. /**
  16683. * @param {?} visitor
  16684. * @param {?} context
  16685. * @return {?}
  16686. */
  16687. WriteKeyExpr.prototype.visitExpression = /**
  16688. * @param {?} visitor
  16689. * @param {?} context
  16690. * @return {?}
  16691. */
  16692. function (visitor, context) {
  16693. return visitor.visitWriteKeyExpr(this, context);
  16694. };
  16695. return WriteKeyExpr;
  16696. }(Expression));
  16697. var WritePropExpr = /** @class */ (function (_super) {
  16698. __extends(WritePropExpr, _super);
  16699. function WritePropExpr(receiver, name, value, type, sourceSpan) {
  16700. var _this = _super.call(this, type || value.type, sourceSpan) || this;
  16701. _this.receiver = receiver;
  16702. _this.name = name;
  16703. _this.value = value;
  16704. return _this;
  16705. }
  16706. /**
  16707. * @param {?} e
  16708. * @return {?}
  16709. */
  16710. WritePropExpr.prototype.isEquivalent = /**
  16711. * @param {?} e
  16712. * @return {?}
  16713. */
  16714. function (e) {
  16715. return e instanceof WritePropExpr && this.receiver.isEquivalent(e.receiver) &&
  16716. this.name === e.name && this.value.isEquivalent(e.value);
  16717. };
  16718. /**
  16719. * @param {?} visitor
  16720. * @param {?} context
  16721. * @return {?}
  16722. */
  16723. WritePropExpr.prototype.visitExpression = /**
  16724. * @param {?} visitor
  16725. * @param {?} context
  16726. * @return {?}
  16727. */
  16728. function (visitor, context) {
  16729. return visitor.visitWritePropExpr(this, context);
  16730. };
  16731. return WritePropExpr;
  16732. }(Expression));
  16733. /** @enum {number} */
  16734. var BuiltinMethod = {
  16735. ConcatArray: 0,
  16736. SubscribeObservable: 1,
  16737. Bind: 2,
  16738. };
  16739. BuiltinMethod[BuiltinMethod.ConcatArray] = "ConcatArray";
  16740. BuiltinMethod[BuiltinMethod.SubscribeObservable] = "SubscribeObservable";
  16741. BuiltinMethod[BuiltinMethod.Bind] = "Bind";
  16742. var InvokeMethodExpr = /** @class */ (function (_super) {
  16743. __extends(InvokeMethodExpr, _super);
  16744. function InvokeMethodExpr(receiver, method, args, type, sourceSpan) {
  16745. var _this = _super.call(this, type, sourceSpan) || this;
  16746. _this.receiver = receiver;
  16747. _this.args = args;
  16748. if (typeof method === 'string') {
  16749. _this.name = method;
  16750. _this.builtin = null;
  16751. }
  16752. else {
  16753. _this.name = null;
  16754. _this.builtin = /** @type {?} */ (method);
  16755. }
  16756. return _this;
  16757. }
  16758. /**
  16759. * @param {?} e
  16760. * @return {?}
  16761. */
  16762. InvokeMethodExpr.prototype.isEquivalent = /**
  16763. * @param {?} e
  16764. * @return {?}
  16765. */
  16766. function (e) {
  16767. return e instanceof InvokeMethodExpr && this.receiver.isEquivalent(e.receiver) &&
  16768. this.name === e.name && this.builtin === e.builtin && areAllEquivalent(this.args, e.args);
  16769. };
  16770. /**
  16771. * @param {?} visitor
  16772. * @param {?} context
  16773. * @return {?}
  16774. */
  16775. InvokeMethodExpr.prototype.visitExpression = /**
  16776. * @param {?} visitor
  16777. * @param {?} context
  16778. * @return {?}
  16779. */
  16780. function (visitor, context) {
  16781. return visitor.visitInvokeMethodExpr(this, context);
  16782. };
  16783. return InvokeMethodExpr;
  16784. }(Expression));
  16785. var InvokeFunctionExpr = /** @class */ (function (_super) {
  16786. __extends(InvokeFunctionExpr, _super);
  16787. function InvokeFunctionExpr(fn, args, type, sourceSpan) {
  16788. var _this = _super.call(this, type, sourceSpan) || this;
  16789. _this.fn = fn;
  16790. _this.args = args;
  16791. return _this;
  16792. }
  16793. /**
  16794. * @param {?} e
  16795. * @return {?}
  16796. */
  16797. InvokeFunctionExpr.prototype.isEquivalent = /**
  16798. * @param {?} e
  16799. * @return {?}
  16800. */
  16801. function (e) {
  16802. return e instanceof InvokeFunctionExpr && this.fn.isEquivalent(e.fn) &&
  16803. areAllEquivalent(this.args, e.args);
  16804. };
  16805. /**
  16806. * @param {?} visitor
  16807. * @param {?} context
  16808. * @return {?}
  16809. */
  16810. InvokeFunctionExpr.prototype.visitExpression = /**
  16811. * @param {?} visitor
  16812. * @param {?} context
  16813. * @return {?}
  16814. */
  16815. function (visitor, context) {
  16816. return visitor.visitInvokeFunctionExpr(this, context);
  16817. };
  16818. return InvokeFunctionExpr;
  16819. }(Expression));
  16820. var InstantiateExpr = /** @class */ (function (_super) {
  16821. __extends(InstantiateExpr, _super);
  16822. function InstantiateExpr(classExpr, args, type, sourceSpan) {
  16823. var _this = _super.call(this, type, sourceSpan) || this;
  16824. _this.classExpr = classExpr;
  16825. _this.args = args;
  16826. return _this;
  16827. }
  16828. /**
  16829. * @param {?} e
  16830. * @return {?}
  16831. */
  16832. InstantiateExpr.prototype.isEquivalent = /**
  16833. * @param {?} e
  16834. * @return {?}
  16835. */
  16836. function (e) {
  16837. return e instanceof InstantiateExpr && this.classExpr.isEquivalent(e.classExpr) &&
  16838. areAllEquivalent(this.args, e.args);
  16839. };
  16840. /**
  16841. * @param {?} visitor
  16842. * @param {?} context
  16843. * @return {?}
  16844. */
  16845. InstantiateExpr.prototype.visitExpression = /**
  16846. * @param {?} visitor
  16847. * @param {?} context
  16848. * @return {?}
  16849. */
  16850. function (visitor, context) {
  16851. return visitor.visitInstantiateExpr(this, context);
  16852. };
  16853. return InstantiateExpr;
  16854. }(Expression));
  16855. var LiteralExpr = /** @class */ (function (_super) {
  16856. __extends(LiteralExpr, _super);
  16857. function LiteralExpr(value, type, sourceSpan) {
  16858. var _this = _super.call(this, type, sourceSpan) || this;
  16859. _this.value = value;
  16860. return _this;
  16861. }
  16862. /**
  16863. * @param {?} e
  16864. * @return {?}
  16865. */
  16866. LiteralExpr.prototype.isEquivalent = /**
  16867. * @param {?} e
  16868. * @return {?}
  16869. */
  16870. function (e) {
  16871. return e instanceof LiteralExpr && this.value === e.value;
  16872. };
  16873. /**
  16874. * @param {?} visitor
  16875. * @param {?} context
  16876. * @return {?}
  16877. */
  16878. LiteralExpr.prototype.visitExpression = /**
  16879. * @param {?} visitor
  16880. * @param {?} context
  16881. * @return {?}
  16882. */
  16883. function (visitor, context) {
  16884. return visitor.visitLiteralExpr(this, context);
  16885. };
  16886. return LiteralExpr;
  16887. }(Expression));
  16888. var ExternalExpr = /** @class */ (function (_super) {
  16889. __extends(ExternalExpr, _super);
  16890. function ExternalExpr(value, type, typeParams, sourceSpan) {
  16891. if (typeParams === void 0) { typeParams = null; }
  16892. var _this = _super.call(this, type, sourceSpan) || this;
  16893. _this.value = value;
  16894. _this.typeParams = typeParams;
  16895. return _this;
  16896. }
  16897. /**
  16898. * @param {?} e
  16899. * @return {?}
  16900. */
  16901. ExternalExpr.prototype.isEquivalent = /**
  16902. * @param {?} e
  16903. * @return {?}
  16904. */
  16905. function (e) {
  16906. return e instanceof ExternalExpr && this.value.name === e.value.name &&
  16907. this.value.moduleName === e.value.moduleName && this.value.runtime === e.value.runtime;
  16908. };
  16909. /**
  16910. * @param {?} visitor
  16911. * @param {?} context
  16912. * @return {?}
  16913. */
  16914. ExternalExpr.prototype.visitExpression = /**
  16915. * @param {?} visitor
  16916. * @param {?} context
  16917. * @return {?}
  16918. */
  16919. function (visitor, context) {
  16920. return visitor.visitExternalExpr(this, context);
  16921. };
  16922. return ExternalExpr;
  16923. }(Expression));
  16924. var ExternalReference = /** @class */ (function () {
  16925. function ExternalReference(moduleName, name, runtime) {
  16926. this.moduleName = moduleName;
  16927. this.name = name;
  16928. this.runtime = runtime;
  16929. }
  16930. return ExternalReference;
  16931. }());
  16932. var ConditionalExpr = /** @class */ (function (_super) {
  16933. __extends(ConditionalExpr, _super);
  16934. function ConditionalExpr(condition, trueCase, falseCase, type, sourceSpan) {
  16935. if (falseCase === void 0) { falseCase = null; }
  16936. var _this = _super.call(this, type || trueCase.type, sourceSpan) || this;
  16937. _this.condition = condition;
  16938. _this.falseCase = falseCase;
  16939. _this.trueCase = trueCase;
  16940. return _this;
  16941. }
  16942. /**
  16943. * @param {?} e
  16944. * @return {?}
  16945. */
  16946. ConditionalExpr.prototype.isEquivalent = /**
  16947. * @param {?} e
  16948. * @return {?}
  16949. */
  16950. function (e) {
  16951. return e instanceof ConditionalExpr && this.condition.isEquivalent(e.condition) &&
  16952. this.trueCase.isEquivalent(e.trueCase) && nullSafeIsEquivalent(this.falseCase, e.falseCase);
  16953. };
  16954. /**
  16955. * @param {?} visitor
  16956. * @param {?} context
  16957. * @return {?}
  16958. */
  16959. ConditionalExpr.prototype.visitExpression = /**
  16960. * @param {?} visitor
  16961. * @param {?} context
  16962. * @return {?}
  16963. */
  16964. function (visitor, context) {
  16965. return visitor.visitConditionalExpr(this, context);
  16966. };
  16967. return ConditionalExpr;
  16968. }(Expression));
  16969. var NotExpr = /** @class */ (function (_super) {
  16970. __extends(NotExpr, _super);
  16971. function NotExpr(condition, sourceSpan) {
  16972. var _this = _super.call(this, BOOL_TYPE, sourceSpan) || this;
  16973. _this.condition = condition;
  16974. return _this;
  16975. }
  16976. /**
  16977. * @param {?} e
  16978. * @return {?}
  16979. */
  16980. NotExpr.prototype.isEquivalent = /**
  16981. * @param {?} e
  16982. * @return {?}
  16983. */
  16984. function (e) {
  16985. return e instanceof NotExpr && this.condition.isEquivalent(e.condition);
  16986. };
  16987. /**
  16988. * @param {?} visitor
  16989. * @param {?} context
  16990. * @return {?}
  16991. */
  16992. NotExpr.prototype.visitExpression = /**
  16993. * @param {?} visitor
  16994. * @param {?} context
  16995. * @return {?}
  16996. */
  16997. function (visitor, context) {
  16998. return visitor.visitNotExpr(this, context);
  16999. };
  17000. return NotExpr;
  17001. }(Expression));
  17002. var AssertNotNull = /** @class */ (function (_super) {
  17003. __extends(AssertNotNull, _super);
  17004. function AssertNotNull(condition, sourceSpan) {
  17005. var _this = _super.call(this, condition.type, sourceSpan) || this;
  17006. _this.condition = condition;
  17007. return _this;
  17008. }
  17009. /**
  17010. * @param {?} e
  17011. * @return {?}
  17012. */
  17013. AssertNotNull.prototype.isEquivalent = /**
  17014. * @param {?} e
  17015. * @return {?}
  17016. */
  17017. function (e) {
  17018. return e instanceof AssertNotNull && this.condition.isEquivalent(e.condition);
  17019. };
  17020. /**
  17021. * @param {?} visitor
  17022. * @param {?} context
  17023. * @return {?}
  17024. */
  17025. AssertNotNull.prototype.visitExpression = /**
  17026. * @param {?} visitor
  17027. * @param {?} context
  17028. * @return {?}
  17029. */
  17030. function (visitor, context) {
  17031. return visitor.visitAssertNotNullExpr(this, context);
  17032. };
  17033. return AssertNotNull;
  17034. }(Expression));
  17035. var CastExpr = /** @class */ (function (_super) {
  17036. __extends(CastExpr, _super);
  17037. function CastExpr(value, type, sourceSpan) {
  17038. var _this = _super.call(this, type, sourceSpan) || this;
  17039. _this.value = value;
  17040. return _this;
  17041. }
  17042. /**
  17043. * @param {?} e
  17044. * @return {?}
  17045. */
  17046. CastExpr.prototype.isEquivalent = /**
  17047. * @param {?} e
  17048. * @return {?}
  17049. */
  17050. function (e) {
  17051. return e instanceof CastExpr && this.value.isEquivalent(e.value);
  17052. };
  17053. /**
  17054. * @param {?} visitor
  17055. * @param {?} context
  17056. * @return {?}
  17057. */
  17058. CastExpr.prototype.visitExpression = /**
  17059. * @param {?} visitor
  17060. * @param {?} context
  17061. * @return {?}
  17062. */
  17063. function (visitor, context) {
  17064. return visitor.visitCastExpr(this, context);
  17065. };
  17066. return CastExpr;
  17067. }(Expression));
  17068. var FnParam = /** @class */ (function () {
  17069. function FnParam(name, type) {
  17070. if (type === void 0) { type = null; }
  17071. this.name = name;
  17072. this.type = type;
  17073. }
  17074. /**
  17075. * @param {?} param
  17076. * @return {?}
  17077. */
  17078. FnParam.prototype.isEquivalent = /**
  17079. * @param {?} param
  17080. * @return {?}
  17081. */
  17082. function (param) { return this.name === param.name; };
  17083. return FnParam;
  17084. }());
  17085. var FunctionExpr = /** @class */ (function (_super) {
  17086. __extends(FunctionExpr, _super);
  17087. function FunctionExpr(params, statements, type, sourceSpan) {
  17088. var _this = _super.call(this, type, sourceSpan) || this;
  17089. _this.params = params;
  17090. _this.statements = statements;
  17091. return _this;
  17092. }
  17093. /**
  17094. * @param {?} e
  17095. * @return {?}
  17096. */
  17097. FunctionExpr.prototype.isEquivalent = /**
  17098. * @param {?} e
  17099. * @return {?}
  17100. */
  17101. function (e) {
  17102. return e instanceof FunctionExpr && areAllEquivalent(this.params, e.params) &&
  17103. areAllEquivalent(this.statements, e.statements);
  17104. };
  17105. /**
  17106. * @param {?} visitor
  17107. * @param {?} context
  17108. * @return {?}
  17109. */
  17110. FunctionExpr.prototype.visitExpression = /**
  17111. * @param {?} visitor
  17112. * @param {?} context
  17113. * @return {?}
  17114. */
  17115. function (visitor, context) {
  17116. return visitor.visitFunctionExpr(this, context);
  17117. };
  17118. /**
  17119. * @param {?} name
  17120. * @param {?=} modifiers
  17121. * @return {?}
  17122. */
  17123. FunctionExpr.prototype.toDeclStmt = /**
  17124. * @param {?} name
  17125. * @param {?=} modifiers
  17126. * @return {?}
  17127. */
  17128. function (name, modifiers) {
  17129. if (modifiers === void 0) { modifiers = null; }
  17130. return new DeclareFunctionStmt(name, this.params, this.statements, this.type, modifiers, this.sourceSpan);
  17131. };
  17132. return FunctionExpr;
  17133. }(Expression));
  17134. var BinaryOperatorExpr = /** @class */ (function (_super) {
  17135. __extends(BinaryOperatorExpr, _super);
  17136. function BinaryOperatorExpr(operator, lhs, rhs, type, sourceSpan) {
  17137. var _this = _super.call(this, type || lhs.type, sourceSpan) || this;
  17138. _this.operator = operator;
  17139. _this.rhs = rhs;
  17140. _this.lhs = lhs;
  17141. return _this;
  17142. }
  17143. /**
  17144. * @param {?} e
  17145. * @return {?}
  17146. */
  17147. BinaryOperatorExpr.prototype.isEquivalent = /**
  17148. * @param {?} e
  17149. * @return {?}
  17150. */
  17151. function (e) {
  17152. return e instanceof BinaryOperatorExpr && this.operator === e.operator &&
  17153. this.lhs.isEquivalent(e.lhs) && this.rhs.isEquivalent(e.rhs);
  17154. };
  17155. /**
  17156. * @param {?} visitor
  17157. * @param {?} context
  17158. * @return {?}
  17159. */
  17160. BinaryOperatorExpr.prototype.visitExpression = /**
  17161. * @param {?} visitor
  17162. * @param {?} context
  17163. * @return {?}
  17164. */
  17165. function (visitor, context) {
  17166. return visitor.visitBinaryOperatorExpr(this, context);
  17167. };
  17168. return BinaryOperatorExpr;
  17169. }(Expression));
  17170. var ReadPropExpr = /** @class */ (function (_super) {
  17171. __extends(ReadPropExpr, _super);
  17172. function ReadPropExpr(receiver, name, type, sourceSpan) {
  17173. var _this = _super.call(this, type, sourceSpan) || this;
  17174. _this.receiver = receiver;
  17175. _this.name = name;
  17176. return _this;
  17177. }
  17178. /**
  17179. * @param {?} e
  17180. * @return {?}
  17181. */
  17182. ReadPropExpr.prototype.isEquivalent = /**
  17183. * @param {?} e
  17184. * @return {?}
  17185. */
  17186. function (e) {
  17187. return e instanceof ReadPropExpr && this.receiver.isEquivalent(e.receiver) &&
  17188. this.name === e.name;
  17189. };
  17190. /**
  17191. * @param {?} visitor
  17192. * @param {?} context
  17193. * @return {?}
  17194. */
  17195. ReadPropExpr.prototype.visitExpression = /**
  17196. * @param {?} visitor
  17197. * @param {?} context
  17198. * @return {?}
  17199. */
  17200. function (visitor, context) {
  17201. return visitor.visitReadPropExpr(this, context);
  17202. };
  17203. /**
  17204. * @param {?} value
  17205. * @return {?}
  17206. */
  17207. ReadPropExpr.prototype.set = /**
  17208. * @param {?} value
  17209. * @return {?}
  17210. */
  17211. function (value) {
  17212. return new WritePropExpr(this.receiver, this.name, value, null, this.sourceSpan);
  17213. };
  17214. return ReadPropExpr;
  17215. }(Expression));
  17216. var ReadKeyExpr = /** @class */ (function (_super) {
  17217. __extends(ReadKeyExpr, _super);
  17218. function ReadKeyExpr(receiver, index, type, sourceSpan) {
  17219. var _this = _super.call(this, type, sourceSpan) || this;
  17220. _this.receiver = receiver;
  17221. _this.index = index;
  17222. return _this;
  17223. }
  17224. /**
  17225. * @param {?} e
  17226. * @return {?}
  17227. */
  17228. ReadKeyExpr.prototype.isEquivalent = /**
  17229. * @param {?} e
  17230. * @return {?}
  17231. */
  17232. function (e) {
  17233. return e instanceof ReadKeyExpr && this.receiver.isEquivalent(e.receiver) &&
  17234. this.index.isEquivalent(e.index);
  17235. };
  17236. /**
  17237. * @param {?} visitor
  17238. * @param {?} context
  17239. * @return {?}
  17240. */
  17241. ReadKeyExpr.prototype.visitExpression = /**
  17242. * @param {?} visitor
  17243. * @param {?} context
  17244. * @return {?}
  17245. */
  17246. function (visitor, context) {
  17247. return visitor.visitReadKeyExpr(this, context);
  17248. };
  17249. /**
  17250. * @param {?} value
  17251. * @return {?}
  17252. */
  17253. ReadKeyExpr.prototype.set = /**
  17254. * @param {?} value
  17255. * @return {?}
  17256. */
  17257. function (value) {
  17258. return new WriteKeyExpr(this.receiver, this.index, value, null, this.sourceSpan);
  17259. };
  17260. return ReadKeyExpr;
  17261. }(Expression));
  17262. var LiteralArrayExpr = /** @class */ (function (_super) {
  17263. __extends(LiteralArrayExpr, _super);
  17264. function LiteralArrayExpr(entries, type, sourceSpan) {
  17265. var _this = _super.call(this, type, sourceSpan) || this;
  17266. _this.entries = entries;
  17267. return _this;
  17268. }
  17269. /**
  17270. * @param {?} e
  17271. * @return {?}
  17272. */
  17273. LiteralArrayExpr.prototype.isEquivalent = /**
  17274. * @param {?} e
  17275. * @return {?}
  17276. */
  17277. function (e) {
  17278. return e instanceof LiteralArrayExpr && areAllEquivalent(this.entries, e.entries);
  17279. };
  17280. /**
  17281. * @param {?} visitor
  17282. * @param {?} context
  17283. * @return {?}
  17284. */
  17285. LiteralArrayExpr.prototype.visitExpression = /**
  17286. * @param {?} visitor
  17287. * @param {?} context
  17288. * @return {?}
  17289. */
  17290. function (visitor, context) {
  17291. return visitor.visitLiteralArrayExpr(this, context);
  17292. };
  17293. return LiteralArrayExpr;
  17294. }(Expression));
  17295. var LiteralMapEntry = /** @class */ (function () {
  17296. function LiteralMapEntry(key, value, quoted) {
  17297. this.key = key;
  17298. this.value = value;
  17299. this.quoted = quoted;
  17300. }
  17301. /**
  17302. * @param {?} e
  17303. * @return {?}
  17304. */
  17305. LiteralMapEntry.prototype.isEquivalent = /**
  17306. * @param {?} e
  17307. * @return {?}
  17308. */
  17309. function (e) {
  17310. return this.key === e.key && this.value.isEquivalent(e.value);
  17311. };
  17312. return LiteralMapEntry;
  17313. }());
  17314. var LiteralMapExpr = /** @class */ (function (_super) {
  17315. __extends(LiteralMapExpr, _super);
  17316. function LiteralMapExpr(entries, type, sourceSpan) {
  17317. var _this = _super.call(this, type, sourceSpan) || this;
  17318. _this.entries = entries;
  17319. _this.valueType = null;
  17320. if (type) {
  17321. _this.valueType = type.valueType;
  17322. }
  17323. return _this;
  17324. }
  17325. /**
  17326. * @param {?} e
  17327. * @return {?}
  17328. */
  17329. LiteralMapExpr.prototype.isEquivalent = /**
  17330. * @param {?} e
  17331. * @return {?}
  17332. */
  17333. function (e) {
  17334. return e instanceof LiteralMapExpr && areAllEquivalent(this.entries, e.entries);
  17335. };
  17336. /**
  17337. * @param {?} visitor
  17338. * @param {?} context
  17339. * @return {?}
  17340. */
  17341. LiteralMapExpr.prototype.visitExpression = /**
  17342. * @param {?} visitor
  17343. * @param {?} context
  17344. * @return {?}
  17345. */
  17346. function (visitor, context) {
  17347. return visitor.visitLiteralMapExpr(this, context);
  17348. };
  17349. return LiteralMapExpr;
  17350. }(Expression));
  17351. var CommaExpr = /** @class */ (function (_super) {
  17352. __extends(CommaExpr, _super);
  17353. function CommaExpr(parts, sourceSpan) {
  17354. var _this = _super.call(this, parts[parts.length - 1].type, sourceSpan) || this;
  17355. _this.parts = parts;
  17356. return _this;
  17357. }
  17358. /**
  17359. * @param {?} e
  17360. * @return {?}
  17361. */
  17362. CommaExpr.prototype.isEquivalent = /**
  17363. * @param {?} e
  17364. * @return {?}
  17365. */
  17366. function (e) {
  17367. return e instanceof CommaExpr && areAllEquivalent(this.parts, e.parts);
  17368. };
  17369. /**
  17370. * @param {?} visitor
  17371. * @param {?} context
  17372. * @return {?}
  17373. */
  17374. CommaExpr.prototype.visitExpression = /**
  17375. * @param {?} visitor
  17376. * @param {?} context
  17377. * @return {?}
  17378. */
  17379. function (visitor, context) {
  17380. return visitor.visitCommaExpr(this, context);
  17381. };
  17382. return CommaExpr;
  17383. }(Expression));
  17384. /**
  17385. * @record
  17386. */
  17387. var THIS_EXPR = new ReadVarExpr(BuiltinVar.This, null, null);
  17388. var SUPER_EXPR = new ReadVarExpr(BuiltinVar.Super, null, null);
  17389. var CATCH_ERROR_VAR = new ReadVarExpr(BuiltinVar.CatchError, null, null);
  17390. var CATCH_STACK_VAR = new ReadVarExpr(BuiltinVar.CatchStack, null, null);
  17391. var NULL_EXPR = new LiteralExpr(null, null, null);
  17392. var TYPED_NULL_EXPR = new LiteralExpr(null, INFERRED_TYPE, null);
  17393. /** @enum {number} */
  17394. var StmtModifier = {
  17395. Final: 0,
  17396. Private: 1,
  17397. Exported: 2,
  17398. };
  17399. StmtModifier[StmtModifier.Final] = "Final";
  17400. StmtModifier[StmtModifier.Private] = "Private";
  17401. StmtModifier[StmtModifier.Exported] = "Exported";
  17402. /**
  17403. * @abstract
  17404. */
  17405. var Statement = /** @class */ (function () {
  17406. function Statement(modifiers, sourceSpan) {
  17407. this.modifiers = modifiers || [];
  17408. this.sourceSpan = sourceSpan || null;
  17409. }
  17410. /**
  17411. * @param {?} modifier
  17412. * @return {?}
  17413. */
  17414. Statement.prototype.hasModifier = /**
  17415. * @param {?} modifier
  17416. * @return {?}
  17417. */
  17418. function (modifier) { return /** @type {?} */ ((this.modifiers)).indexOf(modifier) !== -1; };
  17419. return Statement;
  17420. }());
  17421. var DeclareVarStmt = /** @class */ (function (_super) {
  17422. __extends(DeclareVarStmt, _super);
  17423. function DeclareVarStmt(name, value, type, modifiers, sourceSpan) {
  17424. if (modifiers === void 0) { modifiers = null; }
  17425. var _this = _super.call(this, modifiers, sourceSpan) || this;
  17426. _this.name = name;
  17427. _this.value = value;
  17428. _this.type = type || value.type;
  17429. return _this;
  17430. }
  17431. /**
  17432. * @param {?} stmt
  17433. * @return {?}
  17434. */
  17435. DeclareVarStmt.prototype.isEquivalent = /**
  17436. * @param {?} stmt
  17437. * @return {?}
  17438. */
  17439. function (stmt) {
  17440. return stmt instanceof DeclareVarStmt && this.name === stmt.name &&
  17441. this.value.isEquivalent(stmt.value);
  17442. };
  17443. /**
  17444. * @param {?} visitor
  17445. * @param {?} context
  17446. * @return {?}
  17447. */
  17448. DeclareVarStmt.prototype.visitStatement = /**
  17449. * @param {?} visitor
  17450. * @param {?} context
  17451. * @return {?}
  17452. */
  17453. function (visitor, context) {
  17454. return visitor.visitDeclareVarStmt(this, context);
  17455. };
  17456. return DeclareVarStmt;
  17457. }(Statement));
  17458. var DeclareFunctionStmt = /** @class */ (function (_super) {
  17459. __extends(DeclareFunctionStmt, _super);
  17460. function DeclareFunctionStmt(name, params, statements, type, modifiers, sourceSpan) {
  17461. if (modifiers === void 0) { modifiers = null; }
  17462. var _this = _super.call(this, modifiers, sourceSpan) || this;
  17463. _this.name = name;
  17464. _this.params = params;
  17465. _this.statements = statements;
  17466. _this.type = type || null;
  17467. return _this;
  17468. }
  17469. /**
  17470. * @param {?} stmt
  17471. * @return {?}
  17472. */
  17473. DeclareFunctionStmt.prototype.isEquivalent = /**
  17474. * @param {?} stmt
  17475. * @return {?}
  17476. */
  17477. function (stmt) {
  17478. return stmt instanceof DeclareFunctionStmt && areAllEquivalent(this.params, stmt.params) &&
  17479. areAllEquivalent(this.statements, stmt.statements);
  17480. };
  17481. /**
  17482. * @param {?} visitor
  17483. * @param {?} context
  17484. * @return {?}
  17485. */
  17486. DeclareFunctionStmt.prototype.visitStatement = /**
  17487. * @param {?} visitor
  17488. * @param {?} context
  17489. * @return {?}
  17490. */
  17491. function (visitor, context) {
  17492. return visitor.visitDeclareFunctionStmt(this, context);
  17493. };
  17494. return DeclareFunctionStmt;
  17495. }(Statement));
  17496. var ExpressionStatement = /** @class */ (function (_super) {
  17497. __extends(ExpressionStatement, _super);
  17498. function ExpressionStatement(expr, sourceSpan) {
  17499. var _this = _super.call(this, null, sourceSpan) || this;
  17500. _this.expr = expr;
  17501. return _this;
  17502. }
  17503. /**
  17504. * @param {?} stmt
  17505. * @return {?}
  17506. */
  17507. ExpressionStatement.prototype.isEquivalent = /**
  17508. * @param {?} stmt
  17509. * @return {?}
  17510. */
  17511. function (stmt) {
  17512. return stmt instanceof ExpressionStatement && this.expr.isEquivalent(stmt.expr);
  17513. };
  17514. /**
  17515. * @param {?} visitor
  17516. * @param {?} context
  17517. * @return {?}
  17518. */
  17519. ExpressionStatement.prototype.visitStatement = /**
  17520. * @param {?} visitor
  17521. * @param {?} context
  17522. * @return {?}
  17523. */
  17524. function (visitor, context) {
  17525. return visitor.visitExpressionStmt(this, context);
  17526. };
  17527. return ExpressionStatement;
  17528. }(Statement));
  17529. var ReturnStatement = /** @class */ (function (_super) {
  17530. __extends(ReturnStatement, _super);
  17531. function ReturnStatement(value, sourceSpan) {
  17532. var _this = _super.call(this, null, sourceSpan) || this;
  17533. _this.value = value;
  17534. return _this;
  17535. }
  17536. /**
  17537. * @param {?} stmt
  17538. * @return {?}
  17539. */
  17540. ReturnStatement.prototype.isEquivalent = /**
  17541. * @param {?} stmt
  17542. * @return {?}
  17543. */
  17544. function (stmt) {
  17545. return stmt instanceof ReturnStatement && this.value.isEquivalent(stmt.value);
  17546. };
  17547. /**
  17548. * @param {?} visitor
  17549. * @param {?} context
  17550. * @return {?}
  17551. */
  17552. ReturnStatement.prototype.visitStatement = /**
  17553. * @param {?} visitor
  17554. * @param {?} context
  17555. * @return {?}
  17556. */
  17557. function (visitor, context) {
  17558. return visitor.visitReturnStmt(this, context);
  17559. };
  17560. return ReturnStatement;
  17561. }(Statement));
  17562. var AbstractClassPart = /** @class */ (function () {
  17563. function AbstractClassPart(type, modifiers) {
  17564. this.modifiers = modifiers;
  17565. if (!modifiers) {
  17566. this.modifiers = [];
  17567. }
  17568. this.type = type || null;
  17569. }
  17570. /**
  17571. * @param {?} modifier
  17572. * @return {?}
  17573. */
  17574. AbstractClassPart.prototype.hasModifier = /**
  17575. * @param {?} modifier
  17576. * @return {?}
  17577. */
  17578. function (modifier) { return /** @type {?} */ ((this.modifiers)).indexOf(modifier) !== -1; };
  17579. return AbstractClassPart;
  17580. }());
  17581. var ClassField = /** @class */ (function (_super) {
  17582. __extends(ClassField, _super);
  17583. function ClassField(name, type, modifiers) {
  17584. if (modifiers === void 0) { modifiers = null; }
  17585. var _this = _super.call(this, type, modifiers) || this;
  17586. _this.name = name;
  17587. return _this;
  17588. }
  17589. /**
  17590. * @param {?} f
  17591. * @return {?}
  17592. */
  17593. ClassField.prototype.isEquivalent = /**
  17594. * @param {?} f
  17595. * @return {?}
  17596. */
  17597. function (f) { return this.name === f.name; };
  17598. return ClassField;
  17599. }(AbstractClassPart));
  17600. var ClassMethod = /** @class */ (function (_super) {
  17601. __extends(ClassMethod, _super);
  17602. function ClassMethod(name, params, body, type, modifiers) {
  17603. if (modifiers === void 0) { modifiers = null; }
  17604. var _this = _super.call(this, type, modifiers) || this;
  17605. _this.name = name;
  17606. _this.params = params;
  17607. _this.body = body;
  17608. return _this;
  17609. }
  17610. /**
  17611. * @param {?} m
  17612. * @return {?}
  17613. */
  17614. ClassMethod.prototype.isEquivalent = /**
  17615. * @param {?} m
  17616. * @return {?}
  17617. */
  17618. function (m) {
  17619. return this.name === m.name && areAllEquivalent(this.body, m.body);
  17620. };
  17621. return ClassMethod;
  17622. }(AbstractClassPart));
  17623. var ClassGetter = /** @class */ (function (_super) {
  17624. __extends(ClassGetter, _super);
  17625. function ClassGetter(name, body, type, modifiers) {
  17626. if (modifiers === void 0) { modifiers = null; }
  17627. var _this = _super.call(this, type, modifiers) || this;
  17628. _this.name = name;
  17629. _this.body = body;
  17630. return _this;
  17631. }
  17632. /**
  17633. * @param {?} m
  17634. * @return {?}
  17635. */
  17636. ClassGetter.prototype.isEquivalent = /**
  17637. * @param {?} m
  17638. * @return {?}
  17639. */
  17640. function (m) {
  17641. return this.name === m.name && areAllEquivalent(this.body, m.body);
  17642. };
  17643. return ClassGetter;
  17644. }(AbstractClassPart));
  17645. var ClassStmt = /** @class */ (function (_super) {
  17646. __extends(ClassStmt, _super);
  17647. function ClassStmt(name, parent, fields, getters, constructorMethod, methods, modifiers, sourceSpan) {
  17648. if (modifiers === void 0) { modifiers = null; }
  17649. var _this = _super.call(this, modifiers, sourceSpan) || this;
  17650. _this.name = name;
  17651. _this.parent = parent;
  17652. _this.fields = fields;
  17653. _this.getters = getters;
  17654. _this.constructorMethod = constructorMethod;
  17655. _this.methods = methods;
  17656. return _this;
  17657. }
  17658. /**
  17659. * @param {?} stmt
  17660. * @return {?}
  17661. */
  17662. ClassStmt.prototype.isEquivalent = /**
  17663. * @param {?} stmt
  17664. * @return {?}
  17665. */
  17666. function (stmt) {
  17667. return stmt instanceof ClassStmt && this.name === stmt.name &&
  17668. nullSafeIsEquivalent(this.parent, stmt.parent) &&
  17669. areAllEquivalent(this.fields, stmt.fields) &&
  17670. areAllEquivalent(this.getters, stmt.getters) &&
  17671. this.constructorMethod.isEquivalent(stmt.constructorMethod) &&
  17672. areAllEquivalent(this.methods, stmt.methods);
  17673. };
  17674. /**
  17675. * @param {?} visitor
  17676. * @param {?} context
  17677. * @return {?}
  17678. */
  17679. ClassStmt.prototype.visitStatement = /**
  17680. * @param {?} visitor
  17681. * @param {?} context
  17682. * @return {?}
  17683. */
  17684. function (visitor, context) {
  17685. return visitor.visitDeclareClassStmt(this, context);
  17686. };
  17687. return ClassStmt;
  17688. }(Statement));
  17689. var IfStmt = /** @class */ (function (_super) {
  17690. __extends(IfStmt, _super);
  17691. function IfStmt(condition, trueCase, falseCase, sourceSpan) {
  17692. if (falseCase === void 0) { falseCase = []; }
  17693. var _this = _super.call(this, null, sourceSpan) || this;
  17694. _this.condition = condition;
  17695. _this.trueCase = trueCase;
  17696. _this.falseCase = falseCase;
  17697. return _this;
  17698. }
  17699. /**
  17700. * @param {?} stmt
  17701. * @return {?}
  17702. */
  17703. IfStmt.prototype.isEquivalent = /**
  17704. * @param {?} stmt
  17705. * @return {?}
  17706. */
  17707. function (stmt) {
  17708. return stmt instanceof IfStmt && this.condition.isEquivalent(stmt.condition) &&
  17709. areAllEquivalent(this.trueCase, stmt.trueCase) &&
  17710. areAllEquivalent(this.falseCase, stmt.falseCase);
  17711. };
  17712. /**
  17713. * @param {?} visitor
  17714. * @param {?} context
  17715. * @return {?}
  17716. */
  17717. IfStmt.prototype.visitStatement = /**
  17718. * @param {?} visitor
  17719. * @param {?} context
  17720. * @return {?}
  17721. */
  17722. function (visitor, context) {
  17723. return visitor.visitIfStmt(this, context);
  17724. };
  17725. return IfStmt;
  17726. }(Statement));
  17727. var CommentStmt = /** @class */ (function (_super) {
  17728. __extends(CommentStmt, _super);
  17729. function CommentStmt(comment, sourceSpan) {
  17730. var _this = _super.call(this, null, sourceSpan) || this;
  17731. _this.comment = comment;
  17732. return _this;
  17733. }
  17734. /**
  17735. * @param {?} stmt
  17736. * @return {?}
  17737. */
  17738. CommentStmt.prototype.isEquivalent = /**
  17739. * @param {?} stmt
  17740. * @return {?}
  17741. */
  17742. function (stmt) { return stmt instanceof CommentStmt; };
  17743. /**
  17744. * @param {?} visitor
  17745. * @param {?} context
  17746. * @return {?}
  17747. */
  17748. CommentStmt.prototype.visitStatement = /**
  17749. * @param {?} visitor
  17750. * @param {?} context
  17751. * @return {?}
  17752. */
  17753. function (visitor, context) {
  17754. return visitor.visitCommentStmt(this, context);
  17755. };
  17756. return CommentStmt;
  17757. }(Statement));
  17758. var TryCatchStmt = /** @class */ (function (_super) {
  17759. __extends(TryCatchStmt, _super);
  17760. function TryCatchStmt(bodyStmts, catchStmts, sourceSpan) {
  17761. var _this = _super.call(this, null, sourceSpan) || this;
  17762. _this.bodyStmts = bodyStmts;
  17763. _this.catchStmts = catchStmts;
  17764. return _this;
  17765. }
  17766. /**
  17767. * @param {?} stmt
  17768. * @return {?}
  17769. */
  17770. TryCatchStmt.prototype.isEquivalent = /**
  17771. * @param {?} stmt
  17772. * @return {?}
  17773. */
  17774. function (stmt) {
  17775. return stmt instanceof TryCatchStmt && areAllEquivalent(this.bodyStmts, stmt.bodyStmts) &&
  17776. areAllEquivalent(this.catchStmts, stmt.catchStmts);
  17777. };
  17778. /**
  17779. * @param {?} visitor
  17780. * @param {?} context
  17781. * @return {?}
  17782. */
  17783. TryCatchStmt.prototype.visitStatement = /**
  17784. * @param {?} visitor
  17785. * @param {?} context
  17786. * @return {?}
  17787. */
  17788. function (visitor, context) {
  17789. return visitor.visitTryCatchStmt(this, context);
  17790. };
  17791. return TryCatchStmt;
  17792. }(Statement));
  17793. var ThrowStmt = /** @class */ (function (_super) {
  17794. __extends(ThrowStmt, _super);
  17795. function ThrowStmt(error, sourceSpan) {
  17796. var _this = _super.call(this, null, sourceSpan) || this;
  17797. _this.error = error;
  17798. return _this;
  17799. }
  17800. /**
  17801. * @param {?} stmt
  17802. * @return {?}
  17803. */
  17804. ThrowStmt.prototype.isEquivalent = /**
  17805. * @param {?} stmt
  17806. * @return {?}
  17807. */
  17808. function (stmt) {
  17809. return stmt instanceof TryCatchStmt && this.error.isEquivalent(stmt.error);
  17810. };
  17811. /**
  17812. * @param {?} visitor
  17813. * @param {?} context
  17814. * @return {?}
  17815. */
  17816. ThrowStmt.prototype.visitStatement = /**
  17817. * @param {?} visitor
  17818. * @param {?} context
  17819. * @return {?}
  17820. */
  17821. function (visitor, context) {
  17822. return visitor.visitThrowStmt(this, context);
  17823. };
  17824. return ThrowStmt;
  17825. }(Statement));
  17826. /**
  17827. * @record
  17828. */
  17829. var AstTransformer$1 = /** @class */ (function () {
  17830. function AstTransformer() {
  17831. }
  17832. /**
  17833. * @param {?} expr
  17834. * @param {?} context
  17835. * @return {?}
  17836. */
  17837. AstTransformer.prototype.transformExpr = /**
  17838. * @param {?} expr
  17839. * @param {?} context
  17840. * @return {?}
  17841. */
  17842. function (expr, context) { return expr; };
  17843. /**
  17844. * @param {?} stmt
  17845. * @param {?} context
  17846. * @return {?}
  17847. */
  17848. AstTransformer.prototype.transformStmt = /**
  17849. * @param {?} stmt
  17850. * @param {?} context
  17851. * @return {?}
  17852. */
  17853. function (stmt, context) { return stmt; };
  17854. /**
  17855. * @param {?} ast
  17856. * @param {?} context
  17857. * @return {?}
  17858. */
  17859. AstTransformer.prototype.visitReadVarExpr = /**
  17860. * @param {?} ast
  17861. * @param {?} context
  17862. * @return {?}
  17863. */
  17864. function (ast, context) { return this.transformExpr(ast, context); };
  17865. /**
  17866. * @param {?} expr
  17867. * @param {?} context
  17868. * @return {?}
  17869. */
  17870. AstTransformer.prototype.visitWriteVarExpr = /**
  17871. * @param {?} expr
  17872. * @param {?} context
  17873. * @return {?}
  17874. */
  17875. function (expr, context) {
  17876. return this.transformExpr(new WriteVarExpr(expr.name, expr.value.visitExpression(this, context), expr.type, expr.sourceSpan), context);
  17877. };
  17878. /**
  17879. * @param {?} expr
  17880. * @param {?} context
  17881. * @return {?}
  17882. */
  17883. AstTransformer.prototype.visitWriteKeyExpr = /**
  17884. * @param {?} expr
  17885. * @param {?} context
  17886. * @return {?}
  17887. */
  17888. function (expr, context) {
  17889. return this.transformExpr(new WriteKeyExpr(expr.receiver.visitExpression(this, context), expr.index.visitExpression(this, context), expr.value.visitExpression(this, context), expr.type, expr.sourceSpan), context);
  17890. };
  17891. /**
  17892. * @param {?} expr
  17893. * @param {?} context
  17894. * @return {?}
  17895. */
  17896. AstTransformer.prototype.visitWritePropExpr = /**
  17897. * @param {?} expr
  17898. * @param {?} context
  17899. * @return {?}
  17900. */
  17901. function (expr, context) {
  17902. return this.transformExpr(new WritePropExpr(expr.receiver.visitExpression(this, context), expr.name, expr.value.visitExpression(this, context), expr.type, expr.sourceSpan), context);
  17903. };
  17904. /**
  17905. * @param {?} ast
  17906. * @param {?} context
  17907. * @return {?}
  17908. */
  17909. AstTransformer.prototype.visitInvokeMethodExpr = /**
  17910. * @param {?} ast
  17911. * @param {?} context
  17912. * @return {?}
  17913. */
  17914. function (ast, context) {
  17915. var /** @type {?} */ method = ast.builtin || ast.name;
  17916. return this.transformExpr(new InvokeMethodExpr(ast.receiver.visitExpression(this, context), /** @type {?} */ ((method)), this.visitAllExpressions(ast.args, context), ast.type, ast.sourceSpan), context);
  17917. };
  17918. /**
  17919. * @param {?} ast
  17920. * @param {?} context
  17921. * @return {?}
  17922. */
  17923. AstTransformer.prototype.visitInvokeFunctionExpr = /**
  17924. * @param {?} ast
  17925. * @param {?} context
  17926. * @return {?}
  17927. */
  17928. function (ast, context) {
  17929. return this.transformExpr(new InvokeFunctionExpr(ast.fn.visitExpression(this, context), this.visitAllExpressions(ast.args, context), ast.type, ast.sourceSpan), context);
  17930. };
  17931. /**
  17932. * @param {?} ast
  17933. * @param {?} context
  17934. * @return {?}
  17935. */
  17936. AstTransformer.prototype.visitInstantiateExpr = /**
  17937. * @param {?} ast
  17938. * @param {?} context
  17939. * @return {?}
  17940. */
  17941. function (ast, context) {
  17942. return this.transformExpr(new InstantiateExpr(ast.classExpr.visitExpression(this, context), this.visitAllExpressions(ast.args, context), ast.type, ast.sourceSpan), context);
  17943. };
  17944. /**
  17945. * @param {?} ast
  17946. * @param {?} context
  17947. * @return {?}
  17948. */
  17949. AstTransformer.prototype.visitLiteralExpr = /**
  17950. * @param {?} ast
  17951. * @param {?} context
  17952. * @return {?}
  17953. */
  17954. function (ast, context) { return this.transformExpr(ast, context); };
  17955. /**
  17956. * @param {?} ast
  17957. * @param {?} context
  17958. * @return {?}
  17959. */
  17960. AstTransformer.prototype.visitExternalExpr = /**
  17961. * @param {?} ast
  17962. * @param {?} context
  17963. * @return {?}
  17964. */
  17965. function (ast, context) {
  17966. return this.transformExpr(ast, context);
  17967. };
  17968. /**
  17969. * @param {?} ast
  17970. * @param {?} context
  17971. * @return {?}
  17972. */
  17973. AstTransformer.prototype.visitConditionalExpr = /**
  17974. * @param {?} ast
  17975. * @param {?} context
  17976. * @return {?}
  17977. */
  17978. function (ast, context) {
  17979. return this.transformExpr(new ConditionalExpr(ast.condition.visitExpression(this, context), ast.trueCase.visitExpression(this, context), /** @type {?} */ ((ast.falseCase)).visitExpression(this, context), ast.type, ast.sourceSpan), context);
  17980. };
  17981. /**
  17982. * @param {?} ast
  17983. * @param {?} context
  17984. * @return {?}
  17985. */
  17986. AstTransformer.prototype.visitNotExpr = /**
  17987. * @param {?} ast
  17988. * @param {?} context
  17989. * @return {?}
  17990. */
  17991. function (ast, context) {
  17992. return this.transformExpr(new NotExpr(ast.condition.visitExpression(this, context), ast.sourceSpan), context);
  17993. };
  17994. /**
  17995. * @param {?} ast
  17996. * @param {?} context
  17997. * @return {?}
  17998. */
  17999. AstTransformer.prototype.visitAssertNotNullExpr = /**
  18000. * @param {?} ast
  18001. * @param {?} context
  18002. * @return {?}
  18003. */
  18004. function (ast, context) {
  18005. return this.transformExpr(new AssertNotNull(ast.condition.visitExpression(this, context), ast.sourceSpan), context);
  18006. };
  18007. /**
  18008. * @param {?} ast
  18009. * @param {?} context
  18010. * @return {?}
  18011. */
  18012. AstTransformer.prototype.visitCastExpr = /**
  18013. * @param {?} ast
  18014. * @param {?} context
  18015. * @return {?}
  18016. */
  18017. function (ast, context) {
  18018. return this.transformExpr(new CastExpr(ast.value.visitExpression(this, context), ast.type, ast.sourceSpan), context);
  18019. };
  18020. /**
  18021. * @param {?} ast
  18022. * @param {?} context
  18023. * @return {?}
  18024. */
  18025. AstTransformer.prototype.visitFunctionExpr = /**
  18026. * @param {?} ast
  18027. * @param {?} context
  18028. * @return {?}
  18029. */
  18030. function (ast, context) {
  18031. return this.transformExpr(new FunctionExpr(ast.params, this.visitAllStatements(ast.statements, context), ast.type, ast.sourceSpan), context);
  18032. };
  18033. /**
  18034. * @param {?} ast
  18035. * @param {?} context
  18036. * @return {?}
  18037. */
  18038. AstTransformer.prototype.visitBinaryOperatorExpr = /**
  18039. * @param {?} ast
  18040. * @param {?} context
  18041. * @return {?}
  18042. */
  18043. function (ast, context) {
  18044. return this.transformExpr(new BinaryOperatorExpr(ast.operator, ast.lhs.visitExpression(this, context), ast.rhs.visitExpression(this, context), ast.type, ast.sourceSpan), context);
  18045. };
  18046. /**
  18047. * @param {?} ast
  18048. * @param {?} context
  18049. * @return {?}
  18050. */
  18051. AstTransformer.prototype.visitReadPropExpr = /**
  18052. * @param {?} ast
  18053. * @param {?} context
  18054. * @return {?}
  18055. */
  18056. function (ast, context) {
  18057. return this.transformExpr(new ReadPropExpr(ast.receiver.visitExpression(this, context), ast.name, ast.type, ast.sourceSpan), context);
  18058. };
  18059. /**
  18060. * @param {?} ast
  18061. * @param {?} context
  18062. * @return {?}
  18063. */
  18064. AstTransformer.prototype.visitReadKeyExpr = /**
  18065. * @param {?} ast
  18066. * @param {?} context
  18067. * @return {?}
  18068. */
  18069. function (ast, context) {
  18070. return this.transformExpr(new ReadKeyExpr(ast.receiver.visitExpression(this, context), ast.index.visitExpression(this, context), ast.type, ast.sourceSpan), context);
  18071. };
  18072. /**
  18073. * @param {?} ast
  18074. * @param {?} context
  18075. * @return {?}
  18076. */
  18077. AstTransformer.prototype.visitLiteralArrayExpr = /**
  18078. * @param {?} ast
  18079. * @param {?} context
  18080. * @return {?}
  18081. */
  18082. function (ast, context) {
  18083. return this.transformExpr(new LiteralArrayExpr(this.visitAllExpressions(ast.entries, context), ast.type, ast.sourceSpan), context);
  18084. };
  18085. /**
  18086. * @param {?} ast
  18087. * @param {?} context
  18088. * @return {?}
  18089. */
  18090. AstTransformer.prototype.visitLiteralMapExpr = /**
  18091. * @param {?} ast
  18092. * @param {?} context
  18093. * @return {?}
  18094. */
  18095. function (ast, context) {
  18096. var _this = this;
  18097. var /** @type {?} */ entries = ast.entries.map(function (entry) {
  18098. return new LiteralMapEntry(entry.key, entry.value.visitExpression(_this, context), entry.quoted);
  18099. });
  18100. var /** @type {?} */ mapType = new MapType(ast.valueType, null);
  18101. return this.transformExpr(new LiteralMapExpr(entries, mapType, ast.sourceSpan), context);
  18102. };
  18103. /**
  18104. * @param {?} ast
  18105. * @param {?} context
  18106. * @return {?}
  18107. */
  18108. AstTransformer.prototype.visitCommaExpr = /**
  18109. * @param {?} ast
  18110. * @param {?} context
  18111. * @return {?}
  18112. */
  18113. function (ast, context) {
  18114. return this.transformExpr(new CommaExpr(this.visitAllExpressions(ast.parts, context), ast.sourceSpan), context);
  18115. };
  18116. /**
  18117. * @param {?} exprs
  18118. * @param {?} context
  18119. * @return {?}
  18120. */
  18121. AstTransformer.prototype.visitAllExpressions = /**
  18122. * @param {?} exprs
  18123. * @param {?} context
  18124. * @return {?}
  18125. */
  18126. function (exprs, context) {
  18127. var _this = this;
  18128. return exprs.map(function (expr) { return expr.visitExpression(_this, context); });
  18129. };
  18130. /**
  18131. * @param {?} stmt
  18132. * @param {?} context
  18133. * @return {?}
  18134. */
  18135. AstTransformer.prototype.visitDeclareVarStmt = /**
  18136. * @param {?} stmt
  18137. * @param {?} context
  18138. * @return {?}
  18139. */
  18140. function (stmt, context) {
  18141. return this.transformStmt(new DeclareVarStmt(stmt.name, stmt.value.visitExpression(this, context), stmt.type, stmt.modifiers, stmt.sourceSpan), context);
  18142. };
  18143. /**
  18144. * @param {?} stmt
  18145. * @param {?} context
  18146. * @return {?}
  18147. */
  18148. AstTransformer.prototype.visitDeclareFunctionStmt = /**
  18149. * @param {?} stmt
  18150. * @param {?} context
  18151. * @return {?}
  18152. */
  18153. function (stmt, context) {
  18154. return this.transformStmt(new DeclareFunctionStmt(stmt.name, stmt.params, this.visitAllStatements(stmt.statements, context), stmt.type, stmt.modifiers, stmt.sourceSpan), context);
  18155. };
  18156. /**
  18157. * @param {?} stmt
  18158. * @param {?} context
  18159. * @return {?}
  18160. */
  18161. AstTransformer.prototype.visitExpressionStmt = /**
  18162. * @param {?} stmt
  18163. * @param {?} context
  18164. * @return {?}
  18165. */
  18166. function (stmt, context) {
  18167. return this.transformStmt(new ExpressionStatement(stmt.expr.visitExpression(this, context), stmt.sourceSpan), context);
  18168. };
  18169. /**
  18170. * @param {?} stmt
  18171. * @param {?} context
  18172. * @return {?}
  18173. */
  18174. AstTransformer.prototype.visitReturnStmt = /**
  18175. * @param {?} stmt
  18176. * @param {?} context
  18177. * @return {?}
  18178. */
  18179. function (stmt, context) {
  18180. return this.transformStmt(new ReturnStatement(stmt.value.visitExpression(this, context), stmt.sourceSpan), context);
  18181. };
  18182. /**
  18183. * @param {?} stmt
  18184. * @param {?} context
  18185. * @return {?}
  18186. */
  18187. AstTransformer.prototype.visitDeclareClassStmt = /**
  18188. * @param {?} stmt
  18189. * @param {?} context
  18190. * @return {?}
  18191. */
  18192. function (stmt, context) {
  18193. var _this = this;
  18194. var /** @type {?} */ parent = /** @type {?} */ ((stmt.parent)).visitExpression(this, context);
  18195. var /** @type {?} */ getters = stmt.getters.map(function (getter) {
  18196. return new ClassGetter(getter.name, _this.visitAllStatements(getter.body, context), getter.type, getter.modifiers);
  18197. });
  18198. var /** @type {?} */ ctorMethod = stmt.constructorMethod &&
  18199. new ClassMethod(stmt.constructorMethod.name, stmt.constructorMethod.params, this.visitAllStatements(stmt.constructorMethod.body, context), stmt.constructorMethod.type, stmt.constructorMethod.modifiers);
  18200. var /** @type {?} */ methods = stmt.methods.map(function (method) {
  18201. return new ClassMethod(method.name, method.params, _this.visitAllStatements(method.body, context), method.type, method.modifiers);
  18202. });
  18203. return this.transformStmt(new ClassStmt(stmt.name, parent, stmt.fields, getters, ctorMethod, methods, stmt.modifiers, stmt.sourceSpan), context);
  18204. };
  18205. /**
  18206. * @param {?} stmt
  18207. * @param {?} context
  18208. * @return {?}
  18209. */
  18210. AstTransformer.prototype.visitIfStmt = /**
  18211. * @param {?} stmt
  18212. * @param {?} context
  18213. * @return {?}
  18214. */
  18215. function (stmt, context) {
  18216. return this.transformStmt(new IfStmt(stmt.condition.visitExpression(this, context), this.visitAllStatements(stmt.trueCase, context), this.visitAllStatements(stmt.falseCase, context), stmt.sourceSpan), context);
  18217. };
  18218. /**
  18219. * @param {?} stmt
  18220. * @param {?} context
  18221. * @return {?}
  18222. */
  18223. AstTransformer.prototype.visitTryCatchStmt = /**
  18224. * @param {?} stmt
  18225. * @param {?} context
  18226. * @return {?}
  18227. */
  18228. function (stmt, context) {
  18229. return this.transformStmt(new TryCatchStmt(this.visitAllStatements(stmt.bodyStmts, context), this.visitAllStatements(stmt.catchStmts, context), stmt.sourceSpan), context);
  18230. };
  18231. /**
  18232. * @param {?} stmt
  18233. * @param {?} context
  18234. * @return {?}
  18235. */
  18236. AstTransformer.prototype.visitThrowStmt = /**
  18237. * @param {?} stmt
  18238. * @param {?} context
  18239. * @return {?}
  18240. */
  18241. function (stmt, context) {
  18242. return this.transformStmt(new ThrowStmt(stmt.error.visitExpression(this, context), stmt.sourceSpan), context);
  18243. };
  18244. /**
  18245. * @param {?} stmt
  18246. * @param {?} context
  18247. * @return {?}
  18248. */
  18249. AstTransformer.prototype.visitCommentStmt = /**
  18250. * @param {?} stmt
  18251. * @param {?} context
  18252. * @return {?}
  18253. */
  18254. function (stmt, context) {
  18255. return this.transformStmt(stmt, context);
  18256. };
  18257. /**
  18258. * @param {?} stmts
  18259. * @param {?} context
  18260. * @return {?}
  18261. */
  18262. AstTransformer.prototype.visitAllStatements = /**
  18263. * @param {?} stmts
  18264. * @param {?} context
  18265. * @return {?}
  18266. */
  18267. function (stmts, context) {
  18268. var _this = this;
  18269. return stmts.map(function (stmt) { return stmt.visitStatement(_this, context); });
  18270. };
  18271. return AstTransformer;
  18272. }());
  18273. var RecursiveAstVisitor$1 = /** @class */ (function () {
  18274. function RecursiveAstVisitor() {
  18275. }
  18276. /**
  18277. * @param {?} ast
  18278. * @param {?} context
  18279. * @return {?}
  18280. */
  18281. RecursiveAstVisitor.prototype.visitType = /**
  18282. * @param {?} ast
  18283. * @param {?} context
  18284. * @return {?}
  18285. */
  18286. function (ast, context) { return ast; };
  18287. /**
  18288. * @param {?} ast
  18289. * @param {?} context
  18290. * @return {?}
  18291. */
  18292. RecursiveAstVisitor.prototype.visitExpression = /**
  18293. * @param {?} ast
  18294. * @param {?} context
  18295. * @return {?}
  18296. */
  18297. function (ast, context) {
  18298. if (ast.type) {
  18299. ast.type.visitType(this, context);
  18300. }
  18301. return ast;
  18302. };
  18303. /**
  18304. * @param {?} type
  18305. * @param {?} context
  18306. * @return {?}
  18307. */
  18308. RecursiveAstVisitor.prototype.visitBuiltintType = /**
  18309. * @param {?} type
  18310. * @param {?} context
  18311. * @return {?}
  18312. */
  18313. function (type, context) { return this.visitType(type, context); };
  18314. /**
  18315. * @param {?} type
  18316. * @param {?} context
  18317. * @return {?}
  18318. */
  18319. RecursiveAstVisitor.prototype.visitExpressionType = /**
  18320. * @param {?} type
  18321. * @param {?} context
  18322. * @return {?}
  18323. */
  18324. function (type, context) {
  18325. type.value.visitExpression(this, context);
  18326. return this.visitType(type, context);
  18327. };
  18328. /**
  18329. * @param {?} type
  18330. * @param {?} context
  18331. * @return {?}
  18332. */
  18333. RecursiveAstVisitor.prototype.visitArrayType = /**
  18334. * @param {?} type
  18335. * @param {?} context
  18336. * @return {?}
  18337. */
  18338. function (type, context) { return this.visitType(type, context); };
  18339. /**
  18340. * @param {?} type
  18341. * @param {?} context
  18342. * @return {?}
  18343. */
  18344. RecursiveAstVisitor.prototype.visitMapType = /**
  18345. * @param {?} type
  18346. * @param {?} context
  18347. * @return {?}
  18348. */
  18349. function (type, context) { return this.visitType(type, context); };
  18350. /**
  18351. * @param {?} ast
  18352. * @param {?} context
  18353. * @return {?}
  18354. */
  18355. RecursiveAstVisitor.prototype.visitReadVarExpr = /**
  18356. * @param {?} ast
  18357. * @param {?} context
  18358. * @return {?}
  18359. */
  18360. function (ast, context) {
  18361. return this.visitExpression(ast, context);
  18362. };
  18363. /**
  18364. * @param {?} ast
  18365. * @param {?} context
  18366. * @return {?}
  18367. */
  18368. RecursiveAstVisitor.prototype.visitWriteVarExpr = /**
  18369. * @param {?} ast
  18370. * @param {?} context
  18371. * @return {?}
  18372. */
  18373. function (ast, context) {
  18374. ast.value.visitExpression(this, context);
  18375. return this.visitExpression(ast, context);
  18376. };
  18377. /**
  18378. * @param {?} ast
  18379. * @param {?} context
  18380. * @return {?}
  18381. */
  18382. RecursiveAstVisitor.prototype.visitWriteKeyExpr = /**
  18383. * @param {?} ast
  18384. * @param {?} context
  18385. * @return {?}
  18386. */
  18387. function (ast, context) {
  18388. ast.receiver.visitExpression(this, context);
  18389. ast.index.visitExpression(this, context);
  18390. ast.value.visitExpression(this, context);
  18391. return this.visitExpression(ast, context);
  18392. };
  18393. /**
  18394. * @param {?} ast
  18395. * @param {?} context
  18396. * @return {?}
  18397. */
  18398. RecursiveAstVisitor.prototype.visitWritePropExpr = /**
  18399. * @param {?} ast
  18400. * @param {?} context
  18401. * @return {?}
  18402. */
  18403. function (ast, context) {
  18404. ast.receiver.visitExpression(this, context);
  18405. ast.value.visitExpression(this, context);
  18406. return this.visitExpression(ast, context);
  18407. };
  18408. /**
  18409. * @param {?} ast
  18410. * @param {?} context
  18411. * @return {?}
  18412. */
  18413. RecursiveAstVisitor.prototype.visitInvokeMethodExpr = /**
  18414. * @param {?} ast
  18415. * @param {?} context
  18416. * @return {?}
  18417. */
  18418. function (ast, context) {
  18419. ast.receiver.visitExpression(this, context);
  18420. this.visitAllExpressions(ast.args, context);
  18421. return this.visitExpression(ast, context);
  18422. };
  18423. /**
  18424. * @param {?} ast
  18425. * @param {?} context
  18426. * @return {?}
  18427. */
  18428. RecursiveAstVisitor.prototype.visitInvokeFunctionExpr = /**
  18429. * @param {?} ast
  18430. * @param {?} context
  18431. * @return {?}
  18432. */
  18433. function (ast, context) {
  18434. ast.fn.visitExpression(this, context);
  18435. this.visitAllExpressions(ast.args, context);
  18436. return this.visitExpression(ast, context);
  18437. };
  18438. /**
  18439. * @param {?} ast
  18440. * @param {?} context
  18441. * @return {?}
  18442. */
  18443. RecursiveAstVisitor.prototype.visitInstantiateExpr = /**
  18444. * @param {?} ast
  18445. * @param {?} context
  18446. * @return {?}
  18447. */
  18448. function (ast, context) {
  18449. ast.classExpr.visitExpression(this, context);
  18450. this.visitAllExpressions(ast.args, context);
  18451. return this.visitExpression(ast, context);
  18452. };
  18453. /**
  18454. * @param {?} ast
  18455. * @param {?} context
  18456. * @return {?}
  18457. */
  18458. RecursiveAstVisitor.prototype.visitLiteralExpr = /**
  18459. * @param {?} ast
  18460. * @param {?} context
  18461. * @return {?}
  18462. */
  18463. function (ast, context) {
  18464. return this.visitExpression(ast, context);
  18465. };
  18466. /**
  18467. * @param {?} ast
  18468. * @param {?} context
  18469. * @return {?}
  18470. */
  18471. RecursiveAstVisitor.prototype.visitExternalExpr = /**
  18472. * @param {?} ast
  18473. * @param {?} context
  18474. * @return {?}
  18475. */
  18476. function (ast, context) {
  18477. var _this = this;
  18478. if (ast.typeParams) {
  18479. ast.typeParams.forEach(function (type) { return type.visitType(_this, context); });
  18480. }
  18481. return this.visitExpression(ast, context);
  18482. };
  18483. /**
  18484. * @param {?} ast
  18485. * @param {?} context
  18486. * @return {?}
  18487. */
  18488. RecursiveAstVisitor.prototype.visitConditionalExpr = /**
  18489. * @param {?} ast
  18490. * @param {?} context
  18491. * @return {?}
  18492. */
  18493. function (ast, context) {
  18494. ast.condition.visitExpression(this, context);
  18495. ast.trueCase.visitExpression(this, context); /** @type {?} */
  18496. ((ast.falseCase)).visitExpression(this, context);
  18497. return this.visitExpression(ast, context);
  18498. };
  18499. /**
  18500. * @param {?} ast
  18501. * @param {?} context
  18502. * @return {?}
  18503. */
  18504. RecursiveAstVisitor.prototype.visitNotExpr = /**
  18505. * @param {?} ast
  18506. * @param {?} context
  18507. * @return {?}
  18508. */
  18509. function (ast, context) {
  18510. ast.condition.visitExpression(this, context);
  18511. return this.visitExpression(ast, context);
  18512. };
  18513. /**
  18514. * @param {?} ast
  18515. * @param {?} context
  18516. * @return {?}
  18517. */
  18518. RecursiveAstVisitor.prototype.visitAssertNotNullExpr = /**
  18519. * @param {?} ast
  18520. * @param {?} context
  18521. * @return {?}
  18522. */
  18523. function (ast, context) {
  18524. ast.condition.visitExpression(this, context);
  18525. return this.visitExpression(ast, context);
  18526. };
  18527. /**
  18528. * @param {?} ast
  18529. * @param {?} context
  18530. * @return {?}
  18531. */
  18532. RecursiveAstVisitor.prototype.visitCastExpr = /**
  18533. * @param {?} ast
  18534. * @param {?} context
  18535. * @return {?}
  18536. */
  18537. function (ast, context) {
  18538. ast.value.visitExpression(this, context);
  18539. return this.visitExpression(ast, context);
  18540. };
  18541. /**
  18542. * @param {?} ast
  18543. * @param {?} context
  18544. * @return {?}
  18545. */
  18546. RecursiveAstVisitor.prototype.visitFunctionExpr = /**
  18547. * @param {?} ast
  18548. * @param {?} context
  18549. * @return {?}
  18550. */
  18551. function (ast, context) {
  18552. this.visitAllStatements(ast.statements, context);
  18553. return this.visitExpression(ast, context);
  18554. };
  18555. /**
  18556. * @param {?} ast
  18557. * @param {?} context
  18558. * @return {?}
  18559. */
  18560. RecursiveAstVisitor.prototype.visitBinaryOperatorExpr = /**
  18561. * @param {?} ast
  18562. * @param {?} context
  18563. * @return {?}
  18564. */
  18565. function (ast, context) {
  18566. ast.lhs.visitExpression(this, context);
  18567. ast.rhs.visitExpression(this, context);
  18568. return this.visitExpression(ast, context);
  18569. };
  18570. /**
  18571. * @param {?} ast
  18572. * @param {?} context
  18573. * @return {?}
  18574. */
  18575. RecursiveAstVisitor.prototype.visitReadPropExpr = /**
  18576. * @param {?} ast
  18577. * @param {?} context
  18578. * @return {?}
  18579. */
  18580. function (ast, context) {
  18581. ast.receiver.visitExpression(this, context);
  18582. return this.visitExpression(ast, context);
  18583. };
  18584. /**
  18585. * @param {?} ast
  18586. * @param {?} context
  18587. * @return {?}
  18588. */
  18589. RecursiveAstVisitor.prototype.visitReadKeyExpr = /**
  18590. * @param {?} ast
  18591. * @param {?} context
  18592. * @return {?}
  18593. */
  18594. function (ast, context) {
  18595. ast.receiver.visitExpression(this, context);
  18596. ast.index.visitExpression(this, context);
  18597. return this.visitExpression(ast, context);
  18598. };
  18599. /**
  18600. * @param {?} ast
  18601. * @param {?} context
  18602. * @return {?}
  18603. */
  18604. RecursiveAstVisitor.prototype.visitLiteralArrayExpr = /**
  18605. * @param {?} ast
  18606. * @param {?} context
  18607. * @return {?}
  18608. */
  18609. function (ast, context) {
  18610. this.visitAllExpressions(ast.entries, context);
  18611. return this.visitExpression(ast, context);
  18612. };
  18613. /**
  18614. * @param {?} ast
  18615. * @param {?} context
  18616. * @return {?}
  18617. */
  18618. RecursiveAstVisitor.prototype.visitLiteralMapExpr = /**
  18619. * @param {?} ast
  18620. * @param {?} context
  18621. * @return {?}
  18622. */
  18623. function (ast, context) {
  18624. var _this = this;
  18625. ast.entries.forEach(function (entry) { return entry.value.visitExpression(_this, context); });
  18626. return this.visitExpression(ast, context);
  18627. };
  18628. /**
  18629. * @param {?} ast
  18630. * @param {?} context
  18631. * @return {?}
  18632. */
  18633. RecursiveAstVisitor.prototype.visitCommaExpr = /**
  18634. * @param {?} ast
  18635. * @param {?} context
  18636. * @return {?}
  18637. */
  18638. function (ast, context) {
  18639. this.visitAllExpressions(ast.parts, context);
  18640. return this.visitExpression(ast, context);
  18641. };
  18642. /**
  18643. * @param {?} exprs
  18644. * @param {?} context
  18645. * @return {?}
  18646. */
  18647. RecursiveAstVisitor.prototype.visitAllExpressions = /**
  18648. * @param {?} exprs
  18649. * @param {?} context
  18650. * @return {?}
  18651. */
  18652. function (exprs, context) {
  18653. var _this = this;
  18654. exprs.forEach(function (expr) { return expr.visitExpression(_this, context); });
  18655. };
  18656. /**
  18657. * @param {?} stmt
  18658. * @param {?} context
  18659. * @return {?}
  18660. */
  18661. RecursiveAstVisitor.prototype.visitDeclareVarStmt = /**
  18662. * @param {?} stmt
  18663. * @param {?} context
  18664. * @return {?}
  18665. */
  18666. function (stmt, context) {
  18667. stmt.value.visitExpression(this, context);
  18668. if (stmt.type) {
  18669. stmt.type.visitType(this, context);
  18670. }
  18671. return stmt;
  18672. };
  18673. /**
  18674. * @param {?} stmt
  18675. * @param {?} context
  18676. * @return {?}
  18677. */
  18678. RecursiveAstVisitor.prototype.visitDeclareFunctionStmt = /**
  18679. * @param {?} stmt
  18680. * @param {?} context
  18681. * @return {?}
  18682. */
  18683. function (stmt, context) {
  18684. this.visitAllStatements(stmt.statements, context);
  18685. if (stmt.type) {
  18686. stmt.type.visitType(this, context);
  18687. }
  18688. return stmt;
  18689. };
  18690. /**
  18691. * @param {?} stmt
  18692. * @param {?} context
  18693. * @return {?}
  18694. */
  18695. RecursiveAstVisitor.prototype.visitExpressionStmt = /**
  18696. * @param {?} stmt
  18697. * @param {?} context
  18698. * @return {?}
  18699. */
  18700. function (stmt, context) {
  18701. stmt.expr.visitExpression(this, context);
  18702. return stmt;
  18703. };
  18704. /**
  18705. * @param {?} stmt
  18706. * @param {?} context
  18707. * @return {?}
  18708. */
  18709. RecursiveAstVisitor.prototype.visitReturnStmt = /**
  18710. * @param {?} stmt
  18711. * @param {?} context
  18712. * @return {?}
  18713. */
  18714. function (stmt, context) {
  18715. stmt.value.visitExpression(this, context);
  18716. return stmt;
  18717. };
  18718. /**
  18719. * @param {?} stmt
  18720. * @param {?} context
  18721. * @return {?}
  18722. */
  18723. RecursiveAstVisitor.prototype.visitDeclareClassStmt = /**
  18724. * @param {?} stmt
  18725. * @param {?} context
  18726. * @return {?}
  18727. */
  18728. function (stmt, context) {
  18729. var _this = this;
  18730. /** @type {?} */ ((stmt.parent)).visitExpression(this, context);
  18731. stmt.getters.forEach(function (getter) { return _this.visitAllStatements(getter.body, context); });
  18732. if (stmt.constructorMethod) {
  18733. this.visitAllStatements(stmt.constructorMethod.body, context);
  18734. }
  18735. stmt.methods.forEach(function (method) { return _this.visitAllStatements(method.body, context); });
  18736. return stmt;
  18737. };
  18738. /**
  18739. * @param {?} stmt
  18740. * @param {?} context
  18741. * @return {?}
  18742. */
  18743. RecursiveAstVisitor.prototype.visitIfStmt = /**
  18744. * @param {?} stmt
  18745. * @param {?} context
  18746. * @return {?}
  18747. */
  18748. function (stmt, context) {
  18749. stmt.condition.visitExpression(this, context);
  18750. this.visitAllStatements(stmt.trueCase, context);
  18751. this.visitAllStatements(stmt.falseCase, context);
  18752. return stmt;
  18753. };
  18754. /**
  18755. * @param {?} stmt
  18756. * @param {?} context
  18757. * @return {?}
  18758. */
  18759. RecursiveAstVisitor.prototype.visitTryCatchStmt = /**
  18760. * @param {?} stmt
  18761. * @param {?} context
  18762. * @return {?}
  18763. */
  18764. function (stmt, context) {
  18765. this.visitAllStatements(stmt.bodyStmts, context);
  18766. this.visitAllStatements(stmt.catchStmts, context);
  18767. return stmt;
  18768. };
  18769. /**
  18770. * @param {?} stmt
  18771. * @param {?} context
  18772. * @return {?}
  18773. */
  18774. RecursiveAstVisitor.prototype.visitThrowStmt = /**
  18775. * @param {?} stmt
  18776. * @param {?} context
  18777. * @return {?}
  18778. */
  18779. function (stmt, context) {
  18780. stmt.error.visitExpression(this, context);
  18781. return stmt;
  18782. };
  18783. /**
  18784. * @param {?} stmt
  18785. * @param {?} context
  18786. * @return {?}
  18787. */
  18788. RecursiveAstVisitor.prototype.visitCommentStmt = /**
  18789. * @param {?} stmt
  18790. * @param {?} context
  18791. * @return {?}
  18792. */
  18793. function (stmt, context) { return stmt; };
  18794. /**
  18795. * @param {?} stmts
  18796. * @param {?} context
  18797. * @return {?}
  18798. */
  18799. RecursiveAstVisitor.prototype.visitAllStatements = /**
  18800. * @param {?} stmts
  18801. * @param {?} context
  18802. * @return {?}
  18803. */
  18804. function (stmts, context) {
  18805. var _this = this;
  18806. stmts.forEach(function (stmt) { return stmt.visitStatement(_this, context); });
  18807. };
  18808. return RecursiveAstVisitor;
  18809. }());
  18810. /**
  18811. * @param {?} stmts
  18812. * @return {?}
  18813. */
  18814. function findReadVarNames(stmts) {
  18815. var /** @type {?} */ visitor = new _ReadVarVisitor();
  18816. visitor.visitAllStatements(stmts, null);
  18817. return visitor.varNames;
  18818. }
  18819. var _ReadVarVisitor = /** @class */ (function (_super) {
  18820. __extends(_ReadVarVisitor, _super);
  18821. function _ReadVarVisitor() {
  18822. var _this = _super !== null && _super.apply(this, arguments) || this;
  18823. _this.varNames = new Set();
  18824. return _this;
  18825. }
  18826. /**
  18827. * @param {?} stmt
  18828. * @param {?} context
  18829. * @return {?}
  18830. */
  18831. _ReadVarVisitor.prototype.visitDeclareFunctionStmt = /**
  18832. * @param {?} stmt
  18833. * @param {?} context
  18834. * @return {?}
  18835. */
  18836. function (stmt, context) {
  18837. // Don't descend into nested functions
  18838. return stmt;
  18839. };
  18840. /**
  18841. * @param {?} stmt
  18842. * @param {?} context
  18843. * @return {?}
  18844. */
  18845. _ReadVarVisitor.prototype.visitDeclareClassStmt = /**
  18846. * @param {?} stmt
  18847. * @param {?} context
  18848. * @return {?}
  18849. */
  18850. function (stmt, context) {
  18851. // Don't descend into nested classes
  18852. return stmt;
  18853. };
  18854. /**
  18855. * @param {?} ast
  18856. * @param {?} context
  18857. * @return {?}
  18858. */
  18859. _ReadVarVisitor.prototype.visitReadVarExpr = /**
  18860. * @param {?} ast
  18861. * @param {?} context
  18862. * @return {?}
  18863. */
  18864. function (ast, context) {
  18865. if (ast.name) {
  18866. this.varNames.add(ast.name);
  18867. }
  18868. return null;
  18869. };
  18870. return _ReadVarVisitor;
  18871. }(RecursiveAstVisitor$1));
  18872. /**
  18873. * @param {?} stmts
  18874. * @return {?}
  18875. */
  18876. function collectExternalReferences(stmts) {
  18877. var /** @type {?} */ visitor = new _FindExternalReferencesVisitor();
  18878. visitor.visitAllStatements(stmts, null);
  18879. return visitor.externalReferences;
  18880. }
  18881. var _FindExternalReferencesVisitor = /** @class */ (function (_super) {
  18882. __extends(_FindExternalReferencesVisitor, _super);
  18883. function _FindExternalReferencesVisitor() {
  18884. var _this = _super !== null && _super.apply(this, arguments) || this;
  18885. _this.externalReferences = [];
  18886. return _this;
  18887. }
  18888. /**
  18889. * @param {?} e
  18890. * @param {?} context
  18891. * @return {?}
  18892. */
  18893. _FindExternalReferencesVisitor.prototype.visitExternalExpr = /**
  18894. * @param {?} e
  18895. * @param {?} context
  18896. * @return {?}
  18897. */
  18898. function (e, context) {
  18899. this.externalReferences.push(e.value);
  18900. return _super.prototype.visitExternalExpr.call(this, e, context);
  18901. };
  18902. return _FindExternalReferencesVisitor;
  18903. }(RecursiveAstVisitor$1));
  18904. /**
  18905. * @param {?} stmt
  18906. * @param {?} sourceSpan
  18907. * @return {?}
  18908. */
  18909. function applySourceSpanToStatementIfNeeded(stmt, sourceSpan) {
  18910. if (!sourceSpan) {
  18911. return stmt;
  18912. }
  18913. var /** @type {?} */ transformer = new _ApplySourceSpanTransformer(sourceSpan);
  18914. return stmt.visitStatement(transformer, null);
  18915. }
  18916. /**
  18917. * @param {?} expr
  18918. * @param {?} sourceSpan
  18919. * @return {?}
  18920. */
  18921. function applySourceSpanToExpressionIfNeeded(expr, sourceSpan) {
  18922. if (!sourceSpan) {
  18923. return expr;
  18924. }
  18925. var /** @type {?} */ transformer = new _ApplySourceSpanTransformer(sourceSpan);
  18926. return expr.visitExpression(transformer, null);
  18927. }
  18928. var _ApplySourceSpanTransformer = /** @class */ (function (_super) {
  18929. __extends(_ApplySourceSpanTransformer, _super);
  18930. function _ApplySourceSpanTransformer(sourceSpan) {
  18931. var _this = _super.call(this) || this;
  18932. _this.sourceSpan = sourceSpan;
  18933. return _this;
  18934. }
  18935. /**
  18936. * @param {?} obj
  18937. * @return {?}
  18938. */
  18939. _ApplySourceSpanTransformer.prototype._clone = /**
  18940. * @param {?} obj
  18941. * @return {?}
  18942. */
  18943. function (obj) {
  18944. var /** @type {?} */ clone = Object.create(obj.constructor.prototype);
  18945. for (var /** @type {?} */ prop in obj) {
  18946. clone[prop] = obj[prop];
  18947. }
  18948. return clone;
  18949. };
  18950. /**
  18951. * @param {?} expr
  18952. * @param {?} context
  18953. * @return {?}
  18954. */
  18955. _ApplySourceSpanTransformer.prototype.transformExpr = /**
  18956. * @param {?} expr
  18957. * @param {?} context
  18958. * @return {?}
  18959. */
  18960. function (expr, context) {
  18961. if (!expr.sourceSpan) {
  18962. expr = this._clone(expr);
  18963. expr.sourceSpan = this.sourceSpan;
  18964. }
  18965. return expr;
  18966. };
  18967. /**
  18968. * @param {?} stmt
  18969. * @param {?} context
  18970. * @return {?}
  18971. */
  18972. _ApplySourceSpanTransformer.prototype.transformStmt = /**
  18973. * @param {?} stmt
  18974. * @param {?} context
  18975. * @return {?}
  18976. */
  18977. function (stmt, context) {
  18978. if (!stmt.sourceSpan) {
  18979. stmt = this._clone(stmt);
  18980. stmt.sourceSpan = this.sourceSpan;
  18981. }
  18982. return stmt;
  18983. };
  18984. return _ApplySourceSpanTransformer;
  18985. }(AstTransformer$1));
  18986. /**
  18987. * @param {?} name
  18988. * @param {?=} type
  18989. * @param {?=} sourceSpan
  18990. * @return {?}
  18991. */
  18992. function variable(name, type, sourceSpan) {
  18993. return new ReadVarExpr(name, type, sourceSpan);
  18994. }
  18995. /**
  18996. * @param {?} id
  18997. * @param {?=} typeParams
  18998. * @param {?=} sourceSpan
  18999. * @return {?}
  19000. */
  19001. function importExpr(id, typeParams, sourceSpan) {
  19002. if (typeParams === void 0) { typeParams = null; }
  19003. return new ExternalExpr(id, null, typeParams, sourceSpan);
  19004. }
  19005. /**
  19006. * @param {?} id
  19007. * @param {?=} typeParams
  19008. * @param {?=} typeModifiers
  19009. * @return {?}
  19010. */
  19011. function importType(id, typeParams, typeModifiers) {
  19012. if (typeParams === void 0) { typeParams = null; }
  19013. if (typeModifiers === void 0) { typeModifiers = null; }
  19014. return id != null ? expressionType(importExpr(id, typeParams, null), typeModifiers) : null;
  19015. }
  19016. /**
  19017. * @param {?} expr
  19018. * @param {?=} typeModifiers
  19019. * @return {?}
  19020. */
  19021. function expressionType(expr, typeModifiers) {
  19022. if (typeModifiers === void 0) { typeModifiers = null; }
  19023. return new ExpressionType(expr, typeModifiers);
  19024. }
  19025. /**
  19026. * @param {?} values
  19027. * @param {?=} type
  19028. * @param {?=} sourceSpan
  19029. * @return {?}
  19030. */
  19031. function literalArr(values, type, sourceSpan) {
  19032. return new LiteralArrayExpr(values, type, sourceSpan);
  19033. }
  19034. /**
  19035. * @param {?} values
  19036. * @param {?=} type
  19037. * @return {?}
  19038. */
  19039. function literalMap(values, type) {
  19040. if (type === void 0) { type = null; }
  19041. return new LiteralMapExpr(values.map(function (e) { return new LiteralMapEntry(e.key, e.value, e.quoted); }), type, null);
  19042. }
  19043. /**
  19044. * @param {?} expr
  19045. * @param {?=} sourceSpan
  19046. * @return {?}
  19047. */
  19048. function not(expr, sourceSpan) {
  19049. return new NotExpr(expr, sourceSpan);
  19050. }
  19051. /**
  19052. * @param {?} expr
  19053. * @param {?=} sourceSpan
  19054. * @return {?}
  19055. */
  19056. function assertNotNull(expr, sourceSpan) {
  19057. return new AssertNotNull(expr, sourceSpan);
  19058. }
  19059. /**
  19060. * @param {?} params
  19061. * @param {?} body
  19062. * @param {?=} type
  19063. * @param {?=} sourceSpan
  19064. * @return {?}
  19065. */
  19066. function fn(params, body, type, sourceSpan) {
  19067. return new FunctionExpr(params, body, type, sourceSpan);
  19068. }
  19069. /**
  19070. * @param {?} value
  19071. * @param {?=} type
  19072. * @param {?=} sourceSpan
  19073. * @return {?}
  19074. */
  19075. function literal(value, type, sourceSpan) {
  19076. return new LiteralExpr(value, type, sourceSpan);
  19077. }
  19078. /**
  19079. * @fileoverview added by tsickle
  19080. * @suppress {checkTypes} checked by tsc
  19081. */
  19082. /**
  19083. * @license
  19084. * Copyright Google Inc. All Rights Reserved.
  19085. *
  19086. * Use of this source code is governed by an MIT-style license that can be
  19087. * found in the LICENSE file at https://angular.io/license
  19088. */
  19089. var ProviderError = /** @class */ (function (_super) {
  19090. __extends(ProviderError, _super);
  19091. function ProviderError(message, span) {
  19092. return _super.call(this, span, message) || this;
  19093. }
  19094. return ProviderError;
  19095. }(ParseError));
  19096. /**
  19097. * @record
  19098. */
  19099. var ProviderViewContext = /** @class */ (function () {
  19100. function ProviderViewContext(reflector, component) {
  19101. var _this = this;
  19102. this.reflector = reflector;
  19103. this.component = component;
  19104. this.errors = [];
  19105. this.viewQueries = _getViewQueries(component);
  19106. this.viewProviders = new Map();
  19107. component.viewProviders.forEach(function (provider) {
  19108. if (_this.viewProviders.get(tokenReference(provider.token)) == null) {
  19109. _this.viewProviders.set(tokenReference(provider.token), true);
  19110. }
  19111. });
  19112. }
  19113. return ProviderViewContext;
  19114. }());
  19115. var ProviderElementContext = /** @class */ (function () {
  19116. function ProviderElementContext(viewContext, _parent, _isViewRoot, _directiveAsts, attrs, refs, isTemplate, contentQueryStartId, _sourceSpan) {
  19117. var _this = this;
  19118. this.viewContext = viewContext;
  19119. this._parent = _parent;
  19120. this._isViewRoot = _isViewRoot;
  19121. this._directiveAsts = _directiveAsts;
  19122. this._sourceSpan = _sourceSpan;
  19123. this._transformedProviders = new Map();
  19124. this._seenProviders = new Map();
  19125. this._queriedTokens = new Map();
  19126. this.transformedHasViewContainer = false;
  19127. this._attrs = {};
  19128. attrs.forEach(function (attrAst) { return _this._attrs[attrAst.name] = attrAst.value; });
  19129. var /** @type {?} */ directivesMeta = _directiveAsts.map(function (directiveAst) { return directiveAst.directive; });
  19130. this._allProviders =
  19131. _resolveProvidersFromDirectives(directivesMeta, _sourceSpan, viewContext.errors);
  19132. this._contentQueries = _getContentQueries(contentQueryStartId, directivesMeta);
  19133. Array.from(this._allProviders.values()).forEach(function (provider) {
  19134. _this._addQueryReadsTo(provider.token, provider.token, _this._queriedTokens);
  19135. });
  19136. if (isTemplate) {
  19137. var /** @type {?} */ templateRefId = createTokenForExternalReference(this.viewContext.reflector, Identifiers.TemplateRef);
  19138. this._addQueryReadsTo(templateRefId, templateRefId, this._queriedTokens);
  19139. }
  19140. refs.forEach(function (refAst) {
  19141. var /** @type {?} */ defaultQueryValue = refAst.value ||
  19142. createTokenForExternalReference(_this.viewContext.reflector, Identifiers.ElementRef);
  19143. _this._addQueryReadsTo({ value: refAst.name }, defaultQueryValue, _this._queriedTokens);
  19144. });
  19145. if (this._queriedTokens.get(this.viewContext.reflector.resolveExternalReference(Identifiers.ViewContainerRef))) {
  19146. this.transformedHasViewContainer = true;
  19147. }
  19148. // create the providers that we know are eager first
  19149. Array.from(this._allProviders.values()).forEach(function (provider) {
  19150. var /** @type {?} */ eager = provider.eager || _this._queriedTokens.get(tokenReference(provider.token));
  19151. if (eager) {
  19152. _this._getOrCreateLocalProvider(provider.providerType, provider.token, true);
  19153. }
  19154. });
  19155. }
  19156. /**
  19157. * @return {?}
  19158. */
  19159. ProviderElementContext.prototype.afterElement = /**
  19160. * @return {?}
  19161. */
  19162. function () {
  19163. var _this = this;
  19164. // collect lazy providers
  19165. Array.from(this._allProviders.values()).forEach(function (provider) {
  19166. _this._getOrCreateLocalProvider(provider.providerType, provider.token, false);
  19167. });
  19168. };
  19169. Object.defineProperty(ProviderElementContext.prototype, "transformProviders", {
  19170. get: /**
  19171. * @return {?}
  19172. */
  19173. function () {
  19174. // Note: Maps keep their insertion order.
  19175. var /** @type {?} */ lazyProviders = [];
  19176. var /** @type {?} */ eagerProviders = [];
  19177. this._transformedProviders.forEach(function (provider) {
  19178. if (provider.eager) {
  19179. eagerProviders.push(provider);
  19180. }
  19181. else {
  19182. lazyProviders.push(provider);
  19183. }
  19184. });
  19185. return lazyProviders.concat(eagerProviders);
  19186. },
  19187. enumerable: true,
  19188. configurable: true
  19189. });
  19190. Object.defineProperty(ProviderElementContext.prototype, "transformedDirectiveAsts", {
  19191. get: /**
  19192. * @return {?}
  19193. */
  19194. function () {
  19195. var /** @type {?} */ sortedProviderTypes = this.transformProviders.map(function (provider) { return provider.token.identifier; });
  19196. var /** @type {?} */ sortedDirectives = this._directiveAsts.slice();
  19197. sortedDirectives.sort(function (dir1, dir2) {
  19198. return sortedProviderTypes.indexOf(dir1.directive.type) -
  19199. sortedProviderTypes.indexOf(dir2.directive.type);
  19200. });
  19201. return sortedDirectives;
  19202. },
  19203. enumerable: true,
  19204. configurable: true
  19205. });
  19206. Object.defineProperty(ProviderElementContext.prototype, "queryMatches", {
  19207. get: /**
  19208. * @return {?}
  19209. */
  19210. function () {
  19211. var /** @type {?} */ allMatches = [];
  19212. this._queriedTokens.forEach(function (matches) { allMatches.push.apply(allMatches, matches); });
  19213. return allMatches;
  19214. },
  19215. enumerable: true,
  19216. configurable: true
  19217. });
  19218. /**
  19219. * @param {?} token
  19220. * @param {?} defaultValue
  19221. * @param {?} queryReadTokens
  19222. * @return {?}
  19223. */
  19224. ProviderElementContext.prototype._addQueryReadsTo = /**
  19225. * @param {?} token
  19226. * @param {?} defaultValue
  19227. * @param {?} queryReadTokens
  19228. * @return {?}
  19229. */
  19230. function (token, defaultValue, queryReadTokens) {
  19231. this._getQueriesFor(token).forEach(function (query) {
  19232. var /** @type {?} */ queryValue = query.meta.read || defaultValue;
  19233. var /** @type {?} */ tokenRef = tokenReference(queryValue);
  19234. var /** @type {?} */ queryMatches = queryReadTokens.get(tokenRef);
  19235. if (!queryMatches) {
  19236. queryMatches = [];
  19237. queryReadTokens.set(tokenRef, queryMatches);
  19238. }
  19239. queryMatches.push({ queryId: query.queryId, value: queryValue });
  19240. });
  19241. };
  19242. /**
  19243. * @param {?} token
  19244. * @return {?}
  19245. */
  19246. ProviderElementContext.prototype._getQueriesFor = /**
  19247. * @param {?} token
  19248. * @return {?}
  19249. */
  19250. function (token) {
  19251. var /** @type {?} */ result = [];
  19252. var /** @type {?} */ currentEl = this;
  19253. var /** @type {?} */ distance = 0;
  19254. var /** @type {?} */ queries;
  19255. while (currentEl !== null) {
  19256. queries = currentEl._contentQueries.get(tokenReference(token));
  19257. if (queries) {
  19258. result.push.apply(result, queries.filter(function (query) { return query.meta.descendants || distance <= 1; }));
  19259. }
  19260. if (currentEl._directiveAsts.length > 0) {
  19261. distance++;
  19262. }
  19263. currentEl = currentEl._parent;
  19264. }
  19265. queries = this.viewContext.viewQueries.get(tokenReference(token));
  19266. if (queries) {
  19267. result.push.apply(result, queries);
  19268. }
  19269. return result;
  19270. };
  19271. /**
  19272. * @param {?} requestingProviderType
  19273. * @param {?} token
  19274. * @param {?} eager
  19275. * @return {?}
  19276. */
  19277. ProviderElementContext.prototype._getOrCreateLocalProvider = /**
  19278. * @param {?} requestingProviderType
  19279. * @param {?} token
  19280. * @param {?} eager
  19281. * @return {?}
  19282. */
  19283. function (requestingProviderType, token, eager) {
  19284. var _this = this;
  19285. var /** @type {?} */ resolvedProvider = this._allProviders.get(tokenReference(token));
  19286. if (!resolvedProvider || ((requestingProviderType === ProviderAstType.Directive ||
  19287. requestingProviderType === ProviderAstType.PublicService) &&
  19288. resolvedProvider.providerType === ProviderAstType.PrivateService) ||
  19289. ((requestingProviderType === ProviderAstType.PrivateService ||
  19290. requestingProviderType === ProviderAstType.PublicService) &&
  19291. resolvedProvider.providerType === ProviderAstType.Builtin)) {
  19292. return null;
  19293. }
  19294. var /** @type {?} */ transformedProviderAst = this._transformedProviders.get(tokenReference(token));
  19295. if (transformedProviderAst) {
  19296. return transformedProviderAst;
  19297. }
  19298. if (this._seenProviders.get(tokenReference(token)) != null) {
  19299. this.viewContext.errors.push(new ProviderError("Cannot instantiate cyclic dependency! " + tokenName(token), this._sourceSpan));
  19300. return null;
  19301. }
  19302. this._seenProviders.set(tokenReference(token), true);
  19303. var /** @type {?} */ transformedProviders = resolvedProvider.providers.map(function (provider) {
  19304. var /** @type {?} */ transformedUseValue = provider.useValue;
  19305. var /** @type {?} */ transformedUseExisting = /** @type {?} */ ((provider.useExisting));
  19306. var /** @type {?} */ transformedDeps = /** @type {?} */ ((undefined));
  19307. if (provider.useExisting != null) {
  19308. var /** @type {?} */ existingDiDep = /** @type {?} */ ((_this._getDependency(resolvedProvider.providerType, { token: provider.useExisting }, eager)));
  19309. if (existingDiDep.token != null) {
  19310. transformedUseExisting = existingDiDep.token;
  19311. }
  19312. else {
  19313. transformedUseExisting = /** @type {?} */ ((null));
  19314. transformedUseValue = existingDiDep.value;
  19315. }
  19316. }
  19317. else if (provider.useFactory) {
  19318. var /** @type {?} */ deps = provider.deps || provider.useFactory.diDeps;
  19319. transformedDeps =
  19320. deps.map(function (dep) { return ((_this._getDependency(resolvedProvider.providerType, dep, eager))); });
  19321. }
  19322. else if (provider.useClass) {
  19323. var /** @type {?} */ deps = provider.deps || provider.useClass.diDeps;
  19324. transformedDeps =
  19325. deps.map(function (dep) { return ((_this._getDependency(resolvedProvider.providerType, dep, eager))); });
  19326. }
  19327. return _transformProvider(provider, {
  19328. useExisting: transformedUseExisting,
  19329. useValue: transformedUseValue,
  19330. deps: transformedDeps
  19331. });
  19332. });
  19333. transformedProviderAst =
  19334. _transformProviderAst(resolvedProvider, { eager: eager, providers: transformedProviders });
  19335. this._transformedProviders.set(tokenReference(token), transformedProviderAst);
  19336. return transformedProviderAst;
  19337. };
  19338. /**
  19339. * @param {?} requestingProviderType
  19340. * @param {?} dep
  19341. * @param {?=} eager
  19342. * @return {?}
  19343. */
  19344. ProviderElementContext.prototype._getLocalDependency = /**
  19345. * @param {?} requestingProviderType
  19346. * @param {?} dep
  19347. * @param {?=} eager
  19348. * @return {?}
  19349. */
  19350. function (requestingProviderType, dep, eager) {
  19351. if (eager === void 0) { eager = false; }
  19352. if (dep.isAttribute) {
  19353. var /** @type {?} */ attrValue = this._attrs[/** @type {?} */ ((dep.token)).value];
  19354. return { isValue: true, value: attrValue == null ? null : attrValue };
  19355. }
  19356. if (dep.token != null) {
  19357. // access builtints
  19358. if ((requestingProviderType === ProviderAstType.Directive ||
  19359. requestingProviderType === ProviderAstType.Component)) {
  19360. if (tokenReference(dep.token) ===
  19361. this.viewContext.reflector.resolveExternalReference(Identifiers.Renderer) ||
  19362. tokenReference(dep.token) ===
  19363. this.viewContext.reflector.resolveExternalReference(Identifiers.ElementRef) ||
  19364. tokenReference(dep.token) ===
  19365. this.viewContext.reflector.resolveExternalReference(Identifiers.ChangeDetectorRef) ||
  19366. tokenReference(dep.token) ===
  19367. this.viewContext.reflector.resolveExternalReference(Identifiers.TemplateRef)) {
  19368. return dep;
  19369. }
  19370. if (tokenReference(dep.token) ===
  19371. this.viewContext.reflector.resolveExternalReference(Identifiers.ViewContainerRef)) {
  19372. (/** @type {?} */ (this)).transformedHasViewContainer = true;
  19373. }
  19374. }
  19375. // access the injector
  19376. if (tokenReference(dep.token) ===
  19377. this.viewContext.reflector.resolveExternalReference(Identifiers.Injector)) {
  19378. return dep;
  19379. }
  19380. // access providers
  19381. if (this._getOrCreateLocalProvider(requestingProviderType, dep.token, eager) != null) {
  19382. return dep;
  19383. }
  19384. }
  19385. return null;
  19386. };
  19387. /**
  19388. * @param {?} requestingProviderType
  19389. * @param {?} dep
  19390. * @param {?=} eager
  19391. * @return {?}
  19392. */
  19393. ProviderElementContext.prototype._getDependency = /**
  19394. * @param {?} requestingProviderType
  19395. * @param {?} dep
  19396. * @param {?=} eager
  19397. * @return {?}
  19398. */
  19399. function (requestingProviderType, dep, eager) {
  19400. if (eager === void 0) { eager = false; }
  19401. var /** @type {?} */ currElement = this;
  19402. var /** @type {?} */ currEager = eager;
  19403. var /** @type {?} */ result = null;
  19404. if (!dep.isSkipSelf) {
  19405. result = this._getLocalDependency(requestingProviderType, dep, eager);
  19406. }
  19407. if (dep.isSelf) {
  19408. if (!result && dep.isOptional) {
  19409. result = { isValue: true, value: null };
  19410. }
  19411. }
  19412. else {
  19413. // check parent elements
  19414. while (!result && currElement._parent) {
  19415. var /** @type {?} */ prevElement = currElement;
  19416. currElement = currElement._parent;
  19417. if (prevElement._isViewRoot) {
  19418. currEager = false;
  19419. }
  19420. result = currElement._getLocalDependency(ProviderAstType.PublicService, dep, currEager);
  19421. }
  19422. // check @Host restriction
  19423. if (!result) {
  19424. if (!dep.isHost || this.viewContext.component.isHost ||
  19425. this.viewContext.component.type.reference === tokenReference(/** @type {?} */ ((dep.token))) ||
  19426. this.viewContext.viewProviders.get(tokenReference(/** @type {?} */ ((dep.token)))) != null) {
  19427. result = dep;
  19428. }
  19429. else {
  19430. result = dep.isOptional ? result = { isValue: true, value: null } : null;
  19431. }
  19432. }
  19433. }
  19434. if (!result) {
  19435. this.viewContext.errors.push(new ProviderError("No provider for " + tokenName((/** @type {?} */ ((dep.token)))), this._sourceSpan));
  19436. }
  19437. return result;
  19438. };
  19439. return ProviderElementContext;
  19440. }());
  19441. var NgModuleProviderAnalyzer = /** @class */ (function () {
  19442. function NgModuleProviderAnalyzer(reflector, ngModule, extraProviders, sourceSpan) {
  19443. var _this = this;
  19444. this.reflector = reflector;
  19445. this._transformedProviders = new Map();
  19446. this._seenProviders = new Map();
  19447. this._errors = [];
  19448. this._allProviders = new Map();
  19449. ngModule.transitiveModule.modules.forEach(function (ngModuleType) {
  19450. var /** @type {?} */ ngModuleProvider = { token: { identifier: ngModuleType }, useClass: ngModuleType };
  19451. _resolveProviders([ngModuleProvider], ProviderAstType.PublicService, true, sourceSpan, _this._errors, _this._allProviders);
  19452. });
  19453. _resolveProviders(ngModule.transitiveModule.providers.map(function (entry) { return entry.provider; }).concat(extraProviders), ProviderAstType.PublicService, false, sourceSpan, this._errors, this._allProviders);
  19454. }
  19455. /**
  19456. * @return {?}
  19457. */
  19458. NgModuleProviderAnalyzer.prototype.parse = /**
  19459. * @return {?}
  19460. */
  19461. function () {
  19462. var _this = this;
  19463. Array.from(this._allProviders.values()).forEach(function (provider) {
  19464. _this._getOrCreateLocalProvider(provider.token, provider.eager);
  19465. });
  19466. if (this._errors.length > 0) {
  19467. var /** @type {?} */ errorString = this._errors.join('\n');
  19468. throw new Error("Provider parse errors:\n" + errorString);
  19469. }
  19470. // Note: Maps keep their insertion order.
  19471. var /** @type {?} */ lazyProviders = [];
  19472. var /** @type {?} */ eagerProviders = [];
  19473. this._transformedProviders.forEach(function (provider) {
  19474. if (provider.eager) {
  19475. eagerProviders.push(provider);
  19476. }
  19477. else {
  19478. lazyProviders.push(provider);
  19479. }
  19480. });
  19481. return lazyProviders.concat(eagerProviders);
  19482. };
  19483. /**
  19484. * @param {?} token
  19485. * @param {?} eager
  19486. * @return {?}
  19487. */
  19488. NgModuleProviderAnalyzer.prototype._getOrCreateLocalProvider = /**
  19489. * @param {?} token
  19490. * @param {?} eager
  19491. * @return {?}
  19492. */
  19493. function (token, eager) {
  19494. var _this = this;
  19495. var /** @type {?} */ resolvedProvider = this._allProviders.get(tokenReference(token));
  19496. if (!resolvedProvider) {
  19497. return null;
  19498. }
  19499. var /** @type {?} */ transformedProviderAst = this._transformedProviders.get(tokenReference(token));
  19500. if (transformedProviderAst) {
  19501. return transformedProviderAst;
  19502. }
  19503. if (this._seenProviders.get(tokenReference(token)) != null) {
  19504. this._errors.push(new ProviderError("Cannot instantiate cyclic dependency! " + tokenName(token), resolvedProvider.sourceSpan));
  19505. return null;
  19506. }
  19507. this._seenProviders.set(tokenReference(token), true);
  19508. var /** @type {?} */ transformedProviders = resolvedProvider.providers.map(function (provider) {
  19509. var /** @type {?} */ transformedUseValue = provider.useValue;
  19510. var /** @type {?} */ transformedUseExisting = /** @type {?} */ ((provider.useExisting));
  19511. var /** @type {?} */ transformedDeps = /** @type {?} */ ((undefined));
  19512. if (provider.useExisting != null) {
  19513. var /** @type {?} */ existingDiDep = _this._getDependency({ token: provider.useExisting }, eager, resolvedProvider.sourceSpan);
  19514. if (existingDiDep.token != null) {
  19515. transformedUseExisting = existingDiDep.token;
  19516. }
  19517. else {
  19518. transformedUseExisting = /** @type {?} */ ((null));
  19519. transformedUseValue = existingDiDep.value;
  19520. }
  19521. }
  19522. else if (provider.useFactory) {
  19523. var /** @type {?} */ deps = provider.deps || provider.useFactory.diDeps;
  19524. transformedDeps =
  19525. deps.map(function (dep) { return _this._getDependency(dep, eager, resolvedProvider.sourceSpan); });
  19526. }
  19527. else if (provider.useClass) {
  19528. var /** @type {?} */ deps = provider.deps || provider.useClass.diDeps;
  19529. transformedDeps =
  19530. deps.map(function (dep) { return _this._getDependency(dep, eager, resolvedProvider.sourceSpan); });
  19531. }
  19532. return _transformProvider(provider, {
  19533. useExisting: transformedUseExisting,
  19534. useValue: transformedUseValue,
  19535. deps: transformedDeps
  19536. });
  19537. });
  19538. transformedProviderAst =
  19539. _transformProviderAst(resolvedProvider, { eager: eager, providers: transformedProviders });
  19540. this._transformedProviders.set(tokenReference(token), transformedProviderAst);
  19541. return transformedProviderAst;
  19542. };
  19543. /**
  19544. * @param {?} dep
  19545. * @param {?=} eager
  19546. * @param {?=} requestorSourceSpan
  19547. * @return {?}
  19548. */
  19549. NgModuleProviderAnalyzer.prototype._getDependency = /**
  19550. * @param {?} dep
  19551. * @param {?=} eager
  19552. * @param {?=} requestorSourceSpan
  19553. * @return {?}
  19554. */
  19555. function (dep, eager, requestorSourceSpan) {
  19556. if (eager === void 0) { eager = false; }
  19557. var /** @type {?} */ foundLocal = false;
  19558. if (!dep.isSkipSelf && dep.token != null) {
  19559. // access the injector
  19560. if (tokenReference(dep.token) ===
  19561. this.reflector.resolveExternalReference(Identifiers.Injector) ||
  19562. tokenReference(dep.token) ===
  19563. this.reflector.resolveExternalReference(Identifiers.ComponentFactoryResolver)) {
  19564. foundLocal = true;
  19565. // access providers
  19566. }
  19567. else if (this._getOrCreateLocalProvider(dep.token, eager) != null) {
  19568. foundLocal = true;
  19569. }
  19570. }
  19571. var /** @type {?} */ result = dep;
  19572. if (dep.isSelf && !foundLocal) {
  19573. if (dep.isOptional) {
  19574. result = { isValue: true, value: null };
  19575. }
  19576. else {
  19577. this._errors.push(new ProviderError("No provider for " + tokenName((/** @type {?} */ ((dep.token)))), requestorSourceSpan));
  19578. }
  19579. }
  19580. return result;
  19581. };
  19582. return NgModuleProviderAnalyzer;
  19583. }());
  19584. /**
  19585. * @param {?} provider
  19586. * @param {?} __1
  19587. * @return {?}
  19588. */
  19589. function _transformProvider(provider, _a) {
  19590. var useExisting = _a.useExisting, useValue = _a.useValue, deps = _a.deps;
  19591. return {
  19592. token: provider.token,
  19593. useClass: provider.useClass,
  19594. useExisting: useExisting,
  19595. useFactory: provider.useFactory,
  19596. useValue: useValue,
  19597. deps: deps,
  19598. multi: provider.multi
  19599. };
  19600. }
  19601. /**
  19602. * @param {?} provider
  19603. * @param {?} __1
  19604. * @return {?}
  19605. */
  19606. function _transformProviderAst(provider, _a) {
  19607. var eager = _a.eager, providers = _a.providers;
  19608. return new ProviderAst(provider.token, provider.multiProvider, provider.eager || eager, providers, provider.providerType, provider.lifecycleHooks, provider.sourceSpan);
  19609. }
  19610. /**
  19611. * @param {?} directives
  19612. * @param {?} sourceSpan
  19613. * @param {?} targetErrors
  19614. * @return {?}
  19615. */
  19616. function _resolveProvidersFromDirectives(directives, sourceSpan, targetErrors) {
  19617. var /** @type {?} */ providersByToken = new Map();
  19618. directives.forEach(function (directive) {
  19619. var /** @type {?} */ dirProvider = { token: { identifier: directive.type }, useClass: directive.type };
  19620. _resolveProviders([dirProvider], directive.isComponent ? ProviderAstType.Component : ProviderAstType.Directive, true, sourceSpan, targetErrors, providersByToken);
  19621. });
  19622. // Note: directives need to be able to overwrite providers of a component!
  19623. var /** @type {?} */ directivesWithComponentFirst = directives.filter(function (dir) { return dir.isComponent; }).concat(directives.filter(function (dir) { return !dir.isComponent; }));
  19624. directivesWithComponentFirst.forEach(function (directive) {
  19625. _resolveProviders(directive.providers, ProviderAstType.PublicService, false, sourceSpan, targetErrors, providersByToken);
  19626. _resolveProviders(directive.viewProviders, ProviderAstType.PrivateService, false, sourceSpan, targetErrors, providersByToken);
  19627. });
  19628. return providersByToken;
  19629. }
  19630. /**
  19631. * @param {?} providers
  19632. * @param {?} providerType
  19633. * @param {?} eager
  19634. * @param {?} sourceSpan
  19635. * @param {?} targetErrors
  19636. * @param {?} targetProvidersByToken
  19637. * @return {?}
  19638. */
  19639. function _resolveProviders(providers, providerType, eager, sourceSpan, targetErrors, targetProvidersByToken) {
  19640. providers.forEach(function (provider) {
  19641. var /** @type {?} */ resolvedProvider = targetProvidersByToken.get(tokenReference(provider.token));
  19642. if (resolvedProvider != null && !!resolvedProvider.multiProvider !== !!provider.multi) {
  19643. targetErrors.push(new ProviderError("Mixing multi and non multi provider is not possible for token " + tokenName(resolvedProvider.token), sourceSpan));
  19644. }
  19645. if (!resolvedProvider) {
  19646. var /** @type {?} */ lifecycleHooks = provider.token.identifier &&
  19647. (/** @type {?} */ (provider.token.identifier)).lifecycleHooks ?
  19648. (/** @type {?} */ (provider.token.identifier)).lifecycleHooks :
  19649. [];
  19650. var /** @type {?} */ isUseValue = !(provider.useClass || provider.useExisting || provider.useFactory);
  19651. resolvedProvider = new ProviderAst(provider.token, !!provider.multi, eager || isUseValue, [provider], providerType, lifecycleHooks, sourceSpan);
  19652. targetProvidersByToken.set(tokenReference(provider.token), resolvedProvider);
  19653. }
  19654. else {
  19655. if (!provider.multi) {
  19656. resolvedProvider.providers.length = 0;
  19657. }
  19658. resolvedProvider.providers.push(provider);
  19659. }
  19660. });
  19661. }
  19662. /**
  19663. * @param {?} component
  19664. * @return {?}
  19665. */
  19666. function _getViewQueries(component) {
  19667. // Note: queries start with id 1 so we can use the number in a Bloom filter!
  19668. var /** @type {?} */ viewQueryId = 1;
  19669. var /** @type {?} */ viewQueries = new Map();
  19670. if (component.viewQueries) {
  19671. component.viewQueries.forEach(function (query) { return _addQueryToTokenMap(viewQueries, { meta: query, queryId: viewQueryId++ }); });
  19672. }
  19673. return viewQueries;
  19674. }
  19675. /**
  19676. * @param {?} contentQueryStartId
  19677. * @param {?} directives
  19678. * @return {?}
  19679. */
  19680. function _getContentQueries(contentQueryStartId, directives) {
  19681. var /** @type {?} */ contentQueryId = contentQueryStartId;
  19682. var /** @type {?} */ contentQueries = new Map();
  19683. directives.forEach(function (directive, directiveIndex) {
  19684. if (directive.queries) {
  19685. directive.queries.forEach(function (query) { return _addQueryToTokenMap(contentQueries, { meta: query, queryId: contentQueryId++ }); });
  19686. }
  19687. });
  19688. return contentQueries;
  19689. }
  19690. /**
  19691. * @param {?} map
  19692. * @param {?} query
  19693. * @return {?}
  19694. */
  19695. function _addQueryToTokenMap(map, query) {
  19696. query.meta.selectors.forEach(function (token) {
  19697. var /** @type {?} */ entry = map.get(tokenReference(token));
  19698. if (!entry) {
  19699. entry = [];
  19700. map.set(tokenReference(token), entry);
  19701. }
  19702. entry.push(query);
  19703. });
  19704. }
  19705. /**
  19706. * @fileoverview added by tsickle
  19707. * @suppress {checkTypes} checked by tsc
  19708. */
  19709. /**
  19710. * @license
  19711. * Copyright Google Inc. All Rights Reserved.
  19712. *
  19713. * Use of this source code is governed by an MIT-style license that can be
  19714. * found in the LICENSE file at https://angular.io/license
  19715. */
  19716. var QUOTED_KEYS = '$quoted$';
  19717. /**
  19718. * @param {?} ctx
  19719. * @param {?} value
  19720. * @param {?=} type
  19721. * @return {?}
  19722. */
  19723. function convertValueToOutputAst(ctx, value, type) {
  19724. if (type === void 0) { type = null; }
  19725. return visitValue(value, new _ValueOutputAstTransformer(ctx), type);
  19726. }
  19727. var _ValueOutputAstTransformer = /** @class */ (function () {
  19728. function _ValueOutputAstTransformer(ctx) {
  19729. this.ctx = ctx;
  19730. }
  19731. /**
  19732. * @param {?} arr
  19733. * @param {?} type
  19734. * @return {?}
  19735. */
  19736. _ValueOutputAstTransformer.prototype.visitArray = /**
  19737. * @param {?} arr
  19738. * @param {?} type
  19739. * @return {?}
  19740. */
  19741. function (arr, type) {
  19742. var _this = this;
  19743. return literalArr(arr.map(function (value) { return visitValue(value, _this, null); }), type);
  19744. };
  19745. /**
  19746. * @param {?} map
  19747. * @param {?} type
  19748. * @return {?}
  19749. */
  19750. _ValueOutputAstTransformer.prototype.visitStringMap = /**
  19751. * @param {?} map
  19752. * @param {?} type
  19753. * @return {?}
  19754. */
  19755. function (map, type) {
  19756. var _this = this;
  19757. var /** @type {?} */ entries = [];
  19758. var /** @type {?} */ quotedSet = new Set(map && map[QUOTED_KEYS]);
  19759. Object.keys(map).forEach(function (key) {
  19760. entries.push(new LiteralMapEntry(key, visitValue(map[key], _this, null), quotedSet.has(key)));
  19761. });
  19762. return new LiteralMapExpr(entries, type);
  19763. };
  19764. /**
  19765. * @param {?} value
  19766. * @param {?} type
  19767. * @return {?}
  19768. */
  19769. _ValueOutputAstTransformer.prototype.visitPrimitive = /**
  19770. * @param {?} value
  19771. * @param {?} type
  19772. * @return {?}
  19773. */
  19774. function (value, type) { return literal(value, type); };
  19775. /**
  19776. * @param {?} value
  19777. * @param {?} type
  19778. * @return {?}
  19779. */
  19780. _ValueOutputAstTransformer.prototype.visitOther = /**
  19781. * @param {?} value
  19782. * @param {?} type
  19783. * @return {?}
  19784. */
  19785. function (value, type) {
  19786. if (value instanceof Expression) {
  19787. return value;
  19788. }
  19789. else {
  19790. return this.ctx.importExpr(value);
  19791. }
  19792. };
  19793. return _ValueOutputAstTransformer;
  19794. }());
  19795. /**
  19796. * @fileoverview added by tsickle
  19797. * @suppress {checkTypes} checked by tsc
  19798. */
  19799. /**
  19800. * @license
  19801. * Copyright Google Inc. All Rights Reserved.
  19802. *
  19803. * Use of this source code is governed by an MIT-style license that can be
  19804. * found in the LICENSE file at https://angular.io/license
  19805. */
  19806. /**
  19807. * @param {?} ctx
  19808. * @param {?} providerAst
  19809. * @return {?}
  19810. */
  19811. function providerDef(ctx, providerAst) {
  19812. var /** @type {?} */ flags = 0;
  19813. if (!providerAst.eager) {
  19814. flags |= 4096 /* LazyProvider */;
  19815. }
  19816. if (providerAst.providerType === ProviderAstType.PrivateService) {
  19817. flags |= 8192 /* PrivateProvider */;
  19818. }
  19819. providerAst.lifecycleHooks.forEach(function (lifecycleHook) {
  19820. // for regular providers, we only support ngOnDestroy
  19821. if (lifecycleHook === LifecycleHooks.OnDestroy ||
  19822. providerAst.providerType === ProviderAstType.Directive ||
  19823. providerAst.providerType === ProviderAstType.Component) {
  19824. flags |= lifecycleHookToNodeFlag(lifecycleHook);
  19825. }
  19826. });
  19827. var _a = providerAst.multiProvider ?
  19828. multiProviderDef(ctx, flags, providerAst.providers) :
  19829. singleProviderDef(ctx, flags, providerAst.providerType, providerAst.providers[0]), providerExpr = _a.providerExpr, providerFlags = _a.flags, depsExpr = _a.depsExpr;
  19830. return {
  19831. providerExpr: providerExpr,
  19832. flags: providerFlags, depsExpr: depsExpr,
  19833. tokenExpr: tokenExpr(ctx, providerAst.token),
  19834. };
  19835. }
  19836. /**
  19837. * @param {?} ctx
  19838. * @param {?} flags
  19839. * @param {?} providers
  19840. * @return {?}
  19841. */
  19842. function multiProviderDef(ctx, flags, providers) {
  19843. var /** @type {?} */ allDepDefs = [];
  19844. var /** @type {?} */ allParams = [];
  19845. var /** @type {?} */ exprs = providers.map(function (provider, providerIndex) {
  19846. var /** @type {?} */ expr;
  19847. if (provider.useClass) {
  19848. var /** @type {?} */ depExprs = convertDeps(providerIndex, provider.deps || provider.useClass.diDeps);
  19849. expr = ctx.importExpr(provider.useClass.reference).instantiate(depExprs);
  19850. }
  19851. else if (provider.useFactory) {
  19852. var /** @type {?} */ depExprs = convertDeps(providerIndex, provider.deps || provider.useFactory.diDeps);
  19853. expr = ctx.importExpr(provider.useFactory.reference).callFn(depExprs);
  19854. }
  19855. else if (provider.useExisting) {
  19856. var /** @type {?} */ depExprs = convertDeps(providerIndex, [{ token: provider.useExisting }]);
  19857. expr = depExprs[0];
  19858. }
  19859. else {
  19860. expr = convertValueToOutputAst(ctx, provider.useValue);
  19861. }
  19862. return expr;
  19863. });
  19864. var /** @type {?} */ providerExpr = fn(allParams, [new ReturnStatement(literalArr(exprs))], INFERRED_TYPE);
  19865. return {
  19866. providerExpr: providerExpr,
  19867. flags: flags | 1024 /* TypeFactoryProvider */,
  19868. depsExpr: literalArr(allDepDefs)
  19869. };
  19870. /**
  19871. * @param {?} providerIndex
  19872. * @param {?} deps
  19873. * @return {?}
  19874. */
  19875. function convertDeps(providerIndex, deps) {
  19876. return deps.map(function (dep, depIndex) {
  19877. var /** @type {?} */ paramName = "p" + providerIndex + "_" + depIndex;
  19878. allParams.push(new FnParam(paramName, DYNAMIC_TYPE));
  19879. allDepDefs.push(depDef(ctx, dep));
  19880. return variable(paramName);
  19881. });
  19882. }
  19883. }
  19884. /**
  19885. * @param {?} ctx
  19886. * @param {?} flags
  19887. * @param {?} providerType
  19888. * @param {?} providerMeta
  19889. * @return {?}
  19890. */
  19891. function singleProviderDef(ctx, flags, providerType, providerMeta) {
  19892. var /** @type {?} */ providerExpr;
  19893. var /** @type {?} */ deps;
  19894. if (providerType === ProviderAstType.Directive || providerType === ProviderAstType.Component) {
  19895. providerExpr = ctx.importExpr(/** @type {?} */ ((providerMeta.useClass)).reference);
  19896. flags |= 16384 /* TypeDirective */;
  19897. deps = providerMeta.deps || /** @type {?} */ ((providerMeta.useClass)).diDeps;
  19898. }
  19899. else {
  19900. if (providerMeta.useClass) {
  19901. providerExpr = ctx.importExpr(providerMeta.useClass.reference);
  19902. flags |= 512 /* TypeClassProvider */;
  19903. deps = providerMeta.deps || providerMeta.useClass.diDeps;
  19904. }
  19905. else if (providerMeta.useFactory) {
  19906. providerExpr = ctx.importExpr(providerMeta.useFactory.reference);
  19907. flags |= 1024 /* TypeFactoryProvider */;
  19908. deps = providerMeta.deps || providerMeta.useFactory.diDeps;
  19909. }
  19910. else if (providerMeta.useExisting) {
  19911. providerExpr = NULL_EXPR;
  19912. flags |= 2048 /* TypeUseExistingProvider */;
  19913. deps = [{ token: providerMeta.useExisting }];
  19914. }
  19915. else {
  19916. providerExpr = convertValueToOutputAst(ctx, providerMeta.useValue);
  19917. flags |= 256 /* TypeValueProvider */;
  19918. deps = [];
  19919. }
  19920. }
  19921. var /** @type {?} */ depsExpr = literalArr(deps.map(function (dep) { return depDef(ctx, dep); }));
  19922. return { providerExpr: providerExpr, flags: flags, depsExpr: depsExpr };
  19923. }
  19924. /**
  19925. * @param {?} ctx
  19926. * @param {?} tokenMeta
  19927. * @return {?}
  19928. */
  19929. function tokenExpr(ctx, tokenMeta) {
  19930. return tokenMeta.identifier ? ctx.importExpr(tokenMeta.identifier.reference) :
  19931. literal(tokenMeta.value);
  19932. }
  19933. /**
  19934. * @param {?} ctx
  19935. * @param {?} dep
  19936. * @return {?}
  19937. */
  19938. function depDef(ctx, dep) {
  19939. // Note: the following fields have already been normalized out by provider_analyzer:
  19940. // - isAttribute, isSelf, isHost
  19941. var /** @type {?} */ expr = dep.isValue ? convertValueToOutputAst(ctx, dep.value) : tokenExpr(ctx, /** @type {?} */ ((dep.token)));
  19942. var /** @type {?} */ flags = 0;
  19943. if (dep.isSkipSelf) {
  19944. flags |= 1 /* SkipSelf */;
  19945. }
  19946. if (dep.isOptional) {
  19947. flags |= 2 /* Optional */;
  19948. }
  19949. if (dep.isValue) {
  19950. flags |= 8 /* Value */;
  19951. }
  19952. return flags === 0 /* None */ ? expr : literalArr([literal(flags), expr]);
  19953. }
  19954. /**
  19955. * @param {?} lifecycleHook
  19956. * @return {?}
  19957. */
  19958. function lifecycleHookToNodeFlag(lifecycleHook) {
  19959. var /** @type {?} */ nodeFlag = 0;
  19960. switch (lifecycleHook) {
  19961. case LifecycleHooks.AfterContentChecked:
  19962. nodeFlag = 2097152 /* AfterContentChecked */;
  19963. break;
  19964. case LifecycleHooks.AfterContentInit:
  19965. nodeFlag = 1048576 /* AfterContentInit */;
  19966. break;
  19967. case LifecycleHooks.AfterViewChecked:
  19968. nodeFlag = 8388608 /* AfterViewChecked */;
  19969. break;
  19970. case LifecycleHooks.AfterViewInit:
  19971. nodeFlag = 4194304 /* AfterViewInit */;
  19972. break;
  19973. case LifecycleHooks.DoCheck:
  19974. nodeFlag = 262144 /* DoCheck */;
  19975. break;
  19976. case LifecycleHooks.OnChanges:
  19977. nodeFlag = 524288 /* OnChanges */;
  19978. break;
  19979. case LifecycleHooks.OnDestroy:
  19980. nodeFlag = 131072 /* OnDestroy */;
  19981. break;
  19982. case LifecycleHooks.OnInit:
  19983. nodeFlag = 65536 /* OnInit */;
  19984. break;
  19985. }
  19986. return nodeFlag;
  19987. }
  19988. /**
  19989. * @param {?} reflector
  19990. * @param {?} ctx
  19991. * @param {?} flags
  19992. * @param {?} entryComponents
  19993. * @return {?}
  19994. */
  19995. function componentFactoryResolverProviderDef(reflector, ctx, flags, entryComponents) {
  19996. var /** @type {?} */ entryComponentFactories = entryComponents.map(function (entryComponent) { return ctx.importExpr(entryComponent.componentFactory); });
  19997. var /** @type {?} */ token = createTokenForExternalReference(reflector, Identifiers.ComponentFactoryResolver);
  19998. var /** @type {?} */ classMeta = {
  19999. diDeps: [
  20000. { isValue: true, value: literalArr(entryComponentFactories) },
  20001. { token: token, isSkipSelf: true, isOptional: true },
  20002. { token: createTokenForExternalReference(reflector, Identifiers.NgModuleRef) },
  20003. ],
  20004. lifecycleHooks: [],
  20005. reference: reflector.resolveExternalReference(Identifiers.CodegenComponentFactoryResolver)
  20006. };
  20007. var _a = singleProviderDef(ctx, flags, ProviderAstType.PrivateService, {
  20008. token: token,
  20009. multi: false,
  20010. useClass: classMeta,
  20011. }), providerExpr = _a.providerExpr, providerFlags = _a.flags, depsExpr = _a.depsExpr;
  20012. return { providerExpr: providerExpr, flags: providerFlags, depsExpr: depsExpr, tokenExpr: tokenExpr(ctx, token) };
  20013. }
  20014. /**
  20015. * @fileoverview added by tsickle
  20016. * @suppress {checkTypes} checked by tsc
  20017. */
  20018. /**
  20019. * @license
  20020. * Copyright Google Inc. All Rights Reserved.
  20021. *
  20022. * Use of this source code is governed by an MIT-style license that can be
  20023. * found in the LICENSE file at https://angular.io/license
  20024. */
  20025. var NgModuleCompileResult = /** @class */ (function () {
  20026. function NgModuleCompileResult(ngModuleFactoryVar) {
  20027. this.ngModuleFactoryVar = ngModuleFactoryVar;
  20028. }
  20029. return NgModuleCompileResult;
  20030. }());
  20031. var LOG_VAR = variable('_l');
  20032. var NgModuleCompiler = /** @class */ (function () {
  20033. function NgModuleCompiler(reflector) {
  20034. this.reflector = reflector;
  20035. }
  20036. /**
  20037. * @param {?} ctx
  20038. * @param {?} ngModuleMeta
  20039. * @param {?} extraProviders
  20040. * @return {?}
  20041. */
  20042. NgModuleCompiler.prototype.compile = /**
  20043. * @param {?} ctx
  20044. * @param {?} ngModuleMeta
  20045. * @param {?} extraProviders
  20046. * @return {?}
  20047. */
  20048. function (ctx, ngModuleMeta, extraProviders) {
  20049. var /** @type {?} */ sourceSpan = typeSourceSpan('NgModule', ngModuleMeta.type);
  20050. var /** @type {?} */ entryComponentFactories = ngModuleMeta.transitiveModule.entryComponents;
  20051. var /** @type {?} */ bootstrapComponents = ngModuleMeta.bootstrapComponents;
  20052. var /** @type {?} */ providerParser = new NgModuleProviderAnalyzer(this.reflector, ngModuleMeta, extraProviders, sourceSpan);
  20053. var /** @type {?} */ providerDefs = [componentFactoryResolverProviderDef(this.reflector, ctx, 0 /* None */, entryComponentFactories)]
  20054. .concat(providerParser.parse().map(function (provider) { return providerDef(ctx, provider); }))
  20055. .map(function (_a) {
  20056. var providerExpr = _a.providerExpr, depsExpr = _a.depsExpr, flags = _a.flags, tokenExpr = _a.tokenExpr;
  20057. return importExpr(Identifiers.moduleProviderDef).callFn([
  20058. literal(flags), tokenExpr, providerExpr, depsExpr
  20059. ]);
  20060. });
  20061. var /** @type {?} */ ngModuleDef = importExpr(Identifiers.moduleDef).callFn([literalArr(providerDefs)]);
  20062. var /** @type {?} */ ngModuleDefFactory = fn([new FnParam(/** @type {?} */ ((LOG_VAR.name)))], [new ReturnStatement(ngModuleDef)], INFERRED_TYPE);
  20063. var /** @type {?} */ ngModuleFactoryVar = identifierName(ngModuleMeta.type) + "NgFactory";
  20064. this._createNgModuleFactory(ctx, ngModuleMeta.type.reference, importExpr(Identifiers.createModuleFactory).callFn([
  20065. ctx.importExpr(ngModuleMeta.type.reference),
  20066. literalArr(bootstrapComponents.map(function (id) { return ctx.importExpr(id.reference); })),
  20067. ngModuleDefFactory
  20068. ]));
  20069. if (ngModuleMeta.id) {
  20070. var /** @type {?} */ registerFactoryStmt = importExpr(Identifiers.RegisterModuleFactoryFn)
  20071. .callFn([literal(ngModuleMeta.id), variable(ngModuleFactoryVar)])
  20072. .toStmt();
  20073. ctx.statements.push(registerFactoryStmt);
  20074. }
  20075. return new NgModuleCompileResult(ngModuleFactoryVar);
  20076. };
  20077. /**
  20078. * @param {?} ctx
  20079. * @param {?} ngModuleReference
  20080. * @return {?}
  20081. */
  20082. NgModuleCompiler.prototype.createStub = /**
  20083. * @param {?} ctx
  20084. * @param {?} ngModuleReference
  20085. * @return {?}
  20086. */
  20087. function (ctx, ngModuleReference) {
  20088. this._createNgModuleFactory(ctx, ngModuleReference, NULL_EXPR);
  20089. };
  20090. /**
  20091. * @param {?} ctx
  20092. * @param {?} reference
  20093. * @param {?} value
  20094. * @return {?}
  20095. */
  20096. NgModuleCompiler.prototype._createNgModuleFactory = /**
  20097. * @param {?} ctx
  20098. * @param {?} reference
  20099. * @param {?} value
  20100. * @return {?}
  20101. */
  20102. function (ctx, reference, value) {
  20103. var /** @type {?} */ ngModuleFactoryVar = identifierName({ reference: reference }) + "NgFactory";
  20104. var /** @type {?} */ ngModuleFactoryStmt = variable(ngModuleFactoryVar)
  20105. .set(value)
  20106. .toDeclStmt(importType(Identifiers.NgModuleFactory, [/** @type {?} */ ((expressionType(ctx.importExpr(reference))))], [TypeModifier.Const]), [StmtModifier.Final, StmtModifier.Exported]);
  20107. ctx.statements.push(ngModuleFactoryStmt);
  20108. };
  20109. return NgModuleCompiler;
  20110. }());
  20111. /**
  20112. * @fileoverview added by tsickle
  20113. * @suppress {checkTypes} checked by tsc
  20114. */
  20115. /**
  20116. * @license
  20117. * Copyright Google Inc. All Rights Reserved.
  20118. *
  20119. * Use of this source code is governed by an MIT-style license that can be
  20120. * found in the LICENSE file at https://angular.io/license
  20121. */
  20122. /**
  20123. * Resolves types to {\@link NgModule}.
  20124. */
  20125. var NgModuleResolver = /** @class */ (function () {
  20126. function NgModuleResolver(_reflector) {
  20127. this._reflector = _reflector;
  20128. }
  20129. /**
  20130. * @param {?} type
  20131. * @return {?}
  20132. */
  20133. NgModuleResolver.prototype.isNgModule = /**
  20134. * @param {?} type
  20135. * @return {?}
  20136. */
  20137. function (type) { return this._reflector.annotations(type).some(createNgModule.isTypeOf); };
  20138. /**
  20139. * @param {?} type
  20140. * @param {?=} throwIfNotFound
  20141. * @return {?}
  20142. */
  20143. NgModuleResolver.prototype.resolve = /**
  20144. * @param {?} type
  20145. * @param {?=} throwIfNotFound
  20146. * @return {?}
  20147. */
  20148. function (type, throwIfNotFound) {
  20149. if (throwIfNotFound === void 0) { throwIfNotFound = true; }
  20150. var /** @type {?} */ ngModuleMeta = findLast(this._reflector.annotations(type), createNgModule.isTypeOf);
  20151. if (ngModuleMeta) {
  20152. return ngModuleMeta;
  20153. }
  20154. else {
  20155. if (throwIfNotFound) {
  20156. throw new Error("No NgModule metadata found for '" + stringify(type) + "'.");
  20157. }
  20158. return null;
  20159. }
  20160. };
  20161. return NgModuleResolver;
  20162. }());
  20163. /**
  20164. * @fileoverview added by tsickle
  20165. * @suppress {checkTypes} checked by tsc
  20166. */
  20167. /**
  20168. * @license
  20169. * Copyright Google Inc. All Rights Reserved.
  20170. *
  20171. * Use of this source code is governed by an MIT-style license that can be
  20172. * found in the LICENSE file at https://angular.io/license
  20173. */
  20174. // https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit
  20175. var VERSION$1 = 3;
  20176. var JS_B64_PREFIX = '# sourceMappingURL=data:application/json;base64,';
  20177. var SourceMapGenerator = /** @class */ (function () {
  20178. function SourceMapGenerator(file) {
  20179. if (file === void 0) { file = null; }
  20180. this.file = file;
  20181. this.sourcesContent = new Map();
  20182. this.lines = [];
  20183. this.lastCol0 = 0;
  20184. this.hasMappings = false;
  20185. }
  20186. // The content is `null` when the content is expected to be loaded using the URL
  20187. /**
  20188. * @param {?} url
  20189. * @param {?=} content
  20190. * @return {?}
  20191. */
  20192. SourceMapGenerator.prototype.addSource = /**
  20193. * @param {?} url
  20194. * @param {?=} content
  20195. * @return {?}
  20196. */
  20197. function (url, content) {
  20198. if (content === void 0) { content = null; }
  20199. if (!this.sourcesContent.has(url)) {
  20200. this.sourcesContent.set(url, content);
  20201. }
  20202. return this;
  20203. };
  20204. /**
  20205. * @return {?}
  20206. */
  20207. SourceMapGenerator.prototype.addLine = /**
  20208. * @return {?}
  20209. */
  20210. function () {
  20211. this.lines.push([]);
  20212. this.lastCol0 = 0;
  20213. return this;
  20214. };
  20215. /**
  20216. * @param {?} col0
  20217. * @param {?=} sourceUrl
  20218. * @param {?=} sourceLine0
  20219. * @param {?=} sourceCol0
  20220. * @return {?}
  20221. */
  20222. SourceMapGenerator.prototype.addMapping = /**
  20223. * @param {?} col0
  20224. * @param {?=} sourceUrl
  20225. * @param {?=} sourceLine0
  20226. * @param {?=} sourceCol0
  20227. * @return {?}
  20228. */
  20229. function (col0, sourceUrl, sourceLine0, sourceCol0) {
  20230. if (!this.currentLine) {
  20231. throw new Error("A line must be added before mappings can be added");
  20232. }
  20233. if (sourceUrl != null && !this.sourcesContent.has(sourceUrl)) {
  20234. throw new Error("Unknown source file \"" + sourceUrl + "\"");
  20235. }
  20236. if (col0 == null) {
  20237. throw new Error("The column in the generated code must be provided");
  20238. }
  20239. if (col0 < this.lastCol0) {
  20240. throw new Error("Mapping should be added in output order");
  20241. }
  20242. if (sourceUrl && (sourceLine0 == null || sourceCol0 == null)) {
  20243. throw new Error("The source location must be provided when a source url is provided");
  20244. }
  20245. this.hasMappings = true;
  20246. this.lastCol0 = col0;
  20247. this.currentLine.push({ col0: col0, sourceUrl: sourceUrl, sourceLine0: sourceLine0, sourceCol0: sourceCol0 });
  20248. return this;
  20249. };
  20250. Object.defineProperty(SourceMapGenerator.prototype, "currentLine", {
  20251. get: /**
  20252. * @return {?}
  20253. */
  20254. function () { return this.lines.slice(-1)[0]; },
  20255. enumerable: true,
  20256. configurable: true
  20257. });
  20258. /**
  20259. * @return {?}
  20260. */
  20261. SourceMapGenerator.prototype.toJSON = /**
  20262. * @return {?}
  20263. */
  20264. function () {
  20265. var _this = this;
  20266. if (!this.hasMappings) {
  20267. return null;
  20268. }
  20269. var /** @type {?} */ sourcesIndex = new Map();
  20270. var /** @type {?} */ sources = [];
  20271. var /** @type {?} */ sourcesContent = [];
  20272. Array.from(this.sourcesContent.keys()).forEach(function (url, i) {
  20273. sourcesIndex.set(url, i);
  20274. sources.push(url);
  20275. sourcesContent.push(_this.sourcesContent.get(url) || null);
  20276. });
  20277. var /** @type {?} */ mappings = '';
  20278. var /** @type {?} */ lastCol0 = 0;
  20279. var /** @type {?} */ lastSourceIndex = 0;
  20280. var /** @type {?} */ lastSourceLine0 = 0;
  20281. var /** @type {?} */ lastSourceCol0 = 0;
  20282. this.lines.forEach(function (segments) {
  20283. lastCol0 = 0;
  20284. mappings += segments
  20285. .map(function (segment) {
  20286. // zero-based starting column of the line in the generated code
  20287. var /** @type {?} */ segAsStr = toBase64VLQ(segment.col0 - lastCol0);
  20288. lastCol0 = segment.col0;
  20289. if (segment.sourceUrl != null) {
  20290. // zero-based index into the “sources” list
  20291. segAsStr +=
  20292. toBase64VLQ(/** @type {?} */ ((sourcesIndex.get(segment.sourceUrl))) - lastSourceIndex);
  20293. lastSourceIndex = /** @type {?} */ ((sourcesIndex.get(segment.sourceUrl)));
  20294. // the zero-based starting line in the original source
  20295. segAsStr += toBase64VLQ(/** @type {?} */ ((segment.sourceLine0)) - lastSourceLine0);
  20296. lastSourceLine0 = /** @type {?} */ ((segment.sourceLine0));
  20297. // the zero-based starting column in the original source
  20298. segAsStr += toBase64VLQ(/** @type {?} */ ((segment.sourceCol0)) - lastSourceCol0);
  20299. lastSourceCol0 = /** @type {?} */ ((segment.sourceCol0));
  20300. }
  20301. return segAsStr;
  20302. })
  20303. .join(',');
  20304. mappings += ';';
  20305. });
  20306. mappings = mappings.slice(0, -1);
  20307. return {
  20308. 'file': this.file || '',
  20309. 'version': VERSION$1,
  20310. 'sourceRoot': '',
  20311. 'sources': sources,
  20312. 'sourcesContent': sourcesContent,
  20313. 'mappings': mappings,
  20314. };
  20315. };
  20316. /**
  20317. * @return {?}
  20318. */
  20319. SourceMapGenerator.prototype.toJsComment = /**
  20320. * @return {?}
  20321. */
  20322. function () {
  20323. return this.hasMappings ? '//' + JS_B64_PREFIX + toBase64String(JSON.stringify(this, null, 0)) :
  20324. '';
  20325. };
  20326. return SourceMapGenerator;
  20327. }());
  20328. /**
  20329. * @param {?} value
  20330. * @return {?}
  20331. */
  20332. function toBase64String(value) {
  20333. var /** @type {?} */ b64 = '';
  20334. value = utf8Encode(value);
  20335. for (var /** @type {?} */ i = 0; i < value.length;) {
  20336. var /** @type {?} */ i1 = value.charCodeAt(i++);
  20337. var /** @type {?} */ i2 = value.charCodeAt(i++);
  20338. var /** @type {?} */ i3 = value.charCodeAt(i++);
  20339. b64 += toBase64Digit(i1 >> 2);
  20340. b64 += toBase64Digit(((i1 & 3) << 4) | (isNaN(i2) ? 0 : i2 >> 4));
  20341. b64 += isNaN(i2) ? '=' : toBase64Digit(((i2 & 15) << 2) | (i3 >> 6));
  20342. b64 += isNaN(i2) || isNaN(i3) ? '=' : toBase64Digit(i3 & 63);
  20343. }
  20344. return b64;
  20345. }
  20346. /**
  20347. * @param {?} value
  20348. * @return {?}
  20349. */
  20350. function toBase64VLQ(value) {
  20351. value = value < 0 ? ((-value) << 1) + 1 : value << 1;
  20352. var /** @type {?} */ out = '';
  20353. do {
  20354. var /** @type {?} */ digit = value & 31;
  20355. value = value >> 5;
  20356. if (value > 0) {
  20357. digit = digit | 32;
  20358. }
  20359. out += toBase64Digit(digit);
  20360. } while (value > 0);
  20361. return out;
  20362. }
  20363. var B64_DIGITS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  20364. /**
  20365. * @param {?} value
  20366. * @return {?}
  20367. */
  20368. function toBase64Digit(value) {
  20369. if (value < 0 || value >= 64) {
  20370. throw new Error("Can only encode value in the range [0, 63]");
  20371. }
  20372. return B64_DIGITS[value];
  20373. }
  20374. /**
  20375. * @fileoverview added by tsickle
  20376. * @suppress {checkTypes} checked by tsc
  20377. */
  20378. /**
  20379. * @license
  20380. * Copyright Google Inc. All Rights Reserved.
  20381. *
  20382. * Use of this source code is governed by an MIT-style license that can be
  20383. * found in the LICENSE file at https://angular.io/license
  20384. */
  20385. var _SINGLE_QUOTE_ESCAPE_STRING_RE = /'|\\|\n|\r|\$/g;
  20386. var _LEGAL_IDENTIFIER_RE = /^[$A-Z_][0-9A-Z_$]*$/i;
  20387. var _INDENT_WITH = ' ';
  20388. var CATCH_ERROR_VAR$1 = variable('error', null, null);
  20389. var CATCH_STACK_VAR$1 = variable('stack', null, null);
  20390. /**
  20391. * @record
  20392. */
  20393. var _EmittedLine = /** @class */ (function () {
  20394. function _EmittedLine(indent) {
  20395. this.indent = indent;
  20396. this.partsLength = 0;
  20397. this.parts = [];
  20398. this.srcSpans = [];
  20399. }
  20400. return _EmittedLine;
  20401. }());
  20402. var EmitterVisitorContext = /** @class */ (function () {
  20403. function EmitterVisitorContext(_indent) {
  20404. this._indent = _indent;
  20405. this._classes = [];
  20406. this._preambleLineCount = 0;
  20407. this._lines = [new _EmittedLine(_indent)];
  20408. }
  20409. /**
  20410. * @return {?}
  20411. */
  20412. EmitterVisitorContext.createRoot = /**
  20413. * @return {?}
  20414. */
  20415. function () { return new EmitterVisitorContext(0); };
  20416. Object.defineProperty(EmitterVisitorContext.prototype, "_currentLine", {
  20417. get: /**
  20418. * @return {?}
  20419. */
  20420. function () { return this._lines[this._lines.length - 1]; },
  20421. enumerable: true,
  20422. configurable: true
  20423. });
  20424. /**
  20425. * @param {?=} from
  20426. * @param {?=} lastPart
  20427. * @return {?}
  20428. */
  20429. EmitterVisitorContext.prototype.println = /**
  20430. * @param {?=} from
  20431. * @param {?=} lastPart
  20432. * @return {?}
  20433. */
  20434. function (from, lastPart) {
  20435. if (lastPart === void 0) { lastPart = ''; }
  20436. this.print(from || null, lastPart, true);
  20437. };
  20438. /**
  20439. * @return {?}
  20440. */
  20441. EmitterVisitorContext.prototype.lineIsEmpty = /**
  20442. * @return {?}
  20443. */
  20444. function () { return this._currentLine.parts.length === 0; };
  20445. /**
  20446. * @return {?}
  20447. */
  20448. EmitterVisitorContext.prototype.lineLength = /**
  20449. * @return {?}
  20450. */
  20451. function () {
  20452. return this._currentLine.indent * _INDENT_WITH.length + this._currentLine.partsLength;
  20453. };
  20454. /**
  20455. * @param {?} from
  20456. * @param {?} part
  20457. * @param {?=} newLine
  20458. * @return {?}
  20459. */
  20460. EmitterVisitorContext.prototype.print = /**
  20461. * @param {?} from
  20462. * @param {?} part
  20463. * @param {?=} newLine
  20464. * @return {?}
  20465. */
  20466. function (from, part, newLine) {
  20467. if (newLine === void 0) { newLine = false; }
  20468. if (part.length > 0) {
  20469. this._currentLine.parts.push(part);
  20470. this._currentLine.partsLength += part.length;
  20471. this._currentLine.srcSpans.push(from && from.sourceSpan || null);
  20472. }
  20473. if (newLine) {
  20474. this._lines.push(new _EmittedLine(this._indent));
  20475. }
  20476. };
  20477. /**
  20478. * @return {?}
  20479. */
  20480. EmitterVisitorContext.prototype.removeEmptyLastLine = /**
  20481. * @return {?}
  20482. */
  20483. function () {
  20484. if (this.lineIsEmpty()) {
  20485. this._lines.pop();
  20486. }
  20487. };
  20488. /**
  20489. * @return {?}
  20490. */
  20491. EmitterVisitorContext.prototype.incIndent = /**
  20492. * @return {?}
  20493. */
  20494. function () {
  20495. this._indent++;
  20496. if (this.lineIsEmpty()) {
  20497. this._currentLine.indent = this._indent;
  20498. }
  20499. };
  20500. /**
  20501. * @return {?}
  20502. */
  20503. EmitterVisitorContext.prototype.decIndent = /**
  20504. * @return {?}
  20505. */
  20506. function () {
  20507. this._indent--;
  20508. if (this.lineIsEmpty()) {
  20509. this._currentLine.indent = this._indent;
  20510. }
  20511. };
  20512. /**
  20513. * @param {?} clazz
  20514. * @return {?}
  20515. */
  20516. EmitterVisitorContext.prototype.pushClass = /**
  20517. * @param {?} clazz
  20518. * @return {?}
  20519. */
  20520. function (clazz) { this._classes.push(clazz); };
  20521. /**
  20522. * @return {?}
  20523. */
  20524. EmitterVisitorContext.prototype.popClass = /**
  20525. * @return {?}
  20526. */
  20527. function () { return /** @type {?} */ ((this._classes.pop())); };
  20528. Object.defineProperty(EmitterVisitorContext.prototype, "currentClass", {
  20529. get: /**
  20530. * @return {?}
  20531. */
  20532. function () {
  20533. return this._classes.length > 0 ? this._classes[this._classes.length - 1] : null;
  20534. },
  20535. enumerable: true,
  20536. configurable: true
  20537. });
  20538. /**
  20539. * @return {?}
  20540. */
  20541. EmitterVisitorContext.prototype.toSource = /**
  20542. * @return {?}
  20543. */
  20544. function () {
  20545. return this.sourceLines
  20546. .map(function (l) { return l.parts.length > 0 ? _createIndent(l.indent) + l.parts.join('') : ''; })
  20547. .join('\n');
  20548. };
  20549. /**
  20550. * @param {?} genFilePath
  20551. * @param {?=} startsAtLine
  20552. * @return {?}
  20553. */
  20554. EmitterVisitorContext.prototype.toSourceMapGenerator = /**
  20555. * @param {?} genFilePath
  20556. * @param {?=} startsAtLine
  20557. * @return {?}
  20558. */
  20559. function (genFilePath, startsAtLine) {
  20560. if (startsAtLine === void 0) { startsAtLine = 0; }
  20561. var /** @type {?} */ map = new SourceMapGenerator(genFilePath);
  20562. var /** @type {?} */ firstOffsetMapped = false;
  20563. var /** @type {?} */ mapFirstOffsetIfNeeded = function () {
  20564. if (!firstOffsetMapped) {
  20565. // Add a single space so that tools won't try to load the file from disk.
  20566. // Note: We are using virtual urls like `ng:///`, so we have to
  20567. // provide a content here.
  20568. map.addSource(genFilePath, ' ').addMapping(0, genFilePath, 0, 0);
  20569. firstOffsetMapped = true;
  20570. }
  20571. };
  20572. for (var /** @type {?} */ i = 0; i < startsAtLine; i++) {
  20573. map.addLine();
  20574. mapFirstOffsetIfNeeded();
  20575. }
  20576. this.sourceLines.forEach(function (line, lineIdx) {
  20577. map.addLine();
  20578. var /** @type {?} */ spans = line.srcSpans;
  20579. var /** @type {?} */ parts = line.parts;
  20580. var /** @type {?} */ col0 = line.indent * _INDENT_WITH.length;
  20581. var /** @type {?} */ spanIdx = 0;
  20582. // skip leading parts without source spans
  20583. while (spanIdx < spans.length && !spans[spanIdx]) {
  20584. col0 += parts[spanIdx].length;
  20585. spanIdx++;
  20586. }
  20587. if (spanIdx < spans.length && lineIdx === 0 && col0 === 0) {
  20588. firstOffsetMapped = true;
  20589. }
  20590. else {
  20591. mapFirstOffsetIfNeeded();
  20592. }
  20593. while (spanIdx < spans.length) {
  20594. var /** @type {?} */ span = /** @type {?} */ ((spans[spanIdx]));
  20595. var /** @type {?} */ source = span.start.file;
  20596. var /** @type {?} */ sourceLine = span.start.line;
  20597. var /** @type {?} */ sourceCol = span.start.col;
  20598. map.addSource(source.url, source.content)
  20599. .addMapping(col0, source.url, sourceLine, sourceCol);
  20600. col0 += parts[spanIdx].length;
  20601. spanIdx++;
  20602. // assign parts without span or the same span to the previous segment
  20603. while (spanIdx < spans.length && (span === spans[spanIdx] || !spans[spanIdx])) {
  20604. col0 += parts[spanIdx].length;
  20605. spanIdx++;
  20606. }
  20607. }
  20608. });
  20609. return map;
  20610. };
  20611. /**
  20612. * @param {?} count
  20613. * @return {?}
  20614. */
  20615. EmitterVisitorContext.prototype.setPreambleLineCount = /**
  20616. * @param {?} count
  20617. * @return {?}
  20618. */
  20619. function (count) { return this._preambleLineCount = count; };
  20620. /**
  20621. * @param {?} line
  20622. * @param {?} column
  20623. * @return {?}
  20624. */
  20625. EmitterVisitorContext.prototype.spanOf = /**
  20626. * @param {?} line
  20627. * @param {?} column
  20628. * @return {?}
  20629. */
  20630. function (line, column) {
  20631. var /** @type {?} */ emittedLine = this._lines[line - this._preambleLineCount];
  20632. if (emittedLine) {
  20633. var /** @type {?} */ columnsLeft = column - _createIndent(emittedLine.indent).length;
  20634. for (var /** @type {?} */ partIndex = 0; partIndex < emittedLine.parts.length; partIndex++) {
  20635. var /** @type {?} */ part = emittedLine.parts[partIndex];
  20636. if (part.length > columnsLeft) {
  20637. return emittedLine.srcSpans[partIndex];
  20638. }
  20639. columnsLeft -= part.length;
  20640. }
  20641. }
  20642. return null;
  20643. };
  20644. Object.defineProperty(EmitterVisitorContext.prototype, "sourceLines", {
  20645. get: /**
  20646. * @return {?}
  20647. */
  20648. function () {
  20649. if (this._lines.length && this._lines[this._lines.length - 1].parts.length === 0) {
  20650. return this._lines.slice(0, -1);
  20651. }
  20652. return this._lines;
  20653. },
  20654. enumerable: true,
  20655. configurable: true
  20656. });
  20657. return EmitterVisitorContext;
  20658. }());
  20659. /**
  20660. * @abstract
  20661. */
  20662. var AbstractEmitterVisitor = /** @class */ (function () {
  20663. function AbstractEmitterVisitor(_escapeDollarInStrings) {
  20664. this._escapeDollarInStrings = _escapeDollarInStrings;
  20665. }
  20666. /**
  20667. * @param {?} stmt
  20668. * @param {?} ctx
  20669. * @return {?}
  20670. */
  20671. AbstractEmitterVisitor.prototype.visitExpressionStmt = /**
  20672. * @param {?} stmt
  20673. * @param {?} ctx
  20674. * @return {?}
  20675. */
  20676. function (stmt, ctx) {
  20677. stmt.expr.visitExpression(this, ctx);
  20678. ctx.println(stmt, ';');
  20679. return null;
  20680. };
  20681. /**
  20682. * @param {?} stmt
  20683. * @param {?} ctx
  20684. * @return {?}
  20685. */
  20686. AbstractEmitterVisitor.prototype.visitReturnStmt = /**
  20687. * @param {?} stmt
  20688. * @param {?} ctx
  20689. * @return {?}
  20690. */
  20691. function (stmt, ctx) {
  20692. ctx.print(stmt, "return ");
  20693. stmt.value.visitExpression(this, ctx);
  20694. ctx.println(stmt, ';');
  20695. return null;
  20696. };
  20697. /**
  20698. * @param {?} stmt
  20699. * @param {?} ctx
  20700. * @return {?}
  20701. */
  20702. AbstractEmitterVisitor.prototype.visitIfStmt = /**
  20703. * @param {?} stmt
  20704. * @param {?} ctx
  20705. * @return {?}
  20706. */
  20707. function (stmt, ctx) {
  20708. ctx.print(stmt, "if (");
  20709. stmt.condition.visitExpression(this, ctx);
  20710. ctx.print(stmt, ") {");
  20711. var /** @type {?} */ hasElseCase = stmt.falseCase != null && stmt.falseCase.length > 0;
  20712. if (stmt.trueCase.length <= 1 && !hasElseCase) {
  20713. ctx.print(stmt, " ");
  20714. this.visitAllStatements(stmt.trueCase, ctx);
  20715. ctx.removeEmptyLastLine();
  20716. ctx.print(stmt, " ");
  20717. }
  20718. else {
  20719. ctx.println();
  20720. ctx.incIndent();
  20721. this.visitAllStatements(stmt.trueCase, ctx);
  20722. ctx.decIndent();
  20723. if (hasElseCase) {
  20724. ctx.println(stmt, "} else {");
  20725. ctx.incIndent();
  20726. this.visitAllStatements(stmt.falseCase, ctx);
  20727. ctx.decIndent();
  20728. }
  20729. }
  20730. ctx.println(stmt, "}");
  20731. return null;
  20732. };
  20733. /**
  20734. * @param {?} stmt
  20735. * @param {?} ctx
  20736. * @return {?}
  20737. */
  20738. AbstractEmitterVisitor.prototype.visitThrowStmt = /**
  20739. * @param {?} stmt
  20740. * @param {?} ctx
  20741. * @return {?}
  20742. */
  20743. function (stmt, ctx) {
  20744. ctx.print(stmt, "throw ");
  20745. stmt.error.visitExpression(this, ctx);
  20746. ctx.println(stmt, ";");
  20747. return null;
  20748. };
  20749. /**
  20750. * @param {?} stmt
  20751. * @param {?} ctx
  20752. * @return {?}
  20753. */
  20754. AbstractEmitterVisitor.prototype.visitCommentStmt = /**
  20755. * @param {?} stmt
  20756. * @param {?} ctx
  20757. * @return {?}
  20758. */
  20759. function (stmt, ctx) {
  20760. var /** @type {?} */ lines = stmt.comment.split('\n');
  20761. lines.forEach(function (line) { ctx.println(stmt, "// " + line); });
  20762. return null;
  20763. };
  20764. /**
  20765. * @param {?} expr
  20766. * @param {?} ctx
  20767. * @return {?}
  20768. */
  20769. AbstractEmitterVisitor.prototype.visitWriteVarExpr = /**
  20770. * @param {?} expr
  20771. * @param {?} ctx
  20772. * @return {?}
  20773. */
  20774. function (expr, ctx) {
  20775. var /** @type {?} */ lineWasEmpty = ctx.lineIsEmpty();
  20776. if (!lineWasEmpty) {
  20777. ctx.print(expr, '(');
  20778. }
  20779. ctx.print(expr, expr.name + " = ");
  20780. expr.value.visitExpression(this, ctx);
  20781. if (!lineWasEmpty) {
  20782. ctx.print(expr, ')');
  20783. }
  20784. return null;
  20785. };
  20786. /**
  20787. * @param {?} expr
  20788. * @param {?} ctx
  20789. * @return {?}
  20790. */
  20791. AbstractEmitterVisitor.prototype.visitWriteKeyExpr = /**
  20792. * @param {?} expr
  20793. * @param {?} ctx
  20794. * @return {?}
  20795. */
  20796. function (expr, ctx) {
  20797. var /** @type {?} */ lineWasEmpty = ctx.lineIsEmpty();
  20798. if (!lineWasEmpty) {
  20799. ctx.print(expr, '(');
  20800. }
  20801. expr.receiver.visitExpression(this, ctx);
  20802. ctx.print(expr, "[");
  20803. expr.index.visitExpression(this, ctx);
  20804. ctx.print(expr, "] = ");
  20805. expr.value.visitExpression(this, ctx);
  20806. if (!lineWasEmpty) {
  20807. ctx.print(expr, ')');
  20808. }
  20809. return null;
  20810. };
  20811. /**
  20812. * @param {?} expr
  20813. * @param {?} ctx
  20814. * @return {?}
  20815. */
  20816. AbstractEmitterVisitor.prototype.visitWritePropExpr = /**
  20817. * @param {?} expr
  20818. * @param {?} ctx
  20819. * @return {?}
  20820. */
  20821. function (expr, ctx) {
  20822. var /** @type {?} */ lineWasEmpty = ctx.lineIsEmpty();
  20823. if (!lineWasEmpty) {
  20824. ctx.print(expr, '(');
  20825. }
  20826. expr.receiver.visitExpression(this, ctx);
  20827. ctx.print(expr, "." + expr.name + " = ");
  20828. expr.value.visitExpression(this, ctx);
  20829. if (!lineWasEmpty) {
  20830. ctx.print(expr, ')');
  20831. }
  20832. return null;
  20833. };
  20834. /**
  20835. * @param {?} expr
  20836. * @param {?} ctx
  20837. * @return {?}
  20838. */
  20839. AbstractEmitterVisitor.prototype.visitInvokeMethodExpr = /**
  20840. * @param {?} expr
  20841. * @param {?} ctx
  20842. * @return {?}
  20843. */
  20844. function (expr, ctx) {
  20845. expr.receiver.visitExpression(this, ctx);
  20846. var /** @type {?} */ name = expr.name;
  20847. if (expr.builtin != null) {
  20848. name = this.getBuiltinMethodName(expr.builtin);
  20849. if (name == null) {
  20850. // some builtins just mean to skip the call.
  20851. return null;
  20852. }
  20853. }
  20854. ctx.print(expr, "." + name + "(");
  20855. this.visitAllExpressions(expr.args, ctx, ",");
  20856. ctx.print(expr, ")");
  20857. return null;
  20858. };
  20859. /**
  20860. * @param {?} expr
  20861. * @param {?} ctx
  20862. * @return {?}
  20863. */
  20864. AbstractEmitterVisitor.prototype.visitInvokeFunctionExpr = /**
  20865. * @param {?} expr
  20866. * @param {?} ctx
  20867. * @return {?}
  20868. */
  20869. function (expr, ctx) {
  20870. expr.fn.visitExpression(this, ctx);
  20871. ctx.print(expr, "(");
  20872. this.visitAllExpressions(expr.args, ctx, ',');
  20873. ctx.print(expr, ")");
  20874. return null;
  20875. };
  20876. /**
  20877. * @param {?} ast
  20878. * @param {?} ctx
  20879. * @return {?}
  20880. */
  20881. AbstractEmitterVisitor.prototype.visitReadVarExpr = /**
  20882. * @param {?} ast
  20883. * @param {?} ctx
  20884. * @return {?}
  20885. */
  20886. function (ast, ctx) {
  20887. var /** @type {?} */ varName = /** @type {?} */ ((ast.name));
  20888. if (ast.builtin != null) {
  20889. switch (ast.builtin) {
  20890. case BuiltinVar.Super:
  20891. varName = 'super';
  20892. break;
  20893. case BuiltinVar.This:
  20894. varName = 'this';
  20895. break;
  20896. case BuiltinVar.CatchError:
  20897. varName = /** @type {?} */ ((CATCH_ERROR_VAR$1.name));
  20898. break;
  20899. case BuiltinVar.CatchStack:
  20900. varName = /** @type {?} */ ((CATCH_STACK_VAR$1.name));
  20901. break;
  20902. default:
  20903. throw new Error("Unknown builtin variable " + ast.builtin);
  20904. }
  20905. }
  20906. ctx.print(ast, varName);
  20907. return null;
  20908. };
  20909. /**
  20910. * @param {?} ast
  20911. * @param {?} ctx
  20912. * @return {?}
  20913. */
  20914. AbstractEmitterVisitor.prototype.visitInstantiateExpr = /**
  20915. * @param {?} ast
  20916. * @param {?} ctx
  20917. * @return {?}
  20918. */
  20919. function (ast, ctx) {
  20920. ctx.print(ast, "new ");
  20921. ast.classExpr.visitExpression(this, ctx);
  20922. ctx.print(ast, "(");
  20923. this.visitAllExpressions(ast.args, ctx, ',');
  20924. ctx.print(ast, ")");
  20925. return null;
  20926. };
  20927. /**
  20928. * @param {?} ast
  20929. * @param {?} ctx
  20930. * @return {?}
  20931. */
  20932. AbstractEmitterVisitor.prototype.visitLiteralExpr = /**
  20933. * @param {?} ast
  20934. * @param {?} ctx
  20935. * @return {?}
  20936. */
  20937. function (ast, ctx) {
  20938. var /** @type {?} */ value = ast.value;
  20939. if (typeof value === 'string') {
  20940. ctx.print(ast, escapeIdentifier(value, this._escapeDollarInStrings));
  20941. }
  20942. else {
  20943. ctx.print(ast, "" + value);
  20944. }
  20945. return null;
  20946. };
  20947. /**
  20948. * @param {?} ast
  20949. * @param {?} ctx
  20950. * @return {?}
  20951. */
  20952. AbstractEmitterVisitor.prototype.visitConditionalExpr = /**
  20953. * @param {?} ast
  20954. * @param {?} ctx
  20955. * @return {?}
  20956. */
  20957. function (ast, ctx) {
  20958. ctx.print(ast, "(");
  20959. ast.condition.visitExpression(this, ctx);
  20960. ctx.print(ast, '? ');
  20961. ast.trueCase.visitExpression(this, ctx);
  20962. ctx.print(ast, ': '); /** @type {?} */
  20963. ((ast.falseCase)).visitExpression(this, ctx);
  20964. ctx.print(ast, ")");
  20965. return null;
  20966. };
  20967. /**
  20968. * @param {?} ast
  20969. * @param {?} ctx
  20970. * @return {?}
  20971. */
  20972. AbstractEmitterVisitor.prototype.visitNotExpr = /**
  20973. * @param {?} ast
  20974. * @param {?} ctx
  20975. * @return {?}
  20976. */
  20977. function (ast, ctx) {
  20978. ctx.print(ast, '!');
  20979. ast.condition.visitExpression(this, ctx);
  20980. return null;
  20981. };
  20982. /**
  20983. * @param {?} ast
  20984. * @param {?} ctx
  20985. * @return {?}
  20986. */
  20987. AbstractEmitterVisitor.prototype.visitAssertNotNullExpr = /**
  20988. * @param {?} ast
  20989. * @param {?} ctx
  20990. * @return {?}
  20991. */
  20992. function (ast, ctx) {
  20993. ast.condition.visitExpression(this, ctx);
  20994. return null;
  20995. };
  20996. /**
  20997. * @param {?} ast
  20998. * @param {?} ctx
  20999. * @return {?}
  21000. */
  21001. AbstractEmitterVisitor.prototype.visitBinaryOperatorExpr = /**
  21002. * @param {?} ast
  21003. * @param {?} ctx
  21004. * @return {?}
  21005. */
  21006. function (ast, ctx) {
  21007. var /** @type {?} */ opStr;
  21008. switch (ast.operator) {
  21009. case BinaryOperator.Equals:
  21010. opStr = '==';
  21011. break;
  21012. case BinaryOperator.Identical:
  21013. opStr = '===';
  21014. break;
  21015. case BinaryOperator.NotEquals:
  21016. opStr = '!=';
  21017. break;
  21018. case BinaryOperator.NotIdentical:
  21019. opStr = '!==';
  21020. break;
  21021. case BinaryOperator.And:
  21022. opStr = '&&';
  21023. break;
  21024. case BinaryOperator.Or:
  21025. opStr = '||';
  21026. break;
  21027. case BinaryOperator.Plus:
  21028. opStr = '+';
  21029. break;
  21030. case BinaryOperator.Minus:
  21031. opStr = '-';
  21032. break;
  21033. case BinaryOperator.Divide:
  21034. opStr = '/';
  21035. break;
  21036. case BinaryOperator.Multiply:
  21037. opStr = '*';
  21038. break;
  21039. case BinaryOperator.Modulo:
  21040. opStr = '%';
  21041. break;
  21042. case BinaryOperator.Lower:
  21043. opStr = '<';
  21044. break;
  21045. case BinaryOperator.LowerEquals:
  21046. opStr = '<=';
  21047. break;
  21048. case BinaryOperator.Bigger:
  21049. opStr = '>';
  21050. break;
  21051. case BinaryOperator.BiggerEquals:
  21052. opStr = '>=';
  21053. break;
  21054. default:
  21055. throw new Error("Unknown operator " + ast.operator);
  21056. }
  21057. ctx.print(ast, "(");
  21058. ast.lhs.visitExpression(this, ctx);
  21059. ctx.print(ast, " " + opStr + " ");
  21060. ast.rhs.visitExpression(this, ctx);
  21061. ctx.print(ast, ")");
  21062. return null;
  21063. };
  21064. /**
  21065. * @param {?} ast
  21066. * @param {?} ctx
  21067. * @return {?}
  21068. */
  21069. AbstractEmitterVisitor.prototype.visitReadPropExpr = /**
  21070. * @param {?} ast
  21071. * @param {?} ctx
  21072. * @return {?}
  21073. */
  21074. function (ast, ctx) {
  21075. ast.receiver.visitExpression(this, ctx);
  21076. ctx.print(ast, ".");
  21077. ctx.print(ast, ast.name);
  21078. return null;
  21079. };
  21080. /**
  21081. * @param {?} ast
  21082. * @param {?} ctx
  21083. * @return {?}
  21084. */
  21085. AbstractEmitterVisitor.prototype.visitReadKeyExpr = /**
  21086. * @param {?} ast
  21087. * @param {?} ctx
  21088. * @return {?}
  21089. */
  21090. function (ast, ctx) {
  21091. ast.receiver.visitExpression(this, ctx);
  21092. ctx.print(ast, "[");
  21093. ast.index.visitExpression(this, ctx);
  21094. ctx.print(ast, "]");
  21095. return null;
  21096. };
  21097. /**
  21098. * @param {?} ast
  21099. * @param {?} ctx
  21100. * @return {?}
  21101. */
  21102. AbstractEmitterVisitor.prototype.visitLiteralArrayExpr = /**
  21103. * @param {?} ast
  21104. * @param {?} ctx
  21105. * @return {?}
  21106. */
  21107. function (ast, ctx) {
  21108. ctx.print(ast, "[");
  21109. this.visitAllExpressions(ast.entries, ctx, ',');
  21110. ctx.print(ast, "]");
  21111. return null;
  21112. };
  21113. /**
  21114. * @param {?} ast
  21115. * @param {?} ctx
  21116. * @return {?}
  21117. */
  21118. AbstractEmitterVisitor.prototype.visitLiteralMapExpr = /**
  21119. * @param {?} ast
  21120. * @param {?} ctx
  21121. * @return {?}
  21122. */
  21123. function (ast, ctx) {
  21124. var _this = this;
  21125. ctx.print(ast, "{");
  21126. this.visitAllObjects(function (entry) {
  21127. ctx.print(ast, escapeIdentifier(entry.key, _this._escapeDollarInStrings, entry.quoted) + ":");
  21128. entry.value.visitExpression(_this, ctx);
  21129. }, ast.entries, ctx, ',');
  21130. ctx.print(ast, "}");
  21131. return null;
  21132. };
  21133. /**
  21134. * @param {?} ast
  21135. * @param {?} ctx
  21136. * @return {?}
  21137. */
  21138. AbstractEmitterVisitor.prototype.visitCommaExpr = /**
  21139. * @param {?} ast
  21140. * @param {?} ctx
  21141. * @return {?}
  21142. */
  21143. function (ast, ctx) {
  21144. ctx.print(ast, '(');
  21145. this.visitAllExpressions(ast.parts, ctx, ',');
  21146. ctx.print(ast, ')');
  21147. return null;
  21148. };
  21149. /**
  21150. * @param {?} expressions
  21151. * @param {?} ctx
  21152. * @param {?} separator
  21153. * @return {?}
  21154. */
  21155. AbstractEmitterVisitor.prototype.visitAllExpressions = /**
  21156. * @param {?} expressions
  21157. * @param {?} ctx
  21158. * @param {?} separator
  21159. * @return {?}
  21160. */
  21161. function (expressions, ctx, separator) {
  21162. var _this = this;
  21163. this.visitAllObjects(function (expr) { return expr.visitExpression(_this, ctx); }, expressions, ctx, separator);
  21164. };
  21165. /**
  21166. * @template T
  21167. * @param {?} handler
  21168. * @param {?} expressions
  21169. * @param {?} ctx
  21170. * @param {?} separator
  21171. * @return {?}
  21172. */
  21173. AbstractEmitterVisitor.prototype.visitAllObjects = /**
  21174. * @template T
  21175. * @param {?} handler
  21176. * @param {?} expressions
  21177. * @param {?} ctx
  21178. * @param {?} separator
  21179. * @return {?}
  21180. */
  21181. function (handler, expressions, ctx, separator) {
  21182. var /** @type {?} */ incrementedIndent = false;
  21183. for (var /** @type {?} */ i = 0; i < expressions.length; i++) {
  21184. if (i > 0) {
  21185. if (ctx.lineLength() > 80) {
  21186. ctx.print(null, separator, true);
  21187. if (!incrementedIndent) {
  21188. // continuation are marked with double indent.
  21189. ctx.incIndent();
  21190. ctx.incIndent();
  21191. incrementedIndent = true;
  21192. }
  21193. }
  21194. else {
  21195. ctx.print(null, separator, false);
  21196. }
  21197. }
  21198. handler(expressions[i]);
  21199. }
  21200. if (incrementedIndent) {
  21201. // continuation are marked with double indent.
  21202. ctx.decIndent();
  21203. ctx.decIndent();
  21204. }
  21205. };
  21206. /**
  21207. * @param {?} statements
  21208. * @param {?} ctx
  21209. * @return {?}
  21210. */
  21211. AbstractEmitterVisitor.prototype.visitAllStatements = /**
  21212. * @param {?} statements
  21213. * @param {?} ctx
  21214. * @return {?}
  21215. */
  21216. function (statements, ctx) {
  21217. var _this = this;
  21218. statements.forEach(function (stmt) { return stmt.visitStatement(_this, ctx); });
  21219. };
  21220. return AbstractEmitterVisitor;
  21221. }());
  21222. /**
  21223. * @param {?} input
  21224. * @param {?} escapeDollar
  21225. * @param {?=} alwaysQuote
  21226. * @return {?}
  21227. */
  21228. function escapeIdentifier(input, escapeDollar, alwaysQuote) {
  21229. if (alwaysQuote === void 0) { alwaysQuote = true; }
  21230. if (input == null) {
  21231. return null;
  21232. }
  21233. var /** @type {?} */ body = input.replace(_SINGLE_QUOTE_ESCAPE_STRING_RE, function () {
  21234. var match = [];
  21235. for (var _i = 0; _i < arguments.length; _i++) {
  21236. match[_i] = arguments[_i];
  21237. }
  21238. if (match[0] == '$') {
  21239. return escapeDollar ? '\\$' : '$';
  21240. }
  21241. else if (match[0] == '\n') {
  21242. return '\\n';
  21243. }
  21244. else if (match[0] == '\r') {
  21245. return '\\r';
  21246. }
  21247. else {
  21248. return "\\" + match[0];
  21249. }
  21250. });
  21251. var /** @type {?} */ requiresQuotes = alwaysQuote || !_LEGAL_IDENTIFIER_RE.test(body);
  21252. return requiresQuotes ? "'" + body + "'" : body;
  21253. }
  21254. /**
  21255. * @param {?} count
  21256. * @return {?}
  21257. */
  21258. function _createIndent(count) {
  21259. var /** @type {?} */ res = '';
  21260. for (var /** @type {?} */ i = 0; i < count; i++) {
  21261. res += _INDENT_WITH;
  21262. }
  21263. return res;
  21264. }
  21265. /**
  21266. * @fileoverview added by tsickle
  21267. * @suppress {checkTypes} checked by tsc
  21268. */
  21269. /**
  21270. * @license
  21271. * Copyright Google Inc. All Rights Reserved.
  21272. *
  21273. * Use of this source code is governed by an MIT-style license that can be
  21274. * found in the LICENSE file at https://angular.io/license
  21275. */
  21276. /**
  21277. * @param {?} ast
  21278. * @return {?}
  21279. */
  21280. function debugOutputAstAsTypeScript(ast) {
  21281. var /** @type {?} */ converter = new _TsEmitterVisitor();
  21282. var /** @type {?} */ ctx = EmitterVisitorContext.createRoot();
  21283. var /** @type {?} */ asts = Array.isArray(ast) ? ast : [ast];
  21284. asts.forEach(function (ast) {
  21285. if (ast instanceof Statement) {
  21286. ast.visitStatement(converter, ctx);
  21287. }
  21288. else if (ast instanceof Expression) {
  21289. ast.visitExpression(converter, ctx);
  21290. }
  21291. else if (ast instanceof Type$1) {
  21292. ast.visitType(converter, ctx);
  21293. }
  21294. else {
  21295. throw new Error("Don't know how to print debug info for " + ast);
  21296. }
  21297. });
  21298. return ctx.toSource();
  21299. }
  21300. var TypeScriptEmitter = /** @class */ (function () {
  21301. function TypeScriptEmitter() {
  21302. }
  21303. /**
  21304. * @param {?} genFilePath
  21305. * @param {?} stmts
  21306. * @param {?=} preamble
  21307. * @param {?=} emitSourceMaps
  21308. * @param {?=} referenceFilter
  21309. * @return {?}
  21310. */
  21311. TypeScriptEmitter.prototype.emitStatementsAndContext = /**
  21312. * @param {?} genFilePath
  21313. * @param {?} stmts
  21314. * @param {?=} preamble
  21315. * @param {?=} emitSourceMaps
  21316. * @param {?=} referenceFilter
  21317. * @return {?}
  21318. */
  21319. function (genFilePath, stmts, preamble, emitSourceMaps, referenceFilter) {
  21320. if (preamble === void 0) { preamble = ''; }
  21321. if (emitSourceMaps === void 0) { emitSourceMaps = true; }
  21322. var /** @type {?} */ converter = new _TsEmitterVisitor(referenceFilter);
  21323. var /** @type {?} */ ctx = EmitterVisitorContext.createRoot();
  21324. converter.visitAllStatements(stmts, ctx);
  21325. var /** @type {?} */ preambleLines = preamble ? preamble.split('\n') : [];
  21326. converter.reexports.forEach(function (reexports, exportedModuleName) {
  21327. var /** @type {?} */ reexportsCode = reexports.map(function (reexport) { return reexport.name + " as " + reexport.as; }).join(',');
  21328. preambleLines.push("export {" + reexportsCode + "} from '" + exportedModuleName + "';");
  21329. });
  21330. converter.importsWithPrefixes.forEach(function (prefix, importedModuleName) {
  21331. // Note: can't write the real word for import as it screws up system.js auto detection...
  21332. preambleLines.push("imp" +
  21333. ("ort * as " + prefix + " from '" + importedModuleName + "';"));
  21334. });
  21335. var /** @type {?} */ sm = emitSourceMaps ?
  21336. ctx.toSourceMapGenerator(genFilePath, preambleLines.length).toJsComment() :
  21337. '';
  21338. var /** @type {?} */ lines = preambleLines.concat([ctx.toSource(), sm]);
  21339. if (sm) {
  21340. // always add a newline at the end, as some tools have bugs without it.
  21341. lines.push('');
  21342. }
  21343. ctx.setPreambleLineCount(preambleLines.length);
  21344. return { sourceText: lines.join('\n'), context: ctx };
  21345. };
  21346. /**
  21347. * @param {?} genFilePath
  21348. * @param {?} stmts
  21349. * @param {?=} preamble
  21350. * @return {?}
  21351. */
  21352. TypeScriptEmitter.prototype.emitStatements = /**
  21353. * @param {?} genFilePath
  21354. * @param {?} stmts
  21355. * @param {?=} preamble
  21356. * @return {?}
  21357. */
  21358. function (genFilePath, stmts, preamble) {
  21359. if (preamble === void 0) { preamble = ''; }
  21360. return this.emitStatementsAndContext(genFilePath, stmts, preamble).sourceText;
  21361. };
  21362. return TypeScriptEmitter;
  21363. }());
  21364. var _TsEmitterVisitor = /** @class */ (function (_super) {
  21365. __extends(_TsEmitterVisitor, _super);
  21366. function _TsEmitterVisitor(referenceFilter) {
  21367. var _this = _super.call(this, false) || this;
  21368. _this.referenceFilter = referenceFilter;
  21369. _this.typeExpression = 0;
  21370. _this.importsWithPrefixes = new Map();
  21371. _this.reexports = new Map();
  21372. return _this;
  21373. }
  21374. /**
  21375. * @param {?} t
  21376. * @param {?} ctx
  21377. * @param {?=} defaultType
  21378. * @return {?}
  21379. */
  21380. _TsEmitterVisitor.prototype.visitType = /**
  21381. * @param {?} t
  21382. * @param {?} ctx
  21383. * @param {?=} defaultType
  21384. * @return {?}
  21385. */
  21386. function (t, ctx, defaultType) {
  21387. if (defaultType === void 0) { defaultType = 'any'; }
  21388. if (t) {
  21389. this.typeExpression++;
  21390. t.visitType(this, ctx);
  21391. this.typeExpression--;
  21392. }
  21393. else {
  21394. ctx.print(null, defaultType);
  21395. }
  21396. };
  21397. /**
  21398. * @param {?} ast
  21399. * @param {?} ctx
  21400. * @return {?}
  21401. */
  21402. _TsEmitterVisitor.prototype.visitLiteralExpr = /**
  21403. * @param {?} ast
  21404. * @param {?} ctx
  21405. * @return {?}
  21406. */
  21407. function (ast, ctx) {
  21408. var /** @type {?} */ value = ast.value;
  21409. if (value == null && ast.type != INFERRED_TYPE) {
  21410. ctx.print(ast, "(" + value + " as any)");
  21411. return null;
  21412. }
  21413. return _super.prototype.visitLiteralExpr.call(this, ast, ctx);
  21414. };
  21415. // Temporary workaround to support strictNullCheck enabled consumers of ngc emit.
  21416. // In SNC mode, [] have the type never[], so we cast here to any[].
  21417. // TODO: narrow the cast to a more explicit type, or use a pattern that does not
  21418. // start with [].concat. see https://github.com/angular/angular/pull/11846
  21419. /**
  21420. * @param {?} ast
  21421. * @param {?} ctx
  21422. * @return {?}
  21423. */
  21424. _TsEmitterVisitor.prototype.visitLiteralArrayExpr = /**
  21425. * @param {?} ast
  21426. * @param {?} ctx
  21427. * @return {?}
  21428. */
  21429. function (ast, ctx) {
  21430. if (ast.entries.length === 0) {
  21431. ctx.print(ast, '(');
  21432. }
  21433. var /** @type {?} */ result = _super.prototype.visitLiteralArrayExpr.call(this, ast, ctx);
  21434. if (ast.entries.length === 0) {
  21435. ctx.print(ast, ' as any[])');
  21436. }
  21437. return result;
  21438. };
  21439. /**
  21440. * @param {?} ast
  21441. * @param {?} ctx
  21442. * @return {?}
  21443. */
  21444. _TsEmitterVisitor.prototype.visitExternalExpr = /**
  21445. * @param {?} ast
  21446. * @param {?} ctx
  21447. * @return {?}
  21448. */
  21449. function (ast, ctx) {
  21450. this._visitIdentifier(ast.value, ast.typeParams, ctx);
  21451. return null;
  21452. };
  21453. /**
  21454. * @param {?} ast
  21455. * @param {?} ctx
  21456. * @return {?}
  21457. */
  21458. _TsEmitterVisitor.prototype.visitAssertNotNullExpr = /**
  21459. * @param {?} ast
  21460. * @param {?} ctx
  21461. * @return {?}
  21462. */
  21463. function (ast, ctx) {
  21464. var /** @type {?} */ result = _super.prototype.visitAssertNotNullExpr.call(this, ast, ctx);
  21465. ctx.print(ast, '!');
  21466. return result;
  21467. };
  21468. /**
  21469. * @param {?} stmt
  21470. * @param {?} ctx
  21471. * @return {?}
  21472. */
  21473. _TsEmitterVisitor.prototype.visitDeclareVarStmt = /**
  21474. * @param {?} stmt
  21475. * @param {?} ctx
  21476. * @return {?}
  21477. */
  21478. function (stmt, ctx) {
  21479. if (stmt.hasModifier(StmtModifier.Exported) && stmt.value instanceof ExternalExpr &&
  21480. !stmt.type) {
  21481. // check for a reexport
  21482. var _a = stmt.value.value, name_1 = _a.name, moduleName = _a.moduleName;
  21483. if (moduleName) {
  21484. var /** @type {?} */ reexports = this.reexports.get(moduleName);
  21485. if (!reexports) {
  21486. reexports = [];
  21487. this.reexports.set(moduleName, reexports);
  21488. }
  21489. reexports.push({ name: /** @type {?} */ ((name_1)), as: stmt.name });
  21490. return null;
  21491. }
  21492. }
  21493. if (stmt.hasModifier(StmtModifier.Exported)) {
  21494. ctx.print(stmt, "export ");
  21495. }
  21496. if (stmt.hasModifier(StmtModifier.Final)) {
  21497. ctx.print(stmt, "const");
  21498. }
  21499. else {
  21500. ctx.print(stmt, "var");
  21501. }
  21502. ctx.print(stmt, " " + stmt.name);
  21503. this._printColonType(stmt.type, ctx);
  21504. ctx.print(stmt, " = ");
  21505. stmt.value.visitExpression(this, ctx);
  21506. ctx.println(stmt, ";");
  21507. return null;
  21508. };
  21509. /**
  21510. * @param {?} ast
  21511. * @param {?} ctx
  21512. * @return {?}
  21513. */
  21514. _TsEmitterVisitor.prototype.visitCastExpr = /**
  21515. * @param {?} ast
  21516. * @param {?} ctx
  21517. * @return {?}
  21518. */
  21519. function (ast, ctx) {
  21520. ctx.print(ast, "(<"); /** @type {?} */
  21521. ((ast.type)).visitType(this, ctx);
  21522. ctx.print(ast, ">");
  21523. ast.value.visitExpression(this, ctx);
  21524. ctx.print(ast, ")");
  21525. return null;
  21526. };
  21527. /**
  21528. * @param {?} ast
  21529. * @param {?} ctx
  21530. * @return {?}
  21531. */
  21532. _TsEmitterVisitor.prototype.visitInstantiateExpr = /**
  21533. * @param {?} ast
  21534. * @param {?} ctx
  21535. * @return {?}
  21536. */
  21537. function (ast, ctx) {
  21538. ctx.print(ast, "new ");
  21539. this.typeExpression++;
  21540. ast.classExpr.visitExpression(this, ctx);
  21541. this.typeExpression--;
  21542. ctx.print(ast, "(");
  21543. this.visitAllExpressions(ast.args, ctx, ',');
  21544. ctx.print(ast, ")");
  21545. return null;
  21546. };
  21547. /**
  21548. * @param {?} stmt
  21549. * @param {?} ctx
  21550. * @return {?}
  21551. */
  21552. _TsEmitterVisitor.prototype.visitDeclareClassStmt = /**
  21553. * @param {?} stmt
  21554. * @param {?} ctx
  21555. * @return {?}
  21556. */
  21557. function (stmt, ctx) {
  21558. var _this = this;
  21559. ctx.pushClass(stmt);
  21560. if (stmt.hasModifier(StmtModifier.Exported)) {
  21561. ctx.print(stmt, "export ");
  21562. }
  21563. ctx.print(stmt, "class " + stmt.name);
  21564. if (stmt.parent != null) {
  21565. ctx.print(stmt, " extends ");
  21566. this.typeExpression++;
  21567. stmt.parent.visitExpression(this, ctx);
  21568. this.typeExpression--;
  21569. }
  21570. ctx.println(stmt, " {");
  21571. ctx.incIndent();
  21572. stmt.fields.forEach(function (field) { return _this._visitClassField(field, ctx); });
  21573. if (stmt.constructorMethod != null) {
  21574. this._visitClassConstructor(stmt, ctx);
  21575. }
  21576. stmt.getters.forEach(function (getter) { return _this._visitClassGetter(getter, ctx); });
  21577. stmt.methods.forEach(function (method) { return _this._visitClassMethod(method, ctx); });
  21578. ctx.decIndent();
  21579. ctx.println(stmt, "}");
  21580. ctx.popClass();
  21581. return null;
  21582. };
  21583. /**
  21584. * @param {?} field
  21585. * @param {?} ctx
  21586. * @return {?}
  21587. */
  21588. _TsEmitterVisitor.prototype._visitClassField = /**
  21589. * @param {?} field
  21590. * @param {?} ctx
  21591. * @return {?}
  21592. */
  21593. function (field, ctx) {
  21594. if (field.hasModifier(StmtModifier.Private)) {
  21595. // comment out as a workaround for #10967
  21596. ctx.print(null, "/*private*/ ");
  21597. }
  21598. ctx.print(null, field.name);
  21599. this._printColonType(field.type, ctx);
  21600. ctx.println(null, ";");
  21601. };
  21602. /**
  21603. * @param {?} getter
  21604. * @param {?} ctx
  21605. * @return {?}
  21606. */
  21607. _TsEmitterVisitor.prototype._visitClassGetter = /**
  21608. * @param {?} getter
  21609. * @param {?} ctx
  21610. * @return {?}
  21611. */
  21612. function (getter, ctx) {
  21613. if (getter.hasModifier(StmtModifier.Private)) {
  21614. ctx.print(null, "private ");
  21615. }
  21616. ctx.print(null, "get " + getter.name + "()");
  21617. this._printColonType(getter.type, ctx);
  21618. ctx.println(null, " {");
  21619. ctx.incIndent();
  21620. this.visitAllStatements(getter.body, ctx);
  21621. ctx.decIndent();
  21622. ctx.println(null, "}");
  21623. };
  21624. /**
  21625. * @param {?} stmt
  21626. * @param {?} ctx
  21627. * @return {?}
  21628. */
  21629. _TsEmitterVisitor.prototype._visitClassConstructor = /**
  21630. * @param {?} stmt
  21631. * @param {?} ctx
  21632. * @return {?}
  21633. */
  21634. function (stmt, ctx) {
  21635. ctx.print(stmt, "constructor(");
  21636. this._visitParams(stmt.constructorMethod.params, ctx);
  21637. ctx.println(stmt, ") {");
  21638. ctx.incIndent();
  21639. this.visitAllStatements(stmt.constructorMethod.body, ctx);
  21640. ctx.decIndent();
  21641. ctx.println(stmt, "}");
  21642. };
  21643. /**
  21644. * @param {?} method
  21645. * @param {?} ctx
  21646. * @return {?}
  21647. */
  21648. _TsEmitterVisitor.prototype._visitClassMethod = /**
  21649. * @param {?} method
  21650. * @param {?} ctx
  21651. * @return {?}
  21652. */
  21653. function (method, ctx) {
  21654. if (method.hasModifier(StmtModifier.Private)) {
  21655. ctx.print(null, "private ");
  21656. }
  21657. ctx.print(null, method.name + "(");
  21658. this._visitParams(method.params, ctx);
  21659. ctx.print(null, ")");
  21660. this._printColonType(method.type, ctx, 'void');
  21661. ctx.println(null, " {");
  21662. ctx.incIndent();
  21663. this.visitAllStatements(method.body, ctx);
  21664. ctx.decIndent();
  21665. ctx.println(null, "}");
  21666. };
  21667. /**
  21668. * @param {?} ast
  21669. * @param {?} ctx
  21670. * @return {?}
  21671. */
  21672. _TsEmitterVisitor.prototype.visitFunctionExpr = /**
  21673. * @param {?} ast
  21674. * @param {?} ctx
  21675. * @return {?}
  21676. */
  21677. function (ast, ctx) {
  21678. ctx.print(ast, "(");
  21679. this._visitParams(ast.params, ctx);
  21680. ctx.print(ast, ")");
  21681. this._printColonType(ast.type, ctx, 'void');
  21682. ctx.println(ast, " => {");
  21683. ctx.incIndent();
  21684. this.visitAllStatements(ast.statements, ctx);
  21685. ctx.decIndent();
  21686. ctx.print(ast, "}");
  21687. return null;
  21688. };
  21689. /**
  21690. * @param {?} stmt
  21691. * @param {?} ctx
  21692. * @return {?}
  21693. */
  21694. _TsEmitterVisitor.prototype.visitDeclareFunctionStmt = /**
  21695. * @param {?} stmt
  21696. * @param {?} ctx
  21697. * @return {?}
  21698. */
  21699. function (stmt, ctx) {
  21700. if (stmt.hasModifier(StmtModifier.Exported)) {
  21701. ctx.print(stmt, "export ");
  21702. }
  21703. ctx.print(stmt, "function " + stmt.name + "(");
  21704. this._visitParams(stmt.params, ctx);
  21705. ctx.print(stmt, ")");
  21706. this._printColonType(stmt.type, ctx, 'void');
  21707. ctx.println(stmt, " {");
  21708. ctx.incIndent();
  21709. this.visitAllStatements(stmt.statements, ctx);
  21710. ctx.decIndent();
  21711. ctx.println(stmt, "}");
  21712. return null;
  21713. };
  21714. /**
  21715. * @param {?} stmt
  21716. * @param {?} ctx
  21717. * @return {?}
  21718. */
  21719. _TsEmitterVisitor.prototype.visitTryCatchStmt = /**
  21720. * @param {?} stmt
  21721. * @param {?} ctx
  21722. * @return {?}
  21723. */
  21724. function (stmt, ctx) {
  21725. ctx.println(stmt, "try {");
  21726. ctx.incIndent();
  21727. this.visitAllStatements(stmt.bodyStmts, ctx);
  21728. ctx.decIndent();
  21729. ctx.println(stmt, "} catch (" + CATCH_ERROR_VAR$1.name + ") {");
  21730. ctx.incIndent();
  21731. var /** @type {?} */ catchStmts = [/** @type {?} */ (CATCH_STACK_VAR$1.set(CATCH_ERROR_VAR$1.prop('stack', null)).toDeclStmt(null, [
  21732. StmtModifier.Final
  21733. ]))].concat(stmt.catchStmts);
  21734. this.visitAllStatements(catchStmts, ctx);
  21735. ctx.decIndent();
  21736. ctx.println(stmt, "}");
  21737. return null;
  21738. };
  21739. /**
  21740. * @param {?} type
  21741. * @param {?} ctx
  21742. * @return {?}
  21743. */
  21744. _TsEmitterVisitor.prototype.visitBuiltintType = /**
  21745. * @param {?} type
  21746. * @param {?} ctx
  21747. * @return {?}
  21748. */
  21749. function (type, ctx) {
  21750. var /** @type {?} */ typeStr;
  21751. switch (type.name) {
  21752. case BuiltinTypeName.Bool:
  21753. typeStr = 'boolean';
  21754. break;
  21755. case BuiltinTypeName.Dynamic:
  21756. typeStr = 'any';
  21757. break;
  21758. case BuiltinTypeName.Function:
  21759. typeStr = 'Function';
  21760. break;
  21761. case BuiltinTypeName.Number:
  21762. typeStr = 'number';
  21763. break;
  21764. case BuiltinTypeName.Int:
  21765. typeStr = 'number';
  21766. break;
  21767. case BuiltinTypeName.String:
  21768. typeStr = 'string';
  21769. break;
  21770. default:
  21771. throw new Error("Unsupported builtin type " + type.name);
  21772. }
  21773. ctx.print(null, typeStr);
  21774. return null;
  21775. };
  21776. /**
  21777. * @param {?} ast
  21778. * @param {?} ctx
  21779. * @return {?}
  21780. */
  21781. _TsEmitterVisitor.prototype.visitExpressionType = /**
  21782. * @param {?} ast
  21783. * @param {?} ctx
  21784. * @return {?}
  21785. */
  21786. function (ast, ctx) {
  21787. ast.value.visitExpression(this, ctx);
  21788. return null;
  21789. };
  21790. /**
  21791. * @param {?} type
  21792. * @param {?} ctx
  21793. * @return {?}
  21794. */
  21795. _TsEmitterVisitor.prototype.visitArrayType = /**
  21796. * @param {?} type
  21797. * @param {?} ctx
  21798. * @return {?}
  21799. */
  21800. function (type, ctx) {
  21801. this.visitType(type.of, ctx);
  21802. ctx.print(null, "[]");
  21803. return null;
  21804. };
  21805. /**
  21806. * @param {?} type
  21807. * @param {?} ctx
  21808. * @return {?}
  21809. */
  21810. _TsEmitterVisitor.prototype.visitMapType = /**
  21811. * @param {?} type
  21812. * @param {?} ctx
  21813. * @return {?}
  21814. */
  21815. function (type, ctx) {
  21816. ctx.print(null, "{[key: string]:");
  21817. this.visitType(type.valueType, ctx);
  21818. ctx.print(null, "}");
  21819. return null;
  21820. };
  21821. /**
  21822. * @param {?} method
  21823. * @return {?}
  21824. */
  21825. _TsEmitterVisitor.prototype.getBuiltinMethodName = /**
  21826. * @param {?} method
  21827. * @return {?}
  21828. */
  21829. function (method) {
  21830. var /** @type {?} */ name;
  21831. switch (method) {
  21832. case BuiltinMethod.ConcatArray:
  21833. name = 'concat';
  21834. break;
  21835. case BuiltinMethod.SubscribeObservable:
  21836. name = 'subscribe';
  21837. break;
  21838. case BuiltinMethod.Bind:
  21839. name = 'bind';
  21840. break;
  21841. default:
  21842. throw new Error("Unknown builtin method: " + method);
  21843. }
  21844. return name;
  21845. };
  21846. /**
  21847. * @param {?} params
  21848. * @param {?} ctx
  21849. * @return {?}
  21850. */
  21851. _TsEmitterVisitor.prototype._visitParams = /**
  21852. * @param {?} params
  21853. * @param {?} ctx
  21854. * @return {?}
  21855. */
  21856. function (params, ctx) {
  21857. var _this = this;
  21858. this.visitAllObjects(function (param) {
  21859. ctx.print(null, param.name);
  21860. _this._printColonType(param.type, ctx);
  21861. }, params, ctx, ',');
  21862. };
  21863. /**
  21864. * @param {?} value
  21865. * @param {?} typeParams
  21866. * @param {?} ctx
  21867. * @return {?}
  21868. */
  21869. _TsEmitterVisitor.prototype._visitIdentifier = /**
  21870. * @param {?} value
  21871. * @param {?} typeParams
  21872. * @param {?} ctx
  21873. * @return {?}
  21874. */
  21875. function (value, typeParams, ctx) {
  21876. var _this = this;
  21877. var name = value.name, moduleName = value.moduleName;
  21878. if (this.referenceFilter && this.referenceFilter(value)) {
  21879. ctx.print(null, '(null as any)');
  21880. return;
  21881. }
  21882. if (moduleName) {
  21883. var /** @type {?} */ prefix = this.importsWithPrefixes.get(moduleName);
  21884. if (prefix == null) {
  21885. prefix = "i" + this.importsWithPrefixes.size;
  21886. this.importsWithPrefixes.set(moduleName, prefix);
  21887. }
  21888. ctx.print(null, prefix + ".");
  21889. }
  21890. ctx.print(null, /** @type {?} */ ((name)));
  21891. if (this.typeExpression > 0) {
  21892. // If we are in a type expression that refers to a generic type then supply
  21893. // the required type parameters. If there were not enough type parameters
  21894. // supplied, supply any as the type. Outside a type expression the reference
  21895. // should not supply type parameters and be treated as a simple value reference
  21896. // to the constructor function itself.
  21897. var /** @type {?} */ suppliedParameters = typeParams || [];
  21898. if (suppliedParameters.length > 0) {
  21899. ctx.print(null, "<");
  21900. this.visitAllObjects(function (type) { return type.visitType(_this, ctx); }, /** @type {?} */ ((typeParams)), ctx, ',');
  21901. ctx.print(null, ">");
  21902. }
  21903. }
  21904. };
  21905. /**
  21906. * @param {?} type
  21907. * @param {?} ctx
  21908. * @param {?=} defaultType
  21909. * @return {?}
  21910. */
  21911. _TsEmitterVisitor.prototype._printColonType = /**
  21912. * @param {?} type
  21913. * @param {?} ctx
  21914. * @param {?=} defaultType
  21915. * @return {?}
  21916. */
  21917. function (type, ctx, defaultType) {
  21918. if (type !== INFERRED_TYPE) {
  21919. ctx.print(null, ':');
  21920. this.visitType(type, ctx, defaultType);
  21921. }
  21922. };
  21923. return _TsEmitterVisitor;
  21924. }(AbstractEmitterVisitor));
  21925. /**
  21926. * @fileoverview added by tsickle
  21927. * @suppress {checkTypes} checked by tsc
  21928. */
  21929. /**
  21930. * @license
  21931. * Copyright Google Inc. All Rights Reserved.
  21932. *
  21933. * Use of this source code is governed by an MIT-style license that can be
  21934. * found in the LICENSE file at https://angular.io/license
  21935. */
  21936. /**
  21937. * Resolve a `Type` for {\@link Pipe}.
  21938. *
  21939. * This interface can be overridden by the application developer to create custom behavior.
  21940. *
  21941. * See {\@link Compiler}
  21942. */
  21943. var PipeResolver = /** @class */ (function () {
  21944. function PipeResolver(_reflector) {
  21945. this._reflector = _reflector;
  21946. }
  21947. /**
  21948. * @param {?} type
  21949. * @return {?}
  21950. */
  21951. PipeResolver.prototype.isPipe = /**
  21952. * @param {?} type
  21953. * @return {?}
  21954. */
  21955. function (type) {
  21956. var /** @type {?} */ typeMetadata = this._reflector.annotations(resolveForwardRef(type));
  21957. return typeMetadata && typeMetadata.some(createPipe.isTypeOf);
  21958. };
  21959. /**
  21960. * Return {@link Pipe} for a given `Type`.
  21961. */
  21962. /**
  21963. * Return {\@link Pipe} for a given `Type`.
  21964. * @param {?} type
  21965. * @param {?=} throwIfNotFound
  21966. * @return {?}
  21967. */
  21968. PipeResolver.prototype.resolve = /**
  21969. * Return {\@link Pipe} for a given `Type`.
  21970. * @param {?} type
  21971. * @param {?=} throwIfNotFound
  21972. * @return {?}
  21973. */
  21974. function (type, throwIfNotFound) {
  21975. if (throwIfNotFound === void 0) { throwIfNotFound = true; }
  21976. var /** @type {?} */ metas = this._reflector.annotations(resolveForwardRef(type));
  21977. if (metas) {
  21978. var /** @type {?} */ annotation = findLast(metas, createPipe.isTypeOf);
  21979. if (annotation) {
  21980. return annotation;
  21981. }
  21982. }
  21983. if (throwIfNotFound) {
  21984. throw new Error("No Pipe decorator found on " + stringify(type));
  21985. }
  21986. return null;
  21987. };
  21988. return PipeResolver;
  21989. }());
  21990. /**
  21991. * @fileoverview added by tsickle
  21992. * @suppress {checkTypes} checked by tsc
  21993. */
  21994. /**
  21995. * @license
  21996. * Copyright Google Inc. All Rights Reserved.
  21997. *
  21998. * Use of this source code is governed by an MIT-style license that can be
  21999. * found in the LICENSE file at https://angular.io/license
  22000. */
  22001. /**
  22002. * Map from tagName|propertyName SecurityContext. Properties applying to all tags use '*'.
  22003. */
  22004. var SECURITY_SCHEMA = {};
  22005. /**
  22006. * @param {?} ctx
  22007. * @param {?} specs
  22008. * @return {?}
  22009. */
  22010. function registerContext(ctx, specs) {
  22011. for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) {
  22012. var spec = specs_1[_i];
  22013. SECURITY_SCHEMA[spec.toLowerCase()] = ctx;
  22014. }
  22015. }
  22016. // Case is insignificant below, all element and attribute names are lower-cased for lookup.
  22017. registerContext(SecurityContext.HTML, [
  22018. 'iframe|srcdoc',
  22019. '*|innerHTML',
  22020. '*|outerHTML',
  22021. ]);
  22022. registerContext(SecurityContext.STYLE, ['*|style']);
  22023. // NB: no SCRIPT contexts here, they are never allowed due to the parser stripping them.
  22024. registerContext(SecurityContext.URL, [
  22025. '*|formAction', 'area|href', 'area|ping', 'audio|src', 'a|href',
  22026. 'a|ping', 'blockquote|cite', 'body|background', 'del|cite', 'form|action',
  22027. 'img|src', 'img|srcset', 'input|src', 'ins|cite', 'q|cite',
  22028. 'source|src', 'source|srcset', 'track|src', 'video|poster', 'video|src',
  22029. ]);
  22030. registerContext(SecurityContext.RESOURCE_URL, [
  22031. 'applet|code',
  22032. 'applet|codebase',
  22033. 'base|href',
  22034. 'embed|src',
  22035. 'frame|src',
  22036. 'head|profile',
  22037. 'html|manifest',
  22038. 'iframe|src',
  22039. 'link|href',
  22040. 'media|src',
  22041. 'object|codebase',
  22042. 'object|data',
  22043. 'script|src',
  22044. ]);
  22045. /**
  22046. * @fileoverview added by tsickle
  22047. * @suppress {checkTypes} checked by tsc
  22048. */
  22049. /**
  22050. * @license
  22051. * Copyright Google Inc. All Rights Reserved.
  22052. *
  22053. * Use of this source code is governed by an MIT-style license that can be
  22054. * found in the LICENSE file at https://angular.io/license
  22055. */
  22056. /**
  22057. * @abstract
  22058. */
  22059. var ElementSchemaRegistry = /** @class */ (function () {
  22060. function ElementSchemaRegistry() {
  22061. }
  22062. return ElementSchemaRegistry;
  22063. }());
  22064. /**
  22065. * @fileoverview added by tsickle
  22066. * @suppress {checkTypes} checked by tsc
  22067. */
  22068. /**
  22069. * @license
  22070. * Copyright Google Inc. All Rights Reserved.
  22071. *
  22072. * Use of this source code is governed by an MIT-style license that can be
  22073. * found in the LICENSE file at https://angular.io/license
  22074. */
  22075. var BOOLEAN = 'boolean';
  22076. var NUMBER = 'number';
  22077. var STRING = 'string';
  22078. var OBJECT = 'object';
  22079. /**
  22080. * This array represents the DOM schema. It encodes inheritance, properties, and events.
  22081. *
  22082. * ## Overview
  22083. *
  22084. * Each line represents one kind of element. The `element_inheritance` and properties are joined
  22085. * using `element_inheritance|properties` syntax.
  22086. *
  22087. * ## Element Inheritance
  22088. *
  22089. * The `element_inheritance` can be further subdivided as `element1,element2,...^parentElement`.
  22090. * Here the individual elements are separated by `,` (commas). Every element in the list
  22091. * has identical properties.
  22092. *
  22093. * An `element` may inherit additional properties from `parentElement` If no `^parentElement` is
  22094. * specified then `""` (blank) element is assumed.
  22095. *
  22096. * NOTE: The blank element inherits from root `[Element]` element, the super element of all
  22097. * elements.
  22098. *
  22099. * NOTE an element prefix such as `:svg:` has no special meaning to the schema.
  22100. *
  22101. * ## Properties
  22102. *
  22103. * Each element has a set of properties separated by `,` (commas). Each property can be prefixed
  22104. * by a special character designating its type:
  22105. *
  22106. * - (no prefix): property is a string.
  22107. * - `*`: property represents an event.
  22108. * - `!`: property is a boolean.
  22109. * - `#`: property is a number.
  22110. * - `%`: property is an object.
  22111. *
  22112. * ## Query
  22113. *
  22114. * The class creates an internal squas representation which allows to easily answer the query of
  22115. * if a given property exist on a given element.
  22116. *
  22117. * NOTE: We don't yet support querying for types or events.
  22118. * NOTE: This schema is auto extracted from `schema_extractor.ts` located in the test folder,
  22119. * see dom_element_schema_registry_spec.ts
  22120. */
  22121. var SCHEMA = [
  22122. '[Element]|textContent,%classList,className,id,innerHTML,*beforecopy,*beforecut,*beforepaste,*copy,*cut,*paste,*search,*selectstart,*webkitfullscreenchange,*webkitfullscreenerror,*wheel,outerHTML,#scrollLeft,#scrollTop,slot' +
  22123. ',*message,*mozfullscreenchange,*mozfullscreenerror,*mozpointerlockchange,*mozpointerlockerror,*webglcontextcreationerror,*webglcontextlost,*webglcontextrestored',
  22124. '[HTMLElement]^[Element]|accessKey,contentEditable,dir,!draggable,!hidden,innerText,lang,*abort,*auxclick,*blur,*cancel,*canplay,*canplaythrough,*change,*click,*close,*contextmenu,*cuechange,*dblclick,*drag,*dragend,*dragenter,*dragleave,*dragover,*dragstart,*drop,*durationchange,*emptied,*ended,*error,*focus,*gotpointercapture,*input,*invalid,*keydown,*keypress,*keyup,*load,*loadeddata,*loadedmetadata,*loadstart,*lostpointercapture,*mousedown,*mouseenter,*mouseleave,*mousemove,*mouseout,*mouseover,*mouseup,*mousewheel,*pause,*play,*playing,*pointercancel,*pointerdown,*pointerenter,*pointerleave,*pointermove,*pointerout,*pointerover,*pointerup,*progress,*ratechange,*reset,*resize,*scroll,*seeked,*seeking,*select,*show,*stalled,*submit,*suspend,*timeupdate,*toggle,*volumechange,*waiting,outerText,!spellcheck,%style,#tabIndex,title,!translate',
  22125. 'abbr,address,article,aside,b,bdi,bdo,cite,code,dd,dfn,dt,em,figcaption,figure,footer,header,i,kbd,main,mark,nav,noscript,rb,rp,rt,rtc,ruby,s,samp,section,small,strong,sub,sup,u,var,wbr^[HTMLElement]|accessKey,contentEditable,dir,!draggable,!hidden,innerText,lang,*abort,*auxclick,*blur,*cancel,*canplay,*canplaythrough,*change,*click,*close,*contextmenu,*cuechange,*dblclick,*drag,*dragend,*dragenter,*dragleave,*dragover,*dragstart,*drop,*durationchange,*emptied,*ended,*error,*focus,*gotpointercapture,*input,*invalid,*keydown,*keypress,*keyup,*load,*loadeddata,*loadedmetadata,*loadstart,*lostpointercapture,*mousedown,*mouseenter,*mouseleave,*mousemove,*mouseout,*mouseover,*mouseup,*mousewheel,*pause,*play,*playing,*pointercancel,*pointerdown,*pointerenter,*pointerleave,*pointermove,*pointerout,*pointerover,*pointerup,*progress,*ratechange,*reset,*resize,*scroll,*seeked,*seeking,*select,*show,*stalled,*submit,*suspend,*timeupdate,*toggle,*volumechange,*waiting,outerText,!spellcheck,%style,#tabIndex,title,!translate',
  22126. 'media^[HTMLElement]|!autoplay,!controls,%controlsList,%crossOrigin,#currentTime,!defaultMuted,#defaultPlaybackRate,!disableRemotePlayback,!loop,!muted,*encrypted,*waitingforkey,#playbackRate,preload,src,%srcObject,#volume',
  22127. ':svg:^[HTMLElement]|*abort,*auxclick,*blur,*cancel,*canplay,*canplaythrough,*change,*click,*close,*contextmenu,*cuechange,*dblclick,*drag,*dragend,*dragenter,*dragleave,*dragover,*dragstart,*drop,*durationchange,*emptied,*ended,*error,*focus,*gotpointercapture,*input,*invalid,*keydown,*keypress,*keyup,*load,*loadeddata,*loadedmetadata,*loadstart,*lostpointercapture,*mousedown,*mouseenter,*mouseleave,*mousemove,*mouseout,*mouseover,*mouseup,*mousewheel,*pause,*play,*playing,*pointercancel,*pointerdown,*pointerenter,*pointerleave,*pointermove,*pointerout,*pointerover,*pointerup,*progress,*ratechange,*reset,*resize,*scroll,*seeked,*seeking,*select,*show,*stalled,*submit,*suspend,*timeupdate,*toggle,*volumechange,*waiting,%style,#tabIndex',
  22128. ':svg:graphics^:svg:|',
  22129. ':svg:animation^:svg:|*begin,*end,*repeat',
  22130. ':svg:geometry^:svg:|',
  22131. ':svg:componentTransferFunction^:svg:|',
  22132. ':svg:gradient^:svg:|',
  22133. ':svg:textContent^:svg:graphics|',
  22134. ':svg:textPositioning^:svg:textContent|',
  22135. 'a^[HTMLElement]|charset,coords,download,hash,host,hostname,href,hreflang,name,password,pathname,ping,port,protocol,referrerPolicy,rel,rev,search,shape,target,text,type,username',
  22136. 'area^[HTMLElement]|alt,coords,download,hash,host,hostname,href,!noHref,password,pathname,ping,port,protocol,referrerPolicy,rel,search,shape,target,username',
  22137. 'audio^media|',
  22138. 'br^[HTMLElement]|clear',
  22139. 'base^[HTMLElement]|href,target',
  22140. 'body^[HTMLElement]|aLink,background,bgColor,link,*beforeunload,*blur,*error,*focus,*hashchange,*languagechange,*load,*message,*offline,*online,*pagehide,*pageshow,*popstate,*rejectionhandled,*resize,*scroll,*storage,*unhandledrejection,*unload,text,vLink',
  22141. 'button^[HTMLElement]|!autofocus,!disabled,formAction,formEnctype,formMethod,!formNoValidate,formTarget,name,type,value',
  22142. 'canvas^[HTMLElement]|#height,#width',
  22143. 'content^[HTMLElement]|select',
  22144. 'dl^[HTMLElement]|!compact',
  22145. 'datalist^[HTMLElement]|',
  22146. 'details^[HTMLElement]|!open',
  22147. 'dialog^[HTMLElement]|!open,returnValue',
  22148. 'dir^[HTMLElement]|!compact',
  22149. 'div^[HTMLElement]|align',
  22150. 'embed^[HTMLElement]|align,height,name,src,type,width',
  22151. 'fieldset^[HTMLElement]|!disabled,name',
  22152. 'font^[HTMLElement]|color,face,size',
  22153. 'form^[HTMLElement]|acceptCharset,action,autocomplete,encoding,enctype,method,name,!noValidate,target',
  22154. 'frame^[HTMLElement]|frameBorder,longDesc,marginHeight,marginWidth,name,!noResize,scrolling,src',
  22155. 'frameset^[HTMLElement]|cols,*beforeunload,*blur,*error,*focus,*hashchange,*languagechange,*load,*message,*offline,*online,*pagehide,*pageshow,*popstate,*rejectionhandled,*resize,*scroll,*storage,*unhandledrejection,*unload,rows',
  22156. 'hr^[HTMLElement]|align,color,!noShade,size,width',
  22157. 'head^[HTMLElement]|',
  22158. 'h1,h2,h3,h4,h5,h6^[HTMLElement]|align',
  22159. 'html^[HTMLElement]|version',
  22160. 'iframe^[HTMLElement]|align,!allowFullscreen,frameBorder,height,longDesc,marginHeight,marginWidth,name,referrerPolicy,%sandbox,scrolling,src,srcdoc,width',
  22161. 'img^[HTMLElement]|align,alt,border,%crossOrigin,#height,#hspace,!isMap,longDesc,lowsrc,name,referrerPolicy,sizes,src,srcset,useMap,#vspace,#width',
  22162. 'input^[HTMLElement]|accept,align,alt,autocapitalize,autocomplete,!autofocus,!checked,!defaultChecked,defaultValue,dirName,!disabled,%files,formAction,formEnctype,formMethod,!formNoValidate,formTarget,#height,!incremental,!indeterminate,max,#maxLength,min,#minLength,!multiple,name,pattern,placeholder,!readOnly,!required,selectionDirection,#selectionEnd,#selectionStart,#size,src,step,type,useMap,value,%valueAsDate,#valueAsNumber,#width',
  22163. 'li^[HTMLElement]|type,#value',
  22164. 'label^[HTMLElement]|htmlFor',
  22165. 'legend^[HTMLElement]|align',
  22166. 'link^[HTMLElement]|as,charset,%crossOrigin,!disabled,href,hreflang,integrity,media,referrerPolicy,rel,%relList,rev,%sizes,target,type',
  22167. 'map^[HTMLElement]|name',
  22168. 'marquee^[HTMLElement]|behavior,bgColor,direction,height,#hspace,#loop,#scrollAmount,#scrollDelay,!trueSpeed,#vspace,width',
  22169. 'menu^[HTMLElement]|!compact',
  22170. 'meta^[HTMLElement]|content,httpEquiv,name,scheme',
  22171. 'meter^[HTMLElement]|#high,#low,#max,#min,#optimum,#value',
  22172. 'ins,del^[HTMLElement]|cite,dateTime',
  22173. 'ol^[HTMLElement]|!compact,!reversed,#start,type',
  22174. 'object^[HTMLElement]|align,archive,border,code,codeBase,codeType,data,!declare,height,#hspace,name,standby,type,useMap,#vspace,width',
  22175. 'optgroup^[HTMLElement]|!disabled,label',
  22176. 'option^[HTMLElement]|!defaultSelected,!disabled,label,!selected,text,value',
  22177. 'output^[HTMLElement]|defaultValue,%htmlFor,name,value',
  22178. 'p^[HTMLElement]|align',
  22179. 'param^[HTMLElement]|name,type,value,valueType',
  22180. 'picture^[HTMLElement]|',
  22181. 'pre^[HTMLElement]|#width',
  22182. 'progress^[HTMLElement]|#max,#value',
  22183. 'q,blockquote,cite^[HTMLElement]|',
  22184. 'script^[HTMLElement]|!async,charset,%crossOrigin,!defer,event,htmlFor,integrity,src,text,type',
  22185. 'select^[HTMLElement]|!autofocus,!disabled,#length,!multiple,name,!required,#selectedIndex,#size,value',
  22186. 'shadow^[HTMLElement]|',
  22187. 'slot^[HTMLElement]|name',
  22188. 'source^[HTMLElement]|media,sizes,src,srcset,type',
  22189. 'span^[HTMLElement]|',
  22190. 'style^[HTMLElement]|!disabled,media,type',
  22191. 'caption^[HTMLElement]|align',
  22192. 'th,td^[HTMLElement]|abbr,align,axis,bgColor,ch,chOff,#colSpan,headers,height,!noWrap,#rowSpan,scope,vAlign,width',
  22193. 'col,colgroup^[HTMLElement]|align,ch,chOff,#span,vAlign,width',
  22194. 'table^[HTMLElement]|align,bgColor,border,%caption,cellPadding,cellSpacing,frame,rules,summary,%tFoot,%tHead,width',
  22195. 'tr^[HTMLElement]|align,bgColor,ch,chOff,vAlign',
  22196. 'tfoot,thead,tbody^[HTMLElement]|align,ch,chOff,vAlign',
  22197. 'template^[HTMLElement]|',
  22198. 'textarea^[HTMLElement]|autocapitalize,!autofocus,#cols,defaultValue,dirName,!disabled,#maxLength,#minLength,name,placeholder,!readOnly,!required,#rows,selectionDirection,#selectionEnd,#selectionStart,value,wrap',
  22199. 'title^[HTMLElement]|text',
  22200. 'track^[HTMLElement]|!default,kind,label,src,srclang',
  22201. 'ul^[HTMLElement]|!compact,type',
  22202. 'unknown^[HTMLElement]|',
  22203. 'video^media|#height,poster,#width',
  22204. ':svg:a^:svg:graphics|',
  22205. ':svg:animate^:svg:animation|',
  22206. ':svg:animateMotion^:svg:animation|',
  22207. ':svg:animateTransform^:svg:animation|',
  22208. ':svg:circle^:svg:geometry|',
  22209. ':svg:clipPath^:svg:graphics|',
  22210. ':svg:defs^:svg:graphics|',
  22211. ':svg:desc^:svg:|',
  22212. ':svg:discard^:svg:|',
  22213. ':svg:ellipse^:svg:geometry|',
  22214. ':svg:feBlend^:svg:|',
  22215. ':svg:feColorMatrix^:svg:|',
  22216. ':svg:feComponentTransfer^:svg:|',
  22217. ':svg:feComposite^:svg:|',
  22218. ':svg:feConvolveMatrix^:svg:|',
  22219. ':svg:feDiffuseLighting^:svg:|',
  22220. ':svg:feDisplacementMap^:svg:|',
  22221. ':svg:feDistantLight^:svg:|',
  22222. ':svg:feDropShadow^:svg:|',
  22223. ':svg:feFlood^:svg:|',
  22224. ':svg:feFuncA^:svg:componentTransferFunction|',
  22225. ':svg:feFuncB^:svg:componentTransferFunction|',
  22226. ':svg:feFuncG^:svg:componentTransferFunction|',
  22227. ':svg:feFuncR^:svg:componentTransferFunction|',
  22228. ':svg:feGaussianBlur^:svg:|',
  22229. ':svg:feImage^:svg:|',
  22230. ':svg:feMerge^:svg:|',
  22231. ':svg:feMergeNode^:svg:|',
  22232. ':svg:feMorphology^:svg:|',
  22233. ':svg:feOffset^:svg:|',
  22234. ':svg:fePointLight^:svg:|',
  22235. ':svg:feSpecularLighting^:svg:|',
  22236. ':svg:feSpotLight^:svg:|',
  22237. ':svg:feTile^:svg:|',
  22238. ':svg:feTurbulence^:svg:|',
  22239. ':svg:filter^:svg:|',
  22240. ':svg:foreignObject^:svg:graphics|',
  22241. ':svg:g^:svg:graphics|',
  22242. ':svg:image^:svg:graphics|',
  22243. ':svg:line^:svg:geometry|',
  22244. ':svg:linearGradient^:svg:gradient|',
  22245. ':svg:mpath^:svg:|',
  22246. ':svg:marker^:svg:|',
  22247. ':svg:mask^:svg:|',
  22248. ':svg:metadata^:svg:|',
  22249. ':svg:path^:svg:geometry|',
  22250. ':svg:pattern^:svg:|',
  22251. ':svg:polygon^:svg:geometry|',
  22252. ':svg:polyline^:svg:geometry|',
  22253. ':svg:radialGradient^:svg:gradient|',
  22254. ':svg:rect^:svg:geometry|',
  22255. ':svg:svg^:svg:graphics|#currentScale,#zoomAndPan',
  22256. ':svg:script^:svg:|type',
  22257. ':svg:set^:svg:animation|',
  22258. ':svg:stop^:svg:|',
  22259. ':svg:style^:svg:|!disabled,media,title,type',
  22260. ':svg:switch^:svg:graphics|',
  22261. ':svg:symbol^:svg:|',
  22262. ':svg:tspan^:svg:textPositioning|',
  22263. ':svg:text^:svg:textPositioning|',
  22264. ':svg:textPath^:svg:textContent|',
  22265. ':svg:title^:svg:|',
  22266. ':svg:use^:svg:graphics|',
  22267. ':svg:view^:svg:|#zoomAndPan',
  22268. 'data^[HTMLElement]|value',
  22269. 'keygen^[HTMLElement]|!autofocus,challenge,!disabled,form,keytype,name',
  22270. 'menuitem^[HTMLElement]|type,label,icon,!disabled,!checked,radiogroup,!default',
  22271. 'summary^[HTMLElement]|',
  22272. 'time^[HTMLElement]|dateTime',
  22273. ':svg:cursor^:svg:|',
  22274. ];
  22275. var _ATTR_TO_PROP = {
  22276. 'class': 'className',
  22277. 'for': 'htmlFor',
  22278. 'formaction': 'formAction',
  22279. 'innerHtml': 'innerHTML',
  22280. 'readonly': 'readOnly',
  22281. 'tabindex': 'tabIndex',
  22282. };
  22283. var DomElementSchemaRegistry = /** @class */ (function (_super) {
  22284. __extends(DomElementSchemaRegistry, _super);
  22285. function DomElementSchemaRegistry() {
  22286. var _this = _super.call(this) || this;
  22287. _this._schema = {};
  22288. SCHEMA.forEach(function (encodedType) {
  22289. var /** @type {?} */ type = {};
  22290. var _a = encodedType.split('|'), strType = _a[0], strProperties = _a[1];
  22291. var /** @type {?} */ properties = strProperties.split(',');
  22292. var _b = strType.split('^'), typeNames = _b[0], superName = _b[1];
  22293. typeNames.split(',').forEach(function (tag) { return _this._schema[tag.toLowerCase()] = type; });
  22294. var /** @type {?} */ superType = superName && _this._schema[superName.toLowerCase()];
  22295. if (superType) {
  22296. Object.keys(superType).forEach(function (prop) { type[prop] = superType[prop]; });
  22297. }
  22298. properties.forEach(function (property) {
  22299. if (property.length > 0) {
  22300. switch (property[0]) {
  22301. case '*':
  22302. // We don't yet support events.
  22303. // If ever allowing to bind to events, GO THROUGH A SECURITY REVIEW, allowing events
  22304. // will
  22305. // almost certainly introduce bad XSS vulnerabilities.
  22306. // type[property.substring(1)] = EVENT;
  22307. break;
  22308. case '!':
  22309. type[property.substring(1)] = BOOLEAN;
  22310. break;
  22311. case '#':
  22312. type[property.substring(1)] = NUMBER;
  22313. break;
  22314. case '%':
  22315. type[property.substring(1)] = OBJECT;
  22316. break;
  22317. default:
  22318. type[property] = STRING;
  22319. }
  22320. }
  22321. });
  22322. });
  22323. return _this;
  22324. }
  22325. /**
  22326. * @param {?} tagName
  22327. * @param {?} propName
  22328. * @param {?} schemaMetas
  22329. * @return {?}
  22330. */
  22331. DomElementSchemaRegistry.prototype.hasProperty = /**
  22332. * @param {?} tagName
  22333. * @param {?} propName
  22334. * @param {?} schemaMetas
  22335. * @return {?}
  22336. */
  22337. function (tagName, propName, schemaMetas) {
  22338. if (schemaMetas.some(function (schema) { return schema.name === NO_ERRORS_SCHEMA.name; })) {
  22339. return true;
  22340. }
  22341. if (tagName.indexOf('-') > -1) {
  22342. if (isNgContainer(tagName) || isNgContent(tagName)) {
  22343. return false;
  22344. }
  22345. if (schemaMetas.some(function (schema) { return schema.name === CUSTOM_ELEMENTS_SCHEMA.name; })) {
  22346. // Can't tell now as we don't know which properties a custom element will get
  22347. // once it is instantiated
  22348. return true;
  22349. }
  22350. }
  22351. var /** @type {?} */ elementProperties = this._schema[tagName.toLowerCase()] || this._schema['unknown'];
  22352. return !!elementProperties[propName];
  22353. };
  22354. /**
  22355. * @param {?} tagName
  22356. * @param {?} schemaMetas
  22357. * @return {?}
  22358. */
  22359. DomElementSchemaRegistry.prototype.hasElement = /**
  22360. * @param {?} tagName
  22361. * @param {?} schemaMetas
  22362. * @return {?}
  22363. */
  22364. function (tagName, schemaMetas) {
  22365. if (schemaMetas.some(function (schema) { return schema.name === NO_ERRORS_SCHEMA.name; })) {
  22366. return true;
  22367. }
  22368. if (tagName.indexOf('-') > -1) {
  22369. if (isNgContainer(tagName) || isNgContent(tagName)) {
  22370. return true;
  22371. }
  22372. if (schemaMetas.some(function (schema) { return schema.name === CUSTOM_ELEMENTS_SCHEMA.name; })) {
  22373. // Allow any custom elements
  22374. return true;
  22375. }
  22376. }
  22377. return !!this._schema[tagName.toLowerCase()];
  22378. };
  22379. /**
  22380. * securityContext returns the security context for the given property on the given DOM tag.
  22381. *
  22382. * Tag and property name are statically known and cannot change at runtime, i.e. it is not
  22383. * possible to bind a value into a changing attribute or tag name.
  22384. *
  22385. * The filtering is white list based. All attributes in the schema above are assumed to have the
  22386. * 'NONE' security context, i.e. that they are safe inert string values. Only specific well known
  22387. * attack vectors are assigned their appropriate context.
  22388. */
  22389. /**
  22390. * securityContext returns the security context for the given property on the given DOM tag.
  22391. *
  22392. * Tag and property name are statically known and cannot change at runtime, i.e. it is not
  22393. * possible to bind a value into a changing attribute or tag name.
  22394. *
  22395. * The filtering is white list based. All attributes in the schema above are assumed to have the
  22396. * 'NONE' security context, i.e. that they are safe inert string values. Only specific well known
  22397. * attack vectors are assigned their appropriate context.
  22398. * @param {?} tagName
  22399. * @param {?} propName
  22400. * @param {?} isAttribute
  22401. * @return {?}
  22402. */
  22403. DomElementSchemaRegistry.prototype.securityContext = /**
  22404. * securityContext returns the security context for the given property on the given DOM tag.
  22405. *
  22406. * Tag and property name are statically known and cannot change at runtime, i.e. it is not
  22407. * possible to bind a value into a changing attribute or tag name.
  22408. *
  22409. * The filtering is white list based. All attributes in the schema above are assumed to have the
  22410. * 'NONE' security context, i.e. that they are safe inert string values. Only specific well known
  22411. * attack vectors are assigned their appropriate context.
  22412. * @param {?} tagName
  22413. * @param {?} propName
  22414. * @param {?} isAttribute
  22415. * @return {?}
  22416. */
  22417. function (tagName, propName, isAttribute) {
  22418. if (isAttribute) {
  22419. // NB: For security purposes, use the mapped property name, not the attribute name.
  22420. propName = this.getMappedPropName(propName);
  22421. }
  22422. // Make sure comparisons are case insensitive, so that case differences between attribute and
  22423. // property names do not have a security impact.
  22424. tagName = tagName.toLowerCase();
  22425. propName = propName.toLowerCase();
  22426. var /** @type {?} */ ctx = SECURITY_SCHEMA[tagName + '|' + propName];
  22427. if (ctx) {
  22428. return ctx;
  22429. }
  22430. ctx = SECURITY_SCHEMA['*|' + propName];
  22431. return ctx ? ctx : SecurityContext.NONE;
  22432. };
  22433. /**
  22434. * @param {?} propName
  22435. * @return {?}
  22436. */
  22437. DomElementSchemaRegistry.prototype.getMappedPropName = /**
  22438. * @param {?} propName
  22439. * @return {?}
  22440. */
  22441. function (propName) { return _ATTR_TO_PROP[propName] || propName; };
  22442. /**
  22443. * @return {?}
  22444. */
  22445. DomElementSchemaRegistry.prototype.getDefaultComponentElementName = /**
  22446. * @return {?}
  22447. */
  22448. function () { return 'ng-component'; };
  22449. /**
  22450. * @param {?} name
  22451. * @return {?}
  22452. */
  22453. DomElementSchemaRegistry.prototype.validateProperty = /**
  22454. * @param {?} name
  22455. * @return {?}
  22456. */
  22457. function (name) {
  22458. if (name.toLowerCase().startsWith('on')) {
  22459. var /** @type {?} */ msg = "Binding to event property '" + name + "' is disallowed for security reasons, " +
  22460. ("please use (" + name.slice(2) + ")=...") +
  22461. ("\nIf '" + name + "' is a directive input, make sure the directive is imported by the") +
  22462. " current module.";
  22463. return { error: true, msg: msg };
  22464. }
  22465. else {
  22466. return { error: false };
  22467. }
  22468. };
  22469. /**
  22470. * @param {?} name
  22471. * @return {?}
  22472. */
  22473. DomElementSchemaRegistry.prototype.validateAttribute = /**
  22474. * @param {?} name
  22475. * @return {?}
  22476. */
  22477. function (name) {
  22478. if (name.toLowerCase().startsWith('on')) {
  22479. var /** @type {?} */ msg = "Binding to event attribute '" + name + "' is disallowed for security reasons, " +
  22480. ("please use (" + name.slice(2) + ")=...");
  22481. return { error: true, msg: msg };
  22482. }
  22483. else {
  22484. return { error: false };
  22485. }
  22486. };
  22487. /**
  22488. * @return {?}
  22489. */
  22490. DomElementSchemaRegistry.prototype.allKnownElementNames = /**
  22491. * @return {?}
  22492. */
  22493. function () { return Object.keys(this._schema); };
  22494. /**
  22495. * @param {?} propName
  22496. * @return {?}
  22497. */
  22498. DomElementSchemaRegistry.prototype.normalizeAnimationStyleProperty = /**
  22499. * @param {?} propName
  22500. * @return {?}
  22501. */
  22502. function (propName) {
  22503. return dashCaseToCamelCase(propName);
  22504. };
  22505. /**
  22506. * @param {?} camelCaseProp
  22507. * @param {?} userProvidedProp
  22508. * @param {?} val
  22509. * @return {?}
  22510. */
  22511. DomElementSchemaRegistry.prototype.normalizeAnimationStyleValue = /**
  22512. * @param {?} camelCaseProp
  22513. * @param {?} userProvidedProp
  22514. * @param {?} val
  22515. * @return {?}
  22516. */
  22517. function (camelCaseProp, userProvidedProp, val) {
  22518. var /** @type {?} */ unit = '';
  22519. var /** @type {?} */ strVal = val.toString().trim();
  22520. var /** @type {?} */ errorMsg = /** @type {?} */ ((null));
  22521. if (_isPixelDimensionStyle(camelCaseProp) && val !== 0 && val !== '0') {
  22522. if (typeof val === 'number') {
  22523. unit = 'px';
  22524. }
  22525. else {
  22526. var /** @type {?} */ valAndSuffixMatch = val.match(/^[+-]?[\d\.]+([a-z]*)$/);
  22527. if (valAndSuffixMatch && valAndSuffixMatch[1].length == 0) {
  22528. errorMsg = "Please provide a CSS unit value for " + userProvidedProp + ":" + val;
  22529. }
  22530. }
  22531. }
  22532. return { error: errorMsg, value: strVal + unit };
  22533. };
  22534. return DomElementSchemaRegistry;
  22535. }(ElementSchemaRegistry));
  22536. /**
  22537. * @param {?} prop
  22538. * @return {?}
  22539. */
  22540. function _isPixelDimensionStyle(prop) {
  22541. switch (prop) {
  22542. case 'width':
  22543. case 'height':
  22544. case 'minWidth':
  22545. case 'minHeight':
  22546. case 'maxWidth':
  22547. case 'maxHeight':
  22548. case 'left':
  22549. case 'top':
  22550. case 'bottom':
  22551. case 'right':
  22552. case 'fontSize':
  22553. case 'outlineWidth':
  22554. case 'outlineOffset':
  22555. case 'paddingTop':
  22556. case 'paddingLeft':
  22557. case 'paddingBottom':
  22558. case 'paddingRight':
  22559. case 'marginTop':
  22560. case 'marginLeft':
  22561. case 'marginBottom':
  22562. case 'marginRight':
  22563. case 'borderRadius':
  22564. case 'borderWidth':
  22565. case 'borderTopWidth':
  22566. case 'borderLeftWidth':
  22567. case 'borderRightWidth':
  22568. case 'borderBottomWidth':
  22569. case 'textIndent':
  22570. return true;
  22571. default:
  22572. return false;
  22573. }
  22574. }
  22575. /**
  22576. * @fileoverview added by tsickle
  22577. * @suppress {checkTypes} checked by tsc
  22578. */
  22579. /**
  22580. * @license
  22581. * Copyright Google Inc. All Rights Reserved.
  22582. *
  22583. * Use of this source code is governed by an MIT-style license that can be
  22584. * found in the LICENSE file at https://angular.io/license
  22585. */
  22586. /**
  22587. * This file is a port of shadowCSS from webcomponents.js to TypeScript.
  22588. *
  22589. * Please make sure to keep to edits in sync with the source file.
  22590. *
  22591. * Source:
  22592. * https://github.com/webcomponents/webcomponentsjs/blob/4efecd7e0e/src/ShadowCSS/ShadowCSS.js
  22593. *
  22594. * The original file level comment is reproduced below
  22595. */
  22596. /*
  22597. This is a limited shim for ShadowDOM css styling.
  22598. https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#styles
  22599. The intention here is to support only the styling features which can be
  22600. relatively simply implemented. The goal is to allow users to avoid the
  22601. most obvious pitfalls and do so without compromising performance significantly.
  22602. For ShadowDOM styling that's not covered here, a set of best practices
  22603. can be provided that should allow users to accomplish more complex styling.
  22604. The following is a list of specific ShadowDOM styling features and a brief
  22605. discussion of the approach used to shim.
  22606. Shimmed features:
  22607. * :host, :host-context: ShadowDOM allows styling of the shadowRoot's host
  22608. element using the :host rule. To shim this feature, the :host styles are
  22609. reformatted and prefixed with a given scope name and promoted to a
  22610. document level stylesheet.
  22611. For example, given a scope name of .foo, a rule like this:
  22612. :host {
  22613. background: red;
  22614. }
  22615. }
  22616. becomes:
  22617. .foo {
  22618. background: red;
  22619. }
  22620. * encapsulation: Styles defined within ShadowDOM, apply only to
  22621. dom inside the ShadowDOM. Polymer uses one of two techniques to implement
  22622. this feature.
  22623. By default, rules are prefixed with the host element tag name
  22624. as a descendant selector. This ensures styling does not leak out of the 'top'
  22625. of the element's ShadowDOM. For example,
  22626. div {
  22627. font-weight: bold;
  22628. }
  22629. becomes:
  22630. x-foo div {
  22631. font-weight: bold;
  22632. }
  22633. becomes:
  22634. Alternatively, if WebComponents.ShadowCSS.strictStyling is set to true then
  22635. selectors are scoped by adding an attribute selector suffix to each
  22636. simple selector that contains the host element tag name. Each element
  22637. in the element's ShadowDOM template is also given the scope attribute.
  22638. Thus, these rules match only elements that have the scope attribute.
  22639. For example, given a scope name of x-foo, a rule like this:
  22640. div {
  22641. font-weight: bold;
  22642. }
  22643. becomes:
  22644. div[x-foo] {
  22645. font-weight: bold;
  22646. }
  22647. Note that elements that are dynamically added to a scope must have the scope
  22648. selector added to them manually.
  22649. * upper/lower bound encapsulation: Styles which are defined outside a
  22650. shadowRoot should not cross the ShadowDOM boundary and should not apply
  22651. inside a shadowRoot.
  22652. This styling behavior is not emulated. Some possible ways to do this that
  22653. were rejected due to complexity and/or performance concerns include: (1) reset
  22654. every possible property for every possible selector for a given scope name;
  22655. (2) re-implement css in javascript.
  22656. As an alternative, users should make sure to use selectors
  22657. specific to the scope in which they are working.
  22658. * ::distributed: This behavior is not emulated. It's often not necessary
  22659. to style the contents of a specific insertion point and instead, descendants
  22660. of the host element can be styled selectively. Users can also create an
  22661. extra node around an insertion point and style that node's contents
  22662. via descendent selectors. For example, with a shadowRoot like this:
  22663. <style>
  22664. ::content(div) {
  22665. background: red;
  22666. }
  22667. </style>
  22668. <content></content>
  22669. could become:
  22670. <style>
  22671. / *@polyfill .content-container div * /
  22672. ::content(div) {
  22673. background: red;
  22674. }
  22675. </style>
  22676. <div class="content-container">
  22677. <content></content>
  22678. </div>
  22679. Note the use of @polyfill in the comment above a ShadowDOM specific style
  22680. declaration. This is a directive to the styling shim to use the selector
  22681. in comments in lieu of the next selector when running under polyfill.
  22682. */
  22683. var ShadowCss = /** @class */ (function () {
  22684. function ShadowCss() {
  22685. this.strictStyling = true;
  22686. }
  22687. /*
  22688. * Shim some cssText with the given selector. Returns cssText that can
  22689. * be included in the document via WebComponents.ShadowCSS.addCssToDocument(css).
  22690. *
  22691. * When strictStyling is true:
  22692. * - selector is the attribute added to all elements inside the host,
  22693. * - hostSelector is the attribute added to the host itself.
  22694. */
  22695. /**
  22696. * @param {?} cssText
  22697. * @param {?} selector
  22698. * @param {?=} hostSelector
  22699. * @return {?}
  22700. */
  22701. ShadowCss.prototype.shimCssText = /**
  22702. * @param {?} cssText
  22703. * @param {?} selector
  22704. * @param {?=} hostSelector
  22705. * @return {?}
  22706. */
  22707. function (cssText, selector, hostSelector) {
  22708. if (hostSelector === void 0) { hostSelector = ''; }
  22709. var /** @type {?} */ commentsWithHash = extractCommentsWithHash(cssText);
  22710. cssText = stripComments(cssText);
  22711. cssText = this._insertDirectives(cssText);
  22712. var /** @type {?} */ scopedCssText = this._scopeCssText(cssText, selector, hostSelector);
  22713. return [scopedCssText].concat(commentsWithHash).join('\n');
  22714. };
  22715. /**
  22716. * @param {?} cssText
  22717. * @return {?}
  22718. */
  22719. ShadowCss.prototype._insertDirectives = /**
  22720. * @param {?} cssText
  22721. * @return {?}
  22722. */
  22723. function (cssText) {
  22724. cssText = this._insertPolyfillDirectivesInCssText(cssText);
  22725. return this._insertPolyfillRulesInCssText(cssText);
  22726. };
  22727. /**
  22728. * @param {?} cssText
  22729. * @return {?}
  22730. */
  22731. ShadowCss.prototype._insertPolyfillDirectivesInCssText = /**
  22732. * @param {?} cssText
  22733. * @return {?}
  22734. */
  22735. function (cssText) {
  22736. // Difference with webcomponents.js: does not handle comments
  22737. return cssText.replace(_cssContentNextSelectorRe, function () {
  22738. var m = [];
  22739. for (var _i = 0; _i < arguments.length; _i++) {
  22740. m[_i] = arguments[_i];
  22741. }
  22742. return m[2] + '{';
  22743. });
  22744. };
  22745. /**
  22746. * @param {?} cssText
  22747. * @return {?}
  22748. */
  22749. ShadowCss.prototype._insertPolyfillRulesInCssText = /**
  22750. * @param {?} cssText
  22751. * @return {?}
  22752. */
  22753. function (cssText) {
  22754. // Difference with webcomponents.js: does not handle comments
  22755. return cssText.replace(_cssContentRuleRe, function () {
  22756. var m = [];
  22757. for (var _i = 0; _i < arguments.length; _i++) {
  22758. m[_i] = arguments[_i];
  22759. }
  22760. var /** @type {?} */ rule = m[0].replace(m[1], '').replace(m[2], '');
  22761. return m[4] + rule;
  22762. });
  22763. };
  22764. /**
  22765. * @param {?} cssText
  22766. * @param {?} scopeSelector
  22767. * @param {?} hostSelector
  22768. * @return {?}
  22769. */
  22770. ShadowCss.prototype._scopeCssText = /**
  22771. * @param {?} cssText
  22772. * @param {?} scopeSelector
  22773. * @param {?} hostSelector
  22774. * @return {?}
  22775. */
  22776. function (cssText, scopeSelector, hostSelector) {
  22777. var /** @type {?} */ unscopedRules = this._extractUnscopedRulesFromCssText(cssText);
  22778. // replace :host and :host-context -shadowcsshost and -shadowcsshost respectively
  22779. cssText = this._insertPolyfillHostInCssText(cssText);
  22780. cssText = this._convertColonHost(cssText);
  22781. cssText = this._convertColonHostContext(cssText);
  22782. cssText = this._convertShadowDOMSelectors(cssText);
  22783. if (scopeSelector) {
  22784. cssText = this._scopeSelectors(cssText, scopeSelector, hostSelector);
  22785. }
  22786. cssText = cssText + '\n' + unscopedRules;
  22787. return cssText.trim();
  22788. };
  22789. /**
  22790. * @param {?} cssText
  22791. * @return {?}
  22792. */
  22793. ShadowCss.prototype._extractUnscopedRulesFromCssText = /**
  22794. * @param {?} cssText
  22795. * @return {?}
  22796. */
  22797. function (cssText) {
  22798. // Difference with webcomponents.js: does not handle comments
  22799. var /** @type {?} */ r = '';
  22800. var /** @type {?} */ m;
  22801. _cssContentUnscopedRuleRe.lastIndex = 0;
  22802. while ((m = _cssContentUnscopedRuleRe.exec(cssText)) !== null) {
  22803. var /** @type {?} */ rule = m[0].replace(m[2], '').replace(m[1], m[4]);
  22804. r += rule + '\n\n';
  22805. }
  22806. return r;
  22807. };
  22808. /**
  22809. * @param {?} cssText
  22810. * @return {?}
  22811. */
  22812. ShadowCss.prototype._convertColonHost = /**
  22813. * @param {?} cssText
  22814. * @return {?}
  22815. */
  22816. function (cssText) {
  22817. return this._convertColonRule(cssText, _cssColonHostRe, this._colonHostPartReplacer);
  22818. };
  22819. /**
  22820. * @param {?} cssText
  22821. * @return {?}
  22822. */
  22823. ShadowCss.prototype._convertColonHostContext = /**
  22824. * @param {?} cssText
  22825. * @return {?}
  22826. */
  22827. function (cssText) {
  22828. return this._convertColonRule(cssText, _cssColonHostContextRe, this._colonHostContextPartReplacer);
  22829. };
  22830. /**
  22831. * @param {?} cssText
  22832. * @param {?} regExp
  22833. * @param {?} partReplacer
  22834. * @return {?}
  22835. */
  22836. ShadowCss.prototype._convertColonRule = /**
  22837. * @param {?} cssText
  22838. * @param {?} regExp
  22839. * @param {?} partReplacer
  22840. * @return {?}
  22841. */
  22842. function (cssText, regExp, partReplacer) {
  22843. // m[1] = :host(-context), m[2] = contents of (), m[3] rest of rule
  22844. return cssText.replace(regExp, function () {
  22845. var m = [];
  22846. for (var _i = 0; _i < arguments.length; _i++) {
  22847. m[_i] = arguments[_i];
  22848. }
  22849. if (m[2]) {
  22850. var /** @type {?} */ parts = m[2].split(',');
  22851. var /** @type {?} */ r = [];
  22852. for (var /** @type {?} */ i = 0; i < parts.length; i++) {
  22853. var /** @type {?} */ p = parts[i].trim();
  22854. if (!p)
  22855. break;
  22856. r.push(partReplacer(_polyfillHostNoCombinator, p, m[3]));
  22857. }
  22858. return r.join(',');
  22859. }
  22860. else {
  22861. return _polyfillHostNoCombinator + m[3];
  22862. }
  22863. });
  22864. };
  22865. /**
  22866. * @param {?} host
  22867. * @param {?} part
  22868. * @param {?} suffix
  22869. * @return {?}
  22870. */
  22871. ShadowCss.prototype._colonHostContextPartReplacer = /**
  22872. * @param {?} host
  22873. * @param {?} part
  22874. * @param {?} suffix
  22875. * @return {?}
  22876. */
  22877. function (host, part, suffix) {
  22878. if (part.indexOf(_polyfillHost) > -1) {
  22879. return this._colonHostPartReplacer(host, part, suffix);
  22880. }
  22881. else {
  22882. return host + part + suffix + ', ' + part + ' ' + host + suffix;
  22883. }
  22884. };
  22885. /**
  22886. * @param {?} host
  22887. * @param {?} part
  22888. * @param {?} suffix
  22889. * @return {?}
  22890. */
  22891. ShadowCss.prototype._colonHostPartReplacer = /**
  22892. * @param {?} host
  22893. * @param {?} part
  22894. * @param {?} suffix
  22895. * @return {?}
  22896. */
  22897. function (host, part, suffix) {
  22898. return host + part.replace(_polyfillHost, '') + suffix;
  22899. };
  22900. /**
  22901. * @param {?} cssText
  22902. * @return {?}
  22903. */
  22904. ShadowCss.prototype._convertShadowDOMSelectors = /**
  22905. * @param {?} cssText
  22906. * @return {?}
  22907. */
  22908. function (cssText) {
  22909. return _shadowDOMSelectorsRe.reduce(function (result, pattern) { return result.replace(pattern, ' '); }, cssText);
  22910. };
  22911. /**
  22912. * @param {?} cssText
  22913. * @param {?} scopeSelector
  22914. * @param {?} hostSelector
  22915. * @return {?}
  22916. */
  22917. ShadowCss.prototype._scopeSelectors = /**
  22918. * @param {?} cssText
  22919. * @param {?} scopeSelector
  22920. * @param {?} hostSelector
  22921. * @return {?}
  22922. */
  22923. function (cssText, scopeSelector, hostSelector) {
  22924. var _this = this;
  22925. return processRules(cssText, function (rule) {
  22926. var /** @type {?} */ selector = rule.selector;
  22927. var /** @type {?} */ content = rule.content;
  22928. if (rule.selector[0] != '@') {
  22929. selector =
  22930. _this._scopeSelector(rule.selector, scopeSelector, hostSelector, _this.strictStyling);
  22931. }
  22932. else if (rule.selector.startsWith('@media') || rule.selector.startsWith('@supports') ||
  22933. rule.selector.startsWith('@page') || rule.selector.startsWith('@document')) {
  22934. content = _this._scopeSelectors(rule.content, scopeSelector, hostSelector);
  22935. }
  22936. return new CssRule(selector, content);
  22937. });
  22938. };
  22939. /**
  22940. * @param {?} selector
  22941. * @param {?} scopeSelector
  22942. * @param {?} hostSelector
  22943. * @param {?} strict
  22944. * @return {?}
  22945. */
  22946. ShadowCss.prototype._scopeSelector = /**
  22947. * @param {?} selector
  22948. * @param {?} scopeSelector
  22949. * @param {?} hostSelector
  22950. * @param {?} strict
  22951. * @return {?}
  22952. */
  22953. function (selector, scopeSelector, hostSelector, strict) {
  22954. var _this = this;
  22955. return selector.split(',')
  22956. .map(function (part) { return part.trim().split(_shadowDeepSelectors); })
  22957. .map(function (deepParts) {
  22958. var shallowPart = deepParts[0], otherParts = deepParts.slice(1);
  22959. var /** @type {?} */ applyScope = function (shallowPart) {
  22960. if (_this._selectorNeedsScoping(shallowPart, scopeSelector)) {
  22961. return strict ?
  22962. _this._applyStrictSelectorScope(shallowPart, scopeSelector, hostSelector) :
  22963. _this._applySelectorScope(shallowPart, scopeSelector, hostSelector);
  22964. }
  22965. else {
  22966. return shallowPart;
  22967. }
  22968. };
  22969. return [applyScope(shallowPart)].concat(otherParts).join(' ');
  22970. })
  22971. .join(', ');
  22972. };
  22973. /**
  22974. * @param {?} selector
  22975. * @param {?} scopeSelector
  22976. * @return {?}
  22977. */
  22978. ShadowCss.prototype._selectorNeedsScoping = /**
  22979. * @param {?} selector
  22980. * @param {?} scopeSelector
  22981. * @return {?}
  22982. */
  22983. function (selector, scopeSelector) {
  22984. var /** @type {?} */ re = this._makeScopeMatcher(scopeSelector);
  22985. return !re.test(selector);
  22986. };
  22987. /**
  22988. * @param {?} scopeSelector
  22989. * @return {?}
  22990. */
  22991. ShadowCss.prototype._makeScopeMatcher = /**
  22992. * @param {?} scopeSelector
  22993. * @return {?}
  22994. */
  22995. function (scopeSelector) {
  22996. var /** @type {?} */ lre = /\[/g;
  22997. var /** @type {?} */ rre = /\]/g;
  22998. scopeSelector = scopeSelector.replace(lre, '\\[').replace(rre, '\\]');
  22999. return new RegExp('^(' + scopeSelector + ')' + _selectorReSuffix, 'm');
  23000. };
  23001. /**
  23002. * @param {?} selector
  23003. * @param {?} scopeSelector
  23004. * @param {?} hostSelector
  23005. * @return {?}
  23006. */
  23007. ShadowCss.prototype._applySelectorScope = /**
  23008. * @param {?} selector
  23009. * @param {?} scopeSelector
  23010. * @param {?} hostSelector
  23011. * @return {?}
  23012. */
  23013. function (selector, scopeSelector, hostSelector) {
  23014. // Difference from webcomponents.js: scopeSelector could not be an array
  23015. return this._applySimpleSelectorScope(selector, scopeSelector, hostSelector);
  23016. };
  23017. /**
  23018. * @param {?} selector
  23019. * @param {?} scopeSelector
  23020. * @param {?} hostSelector
  23021. * @return {?}
  23022. */
  23023. ShadowCss.prototype._applySimpleSelectorScope = /**
  23024. * @param {?} selector
  23025. * @param {?} scopeSelector
  23026. * @param {?} hostSelector
  23027. * @return {?}
  23028. */
  23029. function (selector, scopeSelector, hostSelector) {
  23030. // In Android browser, the lastIndex is not reset when the regex is used in String.replace()
  23031. _polyfillHostRe.lastIndex = 0;
  23032. if (_polyfillHostRe.test(selector)) {
  23033. var /** @type {?} */ replaceBy_1 = this.strictStyling ? "[" + hostSelector + "]" : scopeSelector;
  23034. return selector
  23035. .replace(_polyfillHostNoCombinatorRe, function (hnc, selector) {
  23036. return selector.replace(/([^:]*)(:*)(.*)/, function (_, before, colon, after) {
  23037. return before + replaceBy_1 + colon + after;
  23038. });
  23039. })
  23040. .replace(_polyfillHostRe, replaceBy_1 + ' ');
  23041. }
  23042. return scopeSelector + ' ' + selector;
  23043. };
  23044. /**
  23045. * @param {?} selector
  23046. * @param {?} scopeSelector
  23047. * @param {?} hostSelector
  23048. * @return {?}
  23049. */
  23050. ShadowCss.prototype._applyStrictSelectorScope = /**
  23051. * @param {?} selector
  23052. * @param {?} scopeSelector
  23053. * @param {?} hostSelector
  23054. * @return {?}
  23055. */
  23056. function (selector, scopeSelector, hostSelector) {
  23057. var _this = this;
  23058. var /** @type {?} */ isRe = /\[is=([^\]]*)\]/g;
  23059. scopeSelector = scopeSelector.replace(isRe, function (_) {
  23060. var parts = [];
  23061. for (var _i = 1; _i < arguments.length; _i++) {
  23062. parts[_i - 1] = arguments[_i];
  23063. }
  23064. return parts[0];
  23065. });
  23066. var /** @type {?} */ attrName = '[' + scopeSelector + ']';
  23067. var /** @type {?} */ _scopeSelectorPart = function (p) {
  23068. var /** @type {?} */ scopedP = p.trim();
  23069. if (!scopedP) {
  23070. return '';
  23071. }
  23072. if (p.indexOf(_polyfillHostNoCombinator) > -1) {
  23073. scopedP = _this._applySimpleSelectorScope(p, scopeSelector, hostSelector);
  23074. }
  23075. else {
  23076. // remove :host since it should be unnecessary
  23077. var /** @type {?} */ t = p.replace(_polyfillHostRe, '');
  23078. if (t.length > 0) {
  23079. var /** @type {?} */ matches = t.match(/([^:]*)(:*)(.*)/);
  23080. if (matches) {
  23081. scopedP = matches[1] + attrName + matches[2] + matches[3];
  23082. }
  23083. }
  23084. }
  23085. return scopedP;
  23086. };
  23087. var /** @type {?} */ safeContent = new SafeSelector(selector);
  23088. selector = safeContent.content();
  23089. var /** @type {?} */ scopedSelector = '';
  23090. var /** @type {?} */ startIndex = 0;
  23091. var /** @type {?} */ res;
  23092. var /** @type {?} */ sep = /( |>|\+|~(?!=))\s*/g;
  23093. // If a selector appears before :host it should not be shimmed as it
  23094. // matches on ancestor elements and not on elements in the host's shadow
  23095. // `:host-context(div)` is transformed to
  23096. // `-shadowcsshost-no-combinatordiv, div -shadowcsshost-no-combinator`
  23097. // the `div` is not part of the component in the 2nd selectors and should not be scoped.
  23098. // Historically `component-tag:host` was matching the component so we also want to preserve
  23099. // this behavior to avoid breaking legacy apps (it should not match).
  23100. // The behavior should be:
  23101. // - `tag:host` -> `tag[h]` (this is to avoid breaking legacy apps, should not match anything)
  23102. // - `tag :host` -> `tag [h]` (`tag` is not scoped because it's considered part of a
  23103. // `:host-context(tag)`)
  23104. var /** @type {?} */ hasHost = selector.indexOf(_polyfillHostNoCombinator) > -1;
  23105. // Only scope parts after the first `-shadowcsshost-no-combinator` when it is present
  23106. var /** @type {?} */ shouldScope = !hasHost;
  23107. while ((res = sep.exec(selector)) !== null) {
  23108. var /** @type {?} */ separator = res[1];
  23109. var /** @type {?} */ part_1 = selector.slice(startIndex, res.index).trim();
  23110. shouldScope = shouldScope || part_1.indexOf(_polyfillHostNoCombinator) > -1;
  23111. var /** @type {?} */ scopedPart = shouldScope ? _scopeSelectorPart(part_1) : part_1;
  23112. scopedSelector += scopedPart + " " + separator + " ";
  23113. startIndex = sep.lastIndex;
  23114. }
  23115. var /** @type {?} */ part = selector.substring(startIndex);
  23116. shouldScope = shouldScope || part.indexOf(_polyfillHostNoCombinator) > -1;
  23117. scopedSelector += shouldScope ? _scopeSelectorPart(part) : part;
  23118. // replace the placeholders with their original values
  23119. return safeContent.restore(scopedSelector);
  23120. };
  23121. /**
  23122. * @param {?} selector
  23123. * @return {?}
  23124. */
  23125. ShadowCss.prototype._insertPolyfillHostInCssText = /**
  23126. * @param {?} selector
  23127. * @return {?}
  23128. */
  23129. function (selector) {
  23130. return selector.replace(_colonHostContextRe, _polyfillHostContext)
  23131. .replace(_colonHostRe, _polyfillHost);
  23132. };
  23133. return ShadowCss;
  23134. }());
  23135. var SafeSelector = /** @class */ (function () {
  23136. function SafeSelector(selector) {
  23137. var _this = this;
  23138. this.placeholders = [];
  23139. this.index = 0;
  23140. // Replaces attribute selectors with placeholders.
  23141. // The WS in [attr="va lue"] would otherwise be interpreted as a selector separator.
  23142. selector = selector.replace(/(\[[^\]]*\])/g, function (_, keep) {
  23143. var /** @type {?} */ replaceBy = "__ph-" + _this.index + "__";
  23144. _this.placeholders.push(keep);
  23145. _this.index++;
  23146. return replaceBy;
  23147. });
  23148. // Replaces the expression in `:nth-child(2n + 1)` with a placeholder.
  23149. // WS and "+" would otherwise be interpreted as selector separators.
  23150. this._content = selector.replace(/(:nth-[-\w]+)(\([^)]+\))/g, function (_, pseudo, exp) {
  23151. var /** @type {?} */ replaceBy = "__ph-" + _this.index + "__";
  23152. _this.placeholders.push(exp);
  23153. _this.index++;
  23154. return pseudo + replaceBy;
  23155. });
  23156. }
  23157. /**
  23158. * @param {?} content
  23159. * @return {?}
  23160. */
  23161. SafeSelector.prototype.restore = /**
  23162. * @param {?} content
  23163. * @return {?}
  23164. */
  23165. function (content) {
  23166. var _this = this;
  23167. return content.replace(/__ph-(\d+)__/g, function (ph, index) { return _this.placeholders[+index]; });
  23168. };
  23169. /**
  23170. * @return {?}
  23171. */
  23172. SafeSelector.prototype.content = /**
  23173. * @return {?}
  23174. */
  23175. function () { return this._content; };
  23176. return SafeSelector;
  23177. }());
  23178. var _cssContentNextSelectorRe = /polyfill-next-selector[^}]*content:[\s]*?(['"])(.*?)\1[;\s]*}([^{]*?){/gim;
  23179. var _cssContentRuleRe = /(polyfill-rule)[^}]*(content:[\s]*(['"])(.*?)\3)[;\s]*[^}]*}/gim;
  23180. var _cssContentUnscopedRuleRe = /(polyfill-unscoped-rule)[^}]*(content:[\s]*(['"])(.*?)\3)[;\s]*[^}]*}/gim;
  23181. var _polyfillHost = '-shadowcsshost';
  23182. // note: :host-context pre-processed to -shadowcsshostcontext.
  23183. var _polyfillHostContext = '-shadowcsscontext';
  23184. var _parenSuffix = ')(?:\\((' +
  23185. '(?:\\([^)(]*\\)|[^)(]*)+?' +
  23186. ')\\))?([^,{]*)';
  23187. var _cssColonHostRe = new RegExp('(' + _polyfillHost + _parenSuffix, 'gim');
  23188. var _cssColonHostContextRe = new RegExp('(' + _polyfillHostContext + _parenSuffix, 'gim');
  23189. var _polyfillHostNoCombinator = _polyfillHost + '-no-combinator';
  23190. var _polyfillHostNoCombinatorRe = /-shadowcsshost-no-combinator([^\s]*)/;
  23191. var _shadowDOMSelectorsRe = [
  23192. /::shadow/g,
  23193. /::content/g,
  23194. /\/shadow-deep\//g,
  23195. /\/shadow\//g,
  23196. ];
  23197. // The deep combinator is deprecated in the CSS spec
  23198. // Support for `>>>`, `deep`, `::ng-deep` is then also deprecated and will be removed in the future.
  23199. // see https://github.com/angular/angular/pull/17677
  23200. var _shadowDeepSelectors = /(?:>>>)|(?:\/deep\/)|(?:::ng-deep)/g;
  23201. var _selectorReSuffix = '([>\\s~+\[.,{:][\\s\\S]*)?$';
  23202. var _polyfillHostRe = /-shadowcsshost/gim;
  23203. var _colonHostRe = /:host/gim;
  23204. var _colonHostContextRe = /:host-context/gim;
  23205. var _commentRe = /\/\*\s*[\s\S]*?\*\//g;
  23206. /**
  23207. * @param {?} input
  23208. * @return {?}
  23209. */
  23210. function stripComments(input) {
  23211. return input.replace(_commentRe, '');
  23212. }
  23213. var _commentWithHashRe = /\/\*\s*#\s*source(Mapping)?URL=[\s\S]+?\*\//g;
  23214. /**
  23215. * @param {?} input
  23216. * @return {?}
  23217. */
  23218. function extractCommentsWithHash(input) {
  23219. return input.match(_commentWithHashRe) || [];
  23220. }
  23221. var _ruleRe = /(\s*)([^;\{\}]+?)(\s*)((?:{%BLOCK%}?\s*;?)|(?:\s*;))/g;
  23222. var _curlyRe = /([{}])/g;
  23223. var OPEN_CURLY = '{';
  23224. var CLOSE_CURLY = '}';
  23225. var BLOCK_PLACEHOLDER = '%BLOCK%';
  23226. var CssRule = /** @class */ (function () {
  23227. function CssRule(selector, content) {
  23228. this.selector = selector;
  23229. this.content = content;
  23230. }
  23231. return CssRule;
  23232. }());
  23233. /**
  23234. * @param {?} input
  23235. * @param {?} ruleCallback
  23236. * @return {?}
  23237. */
  23238. function processRules(input, ruleCallback) {
  23239. var /** @type {?} */ inputWithEscapedBlocks = escapeBlocks(input);
  23240. var /** @type {?} */ nextBlockIndex = 0;
  23241. return inputWithEscapedBlocks.escapedString.replace(_ruleRe, function () {
  23242. var m = [];
  23243. for (var _i = 0; _i < arguments.length; _i++) {
  23244. m[_i] = arguments[_i];
  23245. }
  23246. var /** @type {?} */ selector = m[2];
  23247. var /** @type {?} */ content = '';
  23248. var /** @type {?} */ suffix = m[4];
  23249. var /** @type {?} */ contentPrefix = '';
  23250. if (suffix && suffix.startsWith('{' + BLOCK_PLACEHOLDER)) {
  23251. content = inputWithEscapedBlocks.blocks[nextBlockIndex++];
  23252. suffix = suffix.substring(BLOCK_PLACEHOLDER.length + 1);
  23253. contentPrefix = '{';
  23254. }
  23255. var /** @type {?} */ rule = ruleCallback(new CssRule(selector, content));
  23256. return "" + m[1] + rule.selector + m[3] + contentPrefix + rule.content + suffix;
  23257. });
  23258. }
  23259. var StringWithEscapedBlocks = /** @class */ (function () {
  23260. function StringWithEscapedBlocks(escapedString, blocks) {
  23261. this.escapedString = escapedString;
  23262. this.blocks = blocks;
  23263. }
  23264. return StringWithEscapedBlocks;
  23265. }());
  23266. /**
  23267. * @param {?} input
  23268. * @return {?}
  23269. */
  23270. function escapeBlocks(input) {
  23271. var /** @type {?} */ inputParts = input.split(_curlyRe);
  23272. var /** @type {?} */ resultParts = [];
  23273. var /** @type {?} */ escapedBlocks = [];
  23274. var /** @type {?} */ bracketCount = 0;
  23275. var /** @type {?} */ currentBlockParts = [];
  23276. for (var /** @type {?} */ partIndex = 0; partIndex < inputParts.length; partIndex++) {
  23277. var /** @type {?} */ part = inputParts[partIndex];
  23278. if (part == CLOSE_CURLY) {
  23279. bracketCount--;
  23280. }
  23281. if (bracketCount > 0) {
  23282. currentBlockParts.push(part);
  23283. }
  23284. else {
  23285. if (currentBlockParts.length > 0) {
  23286. escapedBlocks.push(currentBlockParts.join(''));
  23287. resultParts.push(BLOCK_PLACEHOLDER);
  23288. currentBlockParts = [];
  23289. }
  23290. resultParts.push(part);
  23291. }
  23292. if (part == OPEN_CURLY) {
  23293. bracketCount++;
  23294. }
  23295. }
  23296. if (currentBlockParts.length > 0) {
  23297. escapedBlocks.push(currentBlockParts.join(''));
  23298. resultParts.push(BLOCK_PLACEHOLDER);
  23299. }
  23300. return new StringWithEscapedBlocks(resultParts.join(''), escapedBlocks);
  23301. }
  23302. /**
  23303. * @fileoverview added by tsickle
  23304. * @suppress {checkTypes} checked by tsc
  23305. */
  23306. /**
  23307. * @license
  23308. * Copyright Google Inc. All Rights Reserved.
  23309. *
  23310. * Use of this source code is governed by an MIT-style license that can be
  23311. * found in the LICENSE file at https://angular.io/license
  23312. */
  23313. var COMPONENT_VARIABLE = '%COMP%';
  23314. var HOST_ATTR = "_nghost-" + COMPONENT_VARIABLE;
  23315. var CONTENT_ATTR = "_ngcontent-" + COMPONENT_VARIABLE;
  23316. var StylesCompileDependency = /** @class */ (function () {
  23317. function StylesCompileDependency(name, moduleUrl, setValue) {
  23318. this.name = name;
  23319. this.moduleUrl = moduleUrl;
  23320. this.setValue = setValue;
  23321. }
  23322. return StylesCompileDependency;
  23323. }());
  23324. var CompiledStylesheet = /** @class */ (function () {
  23325. function CompiledStylesheet(outputCtx, stylesVar, dependencies, isShimmed, meta) {
  23326. this.outputCtx = outputCtx;
  23327. this.stylesVar = stylesVar;
  23328. this.dependencies = dependencies;
  23329. this.isShimmed = isShimmed;
  23330. this.meta = meta;
  23331. }
  23332. return CompiledStylesheet;
  23333. }());
  23334. var StyleCompiler = /** @class */ (function () {
  23335. function StyleCompiler(_urlResolver) {
  23336. this._urlResolver = _urlResolver;
  23337. this._shadowCss = new ShadowCss();
  23338. }
  23339. /**
  23340. * @param {?} outputCtx
  23341. * @param {?} comp
  23342. * @return {?}
  23343. */
  23344. StyleCompiler.prototype.compileComponent = /**
  23345. * @param {?} outputCtx
  23346. * @param {?} comp
  23347. * @return {?}
  23348. */
  23349. function (outputCtx, comp) {
  23350. var /** @type {?} */ template = /** @type {?} */ ((comp.template));
  23351. return this._compileStyles(outputCtx, comp, new CompileStylesheetMetadata({
  23352. styles: template.styles,
  23353. styleUrls: template.styleUrls,
  23354. moduleUrl: identifierModuleUrl(comp.type)
  23355. }), this.needsStyleShim(comp), true);
  23356. };
  23357. /**
  23358. * @param {?} outputCtx
  23359. * @param {?} comp
  23360. * @param {?} stylesheet
  23361. * @param {?=} shim
  23362. * @return {?}
  23363. */
  23364. StyleCompiler.prototype.compileStyles = /**
  23365. * @param {?} outputCtx
  23366. * @param {?} comp
  23367. * @param {?} stylesheet
  23368. * @param {?=} shim
  23369. * @return {?}
  23370. */
  23371. function (outputCtx, comp, stylesheet, shim) {
  23372. if (shim === void 0) { shim = this.needsStyleShim(comp); }
  23373. return this._compileStyles(outputCtx, comp, stylesheet, shim, false);
  23374. };
  23375. /**
  23376. * @param {?} comp
  23377. * @return {?}
  23378. */
  23379. StyleCompiler.prototype.needsStyleShim = /**
  23380. * @param {?} comp
  23381. * @return {?}
  23382. */
  23383. function (comp) {
  23384. return /** @type {?} */ ((comp.template)).encapsulation === ViewEncapsulation.Emulated;
  23385. };
  23386. /**
  23387. * @param {?} outputCtx
  23388. * @param {?} comp
  23389. * @param {?} stylesheet
  23390. * @param {?} shim
  23391. * @param {?} isComponentStylesheet
  23392. * @return {?}
  23393. */
  23394. StyleCompiler.prototype._compileStyles = /**
  23395. * @param {?} outputCtx
  23396. * @param {?} comp
  23397. * @param {?} stylesheet
  23398. * @param {?} shim
  23399. * @param {?} isComponentStylesheet
  23400. * @return {?}
  23401. */
  23402. function (outputCtx, comp, stylesheet, shim, isComponentStylesheet) {
  23403. var _this = this;
  23404. var /** @type {?} */ styleExpressions = stylesheet.styles.map(function (plainStyle) { return literal(_this._shimIfNeeded(plainStyle, shim)); });
  23405. var /** @type {?} */ dependencies = [];
  23406. stylesheet.styleUrls.forEach(function (styleUrl) {
  23407. var /** @type {?} */ exprIndex = styleExpressions.length;
  23408. // Note: This placeholder will be filled later.
  23409. styleExpressions.push(/** @type {?} */ ((null)));
  23410. dependencies.push(new StylesCompileDependency(getStylesVarName(null), styleUrl, function (value) { return styleExpressions[exprIndex] = outputCtx.importExpr(value); }));
  23411. });
  23412. // styles variable contains plain strings and arrays of other styles arrays (recursive),
  23413. // so we set its type to dynamic.
  23414. var /** @type {?} */ stylesVar = getStylesVarName(isComponentStylesheet ? comp : null);
  23415. var /** @type {?} */ stmt = variable(stylesVar)
  23416. .set(literalArr(styleExpressions, new ArrayType(DYNAMIC_TYPE, [TypeModifier.Const])))
  23417. .toDeclStmt(null, isComponentStylesheet ? [StmtModifier.Final] : [
  23418. StmtModifier.Final, StmtModifier.Exported
  23419. ]);
  23420. outputCtx.statements.push(stmt);
  23421. return new CompiledStylesheet(outputCtx, stylesVar, dependencies, shim, stylesheet);
  23422. };
  23423. /**
  23424. * @param {?} style
  23425. * @param {?} shim
  23426. * @return {?}
  23427. */
  23428. StyleCompiler.prototype._shimIfNeeded = /**
  23429. * @param {?} style
  23430. * @param {?} shim
  23431. * @return {?}
  23432. */
  23433. function (style, shim) {
  23434. return shim ? this._shadowCss.shimCssText(style, CONTENT_ATTR, HOST_ATTR) : style;
  23435. };
  23436. return StyleCompiler;
  23437. }());
  23438. /**
  23439. * @param {?} component
  23440. * @return {?}
  23441. */
  23442. function getStylesVarName(component) {
  23443. var /** @type {?} */ result = "styles";
  23444. if (component) {
  23445. result += "_" + identifierName(component.type);
  23446. }
  23447. return result;
  23448. }
  23449. /**
  23450. * @fileoverview added by tsickle
  23451. * @suppress {checkTypes} checked by tsc
  23452. */
  23453. /**
  23454. * @license
  23455. * Copyright Google Inc. All Rights Reserved.
  23456. *
  23457. * Use of this source code is governed by an MIT-style license that can be
  23458. * found in the LICENSE file at https://angular.io/license
  23459. */
  23460. var PRESERVE_WS_ATTR_NAME = 'ngPreserveWhitespaces';
  23461. var SKIP_WS_TRIM_TAGS = new Set(['pre', 'template', 'textarea', 'script', 'style']);
  23462. // Equivalent to \s with \u00a0 (non-breaking space) excluded.
  23463. // Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
  23464. var WS_CHARS = ' \f\n\r\t\v\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff';
  23465. var NO_WS_REGEXP = new RegExp("[^" + WS_CHARS + "]");
  23466. var WS_REPLACE_REGEXP = new RegExp("[" + WS_CHARS + "]{2,}", 'g');
  23467. /**
  23468. * @param {?} attrs
  23469. * @return {?}
  23470. */
  23471. function hasPreserveWhitespacesAttr(attrs) {
  23472. return attrs.some(function (attr) { return attr.name === PRESERVE_WS_ATTR_NAME; });
  23473. }
  23474. /**
  23475. * Angular Dart introduced &ngsp; as a placeholder for non-removable space, see:
  23476. * https://github.com/dart-lang/angular/blob/0bb611387d29d65b5af7f9d2515ab571fd3fbee4/_tests/test/compiler/preserve_whitespace_test.dart#L25-L32
  23477. * In Angular Dart &ngsp; is converted to the 0xE500 PUA (Private Use Areas) unicode character
  23478. * and later on replaced by a space. We are re-implementing the same idea here.
  23479. * @param {?} value
  23480. * @return {?}
  23481. */
  23482. function replaceNgsp(value) {
  23483. // lexer is replacing the &ngsp; pseudo-entity with NGSP_UNICODE
  23484. return value.replace(new RegExp(NGSP_UNICODE, 'g'), ' ');
  23485. }
  23486. /**
  23487. * This visitor can walk HTML parse tree and remove / trim text nodes using the following rules:
  23488. * - consider spaces, tabs and new lines as whitespace characters;
  23489. * - drop text nodes consisting of whitespace characters only;
  23490. * - for all other text nodes replace consecutive whitespace characters with one space;
  23491. * - convert &ngsp; pseudo-entity to a single space;
  23492. *
  23493. * Removal and trimming of whitespaces have positive performance impact (less code to generate
  23494. * while compiling templates, faster view creation). At the same time it can be "destructive"
  23495. * in some cases (whitespaces can influence layout). Because of the potential of breaking layout
  23496. * this visitor is not activated by default in Angular 5 and people need to explicitly opt-in for
  23497. * whitespace removal. The default option for whitespace removal will be revisited in Angular 6
  23498. * and might be changed to "on" by default.
  23499. */
  23500. var WhitespaceVisitor = /** @class */ (function () {
  23501. function WhitespaceVisitor() {
  23502. }
  23503. /**
  23504. * @param {?} element
  23505. * @param {?} context
  23506. * @return {?}
  23507. */
  23508. WhitespaceVisitor.prototype.visitElement = /**
  23509. * @param {?} element
  23510. * @param {?} context
  23511. * @return {?}
  23512. */
  23513. function (element, context) {
  23514. if (SKIP_WS_TRIM_TAGS.has(element.name) || hasPreserveWhitespacesAttr(element.attrs)) {
  23515. // don't descent into elements where we need to preserve whitespaces
  23516. // but still visit all attributes to eliminate one used as a market to preserve WS
  23517. return new Element(element.name, visitAll(this, element.attrs), element.children, element.sourceSpan, element.startSourceSpan, element.endSourceSpan);
  23518. }
  23519. return new Element(element.name, element.attrs, visitAll(this, element.children), element.sourceSpan, element.startSourceSpan, element.endSourceSpan);
  23520. };
  23521. /**
  23522. * @param {?} attribute
  23523. * @param {?} context
  23524. * @return {?}
  23525. */
  23526. WhitespaceVisitor.prototype.visitAttribute = /**
  23527. * @param {?} attribute
  23528. * @param {?} context
  23529. * @return {?}
  23530. */
  23531. function (attribute, context) {
  23532. return attribute.name !== PRESERVE_WS_ATTR_NAME ? attribute : null;
  23533. };
  23534. /**
  23535. * @param {?} text
  23536. * @param {?} context
  23537. * @return {?}
  23538. */
  23539. WhitespaceVisitor.prototype.visitText = /**
  23540. * @param {?} text
  23541. * @param {?} context
  23542. * @return {?}
  23543. */
  23544. function (text, context) {
  23545. var /** @type {?} */ isNotBlank = text.value.match(NO_WS_REGEXP);
  23546. if (isNotBlank) {
  23547. return new Text(replaceNgsp(text.value).replace(WS_REPLACE_REGEXP, ' '), text.sourceSpan);
  23548. }
  23549. return null;
  23550. };
  23551. /**
  23552. * @param {?} comment
  23553. * @param {?} context
  23554. * @return {?}
  23555. */
  23556. WhitespaceVisitor.prototype.visitComment = /**
  23557. * @param {?} comment
  23558. * @param {?} context
  23559. * @return {?}
  23560. */
  23561. function (comment, context) { return comment; };
  23562. /**
  23563. * @param {?} expansion
  23564. * @param {?} context
  23565. * @return {?}
  23566. */
  23567. WhitespaceVisitor.prototype.visitExpansion = /**
  23568. * @param {?} expansion
  23569. * @param {?} context
  23570. * @return {?}
  23571. */
  23572. function (expansion, context) { return expansion; };
  23573. /**
  23574. * @param {?} expansionCase
  23575. * @param {?} context
  23576. * @return {?}
  23577. */
  23578. WhitespaceVisitor.prototype.visitExpansionCase = /**
  23579. * @param {?} expansionCase
  23580. * @param {?} context
  23581. * @return {?}
  23582. */
  23583. function (expansionCase, context) { return expansionCase; };
  23584. return WhitespaceVisitor;
  23585. }());
  23586. /**
  23587. * @param {?} htmlAstWithErrors
  23588. * @return {?}
  23589. */
  23590. function removeWhitespaces(htmlAstWithErrors) {
  23591. return new ParseTreeResult(visitAll(new WhitespaceVisitor(), htmlAstWithErrors.rootNodes), htmlAstWithErrors.errors);
  23592. }
  23593. /**
  23594. * @fileoverview added by tsickle
  23595. * @suppress {checkTypes} checked by tsc
  23596. */
  23597. /**
  23598. * @license
  23599. * Copyright Google Inc. All Rights Reserved.
  23600. *
  23601. * Use of this source code is governed by an MIT-style license that can be
  23602. * found in the LICENSE file at https://angular.io/license
  23603. */
  23604. // http://cldr.unicode.org/index/cldr-spec/plural-rules
  23605. var PLURAL_CASES = ['zero', 'one', 'two', 'few', 'many', 'other'];
  23606. /**
  23607. * Expands special forms into elements.
  23608. *
  23609. * For example,
  23610. *
  23611. * ```
  23612. * { messages.length, plural,
  23613. * =0 {zero}
  23614. * =1 {one}
  23615. * other {more than one}
  23616. * }
  23617. * ```
  23618. *
  23619. * will be expanded into
  23620. *
  23621. * ```
  23622. * <ng-container [ngPlural]="messages.length">
  23623. * <ng-template ngPluralCase="=0">zero</ng-template>
  23624. * <ng-template ngPluralCase="=1">one</ng-template>
  23625. * <ng-template ngPluralCase="other">more than one</ng-template>
  23626. * </ng-container>
  23627. * ```
  23628. * @param {?} nodes
  23629. * @return {?}
  23630. */
  23631. function expandNodes(nodes) {
  23632. var /** @type {?} */ expander = new _Expander();
  23633. return new ExpansionResult(visitAll(expander, nodes), expander.isExpanded, expander.errors);
  23634. }
  23635. var ExpansionResult = /** @class */ (function () {
  23636. function ExpansionResult(nodes, expanded, errors) {
  23637. this.nodes = nodes;
  23638. this.expanded = expanded;
  23639. this.errors = errors;
  23640. }
  23641. return ExpansionResult;
  23642. }());
  23643. var ExpansionError = /** @class */ (function (_super) {
  23644. __extends(ExpansionError, _super);
  23645. function ExpansionError(span, errorMsg) {
  23646. return _super.call(this, span, errorMsg) || this;
  23647. }
  23648. return ExpansionError;
  23649. }(ParseError));
  23650. /**
  23651. * Expand expansion forms (plural, select) to directives
  23652. *
  23653. * \@internal
  23654. */
  23655. var _Expander = /** @class */ (function () {
  23656. function _Expander() {
  23657. this.isExpanded = false;
  23658. this.errors = [];
  23659. }
  23660. /**
  23661. * @param {?} element
  23662. * @param {?} context
  23663. * @return {?}
  23664. */
  23665. _Expander.prototype.visitElement = /**
  23666. * @param {?} element
  23667. * @param {?} context
  23668. * @return {?}
  23669. */
  23670. function (element, context) {
  23671. return new Element(element.name, element.attrs, visitAll(this, element.children), element.sourceSpan, element.startSourceSpan, element.endSourceSpan);
  23672. };
  23673. /**
  23674. * @param {?} attribute
  23675. * @param {?} context
  23676. * @return {?}
  23677. */
  23678. _Expander.prototype.visitAttribute = /**
  23679. * @param {?} attribute
  23680. * @param {?} context
  23681. * @return {?}
  23682. */
  23683. function (attribute, context) { return attribute; };
  23684. /**
  23685. * @param {?} text
  23686. * @param {?} context
  23687. * @return {?}
  23688. */
  23689. _Expander.prototype.visitText = /**
  23690. * @param {?} text
  23691. * @param {?} context
  23692. * @return {?}
  23693. */
  23694. function (text, context) { return text; };
  23695. /**
  23696. * @param {?} comment
  23697. * @param {?} context
  23698. * @return {?}
  23699. */
  23700. _Expander.prototype.visitComment = /**
  23701. * @param {?} comment
  23702. * @param {?} context
  23703. * @return {?}
  23704. */
  23705. function (comment, context) { return comment; };
  23706. /**
  23707. * @param {?} icu
  23708. * @param {?} context
  23709. * @return {?}
  23710. */
  23711. _Expander.prototype.visitExpansion = /**
  23712. * @param {?} icu
  23713. * @param {?} context
  23714. * @return {?}
  23715. */
  23716. function (icu, context) {
  23717. this.isExpanded = true;
  23718. return icu.type == 'plural' ? _expandPluralForm(icu, this.errors) :
  23719. _expandDefaultForm(icu, this.errors);
  23720. };
  23721. /**
  23722. * @param {?} icuCase
  23723. * @param {?} context
  23724. * @return {?}
  23725. */
  23726. _Expander.prototype.visitExpansionCase = /**
  23727. * @param {?} icuCase
  23728. * @param {?} context
  23729. * @return {?}
  23730. */
  23731. function (icuCase, context) {
  23732. throw new Error('Should not be reached');
  23733. };
  23734. return _Expander;
  23735. }());
  23736. /**
  23737. * @param {?} ast
  23738. * @param {?} errors
  23739. * @return {?}
  23740. */
  23741. function _expandPluralForm(ast, errors) {
  23742. var /** @type {?} */ children = ast.cases.map(function (c) {
  23743. if (PLURAL_CASES.indexOf(c.value) == -1 && !c.value.match(/^=\d+$/)) {
  23744. errors.push(new ExpansionError(c.valueSourceSpan, "Plural cases should be \"=<number>\" or one of " + PLURAL_CASES.join(", ")));
  23745. }
  23746. var /** @type {?} */ expansionResult = expandNodes(c.expression);
  23747. errors.push.apply(errors, expansionResult.errors);
  23748. return new Element("ng-template", [new Attribute$1('ngPluralCase', "" + c.value, c.valueSourceSpan)], expansionResult.nodes, c.sourceSpan, c.sourceSpan, c.sourceSpan);
  23749. });
  23750. var /** @type {?} */ switchAttr = new Attribute$1('[ngPlural]', ast.switchValue, ast.switchValueSourceSpan);
  23751. return new Element('ng-container', [switchAttr], children, ast.sourceSpan, ast.sourceSpan, ast.sourceSpan);
  23752. }
  23753. /**
  23754. * @param {?} ast
  23755. * @param {?} errors
  23756. * @return {?}
  23757. */
  23758. function _expandDefaultForm(ast, errors) {
  23759. var /** @type {?} */ children = ast.cases.map(function (c) {
  23760. var /** @type {?} */ expansionResult = expandNodes(c.expression);
  23761. errors.push.apply(errors, expansionResult.errors);
  23762. if (c.value === 'other') {
  23763. // other is the default case when no values match
  23764. return new Element("ng-template", [new Attribute$1('ngSwitchDefault', '', c.valueSourceSpan)], expansionResult.nodes, c.sourceSpan, c.sourceSpan, c.sourceSpan);
  23765. }
  23766. return new Element("ng-template", [new Attribute$1('ngSwitchCase', "" + c.value, c.valueSourceSpan)], expansionResult.nodes, c.sourceSpan, c.sourceSpan, c.sourceSpan);
  23767. });
  23768. var /** @type {?} */ switchAttr = new Attribute$1('[ngSwitch]', ast.switchValue, ast.switchValueSourceSpan);
  23769. return new Element('ng-container', [switchAttr], children, ast.sourceSpan, ast.sourceSpan, ast.sourceSpan);
  23770. }
  23771. /**
  23772. * @fileoverview added by tsickle
  23773. * @suppress {checkTypes} checked by tsc
  23774. */
  23775. /**
  23776. * @license
  23777. * Copyright Google Inc. All Rights Reserved.
  23778. *
  23779. * Use of this source code is governed by an MIT-style license that can be
  23780. * found in the LICENSE file at https://angular.io/license
  23781. */
  23782. var PROPERTY_PARTS_SEPARATOR = '.';
  23783. var ATTRIBUTE_PREFIX = 'attr';
  23784. var CLASS_PREFIX = 'class';
  23785. var STYLE_PREFIX = 'style';
  23786. var ANIMATE_PROP_PREFIX = 'animate-';
  23787. /** @enum {number} */
  23788. var BoundPropertyType = {
  23789. DEFAULT: 0,
  23790. LITERAL_ATTR: 1,
  23791. ANIMATION: 2,
  23792. };
  23793. BoundPropertyType[BoundPropertyType.DEFAULT] = "DEFAULT";
  23794. BoundPropertyType[BoundPropertyType.LITERAL_ATTR] = "LITERAL_ATTR";
  23795. BoundPropertyType[BoundPropertyType.ANIMATION] = "ANIMATION";
  23796. /**
  23797. * Represents a parsed property.
  23798. */
  23799. var BoundProperty = /** @class */ (function () {
  23800. function BoundProperty(name, expression, type, sourceSpan) {
  23801. this.name = name;
  23802. this.expression = expression;
  23803. this.type = type;
  23804. this.sourceSpan = sourceSpan;
  23805. this.isLiteral = this.type === BoundPropertyType.LITERAL_ATTR;
  23806. this.isAnimation = this.type === BoundPropertyType.ANIMATION;
  23807. }
  23808. return BoundProperty;
  23809. }());
  23810. /**
  23811. * Parses bindings in templates and in the directive host area.
  23812. */
  23813. var BindingParser = /** @class */ (function () {
  23814. function BindingParser(_exprParser, _interpolationConfig, _schemaRegistry, pipes, _targetErrors) {
  23815. var _this = this;
  23816. this._exprParser = _exprParser;
  23817. this._interpolationConfig = _interpolationConfig;
  23818. this._schemaRegistry = _schemaRegistry;
  23819. this._targetErrors = _targetErrors;
  23820. this.pipesByName = new Map();
  23821. this._usedPipes = new Map();
  23822. pipes.forEach(function (pipe) { return _this.pipesByName.set(pipe.name, pipe); });
  23823. }
  23824. /**
  23825. * @return {?}
  23826. */
  23827. BindingParser.prototype.getUsedPipes = /**
  23828. * @return {?}
  23829. */
  23830. function () { return Array.from(this._usedPipes.values()); };
  23831. /**
  23832. * @param {?} dirMeta
  23833. * @param {?} elementSelector
  23834. * @param {?} sourceSpan
  23835. * @return {?}
  23836. */
  23837. BindingParser.prototype.createDirectiveHostPropertyAsts = /**
  23838. * @param {?} dirMeta
  23839. * @param {?} elementSelector
  23840. * @param {?} sourceSpan
  23841. * @return {?}
  23842. */
  23843. function (dirMeta, elementSelector, sourceSpan) {
  23844. var _this = this;
  23845. if (dirMeta.hostProperties) {
  23846. var /** @type {?} */ boundProps_1 = [];
  23847. Object.keys(dirMeta.hostProperties).forEach(function (propName) {
  23848. var /** @type {?} */ expression = dirMeta.hostProperties[propName];
  23849. if (typeof expression === 'string') {
  23850. _this.parsePropertyBinding(propName, expression, true, sourceSpan, [], boundProps_1);
  23851. }
  23852. else {
  23853. _this._reportError("Value of the host property binding \"" + propName + "\" needs to be a string representing an expression but got \"" + expression + "\" (" + typeof expression + ")", sourceSpan);
  23854. }
  23855. });
  23856. return boundProps_1.map(function (prop) { return _this.createElementPropertyAst(elementSelector, prop); });
  23857. }
  23858. return null;
  23859. };
  23860. /**
  23861. * @param {?} dirMeta
  23862. * @param {?} sourceSpan
  23863. * @return {?}
  23864. */
  23865. BindingParser.prototype.createDirectiveHostEventAsts = /**
  23866. * @param {?} dirMeta
  23867. * @param {?} sourceSpan
  23868. * @return {?}
  23869. */
  23870. function (dirMeta, sourceSpan) {
  23871. var _this = this;
  23872. if (dirMeta.hostListeners) {
  23873. var /** @type {?} */ targetEventAsts_1 = [];
  23874. Object.keys(dirMeta.hostListeners).forEach(function (propName) {
  23875. var /** @type {?} */ expression = dirMeta.hostListeners[propName];
  23876. if (typeof expression === 'string') {
  23877. _this.parseEvent(propName, expression, sourceSpan, [], targetEventAsts_1);
  23878. }
  23879. else {
  23880. _this._reportError("Value of the host listener \"" + propName + "\" needs to be a string representing an expression but got \"" + expression + "\" (" + typeof expression + ")", sourceSpan);
  23881. }
  23882. });
  23883. return targetEventAsts_1;
  23884. }
  23885. return null;
  23886. };
  23887. /**
  23888. * @param {?} value
  23889. * @param {?} sourceSpan
  23890. * @return {?}
  23891. */
  23892. BindingParser.prototype.parseInterpolation = /**
  23893. * @param {?} value
  23894. * @param {?} sourceSpan
  23895. * @return {?}
  23896. */
  23897. function (value, sourceSpan) {
  23898. var /** @type {?} */ sourceInfo = sourceSpan.start.toString();
  23899. try {
  23900. var /** @type {?} */ ast = /** @type {?} */ ((this._exprParser.parseInterpolation(value, sourceInfo, this._interpolationConfig)));
  23901. if (ast)
  23902. this._reportExpressionParserErrors(ast.errors, sourceSpan);
  23903. this._checkPipes(ast, sourceSpan);
  23904. return ast;
  23905. }
  23906. catch (/** @type {?} */ e) {
  23907. this._reportError("" + e, sourceSpan);
  23908. return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo);
  23909. }
  23910. };
  23911. /**
  23912. * @param {?} prefixToken
  23913. * @param {?} value
  23914. * @param {?} sourceSpan
  23915. * @param {?} targetMatchableAttrs
  23916. * @param {?} targetProps
  23917. * @param {?} targetVars
  23918. * @return {?}
  23919. */
  23920. BindingParser.prototype.parseInlineTemplateBinding = /**
  23921. * @param {?} prefixToken
  23922. * @param {?} value
  23923. * @param {?} sourceSpan
  23924. * @param {?} targetMatchableAttrs
  23925. * @param {?} targetProps
  23926. * @param {?} targetVars
  23927. * @return {?}
  23928. */
  23929. function (prefixToken, value, sourceSpan, targetMatchableAttrs, targetProps, targetVars) {
  23930. var /** @type {?} */ bindings = this._parseTemplateBindings(prefixToken, value, sourceSpan);
  23931. for (var /** @type {?} */ i = 0; i < bindings.length; i++) {
  23932. var /** @type {?} */ binding = bindings[i];
  23933. if (binding.keyIsVar) {
  23934. targetVars.push(new VariableAst(binding.key, binding.name, sourceSpan));
  23935. }
  23936. else if (binding.expression) {
  23937. this._parsePropertyAst(binding.key, binding.expression, sourceSpan, targetMatchableAttrs, targetProps);
  23938. }
  23939. else {
  23940. targetMatchableAttrs.push([binding.key, '']);
  23941. this.parseLiteralAttr(binding.key, null, sourceSpan, targetMatchableAttrs, targetProps);
  23942. }
  23943. }
  23944. };
  23945. /**
  23946. * @param {?} prefixToken
  23947. * @param {?} value
  23948. * @param {?} sourceSpan
  23949. * @return {?}
  23950. */
  23951. BindingParser.prototype._parseTemplateBindings = /**
  23952. * @param {?} prefixToken
  23953. * @param {?} value
  23954. * @param {?} sourceSpan
  23955. * @return {?}
  23956. */
  23957. function (prefixToken, value, sourceSpan) {
  23958. var _this = this;
  23959. var /** @type {?} */ sourceInfo = sourceSpan.start.toString();
  23960. try {
  23961. var /** @type {?} */ bindingsResult = this._exprParser.parseTemplateBindings(prefixToken, value, sourceInfo);
  23962. this._reportExpressionParserErrors(bindingsResult.errors, sourceSpan);
  23963. bindingsResult.templateBindings.forEach(function (binding) {
  23964. if (binding.expression) {
  23965. _this._checkPipes(binding.expression, sourceSpan);
  23966. }
  23967. });
  23968. bindingsResult.warnings.forEach(function (warning) { _this._reportError(warning, sourceSpan, ParseErrorLevel.WARNING); });
  23969. return bindingsResult.templateBindings;
  23970. }
  23971. catch (/** @type {?} */ e) {
  23972. this._reportError("" + e, sourceSpan);
  23973. return [];
  23974. }
  23975. };
  23976. /**
  23977. * @param {?} name
  23978. * @param {?} value
  23979. * @param {?} sourceSpan
  23980. * @param {?} targetMatchableAttrs
  23981. * @param {?} targetProps
  23982. * @return {?}
  23983. */
  23984. BindingParser.prototype.parseLiteralAttr = /**
  23985. * @param {?} name
  23986. * @param {?} value
  23987. * @param {?} sourceSpan
  23988. * @param {?} targetMatchableAttrs
  23989. * @param {?} targetProps
  23990. * @return {?}
  23991. */
  23992. function (name, value, sourceSpan, targetMatchableAttrs, targetProps) {
  23993. if (_isAnimationLabel(name)) {
  23994. name = name.substring(1);
  23995. if (value) {
  23996. this._reportError("Assigning animation triggers via @prop=\"exp\" attributes with an expression is invalid." +
  23997. " Use property bindings (e.g. [@prop]=\"exp\") or use an attribute without a value (e.g. @prop) instead.", sourceSpan, ParseErrorLevel.ERROR);
  23998. }
  23999. this._parseAnimation(name, value, sourceSpan, targetMatchableAttrs, targetProps);
  24000. }
  24001. else {
  24002. targetProps.push(new BoundProperty(name, this._exprParser.wrapLiteralPrimitive(value, ''), BoundPropertyType.LITERAL_ATTR, sourceSpan));
  24003. }
  24004. };
  24005. /**
  24006. * @param {?} name
  24007. * @param {?} expression
  24008. * @param {?} isHost
  24009. * @param {?} sourceSpan
  24010. * @param {?} targetMatchableAttrs
  24011. * @param {?} targetProps
  24012. * @return {?}
  24013. */
  24014. BindingParser.prototype.parsePropertyBinding = /**
  24015. * @param {?} name
  24016. * @param {?} expression
  24017. * @param {?} isHost
  24018. * @param {?} sourceSpan
  24019. * @param {?} targetMatchableAttrs
  24020. * @param {?} targetProps
  24021. * @return {?}
  24022. */
  24023. function (name, expression, isHost, sourceSpan, targetMatchableAttrs, targetProps) {
  24024. var /** @type {?} */ isAnimationProp = false;
  24025. if (name.startsWith(ANIMATE_PROP_PREFIX)) {
  24026. isAnimationProp = true;
  24027. name = name.substring(ANIMATE_PROP_PREFIX.length);
  24028. }
  24029. else if (_isAnimationLabel(name)) {
  24030. isAnimationProp = true;
  24031. name = name.substring(1);
  24032. }
  24033. if (isAnimationProp) {
  24034. this._parseAnimation(name, expression, sourceSpan, targetMatchableAttrs, targetProps);
  24035. }
  24036. else {
  24037. this._parsePropertyAst(name, this._parseBinding(expression, isHost, sourceSpan), sourceSpan, targetMatchableAttrs, targetProps);
  24038. }
  24039. };
  24040. /**
  24041. * @param {?} name
  24042. * @param {?} value
  24043. * @param {?} sourceSpan
  24044. * @param {?} targetMatchableAttrs
  24045. * @param {?} targetProps
  24046. * @return {?}
  24047. */
  24048. BindingParser.prototype.parsePropertyInterpolation = /**
  24049. * @param {?} name
  24050. * @param {?} value
  24051. * @param {?} sourceSpan
  24052. * @param {?} targetMatchableAttrs
  24053. * @param {?} targetProps
  24054. * @return {?}
  24055. */
  24056. function (name, value, sourceSpan, targetMatchableAttrs, targetProps) {
  24057. var /** @type {?} */ expr = this.parseInterpolation(value, sourceSpan);
  24058. if (expr) {
  24059. this._parsePropertyAst(name, expr, sourceSpan, targetMatchableAttrs, targetProps);
  24060. return true;
  24061. }
  24062. return false;
  24063. };
  24064. /**
  24065. * @param {?} name
  24066. * @param {?} ast
  24067. * @param {?} sourceSpan
  24068. * @param {?} targetMatchableAttrs
  24069. * @param {?} targetProps
  24070. * @return {?}
  24071. */
  24072. BindingParser.prototype._parsePropertyAst = /**
  24073. * @param {?} name
  24074. * @param {?} ast
  24075. * @param {?} sourceSpan
  24076. * @param {?} targetMatchableAttrs
  24077. * @param {?} targetProps
  24078. * @return {?}
  24079. */
  24080. function (name, ast, sourceSpan, targetMatchableAttrs, targetProps) {
  24081. targetMatchableAttrs.push([name, /** @type {?} */ ((ast.source))]);
  24082. targetProps.push(new BoundProperty(name, ast, BoundPropertyType.DEFAULT, sourceSpan));
  24083. };
  24084. /**
  24085. * @param {?} name
  24086. * @param {?} expression
  24087. * @param {?} sourceSpan
  24088. * @param {?} targetMatchableAttrs
  24089. * @param {?} targetProps
  24090. * @return {?}
  24091. */
  24092. BindingParser.prototype._parseAnimation = /**
  24093. * @param {?} name
  24094. * @param {?} expression
  24095. * @param {?} sourceSpan
  24096. * @param {?} targetMatchableAttrs
  24097. * @param {?} targetProps
  24098. * @return {?}
  24099. */
  24100. function (name, expression, sourceSpan, targetMatchableAttrs, targetProps) {
  24101. // This will occur when a @trigger is not paired with an expression.
  24102. // For animations it is valid to not have an expression since */void
  24103. // states will be applied by angular when the element is attached/detached
  24104. var /** @type {?} */ ast = this._parseBinding(expression || 'undefined', false, sourceSpan);
  24105. targetMatchableAttrs.push([name, /** @type {?} */ ((ast.source))]);
  24106. targetProps.push(new BoundProperty(name, ast, BoundPropertyType.ANIMATION, sourceSpan));
  24107. };
  24108. /**
  24109. * @param {?} value
  24110. * @param {?} isHostBinding
  24111. * @param {?} sourceSpan
  24112. * @return {?}
  24113. */
  24114. BindingParser.prototype._parseBinding = /**
  24115. * @param {?} value
  24116. * @param {?} isHostBinding
  24117. * @param {?} sourceSpan
  24118. * @return {?}
  24119. */
  24120. function (value, isHostBinding, sourceSpan) {
  24121. var /** @type {?} */ sourceInfo = sourceSpan.start.toString();
  24122. try {
  24123. var /** @type {?} */ ast = isHostBinding ?
  24124. this._exprParser.parseSimpleBinding(value, sourceInfo, this._interpolationConfig) :
  24125. this._exprParser.parseBinding(value, sourceInfo, this._interpolationConfig);
  24126. if (ast)
  24127. this._reportExpressionParserErrors(ast.errors, sourceSpan);
  24128. this._checkPipes(ast, sourceSpan);
  24129. return ast;
  24130. }
  24131. catch (/** @type {?} */ e) {
  24132. this._reportError("" + e, sourceSpan);
  24133. return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo);
  24134. }
  24135. };
  24136. /**
  24137. * @param {?} elementSelector
  24138. * @param {?} boundProp
  24139. * @return {?}
  24140. */
  24141. BindingParser.prototype.createElementPropertyAst = /**
  24142. * @param {?} elementSelector
  24143. * @param {?} boundProp
  24144. * @return {?}
  24145. */
  24146. function (elementSelector, boundProp) {
  24147. if (boundProp.isAnimation) {
  24148. return new BoundElementPropertyAst(boundProp.name, PropertyBindingType.Animation, SecurityContext.NONE, boundProp.expression, null, boundProp.sourceSpan);
  24149. }
  24150. var /** @type {?} */ unit = null;
  24151. var /** @type {?} */ bindingType = /** @type {?} */ ((undefined));
  24152. var /** @type {?} */ boundPropertyName = null;
  24153. var /** @type {?} */ parts = boundProp.name.split(PROPERTY_PARTS_SEPARATOR);
  24154. var /** @type {?} */ securityContexts = /** @type {?} */ ((undefined));
  24155. // Check check for special cases (prefix style, attr, class)
  24156. if (parts.length > 1) {
  24157. if (parts[0] == ATTRIBUTE_PREFIX) {
  24158. boundPropertyName = parts[1];
  24159. this._validatePropertyOrAttributeName(boundPropertyName, boundProp.sourceSpan, true);
  24160. securityContexts = calcPossibleSecurityContexts(this._schemaRegistry, elementSelector, boundPropertyName, true);
  24161. var /** @type {?} */ nsSeparatorIdx = boundPropertyName.indexOf(':');
  24162. if (nsSeparatorIdx > -1) {
  24163. var /** @type {?} */ ns = boundPropertyName.substring(0, nsSeparatorIdx);
  24164. var /** @type {?} */ name_1 = boundPropertyName.substring(nsSeparatorIdx + 1);
  24165. boundPropertyName = mergeNsAndName(ns, name_1);
  24166. }
  24167. bindingType = PropertyBindingType.Attribute;
  24168. }
  24169. else if (parts[0] == CLASS_PREFIX) {
  24170. boundPropertyName = parts[1];
  24171. bindingType = PropertyBindingType.Class;
  24172. securityContexts = [SecurityContext.NONE];
  24173. }
  24174. else if (parts[0] == STYLE_PREFIX) {
  24175. unit = parts.length > 2 ? parts[2] : null;
  24176. boundPropertyName = parts[1];
  24177. bindingType = PropertyBindingType.Style;
  24178. securityContexts = [SecurityContext.STYLE];
  24179. }
  24180. }
  24181. // If not a special case, use the full property name
  24182. if (boundPropertyName === null) {
  24183. boundPropertyName = this._schemaRegistry.getMappedPropName(boundProp.name);
  24184. securityContexts = calcPossibleSecurityContexts(this._schemaRegistry, elementSelector, boundPropertyName, false);
  24185. bindingType = PropertyBindingType.Property;
  24186. this._validatePropertyOrAttributeName(boundPropertyName, boundProp.sourceSpan, false);
  24187. }
  24188. return new BoundElementPropertyAst(boundPropertyName, bindingType, securityContexts[0], boundProp.expression, unit, boundProp.sourceSpan);
  24189. };
  24190. /**
  24191. * @param {?} name
  24192. * @param {?} expression
  24193. * @param {?} sourceSpan
  24194. * @param {?} targetMatchableAttrs
  24195. * @param {?} targetEvents
  24196. * @return {?}
  24197. */
  24198. BindingParser.prototype.parseEvent = /**
  24199. * @param {?} name
  24200. * @param {?} expression
  24201. * @param {?} sourceSpan
  24202. * @param {?} targetMatchableAttrs
  24203. * @param {?} targetEvents
  24204. * @return {?}
  24205. */
  24206. function (name, expression, sourceSpan, targetMatchableAttrs, targetEvents) {
  24207. if (_isAnimationLabel(name)) {
  24208. name = name.substr(1);
  24209. this._parseAnimationEvent(name, expression, sourceSpan, targetEvents);
  24210. }
  24211. else {
  24212. this._parseEvent(name, expression, sourceSpan, targetMatchableAttrs, targetEvents);
  24213. }
  24214. };
  24215. /**
  24216. * @param {?} name
  24217. * @param {?} expression
  24218. * @param {?} sourceSpan
  24219. * @param {?} targetEvents
  24220. * @return {?}
  24221. */
  24222. BindingParser.prototype._parseAnimationEvent = /**
  24223. * @param {?} name
  24224. * @param {?} expression
  24225. * @param {?} sourceSpan
  24226. * @param {?} targetEvents
  24227. * @return {?}
  24228. */
  24229. function (name, expression, sourceSpan, targetEvents) {
  24230. var /** @type {?} */ matches = splitAtPeriod(name, [name, '']);
  24231. var /** @type {?} */ eventName = matches[0];
  24232. var /** @type {?} */ phase = matches[1].toLowerCase();
  24233. if (phase) {
  24234. switch (phase) {
  24235. case 'start':
  24236. case 'done':
  24237. var /** @type {?} */ ast = this._parseAction(expression, sourceSpan);
  24238. targetEvents.push(new BoundEventAst(eventName, null, phase, ast, sourceSpan));
  24239. break;
  24240. default:
  24241. this._reportError("The provided animation output phase value \"" + phase + "\" for \"@" + eventName + "\" is not supported (use start or done)", sourceSpan);
  24242. break;
  24243. }
  24244. }
  24245. else {
  24246. this._reportError("The animation trigger output event (@" + eventName + ") is missing its phase value name (start or done are currently supported)", sourceSpan);
  24247. }
  24248. };
  24249. /**
  24250. * @param {?} name
  24251. * @param {?} expression
  24252. * @param {?} sourceSpan
  24253. * @param {?} targetMatchableAttrs
  24254. * @param {?} targetEvents
  24255. * @return {?}
  24256. */
  24257. BindingParser.prototype._parseEvent = /**
  24258. * @param {?} name
  24259. * @param {?} expression
  24260. * @param {?} sourceSpan
  24261. * @param {?} targetMatchableAttrs
  24262. * @param {?} targetEvents
  24263. * @return {?}
  24264. */
  24265. function (name, expression, sourceSpan, targetMatchableAttrs, targetEvents) {
  24266. // long format: 'target: eventName'
  24267. var _a = splitAtColon(name, [/** @type {?} */ ((null)), name]), target = _a[0], eventName = _a[1];
  24268. var /** @type {?} */ ast = this._parseAction(expression, sourceSpan);
  24269. targetMatchableAttrs.push([/** @type {?} */ ((name)), /** @type {?} */ ((ast.source))]);
  24270. targetEvents.push(new BoundEventAst(eventName, target, null, ast, sourceSpan));
  24271. // Don't detect directives for event names for now,
  24272. // so don't add the event name to the matchableAttrs
  24273. };
  24274. /**
  24275. * @param {?} value
  24276. * @param {?} sourceSpan
  24277. * @return {?}
  24278. */
  24279. BindingParser.prototype._parseAction = /**
  24280. * @param {?} value
  24281. * @param {?} sourceSpan
  24282. * @return {?}
  24283. */
  24284. function (value, sourceSpan) {
  24285. var /** @type {?} */ sourceInfo = sourceSpan.start.toString();
  24286. try {
  24287. var /** @type {?} */ ast = this._exprParser.parseAction(value, sourceInfo, this._interpolationConfig);
  24288. if (ast) {
  24289. this._reportExpressionParserErrors(ast.errors, sourceSpan);
  24290. }
  24291. if (!ast || ast.ast instanceof EmptyExpr) {
  24292. this._reportError("Empty expressions are not allowed", sourceSpan);
  24293. return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo);
  24294. }
  24295. this._checkPipes(ast, sourceSpan);
  24296. return ast;
  24297. }
  24298. catch (/** @type {?} */ e) {
  24299. this._reportError("" + e, sourceSpan);
  24300. return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo);
  24301. }
  24302. };
  24303. /**
  24304. * @param {?} message
  24305. * @param {?} sourceSpan
  24306. * @param {?=} level
  24307. * @return {?}
  24308. */
  24309. BindingParser.prototype._reportError = /**
  24310. * @param {?} message
  24311. * @param {?} sourceSpan
  24312. * @param {?=} level
  24313. * @return {?}
  24314. */
  24315. function (message, sourceSpan, level) {
  24316. if (level === void 0) { level = ParseErrorLevel.ERROR; }
  24317. this._targetErrors.push(new ParseError(sourceSpan, message, level));
  24318. };
  24319. /**
  24320. * @param {?} errors
  24321. * @param {?} sourceSpan
  24322. * @return {?}
  24323. */
  24324. BindingParser.prototype._reportExpressionParserErrors = /**
  24325. * @param {?} errors
  24326. * @param {?} sourceSpan
  24327. * @return {?}
  24328. */
  24329. function (errors, sourceSpan) {
  24330. for (var _i = 0, errors_1 = errors; _i < errors_1.length; _i++) {
  24331. var error = errors_1[_i];
  24332. this._reportError(error.message, sourceSpan);
  24333. }
  24334. };
  24335. /**
  24336. * @param {?} ast
  24337. * @param {?} sourceSpan
  24338. * @return {?}
  24339. */
  24340. BindingParser.prototype._checkPipes = /**
  24341. * @param {?} ast
  24342. * @param {?} sourceSpan
  24343. * @return {?}
  24344. */
  24345. function (ast, sourceSpan) {
  24346. var _this = this;
  24347. if (ast) {
  24348. var /** @type {?} */ collector = new PipeCollector();
  24349. ast.visit(collector);
  24350. collector.pipes.forEach(function (ast, pipeName) {
  24351. var /** @type {?} */ pipeMeta = _this.pipesByName.get(pipeName);
  24352. if (!pipeMeta) {
  24353. _this._reportError("The pipe '" + pipeName + "' could not be found", new ParseSourceSpan(sourceSpan.start.moveBy(ast.span.start), sourceSpan.start.moveBy(ast.span.end)));
  24354. }
  24355. else {
  24356. _this._usedPipes.set(pipeName, pipeMeta);
  24357. }
  24358. });
  24359. }
  24360. };
  24361. /**
  24362. * @param {?} propName the name of the property / attribute
  24363. * @param {?} sourceSpan
  24364. * @param {?} isAttr true when binding to an attribute
  24365. * @return {?}
  24366. */
  24367. BindingParser.prototype._validatePropertyOrAttributeName = /**
  24368. * @param {?} propName the name of the property / attribute
  24369. * @param {?} sourceSpan
  24370. * @param {?} isAttr true when binding to an attribute
  24371. * @return {?}
  24372. */
  24373. function (propName, sourceSpan, isAttr) {
  24374. var /** @type {?} */ report = isAttr ? this._schemaRegistry.validateAttribute(propName) :
  24375. this._schemaRegistry.validateProperty(propName);
  24376. if (report.error) {
  24377. this._reportError(/** @type {?} */ ((report.msg)), sourceSpan, ParseErrorLevel.ERROR);
  24378. }
  24379. };
  24380. return BindingParser;
  24381. }());
  24382. var PipeCollector = /** @class */ (function (_super) {
  24383. __extends(PipeCollector, _super);
  24384. function PipeCollector() {
  24385. var _this = _super !== null && _super.apply(this, arguments) || this;
  24386. _this.pipes = new Map();
  24387. return _this;
  24388. }
  24389. /**
  24390. * @param {?} ast
  24391. * @param {?} context
  24392. * @return {?}
  24393. */
  24394. PipeCollector.prototype.visitPipe = /**
  24395. * @param {?} ast
  24396. * @param {?} context
  24397. * @return {?}
  24398. */
  24399. function (ast, context) {
  24400. this.pipes.set(ast.name, ast);
  24401. ast.exp.visit(this);
  24402. this.visitAll(ast.args, context);
  24403. return null;
  24404. };
  24405. return PipeCollector;
  24406. }(RecursiveAstVisitor));
  24407. /**
  24408. * @param {?} name
  24409. * @return {?}
  24410. */
  24411. function _isAnimationLabel(name) {
  24412. return name[0] == '@';
  24413. }
  24414. /**
  24415. * @param {?} registry
  24416. * @param {?} selector
  24417. * @param {?} propName
  24418. * @param {?} isAttribute
  24419. * @return {?}
  24420. */
  24421. function calcPossibleSecurityContexts(registry, selector, propName, isAttribute) {
  24422. var /** @type {?} */ ctxs = [];
  24423. CssSelector.parse(selector).forEach(function (selector) {
  24424. var /** @type {?} */ elementNames = selector.element ? [selector.element] : registry.allKnownElementNames();
  24425. var /** @type {?} */ notElementNames = new Set(selector.notSelectors.filter(function (selector) { return selector.isElementSelector(); })
  24426. .map(function (selector) { return selector.element; }));
  24427. var /** @type {?} */ possibleElementNames = elementNames.filter(function (elementName) { return !notElementNames.has(elementName); });
  24428. ctxs.push.apply(ctxs, possibleElementNames.map(function (elementName) { return registry.securityContext(elementName, propName, isAttribute); }));
  24429. });
  24430. return ctxs.length === 0 ? [SecurityContext.NONE] : Array.from(new Set(ctxs)).sort();
  24431. }
  24432. /**
  24433. * @fileoverview added by tsickle
  24434. * @suppress {checkTypes} checked by tsc
  24435. */
  24436. /**
  24437. * @license
  24438. * Copyright Google Inc. All Rights Reserved.
  24439. *
  24440. * Use of this source code is governed by an MIT-style license that can be
  24441. * found in the LICENSE file at https://angular.io/license
  24442. */
  24443. var BIND_NAME_REGEXP = /^(?:(?:(?:(bind-)|(let-)|(ref-|#)|(on-)|(bindon-)|(@))(.+))|\[\(([^\)]+)\)\]|\[([^\]]+)\]|\(([^\)]+)\))$/;
  24444. // Group 1 = "bind-"
  24445. var KW_BIND_IDX = 1;
  24446. // Group 2 = "let-"
  24447. var KW_LET_IDX = 2;
  24448. // Group 3 = "ref-/#"
  24449. var KW_REF_IDX = 3;
  24450. // Group 4 = "on-"
  24451. var KW_ON_IDX = 4;
  24452. // Group 5 = "bindon-"
  24453. var KW_BINDON_IDX = 5;
  24454. // Group 6 = "@"
  24455. var KW_AT_IDX = 6;
  24456. // Group 7 = the identifier after "bind-", "let-", "ref-/#", "on-", "bindon-" or "@"
  24457. var IDENT_KW_IDX = 7;
  24458. // Group 8 = identifier inside [()]
  24459. var IDENT_BANANA_BOX_IDX = 8;
  24460. // Group 9 = identifier inside []
  24461. var IDENT_PROPERTY_IDX = 9;
  24462. // Group 10 = identifier inside ()
  24463. var IDENT_EVENT_IDX = 10;
  24464. // deprecated in 4.x
  24465. var TEMPLATE_ELEMENT = 'template';
  24466. // deprecated in 4.x
  24467. var TEMPLATE_ATTR = 'template';
  24468. var TEMPLATE_ATTR_PREFIX = '*';
  24469. var CLASS_ATTR = 'class';
  24470. var TEXT_CSS_SELECTOR = CssSelector.parse('*')[0];
  24471. var TEMPLATE_ELEMENT_DEPRECATION_WARNING = 'The <template> element is deprecated. Use <ng-template> instead';
  24472. var TEMPLATE_ATTR_DEPRECATION_WARNING = 'The template attribute is deprecated. Use an ng-template element instead.';
  24473. var warningCounts = {};
  24474. /**
  24475. * @param {?} warnings
  24476. * @return {?}
  24477. */
  24478. function warnOnlyOnce(warnings) {
  24479. return function (error) {
  24480. if (warnings.indexOf(error.msg) !== -1) {
  24481. warningCounts[error.msg] = (warningCounts[error.msg] || 0) + 1;
  24482. return warningCounts[error.msg] <= 1;
  24483. }
  24484. return true;
  24485. };
  24486. }
  24487. var TemplateParseError = /** @class */ (function (_super) {
  24488. __extends(TemplateParseError, _super);
  24489. function TemplateParseError(message, span, level) {
  24490. return _super.call(this, span, message, level) || this;
  24491. }
  24492. return TemplateParseError;
  24493. }(ParseError));
  24494. var TemplateParseResult = /** @class */ (function () {
  24495. function TemplateParseResult(templateAst, usedPipes, errors) {
  24496. this.templateAst = templateAst;
  24497. this.usedPipes = usedPipes;
  24498. this.errors = errors;
  24499. }
  24500. return TemplateParseResult;
  24501. }());
  24502. var TemplateParser = /** @class */ (function () {
  24503. function TemplateParser(_config, _reflector, _exprParser, _schemaRegistry, _htmlParser, _console, transforms) {
  24504. this._config = _config;
  24505. this._reflector = _reflector;
  24506. this._exprParser = _exprParser;
  24507. this._schemaRegistry = _schemaRegistry;
  24508. this._htmlParser = _htmlParser;
  24509. this._console = _console;
  24510. this.transforms = transforms;
  24511. }
  24512. /**
  24513. * @param {?} component
  24514. * @param {?} template
  24515. * @param {?} directives
  24516. * @param {?} pipes
  24517. * @param {?} schemas
  24518. * @param {?} templateUrl
  24519. * @param {?} preserveWhitespaces
  24520. * @return {?}
  24521. */
  24522. TemplateParser.prototype.parse = /**
  24523. * @param {?} component
  24524. * @param {?} template
  24525. * @param {?} directives
  24526. * @param {?} pipes
  24527. * @param {?} schemas
  24528. * @param {?} templateUrl
  24529. * @param {?} preserveWhitespaces
  24530. * @return {?}
  24531. */
  24532. function (component, template, directives, pipes, schemas, templateUrl, preserveWhitespaces) {
  24533. var /** @type {?} */ result = this.tryParse(component, template, directives, pipes, schemas, templateUrl, preserveWhitespaces);
  24534. var /** @type {?} */ warnings = /** @type {?} */ ((result.errors)).filter(function (error) { return error.level === ParseErrorLevel.WARNING; }).filter(warnOnlyOnce([TEMPLATE_ATTR_DEPRECATION_WARNING, TEMPLATE_ELEMENT_DEPRECATION_WARNING]));
  24535. var /** @type {?} */ errors = /** @type {?} */ ((result.errors)).filter(function (error) { return error.level === ParseErrorLevel.ERROR; });
  24536. if (warnings.length > 0) {
  24537. this._console.warn("Template parse warnings:\n" + warnings.join('\n'));
  24538. }
  24539. if (errors.length > 0) {
  24540. var /** @type {?} */ errorString = errors.join('\n');
  24541. throw syntaxError("Template parse errors:\n" + errorString, errors);
  24542. }
  24543. return { template: /** @type {?} */ ((result.templateAst)), pipes: /** @type {?} */ ((result.usedPipes)) };
  24544. };
  24545. /**
  24546. * @param {?} component
  24547. * @param {?} template
  24548. * @param {?} directives
  24549. * @param {?} pipes
  24550. * @param {?} schemas
  24551. * @param {?} templateUrl
  24552. * @param {?} preserveWhitespaces
  24553. * @return {?}
  24554. */
  24555. TemplateParser.prototype.tryParse = /**
  24556. * @param {?} component
  24557. * @param {?} template
  24558. * @param {?} directives
  24559. * @param {?} pipes
  24560. * @param {?} schemas
  24561. * @param {?} templateUrl
  24562. * @param {?} preserveWhitespaces
  24563. * @return {?}
  24564. */
  24565. function (component, template, directives, pipes, schemas, templateUrl, preserveWhitespaces) {
  24566. var /** @type {?} */ htmlParseResult = typeof template === 'string' ? /** @type {?} */ ((this._htmlParser)).parse(template, templateUrl, true, this.getInterpolationConfig(component)) :
  24567. template;
  24568. if (!preserveWhitespaces) {
  24569. htmlParseResult = removeWhitespaces(htmlParseResult);
  24570. }
  24571. return this.tryParseHtml(this.expandHtml(htmlParseResult), component, directives, pipes, schemas);
  24572. };
  24573. /**
  24574. * @param {?} htmlAstWithErrors
  24575. * @param {?} component
  24576. * @param {?} directives
  24577. * @param {?} pipes
  24578. * @param {?} schemas
  24579. * @return {?}
  24580. */
  24581. TemplateParser.prototype.tryParseHtml = /**
  24582. * @param {?} htmlAstWithErrors
  24583. * @param {?} component
  24584. * @param {?} directives
  24585. * @param {?} pipes
  24586. * @param {?} schemas
  24587. * @return {?}
  24588. */
  24589. function (htmlAstWithErrors, component, directives, pipes, schemas) {
  24590. var /** @type {?} */ result;
  24591. var /** @type {?} */ errors = htmlAstWithErrors.errors;
  24592. var /** @type {?} */ usedPipes = [];
  24593. if (htmlAstWithErrors.rootNodes.length > 0) {
  24594. var /** @type {?} */ uniqDirectives = removeSummaryDuplicates(directives);
  24595. var /** @type {?} */ uniqPipes = removeSummaryDuplicates(pipes);
  24596. var /** @type {?} */ providerViewContext = new ProviderViewContext(this._reflector, component);
  24597. var /** @type {?} */ interpolationConfig = /** @type {?} */ ((undefined));
  24598. if (component.template && component.template.interpolation) {
  24599. interpolationConfig = {
  24600. start: component.template.interpolation[0],
  24601. end: component.template.interpolation[1]
  24602. };
  24603. }
  24604. var /** @type {?} */ bindingParser = new BindingParser(this._exprParser, /** @type {?} */ ((interpolationConfig)), this._schemaRegistry, uniqPipes, errors);
  24605. var /** @type {?} */ parseVisitor = new TemplateParseVisitor(this._reflector, this._config, providerViewContext, uniqDirectives, bindingParser, this._schemaRegistry, schemas, errors);
  24606. result = visitAll(parseVisitor, htmlAstWithErrors.rootNodes, EMPTY_ELEMENT_CONTEXT);
  24607. errors.push.apply(errors, providerViewContext.errors);
  24608. usedPipes.push.apply(usedPipes, bindingParser.getUsedPipes());
  24609. }
  24610. else {
  24611. result = [];
  24612. }
  24613. this._assertNoReferenceDuplicationOnTemplate(result, errors);
  24614. if (errors.length > 0) {
  24615. return new TemplateParseResult(result, usedPipes, errors);
  24616. }
  24617. if (this.transforms) {
  24618. this.transforms.forEach(function (transform) { result = templateVisitAll(transform, result); });
  24619. }
  24620. return new TemplateParseResult(result, usedPipes, errors);
  24621. };
  24622. /**
  24623. * @param {?} htmlAstWithErrors
  24624. * @param {?=} forced
  24625. * @return {?}
  24626. */
  24627. TemplateParser.prototype.expandHtml = /**
  24628. * @param {?} htmlAstWithErrors
  24629. * @param {?=} forced
  24630. * @return {?}
  24631. */
  24632. function (htmlAstWithErrors, forced) {
  24633. if (forced === void 0) { forced = false; }
  24634. var /** @type {?} */ errors = htmlAstWithErrors.errors;
  24635. if (errors.length == 0 || forced) {
  24636. // Transform ICU messages to angular directives
  24637. var /** @type {?} */ expandedHtmlAst = expandNodes(htmlAstWithErrors.rootNodes);
  24638. errors.push.apply(errors, expandedHtmlAst.errors);
  24639. htmlAstWithErrors = new ParseTreeResult(expandedHtmlAst.nodes, errors);
  24640. }
  24641. return htmlAstWithErrors;
  24642. };
  24643. /**
  24644. * @param {?} component
  24645. * @return {?}
  24646. */
  24647. TemplateParser.prototype.getInterpolationConfig = /**
  24648. * @param {?} component
  24649. * @return {?}
  24650. */
  24651. function (component) {
  24652. if (component.template) {
  24653. return InterpolationConfig.fromArray(component.template.interpolation);
  24654. }
  24655. return undefined;
  24656. };
  24657. /** @internal */
  24658. /**
  24659. * \@internal
  24660. * @param {?} result
  24661. * @param {?} errors
  24662. * @return {?}
  24663. */
  24664. TemplateParser.prototype._assertNoReferenceDuplicationOnTemplate = /**
  24665. * \@internal
  24666. * @param {?} result
  24667. * @param {?} errors
  24668. * @return {?}
  24669. */
  24670. function (result, errors) {
  24671. var /** @type {?} */ existingReferences = [];
  24672. result.filter(function (element) { return !!(/** @type {?} */ (element)).references; })
  24673. .forEach(function (element) {
  24674. return (/** @type {?} */ (element)).references.forEach(function (reference) {
  24675. var /** @type {?} */ name = reference.name;
  24676. if (existingReferences.indexOf(name) < 0) {
  24677. existingReferences.push(name);
  24678. }
  24679. else {
  24680. var /** @type {?} */ error = new TemplateParseError("Reference \"#" + name + "\" is defined several times", reference.sourceSpan, ParseErrorLevel.ERROR);
  24681. errors.push(error);
  24682. }
  24683. });
  24684. });
  24685. };
  24686. return TemplateParser;
  24687. }());
  24688. var TemplateParseVisitor = /** @class */ (function () {
  24689. function TemplateParseVisitor(reflector, config, providerViewContext, directives, _bindingParser, _schemaRegistry, _schemas, _targetErrors) {
  24690. var _this = this;
  24691. this.reflector = reflector;
  24692. this.config = config;
  24693. this.providerViewContext = providerViewContext;
  24694. this._bindingParser = _bindingParser;
  24695. this._schemaRegistry = _schemaRegistry;
  24696. this._schemas = _schemas;
  24697. this._targetErrors = _targetErrors;
  24698. this.selectorMatcher = new SelectorMatcher();
  24699. this.directivesIndex = new Map();
  24700. this.ngContentCount = 0;
  24701. // Note: queries start with id 1 so we can use the number in a Bloom filter!
  24702. this.contentQueryStartId = providerViewContext.component.viewQueries.length + 1;
  24703. directives.forEach(function (directive, index) {
  24704. var /** @type {?} */ selector = CssSelector.parse(/** @type {?} */ ((directive.selector)));
  24705. _this.selectorMatcher.addSelectables(selector, directive);
  24706. _this.directivesIndex.set(directive, index);
  24707. });
  24708. }
  24709. /**
  24710. * @param {?} expansion
  24711. * @param {?} context
  24712. * @return {?}
  24713. */
  24714. TemplateParseVisitor.prototype.visitExpansion = /**
  24715. * @param {?} expansion
  24716. * @param {?} context
  24717. * @return {?}
  24718. */
  24719. function (expansion, context) { return null; };
  24720. /**
  24721. * @param {?} expansionCase
  24722. * @param {?} context
  24723. * @return {?}
  24724. */
  24725. TemplateParseVisitor.prototype.visitExpansionCase = /**
  24726. * @param {?} expansionCase
  24727. * @param {?} context
  24728. * @return {?}
  24729. */
  24730. function (expansionCase, context) { return null; };
  24731. /**
  24732. * @param {?} text
  24733. * @param {?} parent
  24734. * @return {?}
  24735. */
  24736. TemplateParseVisitor.prototype.visitText = /**
  24737. * @param {?} text
  24738. * @param {?} parent
  24739. * @return {?}
  24740. */
  24741. function (text, parent) {
  24742. var /** @type {?} */ ngContentIndex = /** @type {?} */ ((parent.findNgContentIndex(TEXT_CSS_SELECTOR)));
  24743. var /** @type {?} */ valueNoNgsp = replaceNgsp(text.value);
  24744. var /** @type {?} */ expr = this._bindingParser.parseInterpolation(valueNoNgsp, /** @type {?} */ ((text.sourceSpan)));
  24745. return expr ? new BoundTextAst(expr, ngContentIndex, /** @type {?} */ ((text.sourceSpan))) :
  24746. new TextAst(valueNoNgsp, ngContentIndex, /** @type {?} */ ((text.sourceSpan)));
  24747. };
  24748. /**
  24749. * @param {?} attribute
  24750. * @param {?} context
  24751. * @return {?}
  24752. */
  24753. TemplateParseVisitor.prototype.visitAttribute = /**
  24754. * @param {?} attribute
  24755. * @param {?} context
  24756. * @return {?}
  24757. */
  24758. function (attribute, context) {
  24759. return new AttrAst(attribute.name, attribute.value, attribute.sourceSpan);
  24760. };
  24761. /**
  24762. * @param {?} comment
  24763. * @param {?} context
  24764. * @return {?}
  24765. */
  24766. TemplateParseVisitor.prototype.visitComment = /**
  24767. * @param {?} comment
  24768. * @param {?} context
  24769. * @return {?}
  24770. */
  24771. function (comment, context) { return null; };
  24772. /**
  24773. * @param {?} element
  24774. * @param {?} parent
  24775. * @return {?}
  24776. */
  24777. TemplateParseVisitor.prototype.visitElement = /**
  24778. * @param {?} element
  24779. * @param {?} parent
  24780. * @return {?}
  24781. */
  24782. function (element, parent) {
  24783. var _this = this;
  24784. var /** @type {?} */ queryStartIndex = this.contentQueryStartId;
  24785. var /** @type {?} */ nodeName = element.name;
  24786. var /** @type {?} */ preparsedElement = preparseElement(element);
  24787. if (preparsedElement.type === PreparsedElementType.SCRIPT ||
  24788. preparsedElement.type === PreparsedElementType.STYLE) {
  24789. // Skipping <script> for security reasons
  24790. // Skipping <style> as we already processed them
  24791. // in the StyleCompiler
  24792. return null;
  24793. }
  24794. if (preparsedElement.type === PreparsedElementType.STYLESHEET &&
  24795. isStyleUrlResolvable(preparsedElement.hrefAttr)) {
  24796. // Skipping stylesheets with either relative urls or package scheme as we already processed
  24797. // them in the StyleCompiler
  24798. return null;
  24799. }
  24800. var /** @type {?} */ matchableAttrs = [];
  24801. var /** @type {?} */ elementOrDirectiveProps = [];
  24802. var /** @type {?} */ elementOrDirectiveRefs = [];
  24803. var /** @type {?} */ elementVars = [];
  24804. var /** @type {?} */ events = [];
  24805. var /** @type {?} */ templateElementOrDirectiveProps = [];
  24806. var /** @type {?} */ templateMatchableAttrs = [];
  24807. var /** @type {?} */ templateElementVars = [];
  24808. var /** @type {?} */ hasInlineTemplates = false;
  24809. var /** @type {?} */ attrs = [];
  24810. var /** @type {?} */ isTemplateElement = isTemplate(element, this.config.enableLegacyTemplate, function (m, span) { return _this._reportError(m, span, ParseErrorLevel.WARNING); });
  24811. element.attrs.forEach(function (attr) {
  24812. var /** @type {?} */ hasBinding = _this._parseAttr(isTemplateElement, attr, matchableAttrs, elementOrDirectiveProps, events, elementOrDirectiveRefs, elementVars);
  24813. var /** @type {?} */ templateBindingsSource;
  24814. var /** @type {?} */ prefixToken;
  24815. var /** @type {?} */ normalizedName = _this._normalizeAttributeName(attr.name);
  24816. if (_this.config.enableLegacyTemplate && normalizedName == TEMPLATE_ATTR) {
  24817. _this._reportError(TEMPLATE_ATTR_DEPRECATION_WARNING, attr.sourceSpan, ParseErrorLevel.WARNING);
  24818. templateBindingsSource = attr.value;
  24819. }
  24820. else if (normalizedName.startsWith(TEMPLATE_ATTR_PREFIX)) {
  24821. templateBindingsSource = attr.value;
  24822. prefixToken = normalizedName.substring(TEMPLATE_ATTR_PREFIX.length) + ':';
  24823. }
  24824. var /** @type {?} */ hasTemplateBinding = templateBindingsSource != null;
  24825. if (hasTemplateBinding) {
  24826. if (hasInlineTemplates) {
  24827. _this._reportError("Can't have multiple template bindings on one element. Use only one attribute named 'template' or prefixed with *", attr.sourceSpan);
  24828. }
  24829. hasInlineTemplates = true;
  24830. _this._bindingParser.parseInlineTemplateBinding(/** @type {?} */ ((prefixToken)), /** @type {?} */ ((templateBindingsSource)), attr.sourceSpan, templateMatchableAttrs, templateElementOrDirectiveProps, templateElementVars);
  24831. }
  24832. if (!hasBinding && !hasTemplateBinding) {
  24833. // don't include the bindings as attributes as well in the AST
  24834. attrs.push(_this.visitAttribute(attr, null));
  24835. matchableAttrs.push([attr.name, attr.value]);
  24836. }
  24837. });
  24838. var /** @type {?} */ elementCssSelector = createElementCssSelector(nodeName, matchableAttrs);
  24839. var _a = this._parseDirectives(this.selectorMatcher, elementCssSelector), directiveMetas = _a.directives, matchElement = _a.matchElement;
  24840. var /** @type {?} */ references = [];
  24841. var /** @type {?} */ boundDirectivePropNames = new Set();
  24842. var /** @type {?} */ directiveAsts = this._createDirectiveAsts(isTemplateElement, element.name, directiveMetas, elementOrDirectiveProps, elementOrDirectiveRefs, /** @type {?} */ ((element.sourceSpan)), references, boundDirectivePropNames);
  24843. var /** @type {?} */ elementProps = this._createElementPropertyAsts(element.name, elementOrDirectiveProps, boundDirectivePropNames);
  24844. var /** @type {?} */ isViewRoot = parent.isTemplateElement || hasInlineTemplates;
  24845. var /** @type {?} */ providerContext = new ProviderElementContext(this.providerViewContext, /** @type {?} */ ((parent.providerContext)), isViewRoot, directiveAsts, attrs, references, isTemplateElement, queryStartIndex, /** @type {?} */ ((element.sourceSpan)));
  24846. var /** @type {?} */ children = visitAll(preparsedElement.nonBindable ? NON_BINDABLE_VISITOR : this, element.children, ElementContext.create(isTemplateElement, directiveAsts, isTemplateElement ? /** @type {?} */ ((parent.providerContext)) : providerContext));
  24847. providerContext.afterElement();
  24848. // Override the actual selector when the `ngProjectAs` attribute is provided
  24849. var /** @type {?} */ projectionSelector = preparsedElement.projectAs != null ?
  24850. CssSelector.parse(preparsedElement.projectAs)[0] :
  24851. elementCssSelector;
  24852. var /** @type {?} */ ngContentIndex = /** @type {?} */ ((parent.findNgContentIndex(projectionSelector)));
  24853. var /** @type {?} */ parsedElement;
  24854. if (preparsedElement.type === PreparsedElementType.NG_CONTENT) {
  24855. if (element.children && !element.children.every(_isEmptyTextNode)) {
  24856. this._reportError("<ng-content> element cannot have content.", /** @type {?} */ ((element.sourceSpan)));
  24857. }
  24858. parsedElement = new NgContentAst(this.ngContentCount++, hasInlineTemplates ? /** @type {?} */ ((null)) : ngContentIndex, /** @type {?} */ ((element.sourceSpan)));
  24859. }
  24860. else if (isTemplateElement) {
  24861. this._assertAllEventsPublishedByDirectives(directiveAsts, events);
  24862. this._assertNoComponentsNorElementBindingsOnTemplate(directiveAsts, elementProps, /** @type {?} */ ((element.sourceSpan)));
  24863. parsedElement = new EmbeddedTemplateAst(attrs, events, references, elementVars, providerContext.transformedDirectiveAsts, providerContext.transformProviders, providerContext.transformedHasViewContainer, providerContext.queryMatches, children, hasInlineTemplates ? /** @type {?} */ ((null)) : ngContentIndex, /** @type {?} */ ((element.sourceSpan)));
  24864. }
  24865. else {
  24866. this._assertElementExists(matchElement, element);
  24867. this._assertOnlyOneComponent(directiveAsts, /** @type {?} */ ((element.sourceSpan)));
  24868. var /** @type {?} */ ngContentIndex_1 = hasInlineTemplates ? null : parent.findNgContentIndex(projectionSelector);
  24869. parsedElement = new ElementAst(nodeName, attrs, elementProps, events, references, providerContext.transformedDirectiveAsts, providerContext.transformProviders, providerContext.transformedHasViewContainer, providerContext.queryMatches, children, hasInlineTemplates ? null : ngContentIndex_1, element.sourceSpan, element.endSourceSpan || null);
  24870. }
  24871. if (hasInlineTemplates) {
  24872. var /** @type {?} */ templateQueryStartIndex = this.contentQueryStartId;
  24873. var /** @type {?} */ templateSelector = createElementCssSelector(TEMPLATE_ELEMENT, templateMatchableAttrs);
  24874. var templateDirectiveMetas = this._parseDirectives(this.selectorMatcher, templateSelector).directives;
  24875. var /** @type {?} */ templateBoundDirectivePropNames = new Set();
  24876. var /** @type {?} */ templateDirectiveAsts = this._createDirectiveAsts(true, element.name, templateDirectiveMetas, templateElementOrDirectiveProps, [], /** @type {?} */ ((element.sourceSpan)), [], templateBoundDirectivePropNames);
  24877. var /** @type {?} */ templateElementProps = this._createElementPropertyAsts(element.name, templateElementOrDirectiveProps, templateBoundDirectivePropNames);
  24878. this._assertNoComponentsNorElementBindingsOnTemplate(templateDirectiveAsts, templateElementProps, /** @type {?} */ ((element.sourceSpan)));
  24879. var /** @type {?} */ templateProviderContext = new ProviderElementContext(this.providerViewContext, /** @type {?} */ ((parent.providerContext)), parent.isTemplateElement, templateDirectiveAsts, [], [], true, templateQueryStartIndex, /** @type {?} */ ((element.sourceSpan)));
  24880. templateProviderContext.afterElement();
  24881. parsedElement = new EmbeddedTemplateAst([], [], [], templateElementVars, templateProviderContext.transformedDirectiveAsts, templateProviderContext.transformProviders, templateProviderContext.transformedHasViewContainer, templateProviderContext.queryMatches, [parsedElement], ngContentIndex, /** @type {?} */ ((element.sourceSpan)));
  24882. }
  24883. return parsedElement;
  24884. };
  24885. /**
  24886. * @param {?} isTemplateElement
  24887. * @param {?} attr
  24888. * @param {?} targetMatchableAttrs
  24889. * @param {?} targetProps
  24890. * @param {?} targetEvents
  24891. * @param {?} targetRefs
  24892. * @param {?} targetVars
  24893. * @return {?}
  24894. */
  24895. TemplateParseVisitor.prototype._parseAttr = /**
  24896. * @param {?} isTemplateElement
  24897. * @param {?} attr
  24898. * @param {?} targetMatchableAttrs
  24899. * @param {?} targetProps
  24900. * @param {?} targetEvents
  24901. * @param {?} targetRefs
  24902. * @param {?} targetVars
  24903. * @return {?}
  24904. */
  24905. function (isTemplateElement, attr, targetMatchableAttrs, targetProps, targetEvents, targetRefs, targetVars) {
  24906. var /** @type {?} */ name = this._normalizeAttributeName(attr.name);
  24907. var /** @type {?} */ value = attr.value;
  24908. var /** @type {?} */ srcSpan = attr.sourceSpan;
  24909. var /** @type {?} */ bindParts = name.match(BIND_NAME_REGEXP);
  24910. var /** @type {?} */ hasBinding = false;
  24911. if (bindParts !== null) {
  24912. hasBinding = true;
  24913. if (bindParts[KW_BIND_IDX] != null) {
  24914. this._bindingParser.parsePropertyBinding(bindParts[IDENT_KW_IDX], value, false, srcSpan, targetMatchableAttrs, targetProps);
  24915. }
  24916. else if (bindParts[KW_LET_IDX]) {
  24917. if (isTemplateElement) {
  24918. var /** @type {?} */ identifier = bindParts[IDENT_KW_IDX];
  24919. this._parseVariable(identifier, value, srcSpan, targetVars);
  24920. }
  24921. else {
  24922. this._reportError("\"let-\" is only supported on ng-template elements.", srcSpan);
  24923. }
  24924. }
  24925. else if (bindParts[KW_REF_IDX]) {
  24926. var /** @type {?} */ identifier = bindParts[IDENT_KW_IDX];
  24927. this._parseReference(identifier, value, srcSpan, targetRefs);
  24928. }
  24929. else if (bindParts[KW_ON_IDX]) {
  24930. this._bindingParser.parseEvent(bindParts[IDENT_KW_IDX], value, srcSpan, targetMatchableAttrs, targetEvents);
  24931. }
  24932. else if (bindParts[KW_BINDON_IDX]) {
  24933. this._bindingParser.parsePropertyBinding(bindParts[IDENT_KW_IDX], value, false, srcSpan, targetMatchableAttrs, targetProps);
  24934. this._parseAssignmentEvent(bindParts[IDENT_KW_IDX], value, srcSpan, targetMatchableAttrs, targetEvents);
  24935. }
  24936. else if (bindParts[KW_AT_IDX]) {
  24937. this._bindingParser.parseLiteralAttr(name, value, srcSpan, targetMatchableAttrs, targetProps);
  24938. }
  24939. else if (bindParts[IDENT_BANANA_BOX_IDX]) {
  24940. this._bindingParser.parsePropertyBinding(bindParts[IDENT_BANANA_BOX_IDX], value, false, srcSpan, targetMatchableAttrs, targetProps);
  24941. this._parseAssignmentEvent(bindParts[IDENT_BANANA_BOX_IDX], value, srcSpan, targetMatchableAttrs, targetEvents);
  24942. }
  24943. else if (bindParts[IDENT_PROPERTY_IDX]) {
  24944. this._bindingParser.parsePropertyBinding(bindParts[IDENT_PROPERTY_IDX], value, false, srcSpan, targetMatchableAttrs, targetProps);
  24945. }
  24946. else if (bindParts[IDENT_EVENT_IDX]) {
  24947. this._bindingParser.parseEvent(bindParts[IDENT_EVENT_IDX], value, srcSpan, targetMatchableAttrs, targetEvents);
  24948. }
  24949. }
  24950. else {
  24951. hasBinding = this._bindingParser.parsePropertyInterpolation(name, value, srcSpan, targetMatchableAttrs, targetProps);
  24952. }
  24953. if (!hasBinding) {
  24954. this._bindingParser.parseLiteralAttr(name, value, srcSpan, targetMatchableAttrs, targetProps);
  24955. }
  24956. return hasBinding;
  24957. };
  24958. /**
  24959. * @param {?} attrName
  24960. * @return {?}
  24961. */
  24962. TemplateParseVisitor.prototype._normalizeAttributeName = /**
  24963. * @param {?} attrName
  24964. * @return {?}
  24965. */
  24966. function (attrName) {
  24967. return /^data-/i.test(attrName) ? attrName.substring(5) : attrName;
  24968. };
  24969. /**
  24970. * @param {?} identifier
  24971. * @param {?} value
  24972. * @param {?} sourceSpan
  24973. * @param {?} targetVars
  24974. * @return {?}
  24975. */
  24976. TemplateParseVisitor.prototype._parseVariable = /**
  24977. * @param {?} identifier
  24978. * @param {?} value
  24979. * @param {?} sourceSpan
  24980. * @param {?} targetVars
  24981. * @return {?}
  24982. */
  24983. function (identifier, value, sourceSpan, targetVars) {
  24984. if (identifier.indexOf('-') > -1) {
  24985. this._reportError("\"-\" is not allowed in variable names", sourceSpan);
  24986. }
  24987. targetVars.push(new VariableAst(identifier, value, sourceSpan));
  24988. };
  24989. /**
  24990. * @param {?} identifier
  24991. * @param {?} value
  24992. * @param {?} sourceSpan
  24993. * @param {?} targetRefs
  24994. * @return {?}
  24995. */
  24996. TemplateParseVisitor.prototype._parseReference = /**
  24997. * @param {?} identifier
  24998. * @param {?} value
  24999. * @param {?} sourceSpan
  25000. * @param {?} targetRefs
  25001. * @return {?}
  25002. */
  25003. function (identifier, value, sourceSpan, targetRefs) {
  25004. if (identifier.indexOf('-') > -1) {
  25005. this._reportError("\"-\" is not allowed in reference names", sourceSpan);
  25006. }
  25007. targetRefs.push(new ElementOrDirectiveRef(identifier, value, sourceSpan));
  25008. };
  25009. /**
  25010. * @param {?} name
  25011. * @param {?} expression
  25012. * @param {?} sourceSpan
  25013. * @param {?} targetMatchableAttrs
  25014. * @param {?} targetEvents
  25015. * @return {?}
  25016. */
  25017. TemplateParseVisitor.prototype._parseAssignmentEvent = /**
  25018. * @param {?} name
  25019. * @param {?} expression
  25020. * @param {?} sourceSpan
  25021. * @param {?} targetMatchableAttrs
  25022. * @param {?} targetEvents
  25023. * @return {?}
  25024. */
  25025. function (name, expression, sourceSpan, targetMatchableAttrs, targetEvents) {
  25026. this._bindingParser.parseEvent(name + "Change", expression + "=$event", sourceSpan, targetMatchableAttrs, targetEvents);
  25027. };
  25028. /**
  25029. * @param {?} selectorMatcher
  25030. * @param {?} elementCssSelector
  25031. * @return {?}
  25032. */
  25033. TemplateParseVisitor.prototype._parseDirectives = /**
  25034. * @param {?} selectorMatcher
  25035. * @param {?} elementCssSelector
  25036. * @return {?}
  25037. */
  25038. function (selectorMatcher, elementCssSelector) {
  25039. var _this = this;
  25040. // Need to sort the directives so that we get consistent results throughout,
  25041. // as selectorMatcher uses Maps inside.
  25042. // Also deduplicate directives as they might match more than one time!
  25043. var /** @type {?} */ directives = new Array(this.directivesIndex.size);
  25044. // Whether any directive selector matches on the element name
  25045. var /** @type {?} */ matchElement = false;
  25046. selectorMatcher.match(elementCssSelector, function (selector, directive) {
  25047. directives[/** @type {?} */ ((_this.directivesIndex.get(directive)))] = directive;
  25048. matchElement = matchElement || selector.hasElementSelector();
  25049. });
  25050. return {
  25051. directives: directives.filter(function (dir) { return !!dir; }),
  25052. matchElement: matchElement,
  25053. };
  25054. };
  25055. /**
  25056. * @param {?} isTemplateElement
  25057. * @param {?} elementName
  25058. * @param {?} directives
  25059. * @param {?} props
  25060. * @param {?} elementOrDirectiveRefs
  25061. * @param {?} elementSourceSpan
  25062. * @param {?} targetReferences
  25063. * @param {?} targetBoundDirectivePropNames
  25064. * @return {?}
  25065. */
  25066. TemplateParseVisitor.prototype._createDirectiveAsts = /**
  25067. * @param {?} isTemplateElement
  25068. * @param {?} elementName
  25069. * @param {?} directives
  25070. * @param {?} props
  25071. * @param {?} elementOrDirectiveRefs
  25072. * @param {?} elementSourceSpan
  25073. * @param {?} targetReferences
  25074. * @param {?} targetBoundDirectivePropNames
  25075. * @return {?}
  25076. */
  25077. function (isTemplateElement, elementName, directives, props, elementOrDirectiveRefs, elementSourceSpan, targetReferences, targetBoundDirectivePropNames) {
  25078. var _this = this;
  25079. var /** @type {?} */ matchedReferences = new Set();
  25080. var /** @type {?} */ component = /** @type {?} */ ((null));
  25081. var /** @type {?} */ directiveAsts = directives.map(function (directive) {
  25082. var /** @type {?} */ sourceSpan = new ParseSourceSpan(elementSourceSpan.start, elementSourceSpan.end, "Directive " + identifierName(directive.type));
  25083. if (directive.isComponent) {
  25084. component = directive;
  25085. }
  25086. var /** @type {?} */ directiveProperties = [];
  25087. var /** @type {?} */ hostProperties = /** @type {?} */ ((_this._bindingParser.createDirectiveHostPropertyAsts(directive, elementName, sourceSpan)));
  25088. // Note: We need to check the host properties here as well,
  25089. // as we don't know the element name in the DirectiveWrapperCompiler yet.
  25090. hostProperties = _this._checkPropertiesInSchema(elementName, hostProperties);
  25091. var /** @type {?} */ hostEvents = /** @type {?} */ ((_this._bindingParser.createDirectiveHostEventAsts(directive, sourceSpan)));
  25092. _this._createDirectivePropertyAsts(directive.inputs, props, directiveProperties, targetBoundDirectivePropNames);
  25093. elementOrDirectiveRefs.forEach(function (elOrDirRef) {
  25094. if ((elOrDirRef.value.length === 0 && directive.isComponent) ||
  25095. (elOrDirRef.isReferenceToDirective(directive))) {
  25096. targetReferences.push(new ReferenceAst(elOrDirRef.name, createTokenForReference(directive.type.reference), elOrDirRef.sourceSpan));
  25097. matchedReferences.add(elOrDirRef.name);
  25098. }
  25099. });
  25100. var /** @type {?} */ contentQueryStartId = _this.contentQueryStartId;
  25101. _this.contentQueryStartId += directive.queries.length;
  25102. return new DirectiveAst(directive, directiveProperties, hostProperties, hostEvents, contentQueryStartId, sourceSpan);
  25103. });
  25104. elementOrDirectiveRefs.forEach(function (elOrDirRef) {
  25105. if (elOrDirRef.value.length > 0) {
  25106. if (!matchedReferences.has(elOrDirRef.name)) {
  25107. _this._reportError("There is no directive with \"exportAs\" set to \"" + elOrDirRef.value + "\"", elOrDirRef.sourceSpan);
  25108. }
  25109. }
  25110. else if (!component) {
  25111. var /** @type {?} */ refToken = /** @type {?} */ ((null));
  25112. if (isTemplateElement) {
  25113. refToken = createTokenForExternalReference(_this.reflector, Identifiers.TemplateRef);
  25114. }
  25115. targetReferences.push(new ReferenceAst(elOrDirRef.name, refToken, elOrDirRef.sourceSpan));
  25116. }
  25117. });
  25118. return directiveAsts;
  25119. };
  25120. /**
  25121. * @param {?} directiveProperties
  25122. * @param {?} boundProps
  25123. * @param {?} targetBoundDirectiveProps
  25124. * @param {?} targetBoundDirectivePropNames
  25125. * @return {?}
  25126. */
  25127. TemplateParseVisitor.prototype._createDirectivePropertyAsts = /**
  25128. * @param {?} directiveProperties
  25129. * @param {?} boundProps
  25130. * @param {?} targetBoundDirectiveProps
  25131. * @param {?} targetBoundDirectivePropNames
  25132. * @return {?}
  25133. */
  25134. function (directiveProperties, boundProps, targetBoundDirectiveProps, targetBoundDirectivePropNames) {
  25135. if (directiveProperties) {
  25136. var /** @type {?} */ boundPropsByName_1 = new Map();
  25137. boundProps.forEach(function (boundProp) {
  25138. var /** @type {?} */ prevValue = boundPropsByName_1.get(boundProp.name);
  25139. if (!prevValue || prevValue.isLiteral) {
  25140. // give [a]="b" a higher precedence than a="b" on the same element
  25141. // give [a]="b" a higher precedence than a="b" on the same element
  25142. boundPropsByName_1.set(boundProp.name, boundProp);
  25143. }
  25144. });
  25145. Object.keys(directiveProperties).forEach(function (dirProp) {
  25146. var /** @type {?} */ elProp = directiveProperties[dirProp];
  25147. var /** @type {?} */ boundProp = boundPropsByName_1.get(elProp);
  25148. // Bindings are optional, so this binding only needs to be set up if an expression is given.
  25149. if (boundProp) {
  25150. targetBoundDirectivePropNames.add(boundProp.name);
  25151. if (!isEmptyExpression(boundProp.expression)) {
  25152. targetBoundDirectiveProps.push(new BoundDirectivePropertyAst(dirProp, boundProp.name, boundProp.expression, boundProp.sourceSpan));
  25153. }
  25154. }
  25155. });
  25156. }
  25157. };
  25158. /**
  25159. * @param {?} elementName
  25160. * @param {?} props
  25161. * @param {?} boundDirectivePropNames
  25162. * @return {?}
  25163. */
  25164. TemplateParseVisitor.prototype._createElementPropertyAsts = /**
  25165. * @param {?} elementName
  25166. * @param {?} props
  25167. * @param {?} boundDirectivePropNames
  25168. * @return {?}
  25169. */
  25170. function (elementName, props, boundDirectivePropNames) {
  25171. var _this = this;
  25172. var /** @type {?} */ boundElementProps = [];
  25173. props.forEach(function (prop) {
  25174. if (!prop.isLiteral && !boundDirectivePropNames.has(prop.name)) {
  25175. boundElementProps.push(_this._bindingParser.createElementPropertyAst(elementName, prop));
  25176. }
  25177. });
  25178. return this._checkPropertiesInSchema(elementName, boundElementProps);
  25179. };
  25180. /**
  25181. * @param {?} directives
  25182. * @return {?}
  25183. */
  25184. TemplateParseVisitor.prototype._findComponentDirectives = /**
  25185. * @param {?} directives
  25186. * @return {?}
  25187. */
  25188. function (directives) {
  25189. return directives.filter(function (directive) { return directive.directive.isComponent; });
  25190. };
  25191. /**
  25192. * @param {?} directives
  25193. * @return {?}
  25194. */
  25195. TemplateParseVisitor.prototype._findComponentDirectiveNames = /**
  25196. * @param {?} directives
  25197. * @return {?}
  25198. */
  25199. function (directives) {
  25200. return this._findComponentDirectives(directives)
  25201. .map(function (directive) { return ((identifierName(directive.directive.type))); });
  25202. };
  25203. /**
  25204. * @param {?} directives
  25205. * @param {?} sourceSpan
  25206. * @return {?}
  25207. */
  25208. TemplateParseVisitor.prototype._assertOnlyOneComponent = /**
  25209. * @param {?} directives
  25210. * @param {?} sourceSpan
  25211. * @return {?}
  25212. */
  25213. function (directives, sourceSpan) {
  25214. var /** @type {?} */ componentTypeNames = this._findComponentDirectiveNames(directives);
  25215. if (componentTypeNames.length > 1) {
  25216. this._reportError("More than one component matched on this element.\n" +
  25217. "Make sure that only one component's selector can match a given element.\n" +
  25218. ("Conflicting components: " + componentTypeNames.join(',')), sourceSpan);
  25219. }
  25220. };
  25221. /**
  25222. * Make sure that non-angular tags conform to the schemas.
  25223. *
  25224. * Note: An element is considered an angular tag when at least one directive selector matches the
  25225. * tag name.
  25226. *
  25227. * @param {?} matchElement Whether any directive has matched on the tag name
  25228. * @param {?} element the html element
  25229. * @return {?}
  25230. */
  25231. TemplateParseVisitor.prototype._assertElementExists = /**
  25232. * Make sure that non-angular tags conform to the schemas.
  25233. *
  25234. * Note: An element is considered an angular tag when at least one directive selector matches the
  25235. * tag name.
  25236. *
  25237. * @param {?} matchElement Whether any directive has matched on the tag name
  25238. * @param {?} element the html element
  25239. * @return {?}
  25240. */
  25241. function (matchElement, element) {
  25242. var /** @type {?} */ elName = element.name.replace(/^:xhtml:/, '');
  25243. if (!matchElement && !this._schemaRegistry.hasElement(elName, this._schemas)) {
  25244. var /** @type {?} */ errorMsg = "'" + elName + "' is not a known element:\n";
  25245. errorMsg +=
  25246. "1. If '" + elName + "' is an Angular component, then verify that it is part of this module.\n";
  25247. if (elName.indexOf('-') > -1) {
  25248. errorMsg +=
  25249. "2. If '" + elName + "' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.";
  25250. }
  25251. else {
  25252. errorMsg +=
  25253. "2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.";
  25254. }
  25255. this._reportError(errorMsg, /** @type {?} */ ((element.sourceSpan)));
  25256. }
  25257. };
  25258. /**
  25259. * @param {?} directives
  25260. * @param {?} elementProps
  25261. * @param {?} sourceSpan
  25262. * @return {?}
  25263. */
  25264. TemplateParseVisitor.prototype._assertNoComponentsNorElementBindingsOnTemplate = /**
  25265. * @param {?} directives
  25266. * @param {?} elementProps
  25267. * @param {?} sourceSpan
  25268. * @return {?}
  25269. */
  25270. function (directives, elementProps, sourceSpan) {
  25271. var _this = this;
  25272. var /** @type {?} */ componentTypeNames = this._findComponentDirectiveNames(directives);
  25273. if (componentTypeNames.length > 0) {
  25274. this._reportError("Components on an embedded template: " + componentTypeNames.join(','), sourceSpan);
  25275. }
  25276. elementProps.forEach(function (prop) {
  25277. _this._reportError("Property binding " + prop.name + " not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the \"@NgModule.declarations\".", sourceSpan);
  25278. });
  25279. };
  25280. /**
  25281. * @param {?} directives
  25282. * @param {?} events
  25283. * @return {?}
  25284. */
  25285. TemplateParseVisitor.prototype._assertAllEventsPublishedByDirectives = /**
  25286. * @param {?} directives
  25287. * @param {?} events
  25288. * @return {?}
  25289. */
  25290. function (directives, events) {
  25291. var _this = this;
  25292. var /** @type {?} */ allDirectiveEvents = new Set();
  25293. directives.forEach(function (directive) {
  25294. Object.keys(directive.directive.outputs).forEach(function (k) {
  25295. var /** @type {?} */ eventName = directive.directive.outputs[k];
  25296. allDirectiveEvents.add(eventName);
  25297. });
  25298. });
  25299. events.forEach(function (event) {
  25300. if (event.target != null || !allDirectiveEvents.has(event.name)) {
  25301. _this._reportError("Event binding " + event.fullName + " not emitted by any directive on an embedded template. Make sure that the event name is spelled correctly and all directives are listed in the \"@NgModule.declarations\".", event.sourceSpan);
  25302. }
  25303. });
  25304. };
  25305. /**
  25306. * @param {?} elementName
  25307. * @param {?} boundProps
  25308. * @return {?}
  25309. */
  25310. TemplateParseVisitor.prototype._checkPropertiesInSchema = /**
  25311. * @param {?} elementName
  25312. * @param {?} boundProps
  25313. * @return {?}
  25314. */
  25315. function (elementName, boundProps) {
  25316. var _this = this;
  25317. // Note: We can't filter out empty expressions before this method,
  25318. // as we still want to validate them!
  25319. return boundProps.filter(function (boundProp) {
  25320. if (boundProp.type === PropertyBindingType.Property &&
  25321. !_this._schemaRegistry.hasProperty(elementName, boundProp.name, _this._schemas)) {
  25322. var /** @type {?} */ errorMsg = "Can't bind to '" + boundProp.name + "' since it isn't a known property of '" + elementName + "'.";
  25323. if (elementName.startsWith('ng-')) {
  25324. errorMsg +=
  25325. "\n1. If '" + boundProp.name + "' is an Angular directive, then add 'CommonModule' to the '@NgModule.imports' of this component." +
  25326. "\n2. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.";
  25327. }
  25328. else if (elementName.indexOf('-') > -1) {
  25329. errorMsg +=
  25330. "\n1. If '" + elementName + "' is an Angular component and it has '" + boundProp.name + "' input, then verify that it is part of this module." +
  25331. ("\n2. If '" + elementName + "' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.") +
  25332. "\n3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.";
  25333. }
  25334. _this._reportError(errorMsg, boundProp.sourceSpan);
  25335. }
  25336. return !isEmptyExpression(boundProp.value);
  25337. });
  25338. };
  25339. /**
  25340. * @param {?} message
  25341. * @param {?} sourceSpan
  25342. * @param {?=} level
  25343. * @return {?}
  25344. */
  25345. TemplateParseVisitor.prototype._reportError = /**
  25346. * @param {?} message
  25347. * @param {?} sourceSpan
  25348. * @param {?=} level
  25349. * @return {?}
  25350. */
  25351. function (message, sourceSpan, level) {
  25352. if (level === void 0) { level = ParseErrorLevel.ERROR; }
  25353. this._targetErrors.push(new ParseError(sourceSpan, message, level));
  25354. };
  25355. return TemplateParseVisitor;
  25356. }());
  25357. var NonBindableVisitor = /** @class */ (function () {
  25358. function NonBindableVisitor() {
  25359. }
  25360. /**
  25361. * @param {?} ast
  25362. * @param {?} parent
  25363. * @return {?}
  25364. */
  25365. NonBindableVisitor.prototype.visitElement = /**
  25366. * @param {?} ast
  25367. * @param {?} parent
  25368. * @return {?}
  25369. */
  25370. function (ast, parent) {
  25371. var /** @type {?} */ preparsedElement = preparseElement(ast);
  25372. if (preparsedElement.type === PreparsedElementType.SCRIPT ||
  25373. preparsedElement.type === PreparsedElementType.STYLE ||
  25374. preparsedElement.type === PreparsedElementType.STYLESHEET) {
  25375. // Skipping <script> for security reasons
  25376. // Skipping <style> and stylesheets as we already processed them
  25377. // in the StyleCompiler
  25378. return null;
  25379. }
  25380. var /** @type {?} */ attrNameAndValues = ast.attrs.map(function (attr) { return [attr.name, attr.value]; });
  25381. var /** @type {?} */ selector = createElementCssSelector(ast.name, attrNameAndValues);
  25382. var /** @type {?} */ ngContentIndex = parent.findNgContentIndex(selector);
  25383. var /** @type {?} */ children = visitAll(this, ast.children, EMPTY_ELEMENT_CONTEXT);
  25384. return new ElementAst(ast.name, visitAll(this, ast.attrs), [], [], [], [], [], false, [], children, ngContentIndex, ast.sourceSpan, ast.endSourceSpan);
  25385. };
  25386. /**
  25387. * @param {?} comment
  25388. * @param {?} context
  25389. * @return {?}
  25390. */
  25391. NonBindableVisitor.prototype.visitComment = /**
  25392. * @param {?} comment
  25393. * @param {?} context
  25394. * @return {?}
  25395. */
  25396. function (comment, context) { return null; };
  25397. /**
  25398. * @param {?} attribute
  25399. * @param {?} context
  25400. * @return {?}
  25401. */
  25402. NonBindableVisitor.prototype.visitAttribute = /**
  25403. * @param {?} attribute
  25404. * @param {?} context
  25405. * @return {?}
  25406. */
  25407. function (attribute, context) {
  25408. return new AttrAst(attribute.name, attribute.value, attribute.sourceSpan);
  25409. };
  25410. /**
  25411. * @param {?} text
  25412. * @param {?} parent
  25413. * @return {?}
  25414. */
  25415. NonBindableVisitor.prototype.visitText = /**
  25416. * @param {?} text
  25417. * @param {?} parent
  25418. * @return {?}
  25419. */
  25420. function (text, parent) {
  25421. var /** @type {?} */ ngContentIndex = /** @type {?} */ ((parent.findNgContentIndex(TEXT_CSS_SELECTOR)));
  25422. return new TextAst(text.value, ngContentIndex, /** @type {?} */ ((text.sourceSpan)));
  25423. };
  25424. /**
  25425. * @param {?} expansion
  25426. * @param {?} context
  25427. * @return {?}
  25428. */
  25429. NonBindableVisitor.prototype.visitExpansion = /**
  25430. * @param {?} expansion
  25431. * @param {?} context
  25432. * @return {?}
  25433. */
  25434. function (expansion, context) { return expansion; };
  25435. /**
  25436. * @param {?} expansionCase
  25437. * @param {?} context
  25438. * @return {?}
  25439. */
  25440. NonBindableVisitor.prototype.visitExpansionCase = /**
  25441. * @param {?} expansionCase
  25442. * @param {?} context
  25443. * @return {?}
  25444. */
  25445. function (expansionCase, context) { return expansionCase; };
  25446. return NonBindableVisitor;
  25447. }());
  25448. /**
  25449. * A reference to an element or directive in a template. E.g., the reference in this template:
  25450. *
  25451. * <div #myMenu="coolMenu">
  25452. *
  25453. * would be {name: 'myMenu', value: 'coolMenu', sourceSpan: ...}
  25454. */
  25455. var ElementOrDirectiveRef = /** @class */ (function () {
  25456. function ElementOrDirectiveRef(name, value, sourceSpan) {
  25457. this.name = name;
  25458. this.value = value;
  25459. this.sourceSpan = sourceSpan;
  25460. }
  25461. /** Gets whether this is a reference to the given directive. */
  25462. /**
  25463. * Gets whether this is a reference to the given directive.
  25464. * @param {?} directive
  25465. * @return {?}
  25466. */
  25467. ElementOrDirectiveRef.prototype.isReferenceToDirective = /**
  25468. * Gets whether this is a reference to the given directive.
  25469. * @param {?} directive
  25470. * @return {?}
  25471. */
  25472. function (directive) {
  25473. return splitExportAs(directive.exportAs).indexOf(this.value) !== -1;
  25474. };
  25475. return ElementOrDirectiveRef;
  25476. }());
  25477. /**
  25478. * Splits a raw, potentially comma-delimted `exportAs` value into an array of names.
  25479. * @param {?} exportAs
  25480. * @return {?}
  25481. */
  25482. function splitExportAs(exportAs) {
  25483. return exportAs ? exportAs.split(',').map(function (e) { return e.trim(); }) : [];
  25484. }
  25485. /**
  25486. * @param {?} classAttrValue
  25487. * @return {?}
  25488. */
  25489. function splitClasses(classAttrValue) {
  25490. return classAttrValue.trim().split(/\s+/g);
  25491. }
  25492. var ElementContext = /** @class */ (function () {
  25493. function ElementContext(isTemplateElement, _ngContentIndexMatcher, _wildcardNgContentIndex, providerContext) {
  25494. this.isTemplateElement = isTemplateElement;
  25495. this._ngContentIndexMatcher = _ngContentIndexMatcher;
  25496. this._wildcardNgContentIndex = _wildcardNgContentIndex;
  25497. this.providerContext = providerContext;
  25498. }
  25499. /**
  25500. * @param {?} isTemplateElement
  25501. * @param {?} directives
  25502. * @param {?} providerContext
  25503. * @return {?}
  25504. */
  25505. ElementContext.create = /**
  25506. * @param {?} isTemplateElement
  25507. * @param {?} directives
  25508. * @param {?} providerContext
  25509. * @return {?}
  25510. */
  25511. function (isTemplateElement, directives, providerContext) {
  25512. var /** @type {?} */ matcher = new SelectorMatcher();
  25513. var /** @type {?} */ wildcardNgContentIndex = /** @type {?} */ ((null));
  25514. var /** @type {?} */ component = directives.find(function (directive) { return directive.directive.isComponent; });
  25515. if (component) {
  25516. var /** @type {?} */ ngContentSelectors = /** @type {?} */ ((component.directive.template)).ngContentSelectors;
  25517. for (var /** @type {?} */ i = 0; i < ngContentSelectors.length; i++) {
  25518. var /** @type {?} */ selector = ngContentSelectors[i];
  25519. if (selector === '*') {
  25520. wildcardNgContentIndex = i;
  25521. }
  25522. else {
  25523. matcher.addSelectables(CssSelector.parse(ngContentSelectors[i]), i);
  25524. }
  25525. }
  25526. }
  25527. return new ElementContext(isTemplateElement, matcher, wildcardNgContentIndex, providerContext);
  25528. };
  25529. /**
  25530. * @param {?} selector
  25531. * @return {?}
  25532. */
  25533. ElementContext.prototype.findNgContentIndex = /**
  25534. * @param {?} selector
  25535. * @return {?}
  25536. */
  25537. function (selector) {
  25538. var /** @type {?} */ ngContentIndices = [];
  25539. this._ngContentIndexMatcher.match(selector, function (selector, ngContentIndex) { ngContentIndices.push(ngContentIndex); });
  25540. ngContentIndices.sort();
  25541. if (this._wildcardNgContentIndex != null) {
  25542. ngContentIndices.push(this._wildcardNgContentIndex);
  25543. }
  25544. return ngContentIndices.length > 0 ? ngContentIndices[0] : null;
  25545. };
  25546. return ElementContext;
  25547. }());
  25548. /**
  25549. * @param {?} elementName
  25550. * @param {?} attributes
  25551. * @return {?}
  25552. */
  25553. function createElementCssSelector(elementName, attributes) {
  25554. var /** @type {?} */ cssSelector = new CssSelector();
  25555. var /** @type {?} */ elNameNoNs = splitNsName(elementName)[1];
  25556. cssSelector.setElement(elNameNoNs);
  25557. for (var /** @type {?} */ i = 0; i < attributes.length; i++) {
  25558. var /** @type {?} */ attrName = attributes[i][0];
  25559. var /** @type {?} */ attrNameNoNs = splitNsName(attrName)[1];
  25560. var /** @type {?} */ attrValue = attributes[i][1];
  25561. cssSelector.addAttribute(attrNameNoNs, attrValue);
  25562. if (attrName.toLowerCase() == CLASS_ATTR) {
  25563. var /** @type {?} */ classes = splitClasses(attrValue);
  25564. classes.forEach(function (className) { return cssSelector.addClassName(className); });
  25565. }
  25566. }
  25567. return cssSelector;
  25568. }
  25569. var EMPTY_ELEMENT_CONTEXT = new ElementContext(true, new SelectorMatcher(), null, null);
  25570. var NON_BINDABLE_VISITOR = new NonBindableVisitor();
  25571. /**
  25572. * @param {?} node
  25573. * @return {?}
  25574. */
  25575. function _isEmptyTextNode(node) {
  25576. return node instanceof Text && node.value.trim().length == 0;
  25577. }
  25578. /**
  25579. * @template T
  25580. * @param {?} items
  25581. * @return {?}
  25582. */
  25583. function removeSummaryDuplicates(items) {
  25584. var /** @type {?} */ map = new Map();
  25585. items.forEach(function (item) {
  25586. if (!map.get(item.type.reference)) {
  25587. map.set(item.type.reference, item);
  25588. }
  25589. });
  25590. return Array.from(map.values());
  25591. }
  25592. /**
  25593. * @param {?} ast
  25594. * @return {?}
  25595. */
  25596. function isEmptyExpression(ast) {
  25597. if (ast instanceof ASTWithSource) {
  25598. ast = ast.ast;
  25599. }
  25600. return ast instanceof EmptyExpr;
  25601. }
  25602. /**
  25603. * @param {?} el
  25604. * @param {?} enableLegacyTemplate
  25605. * @param {?} reportDeprecation
  25606. * @return {?}
  25607. */
  25608. function isTemplate(el, enableLegacyTemplate, reportDeprecation) {
  25609. if (isNgTemplate(el.name))
  25610. return true;
  25611. var /** @type {?} */ tagNoNs = splitNsName(el.name)[1];
  25612. // `<template>` is HTML and case insensitive
  25613. if (tagNoNs.toLowerCase() === TEMPLATE_ELEMENT) {
  25614. if (enableLegacyTemplate && tagNoNs.toLowerCase() === TEMPLATE_ELEMENT) {
  25615. reportDeprecation(TEMPLATE_ELEMENT_DEPRECATION_WARNING, /** @type {?} */ ((el.sourceSpan)));
  25616. return true;
  25617. }
  25618. }
  25619. return false;
  25620. }
  25621. /**
  25622. * @fileoverview added by tsickle
  25623. * @suppress {checkTypes} checked by tsc
  25624. */
  25625. /**
  25626. * @license
  25627. * Copyright Google Inc. All Rights Reserved.
  25628. *
  25629. * Use of this source code is governed by an MIT-style license that can be
  25630. * found in the LICENSE file at https://angular.io/license
  25631. */
  25632. var EventHandlerVars = /** @class */ (function () {
  25633. function EventHandlerVars() {
  25634. }
  25635. EventHandlerVars.event = variable('$event');
  25636. return EventHandlerVars;
  25637. }());
  25638. /**
  25639. * @record
  25640. */
  25641. var ConvertActionBindingResult = /** @class */ (function () {
  25642. function ConvertActionBindingResult(stmts, allowDefault) {
  25643. this.stmts = stmts;
  25644. this.allowDefault = allowDefault;
  25645. }
  25646. return ConvertActionBindingResult;
  25647. }());
  25648. /**
  25649. * Converts the given expression AST into an executable output AST, assuming the expression is
  25650. * used in an action binding (e.g. an event handler).
  25651. * @param {?} localResolver
  25652. * @param {?} implicitReceiver
  25653. * @param {?} action
  25654. * @param {?} bindingId
  25655. * @return {?}
  25656. */
  25657. function convertActionBinding(localResolver, implicitReceiver, action, bindingId) {
  25658. if (!localResolver) {
  25659. localResolver = new DefaultLocalResolver();
  25660. }
  25661. var /** @type {?} */ actionWithoutBuiltins = convertPropertyBindingBuiltins({
  25662. createLiteralArrayConverter: function (argCount) {
  25663. // Note: no caching for literal arrays in actions.
  25664. return function (args) { return literalArr(args); };
  25665. },
  25666. createLiteralMapConverter: function (keys) {
  25667. // Note: no caching for literal maps in actions.
  25668. return function (values) {
  25669. var /** @type {?} */ entries = keys.map(function (k, i) {
  25670. return ({
  25671. key: k.key,
  25672. value: values[i],
  25673. quoted: k.quoted,
  25674. });
  25675. });
  25676. return literalMap(entries);
  25677. };
  25678. },
  25679. createPipeConverter: function (name) {
  25680. throw new Error("Illegal State: Actions are not allowed to contain pipes. Pipe: " + name);
  25681. }
  25682. }, action);
  25683. var /** @type {?} */ visitor = new _AstToIrVisitor(localResolver, implicitReceiver, bindingId);
  25684. var /** @type {?} */ actionStmts = [];
  25685. flattenStatements(actionWithoutBuiltins.visit(visitor, _Mode.Statement), actionStmts);
  25686. prependTemporaryDecls(visitor.temporaryCount, bindingId, actionStmts);
  25687. var /** @type {?} */ lastIndex = actionStmts.length - 1;
  25688. var /** @type {?} */ preventDefaultVar = /** @type {?} */ ((null));
  25689. if (lastIndex >= 0) {
  25690. var /** @type {?} */ lastStatement = actionStmts[lastIndex];
  25691. var /** @type {?} */ returnExpr = convertStmtIntoExpression(lastStatement);
  25692. if (returnExpr) {
  25693. // Note: We need to cast the result of the method call to dynamic,
  25694. // as it might be a void method!
  25695. preventDefaultVar = createPreventDefaultVar(bindingId);
  25696. actionStmts[lastIndex] =
  25697. preventDefaultVar.set(returnExpr.cast(DYNAMIC_TYPE).notIdentical(literal(false)))
  25698. .toDeclStmt(null, [StmtModifier.Final]);
  25699. }
  25700. }
  25701. return new ConvertActionBindingResult(actionStmts, preventDefaultVar);
  25702. }
  25703. /**
  25704. * @record
  25705. */
  25706. /**
  25707. * @record
  25708. */
  25709. /**
  25710. * @param {?} converterFactory
  25711. * @param {?} ast
  25712. * @return {?}
  25713. */
  25714. function convertPropertyBindingBuiltins(converterFactory, ast) {
  25715. return convertBuiltins(converterFactory, ast);
  25716. }
  25717. var ConvertPropertyBindingResult = /** @class */ (function () {
  25718. function ConvertPropertyBindingResult(stmts, currValExpr) {
  25719. this.stmts = stmts;
  25720. this.currValExpr = currValExpr;
  25721. }
  25722. return ConvertPropertyBindingResult;
  25723. }());
  25724. /** @enum {number} */
  25725. var BindingForm = {
  25726. // The general form of binding expression, supports all expressions.
  25727. General: 0,
  25728. // Try to generate a simple binding (no temporaries or statements)
  25729. // otherise generate a general binding
  25730. TrySimple: 1,
  25731. };
  25732. BindingForm[BindingForm.General] = "General";
  25733. BindingForm[BindingForm.TrySimple] = "TrySimple";
  25734. /**
  25735. * Converts the given expression AST into an executable output AST, assuming the expression
  25736. * is used in property binding. The expression has to be preprocessed via
  25737. * `convertPropertyBindingBuiltins`.
  25738. * @param {?} localResolver
  25739. * @param {?} implicitReceiver
  25740. * @param {?} expressionWithoutBuiltins
  25741. * @param {?} bindingId
  25742. * @param {?} form
  25743. * @return {?}
  25744. */
  25745. function convertPropertyBinding(localResolver, implicitReceiver, expressionWithoutBuiltins, bindingId, form) {
  25746. if (!localResolver) {
  25747. localResolver = new DefaultLocalResolver();
  25748. }
  25749. var /** @type {?} */ currValExpr = createCurrValueExpr(bindingId);
  25750. var /** @type {?} */ stmts = [];
  25751. var /** @type {?} */ visitor = new _AstToIrVisitor(localResolver, implicitReceiver, bindingId);
  25752. var /** @type {?} */ outputExpr = expressionWithoutBuiltins.visit(visitor, _Mode.Expression);
  25753. if (visitor.temporaryCount) {
  25754. for (var /** @type {?} */ i = 0; i < visitor.temporaryCount; i++) {
  25755. stmts.push(temporaryDeclaration(bindingId, i));
  25756. }
  25757. }
  25758. else if (form == BindingForm.TrySimple) {
  25759. return new ConvertPropertyBindingResult([], outputExpr);
  25760. }
  25761. stmts.push(currValExpr.set(outputExpr).toDeclStmt(DYNAMIC_TYPE, [StmtModifier.Final]));
  25762. return new ConvertPropertyBindingResult(stmts, currValExpr);
  25763. }
  25764. /**
  25765. * @param {?} converterFactory
  25766. * @param {?} ast
  25767. * @return {?}
  25768. */
  25769. function convertBuiltins(converterFactory, ast) {
  25770. var /** @type {?} */ visitor = new _BuiltinAstConverter(converterFactory);
  25771. return ast.visit(visitor);
  25772. }
  25773. /**
  25774. * @param {?} bindingId
  25775. * @param {?} temporaryNumber
  25776. * @return {?}
  25777. */
  25778. function temporaryName(bindingId, temporaryNumber) {
  25779. return "tmp_" + bindingId + "_" + temporaryNumber;
  25780. }
  25781. /**
  25782. * @param {?} bindingId
  25783. * @param {?} temporaryNumber
  25784. * @return {?}
  25785. */
  25786. function temporaryDeclaration(bindingId, temporaryNumber) {
  25787. return new DeclareVarStmt(temporaryName(bindingId, temporaryNumber), NULL_EXPR);
  25788. }
  25789. /**
  25790. * @param {?} temporaryCount
  25791. * @param {?} bindingId
  25792. * @param {?} statements
  25793. * @return {?}
  25794. */
  25795. function prependTemporaryDecls(temporaryCount, bindingId, statements) {
  25796. for (var /** @type {?} */ i = temporaryCount - 1; i >= 0; i--) {
  25797. statements.unshift(temporaryDeclaration(bindingId, i));
  25798. }
  25799. }
  25800. /** @enum {number} */
  25801. var _Mode = {
  25802. Statement: 0,
  25803. Expression: 1,
  25804. };
  25805. _Mode[_Mode.Statement] = "Statement";
  25806. _Mode[_Mode.Expression] = "Expression";
  25807. /**
  25808. * @param {?} mode
  25809. * @param {?} ast
  25810. * @return {?}
  25811. */
  25812. function ensureStatementMode(mode, ast) {
  25813. if (mode !== _Mode.Statement) {
  25814. throw new Error("Expected a statement, but saw " + ast);
  25815. }
  25816. }
  25817. /**
  25818. * @param {?} mode
  25819. * @param {?} ast
  25820. * @return {?}
  25821. */
  25822. function ensureExpressionMode(mode, ast) {
  25823. if (mode !== _Mode.Expression) {
  25824. throw new Error("Expected an expression, but saw " + ast);
  25825. }
  25826. }
  25827. /**
  25828. * @param {?} mode
  25829. * @param {?} expr
  25830. * @return {?}
  25831. */
  25832. function convertToStatementIfNeeded(mode, expr) {
  25833. if (mode === _Mode.Statement) {
  25834. return expr.toStmt();
  25835. }
  25836. else {
  25837. return expr;
  25838. }
  25839. }
  25840. var _BuiltinAstConverter = /** @class */ (function (_super) {
  25841. __extends(_BuiltinAstConverter, _super);
  25842. function _BuiltinAstConverter(_converterFactory) {
  25843. var _this = _super.call(this) || this;
  25844. _this._converterFactory = _converterFactory;
  25845. return _this;
  25846. }
  25847. /**
  25848. * @param {?} ast
  25849. * @param {?} context
  25850. * @return {?}
  25851. */
  25852. _BuiltinAstConverter.prototype.visitPipe = /**
  25853. * @param {?} ast
  25854. * @param {?} context
  25855. * @return {?}
  25856. */
  25857. function (ast, context) {
  25858. var _this = this;
  25859. var /** @type {?} */ args = [ast.exp].concat(ast.args).map(function (ast) { return ast.visit(_this, context); });
  25860. return new BuiltinFunctionCall(ast.span, args, this._converterFactory.createPipeConverter(ast.name, args.length));
  25861. };
  25862. /**
  25863. * @param {?} ast
  25864. * @param {?} context
  25865. * @return {?}
  25866. */
  25867. _BuiltinAstConverter.prototype.visitLiteralArray = /**
  25868. * @param {?} ast
  25869. * @param {?} context
  25870. * @return {?}
  25871. */
  25872. function (ast, context) {
  25873. var _this = this;
  25874. var /** @type {?} */ args = ast.expressions.map(function (ast) { return ast.visit(_this, context); });
  25875. return new BuiltinFunctionCall(ast.span, args, this._converterFactory.createLiteralArrayConverter(ast.expressions.length));
  25876. };
  25877. /**
  25878. * @param {?} ast
  25879. * @param {?} context
  25880. * @return {?}
  25881. */
  25882. _BuiltinAstConverter.prototype.visitLiteralMap = /**
  25883. * @param {?} ast
  25884. * @param {?} context
  25885. * @return {?}
  25886. */
  25887. function (ast, context) {
  25888. var _this = this;
  25889. var /** @type {?} */ args = ast.values.map(function (ast) { return ast.visit(_this, context); });
  25890. return new BuiltinFunctionCall(ast.span, args, this._converterFactory.createLiteralMapConverter(ast.keys));
  25891. };
  25892. return _BuiltinAstConverter;
  25893. }(AstTransformer));
  25894. var _AstToIrVisitor = /** @class */ (function () {
  25895. function _AstToIrVisitor(_localResolver, _implicitReceiver, bindingId) {
  25896. this._localResolver = _localResolver;
  25897. this._implicitReceiver = _implicitReceiver;
  25898. this.bindingId = bindingId;
  25899. this._nodeMap = new Map();
  25900. this._resultMap = new Map();
  25901. this._currentTemporary = 0;
  25902. this.temporaryCount = 0;
  25903. }
  25904. /**
  25905. * @param {?} ast
  25906. * @param {?} mode
  25907. * @return {?}
  25908. */
  25909. _AstToIrVisitor.prototype.visitBinary = /**
  25910. * @param {?} ast
  25911. * @param {?} mode
  25912. * @return {?}
  25913. */
  25914. function (ast, mode) {
  25915. var /** @type {?} */ op;
  25916. switch (ast.operation) {
  25917. case '+':
  25918. op = BinaryOperator.Plus;
  25919. break;
  25920. case '-':
  25921. op = BinaryOperator.Minus;
  25922. break;
  25923. case '*':
  25924. op = BinaryOperator.Multiply;
  25925. break;
  25926. case '/':
  25927. op = BinaryOperator.Divide;
  25928. break;
  25929. case '%':
  25930. op = BinaryOperator.Modulo;
  25931. break;
  25932. case '&&':
  25933. op = BinaryOperator.And;
  25934. break;
  25935. case '||':
  25936. op = BinaryOperator.Or;
  25937. break;
  25938. case '==':
  25939. op = BinaryOperator.Equals;
  25940. break;
  25941. case '!=':
  25942. op = BinaryOperator.NotEquals;
  25943. break;
  25944. case '===':
  25945. op = BinaryOperator.Identical;
  25946. break;
  25947. case '!==':
  25948. op = BinaryOperator.NotIdentical;
  25949. break;
  25950. case '<':
  25951. op = BinaryOperator.Lower;
  25952. break;
  25953. case '>':
  25954. op = BinaryOperator.Bigger;
  25955. break;
  25956. case '<=':
  25957. op = BinaryOperator.LowerEquals;
  25958. break;
  25959. case '>=':
  25960. op = BinaryOperator.BiggerEquals;
  25961. break;
  25962. default:
  25963. throw new Error("Unsupported operation " + ast.operation);
  25964. }
  25965. return convertToStatementIfNeeded(mode, new BinaryOperatorExpr(op, this._visit(ast.left, _Mode.Expression), this._visit(ast.right, _Mode.Expression)));
  25966. };
  25967. /**
  25968. * @param {?} ast
  25969. * @param {?} mode
  25970. * @return {?}
  25971. */
  25972. _AstToIrVisitor.prototype.visitChain = /**
  25973. * @param {?} ast
  25974. * @param {?} mode
  25975. * @return {?}
  25976. */
  25977. function (ast, mode) {
  25978. ensureStatementMode(mode, ast);
  25979. return this.visitAll(ast.expressions, mode);
  25980. };
  25981. /**
  25982. * @param {?} ast
  25983. * @param {?} mode
  25984. * @return {?}
  25985. */
  25986. _AstToIrVisitor.prototype.visitConditional = /**
  25987. * @param {?} ast
  25988. * @param {?} mode
  25989. * @return {?}
  25990. */
  25991. function (ast, mode) {
  25992. var /** @type {?} */ value = this._visit(ast.condition, _Mode.Expression);
  25993. return convertToStatementIfNeeded(mode, value.conditional(this._visit(ast.trueExp, _Mode.Expression), this._visit(ast.falseExp, _Mode.Expression)));
  25994. };
  25995. /**
  25996. * @param {?} ast
  25997. * @param {?} mode
  25998. * @return {?}
  25999. */
  26000. _AstToIrVisitor.prototype.visitPipe = /**
  26001. * @param {?} ast
  26002. * @param {?} mode
  26003. * @return {?}
  26004. */
  26005. function (ast, mode) {
  26006. throw new Error("Illegal state: Pipes should have been converted into functions. Pipe: " + ast.name);
  26007. };
  26008. /**
  26009. * @param {?} ast
  26010. * @param {?} mode
  26011. * @return {?}
  26012. */
  26013. _AstToIrVisitor.prototype.visitFunctionCall = /**
  26014. * @param {?} ast
  26015. * @param {?} mode
  26016. * @return {?}
  26017. */
  26018. function (ast, mode) {
  26019. var /** @type {?} */ convertedArgs = this.visitAll(ast.args, _Mode.Expression);
  26020. var /** @type {?} */ fnResult;
  26021. if (ast instanceof BuiltinFunctionCall) {
  26022. fnResult = ast.converter(convertedArgs);
  26023. }
  26024. else {
  26025. fnResult = this._visit(/** @type {?} */ ((ast.target)), _Mode.Expression).callFn(convertedArgs);
  26026. }
  26027. return convertToStatementIfNeeded(mode, fnResult);
  26028. };
  26029. /**
  26030. * @param {?} ast
  26031. * @param {?} mode
  26032. * @return {?}
  26033. */
  26034. _AstToIrVisitor.prototype.visitImplicitReceiver = /**
  26035. * @param {?} ast
  26036. * @param {?} mode
  26037. * @return {?}
  26038. */
  26039. function (ast, mode) {
  26040. ensureExpressionMode(mode, ast);
  26041. return this._implicitReceiver;
  26042. };
  26043. /**
  26044. * @param {?} ast
  26045. * @param {?} mode
  26046. * @return {?}
  26047. */
  26048. _AstToIrVisitor.prototype.visitInterpolation = /**
  26049. * @param {?} ast
  26050. * @param {?} mode
  26051. * @return {?}
  26052. */
  26053. function (ast, mode) {
  26054. ensureExpressionMode(mode, ast);
  26055. var /** @type {?} */ args = [literal(ast.expressions.length)];
  26056. for (var /** @type {?} */ i = 0; i < ast.strings.length - 1; i++) {
  26057. args.push(literal(ast.strings[i]));
  26058. args.push(this._visit(ast.expressions[i], _Mode.Expression));
  26059. }
  26060. args.push(literal(ast.strings[ast.strings.length - 1]));
  26061. return ast.expressions.length <= 9 ?
  26062. importExpr(Identifiers.inlineInterpolate).callFn(args) :
  26063. importExpr(Identifiers.interpolate).callFn([args[0], literalArr(args.slice(1))]);
  26064. };
  26065. /**
  26066. * @param {?} ast
  26067. * @param {?} mode
  26068. * @return {?}
  26069. */
  26070. _AstToIrVisitor.prototype.visitKeyedRead = /**
  26071. * @param {?} ast
  26072. * @param {?} mode
  26073. * @return {?}
  26074. */
  26075. function (ast, mode) {
  26076. var /** @type {?} */ leftMostSafe = this.leftMostSafeNode(ast);
  26077. if (leftMostSafe) {
  26078. return this.convertSafeAccess(ast, leftMostSafe, mode);
  26079. }
  26080. else {
  26081. return convertToStatementIfNeeded(mode, this._visit(ast.obj, _Mode.Expression).key(this._visit(ast.key, _Mode.Expression)));
  26082. }
  26083. };
  26084. /**
  26085. * @param {?} ast
  26086. * @param {?} mode
  26087. * @return {?}
  26088. */
  26089. _AstToIrVisitor.prototype.visitKeyedWrite = /**
  26090. * @param {?} ast
  26091. * @param {?} mode
  26092. * @return {?}
  26093. */
  26094. function (ast, mode) {
  26095. var /** @type {?} */ obj = this._visit(ast.obj, _Mode.Expression);
  26096. var /** @type {?} */ key = this._visit(ast.key, _Mode.Expression);
  26097. var /** @type {?} */ value = this._visit(ast.value, _Mode.Expression);
  26098. return convertToStatementIfNeeded(mode, obj.key(key).set(value));
  26099. };
  26100. /**
  26101. * @param {?} ast
  26102. * @param {?} mode
  26103. * @return {?}
  26104. */
  26105. _AstToIrVisitor.prototype.visitLiteralArray = /**
  26106. * @param {?} ast
  26107. * @param {?} mode
  26108. * @return {?}
  26109. */
  26110. function (ast, mode) {
  26111. throw new Error("Illegal State: literal arrays should have been converted into functions");
  26112. };
  26113. /**
  26114. * @param {?} ast
  26115. * @param {?} mode
  26116. * @return {?}
  26117. */
  26118. _AstToIrVisitor.prototype.visitLiteralMap = /**
  26119. * @param {?} ast
  26120. * @param {?} mode
  26121. * @return {?}
  26122. */
  26123. function (ast, mode) {
  26124. throw new Error("Illegal State: literal maps should have been converted into functions");
  26125. };
  26126. /**
  26127. * @param {?} ast
  26128. * @param {?} mode
  26129. * @return {?}
  26130. */
  26131. _AstToIrVisitor.prototype.visitLiteralPrimitive = /**
  26132. * @param {?} ast
  26133. * @param {?} mode
  26134. * @return {?}
  26135. */
  26136. function (ast, mode) {
  26137. // For literal values of null, undefined, true, or false allow type inteference
  26138. // to infer the type.
  26139. var /** @type {?} */ type = ast.value === null || ast.value === undefined || ast.value === true || ast.value === true ?
  26140. INFERRED_TYPE :
  26141. undefined;
  26142. return convertToStatementIfNeeded(mode, literal(ast.value, type));
  26143. };
  26144. /**
  26145. * @param {?} name
  26146. * @return {?}
  26147. */
  26148. _AstToIrVisitor.prototype._getLocal = /**
  26149. * @param {?} name
  26150. * @return {?}
  26151. */
  26152. function (name) { return this._localResolver.getLocal(name); };
  26153. /**
  26154. * @param {?} ast
  26155. * @param {?} mode
  26156. * @return {?}
  26157. */
  26158. _AstToIrVisitor.prototype.visitMethodCall = /**
  26159. * @param {?} ast
  26160. * @param {?} mode
  26161. * @return {?}
  26162. */
  26163. function (ast, mode) {
  26164. if (ast.receiver instanceof ImplicitReceiver && ast.name == '$any') {
  26165. var /** @type {?} */ args = /** @type {?} */ (this.visitAll(ast.args, _Mode.Expression));
  26166. if (args.length != 1) {
  26167. throw new Error("Invalid call to $any, expected 1 argument but received " + (args.length || 'none'));
  26168. }
  26169. return (/** @type {?} */ (args[0])).cast(DYNAMIC_TYPE);
  26170. }
  26171. var /** @type {?} */ leftMostSafe = this.leftMostSafeNode(ast);
  26172. if (leftMostSafe) {
  26173. return this.convertSafeAccess(ast, leftMostSafe, mode);
  26174. }
  26175. else {
  26176. var /** @type {?} */ args = this.visitAll(ast.args, _Mode.Expression);
  26177. var /** @type {?} */ result = null;
  26178. var /** @type {?} */ receiver = this._visit(ast.receiver, _Mode.Expression);
  26179. if (receiver === this._implicitReceiver) {
  26180. var /** @type {?} */ varExpr = this._getLocal(ast.name);
  26181. if (varExpr) {
  26182. result = varExpr.callFn(args);
  26183. }
  26184. }
  26185. if (result == null) {
  26186. result = receiver.callMethod(ast.name, args);
  26187. }
  26188. return convertToStatementIfNeeded(mode, result);
  26189. }
  26190. };
  26191. /**
  26192. * @param {?} ast
  26193. * @param {?} mode
  26194. * @return {?}
  26195. */
  26196. _AstToIrVisitor.prototype.visitPrefixNot = /**
  26197. * @param {?} ast
  26198. * @param {?} mode
  26199. * @return {?}
  26200. */
  26201. function (ast, mode) {
  26202. return convertToStatementIfNeeded(mode, not(this._visit(ast.expression, _Mode.Expression)));
  26203. };
  26204. /**
  26205. * @param {?} ast
  26206. * @param {?} mode
  26207. * @return {?}
  26208. */
  26209. _AstToIrVisitor.prototype.visitNonNullAssert = /**
  26210. * @param {?} ast
  26211. * @param {?} mode
  26212. * @return {?}
  26213. */
  26214. function (ast, mode) {
  26215. return convertToStatementIfNeeded(mode, assertNotNull(this._visit(ast.expression, _Mode.Expression)));
  26216. };
  26217. /**
  26218. * @param {?} ast
  26219. * @param {?} mode
  26220. * @return {?}
  26221. */
  26222. _AstToIrVisitor.prototype.visitPropertyRead = /**
  26223. * @param {?} ast
  26224. * @param {?} mode
  26225. * @return {?}
  26226. */
  26227. function (ast, mode) {
  26228. var /** @type {?} */ leftMostSafe = this.leftMostSafeNode(ast);
  26229. if (leftMostSafe) {
  26230. return this.convertSafeAccess(ast, leftMostSafe, mode);
  26231. }
  26232. else {
  26233. var /** @type {?} */ result = null;
  26234. var /** @type {?} */ receiver = this._visit(ast.receiver, _Mode.Expression);
  26235. if (receiver === this._implicitReceiver) {
  26236. result = this._getLocal(ast.name);
  26237. }
  26238. if (result == null) {
  26239. result = receiver.prop(ast.name);
  26240. }
  26241. return convertToStatementIfNeeded(mode, result);
  26242. }
  26243. };
  26244. /**
  26245. * @param {?} ast
  26246. * @param {?} mode
  26247. * @return {?}
  26248. */
  26249. _AstToIrVisitor.prototype.visitPropertyWrite = /**
  26250. * @param {?} ast
  26251. * @param {?} mode
  26252. * @return {?}
  26253. */
  26254. function (ast, mode) {
  26255. var /** @type {?} */ receiver = this._visit(ast.receiver, _Mode.Expression);
  26256. if (receiver === this._implicitReceiver) {
  26257. var /** @type {?} */ varExpr = this._getLocal(ast.name);
  26258. if (varExpr) {
  26259. throw new Error('Cannot assign to a reference or variable!');
  26260. }
  26261. }
  26262. return convertToStatementIfNeeded(mode, receiver.prop(ast.name).set(this._visit(ast.value, _Mode.Expression)));
  26263. };
  26264. /**
  26265. * @param {?} ast
  26266. * @param {?} mode
  26267. * @return {?}
  26268. */
  26269. _AstToIrVisitor.prototype.visitSafePropertyRead = /**
  26270. * @param {?} ast
  26271. * @param {?} mode
  26272. * @return {?}
  26273. */
  26274. function (ast, mode) {
  26275. return this.convertSafeAccess(ast, this.leftMostSafeNode(ast), mode);
  26276. };
  26277. /**
  26278. * @param {?} ast
  26279. * @param {?} mode
  26280. * @return {?}
  26281. */
  26282. _AstToIrVisitor.prototype.visitSafeMethodCall = /**
  26283. * @param {?} ast
  26284. * @param {?} mode
  26285. * @return {?}
  26286. */
  26287. function (ast, mode) {
  26288. return this.convertSafeAccess(ast, this.leftMostSafeNode(ast), mode);
  26289. };
  26290. /**
  26291. * @param {?} asts
  26292. * @param {?} mode
  26293. * @return {?}
  26294. */
  26295. _AstToIrVisitor.prototype.visitAll = /**
  26296. * @param {?} asts
  26297. * @param {?} mode
  26298. * @return {?}
  26299. */
  26300. function (asts, mode) {
  26301. var _this = this;
  26302. return asts.map(function (ast) { return _this._visit(ast, mode); });
  26303. };
  26304. /**
  26305. * @param {?} ast
  26306. * @param {?} mode
  26307. * @return {?}
  26308. */
  26309. _AstToIrVisitor.prototype.visitQuote = /**
  26310. * @param {?} ast
  26311. * @param {?} mode
  26312. * @return {?}
  26313. */
  26314. function (ast, mode) {
  26315. throw new Error("Quotes are not supported for evaluation!\n Statement: " + ast.uninterpretedExpression + " located at " + ast.location);
  26316. };
  26317. /**
  26318. * @param {?} ast
  26319. * @param {?} mode
  26320. * @return {?}
  26321. */
  26322. _AstToIrVisitor.prototype._visit = /**
  26323. * @param {?} ast
  26324. * @param {?} mode
  26325. * @return {?}
  26326. */
  26327. function (ast, mode) {
  26328. var /** @type {?} */ result = this._resultMap.get(ast);
  26329. if (result)
  26330. return result;
  26331. return (this._nodeMap.get(ast) || ast).visit(this, mode);
  26332. };
  26333. /**
  26334. * @param {?} ast
  26335. * @param {?} leftMostSafe
  26336. * @param {?} mode
  26337. * @return {?}
  26338. */
  26339. _AstToIrVisitor.prototype.convertSafeAccess = /**
  26340. * @param {?} ast
  26341. * @param {?} leftMostSafe
  26342. * @param {?} mode
  26343. * @return {?}
  26344. */
  26345. function (ast, leftMostSafe, mode) {
  26346. // If the expression contains a safe access node on the left it needs to be converted to
  26347. // an expression that guards the access to the member by checking the receiver for blank. As
  26348. // execution proceeds from left to right, the left most part of the expression must be guarded
  26349. // first but, because member access is left associative, the right side of the expression is at
  26350. // the top of the AST. The desired result requires lifting a copy of the the left part of the
  26351. // expression up to test it for blank before generating the unguarded version.
  26352. // Consider, for example the following expression: a?.b.c?.d.e
  26353. // This results in the ast:
  26354. // .
  26355. // / \
  26356. // ?. e
  26357. // / \
  26358. // . d
  26359. // / \
  26360. // ?. c
  26361. // / \
  26362. // a b
  26363. // The following tree should be generated:
  26364. //
  26365. // /---- ? ----\
  26366. // / | \
  26367. // a /--- ? ---\ null
  26368. // / | \
  26369. // . . null
  26370. // / \ / \
  26371. // . c . e
  26372. // / \ / \
  26373. // a b , d
  26374. // / \
  26375. // . c
  26376. // / \
  26377. // a b
  26378. //
  26379. // Notice that the first guard condition is the left hand of the left most safe access node
  26380. // which comes in as leftMostSafe to this routine.
  26381. var /** @type {?} */ guardedExpression = this._visit(leftMostSafe.receiver, _Mode.Expression);
  26382. var /** @type {?} */ temporary = /** @type {?} */ ((undefined));
  26383. if (this.needsTemporary(leftMostSafe.receiver)) {
  26384. // If the expression has method calls or pipes then we need to save the result into a
  26385. // temporary variable to avoid calling stateful or impure code more than once.
  26386. temporary = this.allocateTemporary();
  26387. // Preserve the result in the temporary variable
  26388. guardedExpression = temporary.set(guardedExpression);
  26389. // Ensure all further references to the guarded expression refer to the temporary instead.
  26390. this._resultMap.set(leftMostSafe.receiver, temporary);
  26391. }
  26392. var /** @type {?} */ condition = guardedExpression.isBlank();
  26393. // Convert the ast to an unguarded access to the receiver's member. The map will substitute
  26394. // leftMostNode with its unguarded version in the call to `this.visit()`.
  26395. if (leftMostSafe instanceof SafeMethodCall) {
  26396. this._nodeMap.set(leftMostSafe, new MethodCall(leftMostSafe.span, leftMostSafe.receiver, leftMostSafe.name, leftMostSafe.args));
  26397. }
  26398. else {
  26399. this._nodeMap.set(leftMostSafe, new PropertyRead(leftMostSafe.span, leftMostSafe.receiver, leftMostSafe.name));
  26400. }
  26401. // Recursively convert the node now without the guarded member access.
  26402. var /** @type {?} */ access = this._visit(ast, _Mode.Expression);
  26403. // Remove the mapping. This is not strictly required as the converter only traverses each node
  26404. // once but is safer if the conversion is changed to traverse the nodes more than once.
  26405. this._nodeMap.delete(leftMostSafe);
  26406. // If we allocated a temporary, release it.
  26407. if (temporary) {
  26408. this.releaseTemporary(temporary);
  26409. }
  26410. // Produce the conditional
  26411. return convertToStatementIfNeeded(mode, condition.conditional(literal(null), access));
  26412. };
  26413. /**
  26414. * @param {?} ast
  26415. * @return {?}
  26416. */
  26417. _AstToIrVisitor.prototype.leftMostSafeNode = /**
  26418. * @param {?} ast
  26419. * @return {?}
  26420. */
  26421. function (ast) {
  26422. var _this = this;
  26423. var /** @type {?} */ visit = function (visitor, ast) {
  26424. return (_this._nodeMap.get(ast) || ast).visit(visitor);
  26425. };
  26426. return ast.visit({
  26427. visitBinary: /**
  26428. * @param {?} ast
  26429. * @return {?}
  26430. */
  26431. function (ast) { return null; },
  26432. visitChain: /**
  26433. * @param {?} ast
  26434. * @return {?}
  26435. */
  26436. function (ast) { return null; },
  26437. visitConditional: /**
  26438. * @param {?} ast
  26439. * @return {?}
  26440. */
  26441. function (ast) { return null; },
  26442. visitFunctionCall: /**
  26443. * @param {?} ast
  26444. * @return {?}
  26445. */
  26446. function (ast) { return null; },
  26447. visitImplicitReceiver: /**
  26448. * @param {?} ast
  26449. * @return {?}
  26450. */
  26451. function (ast) { return null; },
  26452. visitInterpolation: /**
  26453. * @param {?} ast
  26454. * @return {?}
  26455. */
  26456. function (ast) { return null; },
  26457. visitKeyedRead: /**
  26458. * @param {?} ast
  26459. * @return {?}
  26460. */
  26461. function (ast) { return visit(this, ast.obj); },
  26462. visitKeyedWrite: /**
  26463. * @param {?} ast
  26464. * @return {?}
  26465. */
  26466. function (ast) { return null; },
  26467. visitLiteralArray: /**
  26468. * @param {?} ast
  26469. * @return {?}
  26470. */
  26471. function (ast) { return null; },
  26472. visitLiteralMap: /**
  26473. * @param {?} ast
  26474. * @return {?}
  26475. */
  26476. function (ast) { return null; },
  26477. visitLiteralPrimitive: /**
  26478. * @param {?} ast
  26479. * @return {?}
  26480. */
  26481. function (ast) { return null; },
  26482. visitMethodCall: /**
  26483. * @param {?} ast
  26484. * @return {?}
  26485. */
  26486. function (ast) { return visit(this, ast.receiver); },
  26487. visitPipe: /**
  26488. * @param {?} ast
  26489. * @return {?}
  26490. */
  26491. function (ast) { return null; },
  26492. visitPrefixNot: /**
  26493. * @param {?} ast
  26494. * @return {?}
  26495. */
  26496. function (ast) { return null; },
  26497. visitNonNullAssert: /**
  26498. * @param {?} ast
  26499. * @return {?}
  26500. */
  26501. function (ast) { return null; },
  26502. visitPropertyRead: /**
  26503. * @param {?} ast
  26504. * @return {?}
  26505. */
  26506. function (ast) { return visit(this, ast.receiver); },
  26507. visitPropertyWrite: /**
  26508. * @param {?} ast
  26509. * @return {?}
  26510. */
  26511. function (ast) { return null; },
  26512. visitQuote: /**
  26513. * @param {?} ast
  26514. * @return {?}
  26515. */
  26516. function (ast) { return null; },
  26517. visitSafeMethodCall: /**
  26518. * @param {?} ast
  26519. * @return {?}
  26520. */
  26521. function (ast) { return visit(this, ast.receiver) || ast; },
  26522. visitSafePropertyRead: /**
  26523. * @param {?} ast
  26524. * @return {?}
  26525. */
  26526. function (ast) {
  26527. return visit(this, ast.receiver) || ast;
  26528. }
  26529. });
  26530. };
  26531. /**
  26532. * @param {?} ast
  26533. * @return {?}
  26534. */
  26535. _AstToIrVisitor.prototype.needsTemporary = /**
  26536. * @param {?} ast
  26537. * @return {?}
  26538. */
  26539. function (ast) {
  26540. var _this = this;
  26541. var /** @type {?} */ visit = function (visitor, ast) {
  26542. return ast && (_this._nodeMap.get(ast) || ast).visit(visitor);
  26543. };
  26544. var /** @type {?} */ visitSome = function (visitor, ast) {
  26545. return ast.some(function (ast) { return visit(visitor, ast); });
  26546. };
  26547. return ast.visit({
  26548. visitBinary: /**
  26549. * @param {?} ast
  26550. * @return {?}
  26551. */
  26552. function (ast) { return visit(this, ast.left) || visit(this, ast.right); },
  26553. visitChain: /**
  26554. * @param {?} ast
  26555. * @return {?}
  26556. */
  26557. function (ast) { return false; },
  26558. visitConditional: /**
  26559. * @param {?} ast
  26560. * @return {?}
  26561. */
  26562. function (ast) {
  26563. return visit(this, ast.condition) || visit(this, ast.trueExp) ||
  26564. visit(this, ast.falseExp);
  26565. },
  26566. visitFunctionCall: /**
  26567. * @param {?} ast
  26568. * @return {?}
  26569. */
  26570. function (ast) { return true; },
  26571. visitImplicitReceiver: /**
  26572. * @param {?} ast
  26573. * @return {?}
  26574. */
  26575. function (ast) { return false; },
  26576. visitInterpolation: /**
  26577. * @param {?} ast
  26578. * @return {?}
  26579. */
  26580. function (ast) { return visitSome(this, ast.expressions); },
  26581. visitKeyedRead: /**
  26582. * @param {?} ast
  26583. * @return {?}
  26584. */
  26585. function (ast) { return false; },
  26586. visitKeyedWrite: /**
  26587. * @param {?} ast
  26588. * @return {?}
  26589. */
  26590. function (ast) { return false; },
  26591. visitLiteralArray: /**
  26592. * @param {?} ast
  26593. * @return {?}
  26594. */
  26595. function (ast) { return true; },
  26596. visitLiteralMap: /**
  26597. * @param {?} ast
  26598. * @return {?}
  26599. */
  26600. function (ast) { return true; },
  26601. visitLiteralPrimitive: /**
  26602. * @param {?} ast
  26603. * @return {?}
  26604. */
  26605. function (ast) { return false; },
  26606. visitMethodCall: /**
  26607. * @param {?} ast
  26608. * @return {?}
  26609. */
  26610. function (ast) { return true; },
  26611. visitPipe: /**
  26612. * @param {?} ast
  26613. * @return {?}
  26614. */
  26615. function (ast) { return true; },
  26616. visitPrefixNot: /**
  26617. * @param {?} ast
  26618. * @return {?}
  26619. */
  26620. function (ast) { return visit(this, ast.expression); },
  26621. visitNonNullAssert: /**
  26622. * @param {?} ast
  26623. * @return {?}
  26624. */
  26625. function (ast) { return visit(this, ast.expression); },
  26626. visitPropertyRead: /**
  26627. * @param {?} ast
  26628. * @return {?}
  26629. */
  26630. function (ast) { return false; },
  26631. visitPropertyWrite: /**
  26632. * @param {?} ast
  26633. * @return {?}
  26634. */
  26635. function (ast) { return false; },
  26636. visitQuote: /**
  26637. * @param {?} ast
  26638. * @return {?}
  26639. */
  26640. function (ast) { return false; },
  26641. visitSafeMethodCall: /**
  26642. * @param {?} ast
  26643. * @return {?}
  26644. */
  26645. function (ast) { return true; },
  26646. visitSafePropertyRead: /**
  26647. * @param {?} ast
  26648. * @return {?}
  26649. */
  26650. function (ast) { return false; }
  26651. });
  26652. };
  26653. /**
  26654. * @return {?}
  26655. */
  26656. _AstToIrVisitor.prototype.allocateTemporary = /**
  26657. * @return {?}
  26658. */
  26659. function () {
  26660. var /** @type {?} */ tempNumber = this._currentTemporary++;
  26661. this.temporaryCount = Math.max(this._currentTemporary, this.temporaryCount);
  26662. return new ReadVarExpr(temporaryName(this.bindingId, tempNumber));
  26663. };
  26664. /**
  26665. * @param {?} temporary
  26666. * @return {?}
  26667. */
  26668. _AstToIrVisitor.prototype.releaseTemporary = /**
  26669. * @param {?} temporary
  26670. * @return {?}
  26671. */
  26672. function (temporary) {
  26673. this._currentTemporary--;
  26674. if (temporary.name != temporaryName(this.bindingId, this._currentTemporary)) {
  26675. throw new Error("Temporary " + temporary.name + " released out of order");
  26676. }
  26677. };
  26678. return _AstToIrVisitor;
  26679. }());
  26680. /**
  26681. * @param {?} arg
  26682. * @param {?} output
  26683. * @return {?}
  26684. */
  26685. function flattenStatements(arg, output) {
  26686. if (Array.isArray(arg)) {
  26687. (/** @type {?} */ (arg)).forEach(function (entry) { return flattenStatements(entry, output); });
  26688. }
  26689. else {
  26690. output.push(arg);
  26691. }
  26692. }
  26693. var DefaultLocalResolver = /** @class */ (function () {
  26694. function DefaultLocalResolver() {
  26695. }
  26696. /**
  26697. * @param {?} name
  26698. * @return {?}
  26699. */
  26700. DefaultLocalResolver.prototype.getLocal = /**
  26701. * @param {?} name
  26702. * @return {?}
  26703. */
  26704. function (name) {
  26705. if (name === EventHandlerVars.event.name) {
  26706. return EventHandlerVars.event;
  26707. }
  26708. return null;
  26709. };
  26710. return DefaultLocalResolver;
  26711. }());
  26712. /**
  26713. * @param {?} bindingId
  26714. * @return {?}
  26715. */
  26716. function createCurrValueExpr(bindingId) {
  26717. return variable("currVal_" + bindingId); // fix syntax highlighting: `
  26718. }
  26719. /**
  26720. * @param {?} bindingId
  26721. * @return {?}
  26722. */
  26723. function createPreventDefaultVar(bindingId) {
  26724. return variable("pd_" + bindingId);
  26725. }
  26726. /**
  26727. * @param {?} stmt
  26728. * @return {?}
  26729. */
  26730. function convertStmtIntoExpression(stmt) {
  26731. if (stmt instanceof ExpressionStatement) {
  26732. return stmt.expr;
  26733. }
  26734. else if (stmt instanceof ReturnStatement) {
  26735. return stmt.value;
  26736. }
  26737. return null;
  26738. }
  26739. var BuiltinFunctionCall = /** @class */ (function (_super) {
  26740. __extends(BuiltinFunctionCall, _super);
  26741. function BuiltinFunctionCall(span, args, converter) {
  26742. var _this = _super.call(this, span, null, args) || this;
  26743. _this.args = args;
  26744. _this.converter = converter;
  26745. return _this;
  26746. }
  26747. return BuiltinFunctionCall;
  26748. }(FunctionCall));
  26749. /**
  26750. * @fileoverview added by tsickle
  26751. * @suppress {checkTypes} checked by tsc
  26752. */
  26753. /**
  26754. * @license
  26755. * Copyright Google Inc. All Rights Reserved.
  26756. *
  26757. * Use of this source code is governed by an MIT-style license that can be
  26758. * found in the LICENSE file at https://angular.io/license
  26759. */
  26760. /**
  26761. * Generates code that is used to type check templates.
  26762. */
  26763. var TypeCheckCompiler = /** @class */ (function () {
  26764. function TypeCheckCompiler(options, reflector) {
  26765. this.options = options;
  26766. this.reflector = reflector;
  26767. }
  26768. /**
  26769. * Important notes:
  26770. * - This must not produce new `import` statements, but only refer to types outside
  26771. * of the file via the variables provided via externalReferenceVars.
  26772. * This allows Typescript to reuse the old program's structure as no imports have changed.
  26773. * - This must not produce any exports, as this would pollute the .d.ts file
  26774. * and also violate the point above.
  26775. */
  26776. /**
  26777. * Important notes:
  26778. * - This must not produce new `import` statements, but only refer to types outside
  26779. * of the file via the variables provided via externalReferenceVars.
  26780. * This allows Typescript to reuse the old program's structure as no imports have changed.
  26781. * - This must not produce any exports, as this would pollute the .d.ts file
  26782. * and also violate the point above.
  26783. * @param {?} componentId
  26784. * @param {?} component
  26785. * @param {?} template
  26786. * @param {?} usedPipes
  26787. * @param {?} externalReferenceVars
  26788. * @param {?} ctx
  26789. * @return {?}
  26790. */
  26791. TypeCheckCompiler.prototype.compileComponent = /**
  26792. * Important notes:
  26793. * - This must not produce new `import` statements, but only refer to types outside
  26794. * of the file via the variables provided via externalReferenceVars.
  26795. * This allows Typescript to reuse the old program's structure as no imports have changed.
  26796. * - This must not produce any exports, as this would pollute the .d.ts file
  26797. * and also violate the point above.
  26798. * @param {?} componentId
  26799. * @param {?} component
  26800. * @param {?} template
  26801. * @param {?} usedPipes
  26802. * @param {?} externalReferenceVars
  26803. * @param {?} ctx
  26804. * @return {?}
  26805. */
  26806. function (componentId, component, template, usedPipes, externalReferenceVars, ctx) {
  26807. var _this = this;
  26808. var /** @type {?} */ pipes = new Map();
  26809. usedPipes.forEach(function (p) { return pipes.set(p.name, p.type.reference); });
  26810. var /** @type {?} */ embeddedViewCount = 0;
  26811. var /** @type {?} */ viewBuilderFactory = function (parent, guards) {
  26812. var /** @type {?} */ embeddedViewIndex = embeddedViewCount++;
  26813. return new ViewBuilder(_this.options, _this.reflector, externalReferenceVars, parent, component.type.reference, component.isHost, embeddedViewIndex, pipes, guards, ctx, viewBuilderFactory);
  26814. };
  26815. var /** @type {?} */ visitor = viewBuilderFactory(null, []);
  26816. visitor.visitAll([], template);
  26817. return visitor.build(componentId);
  26818. };
  26819. return TypeCheckCompiler;
  26820. }());
  26821. var DYNAMIC_VAR_NAME = '_any';
  26822. var TypeCheckLocalResolver = /** @class */ (function () {
  26823. function TypeCheckLocalResolver() {
  26824. }
  26825. /**
  26826. * @param {?} name
  26827. * @return {?}
  26828. */
  26829. TypeCheckLocalResolver.prototype.getLocal = /**
  26830. * @param {?} name
  26831. * @return {?}
  26832. */
  26833. function (name) {
  26834. if (name === EventHandlerVars.event.name) {
  26835. // References to the event should not be type-checked.
  26836. // TODO(chuckj): determine a better type for the event.
  26837. return variable(DYNAMIC_VAR_NAME);
  26838. }
  26839. return null;
  26840. };
  26841. return TypeCheckLocalResolver;
  26842. }());
  26843. var defaultResolver = new TypeCheckLocalResolver();
  26844. var ViewBuilder = /** @class */ (function () {
  26845. function ViewBuilder(options, reflector, externalReferenceVars, parent, component, isHostComponent, embeddedViewIndex, pipes, guards, ctx, viewBuilderFactory) {
  26846. this.options = options;
  26847. this.reflector = reflector;
  26848. this.externalReferenceVars = externalReferenceVars;
  26849. this.parent = parent;
  26850. this.component = component;
  26851. this.isHostComponent = isHostComponent;
  26852. this.embeddedViewIndex = embeddedViewIndex;
  26853. this.pipes = pipes;
  26854. this.guards = guards;
  26855. this.ctx = ctx;
  26856. this.viewBuilderFactory = viewBuilderFactory;
  26857. this.refOutputVars = new Map();
  26858. this.variables = [];
  26859. this.children = [];
  26860. this.updates = [];
  26861. this.actions = [];
  26862. }
  26863. /**
  26864. * @param {?} type
  26865. * @return {?}
  26866. */
  26867. ViewBuilder.prototype.getOutputVar = /**
  26868. * @param {?} type
  26869. * @return {?}
  26870. */
  26871. function (type) {
  26872. var /** @type {?} */ varName;
  26873. if (type === this.component && this.isHostComponent) {
  26874. varName = DYNAMIC_VAR_NAME;
  26875. }
  26876. else if (type instanceof StaticSymbol) {
  26877. varName = this.externalReferenceVars.get(type);
  26878. }
  26879. else {
  26880. varName = DYNAMIC_VAR_NAME;
  26881. }
  26882. if (!varName) {
  26883. throw new Error("Illegal State: referring to a type without a variable " + JSON.stringify(type));
  26884. }
  26885. return varName;
  26886. };
  26887. /**
  26888. * @param {?} ast
  26889. * @return {?}
  26890. */
  26891. ViewBuilder.prototype.getTypeGuardExpressions = /**
  26892. * @param {?} ast
  26893. * @return {?}
  26894. */
  26895. function (ast) {
  26896. var /** @type {?} */ result = this.guards.slice();
  26897. for (var _i = 0, _a = ast.directives; _i < _a.length; _i++) {
  26898. var directive = _a[_i];
  26899. for (var _b = 0, _c = directive.inputs; _b < _c.length; _b++) {
  26900. var input = _c[_b];
  26901. var /** @type {?} */ guard = directive.directive.guards[input.directiveName];
  26902. if (guard) {
  26903. var /** @type {?} */ useIf = guard === 'UseIf';
  26904. result.push({
  26905. guard: guard,
  26906. useIf: useIf,
  26907. expression: /** @type {?} */ ({ context: this.component, value: input.value })
  26908. });
  26909. }
  26910. }
  26911. }
  26912. return result;
  26913. };
  26914. /**
  26915. * @param {?} variables
  26916. * @param {?} astNodes
  26917. * @return {?}
  26918. */
  26919. ViewBuilder.prototype.visitAll = /**
  26920. * @param {?} variables
  26921. * @param {?} astNodes
  26922. * @return {?}
  26923. */
  26924. function (variables, astNodes) {
  26925. this.variables = variables;
  26926. templateVisitAll(this, astNodes);
  26927. };
  26928. /**
  26929. * @param {?} componentId
  26930. * @param {?=} targetStatements
  26931. * @return {?}
  26932. */
  26933. ViewBuilder.prototype.build = /**
  26934. * @param {?} componentId
  26935. * @param {?=} targetStatements
  26936. * @return {?}
  26937. */
  26938. function (componentId, targetStatements) {
  26939. var _this = this;
  26940. if (targetStatements === void 0) { targetStatements = []; }
  26941. this.children.forEach(function (child) { return child.build(componentId, targetStatements); });
  26942. var /** @type {?} */ viewStmts = [variable(DYNAMIC_VAR_NAME).set(NULL_EXPR).toDeclStmt(DYNAMIC_TYPE)];
  26943. var /** @type {?} */ bindingCount = 0;
  26944. this.updates.forEach(function (expression) {
  26945. var _a = _this.preprocessUpdateExpression(expression), sourceSpan = _a.sourceSpan, context = _a.context, value = _a.value;
  26946. var /** @type {?} */ bindingId = "" + bindingCount++;
  26947. var /** @type {?} */ nameResolver = context === _this.component ? _this : defaultResolver;
  26948. var _b = convertPropertyBinding(nameResolver, variable(_this.getOutputVar(context)), value, bindingId, BindingForm.General), stmts = _b.stmts, currValExpr = _b.currValExpr;
  26949. stmts.push(new ExpressionStatement(currValExpr));
  26950. viewStmts.push.apply(viewStmts, stmts.map(function (stmt) { return applySourceSpanToStatementIfNeeded(stmt, sourceSpan); }));
  26951. });
  26952. this.actions.forEach(function (_a) {
  26953. var sourceSpan = _a.sourceSpan, context = _a.context, value = _a.value;
  26954. var /** @type {?} */ bindingId = "" + bindingCount++;
  26955. var /** @type {?} */ nameResolver = context === _this.component ? _this : defaultResolver;
  26956. var stmts = convertActionBinding(nameResolver, variable(_this.getOutputVar(context)), value, bindingId).stmts;
  26957. viewStmts.push.apply(viewStmts, stmts.map(function (stmt) { return applySourceSpanToStatementIfNeeded(stmt, sourceSpan); }));
  26958. });
  26959. if (this.guards.length) {
  26960. var /** @type {?} */ guardExpression = undefined;
  26961. for (var _i = 0, _a = this.guards; _i < _a.length; _i++) {
  26962. var guard = _a[_i];
  26963. var _b = this.preprocessUpdateExpression(guard.expression), context = _b.context, value = _b.value;
  26964. var /** @type {?} */ bindingId = "" + bindingCount++;
  26965. var /** @type {?} */ nameResolver = context === this.component ? this : defaultResolver;
  26966. // We only support support simple expressions and ignore others as they
  26967. // are unlikely to affect type narrowing.
  26968. var _c = convertPropertyBinding(nameResolver, variable(this.getOutputVar(context)), value, bindingId, BindingForm.TrySimple), stmts = _c.stmts, currValExpr = _c.currValExpr;
  26969. if (stmts.length == 0) {
  26970. var /** @type {?} */ guardClause = guard.useIf ? currValExpr : this.ctx.importExpr(guard.guard).callFn([currValExpr]);
  26971. guardExpression = guardExpression ? guardExpression.and(guardClause) : guardClause;
  26972. }
  26973. }
  26974. if (guardExpression) {
  26975. viewStmts = [new IfStmt(guardExpression, viewStmts)];
  26976. }
  26977. }
  26978. var /** @type {?} */ viewName = "_View_" + componentId + "_" + this.embeddedViewIndex;
  26979. var /** @type {?} */ viewFactory = new DeclareFunctionStmt(viewName, [], viewStmts);
  26980. targetStatements.push(viewFactory);
  26981. return targetStatements;
  26982. };
  26983. /**
  26984. * @param {?} ast
  26985. * @param {?} context
  26986. * @return {?}
  26987. */
  26988. ViewBuilder.prototype.visitBoundText = /**
  26989. * @param {?} ast
  26990. * @param {?} context
  26991. * @return {?}
  26992. */
  26993. function (ast, context) {
  26994. var _this = this;
  26995. var /** @type {?} */ astWithSource = /** @type {?} */ (ast.value);
  26996. var /** @type {?} */ inter = /** @type {?} */ (astWithSource.ast);
  26997. inter.expressions.forEach(function (expr) {
  26998. return _this.updates.push({ context: _this.component, value: expr, sourceSpan: ast.sourceSpan });
  26999. });
  27000. };
  27001. /**
  27002. * @param {?} ast
  27003. * @param {?} context
  27004. * @return {?}
  27005. */
  27006. ViewBuilder.prototype.visitEmbeddedTemplate = /**
  27007. * @param {?} ast
  27008. * @param {?} context
  27009. * @return {?}
  27010. */
  27011. function (ast, context) {
  27012. this.visitElementOrTemplate(ast);
  27013. // Note: The old view compiler used to use an `any` type
  27014. // for the context in any embedded view.
  27015. // We keep this behaivor behind a flag for now.
  27016. if (this.options.fullTemplateTypeCheck) {
  27017. // Find any applicable type guards. For example, NgIf has a type guard on ngIf
  27018. // (see NgIf.ngIfTypeGuard) that can be used to indicate that a template is only
  27019. // stamped out if ngIf is truthy so any bindings in the template can assume that,
  27020. // if a nullable type is used for ngIf, that expression is not null or undefined.
  27021. var /** @type {?} */ guards = this.getTypeGuardExpressions(ast);
  27022. var /** @type {?} */ childVisitor = this.viewBuilderFactory(this, guards);
  27023. this.children.push(childVisitor);
  27024. childVisitor.visitAll(ast.variables, ast.children);
  27025. }
  27026. };
  27027. /**
  27028. * @param {?} ast
  27029. * @param {?} context
  27030. * @return {?}
  27031. */
  27032. ViewBuilder.prototype.visitElement = /**
  27033. * @param {?} ast
  27034. * @param {?} context
  27035. * @return {?}
  27036. */
  27037. function (ast, context) {
  27038. var _this = this;
  27039. this.visitElementOrTemplate(ast);
  27040. var /** @type {?} */ inputDefs = [];
  27041. var /** @type {?} */ updateRendererExpressions = [];
  27042. var /** @type {?} */ outputDefs = [];
  27043. ast.inputs.forEach(function (inputAst) {
  27044. _this.updates.push({ context: _this.component, value: inputAst.value, sourceSpan: inputAst.sourceSpan });
  27045. });
  27046. templateVisitAll(this, ast.children);
  27047. };
  27048. /**
  27049. * @param {?} ast
  27050. * @return {?}
  27051. */
  27052. ViewBuilder.prototype.visitElementOrTemplate = /**
  27053. * @param {?} ast
  27054. * @return {?}
  27055. */
  27056. function (ast) {
  27057. var _this = this;
  27058. ast.directives.forEach(function (dirAst) { _this.visitDirective(dirAst); });
  27059. ast.references.forEach(function (ref) {
  27060. var /** @type {?} */ outputVarType = /** @type {?} */ ((null));
  27061. // Note: The old view compiler used to use an `any` type
  27062. // for directives exposed via `exportAs`.
  27063. // We keep this behaivor behind a flag for now.
  27064. if (ref.value && ref.value.identifier && _this.options.fullTemplateTypeCheck) {
  27065. outputVarType = ref.value.identifier.reference;
  27066. }
  27067. else {
  27068. outputVarType = BuiltinTypeName.Dynamic;
  27069. }
  27070. _this.refOutputVars.set(ref.name, outputVarType);
  27071. });
  27072. ast.outputs.forEach(function (outputAst) {
  27073. _this.actions.push({ context: _this.component, value: outputAst.handler, sourceSpan: outputAst.sourceSpan });
  27074. });
  27075. };
  27076. /**
  27077. * @param {?} dirAst
  27078. * @return {?}
  27079. */
  27080. ViewBuilder.prototype.visitDirective = /**
  27081. * @param {?} dirAst
  27082. * @return {?}
  27083. */
  27084. function (dirAst) {
  27085. var _this = this;
  27086. var /** @type {?} */ dirType = dirAst.directive.type.reference;
  27087. dirAst.inputs.forEach(function (input) {
  27088. return _this.updates.push({ context: _this.component, value: input.value, sourceSpan: input.sourceSpan });
  27089. });
  27090. // Note: The old view compiler used to use an `any` type
  27091. // for expressions in host properties / events.
  27092. // We keep this behaivor behind a flag for now.
  27093. if (this.options.fullTemplateTypeCheck) {
  27094. dirAst.hostProperties.forEach(function (inputAst) {
  27095. return _this.updates.push({ context: dirType, value: inputAst.value, sourceSpan: inputAst.sourceSpan });
  27096. });
  27097. dirAst.hostEvents.forEach(function (hostEventAst) {
  27098. return _this.actions.push({
  27099. context: dirType,
  27100. value: hostEventAst.handler,
  27101. sourceSpan: hostEventAst.sourceSpan
  27102. });
  27103. });
  27104. }
  27105. };
  27106. /**
  27107. * @param {?} name
  27108. * @return {?}
  27109. */
  27110. ViewBuilder.prototype.getLocal = /**
  27111. * @param {?} name
  27112. * @return {?}
  27113. */
  27114. function (name) {
  27115. if (name == EventHandlerVars.event.name) {
  27116. return variable(this.getOutputVar(BuiltinTypeName.Dynamic));
  27117. }
  27118. for (var /** @type {?} */ currBuilder = this; currBuilder; currBuilder = currBuilder.parent) {
  27119. var /** @type {?} */ outputVarType = void 0;
  27120. // check references
  27121. outputVarType = currBuilder.refOutputVars.get(name);
  27122. if (outputVarType == null) {
  27123. // check variables
  27124. var /** @type {?} */ varAst = currBuilder.variables.find(function (varAst) { return varAst.name === name; });
  27125. if (varAst) {
  27126. outputVarType = BuiltinTypeName.Dynamic;
  27127. }
  27128. }
  27129. if (outputVarType != null) {
  27130. return variable(this.getOutputVar(outputVarType));
  27131. }
  27132. }
  27133. return null;
  27134. };
  27135. /**
  27136. * @param {?} name
  27137. * @return {?}
  27138. */
  27139. ViewBuilder.prototype.pipeOutputVar = /**
  27140. * @param {?} name
  27141. * @return {?}
  27142. */
  27143. function (name) {
  27144. var /** @type {?} */ pipe = this.pipes.get(name);
  27145. if (!pipe) {
  27146. throw new Error("Illegal State: Could not find pipe " + name + " in template of " + this.component);
  27147. }
  27148. return this.getOutputVar(pipe);
  27149. };
  27150. /**
  27151. * @param {?} expression
  27152. * @return {?}
  27153. */
  27154. ViewBuilder.prototype.preprocessUpdateExpression = /**
  27155. * @param {?} expression
  27156. * @return {?}
  27157. */
  27158. function (expression) {
  27159. var _this = this;
  27160. return {
  27161. sourceSpan: expression.sourceSpan,
  27162. context: expression.context,
  27163. value: convertPropertyBindingBuiltins({
  27164. createLiteralArrayConverter: function (argCount) {
  27165. return function (args) {
  27166. var /** @type {?} */ arr = literalArr(args);
  27167. // Note: The old view compiler used to use an `any` type
  27168. // for arrays.
  27169. return _this.options.fullTemplateTypeCheck ? arr : arr.cast(DYNAMIC_TYPE);
  27170. };
  27171. },
  27172. createLiteralMapConverter: function (keys) {
  27173. return function (values) {
  27174. var /** @type {?} */ entries = keys.map(function (k, i) {
  27175. return ({
  27176. key: k.key,
  27177. value: values[i],
  27178. quoted: k.quoted,
  27179. });
  27180. });
  27181. var /** @type {?} */ map = literalMap(entries);
  27182. // Note: The old view compiler used to use an `any` type
  27183. // for maps.
  27184. return _this.options.fullTemplateTypeCheck ? map : map.cast(DYNAMIC_TYPE);
  27185. };
  27186. },
  27187. createPipeConverter: function (name, argCount) {
  27188. return function (args) {
  27189. // Note: The old view compiler used to use an `any` type
  27190. // for pipes.
  27191. var /** @type {?} */ pipeExpr = _this.options.fullTemplateTypeCheck ?
  27192. variable(_this.pipeOutputVar(name)) :
  27193. variable(_this.getOutputVar(BuiltinTypeName.Dynamic));
  27194. return pipeExpr.callMethod('transform', args);
  27195. };
  27196. },
  27197. }, expression.value)
  27198. };
  27199. };
  27200. /**
  27201. * @param {?} ast
  27202. * @param {?} context
  27203. * @return {?}
  27204. */
  27205. ViewBuilder.prototype.visitNgContent = /**
  27206. * @param {?} ast
  27207. * @param {?} context
  27208. * @return {?}
  27209. */
  27210. function (ast, context) { };
  27211. /**
  27212. * @param {?} ast
  27213. * @param {?} context
  27214. * @return {?}
  27215. */
  27216. ViewBuilder.prototype.visitText = /**
  27217. * @param {?} ast
  27218. * @param {?} context
  27219. * @return {?}
  27220. */
  27221. function (ast, context) { };
  27222. /**
  27223. * @param {?} ast
  27224. * @param {?} context
  27225. * @return {?}
  27226. */
  27227. ViewBuilder.prototype.visitDirectiveProperty = /**
  27228. * @param {?} ast
  27229. * @param {?} context
  27230. * @return {?}
  27231. */
  27232. function (ast, context) { };
  27233. /**
  27234. * @param {?} ast
  27235. * @param {?} context
  27236. * @return {?}
  27237. */
  27238. ViewBuilder.prototype.visitReference = /**
  27239. * @param {?} ast
  27240. * @param {?} context
  27241. * @return {?}
  27242. */
  27243. function (ast, context) { };
  27244. /**
  27245. * @param {?} ast
  27246. * @param {?} context
  27247. * @return {?}
  27248. */
  27249. ViewBuilder.prototype.visitVariable = /**
  27250. * @param {?} ast
  27251. * @param {?} context
  27252. * @return {?}
  27253. */
  27254. function (ast, context) { };
  27255. /**
  27256. * @param {?} ast
  27257. * @param {?} context
  27258. * @return {?}
  27259. */
  27260. ViewBuilder.prototype.visitEvent = /**
  27261. * @param {?} ast
  27262. * @param {?} context
  27263. * @return {?}
  27264. */
  27265. function (ast, context) { };
  27266. /**
  27267. * @param {?} ast
  27268. * @param {?} context
  27269. * @return {?}
  27270. */
  27271. ViewBuilder.prototype.visitElementProperty = /**
  27272. * @param {?} ast
  27273. * @param {?} context
  27274. * @return {?}
  27275. */
  27276. function (ast, context) { };
  27277. /**
  27278. * @param {?} ast
  27279. * @param {?} context
  27280. * @return {?}
  27281. */
  27282. ViewBuilder.prototype.visitAttr = /**
  27283. * @param {?} ast
  27284. * @param {?} context
  27285. * @return {?}
  27286. */
  27287. function (ast, context) { };
  27288. return ViewBuilder;
  27289. }());
  27290. /**
  27291. * @fileoverview added by tsickle
  27292. * @suppress {checkTypes} checked by tsc
  27293. */
  27294. /**
  27295. * @license
  27296. * Copyright Google Inc. All Rights Reserved.
  27297. *
  27298. * Use of this source code is governed by an MIT-style license that can be
  27299. * found in the LICENSE file at https://angular.io/license
  27300. */
  27301. var CLASS_ATTR$1 = 'class';
  27302. var STYLE_ATTR = 'style';
  27303. var IMPLICIT_TEMPLATE_VAR = '\$implicit';
  27304. var ViewCompileResult = /** @class */ (function () {
  27305. function ViewCompileResult(viewClassVar, rendererTypeVar) {
  27306. this.viewClassVar = viewClassVar;
  27307. this.rendererTypeVar = rendererTypeVar;
  27308. }
  27309. return ViewCompileResult;
  27310. }());
  27311. var ViewCompiler = /** @class */ (function () {
  27312. function ViewCompiler(_reflector) {
  27313. this._reflector = _reflector;
  27314. }
  27315. /**
  27316. * @param {?} outputCtx
  27317. * @param {?} component
  27318. * @param {?} template
  27319. * @param {?} styles
  27320. * @param {?} usedPipes
  27321. * @return {?}
  27322. */
  27323. ViewCompiler.prototype.compileComponent = /**
  27324. * @param {?} outputCtx
  27325. * @param {?} component
  27326. * @param {?} template
  27327. * @param {?} styles
  27328. * @param {?} usedPipes
  27329. * @return {?}
  27330. */
  27331. function (outputCtx, component, template, styles, usedPipes) {
  27332. var _this = this;
  27333. var /** @type {?} */ embeddedViewCount = 0;
  27334. var /** @type {?} */ staticQueryIds = findStaticQueryIds(template);
  27335. var /** @type {?} */ renderComponentVarName = /** @type {?} */ ((undefined));
  27336. if (!component.isHost) {
  27337. var /** @type {?} */ template_1 = /** @type {?} */ ((component.template));
  27338. var /** @type {?} */ customRenderData = [];
  27339. if (template_1.animations && template_1.animations.length) {
  27340. customRenderData.push(new LiteralMapEntry('animation', convertValueToOutputAst(outputCtx, template_1.animations), true));
  27341. }
  27342. var /** @type {?} */ renderComponentVar = variable(rendererTypeName(component.type.reference));
  27343. renderComponentVarName = /** @type {?} */ ((renderComponentVar.name));
  27344. outputCtx.statements.push(renderComponentVar
  27345. .set(importExpr(Identifiers.createRendererType2).callFn([new LiteralMapExpr([
  27346. new LiteralMapEntry('encapsulation', literal(template_1.encapsulation), false),
  27347. new LiteralMapEntry('styles', styles, false),
  27348. new LiteralMapEntry('data', new LiteralMapExpr(customRenderData), false)
  27349. ])]))
  27350. .toDeclStmt(importType(Identifiers.RendererType2), [StmtModifier.Final, StmtModifier.Exported]));
  27351. }
  27352. var /** @type {?} */ viewBuilderFactory = function (parent) {
  27353. var /** @type {?} */ embeddedViewIndex = embeddedViewCount++;
  27354. return new ViewBuilder$1(_this._reflector, outputCtx, parent, component, embeddedViewIndex, usedPipes, staticQueryIds, viewBuilderFactory);
  27355. };
  27356. var /** @type {?} */ visitor = viewBuilderFactory(null);
  27357. visitor.visitAll([], template);
  27358. (_a = outputCtx.statements).push.apply(_a, visitor.build());
  27359. return new ViewCompileResult(visitor.viewName, renderComponentVarName);
  27360. var _a;
  27361. };
  27362. return ViewCompiler;
  27363. }());
  27364. var LOG_VAR$1 = variable('_l');
  27365. var VIEW_VAR = variable('_v');
  27366. var CHECK_VAR = variable('_ck');
  27367. var COMP_VAR = variable('_co');
  27368. var EVENT_NAME_VAR = variable('en');
  27369. var ALLOW_DEFAULT_VAR = variable("ad");
  27370. var ViewBuilder$1 = /** @class */ (function () {
  27371. function ViewBuilder(reflector, outputCtx, parent, component, embeddedViewIndex, usedPipes, staticQueryIds, viewBuilderFactory) {
  27372. this.reflector = reflector;
  27373. this.outputCtx = outputCtx;
  27374. this.parent = parent;
  27375. this.component = component;
  27376. this.embeddedViewIndex = embeddedViewIndex;
  27377. this.usedPipes = usedPipes;
  27378. this.staticQueryIds = staticQueryIds;
  27379. this.viewBuilderFactory = viewBuilderFactory;
  27380. this.nodes = [];
  27381. this.purePipeNodeIndices = Object.create(null);
  27382. this.refNodeIndices = Object.create(null);
  27383. this.variables = [];
  27384. this.children = [];
  27385. // TODO(tbosch): The old view compiler used to use an `any` type
  27386. // for the context in any embedded view. We keep this behaivor for now
  27387. // to be able to introduce the new view compiler without too many errors.
  27388. this.compType = this.embeddedViewIndex > 0 ?
  27389. DYNAMIC_TYPE : /** @type {?} */
  27390. ((expressionType(outputCtx.importExpr(this.component.type.reference))));
  27391. this.viewName = viewClassName(this.component.type.reference, this.embeddedViewIndex);
  27392. }
  27393. /**
  27394. * @param {?} variables
  27395. * @param {?} astNodes
  27396. * @return {?}
  27397. */
  27398. ViewBuilder.prototype.visitAll = /**
  27399. * @param {?} variables
  27400. * @param {?} astNodes
  27401. * @return {?}
  27402. */
  27403. function (variables, astNodes) {
  27404. var _this = this;
  27405. this.variables = variables;
  27406. // create the pipes for the pure pipes immediately, so that we know their indices.
  27407. if (!this.parent) {
  27408. this.usedPipes.forEach(function (pipe) {
  27409. if (pipe.pure) {
  27410. _this.purePipeNodeIndices[pipe.name] = _this._createPipe(null, pipe);
  27411. }
  27412. });
  27413. }
  27414. if (!this.parent) {
  27415. var /** @type {?} */ queryIds_1 = staticViewQueryIds(this.staticQueryIds);
  27416. this.component.viewQueries.forEach(function (query, queryIndex) {
  27417. // Note: queries start with id 1 so we can use the number in a Bloom filter!
  27418. var /** @type {?} */ queryId = queryIndex + 1;
  27419. var /** @type {?} */ bindingType = query.first ? 0 /* First */ : 1;
  27420. var /** @type {?} */ flags = 134217728 /* TypeViewQuery */ | calcStaticDynamicQueryFlags(queryIds_1, queryId, query.first);
  27421. _this.nodes.push(function () {
  27422. return ({
  27423. sourceSpan: null,
  27424. nodeFlags: flags,
  27425. nodeDef: importExpr(Identifiers.queryDef).callFn([
  27426. literal(flags), literal(queryId),
  27427. new LiteralMapExpr([new LiteralMapEntry(query.propertyName, literal(bindingType), false)])
  27428. ])
  27429. });
  27430. });
  27431. });
  27432. }
  27433. templateVisitAll(this, astNodes);
  27434. if (this.parent && (astNodes.length === 0 || needsAdditionalRootNode(astNodes))) {
  27435. // if the view is an embedded view, then we need to add an additional root node in some cases
  27436. this.nodes.push(function () {
  27437. return ({
  27438. sourceSpan: null,
  27439. nodeFlags: 1 /* TypeElement */,
  27440. nodeDef: importExpr(Identifiers.anchorDef).callFn([
  27441. literal(0 /* None */), NULL_EXPR, NULL_EXPR, literal(0)
  27442. ])
  27443. });
  27444. });
  27445. }
  27446. };
  27447. /**
  27448. * @param {?=} targetStatements
  27449. * @return {?}
  27450. */
  27451. ViewBuilder.prototype.build = /**
  27452. * @param {?=} targetStatements
  27453. * @return {?}
  27454. */
  27455. function (targetStatements) {
  27456. if (targetStatements === void 0) { targetStatements = []; }
  27457. this.children.forEach(function (child) { return child.build(targetStatements); });
  27458. var _a = this._createNodeExpressions(), updateRendererStmts = _a.updateRendererStmts, updateDirectivesStmts = _a.updateDirectivesStmts, nodeDefExprs = _a.nodeDefExprs;
  27459. var /** @type {?} */ updateRendererFn = this._createUpdateFn(updateRendererStmts);
  27460. var /** @type {?} */ updateDirectivesFn = this._createUpdateFn(updateDirectivesStmts);
  27461. var /** @type {?} */ viewFlags = 0;
  27462. if (!this.parent && this.component.changeDetection === ChangeDetectionStrategy.OnPush) {
  27463. viewFlags |= 2 /* OnPush */;
  27464. }
  27465. var /** @type {?} */ viewFactory = new DeclareFunctionStmt(this.viewName, [new FnParam(/** @type {?} */ ((LOG_VAR$1.name)))], [new ReturnStatement(importExpr(Identifiers.viewDef).callFn([
  27466. literal(viewFlags),
  27467. literalArr(nodeDefExprs),
  27468. updateDirectivesFn,
  27469. updateRendererFn,
  27470. ]))], importType(Identifiers.ViewDefinition), this.embeddedViewIndex === 0 ? [StmtModifier.Exported] : []);
  27471. targetStatements.push(viewFactory);
  27472. return targetStatements;
  27473. };
  27474. /**
  27475. * @param {?} updateStmts
  27476. * @return {?}
  27477. */
  27478. ViewBuilder.prototype._createUpdateFn = /**
  27479. * @param {?} updateStmts
  27480. * @return {?}
  27481. */
  27482. function (updateStmts) {
  27483. var /** @type {?} */ updateFn;
  27484. if (updateStmts.length > 0) {
  27485. var /** @type {?} */ preStmts = [];
  27486. if (!this.component.isHost && findReadVarNames(updateStmts).has(/** @type {?} */ ((COMP_VAR.name)))) {
  27487. preStmts.push(COMP_VAR.set(VIEW_VAR.prop('component')).toDeclStmt(this.compType));
  27488. }
  27489. updateFn = fn([
  27490. new FnParam(/** @type {?} */ ((CHECK_VAR.name)), INFERRED_TYPE),
  27491. new FnParam(/** @type {?} */ ((VIEW_VAR.name)), INFERRED_TYPE)
  27492. ], preStmts.concat(updateStmts), INFERRED_TYPE);
  27493. }
  27494. else {
  27495. updateFn = NULL_EXPR;
  27496. }
  27497. return updateFn;
  27498. };
  27499. /**
  27500. * @param {?} ast
  27501. * @param {?} context
  27502. * @return {?}
  27503. */
  27504. ViewBuilder.prototype.visitNgContent = /**
  27505. * @param {?} ast
  27506. * @param {?} context
  27507. * @return {?}
  27508. */
  27509. function (ast, context) {
  27510. // ngContentDef(ngContentIndex: number, index: number): NodeDef;
  27511. this.nodes.push(function () {
  27512. return ({
  27513. sourceSpan: ast.sourceSpan,
  27514. nodeFlags: 8 /* TypeNgContent */,
  27515. nodeDef: importExpr(Identifiers.ngContentDef).callFn([
  27516. literal(ast.ngContentIndex), literal(ast.index)
  27517. ])
  27518. });
  27519. });
  27520. };
  27521. /**
  27522. * @param {?} ast
  27523. * @param {?} context
  27524. * @return {?}
  27525. */
  27526. ViewBuilder.prototype.visitText = /**
  27527. * @param {?} ast
  27528. * @param {?} context
  27529. * @return {?}
  27530. */
  27531. function (ast, context) {
  27532. // Static text nodes have no check function
  27533. var /** @type {?} */ checkIndex = -1;
  27534. this.nodes.push(function () {
  27535. return ({
  27536. sourceSpan: ast.sourceSpan,
  27537. nodeFlags: 2 /* TypeText */,
  27538. nodeDef: importExpr(Identifiers.textDef).callFn([
  27539. literal(checkIndex),
  27540. literal(ast.ngContentIndex),
  27541. literalArr([literal(ast.value)]),
  27542. ])
  27543. });
  27544. });
  27545. };
  27546. /**
  27547. * @param {?} ast
  27548. * @param {?} context
  27549. * @return {?}
  27550. */
  27551. ViewBuilder.prototype.visitBoundText = /**
  27552. * @param {?} ast
  27553. * @param {?} context
  27554. * @return {?}
  27555. */
  27556. function (ast, context) {
  27557. var _this = this;
  27558. var /** @type {?} */ nodeIndex = this.nodes.length;
  27559. // reserve the space in the nodeDefs array
  27560. this.nodes.push(/** @type {?} */ ((null)));
  27561. var /** @type {?} */ astWithSource = /** @type {?} */ (ast.value);
  27562. var /** @type {?} */ inter = /** @type {?} */ (astWithSource.ast);
  27563. var /** @type {?} */ updateRendererExpressions = inter.expressions.map(function (expr, bindingIndex) {
  27564. return _this._preprocessUpdateExpression({ nodeIndex: nodeIndex, bindingIndex: bindingIndex, sourceSpan: ast.sourceSpan, context: COMP_VAR, value: expr });
  27565. });
  27566. // Check index is the same as the node index during compilation
  27567. // They might only differ at runtime
  27568. var /** @type {?} */ checkIndex = nodeIndex;
  27569. this.nodes[nodeIndex] = function () {
  27570. return ({
  27571. sourceSpan: ast.sourceSpan,
  27572. nodeFlags: 2 /* TypeText */,
  27573. nodeDef: importExpr(Identifiers.textDef).callFn([
  27574. literal(checkIndex),
  27575. literal(ast.ngContentIndex),
  27576. literalArr(inter.strings.map(function (s) { return literal(s); })),
  27577. ]),
  27578. updateRenderer: updateRendererExpressions
  27579. });
  27580. };
  27581. };
  27582. /**
  27583. * @param {?} ast
  27584. * @param {?} context
  27585. * @return {?}
  27586. */
  27587. ViewBuilder.prototype.visitEmbeddedTemplate = /**
  27588. * @param {?} ast
  27589. * @param {?} context
  27590. * @return {?}
  27591. */
  27592. function (ast, context) {
  27593. var _this = this;
  27594. var /** @type {?} */ nodeIndex = this.nodes.length;
  27595. // reserve the space in the nodeDefs array
  27596. this.nodes.push(/** @type {?} */ ((null)));
  27597. var _a = this._visitElementOrTemplate(nodeIndex, ast), flags = _a.flags, queryMatchesExpr = _a.queryMatchesExpr, hostEvents = _a.hostEvents;
  27598. var /** @type {?} */ childVisitor = this.viewBuilderFactory(this);
  27599. this.children.push(childVisitor);
  27600. childVisitor.visitAll(ast.variables, ast.children);
  27601. var /** @type {?} */ childCount = this.nodes.length - nodeIndex - 1;
  27602. // anchorDef(
  27603. // flags: NodeFlags, matchedQueries: [string, QueryValueType][], ngContentIndex: number,
  27604. // childCount: number, handleEventFn?: ElementHandleEventFn, templateFactory?:
  27605. // ViewDefinitionFactory): NodeDef;
  27606. this.nodes[nodeIndex] = function () {
  27607. return ({
  27608. sourceSpan: ast.sourceSpan,
  27609. nodeFlags: 1 /* TypeElement */ | flags,
  27610. nodeDef: importExpr(Identifiers.anchorDef).callFn([
  27611. literal(flags),
  27612. queryMatchesExpr,
  27613. literal(ast.ngContentIndex),
  27614. literal(childCount),
  27615. _this._createElementHandleEventFn(nodeIndex, hostEvents),
  27616. variable(childVisitor.viewName),
  27617. ])
  27618. });
  27619. };
  27620. };
  27621. /**
  27622. * @param {?} ast
  27623. * @param {?} context
  27624. * @return {?}
  27625. */
  27626. ViewBuilder.prototype.visitElement = /**
  27627. * @param {?} ast
  27628. * @param {?} context
  27629. * @return {?}
  27630. */
  27631. function (ast, context) {
  27632. var _this = this;
  27633. var /** @type {?} */ nodeIndex = this.nodes.length;
  27634. // reserve the space in the nodeDefs array so we can add children
  27635. this.nodes.push(/** @type {?} */ ((null)));
  27636. // Using a null element name creates an anchor.
  27637. var /** @type {?} */ elName = isNgContainer(ast.name) ? null : ast.name;
  27638. var _a = this._visitElementOrTemplate(nodeIndex, ast), flags = _a.flags, usedEvents = _a.usedEvents, queryMatchesExpr = _a.queryMatchesExpr, dirHostBindings = _a.hostBindings, hostEvents = _a.hostEvents;
  27639. var /** @type {?} */ inputDefs = [];
  27640. var /** @type {?} */ updateRendererExpressions = [];
  27641. var /** @type {?} */ outputDefs = [];
  27642. if (elName) {
  27643. var /** @type {?} */ hostBindings = ast.inputs
  27644. .map(function (inputAst) {
  27645. return ({
  27646. context: /** @type {?} */ (COMP_VAR),
  27647. inputAst: inputAst,
  27648. dirAst: /** @type {?} */ (null),
  27649. });
  27650. })
  27651. .concat(dirHostBindings);
  27652. if (hostBindings.length) {
  27653. updateRendererExpressions =
  27654. hostBindings.map(function (hostBinding, bindingIndex) {
  27655. return _this._preprocessUpdateExpression({
  27656. context: hostBinding.context,
  27657. nodeIndex: nodeIndex,
  27658. bindingIndex: bindingIndex,
  27659. sourceSpan: hostBinding.inputAst.sourceSpan,
  27660. value: hostBinding.inputAst.value
  27661. });
  27662. });
  27663. inputDefs = hostBindings.map(function (hostBinding) { return elementBindingDef(hostBinding.inputAst, hostBinding.dirAst); });
  27664. }
  27665. outputDefs = usedEvents.map(function (_a) {
  27666. var target = _a[0], eventName = _a[1];
  27667. return literalArr([literal(target), literal(eventName)]);
  27668. });
  27669. }
  27670. templateVisitAll(this, ast.children);
  27671. var /** @type {?} */ childCount = this.nodes.length - nodeIndex - 1;
  27672. var /** @type {?} */ compAst = ast.directives.find(function (dirAst) { return dirAst.directive.isComponent; });
  27673. var /** @type {?} */ compRendererType = /** @type {?} */ (NULL_EXPR);
  27674. var /** @type {?} */ compView = /** @type {?} */ (NULL_EXPR);
  27675. if (compAst) {
  27676. compView = this.outputCtx.importExpr(compAst.directive.componentViewType);
  27677. compRendererType = this.outputCtx.importExpr(compAst.directive.rendererType);
  27678. }
  27679. // Check index is the same as the node index during compilation
  27680. // They might only differ at runtime
  27681. var /** @type {?} */ checkIndex = nodeIndex;
  27682. this.nodes[nodeIndex] = function () {
  27683. return ({
  27684. sourceSpan: ast.sourceSpan,
  27685. nodeFlags: 1 /* TypeElement */ | flags,
  27686. nodeDef: importExpr(Identifiers.elementDef).callFn([
  27687. literal(checkIndex),
  27688. literal(flags),
  27689. queryMatchesExpr,
  27690. literal(ast.ngContentIndex),
  27691. literal(childCount),
  27692. literal(elName),
  27693. elName ? fixedAttrsDef(ast) : NULL_EXPR,
  27694. inputDefs.length ? literalArr(inputDefs) : NULL_EXPR,
  27695. outputDefs.length ? literalArr(outputDefs) : NULL_EXPR,
  27696. _this._createElementHandleEventFn(nodeIndex, hostEvents),
  27697. compView,
  27698. compRendererType,
  27699. ]),
  27700. updateRenderer: updateRendererExpressions
  27701. });
  27702. };
  27703. };
  27704. /**
  27705. * @param {?} nodeIndex
  27706. * @param {?} ast
  27707. * @return {?}
  27708. */
  27709. ViewBuilder.prototype._visitElementOrTemplate = /**
  27710. * @param {?} nodeIndex
  27711. * @param {?} ast
  27712. * @return {?}
  27713. */
  27714. function (nodeIndex, ast) {
  27715. var _this = this;
  27716. var /** @type {?} */ flags = 0;
  27717. if (ast.hasViewContainer) {
  27718. flags |= 16777216 /* EmbeddedViews */;
  27719. }
  27720. var /** @type {?} */ usedEvents = new Map();
  27721. ast.outputs.forEach(function (event) {
  27722. var _a = elementEventNameAndTarget(event, null), name = _a.name, target = _a.target;
  27723. usedEvents.set(elementEventFullName(target, name), [target, name]);
  27724. });
  27725. ast.directives.forEach(function (dirAst) {
  27726. dirAst.hostEvents.forEach(function (event) {
  27727. var _a = elementEventNameAndTarget(event, dirAst), name = _a.name, target = _a.target;
  27728. usedEvents.set(elementEventFullName(target, name), [target, name]);
  27729. });
  27730. });
  27731. var /** @type {?} */ hostBindings = [];
  27732. var /** @type {?} */ hostEvents = [];
  27733. this._visitComponentFactoryResolverProvider(ast.directives);
  27734. ast.providers.forEach(function (providerAst, providerIndex) {
  27735. var /** @type {?} */ dirAst = /** @type {?} */ ((undefined));
  27736. var /** @type {?} */ dirIndex = /** @type {?} */ ((undefined));
  27737. ast.directives.forEach(function (localDirAst, i) {
  27738. if (localDirAst.directive.type.reference === tokenReference(providerAst.token)) {
  27739. dirAst = localDirAst;
  27740. dirIndex = i;
  27741. }
  27742. });
  27743. if (dirAst) {
  27744. var _a = _this._visitDirective(providerAst, dirAst, dirIndex, nodeIndex, ast.references, ast.queryMatches, usedEvents, /** @type {?} */ ((_this.staticQueryIds.get(/** @type {?} */ (ast))))), dirHostBindings = _a.hostBindings, dirHostEvents = _a.hostEvents;
  27745. hostBindings.push.apply(hostBindings, dirHostBindings);
  27746. hostEvents.push.apply(hostEvents, dirHostEvents);
  27747. }
  27748. else {
  27749. _this._visitProvider(providerAst, ast.queryMatches);
  27750. }
  27751. });
  27752. var /** @type {?} */ queryMatchExprs = [];
  27753. ast.queryMatches.forEach(function (match) {
  27754. var /** @type {?} */ valueType = /** @type {?} */ ((undefined));
  27755. if (tokenReference(match.value) ===
  27756. _this.reflector.resolveExternalReference(Identifiers.ElementRef)) {
  27757. valueType = 0 /* ElementRef */;
  27758. }
  27759. else if (tokenReference(match.value) ===
  27760. _this.reflector.resolveExternalReference(Identifiers.ViewContainerRef)) {
  27761. valueType = 3 /* ViewContainerRef */;
  27762. }
  27763. else if (tokenReference(match.value) ===
  27764. _this.reflector.resolveExternalReference(Identifiers.TemplateRef)) {
  27765. valueType = 2 /* TemplateRef */;
  27766. }
  27767. if (valueType != null) {
  27768. queryMatchExprs.push(literalArr([literal(match.queryId), literal(valueType)]));
  27769. }
  27770. });
  27771. ast.references.forEach(function (ref) {
  27772. var /** @type {?} */ valueType = /** @type {?} */ ((undefined));
  27773. if (!ref.value) {
  27774. valueType = 1 /* RenderElement */;
  27775. }
  27776. else if (tokenReference(ref.value) ===
  27777. _this.reflector.resolveExternalReference(Identifiers.TemplateRef)) {
  27778. valueType = 2 /* TemplateRef */;
  27779. }
  27780. if (valueType != null) {
  27781. _this.refNodeIndices[ref.name] = nodeIndex;
  27782. queryMatchExprs.push(literalArr([literal(ref.name), literal(valueType)]));
  27783. }
  27784. });
  27785. ast.outputs.forEach(function (outputAst) {
  27786. hostEvents.push({ context: COMP_VAR, eventAst: outputAst, dirAst: /** @type {?} */ ((null)) });
  27787. });
  27788. return {
  27789. flags: flags,
  27790. usedEvents: Array.from(usedEvents.values()),
  27791. queryMatchesExpr: queryMatchExprs.length ? literalArr(queryMatchExprs) : NULL_EXPR,
  27792. hostBindings: hostBindings,
  27793. hostEvents: hostEvents
  27794. };
  27795. };
  27796. /**
  27797. * @param {?} providerAst
  27798. * @param {?} dirAst
  27799. * @param {?} directiveIndex
  27800. * @param {?} elementNodeIndex
  27801. * @param {?} refs
  27802. * @param {?} queryMatches
  27803. * @param {?} usedEvents
  27804. * @param {?} queryIds
  27805. * @return {?}
  27806. */
  27807. ViewBuilder.prototype._visitDirective = /**
  27808. * @param {?} providerAst
  27809. * @param {?} dirAst
  27810. * @param {?} directiveIndex
  27811. * @param {?} elementNodeIndex
  27812. * @param {?} refs
  27813. * @param {?} queryMatches
  27814. * @param {?} usedEvents
  27815. * @param {?} queryIds
  27816. * @return {?}
  27817. */
  27818. function (providerAst, dirAst, directiveIndex, elementNodeIndex, refs, queryMatches, usedEvents, queryIds) {
  27819. var _this = this;
  27820. var /** @type {?} */ nodeIndex = this.nodes.length;
  27821. // reserve the space in the nodeDefs array so we can add children
  27822. this.nodes.push(/** @type {?} */ ((null)));
  27823. dirAst.directive.queries.forEach(function (query, queryIndex) {
  27824. var /** @type {?} */ queryId = dirAst.contentQueryStartId + queryIndex;
  27825. var /** @type {?} */ flags = 67108864 /* TypeContentQuery */ | calcStaticDynamicQueryFlags(queryIds, queryId, query.first);
  27826. var /** @type {?} */ bindingType = query.first ? 0 /* First */ : 1;
  27827. _this.nodes.push(function () {
  27828. return ({
  27829. sourceSpan: dirAst.sourceSpan,
  27830. nodeFlags: flags,
  27831. nodeDef: importExpr(Identifiers.queryDef).callFn([
  27832. literal(flags), literal(queryId),
  27833. new LiteralMapExpr([new LiteralMapEntry(query.propertyName, literal(bindingType), false)])
  27834. ]),
  27835. });
  27836. });
  27837. });
  27838. // Note: the operation below might also create new nodeDefs,
  27839. // but we don't want them to be a child of a directive,
  27840. // as they might be a provider/pipe on their own.
  27841. // I.e. we only allow queries as children of directives nodes.
  27842. var /** @type {?} */ childCount = this.nodes.length - nodeIndex - 1;
  27843. var _a = this._visitProviderOrDirective(providerAst, queryMatches), flags = _a.flags, queryMatchExprs = _a.queryMatchExprs, providerExpr = _a.providerExpr, depsExpr = _a.depsExpr;
  27844. refs.forEach(function (ref) {
  27845. if (ref.value && tokenReference(ref.value) === tokenReference(providerAst.token)) {
  27846. _this.refNodeIndices[ref.name] = nodeIndex;
  27847. queryMatchExprs.push(literalArr([literal(ref.name), literal(4 /* Provider */)]));
  27848. }
  27849. });
  27850. if (dirAst.directive.isComponent) {
  27851. flags |= 32768 /* Component */;
  27852. }
  27853. var /** @type {?} */ inputDefs = dirAst.inputs.map(function (inputAst, inputIndex) {
  27854. var /** @type {?} */ mapValue = literalArr([literal(inputIndex), literal(inputAst.directiveName)]);
  27855. // Note: it's important to not quote the key so that we can capture renames by minifiers!
  27856. return new LiteralMapEntry(inputAst.directiveName, mapValue, false);
  27857. });
  27858. var /** @type {?} */ outputDefs = [];
  27859. var /** @type {?} */ dirMeta = dirAst.directive;
  27860. Object.keys(dirMeta.outputs).forEach(function (propName) {
  27861. var /** @type {?} */ eventName = dirMeta.outputs[propName];
  27862. if (usedEvents.has(eventName)) {
  27863. // Note: it's important to not quote the key so that we can capture renames by minifiers!
  27864. outputDefs.push(new LiteralMapEntry(propName, literal(eventName), false));
  27865. }
  27866. });
  27867. var /** @type {?} */ updateDirectiveExpressions = [];
  27868. if (dirAst.inputs.length || (flags & (262144 /* DoCheck */ | 65536 /* OnInit */)) > 0) {
  27869. updateDirectiveExpressions =
  27870. dirAst.inputs.map(function (input, bindingIndex) {
  27871. return _this._preprocessUpdateExpression({
  27872. nodeIndex: nodeIndex,
  27873. bindingIndex: bindingIndex,
  27874. sourceSpan: input.sourceSpan,
  27875. context: COMP_VAR,
  27876. value: input.value
  27877. });
  27878. });
  27879. }
  27880. var /** @type {?} */ dirContextExpr = importExpr(Identifiers.nodeValue).callFn([VIEW_VAR, literal(nodeIndex)]);
  27881. var /** @type {?} */ hostBindings = dirAst.hostProperties.map(function (inputAst) {
  27882. return ({
  27883. context: dirContextExpr,
  27884. dirAst: dirAst,
  27885. inputAst: inputAst,
  27886. });
  27887. });
  27888. var /** @type {?} */ hostEvents = dirAst.hostEvents.map(function (hostEventAst) {
  27889. return ({
  27890. context: dirContextExpr,
  27891. eventAst: hostEventAst, dirAst: dirAst,
  27892. });
  27893. });
  27894. // Check index is the same as the node index during compilation
  27895. // They might only differ at runtime
  27896. var /** @type {?} */ checkIndex = nodeIndex;
  27897. this.nodes[nodeIndex] = function () {
  27898. return ({
  27899. sourceSpan: dirAst.sourceSpan,
  27900. nodeFlags: 16384 /* TypeDirective */ | flags,
  27901. nodeDef: importExpr(Identifiers.directiveDef).callFn([
  27902. literal(checkIndex),
  27903. literal(flags),
  27904. queryMatchExprs.length ? literalArr(queryMatchExprs) : NULL_EXPR,
  27905. literal(childCount),
  27906. providerExpr,
  27907. depsExpr,
  27908. inputDefs.length ? new LiteralMapExpr(inputDefs) : NULL_EXPR,
  27909. outputDefs.length ? new LiteralMapExpr(outputDefs) : NULL_EXPR,
  27910. ]),
  27911. updateDirectives: updateDirectiveExpressions,
  27912. directive: dirAst.directive.type,
  27913. });
  27914. };
  27915. return { hostBindings: hostBindings, hostEvents: hostEvents };
  27916. };
  27917. /**
  27918. * @param {?} providerAst
  27919. * @param {?} queryMatches
  27920. * @return {?}
  27921. */
  27922. ViewBuilder.prototype._visitProvider = /**
  27923. * @param {?} providerAst
  27924. * @param {?} queryMatches
  27925. * @return {?}
  27926. */
  27927. function (providerAst, queryMatches) {
  27928. this._addProviderNode(this._visitProviderOrDirective(providerAst, queryMatches));
  27929. };
  27930. /**
  27931. * @param {?} directives
  27932. * @return {?}
  27933. */
  27934. ViewBuilder.prototype._visitComponentFactoryResolverProvider = /**
  27935. * @param {?} directives
  27936. * @return {?}
  27937. */
  27938. function (directives) {
  27939. var /** @type {?} */ componentDirMeta = directives.find(function (dirAst) { return dirAst.directive.isComponent; });
  27940. if (componentDirMeta && componentDirMeta.directive.entryComponents.length) {
  27941. var _a = componentFactoryResolverProviderDef(this.reflector, this.outputCtx, 8192 /* PrivateProvider */, componentDirMeta.directive.entryComponents), providerExpr = _a.providerExpr, depsExpr = _a.depsExpr, flags = _a.flags, tokenExpr = _a.tokenExpr;
  27942. this._addProviderNode({
  27943. providerExpr: providerExpr,
  27944. depsExpr: depsExpr,
  27945. flags: flags,
  27946. tokenExpr: tokenExpr,
  27947. queryMatchExprs: [],
  27948. sourceSpan: componentDirMeta.sourceSpan
  27949. });
  27950. }
  27951. };
  27952. /**
  27953. * @param {?} data
  27954. * @return {?}
  27955. */
  27956. ViewBuilder.prototype._addProviderNode = /**
  27957. * @param {?} data
  27958. * @return {?}
  27959. */
  27960. function (data) {
  27961. var /** @type {?} */ nodeIndex = this.nodes.length;
  27962. // providerDef(
  27963. // flags: NodeFlags, matchedQueries: [string, QueryValueType][], token:any,
  27964. // value: any, deps: ([DepFlags, any] | any)[]): NodeDef;
  27965. this.nodes.push(function () {
  27966. return ({
  27967. sourceSpan: data.sourceSpan,
  27968. nodeFlags: data.flags,
  27969. nodeDef: importExpr(Identifiers.providerDef).callFn([
  27970. literal(data.flags),
  27971. data.queryMatchExprs.length ? literalArr(data.queryMatchExprs) : NULL_EXPR,
  27972. data.tokenExpr, data.providerExpr, data.depsExpr
  27973. ])
  27974. });
  27975. });
  27976. };
  27977. /**
  27978. * @param {?} providerAst
  27979. * @param {?} queryMatches
  27980. * @return {?}
  27981. */
  27982. ViewBuilder.prototype._visitProviderOrDirective = /**
  27983. * @param {?} providerAst
  27984. * @param {?} queryMatches
  27985. * @return {?}
  27986. */
  27987. function (providerAst, queryMatches) {
  27988. var /** @type {?} */ flags = 0;
  27989. var /** @type {?} */ queryMatchExprs = [];
  27990. queryMatches.forEach(function (match) {
  27991. if (tokenReference(match.value) === tokenReference(providerAst.token)) {
  27992. queryMatchExprs.push(literalArr([literal(match.queryId), literal(4 /* Provider */)]));
  27993. }
  27994. });
  27995. var _a = providerDef(this.outputCtx, providerAst), providerExpr = _a.providerExpr, depsExpr = _a.depsExpr, providerFlags = _a.flags, tokenExpr = _a.tokenExpr;
  27996. return {
  27997. flags: flags | providerFlags,
  27998. queryMatchExprs: queryMatchExprs,
  27999. providerExpr: providerExpr,
  28000. depsExpr: depsExpr,
  28001. tokenExpr: tokenExpr,
  28002. sourceSpan: providerAst.sourceSpan
  28003. };
  28004. };
  28005. /**
  28006. * @param {?} name
  28007. * @return {?}
  28008. */
  28009. ViewBuilder.prototype.getLocal = /**
  28010. * @param {?} name
  28011. * @return {?}
  28012. */
  28013. function (name) {
  28014. if (name == EventHandlerVars.event.name) {
  28015. return EventHandlerVars.event;
  28016. }
  28017. var /** @type {?} */ currViewExpr = VIEW_VAR;
  28018. for (var /** @type {?} */ currBuilder = this; currBuilder; currBuilder = currBuilder.parent,
  28019. currViewExpr = currViewExpr.prop('parent').cast(DYNAMIC_TYPE)) {
  28020. // check references
  28021. var /** @type {?} */ refNodeIndex = currBuilder.refNodeIndices[name];
  28022. if (refNodeIndex != null) {
  28023. return importExpr(Identifiers.nodeValue).callFn([currViewExpr, literal(refNodeIndex)]);
  28024. }
  28025. // check variables
  28026. var /** @type {?} */ varAst = currBuilder.variables.find(function (varAst) { return varAst.name === name; });
  28027. if (varAst) {
  28028. var /** @type {?} */ varValue = varAst.value || IMPLICIT_TEMPLATE_VAR;
  28029. return currViewExpr.prop('context').prop(varValue);
  28030. }
  28031. }
  28032. return null;
  28033. };
  28034. /**
  28035. * @param {?} sourceSpan
  28036. * @param {?} argCount
  28037. * @return {?}
  28038. */
  28039. ViewBuilder.prototype._createLiteralArrayConverter = /**
  28040. * @param {?} sourceSpan
  28041. * @param {?} argCount
  28042. * @return {?}
  28043. */
  28044. function (sourceSpan, argCount) {
  28045. if (argCount === 0) {
  28046. var /** @type {?} */ valueExpr_1 = importExpr(Identifiers.EMPTY_ARRAY);
  28047. return function () { return valueExpr_1; };
  28048. }
  28049. var /** @type {?} */ checkIndex = this.nodes.length;
  28050. this.nodes.push(function () {
  28051. return ({
  28052. sourceSpan: sourceSpan,
  28053. nodeFlags: 32 /* TypePureArray */,
  28054. nodeDef: importExpr(Identifiers.pureArrayDef).callFn([
  28055. literal(checkIndex),
  28056. literal(argCount),
  28057. ])
  28058. });
  28059. });
  28060. return function (args) { return callCheckStmt(checkIndex, args); };
  28061. };
  28062. /**
  28063. * @param {?} sourceSpan
  28064. * @param {?} keys
  28065. * @return {?}
  28066. */
  28067. ViewBuilder.prototype._createLiteralMapConverter = /**
  28068. * @param {?} sourceSpan
  28069. * @param {?} keys
  28070. * @return {?}
  28071. */
  28072. function (sourceSpan, keys) {
  28073. if (keys.length === 0) {
  28074. var /** @type {?} */ valueExpr_2 = importExpr(Identifiers.EMPTY_MAP);
  28075. return function () { return valueExpr_2; };
  28076. }
  28077. var /** @type {?} */ map = literalMap(keys.map(function (e, i) { return (__assign({}, e, { value: literal(i) })); }));
  28078. var /** @type {?} */ checkIndex = this.nodes.length;
  28079. this.nodes.push(function () {
  28080. return ({
  28081. sourceSpan: sourceSpan,
  28082. nodeFlags: 64 /* TypePureObject */,
  28083. nodeDef: importExpr(Identifiers.pureObjectDef).callFn([
  28084. literal(checkIndex),
  28085. map,
  28086. ])
  28087. });
  28088. });
  28089. return function (args) { return callCheckStmt(checkIndex, args); };
  28090. };
  28091. /**
  28092. * @param {?} expression
  28093. * @param {?} name
  28094. * @param {?} argCount
  28095. * @return {?}
  28096. */
  28097. ViewBuilder.prototype._createPipeConverter = /**
  28098. * @param {?} expression
  28099. * @param {?} name
  28100. * @param {?} argCount
  28101. * @return {?}
  28102. */
  28103. function (expression, name, argCount) {
  28104. var /** @type {?} */ pipe = /** @type {?} */ ((this.usedPipes.find(function (pipeSummary) { return pipeSummary.name === name; })));
  28105. if (pipe.pure) {
  28106. var /** @type {?} */ checkIndex_1 = this.nodes.length;
  28107. this.nodes.push(function () {
  28108. return ({
  28109. sourceSpan: expression.sourceSpan,
  28110. nodeFlags: 128 /* TypePurePipe */,
  28111. nodeDef: importExpr(Identifiers.purePipeDef).callFn([
  28112. literal(checkIndex_1),
  28113. literal(argCount),
  28114. ])
  28115. });
  28116. });
  28117. // find underlying pipe in the component view
  28118. var /** @type {?} */ compViewExpr = VIEW_VAR;
  28119. var /** @type {?} */ compBuilder = this;
  28120. while (compBuilder.parent) {
  28121. compBuilder = compBuilder.parent;
  28122. compViewExpr = compViewExpr.prop('parent').cast(DYNAMIC_TYPE);
  28123. }
  28124. var /** @type {?} */ pipeNodeIndex = compBuilder.purePipeNodeIndices[name];
  28125. var /** @type {?} */ pipeValueExpr_1 = importExpr(Identifiers.nodeValue).callFn([compViewExpr, literal(pipeNodeIndex)]);
  28126. return function (args) {
  28127. return callUnwrapValue(expression.nodeIndex, expression.bindingIndex, callCheckStmt(checkIndex_1, [pipeValueExpr_1].concat(args)));
  28128. };
  28129. }
  28130. else {
  28131. var /** @type {?} */ nodeIndex = this._createPipe(expression.sourceSpan, pipe);
  28132. var /** @type {?} */ nodeValueExpr_1 = importExpr(Identifiers.nodeValue).callFn([VIEW_VAR, literal(nodeIndex)]);
  28133. return function (args) {
  28134. return callUnwrapValue(expression.nodeIndex, expression.bindingIndex, nodeValueExpr_1.callMethod('transform', args));
  28135. };
  28136. }
  28137. };
  28138. /**
  28139. * @param {?} sourceSpan
  28140. * @param {?} pipe
  28141. * @return {?}
  28142. */
  28143. ViewBuilder.prototype._createPipe = /**
  28144. * @param {?} sourceSpan
  28145. * @param {?} pipe
  28146. * @return {?}
  28147. */
  28148. function (sourceSpan, pipe) {
  28149. var _this = this;
  28150. var /** @type {?} */ nodeIndex = this.nodes.length;
  28151. var /** @type {?} */ flags = 0;
  28152. pipe.type.lifecycleHooks.forEach(function (lifecycleHook) {
  28153. // for pipes, we only support ngOnDestroy
  28154. if (lifecycleHook === LifecycleHooks.OnDestroy) {
  28155. flags |= lifecycleHookToNodeFlag(lifecycleHook);
  28156. }
  28157. });
  28158. var /** @type {?} */ depExprs = pipe.type.diDeps.map(function (diDep) { return depDef(_this.outputCtx, diDep); });
  28159. // function pipeDef(
  28160. // flags: NodeFlags, ctor: any, deps: ([DepFlags, any] | any)[]): NodeDef
  28161. this.nodes.push(function () {
  28162. return ({
  28163. sourceSpan: sourceSpan,
  28164. nodeFlags: 16 /* TypePipe */,
  28165. nodeDef: importExpr(Identifiers.pipeDef).callFn([
  28166. literal(flags), _this.outputCtx.importExpr(pipe.type.reference), literalArr(depExprs)
  28167. ])
  28168. });
  28169. });
  28170. return nodeIndex;
  28171. };
  28172. /**
  28173. * For the AST in `UpdateExpression.value`:
  28174. * - create nodes for pipes, literal arrays and, literal maps,
  28175. * - update the AST to replace pipes, literal arrays and, literal maps with calls to check fn.
  28176. *
  28177. * WARNING: This might create new nodeDefs (for pipes and literal arrays and literal maps)!
  28178. * @param {?} expression
  28179. * @return {?}
  28180. */
  28181. ViewBuilder.prototype._preprocessUpdateExpression = /**
  28182. * For the AST in `UpdateExpression.value`:
  28183. * - create nodes for pipes, literal arrays and, literal maps,
  28184. * - update the AST to replace pipes, literal arrays and, literal maps with calls to check fn.
  28185. *
  28186. * WARNING: This might create new nodeDefs (for pipes and literal arrays and literal maps)!
  28187. * @param {?} expression
  28188. * @return {?}
  28189. */
  28190. function (expression) {
  28191. var _this = this;
  28192. return {
  28193. nodeIndex: expression.nodeIndex,
  28194. bindingIndex: expression.bindingIndex,
  28195. sourceSpan: expression.sourceSpan,
  28196. context: expression.context,
  28197. value: convertPropertyBindingBuiltins({
  28198. createLiteralArrayConverter: function (argCount) {
  28199. return _this._createLiteralArrayConverter(expression.sourceSpan, argCount);
  28200. },
  28201. createLiteralMapConverter: function (keys) {
  28202. return _this._createLiteralMapConverter(expression.sourceSpan, keys);
  28203. },
  28204. createPipeConverter: function (name, argCount) {
  28205. return _this._createPipeConverter(expression, name, argCount);
  28206. }
  28207. }, expression.value)
  28208. };
  28209. };
  28210. /**
  28211. * @return {?}
  28212. */
  28213. ViewBuilder.prototype._createNodeExpressions = /**
  28214. * @return {?}
  28215. */
  28216. function () {
  28217. var /** @type {?} */ self = this;
  28218. var /** @type {?} */ updateBindingCount = 0;
  28219. var /** @type {?} */ updateRendererStmts = [];
  28220. var /** @type {?} */ updateDirectivesStmts = [];
  28221. var /** @type {?} */ nodeDefExprs = this.nodes.map(function (factory, nodeIndex) {
  28222. var _a = factory(), nodeDef = _a.nodeDef, nodeFlags = _a.nodeFlags, updateDirectives = _a.updateDirectives, updateRenderer = _a.updateRenderer, sourceSpan = _a.sourceSpan;
  28223. if (updateRenderer) {
  28224. updateRendererStmts.push.apply(updateRendererStmts, createUpdateStatements(nodeIndex, sourceSpan, updateRenderer, false));
  28225. }
  28226. if (updateDirectives) {
  28227. updateDirectivesStmts.push.apply(updateDirectivesStmts, createUpdateStatements(nodeIndex, sourceSpan, updateDirectives, (nodeFlags & (262144 /* DoCheck */ | 65536 /* OnInit */)) > 0));
  28228. }
  28229. // We use a comma expression to call the log function before
  28230. // the nodeDef function, but still use the result of the nodeDef function
  28231. // as the value.
  28232. // Note: We only add the logger to elements / text nodes,
  28233. // so we don't generate too much code.
  28234. var /** @type {?} */ logWithNodeDef = nodeFlags & 3 /* CatRenderNode */ ?
  28235. new CommaExpr([LOG_VAR$1.callFn([]).callFn([]), nodeDef]) :
  28236. nodeDef;
  28237. return applySourceSpanToExpressionIfNeeded(logWithNodeDef, sourceSpan);
  28238. });
  28239. return { updateRendererStmts: updateRendererStmts, updateDirectivesStmts: updateDirectivesStmts, nodeDefExprs: nodeDefExprs };
  28240. /**
  28241. * @param {?} nodeIndex
  28242. * @param {?} sourceSpan
  28243. * @param {?} expressions
  28244. * @param {?} allowEmptyExprs
  28245. * @return {?}
  28246. */
  28247. function createUpdateStatements(nodeIndex, sourceSpan, expressions, allowEmptyExprs) {
  28248. var /** @type {?} */ updateStmts = [];
  28249. var /** @type {?} */ exprs = expressions.map(function (_a) {
  28250. var sourceSpan = _a.sourceSpan, context = _a.context, value = _a.value;
  28251. var /** @type {?} */ bindingId = "" + updateBindingCount++;
  28252. var /** @type {?} */ nameResolver = context === COMP_VAR ? self : null;
  28253. var _b = convertPropertyBinding(nameResolver, context, value, bindingId, BindingForm.General), stmts = _b.stmts, currValExpr = _b.currValExpr;
  28254. updateStmts.push.apply(updateStmts, stmts.map(function (stmt) { return applySourceSpanToStatementIfNeeded(stmt, sourceSpan); }));
  28255. return applySourceSpanToExpressionIfNeeded(currValExpr, sourceSpan);
  28256. });
  28257. if (expressions.length || allowEmptyExprs) {
  28258. updateStmts.push(applySourceSpanToStatementIfNeeded(callCheckStmt(nodeIndex, exprs).toStmt(), sourceSpan));
  28259. }
  28260. return updateStmts;
  28261. }
  28262. };
  28263. /**
  28264. * @param {?} nodeIndex
  28265. * @param {?} handlers
  28266. * @return {?}
  28267. */
  28268. ViewBuilder.prototype._createElementHandleEventFn = /**
  28269. * @param {?} nodeIndex
  28270. * @param {?} handlers
  28271. * @return {?}
  28272. */
  28273. function (nodeIndex, handlers) {
  28274. var _this = this;
  28275. var /** @type {?} */ handleEventStmts = [];
  28276. var /** @type {?} */ handleEventBindingCount = 0;
  28277. handlers.forEach(function (_a) {
  28278. var context = _a.context, eventAst = _a.eventAst, dirAst = _a.dirAst;
  28279. var /** @type {?} */ bindingId = "" + handleEventBindingCount++;
  28280. var /** @type {?} */ nameResolver = context === COMP_VAR ? _this : null;
  28281. var _b = convertActionBinding(nameResolver, context, eventAst.handler, bindingId), stmts = _b.stmts, allowDefault = _b.allowDefault;
  28282. var /** @type {?} */ trueStmts = stmts;
  28283. if (allowDefault) {
  28284. trueStmts.push(ALLOW_DEFAULT_VAR.set(allowDefault.and(ALLOW_DEFAULT_VAR)).toStmt());
  28285. }
  28286. var _c = elementEventNameAndTarget(eventAst, dirAst), eventTarget = _c.target, eventName = _c.name;
  28287. var /** @type {?} */ fullEventName = elementEventFullName(eventTarget, eventName);
  28288. handleEventStmts.push(applySourceSpanToStatementIfNeeded(new IfStmt(literal(fullEventName).identical(EVENT_NAME_VAR), trueStmts), eventAst.sourceSpan));
  28289. });
  28290. var /** @type {?} */ handleEventFn;
  28291. if (handleEventStmts.length > 0) {
  28292. var /** @type {?} */ preStmts = [ALLOW_DEFAULT_VAR.set(literal(true)).toDeclStmt(BOOL_TYPE)];
  28293. if (!this.component.isHost && findReadVarNames(handleEventStmts).has(/** @type {?} */ ((COMP_VAR.name)))) {
  28294. preStmts.push(COMP_VAR.set(VIEW_VAR.prop('component')).toDeclStmt(this.compType));
  28295. }
  28296. handleEventFn = fn([
  28297. new FnParam(/** @type {?} */ ((VIEW_VAR.name)), INFERRED_TYPE),
  28298. new FnParam(/** @type {?} */ ((EVENT_NAME_VAR.name)), INFERRED_TYPE),
  28299. new FnParam(/** @type {?} */ ((EventHandlerVars.event.name)), INFERRED_TYPE)
  28300. ], preStmts.concat(handleEventStmts, [new ReturnStatement(ALLOW_DEFAULT_VAR)]), INFERRED_TYPE);
  28301. }
  28302. else {
  28303. handleEventFn = NULL_EXPR;
  28304. }
  28305. return handleEventFn;
  28306. };
  28307. /**
  28308. * @param {?} ast
  28309. * @param {?} context
  28310. * @return {?}
  28311. */
  28312. ViewBuilder.prototype.visitDirective = /**
  28313. * @param {?} ast
  28314. * @param {?} context
  28315. * @return {?}
  28316. */
  28317. function (ast, context) { };
  28318. /**
  28319. * @param {?} ast
  28320. * @param {?} context
  28321. * @return {?}
  28322. */
  28323. ViewBuilder.prototype.visitDirectiveProperty = /**
  28324. * @param {?} ast
  28325. * @param {?} context
  28326. * @return {?}
  28327. */
  28328. function (ast, context) { };
  28329. /**
  28330. * @param {?} ast
  28331. * @param {?} context
  28332. * @return {?}
  28333. */
  28334. ViewBuilder.prototype.visitReference = /**
  28335. * @param {?} ast
  28336. * @param {?} context
  28337. * @return {?}
  28338. */
  28339. function (ast, context) { };
  28340. /**
  28341. * @param {?} ast
  28342. * @param {?} context
  28343. * @return {?}
  28344. */
  28345. ViewBuilder.prototype.visitVariable = /**
  28346. * @param {?} ast
  28347. * @param {?} context
  28348. * @return {?}
  28349. */
  28350. function (ast, context) { };
  28351. /**
  28352. * @param {?} ast
  28353. * @param {?} context
  28354. * @return {?}
  28355. */
  28356. ViewBuilder.prototype.visitEvent = /**
  28357. * @param {?} ast
  28358. * @param {?} context
  28359. * @return {?}
  28360. */
  28361. function (ast, context) { };
  28362. /**
  28363. * @param {?} ast
  28364. * @param {?} context
  28365. * @return {?}
  28366. */
  28367. ViewBuilder.prototype.visitElementProperty = /**
  28368. * @param {?} ast
  28369. * @param {?} context
  28370. * @return {?}
  28371. */
  28372. function (ast, context) { };
  28373. /**
  28374. * @param {?} ast
  28375. * @param {?} context
  28376. * @return {?}
  28377. */
  28378. ViewBuilder.prototype.visitAttr = /**
  28379. * @param {?} ast
  28380. * @param {?} context
  28381. * @return {?}
  28382. */
  28383. function (ast, context) { };
  28384. return ViewBuilder;
  28385. }());
  28386. /**
  28387. * @param {?} astNodes
  28388. * @return {?}
  28389. */
  28390. function needsAdditionalRootNode(astNodes) {
  28391. var /** @type {?} */ lastAstNode = astNodes[astNodes.length - 1];
  28392. if (lastAstNode instanceof EmbeddedTemplateAst) {
  28393. return lastAstNode.hasViewContainer;
  28394. }
  28395. if (lastAstNode instanceof ElementAst) {
  28396. if (isNgContainer(lastAstNode.name) && lastAstNode.children.length) {
  28397. return needsAdditionalRootNode(lastAstNode.children);
  28398. }
  28399. return lastAstNode.hasViewContainer;
  28400. }
  28401. return lastAstNode instanceof NgContentAst;
  28402. }
  28403. /**
  28404. * @param {?} inputAst
  28405. * @param {?} dirAst
  28406. * @return {?}
  28407. */
  28408. function elementBindingDef(inputAst, dirAst) {
  28409. switch (inputAst.type) {
  28410. case PropertyBindingType.Attribute:
  28411. return literalArr([
  28412. literal(1 /* TypeElementAttribute */), literal(inputAst.name),
  28413. literal(inputAst.securityContext)
  28414. ]);
  28415. case PropertyBindingType.Property:
  28416. return literalArr([
  28417. literal(8 /* TypeProperty */), literal(inputAst.name),
  28418. literal(inputAst.securityContext)
  28419. ]);
  28420. case PropertyBindingType.Animation:
  28421. var /** @type {?} */ bindingType = 8 /* TypeProperty */ |
  28422. (dirAst && dirAst.directive.isComponent ? 32 /* SyntheticHostProperty */ :
  28423. 16 /* SyntheticProperty */);
  28424. return literalArr([
  28425. literal(bindingType), literal('@' + inputAst.name), literal(inputAst.securityContext)
  28426. ]);
  28427. case PropertyBindingType.Class:
  28428. return literalArr([literal(2 /* TypeElementClass */), literal(inputAst.name), NULL_EXPR]);
  28429. case PropertyBindingType.Style:
  28430. return literalArr([
  28431. literal(4 /* TypeElementStyle */), literal(inputAst.name), literal(inputAst.unit)
  28432. ]);
  28433. }
  28434. }
  28435. /**
  28436. * @param {?} elementAst
  28437. * @return {?}
  28438. */
  28439. function fixedAttrsDef(elementAst) {
  28440. var /** @type {?} */ mapResult = Object.create(null);
  28441. elementAst.attrs.forEach(function (attrAst) { mapResult[attrAst.name] = attrAst.value; });
  28442. elementAst.directives.forEach(function (dirAst) {
  28443. Object.keys(dirAst.directive.hostAttributes).forEach(function (name) {
  28444. var /** @type {?} */ value = dirAst.directive.hostAttributes[name];
  28445. var /** @type {?} */ prevValue = mapResult[name];
  28446. mapResult[name] = prevValue != null ? mergeAttributeValue(name, prevValue, value) : value;
  28447. });
  28448. });
  28449. // Note: We need to sort to get a defined output order
  28450. // for tests and for caching generated artifacts...
  28451. return literalArr(Object.keys(mapResult).sort().map(function (attrName) { return literalArr([literal(attrName), literal(mapResult[attrName])]); }));
  28452. }
  28453. /**
  28454. * @param {?} attrName
  28455. * @param {?} attrValue1
  28456. * @param {?} attrValue2
  28457. * @return {?}
  28458. */
  28459. function mergeAttributeValue(attrName, attrValue1, attrValue2) {
  28460. if (attrName == CLASS_ATTR$1 || attrName == STYLE_ATTR) {
  28461. return attrValue1 + " " + attrValue2;
  28462. }
  28463. else {
  28464. return attrValue2;
  28465. }
  28466. }
  28467. /**
  28468. * @param {?} nodeIndex
  28469. * @param {?} exprs
  28470. * @return {?}
  28471. */
  28472. function callCheckStmt(nodeIndex, exprs) {
  28473. if (exprs.length > 10) {
  28474. return CHECK_VAR.callFn([VIEW_VAR, literal(nodeIndex), literal(1 /* Dynamic */), literalArr(exprs)]);
  28475. }
  28476. else {
  28477. return CHECK_VAR.callFn([VIEW_VAR, literal(nodeIndex), literal(0 /* Inline */)].concat(exprs));
  28478. }
  28479. }
  28480. /**
  28481. * @param {?} nodeIndex
  28482. * @param {?} bindingIdx
  28483. * @param {?} expr
  28484. * @return {?}
  28485. */
  28486. function callUnwrapValue(nodeIndex, bindingIdx, expr) {
  28487. return importExpr(Identifiers.unwrapValue).callFn([
  28488. VIEW_VAR, literal(nodeIndex), literal(bindingIdx), expr
  28489. ]);
  28490. }
  28491. /**
  28492. * @param {?} nodes
  28493. * @param {?=} result
  28494. * @return {?}
  28495. */
  28496. function findStaticQueryIds(nodes, result) {
  28497. if (result === void 0) { result = new Map(); }
  28498. nodes.forEach(function (node) {
  28499. var /** @type {?} */ staticQueryIds = new Set();
  28500. var /** @type {?} */ dynamicQueryIds = new Set();
  28501. var /** @type {?} */ queryMatches = /** @type {?} */ ((undefined));
  28502. if (node instanceof ElementAst) {
  28503. findStaticQueryIds(node.children, result);
  28504. node.children.forEach(function (child) {
  28505. var /** @type {?} */ childData = /** @type {?} */ ((result.get(child)));
  28506. childData.staticQueryIds.forEach(function (queryId) { return staticQueryIds.add(queryId); });
  28507. childData.dynamicQueryIds.forEach(function (queryId) { return dynamicQueryIds.add(queryId); });
  28508. });
  28509. queryMatches = node.queryMatches;
  28510. }
  28511. else if (node instanceof EmbeddedTemplateAst) {
  28512. findStaticQueryIds(node.children, result);
  28513. node.children.forEach(function (child) {
  28514. var /** @type {?} */ childData = /** @type {?} */ ((result.get(child)));
  28515. childData.staticQueryIds.forEach(function (queryId) { return dynamicQueryIds.add(queryId); });
  28516. childData.dynamicQueryIds.forEach(function (queryId) { return dynamicQueryIds.add(queryId); });
  28517. });
  28518. queryMatches = node.queryMatches;
  28519. }
  28520. if (queryMatches) {
  28521. queryMatches.forEach(function (match) { return staticQueryIds.add(match.queryId); });
  28522. }
  28523. dynamicQueryIds.forEach(function (queryId) { return staticQueryIds.delete(queryId); });
  28524. result.set(node, { staticQueryIds: staticQueryIds, dynamicQueryIds: dynamicQueryIds });
  28525. });
  28526. return result;
  28527. }
  28528. /**
  28529. * @param {?} nodeStaticQueryIds
  28530. * @return {?}
  28531. */
  28532. function staticViewQueryIds(nodeStaticQueryIds) {
  28533. var /** @type {?} */ staticQueryIds = new Set();
  28534. var /** @type {?} */ dynamicQueryIds = new Set();
  28535. Array.from(nodeStaticQueryIds.values()).forEach(function (entry) {
  28536. entry.staticQueryIds.forEach(function (queryId) { return staticQueryIds.add(queryId); });
  28537. entry.dynamicQueryIds.forEach(function (queryId) { return dynamicQueryIds.add(queryId); });
  28538. });
  28539. dynamicQueryIds.forEach(function (queryId) { return staticQueryIds.delete(queryId); });
  28540. return { staticQueryIds: staticQueryIds, dynamicQueryIds: dynamicQueryIds };
  28541. }
  28542. /**
  28543. * @param {?} eventAst
  28544. * @param {?} dirAst
  28545. * @return {?}
  28546. */
  28547. function elementEventNameAndTarget(eventAst, dirAst) {
  28548. if (eventAst.isAnimation) {
  28549. return {
  28550. name: "@" + eventAst.name + "." + eventAst.phase,
  28551. target: dirAst && dirAst.directive.isComponent ? 'component' : null
  28552. };
  28553. }
  28554. else {
  28555. return eventAst;
  28556. }
  28557. }
  28558. /**
  28559. * @param {?} queryIds
  28560. * @param {?} queryId
  28561. * @param {?} isFirst
  28562. * @return {?}
  28563. */
  28564. function calcStaticDynamicQueryFlags(queryIds, queryId, isFirst) {
  28565. var /** @type {?} */ flags = 0;
  28566. // Note: We only make queries static that query for a single item.
  28567. // This is because of backwards compatibility with the old view compiler...
  28568. if (isFirst && (queryIds.staticQueryIds.has(queryId) || !queryIds.dynamicQueryIds.has(queryId))) {
  28569. flags |= 268435456 /* StaticQuery */;
  28570. }
  28571. else {
  28572. flags |= 536870912 /* DynamicQuery */;
  28573. }
  28574. return flags;
  28575. }
  28576. /**
  28577. * @param {?} target
  28578. * @param {?} name
  28579. * @return {?}
  28580. */
  28581. function elementEventFullName(target, name) {
  28582. return target ? target + ":" + name : name;
  28583. }
  28584. /**
  28585. * @fileoverview added by tsickle
  28586. * @suppress {checkTypes} checked by tsc
  28587. */
  28588. /**
  28589. * @license
  28590. * Copyright Google Inc. All Rights Reserved.
  28591. *
  28592. * Use of this source code is governed by an MIT-style license that can be
  28593. * found in the LICENSE file at https://angular.io/license
  28594. */
  28595. /**
  28596. * A container for message extracted from the templates.
  28597. */
  28598. var MessageBundle = /** @class */ (function () {
  28599. function MessageBundle(_htmlParser, _implicitTags, _implicitAttrs, _locale) {
  28600. if (_locale === void 0) { _locale = null; }
  28601. this._htmlParser = _htmlParser;
  28602. this._implicitTags = _implicitTags;
  28603. this._implicitAttrs = _implicitAttrs;
  28604. this._locale = _locale;
  28605. this._messages = [];
  28606. }
  28607. /**
  28608. * @param {?} html
  28609. * @param {?} url
  28610. * @param {?} interpolationConfig
  28611. * @return {?}
  28612. */
  28613. MessageBundle.prototype.updateFromTemplate = /**
  28614. * @param {?} html
  28615. * @param {?} url
  28616. * @param {?} interpolationConfig
  28617. * @return {?}
  28618. */
  28619. function (html, url, interpolationConfig) {
  28620. var /** @type {?} */ htmlParserResult = this._htmlParser.parse(html, url, true, interpolationConfig);
  28621. if (htmlParserResult.errors.length) {
  28622. return htmlParserResult.errors;
  28623. }
  28624. var /** @type {?} */ i18nParserResult = extractMessages(htmlParserResult.rootNodes, interpolationConfig, this._implicitTags, this._implicitAttrs);
  28625. if (i18nParserResult.errors.length) {
  28626. return i18nParserResult.errors;
  28627. }
  28628. (_a = this._messages).push.apply(_a, i18nParserResult.messages);
  28629. return [];
  28630. var _a;
  28631. };
  28632. // Return the message in the internal format
  28633. // The public (serialized) format might be different, see the `write` method.
  28634. /**
  28635. * @return {?}
  28636. */
  28637. MessageBundle.prototype.getMessages = /**
  28638. * @return {?}
  28639. */
  28640. function () { return this._messages; };
  28641. /**
  28642. * @param {?} serializer
  28643. * @param {?=} filterSources
  28644. * @return {?}
  28645. */
  28646. MessageBundle.prototype.write = /**
  28647. * @param {?} serializer
  28648. * @param {?=} filterSources
  28649. * @return {?}
  28650. */
  28651. function (serializer, filterSources) {
  28652. var /** @type {?} */ messages = {};
  28653. var /** @type {?} */ mapperVisitor = new MapPlaceholderNames();
  28654. // Deduplicate messages based on their ID
  28655. this._messages.forEach(function (message) {
  28656. var /** @type {?} */ id = serializer.digest(message);
  28657. if (!messages.hasOwnProperty(id)) {
  28658. messages[id] = message;
  28659. }
  28660. else {
  28661. (_a = messages[id].sources).push.apply(_a, message.sources);
  28662. }
  28663. var _a;
  28664. });
  28665. // Transform placeholder names using the serializer mapping
  28666. var /** @type {?} */ msgList = Object.keys(messages).map(function (id) {
  28667. var /** @type {?} */ mapper = serializer.createNameMapper(messages[id]);
  28668. var /** @type {?} */ src = messages[id];
  28669. var /** @type {?} */ nodes = mapper ? mapperVisitor.convert(src.nodes, mapper) : src.nodes;
  28670. var /** @type {?} */ transformedMessage = new Message(nodes, {}, {}, src.meaning, src.description, id);
  28671. transformedMessage.sources = src.sources;
  28672. if (filterSources) {
  28673. transformedMessage.sources.forEach(function (source) { return source.filePath = filterSources(source.filePath); });
  28674. }
  28675. return transformedMessage;
  28676. });
  28677. return serializer.write(msgList, this._locale);
  28678. };
  28679. return MessageBundle;
  28680. }());
  28681. var MapPlaceholderNames = /** @class */ (function (_super) {
  28682. __extends(MapPlaceholderNames, _super);
  28683. function MapPlaceholderNames() {
  28684. return _super !== null && _super.apply(this, arguments) || this;
  28685. }
  28686. /**
  28687. * @param {?} nodes
  28688. * @param {?} mapper
  28689. * @return {?}
  28690. */
  28691. MapPlaceholderNames.prototype.convert = /**
  28692. * @param {?} nodes
  28693. * @param {?} mapper
  28694. * @return {?}
  28695. */
  28696. function (nodes, mapper) {
  28697. var _this = this;
  28698. return mapper ? nodes.map(function (n) { return n.visit(_this, mapper); }) : nodes;
  28699. };
  28700. /**
  28701. * @param {?} ph
  28702. * @param {?} mapper
  28703. * @return {?}
  28704. */
  28705. MapPlaceholderNames.prototype.visitTagPlaceholder = /**
  28706. * @param {?} ph
  28707. * @param {?} mapper
  28708. * @return {?}
  28709. */
  28710. function (ph, mapper) {
  28711. var _this = this;
  28712. var /** @type {?} */ startName = /** @type {?} */ ((mapper.toPublicName(ph.startName)));
  28713. var /** @type {?} */ closeName = ph.closeName ? /** @type {?} */ ((mapper.toPublicName(ph.closeName))) : ph.closeName;
  28714. var /** @type {?} */ children = ph.children.map(function (n) { return n.visit(_this, mapper); });
  28715. return new TagPlaceholder(ph.tag, ph.attrs, startName, closeName, children, ph.isVoid, ph.sourceSpan);
  28716. };
  28717. /**
  28718. * @param {?} ph
  28719. * @param {?} mapper
  28720. * @return {?}
  28721. */
  28722. MapPlaceholderNames.prototype.visitPlaceholder = /**
  28723. * @param {?} ph
  28724. * @param {?} mapper
  28725. * @return {?}
  28726. */
  28727. function (ph, mapper) {
  28728. return new Placeholder(ph.value, /** @type {?} */ ((mapper.toPublicName(ph.name))), ph.sourceSpan);
  28729. };
  28730. /**
  28731. * @param {?} ph
  28732. * @param {?} mapper
  28733. * @return {?}
  28734. */
  28735. MapPlaceholderNames.prototype.visitIcuPlaceholder = /**
  28736. * @param {?} ph
  28737. * @param {?} mapper
  28738. * @return {?}
  28739. */
  28740. function (ph, mapper) {
  28741. return new IcuPlaceholder(ph.value, /** @type {?} */ ((mapper.toPublicName(ph.name))), ph.sourceSpan);
  28742. };
  28743. return MapPlaceholderNames;
  28744. }(CloneVisitor));
  28745. /**
  28746. * @fileoverview added by tsickle
  28747. * @suppress {checkTypes} checked by tsc
  28748. */
  28749. /**
  28750. * @license
  28751. * Copyright Google Inc. All Rights Reserved.
  28752. *
  28753. * Use of this source code is governed by an MIT-style license that can be
  28754. * found in the LICENSE file at https://angular.io/license
  28755. */
  28756. var GeneratedFile = /** @class */ (function () {
  28757. function GeneratedFile(srcFileUrl, genFileUrl, sourceOrStmts) {
  28758. this.srcFileUrl = srcFileUrl;
  28759. this.genFileUrl = genFileUrl;
  28760. if (typeof sourceOrStmts === 'string') {
  28761. this.source = sourceOrStmts;
  28762. this.stmts = null;
  28763. }
  28764. else {
  28765. this.source = null;
  28766. this.stmts = sourceOrStmts;
  28767. }
  28768. }
  28769. /**
  28770. * @param {?} other
  28771. * @return {?}
  28772. */
  28773. GeneratedFile.prototype.isEquivalent = /**
  28774. * @param {?} other
  28775. * @return {?}
  28776. */
  28777. function (other) {
  28778. if (this.genFileUrl !== other.genFileUrl) {
  28779. return false;
  28780. }
  28781. if (this.source) {
  28782. return this.source === other.source;
  28783. }
  28784. if (other.stmts == null) {
  28785. return false;
  28786. }
  28787. // Note: the constructor guarantees that if this.source is not filled,
  28788. // then this.stmts is.
  28789. return areAllEquivalent(/** @type {?} */ ((this.stmts)), /** @type {?} */ ((other.stmts)));
  28790. };
  28791. return GeneratedFile;
  28792. }());
  28793. /**
  28794. * @param {?} file
  28795. * @param {?=} preamble
  28796. * @return {?}
  28797. */
  28798. function toTypeScript(file, preamble) {
  28799. if (preamble === void 0) { preamble = ''; }
  28800. if (!file.stmts) {
  28801. throw new Error("Illegal state: No stmts present on GeneratedFile " + file.genFileUrl);
  28802. }
  28803. return new TypeScriptEmitter().emitStatements(file.genFileUrl, file.stmts, preamble);
  28804. }
  28805. /**
  28806. * @fileoverview added by tsickle
  28807. * @suppress {checkTypes} checked by tsc
  28808. */
  28809. /**
  28810. * @license
  28811. * Copyright Google Inc. All Rights Reserved.
  28812. *
  28813. * Use of this source code is governed by an MIT-style license that can be
  28814. * found in the LICENSE file at https://angular.io/license
  28815. */
  28816. /**
  28817. * @record
  28818. */
  28819. /**
  28820. * @param {?} moduleMeta
  28821. * @param {?} reflector
  28822. * @return {?}
  28823. */
  28824. function listLazyRoutes(moduleMeta, reflector) {
  28825. var /** @type {?} */ allLazyRoutes = [];
  28826. for (var _i = 0, _a = moduleMeta.transitiveModule.providers; _i < _a.length; _i++) {
  28827. var _b = _a[_i], provider = _b.provider, module = _b.module;
  28828. if (tokenReference(provider.token) === reflector.ROUTES) {
  28829. var /** @type {?} */ loadChildren = _collectLoadChildren(provider.useValue);
  28830. for (var _c = 0, loadChildren_1 = loadChildren; _c < loadChildren_1.length; _c++) {
  28831. var route = loadChildren_1[_c];
  28832. allLazyRoutes.push(parseLazyRoute(route, reflector, module.reference));
  28833. }
  28834. }
  28835. }
  28836. return allLazyRoutes;
  28837. }
  28838. /**
  28839. * @param {?} routes
  28840. * @param {?=} target
  28841. * @return {?}
  28842. */
  28843. function _collectLoadChildren(routes, target) {
  28844. if (target === void 0) { target = []; }
  28845. if (typeof routes === 'string') {
  28846. target.push(routes);
  28847. }
  28848. else if (Array.isArray(routes)) {
  28849. for (var _i = 0, routes_1 = routes; _i < routes_1.length; _i++) {
  28850. var route = routes_1[_i];
  28851. _collectLoadChildren(route, target);
  28852. }
  28853. }
  28854. else if (routes.loadChildren) {
  28855. _collectLoadChildren(routes.loadChildren, target);
  28856. }
  28857. else if (routes.children) {
  28858. _collectLoadChildren(routes.children, target);
  28859. }
  28860. return target;
  28861. }
  28862. /**
  28863. * @param {?} route
  28864. * @param {?} reflector
  28865. * @param {?=} module
  28866. * @return {?}
  28867. */
  28868. function parseLazyRoute(route, reflector, module) {
  28869. var _a = route.split('#'), routePath = _a[0], routeName = _a[1];
  28870. var /** @type {?} */ referencedModule = reflector.resolveExternalReference({
  28871. moduleName: routePath,
  28872. name: routeName,
  28873. }, module ? module.filePath : undefined);
  28874. return { route: route, module: module || referencedModule, referencedModule: referencedModule };
  28875. }
  28876. /**
  28877. * @fileoverview added by tsickle
  28878. * @suppress {checkTypes} checked by tsc
  28879. */
  28880. /**
  28881. * @license
  28882. * Copyright Google Inc. All Rights Reserved.
  28883. *
  28884. * Use of this source code is governed by an MIT-style license that can be
  28885. * found in the LICENSE file at https://angular.io/license
  28886. */
  28887. var ResolvedStaticSymbol = /** @class */ (function () {
  28888. function ResolvedStaticSymbol(symbol, metadata) {
  28889. this.symbol = symbol;
  28890. this.metadata = metadata;
  28891. }
  28892. return ResolvedStaticSymbol;
  28893. }());
  28894. /**
  28895. * The host of the SymbolResolverHost disconnects the implementation from TypeScript / other
  28896. * language
  28897. * services and from underlying file systems.
  28898. * @record
  28899. */
  28900. var SUPPORTED_SCHEMA_VERSION = 4;
  28901. /**
  28902. * This class is responsible for loading metadata per symbol,
  28903. * and normalizing references between symbols.
  28904. *
  28905. * Internally, it only uses symbols without members,
  28906. * and deduces the values for symbols with members based
  28907. * on these symbols.
  28908. */
  28909. var StaticSymbolResolver = /** @class */ (function () {
  28910. function StaticSymbolResolver(host, staticSymbolCache, summaryResolver, errorRecorder) {
  28911. this.host = host;
  28912. this.staticSymbolCache = staticSymbolCache;
  28913. this.summaryResolver = summaryResolver;
  28914. this.errorRecorder = errorRecorder;
  28915. this.metadataCache = new Map();
  28916. this.resolvedSymbols = new Map();
  28917. this.resolvedFilePaths = new Set();
  28918. this.importAs = new Map();
  28919. this.symbolResourcePaths = new Map();
  28920. this.symbolFromFile = new Map();
  28921. this.knownFileNameToModuleNames = new Map();
  28922. }
  28923. /**
  28924. * @param {?} staticSymbol
  28925. * @return {?}
  28926. */
  28927. StaticSymbolResolver.prototype.resolveSymbol = /**
  28928. * @param {?} staticSymbol
  28929. * @return {?}
  28930. */
  28931. function (staticSymbol) {
  28932. if (staticSymbol.members.length > 0) {
  28933. return /** @type {?} */ ((this._resolveSymbolMembers(staticSymbol)));
  28934. }
  28935. // Note: always ask for a summary first,
  28936. // as we might have read shallow metadata via a .d.ts file
  28937. // for the symbol.
  28938. var /** @type {?} */ resultFromSummary = /** @type {?} */ ((this._resolveSymbolFromSummary(staticSymbol)));
  28939. if (resultFromSummary) {
  28940. return resultFromSummary;
  28941. }
  28942. var /** @type {?} */ resultFromCache = this.resolvedSymbols.get(staticSymbol);
  28943. if (resultFromCache) {
  28944. return resultFromCache;
  28945. }
  28946. // Note: Some users use libraries that were not compiled with ngc, i.e. they don't
  28947. // have summaries, only .d.ts files. So we always need to check both, the summary
  28948. // and metadata.
  28949. this._createSymbolsOf(staticSymbol.filePath);
  28950. return /** @type {?} */ ((this.resolvedSymbols.get(staticSymbol)));
  28951. };
  28952. /**
  28953. * getImportAs produces a symbol that can be used to import the given symbol.
  28954. * The import might be different than the symbol if the symbol is exported from
  28955. * a library with a summary; in which case we want to import the symbol from the
  28956. * ngfactory re-export instead of directly to avoid introducing a direct dependency
  28957. * on an otherwise indirect dependency.
  28958. *
  28959. * @param staticSymbol the symbol for which to generate a import symbol
  28960. */
  28961. /**
  28962. * getImportAs produces a symbol that can be used to import the given symbol.
  28963. * The import might be different than the symbol if the symbol is exported from
  28964. * a library with a summary; in which case we want to import the symbol from the
  28965. * ngfactory re-export instead of directly to avoid introducing a direct dependency
  28966. * on an otherwise indirect dependency.
  28967. *
  28968. * @param {?} staticSymbol the symbol for which to generate a import symbol
  28969. * @param {?=} useSummaries
  28970. * @return {?}
  28971. */
  28972. StaticSymbolResolver.prototype.getImportAs = /**
  28973. * getImportAs produces a symbol that can be used to import the given symbol.
  28974. * The import might be different than the symbol if the symbol is exported from
  28975. * a library with a summary; in which case we want to import the symbol from the
  28976. * ngfactory re-export instead of directly to avoid introducing a direct dependency
  28977. * on an otherwise indirect dependency.
  28978. *
  28979. * @param {?} staticSymbol the symbol for which to generate a import symbol
  28980. * @param {?=} useSummaries
  28981. * @return {?}
  28982. */
  28983. function (staticSymbol, useSummaries) {
  28984. if (useSummaries === void 0) { useSummaries = true; }
  28985. if (staticSymbol.members.length) {
  28986. var /** @type {?} */ baseSymbol = this.getStaticSymbol(staticSymbol.filePath, staticSymbol.name);
  28987. var /** @type {?} */ baseImportAs = this.getImportAs(baseSymbol, useSummaries);
  28988. return baseImportAs ?
  28989. this.getStaticSymbol(baseImportAs.filePath, baseImportAs.name, staticSymbol.members) :
  28990. null;
  28991. }
  28992. var /** @type {?} */ summarizedFileName = stripSummaryForJitFileSuffix(staticSymbol.filePath);
  28993. if (summarizedFileName !== staticSymbol.filePath) {
  28994. var /** @type {?} */ summarizedName = stripSummaryForJitNameSuffix(staticSymbol.name);
  28995. var /** @type {?} */ baseSymbol = this.getStaticSymbol(summarizedFileName, summarizedName, staticSymbol.members);
  28996. var /** @type {?} */ baseImportAs = this.getImportAs(baseSymbol, useSummaries);
  28997. return baseImportAs ?
  28998. this.getStaticSymbol(summaryForJitFileName(baseImportAs.filePath), summaryForJitName(baseImportAs.name), baseSymbol.members) :
  28999. null;
  29000. }
  29001. var /** @type {?} */ result = (useSummaries && this.summaryResolver.getImportAs(staticSymbol)) || null;
  29002. if (!result) {
  29003. result = /** @type {?} */ ((this.importAs.get(staticSymbol)));
  29004. }
  29005. return result;
  29006. };
  29007. /**
  29008. * getResourcePath produces the path to the original location of the symbol and should
  29009. * be used to determine the relative location of resource references recorded in
  29010. * symbol metadata.
  29011. */
  29012. /**
  29013. * getResourcePath produces the path to the original location of the symbol and should
  29014. * be used to determine the relative location of resource references recorded in
  29015. * symbol metadata.
  29016. * @param {?} staticSymbol
  29017. * @return {?}
  29018. */
  29019. StaticSymbolResolver.prototype.getResourcePath = /**
  29020. * getResourcePath produces the path to the original location of the symbol and should
  29021. * be used to determine the relative location of resource references recorded in
  29022. * symbol metadata.
  29023. * @param {?} staticSymbol
  29024. * @return {?}
  29025. */
  29026. function (staticSymbol) {
  29027. return this.symbolResourcePaths.get(staticSymbol) || staticSymbol.filePath;
  29028. };
  29029. /**
  29030. * getTypeArity returns the number of generic type parameters the given symbol
  29031. * has. If the symbol is not a type the result is null.
  29032. */
  29033. /**
  29034. * getTypeArity returns the number of generic type parameters the given symbol
  29035. * has. If the symbol is not a type the result is null.
  29036. * @param {?} staticSymbol
  29037. * @return {?}
  29038. */
  29039. StaticSymbolResolver.prototype.getTypeArity = /**
  29040. * getTypeArity returns the number of generic type parameters the given symbol
  29041. * has. If the symbol is not a type the result is null.
  29042. * @param {?} staticSymbol
  29043. * @return {?}
  29044. */
  29045. function (staticSymbol) {
  29046. // If the file is a factory/ngsummary file, don't resolve the symbol as doing so would
  29047. // cause the metadata for an factory/ngsummary file to be loaded which doesn't exist.
  29048. // All references to generated classes must include the correct arity whenever
  29049. // generating code.
  29050. if (isGeneratedFile(staticSymbol.filePath)) {
  29051. return null;
  29052. }
  29053. var /** @type {?} */ resolvedSymbol = unwrapResolvedMetadata(this.resolveSymbol(staticSymbol));
  29054. while (resolvedSymbol && resolvedSymbol.metadata instanceof StaticSymbol) {
  29055. resolvedSymbol = unwrapResolvedMetadata(this.resolveSymbol(resolvedSymbol.metadata));
  29056. }
  29057. return (resolvedSymbol && resolvedSymbol.metadata && resolvedSymbol.metadata.arity) || null;
  29058. };
  29059. /**
  29060. * @param {?} filePath
  29061. * @return {?}
  29062. */
  29063. StaticSymbolResolver.prototype.getKnownModuleName = /**
  29064. * @param {?} filePath
  29065. * @return {?}
  29066. */
  29067. function (filePath) {
  29068. return this.knownFileNameToModuleNames.get(filePath) || null;
  29069. };
  29070. /**
  29071. * @param {?} sourceSymbol
  29072. * @param {?} targetSymbol
  29073. * @return {?}
  29074. */
  29075. StaticSymbolResolver.prototype.recordImportAs = /**
  29076. * @param {?} sourceSymbol
  29077. * @param {?} targetSymbol
  29078. * @return {?}
  29079. */
  29080. function (sourceSymbol, targetSymbol) {
  29081. sourceSymbol.assertNoMembers();
  29082. targetSymbol.assertNoMembers();
  29083. this.importAs.set(sourceSymbol, targetSymbol);
  29084. };
  29085. /**
  29086. * @param {?} fileName
  29087. * @param {?} moduleName
  29088. * @return {?}
  29089. */
  29090. StaticSymbolResolver.prototype.recordModuleNameForFileName = /**
  29091. * @param {?} fileName
  29092. * @param {?} moduleName
  29093. * @return {?}
  29094. */
  29095. function (fileName, moduleName) {
  29096. this.knownFileNameToModuleNames.set(fileName, moduleName);
  29097. };
  29098. /**
  29099. * Invalidate all information derived from the given file.
  29100. *
  29101. * @param fileName the file to invalidate
  29102. */
  29103. /**
  29104. * Invalidate all information derived from the given file.
  29105. *
  29106. * @param {?} fileName the file to invalidate
  29107. * @return {?}
  29108. */
  29109. StaticSymbolResolver.prototype.invalidateFile = /**
  29110. * Invalidate all information derived from the given file.
  29111. *
  29112. * @param {?} fileName the file to invalidate
  29113. * @return {?}
  29114. */
  29115. function (fileName) {
  29116. this.metadataCache.delete(fileName);
  29117. this.resolvedFilePaths.delete(fileName);
  29118. var /** @type {?} */ symbols = this.symbolFromFile.get(fileName);
  29119. if (symbols) {
  29120. this.symbolFromFile.delete(fileName);
  29121. for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
  29122. var symbol = symbols_1[_i];
  29123. this.resolvedSymbols.delete(symbol);
  29124. this.importAs.delete(symbol);
  29125. this.symbolResourcePaths.delete(symbol);
  29126. }
  29127. }
  29128. };
  29129. /* @internal */
  29130. /**
  29131. * @template T
  29132. * @param {?} cb
  29133. * @return {?}
  29134. */
  29135. StaticSymbolResolver.prototype.ignoreErrorsFor = /**
  29136. * @template T
  29137. * @param {?} cb
  29138. * @return {?}
  29139. */
  29140. function (cb) {
  29141. var /** @type {?} */ recorder = this.errorRecorder;
  29142. this.errorRecorder = function () { };
  29143. try {
  29144. return cb();
  29145. }
  29146. finally {
  29147. this.errorRecorder = recorder;
  29148. }
  29149. };
  29150. /**
  29151. * @param {?} staticSymbol
  29152. * @return {?}
  29153. */
  29154. StaticSymbolResolver.prototype._resolveSymbolMembers = /**
  29155. * @param {?} staticSymbol
  29156. * @return {?}
  29157. */
  29158. function (staticSymbol) {
  29159. var /** @type {?} */ members = staticSymbol.members;
  29160. var /** @type {?} */ baseResolvedSymbol = this.resolveSymbol(this.getStaticSymbol(staticSymbol.filePath, staticSymbol.name));
  29161. if (!baseResolvedSymbol) {
  29162. return null;
  29163. }
  29164. var /** @type {?} */ baseMetadata = unwrapResolvedMetadata(baseResolvedSymbol.metadata);
  29165. if (baseMetadata instanceof StaticSymbol) {
  29166. return new ResolvedStaticSymbol(staticSymbol, this.getStaticSymbol(baseMetadata.filePath, baseMetadata.name, members));
  29167. }
  29168. else if (baseMetadata && baseMetadata.__symbolic === 'class') {
  29169. if (baseMetadata.statics && members.length === 1) {
  29170. return new ResolvedStaticSymbol(staticSymbol, baseMetadata.statics[members[0]]);
  29171. }
  29172. }
  29173. else {
  29174. var /** @type {?} */ value = baseMetadata;
  29175. for (var /** @type {?} */ i = 0; i < members.length && value; i++) {
  29176. value = value[members[i]];
  29177. }
  29178. return new ResolvedStaticSymbol(staticSymbol, value);
  29179. }
  29180. return null;
  29181. };
  29182. /**
  29183. * @param {?} staticSymbol
  29184. * @return {?}
  29185. */
  29186. StaticSymbolResolver.prototype._resolveSymbolFromSummary = /**
  29187. * @param {?} staticSymbol
  29188. * @return {?}
  29189. */
  29190. function (staticSymbol) {
  29191. var /** @type {?} */ summary = this.summaryResolver.resolveSummary(staticSymbol);
  29192. return summary ? new ResolvedStaticSymbol(staticSymbol, summary.metadata) : null;
  29193. };
  29194. /**
  29195. * getStaticSymbol produces a Type whose metadata is known but whose implementation is not loaded.
  29196. * All types passed to the StaticResolver should be pseudo-types returned by this method.
  29197. *
  29198. * @param declarationFile the absolute path of the file where the symbol is declared
  29199. * @param name the name of the type.
  29200. * @param members a symbol for a static member of the named type
  29201. */
  29202. /**
  29203. * getStaticSymbol produces a Type whose metadata is known but whose implementation is not loaded.
  29204. * All types passed to the StaticResolver should be pseudo-types returned by this method.
  29205. *
  29206. * @param {?} declarationFile the absolute path of the file where the symbol is declared
  29207. * @param {?} name the name of the type.
  29208. * @param {?=} members a symbol for a static member of the named type
  29209. * @return {?}
  29210. */
  29211. StaticSymbolResolver.prototype.getStaticSymbol = /**
  29212. * getStaticSymbol produces a Type whose metadata is known but whose implementation is not loaded.
  29213. * All types passed to the StaticResolver should be pseudo-types returned by this method.
  29214. *
  29215. * @param {?} declarationFile the absolute path of the file where the symbol is declared
  29216. * @param {?} name the name of the type.
  29217. * @param {?=} members a symbol for a static member of the named type
  29218. * @return {?}
  29219. */
  29220. function (declarationFile, name, members) {
  29221. return this.staticSymbolCache.get(declarationFile, name, members);
  29222. };
  29223. /**
  29224. * hasDecorators checks a file's metadata for the presense of decorators without evalutating the
  29225. * metadata.
  29226. *
  29227. * @param filePath the absolute path to examine for decorators.
  29228. * @returns true if any class in the file has a decorator.
  29229. */
  29230. /**
  29231. * hasDecorators checks a file's metadata for the presense of decorators without evalutating the
  29232. * metadata.
  29233. *
  29234. * @param {?} filePath the absolute path to examine for decorators.
  29235. * @return {?} true if any class in the file has a decorator.
  29236. */
  29237. StaticSymbolResolver.prototype.hasDecorators = /**
  29238. * hasDecorators checks a file's metadata for the presense of decorators without evalutating the
  29239. * metadata.
  29240. *
  29241. * @param {?} filePath the absolute path to examine for decorators.
  29242. * @return {?} true if any class in the file has a decorator.
  29243. */
  29244. function (filePath) {
  29245. var /** @type {?} */ metadata = this.getModuleMetadata(filePath);
  29246. if (metadata['metadata']) {
  29247. return Object.keys(metadata['metadata']).some(function (metadataKey) {
  29248. var /** @type {?} */ entry = metadata['metadata'][metadataKey];
  29249. return entry && entry.__symbolic === 'class' && entry.decorators;
  29250. });
  29251. }
  29252. return false;
  29253. };
  29254. /**
  29255. * @param {?} filePath
  29256. * @return {?}
  29257. */
  29258. StaticSymbolResolver.prototype.getSymbolsOf = /**
  29259. * @param {?} filePath
  29260. * @return {?}
  29261. */
  29262. function (filePath) {
  29263. var /** @type {?} */ summarySymbols = this.summaryResolver.getSymbolsOf(filePath);
  29264. if (summarySymbols) {
  29265. return summarySymbols;
  29266. }
  29267. // Note: Some users use libraries that were not compiled with ngc, i.e. they don't
  29268. // have summaries, only .d.ts files, but `summaryResolver.isLibraryFile` returns true.
  29269. this._createSymbolsOf(filePath);
  29270. var /** @type {?} */ metadataSymbols = [];
  29271. this.resolvedSymbols.forEach(function (resolvedSymbol) {
  29272. if (resolvedSymbol.symbol.filePath === filePath) {
  29273. metadataSymbols.push(resolvedSymbol.symbol);
  29274. }
  29275. });
  29276. return metadataSymbols;
  29277. };
  29278. /**
  29279. * @param {?} filePath
  29280. * @return {?}
  29281. */
  29282. StaticSymbolResolver.prototype._createSymbolsOf = /**
  29283. * @param {?} filePath
  29284. * @return {?}
  29285. */
  29286. function (filePath) {
  29287. var _this = this;
  29288. if (this.resolvedFilePaths.has(filePath)) {
  29289. return;
  29290. }
  29291. this.resolvedFilePaths.add(filePath);
  29292. var /** @type {?} */ resolvedSymbols = [];
  29293. var /** @type {?} */ metadata = this.getModuleMetadata(filePath);
  29294. if (metadata['importAs']) {
  29295. // Index bundle indices should use the importAs module name defined
  29296. // in the bundle.
  29297. this.knownFileNameToModuleNames.set(filePath, metadata['importAs']);
  29298. }
  29299. // handle the symbols in one of the re-export location
  29300. if (metadata['exports']) {
  29301. var _loop_1 = function (moduleExport) {
  29302. // handle the symbols in the list of explicitly re-exported symbols.
  29303. if (moduleExport.export) {
  29304. moduleExport.export.forEach(function (exportSymbol) {
  29305. var /** @type {?} */ symbolName;
  29306. if (typeof exportSymbol === 'string') {
  29307. symbolName = exportSymbol;
  29308. }
  29309. else {
  29310. symbolName = exportSymbol.as;
  29311. }
  29312. symbolName = unescapeIdentifier(symbolName);
  29313. var /** @type {?} */ symName = symbolName;
  29314. if (typeof exportSymbol !== 'string') {
  29315. symName = unescapeIdentifier(exportSymbol.name);
  29316. }
  29317. var /** @type {?} */ resolvedModule = _this.resolveModule(moduleExport.from, filePath);
  29318. if (resolvedModule) {
  29319. var /** @type {?} */ targetSymbol = _this.getStaticSymbol(resolvedModule, symName);
  29320. var /** @type {?} */ sourceSymbol = _this.getStaticSymbol(filePath, symbolName);
  29321. resolvedSymbols.push(_this.createExport(sourceSymbol, targetSymbol));
  29322. }
  29323. });
  29324. }
  29325. else {
  29326. // handle the symbols via export * directives.
  29327. var /** @type {?} */ resolvedModule = this_1.resolveModule(moduleExport.from, filePath);
  29328. if (resolvedModule) {
  29329. var /** @type {?} */ nestedExports = this_1.getSymbolsOf(resolvedModule);
  29330. nestedExports.forEach(function (targetSymbol) {
  29331. var /** @type {?} */ sourceSymbol = _this.getStaticSymbol(filePath, targetSymbol.name);
  29332. resolvedSymbols.push(_this.createExport(sourceSymbol, targetSymbol));
  29333. });
  29334. }
  29335. }
  29336. };
  29337. var this_1 = this;
  29338. for (var _i = 0, _a = metadata['exports']; _i < _a.length; _i++) {
  29339. var moduleExport = _a[_i];
  29340. _loop_1(moduleExport);
  29341. }
  29342. }
  29343. // handle the actual metadata. Has to be after the exports
  29344. // as there migth be collisions in the names, and we want the symbols
  29345. // of the current module to win ofter reexports.
  29346. if (metadata['metadata']) {
  29347. // handle direct declarations of the symbol
  29348. var /** @type {?} */ topLevelSymbolNames_1 = new Set(Object.keys(metadata['metadata']).map(unescapeIdentifier));
  29349. var /** @type {?} */ origins_1 = metadata['origins'] || {};
  29350. Object.keys(metadata['metadata']).forEach(function (metadataKey) {
  29351. var /** @type {?} */ symbolMeta = metadata['metadata'][metadataKey];
  29352. var /** @type {?} */ name = unescapeIdentifier(metadataKey);
  29353. var /** @type {?} */ symbol = _this.getStaticSymbol(filePath, name);
  29354. var /** @type {?} */ origin = origins_1.hasOwnProperty(metadataKey) && origins_1[metadataKey];
  29355. if (origin) {
  29356. // If the symbol is from a bundled index, use the declaration location of the
  29357. // symbol so relative references (such as './my.html') will be calculated
  29358. // correctly.
  29359. var /** @type {?} */ originFilePath = _this.resolveModule(origin, filePath);
  29360. if (!originFilePath) {
  29361. _this.reportError(new Error("Couldn't resolve original symbol for " + origin + " from " + filePath));
  29362. }
  29363. else {
  29364. _this.symbolResourcePaths.set(symbol, originFilePath);
  29365. }
  29366. }
  29367. resolvedSymbols.push(_this.createResolvedSymbol(symbol, filePath, topLevelSymbolNames_1, symbolMeta));
  29368. });
  29369. }
  29370. resolvedSymbols.forEach(function (resolvedSymbol) { return _this.resolvedSymbols.set(resolvedSymbol.symbol, resolvedSymbol); });
  29371. this.symbolFromFile.set(filePath, resolvedSymbols.map(function (resolvedSymbol) { return resolvedSymbol.symbol; }));
  29372. };
  29373. /**
  29374. * @param {?} sourceSymbol
  29375. * @param {?} topLevelPath
  29376. * @param {?} topLevelSymbolNames
  29377. * @param {?} metadata
  29378. * @return {?}
  29379. */
  29380. StaticSymbolResolver.prototype.createResolvedSymbol = /**
  29381. * @param {?} sourceSymbol
  29382. * @param {?} topLevelPath
  29383. * @param {?} topLevelSymbolNames
  29384. * @param {?} metadata
  29385. * @return {?}
  29386. */
  29387. function (sourceSymbol, topLevelPath, topLevelSymbolNames, metadata) {
  29388. var _this = this;
  29389. // For classes that don't have Angular summaries / metadata,
  29390. // we only keep their arity, but nothing else
  29391. // (e.g. their constructor parameters).
  29392. // We do this to prevent introducing deep imports
  29393. // as we didn't generate .ngfactory.ts files with proper reexports.
  29394. if (this.summaryResolver.isLibraryFile(sourceSymbol.filePath) && metadata &&
  29395. metadata['__symbolic'] === 'class') {
  29396. var /** @type {?} */ transformedMeta_1 = { __symbolic: 'class', arity: metadata.arity };
  29397. return new ResolvedStaticSymbol(sourceSymbol, transformedMeta_1);
  29398. }
  29399. var /** @type {?} */ _originalFileMemo;
  29400. var /** @type {?} */ getOriginalName = function () {
  29401. if (!_originalFileMemo) {
  29402. // Guess what hte original file name is from the reference. If it has a `.d.ts` extension
  29403. // replace it with `.ts`. If it already has `.ts` just leave it in place. If it doesn't have
  29404. // .ts or .d.ts, append `.ts'. Also, if it is in `node_modules`, trim the `node_module`
  29405. // location as it is not important to finding the file.
  29406. _originalFileMemo =
  29407. _this.host.getOutputName(topLevelPath.replace(/((\.ts)|(\.d\.ts)|)$/, '.ts')
  29408. .replace(/^.*node_modules[/\\]/, ''));
  29409. }
  29410. return _originalFileMemo;
  29411. };
  29412. var /** @type {?} */ self = this;
  29413. var ReferenceTransformer = /** @class */ (function (_super) {
  29414. __extends(ReferenceTransformer, _super);
  29415. function ReferenceTransformer() {
  29416. return _super !== null && _super.apply(this, arguments) || this;
  29417. }
  29418. /**
  29419. * @param {?} map
  29420. * @param {?} functionParams
  29421. * @return {?}
  29422. */
  29423. ReferenceTransformer.prototype.visitStringMap = /**
  29424. * @param {?} map
  29425. * @param {?} functionParams
  29426. * @return {?}
  29427. */
  29428. function (map, functionParams) {
  29429. var /** @type {?} */ symbolic = map['__symbolic'];
  29430. if (symbolic === 'function') {
  29431. var /** @type {?} */ oldLen = functionParams.length;
  29432. functionParams.push.apply(functionParams, (map['parameters'] || []));
  29433. var /** @type {?} */ result = _super.prototype.visitStringMap.call(this, map, functionParams);
  29434. functionParams.length = oldLen;
  29435. return result;
  29436. }
  29437. else if (symbolic === 'reference') {
  29438. var /** @type {?} */ module = map['module'];
  29439. var /** @type {?} */ name_1 = map['name'] ? unescapeIdentifier(map['name']) : map['name'];
  29440. if (!name_1) {
  29441. return null;
  29442. }
  29443. var /** @type {?} */ filePath = void 0;
  29444. if (module) {
  29445. filePath = /** @type {?} */ ((self.resolveModule(module, sourceSymbol.filePath)));
  29446. if (!filePath) {
  29447. return {
  29448. __symbolic: 'error',
  29449. message: "Could not resolve " + module + " relative to " + sourceSymbol.filePath + ".",
  29450. line: map["line"],
  29451. character: map["character"],
  29452. fileName: getOriginalName()
  29453. };
  29454. }
  29455. return {
  29456. __symbolic: 'resolved',
  29457. symbol: self.getStaticSymbol(filePath, name_1),
  29458. line: map["line"],
  29459. character: map["character"],
  29460. fileName: getOriginalName()
  29461. };
  29462. }
  29463. else if (functionParams.indexOf(name_1) >= 0) {
  29464. // reference to a function parameter
  29465. return { __symbolic: 'reference', name: name_1 };
  29466. }
  29467. else {
  29468. if (topLevelSymbolNames.has(name_1)) {
  29469. return self.getStaticSymbol(topLevelPath, name_1);
  29470. }
  29471. // ambient value
  29472. null;
  29473. }
  29474. }
  29475. else if (symbolic === 'error') {
  29476. return __assign({}, map, { fileName: getOriginalName() });
  29477. }
  29478. else {
  29479. return _super.prototype.visitStringMap.call(this, map, functionParams);
  29480. }
  29481. };
  29482. return ReferenceTransformer;
  29483. }(ValueTransformer));
  29484. var /** @type {?} */ transformedMeta = visitValue(metadata, new ReferenceTransformer(), []);
  29485. var /** @type {?} */ unwrappedTransformedMeta = unwrapResolvedMetadata(transformedMeta);
  29486. if (unwrappedTransformedMeta instanceof StaticSymbol) {
  29487. return this.createExport(sourceSymbol, unwrappedTransformedMeta);
  29488. }
  29489. return new ResolvedStaticSymbol(sourceSymbol, transformedMeta);
  29490. };
  29491. /**
  29492. * @param {?} sourceSymbol
  29493. * @param {?} targetSymbol
  29494. * @return {?}
  29495. */
  29496. StaticSymbolResolver.prototype.createExport = /**
  29497. * @param {?} sourceSymbol
  29498. * @param {?} targetSymbol
  29499. * @return {?}
  29500. */
  29501. function (sourceSymbol, targetSymbol) {
  29502. sourceSymbol.assertNoMembers();
  29503. targetSymbol.assertNoMembers();
  29504. if (this.summaryResolver.isLibraryFile(sourceSymbol.filePath) &&
  29505. this.summaryResolver.isLibraryFile(targetSymbol.filePath)) {
  29506. // This case is for an ng library importing symbols from a plain ts library
  29507. // transitively.
  29508. // Note: We rely on the fact that we discover symbols in the direction
  29509. // from source files to library files
  29510. this.importAs.set(targetSymbol, this.getImportAs(sourceSymbol) || sourceSymbol);
  29511. }
  29512. return new ResolvedStaticSymbol(sourceSymbol, targetSymbol);
  29513. };
  29514. /**
  29515. * @param {?} error
  29516. * @param {?=} context
  29517. * @param {?=} path
  29518. * @return {?}
  29519. */
  29520. StaticSymbolResolver.prototype.reportError = /**
  29521. * @param {?} error
  29522. * @param {?=} context
  29523. * @param {?=} path
  29524. * @return {?}
  29525. */
  29526. function (error, context, path) {
  29527. if (this.errorRecorder) {
  29528. this.errorRecorder(error, (context && context.filePath) || path);
  29529. }
  29530. else {
  29531. throw error;
  29532. }
  29533. };
  29534. /**
  29535. * @param {?} module an absolute path to a module file.
  29536. * @return {?}
  29537. */
  29538. StaticSymbolResolver.prototype.getModuleMetadata = /**
  29539. * @param {?} module an absolute path to a module file.
  29540. * @return {?}
  29541. */
  29542. function (module) {
  29543. var /** @type {?} */ moduleMetadata = this.metadataCache.get(module);
  29544. if (!moduleMetadata) {
  29545. var /** @type {?} */ moduleMetadatas = this.host.getMetadataFor(module);
  29546. if (moduleMetadatas) {
  29547. var /** @type {?} */ maxVersion_1 = -1;
  29548. moduleMetadatas.forEach(function (md) {
  29549. if (md && md['version'] > maxVersion_1) {
  29550. maxVersion_1 = md['version'];
  29551. moduleMetadata = md;
  29552. }
  29553. });
  29554. }
  29555. if (!moduleMetadata) {
  29556. moduleMetadata =
  29557. { __symbolic: 'module', version: SUPPORTED_SCHEMA_VERSION, module: module, metadata: {} };
  29558. }
  29559. if (moduleMetadata['version'] != SUPPORTED_SCHEMA_VERSION) {
  29560. var /** @type {?} */ errorMessage = moduleMetadata['version'] == 2 ?
  29561. "Unsupported metadata version " + moduleMetadata['version'] + " for module " + module + ". This module should be compiled with a newer version of ngc" :
  29562. "Metadata version mismatch for module " + module + ", found version " + moduleMetadata['version'] + ", expected " + SUPPORTED_SCHEMA_VERSION;
  29563. this.reportError(new Error(errorMessage));
  29564. }
  29565. this.metadataCache.set(module, moduleMetadata);
  29566. }
  29567. return moduleMetadata;
  29568. };
  29569. /**
  29570. * @param {?} module
  29571. * @param {?} symbolName
  29572. * @param {?=} containingFile
  29573. * @return {?}
  29574. */
  29575. StaticSymbolResolver.prototype.getSymbolByModule = /**
  29576. * @param {?} module
  29577. * @param {?} symbolName
  29578. * @param {?=} containingFile
  29579. * @return {?}
  29580. */
  29581. function (module, symbolName, containingFile) {
  29582. var /** @type {?} */ filePath = this.resolveModule(module, containingFile);
  29583. if (!filePath) {
  29584. this.reportError(new Error("Could not resolve module " + module + (containingFile ? ' relative to ' +
  29585. containingFile : '')));
  29586. return this.getStaticSymbol("ERROR:" + module, symbolName);
  29587. }
  29588. return this.getStaticSymbol(filePath, symbolName);
  29589. };
  29590. /**
  29591. * @param {?} module
  29592. * @param {?=} containingFile
  29593. * @return {?}
  29594. */
  29595. StaticSymbolResolver.prototype.resolveModule = /**
  29596. * @param {?} module
  29597. * @param {?=} containingFile
  29598. * @return {?}
  29599. */
  29600. function (module, containingFile) {
  29601. try {
  29602. return this.host.moduleNameToFileName(module, containingFile);
  29603. }
  29604. catch (/** @type {?} */ e) {
  29605. console.error("Could not resolve module '" + module + "' relative to file " + containingFile);
  29606. this.reportError(e, undefined, containingFile);
  29607. }
  29608. return null;
  29609. };
  29610. return StaticSymbolResolver;
  29611. }());
  29612. /**
  29613. * @param {?} identifier
  29614. * @return {?}
  29615. */
  29616. function unescapeIdentifier(identifier) {
  29617. return identifier.startsWith('___') ? identifier.substr(1) : identifier;
  29618. }
  29619. /**
  29620. * @param {?} metadata
  29621. * @return {?}
  29622. */
  29623. function unwrapResolvedMetadata(metadata) {
  29624. if (metadata && metadata.__symbolic === 'resolved') {
  29625. return metadata.symbol;
  29626. }
  29627. return metadata;
  29628. }
  29629. /**
  29630. * @fileoverview added by tsickle
  29631. * @suppress {checkTypes} checked by tsc
  29632. */
  29633. /**
  29634. * @param {?} srcFileName
  29635. * @param {?} forJitCtx
  29636. * @param {?} summaryResolver
  29637. * @param {?} symbolResolver
  29638. * @param {?} symbols
  29639. * @param {?} types
  29640. * @return {?}
  29641. */
  29642. function serializeSummaries(srcFileName, forJitCtx, summaryResolver, symbolResolver, symbols, types) {
  29643. var /** @type {?} */ toJsonSerializer = new ToJsonSerializer(symbolResolver, summaryResolver, srcFileName);
  29644. // for symbols, we use everything except for the class metadata itself
  29645. // (we keep the statics though), as the class metadata is contained in the
  29646. // CompileTypeSummary.
  29647. symbols.forEach(function (resolvedSymbol) {
  29648. return toJsonSerializer.addSummary({ symbol: resolvedSymbol.symbol, metadata: resolvedSymbol.metadata });
  29649. });
  29650. // Add type summaries.
  29651. types.forEach(function (_a) {
  29652. var summary = _a.summary, metadata = _a.metadata;
  29653. toJsonSerializer.addSummary({ symbol: summary.type.reference, metadata: undefined, type: summary });
  29654. });
  29655. var _a = toJsonSerializer.serialize(), json = _a.json, exportAs = _a.exportAs;
  29656. if (forJitCtx) {
  29657. var /** @type {?} */ forJitSerializer_1 = new ForJitSerializer(forJitCtx, symbolResolver, summaryResolver);
  29658. types.forEach(function (_a) {
  29659. var summary = _a.summary, metadata = _a.metadata;
  29660. forJitSerializer_1.addSourceType(summary, metadata);
  29661. });
  29662. toJsonSerializer.unprocessedSymbolSummariesBySymbol.forEach(function (summary) {
  29663. if (summaryResolver.isLibraryFile(summary.symbol.filePath) && summary.type) {
  29664. forJitSerializer_1.addLibType(summary.type);
  29665. }
  29666. });
  29667. forJitSerializer_1.serialize(exportAs);
  29668. }
  29669. return { json: json, exportAs: exportAs };
  29670. }
  29671. /**
  29672. * @param {?} symbolCache
  29673. * @param {?} summaryResolver
  29674. * @param {?} libraryFileName
  29675. * @param {?} json
  29676. * @return {?}
  29677. */
  29678. function deserializeSummaries(symbolCache, summaryResolver, libraryFileName, json) {
  29679. var /** @type {?} */ deserializer = new FromJsonDeserializer(symbolCache, summaryResolver);
  29680. return deserializer.deserialize(libraryFileName, json);
  29681. }
  29682. /**
  29683. * @param {?} outputCtx
  29684. * @param {?} reference
  29685. * @return {?}
  29686. */
  29687. function createForJitStub(outputCtx, reference) {
  29688. return createSummaryForJitFunction(outputCtx, reference, NULL_EXPR);
  29689. }
  29690. /**
  29691. * @param {?} outputCtx
  29692. * @param {?} reference
  29693. * @param {?} value
  29694. * @return {?}
  29695. */
  29696. function createSummaryForJitFunction(outputCtx, reference, value) {
  29697. var /** @type {?} */ fnName = summaryForJitName(reference.name);
  29698. outputCtx.statements.push(fn([], [new ReturnStatement(value)], new ArrayType(DYNAMIC_TYPE)).toDeclStmt(fnName, [
  29699. StmtModifier.Final, StmtModifier.Exported
  29700. ]));
  29701. }
  29702. var ToJsonSerializer = /** @class */ (function (_super) {
  29703. __extends(ToJsonSerializer, _super);
  29704. function ToJsonSerializer(symbolResolver, summaryResolver, srcFileName) {
  29705. var _this = _super.call(this) || this;
  29706. _this.symbolResolver = symbolResolver;
  29707. _this.summaryResolver = summaryResolver;
  29708. _this.srcFileName = srcFileName;
  29709. _this.symbols = [];
  29710. _this.indexBySymbol = new Map();
  29711. _this.reexportedBy = new Map();
  29712. _this.processedSummaryBySymbol = new Map();
  29713. _this.processedSummaries = [];
  29714. _this.unprocessedSymbolSummariesBySymbol = new Map();
  29715. _this.moduleName = symbolResolver.getKnownModuleName(srcFileName);
  29716. return _this;
  29717. }
  29718. /**
  29719. * @param {?} summary
  29720. * @return {?}
  29721. */
  29722. ToJsonSerializer.prototype.addSummary = /**
  29723. * @param {?} summary
  29724. * @return {?}
  29725. */
  29726. function (summary) {
  29727. var _this = this;
  29728. var /** @type {?} */ unprocessedSummary = this.unprocessedSymbolSummariesBySymbol.get(summary.symbol);
  29729. var /** @type {?} */ processedSummary = this.processedSummaryBySymbol.get(summary.symbol);
  29730. if (!unprocessedSummary) {
  29731. unprocessedSummary = { symbol: summary.symbol, metadata: undefined };
  29732. this.unprocessedSymbolSummariesBySymbol.set(summary.symbol, unprocessedSummary);
  29733. processedSummary = { symbol: this.processValue(summary.symbol, 0 /* None */) };
  29734. this.processedSummaries.push(processedSummary);
  29735. this.processedSummaryBySymbol.set(summary.symbol, processedSummary);
  29736. }
  29737. if (!unprocessedSummary.metadata && summary.metadata) {
  29738. var /** @type {?} */ metadata_1 = summary.metadata || {};
  29739. if (metadata_1.__symbolic === 'class') {
  29740. // For classes, we keep everything except their class decorators.
  29741. // We need to keep e.g. the ctor args, method names, method decorators
  29742. // so that the class can be extended in another compilation unit.
  29743. // We don't keep the class decorators as
  29744. // 1) they refer to data
  29745. // that should not cause a rebuild of downstream compilation units
  29746. // (e.g. inline templates of @Component, or @NgModule.declarations)
  29747. // 2) their data is already captured in TypeSummaries, e.g. DirectiveSummary.
  29748. var /** @type {?} */ clone_1 = {};
  29749. Object.keys(metadata_1).forEach(function (propName) {
  29750. if (propName !== 'decorators') {
  29751. clone_1[propName] = metadata_1[propName];
  29752. }
  29753. });
  29754. metadata_1 = clone_1;
  29755. }
  29756. else if (isCall(metadata_1)) {
  29757. if (!isFunctionCall(metadata_1) && !isMethodCallOnVariable(metadata_1)) {
  29758. // Don't store complex calls as we won't be able to simplify them anyways later on.
  29759. // Don't store complex calls as we won't be able to simplify them anyways later on.
  29760. metadata_1 = {
  29761. __symbolic: 'error',
  29762. message: 'Complex function calls are not supported.',
  29763. };
  29764. }
  29765. }
  29766. // Note: We need to keep storing ctor calls for e.g.
  29767. // `export const x = new InjectionToken(...)`
  29768. unprocessedSummary.metadata = metadata_1;
  29769. processedSummary.metadata = this.processValue(metadata_1, 1 /* ResolveValue */);
  29770. if (metadata_1 instanceof StaticSymbol &&
  29771. this.summaryResolver.isLibraryFile(metadata_1.filePath)) {
  29772. var /** @type {?} */ declarationSymbol = this.symbols[/** @type {?} */ ((this.indexBySymbol.get(metadata_1)))];
  29773. if (!isLoweredSymbol(declarationSymbol.name)) {
  29774. // Note: symbols that were introduced during codegen in the user file can have a reexport
  29775. // if a user used `export *`. However, we can't rely on this as tsickle will change
  29776. // `export *` into named exports, using only the information from the typechecker.
  29777. // As we introduce the new symbols after typecheck, Tsickle does not know about them,
  29778. // and omits them when expanding `export *`.
  29779. // So we have to keep reexporting these symbols manually via .ngfactory files.
  29780. this.reexportedBy.set(declarationSymbol, summary.symbol);
  29781. }
  29782. }
  29783. }
  29784. if (!unprocessedSummary.type && summary.type) {
  29785. unprocessedSummary.type = summary.type;
  29786. // Note: We don't add the summaries of all referenced symbols as for the ResolvedSymbols,
  29787. // as the type summaries already contain the transitive data that they require
  29788. // (in a minimal way).
  29789. processedSummary.type = this.processValue(summary.type, 0 /* None */);
  29790. // except for reexported directives / pipes, so we need to store
  29791. // their summaries explicitly.
  29792. if (summary.type.summaryKind === CompileSummaryKind.NgModule) {
  29793. var /** @type {?} */ ngModuleSummary = /** @type {?} */ (summary.type);
  29794. ngModuleSummary.exportedDirectives.concat(ngModuleSummary.exportedPipes).forEach(function (id) {
  29795. var /** @type {?} */ symbol = id.reference;
  29796. if (_this.summaryResolver.isLibraryFile(symbol.filePath) &&
  29797. !_this.unprocessedSymbolSummariesBySymbol.has(symbol)) {
  29798. var /** @type {?} */ summary_1 = _this.summaryResolver.resolveSummary(symbol);
  29799. if (summary_1) {
  29800. _this.addSummary(summary_1);
  29801. }
  29802. }
  29803. });
  29804. }
  29805. }
  29806. };
  29807. /**
  29808. * @return {?}
  29809. */
  29810. ToJsonSerializer.prototype.serialize = /**
  29811. * @return {?}
  29812. */
  29813. function () {
  29814. var _this = this;
  29815. var /** @type {?} */ exportAs = [];
  29816. var /** @type {?} */ json = JSON.stringify({
  29817. moduleName: this.moduleName,
  29818. summaries: this.processedSummaries,
  29819. symbols: this.symbols.map(function (symbol, index) {
  29820. symbol.assertNoMembers();
  29821. var /** @type {?} */ importAs = /** @type {?} */ ((undefined));
  29822. if (_this.summaryResolver.isLibraryFile(symbol.filePath)) {
  29823. var /** @type {?} */ reexportSymbol = _this.reexportedBy.get(symbol);
  29824. if (reexportSymbol) {
  29825. importAs = /** @type {?} */ ((_this.indexBySymbol.get(reexportSymbol)));
  29826. }
  29827. else {
  29828. var /** @type {?} */ summary = _this.unprocessedSymbolSummariesBySymbol.get(symbol);
  29829. if (!summary || !summary.metadata || summary.metadata.__symbolic !== 'interface') {
  29830. importAs = symbol.name + "_" + index;
  29831. exportAs.push({ symbol: symbol, exportAs: importAs });
  29832. }
  29833. }
  29834. }
  29835. return {
  29836. __symbol: index,
  29837. name: symbol.name,
  29838. filePath: _this.summaryResolver.toSummaryFileName(symbol.filePath, _this.srcFileName),
  29839. importAs: importAs
  29840. };
  29841. })
  29842. });
  29843. return { json: json, exportAs: exportAs };
  29844. };
  29845. /**
  29846. * @param {?} value
  29847. * @param {?} flags
  29848. * @return {?}
  29849. */
  29850. ToJsonSerializer.prototype.processValue = /**
  29851. * @param {?} value
  29852. * @param {?} flags
  29853. * @return {?}
  29854. */
  29855. function (value, flags) {
  29856. return visitValue(value, this, flags);
  29857. };
  29858. /**
  29859. * @param {?} value
  29860. * @param {?} context
  29861. * @return {?}
  29862. */
  29863. ToJsonSerializer.prototype.visitOther = /**
  29864. * @param {?} value
  29865. * @param {?} context
  29866. * @return {?}
  29867. */
  29868. function (value, context) {
  29869. if (value instanceof StaticSymbol) {
  29870. var /** @type {?} */ baseSymbol = this.symbolResolver.getStaticSymbol(value.filePath, value.name);
  29871. var /** @type {?} */ index = this.visitStaticSymbol(baseSymbol, context);
  29872. return { __symbol: index, members: value.members };
  29873. }
  29874. };
  29875. /**
  29876. * Returns null if the options.resolveValue is true, and the summary for the symbol
  29877. * resolved to a type or could not be resolved.
  29878. * @param {?} baseSymbol
  29879. * @param {?} flags
  29880. * @return {?}
  29881. */
  29882. ToJsonSerializer.prototype.visitStaticSymbol = /**
  29883. * Returns null if the options.resolveValue is true, and the summary for the symbol
  29884. * resolved to a type or could not be resolved.
  29885. * @param {?} baseSymbol
  29886. * @param {?} flags
  29887. * @return {?}
  29888. */
  29889. function (baseSymbol, flags) {
  29890. var /** @type {?} */ index = this.indexBySymbol.get(baseSymbol);
  29891. var /** @type {?} */ summary = null;
  29892. if (flags & 1 /* ResolveValue */ &&
  29893. this.summaryResolver.isLibraryFile(baseSymbol.filePath)) {
  29894. if (this.unprocessedSymbolSummariesBySymbol.has(baseSymbol)) {
  29895. // the summary for this symbol was already added
  29896. // -> nothing to do.
  29897. return /** @type {?} */ ((index));
  29898. }
  29899. summary = this.loadSummary(baseSymbol);
  29900. if (summary && summary.metadata instanceof StaticSymbol) {
  29901. // The summary is a reexport
  29902. index = this.visitStaticSymbol(summary.metadata, flags);
  29903. // reset the summary as it is just a reexport, so we don't want to store it.
  29904. summary = null;
  29905. }
  29906. }
  29907. else if (index != null) {
  29908. // Note: == on purpose to compare with undefined!
  29909. // No summary and the symbol is already added -> nothing to do.
  29910. return index;
  29911. }
  29912. // Note: == on purpose to compare with undefined!
  29913. if (index == null) {
  29914. index = this.symbols.length;
  29915. this.symbols.push(baseSymbol);
  29916. }
  29917. this.indexBySymbol.set(baseSymbol, index);
  29918. if (summary) {
  29919. this.addSummary(summary);
  29920. }
  29921. return index;
  29922. };
  29923. /**
  29924. * @param {?} symbol
  29925. * @return {?}
  29926. */
  29927. ToJsonSerializer.prototype.loadSummary = /**
  29928. * @param {?} symbol
  29929. * @return {?}
  29930. */
  29931. function (symbol) {
  29932. var /** @type {?} */ summary = this.summaryResolver.resolveSummary(symbol);
  29933. if (!summary) {
  29934. // some symbols might originate from a plain typescript library
  29935. // that just exported .d.ts and .metadata.json files, i.e. where no summary
  29936. // files were created.
  29937. var /** @type {?} */ resolvedSymbol = this.symbolResolver.resolveSymbol(symbol);
  29938. if (resolvedSymbol) {
  29939. summary = { symbol: resolvedSymbol.symbol, metadata: resolvedSymbol.metadata };
  29940. }
  29941. }
  29942. return summary;
  29943. };
  29944. return ToJsonSerializer;
  29945. }(ValueTransformer));
  29946. var ForJitSerializer = /** @class */ (function () {
  29947. function ForJitSerializer(outputCtx, symbolResolver, summaryResolver) {
  29948. this.outputCtx = outputCtx;
  29949. this.symbolResolver = symbolResolver;
  29950. this.summaryResolver = summaryResolver;
  29951. this.data = [];
  29952. }
  29953. /**
  29954. * @param {?} summary
  29955. * @param {?} metadata
  29956. * @return {?}
  29957. */
  29958. ForJitSerializer.prototype.addSourceType = /**
  29959. * @param {?} summary
  29960. * @param {?} metadata
  29961. * @return {?}
  29962. */
  29963. function (summary, metadata) {
  29964. this.data.push({ summary: summary, metadata: metadata, isLibrary: false });
  29965. };
  29966. /**
  29967. * @param {?} summary
  29968. * @return {?}
  29969. */
  29970. ForJitSerializer.prototype.addLibType = /**
  29971. * @param {?} summary
  29972. * @return {?}
  29973. */
  29974. function (summary) {
  29975. this.data.push({ summary: summary, metadata: null, isLibrary: true });
  29976. };
  29977. /**
  29978. * @param {?} exportAsArr
  29979. * @return {?}
  29980. */
  29981. ForJitSerializer.prototype.serialize = /**
  29982. * @param {?} exportAsArr
  29983. * @return {?}
  29984. */
  29985. function (exportAsArr) {
  29986. var _this = this;
  29987. var /** @type {?} */ exportAsBySymbol = new Map();
  29988. for (var _i = 0, exportAsArr_1 = exportAsArr; _i < exportAsArr_1.length; _i++) {
  29989. var _a = exportAsArr_1[_i], symbol = _a.symbol, exportAs = _a.exportAs;
  29990. exportAsBySymbol.set(symbol, exportAs);
  29991. }
  29992. var /** @type {?} */ ngModuleSymbols = new Set();
  29993. for (var _b = 0, _c = this.data; _b < _c.length; _b++) {
  29994. var _d = _c[_b], summary = _d.summary, metadata = _d.metadata, isLibrary = _d.isLibrary;
  29995. if (summary.summaryKind === CompileSummaryKind.NgModule) {
  29996. // collect the symbols that refer to NgModule classes.
  29997. // Note: we can't just rely on `summary.type.summaryKind` to determine this as
  29998. // we don't add the summaries of all referenced symbols when we serialize type summaries.
  29999. // See serializeSummaries for details.
  30000. ngModuleSymbols.add(summary.type.reference);
  30001. var /** @type {?} */ modSummary = /** @type {?} */ (summary);
  30002. for (var _e = 0, _f = modSummary.modules; _e < _f.length; _e++) {
  30003. var mod = _f[_e];
  30004. ngModuleSymbols.add(mod.reference);
  30005. }
  30006. }
  30007. if (!isLibrary) {
  30008. var /** @type {?} */ fnName = summaryForJitName(summary.type.reference.name);
  30009. createSummaryForJitFunction(this.outputCtx, summary.type.reference, this.serializeSummaryWithDeps(summary, /** @type {?} */ ((metadata))));
  30010. }
  30011. }
  30012. ngModuleSymbols.forEach(function (ngModuleSymbol) {
  30013. if (_this.summaryResolver.isLibraryFile(ngModuleSymbol.filePath)) {
  30014. var /** @type {?} */ exportAs = exportAsBySymbol.get(ngModuleSymbol) || ngModuleSymbol.name;
  30015. var /** @type {?} */ jitExportAsName = summaryForJitName(exportAs);
  30016. _this.outputCtx.statements.push(variable(jitExportAsName)
  30017. .set(_this.serializeSummaryRef(ngModuleSymbol))
  30018. .toDeclStmt(null, [StmtModifier.Exported]));
  30019. }
  30020. });
  30021. };
  30022. /**
  30023. * @param {?} summary
  30024. * @param {?} metadata
  30025. * @return {?}
  30026. */
  30027. ForJitSerializer.prototype.serializeSummaryWithDeps = /**
  30028. * @param {?} summary
  30029. * @param {?} metadata
  30030. * @return {?}
  30031. */
  30032. function (summary, metadata) {
  30033. var _this = this;
  30034. var /** @type {?} */ expressions = [this.serializeSummary(summary)];
  30035. var /** @type {?} */ providers = [];
  30036. if (metadata instanceof CompileNgModuleMetadata) {
  30037. expressions.push.apply(expressions,
  30038. // For directives / pipes, we only add the declared ones,
  30039. // and rely on transitively importing NgModules to get the transitive
  30040. // summaries.
  30041. metadata.declaredDirectives.concat(metadata.declaredPipes)
  30042. .map(function (type) { return type.reference; })
  30043. .concat(metadata.transitiveModule.modules.map(function (type) { return type.reference; })
  30044. .filter(function (ref) { return ref !== metadata.type.reference; }))
  30045. .map(function (ref) { return _this.serializeSummaryRef(ref); }));
  30046. // Note: We don't use `NgModuleSummary.providers`, as that one is transitive,
  30047. // and we already have transitive modules.
  30048. providers = metadata.providers;
  30049. }
  30050. else if (summary.summaryKind === CompileSummaryKind.Directive) {
  30051. var /** @type {?} */ dirSummary = /** @type {?} */ (summary);
  30052. providers = dirSummary.providers.concat(dirSummary.viewProviders);
  30053. }
  30054. // Note: We can't just refer to the `ngsummary.ts` files for `useClass` providers (as we do for
  30055. // declaredDirectives / declaredPipes), as we allow
  30056. // providers without ctor arguments to skip the `@Injectable` decorator,
  30057. // i.e. we didn't generate .ngsummary.ts files for these.
  30058. expressions.push.apply(expressions, providers.filter(function (provider) { return !!provider.useClass; }).map(function (provider) {
  30059. return _this.serializeSummary(/** @type {?} */ ({
  30060. summaryKind: CompileSummaryKind.Injectable, type: provider.useClass
  30061. }));
  30062. }));
  30063. return literalArr(expressions);
  30064. };
  30065. /**
  30066. * @param {?} typeSymbol
  30067. * @return {?}
  30068. */
  30069. ForJitSerializer.prototype.serializeSummaryRef = /**
  30070. * @param {?} typeSymbol
  30071. * @return {?}
  30072. */
  30073. function (typeSymbol) {
  30074. var /** @type {?} */ jitImportedSymbol = this.symbolResolver.getStaticSymbol(summaryForJitFileName(typeSymbol.filePath), summaryForJitName(typeSymbol.name));
  30075. return this.outputCtx.importExpr(jitImportedSymbol);
  30076. };
  30077. /**
  30078. * @param {?} data
  30079. * @return {?}
  30080. */
  30081. ForJitSerializer.prototype.serializeSummary = /**
  30082. * @param {?} data
  30083. * @return {?}
  30084. */
  30085. function (data) {
  30086. var /** @type {?} */ outputCtx = this.outputCtx;
  30087. var Transformer = /** @class */ (function () {
  30088. function Transformer() {
  30089. }
  30090. /**
  30091. * @param {?} arr
  30092. * @param {?} context
  30093. * @return {?}
  30094. */
  30095. Transformer.prototype.visitArray = /**
  30096. * @param {?} arr
  30097. * @param {?} context
  30098. * @return {?}
  30099. */
  30100. function (arr, context) {
  30101. var _this = this;
  30102. return literalArr(arr.map(function (entry) { return visitValue(entry, _this, context); }));
  30103. };
  30104. /**
  30105. * @param {?} map
  30106. * @param {?} context
  30107. * @return {?}
  30108. */
  30109. Transformer.prototype.visitStringMap = /**
  30110. * @param {?} map
  30111. * @param {?} context
  30112. * @return {?}
  30113. */
  30114. function (map, context) {
  30115. var _this = this;
  30116. return new LiteralMapExpr(Object.keys(map).map(function (key) { return new LiteralMapEntry(key, visitValue(map[key], _this, context), false); }));
  30117. };
  30118. /**
  30119. * @param {?} value
  30120. * @param {?} context
  30121. * @return {?}
  30122. */
  30123. Transformer.prototype.visitPrimitive = /**
  30124. * @param {?} value
  30125. * @param {?} context
  30126. * @return {?}
  30127. */
  30128. function (value, context) { return literal(value); };
  30129. /**
  30130. * @param {?} value
  30131. * @param {?} context
  30132. * @return {?}
  30133. */
  30134. Transformer.prototype.visitOther = /**
  30135. * @param {?} value
  30136. * @param {?} context
  30137. * @return {?}
  30138. */
  30139. function (value, context) {
  30140. if (value instanceof StaticSymbol) {
  30141. return outputCtx.importExpr(value);
  30142. }
  30143. else {
  30144. throw new Error("Illegal State: Encountered value " + value);
  30145. }
  30146. };
  30147. return Transformer;
  30148. }());
  30149. return visitValue(data, new Transformer(), null);
  30150. };
  30151. return ForJitSerializer;
  30152. }());
  30153. var FromJsonDeserializer = /** @class */ (function (_super) {
  30154. __extends(FromJsonDeserializer, _super);
  30155. function FromJsonDeserializer(symbolCache, summaryResolver) {
  30156. var _this = _super.call(this) || this;
  30157. _this.symbolCache = symbolCache;
  30158. _this.summaryResolver = summaryResolver;
  30159. return _this;
  30160. }
  30161. /**
  30162. * @param {?} libraryFileName
  30163. * @param {?} json
  30164. * @return {?}
  30165. */
  30166. FromJsonDeserializer.prototype.deserialize = /**
  30167. * @param {?} libraryFileName
  30168. * @param {?} json
  30169. * @return {?}
  30170. */
  30171. function (libraryFileName, json) {
  30172. var _this = this;
  30173. var /** @type {?} */ data = JSON.parse(json);
  30174. var /** @type {?} */ allImportAs = [];
  30175. this.symbols = data.symbols.map(function (serializedSymbol) {
  30176. return _this.symbolCache.get(_this.summaryResolver.fromSummaryFileName(serializedSymbol.filePath, libraryFileName), serializedSymbol.name);
  30177. });
  30178. data.symbols.forEach(function (serializedSymbol, index) {
  30179. var /** @type {?} */ symbol = _this.symbols[index];
  30180. var /** @type {?} */ importAs = serializedSymbol.importAs;
  30181. if (typeof importAs === 'number') {
  30182. allImportAs.push({ symbol: symbol, importAs: _this.symbols[importAs] });
  30183. }
  30184. else if (typeof importAs === 'string') {
  30185. allImportAs.push({ symbol: symbol, importAs: _this.symbolCache.get(ngfactoryFilePath(libraryFileName), importAs) });
  30186. }
  30187. });
  30188. var /** @type {?} */ summaries = /** @type {?} */ (visitValue(data.summaries, this, null));
  30189. return { moduleName: data.moduleName, summaries: summaries, importAs: allImportAs };
  30190. };
  30191. /**
  30192. * @param {?} map
  30193. * @param {?} context
  30194. * @return {?}
  30195. */
  30196. FromJsonDeserializer.prototype.visitStringMap = /**
  30197. * @param {?} map
  30198. * @param {?} context
  30199. * @return {?}
  30200. */
  30201. function (map, context) {
  30202. if ('__symbol' in map) {
  30203. var /** @type {?} */ baseSymbol = this.symbols[map['__symbol']];
  30204. var /** @type {?} */ members = map['members'];
  30205. return members.length ? this.symbolCache.get(baseSymbol.filePath, baseSymbol.name, members) :
  30206. baseSymbol;
  30207. }
  30208. else {
  30209. return _super.prototype.visitStringMap.call(this, map, context);
  30210. }
  30211. };
  30212. return FromJsonDeserializer;
  30213. }(ValueTransformer));
  30214. /**
  30215. * @param {?} metadata
  30216. * @return {?}
  30217. */
  30218. function isCall(metadata) {
  30219. return metadata && metadata.__symbolic === 'call';
  30220. }
  30221. /**
  30222. * @param {?} metadata
  30223. * @return {?}
  30224. */
  30225. function isFunctionCall(metadata) {
  30226. return isCall(metadata) && unwrapResolvedMetadata(metadata.expression) instanceof StaticSymbol;
  30227. }
  30228. /**
  30229. * @param {?} metadata
  30230. * @return {?}
  30231. */
  30232. function isMethodCallOnVariable(metadata) {
  30233. return isCall(metadata) && metadata.expression && metadata.expression.__symbolic === 'select' &&
  30234. unwrapResolvedMetadata(metadata.expression.expression) instanceof StaticSymbol;
  30235. }
  30236. /**
  30237. * @fileoverview added by tsickle
  30238. * @suppress {checkTypes} checked by tsc
  30239. */
  30240. /**
  30241. * @license
  30242. * Copyright Google Inc. All Rights Reserved.
  30243. *
  30244. * Use of this source code is governed by an MIT-style license that can be
  30245. * found in the LICENSE file at https://angular.io/license
  30246. */
  30247. /** @enum {number} */
  30248. var StubEmitFlags = {
  30249. Basic: 1,
  30250. TypeCheck: 2,
  30251. All: 3,
  30252. };
  30253. StubEmitFlags[StubEmitFlags.Basic] = "Basic";
  30254. StubEmitFlags[StubEmitFlags.TypeCheck] = "TypeCheck";
  30255. StubEmitFlags[StubEmitFlags.All] = "All";
  30256. var AotCompiler = /** @class */ (function () {
  30257. function AotCompiler(_config, _options, _host, _reflector, _metadataResolver, _templateParser, _styleCompiler, _viewCompiler, _typeCheckCompiler, _ngModuleCompiler, _outputEmitter, _summaryResolver, _symbolResolver) {
  30258. this._config = _config;
  30259. this._options = _options;
  30260. this._host = _host;
  30261. this._reflector = _reflector;
  30262. this._metadataResolver = _metadataResolver;
  30263. this._templateParser = _templateParser;
  30264. this._styleCompiler = _styleCompiler;
  30265. this._viewCompiler = _viewCompiler;
  30266. this._typeCheckCompiler = _typeCheckCompiler;
  30267. this._ngModuleCompiler = _ngModuleCompiler;
  30268. this._outputEmitter = _outputEmitter;
  30269. this._summaryResolver = _summaryResolver;
  30270. this._symbolResolver = _symbolResolver;
  30271. this._templateAstCache = new Map();
  30272. this._analyzedFiles = new Map();
  30273. }
  30274. /**
  30275. * @return {?}
  30276. */
  30277. AotCompiler.prototype.clearCache = /**
  30278. * @return {?}
  30279. */
  30280. function () { this._metadataResolver.clearCache(); };
  30281. /**
  30282. * @param {?} rootFiles
  30283. * @return {?}
  30284. */
  30285. AotCompiler.prototype.analyzeModulesSync = /**
  30286. * @param {?} rootFiles
  30287. * @return {?}
  30288. */
  30289. function (rootFiles) {
  30290. var _this = this;
  30291. var /** @type {?} */ analyzeResult = analyzeAndValidateNgModules(rootFiles, this._host, this._symbolResolver, this._metadataResolver);
  30292. analyzeResult.ngModules.forEach(function (ngModule) {
  30293. return _this._metadataResolver.loadNgModuleDirectiveAndPipeMetadata(ngModule.type.reference, true);
  30294. });
  30295. return analyzeResult;
  30296. };
  30297. /**
  30298. * @param {?} rootFiles
  30299. * @return {?}
  30300. */
  30301. AotCompiler.prototype.analyzeModulesAsync = /**
  30302. * @param {?} rootFiles
  30303. * @return {?}
  30304. */
  30305. function (rootFiles) {
  30306. var _this = this;
  30307. var /** @type {?} */ analyzeResult = analyzeAndValidateNgModules(rootFiles, this._host, this._symbolResolver, this._metadataResolver);
  30308. return Promise
  30309. .all(analyzeResult.ngModules.map(function (ngModule) {
  30310. return _this._metadataResolver.loadNgModuleDirectiveAndPipeMetadata(ngModule.type.reference, false);
  30311. }))
  30312. .then(function () { return analyzeResult; });
  30313. };
  30314. /**
  30315. * @param {?} fileName
  30316. * @return {?}
  30317. */
  30318. AotCompiler.prototype._analyzeFile = /**
  30319. * @param {?} fileName
  30320. * @return {?}
  30321. */
  30322. function (fileName) {
  30323. var /** @type {?} */ analyzedFile = this._analyzedFiles.get(fileName);
  30324. if (!analyzedFile) {
  30325. analyzedFile =
  30326. analyzeFile(this._host, this._symbolResolver, this._metadataResolver, fileName);
  30327. this._analyzedFiles.set(fileName, analyzedFile);
  30328. }
  30329. return analyzedFile;
  30330. };
  30331. /**
  30332. * @param {?} fileName
  30333. * @return {?}
  30334. */
  30335. AotCompiler.prototype.findGeneratedFileNames = /**
  30336. * @param {?} fileName
  30337. * @return {?}
  30338. */
  30339. function (fileName) {
  30340. var _this = this;
  30341. var /** @type {?} */ genFileNames = [];
  30342. var /** @type {?} */ file = this._analyzeFile(fileName);
  30343. // Make sure we create a .ngfactory if we have a injectable/directive/pipe/NgModule
  30344. // or a reference to a non source file.
  30345. // Note: This is overestimating the required .ngfactory files as the real calculation is harder.
  30346. // Only do this for StubEmitFlags.Basic, as adding a type check block
  30347. // does not change this file (as we generate type check blocks based on NgModules).
  30348. if (this._options.allowEmptyCodegenFiles || file.directives.length || file.pipes.length ||
  30349. file.injectables.length || file.ngModules.length || file.exportsNonSourceFiles) {
  30350. genFileNames.push(ngfactoryFilePath(file.fileName, true));
  30351. if (this._options.enableSummariesForJit) {
  30352. genFileNames.push(summaryForJitFileName(file.fileName, true));
  30353. }
  30354. }
  30355. var /** @type {?} */ fileSuffix = normalizeGenFileSuffix(splitTypescriptSuffix(file.fileName, true)[1]);
  30356. file.directives.forEach(function (dirSymbol) {
  30357. var /** @type {?} */ compMeta = /** @type {?} */ ((_this._metadataResolver.getNonNormalizedDirectiveMetadata(dirSymbol))).metadata;
  30358. if (!compMeta.isComponent) {
  30359. return;
  30360. } /** @type {?} */
  30361. ((
  30362. // Note: compMeta is a component and therefore template is non null.
  30363. compMeta.template)).styleUrls.forEach(function (styleUrl) {
  30364. var /** @type {?} */ normalizedUrl = _this._host.resourceNameToFileName(styleUrl, file.fileName);
  30365. if (!normalizedUrl) {
  30366. throw syntaxError("Couldn't resolve resource " + styleUrl + " relative to " + file.fileName);
  30367. }
  30368. var /** @type {?} */ needsShim = (/** @type {?} */ ((compMeta.template)).encapsulation || _this._config.defaultEncapsulation) === ViewEncapsulation.Emulated;
  30369. genFileNames.push(_stylesModuleUrl(normalizedUrl, needsShim, fileSuffix));
  30370. if (_this._options.allowEmptyCodegenFiles) {
  30371. genFileNames.push(_stylesModuleUrl(normalizedUrl, !needsShim, fileSuffix));
  30372. }
  30373. });
  30374. });
  30375. return genFileNames;
  30376. };
  30377. /**
  30378. * @param {?} genFileName
  30379. * @param {?=} originalFileName
  30380. * @return {?}
  30381. */
  30382. AotCompiler.prototype.emitBasicStub = /**
  30383. * @param {?} genFileName
  30384. * @param {?=} originalFileName
  30385. * @return {?}
  30386. */
  30387. function (genFileName, originalFileName) {
  30388. var /** @type {?} */ outputCtx = this._createOutputContext(genFileName);
  30389. if (genFileName.endsWith('.ngfactory.ts')) {
  30390. if (!originalFileName) {
  30391. throw new Error("Assertion error: require the original file for .ngfactory.ts stubs. File: " + genFileName);
  30392. }
  30393. var /** @type {?} */ originalFile = this._analyzeFile(originalFileName);
  30394. this._createNgFactoryStub(outputCtx, originalFile, StubEmitFlags.Basic);
  30395. }
  30396. else if (genFileName.endsWith('.ngsummary.ts')) {
  30397. if (this._options.enableSummariesForJit) {
  30398. if (!originalFileName) {
  30399. throw new Error("Assertion error: require the original file for .ngsummary.ts stubs. File: " + genFileName);
  30400. }
  30401. var /** @type {?} */ originalFile = this._analyzeFile(originalFileName);
  30402. _createEmptyStub(outputCtx);
  30403. originalFile.ngModules.forEach(function (ngModule) {
  30404. // create exports that user code can reference
  30405. createForJitStub(outputCtx, ngModule.type.reference);
  30406. });
  30407. }
  30408. }
  30409. else if (genFileName.endsWith('.ngstyle.ts')) {
  30410. _createEmptyStub(outputCtx);
  30411. }
  30412. // Note: for the stubs, we don't need a property srcFileUrl,
  30413. // as lateron in emitAllImpls we will create the proper GeneratedFiles with the
  30414. // correct srcFileUrl.
  30415. // This is good as e.g. for .ngstyle.ts files we can't derive
  30416. // the url of components based on the genFileUrl.
  30417. return this._codegenSourceModule('unknown', outputCtx);
  30418. };
  30419. /**
  30420. * @param {?} genFileName
  30421. * @param {?} originalFileName
  30422. * @return {?}
  30423. */
  30424. AotCompiler.prototype.emitTypeCheckStub = /**
  30425. * @param {?} genFileName
  30426. * @param {?} originalFileName
  30427. * @return {?}
  30428. */
  30429. function (genFileName, originalFileName) {
  30430. var /** @type {?} */ originalFile = this._analyzeFile(originalFileName);
  30431. var /** @type {?} */ outputCtx = this._createOutputContext(genFileName);
  30432. if (genFileName.endsWith('.ngfactory.ts')) {
  30433. this._createNgFactoryStub(outputCtx, originalFile, StubEmitFlags.TypeCheck);
  30434. }
  30435. return outputCtx.statements.length > 0 ?
  30436. this._codegenSourceModule(originalFile.fileName, outputCtx) :
  30437. null;
  30438. };
  30439. /**
  30440. * @param {?} fileNames
  30441. * @return {?}
  30442. */
  30443. AotCompiler.prototype.loadFilesAsync = /**
  30444. * @param {?} fileNames
  30445. * @return {?}
  30446. */
  30447. function (fileNames) {
  30448. var _this = this;
  30449. var /** @type {?} */ files = fileNames.map(function (fileName) { return _this._analyzeFile(fileName); });
  30450. var /** @type {?} */ loadingPromises = [];
  30451. files.forEach(function (file) {
  30452. return file.ngModules.forEach(function (ngModule) {
  30453. return loadingPromises.push(_this._metadataResolver.loadNgModuleDirectiveAndPipeMetadata(ngModule.type.reference, false));
  30454. });
  30455. });
  30456. return Promise.all(loadingPromises).then(function (_) { return mergeAndValidateNgFiles(files); });
  30457. };
  30458. /**
  30459. * @param {?} fileNames
  30460. * @return {?}
  30461. */
  30462. AotCompiler.prototype.loadFilesSync = /**
  30463. * @param {?} fileNames
  30464. * @return {?}
  30465. */
  30466. function (fileNames) {
  30467. var _this = this;
  30468. var /** @type {?} */ files = fileNames.map(function (fileName) { return _this._analyzeFile(fileName); });
  30469. files.forEach(function (file) {
  30470. return file.ngModules.forEach(function (ngModule) {
  30471. return _this._metadataResolver.loadNgModuleDirectiveAndPipeMetadata(ngModule.type.reference, true);
  30472. });
  30473. });
  30474. return mergeAndValidateNgFiles(files);
  30475. };
  30476. /**
  30477. * @param {?} outputCtx
  30478. * @param {?} file
  30479. * @param {?} emitFlags
  30480. * @return {?}
  30481. */
  30482. AotCompiler.prototype._createNgFactoryStub = /**
  30483. * @param {?} outputCtx
  30484. * @param {?} file
  30485. * @param {?} emitFlags
  30486. * @return {?}
  30487. */
  30488. function (outputCtx, file, emitFlags) {
  30489. var _this = this;
  30490. var /** @type {?} */ componentId = 0;
  30491. file.ngModules.forEach(function (ngModuleMeta, ngModuleIndex) {
  30492. // Note: the code below needs to executed for StubEmitFlags.Basic and StubEmitFlags.TypeCheck,
  30493. // so we don't change the .ngfactory file too much when adding the typecheck block.
  30494. // create exports that user code can reference
  30495. // Note: the code below needs to executed for StubEmitFlags.Basic and StubEmitFlags.TypeCheck,
  30496. // so we don't change the .ngfactory file too much when adding the typecheck block.
  30497. // create exports that user code can reference
  30498. _this._ngModuleCompiler.createStub(outputCtx, ngModuleMeta.type.reference);
  30499. // add references to the symbols from the metadata.
  30500. // These can be used by the type check block for components,
  30501. // and they also cause TypeScript to include these files into the program too,
  30502. // which will make them part of the analyzedFiles.
  30503. var /** @type {?} */ externalReferences = ngModuleMeta.transitiveModule.directives.map(function (d) { return d.reference; }).concat(ngModuleMeta.transitiveModule.pipes.map(function (d) { return d.reference; }), ngModuleMeta.importedModules.map(function (m) { return m.type.reference; }), ngModuleMeta.exportedModules.map(function (m) { return m.type.reference; }), _this._externalIdentifierReferences([Identifiers.TemplateRef, Identifiers.ElementRef]));
  30504. var /** @type {?} */ externalReferenceVars = new Map();
  30505. externalReferences.forEach(function (ref, typeIndex) {
  30506. externalReferenceVars.set(ref, "_decl" + ngModuleIndex + "_" + typeIndex);
  30507. });
  30508. externalReferenceVars.forEach(function (varName, reference) {
  30509. outputCtx.statements.push(variable(varName)
  30510. .set(NULL_EXPR.cast(DYNAMIC_TYPE))
  30511. .toDeclStmt(expressionType(outputCtx.importExpr(reference, /* typeParams */ null, /* useSummaries */ /* useSummaries */ false))));
  30512. });
  30513. if (emitFlags & StubEmitFlags.TypeCheck) {
  30514. // add the typecheck block for all components of the NgModule
  30515. ngModuleMeta.declaredDirectives.forEach(function (dirId) {
  30516. var /** @type {?} */ compMeta = _this._metadataResolver.getDirectiveMetadata(dirId.reference);
  30517. if (!compMeta.isComponent) {
  30518. return;
  30519. }
  30520. componentId++;
  30521. _this._createTypeCheckBlock(outputCtx, compMeta.type.reference.name + "_Host_" + componentId, ngModuleMeta, _this._metadataResolver.getHostComponentMetadata(compMeta), [compMeta.type], externalReferenceVars);
  30522. _this._createTypeCheckBlock(outputCtx, compMeta.type.reference.name + "_" + componentId, ngModuleMeta, compMeta, ngModuleMeta.transitiveModule.directives, externalReferenceVars);
  30523. });
  30524. }
  30525. });
  30526. if (outputCtx.statements.length === 0) {
  30527. _createEmptyStub(outputCtx);
  30528. }
  30529. };
  30530. /**
  30531. * @param {?} references
  30532. * @return {?}
  30533. */
  30534. AotCompiler.prototype._externalIdentifierReferences = /**
  30535. * @param {?} references
  30536. * @return {?}
  30537. */
  30538. function (references) {
  30539. var /** @type {?} */ result = [];
  30540. for (var _i = 0, references_1 = references; _i < references_1.length; _i++) {
  30541. var reference = references_1[_i];
  30542. var /** @type {?} */ token = createTokenForExternalReference(this._reflector, reference);
  30543. if (token.identifier) {
  30544. result.push(token.identifier.reference);
  30545. }
  30546. }
  30547. return result;
  30548. };
  30549. /**
  30550. * @param {?} ctx
  30551. * @param {?} componentId
  30552. * @param {?} moduleMeta
  30553. * @param {?} compMeta
  30554. * @param {?} directives
  30555. * @param {?} externalReferenceVars
  30556. * @return {?}
  30557. */
  30558. AotCompiler.prototype._createTypeCheckBlock = /**
  30559. * @param {?} ctx
  30560. * @param {?} componentId
  30561. * @param {?} moduleMeta
  30562. * @param {?} compMeta
  30563. * @param {?} directives
  30564. * @param {?} externalReferenceVars
  30565. * @return {?}
  30566. */
  30567. function (ctx, componentId, moduleMeta, compMeta, directives, externalReferenceVars) {
  30568. var _a = this._parseTemplate(compMeta, moduleMeta, directives), parsedTemplate = _a.template, usedPipes = _a.pipes;
  30569. (_b = ctx.statements).push.apply(_b, this._typeCheckCompiler.compileComponent(componentId, compMeta, parsedTemplate, usedPipes, externalReferenceVars, ctx));
  30570. var _b;
  30571. };
  30572. /**
  30573. * @param {?} analyzeResult
  30574. * @param {?} locale
  30575. * @return {?}
  30576. */
  30577. AotCompiler.prototype.emitMessageBundle = /**
  30578. * @param {?} analyzeResult
  30579. * @param {?} locale
  30580. * @return {?}
  30581. */
  30582. function (analyzeResult, locale) {
  30583. var _this = this;
  30584. var /** @type {?} */ errors = [];
  30585. var /** @type {?} */ htmlParser = new HtmlParser();
  30586. // TODO(vicb): implicit tags & attributes
  30587. var /** @type {?} */ messageBundle = new MessageBundle(htmlParser, [], {}, locale);
  30588. analyzeResult.files.forEach(function (file) {
  30589. var /** @type {?} */ compMetas = [];
  30590. file.directives.forEach(function (directiveType) {
  30591. var /** @type {?} */ dirMeta = _this._metadataResolver.getDirectiveMetadata(directiveType);
  30592. if (dirMeta && dirMeta.isComponent) {
  30593. compMetas.push(dirMeta);
  30594. }
  30595. });
  30596. compMetas.forEach(function (compMeta) {
  30597. var /** @type {?} */ html = /** @type {?} */ ((/** @type {?} */ ((compMeta.template)).template));
  30598. var /** @type {?} */ interpolationConfig = InterpolationConfig.fromArray(/** @type {?} */ ((compMeta.template)).interpolation);
  30599. errors.push.apply(errors, /** @type {?} */ ((messageBundle.updateFromTemplate(html, file.fileName, interpolationConfig))));
  30600. });
  30601. });
  30602. if (errors.length) {
  30603. throw new Error(errors.map(function (e) { return e.toString(); }).join('\n'));
  30604. }
  30605. return messageBundle;
  30606. };
  30607. /**
  30608. * @param {?} analyzeResult
  30609. * @return {?}
  30610. */
  30611. AotCompiler.prototype.emitAllImpls = /**
  30612. * @param {?} analyzeResult
  30613. * @return {?}
  30614. */
  30615. function (analyzeResult) {
  30616. var _this = this;
  30617. var ngModuleByPipeOrDirective = analyzeResult.ngModuleByPipeOrDirective, files = analyzeResult.files;
  30618. var /** @type {?} */ sourceModules = files.map(function (file) {
  30619. return _this._compileImplFile(file.fileName, ngModuleByPipeOrDirective, file.directives, file.pipes, file.ngModules, file.injectables);
  30620. });
  30621. return flatten(sourceModules);
  30622. };
  30623. /**
  30624. * @param {?} srcFileUrl
  30625. * @param {?} ngModuleByPipeOrDirective
  30626. * @param {?} directives
  30627. * @param {?} pipes
  30628. * @param {?} ngModules
  30629. * @param {?} injectables
  30630. * @return {?}
  30631. */
  30632. AotCompiler.prototype._compileImplFile = /**
  30633. * @param {?} srcFileUrl
  30634. * @param {?} ngModuleByPipeOrDirective
  30635. * @param {?} directives
  30636. * @param {?} pipes
  30637. * @param {?} ngModules
  30638. * @param {?} injectables
  30639. * @return {?}
  30640. */
  30641. function (srcFileUrl, ngModuleByPipeOrDirective, directives, pipes, ngModules, injectables) {
  30642. var _this = this;
  30643. var /** @type {?} */ fileSuffix = normalizeGenFileSuffix(splitTypescriptSuffix(srcFileUrl, true)[1]);
  30644. var /** @type {?} */ generatedFiles = [];
  30645. var /** @type {?} */ outputCtx = this._createOutputContext(ngfactoryFilePath(srcFileUrl, true));
  30646. generatedFiles.push.apply(generatedFiles, this._createSummary(srcFileUrl, directives, pipes, ngModules, injectables, outputCtx));
  30647. // compile all ng modules
  30648. ngModules.forEach(function (ngModuleMeta) { return _this._compileModule(outputCtx, ngModuleMeta); });
  30649. // compile components
  30650. directives.forEach(function (dirType) {
  30651. var /** @type {?} */ compMeta = _this._metadataResolver.getDirectiveMetadata(/** @type {?} */ (dirType));
  30652. if (!compMeta.isComponent) {
  30653. return;
  30654. }
  30655. var /** @type {?} */ ngModule = ngModuleByPipeOrDirective.get(dirType);
  30656. if (!ngModule) {
  30657. throw new Error("Internal Error: cannot determine the module for component " + identifierName(compMeta.type) + "!");
  30658. }
  30659. // compile styles
  30660. var /** @type {?} */ componentStylesheet = _this._styleCompiler.compileComponent(outputCtx, compMeta); /** @type {?} */
  30661. ((
  30662. // Note: compMeta is a component and therefore template is non null.
  30663. compMeta.template)).externalStylesheets.forEach(function (stylesheetMeta) {
  30664. // Note: fill non shim and shim style files as they might
  30665. // be shared by component with and without ViewEncapsulation.
  30666. var /** @type {?} */ shim = _this._styleCompiler.needsStyleShim(compMeta);
  30667. generatedFiles.push(_this._codegenStyles(srcFileUrl, compMeta, stylesheetMeta, shim, fileSuffix));
  30668. if (_this._options.allowEmptyCodegenFiles) {
  30669. generatedFiles.push(_this._codegenStyles(srcFileUrl, compMeta, stylesheetMeta, !shim, fileSuffix));
  30670. }
  30671. });
  30672. // compile components
  30673. var /** @type {?} */ compViewVars = _this._compileComponent(outputCtx, compMeta, ngModule, ngModule.transitiveModule.directives, componentStylesheet, fileSuffix);
  30674. _this._compileComponentFactory(outputCtx, compMeta, ngModule, fileSuffix);
  30675. });
  30676. if (outputCtx.statements.length > 0 || this._options.allowEmptyCodegenFiles) {
  30677. var /** @type {?} */ srcModule = this._codegenSourceModule(srcFileUrl, outputCtx);
  30678. generatedFiles.unshift(srcModule);
  30679. }
  30680. return generatedFiles;
  30681. };
  30682. /**
  30683. * @param {?} srcFileName
  30684. * @param {?} directives
  30685. * @param {?} pipes
  30686. * @param {?} ngModules
  30687. * @param {?} injectables
  30688. * @param {?} ngFactoryCtx
  30689. * @return {?}
  30690. */
  30691. AotCompiler.prototype._createSummary = /**
  30692. * @param {?} srcFileName
  30693. * @param {?} directives
  30694. * @param {?} pipes
  30695. * @param {?} ngModules
  30696. * @param {?} injectables
  30697. * @param {?} ngFactoryCtx
  30698. * @return {?}
  30699. */
  30700. function (srcFileName, directives, pipes, ngModules, injectables, ngFactoryCtx) {
  30701. var _this = this;
  30702. var /** @type {?} */ symbolSummaries = this._symbolResolver.getSymbolsOf(srcFileName)
  30703. .map(function (symbol) { return _this._symbolResolver.resolveSymbol(symbol); });
  30704. var /** @type {?} */ typeData = ngModules.map(function (meta) {
  30705. return ({
  30706. summary: /** @type {?} */ ((_this._metadataResolver.getNgModuleSummary(meta.type.reference))),
  30707. metadata: /** @type {?} */ ((_this._metadataResolver.getNgModuleMetadata(meta.type.reference)))
  30708. });
  30709. }).concat(directives.map(function (ref) {
  30710. return ({
  30711. summary: /** @type {?} */ ((_this._metadataResolver.getDirectiveSummary(ref))),
  30712. metadata: /** @type {?} */ ((_this._metadataResolver.getDirectiveMetadata(ref)))
  30713. });
  30714. }), pipes.map(function (ref) {
  30715. return ({
  30716. summary: /** @type {?} */ ((_this._metadataResolver.getPipeSummary(ref))),
  30717. metadata: /** @type {?} */ ((_this._metadataResolver.getPipeMetadata(ref)))
  30718. });
  30719. }), injectables.map(function (ref) {
  30720. return ({
  30721. summary: /** @type {?} */ ((_this._metadataResolver.getInjectableSummary(ref))),
  30722. metadata: /** @type {?} */ ((_this._metadataResolver.getInjectableSummary(ref))).type
  30723. });
  30724. }));
  30725. var /** @type {?} */ forJitOutputCtx = this._options.enableSummariesForJit ?
  30726. this._createOutputContext(summaryForJitFileName(srcFileName, true)) :
  30727. null;
  30728. var _a = serializeSummaries(srcFileName, forJitOutputCtx, this._summaryResolver, this._symbolResolver, symbolSummaries, typeData), json = _a.json, exportAs = _a.exportAs;
  30729. exportAs.forEach(function (entry) {
  30730. ngFactoryCtx.statements.push(variable(entry.exportAs).set(ngFactoryCtx.importExpr(entry.symbol)).toDeclStmt(null, [
  30731. StmtModifier.Exported
  30732. ]));
  30733. });
  30734. var /** @type {?} */ summaryJson = new GeneratedFile(srcFileName, summaryFileName(srcFileName), json);
  30735. var /** @type {?} */ result = [summaryJson];
  30736. if (forJitOutputCtx) {
  30737. result.push(this._codegenSourceModule(srcFileName, forJitOutputCtx));
  30738. }
  30739. return result;
  30740. };
  30741. /**
  30742. * @param {?} outputCtx
  30743. * @param {?} ngModule
  30744. * @return {?}
  30745. */
  30746. AotCompiler.prototype._compileModule = /**
  30747. * @param {?} outputCtx
  30748. * @param {?} ngModule
  30749. * @return {?}
  30750. */
  30751. function (outputCtx, ngModule) {
  30752. var /** @type {?} */ providers = [];
  30753. if (this._options.locale) {
  30754. var /** @type {?} */ normalizedLocale = this._options.locale.replace(/_/g, '-');
  30755. providers.push({
  30756. token: createTokenForExternalReference(this._reflector, Identifiers.LOCALE_ID),
  30757. useValue: normalizedLocale,
  30758. });
  30759. }
  30760. if (this._options.i18nFormat) {
  30761. providers.push({
  30762. token: createTokenForExternalReference(this._reflector, Identifiers.TRANSLATIONS_FORMAT),
  30763. useValue: this._options.i18nFormat
  30764. });
  30765. }
  30766. this._ngModuleCompiler.compile(outputCtx, ngModule, providers);
  30767. };
  30768. /**
  30769. * @param {?} outputCtx
  30770. * @param {?} compMeta
  30771. * @param {?} ngModule
  30772. * @param {?} fileSuffix
  30773. * @return {?}
  30774. */
  30775. AotCompiler.prototype._compileComponentFactory = /**
  30776. * @param {?} outputCtx
  30777. * @param {?} compMeta
  30778. * @param {?} ngModule
  30779. * @param {?} fileSuffix
  30780. * @return {?}
  30781. */
  30782. function (outputCtx, compMeta, ngModule, fileSuffix) {
  30783. var /** @type {?} */ hostMeta = this._metadataResolver.getHostComponentMetadata(compMeta);
  30784. var /** @type {?} */ hostViewFactoryVar = this._compileComponent(outputCtx, hostMeta, ngModule, [compMeta.type], null, fileSuffix)
  30785. .viewClassVar;
  30786. var /** @type {?} */ compFactoryVar = componentFactoryName(compMeta.type.reference);
  30787. var /** @type {?} */ inputsExprs = [];
  30788. for (var /** @type {?} */ propName in compMeta.inputs) {
  30789. var /** @type {?} */ templateName = compMeta.inputs[propName];
  30790. // Don't quote so that the key gets minified...
  30791. inputsExprs.push(new LiteralMapEntry(propName, literal(templateName), false));
  30792. }
  30793. var /** @type {?} */ outputsExprs = [];
  30794. for (var /** @type {?} */ propName in compMeta.outputs) {
  30795. var /** @type {?} */ templateName = compMeta.outputs[propName];
  30796. // Don't quote so that the key gets minified...
  30797. outputsExprs.push(new LiteralMapEntry(propName, literal(templateName), false));
  30798. }
  30799. outputCtx.statements.push(variable(compFactoryVar)
  30800. .set(importExpr(Identifiers.createComponentFactory).callFn([
  30801. literal(compMeta.selector), outputCtx.importExpr(compMeta.type.reference),
  30802. variable(hostViewFactoryVar), new LiteralMapExpr(inputsExprs),
  30803. new LiteralMapExpr(outputsExprs),
  30804. literalArr(/** @type {?} */ ((compMeta.template)).ngContentSelectors.map(function (selector) { return literal(selector); }))
  30805. ]))
  30806. .toDeclStmt(importType(Identifiers.ComponentFactory, [/** @type {?} */ ((expressionType(outputCtx.importExpr(compMeta.type.reference))))], [TypeModifier.Const]), [StmtModifier.Final, StmtModifier.Exported]));
  30807. };
  30808. /**
  30809. * @param {?} outputCtx
  30810. * @param {?} compMeta
  30811. * @param {?} ngModule
  30812. * @param {?} directiveIdentifiers
  30813. * @param {?} componentStyles
  30814. * @param {?} fileSuffix
  30815. * @return {?}
  30816. */
  30817. AotCompiler.prototype._compileComponent = /**
  30818. * @param {?} outputCtx
  30819. * @param {?} compMeta
  30820. * @param {?} ngModule
  30821. * @param {?} directiveIdentifiers
  30822. * @param {?} componentStyles
  30823. * @param {?} fileSuffix
  30824. * @return {?}
  30825. */
  30826. function (outputCtx, compMeta, ngModule, directiveIdentifiers, componentStyles, fileSuffix) {
  30827. var _a = this._parseTemplate(compMeta, ngModule, directiveIdentifiers), parsedTemplate = _a.template, usedPipes = _a.pipes;
  30828. var /** @type {?} */ stylesExpr = componentStyles ? variable(componentStyles.stylesVar) : literalArr([]);
  30829. var /** @type {?} */ viewResult = this._viewCompiler.compileComponent(outputCtx, compMeta, parsedTemplate, stylesExpr, usedPipes);
  30830. if (componentStyles) {
  30831. _resolveStyleStatements(this._symbolResolver, componentStyles, this._styleCompiler.needsStyleShim(compMeta), fileSuffix);
  30832. }
  30833. return viewResult;
  30834. };
  30835. /**
  30836. * @param {?} compMeta
  30837. * @param {?} ngModule
  30838. * @param {?} directiveIdentifiers
  30839. * @return {?}
  30840. */
  30841. AotCompiler.prototype._parseTemplate = /**
  30842. * @param {?} compMeta
  30843. * @param {?} ngModule
  30844. * @param {?} directiveIdentifiers
  30845. * @return {?}
  30846. */
  30847. function (compMeta, ngModule, directiveIdentifiers) {
  30848. var _this = this;
  30849. if (this._templateAstCache.has(compMeta.type.reference)) {
  30850. return /** @type {?} */ ((this._templateAstCache.get(compMeta.type.reference)));
  30851. }
  30852. var /** @type {?} */ preserveWhitespaces = /** @type {?} */ ((/** @type {?} */ ((compMeta)).template)).preserveWhitespaces;
  30853. var /** @type {?} */ directives = directiveIdentifiers.map(function (dir) { return _this._metadataResolver.getDirectiveSummary(dir.reference); });
  30854. var /** @type {?} */ pipes = ngModule.transitiveModule.pipes.map(function (pipe) { return _this._metadataResolver.getPipeSummary(pipe.reference); });
  30855. var /** @type {?} */ result = this._templateParser.parse(compMeta, /** @type {?} */ ((/** @type {?} */ ((compMeta.template)).htmlAst)), directives, pipes, ngModule.schemas, templateSourceUrl(ngModule.type, compMeta, /** @type {?} */ ((compMeta.template))), preserveWhitespaces);
  30856. this._templateAstCache.set(compMeta.type.reference, result);
  30857. return result;
  30858. };
  30859. /**
  30860. * @param {?} genFilePath
  30861. * @return {?}
  30862. */
  30863. AotCompiler.prototype._createOutputContext = /**
  30864. * @param {?} genFilePath
  30865. * @return {?}
  30866. */
  30867. function (genFilePath) {
  30868. var _this = this;
  30869. var /** @type {?} */ importExpr$$1 = function (symbol, typeParams, useSummaries) {
  30870. if (typeParams === void 0) { typeParams = null; }
  30871. if (useSummaries === void 0) { useSummaries = true; }
  30872. if (!(symbol instanceof StaticSymbol)) {
  30873. throw new Error("Internal error: unknown identifier " + JSON.stringify(symbol));
  30874. }
  30875. var /** @type {?} */ arity = _this._symbolResolver.getTypeArity(symbol) || 0;
  30876. var _a = _this._symbolResolver.getImportAs(symbol, useSummaries) || symbol, filePath = _a.filePath, name = _a.name, members = _a.members;
  30877. var /** @type {?} */ importModule = _this._fileNameToModuleName(filePath, genFilePath);
  30878. // It should be good enough to compare filePath to genFilePath and if they are equal
  30879. // there is a self reference. However, ngfactory files generate to .ts but their
  30880. // symbols have .d.ts so a simple compare is insufficient. They should be canonical
  30881. // and is tracked by #17705.
  30882. var /** @type {?} */ selfReference = _this._fileNameToModuleName(genFilePath, genFilePath);
  30883. var /** @type {?} */ moduleName = importModule === selfReference ? null : importModule;
  30884. // If we are in a type expression that refers to a generic type then supply
  30885. // the required type parameters. If there were not enough type parameters
  30886. // supplied, supply any as the type. Outside a type expression the reference
  30887. // should not supply type parameters and be treated as a simple value reference
  30888. // to the constructor function itself.
  30889. var /** @type {?} */ suppliedTypeParams = typeParams || [];
  30890. var /** @type {?} */ missingTypeParamsCount = arity - suppliedTypeParams.length;
  30891. var /** @type {?} */ allTypeParams = suppliedTypeParams.concat(new Array(missingTypeParamsCount).fill(DYNAMIC_TYPE));
  30892. return members.reduce(function (expr, memberName) { return expr.prop(memberName); }, /** @type {?} */ (importExpr(new ExternalReference(moduleName, name, null), allTypeParams)));
  30893. };
  30894. return { statements: [], genFilePath: genFilePath, importExpr: importExpr$$1 };
  30895. };
  30896. /**
  30897. * @param {?} importedFilePath
  30898. * @param {?} containingFilePath
  30899. * @return {?}
  30900. */
  30901. AotCompiler.prototype._fileNameToModuleName = /**
  30902. * @param {?} importedFilePath
  30903. * @param {?} containingFilePath
  30904. * @return {?}
  30905. */
  30906. function (importedFilePath, containingFilePath) {
  30907. return this._summaryResolver.getKnownModuleName(importedFilePath) ||
  30908. this._symbolResolver.getKnownModuleName(importedFilePath) ||
  30909. this._host.fileNameToModuleName(importedFilePath, containingFilePath);
  30910. };
  30911. /**
  30912. * @param {?} srcFileUrl
  30913. * @param {?} compMeta
  30914. * @param {?} stylesheetMetadata
  30915. * @param {?} isShimmed
  30916. * @param {?} fileSuffix
  30917. * @return {?}
  30918. */
  30919. AotCompiler.prototype._codegenStyles = /**
  30920. * @param {?} srcFileUrl
  30921. * @param {?} compMeta
  30922. * @param {?} stylesheetMetadata
  30923. * @param {?} isShimmed
  30924. * @param {?} fileSuffix
  30925. * @return {?}
  30926. */
  30927. function (srcFileUrl, compMeta, stylesheetMetadata, isShimmed, fileSuffix) {
  30928. var /** @type {?} */ outputCtx = this._createOutputContext(_stylesModuleUrl(/** @type {?} */ ((stylesheetMetadata.moduleUrl)), isShimmed, fileSuffix));
  30929. var /** @type {?} */ compiledStylesheet = this._styleCompiler.compileStyles(outputCtx, compMeta, stylesheetMetadata, isShimmed);
  30930. _resolveStyleStatements(this._symbolResolver, compiledStylesheet, isShimmed, fileSuffix);
  30931. return this._codegenSourceModule(srcFileUrl, outputCtx);
  30932. };
  30933. /**
  30934. * @param {?} srcFileUrl
  30935. * @param {?} ctx
  30936. * @return {?}
  30937. */
  30938. AotCompiler.prototype._codegenSourceModule = /**
  30939. * @param {?} srcFileUrl
  30940. * @param {?} ctx
  30941. * @return {?}
  30942. */
  30943. function (srcFileUrl, ctx) {
  30944. return new GeneratedFile(srcFileUrl, ctx.genFilePath, ctx.statements);
  30945. };
  30946. /**
  30947. * @param {?=} entryRoute
  30948. * @param {?=} analyzedModules
  30949. * @return {?}
  30950. */
  30951. AotCompiler.prototype.listLazyRoutes = /**
  30952. * @param {?=} entryRoute
  30953. * @param {?=} analyzedModules
  30954. * @return {?}
  30955. */
  30956. function (entryRoute, analyzedModules) {
  30957. var /** @type {?} */ self = this;
  30958. if (entryRoute) {
  30959. var /** @type {?} */ symbol = parseLazyRoute(entryRoute, this._reflector).referencedModule;
  30960. return visitLazyRoute(symbol);
  30961. }
  30962. else if (analyzedModules) {
  30963. var /** @type {?} */ allLazyRoutes = [];
  30964. for (var _i = 0, _a = analyzedModules.ngModules; _i < _a.length; _i++) {
  30965. var ngModule = _a[_i];
  30966. var /** @type {?} */ lazyRoutes = listLazyRoutes(ngModule, this._reflector);
  30967. for (var _b = 0, lazyRoutes_1 = lazyRoutes; _b < lazyRoutes_1.length; _b++) {
  30968. var lazyRoute = lazyRoutes_1[_b];
  30969. allLazyRoutes.push(lazyRoute);
  30970. }
  30971. }
  30972. return allLazyRoutes;
  30973. }
  30974. else {
  30975. throw new Error("Either route or analyzedModules has to be specified!");
  30976. }
  30977. /**
  30978. * @param {?} symbol
  30979. * @param {?=} seenRoutes
  30980. * @param {?=} allLazyRoutes
  30981. * @return {?}
  30982. */
  30983. function visitLazyRoute(symbol, seenRoutes, allLazyRoutes) {
  30984. if (seenRoutes === void 0) { seenRoutes = new Set(); }
  30985. if (allLazyRoutes === void 0) { allLazyRoutes = []; }
  30986. // Support pointing to default exports, but stop recursing there,
  30987. // as the StaticReflector does not yet support default exports.
  30988. if (seenRoutes.has(symbol) || !symbol.name) {
  30989. return allLazyRoutes;
  30990. }
  30991. seenRoutes.add(symbol);
  30992. var /** @type {?} */ lazyRoutes = listLazyRoutes(/** @type {?} */ ((self._metadataResolver.getNgModuleMetadata(symbol, true))), self._reflector);
  30993. for (var _i = 0, lazyRoutes_2 = lazyRoutes; _i < lazyRoutes_2.length; _i++) {
  30994. var lazyRoute = lazyRoutes_2[_i];
  30995. allLazyRoutes.push(lazyRoute);
  30996. visitLazyRoute(lazyRoute.referencedModule, seenRoutes, allLazyRoutes);
  30997. }
  30998. return allLazyRoutes;
  30999. }
  31000. };
  31001. return AotCompiler;
  31002. }());
  31003. /**
  31004. * @param {?} outputCtx
  31005. * @return {?}
  31006. */
  31007. function _createEmptyStub(outputCtx) {
  31008. // Note: We need to produce at least one import statement so that
  31009. // TypeScript knows that the file is an es6 module. Otherwise our generated
  31010. // exports / imports won't be emitted properly by TypeScript.
  31011. outputCtx.statements.push(importExpr(Identifiers.ComponentFactory).toStmt());
  31012. }
  31013. /**
  31014. * @param {?} symbolResolver
  31015. * @param {?} compileResult
  31016. * @param {?} needsShim
  31017. * @param {?} fileSuffix
  31018. * @return {?}
  31019. */
  31020. function _resolveStyleStatements(symbolResolver, compileResult, needsShim, fileSuffix) {
  31021. compileResult.dependencies.forEach(function (dep) {
  31022. dep.setValue(symbolResolver.getStaticSymbol(_stylesModuleUrl(dep.moduleUrl, needsShim, fileSuffix), dep.name));
  31023. });
  31024. }
  31025. /**
  31026. * @param {?} stylesheetUrl
  31027. * @param {?} shim
  31028. * @param {?} suffix
  31029. * @return {?}
  31030. */
  31031. function _stylesModuleUrl(stylesheetUrl, shim, suffix) {
  31032. return "" + stylesheetUrl + (shim ? '.shim' : '') + ".ngstyle" + suffix;
  31033. }
  31034. /**
  31035. * @record
  31036. */
  31037. /**
  31038. * @record
  31039. */
  31040. /**
  31041. * @record
  31042. */
  31043. /**
  31044. * @param {?} fileNames
  31045. * @param {?} host
  31046. * @param {?} staticSymbolResolver
  31047. * @param {?} metadataResolver
  31048. * @return {?}
  31049. */
  31050. function analyzeNgModules(fileNames, host, staticSymbolResolver, metadataResolver) {
  31051. var /** @type {?} */ files = _analyzeFilesIncludingNonProgramFiles(fileNames, host, staticSymbolResolver, metadataResolver);
  31052. return mergeAnalyzedFiles(files);
  31053. }
  31054. /**
  31055. * @param {?} fileNames
  31056. * @param {?} host
  31057. * @param {?} staticSymbolResolver
  31058. * @param {?} metadataResolver
  31059. * @return {?}
  31060. */
  31061. function analyzeAndValidateNgModules(fileNames, host, staticSymbolResolver, metadataResolver) {
  31062. return validateAnalyzedModules(analyzeNgModules(fileNames, host, staticSymbolResolver, metadataResolver));
  31063. }
  31064. /**
  31065. * @param {?} analyzedModules
  31066. * @return {?}
  31067. */
  31068. function validateAnalyzedModules(analyzedModules) {
  31069. if (analyzedModules.symbolsMissingModule && analyzedModules.symbolsMissingModule.length) {
  31070. var /** @type {?} */ messages = analyzedModules.symbolsMissingModule.map(function (s) {
  31071. return "Cannot determine the module for class " + s.name + " in " + s.filePath + "! Add " + s.name + " to the NgModule to fix it.";
  31072. });
  31073. throw syntaxError(messages.join('\n'));
  31074. }
  31075. return analyzedModules;
  31076. }
  31077. /**
  31078. * @param {?} fileNames
  31079. * @param {?} host
  31080. * @param {?} staticSymbolResolver
  31081. * @param {?} metadataResolver
  31082. * @return {?}
  31083. */
  31084. function _analyzeFilesIncludingNonProgramFiles(fileNames, host, staticSymbolResolver, metadataResolver) {
  31085. var /** @type {?} */ seenFiles = new Set();
  31086. var /** @type {?} */ files = [];
  31087. var /** @type {?} */ visitFile = function (fileName) {
  31088. if (seenFiles.has(fileName) || !host.isSourceFile(fileName)) {
  31089. return false;
  31090. }
  31091. seenFiles.add(fileName);
  31092. var /** @type {?} */ analyzedFile = analyzeFile(host, staticSymbolResolver, metadataResolver, fileName);
  31093. files.push(analyzedFile);
  31094. analyzedFile.ngModules.forEach(function (ngModule) {
  31095. ngModule.transitiveModule.modules.forEach(function (modMeta) { return visitFile(modMeta.reference.filePath); });
  31096. });
  31097. };
  31098. fileNames.forEach(function (fileName) { return visitFile(fileName); });
  31099. return files;
  31100. }
  31101. /**
  31102. * @param {?} host
  31103. * @param {?} staticSymbolResolver
  31104. * @param {?} metadataResolver
  31105. * @param {?} fileName
  31106. * @return {?}
  31107. */
  31108. function analyzeFile(host, staticSymbolResolver, metadataResolver, fileName) {
  31109. var /** @type {?} */ directives = [];
  31110. var /** @type {?} */ pipes = [];
  31111. var /** @type {?} */ injectables = [];
  31112. var /** @type {?} */ ngModules = [];
  31113. var /** @type {?} */ hasDecorators = staticSymbolResolver.hasDecorators(fileName);
  31114. var /** @type {?} */ exportsNonSourceFiles = false;
  31115. // Don't analyze .d.ts files that have no decorators as a shortcut
  31116. // to speed up the analysis. This prevents us from
  31117. // resolving the references in these files.
  31118. // Note: exportsNonSourceFiles is only needed when compiling with summaries,
  31119. // which is not the case when .d.ts files are treated as input files.
  31120. if (!fileName.endsWith('.d.ts') || hasDecorators) {
  31121. staticSymbolResolver.getSymbolsOf(fileName).forEach(function (symbol) {
  31122. var /** @type {?} */ resolvedSymbol = staticSymbolResolver.resolveSymbol(symbol);
  31123. var /** @type {?} */ symbolMeta = resolvedSymbol.metadata;
  31124. if (!symbolMeta || symbolMeta.__symbolic === 'error') {
  31125. return;
  31126. }
  31127. var /** @type {?} */ isNgSymbol = false;
  31128. if (symbolMeta.__symbolic === 'class') {
  31129. if (metadataResolver.isDirective(symbol)) {
  31130. isNgSymbol = true;
  31131. directives.push(symbol);
  31132. }
  31133. else if (metadataResolver.isPipe(symbol)) {
  31134. isNgSymbol = true;
  31135. pipes.push(symbol);
  31136. }
  31137. else if (metadataResolver.isNgModule(symbol)) {
  31138. var /** @type {?} */ ngModule = metadataResolver.getNgModuleMetadata(symbol, false);
  31139. if (ngModule) {
  31140. isNgSymbol = true;
  31141. ngModules.push(ngModule);
  31142. }
  31143. }
  31144. else if (metadataResolver.isInjectable(symbol)) {
  31145. isNgSymbol = true;
  31146. injectables.push(symbol);
  31147. }
  31148. }
  31149. if (!isNgSymbol) {
  31150. exportsNonSourceFiles =
  31151. exportsNonSourceFiles || isValueExportingNonSourceFile(host, symbolMeta);
  31152. }
  31153. });
  31154. }
  31155. return {
  31156. fileName: fileName, directives: directives, pipes: pipes, ngModules: ngModules, injectables: injectables, exportsNonSourceFiles: exportsNonSourceFiles,
  31157. };
  31158. }
  31159. /**
  31160. * @param {?} host
  31161. * @param {?} metadata
  31162. * @return {?}
  31163. */
  31164. function isValueExportingNonSourceFile(host, metadata) {
  31165. var /** @type {?} */ exportsNonSourceFiles = false;
  31166. var Visitor = /** @class */ (function () {
  31167. function Visitor() {
  31168. }
  31169. /**
  31170. * @param {?} arr
  31171. * @param {?} context
  31172. * @return {?}
  31173. */
  31174. Visitor.prototype.visitArray = /**
  31175. * @param {?} arr
  31176. * @param {?} context
  31177. * @return {?}
  31178. */
  31179. function (arr, context) {
  31180. var _this = this;
  31181. arr.forEach(function (v) { return visitValue(v, _this, context); });
  31182. };
  31183. /**
  31184. * @param {?} map
  31185. * @param {?} context
  31186. * @return {?}
  31187. */
  31188. Visitor.prototype.visitStringMap = /**
  31189. * @param {?} map
  31190. * @param {?} context
  31191. * @return {?}
  31192. */
  31193. function (map, context) {
  31194. var _this = this;
  31195. Object.keys(map).forEach(function (key) { return visitValue(map[key], _this, context); });
  31196. };
  31197. /**
  31198. * @param {?} value
  31199. * @param {?} context
  31200. * @return {?}
  31201. */
  31202. Visitor.prototype.visitPrimitive = /**
  31203. * @param {?} value
  31204. * @param {?} context
  31205. * @return {?}
  31206. */
  31207. function (value, context) { };
  31208. /**
  31209. * @param {?} value
  31210. * @param {?} context
  31211. * @return {?}
  31212. */
  31213. Visitor.prototype.visitOther = /**
  31214. * @param {?} value
  31215. * @param {?} context
  31216. * @return {?}
  31217. */
  31218. function (value, context) {
  31219. if (value instanceof StaticSymbol && !host.isSourceFile(value.filePath)) {
  31220. exportsNonSourceFiles = true;
  31221. }
  31222. };
  31223. return Visitor;
  31224. }());
  31225. visitValue(metadata, new Visitor(), null);
  31226. return exportsNonSourceFiles;
  31227. }
  31228. /**
  31229. * @param {?} analyzedFiles
  31230. * @return {?}
  31231. */
  31232. function mergeAnalyzedFiles(analyzedFiles) {
  31233. var /** @type {?} */ allNgModules = [];
  31234. var /** @type {?} */ ngModuleByPipeOrDirective = new Map();
  31235. var /** @type {?} */ allPipesAndDirectives = new Set();
  31236. analyzedFiles.forEach(function (af) {
  31237. af.ngModules.forEach(function (ngModule) {
  31238. allNgModules.push(ngModule);
  31239. ngModule.declaredDirectives.forEach(function (d) { return ngModuleByPipeOrDirective.set(d.reference, ngModule); });
  31240. ngModule.declaredPipes.forEach(function (p) { return ngModuleByPipeOrDirective.set(p.reference, ngModule); });
  31241. });
  31242. af.directives.forEach(function (d) { return allPipesAndDirectives.add(d); });
  31243. af.pipes.forEach(function (p) { return allPipesAndDirectives.add(p); });
  31244. });
  31245. var /** @type {?} */ symbolsMissingModule = [];
  31246. allPipesAndDirectives.forEach(function (ref) {
  31247. if (!ngModuleByPipeOrDirective.has(ref)) {
  31248. symbolsMissingModule.push(ref);
  31249. }
  31250. });
  31251. return {
  31252. ngModules: allNgModules,
  31253. ngModuleByPipeOrDirective: ngModuleByPipeOrDirective,
  31254. symbolsMissingModule: symbolsMissingModule,
  31255. files: analyzedFiles
  31256. };
  31257. }
  31258. /**
  31259. * @param {?} files
  31260. * @return {?}
  31261. */
  31262. function mergeAndValidateNgFiles(files) {
  31263. return validateAnalyzedModules(mergeAnalyzedFiles(files));
  31264. }
  31265. /**
  31266. * @fileoverview added by tsickle
  31267. * @suppress {checkTypes} checked by tsc
  31268. */
  31269. /**
  31270. * @license
  31271. * Copyright Google Inc. All Rights Reserved.
  31272. *
  31273. * Use of this source code is governed by an MIT-style license that can be
  31274. * found in the LICENSE file at https://angular.io/license
  31275. */
  31276. /**
  31277. * @record
  31278. */
  31279. /**
  31280. * @record
  31281. */
  31282. var FORMATTED_MESSAGE = 'ngFormattedMessage';
  31283. /**
  31284. * @param {?} level
  31285. * @return {?}
  31286. */
  31287. function indentStr(level) {
  31288. if (level <= 0)
  31289. return '';
  31290. if (level < 6)
  31291. return ['', ' ', ' ', ' ', ' ', ' '][level];
  31292. var /** @type {?} */ half = indentStr(Math.floor(level / 2));
  31293. return half + half + (level % 2 === 1 ? ' ' : '');
  31294. }
  31295. /**
  31296. * @param {?} chain
  31297. * @param {?=} indent
  31298. * @return {?}
  31299. */
  31300. function formatChain(chain, indent) {
  31301. if (indent === void 0) { indent = 0; }
  31302. if (!chain)
  31303. return '';
  31304. var /** @type {?} */ position = chain.position ?
  31305. chain.position.fileName + "(" + (chain.position.line + 1) + "," + (chain.position.column + 1) + ")" :
  31306. '';
  31307. var /** @type {?} */ prefix = position && indent === 0 ? position + ": " : '';
  31308. var /** @type {?} */ postfix = position && indent !== 0 ? " at " + position : '';
  31309. var /** @type {?} */ message = "" + prefix + chain.message + postfix;
  31310. return "" + indentStr(indent) + message + ((chain.next && ('\n' + formatChain(chain.next, indent + 2))) || '');
  31311. }
  31312. /**
  31313. * @param {?} chain
  31314. * @return {?}
  31315. */
  31316. function formattedError(chain) {
  31317. var /** @type {?} */ message = formatChain(chain) + '.';
  31318. var /** @type {?} */ error = /** @type {?} */ (syntaxError(message));
  31319. (/** @type {?} */ (error))[FORMATTED_MESSAGE] = true;
  31320. error.chain = chain;
  31321. error.position = chain.position;
  31322. return error;
  31323. }
  31324. /**
  31325. * @param {?} error
  31326. * @return {?}
  31327. */
  31328. function isFormattedError(error) {
  31329. return !!(/** @type {?} */ (error))[FORMATTED_MESSAGE];
  31330. }
  31331. /**
  31332. * @fileoverview added by tsickle
  31333. * @suppress {checkTypes} checked by tsc
  31334. */
  31335. /**
  31336. * @license
  31337. * Copyright Google Inc. All Rights Reserved.
  31338. *
  31339. * Use of this source code is governed by an MIT-style license that can be
  31340. * found in the LICENSE file at https://angular.io/license
  31341. */
  31342. var ANGULAR_CORE = '@angular/core';
  31343. var ANGULAR_ROUTER = '@angular/router';
  31344. var HIDDEN_KEY = /^\$.*\$$/;
  31345. var IGNORE = {
  31346. __symbolic: 'ignore'
  31347. };
  31348. var USE_VALUE = 'useValue';
  31349. var PROVIDE = 'provide';
  31350. var REFERENCE_SET = new Set([USE_VALUE, 'useFactory', 'data']);
  31351. var TYPEGUARD_POSTFIX = 'TypeGuard';
  31352. var USE_IF = 'UseIf';
  31353. /**
  31354. * @param {?} value
  31355. * @return {?}
  31356. */
  31357. function shouldIgnore(value) {
  31358. return value && value.__symbolic == 'ignore';
  31359. }
  31360. /**
  31361. * A static reflector implements enough of the Reflector API that is necessary to compile
  31362. * templates statically.
  31363. */
  31364. var StaticReflector = /** @class */ (function () {
  31365. function StaticReflector(summaryResolver, symbolResolver, knownMetadataClasses, knownMetadataFunctions, errorRecorder) {
  31366. if (knownMetadataClasses === void 0) { knownMetadataClasses = []; }
  31367. if (knownMetadataFunctions === void 0) { knownMetadataFunctions = []; }
  31368. var _this = this;
  31369. this.summaryResolver = summaryResolver;
  31370. this.symbolResolver = symbolResolver;
  31371. this.errorRecorder = errorRecorder;
  31372. this.annotationCache = new Map();
  31373. this.propertyCache = new Map();
  31374. this.parameterCache = new Map();
  31375. this.methodCache = new Map();
  31376. this.staticCache = new Map();
  31377. this.conversionMap = new Map();
  31378. this.resolvedExternalReferences = new Map();
  31379. this.annotationForParentClassWithSummaryKind = new Map();
  31380. this.initializeConversionMap();
  31381. knownMetadataClasses.forEach(function (kc) {
  31382. return _this._registerDecoratorOrConstructor(_this.getStaticSymbol(kc.filePath, kc.name), kc.ctor);
  31383. });
  31384. knownMetadataFunctions.forEach(function (kf) { return _this._registerFunction(_this.getStaticSymbol(kf.filePath, kf.name), kf.fn); });
  31385. this.annotationForParentClassWithSummaryKind.set(CompileSummaryKind.Directive, [createDirective, createComponent]);
  31386. this.annotationForParentClassWithSummaryKind.set(CompileSummaryKind.Pipe, [createPipe]);
  31387. this.annotationForParentClassWithSummaryKind.set(CompileSummaryKind.NgModule, [createNgModule]);
  31388. this.annotationForParentClassWithSummaryKind.set(CompileSummaryKind.Injectable, [createInjectable, createPipe, createDirective, createComponent, createNgModule]);
  31389. }
  31390. /**
  31391. * @param {?} typeOrFunc
  31392. * @return {?}
  31393. */
  31394. StaticReflector.prototype.componentModuleUrl = /**
  31395. * @param {?} typeOrFunc
  31396. * @return {?}
  31397. */
  31398. function (typeOrFunc) {
  31399. var /** @type {?} */ staticSymbol = this.findSymbolDeclaration(typeOrFunc);
  31400. return this.symbolResolver.getResourcePath(staticSymbol);
  31401. };
  31402. /**
  31403. * @param {?} ref
  31404. * @param {?=} containingFile
  31405. * @return {?}
  31406. */
  31407. StaticReflector.prototype.resolveExternalReference = /**
  31408. * @param {?} ref
  31409. * @param {?=} containingFile
  31410. * @return {?}
  31411. */
  31412. function (ref, containingFile) {
  31413. var /** @type {?} */ key = undefined;
  31414. if (!containingFile) {
  31415. key = ref.moduleName + ":" + ref.name;
  31416. var /** @type {?} */ declarationSymbol_1 = this.resolvedExternalReferences.get(key);
  31417. if (declarationSymbol_1)
  31418. return declarationSymbol_1;
  31419. }
  31420. var /** @type {?} */ refSymbol = this.symbolResolver.getSymbolByModule(/** @type {?} */ ((ref.moduleName)), /** @type {?} */ ((ref.name)), containingFile);
  31421. var /** @type {?} */ declarationSymbol = this.findSymbolDeclaration(refSymbol);
  31422. if (!containingFile) {
  31423. this.symbolResolver.recordModuleNameForFileName(refSymbol.filePath, /** @type {?} */ ((ref.moduleName)));
  31424. this.symbolResolver.recordImportAs(declarationSymbol, refSymbol);
  31425. }
  31426. if (key) {
  31427. this.resolvedExternalReferences.set(key, declarationSymbol);
  31428. }
  31429. return declarationSymbol;
  31430. };
  31431. /**
  31432. * @param {?} moduleUrl
  31433. * @param {?} name
  31434. * @param {?=} containingFile
  31435. * @return {?}
  31436. */
  31437. StaticReflector.prototype.findDeclaration = /**
  31438. * @param {?} moduleUrl
  31439. * @param {?} name
  31440. * @param {?=} containingFile
  31441. * @return {?}
  31442. */
  31443. function (moduleUrl, name, containingFile) {
  31444. return this.findSymbolDeclaration(this.symbolResolver.getSymbolByModule(moduleUrl, name, containingFile));
  31445. };
  31446. /**
  31447. * @param {?} moduleUrl
  31448. * @param {?} name
  31449. * @return {?}
  31450. */
  31451. StaticReflector.prototype.tryFindDeclaration = /**
  31452. * @param {?} moduleUrl
  31453. * @param {?} name
  31454. * @return {?}
  31455. */
  31456. function (moduleUrl, name) {
  31457. var _this = this;
  31458. return this.symbolResolver.ignoreErrorsFor(function () { return _this.findDeclaration(moduleUrl, name); });
  31459. };
  31460. /**
  31461. * @param {?} symbol
  31462. * @return {?}
  31463. */
  31464. StaticReflector.prototype.findSymbolDeclaration = /**
  31465. * @param {?} symbol
  31466. * @return {?}
  31467. */
  31468. function (symbol) {
  31469. var /** @type {?} */ resolvedSymbol = this.symbolResolver.resolveSymbol(symbol);
  31470. if (resolvedSymbol) {
  31471. var /** @type {?} */ resolvedMetadata = resolvedSymbol.metadata;
  31472. if (resolvedMetadata && resolvedMetadata.__symbolic === 'resolved') {
  31473. resolvedMetadata = resolvedMetadata.symbol;
  31474. }
  31475. if (resolvedMetadata instanceof StaticSymbol) {
  31476. return this.findSymbolDeclaration(resolvedSymbol.metadata);
  31477. }
  31478. }
  31479. return symbol;
  31480. };
  31481. /**
  31482. * @param {?} type
  31483. * @return {?}
  31484. */
  31485. StaticReflector.prototype.annotations = /**
  31486. * @param {?} type
  31487. * @return {?}
  31488. */
  31489. function (type) {
  31490. var /** @type {?} */ annotations = this.annotationCache.get(type);
  31491. if (!annotations) {
  31492. annotations = [];
  31493. var /** @type {?} */ classMetadata = this.getTypeMetadata(type);
  31494. var /** @type {?} */ parentType = this.findParentType(type, classMetadata);
  31495. if (parentType) {
  31496. var /** @type {?} */ parentAnnotations = this.annotations(parentType);
  31497. annotations.push.apply(annotations, parentAnnotations);
  31498. }
  31499. var /** @type {?} */ ownAnnotations_1 = [];
  31500. if (classMetadata['decorators']) {
  31501. ownAnnotations_1 = this.simplify(type, classMetadata['decorators']);
  31502. annotations.push.apply(annotations, ownAnnotations_1);
  31503. }
  31504. if (parentType && !this.summaryResolver.isLibraryFile(type.filePath) &&
  31505. this.summaryResolver.isLibraryFile(parentType.filePath)) {
  31506. var /** @type {?} */ summary = this.summaryResolver.resolveSummary(parentType);
  31507. if (summary && summary.type) {
  31508. var /** @type {?} */ requiredAnnotationTypes = /** @type {?} */ ((this.annotationForParentClassWithSummaryKind.get(/** @type {?} */ ((summary.type.summaryKind)))));
  31509. var /** @type {?} */ typeHasRequiredAnnotation = requiredAnnotationTypes.some(function (requiredType) { return ownAnnotations_1.some(function (ann) { return requiredType.isTypeOf(ann); }); });
  31510. if (!typeHasRequiredAnnotation) {
  31511. this.reportError(formatMetadataError(metadataError("Class " + type.name + " in " + type.filePath + " extends from a " + CompileSummaryKind[(/** @type {?} */ ((summary.type.summaryKind)))] + " in another compilation unit without duplicating the decorator", undefined, "Please add a " + requiredAnnotationTypes.map(function (type) { return type.ngMetadataName; }).join(' or ') + " decorator to the class"), type), type);
  31512. }
  31513. }
  31514. }
  31515. this.annotationCache.set(type, annotations.filter(function (ann) { return !!ann; }));
  31516. }
  31517. return annotations;
  31518. };
  31519. /**
  31520. * @param {?} type
  31521. * @return {?}
  31522. */
  31523. StaticReflector.prototype.propMetadata = /**
  31524. * @param {?} type
  31525. * @return {?}
  31526. */
  31527. function (type) {
  31528. var _this = this;
  31529. var /** @type {?} */ propMetadata = this.propertyCache.get(type);
  31530. if (!propMetadata) {
  31531. var /** @type {?} */ classMetadata = this.getTypeMetadata(type);
  31532. propMetadata = {};
  31533. var /** @type {?} */ parentType = this.findParentType(type, classMetadata);
  31534. if (parentType) {
  31535. var /** @type {?} */ parentPropMetadata_1 = this.propMetadata(parentType);
  31536. Object.keys(parentPropMetadata_1).forEach(function (parentProp) {
  31537. /** @type {?} */ ((propMetadata))[parentProp] = parentPropMetadata_1[parentProp];
  31538. });
  31539. }
  31540. var /** @type {?} */ members_1 = classMetadata['members'] || {};
  31541. Object.keys(members_1).forEach(function (propName) {
  31542. var /** @type {?} */ propData = members_1[propName];
  31543. var /** @type {?} */ prop = (/** @type {?} */ (propData))
  31544. .find(function (a) { return a['__symbolic'] == 'property' || a['__symbolic'] == 'method'; });
  31545. var /** @type {?} */ decorators = [];
  31546. if (/** @type {?} */ ((propMetadata))[propName]) {
  31547. decorators.push.apply(decorators, /** @type {?} */ ((propMetadata))[propName]);
  31548. } /** @type {?} */
  31549. ((propMetadata))[propName] = decorators;
  31550. if (prop && prop['decorators']) {
  31551. decorators.push.apply(decorators, _this.simplify(type, prop['decorators']));
  31552. }
  31553. });
  31554. this.propertyCache.set(type, propMetadata);
  31555. }
  31556. return propMetadata;
  31557. };
  31558. /**
  31559. * @param {?} type
  31560. * @return {?}
  31561. */
  31562. StaticReflector.prototype.parameters = /**
  31563. * @param {?} type
  31564. * @return {?}
  31565. */
  31566. function (type) {
  31567. var _this = this;
  31568. if (!(type instanceof StaticSymbol)) {
  31569. this.reportError(new Error("parameters received " + JSON.stringify(type) + " which is not a StaticSymbol"), type);
  31570. return [];
  31571. }
  31572. try {
  31573. var /** @type {?} */ parameters_1 = this.parameterCache.get(type);
  31574. if (!parameters_1) {
  31575. var /** @type {?} */ classMetadata = this.getTypeMetadata(type);
  31576. var /** @type {?} */ parentType = this.findParentType(type, classMetadata);
  31577. var /** @type {?} */ members = classMetadata ? classMetadata['members'] : null;
  31578. var /** @type {?} */ ctorData = members ? members['__ctor__'] : null;
  31579. if (ctorData) {
  31580. var /** @type {?} */ ctor = (/** @type {?} */ (ctorData)).find(function (a) { return a['__symbolic'] == 'constructor'; });
  31581. var /** @type {?} */ rawParameterTypes = /** @type {?} */ (ctor['parameters']) || [];
  31582. var /** @type {?} */ parameterDecorators_1 = /** @type {?} */ (this.simplify(type, ctor['parameterDecorators'] || []));
  31583. parameters_1 = [];
  31584. rawParameterTypes.forEach(function (rawParamType, index) {
  31585. var /** @type {?} */ nestedResult = [];
  31586. var /** @type {?} */ paramType = _this.trySimplify(type, rawParamType);
  31587. if (paramType)
  31588. nestedResult.push(paramType);
  31589. var /** @type {?} */ decorators = parameterDecorators_1 ? parameterDecorators_1[index] : null;
  31590. if (decorators) {
  31591. nestedResult.push.apply(nestedResult, decorators);
  31592. } /** @type {?} */
  31593. ((parameters_1)).push(nestedResult);
  31594. });
  31595. }
  31596. else if (parentType) {
  31597. parameters_1 = this.parameters(parentType);
  31598. }
  31599. if (!parameters_1) {
  31600. parameters_1 = [];
  31601. }
  31602. this.parameterCache.set(type, parameters_1);
  31603. }
  31604. return parameters_1;
  31605. }
  31606. catch (/** @type {?} */ e) {
  31607. console.error("Failed on type " + JSON.stringify(type) + " with error " + e);
  31608. throw e;
  31609. }
  31610. };
  31611. /**
  31612. * @param {?} type
  31613. * @return {?}
  31614. */
  31615. StaticReflector.prototype._methodNames = /**
  31616. * @param {?} type
  31617. * @return {?}
  31618. */
  31619. function (type) {
  31620. var /** @type {?} */ methodNames = this.methodCache.get(type);
  31621. if (!methodNames) {
  31622. var /** @type {?} */ classMetadata = this.getTypeMetadata(type);
  31623. methodNames = {};
  31624. var /** @type {?} */ parentType = this.findParentType(type, classMetadata);
  31625. if (parentType) {
  31626. var /** @type {?} */ parentMethodNames_1 = this._methodNames(parentType);
  31627. Object.keys(parentMethodNames_1).forEach(function (parentProp) {
  31628. /** @type {?} */ ((methodNames))[parentProp] = parentMethodNames_1[parentProp];
  31629. });
  31630. }
  31631. var /** @type {?} */ members_2 = classMetadata['members'] || {};
  31632. Object.keys(members_2).forEach(function (propName) {
  31633. var /** @type {?} */ propData = members_2[propName];
  31634. var /** @type {?} */ isMethod = (/** @type {?} */ (propData)).some(function (a) { return a['__symbolic'] == 'method'; }); /** @type {?} */
  31635. ((methodNames))[propName] = /** @type {?} */ ((methodNames))[propName] || isMethod;
  31636. });
  31637. this.methodCache.set(type, methodNames);
  31638. }
  31639. return methodNames;
  31640. };
  31641. /**
  31642. * @param {?} type
  31643. * @return {?}
  31644. */
  31645. StaticReflector.prototype._staticMembers = /**
  31646. * @param {?} type
  31647. * @return {?}
  31648. */
  31649. function (type) {
  31650. var /** @type {?} */ staticMembers = this.staticCache.get(type);
  31651. if (!staticMembers) {
  31652. var /** @type {?} */ classMetadata = this.getTypeMetadata(type);
  31653. var /** @type {?} */ staticMemberData = classMetadata['statics'] || {};
  31654. staticMembers = Object.keys(staticMemberData);
  31655. this.staticCache.set(type, staticMembers);
  31656. }
  31657. return staticMembers;
  31658. };
  31659. /**
  31660. * @param {?} type
  31661. * @param {?} classMetadata
  31662. * @return {?}
  31663. */
  31664. StaticReflector.prototype.findParentType = /**
  31665. * @param {?} type
  31666. * @param {?} classMetadata
  31667. * @return {?}
  31668. */
  31669. function (type, classMetadata) {
  31670. var /** @type {?} */ parentType = this.trySimplify(type, classMetadata['extends']);
  31671. if (parentType instanceof StaticSymbol) {
  31672. return parentType;
  31673. }
  31674. };
  31675. /**
  31676. * @param {?} type
  31677. * @param {?} lcProperty
  31678. * @return {?}
  31679. */
  31680. StaticReflector.prototype.hasLifecycleHook = /**
  31681. * @param {?} type
  31682. * @param {?} lcProperty
  31683. * @return {?}
  31684. */
  31685. function (type, lcProperty) {
  31686. if (!(type instanceof StaticSymbol)) {
  31687. this.reportError(new Error("hasLifecycleHook received " + JSON.stringify(type) + " which is not a StaticSymbol"), type);
  31688. }
  31689. try {
  31690. return !!this._methodNames(type)[lcProperty];
  31691. }
  31692. catch (/** @type {?} */ e) {
  31693. console.error("Failed on type " + JSON.stringify(type) + " with error " + e);
  31694. throw e;
  31695. }
  31696. };
  31697. /**
  31698. * @param {?} type
  31699. * @return {?}
  31700. */
  31701. StaticReflector.prototype.guards = /**
  31702. * @param {?} type
  31703. * @return {?}
  31704. */
  31705. function (type) {
  31706. if (!(type instanceof StaticSymbol)) {
  31707. this.reportError(new Error("guards received " + JSON.stringify(type) + " which is not a StaticSymbol"), type);
  31708. return {};
  31709. }
  31710. var /** @type {?} */ staticMembers = this._staticMembers(type);
  31711. var /** @type {?} */ result = {};
  31712. for (var _i = 0, staticMembers_1 = staticMembers; _i < staticMembers_1.length; _i++) {
  31713. var name_1 = staticMembers_1[_i];
  31714. if (name_1.endsWith(TYPEGUARD_POSTFIX)) {
  31715. var /** @type {?} */ property = name_1.substr(0, name_1.length - TYPEGUARD_POSTFIX.length);
  31716. var /** @type {?} */ value = void 0;
  31717. if (property.endsWith(USE_IF)) {
  31718. property = name_1.substr(0, property.length - USE_IF.length);
  31719. value = USE_IF;
  31720. }
  31721. else {
  31722. value = this.getStaticSymbol(type.filePath, type.name, [name_1]);
  31723. }
  31724. result[property] = value;
  31725. }
  31726. }
  31727. return result;
  31728. };
  31729. /**
  31730. * @param {?} type
  31731. * @param {?} ctor
  31732. * @return {?}
  31733. */
  31734. StaticReflector.prototype._registerDecoratorOrConstructor = /**
  31735. * @param {?} type
  31736. * @param {?} ctor
  31737. * @return {?}
  31738. */
  31739. function (type, ctor) {
  31740. this.conversionMap.set(type, function (context, args) { return new (ctor.bind.apply(ctor, [void 0].concat(args)))(); });
  31741. };
  31742. /**
  31743. * @param {?} type
  31744. * @param {?} fn
  31745. * @return {?}
  31746. */
  31747. StaticReflector.prototype._registerFunction = /**
  31748. * @param {?} type
  31749. * @param {?} fn
  31750. * @return {?}
  31751. */
  31752. function (type, fn) {
  31753. this.conversionMap.set(type, function (context, args) { return fn.apply(undefined, args); });
  31754. };
  31755. /**
  31756. * @return {?}
  31757. */
  31758. StaticReflector.prototype.initializeConversionMap = /**
  31759. * @return {?}
  31760. */
  31761. function () {
  31762. this.injectionToken = this.findDeclaration(ANGULAR_CORE, 'InjectionToken');
  31763. this.opaqueToken = this.findDeclaration(ANGULAR_CORE, 'OpaqueToken');
  31764. this.ROUTES = this.tryFindDeclaration(ANGULAR_ROUTER, 'ROUTES');
  31765. this.ANALYZE_FOR_ENTRY_COMPONENTS =
  31766. this.findDeclaration(ANGULAR_CORE, 'ANALYZE_FOR_ENTRY_COMPONENTS');
  31767. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Host'), createHost);
  31768. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Injectable'), createInjectable);
  31769. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Self'), createSelf);
  31770. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'SkipSelf'), createSkipSelf);
  31771. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Inject'), createInject);
  31772. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Optional'), createOptional);
  31773. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Attribute'), createAttribute);
  31774. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'ContentChild'), createContentChild);
  31775. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'ContentChildren'), createContentChildren);
  31776. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'ViewChild'), createViewChild);
  31777. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'ViewChildren'), createViewChildren);
  31778. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Input'), createInput);
  31779. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Output'), createOutput);
  31780. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Pipe'), createPipe);
  31781. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'HostBinding'), createHostBinding);
  31782. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'HostListener'), createHostListener);
  31783. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Directive'), createDirective);
  31784. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Component'), createComponent);
  31785. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'NgModule'), createNgModule);
  31786. // Note: Some metadata classes can be used directly with Provider.deps.
  31787. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Host'), createHost);
  31788. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Self'), createSelf);
  31789. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'SkipSelf'), createSkipSelf);
  31790. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Optional'), createOptional);
  31791. };
  31792. /**
  31793. * getStaticSymbol produces a Type whose metadata is known but whose implementation is not loaded.
  31794. * All types passed to the StaticResolver should be pseudo-types returned by this method.
  31795. *
  31796. * @param declarationFile the absolute path of the file where the symbol is declared
  31797. * @param name the name of the type.
  31798. */
  31799. /**
  31800. * getStaticSymbol produces a Type whose metadata is known but whose implementation is not loaded.
  31801. * All types passed to the StaticResolver should be pseudo-types returned by this method.
  31802. *
  31803. * @param {?} declarationFile the absolute path of the file where the symbol is declared
  31804. * @param {?} name the name of the type.
  31805. * @param {?=} members
  31806. * @return {?}
  31807. */
  31808. StaticReflector.prototype.getStaticSymbol = /**
  31809. * getStaticSymbol produces a Type whose metadata is known but whose implementation is not loaded.
  31810. * All types passed to the StaticResolver should be pseudo-types returned by this method.
  31811. *
  31812. * @param {?} declarationFile the absolute path of the file where the symbol is declared
  31813. * @param {?} name the name of the type.
  31814. * @param {?=} members
  31815. * @return {?}
  31816. */
  31817. function (declarationFile, name, members) {
  31818. return this.symbolResolver.getStaticSymbol(declarationFile, name, members);
  31819. };
  31820. /**
  31821. * Simplify but discard any errors
  31822. * @param {?} context
  31823. * @param {?} value
  31824. * @return {?}
  31825. */
  31826. StaticReflector.prototype.trySimplify = /**
  31827. * Simplify but discard any errors
  31828. * @param {?} context
  31829. * @param {?} value
  31830. * @return {?}
  31831. */
  31832. function (context, value) {
  31833. var /** @type {?} */ originalRecorder = this.errorRecorder;
  31834. this.errorRecorder = function (error, fileName) { };
  31835. var /** @type {?} */ result = this.simplify(context, value);
  31836. this.errorRecorder = originalRecorder;
  31837. return result;
  31838. };
  31839. /**
  31840. * \@internal
  31841. * @param {?} context
  31842. * @param {?} value
  31843. * @return {?}
  31844. */
  31845. StaticReflector.prototype.simplify = /**
  31846. * \@internal
  31847. * @param {?} context
  31848. * @param {?} value
  31849. * @return {?}
  31850. */
  31851. function (context, value) {
  31852. var /** @type {?} */ self = this;
  31853. var /** @type {?} */ scope = BindingScope.empty;
  31854. var /** @type {?} */ calling = new Map();
  31855. var /** @type {?} */ rootContext = context;
  31856. /**
  31857. * @param {?} context
  31858. * @param {?} value
  31859. * @param {?} depth
  31860. * @param {?} references
  31861. * @return {?}
  31862. */
  31863. function simplifyInContext(context, value, depth, references) {
  31864. /**
  31865. * @param {?} staticSymbol
  31866. * @return {?}
  31867. */
  31868. function resolveReferenceValue(staticSymbol) {
  31869. var /** @type {?} */ resolvedSymbol = self.symbolResolver.resolveSymbol(staticSymbol);
  31870. return resolvedSymbol ? resolvedSymbol.metadata : null;
  31871. }
  31872. /**
  31873. * @param {?} value
  31874. * @return {?}
  31875. */
  31876. function simplifyEagerly(value) {
  31877. return simplifyInContext(context, value, depth, 0);
  31878. }
  31879. /**
  31880. * @param {?} value
  31881. * @return {?}
  31882. */
  31883. function simplifyLazily(value) {
  31884. return simplifyInContext(context, value, depth, references + 1);
  31885. }
  31886. /**
  31887. * @param {?} nestedContext
  31888. * @param {?} value
  31889. * @return {?}
  31890. */
  31891. function simplifyNested(nestedContext, value) {
  31892. if (nestedContext === context) {
  31893. // If the context hasn't changed let the exception propagate unmodified.
  31894. return simplifyInContext(nestedContext, value, depth + 1, references);
  31895. }
  31896. try {
  31897. return simplifyInContext(nestedContext, value, depth + 1, references);
  31898. }
  31899. catch (/** @type {?} */ e) {
  31900. if (isMetadataError(e)) {
  31901. // Propagate the message text up but add a message to the chain that explains how we got
  31902. // here.
  31903. // e.chain implies e.symbol
  31904. var /** @type {?} */ summaryMsg = e.chain ? 'references \'' + /** @type {?} */ ((e.symbol)).name + '\'' : errorSummary(e);
  31905. var /** @type {?} */ summary = "'" + nestedContext.name + "' " + summaryMsg;
  31906. var /** @type {?} */ chain = { message: summary, position: e.position, next: e.chain };
  31907. // TODO(chuckj): retrieve the position information indirectly from the collectors node
  31908. // map if the metadata is from a .ts file.
  31909. self.error({
  31910. message: e.message,
  31911. advise: e.advise,
  31912. context: e.context, chain: chain,
  31913. symbol: nestedContext
  31914. }, context);
  31915. }
  31916. else {
  31917. // It is probably an internal error.
  31918. throw e;
  31919. }
  31920. }
  31921. }
  31922. /**
  31923. * @param {?} functionSymbol
  31924. * @param {?} targetFunction
  31925. * @param {?} args
  31926. * @param {?} targetExpression
  31927. * @return {?}
  31928. */
  31929. function simplifyCall(functionSymbol, targetFunction, args, targetExpression) {
  31930. if (targetFunction && targetFunction['__symbolic'] == 'function') {
  31931. if (calling.get(functionSymbol)) {
  31932. self.error({
  31933. message: 'Recursion is not supported',
  31934. summary: "called '" + functionSymbol.name + "' recursively",
  31935. value: targetFunction
  31936. }, functionSymbol);
  31937. }
  31938. try {
  31939. var /** @type {?} */ value_1 = targetFunction['value'];
  31940. if (value_1 && (depth != 0 || value_1.__symbolic != 'error')) {
  31941. var /** @type {?} */ parameters = targetFunction['parameters'];
  31942. var /** @type {?} */ defaults = targetFunction.defaults;
  31943. args = args.map(function (arg) { return simplifyNested(context, arg); })
  31944. .map(function (arg) { return shouldIgnore(arg) ? undefined : arg; });
  31945. if (defaults && defaults.length > args.length) {
  31946. args.push.apply(args, defaults.slice(args.length).map(function (value) { return simplify(value); }));
  31947. }
  31948. calling.set(functionSymbol, true);
  31949. var /** @type {?} */ functionScope = BindingScope.build();
  31950. for (var /** @type {?} */ i = 0; i < parameters.length; i++) {
  31951. functionScope.define(parameters[i], args[i]);
  31952. }
  31953. var /** @type {?} */ oldScope = scope;
  31954. var /** @type {?} */ result_1;
  31955. try {
  31956. scope = functionScope.done();
  31957. result_1 = simplifyNested(functionSymbol, value_1);
  31958. }
  31959. finally {
  31960. scope = oldScope;
  31961. }
  31962. return result_1;
  31963. }
  31964. }
  31965. finally {
  31966. calling.delete(functionSymbol);
  31967. }
  31968. }
  31969. if (depth === 0) {
  31970. // If depth is 0 we are evaluating the top level expression that is describing element
  31971. // decorator. In this case, it is a decorator we don't understand, such as a custom
  31972. // non-angular decorator, and we should just ignore it.
  31973. return IGNORE;
  31974. }
  31975. var /** @type {?} */ position = undefined;
  31976. if (targetExpression && targetExpression.__symbolic == 'resolved') {
  31977. var /** @type {?} */ line = targetExpression.line;
  31978. var /** @type {?} */ character = targetExpression.character;
  31979. var /** @type {?} */ fileName = targetExpression.fileName;
  31980. if (fileName != null && line != null && character != null) {
  31981. position = { fileName: fileName, line: line, column: character };
  31982. }
  31983. }
  31984. self.error({
  31985. message: FUNCTION_CALL_NOT_SUPPORTED,
  31986. context: functionSymbol,
  31987. value: targetFunction, position: position
  31988. }, context);
  31989. }
  31990. /**
  31991. * @param {?} expression
  31992. * @return {?}
  31993. */
  31994. function simplify(expression) {
  31995. if (isPrimitive(expression)) {
  31996. return expression;
  31997. }
  31998. if (expression instanceof Array) {
  31999. var /** @type {?} */ result_2 = [];
  32000. for (var _i = 0, _a = (/** @type {?} */ (expression)); _i < _a.length; _i++) {
  32001. var item = _a[_i];
  32002. // Check for a spread expression
  32003. if (item && item.__symbolic === 'spread') {
  32004. // We call with references as 0 because we require the actual value and cannot
  32005. // tolerate a reference here.
  32006. var /** @type {?} */ spreadArray = simplifyEagerly(item.expression);
  32007. if (Array.isArray(spreadArray)) {
  32008. for (var _b = 0, spreadArray_1 = spreadArray; _b < spreadArray_1.length; _b++) {
  32009. var spreadItem = spreadArray_1[_b];
  32010. result_2.push(spreadItem);
  32011. }
  32012. continue;
  32013. }
  32014. }
  32015. var /** @type {?} */ value_2 = simplify(item);
  32016. if (shouldIgnore(value_2)) {
  32017. continue;
  32018. }
  32019. result_2.push(value_2);
  32020. }
  32021. return result_2;
  32022. }
  32023. if (expression instanceof StaticSymbol) {
  32024. // Stop simplification at builtin symbols or if we are in a reference context and
  32025. // the symbol doesn't have members.
  32026. if (expression === self.injectionToken || self.conversionMap.has(expression) ||
  32027. (references > 0 && !expression.members.length)) {
  32028. return expression;
  32029. }
  32030. else {
  32031. var /** @type {?} */ staticSymbol = expression;
  32032. var /** @type {?} */ declarationValue = resolveReferenceValue(staticSymbol);
  32033. if (declarationValue != null) {
  32034. return simplifyNested(staticSymbol, declarationValue);
  32035. }
  32036. else {
  32037. return staticSymbol;
  32038. }
  32039. }
  32040. }
  32041. if (expression) {
  32042. if (expression['__symbolic']) {
  32043. var /** @type {?} */ staticSymbol = void 0;
  32044. switch (expression['__symbolic']) {
  32045. case 'binop':
  32046. var /** @type {?} */ left = simplify(expression['left']);
  32047. if (shouldIgnore(left))
  32048. return left;
  32049. var /** @type {?} */ right = simplify(expression['right']);
  32050. if (shouldIgnore(right))
  32051. return right;
  32052. switch (expression['operator']) {
  32053. case '&&':
  32054. return left && right;
  32055. case '||':
  32056. return left || right;
  32057. case '|':
  32058. return left | right;
  32059. case '^':
  32060. return left ^ right;
  32061. case '&':
  32062. return left & right;
  32063. case '==':
  32064. return left == right;
  32065. case '!=':
  32066. return left != right;
  32067. case '===':
  32068. return left === right;
  32069. case '!==':
  32070. return left !== right;
  32071. case '<':
  32072. return left < right;
  32073. case '>':
  32074. return left > right;
  32075. case '<=':
  32076. return left <= right;
  32077. case '>=':
  32078. return left >= right;
  32079. case '<<':
  32080. return left << right;
  32081. case '>>':
  32082. return left >> right;
  32083. case '+':
  32084. return left + right;
  32085. case '-':
  32086. return left - right;
  32087. case '*':
  32088. return left * right;
  32089. case '/':
  32090. return left / right;
  32091. case '%':
  32092. return left % right;
  32093. }
  32094. return null;
  32095. case 'if':
  32096. var /** @type {?} */ condition = simplify(expression['condition']);
  32097. return condition ? simplify(expression['thenExpression']) :
  32098. simplify(expression['elseExpression']);
  32099. case 'pre':
  32100. var /** @type {?} */ operand = simplify(expression['operand']);
  32101. if (shouldIgnore(operand))
  32102. return operand;
  32103. switch (expression['operator']) {
  32104. case '+':
  32105. return operand;
  32106. case '-':
  32107. return -operand;
  32108. case '!':
  32109. return !operand;
  32110. case '~':
  32111. return ~operand;
  32112. }
  32113. return null;
  32114. case 'index':
  32115. var /** @type {?} */ indexTarget = simplifyEagerly(expression['expression']);
  32116. var /** @type {?} */ index = simplifyEagerly(expression['index']);
  32117. if (indexTarget && isPrimitive(index))
  32118. return indexTarget[index];
  32119. return null;
  32120. case 'select':
  32121. var /** @type {?} */ member = expression['member'];
  32122. var /** @type {?} */ selectContext = context;
  32123. var /** @type {?} */ selectTarget = simplify(expression['expression']);
  32124. if (selectTarget instanceof StaticSymbol) {
  32125. var /** @type {?} */ members = selectTarget.members.concat(member);
  32126. selectContext =
  32127. self.getStaticSymbol(selectTarget.filePath, selectTarget.name, members);
  32128. var /** @type {?} */ declarationValue = resolveReferenceValue(selectContext);
  32129. if (declarationValue != null) {
  32130. return simplifyNested(selectContext, declarationValue);
  32131. }
  32132. else {
  32133. return selectContext;
  32134. }
  32135. }
  32136. if (selectTarget && isPrimitive(member))
  32137. return simplifyNested(selectContext, selectTarget[member]);
  32138. return null;
  32139. case 'reference':
  32140. // Note: This only has to deal with variable references, as symbol references have
  32141. // been converted into 'resolved'
  32142. // in the StaticSymbolResolver.
  32143. var /** @type {?} */ name_2 = expression['name'];
  32144. var /** @type {?} */ localValue = scope.resolve(name_2);
  32145. if (localValue != BindingScope.missing) {
  32146. return localValue;
  32147. }
  32148. break;
  32149. case 'resolved':
  32150. try {
  32151. return simplify(expression.symbol);
  32152. }
  32153. catch (/** @type {?} */ e) {
  32154. // If an error is reported evaluating the symbol record the position of the
  32155. // reference in the error so it can
  32156. // be reported in the error message generated from the exception.
  32157. if (isMetadataError(e) && expression.fileName != null &&
  32158. expression.line != null && expression.character != null) {
  32159. e.position = {
  32160. fileName: expression.fileName,
  32161. line: expression.line,
  32162. column: expression.character
  32163. };
  32164. }
  32165. throw e;
  32166. }
  32167. case 'class':
  32168. return context;
  32169. case 'function':
  32170. return context;
  32171. case 'new':
  32172. case 'call':
  32173. // Determine if the function is a built-in conversion
  32174. staticSymbol = simplifyInContext(context, expression['expression'], depth + 1, /* references */ 0);
  32175. if (staticSymbol instanceof StaticSymbol) {
  32176. if (staticSymbol === self.injectionToken || staticSymbol === self.opaqueToken) {
  32177. // if somebody calls new InjectionToken, don't create an InjectionToken,
  32178. // but rather return the symbol to which the InjectionToken is assigned to.
  32179. // OpaqueToken is supported too as it is required by the language service to
  32180. // support v4 and prior versions of Angular.
  32181. return context;
  32182. }
  32183. var /** @type {?} */ argExpressions = expression['arguments'] || [];
  32184. var /** @type {?} */ converter = self.conversionMap.get(staticSymbol);
  32185. if (converter) {
  32186. var /** @type {?} */ args = argExpressions.map(function (arg) { return simplifyNested(context, arg); })
  32187. .map(function (arg) { return shouldIgnore(arg) ? undefined : arg; });
  32188. return converter(context, args);
  32189. }
  32190. else {
  32191. // Determine if the function is one we can simplify.
  32192. var /** @type {?} */ targetFunction = resolveReferenceValue(staticSymbol);
  32193. return simplifyCall(staticSymbol, targetFunction, argExpressions, expression['expression']);
  32194. }
  32195. }
  32196. return IGNORE;
  32197. case 'error':
  32198. var /** @type {?} */ message = expression.message;
  32199. if (expression['line'] != null) {
  32200. self.error({
  32201. message: message,
  32202. context: expression.context,
  32203. value: expression,
  32204. position: {
  32205. fileName: expression['fileName'],
  32206. line: expression['line'],
  32207. column: expression['character']
  32208. }
  32209. }, context);
  32210. }
  32211. else {
  32212. self.error({ message: message, context: expression.context }, context);
  32213. }
  32214. return IGNORE;
  32215. case 'ignore':
  32216. return expression;
  32217. }
  32218. return null;
  32219. }
  32220. return mapStringMap(expression, function (value, name) {
  32221. if (REFERENCE_SET.has(name)) {
  32222. if (name === USE_VALUE && PROVIDE in expression) {
  32223. // If this is a provider expression, check for special tokens that need the value
  32224. // during analysis.
  32225. var /** @type {?} */ provide = simplify(expression.provide);
  32226. if (provide === self.ROUTES || provide == self.ANALYZE_FOR_ENTRY_COMPONENTS) {
  32227. return simplify(value);
  32228. }
  32229. }
  32230. return simplifyLazily(value);
  32231. }
  32232. return simplify(value);
  32233. });
  32234. }
  32235. return IGNORE;
  32236. }
  32237. return simplify(value);
  32238. }
  32239. var /** @type {?} */ result;
  32240. try {
  32241. result = simplifyInContext(context, value, 0, 0);
  32242. }
  32243. catch (/** @type {?} */ e) {
  32244. if (this.errorRecorder) {
  32245. this.reportError(e, context);
  32246. }
  32247. else {
  32248. throw formatMetadataError(e, context);
  32249. }
  32250. }
  32251. if (shouldIgnore(result)) {
  32252. return undefined;
  32253. }
  32254. return result;
  32255. };
  32256. /**
  32257. * @param {?} type
  32258. * @return {?}
  32259. */
  32260. StaticReflector.prototype.getTypeMetadata = /**
  32261. * @param {?} type
  32262. * @return {?}
  32263. */
  32264. function (type) {
  32265. var /** @type {?} */ resolvedSymbol = this.symbolResolver.resolveSymbol(type);
  32266. return resolvedSymbol && resolvedSymbol.metadata ? resolvedSymbol.metadata :
  32267. { __symbolic: 'class' };
  32268. };
  32269. /**
  32270. * @param {?} error
  32271. * @param {?} context
  32272. * @param {?=} path
  32273. * @return {?}
  32274. */
  32275. StaticReflector.prototype.reportError = /**
  32276. * @param {?} error
  32277. * @param {?} context
  32278. * @param {?=} path
  32279. * @return {?}
  32280. */
  32281. function (error, context, path) {
  32282. if (this.errorRecorder) {
  32283. this.errorRecorder(formatMetadataError(error, context), (context && context.filePath) || path);
  32284. }
  32285. else {
  32286. throw error;
  32287. }
  32288. };
  32289. /**
  32290. * @param {?} __0
  32291. * @param {?} reportingContext
  32292. * @return {?}
  32293. */
  32294. StaticReflector.prototype.error = /**
  32295. * @param {?} __0
  32296. * @param {?} reportingContext
  32297. * @return {?}
  32298. */
  32299. function (_a, reportingContext) {
  32300. var message = _a.message, summary = _a.summary, advise = _a.advise, position = _a.position, context = _a.context, value = _a.value, symbol = _a.symbol, chain = _a.chain;
  32301. this.reportError(metadataError(message, summary, advise, position, symbol, context, chain), reportingContext);
  32302. };
  32303. return StaticReflector;
  32304. }());
  32305. var METADATA_ERROR = 'ngMetadataError';
  32306. /**
  32307. * @param {?} message
  32308. * @param {?=} summary
  32309. * @param {?=} advise
  32310. * @param {?=} position
  32311. * @param {?=} symbol
  32312. * @param {?=} context
  32313. * @param {?=} chain
  32314. * @return {?}
  32315. */
  32316. function metadataError(message, summary, advise, position, symbol, context, chain) {
  32317. var /** @type {?} */ error = /** @type {?} */ (syntaxError(message));
  32318. (/** @type {?} */ (error))[METADATA_ERROR] = true;
  32319. if (advise)
  32320. error.advise = advise;
  32321. if (position)
  32322. error.position = position;
  32323. if (summary)
  32324. error.summary = summary;
  32325. if (context)
  32326. error.context = context;
  32327. if (chain)
  32328. error.chain = chain;
  32329. if (symbol)
  32330. error.symbol = symbol;
  32331. return error;
  32332. }
  32333. /**
  32334. * @param {?} error
  32335. * @return {?}
  32336. */
  32337. function isMetadataError(error) {
  32338. return !!(/** @type {?} */ (error))[METADATA_ERROR];
  32339. }
  32340. var REFERENCE_TO_NONEXPORTED_CLASS = 'Reference to non-exported class';
  32341. var VARIABLE_NOT_INITIALIZED = 'Variable not initialized';
  32342. var DESTRUCTURE_NOT_SUPPORTED = 'Destructuring not supported';
  32343. var COULD_NOT_RESOLVE_TYPE = 'Could not resolve type';
  32344. var FUNCTION_CALL_NOT_SUPPORTED = 'Function call not supported';
  32345. var REFERENCE_TO_LOCAL_SYMBOL = 'Reference to a local symbol';
  32346. var LAMBDA_NOT_SUPPORTED = 'Lambda not supported';
  32347. /**
  32348. * @param {?} message
  32349. * @param {?} context
  32350. * @return {?}
  32351. */
  32352. function expandedMessage(message, context) {
  32353. switch (message) {
  32354. case REFERENCE_TO_NONEXPORTED_CLASS:
  32355. if (context && context.className) {
  32356. return "References to a non-exported class are not supported in decorators but " + context.className + " was referenced.";
  32357. }
  32358. break;
  32359. case VARIABLE_NOT_INITIALIZED:
  32360. return 'Only initialized variables and constants can be referenced in decorators because the value of this variable is needed by the template compiler';
  32361. case DESTRUCTURE_NOT_SUPPORTED:
  32362. return 'Referencing an exported destructured variable or constant is not supported in decorators and this value is needed by the template compiler';
  32363. case COULD_NOT_RESOLVE_TYPE:
  32364. if (context && context.typeName) {
  32365. return "Could not resolve type " + context.typeName;
  32366. }
  32367. break;
  32368. case FUNCTION_CALL_NOT_SUPPORTED:
  32369. if (context && context.name) {
  32370. return "Function calls are not supported in decorators but '" + context.name + "' was called";
  32371. }
  32372. return 'Function calls are not supported in decorators';
  32373. case REFERENCE_TO_LOCAL_SYMBOL:
  32374. if (context && context.name) {
  32375. return "Reference to a local (non-exported) symbols are not supported in decorators but '" + context.name + "' was referenced";
  32376. }
  32377. break;
  32378. case LAMBDA_NOT_SUPPORTED:
  32379. return "Function expressions are not supported in decorators";
  32380. }
  32381. return message;
  32382. }
  32383. /**
  32384. * @param {?} message
  32385. * @param {?} context
  32386. * @return {?}
  32387. */
  32388. function messageAdvise(message, context) {
  32389. switch (message) {
  32390. case REFERENCE_TO_NONEXPORTED_CLASS:
  32391. if (context && context.className) {
  32392. return "Consider exporting '" + context.className + "'";
  32393. }
  32394. break;
  32395. case DESTRUCTURE_NOT_SUPPORTED:
  32396. return 'Consider simplifying to avoid destructuring';
  32397. case REFERENCE_TO_LOCAL_SYMBOL:
  32398. if (context && context.name) {
  32399. return "Consider exporting '" + context.name + "'";
  32400. }
  32401. break;
  32402. case LAMBDA_NOT_SUPPORTED:
  32403. return "Consider changing the function expression into an exported function";
  32404. }
  32405. return undefined;
  32406. }
  32407. /**
  32408. * @param {?} error
  32409. * @return {?}
  32410. */
  32411. function errorSummary(error) {
  32412. if (error.summary) {
  32413. return error.summary;
  32414. }
  32415. switch (error.message) {
  32416. case REFERENCE_TO_NONEXPORTED_CLASS:
  32417. if (error.context && error.context.className) {
  32418. return "references non-exported class " + error.context.className;
  32419. }
  32420. break;
  32421. case VARIABLE_NOT_INITIALIZED:
  32422. return 'is not initialized';
  32423. case DESTRUCTURE_NOT_SUPPORTED:
  32424. return 'is a destructured variable';
  32425. case COULD_NOT_RESOLVE_TYPE:
  32426. return 'could not be resolved';
  32427. case FUNCTION_CALL_NOT_SUPPORTED:
  32428. if (error.context && error.context.name) {
  32429. return "calls '" + error.context.name + "'";
  32430. }
  32431. return "calls a function";
  32432. case REFERENCE_TO_LOCAL_SYMBOL:
  32433. if (error.context && error.context.name) {
  32434. return "references local variable " + error.context.name;
  32435. }
  32436. return "references a local variable";
  32437. }
  32438. return 'contains the error';
  32439. }
  32440. /**
  32441. * @param {?} input
  32442. * @param {?} transform
  32443. * @return {?}
  32444. */
  32445. function mapStringMap(input, transform) {
  32446. if (!input)
  32447. return {};
  32448. var /** @type {?} */ result = {};
  32449. Object.keys(input).forEach(function (key) {
  32450. var /** @type {?} */ value = transform(input[key], key);
  32451. if (!shouldIgnore(value)) {
  32452. if (HIDDEN_KEY.test(key)) {
  32453. Object.defineProperty(result, key, { enumerable: false, configurable: true, value: value });
  32454. }
  32455. else {
  32456. result[key] = value;
  32457. }
  32458. }
  32459. });
  32460. return result;
  32461. }
  32462. /**
  32463. * @param {?} o
  32464. * @return {?}
  32465. */
  32466. function isPrimitive(o) {
  32467. return o === null || (typeof o !== 'function' && typeof o !== 'object');
  32468. }
  32469. /**
  32470. * @abstract
  32471. */
  32472. var BindingScope = /** @class */ (function () {
  32473. function BindingScope() {
  32474. }
  32475. /**
  32476. * @return {?}
  32477. */
  32478. BindingScope.build = /**
  32479. * @return {?}
  32480. */
  32481. function () {
  32482. var /** @type {?} */ current = new Map();
  32483. return {
  32484. define: function (name, value) {
  32485. current.set(name, value);
  32486. return this;
  32487. },
  32488. done: function () {
  32489. return current.size > 0 ? new PopulatedScope(current) : BindingScope.empty;
  32490. }
  32491. };
  32492. };
  32493. BindingScope.missing = {};
  32494. BindingScope.empty = { resolve: function (name) { return BindingScope.missing; } };
  32495. return BindingScope;
  32496. }());
  32497. var PopulatedScope = /** @class */ (function (_super) {
  32498. __extends(PopulatedScope, _super);
  32499. function PopulatedScope(bindings) {
  32500. var _this = _super.call(this) || this;
  32501. _this.bindings = bindings;
  32502. return _this;
  32503. }
  32504. /**
  32505. * @param {?} name
  32506. * @return {?}
  32507. */
  32508. PopulatedScope.prototype.resolve = /**
  32509. * @param {?} name
  32510. * @return {?}
  32511. */
  32512. function (name) {
  32513. return this.bindings.has(name) ? this.bindings.get(name) : BindingScope.missing;
  32514. };
  32515. return PopulatedScope;
  32516. }(BindingScope));
  32517. /**
  32518. * @param {?} chain
  32519. * @param {?} advise
  32520. * @return {?}
  32521. */
  32522. function formatMetadataMessageChain(chain, advise) {
  32523. var /** @type {?} */ expanded = expandedMessage(chain.message, chain.context);
  32524. var /** @type {?} */ nesting = chain.symbol ? " in '" + chain.symbol.name + "'" : '';
  32525. var /** @type {?} */ message = "" + expanded + nesting;
  32526. var /** @type {?} */ position = chain.position;
  32527. var /** @type {?} */ next = chain.next ?
  32528. formatMetadataMessageChain(chain.next, advise) :
  32529. advise ? { message: advise } : undefined;
  32530. return { message: message, position: position, next: next };
  32531. }
  32532. /**
  32533. * @param {?} e
  32534. * @param {?} context
  32535. * @return {?}
  32536. */
  32537. function formatMetadataError(e, context) {
  32538. if (isMetadataError(e)) {
  32539. // Produce a formatted version of the and leaving enough information in the original error
  32540. // to recover the formatting information to eventually produce a diagnostic error message.
  32541. var /** @type {?} */ position = e.position;
  32542. var /** @type {?} */ chain = {
  32543. message: "Error during template compile of '" + context.name + "'",
  32544. position: position,
  32545. next: { message: e.message, next: e.chain, context: e.context, symbol: e.symbol }
  32546. };
  32547. var /** @type {?} */ advise = e.advise || messageAdvise(e.message, e.context);
  32548. return formattedError(formatMetadataMessageChain(chain, advise));
  32549. }
  32550. return e;
  32551. }
  32552. /**
  32553. * @fileoverview added by tsickle
  32554. * @suppress {checkTypes} checked by tsc
  32555. */
  32556. /**
  32557. * @license
  32558. * Copyright Google Inc. All Rights Reserved.
  32559. *
  32560. * Use of this source code is governed by an MIT-style license that can be
  32561. * found in the LICENSE file at https://angular.io/license
  32562. */
  32563. /**
  32564. * @record
  32565. */
  32566. var AotSummaryResolver = /** @class */ (function () {
  32567. function AotSummaryResolver(host, staticSymbolCache) {
  32568. this.host = host;
  32569. this.staticSymbolCache = staticSymbolCache;
  32570. this.summaryCache = new Map();
  32571. this.loadedFilePaths = new Map();
  32572. this.importAs = new Map();
  32573. this.knownFileNameToModuleNames = new Map();
  32574. }
  32575. /**
  32576. * @param {?} filePath
  32577. * @return {?}
  32578. */
  32579. AotSummaryResolver.prototype.isLibraryFile = /**
  32580. * @param {?} filePath
  32581. * @return {?}
  32582. */
  32583. function (filePath) {
  32584. // Note: We need to strip the .ngfactory. file path,
  32585. // so this method also works for generated files
  32586. // (for which host.isSourceFile will always return false).
  32587. return !this.host.isSourceFile(stripGeneratedFileSuffix(filePath));
  32588. };
  32589. /**
  32590. * @param {?} filePath
  32591. * @param {?} referringSrcFileName
  32592. * @return {?}
  32593. */
  32594. AotSummaryResolver.prototype.toSummaryFileName = /**
  32595. * @param {?} filePath
  32596. * @param {?} referringSrcFileName
  32597. * @return {?}
  32598. */
  32599. function (filePath, referringSrcFileName) {
  32600. return this.host.toSummaryFileName(filePath, referringSrcFileName);
  32601. };
  32602. /**
  32603. * @param {?} fileName
  32604. * @param {?} referringLibFileName
  32605. * @return {?}
  32606. */
  32607. AotSummaryResolver.prototype.fromSummaryFileName = /**
  32608. * @param {?} fileName
  32609. * @param {?} referringLibFileName
  32610. * @return {?}
  32611. */
  32612. function (fileName, referringLibFileName) {
  32613. return this.host.fromSummaryFileName(fileName, referringLibFileName);
  32614. };
  32615. /**
  32616. * @param {?} staticSymbol
  32617. * @return {?}
  32618. */
  32619. AotSummaryResolver.prototype.resolveSummary = /**
  32620. * @param {?} staticSymbol
  32621. * @return {?}
  32622. */
  32623. function (staticSymbol) {
  32624. var /** @type {?} */ rootSymbol = staticSymbol.members.length ?
  32625. this.staticSymbolCache.get(staticSymbol.filePath, staticSymbol.name) :
  32626. staticSymbol;
  32627. var /** @type {?} */ summary = this.summaryCache.get(rootSymbol);
  32628. if (!summary) {
  32629. this._loadSummaryFile(staticSymbol.filePath);
  32630. summary = /** @type {?} */ ((this.summaryCache.get(staticSymbol)));
  32631. }
  32632. return (rootSymbol === staticSymbol && summary) || null;
  32633. };
  32634. /**
  32635. * @param {?} filePath
  32636. * @return {?}
  32637. */
  32638. AotSummaryResolver.prototype.getSymbolsOf = /**
  32639. * @param {?} filePath
  32640. * @return {?}
  32641. */
  32642. function (filePath) {
  32643. if (this._loadSummaryFile(filePath)) {
  32644. return Array.from(this.summaryCache.keys()).filter(function (symbol) { return symbol.filePath === filePath; });
  32645. }
  32646. return null;
  32647. };
  32648. /**
  32649. * @param {?} staticSymbol
  32650. * @return {?}
  32651. */
  32652. AotSummaryResolver.prototype.getImportAs = /**
  32653. * @param {?} staticSymbol
  32654. * @return {?}
  32655. */
  32656. function (staticSymbol) {
  32657. staticSymbol.assertNoMembers();
  32658. return /** @type {?} */ ((this.importAs.get(staticSymbol)));
  32659. };
  32660. /**
  32661. * Converts a file path to a module name that can be used as an `import`.
  32662. */
  32663. /**
  32664. * Converts a file path to a module name that can be used as an `import`.
  32665. * @param {?} importedFilePath
  32666. * @return {?}
  32667. */
  32668. AotSummaryResolver.prototype.getKnownModuleName = /**
  32669. * Converts a file path to a module name that can be used as an `import`.
  32670. * @param {?} importedFilePath
  32671. * @return {?}
  32672. */
  32673. function (importedFilePath) {
  32674. return this.knownFileNameToModuleNames.get(importedFilePath) || null;
  32675. };
  32676. /**
  32677. * @param {?} summary
  32678. * @return {?}
  32679. */
  32680. AotSummaryResolver.prototype.addSummary = /**
  32681. * @param {?} summary
  32682. * @return {?}
  32683. */
  32684. function (summary) { this.summaryCache.set(summary.symbol, summary); };
  32685. /**
  32686. * @param {?} filePath
  32687. * @return {?}
  32688. */
  32689. AotSummaryResolver.prototype._loadSummaryFile = /**
  32690. * @param {?} filePath
  32691. * @return {?}
  32692. */
  32693. function (filePath) {
  32694. var _this = this;
  32695. var /** @type {?} */ hasSummary = this.loadedFilePaths.get(filePath);
  32696. if (hasSummary != null) {
  32697. return hasSummary;
  32698. }
  32699. var /** @type {?} */ json = null;
  32700. if (this.isLibraryFile(filePath)) {
  32701. var /** @type {?} */ summaryFilePath = summaryFileName(filePath);
  32702. try {
  32703. json = this.host.loadSummary(summaryFilePath);
  32704. }
  32705. catch (/** @type {?} */ e) {
  32706. console.error("Error loading summary file " + summaryFilePath);
  32707. throw e;
  32708. }
  32709. }
  32710. hasSummary = json != null;
  32711. this.loadedFilePaths.set(filePath, hasSummary);
  32712. if (json) {
  32713. var _a = deserializeSummaries(this.staticSymbolCache, this, filePath, json), moduleName = _a.moduleName, summaries = _a.summaries, importAs = _a.importAs;
  32714. summaries.forEach(function (summary) { return _this.summaryCache.set(summary.symbol, summary); });
  32715. if (moduleName) {
  32716. this.knownFileNameToModuleNames.set(filePath, moduleName);
  32717. }
  32718. importAs.forEach(function (importAs) { _this.importAs.set(importAs.symbol, importAs.importAs); });
  32719. }
  32720. return hasSummary;
  32721. };
  32722. return AotSummaryResolver;
  32723. }());
  32724. /**
  32725. * @fileoverview added by tsickle
  32726. * @suppress {checkTypes} checked by tsc
  32727. */
  32728. /**
  32729. * @license
  32730. * Copyright Google Inc. All Rights Reserved.
  32731. *
  32732. * Use of this source code is governed by an MIT-style license that can be
  32733. * found in the LICENSE file at https://angular.io/license
  32734. */
  32735. /**
  32736. * @param {?} host
  32737. * @return {?}
  32738. */
  32739. function createAotUrlResolver(host) {
  32740. return {
  32741. resolve: function (basePath, url) {
  32742. var /** @type {?} */ filePath = host.resourceNameToFileName(url, basePath);
  32743. if (!filePath) {
  32744. throw syntaxError("Couldn't resolve resource " + url + " from " + basePath);
  32745. }
  32746. return filePath;
  32747. }
  32748. };
  32749. }
  32750. /**
  32751. * Creates a new AotCompiler based on options and a host.
  32752. * @param {?} compilerHost
  32753. * @param {?} options
  32754. * @param {?=} errorCollector
  32755. * @return {?}
  32756. */
  32757. function createAotCompiler(compilerHost, options, errorCollector) {
  32758. var /** @type {?} */ translations = options.translations || '';
  32759. var /** @type {?} */ urlResolver = createAotUrlResolver(compilerHost);
  32760. var /** @type {?} */ symbolCache = new StaticSymbolCache();
  32761. var /** @type {?} */ summaryResolver = new AotSummaryResolver(compilerHost, symbolCache);
  32762. var /** @type {?} */ symbolResolver = new StaticSymbolResolver(compilerHost, symbolCache, summaryResolver);
  32763. var /** @type {?} */ staticReflector = new StaticReflector(summaryResolver, symbolResolver, [], [], errorCollector);
  32764. var /** @type {?} */ htmlParser = new I18NHtmlParser(new HtmlParser(), translations, options.i18nFormat, options.missingTranslation, console);
  32765. var /** @type {?} */ config = new CompilerConfig({
  32766. defaultEncapsulation: ViewEncapsulation.Emulated,
  32767. useJit: false,
  32768. enableLegacyTemplate: options.enableLegacyTemplate === true,
  32769. missingTranslation: options.missingTranslation,
  32770. preserveWhitespaces: options.preserveWhitespaces,
  32771. strictInjectionParameters: options.strictInjectionParameters,
  32772. });
  32773. var /** @type {?} */ normalizer = new DirectiveNormalizer({ get: function (url) { return compilerHost.loadResource(url); } }, urlResolver, htmlParser, config);
  32774. var /** @type {?} */ expressionParser = new Parser(new Lexer());
  32775. var /** @type {?} */ elementSchemaRegistry = new DomElementSchemaRegistry();
  32776. var /** @type {?} */ tmplParser = new TemplateParser(config, staticReflector, expressionParser, elementSchemaRegistry, htmlParser, console, []);
  32777. var /** @type {?} */ resolver = new CompileMetadataResolver(config, htmlParser, new NgModuleResolver(staticReflector), new DirectiveResolver(staticReflector), new PipeResolver(staticReflector), summaryResolver, elementSchemaRegistry, normalizer, console, symbolCache, staticReflector, errorCollector);
  32778. // TODO(vicb): do not pass options.i18nFormat here
  32779. var /** @type {?} */ viewCompiler = new ViewCompiler(staticReflector);
  32780. var /** @type {?} */ typeCheckCompiler = new TypeCheckCompiler(options, staticReflector);
  32781. var /** @type {?} */ compiler = new AotCompiler(config, options, compilerHost, staticReflector, resolver, tmplParser, new StyleCompiler(urlResolver), viewCompiler, typeCheckCompiler, new NgModuleCompiler(staticReflector), new TypeScriptEmitter(), summaryResolver, symbolResolver);
  32782. return { compiler: compiler, reflector: staticReflector };
  32783. }
  32784. /**
  32785. * @fileoverview added by tsickle
  32786. * @suppress {checkTypes} checked by tsc
  32787. */
  32788. /**
  32789. * @record
  32790. * @template T
  32791. */
  32792. /**
  32793. * @abstract
  32794. * @template T
  32795. */
  32796. var SummaryResolver = /** @class */ (function () {
  32797. function SummaryResolver() {
  32798. }
  32799. return SummaryResolver;
  32800. }());
  32801. var JitSummaryResolver = /** @class */ (function () {
  32802. function JitSummaryResolver() {
  32803. this._summaries = new Map();
  32804. }
  32805. /**
  32806. * @return {?}
  32807. */
  32808. JitSummaryResolver.prototype.isLibraryFile = /**
  32809. * @return {?}
  32810. */
  32811. function () { return false; };
  32812. /**
  32813. * @param {?} fileName
  32814. * @return {?}
  32815. */
  32816. JitSummaryResolver.prototype.toSummaryFileName = /**
  32817. * @param {?} fileName
  32818. * @return {?}
  32819. */
  32820. function (fileName) { return fileName; };
  32821. /**
  32822. * @param {?} fileName
  32823. * @return {?}
  32824. */
  32825. JitSummaryResolver.prototype.fromSummaryFileName = /**
  32826. * @param {?} fileName
  32827. * @return {?}
  32828. */
  32829. function (fileName) { return fileName; };
  32830. /**
  32831. * @param {?} reference
  32832. * @return {?}
  32833. */
  32834. JitSummaryResolver.prototype.resolveSummary = /**
  32835. * @param {?} reference
  32836. * @return {?}
  32837. */
  32838. function (reference) {
  32839. return this._summaries.get(reference) || null;
  32840. };
  32841. /**
  32842. * @return {?}
  32843. */
  32844. JitSummaryResolver.prototype.getSymbolsOf = /**
  32845. * @return {?}
  32846. */
  32847. function () { return []; };
  32848. /**
  32849. * @param {?} reference
  32850. * @return {?}
  32851. */
  32852. JitSummaryResolver.prototype.getImportAs = /**
  32853. * @param {?} reference
  32854. * @return {?}
  32855. */
  32856. function (reference) { return reference; };
  32857. /**
  32858. * @param {?} fileName
  32859. * @return {?}
  32860. */
  32861. JitSummaryResolver.prototype.getKnownModuleName = /**
  32862. * @param {?} fileName
  32863. * @return {?}
  32864. */
  32865. function (fileName) { return null; };
  32866. /**
  32867. * @param {?} summary
  32868. * @return {?}
  32869. */
  32870. JitSummaryResolver.prototype.addSummary = /**
  32871. * @param {?} summary
  32872. * @return {?}
  32873. */
  32874. function (summary) { this._summaries.set(summary.symbol, summary); };
  32875. return JitSummaryResolver;
  32876. }());
  32877. /**
  32878. * @fileoverview added by tsickle
  32879. * @suppress {checkTypes} checked by tsc
  32880. */
  32881. /**
  32882. * @license
  32883. * Copyright Google Inc. All Rights Reserved.
  32884. *
  32885. * Use of this source code is governed by an MIT-style license that can be
  32886. * found in the LICENSE file at https://angular.io/license
  32887. */
  32888. /**
  32889. * @param {?} statements
  32890. * @param {?} reflector
  32891. * @return {?}
  32892. */
  32893. function interpretStatements(statements, reflector) {
  32894. var /** @type {?} */ ctx = new _ExecutionContext(null, null, null, new Map());
  32895. var /** @type {?} */ visitor = new StatementInterpreter(reflector);
  32896. visitor.visitAllStatements(statements, ctx);
  32897. var /** @type {?} */ result = {};
  32898. ctx.exports.forEach(function (exportName) { result[exportName] = ctx.vars.get(exportName); });
  32899. return result;
  32900. }
  32901. /**
  32902. * @param {?} varNames
  32903. * @param {?} varValues
  32904. * @param {?} statements
  32905. * @param {?} ctx
  32906. * @param {?} visitor
  32907. * @return {?}
  32908. */
  32909. function _executeFunctionStatements(varNames, varValues, statements, ctx, visitor) {
  32910. var /** @type {?} */ childCtx = ctx.createChildWihtLocalVars();
  32911. for (var /** @type {?} */ i = 0; i < varNames.length; i++) {
  32912. childCtx.vars.set(varNames[i], varValues[i]);
  32913. }
  32914. var /** @type {?} */ result = visitor.visitAllStatements(statements, childCtx);
  32915. return result ? result.value : null;
  32916. }
  32917. var _ExecutionContext = /** @class */ (function () {
  32918. function _ExecutionContext(parent, instance, className, vars) {
  32919. this.parent = parent;
  32920. this.instance = instance;
  32921. this.className = className;
  32922. this.vars = vars;
  32923. this.exports = [];
  32924. }
  32925. /**
  32926. * @return {?}
  32927. */
  32928. _ExecutionContext.prototype.createChildWihtLocalVars = /**
  32929. * @return {?}
  32930. */
  32931. function () {
  32932. return new _ExecutionContext(this, this.instance, this.className, new Map());
  32933. };
  32934. return _ExecutionContext;
  32935. }());
  32936. var ReturnValue = /** @class */ (function () {
  32937. function ReturnValue(value) {
  32938. this.value = value;
  32939. }
  32940. return ReturnValue;
  32941. }());
  32942. /**
  32943. * @param {?} _classStmt
  32944. * @param {?} _ctx
  32945. * @param {?} _visitor
  32946. * @return {?}
  32947. */
  32948. function createDynamicClass(_classStmt, _ctx, _visitor) {
  32949. var /** @type {?} */ propertyDescriptors = {};
  32950. _classStmt.getters.forEach(function (getter) {
  32951. // Note: use `function` instead of arrow function to capture `this`
  32952. propertyDescriptors[getter.name] = {
  32953. configurable: false,
  32954. get: function () {
  32955. var /** @type {?} */ instanceCtx = new _ExecutionContext(_ctx, this, _classStmt.name, _ctx.vars);
  32956. return _executeFunctionStatements([], [], getter.body, instanceCtx, _visitor);
  32957. }
  32958. };
  32959. });
  32960. _classStmt.methods.forEach(function (method) {
  32961. var /** @type {?} */ paramNames = method.params.map(function (param) { return param.name; });
  32962. // Note: use `function` instead of arrow function to capture `this`
  32963. propertyDescriptors[/** @type {?} */ ((method.name))] = {
  32964. writable: false,
  32965. configurable: false,
  32966. value: function () {
  32967. var args = [];
  32968. for (var _i = 0; _i < arguments.length; _i++) {
  32969. args[_i] = arguments[_i];
  32970. }
  32971. var /** @type {?} */ instanceCtx = new _ExecutionContext(_ctx, this, _classStmt.name, _ctx.vars);
  32972. return _executeFunctionStatements(paramNames, args, method.body, instanceCtx, _visitor);
  32973. }
  32974. };
  32975. });
  32976. var /** @type {?} */ ctorParamNames = _classStmt.constructorMethod.params.map(function (param) { return param.name; });
  32977. // Note: use `function` instead of arrow function to capture `this`
  32978. var /** @type {?} */ ctor = function () {
  32979. var _this = this;
  32980. var args = [];
  32981. for (var _i = 0; _i < arguments.length; _i++) {
  32982. args[_i] = arguments[_i];
  32983. }
  32984. var /** @type {?} */ instanceCtx = new _ExecutionContext(_ctx, this, _classStmt.name, _ctx.vars);
  32985. _classStmt.fields.forEach(function (field) { _this[field.name] = undefined; });
  32986. _executeFunctionStatements(ctorParamNames, args, _classStmt.constructorMethod.body, instanceCtx, _visitor);
  32987. };
  32988. var /** @type {?} */ superClass = _classStmt.parent ? _classStmt.parent.visitExpression(_visitor, _ctx) : Object;
  32989. ctor.prototype = Object.create(superClass.prototype, propertyDescriptors);
  32990. return ctor;
  32991. }
  32992. var StatementInterpreter = /** @class */ (function () {
  32993. function StatementInterpreter(reflector) {
  32994. this.reflector = reflector;
  32995. }
  32996. /**
  32997. * @param {?} ast
  32998. * @return {?}
  32999. */
  33000. StatementInterpreter.prototype.debugAst = /**
  33001. * @param {?} ast
  33002. * @return {?}
  33003. */
  33004. function (ast) { return debugOutputAstAsTypeScript(ast); };
  33005. /**
  33006. * @param {?} stmt
  33007. * @param {?} ctx
  33008. * @return {?}
  33009. */
  33010. StatementInterpreter.prototype.visitDeclareVarStmt = /**
  33011. * @param {?} stmt
  33012. * @param {?} ctx
  33013. * @return {?}
  33014. */
  33015. function (stmt, ctx) {
  33016. ctx.vars.set(stmt.name, stmt.value.visitExpression(this, ctx));
  33017. if (stmt.hasModifier(StmtModifier.Exported)) {
  33018. ctx.exports.push(stmt.name);
  33019. }
  33020. return null;
  33021. };
  33022. /**
  33023. * @param {?} expr
  33024. * @param {?} ctx
  33025. * @return {?}
  33026. */
  33027. StatementInterpreter.prototype.visitWriteVarExpr = /**
  33028. * @param {?} expr
  33029. * @param {?} ctx
  33030. * @return {?}
  33031. */
  33032. function (expr, ctx) {
  33033. var /** @type {?} */ value = expr.value.visitExpression(this, ctx);
  33034. var /** @type {?} */ currCtx = ctx;
  33035. while (currCtx != null) {
  33036. if (currCtx.vars.has(expr.name)) {
  33037. currCtx.vars.set(expr.name, value);
  33038. return value;
  33039. }
  33040. currCtx = /** @type {?} */ ((currCtx.parent));
  33041. }
  33042. throw new Error("Not declared variable " + expr.name);
  33043. };
  33044. /**
  33045. * @param {?} ast
  33046. * @param {?} ctx
  33047. * @return {?}
  33048. */
  33049. StatementInterpreter.prototype.visitReadVarExpr = /**
  33050. * @param {?} ast
  33051. * @param {?} ctx
  33052. * @return {?}
  33053. */
  33054. function (ast, ctx) {
  33055. var /** @type {?} */ varName = /** @type {?} */ ((ast.name));
  33056. if (ast.builtin != null) {
  33057. switch (ast.builtin) {
  33058. case BuiltinVar.Super:
  33059. return ctx.instance.__proto__;
  33060. case BuiltinVar.This:
  33061. return ctx.instance;
  33062. case BuiltinVar.CatchError:
  33063. varName = CATCH_ERROR_VAR$2;
  33064. break;
  33065. case BuiltinVar.CatchStack:
  33066. varName = CATCH_STACK_VAR$2;
  33067. break;
  33068. default:
  33069. throw new Error("Unknown builtin variable " + ast.builtin);
  33070. }
  33071. }
  33072. var /** @type {?} */ currCtx = ctx;
  33073. while (currCtx != null) {
  33074. if (currCtx.vars.has(varName)) {
  33075. return currCtx.vars.get(varName);
  33076. }
  33077. currCtx = /** @type {?} */ ((currCtx.parent));
  33078. }
  33079. throw new Error("Not declared variable " + varName);
  33080. };
  33081. /**
  33082. * @param {?} expr
  33083. * @param {?} ctx
  33084. * @return {?}
  33085. */
  33086. StatementInterpreter.prototype.visitWriteKeyExpr = /**
  33087. * @param {?} expr
  33088. * @param {?} ctx
  33089. * @return {?}
  33090. */
  33091. function (expr, ctx) {
  33092. var /** @type {?} */ receiver = expr.receiver.visitExpression(this, ctx);
  33093. var /** @type {?} */ index = expr.index.visitExpression(this, ctx);
  33094. var /** @type {?} */ value = expr.value.visitExpression(this, ctx);
  33095. receiver[index] = value;
  33096. return value;
  33097. };
  33098. /**
  33099. * @param {?} expr
  33100. * @param {?} ctx
  33101. * @return {?}
  33102. */
  33103. StatementInterpreter.prototype.visitWritePropExpr = /**
  33104. * @param {?} expr
  33105. * @param {?} ctx
  33106. * @return {?}
  33107. */
  33108. function (expr, ctx) {
  33109. var /** @type {?} */ receiver = expr.receiver.visitExpression(this, ctx);
  33110. var /** @type {?} */ value = expr.value.visitExpression(this, ctx);
  33111. receiver[expr.name] = value;
  33112. return value;
  33113. };
  33114. /**
  33115. * @param {?} expr
  33116. * @param {?} ctx
  33117. * @return {?}
  33118. */
  33119. StatementInterpreter.prototype.visitInvokeMethodExpr = /**
  33120. * @param {?} expr
  33121. * @param {?} ctx
  33122. * @return {?}
  33123. */
  33124. function (expr, ctx) {
  33125. var /** @type {?} */ receiver = expr.receiver.visitExpression(this, ctx);
  33126. var /** @type {?} */ args = this.visitAllExpressions(expr.args, ctx);
  33127. var /** @type {?} */ result;
  33128. if (expr.builtin != null) {
  33129. switch (expr.builtin) {
  33130. case BuiltinMethod.ConcatArray:
  33131. result = receiver.concat.apply(receiver, args);
  33132. break;
  33133. case BuiltinMethod.SubscribeObservable:
  33134. result = receiver.subscribe({ next: args[0] });
  33135. break;
  33136. case BuiltinMethod.Bind:
  33137. result = receiver.bind.apply(receiver, args);
  33138. break;
  33139. default:
  33140. throw new Error("Unknown builtin method " + expr.builtin);
  33141. }
  33142. }
  33143. else {
  33144. result = receiver[/** @type {?} */ ((expr.name))].apply(receiver, args);
  33145. }
  33146. return result;
  33147. };
  33148. /**
  33149. * @param {?} stmt
  33150. * @param {?} ctx
  33151. * @return {?}
  33152. */
  33153. StatementInterpreter.prototype.visitInvokeFunctionExpr = /**
  33154. * @param {?} stmt
  33155. * @param {?} ctx
  33156. * @return {?}
  33157. */
  33158. function (stmt, ctx) {
  33159. var /** @type {?} */ args = this.visitAllExpressions(stmt.args, ctx);
  33160. var /** @type {?} */ fnExpr = stmt.fn;
  33161. if (fnExpr instanceof ReadVarExpr && fnExpr.builtin === BuiltinVar.Super) {
  33162. ctx.instance.constructor.prototype.constructor.apply(ctx.instance, args);
  33163. return null;
  33164. }
  33165. else {
  33166. var /** @type {?} */ fn$$1 = stmt.fn.visitExpression(this, ctx);
  33167. return fn$$1.apply(null, args);
  33168. }
  33169. };
  33170. /**
  33171. * @param {?} stmt
  33172. * @param {?} ctx
  33173. * @return {?}
  33174. */
  33175. StatementInterpreter.prototype.visitReturnStmt = /**
  33176. * @param {?} stmt
  33177. * @param {?} ctx
  33178. * @return {?}
  33179. */
  33180. function (stmt, ctx) {
  33181. return new ReturnValue(stmt.value.visitExpression(this, ctx));
  33182. };
  33183. /**
  33184. * @param {?} stmt
  33185. * @param {?} ctx
  33186. * @return {?}
  33187. */
  33188. StatementInterpreter.prototype.visitDeclareClassStmt = /**
  33189. * @param {?} stmt
  33190. * @param {?} ctx
  33191. * @return {?}
  33192. */
  33193. function (stmt, ctx) {
  33194. var /** @type {?} */ clazz = createDynamicClass(stmt, ctx, this);
  33195. ctx.vars.set(stmt.name, clazz);
  33196. if (stmt.hasModifier(StmtModifier.Exported)) {
  33197. ctx.exports.push(stmt.name);
  33198. }
  33199. return null;
  33200. };
  33201. /**
  33202. * @param {?} stmt
  33203. * @param {?} ctx
  33204. * @return {?}
  33205. */
  33206. StatementInterpreter.prototype.visitExpressionStmt = /**
  33207. * @param {?} stmt
  33208. * @param {?} ctx
  33209. * @return {?}
  33210. */
  33211. function (stmt, ctx) {
  33212. return stmt.expr.visitExpression(this, ctx);
  33213. };
  33214. /**
  33215. * @param {?} stmt
  33216. * @param {?} ctx
  33217. * @return {?}
  33218. */
  33219. StatementInterpreter.prototype.visitIfStmt = /**
  33220. * @param {?} stmt
  33221. * @param {?} ctx
  33222. * @return {?}
  33223. */
  33224. function (stmt, ctx) {
  33225. var /** @type {?} */ condition = stmt.condition.visitExpression(this, ctx);
  33226. if (condition) {
  33227. return this.visitAllStatements(stmt.trueCase, ctx);
  33228. }
  33229. else if (stmt.falseCase != null) {
  33230. return this.visitAllStatements(stmt.falseCase, ctx);
  33231. }
  33232. return null;
  33233. };
  33234. /**
  33235. * @param {?} stmt
  33236. * @param {?} ctx
  33237. * @return {?}
  33238. */
  33239. StatementInterpreter.prototype.visitTryCatchStmt = /**
  33240. * @param {?} stmt
  33241. * @param {?} ctx
  33242. * @return {?}
  33243. */
  33244. function (stmt, ctx) {
  33245. try {
  33246. return this.visitAllStatements(stmt.bodyStmts, ctx);
  33247. }
  33248. catch (/** @type {?} */ e) {
  33249. var /** @type {?} */ childCtx = ctx.createChildWihtLocalVars();
  33250. childCtx.vars.set(CATCH_ERROR_VAR$2, e);
  33251. childCtx.vars.set(CATCH_STACK_VAR$2, e.stack);
  33252. return this.visitAllStatements(stmt.catchStmts, childCtx);
  33253. }
  33254. };
  33255. /**
  33256. * @param {?} stmt
  33257. * @param {?} ctx
  33258. * @return {?}
  33259. */
  33260. StatementInterpreter.prototype.visitThrowStmt = /**
  33261. * @param {?} stmt
  33262. * @param {?} ctx
  33263. * @return {?}
  33264. */
  33265. function (stmt, ctx) {
  33266. throw stmt.error.visitExpression(this, ctx);
  33267. };
  33268. /**
  33269. * @param {?} stmt
  33270. * @param {?=} context
  33271. * @return {?}
  33272. */
  33273. StatementInterpreter.prototype.visitCommentStmt = /**
  33274. * @param {?} stmt
  33275. * @param {?=} context
  33276. * @return {?}
  33277. */
  33278. function (stmt, context) { return null; };
  33279. /**
  33280. * @param {?} ast
  33281. * @param {?} ctx
  33282. * @return {?}
  33283. */
  33284. StatementInterpreter.prototype.visitInstantiateExpr = /**
  33285. * @param {?} ast
  33286. * @param {?} ctx
  33287. * @return {?}
  33288. */
  33289. function (ast, ctx) {
  33290. var /** @type {?} */ args = this.visitAllExpressions(ast.args, ctx);
  33291. var /** @type {?} */ clazz = ast.classExpr.visitExpression(this, ctx);
  33292. return new (clazz.bind.apply(clazz, [void 0].concat(args)))();
  33293. };
  33294. /**
  33295. * @param {?} ast
  33296. * @param {?} ctx
  33297. * @return {?}
  33298. */
  33299. StatementInterpreter.prototype.visitLiteralExpr = /**
  33300. * @param {?} ast
  33301. * @param {?} ctx
  33302. * @return {?}
  33303. */
  33304. function (ast, ctx) { return ast.value; };
  33305. /**
  33306. * @param {?} ast
  33307. * @param {?} ctx
  33308. * @return {?}
  33309. */
  33310. StatementInterpreter.prototype.visitExternalExpr = /**
  33311. * @param {?} ast
  33312. * @param {?} ctx
  33313. * @return {?}
  33314. */
  33315. function (ast, ctx) {
  33316. return this.reflector.resolveExternalReference(ast.value);
  33317. };
  33318. /**
  33319. * @param {?} ast
  33320. * @param {?} ctx
  33321. * @return {?}
  33322. */
  33323. StatementInterpreter.prototype.visitConditionalExpr = /**
  33324. * @param {?} ast
  33325. * @param {?} ctx
  33326. * @return {?}
  33327. */
  33328. function (ast, ctx) {
  33329. if (ast.condition.visitExpression(this, ctx)) {
  33330. return ast.trueCase.visitExpression(this, ctx);
  33331. }
  33332. else if (ast.falseCase != null) {
  33333. return ast.falseCase.visitExpression(this, ctx);
  33334. }
  33335. return null;
  33336. };
  33337. /**
  33338. * @param {?} ast
  33339. * @param {?} ctx
  33340. * @return {?}
  33341. */
  33342. StatementInterpreter.prototype.visitNotExpr = /**
  33343. * @param {?} ast
  33344. * @param {?} ctx
  33345. * @return {?}
  33346. */
  33347. function (ast, ctx) {
  33348. return !ast.condition.visitExpression(this, ctx);
  33349. };
  33350. /**
  33351. * @param {?} ast
  33352. * @param {?} ctx
  33353. * @return {?}
  33354. */
  33355. StatementInterpreter.prototype.visitAssertNotNullExpr = /**
  33356. * @param {?} ast
  33357. * @param {?} ctx
  33358. * @return {?}
  33359. */
  33360. function (ast, ctx) {
  33361. return ast.condition.visitExpression(this, ctx);
  33362. };
  33363. /**
  33364. * @param {?} ast
  33365. * @param {?} ctx
  33366. * @return {?}
  33367. */
  33368. StatementInterpreter.prototype.visitCastExpr = /**
  33369. * @param {?} ast
  33370. * @param {?} ctx
  33371. * @return {?}
  33372. */
  33373. function (ast, ctx) {
  33374. return ast.value.visitExpression(this, ctx);
  33375. };
  33376. /**
  33377. * @param {?} ast
  33378. * @param {?} ctx
  33379. * @return {?}
  33380. */
  33381. StatementInterpreter.prototype.visitFunctionExpr = /**
  33382. * @param {?} ast
  33383. * @param {?} ctx
  33384. * @return {?}
  33385. */
  33386. function (ast, ctx) {
  33387. var /** @type {?} */ paramNames = ast.params.map(function (param) { return param.name; });
  33388. return _declareFn(paramNames, ast.statements, ctx, this);
  33389. };
  33390. /**
  33391. * @param {?} stmt
  33392. * @param {?} ctx
  33393. * @return {?}
  33394. */
  33395. StatementInterpreter.prototype.visitDeclareFunctionStmt = /**
  33396. * @param {?} stmt
  33397. * @param {?} ctx
  33398. * @return {?}
  33399. */
  33400. function (stmt, ctx) {
  33401. var /** @type {?} */ paramNames = stmt.params.map(function (param) { return param.name; });
  33402. ctx.vars.set(stmt.name, _declareFn(paramNames, stmt.statements, ctx, this));
  33403. if (stmt.hasModifier(StmtModifier.Exported)) {
  33404. ctx.exports.push(stmt.name);
  33405. }
  33406. return null;
  33407. };
  33408. /**
  33409. * @param {?} ast
  33410. * @param {?} ctx
  33411. * @return {?}
  33412. */
  33413. StatementInterpreter.prototype.visitBinaryOperatorExpr = /**
  33414. * @param {?} ast
  33415. * @param {?} ctx
  33416. * @return {?}
  33417. */
  33418. function (ast, ctx) {
  33419. var _this = this;
  33420. var /** @type {?} */ lhs = function () { return ast.lhs.visitExpression(_this, ctx); };
  33421. var /** @type {?} */ rhs = function () { return ast.rhs.visitExpression(_this, ctx); };
  33422. switch (ast.operator) {
  33423. case BinaryOperator.Equals:
  33424. return lhs() == rhs();
  33425. case BinaryOperator.Identical:
  33426. return lhs() === rhs();
  33427. case BinaryOperator.NotEquals:
  33428. return lhs() != rhs();
  33429. case BinaryOperator.NotIdentical:
  33430. return lhs() !== rhs();
  33431. case BinaryOperator.And:
  33432. return lhs() && rhs();
  33433. case BinaryOperator.Or:
  33434. return lhs() || rhs();
  33435. case BinaryOperator.Plus:
  33436. return lhs() + rhs();
  33437. case BinaryOperator.Minus:
  33438. return lhs() - rhs();
  33439. case BinaryOperator.Divide:
  33440. return lhs() / rhs();
  33441. case BinaryOperator.Multiply:
  33442. return lhs() * rhs();
  33443. case BinaryOperator.Modulo:
  33444. return lhs() % rhs();
  33445. case BinaryOperator.Lower:
  33446. return lhs() < rhs();
  33447. case BinaryOperator.LowerEquals:
  33448. return lhs() <= rhs();
  33449. case BinaryOperator.Bigger:
  33450. return lhs() > rhs();
  33451. case BinaryOperator.BiggerEquals:
  33452. return lhs() >= rhs();
  33453. default:
  33454. throw new Error("Unknown operator " + ast.operator);
  33455. }
  33456. };
  33457. /**
  33458. * @param {?} ast
  33459. * @param {?} ctx
  33460. * @return {?}
  33461. */
  33462. StatementInterpreter.prototype.visitReadPropExpr = /**
  33463. * @param {?} ast
  33464. * @param {?} ctx
  33465. * @return {?}
  33466. */
  33467. function (ast, ctx) {
  33468. var /** @type {?} */ result;
  33469. var /** @type {?} */ receiver = ast.receiver.visitExpression(this, ctx);
  33470. result = receiver[ast.name];
  33471. return result;
  33472. };
  33473. /**
  33474. * @param {?} ast
  33475. * @param {?} ctx
  33476. * @return {?}
  33477. */
  33478. StatementInterpreter.prototype.visitReadKeyExpr = /**
  33479. * @param {?} ast
  33480. * @param {?} ctx
  33481. * @return {?}
  33482. */
  33483. function (ast, ctx) {
  33484. var /** @type {?} */ receiver = ast.receiver.visitExpression(this, ctx);
  33485. var /** @type {?} */ prop = ast.index.visitExpression(this, ctx);
  33486. return receiver[prop];
  33487. };
  33488. /**
  33489. * @param {?} ast
  33490. * @param {?} ctx
  33491. * @return {?}
  33492. */
  33493. StatementInterpreter.prototype.visitLiteralArrayExpr = /**
  33494. * @param {?} ast
  33495. * @param {?} ctx
  33496. * @return {?}
  33497. */
  33498. function (ast, ctx) {
  33499. return this.visitAllExpressions(ast.entries, ctx);
  33500. };
  33501. /**
  33502. * @param {?} ast
  33503. * @param {?} ctx
  33504. * @return {?}
  33505. */
  33506. StatementInterpreter.prototype.visitLiteralMapExpr = /**
  33507. * @param {?} ast
  33508. * @param {?} ctx
  33509. * @return {?}
  33510. */
  33511. function (ast, ctx) {
  33512. var _this = this;
  33513. var /** @type {?} */ result = {};
  33514. ast.entries.forEach(function (entry) { return result[entry.key] = entry.value.visitExpression(_this, ctx); });
  33515. return result;
  33516. };
  33517. /**
  33518. * @param {?} ast
  33519. * @param {?} context
  33520. * @return {?}
  33521. */
  33522. StatementInterpreter.prototype.visitCommaExpr = /**
  33523. * @param {?} ast
  33524. * @param {?} context
  33525. * @return {?}
  33526. */
  33527. function (ast, context) {
  33528. var /** @type {?} */ values = this.visitAllExpressions(ast.parts, context);
  33529. return values[values.length - 1];
  33530. };
  33531. /**
  33532. * @param {?} expressions
  33533. * @param {?} ctx
  33534. * @return {?}
  33535. */
  33536. StatementInterpreter.prototype.visitAllExpressions = /**
  33537. * @param {?} expressions
  33538. * @param {?} ctx
  33539. * @return {?}
  33540. */
  33541. function (expressions, ctx) {
  33542. var _this = this;
  33543. return expressions.map(function (expr) { return expr.visitExpression(_this, ctx); });
  33544. };
  33545. /**
  33546. * @param {?} statements
  33547. * @param {?} ctx
  33548. * @return {?}
  33549. */
  33550. StatementInterpreter.prototype.visitAllStatements = /**
  33551. * @param {?} statements
  33552. * @param {?} ctx
  33553. * @return {?}
  33554. */
  33555. function (statements, ctx) {
  33556. for (var /** @type {?} */ i = 0; i < statements.length; i++) {
  33557. var /** @type {?} */ stmt = statements[i];
  33558. var /** @type {?} */ val = stmt.visitStatement(this, ctx);
  33559. if (val instanceof ReturnValue) {
  33560. return val;
  33561. }
  33562. }
  33563. return null;
  33564. };
  33565. return StatementInterpreter;
  33566. }());
  33567. /**
  33568. * @param {?} varNames
  33569. * @param {?} statements
  33570. * @param {?} ctx
  33571. * @param {?} visitor
  33572. * @return {?}
  33573. */
  33574. function _declareFn(varNames, statements, ctx, visitor) {
  33575. return function () {
  33576. var args = [];
  33577. for (var _i = 0; _i < arguments.length; _i++) {
  33578. args[_i] = arguments[_i];
  33579. }
  33580. return _executeFunctionStatements(varNames, args, statements, ctx, visitor);
  33581. };
  33582. }
  33583. var CATCH_ERROR_VAR$2 = 'error';
  33584. var CATCH_STACK_VAR$2 = 'stack';
  33585. /**
  33586. * @fileoverview added by tsickle
  33587. * @suppress {checkTypes} checked by tsc
  33588. */
  33589. /**
  33590. * @license
  33591. * Copyright Google Inc. All Rights Reserved.
  33592. *
  33593. * Use of this source code is governed by an MIT-style license that can be
  33594. * found in the LICENSE file at https://angular.io/license
  33595. */
  33596. /**
  33597. * @abstract
  33598. */
  33599. var AbstractJsEmitterVisitor = /** @class */ (function (_super) {
  33600. __extends(AbstractJsEmitterVisitor, _super);
  33601. function AbstractJsEmitterVisitor() {
  33602. return _super.call(this, false) || this;
  33603. }
  33604. /**
  33605. * @param {?} stmt
  33606. * @param {?} ctx
  33607. * @return {?}
  33608. */
  33609. AbstractJsEmitterVisitor.prototype.visitDeclareClassStmt = /**
  33610. * @param {?} stmt
  33611. * @param {?} ctx
  33612. * @return {?}
  33613. */
  33614. function (stmt, ctx) {
  33615. var _this = this;
  33616. ctx.pushClass(stmt);
  33617. this._visitClassConstructor(stmt, ctx);
  33618. if (stmt.parent != null) {
  33619. ctx.print(stmt, stmt.name + ".prototype = Object.create(");
  33620. stmt.parent.visitExpression(this, ctx);
  33621. ctx.println(stmt, ".prototype);");
  33622. }
  33623. stmt.getters.forEach(function (getter) { return _this._visitClassGetter(stmt, getter, ctx); });
  33624. stmt.methods.forEach(function (method) { return _this._visitClassMethod(stmt, method, ctx); });
  33625. ctx.popClass();
  33626. return null;
  33627. };
  33628. /**
  33629. * @param {?} stmt
  33630. * @param {?} ctx
  33631. * @return {?}
  33632. */
  33633. AbstractJsEmitterVisitor.prototype._visitClassConstructor = /**
  33634. * @param {?} stmt
  33635. * @param {?} ctx
  33636. * @return {?}
  33637. */
  33638. function (stmt, ctx) {
  33639. ctx.print(stmt, "function " + stmt.name + "(");
  33640. if (stmt.constructorMethod != null) {
  33641. this._visitParams(stmt.constructorMethod.params, ctx);
  33642. }
  33643. ctx.println(stmt, ") {");
  33644. ctx.incIndent();
  33645. if (stmt.constructorMethod != null) {
  33646. if (stmt.constructorMethod.body.length > 0) {
  33647. ctx.println(stmt, "var self = this;");
  33648. this.visitAllStatements(stmt.constructorMethod.body, ctx);
  33649. }
  33650. }
  33651. ctx.decIndent();
  33652. ctx.println(stmt, "}");
  33653. };
  33654. /**
  33655. * @param {?} stmt
  33656. * @param {?} getter
  33657. * @param {?} ctx
  33658. * @return {?}
  33659. */
  33660. AbstractJsEmitterVisitor.prototype._visitClassGetter = /**
  33661. * @param {?} stmt
  33662. * @param {?} getter
  33663. * @param {?} ctx
  33664. * @return {?}
  33665. */
  33666. function (stmt, getter, ctx) {
  33667. ctx.println(stmt, "Object.defineProperty(" + stmt.name + ".prototype, '" + getter.name + "', { get: function() {");
  33668. ctx.incIndent();
  33669. if (getter.body.length > 0) {
  33670. ctx.println(stmt, "var self = this;");
  33671. this.visitAllStatements(getter.body, ctx);
  33672. }
  33673. ctx.decIndent();
  33674. ctx.println(stmt, "}});");
  33675. };
  33676. /**
  33677. * @param {?} stmt
  33678. * @param {?} method
  33679. * @param {?} ctx
  33680. * @return {?}
  33681. */
  33682. AbstractJsEmitterVisitor.prototype._visitClassMethod = /**
  33683. * @param {?} stmt
  33684. * @param {?} method
  33685. * @param {?} ctx
  33686. * @return {?}
  33687. */
  33688. function (stmt, method, ctx) {
  33689. ctx.print(stmt, stmt.name + ".prototype." + method.name + " = function(");
  33690. this._visitParams(method.params, ctx);
  33691. ctx.println(stmt, ") {");
  33692. ctx.incIndent();
  33693. if (method.body.length > 0) {
  33694. ctx.println(stmt, "var self = this;");
  33695. this.visitAllStatements(method.body, ctx);
  33696. }
  33697. ctx.decIndent();
  33698. ctx.println(stmt, "};");
  33699. };
  33700. /**
  33701. * @param {?} ast
  33702. * @param {?} ctx
  33703. * @return {?}
  33704. */
  33705. AbstractJsEmitterVisitor.prototype.visitReadVarExpr = /**
  33706. * @param {?} ast
  33707. * @param {?} ctx
  33708. * @return {?}
  33709. */
  33710. function (ast, ctx) {
  33711. if (ast.builtin === BuiltinVar.This) {
  33712. ctx.print(ast, 'self');
  33713. }
  33714. else if (ast.builtin === BuiltinVar.Super) {
  33715. throw new Error("'super' needs to be handled at a parent ast node, not at the variable level!");
  33716. }
  33717. else {
  33718. _super.prototype.visitReadVarExpr.call(this, ast, ctx);
  33719. }
  33720. return null;
  33721. };
  33722. /**
  33723. * @param {?} stmt
  33724. * @param {?} ctx
  33725. * @return {?}
  33726. */
  33727. AbstractJsEmitterVisitor.prototype.visitDeclareVarStmt = /**
  33728. * @param {?} stmt
  33729. * @param {?} ctx
  33730. * @return {?}
  33731. */
  33732. function (stmt, ctx) {
  33733. ctx.print(stmt, "var " + stmt.name + " = ");
  33734. stmt.value.visitExpression(this, ctx);
  33735. ctx.println(stmt, ";");
  33736. return null;
  33737. };
  33738. /**
  33739. * @param {?} ast
  33740. * @param {?} ctx
  33741. * @return {?}
  33742. */
  33743. AbstractJsEmitterVisitor.prototype.visitCastExpr = /**
  33744. * @param {?} ast
  33745. * @param {?} ctx
  33746. * @return {?}
  33747. */
  33748. function (ast, ctx) {
  33749. ast.value.visitExpression(this, ctx);
  33750. return null;
  33751. };
  33752. /**
  33753. * @param {?} expr
  33754. * @param {?} ctx
  33755. * @return {?}
  33756. */
  33757. AbstractJsEmitterVisitor.prototype.visitInvokeFunctionExpr = /**
  33758. * @param {?} expr
  33759. * @param {?} ctx
  33760. * @return {?}
  33761. */
  33762. function (expr, ctx) {
  33763. var /** @type {?} */ fnExpr = expr.fn;
  33764. if (fnExpr instanceof ReadVarExpr && fnExpr.builtin === BuiltinVar.Super) {
  33765. /** @type {?} */ ((/** @type {?} */ ((ctx.currentClass)).parent)).visitExpression(this, ctx);
  33766. ctx.print(expr, ".call(this");
  33767. if (expr.args.length > 0) {
  33768. ctx.print(expr, ", ");
  33769. this.visitAllExpressions(expr.args, ctx, ',');
  33770. }
  33771. ctx.print(expr, ")");
  33772. }
  33773. else {
  33774. _super.prototype.visitInvokeFunctionExpr.call(this, expr, ctx);
  33775. }
  33776. return null;
  33777. };
  33778. /**
  33779. * @param {?} ast
  33780. * @param {?} ctx
  33781. * @return {?}
  33782. */
  33783. AbstractJsEmitterVisitor.prototype.visitFunctionExpr = /**
  33784. * @param {?} ast
  33785. * @param {?} ctx
  33786. * @return {?}
  33787. */
  33788. function (ast, ctx) {
  33789. ctx.print(ast, "function(");
  33790. this._visitParams(ast.params, ctx);
  33791. ctx.println(ast, ") {");
  33792. ctx.incIndent();
  33793. this.visitAllStatements(ast.statements, ctx);
  33794. ctx.decIndent();
  33795. ctx.print(ast, "}");
  33796. return null;
  33797. };
  33798. /**
  33799. * @param {?} stmt
  33800. * @param {?} ctx
  33801. * @return {?}
  33802. */
  33803. AbstractJsEmitterVisitor.prototype.visitDeclareFunctionStmt = /**
  33804. * @param {?} stmt
  33805. * @param {?} ctx
  33806. * @return {?}
  33807. */
  33808. function (stmt, ctx) {
  33809. ctx.print(stmt, "function " + stmt.name + "(");
  33810. this._visitParams(stmt.params, ctx);
  33811. ctx.println(stmt, ") {");
  33812. ctx.incIndent();
  33813. this.visitAllStatements(stmt.statements, ctx);
  33814. ctx.decIndent();
  33815. ctx.println(stmt, "}");
  33816. return null;
  33817. };
  33818. /**
  33819. * @param {?} stmt
  33820. * @param {?} ctx
  33821. * @return {?}
  33822. */
  33823. AbstractJsEmitterVisitor.prototype.visitTryCatchStmt = /**
  33824. * @param {?} stmt
  33825. * @param {?} ctx
  33826. * @return {?}
  33827. */
  33828. function (stmt, ctx) {
  33829. ctx.println(stmt, "try {");
  33830. ctx.incIndent();
  33831. this.visitAllStatements(stmt.bodyStmts, ctx);
  33832. ctx.decIndent();
  33833. ctx.println(stmt, "} catch (" + CATCH_ERROR_VAR$1.name + ") {");
  33834. ctx.incIndent();
  33835. var /** @type {?} */ catchStmts = [/** @type {?} */ (CATCH_STACK_VAR$1.set(CATCH_ERROR_VAR$1.prop('stack')).toDeclStmt(null, [
  33836. StmtModifier.Final
  33837. ]))].concat(stmt.catchStmts);
  33838. this.visitAllStatements(catchStmts, ctx);
  33839. ctx.decIndent();
  33840. ctx.println(stmt, "}");
  33841. return null;
  33842. };
  33843. /**
  33844. * @param {?} params
  33845. * @param {?} ctx
  33846. * @return {?}
  33847. */
  33848. AbstractJsEmitterVisitor.prototype._visitParams = /**
  33849. * @param {?} params
  33850. * @param {?} ctx
  33851. * @return {?}
  33852. */
  33853. function (params, ctx) {
  33854. this.visitAllObjects(function (param) { return ctx.print(null, param.name); }, params, ctx, ',');
  33855. };
  33856. /**
  33857. * @param {?} method
  33858. * @return {?}
  33859. */
  33860. AbstractJsEmitterVisitor.prototype.getBuiltinMethodName = /**
  33861. * @param {?} method
  33862. * @return {?}
  33863. */
  33864. function (method) {
  33865. var /** @type {?} */ name;
  33866. switch (method) {
  33867. case BuiltinMethod.ConcatArray:
  33868. name = 'concat';
  33869. break;
  33870. case BuiltinMethod.SubscribeObservable:
  33871. name = 'subscribe';
  33872. break;
  33873. case BuiltinMethod.Bind:
  33874. name = 'bind';
  33875. break;
  33876. default:
  33877. throw new Error("Unknown builtin method: " + method);
  33878. }
  33879. return name;
  33880. };
  33881. return AbstractJsEmitterVisitor;
  33882. }(AbstractEmitterVisitor));
  33883. /**
  33884. * @fileoverview added by tsickle
  33885. * @suppress {checkTypes} checked by tsc
  33886. */
  33887. /**
  33888. * @license
  33889. * Copyright Google Inc. All Rights Reserved.
  33890. *
  33891. * Use of this source code is governed by an MIT-style license that can be
  33892. * found in the LICENSE file at https://angular.io/license
  33893. */
  33894. /**
  33895. * @param {?} sourceUrl
  33896. * @param {?} ctx
  33897. * @param {?} vars
  33898. * @param {?} createSourceMap
  33899. * @return {?}
  33900. */
  33901. function evalExpression(sourceUrl, ctx, vars, createSourceMap) {
  33902. var /** @type {?} */ fnBody = ctx.toSource() + "\n//# sourceURL=" + sourceUrl;
  33903. var /** @type {?} */ fnArgNames = [];
  33904. var /** @type {?} */ fnArgValues = [];
  33905. for (var /** @type {?} */ argName in vars) {
  33906. fnArgNames.push(argName);
  33907. fnArgValues.push(vars[argName]);
  33908. }
  33909. if (createSourceMap) {
  33910. // using `new Function(...)` generates a header, 1 line of no arguments, 2 lines otherwise
  33911. // E.g. ```
  33912. // function anonymous(a,b,c
  33913. // /**/) { ... }```
  33914. // We don't want to hard code this fact, so we auto detect it via an empty function first.
  33915. var /** @type {?} */ emptyFn = new (Function.bind.apply(Function, [void 0].concat(fnArgNames.concat('return null;'))))().toString();
  33916. var /** @type {?} */ headerLines = emptyFn.slice(0, emptyFn.indexOf('return null;')).split('\n').length - 1;
  33917. fnBody += "\n" + ctx.toSourceMapGenerator(sourceUrl, headerLines).toJsComment();
  33918. }
  33919. return new (Function.bind.apply(Function, [void 0].concat(fnArgNames.concat(fnBody))))().apply(void 0, fnArgValues);
  33920. }
  33921. /**
  33922. * @param {?} sourceUrl
  33923. * @param {?} statements
  33924. * @param {?} reflector
  33925. * @param {?} createSourceMaps
  33926. * @return {?}
  33927. */
  33928. function jitStatements(sourceUrl, statements, reflector, createSourceMaps) {
  33929. var /** @type {?} */ converter = new JitEmitterVisitor(reflector);
  33930. var /** @type {?} */ ctx = EmitterVisitorContext.createRoot();
  33931. converter.visitAllStatements(statements, ctx);
  33932. converter.createReturnStmt(ctx);
  33933. return evalExpression(sourceUrl, ctx, converter.getArgs(), createSourceMaps);
  33934. }
  33935. var JitEmitterVisitor = /** @class */ (function (_super) {
  33936. __extends(JitEmitterVisitor, _super);
  33937. function JitEmitterVisitor(reflector) {
  33938. var _this = _super.call(this) || this;
  33939. _this.reflector = reflector;
  33940. _this._evalArgNames = [];
  33941. _this._evalArgValues = [];
  33942. _this._evalExportedVars = [];
  33943. return _this;
  33944. }
  33945. /**
  33946. * @param {?} ctx
  33947. * @return {?}
  33948. */
  33949. JitEmitterVisitor.prototype.createReturnStmt = /**
  33950. * @param {?} ctx
  33951. * @return {?}
  33952. */
  33953. function (ctx) {
  33954. var /** @type {?} */ stmt = new ReturnStatement(new LiteralMapExpr(this._evalExportedVars.map(function (resultVar) { return new LiteralMapEntry(resultVar, variable(resultVar), false); })));
  33955. stmt.visitStatement(this, ctx);
  33956. };
  33957. /**
  33958. * @return {?}
  33959. */
  33960. JitEmitterVisitor.prototype.getArgs = /**
  33961. * @return {?}
  33962. */
  33963. function () {
  33964. var /** @type {?} */ result = {};
  33965. for (var /** @type {?} */ i = 0; i < this._evalArgNames.length; i++) {
  33966. result[this._evalArgNames[i]] = this._evalArgValues[i];
  33967. }
  33968. return result;
  33969. };
  33970. /**
  33971. * @param {?} ast
  33972. * @param {?} ctx
  33973. * @return {?}
  33974. */
  33975. JitEmitterVisitor.prototype.visitExternalExpr = /**
  33976. * @param {?} ast
  33977. * @param {?} ctx
  33978. * @return {?}
  33979. */
  33980. function (ast, ctx) {
  33981. var /** @type {?} */ value = this.reflector.resolveExternalReference(ast.value);
  33982. var /** @type {?} */ id = this._evalArgValues.indexOf(value);
  33983. if (id === -1) {
  33984. id = this._evalArgValues.length;
  33985. this._evalArgValues.push(value);
  33986. var /** @type {?} */ name_1 = identifierName({ reference: value }) || 'val';
  33987. this._evalArgNames.push("jit_" + name_1 + "_" + id);
  33988. }
  33989. ctx.print(ast, this._evalArgNames[id]);
  33990. return null;
  33991. };
  33992. /**
  33993. * @param {?} stmt
  33994. * @param {?} ctx
  33995. * @return {?}
  33996. */
  33997. JitEmitterVisitor.prototype.visitDeclareVarStmt = /**
  33998. * @param {?} stmt
  33999. * @param {?} ctx
  34000. * @return {?}
  34001. */
  34002. function (stmt, ctx) {
  34003. if (stmt.hasModifier(StmtModifier.Exported)) {
  34004. this._evalExportedVars.push(stmt.name);
  34005. }
  34006. return _super.prototype.visitDeclareVarStmt.call(this, stmt, ctx);
  34007. };
  34008. /**
  34009. * @param {?} stmt
  34010. * @param {?} ctx
  34011. * @return {?}
  34012. */
  34013. JitEmitterVisitor.prototype.visitDeclareFunctionStmt = /**
  34014. * @param {?} stmt
  34015. * @param {?} ctx
  34016. * @return {?}
  34017. */
  34018. function (stmt, ctx) {
  34019. if (stmt.hasModifier(StmtModifier.Exported)) {
  34020. this._evalExportedVars.push(stmt.name);
  34021. }
  34022. return _super.prototype.visitDeclareFunctionStmt.call(this, stmt, ctx);
  34023. };
  34024. /**
  34025. * @param {?} stmt
  34026. * @param {?} ctx
  34027. * @return {?}
  34028. */
  34029. JitEmitterVisitor.prototype.visitDeclareClassStmt = /**
  34030. * @param {?} stmt
  34031. * @param {?} ctx
  34032. * @return {?}
  34033. */
  34034. function (stmt, ctx) {
  34035. if (stmt.hasModifier(StmtModifier.Exported)) {
  34036. this._evalExportedVars.push(stmt.name);
  34037. }
  34038. return _super.prototype.visitDeclareClassStmt.call(this, stmt, ctx);
  34039. };
  34040. return JitEmitterVisitor;
  34041. }(AbstractJsEmitterVisitor));
  34042. /**
  34043. * @fileoverview added by tsickle
  34044. * @suppress {checkTypes} checked by tsc
  34045. */
  34046. /**
  34047. * @license
  34048. * Copyright Google Inc. All Rights Reserved.
  34049. *
  34050. * Use of this source code is governed by an MIT-style license that can be
  34051. * found in the LICENSE file at https://angular.io/license
  34052. */
  34053. /**
  34054. * @record
  34055. */
  34056. /**
  34057. * An internal module of the Angular compiler that begins with component types,
  34058. * extracts templates, and eventually produces a compiled version of the component
  34059. * ready for linking into an application.
  34060. *
  34061. * \@security When compiling templates at runtime, you must ensure that the entire template comes
  34062. * from a trusted source. Attacker-controlled data introduced by a template could expose your
  34063. * application to XSS risks. For more detail, see the [Security Guide](http://g.co/ng/security).
  34064. */
  34065. var JitCompiler = /** @class */ (function () {
  34066. function JitCompiler(_metadataResolver, _templateParser, _styleCompiler, _viewCompiler, _ngModuleCompiler, _summaryResolver, _reflector, _compilerConfig, _console, getExtraNgModuleProviders) {
  34067. this._metadataResolver = _metadataResolver;
  34068. this._templateParser = _templateParser;
  34069. this._styleCompiler = _styleCompiler;
  34070. this._viewCompiler = _viewCompiler;
  34071. this._ngModuleCompiler = _ngModuleCompiler;
  34072. this._summaryResolver = _summaryResolver;
  34073. this._reflector = _reflector;
  34074. this._compilerConfig = _compilerConfig;
  34075. this._console = _console;
  34076. this.getExtraNgModuleProviders = getExtraNgModuleProviders;
  34077. this._compiledTemplateCache = new Map();
  34078. this._compiledHostTemplateCache = new Map();
  34079. this._compiledDirectiveWrapperCache = new Map();
  34080. this._compiledNgModuleCache = new Map();
  34081. this._sharedStylesheetCount = 0;
  34082. this._addedAotSummaries = new Set();
  34083. }
  34084. /**
  34085. * @param {?} moduleType
  34086. * @return {?}
  34087. */
  34088. JitCompiler.prototype.compileModuleSync = /**
  34089. * @param {?} moduleType
  34090. * @return {?}
  34091. */
  34092. function (moduleType) {
  34093. return SyncAsync.assertSync(this._compileModuleAndComponents(moduleType, true));
  34094. };
  34095. /**
  34096. * @param {?} moduleType
  34097. * @return {?}
  34098. */
  34099. JitCompiler.prototype.compileModuleAsync = /**
  34100. * @param {?} moduleType
  34101. * @return {?}
  34102. */
  34103. function (moduleType) {
  34104. return Promise.resolve(this._compileModuleAndComponents(moduleType, false));
  34105. };
  34106. /**
  34107. * @param {?} moduleType
  34108. * @return {?}
  34109. */
  34110. JitCompiler.prototype.compileModuleAndAllComponentsSync = /**
  34111. * @param {?} moduleType
  34112. * @return {?}
  34113. */
  34114. function (moduleType) {
  34115. return SyncAsync.assertSync(this._compileModuleAndAllComponents(moduleType, true));
  34116. };
  34117. /**
  34118. * @param {?} moduleType
  34119. * @return {?}
  34120. */
  34121. JitCompiler.prototype.compileModuleAndAllComponentsAsync = /**
  34122. * @param {?} moduleType
  34123. * @return {?}
  34124. */
  34125. function (moduleType) {
  34126. return Promise.resolve(this._compileModuleAndAllComponents(moduleType, false));
  34127. };
  34128. /**
  34129. * @param {?} component
  34130. * @return {?}
  34131. */
  34132. JitCompiler.prototype.getComponentFactory = /**
  34133. * @param {?} component
  34134. * @return {?}
  34135. */
  34136. function (component) {
  34137. var /** @type {?} */ summary = this._metadataResolver.getDirectiveSummary(component);
  34138. return /** @type {?} */ (summary.componentFactory);
  34139. };
  34140. /**
  34141. * @param {?} summaries
  34142. * @return {?}
  34143. */
  34144. JitCompiler.prototype.loadAotSummaries = /**
  34145. * @param {?} summaries
  34146. * @return {?}
  34147. */
  34148. function (summaries) {
  34149. this.clearCache();
  34150. this._addAotSummaries(summaries);
  34151. };
  34152. /**
  34153. * @param {?} fn
  34154. * @return {?}
  34155. */
  34156. JitCompiler.prototype._addAotSummaries = /**
  34157. * @param {?} fn
  34158. * @return {?}
  34159. */
  34160. function (fn$$1) {
  34161. if (this._addedAotSummaries.has(fn$$1)) {
  34162. return;
  34163. }
  34164. this._addedAotSummaries.add(fn$$1);
  34165. var /** @type {?} */ summaries = fn$$1();
  34166. for (var /** @type {?} */ i = 0; i < summaries.length; i++) {
  34167. var /** @type {?} */ entry = summaries[i];
  34168. if (typeof entry === 'function') {
  34169. this._addAotSummaries(entry);
  34170. }
  34171. else {
  34172. var /** @type {?} */ summary = /** @type {?} */ (entry);
  34173. this._summaryResolver.addSummary({ symbol: summary.type.reference, metadata: null, type: summary });
  34174. }
  34175. }
  34176. };
  34177. /**
  34178. * @param {?} ref
  34179. * @return {?}
  34180. */
  34181. JitCompiler.prototype.hasAotSummary = /**
  34182. * @param {?} ref
  34183. * @return {?}
  34184. */
  34185. function (ref) { return !!this._summaryResolver.resolveSummary(ref); };
  34186. /**
  34187. * @param {?} ids
  34188. * @return {?}
  34189. */
  34190. JitCompiler.prototype._filterJitIdentifiers = /**
  34191. * @param {?} ids
  34192. * @return {?}
  34193. */
  34194. function (ids) {
  34195. var _this = this;
  34196. return ids.map(function (mod) { return mod.reference; }).filter(function (ref) { return !_this.hasAotSummary(ref); });
  34197. };
  34198. /**
  34199. * @param {?} moduleType
  34200. * @param {?} isSync
  34201. * @return {?}
  34202. */
  34203. JitCompiler.prototype._compileModuleAndComponents = /**
  34204. * @param {?} moduleType
  34205. * @param {?} isSync
  34206. * @return {?}
  34207. */
  34208. function (moduleType, isSync) {
  34209. var _this = this;
  34210. return SyncAsync.then(this._loadModules(moduleType, isSync), function () {
  34211. _this._compileComponents(moduleType, null);
  34212. return _this._compileModule(moduleType);
  34213. });
  34214. };
  34215. /**
  34216. * @param {?} moduleType
  34217. * @param {?} isSync
  34218. * @return {?}
  34219. */
  34220. JitCompiler.prototype._compileModuleAndAllComponents = /**
  34221. * @param {?} moduleType
  34222. * @param {?} isSync
  34223. * @return {?}
  34224. */
  34225. function (moduleType, isSync) {
  34226. var _this = this;
  34227. return SyncAsync.then(this._loadModules(moduleType, isSync), function () {
  34228. var /** @type {?} */ componentFactories = [];
  34229. _this._compileComponents(moduleType, componentFactories);
  34230. return {
  34231. ngModuleFactory: _this._compileModule(moduleType),
  34232. componentFactories: componentFactories
  34233. };
  34234. });
  34235. };
  34236. /**
  34237. * @param {?} mainModule
  34238. * @param {?} isSync
  34239. * @return {?}
  34240. */
  34241. JitCompiler.prototype._loadModules = /**
  34242. * @param {?} mainModule
  34243. * @param {?} isSync
  34244. * @return {?}
  34245. */
  34246. function (mainModule, isSync) {
  34247. var _this = this;
  34248. var /** @type {?} */ loading = [];
  34249. var /** @type {?} */ mainNgModule = /** @type {?} */ ((this._metadataResolver.getNgModuleMetadata(mainModule)));
  34250. // Note: for runtime compilation, we want to transitively compile all modules,
  34251. // so we also need to load the declared directives / pipes for all nested modules.
  34252. this._filterJitIdentifiers(mainNgModule.transitiveModule.modules).forEach(function (nestedNgModule) {
  34253. // getNgModuleMetadata only returns null if the value passed in is not an NgModule
  34254. var /** @type {?} */ moduleMeta = /** @type {?} */ ((_this._metadataResolver.getNgModuleMetadata(nestedNgModule)));
  34255. _this._filterJitIdentifiers(moduleMeta.declaredDirectives).forEach(function (ref) {
  34256. var /** @type {?} */ promise = _this._metadataResolver.loadDirectiveMetadata(moduleMeta.type.reference, ref, isSync);
  34257. if (promise) {
  34258. loading.push(promise);
  34259. }
  34260. });
  34261. _this._filterJitIdentifiers(moduleMeta.declaredPipes)
  34262. .forEach(function (ref) { return _this._metadataResolver.getOrLoadPipeMetadata(ref); });
  34263. });
  34264. return SyncAsync.all(loading);
  34265. };
  34266. /**
  34267. * @param {?} moduleType
  34268. * @return {?}
  34269. */
  34270. JitCompiler.prototype._compileModule = /**
  34271. * @param {?} moduleType
  34272. * @return {?}
  34273. */
  34274. function (moduleType) {
  34275. var /** @type {?} */ ngModuleFactory = /** @type {?} */ ((this._compiledNgModuleCache.get(moduleType)));
  34276. if (!ngModuleFactory) {
  34277. var /** @type {?} */ moduleMeta = /** @type {?} */ ((this._metadataResolver.getNgModuleMetadata(moduleType)));
  34278. // Always provide a bound Compiler
  34279. var /** @type {?} */ extraProviders = this.getExtraNgModuleProviders(moduleMeta.type.reference);
  34280. var /** @type {?} */ outputCtx = createOutputContext();
  34281. var /** @type {?} */ compileResult = this._ngModuleCompiler.compile(outputCtx, moduleMeta, extraProviders);
  34282. ngModuleFactory = this._interpretOrJit(ngModuleJitUrl(moduleMeta), outputCtx.statements)[compileResult.ngModuleFactoryVar];
  34283. this._compiledNgModuleCache.set(moduleMeta.type.reference, ngModuleFactory);
  34284. }
  34285. return ngModuleFactory;
  34286. };
  34287. /**
  34288. * @internal
  34289. */
  34290. /**
  34291. * \@internal
  34292. * @param {?} mainModule
  34293. * @param {?} allComponentFactories
  34294. * @return {?}
  34295. */
  34296. JitCompiler.prototype._compileComponents = /**
  34297. * \@internal
  34298. * @param {?} mainModule
  34299. * @param {?} allComponentFactories
  34300. * @return {?}
  34301. */
  34302. function (mainModule, allComponentFactories) {
  34303. var _this = this;
  34304. var /** @type {?} */ ngModule = /** @type {?} */ ((this._metadataResolver.getNgModuleMetadata(mainModule)));
  34305. var /** @type {?} */ moduleByJitDirective = new Map();
  34306. var /** @type {?} */ templates = new Set();
  34307. var /** @type {?} */ transJitModules = this._filterJitIdentifiers(ngModule.transitiveModule.modules);
  34308. transJitModules.forEach(function (localMod) {
  34309. var /** @type {?} */ localModuleMeta = /** @type {?} */ ((_this._metadataResolver.getNgModuleMetadata(localMod)));
  34310. _this._filterJitIdentifiers(localModuleMeta.declaredDirectives).forEach(function (dirRef) {
  34311. moduleByJitDirective.set(dirRef, localModuleMeta);
  34312. var /** @type {?} */ dirMeta = _this._metadataResolver.getDirectiveMetadata(dirRef);
  34313. if (dirMeta.isComponent) {
  34314. templates.add(_this._createCompiledTemplate(dirMeta, localModuleMeta));
  34315. if (allComponentFactories) {
  34316. var /** @type {?} */ template = _this._createCompiledHostTemplate(dirMeta.type.reference, localModuleMeta);
  34317. templates.add(template);
  34318. allComponentFactories.push(/** @type {?} */ (dirMeta.componentFactory));
  34319. }
  34320. }
  34321. });
  34322. });
  34323. transJitModules.forEach(function (localMod) {
  34324. var /** @type {?} */ localModuleMeta = /** @type {?} */ ((_this._metadataResolver.getNgModuleMetadata(localMod)));
  34325. _this._filterJitIdentifiers(localModuleMeta.declaredDirectives).forEach(function (dirRef) {
  34326. var /** @type {?} */ dirMeta = _this._metadataResolver.getDirectiveMetadata(dirRef);
  34327. if (dirMeta.isComponent) {
  34328. dirMeta.entryComponents.forEach(function (entryComponentType) {
  34329. var /** @type {?} */ moduleMeta = /** @type {?} */ ((moduleByJitDirective.get(entryComponentType.componentType)));
  34330. templates.add(_this._createCompiledHostTemplate(entryComponentType.componentType, moduleMeta));
  34331. });
  34332. }
  34333. });
  34334. localModuleMeta.entryComponents.forEach(function (entryComponentType) {
  34335. if (!_this.hasAotSummary(entryComponentType.componentType.reference)) {
  34336. var /** @type {?} */ moduleMeta = /** @type {?} */ ((moduleByJitDirective.get(entryComponentType.componentType)));
  34337. templates.add(_this._createCompiledHostTemplate(entryComponentType.componentType, moduleMeta));
  34338. }
  34339. });
  34340. });
  34341. templates.forEach(function (template) { return _this._compileTemplate(template); });
  34342. };
  34343. /**
  34344. * @param {?} type
  34345. * @return {?}
  34346. */
  34347. JitCompiler.prototype.clearCacheFor = /**
  34348. * @param {?} type
  34349. * @return {?}
  34350. */
  34351. function (type) {
  34352. this._compiledNgModuleCache.delete(type);
  34353. this._metadataResolver.clearCacheFor(type);
  34354. this._compiledHostTemplateCache.delete(type);
  34355. var /** @type {?} */ compiledTemplate = this._compiledTemplateCache.get(type);
  34356. if (compiledTemplate) {
  34357. this._compiledTemplateCache.delete(type);
  34358. }
  34359. };
  34360. /**
  34361. * @return {?}
  34362. */
  34363. JitCompiler.prototype.clearCache = /**
  34364. * @return {?}
  34365. */
  34366. function () {
  34367. // Note: don't clear the _addedAotSummaries, as they don't change!
  34368. this._metadataResolver.clearCache();
  34369. this._compiledTemplateCache.clear();
  34370. this._compiledHostTemplateCache.clear();
  34371. this._compiledNgModuleCache.clear();
  34372. };
  34373. /**
  34374. * @param {?} compType
  34375. * @param {?} ngModule
  34376. * @return {?}
  34377. */
  34378. JitCompiler.prototype._createCompiledHostTemplate = /**
  34379. * @param {?} compType
  34380. * @param {?} ngModule
  34381. * @return {?}
  34382. */
  34383. function (compType, ngModule) {
  34384. if (!ngModule) {
  34385. throw new Error("Component " + stringify(compType) + " is not part of any NgModule or the module has not been imported into your module.");
  34386. }
  34387. var /** @type {?} */ compiledTemplate = this._compiledHostTemplateCache.get(compType);
  34388. if (!compiledTemplate) {
  34389. var /** @type {?} */ compMeta = this._metadataResolver.getDirectiveMetadata(compType);
  34390. assertComponent(compMeta);
  34391. var /** @type {?} */ hostMeta = this._metadataResolver.getHostComponentMetadata(compMeta, (/** @type {?} */ (compMeta.componentFactory)).viewDefFactory);
  34392. compiledTemplate =
  34393. new CompiledTemplate(true, compMeta.type, hostMeta, ngModule, [compMeta.type]);
  34394. this._compiledHostTemplateCache.set(compType, compiledTemplate);
  34395. }
  34396. return compiledTemplate;
  34397. };
  34398. /**
  34399. * @param {?} compMeta
  34400. * @param {?} ngModule
  34401. * @return {?}
  34402. */
  34403. JitCompiler.prototype._createCompiledTemplate = /**
  34404. * @param {?} compMeta
  34405. * @param {?} ngModule
  34406. * @return {?}
  34407. */
  34408. function (compMeta, ngModule) {
  34409. var /** @type {?} */ compiledTemplate = this._compiledTemplateCache.get(compMeta.type.reference);
  34410. if (!compiledTemplate) {
  34411. assertComponent(compMeta);
  34412. compiledTemplate = new CompiledTemplate(false, compMeta.type, compMeta, ngModule, ngModule.transitiveModule.directives);
  34413. this._compiledTemplateCache.set(compMeta.type.reference, compiledTemplate);
  34414. }
  34415. return compiledTemplate;
  34416. };
  34417. /**
  34418. * @param {?} template
  34419. * @return {?}
  34420. */
  34421. JitCompiler.prototype._compileTemplate = /**
  34422. * @param {?} template
  34423. * @return {?}
  34424. */
  34425. function (template) {
  34426. var _this = this;
  34427. if (template.isCompiled) {
  34428. return;
  34429. }
  34430. var /** @type {?} */ compMeta = template.compMeta;
  34431. var /** @type {?} */ externalStylesheetsByModuleUrl = new Map();
  34432. var /** @type {?} */ outputContext = createOutputContext();
  34433. var /** @type {?} */ componentStylesheet = this._styleCompiler.compileComponent(outputContext, compMeta); /** @type {?} */
  34434. ((compMeta.template)).externalStylesheets.forEach(function (stylesheetMeta) {
  34435. var /** @type {?} */ compiledStylesheet = _this._styleCompiler.compileStyles(createOutputContext(), compMeta, stylesheetMeta);
  34436. externalStylesheetsByModuleUrl.set(/** @type {?} */ ((stylesheetMeta.moduleUrl)), compiledStylesheet);
  34437. });
  34438. this._resolveStylesCompileResult(componentStylesheet, externalStylesheetsByModuleUrl);
  34439. var /** @type {?} */ pipes = template.ngModule.transitiveModule.pipes.map(function (pipe) { return _this._metadataResolver.getPipeSummary(pipe.reference); });
  34440. var _a = this._parseTemplate(compMeta, template.ngModule, template.directives), parsedTemplate = _a.template, usedPipes = _a.pipes;
  34441. var /** @type {?} */ compileResult = this._viewCompiler.compileComponent(outputContext, compMeta, parsedTemplate, variable(componentStylesheet.stylesVar), usedPipes);
  34442. var /** @type {?} */ evalResult = this._interpretOrJit(templateJitUrl(template.ngModule.type, template.compMeta), outputContext.statements);
  34443. var /** @type {?} */ viewClass = evalResult[compileResult.viewClassVar];
  34444. var /** @type {?} */ rendererType = evalResult[compileResult.rendererTypeVar];
  34445. template.compiled(viewClass, rendererType);
  34446. };
  34447. /**
  34448. * @param {?} compMeta
  34449. * @param {?} ngModule
  34450. * @param {?} directiveIdentifiers
  34451. * @return {?}
  34452. */
  34453. JitCompiler.prototype._parseTemplate = /**
  34454. * @param {?} compMeta
  34455. * @param {?} ngModule
  34456. * @param {?} directiveIdentifiers
  34457. * @return {?}
  34458. */
  34459. function (compMeta, ngModule, directiveIdentifiers) {
  34460. var _this = this;
  34461. // Note: ! is ok here as components always have a template.
  34462. var /** @type {?} */ preserveWhitespaces = /** @type {?} */ ((compMeta.template)).preserveWhitespaces;
  34463. var /** @type {?} */ directives = directiveIdentifiers.map(function (dir) { return _this._metadataResolver.getDirectiveSummary(dir.reference); });
  34464. var /** @type {?} */ pipes = ngModule.transitiveModule.pipes.map(function (pipe) { return _this._metadataResolver.getPipeSummary(pipe.reference); });
  34465. return this._templateParser.parse(compMeta, /** @type {?} */ ((/** @type {?} */ ((compMeta.template)).htmlAst)), directives, pipes, ngModule.schemas, templateSourceUrl(ngModule.type, compMeta, /** @type {?} */ ((compMeta.template))), preserveWhitespaces);
  34466. };
  34467. /**
  34468. * @param {?} result
  34469. * @param {?} externalStylesheetsByModuleUrl
  34470. * @return {?}
  34471. */
  34472. JitCompiler.prototype._resolveStylesCompileResult = /**
  34473. * @param {?} result
  34474. * @param {?} externalStylesheetsByModuleUrl
  34475. * @return {?}
  34476. */
  34477. function (result, externalStylesheetsByModuleUrl) {
  34478. var _this = this;
  34479. result.dependencies.forEach(function (dep, i) {
  34480. var /** @type {?} */ nestedCompileResult = /** @type {?} */ ((externalStylesheetsByModuleUrl.get(dep.moduleUrl)));
  34481. var /** @type {?} */ nestedStylesArr = _this._resolveAndEvalStylesCompileResult(nestedCompileResult, externalStylesheetsByModuleUrl);
  34482. dep.setValue(nestedStylesArr);
  34483. });
  34484. };
  34485. /**
  34486. * @param {?} result
  34487. * @param {?} externalStylesheetsByModuleUrl
  34488. * @return {?}
  34489. */
  34490. JitCompiler.prototype._resolveAndEvalStylesCompileResult = /**
  34491. * @param {?} result
  34492. * @param {?} externalStylesheetsByModuleUrl
  34493. * @return {?}
  34494. */
  34495. function (result, externalStylesheetsByModuleUrl) {
  34496. this._resolveStylesCompileResult(result, externalStylesheetsByModuleUrl);
  34497. return this._interpretOrJit(sharedStylesheetJitUrl(result.meta, this._sharedStylesheetCount++), result.outputCtx.statements)[result.stylesVar];
  34498. };
  34499. /**
  34500. * @param {?} sourceUrl
  34501. * @param {?} statements
  34502. * @return {?}
  34503. */
  34504. JitCompiler.prototype._interpretOrJit = /**
  34505. * @param {?} sourceUrl
  34506. * @param {?} statements
  34507. * @return {?}
  34508. */
  34509. function (sourceUrl, statements) {
  34510. if (!this._compilerConfig.useJit) {
  34511. return interpretStatements(statements, this._reflector);
  34512. }
  34513. else {
  34514. return jitStatements(sourceUrl, statements, this._reflector, this._compilerConfig.jitDevMode);
  34515. }
  34516. };
  34517. return JitCompiler;
  34518. }());
  34519. var CompiledTemplate = /** @class */ (function () {
  34520. function CompiledTemplate(isHost, compType, compMeta, ngModule, directives) {
  34521. this.isHost = isHost;
  34522. this.compType = compType;
  34523. this.compMeta = compMeta;
  34524. this.ngModule = ngModule;
  34525. this.directives = directives;
  34526. this._viewClass = /** @type {?} */ ((null));
  34527. this.isCompiled = false;
  34528. }
  34529. /**
  34530. * @param {?} viewClass
  34531. * @param {?} rendererType
  34532. * @return {?}
  34533. */
  34534. CompiledTemplate.prototype.compiled = /**
  34535. * @param {?} viewClass
  34536. * @param {?} rendererType
  34537. * @return {?}
  34538. */
  34539. function (viewClass, rendererType) {
  34540. this._viewClass = viewClass;
  34541. (/** @type {?} */ (this.compMeta.componentViewType)).setDelegate(viewClass);
  34542. for (var /** @type {?} */ prop in rendererType) {
  34543. (/** @type {?} */ (this.compMeta.rendererType))[prop] = rendererType[prop];
  34544. }
  34545. this.isCompiled = true;
  34546. };
  34547. return CompiledTemplate;
  34548. }());
  34549. /**
  34550. * @param {?} meta
  34551. * @return {?}
  34552. */
  34553. function assertComponent(meta) {
  34554. if (!meta.isComponent) {
  34555. throw new Error("Could not compile '" + identifierName(meta.type) + "' because it is not a component.");
  34556. }
  34557. }
  34558. /**
  34559. * @return {?}
  34560. */
  34561. function createOutputContext() {
  34562. var /** @type {?} */ importExpr$$1 = function (symbol) {
  34563. return importExpr({ name: identifierName(symbol), moduleName: null, runtime: symbol });
  34564. };
  34565. return { statements: [], genFilePath: '', importExpr: importExpr$$1 };
  34566. }
  34567. /**
  34568. * @fileoverview added by tsickle
  34569. * @suppress {checkTypes} checked by tsc
  34570. */
  34571. /**
  34572. * @license
  34573. * Copyright Google Inc. All Rights Reserved.
  34574. *
  34575. * Use of this source code is governed by an MIT-style license that can be
  34576. * found in the LICENSE file at https://angular.io/license
  34577. */
  34578. /**
  34579. * Provides access to reflection data about symbols that the compiler needs.
  34580. * @abstract
  34581. */
  34582. var CompileReflector = /** @class */ (function () {
  34583. function CompileReflector() {
  34584. }
  34585. return CompileReflector;
  34586. }());
  34587. /**
  34588. * @fileoverview added by tsickle
  34589. * @suppress {checkTypes} checked by tsc
  34590. */
  34591. /**
  34592. * @license
  34593. * Copyright Google Inc. All Rights Reserved.
  34594. *
  34595. * Use of this source code is governed by an MIT-style license that can be
  34596. * found in the LICENSE file at https://angular.io/license
  34597. */
  34598. /**
  34599. * Create a {\@link UrlResolver} with no package prefix.
  34600. * @return {?}
  34601. */
  34602. function createUrlResolverWithoutPackagePrefix() {
  34603. return new UrlResolver();
  34604. }
  34605. /**
  34606. * @return {?}
  34607. */
  34608. function createOfflineCompileUrlResolver() {
  34609. return new UrlResolver('.');
  34610. }
  34611. /**
  34612. * @record
  34613. */
  34614. var UrlResolver = /** @class */ (function () {
  34615. function UrlResolverImpl(_packagePrefix) {
  34616. if (_packagePrefix === void 0) { _packagePrefix = null; }
  34617. this._packagePrefix = _packagePrefix;
  34618. }
  34619. /**
  34620. * Resolves the `url` given the `baseUrl`:
  34621. * - when the `url` is null, the `baseUrl` is returned,
  34622. * - if `url` is relative ('path/to/here', './path/to/here'), the resolved url is a combination of
  34623. * `baseUrl` and `url`,
  34624. * - if `url` is absolute (it has a scheme: 'http://', 'https://' or start with '/'), the `url` is
  34625. * returned as is (ignoring the `baseUrl`)
  34626. */
  34627. /**
  34628. * Resolves the `url` given the `baseUrl`:
  34629. * - when the `url` is null, the `baseUrl` is returned,
  34630. * - if `url` is relative ('path/to/here', './path/to/here'), the resolved url is a combination of
  34631. * `baseUrl` and `url`,
  34632. * - if `url` is absolute (it has a scheme: 'http://', 'https://' or start with '/'), the `url` is
  34633. * returned as is (ignoring the `baseUrl`)
  34634. * @param {?} baseUrl
  34635. * @param {?} url
  34636. * @return {?}
  34637. */
  34638. UrlResolverImpl.prototype.resolve = /**
  34639. * Resolves the `url` given the `baseUrl`:
  34640. * - when the `url` is null, the `baseUrl` is returned,
  34641. * - if `url` is relative ('path/to/here', './path/to/here'), the resolved url is a combination of
  34642. * `baseUrl` and `url`,
  34643. * - if `url` is absolute (it has a scheme: 'http://', 'https://' or start with '/'), the `url` is
  34644. * returned as is (ignoring the `baseUrl`)
  34645. * @param {?} baseUrl
  34646. * @param {?} url
  34647. * @return {?}
  34648. */
  34649. function (baseUrl, url) {
  34650. var /** @type {?} */ resolvedUrl = url;
  34651. if (baseUrl != null && baseUrl.length > 0) {
  34652. resolvedUrl = _resolveUrl(baseUrl, resolvedUrl);
  34653. }
  34654. var /** @type {?} */ resolvedParts = _split(resolvedUrl);
  34655. var /** @type {?} */ prefix = this._packagePrefix;
  34656. if (prefix != null && resolvedParts != null &&
  34657. resolvedParts[_ComponentIndex.Scheme] == 'package') {
  34658. var /** @type {?} */ path = resolvedParts[_ComponentIndex.Path];
  34659. prefix = prefix.replace(/\/+$/, '');
  34660. path = path.replace(/^\/+/, '');
  34661. return prefix + "/" + path;
  34662. }
  34663. return resolvedUrl;
  34664. };
  34665. return UrlResolverImpl;
  34666. }());
  34667. /**
  34668. * Extract the scheme of a URL.
  34669. * @param {?} url
  34670. * @return {?}
  34671. */
  34672. function getUrlScheme(url) {
  34673. var /** @type {?} */ match = _split(url);
  34674. return (match && match[_ComponentIndex.Scheme]) || '';
  34675. }
  34676. /**
  34677. * Builds a URI string from already-encoded parts.
  34678. *
  34679. * No encoding is performed. Any component may be omitted as either null or
  34680. * undefined.
  34681. *
  34682. * @param {?=} opt_scheme The scheme such as 'http'.
  34683. * @param {?=} opt_userInfo The user name before the '\@'.
  34684. * @param {?=} opt_domain The domain such as 'www.google.com', already
  34685. * URI-encoded.
  34686. * @param {?=} opt_port The port number.
  34687. * @param {?=} opt_path The path, already URI-encoded. If it is not
  34688. * empty, it must begin with a slash.
  34689. * @param {?=} opt_queryData The URI-encoded query data.
  34690. * @param {?=} opt_fragment The URI-encoded fragment identifier.
  34691. * @return {?} The fully combined URI.
  34692. */
  34693. function _buildFromEncodedParts(opt_scheme, opt_userInfo, opt_domain, opt_port, opt_path, opt_queryData, opt_fragment) {
  34694. var /** @type {?} */ out = [];
  34695. if (opt_scheme != null) {
  34696. out.push(opt_scheme + ':');
  34697. }
  34698. if (opt_domain != null) {
  34699. out.push('//');
  34700. if (opt_userInfo != null) {
  34701. out.push(opt_userInfo + '@');
  34702. }
  34703. out.push(opt_domain);
  34704. if (opt_port != null) {
  34705. out.push(':' + opt_port);
  34706. }
  34707. }
  34708. if (opt_path != null) {
  34709. out.push(opt_path);
  34710. }
  34711. if (opt_queryData != null) {
  34712. out.push('?' + opt_queryData);
  34713. }
  34714. if (opt_fragment != null) {
  34715. out.push('#' + opt_fragment);
  34716. }
  34717. return out.join('');
  34718. }
  34719. /**
  34720. * A regular expression for breaking a URI into its component parts.
  34721. *
  34722. * {\@link http://www.gbiv.com/protocols/uri/rfc/rfc3986.html#RFC2234} says
  34723. * As the "first-match-wins" algorithm is identical to the "greedy"
  34724. * disambiguation method used by POSIX regular expressions, it is natural and
  34725. * commonplace to use a regular expression for parsing the potential five
  34726. * components of a URI reference.
  34727. *
  34728. * The following line is the regular expression for breaking-down a
  34729. * well-formed URI reference into its components.
  34730. *
  34731. * <pre>
  34732. * ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
  34733. * 12 3 4 5 6 7 8 9
  34734. * </pre>
  34735. *
  34736. * The numbers in the second line above are only to assist readability; they
  34737. * indicate the reference points for each subexpression (i.e., each paired
  34738. * parenthesis). We refer to the value matched for subexpression <n> as $<n>.
  34739. * For example, matching the above expression to
  34740. * <pre>
  34741. * http://www.ics.uci.edu/pub/ietf/uri/#Related
  34742. * </pre>
  34743. * results in the following subexpression matches:
  34744. * <pre>
  34745. * $1 = http:
  34746. * $2 = http
  34747. * $3 = //www.ics.uci.edu
  34748. * $4 = www.ics.uci.edu
  34749. * $5 = /pub/ietf/uri/
  34750. * $6 = <undefined>
  34751. * $7 = <undefined>
  34752. * $8 = #Related
  34753. * $9 = Related
  34754. * </pre>
  34755. * where <undefined> indicates that the component is not present, as is the
  34756. * case for the query component in the above example. Therefore, we can
  34757. * determine the value of the five components as
  34758. * <pre>
  34759. * scheme = $2
  34760. * authority = $4
  34761. * path = $5
  34762. * query = $7
  34763. * fragment = $9
  34764. * </pre>
  34765. *
  34766. * The regular expression has been modified slightly to expose the
  34767. * userInfo, domain, and port separately from the authority.
  34768. * The modified version yields
  34769. * <pre>
  34770. * $1 = http scheme
  34771. * $2 = <undefined> userInfo -\
  34772. * $3 = www.ics.uci.edu domain | authority
  34773. * $4 = <undefined> port -/
  34774. * $5 = /pub/ietf/uri/ path
  34775. * $6 = <undefined> query without ?
  34776. * $7 = Related fragment without #
  34777. * </pre>
  34778. * \@internal
  34779. */
  34780. var _splitRe = new RegExp('^' +
  34781. '(?:' +
  34782. '([^:/?#.]+)' + // scheme - ignore special characters
  34783. ':)?' +
  34784. '(?://' +
  34785. '(?:([^/?#]*)@)?' + // userInfo
  34786. '([\\w\\d\\-\\u0100-\\uffff.%]*)' + // domain - restrict to letters,
  34787. '(?::([0-9]+))?' + // port
  34788. ')?' +
  34789. '([^?#]+)?' + // path
  34790. '(?:\\?([^#]*))?' + // query
  34791. '(?:#(.*))?' + // fragment
  34792. '$');
  34793. /** @enum {number} */
  34794. var _ComponentIndex = {
  34795. Scheme: 1,
  34796. UserInfo: 2,
  34797. Domain: 3,
  34798. Port: 4,
  34799. Path: 5,
  34800. QueryData: 6,
  34801. Fragment: 7,
  34802. };
  34803. _ComponentIndex[_ComponentIndex.Scheme] = "Scheme";
  34804. _ComponentIndex[_ComponentIndex.UserInfo] = "UserInfo";
  34805. _ComponentIndex[_ComponentIndex.Domain] = "Domain";
  34806. _ComponentIndex[_ComponentIndex.Port] = "Port";
  34807. _ComponentIndex[_ComponentIndex.Path] = "Path";
  34808. _ComponentIndex[_ComponentIndex.QueryData] = "QueryData";
  34809. _ComponentIndex[_ComponentIndex.Fragment] = "Fragment";
  34810. /**
  34811. * Splits a URI into its component parts.
  34812. *
  34813. * Each component can be accessed via the component indices; for example:
  34814. * <pre>
  34815. * goog.uri.utils.split(someStr)[goog.uri.utils.CompontentIndex.QUERY_DATA];
  34816. * </pre>
  34817. *
  34818. * @param {?} uri The URI string to examine.
  34819. * @return {?} Each component still URI-encoded.
  34820. * Each component that is present will contain the encoded value, whereas
  34821. * components that are not present will be undefined or empty, depending
  34822. * on the browser's regular expression implementation. Never null, since
  34823. * arbitrary strings may still look like path names.
  34824. */
  34825. function _split(uri) {
  34826. return /** @type {?} */ ((uri.match(_splitRe)));
  34827. }
  34828. /**
  34829. * Removes dot segments in given path component, as described in
  34830. * RFC 3986, section 5.2.4.
  34831. *
  34832. * @param {?} path A non-empty path component.
  34833. * @return {?} Path component with removed dot segments.
  34834. */
  34835. function _removeDotSegments(path) {
  34836. if (path == '/')
  34837. return '/';
  34838. var /** @type {?} */ leadingSlash = path[0] == '/' ? '/' : '';
  34839. var /** @type {?} */ trailingSlash = path[path.length - 1] === '/' ? '/' : '';
  34840. var /** @type {?} */ segments = path.split('/');
  34841. var /** @type {?} */ out = [];
  34842. var /** @type {?} */ up = 0;
  34843. for (var /** @type {?} */ pos = 0; pos < segments.length; pos++) {
  34844. var /** @type {?} */ segment = segments[pos];
  34845. switch (segment) {
  34846. case '':
  34847. case '.':
  34848. break;
  34849. case '..':
  34850. if (out.length > 0) {
  34851. out.pop();
  34852. }
  34853. else {
  34854. up++;
  34855. }
  34856. break;
  34857. default:
  34858. out.push(segment);
  34859. }
  34860. }
  34861. if (leadingSlash == '') {
  34862. while (up-- > 0) {
  34863. out.unshift('..');
  34864. }
  34865. if (out.length === 0)
  34866. out.push('.');
  34867. }
  34868. return leadingSlash + out.join('/') + trailingSlash;
  34869. }
  34870. /**
  34871. * Takes an array of the parts from split and canonicalizes the path part
  34872. * and then joins all the parts.
  34873. * @param {?} parts
  34874. * @return {?}
  34875. */
  34876. function _joinAndCanonicalizePath(parts) {
  34877. var /** @type {?} */ path = parts[_ComponentIndex.Path];
  34878. path = path == null ? '' : _removeDotSegments(path);
  34879. parts[_ComponentIndex.Path] = path;
  34880. return _buildFromEncodedParts(parts[_ComponentIndex.Scheme], parts[_ComponentIndex.UserInfo], parts[_ComponentIndex.Domain], parts[_ComponentIndex.Port], path, parts[_ComponentIndex.QueryData], parts[_ComponentIndex.Fragment]);
  34881. }
  34882. /**
  34883. * Resolves a URL.
  34884. * @param {?} base The URL acting as the base URL.
  34885. * @param {?} url
  34886. * @return {?}
  34887. */
  34888. function _resolveUrl(base, url) {
  34889. var /** @type {?} */ parts = _split(encodeURI(url));
  34890. var /** @type {?} */ baseParts = _split(base);
  34891. if (parts[_ComponentIndex.Scheme] != null) {
  34892. return _joinAndCanonicalizePath(parts);
  34893. }
  34894. else {
  34895. parts[_ComponentIndex.Scheme] = baseParts[_ComponentIndex.Scheme];
  34896. }
  34897. for (var /** @type {?} */ i = _ComponentIndex.Scheme; i <= _ComponentIndex.Port; i++) {
  34898. if (parts[i] == null) {
  34899. parts[i] = baseParts[i];
  34900. }
  34901. }
  34902. if (parts[_ComponentIndex.Path][0] == '/') {
  34903. return _joinAndCanonicalizePath(parts);
  34904. }
  34905. var /** @type {?} */ path = baseParts[_ComponentIndex.Path];
  34906. if (path == null)
  34907. path = '/';
  34908. var /** @type {?} */ index = path.lastIndexOf('/');
  34909. path = path.substring(0, index + 1) + parts[_ComponentIndex.Path];
  34910. parts[_ComponentIndex.Path] = path;
  34911. return _joinAndCanonicalizePath(parts);
  34912. }
  34913. /**
  34914. * @fileoverview added by tsickle
  34915. * @suppress {checkTypes} checked by tsc
  34916. */
  34917. /**
  34918. * @license
  34919. * Copyright Google Inc. All Rights Reserved.
  34920. *
  34921. * Use of this source code is governed by an MIT-style license that can be
  34922. * found in the LICENSE file at https://angular.io/license
  34923. */
  34924. /**
  34925. * An interface for retrieving documents by URL that the compiler uses
  34926. * to load templates.
  34927. */
  34928. var ResourceLoader = /** @class */ (function () {
  34929. function ResourceLoader() {
  34930. }
  34931. /**
  34932. * @param {?} url
  34933. * @return {?}
  34934. */
  34935. ResourceLoader.prototype.get = /**
  34936. * @param {?} url
  34937. * @return {?}
  34938. */
  34939. function (url) { return ''; };
  34940. return ResourceLoader;
  34941. }());
  34942. /**
  34943. * @fileoverview added by tsickle
  34944. * @suppress {checkTypes} checked by tsc
  34945. */
  34946. /**
  34947. * @license
  34948. * Copyright Google Inc. All Rights Reserved.
  34949. *
  34950. * Use of this source code is governed by an MIT-style license that can be
  34951. * found in the LICENSE file at https://angular.io/license
  34952. */
  34953. /**
  34954. * The host of the Extractor disconnects the implementation from TypeScript / other language
  34955. * services and from underlying file systems.
  34956. * @record
  34957. */
  34958. var Extractor = /** @class */ (function () {
  34959. function Extractor(host, staticSymbolResolver, messageBundle, metadataResolver) {
  34960. this.host = host;
  34961. this.staticSymbolResolver = staticSymbolResolver;
  34962. this.messageBundle = messageBundle;
  34963. this.metadataResolver = metadataResolver;
  34964. }
  34965. /**
  34966. * @param {?} rootFiles
  34967. * @return {?}
  34968. */
  34969. Extractor.prototype.extract = /**
  34970. * @param {?} rootFiles
  34971. * @return {?}
  34972. */
  34973. function (rootFiles) {
  34974. var _this = this;
  34975. var _a = analyzeAndValidateNgModules(rootFiles, this.host, this.staticSymbolResolver, this.metadataResolver), files = _a.files, ngModules = _a.ngModules;
  34976. return Promise
  34977. .all(ngModules.map(function (ngModule) {
  34978. return _this.metadataResolver.loadNgModuleDirectiveAndPipeMetadata(ngModule.type.reference, false);
  34979. }))
  34980. .then(function () {
  34981. var /** @type {?} */ errors = [];
  34982. files.forEach(function (file) {
  34983. var /** @type {?} */ compMetas = [];
  34984. file.directives.forEach(function (directiveType) {
  34985. var /** @type {?} */ dirMeta = _this.metadataResolver.getDirectiveMetadata(directiveType);
  34986. if (dirMeta && dirMeta.isComponent) {
  34987. compMetas.push(dirMeta);
  34988. }
  34989. });
  34990. compMetas.forEach(function (compMeta) {
  34991. var /** @type {?} */ html = /** @type {?} */ ((/** @type {?} */ ((compMeta.template)).template));
  34992. var /** @type {?} */ interpolationConfig = InterpolationConfig.fromArray(/** @type {?} */ ((compMeta.template)).interpolation);
  34993. errors.push.apply(errors, /** @type {?} */ ((_this.messageBundle.updateFromTemplate(html, file.fileName, interpolationConfig))));
  34994. });
  34995. });
  34996. if (errors.length) {
  34997. throw new Error(errors.map(function (e) { return e.toString(); }).join('\n'));
  34998. }
  34999. return _this.messageBundle;
  35000. });
  35001. };
  35002. /**
  35003. * @param {?} host
  35004. * @param {?} locale
  35005. * @return {?}
  35006. */
  35007. Extractor.create = /**
  35008. * @param {?} host
  35009. * @param {?} locale
  35010. * @return {?}
  35011. */
  35012. function (host, locale) {
  35013. var /** @type {?} */ htmlParser = new HtmlParser();
  35014. var /** @type {?} */ urlResolver = createAotUrlResolver(host);
  35015. var /** @type {?} */ symbolCache = new StaticSymbolCache();
  35016. var /** @type {?} */ summaryResolver = new AotSummaryResolver(host, symbolCache);
  35017. var /** @type {?} */ staticSymbolResolver = new StaticSymbolResolver(host, symbolCache, summaryResolver);
  35018. var /** @type {?} */ staticReflector = new StaticReflector(summaryResolver, staticSymbolResolver);
  35019. var /** @type {?} */ config = new CompilerConfig({ defaultEncapsulation: ViewEncapsulation.Emulated, useJit: false });
  35020. var /** @type {?} */ normalizer = new DirectiveNormalizer({ get: function (url) { return host.loadResource(url); } }, urlResolver, htmlParser, config);
  35021. var /** @type {?} */ elementSchemaRegistry = new DomElementSchemaRegistry();
  35022. var /** @type {?} */ resolver = new CompileMetadataResolver(config, htmlParser, new NgModuleResolver(staticReflector), new DirectiveResolver(staticReflector), new PipeResolver(staticReflector), summaryResolver, elementSchemaRegistry, normalizer, console, symbolCache, staticReflector);
  35023. // TODO(vicb): implicit tags & attributes
  35024. var /** @type {?} */ messageBundle = new MessageBundle(htmlParser, [], {}, locale);
  35025. var /** @type {?} */ extractor = new Extractor(host, staticSymbolResolver, messageBundle, resolver);
  35026. return { extractor: extractor, staticReflector: staticReflector };
  35027. };
  35028. return Extractor;
  35029. }());
  35030. /**
  35031. * @fileoverview added by tsickle
  35032. * @suppress {checkTypes} checked by tsc
  35033. */
  35034. /**
  35035. * @license
  35036. * Copyright Google Inc. All Rights Reserved.
  35037. *
  35038. * Use of this source code is governed by an MIT-style license that can be
  35039. * found in the LICENSE file at https://angular.io/license
  35040. */
  35041. /**
  35042. * @fileoverview added by tsickle
  35043. * @suppress {checkTypes} checked by tsc
  35044. */
  35045. /**
  35046. * @license
  35047. * Copyright Google Inc. All Rights Reserved.
  35048. *
  35049. * Use of this source code is governed by an MIT-style license that can be
  35050. * found in the LICENSE file at https://angular.io/license
  35051. */
  35052. // This file only reexports content of the `src` folder. Keep it that way.
  35053. /**
  35054. * @fileoverview added by tsickle
  35055. * @suppress {checkTypes} checked by tsc
  35056. */
  35057. /**
  35058. * @license
  35059. * Copyright Google Inc. All Rights Reserved.
  35060. *
  35061. * Use of this source code is governed by an MIT-style license that can be
  35062. * found in the LICENSE file at https://angular.io/license
  35063. */
  35064. /**
  35065. * @module
  35066. * @description
  35067. * Entry point for all public APIs of this package.
  35068. */
  35069. // This file only reexports content of the `src` folder. Keep it that way.
  35070. /**
  35071. * @fileoverview added by tsickle
  35072. * @suppress {checkTypes} checked by tsc
  35073. */
  35074. /**
  35075. * @license
  35076. * Copyright Google Inc. All Rights Reserved.
  35077. *
  35078. * Use of this source code is governed by an MIT-style license that can be
  35079. * found in the LICENSE file at https://angular.io/license
  35080. */
  35081. // This file is not used to build this module. It is only used during editing
  35082. // by the TypeScript language service and during build for verification. `ngc`
  35083. // replaces this file with production index.ts when it rewrites private symbol
  35084. // names.
  35085. export { core, CompilerConfig, preserveWhitespacesDefault, isLoweredSymbol, createLoweredSymbol, Identifiers, JitCompiler, DirectiveResolver, PipeResolver, NgModuleResolver, DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig, NgModuleCompiler, AssertNotNull, BinaryOperator, BinaryOperatorExpr, BuiltinMethod, BuiltinVar, CastExpr, ClassStmt, CommaExpr, CommentStmt, ConditionalExpr, DeclareFunctionStmt, DeclareVarStmt, ExpressionStatement, ExternalExpr, ExternalReference, FunctionExpr, IfStmt, InstantiateExpr, InvokeFunctionExpr, InvokeMethodExpr, LiteralArrayExpr, LiteralExpr, LiteralMapExpr, NotExpr, ReadKeyExpr, ReadPropExpr, ReadVarExpr, ReturnStatement, ThrowStmt, TryCatchStmt, WriteKeyExpr, WritePropExpr, WriteVarExpr, StmtModifier, Statement, collectExternalReferences, EmitterVisitorContext, ViewCompiler, getParseErrors, isSyntaxError, syntaxError, Version, VERSION, TextAst, BoundTextAst, AttrAst, BoundElementPropertyAst, BoundEventAst, ReferenceAst, VariableAst, ElementAst, EmbeddedTemplateAst, BoundDirectivePropertyAst, DirectiveAst, ProviderAst, ProviderAstType, NgContentAst, PropertyBindingType, NullTemplateVisitor, RecursiveTemplateAstVisitor, templateVisitAll, identifierName, identifierModuleUrl, viewClassName, rendererTypeName, hostViewClassName, componentFactoryName, CompileSummaryKind, tokenName, tokenReference, CompileStylesheetMetadata, CompileTemplateMetadata, CompileDirectiveMetadata, CompilePipeMetadata, CompileNgModuleMetadata, TransitiveCompileNgModuleMetadata, ProviderMeta, flatten, templateSourceUrl, sharedStylesheetJitUrl, ngModuleJitUrl, templateJitUrl, createAotUrlResolver, createAotCompiler, AotCompiler, analyzeNgModules, analyzeAndValidateNgModules, analyzeFile, mergeAnalyzedFiles, GeneratedFile, toTypeScript, formattedError, isFormattedError, StaticReflector, StaticSymbol, StaticSymbolCache, ResolvedStaticSymbol, StaticSymbolResolver, unescapeIdentifier, unwrapResolvedMetadata, AotSummaryResolver, AstPath, SummaryResolver, JitSummaryResolver, CompileReflector, createUrlResolverWithoutPackagePrefix, createOfflineCompileUrlResolver, UrlResolver, getUrlScheme, ResourceLoader, ElementSchemaRegistry, Extractor, I18NHtmlParser, MessageBundle, Serializer, Xliff, Xliff2, Xmb, Xtb, DirectiveNormalizer, ParserError, ParseSpan, AST, Quote, EmptyExpr, ImplicitReceiver, Chain, Conditional, PropertyRead, PropertyWrite, SafePropertyRead, KeyedRead, KeyedWrite, BindingPipe, LiteralPrimitive, LiteralArray, LiteralMap, Interpolation, Binary, PrefixNot, NonNullAssert, MethodCall, SafeMethodCall, FunctionCall, ASTWithSource, TemplateBinding, NullAstVisitor, RecursiveAstVisitor, AstTransformer, visitAstChildren, TokenType, Lexer, Token, EOF, isIdentifier, isQuote, SplitInterpolation, TemplateBindingParseResult, Parser, _ParseAST, ERROR_COMPONENT_TYPE, CompileMetadataResolver, Text, Expansion, ExpansionCase, Attribute$1 as Attribute, Element, Comment, visitAll, RecursiveVisitor, findNode, ParseTreeResult, TreeError, HtmlParser, HtmlTagDefinition, getHtmlTagDefinition, TagContentType, splitNsName, isNgContainer, isNgContent, isNgTemplate, getNsPrefix, mergeNsAndName, NAMED_ENTITIES, NGSP_UNICODE, debugOutputAstAsTypeScript, TypeScriptEmitter, ParseLocation, ParseSourceFile, ParseSourceSpan, ParseErrorLevel, ParseError, typeSourceSpan, DomElementSchemaRegistry, CssSelector, SelectorMatcher, SelectorListContext, SelectorContext, StylesCompileDependency, CompiledStylesheet, StyleCompiler, TemplateParseError, TemplateParseResult, TemplateParser, splitClasses, createElementCssSelector, removeSummaryDuplicates };
  35086. //# sourceMappingURL=compiler.js.map