123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469
  1. /**
  2. * @license Angular v5.2.11
  3. * (c) 2010-2018 Google, Inc. https://angular.io/
  4. * License: MIT
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  8. typeof define === 'function' && define.amd ? define('@angular/compiler', ['exports'], factory) :
  9. (factory((global.ng = global.ng || {}, global.ng.compiler = {})));
  10. }(this, (function (exports) { 'use strict';
  11. /*! *****************************************************************************
  12. Copyright (c) Microsoft Corporation. All rights reserved.
  13. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  14. this file except in compliance with the License. You may obtain a copy of the
  15. License at http://www.apache.org/licenses/LICENSE-2.0
  16. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  18. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  19. MERCHANTABLITY OR NON-INFRINGEMENT.
  20. See the Apache Version 2.0 License for specific language governing permissions
  21. and limitations under the License.
  22. ***************************************************************************** */
  23. /* global Reflect, Promise */
  24. var extendStatics = Object.setPrototypeOf ||
  25. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  26. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  27. function __extends(d, b) {
  28. extendStatics(d, b);
  29. function __() { this.constructor = d; }
  30. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31. }
  32. var __assign = Object.assign || function __assign(t) {
  33. for (var s, i = 1, n = arguments.length; i < n; i++) {
  34. s = arguments[i];
  35. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  36. }
  37. return t;
  38. };
  39. /**
  40. * @license Angular v5.2.11
  41. * (c) 2010-2018 Google, Inc. https://angular.io/
  42. * License: MIT
  43. */
  44. /**
  45. * @fileoverview added by tsickle
  46. * @suppress {checkTypes} checked by tsc
  47. */
  48. /**
  49. * @license
  50. * Copyright Google Inc. All Rights Reserved.
  51. *
  52. * Use of this source code is governed by an MIT-style license that can be
  53. * found in the LICENSE file at https://angular.io/license
  54. */
  55. // Attention:
  56. // This file duplicates types and values from @angular/core
  57. // so that we are able to make @angular/compiler independent of @angular/core.
  58. // This is important to prevent a build cycle, as @angular/core needs to
  59. // be compiled with the compiler.
  60. /**
  61. * @record
  62. */
  63. function Inject() { }
  64. var createInject = makeMetadataFactory('Inject', function (token) { return ({ token: token }); });
  65. var createInjectionToken = makeMetadataFactory('InjectionToken', function (desc) { return ({ _desc: desc }); });
  66. /**
  67. * @record
  68. */
  69. function Attribute() { }
  70. var createAttribute = makeMetadataFactory('Attribute', function (attributeName) { return ({ attributeName: attributeName }); });
  71. /**
  72. * @record
  73. */
  74. function Query() { }
  75. var createContentChildren = makeMetadataFactory('ContentChildren', function (selector, data) {
  76. if (data === void 0) { data = {}; }
  77. return (__assign({ selector: selector, first: false, isViewQuery: false, descendants: false }, data));
  78. });
  79. var createContentChild = makeMetadataFactory('ContentChild', function (selector, data) {
  80. if (data === void 0) { data = {}; }
  81. return (__assign({ selector: selector, first: true, isViewQuery: false, descendants: true }, data));
  82. });
  83. var createViewChildren = makeMetadataFactory('ViewChildren', function (selector, data) {
  84. if (data === void 0) { data = {}; }
  85. return (__assign({ selector: selector, first: false, isViewQuery: true, descendants: true }, data));
  86. });
  87. var createViewChild = makeMetadataFactory('ViewChild', function (selector, data) {
  88. return (__assign({ selector: selector, first: true, isViewQuery: true, descendants: true }, data));
  89. });
  90. /**
  91. * @record
  92. */
  93. function Directive() { }
  94. var createDirective = makeMetadataFactory('Directive', function (dir) {
  95. if (dir === void 0) { dir = {}; }
  96. return dir;
  97. });
  98. /**
  99. * @record
  100. */
  101. function Component() { }
  102. /** @enum {number} */
  103. var ViewEncapsulation = {
  104. Emulated: 0,
  105. Native: 1,
  106. None: 2,
  107. };
  108. ViewEncapsulation[ViewEncapsulation.Emulated] = "Emulated";
  109. ViewEncapsulation[ViewEncapsulation.Native] = "Native";
  110. ViewEncapsulation[ViewEncapsulation.None] = "None";
  111. /** @enum {number} */
  112. var ChangeDetectionStrategy = {
  113. OnPush: 0,
  114. Default: 1,
  115. };
  116. ChangeDetectionStrategy[ChangeDetectionStrategy.OnPush] = "OnPush";
  117. ChangeDetectionStrategy[ChangeDetectionStrategy.Default] = "Default";
  118. var createComponent = makeMetadataFactory('Component', function (c) {
  119. if (c === void 0) { c = {}; }
  120. return (__assign({ changeDetection: ChangeDetectionStrategy.Default }, c));
  121. });
  122. /**
  123. * @record
  124. */
  125. function Pipe() { }
  126. var createPipe = makeMetadataFactory('Pipe', function (p) { return (__assign({ pure: true }, p)); });
  127. /**
  128. * @record
  129. */
  130. function Input() { }
  131. var createInput = makeMetadataFactory('Input', function (bindingPropertyName) { return ({ bindingPropertyName: bindingPropertyName }); });
  132. /**
  133. * @record
  134. */
  135. function Output() { }
  136. var createOutput = makeMetadataFactory('Output', function (bindingPropertyName) { return ({ bindingPropertyName: bindingPropertyName }); });
  137. /**
  138. * @record
  139. */
  140. function HostBinding() { }
  141. var createHostBinding = makeMetadataFactory('HostBinding', function (hostPropertyName) { return ({ hostPropertyName: hostPropertyName }); });
  142. /**
  143. * @record
  144. */
  145. function HostListener() { }
  146. var createHostListener = makeMetadataFactory('HostListener', function (eventName, args) { return ({ eventName: eventName, args: args }); });
  147. /**
  148. * @record
  149. */
  150. function NgModule() { }
  151. var createNgModule = makeMetadataFactory('NgModule', function (ngModule) { return ngModule; });
  152. /**
  153. * @record
  154. */
  155. function ModuleWithProviders() { }
  156. /**
  157. * @record
  158. */
  159. function SchemaMetadata() { }
  160. var CUSTOM_ELEMENTS_SCHEMA = {
  161. name: 'custom-elements'
  162. };
  163. var NO_ERRORS_SCHEMA = {
  164. name: 'no-errors-schema'
  165. };
  166. var createOptional = makeMetadataFactory('Optional');
  167. var createInjectable = makeMetadataFactory('Injectable');
  168. var createSelf = makeMetadataFactory('Self');
  169. var createSkipSelf = makeMetadataFactory('SkipSelf');
  170. var createHost = makeMetadataFactory('Host');
  171. var Type = Function;
  172. /** @enum {number} */
  173. var SecurityContext = {
  174. NONE: 0,
  175. HTML: 1,
  176. STYLE: 2,
  177. SCRIPT: 3,
  178. URL: 4,
  179. RESOURCE_URL: 5,
  180. };
  181. SecurityContext[SecurityContext.NONE] = "NONE";
  182. SecurityContext[SecurityContext.HTML] = "HTML";
  183. SecurityContext[SecurityContext.STYLE] = "STYLE";
  184. SecurityContext[SecurityContext.SCRIPT] = "SCRIPT";
  185. SecurityContext[SecurityContext.URL] = "URL";
  186. SecurityContext[SecurityContext.RESOURCE_URL] = "RESOURCE_URL";
  187. /** @enum {number} */
  188. var NodeFlags = {
  189. None: 0,
  190. TypeElement: 1,
  191. TypeText: 2,
  192. ProjectedTemplate: 4,
  193. CatRenderNode: 3,
  194. TypeNgContent: 8,
  195. TypePipe: 16,
  196. TypePureArray: 32,
  197. TypePureObject: 64,
  198. TypePurePipe: 128,
  199. CatPureExpression: 224,
  200. TypeValueProvider: 256,
  201. TypeClassProvider: 512,
  202. TypeFactoryProvider: 1024,
  203. TypeUseExistingProvider: 2048,
  204. LazyProvider: 4096,
  205. PrivateProvider: 8192,
  206. TypeDirective: 16384,
  207. Component: 32768,
  208. CatProviderNoDirective: 3840,
  209. CatProvider: 20224,
  210. OnInit: 65536,
  211. OnDestroy: 131072,
  212. DoCheck: 262144,
  213. OnChanges: 524288,
  214. AfterContentInit: 1048576,
  215. AfterContentChecked: 2097152,
  216. AfterViewInit: 4194304,
  217. AfterViewChecked: 8388608,
  218. EmbeddedViews: 16777216,
  219. ComponentView: 33554432,
  220. TypeContentQuery: 67108864,
  221. TypeViewQuery: 134217728,
  222. StaticQuery: 268435456,
  223. DynamicQuery: 536870912,
  224. CatQuery: 201326592,
  225. // mutually exclusive values...
  226. Types: 201347067,
  227. };
  228. /** @enum {number} */
  229. var DepFlags = {
  230. None: 0,
  231. SkipSelf: 1,
  232. Optional: 2,
  233. Value: 8,
  234. };
  235. /** @enum {number} */
  236. var ArgumentType = { Inline: 0, Dynamic: 1, };
  237. /** @enum {number} */
  238. var BindingFlags = {
  239. TypeElementAttribute: 1,
  240. TypeElementClass: 2,
  241. TypeElementStyle: 4,
  242. TypeProperty: 8,
  243. SyntheticProperty: 16,
  244. SyntheticHostProperty: 32,
  245. CatSyntheticProperty: 48,
  246. // mutually exclusive values...
  247. Types: 15,
  248. };
  249. /** @enum {number} */
  250. var QueryBindingType = { First: 0, All: 1, };
  251. /** @enum {number} */
  252. var QueryValueType = {
  253. ElementRef: 0,
  254. RenderElement: 1,
  255. TemplateRef: 2,
  256. ViewContainerRef: 3,
  257. Provider: 4,
  258. };
  259. /** @enum {number} */
  260. var ViewFlags = {
  261. None: 0,
  262. OnPush: 2,
  263. };
  264. /** @enum {number} */
  265. var MissingTranslationStrategy = {
  266. Error: 0,
  267. Warning: 1,
  268. Ignore: 2,
  269. };
  270. MissingTranslationStrategy[MissingTranslationStrategy.Error] = "Error";
  271. MissingTranslationStrategy[MissingTranslationStrategy.Warning] = "Warning";
  272. MissingTranslationStrategy[MissingTranslationStrategy.Ignore] = "Ignore";
  273. /**
  274. * @record
  275. * @template T
  276. */
  277. function MetadataFactory() { }
  278. /**
  279. * @template T
  280. * @param {?} name
  281. * @param {?=} props
  282. * @return {?}
  283. */
  284. function makeMetadataFactory(name, props) {
  285. var /** @type {?} */ factory = function () {
  286. var args = [];
  287. for (var _i = 0; _i < arguments.length; _i++) {
  288. args[_i] = arguments[_i];
  289. }
  290. var /** @type {?} */ values = props ? props.apply(void 0, args) : {};
  291. return __assign({ ngMetadataName: name }, values);
  292. };
  293. factory.isTypeOf = function (obj) { return obj && obj.ngMetadataName === name; };
  294. factory.ngMetadataName = name;
  295. return factory;
  296. }
  297. /**
  298. * @record
  299. */
  300. function Route() { }
  301. var core = Object.freeze({
  302. Inject: Inject,
  303. createInject: createInject,
  304. createInjectionToken: createInjectionToken,
  305. Attribute: Attribute,
  306. createAttribute: createAttribute,
  307. Query: Query,
  308. createContentChildren: createContentChildren,
  309. createContentChild: createContentChild,
  310. createViewChildren: createViewChildren,
  311. createViewChild: createViewChild,
  312. Directive: Directive,
  313. createDirective: createDirective,
  314. Component: Component,
  315. ViewEncapsulation: ViewEncapsulation,
  316. ChangeDetectionStrategy: ChangeDetectionStrategy,
  317. createComponent: createComponent,
  318. Pipe: Pipe,
  319. createPipe: createPipe,
  320. Input: Input,
  321. createInput: createInput,
  322. Output: Output,
  323. createOutput: createOutput,
  324. HostBinding: HostBinding,
  325. createHostBinding: createHostBinding,
  326. HostListener: HostListener,
  327. createHostListener: createHostListener,
  328. NgModule: NgModule,
  329. createNgModule: createNgModule,
  330. ModuleWithProviders: ModuleWithProviders,
  331. SchemaMetadata: SchemaMetadata,
  332. CUSTOM_ELEMENTS_SCHEMA: CUSTOM_ELEMENTS_SCHEMA,
  333. NO_ERRORS_SCHEMA: NO_ERRORS_SCHEMA,
  334. createOptional: createOptional,
  335. createInjectable: createInjectable,
  336. createSelf: createSelf,
  337. createSkipSelf: createSkipSelf,
  338. createHost: createHost,
  339. Type: Type,
  340. SecurityContext: SecurityContext,
  341. NodeFlags: NodeFlags,
  342. DepFlags: DepFlags,
  343. ArgumentType: ArgumentType,
  344. BindingFlags: BindingFlags,
  345. QueryBindingType: QueryBindingType,
  346. QueryValueType: QueryValueType,
  347. ViewFlags: ViewFlags,
  348. MissingTranslationStrategy: MissingTranslationStrategy,
  349. MetadataFactory: MetadataFactory,
  350. Route: Route
  351. });
  352. /**
  353. * @fileoverview added by tsickle
  354. * @suppress {checkTypes} checked by tsc
  355. */
  356. /**
  357. * @license
  358. * Copyright Google Inc. All Rights Reserved.
  359. *
  360. * Use of this source code is governed by an MIT-style license that can be
  361. * found in the LICENSE file at https://angular.io/license
  362. */
  363. var DASH_CASE_REGEXP = /-+([a-z0-9])/g;
  364. /**
  365. * @param {?} input
  366. * @return {?}
  367. */
  368. function dashCaseToCamelCase(input) {
  369. return input.replace(DASH_CASE_REGEXP, function () {
  370. var m = [];
  371. for (var _i = 0; _i < arguments.length; _i++) {
  372. m[_i] = arguments[_i];
  373. }
  374. return m[1].toUpperCase();
  375. });
  376. }
  377. /**
  378. * @param {?} input
  379. * @param {?} defaultValues
  380. * @return {?}
  381. */
  382. function splitAtColon(input, defaultValues) {
  383. return _splitAt(input, ':', defaultValues);
  384. }
  385. /**
  386. * @param {?} input
  387. * @param {?} defaultValues
  388. * @return {?}
  389. */
  390. function splitAtPeriod(input, defaultValues) {
  391. return _splitAt(input, '.', defaultValues);
  392. }
  393. /**
  394. * @param {?} input
  395. * @param {?} character
  396. * @param {?} defaultValues
  397. * @return {?}
  398. */
  399. function _splitAt(input, character, defaultValues) {
  400. var /** @type {?} */ characterIndex = input.indexOf(character);
  401. if (characterIndex == -1)
  402. return defaultValues;
  403. return [input.slice(0, characterIndex).trim(), input.slice(characterIndex + 1).trim()];
  404. }
  405. /**
  406. * @param {?} value
  407. * @param {?} visitor
  408. * @param {?} context
  409. * @return {?}
  410. */
  411. function visitValue(value, visitor, context) {
  412. if (Array.isArray(value)) {
  413. return visitor.visitArray(/** @type {?} */ (value), context);
  414. }
  415. if (isStrictStringMap(value)) {
  416. return visitor.visitStringMap(/** @type {?} */ (value), context);
  417. }
  418. if (value == null || typeof value == 'string' || typeof value == 'number' ||
  419. typeof value == 'boolean') {
  420. return visitor.visitPrimitive(value, context);
  421. }
  422. return visitor.visitOther(value, context);
  423. }
  424. /**
  425. * @param {?} val
  426. * @return {?}
  427. */
  428. function isDefined(val) {
  429. return val !== null && val !== undefined;
  430. }
  431. /**
  432. * @template T
  433. * @param {?} val
  434. * @return {?}
  435. */
  436. function noUndefined(val) {
  437. return val === undefined ? /** @type {?} */ ((null)) : val;
  438. }
  439. /**
  440. * @record
  441. */
  442. var ValueTransformer = /** @class */ (function () {
  443. function ValueTransformer() {
  444. }
  445. /**
  446. * @param {?} arr
  447. * @param {?} context
  448. * @return {?}
  449. */
  450. ValueTransformer.prototype.visitArray = /**
  451. * @param {?} arr
  452. * @param {?} context
  453. * @return {?}
  454. */
  455. function (arr, context) {
  456. var _this = this;
  457. return arr.map(function (value) { return visitValue(value, _this, context); });
  458. };
  459. /**
  460. * @param {?} map
  461. * @param {?} context
  462. * @return {?}
  463. */
  464. ValueTransformer.prototype.visitStringMap = /**
  465. * @param {?} map
  466. * @param {?} context
  467. * @return {?}
  468. */
  469. function (map, context) {
  470. var _this = this;
  471. var /** @type {?} */ result = {};
  472. Object.keys(map).forEach(function (key) { result[key] = visitValue(map[key], _this, context); });
  473. return result;
  474. };
  475. /**
  476. * @param {?} value
  477. * @param {?} context
  478. * @return {?}
  479. */
  480. ValueTransformer.prototype.visitPrimitive = /**
  481. * @param {?} value
  482. * @param {?} context
  483. * @return {?}
  484. */
  485. function (value, context) { return value; };
  486. /**
  487. * @param {?} value
  488. * @param {?} context
  489. * @return {?}
  490. */
  491. ValueTransformer.prototype.visitOther = /**
  492. * @param {?} value
  493. * @param {?} context
  494. * @return {?}
  495. */
  496. function (value, context) { return value; };
  497. return ValueTransformer;
  498. }());
  499. var SyncAsync = {
  500. assertSync: function (value) {
  501. if (isPromise(value)) {
  502. throw new Error("Illegal state: value cannot be a promise");
  503. }
  504. return value;
  505. },
  506. then: function (value, cb) { return isPromise(value) ? value.then(cb) : cb(value); },
  507. all: function (syncAsyncValues) {
  508. return syncAsyncValues.some(isPromise) ? Promise.all(syncAsyncValues) : /** @type {?} */ (syncAsyncValues);
  509. }
  510. };
  511. /**
  512. * @param {?} msg
  513. * @param {?=} parseErrors
  514. * @return {?}
  515. */
  516. function syntaxError(msg, parseErrors) {
  517. var /** @type {?} */ error = Error(msg);
  518. (/** @type {?} */ (error))[ERROR_SYNTAX_ERROR] = true;
  519. if (parseErrors)
  520. (/** @type {?} */ (error))[ERROR_PARSE_ERRORS] = parseErrors;
  521. return error;
  522. }
  523. var ERROR_SYNTAX_ERROR = 'ngSyntaxError';
  524. var ERROR_PARSE_ERRORS = 'ngParseErrors';
  525. /**
  526. * @param {?} error
  527. * @return {?}
  528. */
  529. function isSyntaxError(error) {
  530. return (/** @type {?} */ (error))[ERROR_SYNTAX_ERROR];
  531. }
  532. /**
  533. * @param {?} error
  534. * @return {?}
  535. */
  536. function getParseErrors(error) {
  537. return (/** @type {?} */ (error))[ERROR_PARSE_ERRORS] || [];
  538. }
  539. /**
  540. * @param {?} s
  541. * @return {?}
  542. */
  543. function escapeRegExp(s) {
  544. return s.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
  545. }
  546. var STRING_MAP_PROTO = Object.getPrototypeOf({});
  547. /**
  548. * @param {?} obj
  549. * @return {?}
  550. */
  551. function isStrictStringMap(obj) {
  552. return typeof obj === 'object' && obj !== null && Object.getPrototypeOf(obj) === STRING_MAP_PROTO;
  553. }
  554. /**
  555. * @param {?} str
  556. * @return {?}
  557. */
  558. function utf8Encode(str) {
  559. var /** @type {?} */ encoded = '';
  560. for (var /** @type {?} */ index = 0; index < str.length; index++) {
  561. var /** @type {?} */ codePoint = str.charCodeAt(index);
  562. // decode surrogate
  563. // see https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  564. if (codePoint >= 0xd800 && codePoint <= 0xdbff && str.length > (index + 1)) {
  565. var /** @type {?} */ low = str.charCodeAt(index + 1);
  566. if (low >= 0xdc00 && low <= 0xdfff) {
  567. index++;
  568. codePoint = ((codePoint - 0xd800) << 10) + low - 0xdc00 + 0x10000;
  569. }
  570. }
  571. if (codePoint <= 0x7f) {
  572. encoded += String.fromCharCode(codePoint);
  573. }
  574. else if (codePoint <= 0x7ff) {
  575. encoded += String.fromCharCode(((codePoint >> 6) & 0x1F) | 0xc0, (codePoint & 0x3f) | 0x80);
  576. }
  577. else if (codePoint <= 0xffff) {
  578. encoded += String.fromCharCode((codePoint >> 12) | 0xe0, ((codePoint >> 6) & 0x3f) | 0x80, (codePoint & 0x3f) | 0x80);
  579. }
  580. else if (codePoint <= 0x1fffff) {
  581. encoded += String.fromCharCode(((codePoint >> 18) & 0x07) | 0xf0, ((codePoint >> 12) & 0x3f) | 0x80, ((codePoint >> 6) & 0x3f) | 0x80, (codePoint & 0x3f) | 0x80);
  582. }
  583. }
  584. return encoded;
  585. }
  586. /**
  587. * @record
  588. */
  589. /**
  590. * @param {?} token
  591. * @return {?}
  592. */
  593. function stringify(token) {
  594. if (typeof token === 'string') {
  595. return token;
  596. }
  597. if (token instanceof Array) {
  598. return '[' + token.map(stringify).join(', ') + ']';
  599. }
  600. if (token == null) {
  601. return '' + token;
  602. }
  603. if (token.overriddenName) {
  604. return "" + token.overriddenName;
  605. }
  606. if (token.name) {
  607. return "" + token.name;
  608. }
  609. var /** @type {?} */ res = token.toString();
  610. if (res == null) {
  611. return '' + res;
  612. }
  613. var /** @type {?} */ newLineIndex = res.indexOf('\n');
  614. return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
  615. }
  616. /**
  617. * Lazily retrieves the reference value from a forwardRef.
  618. * @param {?} type
  619. * @return {?}
  620. */
  621. function resolveForwardRef(type) {
  622. if (typeof type === 'function' && type.hasOwnProperty('__forward_ref__')) {
  623. return type();
  624. }
  625. else {
  626. return type;
  627. }
  628. }
  629. /**
  630. * Determine if the argument is shaped like a Promise
  631. * @param {?} obj
  632. * @return {?}
  633. */
  634. function isPromise(obj) {
  635. // allow any Promise/A+ compliant thenable.
  636. // It's up to the caller to ensure that obj.then conforms to the spec
  637. return !!obj && typeof obj.then === 'function';
  638. }
  639. var Version = /** @class */ (function () {
  640. function Version(full) {
  641. this.full = full;
  642. var /** @type {?} */ splits = full.split('.');
  643. this.major = splits[0];
  644. this.minor = splits[1];
  645. this.patch = splits.slice(2).join('.');
  646. }
  647. return Version;
  648. }());
  649. /**
  650. * @record
  651. */
  652. /**
  653. * @fileoverview added by tsickle
  654. * @suppress {checkTypes} checked by tsc
  655. */
  656. /**
  657. * @license
  658. * Copyright Google Inc. All Rights Reserved.
  659. *
  660. * Use of this source code is governed by an MIT-style license that can be
  661. * found in the LICENSE file at https://angular.io/license
  662. */
  663. /**
  664. * \@stable
  665. */
  666. var VERSION = new Version('5.2.11');
  667. /**
  668. * @fileoverview added by tsickle
  669. * @suppress {checkTypes} checked by tsc
  670. */
  671. /**
  672. * @license
  673. * Copyright Google Inc. All Rights Reserved.
  674. *
  675. * Use of this source code is governed by an MIT-style license that can be
  676. * found in the LICENSE file at https://angular.io/license
  677. */
  678. /**
  679. * An Abstract Syntax Tree node representing part of a parsed Angular template.
  680. * @record
  681. */
  682. /**
  683. * A segment of text within the template.
  684. */
  685. var TextAst = /** @class */ (function () {
  686. function TextAst(value, ngContentIndex, sourceSpan) {
  687. this.value = value;
  688. this.ngContentIndex = ngContentIndex;
  689. this.sourceSpan = sourceSpan;
  690. }
  691. /**
  692. * @param {?} visitor
  693. * @param {?} context
  694. * @return {?}
  695. */
  696. TextAst.prototype.visit = /**
  697. * @param {?} visitor
  698. * @param {?} context
  699. * @return {?}
  700. */
  701. function (visitor, context) { return visitor.visitText(this, context); };
  702. return TextAst;
  703. }());
  704. /**
  705. * A bound expression within the text of a template.
  706. */
  707. var BoundTextAst = /** @class */ (function () {
  708. function BoundTextAst(value, ngContentIndex, sourceSpan) {
  709. this.value = value;
  710. this.ngContentIndex = ngContentIndex;
  711. this.sourceSpan = sourceSpan;
  712. }
  713. /**
  714. * @param {?} visitor
  715. * @param {?} context
  716. * @return {?}
  717. */
  718. BoundTextAst.prototype.visit = /**
  719. * @param {?} visitor
  720. * @param {?} context
  721. * @return {?}
  722. */
  723. function (visitor, context) {
  724. return visitor.visitBoundText(this, context);
  725. };
  726. return BoundTextAst;
  727. }());
  728. /**
  729. * A plain attribute on an element.
  730. */
  731. var AttrAst = /** @class */ (function () {
  732. function AttrAst(name, value, sourceSpan) {
  733. this.name = name;
  734. this.value = value;
  735. this.sourceSpan = sourceSpan;
  736. }
  737. /**
  738. * @param {?} visitor
  739. * @param {?} context
  740. * @return {?}
  741. */
  742. AttrAst.prototype.visit = /**
  743. * @param {?} visitor
  744. * @param {?} context
  745. * @return {?}
  746. */
  747. function (visitor, context) { return visitor.visitAttr(this, context); };
  748. return AttrAst;
  749. }());
  750. /**
  751. * A binding for an element property (e.g. `[property]="expression"`) or an animation trigger (e.g.
  752. * `[\@trigger]="stateExp"`)
  753. */
  754. var BoundElementPropertyAst = /** @class */ (function () {
  755. function BoundElementPropertyAst(name, type, securityContext, value, unit, sourceSpan) {
  756. this.name = name;
  757. this.type = type;
  758. this.securityContext = securityContext;
  759. this.value = value;
  760. this.unit = unit;
  761. this.sourceSpan = sourceSpan;
  762. this.isAnimation = this.type === PropertyBindingType.Animation;
  763. }
  764. /**
  765. * @param {?} visitor
  766. * @param {?} context
  767. * @return {?}
  768. */
  769. BoundElementPropertyAst.prototype.visit = /**
  770. * @param {?} visitor
  771. * @param {?} context
  772. * @return {?}
  773. */
  774. function (visitor, context) {
  775. return visitor.visitElementProperty(this, context);
  776. };
  777. return BoundElementPropertyAst;
  778. }());
  779. /**
  780. * A binding for an element event (e.g. `(event)="handler()"`) or an animation trigger event (e.g.
  781. * `(\@trigger.phase)="callback($event)"`).
  782. */
  783. var BoundEventAst = /** @class */ (function () {
  784. function BoundEventAst(name, target, phase, handler, sourceSpan) {
  785. this.name = name;
  786. this.target = target;
  787. this.phase = phase;
  788. this.handler = handler;
  789. this.sourceSpan = sourceSpan;
  790. this.fullName = BoundEventAst.calcFullName(this.name, this.target, this.phase);
  791. this.isAnimation = !!this.phase;
  792. }
  793. /**
  794. * @param {?} name
  795. * @param {?} target
  796. * @param {?} phase
  797. * @return {?}
  798. */
  799. BoundEventAst.calcFullName = /**
  800. * @param {?} name
  801. * @param {?} target
  802. * @param {?} phase
  803. * @return {?}
  804. */
  805. function (name, target, phase) {
  806. if (target) {
  807. return target + ":" + name;
  808. }
  809. else if (phase) {
  810. return "@" + name + "." + phase;
  811. }
  812. else {
  813. return name;
  814. }
  815. };
  816. /**
  817. * @param {?} visitor
  818. * @param {?} context
  819. * @return {?}
  820. */
  821. BoundEventAst.prototype.visit = /**
  822. * @param {?} visitor
  823. * @param {?} context
  824. * @return {?}
  825. */
  826. function (visitor, context) {
  827. return visitor.visitEvent(this, context);
  828. };
  829. return BoundEventAst;
  830. }());
  831. /**
  832. * A reference declaration on an element (e.g. `let someName="expression"`).
  833. */
  834. var ReferenceAst = /** @class */ (function () {
  835. function ReferenceAst(name, value, sourceSpan) {
  836. this.name = name;
  837. this.value = value;
  838. this.sourceSpan = sourceSpan;
  839. }
  840. /**
  841. * @param {?} visitor
  842. * @param {?} context
  843. * @return {?}
  844. */
  845. ReferenceAst.prototype.visit = /**
  846. * @param {?} visitor
  847. * @param {?} context
  848. * @return {?}
  849. */
  850. function (visitor, context) {
  851. return visitor.visitReference(this, context);
  852. };
  853. return ReferenceAst;
  854. }());
  855. /**
  856. * A variable declaration on a <ng-template> (e.g. `var-someName="someLocalName"`).
  857. */
  858. var VariableAst = /** @class */ (function () {
  859. function VariableAst(name, value, sourceSpan) {
  860. this.name = name;
  861. this.value = value;
  862. this.sourceSpan = sourceSpan;
  863. }
  864. /**
  865. * @param {?} visitor
  866. * @param {?} context
  867. * @return {?}
  868. */
  869. VariableAst.prototype.visit = /**
  870. * @param {?} visitor
  871. * @param {?} context
  872. * @return {?}
  873. */
  874. function (visitor, context) {
  875. return visitor.visitVariable(this, context);
  876. };
  877. return VariableAst;
  878. }());
  879. /**
  880. * An element declaration in a template.
  881. */
  882. var ElementAst = /** @class */ (function () {
  883. function ElementAst(name, attrs, inputs, outputs, references, directives, providers, hasViewContainer, queryMatches, children, ngContentIndex, sourceSpan, endSourceSpan) {
  884. this.name = name;
  885. this.attrs = attrs;
  886. this.inputs = inputs;
  887. this.outputs = outputs;
  888. this.references = references;
  889. this.directives = directives;
  890. this.providers = providers;
  891. this.hasViewContainer = hasViewContainer;
  892. this.queryMatches = queryMatches;
  893. this.children = children;
  894. this.ngContentIndex = ngContentIndex;
  895. this.sourceSpan = sourceSpan;
  896. this.endSourceSpan = endSourceSpan;
  897. }
  898. /**
  899. * @param {?} visitor
  900. * @param {?} context
  901. * @return {?}
  902. */
  903. ElementAst.prototype.visit = /**
  904. * @param {?} visitor
  905. * @param {?} context
  906. * @return {?}
  907. */
  908. function (visitor, context) {
  909. return visitor.visitElement(this, context);
  910. };
  911. return ElementAst;
  912. }());
  913. /**
  914. * A `<ng-template>` element included in an Angular template.
  915. */
  916. var EmbeddedTemplateAst = /** @class */ (function () {
  917. function EmbeddedTemplateAst(attrs, outputs, references, variables, directives, providers, hasViewContainer, queryMatches, children, ngContentIndex, sourceSpan) {
  918. this.attrs = attrs;
  919. this.outputs = outputs;
  920. this.references = references;
  921. this.variables = variables;
  922. this.directives = directives;
  923. this.providers = providers;
  924. this.hasViewContainer = hasViewContainer;
  925. this.queryMatches = queryMatches;
  926. this.children = children;
  927. this.ngContentIndex = ngContentIndex;
  928. this.sourceSpan = sourceSpan;
  929. }
  930. /**
  931. * @param {?} visitor
  932. * @param {?} context
  933. * @return {?}
  934. */
  935. EmbeddedTemplateAst.prototype.visit = /**
  936. * @param {?} visitor
  937. * @param {?} context
  938. * @return {?}
  939. */
  940. function (visitor, context) {
  941. return visitor.visitEmbeddedTemplate(this, context);
  942. };
  943. return EmbeddedTemplateAst;
  944. }());
  945. /**
  946. * A directive property with a bound value (e.g. `*ngIf="condition").
  947. */
  948. var BoundDirectivePropertyAst = /** @class */ (function () {
  949. function BoundDirectivePropertyAst(directiveName, templateName, value, sourceSpan) {
  950. this.directiveName = directiveName;
  951. this.templateName = templateName;
  952. this.value = value;
  953. this.sourceSpan = sourceSpan;
  954. }
  955. /**
  956. * @param {?} visitor
  957. * @param {?} context
  958. * @return {?}
  959. */
  960. BoundDirectivePropertyAst.prototype.visit = /**
  961. * @param {?} visitor
  962. * @param {?} context
  963. * @return {?}
  964. */
  965. function (visitor, context) {
  966. return visitor.visitDirectiveProperty(this, context);
  967. };
  968. return BoundDirectivePropertyAst;
  969. }());
  970. /**
  971. * A directive declared on an element.
  972. */
  973. var DirectiveAst = /** @class */ (function () {
  974. function DirectiveAst(directive, inputs, hostProperties, hostEvents, contentQueryStartId, sourceSpan) {
  975. this.directive = directive;
  976. this.inputs = inputs;
  977. this.hostProperties = hostProperties;
  978. this.hostEvents = hostEvents;
  979. this.contentQueryStartId = contentQueryStartId;
  980. this.sourceSpan = sourceSpan;
  981. }
  982. /**
  983. * @param {?} visitor
  984. * @param {?} context
  985. * @return {?}
  986. */
  987. DirectiveAst.prototype.visit = /**
  988. * @param {?} visitor
  989. * @param {?} context
  990. * @return {?}
  991. */
  992. function (visitor, context) {
  993. return visitor.visitDirective(this, context);
  994. };
  995. return DirectiveAst;
  996. }());
  997. /**
  998. * A provider declared on an element
  999. */
  1000. var ProviderAst = /** @class */ (function () {
  1001. function ProviderAst(token, multiProvider, eager, providers, providerType, lifecycleHooks, sourceSpan) {
  1002. this.token = token;
  1003. this.multiProvider = multiProvider;
  1004. this.eager = eager;
  1005. this.providers = providers;
  1006. this.providerType = providerType;
  1007. this.lifecycleHooks = lifecycleHooks;
  1008. this.sourceSpan = sourceSpan;
  1009. }
  1010. /**
  1011. * @param {?} visitor
  1012. * @param {?} context
  1013. * @return {?}
  1014. */
  1015. ProviderAst.prototype.visit = /**
  1016. * @param {?} visitor
  1017. * @param {?} context
  1018. * @return {?}
  1019. */
  1020. function (visitor, context) {
  1021. // No visit method in the visitor for now...
  1022. return null;
  1023. };
  1024. return ProviderAst;
  1025. }());
  1026. /** @enum {number} */
  1027. var ProviderAstType = {
  1028. PublicService: 0,
  1029. PrivateService: 1,
  1030. Component: 2,
  1031. Directive: 3,
  1032. Builtin: 4,
  1033. };
  1034. ProviderAstType[ProviderAstType.PublicService] = "PublicService";
  1035. ProviderAstType[ProviderAstType.PrivateService] = "PrivateService";
  1036. ProviderAstType[ProviderAstType.Component] = "Component";
  1037. ProviderAstType[ProviderAstType.Directive] = "Directive";
  1038. ProviderAstType[ProviderAstType.Builtin] = "Builtin";
  1039. /**
  1040. * Position where content is to be projected (instance of `<ng-content>` in a template).
  1041. */
  1042. var NgContentAst = /** @class */ (function () {
  1043. function NgContentAst(index, ngContentIndex, sourceSpan) {
  1044. this.index = index;
  1045. this.ngContentIndex = ngContentIndex;
  1046. this.sourceSpan = sourceSpan;
  1047. }
  1048. /**
  1049. * @param {?} visitor
  1050. * @param {?} context
  1051. * @return {?}
  1052. */
  1053. NgContentAst.prototype.visit = /**
  1054. * @param {?} visitor
  1055. * @param {?} context
  1056. * @return {?}
  1057. */
  1058. function (visitor, context) {
  1059. return visitor.visitNgContent(this, context);
  1060. };
  1061. return NgContentAst;
  1062. }());
  1063. /** @enum {number} */
  1064. var PropertyBindingType = {
  1065. /**
  1066. * A normal binding to a property (e.g. `[property]="expression"`).
  1067. */
  1068. Property: 0,
  1069. /**
  1070. * A binding to an element attribute (e.g. `[attr.name]="expression"`).
  1071. */
  1072. Attribute: 1,
  1073. /**
  1074. * A binding to a CSS class (e.g. `[class.name]="condition"`).
  1075. */
  1076. Class: 2,
  1077. /**
  1078. * A binding to a style rule (e.g. `[style.rule]="expression"`).
  1079. */
  1080. Style: 3,
  1081. /**
  1082. * A binding to an animation reference (e.g. `[animate.key]="expression"`).
  1083. */
  1084. Animation: 4,
  1085. };
  1086. PropertyBindingType[PropertyBindingType.Property] = "Property";
  1087. PropertyBindingType[PropertyBindingType.Attribute] = "Attribute";
  1088. PropertyBindingType[PropertyBindingType.Class] = "Class";
  1089. PropertyBindingType[PropertyBindingType.Style] = "Style";
  1090. PropertyBindingType[PropertyBindingType.Animation] = "Animation";
  1091. /**
  1092. * @record
  1093. */
  1094. /**
  1095. * A visitor for {\@link TemplateAst} trees that will process each node.
  1096. * @record
  1097. */
  1098. /**
  1099. * A visitor that accepts each node but doesn't do anything. It is intended to be used
  1100. * as the base class for a visitor that is only interested in a subset of the node types.
  1101. */
  1102. var NullTemplateVisitor = /** @class */ (function () {
  1103. function NullTemplateVisitor() {
  1104. }
  1105. /**
  1106. * @param {?} ast
  1107. * @param {?} context
  1108. * @return {?}
  1109. */
  1110. NullTemplateVisitor.prototype.visitNgContent = /**
  1111. * @param {?} ast
  1112. * @param {?} context
  1113. * @return {?}
  1114. */
  1115. function (ast, context) { };
  1116. /**
  1117. * @param {?} ast
  1118. * @param {?} context
  1119. * @return {?}
  1120. */
  1121. NullTemplateVisitor.prototype.visitEmbeddedTemplate = /**
  1122. * @param {?} ast
  1123. * @param {?} context
  1124. * @return {?}
  1125. */
  1126. function (ast, context) { };
  1127. /**
  1128. * @param {?} ast
  1129. * @param {?} context
  1130. * @return {?}
  1131. */
  1132. NullTemplateVisitor.prototype.visitElement = /**
  1133. * @param {?} ast
  1134. * @param {?} context
  1135. * @return {?}
  1136. */
  1137. function (ast, context) { };
  1138. /**
  1139. * @param {?} ast
  1140. * @param {?} context
  1141. * @return {?}
  1142. */
  1143. NullTemplateVisitor.prototype.visitReference = /**
  1144. * @param {?} ast
  1145. * @param {?} context
  1146. * @return {?}
  1147. */
  1148. function (ast, context) { };
  1149. /**
  1150. * @param {?} ast
  1151. * @param {?} context
  1152. * @return {?}
  1153. */
  1154. NullTemplateVisitor.prototype.visitVariable = /**
  1155. * @param {?} ast
  1156. * @param {?} context
  1157. * @return {?}
  1158. */
  1159. function (ast, context) { };
  1160. /**
  1161. * @param {?} ast
  1162. * @param {?} context
  1163. * @return {?}
  1164. */
  1165. NullTemplateVisitor.prototype.visitEvent = /**
  1166. * @param {?} ast
  1167. * @param {?} context
  1168. * @return {?}
  1169. */
  1170. function (ast, context) { };
  1171. /**
  1172. * @param {?} ast
  1173. * @param {?} context
  1174. * @return {?}
  1175. */
  1176. NullTemplateVisitor.prototype.visitElementProperty = /**
  1177. * @param {?} ast
  1178. * @param {?} context
  1179. * @return {?}
  1180. */
  1181. function (ast, context) { };
  1182. /**
  1183. * @param {?} ast
  1184. * @param {?} context
  1185. * @return {?}
  1186. */
  1187. NullTemplateVisitor.prototype.visitAttr = /**
  1188. * @param {?} ast
  1189. * @param {?} context
  1190. * @return {?}
  1191. */
  1192. function (ast, context) { };
  1193. /**
  1194. * @param {?} ast
  1195. * @param {?} context
  1196. * @return {?}
  1197. */
  1198. NullTemplateVisitor.prototype.visitBoundText = /**
  1199. * @param {?} ast
  1200. * @param {?} context
  1201. * @return {?}
  1202. */
  1203. function (ast, context) { };
  1204. /**
  1205. * @param {?} ast
  1206. * @param {?} context
  1207. * @return {?}
  1208. */
  1209. NullTemplateVisitor.prototype.visitText = /**
  1210. * @param {?} ast
  1211. * @param {?} context
  1212. * @return {?}
  1213. */
  1214. function (ast, context) { };
  1215. /**
  1216. * @param {?} ast
  1217. * @param {?} context
  1218. * @return {?}
  1219. */
  1220. NullTemplateVisitor.prototype.visitDirective = /**
  1221. * @param {?} ast
  1222. * @param {?} context
  1223. * @return {?}
  1224. */
  1225. function (ast, context) { };
  1226. /**
  1227. * @param {?} ast
  1228. * @param {?} context
  1229. * @return {?}
  1230. */
  1231. NullTemplateVisitor.prototype.visitDirectiveProperty = /**
  1232. * @param {?} ast
  1233. * @param {?} context
  1234. * @return {?}
  1235. */
  1236. function (ast, context) { };
  1237. return NullTemplateVisitor;
  1238. }());
  1239. /**
  1240. * Base class that can be used to build a visitor that visits each node
  1241. * in an template ast recursively.
  1242. */
  1243. var RecursiveTemplateAstVisitor = /** @class */ (function (_super) {
  1244. __extends(RecursiveTemplateAstVisitor, _super);
  1245. function RecursiveTemplateAstVisitor() {
  1246. return _super.call(this) || this;
  1247. }
  1248. // Nodes with children
  1249. /**
  1250. * @param {?} ast
  1251. * @param {?} context
  1252. * @return {?}
  1253. */
  1254. RecursiveTemplateAstVisitor.prototype.visitEmbeddedTemplate = /**
  1255. * @param {?} ast
  1256. * @param {?} context
  1257. * @return {?}
  1258. */
  1259. function (ast, context) {
  1260. return this.visitChildren(context, function (visit) {
  1261. visit(ast.attrs);
  1262. visit(ast.references);
  1263. visit(ast.variables);
  1264. visit(ast.directives);
  1265. visit(ast.providers);
  1266. visit(ast.children);
  1267. });
  1268. };
  1269. /**
  1270. * @param {?} ast
  1271. * @param {?} context
  1272. * @return {?}
  1273. */
  1274. RecursiveTemplateAstVisitor.prototype.visitElement = /**
  1275. * @param {?} ast
  1276. * @param {?} context
  1277. * @return {?}
  1278. */
  1279. function (ast, context) {
  1280. return this.visitChildren(context, function (visit) {
  1281. visit(ast.attrs);
  1282. visit(ast.inputs);
  1283. visit(ast.outputs);
  1284. visit(ast.references);
  1285. visit(ast.directives);
  1286. visit(ast.providers);
  1287. visit(ast.children);
  1288. });
  1289. };
  1290. /**
  1291. * @param {?} ast
  1292. * @param {?} context
  1293. * @return {?}
  1294. */
  1295. RecursiveTemplateAstVisitor.prototype.visitDirective = /**
  1296. * @param {?} ast
  1297. * @param {?} context
  1298. * @return {?}
  1299. */
  1300. function (ast, context) {
  1301. return this.visitChildren(context, function (visit) {
  1302. visit(ast.inputs);
  1303. visit(ast.hostProperties);
  1304. visit(ast.hostEvents);
  1305. });
  1306. };
  1307. /**
  1308. * @template T
  1309. * @param {?} context
  1310. * @param {?} cb
  1311. * @return {?}
  1312. */
  1313. RecursiveTemplateAstVisitor.prototype.visitChildren = /**
  1314. * @template T
  1315. * @param {?} context
  1316. * @param {?} cb
  1317. * @return {?}
  1318. */
  1319. function (context, cb) {
  1320. var /** @type {?} */ results = [];
  1321. var /** @type {?} */ t = this;
  1322. /**
  1323. * @template T
  1324. * @param {?} children
  1325. * @return {?}
  1326. */
  1327. function visit(children) {
  1328. if (children && children.length)
  1329. results.push(templateVisitAll(t, children, context));
  1330. }
  1331. cb(visit);
  1332. return [].concat.apply([], results);
  1333. };
  1334. return RecursiveTemplateAstVisitor;
  1335. }(NullTemplateVisitor));
  1336. /**
  1337. * Visit every node in a list of {\@link TemplateAst}s with the given {\@link TemplateAstVisitor}.
  1338. * @param {?} visitor
  1339. * @param {?} asts
  1340. * @param {?=} context
  1341. * @return {?}
  1342. */
  1343. function templateVisitAll(visitor, asts, context) {
  1344. if (context === void 0) { context = null; }
  1345. var /** @type {?} */ result = [];
  1346. var /** @type {?} */ visit = visitor.visit ?
  1347. function (ast) { return ((visitor.visit))(ast, context) || ast.visit(visitor, context); } :
  1348. function (ast) { return ast.visit(visitor, context); };
  1349. asts.forEach(function (ast) {
  1350. var /** @type {?} */ astResult = visit(ast);
  1351. if (astResult) {
  1352. result.push(astResult);
  1353. }
  1354. });
  1355. return result;
  1356. }
  1357. /**
  1358. * @fileoverview added by tsickle
  1359. * @suppress {checkTypes} checked by tsc
  1360. */
  1361. /**
  1362. * @license
  1363. * Copyright Google Inc. All Rights Reserved.
  1364. *
  1365. * Use of this source code is governed by an MIT-style license that can be
  1366. * found in the LICENSE file at https://angular.io/license
  1367. */
  1368. var CompilerConfig = /** @class */ (function () {
  1369. function CompilerConfig(_a) {
  1370. 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;
  1371. this.defaultEncapsulation = defaultEncapsulation;
  1372. this.useJit = !!useJit;
  1373. this.jitDevMode = !!jitDevMode;
  1374. this.missingTranslation = missingTranslation;
  1375. this.enableLegacyTemplate = enableLegacyTemplate === true;
  1376. this.preserveWhitespaces = preserveWhitespacesDefault(noUndefined(preserveWhitespaces));
  1377. this.strictInjectionParameters = strictInjectionParameters === true;
  1378. }
  1379. return CompilerConfig;
  1380. }());
  1381. /**
  1382. * @param {?} preserveWhitespacesOption
  1383. * @param {?=} defaultSetting
  1384. * @return {?}
  1385. */
  1386. function preserveWhitespacesDefault(preserveWhitespacesOption, defaultSetting) {
  1387. if (defaultSetting === void 0) { defaultSetting = true; }
  1388. return preserveWhitespacesOption === null ? defaultSetting : preserveWhitespacesOption;
  1389. }
  1390. /**
  1391. * @fileoverview added by tsickle
  1392. * @suppress {checkTypes} checked by tsc
  1393. */
  1394. /**
  1395. * @license
  1396. * Copyright Google Inc. All Rights Reserved.
  1397. *
  1398. * Use of this source code is governed by an MIT-style license that can be
  1399. * found in the LICENSE file at https://angular.io/license
  1400. */
  1401. /**
  1402. * A token representing the a reference to a static type.
  1403. *
  1404. * This token is unique for a filePath and name and can be used as a hash table key.
  1405. */
  1406. var StaticSymbol = /** @class */ (function () {
  1407. function StaticSymbol(filePath, name, members) {
  1408. this.filePath = filePath;
  1409. this.name = name;
  1410. this.members = members;
  1411. }
  1412. /**
  1413. * @return {?}
  1414. */
  1415. StaticSymbol.prototype.assertNoMembers = /**
  1416. * @return {?}
  1417. */
  1418. function () {
  1419. if (this.members.length) {
  1420. throw new Error("Illegal state: symbol without members expected, but got " + JSON.stringify(this) + ".");
  1421. }
  1422. };
  1423. return StaticSymbol;
  1424. }());
  1425. /**
  1426. * A cache of static symbol used by the StaticReflector to return the same symbol for the
  1427. * same symbol values.
  1428. */
  1429. var StaticSymbolCache = /** @class */ (function () {
  1430. function StaticSymbolCache() {
  1431. this.cache = new Map();
  1432. }
  1433. /**
  1434. * @param {?} declarationFile
  1435. * @param {?} name
  1436. * @param {?=} members
  1437. * @return {?}
  1438. */
  1439. StaticSymbolCache.prototype.get = /**
  1440. * @param {?} declarationFile
  1441. * @param {?} name
  1442. * @param {?=} members
  1443. * @return {?}
  1444. */
  1445. function (declarationFile, name, members) {
  1446. members = members || [];
  1447. var /** @type {?} */ memberSuffix = members.length ? "." + members.join('.') : '';
  1448. var /** @type {?} */ key = "\"" + declarationFile + "\"." + name + memberSuffix;
  1449. var /** @type {?} */ result = this.cache.get(key);
  1450. if (!result) {
  1451. result = new StaticSymbol(declarationFile, name, members);
  1452. this.cache.set(key, result);
  1453. }
  1454. return result;
  1455. };
  1456. return StaticSymbolCache;
  1457. }());
  1458. /**
  1459. * @fileoverview added by tsickle
  1460. * @suppress {checkTypes} checked by tsc
  1461. */
  1462. /**
  1463. * @license
  1464. * Copyright Google Inc. All Rights Reserved.
  1465. *
  1466. * Use of this source code is governed by an MIT-style license that can be
  1467. * found in the LICENSE file at https://angular.io/license
  1468. */
  1469. // group 0: "[prop] or (event) or @trigger"
  1470. // group 1: "prop" from "[prop]"
  1471. // group 2: "event" from "(event)"
  1472. // group 3: "@trigger" from "@trigger"
  1473. var HOST_REG_EXP = /^(?:(?:\[([^\]]+)\])|(?:\(([^\)]+)\)))|(\@[-\w]+)$/;
  1474. /**
  1475. * @param {?} name
  1476. * @return {?}
  1477. */
  1478. function _sanitizeIdentifier(name) {
  1479. return name.replace(/\W/g, '_');
  1480. }
  1481. var _anonymousTypeIndex = 0;
  1482. /**
  1483. * @param {?} compileIdentifier
  1484. * @return {?}
  1485. */
  1486. function identifierName(compileIdentifier) {
  1487. if (!compileIdentifier || !compileIdentifier.reference) {
  1488. return null;
  1489. }
  1490. var /** @type {?} */ ref = compileIdentifier.reference;
  1491. if (ref instanceof StaticSymbol) {
  1492. return ref.name;
  1493. }
  1494. if (ref['__anonymousType']) {
  1495. return ref['__anonymousType'];
  1496. }
  1497. var /** @type {?} */ identifier = stringify(ref);
  1498. if (identifier.indexOf('(') >= 0) {
  1499. // case: anonymous functions!
  1500. identifier = "anonymous_" + _anonymousTypeIndex++;
  1501. ref['__anonymousType'] = identifier;
  1502. }
  1503. else {
  1504. identifier = _sanitizeIdentifier(identifier);
  1505. }
  1506. return identifier;
  1507. }
  1508. /**
  1509. * @param {?} compileIdentifier
  1510. * @return {?}
  1511. */
  1512. function identifierModuleUrl(compileIdentifier) {
  1513. var /** @type {?} */ ref = compileIdentifier.reference;
  1514. if (ref instanceof StaticSymbol) {
  1515. return ref.filePath;
  1516. }
  1517. // Runtime type
  1518. return "./" + stringify(ref);
  1519. }
  1520. /**
  1521. * @param {?} compType
  1522. * @param {?} embeddedTemplateIndex
  1523. * @return {?}
  1524. */
  1525. function viewClassName(compType, embeddedTemplateIndex) {
  1526. return "View_" + identifierName({ reference: compType }) + "_" + embeddedTemplateIndex;
  1527. }
  1528. /**
  1529. * @param {?} compType
  1530. * @return {?}
  1531. */
  1532. function rendererTypeName(compType) {
  1533. return "RenderType_" + identifierName({ reference: compType });
  1534. }
  1535. /**
  1536. * @param {?} compType
  1537. * @return {?}
  1538. */
  1539. function hostViewClassName(compType) {
  1540. return "HostView_" + identifierName({ reference: compType });
  1541. }
  1542. /**
  1543. * @param {?} compType
  1544. * @return {?}
  1545. */
  1546. function componentFactoryName(compType) {
  1547. return identifierName({ reference: compType }) + "NgFactory";
  1548. }
  1549. /**
  1550. * @record
  1551. */
  1552. /**
  1553. * @record
  1554. */
  1555. /** @enum {number} */
  1556. var CompileSummaryKind = {
  1557. Pipe: 0,
  1558. Directive: 1,
  1559. NgModule: 2,
  1560. Injectable: 3,
  1561. };
  1562. CompileSummaryKind[CompileSummaryKind.Pipe] = "Pipe";
  1563. CompileSummaryKind[CompileSummaryKind.Directive] = "Directive";
  1564. CompileSummaryKind[CompileSummaryKind.NgModule] = "NgModule";
  1565. CompileSummaryKind[CompileSummaryKind.Injectable] = "Injectable";
  1566. /**
  1567. * A CompileSummary is the data needed to use a directive / pipe / module
  1568. * in other modules / components. However, this data is not enough to compile
  1569. * the directive / module itself.
  1570. * @record
  1571. */
  1572. /**
  1573. * @record
  1574. */
  1575. /**
  1576. * @record
  1577. */
  1578. /**
  1579. * @record
  1580. */
  1581. /**
  1582. * @param {?} token
  1583. * @return {?}
  1584. */
  1585. function tokenName(token) {
  1586. return token.value != null ? _sanitizeIdentifier(token.value) : identifierName(token.identifier);
  1587. }
  1588. /**
  1589. * @param {?} token
  1590. * @return {?}
  1591. */
  1592. function tokenReference(token) {
  1593. if (token.identifier != null) {
  1594. return token.identifier.reference;
  1595. }
  1596. else {
  1597. return token.value;
  1598. }
  1599. }
  1600. /**
  1601. * @record
  1602. */
  1603. /**
  1604. * Metadata regarding compilation of a type.
  1605. * @record
  1606. */
  1607. /**
  1608. * @record
  1609. */
  1610. /**
  1611. * Metadata about a stylesheet
  1612. */
  1613. var CompileStylesheetMetadata = /** @class */ (function () {
  1614. function CompileStylesheetMetadata(_a) {
  1615. var _b = _a === void 0 ? {} : _a, moduleUrl = _b.moduleUrl, styles = _b.styles, styleUrls = _b.styleUrls;
  1616. this.moduleUrl = moduleUrl || null;
  1617. this.styles = _normalizeArray(styles);
  1618. this.styleUrls = _normalizeArray(styleUrls);
  1619. }
  1620. return CompileStylesheetMetadata;
  1621. }());
  1622. /**
  1623. * Summary Metadata regarding compilation of a template.
  1624. * @record
  1625. */
  1626. /**
  1627. * Metadata regarding compilation of a template.
  1628. */
  1629. var CompileTemplateMetadata = /** @class */ (function () {
  1630. function CompileTemplateMetadata(_a) {
  1631. 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;
  1632. this.encapsulation = encapsulation;
  1633. this.template = template;
  1634. this.templateUrl = templateUrl;
  1635. this.htmlAst = htmlAst;
  1636. this.styles = _normalizeArray(styles);
  1637. this.styleUrls = _normalizeArray(styleUrls);
  1638. this.externalStylesheets = _normalizeArray(externalStylesheets);
  1639. this.animations = animations ? flatten(animations) : [];
  1640. this.ngContentSelectors = ngContentSelectors || [];
  1641. if (interpolation && interpolation.length != 2) {
  1642. throw new Error("'interpolation' should have a start and an end symbol.");
  1643. }
  1644. this.interpolation = interpolation;
  1645. this.isInline = isInline;
  1646. this.preserveWhitespaces = preserveWhitespaces;
  1647. }
  1648. /**
  1649. * @return {?}
  1650. */
  1651. CompileTemplateMetadata.prototype.toSummary = /**
  1652. * @return {?}
  1653. */
  1654. function () {
  1655. return {
  1656. ngContentSelectors: this.ngContentSelectors,
  1657. encapsulation: this.encapsulation,
  1658. };
  1659. };
  1660. return CompileTemplateMetadata;
  1661. }());
  1662. /**
  1663. * @record
  1664. */
  1665. /**
  1666. * @record
  1667. */
  1668. /**
  1669. * Metadata regarding compilation of a directive.
  1670. */
  1671. var CompileDirectiveMetadata = /** @class */ (function () {
  1672. function CompileDirectiveMetadata(_a) {
  1673. 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;
  1674. this.isHost = !!isHost;
  1675. this.type = type;
  1676. this.isComponent = isComponent;
  1677. this.selector = selector;
  1678. this.exportAs = exportAs;
  1679. this.changeDetection = changeDetection;
  1680. this.inputs = inputs;
  1681. this.outputs = outputs;
  1682. this.hostListeners = hostListeners;
  1683. this.hostProperties = hostProperties;
  1684. this.hostAttributes = hostAttributes;
  1685. this.providers = _normalizeArray(providers);
  1686. this.viewProviders = _normalizeArray(viewProviders);
  1687. this.queries = _normalizeArray(queries);
  1688. this.guards = guards;
  1689. this.viewQueries = _normalizeArray(viewQueries);
  1690. this.entryComponents = _normalizeArray(entryComponents);
  1691. this.template = template;
  1692. this.componentViewType = componentViewType;
  1693. this.rendererType = rendererType;
  1694. this.componentFactory = componentFactory;
  1695. }
  1696. /**
  1697. * @param {?} __0
  1698. * @return {?}
  1699. */
  1700. CompileDirectiveMetadata.create = /**
  1701. * @param {?} __0
  1702. * @return {?}
  1703. */
  1704. function (_a) {
  1705. 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;
  1706. var /** @type {?} */ hostListeners = {};
  1707. var /** @type {?} */ hostProperties = {};
  1708. var /** @type {?} */ hostAttributes = {};
  1709. if (host != null) {
  1710. Object.keys(host).forEach(function (key) {
  1711. var /** @type {?} */ value = host[key];
  1712. var /** @type {?} */ matches = key.match(HOST_REG_EXP);
  1713. if (matches === null) {
  1714. hostAttributes[key] = value;
  1715. }
  1716. else if (matches[1] != null) {
  1717. hostProperties[matches[1]] = value;
  1718. }
  1719. else if (matches[2] != null) {
  1720. hostListeners[matches[2]] = value;
  1721. }
  1722. });
  1723. }
  1724. var /** @type {?} */ inputsMap = {};
  1725. if (inputs != null) {
  1726. inputs.forEach(function (bindConfig) {
  1727. // canonical syntax: `dirProp: elProp`
  1728. // if there is no `:`, use dirProp = elProp
  1729. var /** @type {?} */ parts = splitAtColon(bindConfig, [bindConfig, bindConfig]);
  1730. inputsMap[parts[0]] = parts[1];
  1731. });
  1732. }
  1733. var /** @type {?} */ outputsMap = {};
  1734. if (outputs != null) {
  1735. outputs.forEach(function (bindConfig) {
  1736. // canonical syntax: `dirProp: elProp`
  1737. // if there is no `:`, use dirProp = elProp
  1738. var /** @type {?} */ parts = splitAtColon(bindConfig, [bindConfig, bindConfig]);
  1739. outputsMap[parts[0]] = parts[1];
  1740. });
  1741. }
  1742. return new CompileDirectiveMetadata({
  1743. isHost: isHost,
  1744. type: type,
  1745. isComponent: !!isComponent, selector: selector, exportAs: exportAs, changeDetection: changeDetection,
  1746. inputs: inputsMap,
  1747. outputs: outputsMap,
  1748. hostListeners: hostListeners,
  1749. hostProperties: hostProperties,
  1750. hostAttributes: hostAttributes,
  1751. providers: providers,
  1752. viewProviders: viewProviders,
  1753. queries: queries,
  1754. guards: guards,
  1755. viewQueries: viewQueries,
  1756. entryComponents: entryComponents,
  1757. template: template,
  1758. componentViewType: componentViewType,
  1759. rendererType: rendererType,
  1760. componentFactory: componentFactory,
  1761. });
  1762. };
  1763. /**
  1764. * @return {?}
  1765. */
  1766. CompileDirectiveMetadata.prototype.toSummary = /**
  1767. * @return {?}
  1768. */
  1769. function () {
  1770. return {
  1771. summaryKind: CompileSummaryKind.Directive,
  1772. type: this.type,
  1773. isComponent: this.isComponent,
  1774. selector: this.selector,
  1775. exportAs: this.exportAs,
  1776. inputs: this.inputs,
  1777. outputs: this.outputs,
  1778. hostListeners: this.hostListeners,
  1779. hostProperties: this.hostProperties,
  1780. hostAttributes: this.hostAttributes,
  1781. providers: this.providers,
  1782. viewProviders: this.viewProviders,
  1783. queries: this.queries,
  1784. guards: this.guards,
  1785. viewQueries: this.viewQueries,
  1786. entryComponents: this.entryComponents,
  1787. changeDetection: this.changeDetection,
  1788. template: this.template && this.template.toSummary(),
  1789. componentViewType: this.componentViewType,
  1790. rendererType: this.rendererType,
  1791. componentFactory: this.componentFactory
  1792. };
  1793. };
  1794. return CompileDirectiveMetadata;
  1795. }());
  1796. /**
  1797. * @record
  1798. */
  1799. var CompilePipeMetadata = /** @class */ (function () {
  1800. function CompilePipeMetadata(_a) {
  1801. var type = _a.type, name = _a.name, pure = _a.pure;
  1802. this.type = type;
  1803. this.name = name;
  1804. this.pure = !!pure;
  1805. }
  1806. /**
  1807. * @return {?}
  1808. */
  1809. CompilePipeMetadata.prototype.toSummary = /**
  1810. * @return {?}
  1811. */
  1812. function () {
  1813. return {
  1814. summaryKind: CompileSummaryKind.Pipe,
  1815. type: this.type,
  1816. name: this.name,
  1817. pure: this.pure
  1818. };
  1819. };
  1820. return CompilePipeMetadata;
  1821. }());
  1822. /**
  1823. * @record
  1824. */
  1825. /**
  1826. * Metadata regarding compilation of a module.
  1827. */
  1828. var CompileNgModuleMetadata = /** @class */ (function () {
  1829. function CompileNgModuleMetadata(_a) {
  1830. 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;
  1831. this.type = type || null;
  1832. this.declaredDirectives = _normalizeArray(declaredDirectives);
  1833. this.exportedDirectives = _normalizeArray(exportedDirectives);
  1834. this.declaredPipes = _normalizeArray(declaredPipes);
  1835. this.exportedPipes = _normalizeArray(exportedPipes);
  1836. this.providers = _normalizeArray(providers);
  1837. this.entryComponents = _normalizeArray(entryComponents);
  1838. this.bootstrapComponents = _normalizeArray(bootstrapComponents);
  1839. this.importedModules = _normalizeArray(importedModules);
  1840. this.exportedModules = _normalizeArray(exportedModules);
  1841. this.schemas = _normalizeArray(schemas);
  1842. this.id = id || null;
  1843. this.transitiveModule = transitiveModule || null;
  1844. }
  1845. /**
  1846. * @return {?}
  1847. */
  1848. CompileNgModuleMetadata.prototype.toSummary = /**
  1849. * @return {?}
  1850. */
  1851. function () {
  1852. var /** @type {?} */ module = /** @type {?} */ ((this.transitiveModule));
  1853. return {
  1854. summaryKind: CompileSummaryKind.NgModule,
  1855. type: this.type,
  1856. entryComponents: module.entryComponents,
  1857. providers: module.providers,
  1858. modules: module.modules,
  1859. exportedDirectives: module.exportedDirectives,
  1860. exportedPipes: module.exportedPipes
  1861. };
  1862. };
  1863. return CompileNgModuleMetadata;
  1864. }());
  1865. var TransitiveCompileNgModuleMetadata = /** @class */ (function () {
  1866. function TransitiveCompileNgModuleMetadata() {
  1867. this.directivesSet = new Set();
  1868. this.directives = [];
  1869. this.exportedDirectivesSet = new Set();
  1870. this.exportedDirectives = [];
  1871. this.pipesSet = new Set();
  1872. this.pipes = [];
  1873. this.exportedPipesSet = new Set();
  1874. this.exportedPipes = [];
  1875. this.modulesSet = new Set();
  1876. this.modules = [];
  1877. this.entryComponentsSet = new Set();
  1878. this.entryComponents = [];
  1879. this.providers = [];
  1880. }
  1881. /**
  1882. * @param {?} provider
  1883. * @param {?} module
  1884. * @return {?}
  1885. */
  1886. TransitiveCompileNgModuleMetadata.prototype.addProvider = /**
  1887. * @param {?} provider
  1888. * @param {?} module
  1889. * @return {?}
  1890. */
  1891. function (provider, module) {
  1892. this.providers.push({ provider: provider, module: module });
  1893. };
  1894. /**
  1895. * @param {?} id
  1896. * @return {?}
  1897. */
  1898. TransitiveCompileNgModuleMetadata.prototype.addDirective = /**
  1899. * @param {?} id
  1900. * @return {?}
  1901. */
  1902. function (id) {
  1903. if (!this.directivesSet.has(id.reference)) {
  1904. this.directivesSet.add(id.reference);
  1905. this.directives.push(id);
  1906. }
  1907. };
  1908. /**
  1909. * @param {?} id
  1910. * @return {?}
  1911. */
  1912. TransitiveCompileNgModuleMetadata.prototype.addExportedDirective = /**
  1913. * @param {?} id
  1914. * @return {?}
  1915. */
  1916. function (id) {
  1917. if (!this.exportedDirectivesSet.has(id.reference)) {
  1918. this.exportedDirectivesSet.add(id.reference);
  1919. this.exportedDirectives.push(id);
  1920. }
  1921. };
  1922. /**
  1923. * @param {?} id
  1924. * @return {?}
  1925. */
  1926. TransitiveCompileNgModuleMetadata.prototype.addPipe = /**
  1927. * @param {?} id
  1928. * @return {?}
  1929. */
  1930. function (id) {
  1931. if (!this.pipesSet.has(id.reference)) {
  1932. this.pipesSet.add(id.reference);
  1933. this.pipes.push(id);
  1934. }
  1935. };
  1936. /**
  1937. * @param {?} id
  1938. * @return {?}
  1939. */
  1940. TransitiveCompileNgModuleMetadata.prototype.addExportedPipe = /**
  1941. * @param {?} id
  1942. * @return {?}
  1943. */
  1944. function (id) {
  1945. if (!this.exportedPipesSet.has(id.reference)) {
  1946. this.exportedPipesSet.add(id.reference);
  1947. this.exportedPipes.push(id);
  1948. }
  1949. };
  1950. /**
  1951. * @param {?} id
  1952. * @return {?}
  1953. */
  1954. TransitiveCompileNgModuleMetadata.prototype.addModule = /**
  1955. * @param {?} id
  1956. * @return {?}
  1957. */
  1958. function (id) {
  1959. if (!this.modulesSet.has(id.reference)) {
  1960. this.modulesSet.add(id.reference);
  1961. this.modules.push(id);
  1962. }
  1963. };
  1964. /**
  1965. * @param {?} ec
  1966. * @return {?}
  1967. */
  1968. TransitiveCompileNgModuleMetadata.prototype.addEntryComponent = /**
  1969. * @param {?} ec
  1970. * @return {?}
  1971. */
  1972. function (ec) {
  1973. if (!this.entryComponentsSet.has(ec.componentType)) {
  1974. this.entryComponentsSet.add(ec.componentType);
  1975. this.entryComponents.push(ec);
  1976. }
  1977. };
  1978. return TransitiveCompileNgModuleMetadata;
  1979. }());
  1980. /**
  1981. * @param {?} obj
  1982. * @return {?}
  1983. */
  1984. function _normalizeArray(obj) {
  1985. return obj || [];
  1986. }
  1987. var ProviderMeta = /** @class */ (function () {
  1988. function ProviderMeta(token, _a) {
  1989. var useClass = _a.useClass, useValue = _a.useValue, useExisting = _a.useExisting, useFactory = _a.useFactory, deps = _a.deps, multi = _a.multi;
  1990. this.token = token;
  1991. this.useClass = useClass || null;
  1992. this.useValue = useValue;
  1993. this.useExisting = useExisting;
  1994. this.useFactory = useFactory || null;
  1995. this.dependencies = deps || null;
  1996. this.multi = !!multi;
  1997. }
  1998. return ProviderMeta;
  1999. }());
  2000. /**
  2001. * @template T
  2002. * @param {?} list
  2003. * @return {?}
  2004. */
  2005. function flatten(list) {
  2006. return list.reduce(function (flat, item) {
  2007. var /** @type {?} */ flatItem = Array.isArray(item) ? flatten(item) : item;
  2008. return (/** @type {?} */ (flat)).concat(flatItem);
  2009. }, []);
  2010. }
  2011. /**
  2012. * @param {?} url
  2013. * @return {?}
  2014. */
  2015. function jitSourceUrl(url) {
  2016. // Note: We need 3 "/" so that ng shows up as a separate domain
  2017. // in the chrome dev tools.
  2018. return url.replace(/(\w+:\/\/[\w:-]+)?(\/+)?/, 'ng:///');
  2019. }
  2020. /**
  2021. * @param {?} ngModuleType
  2022. * @param {?} compMeta
  2023. * @param {?} templateMeta
  2024. * @return {?}
  2025. */
  2026. function templateSourceUrl(ngModuleType, compMeta, templateMeta) {
  2027. var /** @type {?} */ url;
  2028. if (templateMeta.isInline) {
  2029. if (compMeta.type.reference instanceof StaticSymbol) {
  2030. // Note: a .ts file might contain multiple components with inline templates,
  2031. // so we need to give them unique urls, as these will be used for sourcemaps.
  2032. url = compMeta.type.reference.filePath + "." + compMeta.type.reference.name + ".html";
  2033. }
  2034. else {
  2035. url = identifierName(ngModuleType) + "/" + identifierName(compMeta.type) + ".html";
  2036. }
  2037. }
  2038. else {
  2039. url = /** @type {?} */ ((templateMeta.templateUrl));
  2040. }
  2041. return compMeta.type.reference instanceof StaticSymbol ? url : jitSourceUrl(url);
  2042. }
  2043. /**
  2044. * @param {?} meta
  2045. * @param {?} id
  2046. * @return {?}
  2047. */
  2048. function sharedStylesheetJitUrl(meta, id) {
  2049. var /** @type {?} */ pathParts = /** @type {?} */ ((meta.moduleUrl)).split(/\/\\/g);
  2050. var /** @type {?} */ baseName = pathParts[pathParts.length - 1];
  2051. return jitSourceUrl("css/" + id + baseName + ".ngstyle.js");
  2052. }
  2053. /**
  2054. * @param {?} moduleMeta
  2055. * @return {?}
  2056. */
  2057. function ngModuleJitUrl(moduleMeta) {
  2058. return jitSourceUrl(identifierName(moduleMeta.type) + "/module.ngfactory.js");
  2059. }
  2060. /**
  2061. * @param {?} ngModuleType
  2062. * @param {?} compMeta
  2063. * @return {?}
  2064. */
  2065. function templateJitUrl(ngModuleType, compMeta) {
  2066. return jitSourceUrl(identifierName(ngModuleType) + "/" + identifierName(compMeta.type) + ".ngfactory.js");
  2067. }
  2068. /**
  2069. * @fileoverview added by tsickle
  2070. * @suppress {checkTypes} checked by tsc
  2071. */
  2072. /**
  2073. * @license
  2074. * Copyright Google Inc. All Rights Reserved.
  2075. *
  2076. * Use of this source code is governed by an MIT-style license that can be
  2077. * found in the LICENSE file at https://angular.io/license
  2078. */
  2079. /**
  2080. * A path is an ordered set of elements. Typically a path is to a
  2081. * particular offset in a source file. The head of the list is the top
  2082. * most node. The tail is the node that contains the offset directly.
  2083. *
  2084. * For example, the expresion `a + b + c` might have an ast that looks
  2085. * like:
  2086. * +
  2087. * / \
  2088. * a +
  2089. * / \
  2090. * b c
  2091. *
  2092. * The path to the node at offset 9 would be `['+' at 1-10, '+' at 7-10,
  2093. * 'c' at 9-10]` and the path the node at offset 1 would be
  2094. * `['+' at 1-10, 'a' at 1-2]`.
  2095. * @template T
  2096. */
  2097. var AstPath = /** @class */ (function () {
  2098. function AstPath(path, position) {
  2099. if (position === void 0) { position = -1; }
  2100. this.path = path;
  2101. this.position = position;
  2102. }
  2103. Object.defineProperty(AstPath.prototype, "empty", {
  2104. get: /**
  2105. * @return {?}
  2106. */
  2107. function () { return !this.path || !this.path.length; },
  2108. enumerable: true,
  2109. configurable: true
  2110. });
  2111. Object.defineProperty(AstPath.prototype, "head", {
  2112. get: /**
  2113. * @return {?}
  2114. */
  2115. function () { return this.path[0]; },
  2116. enumerable: true,
  2117. configurable: true
  2118. });
  2119. Object.defineProperty(AstPath.prototype, "tail", {
  2120. get: /**
  2121. * @return {?}
  2122. */
  2123. function () { return this.path[this.path.length - 1]; },
  2124. enumerable: true,
  2125. configurable: true
  2126. });
  2127. /**
  2128. * @param {?} node
  2129. * @return {?}
  2130. */
  2131. AstPath.prototype.parentOf = /**
  2132. * @param {?} node
  2133. * @return {?}
  2134. */
  2135. function (node) {
  2136. return node && this.path[this.path.indexOf(node) - 1];
  2137. };
  2138. /**
  2139. * @param {?} node
  2140. * @return {?}
  2141. */
  2142. AstPath.prototype.childOf = /**
  2143. * @param {?} node
  2144. * @return {?}
  2145. */
  2146. function (node) { return this.path[this.path.indexOf(node) + 1]; };
  2147. /**
  2148. * @template N
  2149. * @param {?} ctor
  2150. * @return {?}
  2151. */
  2152. AstPath.prototype.first = /**
  2153. * @template N
  2154. * @param {?} ctor
  2155. * @return {?}
  2156. */
  2157. function (ctor) {
  2158. for (var /** @type {?} */ i = this.path.length - 1; i >= 0; i--) {
  2159. var /** @type {?} */ item = this.path[i];
  2160. if (item instanceof ctor)
  2161. return /** @type {?} */ (item);
  2162. }
  2163. };
  2164. /**
  2165. * @param {?} node
  2166. * @return {?}
  2167. */
  2168. AstPath.prototype.push = /**
  2169. * @param {?} node
  2170. * @return {?}
  2171. */
  2172. function (node) { this.path.push(node); };
  2173. /**
  2174. * @return {?}
  2175. */
  2176. AstPath.prototype.pop = /**
  2177. * @return {?}
  2178. */
  2179. function () { return /** @type {?} */ ((this.path.pop())); };
  2180. return AstPath;
  2181. }());
  2182. /**
  2183. * @fileoverview added by tsickle
  2184. * @suppress {checkTypes} checked by tsc
  2185. */
  2186. /**
  2187. * @license
  2188. * Copyright Google Inc. All Rights Reserved.
  2189. *
  2190. * Use of this source code is governed by an MIT-style license that can be
  2191. * found in the LICENSE file at https://angular.io/license
  2192. */
  2193. /**
  2194. * @record
  2195. */
  2196. var Text = /** @class */ (function () {
  2197. function Text(value, sourceSpan) {
  2198. this.value = value;
  2199. this.sourceSpan = sourceSpan;
  2200. }
  2201. /**
  2202. * @param {?} visitor
  2203. * @param {?} context
  2204. * @return {?}
  2205. */
  2206. Text.prototype.visit = /**
  2207. * @param {?} visitor
  2208. * @param {?} context
  2209. * @return {?}
  2210. */
  2211. function (visitor, context) { return visitor.visitText(this, context); };
  2212. return Text;
  2213. }());
  2214. var Expansion = /** @class */ (function () {
  2215. function Expansion(switchValue, type, cases, sourceSpan, switchValueSourceSpan) {
  2216. this.switchValue = switchValue;
  2217. this.type = type;
  2218. this.cases = cases;
  2219. this.sourceSpan = sourceSpan;
  2220. this.switchValueSourceSpan = switchValueSourceSpan;
  2221. }
  2222. /**
  2223. * @param {?} visitor
  2224. * @param {?} context
  2225. * @return {?}
  2226. */
  2227. Expansion.prototype.visit = /**
  2228. * @param {?} visitor
  2229. * @param {?} context
  2230. * @return {?}
  2231. */
  2232. function (visitor, context) { return visitor.visitExpansion(this, context); };
  2233. return Expansion;
  2234. }());
  2235. var ExpansionCase = /** @class */ (function () {
  2236. function ExpansionCase(value, expression, sourceSpan, valueSourceSpan, expSourceSpan) {
  2237. this.value = value;
  2238. this.expression = expression;
  2239. this.sourceSpan = sourceSpan;
  2240. this.valueSourceSpan = valueSourceSpan;
  2241. this.expSourceSpan = expSourceSpan;
  2242. }
  2243. /**
  2244. * @param {?} visitor
  2245. * @param {?} context
  2246. * @return {?}
  2247. */
  2248. ExpansionCase.prototype.visit = /**
  2249. * @param {?} visitor
  2250. * @param {?} context
  2251. * @return {?}
  2252. */
  2253. function (visitor, context) { return visitor.visitExpansionCase(this, context); };
  2254. return ExpansionCase;
  2255. }());
  2256. var Attribute$1 = /** @class */ (function () {
  2257. function Attribute(name, value, sourceSpan, valueSpan) {
  2258. this.name = name;
  2259. this.value = value;
  2260. this.sourceSpan = sourceSpan;
  2261. this.valueSpan = valueSpan;
  2262. }
  2263. /**
  2264. * @param {?} visitor
  2265. * @param {?} context
  2266. * @return {?}
  2267. */
  2268. Attribute.prototype.visit = /**
  2269. * @param {?} visitor
  2270. * @param {?} context
  2271. * @return {?}
  2272. */
  2273. function (visitor, context) { return visitor.visitAttribute(this, context); };
  2274. return Attribute;
  2275. }());
  2276. var Element = /** @class */ (function () {
  2277. function Element(name, attrs, children, sourceSpan, startSourceSpan, endSourceSpan) {
  2278. if (startSourceSpan === void 0) { startSourceSpan = null; }
  2279. if (endSourceSpan === void 0) { endSourceSpan = null; }
  2280. this.name = name;
  2281. this.attrs = attrs;
  2282. this.children = children;
  2283. this.sourceSpan = sourceSpan;
  2284. this.startSourceSpan = startSourceSpan;
  2285. this.endSourceSpan = endSourceSpan;
  2286. }
  2287. /**
  2288. * @param {?} visitor
  2289. * @param {?} context
  2290. * @return {?}
  2291. */
  2292. Element.prototype.visit = /**
  2293. * @param {?} visitor
  2294. * @param {?} context
  2295. * @return {?}
  2296. */
  2297. function (visitor, context) { return visitor.visitElement(this, context); };
  2298. return Element;
  2299. }());
  2300. var Comment = /** @class */ (function () {
  2301. function Comment(value, sourceSpan) {
  2302. this.value = value;
  2303. this.sourceSpan = sourceSpan;
  2304. }
  2305. /**
  2306. * @param {?} visitor
  2307. * @param {?} context
  2308. * @return {?}
  2309. */
  2310. Comment.prototype.visit = /**
  2311. * @param {?} visitor
  2312. * @param {?} context
  2313. * @return {?}
  2314. */
  2315. function (visitor, context) { return visitor.visitComment(this, context); };
  2316. return Comment;
  2317. }());
  2318. /**
  2319. * @record
  2320. */
  2321. /**
  2322. * @param {?} visitor
  2323. * @param {?} nodes
  2324. * @param {?=} context
  2325. * @return {?}
  2326. */
  2327. function visitAll(visitor, nodes, context) {
  2328. if (context === void 0) { context = null; }
  2329. var /** @type {?} */ result = [];
  2330. var /** @type {?} */ visit = visitor.visit ?
  2331. function (ast) { return ((visitor.visit))(ast, context) || ast.visit(visitor, context); } :
  2332. function (ast) { return ast.visit(visitor, context); };
  2333. nodes.forEach(function (ast) {
  2334. var /** @type {?} */ astResult = visit(ast);
  2335. if (astResult) {
  2336. result.push(astResult);
  2337. }
  2338. });
  2339. return result;
  2340. }
  2341. var RecursiveVisitor = /** @class */ (function () {
  2342. function RecursiveVisitor() {
  2343. }
  2344. /**
  2345. * @param {?} ast
  2346. * @param {?} context
  2347. * @return {?}
  2348. */
  2349. RecursiveVisitor.prototype.visitElement = /**
  2350. * @param {?} ast
  2351. * @param {?} context
  2352. * @return {?}
  2353. */
  2354. function (ast, context) {
  2355. this.visitChildren(context, function (visit) {
  2356. visit(ast.attrs);
  2357. visit(ast.children);
  2358. });
  2359. };
  2360. /**
  2361. * @param {?} ast
  2362. * @param {?} context
  2363. * @return {?}
  2364. */
  2365. RecursiveVisitor.prototype.visitAttribute = /**
  2366. * @param {?} ast
  2367. * @param {?} context
  2368. * @return {?}
  2369. */
  2370. function (ast, context) { };
  2371. /**
  2372. * @param {?} ast
  2373. * @param {?} context
  2374. * @return {?}
  2375. */
  2376. RecursiveVisitor.prototype.visitText = /**
  2377. * @param {?} ast
  2378. * @param {?} context
  2379. * @return {?}
  2380. */
  2381. function (ast, context) { };
  2382. /**
  2383. * @param {?} ast
  2384. * @param {?} context
  2385. * @return {?}
  2386. */
  2387. RecursiveVisitor.prototype.visitComment = /**
  2388. * @param {?} ast
  2389. * @param {?} context
  2390. * @return {?}
  2391. */
  2392. function (ast, context) { };
  2393. /**
  2394. * @param {?} ast
  2395. * @param {?} context
  2396. * @return {?}
  2397. */
  2398. RecursiveVisitor.prototype.visitExpansion = /**
  2399. * @param {?} ast
  2400. * @param {?} context
  2401. * @return {?}
  2402. */
  2403. function (ast, context) {
  2404. return this.visitChildren(context, function (visit) { visit(ast.cases); });
  2405. };
  2406. /**
  2407. * @param {?} ast
  2408. * @param {?} context
  2409. * @return {?}
  2410. */
  2411. RecursiveVisitor.prototype.visitExpansionCase = /**
  2412. * @param {?} ast
  2413. * @param {?} context
  2414. * @return {?}
  2415. */
  2416. function (ast, context) { };
  2417. /**
  2418. * @template T
  2419. * @param {?} context
  2420. * @param {?} cb
  2421. * @return {?}
  2422. */
  2423. RecursiveVisitor.prototype.visitChildren = /**
  2424. * @template T
  2425. * @param {?} context
  2426. * @param {?} cb
  2427. * @return {?}
  2428. */
  2429. function (context, cb) {
  2430. var /** @type {?} */ results = [];
  2431. var /** @type {?} */ t = this;
  2432. /**
  2433. * @template T
  2434. * @param {?} children
  2435. * @return {?}
  2436. */
  2437. function visit(children) {
  2438. if (children)
  2439. results.push(visitAll(t, children, context));
  2440. }
  2441. cb(visit);
  2442. return [].concat.apply([], results);
  2443. };
  2444. return RecursiveVisitor;
  2445. }());
  2446. /**
  2447. * @param {?} ast
  2448. * @return {?}
  2449. */
  2450. function spanOf(ast) {
  2451. var /** @type {?} */ start = ast.sourceSpan.start.offset;
  2452. var /** @type {?} */ end = ast.sourceSpan.end.offset;
  2453. if (ast instanceof Element) {
  2454. if (ast.endSourceSpan) {
  2455. end = ast.endSourceSpan.end.offset;
  2456. }
  2457. else if (ast.children && ast.children.length) {
  2458. end = spanOf(ast.children[ast.children.length - 1]).end;
  2459. }
  2460. }
  2461. return { start: start, end: end };
  2462. }
  2463. /**
  2464. * @param {?} nodes
  2465. * @param {?} position
  2466. * @return {?}
  2467. */
  2468. function findNode(nodes, position) {
  2469. var /** @type {?} */ path = [];
  2470. var /** @type {?} */ visitor = new /** @class */ (function (_super) {
  2471. __extends(class_1, _super);
  2472. function class_1() {
  2473. return _super !== null && _super.apply(this, arguments) || this;
  2474. }
  2475. /**
  2476. * @param {?} ast
  2477. * @param {?} context
  2478. * @return {?}
  2479. */
  2480. class_1.prototype.visit = /**
  2481. * @param {?} ast
  2482. * @param {?} context
  2483. * @return {?}
  2484. */
  2485. function (ast, context) {
  2486. var /** @type {?} */ span = spanOf(ast);
  2487. if (span.start <= position && position < span.end) {
  2488. path.push(ast);
  2489. }
  2490. else {
  2491. // Returning a value here will result in the children being skipped.
  2492. return true;
  2493. }
  2494. };
  2495. return class_1;
  2496. }(RecursiveVisitor));
  2497. visitAll(visitor, nodes);
  2498. return new AstPath(path, position);
  2499. }
  2500. /**
  2501. * @fileoverview added by tsickle
  2502. * @suppress {checkTypes} checked by tsc
  2503. */
  2504. /**
  2505. * @license
  2506. * Copyright Google Inc. All Rights Reserved.
  2507. *
  2508. * Use of this source code is governed by an MIT-style license that can be
  2509. * found in the LICENSE file at https://angular.io/license
  2510. */
  2511. /**
  2512. * @param {?} identifier
  2513. * @param {?} value
  2514. * @return {?}
  2515. */
  2516. function assertArrayOfStrings(identifier, value) {
  2517. if (value == null) {
  2518. return;
  2519. }
  2520. if (!Array.isArray(value)) {
  2521. throw new Error("Expected '" + identifier + "' to be an array of strings.");
  2522. }
  2523. for (var /** @type {?} */ i = 0; i < value.length; i += 1) {
  2524. if (typeof value[i] !== 'string') {
  2525. throw new Error("Expected '" + identifier + "' to be an array of strings.");
  2526. }
  2527. }
  2528. }
  2529. var INTERPOLATION_BLACKLIST_REGEXPS = [
  2530. /^\s*$/,
  2531. /[<>]/,
  2532. /^[{}]$/,
  2533. /&(#|[a-z])/i,
  2534. /^\/\//,
  2535. ];
  2536. /**
  2537. * @param {?} identifier
  2538. * @param {?} value
  2539. * @return {?}
  2540. */
  2541. function assertInterpolationSymbols(identifier, value) {
  2542. if (value != null && !(Array.isArray(value) && value.length == 2)) {
  2543. throw new Error("Expected '" + identifier + "' to be an array, [start, end].");
  2544. }
  2545. else if (value != null) {
  2546. var /** @type {?} */ start_1 = /** @type {?} */ (value[0]);
  2547. var /** @type {?} */ end_1 = /** @type {?} */ (value[1]);
  2548. // black list checking
  2549. INTERPOLATION_BLACKLIST_REGEXPS.forEach(function (regexp) {
  2550. if (regexp.test(start_1) || regexp.test(end_1)) {
  2551. throw new Error("['" + start_1 + "', '" + end_1 + "'] contains unusable interpolation symbol.");
  2552. }
  2553. });
  2554. }
  2555. }
  2556. /**
  2557. * @fileoverview added by tsickle
  2558. * @suppress {checkTypes} checked by tsc
  2559. */
  2560. /**
  2561. * @license
  2562. * Copyright Google Inc. All Rights Reserved.
  2563. *
  2564. * Use of this source code is governed by an MIT-style license that can be
  2565. * found in the LICENSE file at https://angular.io/license
  2566. */
  2567. var InterpolationConfig = /** @class */ (function () {
  2568. function InterpolationConfig(start, end) {
  2569. this.start = start;
  2570. this.end = end;
  2571. }
  2572. /**
  2573. * @param {?} markers
  2574. * @return {?}
  2575. */
  2576. InterpolationConfig.fromArray = /**
  2577. * @param {?} markers
  2578. * @return {?}
  2579. */
  2580. function (markers) {
  2581. if (!markers) {
  2582. return DEFAULT_INTERPOLATION_CONFIG;
  2583. }
  2584. assertInterpolationSymbols('interpolation', markers);
  2585. return new InterpolationConfig(markers[0], markers[1]);
  2586. };
  2587. return InterpolationConfig;
  2588. }());
  2589. var DEFAULT_INTERPOLATION_CONFIG = new InterpolationConfig('{{', '}}');
  2590. /**
  2591. * @fileoverview added by tsickle
  2592. * @suppress {checkTypes} checked by tsc
  2593. */
  2594. /**
  2595. * @license
  2596. * Copyright Google Inc. All Rights Reserved.
  2597. *
  2598. * Use of this source code is governed by an MIT-style license that can be
  2599. * found in the LICENSE file at https://angular.io/license
  2600. */
  2601. var StyleWithImports = /** @class */ (function () {
  2602. function StyleWithImports(style, styleUrls) {
  2603. this.style = style;
  2604. this.styleUrls = styleUrls;
  2605. }
  2606. return StyleWithImports;
  2607. }());
  2608. /**
  2609. * @param {?} url
  2610. * @return {?}
  2611. */
  2612. function isStyleUrlResolvable(url) {
  2613. if (url == null || url.length === 0 || url[0] == '/')
  2614. return false;
  2615. var /** @type {?} */ schemeMatch = url.match(URL_WITH_SCHEMA_REGEXP);
  2616. return schemeMatch === null || schemeMatch[1] == 'package' || schemeMatch[1] == 'asset';
  2617. }
  2618. /**
  2619. * Rewrites stylesheets by resolving and removing the \@import urls that
  2620. * are either relative or don't have a `package:` scheme
  2621. * @param {?} resolver
  2622. * @param {?} baseUrl
  2623. * @param {?} cssText
  2624. * @return {?}
  2625. */
  2626. function extractStyleUrls(resolver, baseUrl, cssText) {
  2627. var /** @type {?} */ foundUrls = [];
  2628. var /** @type {?} */ modifiedCssText = cssText.replace(CSS_STRIPPABLE_COMMENT_REGEXP, '')
  2629. .replace(CSS_IMPORT_REGEXP, function () {
  2630. var m = [];
  2631. for (var _i = 0; _i < arguments.length; _i++) {
  2632. m[_i] = arguments[_i];
  2633. }
  2634. var /** @type {?} */ url = m[1] || m[2];
  2635. if (!isStyleUrlResolvable(url)) {
  2636. // Do not attempt to resolve non-package absolute URLs with URI
  2637. // scheme
  2638. return m[0];
  2639. }
  2640. foundUrls.push(resolver.resolve(baseUrl, url));
  2641. return '';
  2642. });
  2643. return new StyleWithImports(modifiedCssText, foundUrls);
  2644. }
  2645. var CSS_IMPORT_REGEXP = /@import\s+(?:url\()?\s*(?:(?:['"]([^'"]*))|([^;\)\s]*))[^;]*;?/g;
  2646. var CSS_STRIPPABLE_COMMENT_REGEXP = /\/\*(?!#\s*(?:sourceURL|sourceMappingURL)=)[\s\S]+?\*\//g;
  2647. var URL_WITH_SCHEMA_REGEXP = /^([^:/?#]+):/;
  2648. /**
  2649. * @fileoverview added by tsickle
  2650. * @suppress {checkTypes} checked by tsc
  2651. */
  2652. /**
  2653. * @license
  2654. * Copyright Google Inc. All Rights Reserved.
  2655. *
  2656. * Use of this source code is governed by an MIT-style license that can be
  2657. * found in the LICENSE file at https://angular.io/license
  2658. */
  2659. /** @enum {number} */
  2660. var TagContentType = {
  2661. RAW_TEXT: 0,
  2662. ESCAPABLE_RAW_TEXT: 1,
  2663. PARSABLE_DATA: 2,
  2664. };
  2665. TagContentType[TagContentType.RAW_TEXT] = "RAW_TEXT";
  2666. TagContentType[TagContentType.ESCAPABLE_RAW_TEXT] = "ESCAPABLE_RAW_TEXT";
  2667. TagContentType[TagContentType.PARSABLE_DATA] = "PARSABLE_DATA";
  2668. /**
  2669. * @record
  2670. */
  2671. /**
  2672. * @param {?} elementName
  2673. * @return {?}
  2674. */
  2675. function splitNsName(elementName) {
  2676. if (elementName[0] != ':') {
  2677. return [null, elementName];
  2678. }
  2679. var /** @type {?} */ colonIndex = elementName.indexOf(':', 1);
  2680. if (colonIndex == -1) {
  2681. throw new Error("Unsupported format \"" + elementName + "\" expecting \":namespace:name\"");
  2682. }
  2683. return [elementName.slice(1, colonIndex), elementName.slice(colonIndex + 1)];
  2684. }
  2685. /**
  2686. * @param {?} tagName
  2687. * @return {?}
  2688. */
  2689. function isNgContainer(tagName) {
  2690. return splitNsName(tagName)[1] === 'ng-container';
  2691. }
  2692. /**
  2693. * @param {?} tagName
  2694. * @return {?}
  2695. */
  2696. function isNgContent(tagName) {
  2697. return splitNsName(tagName)[1] === 'ng-content';
  2698. }
  2699. /**
  2700. * @param {?} tagName
  2701. * @return {?}
  2702. */
  2703. function isNgTemplate(tagName) {
  2704. return splitNsName(tagName)[1] === 'ng-template';
  2705. }
  2706. /**
  2707. * @param {?} fullName
  2708. * @return {?}
  2709. */
  2710. function getNsPrefix(fullName) {
  2711. return fullName === null ? null : splitNsName(fullName)[0];
  2712. }
  2713. /**
  2714. * @param {?} prefix
  2715. * @param {?} localName
  2716. * @return {?}
  2717. */
  2718. function mergeNsAndName(prefix, localName) {
  2719. return prefix ? ":" + prefix + ":" + localName : localName;
  2720. }
  2721. // see http://www.w3.org/TR/html51/syntax.html#named-character-references
  2722. // see https://html.spec.whatwg.org/multipage/entities.json
  2723. // This list is not exhaustive to keep the compiler footprint low.
  2724. // The `&#123;` / `&#x1ab;` syntax should be used when the named character reference does not
  2725. // exist.
  2726. var NAMED_ENTITIES = {
  2727. 'Aacute': '\u00C1',
  2728. 'aacute': '\u00E1',
  2729. 'Acirc': '\u00C2',
  2730. 'acirc': '\u00E2',
  2731. 'acute': '\u00B4',
  2732. 'AElig': '\u00C6',
  2733. 'aelig': '\u00E6',
  2734. 'Agrave': '\u00C0',
  2735. 'agrave': '\u00E0',
  2736. 'alefsym': '\u2135',
  2737. 'Alpha': '\u0391',
  2738. 'alpha': '\u03B1',
  2739. 'amp': '&',
  2740. 'and': '\u2227',
  2741. 'ang': '\u2220',
  2742. 'apos': '\u0027',
  2743. 'Aring': '\u00C5',
  2744. 'aring': '\u00E5',
  2745. 'asymp': '\u2248',
  2746. 'Atilde': '\u00C3',
  2747. 'atilde': '\u00E3',
  2748. 'Auml': '\u00C4',
  2749. 'auml': '\u00E4',
  2750. 'bdquo': '\u201E',
  2751. 'Beta': '\u0392',
  2752. 'beta': '\u03B2',
  2753. 'brvbar': '\u00A6',
  2754. 'bull': '\u2022',
  2755. 'cap': '\u2229',
  2756. 'Ccedil': '\u00C7',
  2757. 'ccedil': '\u00E7',
  2758. 'cedil': '\u00B8',
  2759. 'cent': '\u00A2',
  2760. 'Chi': '\u03A7',
  2761. 'chi': '\u03C7',
  2762. 'circ': '\u02C6',
  2763. 'clubs': '\u2663',
  2764. 'cong': '\u2245',
  2765. 'copy': '\u00A9',
  2766. 'crarr': '\u21B5',
  2767. 'cup': '\u222A',
  2768. 'curren': '\u00A4',
  2769. 'dagger': '\u2020',
  2770. 'Dagger': '\u2021',
  2771. 'darr': '\u2193',
  2772. 'dArr': '\u21D3',
  2773. 'deg': '\u00B0',
  2774. 'Delta': '\u0394',
  2775. 'delta': '\u03B4',
  2776. 'diams': '\u2666',
  2777. 'divide': '\u00F7',
  2778. 'Eacute': '\u00C9',
  2779. 'eacute': '\u00E9',
  2780. 'Ecirc': '\u00CA',
  2781. 'ecirc': '\u00EA',
  2782. 'Egrave': '\u00C8',
  2783. 'egrave': '\u00E8',
  2784. 'empty': '\u2205',
  2785. 'emsp': '\u2003',
  2786. 'ensp': '\u2002',
  2787. 'Epsilon': '\u0395',
  2788. 'epsilon': '\u03B5',
  2789. 'equiv': '\u2261',
  2790. 'Eta': '\u0397',
  2791. 'eta': '\u03B7',
  2792. 'ETH': '\u00D0',
  2793. 'eth': '\u00F0',
  2794. 'Euml': '\u00CB',
  2795. 'euml': '\u00EB',
  2796. 'euro': '\u20AC',
  2797. 'exist': '\u2203',
  2798. 'fnof': '\u0192',
  2799. 'forall': '\u2200',
  2800. 'frac12': '\u00BD',
  2801. 'frac14': '\u00BC',
  2802. 'frac34': '\u00BE',
  2803. 'frasl': '\u2044',
  2804. 'Gamma': '\u0393',
  2805. 'gamma': '\u03B3',
  2806. 'ge': '\u2265',
  2807. 'gt': '>',
  2808. 'harr': '\u2194',
  2809. 'hArr': '\u21D4',
  2810. 'hearts': '\u2665',
  2811. 'hellip': '\u2026',
  2812. 'Iacute': '\u00CD',
  2813. 'iacute': '\u00ED',
  2814. 'Icirc': '\u00CE',
  2815. 'icirc': '\u00EE',
  2816. 'iexcl': '\u00A1',
  2817. 'Igrave': '\u00CC',
  2818. 'igrave': '\u00EC',
  2819. 'image': '\u2111',
  2820. 'infin': '\u221E',
  2821. 'int': '\u222B',
  2822. 'Iota': '\u0399',
  2823. 'iota': '\u03B9',
  2824. 'iquest': '\u00BF',
  2825. 'isin': '\u2208',
  2826. 'Iuml': '\u00CF',
  2827. 'iuml': '\u00EF',
  2828. 'Kappa': '\u039A',
  2829. 'kappa': '\u03BA',
  2830. 'Lambda': '\u039B',
  2831. 'lambda': '\u03BB',
  2832. 'lang': '\u27E8',
  2833. 'laquo': '\u00AB',
  2834. 'larr': '\u2190',
  2835. 'lArr': '\u21D0',
  2836. 'lceil': '\u2308',
  2837. 'ldquo': '\u201C',
  2838. 'le': '\u2264',
  2839. 'lfloor': '\u230A',
  2840. 'lowast': '\u2217',
  2841. 'loz': '\u25CA',
  2842. 'lrm': '\u200E',
  2843. 'lsaquo': '\u2039',
  2844. 'lsquo': '\u2018',
  2845. 'lt': '<',
  2846. 'macr': '\u00AF',
  2847. 'mdash': '\u2014',
  2848. 'micro': '\u00B5',
  2849. 'middot': '\u00B7',
  2850. 'minus': '\u2212',
  2851. 'Mu': '\u039C',
  2852. 'mu': '\u03BC',
  2853. 'nabla': '\u2207',
  2854. 'nbsp': '\u00A0',
  2855. 'ndash': '\u2013',
  2856. 'ne': '\u2260',
  2857. 'ni': '\u220B',
  2858. 'not': '\u00AC',
  2859. 'notin': '\u2209',
  2860. 'nsub': '\u2284',
  2861. 'Ntilde': '\u00D1',
  2862. 'ntilde': '\u00F1',
  2863. 'Nu': '\u039D',
  2864. 'nu': '\u03BD',
  2865. 'Oacute': '\u00D3',
  2866. 'oacute': '\u00F3',
  2867. 'Ocirc': '\u00D4',
  2868. 'ocirc': '\u00F4',
  2869. 'OElig': '\u0152',
  2870. 'oelig': '\u0153',
  2871. 'Ograve': '\u00D2',
  2872. 'ograve': '\u00F2',
  2873. 'oline': '\u203E',
  2874. 'Omega': '\u03A9',
  2875. 'omega': '\u03C9',
  2876. 'Omicron': '\u039F',
  2877. 'omicron': '\u03BF',
  2878. 'oplus': '\u2295',
  2879. 'or': '\u2228',
  2880. 'ordf': '\u00AA',
  2881. 'ordm': '\u00BA',
  2882. 'Oslash': '\u00D8',
  2883. 'oslash': '\u00F8',
  2884. 'Otilde': '\u00D5',
  2885. 'otilde': '\u00F5',
  2886. 'otimes': '\u2297',
  2887. 'Ouml': '\u00D6',
  2888. 'ouml': '\u00F6',
  2889. 'para': '\u00B6',
  2890. 'permil': '\u2030',
  2891. 'perp': '\u22A5',
  2892. 'Phi': '\u03A6',
  2893. 'phi': '\u03C6',
  2894. 'Pi': '\u03A0',
  2895. 'pi': '\u03C0',
  2896. 'piv': '\u03D6',
  2897. 'plusmn': '\u00B1',
  2898. 'pound': '\u00A3',
  2899. 'prime': '\u2032',
  2900. 'Prime': '\u2033',
  2901. 'prod': '\u220F',
  2902. 'prop': '\u221D',
  2903. 'Psi': '\u03A8',
  2904. 'psi': '\u03C8',
  2905. 'quot': '\u0022',
  2906. 'radic': '\u221A',
  2907. 'rang': '\u27E9',
  2908. 'raquo': '\u00BB',
  2909. 'rarr': '\u2192',
  2910. 'rArr': '\u21D2',
  2911. 'rceil': '\u2309',
  2912. 'rdquo': '\u201D',
  2913. 'real': '\u211C',
  2914. 'reg': '\u00AE',
  2915. 'rfloor': '\u230B',
  2916. 'Rho': '\u03A1',
  2917. 'rho': '\u03C1',
  2918. 'rlm': '\u200F',
  2919. 'rsaquo': '\u203A',
  2920. 'rsquo': '\u2019',
  2921. 'sbquo': '\u201A',
  2922. 'Scaron': '\u0160',
  2923. 'scaron': '\u0161',
  2924. 'sdot': '\u22C5',
  2925. 'sect': '\u00A7',
  2926. 'shy': '\u00AD',
  2927. 'Sigma': '\u03A3',
  2928. 'sigma': '\u03C3',
  2929. 'sigmaf': '\u03C2',
  2930. 'sim': '\u223C',
  2931. 'spades': '\u2660',
  2932. 'sub': '\u2282',
  2933. 'sube': '\u2286',
  2934. 'sum': '\u2211',
  2935. 'sup': '\u2283',
  2936. 'sup1': '\u00B9',
  2937. 'sup2': '\u00B2',
  2938. 'sup3': '\u00B3',
  2939. 'supe': '\u2287',
  2940. 'szlig': '\u00DF',
  2941. 'Tau': '\u03A4',
  2942. 'tau': '\u03C4',
  2943. 'there4': '\u2234',
  2944. 'Theta': '\u0398',
  2945. 'theta': '\u03B8',
  2946. 'thetasym': '\u03D1',
  2947. 'thinsp': '\u2009',
  2948. 'THORN': '\u00DE',
  2949. 'thorn': '\u00FE',
  2950. 'tilde': '\u02DC',
  2951. 'times': '\u00D7',
  2952. 'trade': '\u2122',
  2953. 'Uacute': '\u00DA',
  2954. 'uacute': '\u00FA',
  2955. 'uarr': '\u2191',
  2956. 'uArr': '\u21D1',
  2957. 'Ucirc': '\u00DB',
  2958. 'ucirc': '\u00FB',
  2959. 'Ugrave': '\u00D9',
  2960. 'ugrave': '\u00F9',
  2961. 'uml': '\u00A8',
  2962. 'upsih': '\u03D2',
  2963. 'Upsilon': '\u03A5',
  2964. 'upsilon': '\u03C5',
  2965. 'Uuml': '\u00DC',
  2966. 'uuml': '\u00FC',
  2967. 'weierp': '\u2118',
  2968. 'Xi': '\u039E',
  2969. 'xi': '\u03BE',
  2970. 'Yacute': '\u00DD',
  2971. 'yacute': '\u00FD',
  2972. 'yen': '\u00A5',
  2973. 'yuml': '\u00FF',
  2974. 'Yuml': '\u0178',
  2975. 'Zeta': '\u0396',
  2976. 'zeta': '\u03B6',
  2977. 'zwj': '\u200D',
  2978. 'zwnj': '\u200C',
  2979. };
  2980. // The &ngsp; pseudo-entity is denoting a space. see:
  2981. // https://github.com/dart-lang/angular/blob/0bb611387d29d65b5af7f9d2515ab571fd3fbee4/_tests/test/compiler/preserve_whitespace_test.dart
  2982. var NGSP_UNICODE = '\uE500';
  2983. NAMED_ENTITIES['ngsp'] = NGSP_UNICODE;
  2984. /**
  2985. * @fileoverview added by tsickle
  2986. * @suppress {checkTypes} checked by tsc
  2987. */
  2988. /**
  2989. * @license
  2990. * Copyright Google Inc. All Rights Reserved.
  2991. *
  2992. * Use of this source code is governed by an MIT-style license that can be
  2993. * found in the LICENSE file at https://angular.io/license
  2994. */
  2995. var NG_CONTENT_SELECT_ATTR = 'select';
  2996. var LINK_ELEMENT = 'link';
  2997. var LINK_STYLE_REL_ATTR = 'rel';
  2998. var LINK_STYLE_HREF_ATTR = 'href';
  2999. var LINK_STYLE_REL_VALUE = 'stylesheet';
  3000. var STYLE_ELEMENT = 'style';
  3001. var SCRIPT_ELEMENT = 'script';
  3002. var NG_NON_BINDABLE_ATTR = 'ngNonBindable';
  3003. var NG_PROJECT_AS = 'ngProjectAs';
  3004. /**
  3005. * @param {?} ast
  3006. * @return {?}
  3007. */
  3008. function preparseElement(ast) {
  3009. var /** @type {?} */ selectAttr = /** @type {?} */ ((null));
  3010. var /** @type {?} */ hrefAttr = /** @type {?} */ ((null));
  3011. var /** @type {?} */ relAttr = /** @type {?} */ ((null));
  3012. var /** @type {?} */ nonBindable = false;
  3013. var /** @type {?} */ projectAs = /** @type {?} */ ((null));
  3014. ast.attrs.forEach(function (attr) {
  3015. var /** @type {?} */ lcAttrName = attr.name.toLowerCase();
  3016. if (lcAttrName == NG_CONTENT_SELECT_ATTR) {
  3017. selectAttr = attr.value;
  3018. }
  3019. else if (lcAttrName == LINK_STYLE_HREF_ATTR) {
  3020. hrefAttr = attr.value;
  3021. }
  3022. else if (lcAttrName == LINK_STYLE_REL_ATTR) {
  3023. relAttr = attr.value;
  3024. }
  3025. else if (attr.name == NG_NON_BINDABLE_ATTR) {
  3026. nonBindable = true;
  3027. }
  3028. else if (attr.name == NG_PROJECT_AS) {
  3029. if (attr.value.length > 0) {
  3030. projectAs = attr.value;
  3031. }
  3032. }
  3033. });
  3034. selectAttr = normalizeNgContentSelect(selectAttr);
  3035. var /** @type {?} */ nodeName = ast.name.toLowerCase();
  3036. var /** @type {?} */ type = PreparsedElementType.OTHER;
  3037. if (isNgContent(nodeName)) {
  3038. type = PreparsedElementType.NG_CONTENT;
  3039. }
  3040. else if (nodeName == STYLE_ELEMENT) {
  3041. type = PreparsedElementType.STYLE;
  3042. }
  3043. else if (nodeName == SCRIPT_ELEMENT) {
  3044. type = PreparsedElementType.SCRIPT;
  3045. }
  3046. else if (nodeName == LINK_ELEMENT && relAttr == LINK_STYLE_REL_VALUE) {
  3047. type = PreparsedElementType.STYLESHEET;
  3048. }
  3049. return new PreparsedElement(type, selectAttr, hrefAttr, nonBindable, projectAs);
  3050. }
  3051. /** @enum {number} */
  3052. var PreparsedElementType = {
  3053. NG_CONTENT: 0,
  3054. STYLE: 1,
  3055. STYLESHEET: 2,
  3056. SCRIPT: 3,
  3057. OTHER: 4,
  3058. };
  3059. PreparsedElementType[PreparsedElementType.NG_CONTENT] = "NG_CONTENT";
  3060. PreparsedElementType[PreparsedElementType.STYLE] = "STYLE";
  3061. PreparsedElementType[PreparsedElementType.STYLESHEET] = "STYLESHEET";
  3062. PreparsedElementType[PreparsedElementType.SCRIPT] = "SCRIPT";
  3063. PreparsedElementType[PreparsedElementType.OTHER] = "OTHER";
  3064. var PreparsedElement = /** @class */ (function () {
  3065. function PreparsedElement(type, selectAttr, hrefAttr, nonBindable, projectAs) {
  3066. this.type = type;
  3067. this.selectAttr = selectAttr;
  3068. this.hrefAttr = hrefAttr;
  3069. this.nonBindable = nonBindable;
  3070. this.projectAs = projectAs;
  3071. }
  3072. return PreparsedElement;
  3073. }());
  3074. /**
  3075. * @param {?} selectAttr
  3076. * @return {?}
  3077. */
  3078. function normalizeNgContentSelect(selectAttr) {
  3079. if (selectAttr === null || selectAttr.length === 0) {
  3080. return '*';
  3081. }
  3082. return selectAttr;
  3083. }
  3084. /**
  3085. * @fileoverview added by tsickle
  3086. * @suppress {checkTypes} checked by tsc
  3087. */
  3088. /**
  3089. * @license
  3090. * Copyright Google Inc. All Rights Reserved.
  3091. *
  3092. * Use of this source code is governed by an MIT-style license that can be
  3093. * found in the LICENSE file at https://angular.io/license
  3094. */
  3095. /**
  3096. * @record
  3097. */
  3098. var DirectiveNormalizer = /** @class */ (function () {
  3099. function DirectiveNormalizer(_resourceLoader, _urlResolver, _htmlParser, _config) {
  3100. this._resourceLoader = _resourceLoader;
  3101. this._urlResolver = _urlResolver;
  3102. this._htmlParser = _htmlParser;
  3103. this._config = _config;
  3104. this._resourceLoaderCache = new Map();
  3105. }
  3106. /**
  3107. * @return {?}
  3108. */
  3109. DirectiveNormalizer.prototype.clearCache = /**
  3110. * @return {?}
  3111. */
  3112. function () { this._resourceLoaderCache.clear(); };
  3113. /**
  3114. * @param {?} normalizedDirective
  3115. * @return {?}
  3116. */
  3117. DirectiveNormalizer.prototype.clearCacheFor = /**
  3118. * @param {?} normalizedDirective
  3119. * @return {?}
  3120. */
  3121. function (normalizedDirective) {
  3122. var _this = this;
  3123. if (!normalizedDirective.isComponent) {
  3124. return;
  3125. }
  3126. var /** @type {?} */ template = /** @type {?} */ ((normalizedDirective.template));
  3127. this._resourceLoaderCache.delete(/** @type {?} */ ((template.templateUrl)));
  3128. template.externalStylesheets.forEach(function (stylesheet) { _this._resourceLoaderCache.delete(/** @type {?} */ ((stylesheet.moduleUrl))); });
  3129. };
  3130. /**
  3131. * @param {?} url
  3132. * @return {?}
  3133. */
  3134. DirectiveNormalizer.prototype._fetch = /**
  3135. * @param {?} url
  3136. * @return {?}
  3137. */
  3138. function (url) {
  3139. var /** @type {?} */ result = this._resourceLoaderCache.get(url);
  3140. if (!result) {
  3141. result = this._resourceLoader.get(url);
  3142. this._resourceLoaderCache.set(url, result);
  3143. }
  3144. return result;
  3145. };
  3146. /**
  3147. * @param {?} prenormData
  3148. * @return {?}
  3149. */
  3150. DirectiveNormalizer.prototype.normalizeTemplate = /**
  3151. * @param {?} prenormData
  3152. * @return {?}
  3153. */
  3154. function (prenormData) {
  3155. var _this = this;
  3156. if (isDefined(prenormData.template)) {
  3157. if (isDefined(prenormData.templateUrl)) {
  3158. throw syntaxError("'" + stringify(prenormData.componentType) + "' component cannot define both template and templateUrl");
  3159. }
  3160. if (typeof prenormData.template !== 'string') {
  3161. throw syntaxError("The template specified for component " + stringify(prenormData.componentType) + " is not a string");
  3162. }
  3163. }
  3164. else if (isDefined(prenormData.templateUrl)) {
  3165. if (typeof prenormData.templateUrl !== 'string') {
  3166. throw syntaxError("The templateUrl specified for component " + stringify(prenormData.componentType) + " is not a string");
  3167. }
  3168. }
  3169. else {
  3170. throw syntaxError("No template specified for component " + stringify(prenormData.componentType));
  3171. }
  3172. if (isDefined(prenormData.preserveWhitespaces) &&
  3173. typeof prenormData.preserveWhitespaces !== 'boolean') {
  3174. throw syntaxError("The preserveWhitespaces option for component " + stringify(prenormData.componentType) + " must be a boolean");
  3175. }
  3176. return SyncAsync.then(this._preParseTemplate(prenormData), function (preparsedTemplate) { return _this._normalizeTemplateMetadata(prenormData, preparsedTemplate); });
  3177. };
  3178. /**
  3179. * @param {?} prenomData
  3180. * @return {?}
  3181. */
  3182. DirectiveNormalizer.prototype._preParseTemplate = /**
  3183. * @param {?} prenomData
  3184. * @return {?}
  3185. */
  3186. function (prenomData) {
  3187. var _this = this;
  3188. var /** @type {?} */ template;
  3189. var /** @type {?} */ templateUrl;
  3190. if (prenomData.template != null) {
  3191. template = prenomData.template;
  3192. templateUrl = prenomData.moduleUrl;
  3193. }
  3194. else {
  3195. templateUrl = this._urlResolver.resolve(prenomData.moduleUrl, /** @type {?} */ ((prenomData.templateUrl)));
  3196. template = this._fetch(templateUrl);
  3197. }
  3198. return SyncAsync.then(template, function (template) { return _this._preparseLoadedTemplate(prenomData, template, templateUrl); });
  3199. };
  3200. /**
  3201. * @param {?} prenormData
  3202. * @param {?} template
  3203. * @param {?} templateAbsUrl
  3204. * @return {?}
  3205. */
  3206. DirectiveNormalizer.prototype._preparseLoadedTemplate = /**
  3207. * @param {?} prenormData
  3208. * @param {?} template
  3209. * @param {?} templateAbsUrl
  3210. * @return {?}
  3211. */
  3212. function (prenormData, template, templateAbsUrl) {
  3213. var /** @type {?} */ isInline = !!prenormData.template;
  3214. var /** @type {?} */ interpolationConfig = InterpolationConfig.fromArray(/** @type {?} */ ((prenormData.interpolation)));
  3215. var /** @type {?} */ rootNodesAndErrors = this._htmlParser.parse(template, templateSourceUrl({ reference: prenormData.ngModuleType }, { type: { reference: prenormData.componentType } }, { isInline: isInline, templateUrl: templateAbsUrl }), true, interpolationConfig);
  3216. if (rootNodesAndErrors.errors.length > 0) {
  3217. var /** @type {?} */ errorString = rootNodesAndErrors.errors.join('\n');
  3218. throw syntaxError("Template parse errors:\n" + errorString);
  3219. }
  3220. var /** @type {?} */ templateMetadataStyles = this._normalizeStylesheet(new CompileStylesheetMetadata({ styles: prenormData.styles, moduleUrl: prenormData.moduleUrl }));
  3221. var /** @type {?} */ visitor = new TemplatePreparseVisitor();
  3222. visitAll(visitor, rootNodesAndErrors.rootNodes);
  3223. var /** @type {?} */ templateStyles = this._normalizeStylesheet(new CompileStylesheetMetadata({ styles: visitor.styles, styleUrls: visitor.styleUrls, moduleUrl: templateAbsUrl }));
  3224. var /** @type {?} */ styles = templateMetadataStyles.styles.concat(templateStyles.styles);
  3225. var /** @type {?} */ inlineStyleUrls = templateMetadataStyles.styleUrls.concat(templateStyles.styleUrls);
  3226. var /** @type {?} */ styleUrls = this
  3227. ._normalizeStylesheet(new CompileStylesheetMetadata({ styleUrls: prenormData.styleUrls, moduleUrl: prenormData.moduleUrl }))
  3228. .styleUrls;
  3229. return {
  3230. template: template,
  3231. templateUrl: templateAbsUrl, isInline: isInline,
  3232. htmlAst: rootNodesAndErrors, styles: styles, inlineStyleUrls: inlineStyleUrls, styleUrls: styleUrls,
  3233. ngContentSelectors: visitor.ngContentSelectors,
  3234. };
  3235. };
  3236. /**
  3237. * @param {?} prenormData
  3238. * @param {?} preparsedTemplate
  3239. * @return {?}
  3240. */
  3241. DirectiveNormalizer.prototype._normalizeTemplateMetadata = /**
  3242. * @param {?} prenormData
  3243. * @param {?} preparsedTemplate
  3244. * @return {?}
  3245. */
  3246. function (prenormData, preparsedTemplate) {
  3247. var _this = this;
  3248. return SyncAsync.then(this._loadMissingExternalStylesheets(preparsedTemplate.styleUrls.concat(preparsedTemplate.inlineStyleUrls)), function (externalStylesheets) {
  3249. return _this._normalizeLoadedTemplateMetadata(prenormData, preparsedTemplate, externalStylesheets);
  3250. });
  3251. };
  3252. /**
  3253. * @param {?} prenormData
  3254. * @param {?} preparsedTemplate
  3255. * @param {?} stylesheets
  3256. * @return {?}
  3257. */
  3258. DirectiveNormalizer.prototype._normalizeLoadedTemplateMetadata = /**
  3259. * @param {?} prenormData
  3260. * @param {?} preparsedTemplate
  3261. * @param {?} stylesheets
  3262. * @return {?}
  3263. */
  3264. function (prenormData, preparsedTemplate, stylesheets) {
  3265. var _this = this;
  3266. // Algorithm:
  3267. // - produce exactly 1 entry per original styleUrl in
  3268. // CompileTemplateMetadata.externalStylesheets whith all styles inlined
  3269. // - inline all styles that are referenced by the template into CompileTemplateMetadata.styles.
  3270. // Reason: be able to determine how many stylesheets there are even without loading
  3271. // the template nor the stylesheets, so we can create a stub for TypeScript always synchronously
  3272. // (as resouce loading may be async)
  3273. var /** @type {?} */ styles = preparsedTemplate.styles.slice();
  3274. this._inlineStyles(preparsedTemplate.inlineStyleUrls, stylesheets, styles);
  3275. var /** @type {?} */ styleUrls = preparsedTemplate.styleUrls;
  3276. var /** @type {?} */ externalStylesheets = styleUrls.map(function (styleUrl) {
  3277. var /** @type {?} */ stylesheet = /** @type {?} */ ((stylesheets.get(styleUrl)));
  3278. var /** @type {?} */ styles = stylesheet.styles.slice();
  3279. _this._inlineStyles(stylesheet.styleUrls, stylesheets, styles);
  3280. return new CompileStylesheetMetadata({ moduleUrl: styleUrl, styles: styles });
  3281. });
  3282. var /** @type {?} */ encapsulation = prenormData.encapsulation;
  3283. if (encapsulation == null) {
  3284. encapsulation = this._config.defaultEncapsulation;
  3285. }
  3286. if (encapsulation === ViewEncapsulation.Emulated && styles.length === 0 &&
  3287. styleUrls.length === 0) {
  3288. encapsulation = ViewEncapsulation.None;
  3289. }
  3290. return new CompileTemplateMetadata({
  3291. encapsulation: encapsulation,
  3292. template: preparsedTemplate.template,
  3293. templateUrl: preparsedTemplate.templateUrl,
  3294. htmlAst: preparsedTemplate.htmlAst, styles: styles, styleUrls: styleUrls,
  3295. ngContentSelectors: preparsedTemplate.ngContentSelectors,
  3296. animations: prenormData.animations,
  3297. interpolation: prenormData.interpolation,
  3298. isInline: preparsedTemplate.isInline, externalStylesheets: externalStylesheets,
  3299. preserveWhitespaces: preserveWhitespacesDefault(prenormData.preserveWhitespaces, this._config.preserveWhitespaces),
  3300. });
  3301. };
  3302. /**
  3303. * @param {?} styleUrls
  3304. * @param {?} stylesheets
  3305. * @param {?} targetStyles
  3306. * @return {?}
  3307. */
  3308. DirectiveNormalizer.prototype._inlineStyles = /**
  3309. * @param {?} styleUrls
  3310. * @param {?} stylesheets
  3311. * @param {?} targetStyles
  3312. * @return {?}
  3313. */
  3314. function (styleUrls, stylesheets, targetStyles) {
  3315. var _this = this;
  3316. styleUrls.forEach(function (styleUrl) {
  3317. var /** @type {?} */ stylesheet = /** @type {?} */ ((stylesheets.get(styleUrl)));
  3318. stylesheet.styles.forEach(function (style) { return targetStyles.push(style); });
  3319. _this._inlineStyles(stylesheet.styleUrls, stylesheets, targetStyles);
  3320. });
  3321. };
  3322. /**
  3323. * @param {?} styleUrls
  3324. * @param {?=} loadedStylesheets
  3325. * @return {?}
  3326. */
  3327. DirectiveNormalizer.prototype._loadMissingExternalStylesheets = /**
  3328. * @param {?} styleUrls
  3329. * @param {?=} loadedStylesheets
  3330. * @return {?}
  3331. */
  3332. function (styleUrls, loadedStylesheets) {
  3333. var _this = this;
  3334. if (loadedStylesheets === void 0) { loadedStylesheets = new Map(); }
  3335. return SyncAsync.then(SyncAsync.all(styleUrls.filter(function (styleUrl) { return !loadedStylesheets.has(styleUrl); })
  3336. .map(function (styleUrl) {
  3337. return SyncAsync.then(_this._fetch(styleUrl), function (loadedStyle) {
  3338. var /** @type {?} */ stylesheet = _this._normalizeStylesheet(new CompileStylesheetMetadata({ styles: [loadedStyle], moduleUrl: styleUrl }));
  3339. loadedStylesheets.set(styleUrl, stylesheet);
  3340. return _this._loadMissingExternalStylesheets(stylesheet.styleUrls, loadedStylesheets);
  3341. });
  3342. })), function (_) { return loadedStylesheets; });
  3343. };
  3344. /**
  3345. * @param {?} stylesheet
  3346. * @return {?}
  3347. */
  3348. DirectiveNormalizer.prototype._normalizeStylesheet = /**
  3349. * @param {?} stylesheet
  3350. * @return {?}
  3351. */
  3352. function (stylesheet) {
  3353. var _this = this;
  3354. var /** @type {?} */ moduleUrl = /** @type {?} */ ((stylesheet.moduleUrl));
  3355. var /** @type {?} */ allStyleUrls = stylesheet.styleUrls.filter(isStyleUrlResolvable)
  3356. .map(function (url) { return _this._urlResolver.resolve(moduleUrl, url); });
  3357. var /** @type {?} */ allStyles = stylesheet.styles.map(function (style) {
  3358. var /** @type {?} */ styleWithImports = extractStyleUrls(_this._urlResolver, moduleUrl, style);
  3359. allStyleUrls.push.apply(allStyleUrls, styleWithImports.styleUrls);
  3360. return styleWithImports.style;
  3361. });
  3362. return new CompileStylesheetMetadata({ styles: allStyles, styleUrls: allStyleUrls, moduleUrl: moduleUrl });
  3363. };
  3364. return DirectiveNormalizer;
  3365. }());
  3366. var TemplatePreparseVisitor = /** @class */ (function () {
  3367. function TemplatePreparseVisitor() {
  3368. this.ngContentSelectors = [];
  3369. this.styles = [];
  3370. this.styleUrls = [];
  3371. this.ngNonBindableStackCount = 0;
  3372. }
  3373. /**
  3374. * @param {?} ast
  3375. * @param {?} context
  3376. * @return {?}
  3377. */
  3378. TemplatePreparseVisitor.prototype.visitElement = /**
  3379. * @param {?} ast
  3380. * @param {?} context
  3381. * @return {?}
  3382. */
  3383. function (ast, context) {
  3384. var /** @type {?} */ preparsedElement = preparseElement(ast);
  3385. switch (preparsedElement.type) {
  3386. case PreparsedElementType.NG_CONTENT:
  3387. if (this.ngNonBindableStackCount === 0) {
  3388. this.ngContentSelectors.push(preparsedElement.selectAttr);
  3389. }
  3390. break;
  3391. case PreparsedElementType.STYLE:
  3392. var /** @type {?} */ textContent_1 = '';
  3393. ast.children.forEach(function (child) {
  3394. if (child instanceof Text) {
  3395. textContent_1 += child.value;
  3396. }
  3397. });
  3398. this.styles.push(textContent_1);
  3399. break;
  3400. case PreparsedElementType.STYLESHEET:
  3401. this.styleUrls.push(preparsedElement.hrefAttr);
  3402. break;
  3403. default:
  3404. break;
  3405. }
  3406. if (preparsedElement.nonBindable) {
  3407. this.ngNonBindableStackCount++;
  3408. }
  3409. visitAll(this, ast.children);
  3410. if (preparsedElement.nonBindable) {
  3411. this.ngNonBindableStackCount--;
  3412. }
  3413. return null;
  3414. };
  3415. /**
  3416. * @param {?} ast
  3417. * @param {?} context
  3418. * @return {?}
  3419. */
  3420. TemplatePreparseVisitor.prototype.visitExpansion = /**
  3421. * @param {?} ast
  3422. * @param {?} context
  3423. * @return {?}
  3424. */
  3425. function (ast, context) { visitAll(this, ast.cases); };
  3426. /**
  3427. * @param {?} ast
  3428. * @param {?} context
  3429. * @return {?}
  3430. */
  3431. TemplatePreparseVisitor.prototype.visitExpansionCase = /**
  3432. * @param {?} ast
  3433. * @param {?} context
  3434. * @return {?}
  3435. */
  3436. function (ast, context) {
  3437. visitAll(this, ast.expression);
  3438. };
  3439. /**
  3440. * @param {?} ast
  3441. * @param {?} context
  3442. * @return {?}
  3443. */
  3444. TemplatePreparseVisitor.prototype.visitComment = /**
  3445. * @param {?} ast
  3446. * @param {?} context
  3447. * @return {?}
  3448. */
  3449. function (ast, context) { return null; };
  3450. /**
  3451. * @param {?} ast
  3452. * @param {?} context
  3453. * @return {?}
  3454. */
  3455. TemplatePreparseVisitor.prototype.visitAttribute = /**
  3456. * @param {?} ast
  3457. * @param {?} context
  3458. * @return {?}
  3459. */
  3460. function (ast, context) { return null; };
  3461. /**
  3462. * @param {?} ast
  3463. * @param {?} context
  3464. * @return {?}
  3465. */
  3466. TemplatePreparseVisitor.prototype.visitText = /**
  3467. * @param {?} ast
  3468. * @param {?} context
  3469. * @return {?}
  3470. */
  3471. function (ast, context) { return null; };
  3472. return TemplatePreparseVisitor;
  3473. }());
  3474. /**
  3475. * @fileoverview added by tsickle
  3476. * @suppress {checkTypes} checked by tsc
  3477. */
  3478. /**
  3479. * @license
  3480. * Copyright Google Inc. All Rights Reserved.
  3481. *
  3482. * Use of this source code is governed by an MIT-style license that can be
  3483. * found in the LICENSE file at https://angular.io/license
  3484. */
  3485. var QUERY_METADATA_IDENTIFIERS = [
  3486. createViewChild,
  3487. createViewChildren,
  3488. createContentChild,
  3489. createContentChildren,
  3490. ];
  3491. var DirectiveResolver = /** @class */ (function () {
  3492. function DirectiveResolver(_reflector) {
  3493. this._reflector = _reflector;
  3494. }
  3495. /**
  3496. * @param {?} type
  3497. * @return {?}
  3498. */
  3499. DirectiveResolver.prototype.isDirective = /**
  3500. * @param {?} type
  3501. * @return {?}
  3502. */
  3503. function (type) {
  3504. var /** @type {?} */ typeMetadata = this._reflector.annotations(resolveForwardRef(type));
  3505. return typeMetadata && typeMetadata.some(isDirectiveMetadata);
  3506. };
  3507. /**
  3508. * @param {?} type
  3509. * @param {?=} throwIfNotFound
  3510. * @return {?}
  3511. */
  3512. DirectiveResolver.prototype.resolve = /**
  3513. * @param {?} type
  3514. * @param {?=} throwIfNotFound
  3515. * @return {?}
  3516. */
  3517. function (type, throwIfNotFound) {
  3518. if (throwIfNotFound === void 0) { throwIfNotFound = true; }
  3519. var /** @type {?} */ typeMetadata = this._reflector.annotations(resolveForwardRef(type));
  3520. if (typeMetadata) {
  3521. var /** @type {?} */ metadata = findLast(typeMetadata, isDirectiveMetadata);
  3522. if (metadata) {
  3523. var /** @type {?} */ propertyMetadata = this._reflector.propMetadata(type);
  3524. var /** @type {?} */ guards = this._reflector.guards(type);
  3525. return this._mergeWithPropertyMetadata(metadata, propertyMetadata, guards, type);
  3526. }
  3527. }
  3528. if (throwIfNotFound) {
  3529. throw new Error("No Directive annotation found on " + stringify(type));
  3530. }
  3531. return null;
  3532. };
  3533. /**
  3534. * @param {?} dm
  3535. * @param {?} propertyMetadata
  3536. * @param {?} guards
  3537. * @param {?} directiveType
  3538. * @return {?}
  3539. */
  3540. DirectiveResolver.prototype._mergeWithPropertyMetadata = /**
  3541. * @param {?} dm
  3542. * @param {?} propertyMetadata
  3543. * @param {?} guards
  3544. * @param {?} directiveType
  3545. * @return {?}
  3546. */
  3547. function (dm, propertyMetadata, guards, directiveType) {
  3548. var /** @type {?} */ inputs = [];
  3549. var /** @type {?} */ outputs = [];
  3550. var /** @type {?} */ host = {};
  3551. var /** @type {?} */ queries = {};
  3552. Object.keys(propertyMetadata).forEach(function (propName) {
  3553. var /** @type {?} */ input = findLast(propertyMetadata[propName], function (a) { return createInput.isTypeOf(a); });
  3554. if (input) {
  3555. if (input.bindingPropertyName) {
  3556. inputs.push(propName + ": " + input.bindingPropertyName);
  3557. }
  3558. else {
  3559. inputs.push(propName);
  3560. }
  3561. }
  3562. var /** @type {?} */ output = findLast(propertyMetadata[propName], function (a) { return createOutput.isTypeOf(a); });
  3563. if (output) {
  3564. if (output.bindingPropertyName) {
  3565. outputs.push(propName + ": " + output.bindingPropertyName);
  3566. }
  3567. else {
  3568. outputs.push(propName);
  3569. }
  3570. }
  3571. var /** @type {?} */ hostBindings = propertyMetadata[propName].filter(function (a) { return createHostBinding.isTypeOf(a); });
  3572. hostBindings.forEach(function (hostBinding) {
  3573. if (hostBinding.hostPropertyName) {
  3574. var /** @type {?} */ startWith = hostBinding.hostPropertyName[0];
  3575. if (startWith === '(') {
  3576. throw new Error("@HostBinding can not bind to events. Use @HostListener instead.");
  3577. }
  3578. else if (startWith === '[') {
  3579. throw new Error("@HostBinding parameter should be a property name, 'class.<name>', or 'attr.<name>'.");
  3580. }
  3581. host["[" + hostBinding.hostPropertyName + "]"] = propName;
  3582. }
  3583. else {
  3584. host["[" + propName + "]"] = propName;
  3585. }
  3586. });
  3587. var /** @type {?} */ hostListeners = propertyMetadata[propName].filter(function (a) { return createHostListener.isTypeOf(a); });
  3588. hostListeners.forEach(function (hostListener) {
  3589. var /** @type {?} */ args = hostListener.args || [];
  3590. host["(" + hostListener.eventName + ")"] = propName + "(" + args.join(',') + ")";
  3591. });
  3592. var /** @type {?} */ query = findLast(propertyMetadata[propName], function (a) { return QUERY_METADATA_IDENTIFIERS.some(function (i) { return i.isTypeOf(a); }); });
  3593. if (query) {
  3594. queries[propName] = query;
  3595. }
  3596. });
  3597. return this._merge(dm, inputs, outputs, host, queries, guards, directiveType);
  3598. };
  3599. /**
  3600. * @param {?} def
  3601. * @return {?}
  3602. */
  3603. DirectiveResolver.prototype._extractPublicName = /**
  3604. * @param {?} def
  3605. * @return {?}
  3606. */
  3607. function (def) { return splitAtColon(def, [/** @type {?} */ ((null)), def])[1].trim(); };
  3608. /**
  3609. * @param {?} bindings
  3610. * @return {?}
  3611. */
  3612. DirectiveResolver.prototype._dedupeBindings = /**
  3613. * @param {?} bindings
  3614. * @return {?}
  3615. */
  3616. function (bindings) {
  3617. var /** @type {?} */ names = new Set();
  3618. var /** @type {?} */ publicNames = new Set();
  3619. var /** @type {?} */ reversedResult = [];
  3620. // go last to first to allow later entries to overwrite previous entries
  3621. for (var /** @type {?} */ i = bindings.length - 1; i >= 0; i--) {
  3622. var /** @type {?} */ binding = bindings[i];
  3623. var /** @type {?} */ name_1 = this._extractPublicName(binding);
  3624. publicNames.add(name_1);
  3625. if (!names.has(name_1)) {
  3626. names.add(name_1);
  3627. reversedResult.push(binding);
  3628. }
  3629. }
  3630. return reversedResult.reverse();
  3631. };
  3632. /**
  3633. * @param {?} directive
  3634. * @param {?} inputs
  3635. * @param {?} outputs
  3636. * @param {?} host
  3637. * @param {?} queries
  3638. * @param {?} guards
  3639. * @param {?} directiveType
  3640. * @return {?}
  3641. */
  3642. DirectiveResolver.prototype._merge = /**
  3643. * @param {?} directive
  3644. * @param {?} inputs
  3645. * @param {?} outputs
  3646. * @param {?} host
  3647. * @param {?} queries
  3648. * @param {?} guards
  3649. * @param {?} directiveType
  3650. * @return {?}
  3651. */
  3652. function (directive, inputs, outputs, host, queries, guards, directiveType) {
  3653. var /** @type {?} */ mergedInputs = this._dedupeBindings(directive.inputs ? directive.inputs.concat(inputs) : inputs);
  3654. var /** @type {?} */ mergedOutputs = this._dedupeBindings(directive.outputs ? directive.outputs.concat(outputs) : outputs);
  3655. var /** @type {?} */ mergedHost = directive.host ? __assign({}, directive.host, host) : host;
  3656. var /** @type {?} */ mergedQueries = directive.queries ? __assign({}, directive.queries, queries) : queries;
  3657. if (createComponent.isTypeOf(directive)) {
  3658. var /** @type {?} */ comp = /** @type {?} */ (directive);
  3659. return createComponent({
  3660. selector: comp.selector,
  3661. inputs: mergedInputs,
  3662. outputs: mergedOutputs,
  3663. host: mergedHost,
  3664. exportAs: comp.exportAs,
  3665. moduleId: comp.moduleId,
  3666. queries: mergedQueries,
  3667. changeDetection: comp.changeDetection,
  3668. providers: comp.providers,
  3669. viewProviders: comp.viewProviders,
  3670. entryComponents: comp.entryComponents,
  3671. template: comp.template,
  3672. templateUrl: comp.templateUrl,
  3673. styles: comp.styles,
  3674. styleUrls: comp.styleUrls,
  3675. encapsulation: comp.encapsulation,
  3676. animations: comp.animations,
  3677. interpolation: comp.interpolation,
  3678. preserveWhitespaces: directive.preserveWhitespaces,
  3679. });
  3680. }
  3681. else {
  3682. return createDirective({
  3683. selector: directive.selector,
  3684. inputs: mergedInputs,
  3685. outputs: mergedOutputs,
  3686. host: mergedHost,
  3687. exportAs: directive.exportAs,
  3688. queries: mergedQueries,
  3689. providers: directive.providers, guards: guards
  3690. });
  3691. }
  3692. };
  3693. return DirectiveResolver;
  3694. }());
  3695. /**
  3696. * @param {?} type
  3697. * @return {?}
  3698. */
  3699. function isDirectiveMetadata(type) {
  3700. return createDirective.isTypeOf(type) || createComponent.isTypeOf(type);
  3701. }
  3702. /**
  3703. * @template T
  3704. * @param {?} arr
  3705. * @param {?} condition
  3706. * @return {?}
  3707. */
  3708. function findLast(arr, condition) {
  3709. for (var /** @type {?} */ i = arr.length - 1; i >= 0; i--) {
  3710. if (condition(arr[i])) {
  3711. return arr[i];
  3712. }
  3713. }
  3714. return null;
  3715. }
  3716. /**
  3717. * @fileoverview added by tsickle
  3718. * @suppress {checkTypes} checked by tsc
  3719. */
  3720. /**
  3721. * @license
  3722. * Copyright Google Inc. All Rights Reserved.
  3723. *
  3724. * Use of this source code is governed by an MIT-style license that can be
  3725. * found in the LICENSE file at https://angular.io/license
  3726. */
  3727. var $EOF = 0;
  3728. var $TAB = 9;
  3729. var $LF = 10;
  3730. var $VTAB = 11;
  3731. var $FF = 12;
  3732. var $CR = 13;
  3733. var $SPACE = 32;
  3734. var $BANG = 33;
  3735. var $DQ = 34;
  3736. var $HASH = 35;
  3737. var $$ = 36;
  3738. var $PERCENT = 37;
  3739. var $AMPERSAND = 38;
  3740. var $SQ = 39;
  3741. var $LPAREN = 40;
  3742. var $RPAREN = 41;
  3743. var $STAR = 42;
  3744. var $PLUS = 43;
  3745. var $COMMA = 44;
  3746. var $MINUS = 45;
  3747. var $PERIOD = 46;
  3748. var $SLASH = 47;
  3749. var $COLON = 58;
  3750. var $SEMICOLON = 59;
  3751. var $LT = 60;
  3752. var $EQ = 61;
  3753. var $GT = 62;
  3754. var $QUESTION = 63;
  3755. var $0 = 48;
  3756. var $9 = 57;
  3757. var $A = 65;
  3758. var $E = 69;
  3759. var $F = 70;
  3760. var $X = 88;
  3761. var $Z = 90;
  3762. var $LBRACKET = 91;
  3763. var $BACKSLASH = 92;
  3764. var $RBRACKET = 93;
  3765. var $CARET = 94;
  3766. var $_ = 95;
  3767. var $a = 97;
  3768. var $e = 101;
  3769. var $f = 102;
  3770. var $n = 110;
  3771. var $r = 114;
  3772. var $t = 116;
  3773. var $u = 117;
  3774. var $v = 118;
  3775. var $x = 120;
  3776. var $z = 122;
  3777. var $LBRACE = 123;
  3778. var $BAR = 124;
  3779. var $RBRACE = 125;
  3780. var $NBSP = 160;
  3781. var $BT = 96;
  3782. /**
  3783. * @param {?} code
  3784. * @return {?}
  3785. */
  3786. function isWhitespace(code) {
  3787. return (code >= $TAB && code <= $SPACE) || (code == $NBSP);
  3788. }
  3789. /**
  3790. * @param {?} code
  3791. * @return {?}
  3792. */
  3793. function isDigit(code) {
  3794. return $0 <= code && code <= $9;
  3795. }
  3796. /**
  3797. * @param {?} code
  3798. * @return {?}
  3799. */
  3800. function isAsciiLetter(code) {
  3801. return code >= $a && code <= $z || code >= $A && code <= $Z;
  3802. }
  3803. /**
  3804. * @param {?} code
  3805. * @return {?}
  3806. */
  3807. function isAsciiHexDigit(code) {
  3808. return code >= $a && code <= $f || code >= $A && code <= $F || isDigit(code);
  3809. }
  3810. /**
  3811. * @fileoverview added by tsickle
  3812. * @suppress {checkTypes} checked by tsc
  3813. */
  3814. /**
  3815. * @license
  3816. * Copyright Google Inc. All Rights Reserved.
  3817. *
  3818. * Use of this source code is governed by an MIT-style license that can be
  3819. * found in the LICENSE file at https://angular.io/license
  3820. */
  3821. /** @enum {number} */
  3822. var TokenType = {
  3823. Character: 0,
  3824. Identifier: 1,
  3825. Keyword: 2,
  3826. String: 3,
  3827. Operator: 4,
  3828. Number: 5,
  3829. Error: 6,
  3830. };
  3831. TokenType[TokenType.Character] = "Character";
  3832. TokenType[TokenType.Identifier] = "Identifier";
  3833. TokenType[TokenType.Keyword] = "Keyword";
  3834. TokenType[TokenType.String] = "String";
  3835. TokenType[TokenType.Operator] = "Operator";
  3836. TokenType[TokenType.Number] = "Number";
  3837. TokenType[TokenType.Error] = "Error";
  3838. var KEYWORDS = ['var', 'let', 'as', 'null', 'undefined', 'true', 'false', 'if', 'else', 'this'];
  3839. var Lexer = /** @class */ (function () {
  3840. function Lexer() {
  3841. }
  3842. /**
  3843. * @param {?} text
  3844. * @return {?}
  3845. */
  3846. Lexer.prototype.tokenize = /**
  3847. * @param {?} text
  3848. * @return {?}
  3849. */
  3850. function (text) {
  3851. var /** @type {?} */ scanner = new _Scanner(text);
  3852. var /** @type {?} */ tokens = [];
  3853. var /** @type {?} */ token = scanner.scanToken();
  3854. while (token != null) {
  3855. tokens.push(token);
  3856. token = scanner.scanToken();
  3857. }
  3858. return tokens;
  3859. };
  3860. return Lexer;
  3861. }());
  3862. var Token = /** @class */ (function () {
  3863. function Token(index, type, numValue, strValue) {
  3864. this.index = index;
  3865. this.type = type;
  3866. this.numValue = numValue;
  3867. this.strValue = strValue;
  3868. }
  3869. /**
  3870. * @param {?} code
  3871. * @return {?}
  3872. */
  3873. Token.prototype.isCharacter = /**
  3874. * @param {?} code
  3875. * @return {?}
  3876. */
  3877. function (code) {
  3878. return this.type == TokenType.Character && this.numValue == code;
  3879. };
  3880. /**
  3881. * @return {?}
  3882. */
  3883. Token.prototype.isNumber = /**
  3884. * @return {?}
  3885. */
  3886. function () { return this.type == TokenType.Number; };
  3887. /**
  3888. * @return {?}
  3889. */
  3890. Token.prototype.isString = /**
  3891. * @return {?}
  3892. */
  3893. function () { return this.type == TokenType.String; };
  3894. /**
  3895. * @param {?} operater
  3896. * @return {?}
  3897. */
  3898. Token.prototype.isOperator = /**
  3899. * @param {?} operater
  3900. * @return {?}
  3901. */
  3902. function (operater) {
  3903. return this.type == TokenType.Operator && this.strValue == operater;
  3904. };
  3905. /**
  3906. * @return {?}
  3907. */
  3908. Token.prototype.isIdentifier = /**
  3909. * @return {?}
  3910. */
  3911. function () { return this.type == TokenType.Identifier; };
  3912. /**
  3913. * @return {?}
  3914. */
  3915. Token.prototype.isKeyword = /**
  3916. * @return {?}
  3917. */
  3918. function () { return this.type == TokenType.Keyword; };
  3919. /**
  3920. * @return {?}
  3921. */
  3922. Token.prototype.isKeywordLet = /**
  3923. * @return {?}
  3924. */
  3925. function () { return this.type == TokenType.Keyword && this.strValue == 'let'; };
  3926. /**
  3927. * @return {?}
  3928. */
  3929. Token.prototype.isKeywordAs = /**
  3930. * @return {?}
  3931. */
  3932. function () { return this.type == TokenType.Keyword && this.strValue == 'as'; };
  3933. /**
  3934. * @return {?}
  3935. */
  3936. Token.prototype.isKeywordNull = /**
  3937. * @return {?}
  3938. */
  3939. function () { return this.type == TokenType.Keyword && this.strValue == 'null'; };
  3940. /**
  3941. * @return {?}
  3942. */
  3943. Token.prototype.isKeywordUndefined = /**
  3944. * @return {?}
  3945. */
  3946. function () {
  3947. return this.type == TokenType.Keyword && this.strValue == 'undefined';
  3948. };
  3949. /**
  3950. * @return {?}
  3951. */
  3952. Token.prototype.isKeywordTrue = /**
  3953. * @return {?}
  3954. */
  3955. function () { return this.type == TokenType.Keyword && this.strValue == 'true'; };
  3956. /**
  3957. * @return {?}
  3958. */
  3959. Token.prototype.isKeywordFalse = /**
  3960. * @return {?}
  3961. */
  3962. function () { return this.type == TokenType.Keyword && this.strValue == 'false'; };
  3963. /**
  3964. * @return {?}
  3965. */
  3966. Token.prototype.isKeywordThis = /**
  3967. * @return {?}
  3968. */
  3969. function () { return this.type == TokenType.Keyword && this.strValue == 'this'; };
  3970. /**
  3971. * @return {?}
  3972. */
  3973. Token.prototype.isError = /**
  3974. * @return {?}
  3975. */
  3976. function () { return this.type == TokenType.Error; };
  3977. /**
  3978. * @return {?}
  3979. */
  3980. Token.prototype.toNumber = /**
  3981. * @return {?}
  3982. */
  3983. function () { return this.type == TokenType.Number ? this.numValue : -1; };
  3984. /**
  3985. * @return {?}
  3986. */
  3987. Token.prototype.toString = /**
  3988. * @return {?}
  3989. */
  3990. function () {
  3991. switch (this.type) {
  3992. case TokenType.Character:
  3993. case TokenType.Identifier:
  3994. case TokenType.Keyword:
  3995. case TokenType.Operator:
  3996. case TokenType.String:
  3997. case TokenType.Error:
  3998. return this.strValue;
  3999. case TokenType.Number:
  4000. return this.numValue.toString();
  4001. default:
  4002. return null;
  4003. }
  4004. };
  4005. return Token;
  4006. }());
  4007. /**
  4008. * @param {?} index
  4009. * @param {?} code
  4010. * @return {?}
  4011. */
  4012. function newCharacterToken(index, code) {
  4013. return new Token(index, TokenType.Character, code, String.fromCharCode(code));
  4014. }
  4015. /**
  4016. * @param {?} index
  4017. * @param {?} text
  4018. * @return {?}
  4019. */
  4020. function newIdentifierToken(index, text) {
  4021. return new Token(index, TokenType.Identifier, 0, text);
  4022. }
  4023. /**
  4024. * @param {?} index
  4025. * @param {?} text
  4026. * @return {?}
  4027. */
  4028. function newKeywordToken(index, text) {
  4029. return new Token(index, TokenType.Keyword, 0, text);
  4030. }
  4031. /**
  4032. * @param {?} index
  4033. * @param {?} text
  4034. * @return {?}
  4035. */
  4036. function newOperatorToken(index, text) {
  4037. return new Token(index, TokenType.Operator, 0, text);
  4038. }
  4039. /**
  4040. * @param {?} index
  4041. * @param {?} text
  4042. * @return {?}
  4043. */
  4044. function newStringToken(index, text) {
  4045. return new Token(index, TokenType.String, 0, text);
  4046. }
  4047. /**
  4048. * @param {?} index
  4049. * @param {?} n
  4050. * @return {?}
  4051. */
  4052. function newNumberToken(index, n) {
  4053. return new Token(index, TokenType.Number, n, '');
  4054. }
  4055. /**
  4056. * @param {?} index
  4057. * @param {?} message
  4058. * @return {?}
  4059. */
  4060. function newErrorToken(index, message) {
  4061. return new Token(index, TokenType.Error, 0, message);
  4062. }
  4063. var EOF = new Token(-1, TokenType.Character, 0, '');
  4064. var _Scanner = /** @class */ (function () {
  4065. function _Scanner(input) {
  4066. this.input = input;
  4067. this.peek = 0;
  4068. this.index = -1;
  4069. this.length = input.length;
  4070. this.advance();
  4071. }
  4072. /**
  4073. * @return {?}
  4074. */
  4075. _Scanner.prototype.advance = /**
  4076. * @return {?}
  4077. */
  4078. function () {
  4079. this.peek = ++this.index >= this.length ? $EOF : this.input.charCodeAt(this.index);
  4080. };
  4081. /**
  4082. * @return {?}
  4083. */
  4084. _Scanner.prototype.scanToken = /**
  4085. * @return {?}
  4086. */
  4087. function () {
  4088. var /** @type {?} */ input = this.input, /** @type {?} */ length = this.length;
  4089. var /** @type {?} */ peek = this.peek, /** @type {?} */ index = this.index;
  4090. // Skip whitespace.
  4091. while (peek <= $SPACE) {
  4092. if (++index >= length) {
  4093. peek = $EOF;
  4094. break;
  4095. }
  4096. else {
  4097. peek = input.charCodeAt(index);
  4098. }
  4099. }
  4100. this.peek = peek;
  4101. this.index = index;
  4102. if (index >= length) {
  4103. return null;
  4104. }
  4105. // Handle identifiers and numbers.
  4106. if (isIdentifierStart(peek))
  4107. return this.scanIdentifier();
  4108. if (isDigit(peek))
  4109. return this.scanNumber(index);
  4110. var /** @type {?} */ start = index;
  4111. switch (peek) {
  4112. case $PERIOD:
  4113. this.advance();
  4114. return isDigit(this.peek) ? this.scanNumber(start) :
  4115. newCharacterToken(start, $PERIOD);
  4116. case $LPAREN:
  4117. case $RPAREN:
  4118. case $LBRACE:
  4119. case $RBRACE:
  4120. case $LBRACKET:
  4121. case $RBRACKET:
  4122. case $COMMA:
  4123. case $COLON:
  4124. case $SEMICOLON:
  4125. return this.scanCharacter(start, peek);
  4126. case $SQ:
  4127. case $DQ:
  4128. return this.scanString();
  4129. case $HASH:
  4130. case $PLUS:
  4131. case $MINUS:
  4132. case $STAR:
  4133. case $SLASH:
  4134. case $PERCENT:
  4135. case $CARET:
  4136. return this.scanOperator(start, String.fromCharCode(peek));
  4137. case $QUESTION:
  4138. return this.scanComplexOperator(start, '?', $PERIOD, '.');
  4139. case $LT:
  4140. case $GT:
  4141. return this.scanComplexOperator(start, String.fromCharCode(peek), $EQ, '=');
  4142. case $BANG:
  4143. case $EQ:
  4144. return this.scanComplexOperator(start, String.fromCharCode(peek), $EQ, '=', $EQ, '=');
  4145. case $AMPERSAND:
  4146. return this.scanComplexOperator(start, '&', $AMPERSAND, '&');
  4147. case $BAR:
  4148. return this.scanComplexOperator(start, '|', $BAR, '|');
  4149. case $NBSP:
  4150. while (isWhitespace(this.peek))
  4151. this.advance();
  4152. return this.scanToken();
  4153. }
  4154. this.advance();
  4155. return this.error("Unexpected character [" + String.fromCharCode(peek) + "]", 0);
  4156. };
  4157. /**
  4158. * @param {?} start
  4159. * @param {?} code
  4160. * @return {?}
  4161. */
  4162. _Scanner.prototype.scanCharacter = /**
  4163. * @param {?} start
  4164. * @param {?} code
  4165. * @return {?}
  4166. */
  4167. function (start, code) {
  4168. this.advance();
  4169. return newCharacterToken(start, code);
  4170. };
  4171. /**
  4172. * @param {?} start
  4173. * @param {?} str
  4174. * @return {?}
  4175. */
  4176. _Scanner.prototype.scanOperator = /**
  4177. * @param {?} start
  4178. * @param {?} str
  4179. * @return {?}
  4180. */
  4181. function (start, str) {
  4182. this.advance();
  4183. return newOperatorToken(start, str);
  4184. };
  4185. /**
  4186. * Tokenize a 2/3 char long operator
  4187. *
  4188. * @param start start index in the expression
  4189. * @param one first symbol (always part of the operator)
  4190. * @param twoCode code point for the second symbol
  4191. * @param two second symbol (part of the operator when the second code point matches)
  4192. * @param threeCode code point for the third symbol
  4193. * @param three third symbol (part of the operator when provided and matches source expression)
  4194. */
  4195. /**
  4196. * Tokenize a 2/3 char long operator
  4197. *
  4198. * @param {?} start start index in the expression
  4199. * @param {?} one first symbol (always part of the operator)
  4200. * @param {?} twoCode code point for the second symbol
  4201. * @param {?} two second symbol (part of the operator when the second code point matches)
  4202. * @param {?=} threeCode code point for the third symbol
  4203. * @param {?=} three third symbol (part of the operator when provided and matches source expression)
  4204. * @return {?}
  4205. */
  4206. _Scanner.prototype.scanComplexOperator = /**
  4207. * Tokenize a 2/3 char long operator
  4208. *
  4209. * @param {?} start start index in the expression
  4210. * @param {?} one first symbol (always part of the operator)
  4211. * @param {?} twoCode code point for the second symbol
  4212. * @param {?} two second symbol (part of the operator when the second code point matches)
  4213. * @param {?=} threeCode code point for the third symbol
  4214. * @param {?=} three third symbol (part of the operator when provided and matches source expression)
  4215. * @return {?}
  4216. */
  4217. function (start, one, twoCode, two, threeCode, three) {
  4218. this.advance();
  4219. var /** @type {?} */ str = one;
  4220. if (this.peek == twoCode) {
  4221. this.advance();
  4222. str += two;
  4223. }
  4224. if (threeCode != null && this.peek == threeCode) {
  4225. this.advance();
  4226. str += three;
  4227. }
  4228. return newOperatorToken(start, str);
  4229. };
  4230. /**
  4231. * @return {?}
  4232. */
  4233. _Scanner.prototype.scanIdentifier = /**
  4234. * @return {?}
  4235. */
  4236. function () {
  4237. var /** @type {?} */ start = this.index;
  4238. this.advance();
  4239. while (isIdentifierPart(this.peek))
  4240. this.advance();
  4241. var /** @type {?} */ str = this.input.substring(start, this.index);
  4242. return KEYWORDS.indexOf(str) > -1 ? newKeywordToken(start, str) :
  4243. newIdentifierToken(start, str);
  4244. };
  4245. /**
  4246. * @param {?} start
  4247. * @return {?}
  4248. */
  4249. _Scanner.prototype.scanNumber = /**
  4250. * @param {?} start
  4251. * @return {?}
  4252. */
  4253. function (start) {
  4254. var /** @type {?} */ simple = (this.index === start);
  4255. this.advance(); // Skip initial digit.
  4256. while (true) {
  4257. if (isDigit(this.peek)) {
  4258. // Do nothing.
  4259. }
  4260. else if (this.peek == $PERIOD) {
  4261. simple = false;
  4262. }
  4263. else if (isExponentStart(this.peek)) {
  4264. this.advance();
  4265. if (isExponentSign(this.peek))
  4266. this.advance();
  4267. if (!isDigit(this.peek))
  4268. return this.error('Invalid exponent', -1);
  4269. simple = false;
  4270. }
  4271. else {
  4272. break;
  4273. }
  4274. this.advance();
  4275. }
  4276. var /** @type {?} */ str = this.input.substring(start, this.index);
  4277. var /** @type {?} */ value = simple ? parseIntAutoRadix(str) : parseFloat(str);
  4278. return newNumberToken(start, value);
  4279. };
  4280. /**
  4281. * @return {?}
  4282. */
  4283. _Scanner.prototype.scanString = /**
  4284. * @return {?}
  4285. */
  4286. function () {
  4287. var /** @type {?} */ start = this.index;
  4288. var /** @type {?} */ quote = this.peek;
  4289. this.advance(); // Skip initial quote.
  4290. var /** @type {?} */ buffer = '';
  4291. var /** @type {?} */ marker = this.index;
  4292. var /** @type {?} */ input = this.input;
  4293. while (this.peek != quote) {
  4294. if (this.peek == $BACKSLASH) {
  4295. buffer += input.substring(marker, this.index);
  4296. this.advance();
  4297. var /** @type {?} */ unescapedCode = void 0;
  4298. // Workaround for TS2.1-introduced type strictness
  4299. this.peek = this.peek;
  4300. if (this.peek == $u) {
  4301. // 4 character hex code for unicode character.
  4302. var /** @type {?} */ hex = input.substring(this.index + 1, this.index + 5);
  4303. if (/^[0-9a-f]+$/i.test(hex)) {
  4304. unescapedCode = parseInt(hex, 16);
  4305. }
  4306. else {
  4307. return this.error("Invalid unicode escape [\\u" + hex + "]", 0);
  4308. }
  4309. for (var /** @type {?} */ i = 0; i < 5; i++) {
  4310. this.advance();
  4311. }
  4312. }
  4313. else {
  4314. unescapedCode = unescape(this.peek);
  4315. this.advance();
  4316. }
  4317. buffer += String.fromCharCode(unescapedCode);
  4318. marker = this.index;
  4319. }
  4320. else if (this.peek == $EOF) {
  4321. return this.error('Unterminated quote', 0);
  4322. }
  4323. else {
  4324. this.advance();
  4325. }
  4326. }
  4327. var /** @type {?} */ last = input.substring(marker, this.index);
  4328. this.advance(); // Skip terminating quote.
  4329. return newStringToken(start, buffer + last);
  4330. };
  4331. /**
  4332. * @param {?} message
  4333. * @param {?} offset
  4334. * @return {?}
  4335. */
  4336. _Scanner.prototype.error = /**
  4337. * @param {?} message
  4338. * @param {?} offset
  4339. * @return {?}
  4340. */
  4341. function (message, offset) {
  4342. var /** @type {?} */ position = this.index + offset;
  4343. return newErrorToken(position, "Lexer Error: " + message + " at column " + position + " in expression [" + this.input + "]");
  4344. };
  4345. return _Scanner;
  4346. }());
  4347. /**
  4348. * @param {?} code
  4349. * @return {?}
  4350. */
  4351. function isIdentifierStart(code) {
  4352. return ($a <= code && code <= $z) || ($A <= code && code <= $Z) ||
  4353. (code == $_) || (code == $$);
  4354. }
  4355. /**
  4356. * @param {?} input
  4357. * @return {?}
  4358. */
  4359. function isIdentifier(input) {
  4360. if (input.length == 0)
  4361. return false;
  4362. var /** @type {?} */ scanner = new _Scanner(input);
  4363. if (!isIdentifierStart(scanner.peek))
  4364. return false;
  4365. scanner.advance();
  4366. while (scanner.peek !== $EOF) {
  4367. if (!isIdentifierPart(scanner.peek))
  4368. return false;
  4369. scanner.advance();
  4370. }
  4371. return true;
  4372. }
  4373. /**
  4374. * @param {?} code
  4375. * @return {?}
  4376. */
  4377. function isIdentifierPart(code) {
  4378. return isAsciiLetter(code) || isDigit(code) || (code == $_) ||
  4379. (code == $$);
  4380. }
  4381. /**
  4382. * @param {?} code
  4383. * @return {?}
  4384. */
  4385. function isExponentStart(code) {
  4386. return code == $e || code == $E;
  4387. }
  4388. /**
  4389. * @param {?} code
  4390. * @return {?}
  4391. */
  4392. function isExponentSign(code) {
  4393. return code == $MINUS || code == $PLUS;
  4394. }
  4395. /**
  4396. * @param {?} code
  4397. * @return {?}
  4398. */
  4399. function isQuote(code) {
  4400. return code === $SQ || code === $DQ || code === $BT;
  4401. }
  4402. /**
  4403. * @param {?} code
  4404. * @return {?}
  4405. */
  4406. function unescape(code) {
  4407. switch (code) {
  4408. case $n:
  4409. return $LF;
  4410. case $f:
  4411. return $FF;
  4412. case $r:
  4413. return $CR;
  4414. case $t:
  4415. return $TAB;
  4416. case $v:
  4417. return $VTAB;
  4418. default:
  4419. return code;
  4420. }
  4421. }
  4422. /**
  4423. * @param {?} text
  4424. * @return {?}
  4425. */
  4426. function parseIntAutoRadix(text) {
  4427. var /** @type {?} */ result = parseInt(text);
  4428. if (isNaN(result)) {
  4429. throw new Error('Invalid integer literal when parsing ' + text);
  4430. }
  4431. return result;
  4432. }
  4433. /**
  4434. * @fileoverview added by tsickle
  4435. * @suppress {checkTypes} checked by tsc
  4436. */
  4437. /**
  4438. * @license
  4439. * Copyright Google Inc. All Rights Reserved.
  4440. *
  4441. * Use of this source code is governed by an MIT-style license that can be
  4442. * found in the LICENSE file at https://angular.io/license
  4443. */
  4444. var ParserError = /** @class */ (function () {
  4445. function ParserError(message, input, errLocation, ctxLocation) {
  4446. this.input = input;
  4447. this.errLocation = errLocation;
  4448. this.ctxLocation = ctxLocation;
  4449. this.message = "Parser Error: " + message + " " + errLocation + " [" + input + "] in " + ctxLocation;
  4450. }
  4451. return ParserError;
  4452. }());
  4453. var ParseSpan = /** @class */ (function () {
  4454. function ParseSpan(start, end) {
  4455. this.start = start;
  4456. this.end = end;
  4457. }
  4458. return ParseSpan;
  4459. }());
  4460. var AST = /** @class */ (function () {
  4461. function AST(span) {
  4462. this.span = span;
  4463. }
  4464. /**
  4465. * @param {?} visitor
  4466. * @param {?=} context
  4467. * @return {?}
  4468. */
  4469. AST.prototype.visit = /**
  4470. * @param {?} visitor
  4471. * @param {?=} context
  4472. * @return {?}
  4473. */
  4474. function (visitor, context) {
  4475. if (context === void 0) { context = null; }
  4476. return null;
  4477. };
  4478. /**
  4479. * @return {?}
  4480. */
  4481. AST.prototype.toString = /**
  4482. * @return {?}
  4483. */
  4484. function () { return 'AST'; };
  4485. return AST;
  4486. }());
  4487. /**
  4488. * Represents a quoted expression of the form:
  4489. *
  4490. * quote = prefix `:` uninterpretedExpression
  4491. * prefix = identifier
  4492. * uninterpretedExpression = arbitrary string
  4493. *
  4494. * A quoted expression is meant to be pre-processed by an AST transformer that
  4495. * converts it into another AST that no longer contains quoted expressions.
  4496. * It is meant to allow third-party developers to extend Angular template
  4497. * expression language. The `uninterpretedExpression` part of the quote is
  4498. * therefore not interpreted by the Angular's own expression parser.
  4499. */
  4500. var Quote = /** @class */ (function (_super) {
  4501. __extends(Quote, _super);
  4502. function Quote(span, prefix, uninterpretedExpression, location) {
  4503. var _this = _super.call(this, span) || this;
  4504. _this.prefix = prefix;
  4505. _this.uninterpretedExpression = uninterpretedExpression;
  4506. _this.location = location;
  4507. return _this;
  4508. }
  4509. /**
  4510. * @param {?} visitor
  4511. * @param {?=} context
  4512. * @return {?}
  4513. */
  4514. Quote.prototype.visit = /**
  4515. * @param {?} visitor
  4516. * @param {?=} context
  4517. * @return {?}
  4518. */
  4519. function (visitor, context) {
  4520. if (context === void 0) { context = null; }
  4521. return visitor.visitQuote(this, context);
  4522. };
  4523. /**
  4524. * @return {?}
  4525. */
  4526. Quote.prototype.toString = /**
  4527. * @return {?}
  4528. */
  4529. function () { return 'Quote'; };
  4530. return Quote;
  4531. }(AST));
  4532. var EmptyExpr = /** @class */ (function (_super) {
  4533. __extends(EmptyExpr, _super);
  4534. function EmptyExpr() {
  4535. return _super !== null && _super.apply(this, arguments) || this;
  4536. }
  4537. /**
  4538. * @param {?} visitor
  4539. * @param {?=} context
  4540. * @return {?}
  4541. */
  4542. EmptyExpr.prototype.visit = /**
  4543. * @param {?} visitor
  4544. * @param {?=} context
  4545. * @return {?}
  4546. */
  4547. function (visitor, context) {
  4548. if (context === void 0) { context = null; }
  4549. // do nothing
  4550. };
  4551. return EmptyExpr;
  4552. }(AST));
  4553. var ImplicitReceiver = /** @class */ (function (_super) {
  4554. __extends(ImplicitReceiver, _super);
  4555. function ImplicitReceiver() {
  4556. return _super !== null && _super.apply(this, arguments) || this;
  4557. }
  4558. /**
  4559. * @param {?} visitor
  4560. * @param {?=} context
  4561. * @return {?}
  4562. */
  4563. ImplicitReceiver.prototype.visit = /**
  4564. * @param {?} visitor
  4565. * @param {?=} context
  4566. * @return {?}
  4567. */
  4568. function (visitor, context) {
  4569. if (context === void 0) { context = null; }
  4570. return visitor.visitImplicitReceiver(this, context);
  4571. };
  4572. return ImplicitReceiver;
  4573. }(AST));
  4574. /**
  4575. * Multiple expressions separated by a semicolon.
  4576. */
  4577. var Chain = /** @class */ (function (_super) {
  4578. __extends(Chain, _super);
  4579. function Chain(span, expressions) {
  4580. var _this = _super.call(this, span) || this;
  4581. _this.expressions = expressions;
  4582. return _this;
  4583. }
  4584. /**
  4585. * @param {?} visitor
  4586. * @param {?=} context
  4587. * @return {?}
  4588. */
  4589. Chain.prototype.visit = /**
  4590. * @param {?} visitor
  4591. * @param {?=} context
  4592. * @return {?}
  4593. */
  4594. function (visitor, context) {
  4595. if (context === void 0) { context = null; }
  4596. return visitor.visitChain(this, context);
  4597. };
  4598. return Chain;
  4599. }(AST));
  4600. var Conditional = /** @class */ (function (_super) {
  4601. __extends(Conditional, _super);
  4602. function Conditional(span, condition, trueExp, falseExp) {
  4603. var _this = _super.call(this, span) || this;
  4604. _this.condition = condition;
  4605. _this.trueExp = trueExp;
  4606. _this.falseExp = falseExp;
  4607. return _this;
  4608. }
  4609. /**
  4610. * @param {?} visitor
  4611. * @param {?=} context
  4612. * @return {?}
  4613. */
  4614. Conditional.prototype.visit = /**
  4615. * @param {?} visitor
  4616. * @param {?=} context
  4617. * @return {?}
  4618. */
  4619. function (visitor, context) {
  4620. if (context === void 0) { context = null; }
  4621. return visitor.visitConditional(this, context);
  4622. };
  4623. return Conditional;
  4624. }(AST));
  4625. var PropertyRead = /** @class */ (function (_super) {
  4626. __extends(PropertyRead, _super);
  4627. function PropertyRead(span, receiver, name) {
  4628. var _this = _super.call(this, span) || this;
  4629. _this.receiver = receiver;
  4630. _this.name = name;
  4631. return _this;
  4632. }
  4633. /**
  4634. * @param {?} visitor
  4635. * @param {?=} context
  4636. * @return {?}
  4637. */
  4638. PropertyRead.prototype.visit = /**
  4639. * @param {?} visitor
  4640. * @param {?=} context
  4641. * @return {?}
  4642. */
  4643. function (visitor, context) {
  4644. if (context === void 0) { context = null; }
  4645. return visitor.visitPropertyRead(this, context);
  4646. };
  4647. return PropertyRead;
  4648. }(AST));
  4649. var PropertyWrite = /** @class */ (function (_super) {
  4650. __extends(PropertyWrite, _super);
  4651. function PropertyWrite(span, receiver, name, value) {
  4652. var _this = _super.call(this, span) || this;
  4653. _this.receiver = receiver;
  4654. _this.name = name;
  4655. _this.value = value;
  4656. return _this;
  4657. }
  4658. /**
  4659. * @param {?} visitor
  4660. * @param {?=} context
  4661. * @return {?}
  4662. */
  4663. PropertyWrite.prototype.visit = /**
  4664. * @param {?} visitor
  4665. * @param {?=} context
  4666. * @return {?}
  4667. */
  4668. function (visitor, context) {
  4669. if (context === void 0) { context = null; }
  4670. return visitor.visitPropertyWrite(this, context);
  4671. };
  4672. return PropertyWrite;
  4673. }(AST));
  4674. var SafePropertyRead = /** @class */ (function (_super) {
  4675. __extends(SafePropertyRead, _super);
  4676. function SafePropertyRead(span, receiver, name) {
  4677. var _this = _super.call(this, span) || this;
  4678. _this.receiver = receiver;
  4679. _this.name = name;
  4680. return _this;
  4681. }
  4682. /**
  4683. * @param {?} visitor
  4684. * @param {?=} context
  4685. * @return {?}
  4686. */
  4687. SafePropertyRead.prototype.visit = /**
  4688. * @param {?} visitor
  4689. * @param {?=} context
  4690. * @return {?}
  4691. */
  4692. function (visitor, context) {
  4693. if (context === void 0) { context = null; }
  4694. return visitor.visitSafePropertyRead(this, context);
  4695. };
  4696. return SafePropertyRead;
  4697. }(AST));
  4698. var KeyedRead = /** @class */ (function (_super) {
  4699. __extends(KeyedRead, _super);
  4700. function KeyedRead(span, obj, key) {
  4701. var _this = _super.call(this, span) || this;
  4702. _this.obj = obj;
  4703. _this.key = key;
  4704. return _this;
  4705. }
  4706. /**
  4707. * @param {?} visitor
  4708. * @param {?=} context
  4709. * @return {?}
  4710. */
  4711. KeyedRead.prototype.visit = /**
  4712. * @param {?} visitor
  4713. * @param {?=} context
  4714. * @return {?}
  4715. */
  4716. function (visitor, context) {
  4717. if (context === void 0) { context = null; }
  4718. return visitor.visitKeyedRead(this, context);
  4719. };
  4720. return KeyedRead;
  4721. }(AST));
  4722. var KeyedWrite = /** @class */ (function (_super) {
  4723. __extends(KeyedWrite, _super);
  4724. function KeyedWrite(span, obj, key, value) {
  4725. var _this = _super.call(this, span) || this;
  4726. _this.obj = obj;
  4727. _this.key = key;
  4728. _this.value = value;
  4729. return _this;
  4730. }
  4731. /**
  4732. * @param {?} visitor
  4733. * @param {?=} context
  4734. * @return {?}
  4735. */
  4736. KeyedWrite.prototype.visit = /**
  4737. * @param {?} visitor
  4738. * @param {?=} context
  4739. * @return {?}
  4740. */
  4741. function (visitor, context) {
  4742. if (context === void 0) { context = null; }
  4743. return visitor.visitKeyedWrite(this, context);
  4744. };
  4745. return KeyedWrite;
  4746. }(AST));
  4747. var BindingPipe = /** @class */ (function (_super) {
  4748. __extends(BindingPipe, _super);
  4749. function BindingPipe(span, exp, name, args) {
  4750. var _this = _super.call(this, span) || this;
  4751. _this.exp = exp;
  4752. _this.name = name;
  4753. _this.args = args;
  4754. return _this;
  4755. }
  4756. /**
  4757. * @param {?} visitor
  4758. * @param {?=} context
  4759. * @return {?}
  4760. */
  4761. BindingPipe.prototype.visit = /**
  4762. * @param {?} visitor
  4763. * @param {?=} context
  4764. * @return {?}
  4765. */
  4766. function (visitor, context) {
  4767. if (context === void 0) { context = null; }
  4768. return visitor.visitPipe(this, context);
  4769. };
  4770. return BindingPipe;
  4771. }(AST));
  4772. var LiteralPrimitive = /** @class */ (function (_super) {
  4773. __extends(LiteralPrimitive, _super);
  4774. function LiteralPrimitive(span, value) {
  4775. var _this = _super.call(this, span) || this;
  4776. _this.value = value;
  4777. return _this;
  4778. }
  4779. /**
  4780. * @param {?} visitor
  4781. * @param {?=} context
  4782. * @return {?}
  4783. */
  4784. LiteralPrimitive.prototype.visit = /**
  4785. * @param {?} visitor
  4786. * @param {?=} context
  4787. * @return {?}
  4788. */
  4789. function (visitor, context) {
  4790. if (context === void 0) { context = null; }
  4791. return visitor.visitLiteralPrimitive(this, context);
  4792. };
  4793. return LiteralPrimitive;
  4794. }(AST));
  4795. var LiteralArray = /** @class */ (function (_super) {
  4796. __extends(LiteralArray, _super);
  4797. function LiteralArray(span, expressions) {
  4798. var _this = _super.call(this, span) || this;
  4799. _this.expressions = expressions;
  4800. return _this;
  4801. }
  4802. /**
  4803. * @param {?} visitor
  4804. * @param {?=} context
  4805. * @return {?}
  4806. */
  4807. LiteralArray.prototype.visit = /**
  4808. * @param {?} visitor
  4809. * @param {?=} context
  4810. * @return {?}
  4811. */
  4812. function (visitor, context) {
  4813. if (context === void 0) { context = null; }
  4814. return visitor.visitLiteralArray(this, context);
  4815. };
  4816. return LiteralArray;
  4817. }(AST));
  4818. var LiteralMap = /** @class */ (function (_super) {
  4819. __extends(LiteralMap, _super);
  4820. function LiteralMap(span, keys, values) {
  4821. var _this = _super.call(this, span) || this;
  4822. _this.keys = keys;
  4823. _this.values = values;
  4824. return _this;
  4825. }
  4826. /**
  4827. * @param {?} visitor
  4828. * @param {?=} context
  4829. * @return {?}
  4830. */
  4831. LiteralMap.prototype.visit = /**
  4832. * @param {?} visitor
  4833. * @param {?=} context
  4834. * @return {?}
  4835. */
  4836. function (visitor, context) {
  4837. if (context === void 0) { context = null; }
  4838. return visitor.visitLiteralMap(this, context);
  4839. };
  4840. return LiteralMap;
  4841. }(AST));
  4842. var Interpolation = /** @class */ (function (_super) {
  4843. __extends(Interpolation, _super);
  4844. function Interpolation(span, strings, expressions) {
  4845. var _this = _super.call(this, span) || this;
  4846. _this.strings = strings;
  4847. _this.expressions = expressions;
  4848. return _this;
  4849. }
  4850. /**
  4851. * @param {?} visitor
  4852. * @param {?=} context
  4853. * @return {?}
  4854. */
  4855. Interpolation.prototype.visit = /**
  4856. * @param {?} visitor
  4857. * @param {?=} context
  4858. * @return {?}
  4859. */
  4860. function (visitor, context) {
  4861. if (context === void 0) { context = null; }
  4862. return visitor.visitInterpolation(this, context);
  4863. };
  4864. return Interpolation;
  4865. }(AST));
  4866. var Binary = /** @class */ (function (_super) {
  4867. __extends(Binary, _super);
  4868. function Binary(span, operation, left, right) {
  4869. var _this = _super.call(this, span) || this;
  4870. _this.operation = operation;
  4871. _this.left = left;
  4872. _this.right = right;
  4873. return _this;
  4874. }
  4875. /**
  4876. * @param {?} visitor
  4877. * @param {?=} context
  4878. * @return {?}
  4879. */
  4880. Binary.prototype.visit = /**
  4881. * @param {?} visitor
  4882. * @param {?=} context
  4883. * @return {?}
  4884. */
  4885. function (visitor, context) {
  4886. if (context === void 0) { context = null; }
  4887. return visitor.visitBinary(this, context);
  4888. };
  4889. return Binary;
  4890. }(AST));
  4891. var PrefixNot = /** @class */ (function (_super) {
  4892. __extends(PrefixNot, _super);
  4893. function PrefixNot(span, expression) {
  4894. var _this = _super.call(this, span) || this;
  4895. _this.expression = expression;
  4896. return _this;
  4897. }
  4898. /**
  4899. * @param {?} visitor
  4900. * @param {?=} context
  4901. * @return {?}
  4902. */
  4903. PrefixNot.prototype.visit = /**
  4904. * @param {?} visitor
  4905. * @param {?=} context
  4906. * @return {?}
  4907. */
  4908. function (visitor, context) {
  4909. if (context === void 0) { context = null; }
  4910. return visitor.visitPrefixNot(this, context);
  4911. };
  4912. return PrefixNot;
  4913. }(AST));
  4914. var NonNullAssert = /** @class */ (function (_super) {
  4915. __extends(NonNullAssert, _super);
  4916. function NonNullAssert(span, expression) {
  4917. var _this = _super.call(this, span) || this;
  4918. _this.expression = expression;
  4919. return _this;
  4920. }
  4921. /**
  4922. * @param {?} visitor
  4923. * @param {?=} context
  4924. * @return {?}
  4925. */
  4926. NonNullAssert.prototype.visit = /**
  4927. * @param {?} visitor
  4928. * @param {?=} context
  4929. * @return {?}
  4930. */
  4931. function (visitor, context) {
  4932. if (context === void 0) { context = null; }
  4933. return visitor.visitNonNullAssert(this, context);
  4934. };
  4935. return NonNullAssert;
  4936. }(AST));
  4937. var MethodCall = /** @class */ (function (_super) {
  4938. __extends(MethodCall, _super);
  4939. function MethodCall(span, receiver, name, args) {
  4940. var _this = _super.call(this, span) || this;
  4941. _this.receiver = receiver;
  4942. _this.name = name;
  4943. _this.args = args;
  4944. return _this;
  4945. }
  4946. /**
  4947. * @param {?} visitor
  4948. * @param {?=} context
  4949. * @return {?}
  4950. */
  4951. MethodCall.prototype.visit = /**
  4952. * @param {?} visitor
  4953. * @param {?=} context
  4954. * @return {?}
  4955. */
  4956. function (visitor, context) {
  4957. if (context === void 0) { context = null; }
  4958. return visitor.visitMethodCall(this, context);
  4959. };
  4960. return MethodCall;
  4961. }(AST));
  4962. var SafeMethodCall = /** @class */ (function (_super) {
  4963. __extends(SafeMethodCall, _super);
  4964. function SafeMethodCall(span, receiver, name, args) {
  4965. var _this = _super.call(this, span) || this;
  4966. _this.receiver = receiver;
  4967. _this.name = name;
  4968. _this.args = args;
  4969. return _this;
  4970. }
  4971. /**
  4972. * @param {?} visitor
  4973. * @param {?=} context
  4974. * @return {?}
  4975. */
  4976. SafeMethodCall.prototype.visit = /**
  4977. * @param {?} visitor
  4978. * @param {?=} context
  4979. * @return {?}
  4980. */
  4981. function (visitor, context) {
  4982. if (context === void 0) { context = null; }
  4983. return visitor.visitSafeMethodCall(this, context);
  4984. };
  4985. return SafeMethodCall;
  4986. }(AST));
  4987. var FunctionCall = /** @class */ (function (_super) {
  4988. __extends(FunctionCall, _super);
  4989. function FunctionCall(span, target, args) {
  4990. var _this = _super.call(this, span) || this;
  4991. _this.target = target;
  4992. _this.args = args;
  4993. return _this;
  4994. }
  4995. /**
  4996. * @param {?} visitor
  4997. * @param {?=} context
  4998. * @return {?}
  4999. */
  5000. FunctionCall.prototype.visit = /**
  5001. * @param {?} visitor
  5002. * @param {?=} context
  5003. * @return {?}
  5004. */
  5005. function (visitor, context) {
  5006. if (context === void 0) { context = null; }
  5007. return visitor.visitFunctionCall(this, context);
  5008. };
  5009. return FunctionCall;
  5010. }(AST));
  5011. var ASTWithSource = /** @class */ (function (_super) {
  5012. __extends(ASTWithSource, _super);
  5013. function ASTWithSource(ast, source, location, errors) {
  5014. var _this = _super.call(this, new ParseSpan(0, source == null ? 0 : source.length)) || this;
  5015. _this.ast = ast;
  5016. _this.source = source;
  5017. _this.location = location;
  5018. _this.errors = errors;
  5019. return _this;
  5020. }
  5021. /**
  5022. * @param {?} visitor
  5023. * @param {?=} context
  5024. * @return {?}
  5025. */
  5026. ASTWithSource.prototype.visit = /**
  5027. * @param {?} visitor
  5028. * @param {?=} context
  5029. * @return {?}
  5030. */
  5031. function (visitor, context) {
  5032. if (context === void 0) { context = null; }
  5033. return this.ast.visit(visitor, context);
  5034. };
  5035. /**
  5036. * @return {?}
  5037. */
  5038. ASTWithSource.prototype.toString = /**
  5039. * @return {?}
  5040. */
  5041. function () { return this.source + " in " + this.location; };
  5042. return ASTWithSource;
  5043. }(AST));
  5044. var TemplateBinding = /** @class */ (function () {
  5045. function TemplateBinding(span, key, keyIsVar, name, expression) {
  5046. this.span = span;
  5047. this.key = key;
  5048. this.keyIsVar = keyIsVar;
  5049. this.name = name;
  5050. this.expression = expression;
  5051. }
  5052. return TemplateBinding;
  5053. }());
  5054. /**
  5055. * @record
  5056. */
  5057. var NullAstVisitor = /** @class */ (function () {
  5058. function NullAstVisitor() {
  5059. }
  5060. /**
  5061. * @param {?} ast
  5062. * @param {?} context
  5063. * @return {?}
  5064. */
  5065. NullAstVisitor.prototype.visitBinary = /**
  5066. * @param {?} ast
  5067. * @param {?} context
  5068. * @return {?}
  5069. */
  5070. function (ast, context) { };
  5071. /**
  5072. * @param {?} ast
  5073. * @param {?} context
  5074. * @return {?}
  5075. */
  5076. NullAstVisitor.prototype.visitChain = /**
  5077. * @param {?} ast
  5078. * @param {?} context
  5079. * @return {?}
  5080. */
  5081. function (ast, context) { };
  5082. /**
  5083. * @param {?} ast
  5084. * @param {?} context
  5085. * @return {?}
  5086. */
  5087. NullAstVisitor.prototype.visitConditional = /**
  5088. * @param {?} ast
  5089. * @param {?} context
  5090. * @return {?}
  5091. */
  5092. function (ast, context) { };
  5093. /**
  5094. * @param {?} ast
  5095. * @param {?} context
  5096. * @return {?}
  5097. */
  5098. NullAstVisitor.prototype.visitFunctionCall = /**
  5099. * @param {?} ast
  5100. * @param {?} context
  5101. * @return {?}
  5102. */
  5103. function (ast, context) { };
  5104. /**
  5105. * @param {?} ast
  5106. * @param {?} context
  5107. * @return {?}
  5108. */
  5109. NullAstVisitor.prototype.visitImplicitReceiver = /**
  5110. * @param {?} ast
  5111. * @param {?} context
  5112. * @return {?}
  5113. */
  5114. function (ast, context) { };
  5115. /**
  5116. * @param {?} ast
  5117. * @param {?} context
  5118. * @return {?}
  5119. */
  5120. NullAstVisitor.prototype.visitInterpolation = /**
  5121. * @param {?} ast
  5122. * @param {?} context
  5123. * @return {?}
  5124. */
  5125. function (ast, context) { };
  5126. /**
  5127. * @param {?} ast
  5128. * @param {?} context
  5129. * @return {?}
  5130. */
  5131. NullAstVisitor.prototype.visitKeyedRead = /**
  5132. * @param {?} ast
  5133. * @param {?} context
  5134. * @return {?}
  5135. */
  5136. function (ast, context) { };
  5137. /**
  5138. * @param {?} ast
  5139. * @param {?} context
  5140. * @return {?}
  5141. */
  5142. NullAstVisitor.prototype.visitKeyedWrite = /**
  5143. * @param {?} ast
  5144. * @param {?} context
  5145. * @return {?}
  5146. */
  5147. function (ast, context) { };
  5148. /**
  5149. * @param {?} ast
  5150. * @param {?} context
  5151. * @return {?}
  5152. */
  5153. NullAstVisitor.prototype.visitLiteralArray = /**
  5154. * @param {?} ast
  5155. * @param {?} context
  5156. * @return {?}
  5157. */
  5158. function (ast, context) { };
  5159. /**
  5160. * @param {?} ast
  5161. * @param {?} context
  5162. * @return {?}
  5163. */
  5164. NullAstVisitor.prototype.visitLiteralMap = /**
  5165. * @param {?} ast
  5166. * @param {?} context
  5167. * @return {?}
  5168. */
  5169. function (ast, context) { };
  5170. /**
  5171. * @param {?} ast
  5172. * @param {?} context
  5173. * @return {?}
  5174. */
  5175. NullAstVisitor.prototype.visitLiteralPrimitive = /**
  5176. * @param {?} ast
  5177. * @param {?} context
  5178. * @return {?}
  5179. */
  5180. function (ast, context) { };
  5181. /**
  5182. * @param {?} ast
  5183. * @param {?} context
  5184. * @return {?}
  5185. */
  5186. NullAstVisitor.prototype.visitMethodCall = /**
  5187. * @param {?} ast
  5188. * @param {?} context
  5189. * @return {?}
  5190. */
  5191. function (ast, context) { };
  5192. /**
  5193. * @param {?} ast
  5194. * @param {?} context
  5195. * @return {?}
  5196. */
  5197. NullAstVisitor.prototype.visitPipe = /**
  5198. * @param {?} ast
  5199. * @param {?} context
  5200. * @return {?}
  5201. */
  5202. function (ast, context) { };
  5203. /**
  5204. * @param {?} ast
  5205. * @param {?} context
  5206. * @return {?}
  5207. */
  5208. NullAstVisitor.prototype.visitPrefixNot = /**
  5209. * @param {?} ast
  5210. * @param {?} context
  5211. * @return {?}
  5212. */
  5213. function (ast, context) { };
  5214. /**
  5215. * @param {?} ast
  5216. * @param {?} context
  5217. * @return {?}
  5218. */
  5219. NullAstVisitor.prototype.visitNonNullAssert = /**
  5220. * @param {?} ast
  5221. * @param {?} context
  5222. * @return {?}
  5223. */
  5224. function (ast, context) { };
  5225. /**
  5226. * @param {?} ast
  5227. * @param {?} context
  5228. * @return {?}
  5229. */
  5230. NullAstVisitor.prototype.visitPropertyRead = /**
  5231. * @param {?} ast
  5232. * @param {?} context
  5233. * @return {?}
  5234. */
  5235. function (ast, context) { };
  5236. /**
  5237. * @param {?} ast
  5238. * @param {?} context
  5239. * @return {?}
  5240. */
  5241. NullAstVisitor.prototype.visitPropertyWrite = /**
  5242. * @param {?} ast
  5243. * @param {?} context
  5244. * @return {?}
  5245. */
  5246. function (ast, context) { };
  5247. /**
  5248. * @param {?} ast
  5249. * @param {?} context
  5250. * @return {?}
  5251. */
  5252. NullAstVisitor.prototype.visitQuote = /**
  5253. * @param {?} ast
  5254. * @param {?} context
  5255. * @return {?}
  5256. */
  5257. function (ast, context) { };
  5258. /**
  5259. * @param {?} ast
  5260. * @param {?} context
  5261. * @return {?}
  5262. */
  5263. NullAstVisitor.prototype.visitSafeMethodCall = /**
  5264. * @param {?} ast
  5265. * @param {?} context
  5266. * @return {?}
  5267. */
  5268. function (ast, context) { };
  5269. /**
  5270. * @param {?} ast
  5271. * @param {?} context
  5272. * @return {?}
  5273. */
  5274. NullAstVisitor.prototype.visitSafePropertyRead = /**
  5275. * @param {?} ast
  5276. * @param {?} context
  5277. * @return {?}
  5278. */
  5279. function (ast, context) { };
  5280. return NullAstVisitor;
  5281. }());
  5282. var RecursiveAstVisitor = /** @class */ (function () {
  5283. function RecursiveAstVisitor() {
  5284. }
  5285. /**
  5286. * @param {?} ast
  5287. * @param {?} context
  5288. * @return {?}
  5289. */
  5290. RecursiveAstVisitor.prototype.visitBinary = /**
  5291. * @param {?} ast
  5292. * @param {?} context
  5293. * @return {?}
  5294. */
  5295. function (ast, context) {
  5296. ast.left.visit(this);
  5297. ast.right.visit(this);
  5298. return null;
  5299. };
  5300. /**
  5301. * @param {?} ast
  5302. * @param {?} context
  5303. * @return {?}
  5304. */
  5305. RecursiveAstVisitor.prototype.visitChain = /**
  5306. * @param {?} ast
  5307. * @param {?} context
  5308. * @return {?}
  5309. */
  5310. function (ast, context) { return this.visitAll(ast.expressions, context); };
  5311. /**
  5312. * @param {?} ast
  5313. * @param {?} context
  5314. * @return {?}
  5315. */
  5316. RecursiveAstVisitor.prototype.visitConditional = /**
  5317. * @param {?} ast
  5318. * @param {?} context
  5319. * @return {?}
  5320. */
  5321. function (ast, context) {
  5322. ast.condition.visit(this);
  5323. ast.trueExp.visit(this);
  5324. ast.falseExp.visit(this);
  5325. return null;
  5326. };
  5327. /**
  5328. * @param {?} ast
  5329. * @param {?} context
  5330. * @return {?}
  5331. */
  5332. RecursiveAstVisitor.prototype.visitPipe = /**
  5333. * @param {?} ast
  5334. * @param {?} context
  5335. * @return {?}
  5336. */
  5337. function (ast, context) {
  5338. ast.exp.visit(this);
  5339. this.visitAll(ast.args, context);
  5340. return null;
  5341. };
  5342. /**
  5343. * @param {?} ast
  5344. * @param {?} context
  5345. * @return {?}
  5346. */
  5347. RecursiveAstVisitor.prototype.visitFunctionCall = /**
  5348. * @param {?} ast
  5349. * @param {?} context
  5350. * @return {?}
  5351. */
  5352. function (ast, context) {
  5353. /** @type {?} */ ((ast.target)).visit(this);
  5354. this.visitAll(ast.args, context);
  5355. return null;
  5356. };
  5357. /**
  5358. * @param {?} ast
  5359. * @param {?} context
  5360. * @return {?}
  5361. */
  5362. RecursiveAstVisitor.prototype.visitImplicitReceiver = /**
  5363. * @param {?} ast
  5364. * @param {?} context
  5365. * @return {?}
  5366. */
  5367. function (ast, context) { return null; };
  5368. /**
  5369. * @param {?} ast
  5370. * @param {?} context
  5371. * @return {?}
  5372. */
  5373. RecursiveAstVisitor.prototype.visitInterpolation = /**
  5374. * @param {?} ast
  5375. * @param {?} context
  5376. * @return {?}
  5377. */
  5378. function (ast, context) {
  5379. return this.visitAll(ast.expressions, context);
  5380. };
  5381. /**
  5382. * @param {?} ast
  5383. * @param {?} context
  5384. * @return {?}
  5385. */
  5386. RecursiveAstVisitor.prototype.visitKeyedRead = /**
  5387. * @param {?} ast
  5388. * @param {?} context
  5389. * @return {?}
  5390. */
  5391. function (ast, context) {
  5392. ast.obj.visit(this);
  5393. ast.key.visit(this);
  5394. return null;
  5395. };
  5396. /**
  5397. * @param {?} ast
  5398. * @param {?} context
  5399. * @return {?}
  5400. */
  5401. RecursiveAstVisitor.prototype.visitKeyedWrite = /**
  5402. * @param {?} ast
  5403. * @param {?} context
  5404. * @return {?}
  5405. */
  5406. function (ast, context) {
  5407. ast.obj.visit(this);
  5408. ast.key.visit(this);
  5409. ast.value.visit(this);
  5410. return null;
  5411. };
  5412. /**
  5413. * @param {?} ast
  5414. * @param {?} context
  5415. * @return {?}
  5416. */
  5417. RecursiveAstVisitor.prototype.visitLiteralArray = /**
  5418. * @param {?} ast
  5419. * @param {?} context
  5420. * @return {?}
  5421. */
  5422. function (ast, context) {
  5423. return this.visitAll(ast.expressions, context);
  5424. };
  5425. /**
  5426. * @param {?} ast
  5427. * @param {?} context
  5428. * @return {?}
  5429. */
  5430. RecursiveAstVisitor.prototype.visitLiteralMap = /**
  5431. * @param {?} ast
  5432. * @param {?} context
  5433. * @return {?}
  5434. */
  5435. function (ast, context) { return this.visitAll(ast.values, context); };
  5436. /**
  5437. * @param {?} ast
  5438. * @param {?} context
  5439. * @return {?}
  5440. */
  5441. RecursiveAstVisitor.prototype.visitLiteralPrimitive = /**
  5442. * @param {?} ast
  5443. * @param {?} context
  5444. * @return {?}
  5445. */
  5446. function (ast, context) { return null; };
  5447. /**
  5448. * @param {?} ast
  5449. * @param {?} context
  5450. * @return {?}
  5451. */
  5452. RecursiveAstVisitor.prototype.visitMethodCall = /**
  5453. * @param {?} ast
  5454. * @param {?} context
  5455. * @return {?}
  5456. */
  5457. function (ast, context) {
  5458. ast.receiver.visit(this);
  5459. return this.visitAll(ast.args, context);
  5460. };
  5461. /**
  5462. * @param {?} ast
  5463. * @param {?} context
  5464. * @return {?}
  5465. */
  5466. RecursiveAstVisitor.prototype.visitPrefixNot = /**
  5467. * @param {?} ast
  5468. * @param {?} context
  5469. * @return {?}
  5470. */
  5471. function (ast, context) {
  5472. ast.expression.visit(this);
  5473. return null;
  5474. };
  5475. /**
  5476. * @param {?} ast
  5477. * @param {?} context
  5478. * @return {?}
  5479. */
  5480. RecursiveAstVisitor.prototype.visitNonNullAssert = /**
  5481. * @param {?} ast
  5482. * @param {?} context
  5483. * @return {?}
  5484. */
  5485. function (ast, context) {
  5486. ast.expression.visit(this);
  5487. return null;
  5488. };
  5489. /**
  5490. * @param {?} ast
  5491. * @param {?} context
  5492. * @return {?}
  5493. */
  5494. RecursiveAstVisitor.prototype.visitPropertyRead = /**
  5495. * @param {?} ast
  5496. * @param {?} context
  5497. * @return {?}
  5498. */
  5499. function (ast, context) {
  5500. ast.receiver.visit(this);
  5501. return null;
  5502. };
  5503. /**
  5504. * @param {?} ast
  5505. * @param {?} context
  5506. * @return {?}
  5507. */
  5508. RecursiveAstVisitor.prototype.visitPropertyWrite = /**
  5509. * @param {?} ast
  5510. * @param {?} context
  5511. * @return {?}
  5512. */
  5513. function (ast, context) {
  5514. ast.receiver.visit(this);
  5515. ast.value.visit(this);
  5516. return null;
  5517. };
  5518. /**
  5519. * @param {?} ast
  5520. * @param {?} context
  5521. * @return {?}
  5522. */
  5523. RecursiveAstVisitor.prototype.visitSafePropertyRead = /**
  5524. * @param {?} ast
  5525. * @param {?} context
  5526. * @return {?}
  5527. */
  5528. function (ast, context) {
  5529. ast.receiver.visit(this);
  5530. return null;
  5531. };
  5532. /**
  5533. * @param {?} ast
  5534. * @param {?} context
  5535. * @return {?}
  5536. */
  5537. RecursiveAstVisitor.prototype.visitSafeMethodCall = /**
  5538. * @param {?} ast
  5539. * @param {?} context
  5540. * @return {?}
  5541. */
  5542. function (ast, context) {
  5543. ast.receiver.visit(this);
  5544. return this.visitAll(ast.args, context);
  5545. };
  5546. /**
  5547. * @param {?} asts
  5548. * @param {?} context
  5549. * @return {?}
  5550. */
  5551. RecursiveAstVisitor.prototype.visitAll = /**
  5552. * @param {?} asts
  5553. * @param {?} context
  5554. * @return {?}
  5555. */
  5556. function (asts, context) {
  5557. var _this = this;
  5558. asts.forEach(function (ast) { return ast.visit(_this, context); });
  5559. return null;
  5560. };
  5561. /**
  5562. * @param {?} ast
  5563. * @param {?} context
  5564. * @return {?}
  5565. */
  5566. RecursiveAstVisitor.prototype.visitQuote = /**
  5567. * @param {?} ast
  5568. * @param {?} context
  5569. * @return {?}
  5570. */
  5571. function (ast, context) { return null; };
  5572. return RecursiveAstVisitor;
  5573. }());
  5574. var AstTransformer = /** @class */ (function () {
  5575. function AstTransformer() {
  5576. }
  5577. /**
  5578. * @param {?} ast
  5579. * @param {?} context
  5580. * @return {?}
  5581. */
  5582. AstTransformer.prototype.visitImplicitReceiver = /**
  5583. * @param {?} ast
  5584. * @param {?} context
  5585. * @return {?}
  5586. */
  5587. function (ast, context) { return ast; };
  5588. /**
  5589. * @param {?} ast
  5590. * @param {?} context
  5591. * @return {?}
  5592. */
  5593. AstTransformer.prototype.visitInterpolation = /**
  5594. * @param {?} ast
  5595. * @param {?} context
  5596. * @return {?}
  5597. */
  5598. function (ast, context) {
  5599. return new Interpolation(ast.span, ast.strings, this.visitAll(ast.expressions));
  5600. };
  5601. /**
  5602. * @param {?} ast
  5603. * @param {?} context
  5604. * @return {?}
  5605. */
  5606. AstTransformer.prototype.visitLiteralPrimitive = /**
  5607. * @param {?} ast
  5608. * @param {?} context
  5609. * @return {?}
  5610. */
  5611. function (ast, context) {
  5612. return new LiteralPrimitive(ast.span, ast.value);
  5613. };
  5614. /**
  5615. * @param {?} ast
  5616. * @param {?} context
  5617. * @return {?}
  5618. */
  5619. AstTransformer.prototype.visitPropertyRead = /**
  5620. * @param {?} ast
  5621. * @param {?} context
  5622. * @return {?}
  5623. */
  5624. function (ast, context) {
  5625. return new PropertyRead(ast.span, ast.receiver.visit(this), ast.name);
  5626. };
  5627. /**
  5628. * @param {?} ast
  5629. * @param {?} context
  5630. * @return {?}
  5631. */
  5632. AstTransformer.prototype.visitPropertyWrite = /**
  5633. * @param {?} ast
  5634. * @param {?} context
  5635. * @return {?}
  5636. */
  5637. function (ast, context) {
  5638. return new PropertyWrite(ast.span, ast.receiver.visit(this), ast.name, ast.value.visit(this));
  5639. };
  5640. /**
  5641. * @param {?} ast
  5642. * @param {?} context
  5643. * @return {?}
  5644. */
  5645. AstTransformer.prototype.visitSafePropertyRead = /**
  5646. * @param {?} ast
  5647. * @param {?} context
  5648. * @return {?}
  5649. */
  5650. function (ast, context) {
  5651. return new SafePropertyRead(ast.span, ast.receiver.visit(this), ast.name);
  5652. };
  5653. /**
  5654. * @param {?} ast
  5655. * @param {?} context
  5656. * @return {?}
  5657. */
  5658. AstTransformer.prototype.visitMethodCall = /**
  5659. * @param {?} ast
  5660. * @param {?} context
  5661. * @return {?}
  5662. */
  5663. function (ast, context) {
  5664. return new MethodCall(ast.span, ast.receiver.visit(this), ast.name, this.visitAll(ast.args));
  5665. };
  5666. /**
  5667. * @param {?} ast
  5668. * @param {?} context
  5669. * @return {?}
  5670. */
  5671. AstTransformer.prototype.visitSafeMethodCall = /**
  5672. * @param {?} ast
  5673. * @param {?} context
  5674. * @return {?}
  5675. */
  5676. function (ast, context) {
  5677. return new SafeMethodCall(ast.span, ast.receiver.visit(this), ast.name, this.visitAll(ast.args));
  5678. };
  5679. /**
  5680. * @param {?} ast
  5681. * @param {?} context
  5682. * @return {?}
  5683. */
  5684. AstTransformer.prototype.visitFunctionCall = /**
  5685. * @param {?} ast
  5686. * @param {?} context
  5687. * @return {?}
  5688. */
  5689. function (ast, context) {
  5690. return new FunctionCall(ast.span, /** @type {?} */ ((ast.target)).visit(this), this.visitAll(ast.args));
  5691. };
  5692. /**
  5693. * @param {?} ast
  5694. * @param {?} context
  5695. * @return {?}
  5696. */
  5697. AstTransformer.prototype.visitLiteralArray = /**
  5698. * @param {?} ast
  5699. * @param {?} context
  5700. * @return {?}
  5701. */
  5702. function (ast, context) {
  5703. return new LiteralArray(ast.span, this.visitAll(ast.expressions));
  5704. };
  5705. /**
  5706. * @param {?} ast
  5707. * @param {?} context
  5708. * @return {?}
  5709. */
  5710. AstTransformer.prototype.visitLiteralMap = /**
  5711. * @param {?} ast
  5712. * @param {?} context
  5713. * @return {?}
  5714. */
  5715. function (ast, context) {
  5716. return new LiteralMap(ast.span, ast.keys, this.visitAll(ast.values));
  5717. };
  5718. /**
  5719. * @param {?} ast
  5720. * @param {?} context
  5721. * @return {?}
  5722. */
  5723. AstTransformer.prototype.visitBinary = /**
  5724. * @param {?} ast
  5725. * @param {?} context
  5726. * @return {?}
  5727. */
  5728. function (ast, context) {
  5729. return new Binary(ast.span, ast.operation, ast.left.visit(this), ast.right.visit(this));
  5730. };
  5731. /**
  5732. * @param {?} ast
  5733. * @param {?} context
  5734. * @return {?}
  5735. */
  5736. AstTransformer.prototype.visitPrefixNot = /**
  5737. * @param {?} ast
  5738. * @param {?} context
  5739. * @return {?}
  5740. */
  5741. function (ast, context) {
  5742. return new PrefixNot(ast.span, ast.expression.visit(this));
  5743. };
  5744. /**
  5745. * @param {?} ast
  5746. * @param {?} context
  5747. * @return {?}
  5748. */
  5749. AstTransformer.prototype.visitNonNullAssert = /**
  5750. * @param {?} ast
  5751. * @param {?} context
  5752. * @return {?}
  5753. */
  5754. function (ast, context) {
  5755. return new NonNullAssert(ast.span, ast.expression.visit(this));
  5756. };
  5757. /**
  5758. * @param {?} ast
  5759. * @param {?} context
  5760. * @return {?}
  5761. */
  5762. AstTransformer.prototype.visitConditional = /**
  5763. * @param {?} ast
  5764. * @param {?} context
  5765. * @return {?}
  5766. */
  5767. function (ast, context) {
  5768. return new Conditional(ast.span, ast.condition.visit(this), ast.trueExp.visit(this), ast.falseExp.visit(this));
  5769. };
  5770. /**
  5771. * @param {?} ast
  5772. * @param {?} context
  5773. * @return {?}
  5774. */
  5775. AstTransformer.prototype.visitPipe = /**
  5776. * @param {?} ast
  5777. * @param {?} context
  5778. * @return {?}
  5779. */
  5780. function (ast, context) {
  5781. return new BindingPipe(ast.span, ast.exp.visit(this), ast.name, this.visitAll(ast.args));
  5782. };
  5783. /**
  5784. * @param {?} ast
  5785. * @param {?} context
  5786. * @return {?}
  5787. */
  5788. AstTransformer.prototype.visitKeyedRead = /**
  5789. * @param {?} ast
  5790. * @param {?} context
  5791. * @return {?}
  5792. */
  5793. function (ast, context) {
  5794. return new KeyedRead(ast.span, ast.obj.visit(this), ast.key.visit(this));
  5795. };
  5796. /**
  5797. * @param {?} ast
  5798. * @param {?} context
  5799. * @return {?}
  5800. */
  5801. AstTransformer.prototype.visitKeyedWrite = /**
  5802. * @param {?} ast
  5803. * @param {?} context
  5804. * @return {?}
  5805. */
  5806. function (ast, context) {
  5807. return new KeyedWrite(ast.span, ast.obj.visit(this), ast.key.visit(this), ast.value.visit(this));
  5808. };
  5809. /**
  5810. * @param {?} asts
  5811. * @return {?}
  5812. */
  5813. AstTransformer.prototype.visitAll = /**
  5814. * @param {?} asts
  5815. * @return {?}
  5816. */
  5817. function (asts) {
  5818. var /** @type {?} */ res = new Array(asts.length);
  5819. for (var /** @type {?} */ i = 0; i < asts.length; ++i) {
  5820. res[i] = asts[i].visit(this);
  5821. }
  5822. return res;
  5823. };
  5824. /**
  5825. * @param {?} ast
  5826. * @param {?} context
  5827. * @return {?}
  5828. */
  5829. AstTransformer.prototype.visitChain = /**
  5830. * @param {?} ast
  5831. * @param {?} context
  5832. * @return {?}
  5833. */
  5834. function (ast, context) {
  5835. return new Chain(ast.span, this.visitAll(ast.expressions));
  5836. };
  5837. /**
  5838. * @param {?} ast
  5839. * @param {?} context
  5840. * @return {?}
  5841. */
  5842. AstTransformer.prototype.visitQuote = /**
  5843. * @param {?} ast
  5844. * @param {?} context
  5845. * @return {?}
  5846. */
  5847. function (ast, context) {
  5848. return new Quote(ast.span, ast.prefix, ast.uninterpretedExpression, ast.location);
  5849. };
  5850. return AstTransformer;
  5851. }());
  5852. /**
  5853. * @param {?} ast
  5854. * @param {?} visitor
  5855. * @param {?=} context
  5856. * @return {?}
  5857. */
  5858. function visitAstChildren(ast, visitor, context) {
  5859. /**
  5860. * @param {?} ast
  5861. * @return {?}
  5862. */
  5863. function visit(ast) {
  5864. visitor.visit && visitor.visit(ast, context) || ast.visit(visitor, context);
  5865. }
  5866. /**
  5867. * @template T
  5868. * @param {?} asts
  5869. * @return {?}
  5870. */
  5871. function visitAll(asts) { asts.forEach(visit); }
  5872. ast.visit({
  5873. visitBinary: /**
  5874. * @param {?} ast
  5875. * @return {?}
  5876. */
  5877. function (ast) {
  5878. visit(ast.left);
  5879. visit(ast.right);
  5880. },
  5881. visitChain: /**
  5882. * @param {?} ast
  5883. * @return {?}
  5884. */
  5885. function (ast) { visitAll(ast.expressions); },
  5886. visitConditional: /**
  5887. * @param {?} ast
  5888. * @return {?}
  5889. */
  5890. function (ast) {
  5891. visit(ast.condition);
  5892. visit(ast.trueExp);
  5893. visit(ast.falseExp);
  5894. },
  5895. visitFunctionCall: /**
  5896. * @param {?} ast
  5897. * @return {?}
  5898. */
  5899. function (ast) {
  5900. if (ast.target) {
  5901. visit(ast.target);
  5902. }
  5903. visitAll(ast.args);
  5904. },
  5905. visitImplicitReceiver: /**
  5906. * @param {?} ast
  5907. * @return {?}
  5908. */
  5909. function (ast) { },
  5910. visitInterpolation: /**
  5911. * @param {?} ast
  5912. * @return {?}
  5913. */
  5914. function (ast) { visitAll(ast.expressions); },
  5915. visitKeyedRead: /**
  5916. * @param {?} ast
  5917. * @return {?}
  5918. */
  5919. function (ast) {
  5920. visit(ast.obj);
  5921. visit(ast.key);
  5922. },
  5923. visitKeyedWrite: /**
  5924. * @param {?} ast
  5925. * @return {?}
  5926. */
  5927. function (ast) {
  5928. visit(ast.obj);
  5929. visit(ast.key);
  5930. visit(ast.obj);
  5931. },
  5932. visitLiteralArray: /**
  5933. * @param {?} ast
  5934. * @return {?}
  5935. */
  5936. function (ast) { visitAll(ast.expressions); },
  5937. visitLiteralMap: /**
  5938. * @param {?} ast
  5939. * @return {?}
  5940. */
  5941. function (ast) { },
  5942. visitLiteralPrimitive: /**
  5943. * @param {?} ast
  5944. * @return {?}
  5945. */
  5946. function (ast) { },
  5947. visitMethodCall: /**
  5948. * @param {?} ast
  5949. * @return {?}
  5950. */
  5951. function (ast) {
  5952. visit(ast.receiver);
  5953. visitAll(ast.args);
  5954. },
  5955. visitPipe: /**
  5956. * @param {?} ast
  5957. * @return {?}
  5958. */
  5959. function (ast) {
  5960. visit(ast.exp);
  5961. visitAll(ast.args);
  5962. },
  5963. visitPrefixNot: /**
  5964. * @param {?} ast
  5965. * @return {?}
  5966. */
  5967. function (ast) { visit(ast.expression); },
  5968. visitNonNullAssert: /**
  5969. * @param {?} ast
  5970. * @return {?}
  5971. */
  5972. function (ast) { visit(ast.expression); },
  5973. visitPropertyRead: /**
  5974. * @param {?} ast
  5975. * @return {?}
  5976. */
  5977. function (ast) { visit(ast.receiver); },
  5978. visitPropertyWrite: /**
  5979. * @param {?} ast
  5980. * @return {?}
  5981. */
  5982. function (ast) {
  5983. visit(ast.receiver);
  5984. visit(ast.value);
  5985. },
  5986. visitQuote: /**
  5987. * @param {?} ast
  5988. * @return {?}
  5989. */
  5990. function (ast) { },
  5991. visitSafeMethodCall: /**
  5992. * @param {?} ast
  5993. * @return {?}
  5994. */
  5995. function (ast) {
  5996. visit(ast.receiver);
  5997. visitAll(ast.args);
  5998. },
  5999. visitSafePropertyRead: /**
  6000. * @param {?} ast
  6001. * @return {?}
  6002. */
  6003. function (ast) { visit(ast.receiver); },
  6004. });
  6005. }
  6006. /**
  6007. * @fileoverview added by tsickle
  6008. * @suppress {checkTypes} checked by tsc
  6009. */
  6010. /**
  6011. * @license
  6012. * Copyright Google Inc. All Rights Reserved.
  6013. *
  6014. * Use of this source code is governed by an MIT-style license that can be
  6015. * found in the LICENSE file at https://angular.io/license
  6016. */
  6017. var SplitInterpolation = /** @class */ (function () {
  6018. function SplitInterpolation(strings, expressions, offsets) {
  6019. this.strings = strings;
  6020. this.expressions = expressions;
  6021. this.offsets = offsets;
  6022. }
  6023. return SplitInterpolation;
  6024. }());
  6025. var TemplateBindingParseResult = /** @class */ (function () {
  6026. function TemplateBindingParseResult(templateBindings, warnings, errors) {
  6027. this.templateBindings = templateBindings;
  6028. this.warnings = warnings;
  6029. this.errors = errors;
  6030. }
  6031. return TemplateBindingParseResult;
  6032. }());
  6033. /**
  6034. * @param {?} config
  6035. * @return {?}
  6036. */
  6037. function _createInterpolateRegExp(config) {
  6038. var /** @type {?} */ pattern = escapeRegExp(config.start) + '([\\s\\S]*?)' + escapeRegExp(config.end);
  6039. return new RegExp(pattern, 'g');
  6040. }
  6041. var Parser = /** @class */ (function () {
  6042. function Parser(_lexer) {
  6043. this._lexer = _lexer;
  6044. this.errors = [];
  6045. }
  6046. /**
  6047. * @param {?} input
  6048. * @param {?} location
  6049. * @param {?=} interpolationConfig
  6050. * @return {?}
  6051. */
  6052. Parser.prototype.parseAction = /**
  6053. * @param {?} input
  6054. * @param {?} location
  6055. * @param {?=} interpolationConfig
  6056. * @return {?}
  6057. */
  6058. function (input, location, interpolationConfig) {
  6059. if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
  6060. this._checkNoInterpolation(input, location, interpolationConfig);
  6061. var /** @type {?} */ sourceToLex = this._stripComments(input);
  6062. var /** @type {?} */ tokens = this._lexer.tokenize(this._stripComments(input));
  6063. var /** @type {?} */ ast = new _ParseAST(input, location, tokens, sourceToLex.length, true, this.errors, input.length - sourceToLex.length)
  6064. .parseChain();
  6065. return new ASTWithSource(ast, input, location, this.errors);
  6066. };
  6067. /**
  6068. * @param {?} input
  6069. * @param {?} location
  6070. * @param {?=} interpolationConfig
  6071. * @return {?}
  6072. */
  6073. Parser.prototype.parseBinding = /**
  6074. * @param {?} input
  6075. * @param {?} location
  6076. * @param {?=} interpolationConfig
  6077. * @return {?}
  6078. */
  6079. function (input, location, interpolationConfig) {
  6080. if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
  6081. var /** @type {?} */ ast = this._parseBindingAst(input, location, interpolationConfig);
  6082. return new ASTWithSource(ast, input, location, this.errors);
  6083. };
  6084. /**
  6085. * @param {?} input
  6086. * @param {?} location
  6087. * @param {?=} interpolationConfig
  6088. * @return {?}
  6089. */
  6090. Parser.prototype.parseSimpleBinding = /**
  6091. * @param {?} input
  6092. * @param {?} location
  6093. * @param {?=} interpolationConfig
  6094. * @return {?}
  6095. */
  6096. function (input, location, interpolationConfig) {
  6097. if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
  6098. var /** @type {?} */ ast = this._parseBindingAst(input, location, interpolationConfig);
  6099. var /** @type {?} */ errors = SimpleExpressionChecker.check(ast);
  6100. if (errors.length > 0) {
  6101. this._reportError("Host binding expression cannot contain " + errors.join(' '), input, location);
  6102. }
  6103. return new ASTWithSource(ast, input, location, this.errors);
  6104. };
  6105. /**
  6106. * @param {?} message
  6107. * @param {?} input
  6108. * @param {?} errLocation
  6109. * @param {?=} ctxLocation
  6110. * @return {?}
  6111. */
  6112. Parser.prototype._reportError = /**
  6113. * @param {?} message
  6114. * @param {?} input
  6115. * @param {?} errLocation
  6116. * @param {?=} ctxLocation
  6117. * @return {?}
  6118. */
  6119. function (message, input, errLocation, ctxLocation) {
  6120. this.errors.push(new ParserError(message, input, errLocation, ctxLocation));
  6121. };
  6122. /**
  6123. * @param {?} input
  6124. * @param {?} location
  6125. * @param {?} interpolationConfig
  6126. * @return {?}
  6127. */
  6128. Parser.prototype._parseBindingAst = /**
  6129. * @param {?} input
  6130. * @param {?} location
  6131. * @param {?} interpolationConfig
  6132. * @return {?}
  6133. */
  6134. function (input, location, interpolationConfig) {
  6135. // Quotes expressions use 3rd-party expression language. We don't want to use
  6136. // our lexer or parser for that, so we check for that ahead of time.
  6137. var /** @type {?} */ quote = this._parseQuote(input, location);
  6138. if (quote != null) {
  6139. return quote;
  6140. }
  6141. this._checkNoInterpolation(input, location, interpolationConfig);
  6142. var /** @type {?} */ sourceToLex = this._stripComments(input);
  6143. var /** @type {?} */ tokens = this._lexer.tokenize(sourceToLex);
  6144. return new _ParseAST(input, location, tokens, sourceToLex.length, false, this.errors, input.length - sourceToLex.length)
  6145. .parseChain();
  6146. };
  6147. /**
  6148. * @param {?} input
  6149. * @param {?} location
  6150. * @return {?}
  6151. */
  6152. Parser.prototype._parseQuote = /**
  6153. * @param {?} input
  6154. * @param {?} location
  6155. * @return {?}
  6156. */
  6157. function (input, location) {
  6158. if (input == null)
  6159. return null;
  6160. var /** @type {?} */ prefixSeparatorIndex = input.indexOf(':');
  6161. if (prefixSeparatorIndex == -1)
  6162. return null;
  6163. var /** @type {?} */ prefix = input.substring(0, prefixSeparatorIndex).trim();
  6164. if (!isIdentifier(prefix))
  6165. return null;
  6166. var /** @type {?} */ uninterpretedExpression = input.substring(prefixSeparatorIndex + 1);
  6167. return new Quote(new ParseSpan(0, input.length), prefix, uninterpretedExpression, location);
  6168. };
  6169. /**
  6170. * @param {?} prefixToken
  6171. * @param {?} input
  6172. * @param {?} location
  6173. * @return {?}
  6174. */
  6175. Parser.prototype.parseTemplateBindings = /**
  6176. * @param {?} prefixToken
  6177. * @param {?} input
  6178. * @param {?} location
  6179. * @return {?}
  6180. */
  6181. function (prefixToken, input, location) {
  6182. var /** @type {?} */ tokens = this._lexer.tokenize(input);
  6183. if (prefixToken) {
  6184. // Prefix the tokens with the tokens from prefixToken but have them take no space (0 index).
  6185. var /** @type {?} */ prefixTokens = this._lexer.tokenize(prefixToken).map(function (t) {
  6186. t.index = 0;
  6187. return t;
  6188. });
  6189. tokens.unshift.apply(tokens, prefixTokens);
  6190. }
  6191. return new _ParseAST(input, location, tokens, input.length, false, this.errors, 0)
  6192. .parseTemplateBindings();
  6193. };
  6194. /**
  6195. * @param {?} input
  6196. * @param {?} location
  6197. * @param {?=} interpolationConfig
  6198. * @return {?}
  6199. */
  6200. Parser.prototype.parseInterpolation = /**
  6201. * @param {?} input
  6202. * @param {?} location
  6203. * @param {?=} interpolationConfig
  6204. * @return {?}
  6205. */
  6206. function (input, location, interpolationConfig) {
  6207. if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
  6208. var /** @type {?} */ split = this.splitInterpolation(input, location, interpolationConfig);
  6209. if (split == null)
  6210. return null;
  6211. var /** @type {?} */ expressions = [];
  6212. for (var /** @type {?} */ i = 0; i < split.expressions.length; ++i) {
  6213. var /** @type {?} */ expressionText = split.expressions[i];
  6214. var /** @type {?} */ sourceToLex = this._stripComments(expressionText);
  6215. var /** @type {?} */ tokens = this._lexer.tokenize(sourceToLex);
  6216. var /** @type {?} */ ast = new _ParseAST(input, location, tokens, sourceToLex.length, false, this.errors, split.offsets[i] + (expressionText.length - sourceToLex.length))
  6217. .parseChain();
  6218. expressions.push(ast);
  6219. }
  6220. return new ASTWithSource(new Interpolation(new ParseSpan(0, input == null ? 0 : input.length), split.strings, expressions), input, location, this.errors);
  6221. };
  6222. /**
  6223. * @param {?} input
  6224. * @param {?} location
  6225. * @param {?=} interpolationConfig
  6226. * @return {?}
  6227. */
  6228. Parser.prototype.splitInterpolation = /**
  6229. * @param {?} input
  6230. * @param {?} location
  6231. * @param {?=} interpolationConfig
  6232. * @return {?}
  6233. */
  6234. function (input, location, interpolationConfig) {
  6235. if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
  6236. var /** @type {?} */ regexp = _createInterpolateRegExp(interpolationConfig);
  6237. var /** @type {?} */ parts = input.split(regexp);
  6238. if (parts.length <= 1) {
  6239. return null;
  6240. }
  6241. var /** @type {?} */ strings = [];
  6242. var /** @type {?} */ expressions = [];
  6243. var /** @type {?} */ offsets = [];
  6244. var /** @type {?} */ offset = 0;
  6245. for (var /** @type {?} */ i = 0; i < parts.length; i++) {
  6246. var /** @type {?} */ part = parts[i];
  6247. if (i % 2 === 0) {
  6248. // fixed string
  6249. strings.push(part);
  6250. offset += part.length;
  6251. }
  6252. else if (part.trim().length > 0) {
  6253. offset += interpolationConfig.start.length;
  6254. expressions.push(part);
  6255. offsets.push(offset);
  6256. offset += part.length + interpolationConfig.end.length;
  6257. }
  6258. else {
  6259. this._reportError('Blank expressions are not allowed in interpolated strings', input, "at column " + this._findInterpolationErrorColumn(parts, i, interpolationConfig) + " in", location);
  6260. expressions.push('$implict');
  6261. offsets.push(offset);
  6262. }
  6263. }
  6264. return new SplitInterpolation(strings, expressions, offsets);
  6265. };
  6266. /**
  6267. * @param {?} input
  6268. * @param {?} location
  6269. * @return {?}
  6270. */
  6271. Parser.prototype.wrapLiteralPrimitive = /**
  6272. * @param {?} input
  6273. * @param {?} location
  6274. * @return {?}
  6275. */
  6276. function (input, location) {
  6277. return new ASTWithSource(new LiteralPrimitive(new ParseSpan(0, input == null ? 0 : input.length), input), input, location, this.errors);
  6278. };
  6279. /**
  6280. * @param {?} input
  6281. * @return {?}
  6282. */
  6283. Parser.prototype._stripComments = /**
  6284. * @param {?} input
  6285. * @return {?}
  6286. */
  6287. function (input) {
  6288. var /** @type {?} */ i = this._commentStart(input);
  6289. return i != null ? input.substring(0, i).trim() : input;
  6290. };
  6291. /**
  6292. * @param {?} input
  6293. * @return {?}
  6294. */
  6295. Parser.prototype._commentStart = /**
  6296. * @param {?} input
  6297. * @return {?}
  6298. */
  6299. function (input) {
  6300. var /** @type {?} */ outerQuote = null;
  6301. for (var /** @type {?} */ i = 0; i < input.length - 1; i++) {
  6302. var /** @type {?} */ char = input.charCodeAt(i);
  6303. var /** @type {?} */ nextChar = input.charCodeAt(i + 1);
  6304. if (char === $SLASH && nextChar == $SLASH && outerQuote == null)
  6305. return i;
  6306. if (outerQuote === char) {
  6307. outerQuote = null;
  6308. }
  6309. else if (outerQuote == null && isQuote(char)) {
  6310. outerQuote = char;
  6311. }
  6312. }
  6313. return null;
  6314. };
  6315. /**
  6316. * @param {?} input
  6317. * @param {?} location
  6318. * @param {?} interpolationConfig
  6319. * @return {?}
  6320. */
  6321. Parser.prototype._checkNoInterpolation = /**
  6322. * @param {?} input
  6323. * @param {?} location
  6324. * @param {?} interpolationConfig
  6325. * @return {?}
  6326. */
  6327. function (input, location, interpolationConfig) {
  6328. var /** @type {?} */ regexp = _createInterpolateRegExp(interpolationConfig);
  6329. var /** @type {?} */ parts = input.split(regexp);
  6330. if (parts.length > 1) {
  6331. this._reportError("Got interpolation (" + interpolationConfig.start + interpolationConfig.end + ") where expression was expected", input, "at column " + this._findInterpolationErrorColumn(parts, 1, interpolationConfig) + " in", location);
  6332. }
  6333. };
  6334. /**
  6335. * @param {?} parts
  6336. * @param {?} partInErrIdx
  6337. * @param {?} interpolationConfig
  6338. * @return {?}
  6339. */
  6340. Parser.prototype._findInterpolationErrorColumn = /**
  6341. * @param {?} parts
  6342. * @param {?} partInErrIdx
  6343. * @param {?} interpolationConfig
  6344. * @return {?}
  6345. */
  6346. function (parts, partInErrIdx, interpolationConfig) {
  6347. var /** @type {?} */ errLocation = '';
  6348. for (var /** @type {?} */ j = 0; j < partInErrIdx; j++) {
  6349. errLocation += j % 2 === 0 ?
  6350. parts[j] :
  6351. "" + interpolationConfig.start + parts[j] + interpolationConfig.end;
  6352. }
  6353. return errLocation.length;
  6354. };
  6355. return Parser;
  6356. }());
  6357. var _ParseAST = /** @class */ (function () {
  6358. function _ParseAST(input, location, tokens, inputLength, parseAction, errors, offset) {
  6359. this.input = input;
  6360. this.location = location;
  6361. this.tokens = tokens;
  6362. this.inputLength = inputLength;
  6363. this.parseAction = parseAction;
  6364. this.errors = errors;
  6365. this.offset = offset;
  6366. this.rparensExpected = 0;
  6367. this.rbracketsExpected = 0;
  6368. this.rbracesExpected = 0;
  6369. this.index = 0;
  6370. }
  6371. /**
  6372. * @param {?} offset
  6373. * @return {?}
  6374. */
  6375. _ParseAST.prototype.peek = /**
  6376. * @param {?} offset
  6377. * @return {?}
  6378. */
  6379. function (offset) {
  6380. var /** @type {?} */ i = this.index + offset;
  6381. return i < this.tokens.length ? this.tokens[i] : EOF;
  6382. };
  6383. Object.defineProperty(_ParseAST.prototype, "next", {
  6384. get: /**
  6385. * @return {?}
  6386. */
  6387. function () { return this.peek(0); },
  6388. enumerable: true,
  6389. configurable: true
  6390. });
  6391. Object.defineProperty(_ParseAST.prototype, "inputIndex", {
  6392. get: /**
  6393. * @return {?}
  6394. */
  6395. function () {
  6396. return (this.index < this.tokens.length) ? this.next.index + this.offset :
  6397. this.inputLength + this.offset;
  6398. },
  6399. enumerable: true,
  6400. configurable: true
  6401. });
  6402. /**
  6403. * @param {?} start
  6404. * @return {?}
  6405. */
  6406. _ParseAST.prototype.span = /**
  6407. * @param {?} start
  6408. * @return {?}
  6409. */
  6410. function (start) { return new ParseSpan(start, this.inputIndex); };
  6411. /**
  6412. * @return {?}
  6413. */
  6414. _ParseAST.prototype.advance = /**
  6415. * @return {?}
  6416. */
  6417. function () { this.index++; };
  6418. /**
  6419. * @param {?} code
  6420. * @return {?}
  6421. */
  6422. _ParseAST.prototype.optionalCharacter = /**
  6423. * @param {?} code
  6424. * @return {?}
  6425. */
  6426. function (code) {
  6427. if (this.next.isCharacter(code)) {
  6428. this.advance();
  6429. return true;
  6430. }
  6431. else {
  6432. return false;
  6433. }
  6434. };
  6435. /**
  6436. * @return {?}
  6437. */
  6438. _ParseAST.prototype.peekKeywordLet = /**
  6439. * @return {?}
  6440. */
  6441. function () { return this.next.isKeywordLet(); };
  6442. /**
  6443. * @return {?}
  6444. */
  6445. _ParseAST.prototype.peekKeywordAs = /**
  6446. * @return {?}
  6447. */
  6448. function () { return this.next.isKeywordAs(); };
  6449. /**
  6450. * @param {?} code
  6451. * @return {?}
  6452. */
  6453. _ParseAST.prototype.expectCharacter = /**
  6454. * @param {?} code
  6455. * @return {?}
  6456. */
  6457. function (code) {
  6458. if (this.optionalCharacter(code))
  6459. return;
  6460. this.error("Missing expected " + String.fromCharCode(code));
  6461. };
  6462. /**
  6463. * @param {?} op
  6464. * @return {?}
  6465. */
  6466. _ParseAST.prototype.optionalOperator = /**
  6467. * @param {?} op
  6468. * @return {?}
  6469. */
  6470. function (op) {
  6471. if (this.next.isOperator(op)) {
  6472. this.advance();
  6473. return true;
  6474. }
  6475. else {
  6476. return false;
  6477. }
  6478. };
  6479. /**
  6480. * @param {?} operator
  6481. * @return {?}
  6482. */
  6483. _ParseAST.prototype.expectOperator = /**
  6484. * @param {?} operator
  6485. * @return {?}
  6486. */
  6487. function (operator) {
  6488. if (this.optionalOperator(operator))
  6489. return;
  6490. this.error("Missing expected operator " + operator);
  6491. };
  6492. /**
  6493. * @return {?}
  6494. */
  6495. _ParseAST.prototype.expectIdentifierOrKeyword = /**
  6496. * @return {?}
  6497. */
  6498. function () {
  6499. var /** @type {?} */ n = this.next;
  6500. if (!n.isIdentifier() && !n.isKeyword()) {
  6501. this.error("Unexpected token " + n + ", expected identifier or keyword");
  6502. return '';
  6503. }
  6504. this.advance();
  6505. return /** @type {?} */ (n.toString());
  6506. };
  6507. /**
  6508. * @return {?}
  6509. */
  6510. _ParseAST.prototype.expectIdentifierOrKeywordOrString = /**
  6511. * @return {?}
  6512. */
  6513. function () {
  6514. var /** @type {?} */ n = this.next;
  6515. if (!n.isIdentifier() && !n.isKeyword() && !n.isString()) {
  6516. this.error("Unexpected token " + n + ", expected identifier, keyword, or string");
  6517. return '';
  6518. }
  6519. this.advance();
  6520. return /** @type {?} */ (n.toString());
  6521. };
  6522. /**
  6523. * @return {?}
  6524. */
  6525. _ParseAST.prototype.parseChain = /**
  6526. * @return {?}
  6527. */
  6528. function () {
  6529. var /** @type {?} */ exprs = [];
  6530. var /** @type {?} */ start = this.inputIndex;
  6531. while (this.index < this.tokens.length) {
  6532. var /** @type {?} */ expr = this.parsePipe();
  6533. exprs.push(expr);
  6534. if (this.optionalCharacter($SEMICOLON)) {
  6535. if (!this.parseAction) {
  6536. this.error('Binding expression cannot contain chained expression');
  6537. }
  6538. while (this.optionalCharacter($SEMICOLON)) {
  6539. } // read all semicolons
  6540. }
  6541. else if (this.index < this.tokens.length) {
  6542. this.error("Unexpected token '" + this.next + "'");
  6543. }
  6544. }
  6545. if (exprs.length == 0)
  6546. return new EmptyExpr(this.span(start));
  6547. if (exprs.length == 1)
  6548. return exprs[0];
  6549. return new Chain(this.span(start), exprs);
  6550. };
  6551. /**
  6552. * @return {?}
  6553. */
  6554. _ParseAST.prototype.parsePipe = /**
  6555. * @return {?}
  6556. */
  6557. function () {
  6558. var /** @type {?} */ result = this.parseExpression();
  6559. if (this.optionalOperator('|')) {
  6560. if (this.parseAction) {
  6561. this.error('Cannot have a pipe in an action expression');
  6562. }
  6563. do {
  6564. var /** @type {?} */ name_1 = this.expectIdentifierOrKeyword();
  6565. var /** @type {?} */ args = [];
  6566. while (this.optionalCharacter($COLON)) {
  6567. args.push(this.parseExpression());
  6568. }
  6569. result = new BindingPipe(this.span(result.span.start), result, name_1, args);
  6570. } while (this.optionalOperator('|'));
  6571. }
  6572. return result;
  6573. };
  6574. /**
  6575. * @return {?}
  6576. */
  6577. _ParseAST.prototype.parseExpression = /**
  6578. * @return {?}
  6579. */
  6580. function () { return this.parseConditional(); };
  6581. /**
  6582. * @return {?}
  6583. */
  6584. _ParseAST.prototype.parseConditional = /**
  6585. * @return {?}
  6586. */
  6587. function () {
  6588. var /** @type {?} */ start = this.inputIndex;
  6589. var /** @type {?} */ result = this.parseLogicalOr();
  6590. if (this.optionalOperator('?')) {
  6591. var /** @type {?} */ yes = this.parsePipe();
  6592. var /** @type {?} */ no = void 0;
  6593. if (!this.optionalCharacter($COLON)) {
  6594. var /** @type {?} */ end = this.inputIndex;
  6595. var /** @type {?} */ expression = this.input.substring(start, end);
  6596. this.error("Conditional expression " + expression + " requires all 3 expressions");
  6597. no = new EmptyExpr(this.span(start));
  6598. }
  6599. else {
  6600. no = this.parsePipe();
  6601. }
  6602. return new Conditional(this.span(start), result, yes, no);
  6603. }
  6604. else {
  6605. return result;
  6606. }
  6607. };
  6608. /**
  6609. * @return {?}
  6610. */
  6611. _ParseAST.prototype.parseLogicalOr = /**
  6612. * @return {?}
  6613. */
  6614. function () {
  6615. // '||'
  6616. var /** @type {?} */ result = this.parseLogicalAnd();
  6617. while (this.optionalOperator('||')) {
  6618. var /** @type {?} */ right = this.parseLogicalAnd();
  6619. result = new Binary(this.span(result.span.start), '||', result, right);
  6620. }
  6621. return result;
  6622. };
  6623. /**
  6624. * @return {?}
  6625. */
  6626. _ParseAST.prototype.parseLogicalAnd = /**
  6627. * @return {?}
  6628. */
  6629. function () {
  6630. // '&&'
  6631. var /** @type {?} */ result = this.parseEquality();
  6632. while (this.optionalOperator('&&')) {
  6633. var /** @type {?} */ right = this.parseEquality();
  6634. result = new Binary(this.span(result.span.start), '&&', result, right);
  6635. }
  6636. return result;
  6637. };
  6638. /**
  6639. * @return {?}
  6640. */
  6641. _ParseAST.prototype.parseEquality = /**
  6642. * @return {?}
  6643. */
  6644. function () {
  6645. // '==','!=','===','!=='
  6646. var /** @type {?} */ result = this.parseRelational();
  6647. while (this.next.type == TokenType.Operator) {
  6648. var /** @type {?} */ operator = this.next.strValue;
  6649. switch (operator) {
  6650. case '==':
  6651. case '===':
  6652. case '!=':
  6653. case '!==':
  6654. this.advance();
  6655. var /** @type {?} */ right = this.parseRelational();
  6656. result = new Binary(this.span(result.span.start), operator, result, right);
  6657. continue;
  6658. }
  6659. break;
  6660. }
  6661. return result;
  6662. };
  6663. /**
  6664. * @return {?}
  6665. */
  6666. _ParseAST.prototype.parseRelational = /**
  6667. * @return {?}
  6668. */
  6669. function () {
  6670. // '<', '>', '<=', '>='
  6671. var /** @type {?} */ result = this.parseAdditive();
  6672. while (this.next.type == TokenType.Operator) {
  6673. var /** @type {?} */ operator = this.next.strValue;
  6674. switch (operator) {
  6675. case '<':
  6676. case '>':
  6677. case '<=':
  6678. case '>=':
  6679. this.advance();
  6680. var /** @type {?} */ right = this.parseAdditive();
  6681. result = new Binary(this.span(result.span.start), operator, result, right);
  6682. continue;
  6683. }
  6684. break;
  6685. }
  6686. return result;
  6687. };
  6688. /**
  6689. * @return {?}
  6690. */
  6691. _ParseAST.prototype.parseAdditive = /**
  6692. * @return {?}
  6693. */
  6694. function () {
  6695. // '+', '-'
  6696. var /** @type {?} */ result = this.parseMultiplicative();
  6697. while (this.next.type == TokenType.Operator) {
  6698. var /** @type {?} */ operator = this.next.strValue;
  6699. switch (operator) {
  6700. case '+':
  6701. case '-':
  6702. this.advance();
  6703. var /** @type {?} */ right = this.parseMultiplicative();
  6704. result = new Binary(this.span(result.span.start), operator, result, right);
  6705. continue;
  6706. }
  6707. break;
  6708. }
  6709. return result;
  6710. };
  6711. /**
  6712. * @return {?}
  6713. */
  6714. _ParseAST.prototype.parseMultiplicative = /**
  6715. * @return {?}
  6716. */
  6717. function () {
  6718. // '*', '%', '/'
  6719. var /** @type {?} */ result = this.parsePrefix();
  6720. while (this.next.type == TokenType.Operator) {
  6721. var /** @type {?} */ operator = this.next.strValue;
  6722. switch (operator) {
  6723. case '*':
  6724. case '%':
  6725. case '/':
  6726. this.advance();
  6727. var /** @type {?} */ right = this.parsePrefix();
  6728. result = new Binary(this.span(result.span.start), operator, result, right);
  6729. continue;
  6730. }
  6731. break;
  6732. }
  6733. return result;
  6734. };
  6735. /**
  6736. * @return {?}
  6737. */
  6738. _ParseAST.prototype.parsePrefix = /**
  6739. * @return {?}
  6740. */
  6741. function () {
  6742. if (this.next.type == TokenType.Operator) {
  6743. var /** @type {?} */ start = this.inputIndex;
  6744. var /** @type {?} */ operator = this.next.strValue;
  6745. var /** @type {?} */ result = void 0;
  6746. switch (operator) {
  6747. case '+':
  6748. this.advance();
  6749. result = this.parsePrefix();
  6750. return new Binary(this.span(start), '-', result, new LiteralPrimitive(new ParseSpan(start, start), 0));
  6751. case '-':
  6752. this.advance();
  6753. result = this.parsePrefix();
  6754. return new Binary(this.span(start), operator, new LiteralPrimitive(new ParseSpan(start, start), 0), result);
  6755. case '!':
  6756. this.advance();
  6757. result = this.parsePrefix();
  6758. return new PrefixNot(this.span(start), result);
  6759. }
  6760. }
  6761. return this.parseCallChain();
  6762. };
  6763. /**
  6764. * @return {?}
  6765. */
  6766. _ParseAST.prototype.parseCallChain = /**
  6767. * @return {?}
  6768. */
  6769. function () {
  6770. var /** @type {?} */ result = this.parsePrimary();
  6771. while (true) {
  6772. if (this.optionalCharacter($PERIOD)) {
  6773. result = this.parseAccessMemberOrMethodCall(result, false);
  6774. }
  6775. else if (this.optionalOperator('?.')) {
  6776. result = this.parseAccessMemberOrMethodCall(result, true);
  6777. }
  6778. else if (this.optionalCharacter($LBRACKET)) {
  6779. this.rbracketsExpected++;
  6780. var /** @type {?} */ key = this.parsePipe();
  6781. this.rbracketsExpected--;
  6782. this.expectCharacter($RBRACKET);
  6783. if (this.optionalOperator('=')) {
  6784. var /** @type {?} */ value = this.parseConditional();
  6785. result = new KeyedWrite(this.span(result.span.start), result, key, value);
  6786. }
  6787. else {
  6788. result = new KeyedRead(this.span(result.span.start), result, key);
  6789. }
  6790. }
  6791. else if (this.optionalCharacter($LPAREN)) {
  6792. this.rparensExpected++;
  6793. var /** @type {?} */ args = this.parseCallArguments();
  6794. this.rparensExpected--;
  6795. this.expectCharacter($RPAREN);
  6796. result = new FunctionCall(this.span(result.span.start), result, args);
  6797. }
  6798. else if (this.optionalOperator('!')) {
  6799. result = new NonNullAssert(this.span(result.span.start), result);
  6800. }
  6801. else {
  6802. return result;
  6803. }
  6804. }
  6805. };
  6806. /**
  6807. * @return {?}
  6808. */
  6809. _ParseAST.prototype.parsePrimary = /**
  6810. * @return {?}
  6811. */
  6812. function () {
  6813. var /** @type {?} */ start = this.inputIndex;
  6814. if (this.optionalCharacter($LPAREN)) {
  6815. this.rparensExpected++;
  6816. var /** @type {?} */ result = this.parsePipe();
  6817. this.rparensExpected--;
  6818. this.expectCharacter($RPAREN);
  6819. return result;
  6820. }
  6821. else if (this.next.isKeywordNull()) {
  6822. this.advance();
  6823. return new LiteralPrimitive(this.span(start), null);
  6824. }
  6825. else if (this.next.isKeywordUndefined()) {
  6826. this.advance();
  6827. return new LiteralPrimitive(this.span(start), void 0);
  6828. }
  6829. else if (this.next.isKeywordTrue()) {
  6830. this.advance();
  6831. return new LiteralPrimitive(this.span(start), true);
  6832. }
  6833. else if (this.next.isKeywordFalse()) {
  6834. this.advance();
  6835. return new LiteralPrimitive(this.span(start), false);
  6836. }
  6837. else if (this.next.isKeywordThis()) {
  6838. this.advance();
  6839. return new ImplicitReceiver(this.span(start));
  6840. }
  6841. else if (this.optionalCharacter($LBRACKET)) {
  6842. this.rbracketsExpected++;
  6843. var /** @type {?} */ elements = this.parseExpressionList($RBRACKET);
  6844. this.rbracketsExpected--;
  6845. this.expectCharacter($RBRACKET);
  6846. return new LiteralArray(this.span(start), elements);
  6847. }
  6848. else if (this.next.isCharacter($LBRACE)) {
  6849. return this.parseLiteralMap();
  6850. }
  6851. else if (this.next.isIdentifier()) {
  6852. return this.parseAccessMemberOrMethodCall(new ImplicitReceiver(this.span(start)), false);
  6853. }
  6854. else if (this.next.isNumber()) {
  6855. var /** @type {?} */ value = this.next.toNumber();
  6856. this.advance();
  6857. return new LiteralPrimitive(this.span(start), value);
  6858. }
  6859. else if (this.next.isString()) {
  6860. var /** @type {?} */ literalValue = this.next.toString();
  6861. this.advance();
  6862. return new LiteralPrimitive(this.span(start), literalValue);
  6863. }
  6864. else if (this.index >= this.tokens.length) {
  6865. this.error("Unexpected end of expression: " + this.input);
  6866. return new EmptyExpr(this.span(start));
  6867. }
  6868. else {
  6869. this.error("Unexpected token " + this.next);
  6870. return new EmptyExpr(this.span(start));
  6871. }
  6872. };
  6873. /**
  6874. * @param {?} terminator
  6875. * @return {?}
  6876. */
  6877. _ParseAST.prototype.parseExpressionList = /**
  6878. * @param {?} terminator
  6879. * @return {?}
  6880. */
  6881. function (terminator) {
  6882. var /** @type {?} */ result = [];
  6883. if (!this.next.isCharacter(terminator)) {
  6884. do {
  6885. result.push(this.parsePipe());
  6886. } while (this.optionalCharacter($COMMA));
  6887. }
  6888. return result;
  6889. };
  6890. /**
  6891. * @return {?}
  6892. */
  6893. _ParseAST.prototype.parseLiteralMap = /**
  6894. * @return {?}
  6895. */
  6896. function () {
  6897. var /** @type {?} */ keys = [];
  6898. var /** @type {?} */ values = [];
  6899. var /** @type {?} */ start = this.inputIndex;
  6900. this.expectCharacter($LBRACE);
  6901. if (!this.optionalCharacter($RBRACE)) {
  6902. this.rbracesExpected++;
  6903. do {
  6904. var /** @type {?} */ quoted = this.next.isString();
  6905. var /** @type {?} */ key = this.expectIdentifierOrKeywordOrString();
  6906. keys.push({ key: key, quoted: quoted });
  6907. this.expectCharacter($COLON);
  6908. values.push(this.parsePipe());
  6909. } while (this.optionalCharacter($COMMA));
  6910. this.rbracesExpected--;
  6911. this.expectCharacter($RBRACE);
  6912. }
  6913. return new LiteralMap(this.span(start), keys, values);
  6914. };
  6915. /**
  6916. * @param {?} receiver
  6917. * @param {?=} isSafe
  6918. * @return {?}
  6919. */
  6920. _ParseAST.prototype.parseAccessMemberOrMethodCall = /**
  6921. * @param {?} receiver
  6922. * @param {?=} isSafe
  6923. * @return {?}
  6924. */
  6925. function (receiver, isSafe) {
  6926. if (isSafe === void 0) { isSafe = false; }
  6927. var /** @type {?} */ start = receiver.span.start;
  6928. var /** @type {?} */ id = this.expectIdentifierOrKeyword();
  6929. if (this.optionalCharacter($LPAREN)) {
  6930. this.rparensExpected++;
  6931. var /** @type {?} */ args = this.parseCallArguments();
  6932. this.expectCharacter($RPAREN);
  6933. this.rparensExpected--;
  6934. var /** @type {?} */ span = this.span(start);
  6935. return isSafe ? new SafeMethodCall(span, receiver, id, args) :
  6936. new MethodCall(span, receiver, id, args);
  6937. }
  6938. else {
  6939. if (isSafe) {
  6940. if (this.optionalOperator('=')) {
  6941. this.error('The \'?.\' operator cannot be used in the assignment');
  6942. return new EmptyExpr(this.span(start));
  6943. }
  6944. else {
  6945. return new SafePropertyRead(this.span(start), receiver, id);
  6946. }
  6947. }
  6948. else {
  6949. if (this.optionalOperator('=')) {
  6950. if (!this.parseAction) {
  6951. this.error('Bindings cannot contain assignments');
  6952. return new EmptyExpr(this.span(start));
  6953. }
  6954. var /** @type {?} */ value = this.parseConditional();
  6955. return new PropertyWrite(this.span(start), receiver, id, value);
  6956. }
  6957. else {
  6958. return new PropertyRead(this.span(start), receiver, id);
  6959. }
  6960. }
  6961. }
  6962. };
  6963. /**
  6964. * @return {?}
  6965. */
  6966. _ParseAST.prototype.parseCallArguments = /**
  6967. * @return {?}
  6968. */
  6969. function () {
  6970. if (this.next.isCharacter($RPAREN))
  6971. return [];
  6972. var /** @type {?} */ positionals = [];
  6973. do {
  6974. positionals.push(this.parsePipe());
  6975. } while (this.optionalCharacter($COMMA));
  6976. return /** @type {?} */ (positionals);
  6977. };
  6978. /**
  6979. * An identifier, a keyword, a string with an optional `-` inbetween.
  6980. */
  6981. /**
  6982. * An identifier, a keyword, a string with an optional `-` inbetween.
  6983. * @return {?}
  6984. */
  6985. _ParseAST.prototype.expectTemplateBindingKey = /**
  6986. * An identifier, a keyword, a string with an optional `-` inbetween.
  6987. * @return {?}
  6988. */
  6989. function () {
  6990. var /** @type {?} */ result = '';
  6991. var /** @type {?} */ operatorFound = false;
  6992. do {
  6993. result += this.expectIdentifierOrKeywordOrString();
  6994. operatorFound = this.optionalOperator('-');
  6995. if (operatorFound) {
  6996. result += '-';
  6997. }
  6998. } while (operatorFound);
  6999. return result.toString();
  7000. };
  7001. /**
  7002. * @return {?}
  7003. */
  7004. _ParseAST.prototype.parseTemplateBindings = /**
  7005. * @return {?}
  7006. */
  7007. function () {
  7008. var /** @type {?} */ bindings = [];
  7009. var /** @type {?} */ prefix = /** @type {?} */ ((null));
  7010. var /** @type {?} */ warnings = [];
  7011. while (this.index < this.tokens.length) {
  7012. var /** @type {?} */ start = this.inputIndex;
  7013. var /** @type {?} */ keyIsVar = this.peekKeywordLet();
  7014. if (keyIsVar) {
  7015. this.advance();
  7016. }
  7017. var /** @type {?} */ rawKey = this.expectTemplateBindingKey();
  7018. var /** @type {?} */ key = rawKey;
  7019. if (!keyIsVar) {
  7020. if (prefix == null) {
  7021. prefix = key;
  7022. }
  7023. else {
  7024. key = prefix + key[0].toUpperCase() + key.substring(1);
  7025. }
  7026. }
  7027. this.optionalCharacter($COLON);
  7028. var /** @type {?} */ name_2 = /** @type {?} */ ((null));
  7029. var /** @type {?} */ expression = /** @type {?} */ ((null));
  7030. if (keyIsVar) {
  7031. if (this.optionalOperator('=')) {
  7032. name_2 = this.expectTemplateBindingKey();
  7033. }
  7034. else {
  7035. name_2 = '\$implicit';
  7036. }
  7037. }
  7038. else if (this.peekKeywordAs()) {
  7039. var /** @type {?} */ letStart = this.inputIndex;
  7040. this.advance(); // consume `as`
  7041. name_2 = rawKey;
  7042. key = this.expectTemplateBindingKey(); // read local var name
  7043. keyIsVar = true;
  7044. }
  7045. else if (this.next !== EOF && !this.peekKeywordLet()) {
  7046. var /** @type {?} */ start_1 = this.inputIndex;
  7047. var /** @type {?} */ ast = this.parsePipe();
  7048. var /** @type {?} */ source = this.input.substring(start_1 - this.offset, this.inputIndex - this.offset);
  7049. expression = new ASTWithSource(ast, source, this.location, this.errors);
  7050. }
  7051. bindings.push(new TemplateBinding(this.span(start), key, keyIsVar, name_2, expression));
  7052. if (this.peekKeywordAs() && !keyIsVar) {
  7053. var /** @type {?} */ letStart = this.inputIndex;
  7054. this.advance(); // consume `as`
  7055. var /** @type {?} */ letName = this.expectTemplateBindingKey(); // read local var name
  7056. bindings.push(new TemplateBinding(this.span(letStart), letName, true, key, /** @type {?} */ ((null))));
  7057. }
  7058. if (!this.optionalCharacter($SEMICOLON)) {
  7059. this.optionalCharacter($COMMA);
  7060. }
  7061. }
  7062. return new TemplateBindingParseResult(bindings, warnings, this.errors);
  7063. };
  7064. /**
  7065. * @param {?} message
  7066. * @param {?=} index
  7067. * @return {?}
  7068. */
  7069. _ParseAST.prototype.error = /**
  7070. * @param {?} message
  7071. * @param {?=} index
  7072. * @return {?}
  7073. */
  7074. function (message, index) {
  7075. if (index === void 0) { index = null; }
  7076. this.errors.push(new ParserError(message, this.input, this.locationText(index), this.location));
  7077. this.skip();
  7078. };
  7079. /**
  7080. * @param {?=} index
  7081. * @return {?}
  7082. */
  7083. _ParseAST.prototype.locationText = /**
  7084. * @param {?=} index
  7085. * @return {?}
  7086. */
  7087. function (index) {
  7088. if (index === void 0) { index = null; }
  7089. if (index == null)
  7090. index = this.index;
  7091. return (index < this.tokens.length) ? "at column " + (this.tokens[index].index + 1) + " in" :
  7092. "at the end of the expression";
  7093. };
  7094. /**
  7095. * @return {?}
  7096. */
  7097. _ParseAST.prototype.skip = /**
  7098. * @return {?}
  7099. */
  7100. function () {
  7101. var /** @type {?} */ n = this.next;
  7102. while (this.index < this.tokens.length && !n.isCharacter($SEMICOLON) &&
  7103. (this.rparensExpected <= 0 || !n.isCharacter($RPAREN)) &&
  7104. (this.rbracesExpected <= 0 || !n.isCharacter($RBRACE)) &&
  7105. (this.rbracketsExpected <= 0 || !n.isCharacter($RBRACKET))) {
  7106. if (this.next.isError()) {
  7107. this.errors.push(new ParserError(/** @type {?} */ ((this.next.toString())), this.input, this.locationText(), this.location));
  7108. }
  7109. this.advance();
  7110. n = this.next;
  7111. }
  7112. };
  7113. return _ParseAST;
  7114. }());
  7115. var SimpleExpressionChecker = /** @class */ (function () {
  7116. function SimpleExpressionChecker() {
  7117. this.errors = [];
  7118. }
  7119. /**
  7120. * @param {?} ast
  7121. * @return {?}
  7122. */
  7123. SimpleExpressionChecker.check = /**
  7124. * @param {?} ast
  7125. * @return {?}
  7126. */
  7127. function (ast) {
  7128. var /** @type {?} */ s = new SimpleExpressionChecker();
  7129. ast.visit(s);
  7130. return s.errors;
  7131. };
  7132. /**
  7133. * @param {?} ast
  7134. * @param {?} context
  7135. * @return {?}
  7136. */
  7137. SimpleExpressionChecker.prototype.visitImplicitReceiver = /**
  7138. * @param {?} ast
  7139. * @param {?} context
  7140. * @return {?}
  7141. */
  7142. function (ast, context) { };
  7143. /**
  7144. * @param {?} ast
  7145. * @param {?} context
  7146. * @return {?}
  7147. */
  7148. SimpleExpressionChecker.prototype.visitInterpolation = /**
  7149. * @param {?} ast
  7150. * @param {?} context
  7151. * @return {?}
  7152. */
  7153. function (ast, context) { };
  7154. /**
  7155. * @param {?} ast
  7156. * @param {?} context
  7157. * @return {?}
  7158. */
  7159. SimpleExpressionChecker.prototype.visitLiteralPrimitive = /**
  7160. * @param {?} ast
  7161. * @param {?} context
  7162. * @return {?}
  7163. */
  7164. function (ast, context) { };
  7165. /**
  7166. * @param {?} ast
  7167. * @param {?} context
  7168. * @return {?}
  7169. */
  7170. SimpleExpressionChecker.prototype.visitPropertyRead = /**
  7171. * @param {?} ast
  7172. * @param {?} context
  7173. * @return {?}
  7174. */
  7175. function (ast, context) { };
  7176. /**
  7177. * @param {?} ast
  7178. * @param {?} context
  7179. * @return {?}
  7180. */
  7181. SimpleExpressionChecker.prototype.visitPropertyWrite = /**
  7182. * @param {?} ast
  7183. * @param {?} context
  7184. * @return {?}
  7185. */
  7186. function (ast, context) { };
  7187. /**
  7188. * @param {?} ast
  7189. * @param {?} context
  7190. * @return {?}
  7191. */
  7192. SimpleExpressionChecker.prototype.visitSafePropertyRead = /**
  7193. * @param {?} ast
  7194. * @param {?} context
  7195. * @return {?}
  7196. */
  7197. function (ast, context) { };
  7198. /**
  7199. * @param {?} ast
  7200. * @param {?} context
  7201. * @return {?}
  7202. */
  7203. SimpleExpressionChecker.prototype.visitMethodCall = /**
  7204. * @param {?} ast
  7205. * @param {?} context
  7206. * @return {?}
  7207. */
  7208. function (ast, context) { };
  7209. /**
  7210. * @param {?} ast
  7211. * @param {?} context
  7212. * @return {?}
  7213. */
  7214. SimpleExpressionChecker.prototype.visitSafeMethodCall = /**
  7215. * @param {?} ast
  7216. * @param {?} context
  7217. * @return {?}
  7218. */
  7219. function (ast, context) { };
  7220. /**
  7221. * @param {?} ast
  7222. * @param {?} context
  7223. * @return {?}
  7224. */
  7225. SimpleExpressionChecker.prototype.visitFunctionCall = /**
  7226. * @param {?} ast
  7227. * @param {?} context
  7228. * @return {?}
  7229. */
  7230. function (ast, context) { };
  7231. /**
  7232. * @param {?} ast
  7233. * @param {?} context
  7234. * @return {?}
  7235. */
  7236. SimpleExpressionChecker.prototype.visitLiteralArray = /**
  7237. * @param {?} ast
  7238. * @param {?} context
  7239. * @return {?}
  7240. */
  7241. function (ast, context) { this.visitAll(ast.expressions); };
  7242. /**
  7243. * @param {?} ast
  7244. * @param {?} context
  7245. * @return {?}
  7246. */
  7247. SimpleExpressionChecker.prototype.visitLiteralMap = /**
  7248. * @param {?} ast
  7249. * @param {?} context
  7250. * @return {?}
  7251. */
  7252. function (ast, context) { this.visitAll(ast.values); };
  7253. /**
  7254. * @param {?} ast
  7255. * @param {?} context
  7256. * @return {?}
  7257. */
  7258. SimpleExpressionChecker.prototype.visitBinary = /**
  7259. * @param {?} ast
  7260. * @param {?} context
  7261. * @return {?}
  7262. */
  7263. function (ast, context) { };
  7264. /**
  7265. * @param {?} ast
  7266. * @param {?} context
  7267. * @return {?}
  7268. */
  7269. SimpleExpressionChecker.prototype.visitPrefixNot = /**
  7270. * @param {?} ast
  7271. * @param {?} context
  7272. * @return {?}
  7273. */
  7274. function (ast, context) { };
  7275. /**
  7276. * @param {?} ast
  7277. * @param {?} context
  7278. * @return {?}
  7279. */
  7280. SimpleExpressionChecker.prototype.visitNonNullAssert = /**
  7281. * @param {?} ast
  7282. * @param {?} context
  7283. * @return {?}
  7284. */
  7285. function (ast, context) { };
  7286. /**
  7287. * @param {?} ast
  7288. * @param {?} context
  7289. * @return {?}
  7290. */
  7291. SimpleExpressionChecker.prototype.visitConditional = /**
  7292. * @param {?} ast
  7293. * @param {?} context
  7294. * @return {?}
  7295. */
  7296. function (ast, context) { };
  7297. /**
  7298. * @param {?} ast
  7299. * @param {?} context
  7300. * @return {?}
  7301. */
  7302. SimpleExpressionChecker.prototype.visitPipe = /**
  7303. * @param {?} ast
  7304. * @param {?} context
  7305. * @return {?}
  7306. */
  7307. function (ast, context) { this.errors.push('pipes'); };
  7308. /**
  7309. * @param {?} ast
  7310. * @param {?} context
  7311. * @return {?}
  7312. */
  7313. SimpleExpressionChecker.prototype.visitKeyedRead = /**
  7314. * @param {?} ast
  7315. * @param {?} context
  7316. * @return {?}
  7317. */
  7318. function (ast, context) { };
  7319. /**
  7320. * @param {?} ast
  7321. * @param {?} context
  7322. * @return {?}
  7323. */
  7324. SimpleExpressionChecker.prototype.visitKeyedWrite = /**
  7325. * @param {?} ast
  7326. * @param {?} context
  7327. * @return {?}
  7328. */
  7329. function (ast, context) { };
  7330. /**
  7331. * @param {?} asts
  7332. * @return {?}
  7333. */
  7334. SimpleExpressionChecker.prototype.visitAll = /**
  7335. * @param {?} asts
  7336. * @return {?}
  7337. */
  7338. function (asts) {
  7339. var _this = this;
  7340. return asts.map(function (node) { return node.visit(_this); });
  7341. };
  7342. /**
  7343. * @param {?} ast
  7344. * @param {?} context
  7345. * @return {?}
  7346. */
  7347. SimpleExpressionChecker.prototype.visitChain = /**
  7348. * @param {?} ast
  7349. * @param {?} context
  7350. * @return {?}
  7351. */
  7352. function (ast, context) { };
  7353. /**
  7354. * @param {?} ast
  7355. * @param {?} context
  7356. * @return {?}
  7357. */
  7358. SimpleExpressionChecker.prototype.visitQuote = /**
  7359. * @param {?} ast
  7360. * @param {?} context
  7361. * @return {?}
  7362. */
  7363. function (ast, context) { };
  7364. return SimpleExpressionChecker;
  7365. }());
  7366. /**
  7367. * @fileoverview added by tsickle
  7368. * @suppress {checkTypes} checked by tsc
  7369. */
  7370. var ParseLocation = /** @class */ (function () {
  7371. function ParseLocation(file, offset, line, col) {
  7372. this.file = file;
  7373. this.offset = offset;
  7374. this.line = line;
  7375. this.col = col;
  7376. }
  7377. /**
  7378. * @return {?}
  7379. */
  7380. ParseLocation.prototype.toString = /**
  7381. * @return {?}
  7382. */
  7383. function () {
  7384. return this.offset != null ? this.file.url + "@" + this.line + ":" + this.col : this.file.url;
  7385. };
  7386. /**
  7387. * @param {?} delta
  7388. * @return {?}
  7389. */
  7390. ParseLocation.prototype.moveBy = /**
  7391. * @param {?} delta
  7392. * @return {?}
  7393. */
  7394. function (delta) {
  7395. var /** @type {?} */ source = this.file.content;
  7396. var /** @type {?} */ len = source.length;
  7397. var /** @type {?} */ offset = this.offset;
  7398. var /** @type {?} */ line = this.line;
  7399. var /** @type {?} */ col = this.col;
  7400. while (offset > 0 && delta < 0) {
  7401. offset--;
  7402. delta++;
  7403. var /** @type {?} */ ch = source.charCodeAt(offset);
  7404. if (ch == $LF) {
  7405. line--;
  7406. var /** @type {?} */ priorLine = source.substr(0, offset - 1).lastIndexOf(String.fromCharCode($LF));
  7407. col = priorLine > 0 ? offset - priorLine : offset;
  7408. }
  7409. else {
  7410. col--;
  7411. }
  7412. }
  7413. while (offset < len && delta > 0) {
  7414. var /** @type {?} */ ch = source.charCodeAt(offset);
  7415. offset++;
  7416. delta--;
  7417. if (ch == $LF) {
  7418. line++;
  7419. col = 0;
  7420. }
  7421. else {
  7422. col++;
  7423. }
  7424. }
  7425. return new ParseLocation(this.file, offset, line, col);
  7426. };
  7427. // Return the source around the location
  7428. // Up to `maxChars` or `maxLines` on each side of the location
  7429. /**
  7430. * @param {?} maxChars
  7431. * @param {?} maxLines
  7432. * @return {?}
  7433. */
  7434. ParseLocation.prototype.getContext = /**
  7435. * @param {?} maxChars
  7436. * @param {?} maxLines
  7437. * @return {?}
  7438. */
  7439. function (maxChars, maxLines) {
  7440. var /** @type {?} */ content = this.file.content;
  7441. var /** @type {?} */ startOffset = this.offset;
  7442. if (startOffset != null) {
  7443. if (startOffset > content.length - 1) {
  7444. startOffset = content.length - 1;
  7445. }
  7446. var /** @type {?} */ endOffset = startOffset;
  7447. var /** @type {?} */ ctxChars = 0;
  7448. var /** @type {?} */ ctxLines = 0;
  7449. while (ctxChars < maxChars && startOffset > 0) {
  7450. startOffset--;
  7451. ctxChars++;
  7452. if (content[startOffset] == '\n') {
  7453. if (++ctxLines == maxLines) {
  7454. break;
  7455. }
  7456. }
  7457. }
  7458. ctxChars = 0;
  7459. ctxLines = 0;
  7460. while (ctxChars < maxChars && endOffset < content.length - 1) {
  7461. endOffset++;
  7462. ctxChars++;
  7463. if (content[endOffset] == '\n') {
  7464. if (++ctxLines == maxLines) {
  7465. break;
  7466. }
  7467. }
  7468. }
  7469. return {
  7470. before: content.substring(startOffset, this.offset),
  7471. after: content.substring(this.offset, endOffset + 1),
  7472. };
  7473. }
  7474. return null;
  7475. };
  7476. return ParseLocation;
  7477. }());
  7478. var ParseSourceFile = /** @class */ (function () {
  7479. function ParseSourceFile(content, url) {
  7480. this.content = content;
  7481. this.url = url;
  7482. }
  7483. return ParseSourceFile;
  7484. }());
  7485. var ParseSourceSpan = /** @class */ (function () {
  7486. function ParseSourceSpan(start, end, details) {
  7487. if (details === void 0) { details = null; }
  7488. this.start = start;
  7489. this.end = end;
  7490. this.details = details;
  7491. }
  7492. /**
  7493. * @return {?}
  7494. */
  7495. ParseSourceSpan.prototype.toString = /**
  7496. * @return {?}
  7497. */
  7498. function () {
  7499. return this.start.file.content.substring(this.start.offset, this.end.offset);
  7500. };
  7501. return ParseSourceSpan;
  7502. }());
  7503. /** @enum {number} */
  7504. var ParseErrorLevel = {
  7505. WARNING: 0,
  7506. ERROR: 1,
  7507. };
  7508. ParseErrorLevel[ParseErrorLevel.WARNING] = "WARNING";
  7509. ParseErrorLevel[ParseErrorLevel.ERROR] = "ERROR";
  7510. var ParseError = /** @class */ (function () {
  7511. function ParseError(span, msg, level) {
  7512. if (level === void 0) { level = ParseErrorLevel.ERROR; }
  7513. this.span = span;
  7514. this.msg = msg;
  7515. this.level = level;
  7516. }
  7517. /**
  7518. * @return {?}
  7519. */
  7520. ParseError.prototype.contextualMessage = /**
  7521. * @return {?}
  7522. */
  7523. function () {
  7524. var /** @type {?} */ ctx = this.span.start.getContext(100, 3);
  7525. return ctx ? this.msg + " (\"" + ctx.before + "[" + ParseErrorLevel[this.level] + " ->]" + ctx.after + "\")" :
  7526. this.msg;
  7527. };
  7528. /**
  7529. * @return {?}
  7530. */
  7531. ParseError.prototype.toString = /**
  7532. * @return {?}
  7533. */
  7534. function () {
  7535. var /** @type {?} */ details = this.span.details ? ", " + this.span.details : '';
  7536. return this.contextualMessage() + ": " + this.span.start + details;
  7537. };
  7538. return ParseError;
  7539. }());
  7540. /**
  7541. * @param {?} kind
  7542. * @param {?} type
  7543. * @return {?}
  7544. */
  7545. function typeSourceSpan(kind, type) {
  7546. var /** @type {?} */ moduleUrl = identifierModuleUrl(type);
  7547. var /** @type {?} */ sourceFileName = moduleUrl != null ? "in " + kind + " " + identifierName(type) + " in " + moduleUrl :
  7548. "in " + kind + " " + identifierName(type);
  7549. var /** @type {?} */ sourceFile = new ParseSourceFile('', sourceFileName);
  7550. return new ParseSourceSpan(new ParseLocation(sourceFile, -1, -1, -1), new ParseLocation(sourceFile, -1, -1, -1));
  7551. }
  7552. /**
  7553. * @fileoverview added by tsickle
  7554. * @suppress {checkTypes} checked by tsc
  7555. */
  7556. /**
  7557. * @license
  7558. * Copyright Google Inc. All Rights Reserved.
  7559. *
  7560. * Use of this source code is governed by an MIT-style license that can be
  7561. * found in the LICENSE file at https://angular.io/license
  7562. */
  7563. /** @enum {number} */
  7564. var TokenType$1 = {
  7565. TAG_OPEN_START: 0,
  7566. TAG_OPEN_END: 1,
  7567. TAG_OPEN_END_VOID: 2,
  7568. TAG_CLOSE: 3,
  7569. TEXT: 4,
  7570. ESCAPABLE_RAW_TEXT: 5,
  7571. RAW_TEXT: 6,
  7572. COMMENT_START: 7,
  7573. COMMENT_END: 8,
  7574. CDATA_START: 9,
  7575. CDATA_END: 10,
  7576. ATTR_NAME: 11,
  7577. ATTR_VALUE: 12,
  7578. DOC_TYPE: 13,
  7579. EXPANSION_FORM_START: 14,
  7580. EXPANSION_CASE_VALUE: 15,
  7581. EXPANSION_CASE_EXP_START: 16,
  7582. EXPANSION_CASE_EXP_END: 17,
  7583. EXPANSION_FORM_END: 18,
  7584. EOF: 19,
  7585. };
  7586. TokenType$1[TokenType$1.TAG_OPEN_START] = "TAG_OPEN_START";
  7587. TokenType$1[TokenType$1.TAG_OPEN_END] = "TAG_OPEN_END";
  7588. TokenType$1[TokenType$1.TAG_OPEN_END_VOID] = "TAG_OPEN_END_VOID";
  7589. TokenType$1[TokenType$1.TAG_CLOSE] = "TAG_CLOSE";
  7590. TokenType$1[TokenType$1.TEXT] = "TEXT";
  7591. TokenType$1[TokenType$1.ESCAPABLE_RAW_TEXT] = "ESCAPABLE_RAW_TEXT";
  7592. TokenType$1[TokenType$1.RAW_TEXT] = "RAW_TEXT";
  7593. TokenType$1[TokenType$1.COMMENT_START] = "COMMENT_START";
  7594. TokenType$1[TokenType$1.COMMENT_END] = "COMMENT_END";
  7595. TokenType$1[TokenType$1.CDATA_START] = "CDATA_START";
  7596. TokenType$1[TokenType$1.CDATA_END] = "CDATA_END";
  7597. TokenType$1[TokenType$1.ATTR_NAME] = "ATTR_NAME";
  7598. TokenType$1[TokenType$1.ATTR_VALUE] = "ATTR_VALUE";
  7599. TokenType$1[TokenType$1.DOC_TYPE] = "DOC_TYPE";
  7600. TokenType$1[TokenType$1.EXPANSION_FORM_START] = "EXPANSION_FORM_START";
  7601. TokenType$1[TokenType$1.EXPANSION_CASE_VALUE] = "EXPANSION_CASE_VALUE";
  7602. TokenType$1[TokenType$1.EXPANSION_CASE_EXP_START] = "EXPANSION_CASE_EXP_START";
  7603. TokenType$1[TokenType$1.EXPANSION_CASE_EXP_END] = "EXPANSION_CASE_EXP_END";
  7604. TokenType$1[TokenType$1.EXPANSION_FORM_END] = "EXPANSION_FORM_END";
  7605. TokenType$1[TokenType$1.EOF] = "EOF";
  7606. var Token$1 = /** @class */ (function () {
  7607. function Token(type, parts, sourceSpan) {
  7608. this.type = type;
  7609. this.parts = parts;
  7610. this.sourceSpan = sourceSpan;
  7611. }
  7612. return Token;
  7613. }());
  7614. var TokenError = /** @class */ (function (_super) {
  7615. __extends(TokenError, _super);
  7616. function TokenError(errorMsg, tokenType, span) {
  7617. var _this = _super.call(this, span, errorMsg) || this;
  7618. _this.tokenType = tokenType;
  7619. return _this;
  7620. }
  7621. return TokenError;
  7622. }(ParseError));
  7623. var TokenizeResult = /** @class */ (function () {
  7624. function TokenizeResult(tokens, errors) {
  7625. this.tokens = tokens;
  7626. this.errors = errors;
  7627. }
  7628. return TokenizeResult;
  7629. }());
  7630. /**
  7631. * @param {?} source
  7632. * @param {?} url
  7633. * @param {?} getTagDefinition
  7634. * @param {?=} tokenizeExpansionForms
  7635. * @param {?=} interpolationConfig
  7636. * @return {?}
  7637. */
  7638. function tokenize(source, url, getTagDefinition, tokenizeExpansionForms, interpolationConfig) {
  7639. if (tokenizeExpansionForms === void 0) { tokenizeExpansionForms = false; }
  7640. if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
  7641. return new _Tokenizer(new ParseSourceFile(source, url), getTagDefinition, tokenizeExpansionForms, interpolationConfig)
  7642. .tokenize();
  7643. }
  7644. var _CR_OR_CRLF_REGEXP = /\r\n?/g;
  7645. /**
  7646. * @param {?} charCode
  7647. * @return {?}
  7648. */
  7649. function _unexpectedCharacterErrorMsg(charCode) {
  7650. var /** @type {?} */ char = charCode === $EOF ? 'EOF' : String.fromCharCode(charCode);
  7651. return "Unexpected character \"" + char + "\"";
  7652. }
  7653. /**
  7654. * @param {?} entitySrc
  7655. * @return {?}
  7656. */
  7657. function _unknownEntityErrorMsg(entitySrc) {
  7658. return "Unknown entity \"" + entitySrc + "\" - use the \"&#<decimal>;\" or \"&#x<hex>;\" syntax";
  7659. }
  7660. var _ControlFlowError = /** @class */ (function () {
  7661. function _ControlFlowError(error) {
  7662. this.error = error;
  7663. }
  7664. return _ControlFlowError;
  7665. }());
  7666. var _Tokenizer = /** @class */ (function () {
  7667. /**
  7668. * @param _file The html source
  7669. * @param _getTagDefinition
  7670. * @param _tokenizeIcu Whether to tokenize ICU messages (considered as text nodes when false)
  7671. * @param _interpolationConfig
  7672. */
  7673. function _Tokenizer(_file, _getTagDefinition, _tokenizeIcu, _interpolationConfig) {
  7674. if (_interpolationConfig === void 0) { _interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
  7675. this._file = _file;
  7676. this._getTagDefinition = _getTagDefinition;
  7677. this._tokenizeIcu = _tokenizeIcu;
  7678. this._interpolationConfig = _interpolationConfig;
  7679. this._peek = -1;
  7680. this._nextPeek = -1;
  7681. this._index = -1;
  7682. this._line = 0;
  7683. this._column = -1;
  7684. this._expansionCaseStack = [];
  7685. this._inInterpolation = false;
  7686. this.tokens = [];
  7687. this.errors = [];
  7688. this._input = _file.content;
  7689. this._length = _file.content.length;
  7690. this._advance();
  7691. }
  7692. /**
  7693. * @param {?} content
  7694. * @return {?}
  7695. */
  7696. _Tokenizer.prototype._processCarriageReturns = /**
  7697. * @param {?} content
  7698. * @return {?}
  7699. */
  7700. function (content) {
  7701. // http://www.w3.org/TR/html5/syntax.html#preprocessing-the-input-stream
  7702. // In order to keep the original position in the source, we can not
  7703. // pre-process it.
  7704. // Instead CRs are processed right before instantiating the tokens.
  7705. return content.replace(_CR_OR_CRLF_REGEXP, '\n');
  7706. };
  7707. /**
  7708. * @return {?}
  7709. */
  7710. _Tokenizer.prototype.tokenize = /**
  7711. * @return {?}
  7712. */
  7713. function () {
  7714. while (this._peek !== $EOF) {
  7715. var /** @type {?} */ start = this._getLocation();
  7716. try {
  7717. if (this._attemptCharCode($LT)) {
  7718. if (this._attemptCharCode($BANG)) {
  7719. if (this._attemptCharCode($LBRACKET)) {
  7720. this._consumeCdata(start);
  7721. }
  7722. else if (this._attemptCharCode($MINUS)) {
  7723. this._consumeComment(start);
  7724. }
  7725. else {
  7726. this._consumeDocType(start);
  7727. }
  7728. }
  7729. else if (this._attemptCharCode($SLASH)) {
  7730. this._consumeTagClose(start);
  7731. }
  7732. else {
  7733. this._consumeTagOpen(start);
  7734. }
  7735. }
  7736. else if (!(this._tokenizeIcu && this._tokenizeExpansionForm())) {
  7737. this._consumeText();
  7738. }
  7739. }
  7740. catch (/** @type {?} */ e) {
  7741. if (e instanceof _ControlFlowError) {
  7742. this.errors.push(e.error);
  7743. }
  7744. else {
  7745. throw e;
  7746. }
  7747. }
  7748. }
  7749. this._beginToken(TokenType$1.EOF);
  7750. this._endToken([]);
  7751. return new TokenizeResult(mergeTextTokens(this.tokens), this.errors);
  7752. };
  7753. /**
  7754. * \@internal
  7755. * @return {?} whether an ICU token has been created
  7756. */
  7757. _Tokenizer.prototype._tokenizeExpansionForm = /**
  7758. * \@internal
  7759. * @return {?} whether an ICU token has been created
  7760. */
  7761. function () {
  7762. if (isExpansionFormStart(this._input, this._index, this._interpolationConfig)) {
  7763. this._consumeExpansionFormStart();
  7764. return true;
  7765. }
  7766. if (isExpansionCaseStart(this._peek) && this._isInExpansionForm()) {
  7767. this._consumeExpansionCaseStart();
  7768. return true;
  7769. }
  7770. if (this._peek === $RBRACE) {
  7771. if (this._isInExpansionCase()) {
  7772. this._consumeExpansionCaseEnd();
  7773. return true;
  7774. }
  7775. if (this._isInExpansionForm()) {
  7776. this._consumeExpansionFormEnd();
  7777. return true;
  7778. }
  7779. }
  7780. return false;
  7781. };
  7782. /**
  7783. * @return {?}
  7784. */
  7785. _Tokenizer.prototype._getLocation = /**
  7786. * @return {?}
  7787. */
  7788. function () {
  7789. return new ParseLocation(this._file, this._index, this._line, this._column);
  7790. };
  7791. /**
  7792. * @param {?=} start
  7793. * @param {?=} end
  7794. * @return {?}
  7795. */
  7796. _Tokenizer.prototype._getSpan = /**
  7797. * @param {?=} start
  7798. * @param {?=} end
  7799. * @return {?}
  7800. */
  7801. function (start, end) {
  7802. if (start === void 0) { start = this._getLocation(); }
  7803. if (end === void 0) { end = this._getLocation(); }
  7804. return new ParseSourceSpan(start, end);
  7805. };
  7806. /**
  7807. * @param {?} type
  7808. * @param {?=} start
  7809. * @return {?}
  7810. */
  7811. _Tokenizer.prototype._beginToken = /**
  7812. * @param {?} type
  7813. * @param {?=} start
  7814. * @return {?}
  7815. */
  7816. function (type, start) {
  7817. if (start === void 0) { start = this._getLocation(); }
  7818. this._currentTokenStart = start;
  7819. this._currentTokenType = type;
  7820. };
  7821. /**
  7822. * @param {?} parts
  7823. * @param {?=} end
  7824. * @return {?}
  7825. */
  7826. _Tokenizer.prototype._endToken = /**
  7827. * @param {?} parts
  7828. * @param {?=} end
  7829. * @return {?}
  7830. */
  7831. function (parts, end) {
  7832. if (end === void 0) { end = this._getLocation(); }
  7833. var /** @type {?} */ token = new Token$1(this._currentTokenType, parts, new ParseSourceSpan(this._currentTokenStart, end));
  7834. this.tokens.push(token);
  7835. this._currentTokenStart = /** @type {?} */ ((null));
  7836. this._currentTokenType = /** @type {?} */ ((null));
  7837. return token;
  7838. };
  7839. /**
  7840. * @param {?} msg
  7841. * @param {?} span
  7842. * @return {?}
  7843. */
  7844. _Tokenizer.prototype._createError = /**
  7845. * @param {?} msg
  7846. * @param {?} span
  7847. * @return {?}
  7848. */
  7849. function (msg, span) {
  7850. if (this._isInExpansionForm()) {
  7851. msg += " (Do you have an unescaped \"{\" in your template? Use \"{{ '{' }}\") to escape it.)";
  7852. }
  7853. var /** @type {?} */ error = new TokenError(msg, this._currentTokenType, span);
  7854. this._currentTokenStart = /** @type {?} */ ((null));
  7855. this._currentTokenType = /** @type {?} */ ((null));
  7856. return new _ControlFlowError(error);
  7857. };
  7858. /**
  7859. * @return {?}
  7860. */
  7861. _Tokenizer.prototype._advance = /**
  7862. * @return {?}
  7863. */
  7864. function () {
  7865. if (this._index >= this._length) {
  7866. throw this._createError(_unexpectedCharacterErrorMsg($EOF), this._getSpan());
  7867. }
  7868. if (this._peek === $LF) {
  7869. this._line++;
  7870. this._column = 0;
  7871. }
  7872. else if (this._peek !== $LF && this._peek !== $CR) {
  7873. this._column++;
  7874. }
  7875. this._index++;
  7876. this._peek = this._index >= this._length ? $EOF : this._input.charCodeAt(this._index);
  7877. this._nextPeek =
  7878. this._index + 1 >= this._length ? $EOF : this._input.charCodeAt(this._index + 1);
  7879. };
  7880. /**
  7881. * @param {?} charCode
  7882. * @return {?}
  7883. */
  7884. _Tokenizer.prototype._attemptCharCode = /**
  7885. * @param {?} charCode
  7886. * @return {?}
  7887. */
  7888. function (charCode) {
  7889. if (this._peek === charCode) {
  7890. this._advance();
  7891. return true;
  7892. }
  7893. return false;
  7894. };
  7895. /**
  7896. * @param {?} charCode
  7897. * @return {?}
  7898. */
  7899. _Tokenizer.prototype._attemptCharCodeCaseInsensitive = /**
  7900. * @param {?} charCode
  7901. * @return {?}
  7902. */
  7903. function (charCode) {
  7904. if (compareCharCodeCaseInsensitive(this._peek, charCode)) {
  7905. this._advance();
  7906. return true;
  7907. }
  7908. return false;
  7909. };
  7910. /**
  7911. * @param {?} charCode
  7912. * @return {?}
  7913. */
  7914. _Tokenizer.prototype._requireCharCode = /**
  7915. * @param {?} charCode
  7916. * @return {?}
  7917. */
  7918. function (charCode) {
  7919. var /** @type {?} */ location = this._getLocation();
  7920. if (!this._attemptCharCode(charCode)) {
  7921. throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan(location, location));
  7922. }
  7923. };
  7924. /**
  7925. * @param {?} chars
  7926. * @return {?}
  7927. */
  7928. _Tokenizer.prototype._attemptStr = /**
  7929. * @param {?} chars
  7930. * @return {?}
  7931. */
  7932. function (chars) {
  7933. var /** @type {?} */ len = chars.length;
  7934. if (this._index + len > this._length) {
  7935. return false;
  7936. }
  7937. var /** @type {?} */ initialPosition = this._savePosition();
  7938. for (var /** @type {?} */ i = 0; i < len; i++) {
  7939. if (!this._attemptCharCode(chars.charCodeAt(i))) {
  7940. // If attempting to parse the string fails, we want to reset the parser
  7941. // to where it was before the attempt
  7942. this._restorePosition(initialPosition);
  7943. return false;
  7944. }
  7945. }
  7946. return true;
  7947. };
  7948. /**
  7949. * @param {?} chars
  7950. * @return {?}
  7951. */
  7952. _Tokenizer.prototype._attemptStrCaseInsensitive = /**
  7953. * @param {?} chars
  7954. * @return {?}
  7955. */
  7956. function (chars) {
  7957. for (var /** @type {?} */ i = 0; i < chars.length; i++) {
  7958. if (!this._attemptCharCodeCaseInsensitive(chars.charCodeAt(i))) {
  7959. return false;
  7960. }
  7961. }
  7962. return true;
  7963. };
  7964. /**
  7965. * @param {?} chars
  7966. * @return {?}
  7967. */
  7968. _Tokenizer.prototype._requireStr = /**
  7969. * @param {?} chars
  7970. * @return {?}
  7971. */
  7972. function (chars) {
  7973. var /** @type {?} */ location = this._getLocation();
  7974. if (!this._attemptStr(chars)) {
  7975. throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan(location));
  7976. }
  7977. };
  7978. /**
  7979. * @param {?} predicate
  7980. * @return {?}
  7981. */
  7982. _Tokenizer.prototype._attemptCharCodeUntilFn = /**
  7983. * @param {?} predicate
  7984. * @return {?}
  7985. */
  7986. function (predicate) {
  7987. while (!predicate(this._peek)) {
  7988. this._advance();
  7989. }
  7990. };
  7991. /**
  7992. * @param {?} predicate
  7993. * @param {?} len
  7994. * @return {?}
  7995. */
  7996. _Tokenizer.prototype._requireCharCodeUntilFn = /**
  7997. * @param {?} predicate
  7998. * @param {?} len
  7999. * @return {?}
  8000. */
  8001. function (predicate, len) {
  8002. var /** @type {?} */ start = this._getLocation();
  8003. this._attemptCharCodeUntilFn(predicate);
  8004. if (this._index - start.offset < len) {
  8005. throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan(start, start));
  8006. }
  8007. };
  8008. /**
  8009. * @param {?} char
  8010. * @return {?}
  8011. */
  8012. _Tokenizer.prototype._attemptUntilChar = /**
  8013. * @param {?} char
  8014. * @return {?}
  8015. */
  8016. function (char) {
  8017. while (this._peek !== char) {
  8018. this._advance();
  8019. }
  8020. };
  8021. /**
  8022. * @param {?} decodeEntities
  8023. * @return {?}
  8024. */
  8025. _Tokenizer.prototype._readChar = /**
  8026. * @param {?} decodeEntities
  8027. * @return {?}
  8028. */
  8029. function (decodeEntities) {
  8030. if (decodeEntities && this._peek === $AMPERSAND) {
  8031. return this._decodeEntity();
  8032. }
  8033. else {
  8034. var /** @type {?} */ index = this._index;
  8035. this._advance();
  8036. return this._input[index];
  8037. }
  8038. };
  8039. /**
  8040. * @return {?}
  8041. */
  8042. _Tokenizer.prototype._decodeEntity = /**
  8043. * @return {?}
  8044. */
  8045. function () {
  8046. var /** @type {?} */ start = this._getLocation();
  8047. this._advance();
  8048. if (this._attemptCharCode($HASH)) {
  8049. var /** @type {?} */ isHex = this._attemptCharCode($x) || this._attemptCharCode($X);
  8050. var /** @type {?} */ numberStart = this._getLocation().offset;
  8051. this._attemptCharCodeUntilFn(isDigitEntityEnd);
  8052. if (this._peek != $SEMICOLON) {
  8053. throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan());
  8054. }
  8055. this._advance();
  8056. var /** @type {?} */ strNum = this._input.substring(numberStart, this._index - 1);
  8057. try {
  8058. var /** @type {?} */ charCode = parseInt(strNum, isHex ? 16 : 10);
  8059. return String.fromCharCode(charCode);
  8060. }
  8061. catch (/** @type {?} */ e) {
  8062. var /** @type {?} */ entity = this._input.substring(start.offset + 1, this._index - 1);
  8063. throw this._createError(_unknownEntityErrorMsg(entity), this._getSpan(start));
  8064. }
  8065. }
  8066. else {
  8067. var /** @type {?} */ startPosition = this._savePosition();
  8068. this._attemptCharCodeUntilFn(isNamedEntityEnd);
  8069. if (this._peek != $SEMICOLON) {
  8070. this._restorePosition(startPosition);
  8071. return '&';
  8072. }
  8073. this._advance();
  8074. var /** @type {?} */ name_1 = this._input.substring(start.offset + 1, this._index - 1);
  8075. var /** @type {?} */ char = NAMED_ENTITIES[name_1];
  8076. if (!char) {
  8077. throw this._createError(_unknownEntityErrorMsg(name_1), this._getSpan(start));
  8078. }
  8079. return char;
  8080. }
  8081. };
  8082. /**
  8083. * @param {?} decodeEntities
  8084. * @param {?} firstCharOfEnd
  8085. * @param {?} attemptEndRest
  8086. * @return {?}
  8087. */
  8088. _Tokenizer.prototype._consumeRawText = /**
  8089. * @param {?} decodeEntities
  8090. * @param {?} firstCharOfEnd
  8091. * @param {?} attemptEndRest
  8092. * @return {?}
  8093. */
  8094. function (decodeEntities, firstCharOfEnd, attemptEndRest) {
  8095. var /** @type {?} */ tagCloseStart;
  8096. var /** @type {?} */ textStart = this._getLocation();
  8097. this._beginToken(decodeEntities ? TokenType$1.ESCAPABLE_RAW_TEXT : TokenType$1.RAW_TEXT, textStart);
  8098. var /** @type {?} */ parts = [];
  8099. while (true) {
  8100. tagCloseStart = this._getLocation();
  8101. if (this._attemptCharCode(firstCharOfEnd) && attemptEndRest()) {
  8102. break;
  8103. }
  8104. if (this._index > tagCloseStart.offset) {
  8105. // add the characters consumed by the previous if statement to the output
  8106. parts.push(this._input.substring(tagCloseStart.offset, this._index));
  8107. }
  8108. while (this._peek !== firstCharOfEnd) {
  8109. parts.push(this._readChar(decodeEntities));
  8110. }
  8111. }
  8112. return this._endToken([this._processCarriageReturns(parts.join(''))], tagCloseStart);
  8113. };
  8114. /**
  8115. * @param {?} start
  8116. * @return {?}
  8117. */
  8118. _Tokenizer.prototype._consumeComment = /**
  8119. * @param {?} start
  8120. * @return {?}
  8121. */
  8122. function (start) {
  8123. var _this = this;
  8124. this._beginToken(TokenType$1.COMMENT_START, start);
  8125. this._requireCharCode($MINUS);
  8126. this._endToken([]);
  8127. var /** @type {?} */ textToken = this._consumeRawText(false, $MINUS, function () { return _this._attemptStr('->'); });
  8128. this._beginToken(TokenType$1.COMMENT_END, textToken.sourceSpan.end);
  8129. this._endToken([]);
  8130. };
  8131. /**
  8132. * @param {?} start
  8133. * @return {?}
  8134. */
  8135. _Tokenizer.prototype._consumeCdata = /**
  8136. * @param {?} start
  8137. * @return {?}
  8138. */
  8139. function (start) {
  8140. var _this = this;
  8141. this._beginToken(TokenType$1.CDATA_START, start);
  8142. this._requireStr('CDATA[');
  8143. this._endToken([]);
  8144. var /** @type {?} */ textToken = this._consumeRawText(false, $RBRACKET, function () { return _this._attemptStr(']>'); });
  8145. this._beginToken(TokenType$1.CDATA_END, textToken.sourceSpan.end);
  8146. this._endToken([]);
  8147. };
  8148. /**
  8149. * @param {?} start
  8150. * @return {?}
  8151. */
  8152. _Tokenizer.prototype._consumeDocType = /**
  8153. * @param {?} start
  8154. * @return {?}
  8155. */
  8156. function (start) {
  8157. this._beginToken(TokenType$1.DOC_TYPE, start);
  8158. this._attemptUntilChar($GT);
  8159. this._advance();
  8160. this._endToken([this._input.substring(start.offset + 2, this._index - 1)]);
  8161. };
  8162. /**
  8163. * @return {?}
  8164. */
  8165. _Tokenizer.prototype._consumePrefixAndName = /**
  8166. * @return {?}
  8167. */
  8168. function () {
  8169. var /** @type {?} */ nameOrPrefixStart = this._index;
  8170. var /** @type {?} */ prefix = /** @type {?} */ ((null));
  8171. while (this._peek !== $COLON && !isPrefixEnd(this._peek)) {
  8172. this._advance();
  8173. }
  8174. var /** @type {?} */ nameStart;
  8175. if (this._peek === $COLON) {
  8176. this._advance();
  8177. prefix = this._input.substring(nameOrPrefixStart, this._index - 1);
  8178. nameStart = this._index;
  8179. }
  8180. else {
  8181. nameStart = nameOrPrefixStart;
  8182. }
  8183. this._requireCharCodeUntilFn(isNameEnd, this._index === nameStart ? 1 : 0);
  8184. var /** @type {?} */ name = this._input.substring(nameStart, this._index);
  8185. return [prefix, name];
  8186. };
  8187. /**
  8188. * @param {?} start
  8189. * @return {?}
  8190. */
  8191. _Tokenizer.prototype._consumeTagOpen = /**
  8192. * @param {?} start
  8193. * @return {?}
  8194. */
  8195. function (start) {
  8196. var /** @type {?} */ savedPos = this._savePosition();
  8197. var /** @type {?} */ tagName;
  8198. var /** @type {?} */ lowercaseTagName;
  8199. try {
  8200. if (!isAsciiLetter(this._peek)) {
  8201. throw this._createError(_unexpectedCharacterErrorMsg(this._peek), this._getSpan());
  8202. }
  8203. var /** @type {?} */ nameStart = this._index;
  8204. this._consumeTagOpenStart(start);
  8205. tagName = this._input.substring(nameStart, this._index);
  8206. lowercaseTagName = tagName.toLowerCase();
  8207. this._attemptCharCodeUntilFn(isNotWhitespace);
  8208. while (this._peek !== $SLASH && this._peek !== $GT) {
  8209. this._consumeAttributeName();
  8210. this._attemptCharCodeUntilFn(isNotWhitespace);
  8211. if (this._attemptCharCode($EQ)) {
  8212. this._attemptCharCodeUntilFn(isNotWhitespace);
  8213. this._consumeAttributeValue();
  8214. }
  8215. this._attemptCharCodeUntilFn(isNotWhitespace);
  8216. }
  8217. this._consumeTagOpenEnd();
  8218. }
  8219. catch (/** @type {?} */ e) {
  8220. if (e instanceof _ControlFlowError) {
  8221. // When the start tag is invalid, assume we want a "<"
  8222. this._restorePosition(savedPos);
  8223. // Back to back text tokens are merged at the end
  8224. this._beginToken(TokenType$1.TEXT, start);
  8225. this._endToken(['<']);
  8226. return;
  8227. }
  8228. throw e;
  8229. }
  8230. var /** @type {?} */ contentTokenType = this._getTagDefinition(tagName).contentType;
  8231. if (contentTokenType === TagContentType.RAW_TEXT) {
  8232. this._consumeRawTextWithTagClose(lowercaseTagName, false);
  8233. }
  8234. else if (contentTokenType === TagContentType.ESCAPABLE_RAW_TEXT) {
  8235. this._consumeRawTextWithTagClose(lowercaseTagName, true);
  8236. }
  8237. };
  8238. /**
  8239. * @param {?} lowercaseTagName
  8240. * @param {?} decodeEntities
  8241. * @return {?}
  8242. */
  8243. _Tokenizer.prototype._consumeRawTextWithTagClose = /**
  8244. * @param {?} lowercaseTagName
  8245. * @param {?} decodeEntities
  8246. * @return {?}
  8247. */
  8248. function (lowercaseTagName, decodeEntities) {
  8249. var _this = this;
  8250. var /** @type {?} */ textToken = this._consumeRawText(decodeEntities, $LT, function () {
  8251. if (!_this._attemptCharCode($SLASH))
  8252. return false;
  8253. _this._attemptCharCodeUntilFn(isNotWhitespace);
  8254. if (!_this._attemptStrCaseInsensitive(lowercaseTagName))
  8255. return false;
  8256. _this._attemptCharCodeUntilFn(isNotWhitespace);
  8257. return _this._attemptCharCode($GT);
  8258. });
  8259. this._beginToken(TokenType$1.TAG_CLOSE, textToken.sourceSpan.end);
  8260. this._endToken([/** @type {?} */ ((null)), lowercaseTagName]);
  8261. };
  8262. /**
  8263. * @param {?} start
  8264. * @return {?}
  8265. */
  8266. _Tokenizer.prototype._consumeTagOpenStart = /**
  8267. * @param {?} start
  8268. * @return {?}
  8269. */
  8270. function (start) {
  8271. this._beginToken(TokenType$1.TAG_OPEN_START, start);
  8272. var /** @type {?} */ parts = this._consumePrefixAndName();
  8273. this._endToken(parts);
  8274. };
  8275. /**
  8276. * @return {?}
  8277. */
  8278. _Tokenizer.prototype._consumeAttributeName = /**
  8279. * @return {?}
  8280. */
  8281. function () {
  8282. this._beginToken(TokenType$1.ATTR_NAME);
  8283. var /** @type {?} */ prefixAndName = this._consumePrefixAndName();
  8284. this._endToken(prefixAndName);
  8285. };
  8286. /**
  8287. * @return {?}
  8288. */
  8289. _Tokenizer.prototype._consumeAttributeValue = /**
  8290. * @return {?}
  8291. */
  8292. function () {
  8293. this._beginToken(TokenType$1.ATTR_VALUE);
  8294. var /** @type {?} */ value;
  8295. if (this._peek === $SQ || this._peek === $DQ) {
  8296. var /** @type {?} */ quoteChar = this._peek;
  8297. this._advance();
  8298. var /** @type {?} */ parts = [];
  8299. while (this._peek !== quoteChar) {
  8300. parts.push(this._readChar(true));
  8301. }
  8302. value = parts.join('');
  8303. this._advance();
  8304. }
  8305. else {
  8306. var /** @type {?} */ valueStart = this._index;
  8307. this._requireCharCodeUntilFn(isNameEnd, 1);
  8308. value = this._input.substring(valueStart, this._index);
  8309. }
  8310. this._endToken([this._processCarriageReturns(value)]);
  8311. };
  8312. /**
  8313. * @return {?}
  8314. */
  8315. _Tokenizer.prototype._consumeTagOpenEnd = /**
  8316. * @return {?}
  8317. */
  8318. function () {
  8319. var /** @type {?} */ tokenType = this._attemptCharCode($SLASH) ? TokenType$1.TAG_OPEN_END_VOID : TokenType$1.TAG_OPEN_END;
  8320. this._beginToken(tokenType);
  8321. this._requireCharCode($GT);
  8322. this._endToken([]);
  8323. };
  8324. /**
  8325. * @param {?} start
  8326. * @return {?}
  8327. */
  8328. _Tokenizer.prototype._consumeTagClose = /**
  8329. * @param {?} start
  8330. * @return {?}
  8331. */
  8332. function (start) {
  8333. this._beginToken(TokenType$1.TAG_CLOSE, start);
  8334. this._attemptCharCodeUntilFn(isNotWhitespace);
  8335. var /** @type {?} */ prefixAndName = this._consumePrefixAndName();
  8336. this._attemptCharCodeUntilFn(isNotWhitespace);
  8337. this._requireCharCode($GT);
  8338. this._endToken(prefixAndName);
  8339. };
  8340. /**
  8341. * @return {?}
  8342. */
  8343. _Tokenizer.prototype._consumeExpansionFormStart = /**
  8344. * @return {?}
  8345. */
  8346. function () {
  8347. this._beginToken(TokenType$1.EXPANSION_FORM_START, this._getLocation());
  8348. this._requireCharCode($LBRACE);
  8349. this._endToken([]);
  8350. this._expansionCaseStack.push(TokenType$1.EXPANSION_FORM_START);
  8351. this._beginToken(TokenType$1.RAW_TEXT, this._getLocation());
  8352. var /** @type {?} */ condition = this._readUntil($COMMA);
  8353. this._endToken([condition], this._getLocation());
  8354. this._requireCharCode($COMMA);
  8355. this._attemptCharCodeUntilFn(isNotWhitespace);
  8356. this._beginToken(TokenType$1.RAW_TEXT, this._getLocation());
  8357. var /** @type {?} */ type = this._readUntil($COMMA);
  8358. this._endToken([type], this._getLocation());
  8359. this._requireCharCode($COMMA);
  8360. this._attemptCharCodeUntilFn(isNotWhitespace);
  8361. };
  8362. /**
  8363. * @return {?}
  8364. */
  8365. _Tokenizer.prototype._consumeExpansionCaseStart = /**
  8366. * @return {?}
  8367. */
  8368. function () {
  8369. this._beginToken(TokenType$1.EXPANSION_CASE_VALUE, this._getLocation());
  8370. var /** @type {?} */ value = this._readUntil($LBRACE).trim();
  8371. this._endToken([value], this._getLocation());
  8372. this._attemptCharCodeUntilFn(isNotWhitespace);
  8373. this._beginToken(TokenType$1.EXPANSION_CASE_EXP_START, this._getLocation());
  8374. this._requireCharCode($LBRACE);
  8375. this._endToken([], this._getLocation());
  8376. this._attemptCharCodeUntilFn(isNotWhitespace);
  8377. this._expansionCaseStack.push(TokenType$1.EXPANSION_CASE_EXP_START);
  8378. };
  8379. /**
  8380. * @return {?}
  8381. */
  8382. _Tokenizer.prototype._consumeExpansionCaseEnd = /**
  8383. * @return {?}
  8384. */
  8385. function () {
  8386. this._beginToken(TokenType$1.EXPANSION_CASE_EXP_END, this._getLocation());
  8387. this._requireCharCode($RBRACE);
  8388. this._endToken([], this._getLocation());
  8389. this._attemptCharCodeUntilFn(isNotWhitespace);
  8390. this._expansionCaseStack.pop();
  8391. };
  8392. /**
  8393. * @return {?}
  8394. */
  8395. _Tokenizer.prototype._consumeExpansionFormEnd = /**
  8396. * @return {?}
  8397. */
  8398. function () {
  8399. this._beginToken(TokenType$1.EXPANSION_FORM_END, this._getLocation());
  8400. this._requireCharCode($RBRACE);
  8401. this._endToken([]);
  8402. this._expansionCaseStack.pop();
  8403. };
  8404. /**
  8405. * @return {?}
  8406. */
  8407. _Tokenizer.prototype._consumeText = /**
  8408. * @return {?}
  8409. */
  8410. function () {
  8411. var /** @type {?} */ start = this._getLocation();
  8412. this._beginToken(TokenType$1.TEXT, start);
  8413. var /** @type {?} */ parts = [];
  8414. do {
  8415. if (this._interpolationConfig && this._attemptStr(this._interpolationConfig.start)) {
  8416. parts.push(this._interpolationConfig.start);
  8417. this._inInterpolation = true;
  8418. }
  8419. else if (this._interpolationConfig && this._inInterpolation &&
  8420. this._attemptStr(this._interpolationConfig.end)) {
  8421. parts.push(this._interpolationConfig.end);
  8422. this._inInterpolation = false;
  8423. }
  8424. else {
  8425. parts.push(this._readChar(true));
  8426. }
  8427. } while (!this._isTextEnd());
  8428. this._endToken([this._processCarriageReturns(parts.join(''))]);
  8429. };
  8430. /**
  8431. * @return {?}
  8432. */
  8433. _Tokenizer.prototype._isTextEnd = /**
  8434. * @return {?}
  8435. */
  8436. function () {
  8437. if (this._peek === $LT || this._peek === $EOF) {
  8438. return true;
  8439. }
  8440. if (this._tokenizeIcu && !this._inInterpolation) {
  8441. if (isExpansionFormStart(this._input, this._index, this._interpolationConfig)) {
  8442. // start of an expansion form
  8443. return true;
  8444. }
  8445. if (this._peek === $RBRACE && this._isInExpansionCase()) {
  8446. // end of and expansion case
  8447. return true;
  8448. }
  8449. }
  8450. return false;
  8451. };
  8452. /**
  8453. * @return {?}
  8454. */
  8455. _Tokenizer.prototype._savePosition = /**
  8456. * @return {?}
  8457. */
  8458. function () {
  8459. return [this._peek, this._index, this._column, this._line, this.tokens.length];
  8460. };
  8461. /**
  8462. * @param {?} char
  8463. * @return {?}
  8464. */
  8465. _Tokenizer.prototype._readUntil = /**
  8466. * @param {?} char
  8467. * @return {?}
  8468. */
  8469. function (char) {
  8470. var /** @type {?} */ start = this._index;
  8471. this._attemptUntilChar(char);
  8472. return this._input.substring(start, this._index);
  8473. };
  8474. /**
  8475. * @param {?} position
  8476. * @return {?}
  8477. */
  8478. _Tokenizer.prototype._restorePosition = /**
  8479. * @param {?} position
  8480. * @return {?}
  8481. */
  8482. function (position) {
  8483. this._peek = position[0];
  8484. this._index = position[1];
  8485. this._column = position[2];
  8486. this._line = position[3];
  8487. var /** @type {?} */ nbTokens = position[4];
  8488. if (nbTokens < this.tokens.length) {
  8489. // remove any extra tokens
  8490. this.tokens = this.tokens.slice(0, nbTokens);
  8491. }
  8492. };
  8493. /**
  8494. * @return {?}
  8495. */
  8496. _Tokenizer.prototype._isInExpansionCase = /**
  8497. * @return {?}
  8498. */
  8499. function () {
  8500. return this._expansionCaseStack.length > 0 &&
  8501. this._expansionCaseStack[this._expansionCaseStack.length - 1] ===
  8502. TokenType$1.EXPANSION_CASE_EXP_START;
  8503. };
  8504. /**
  8505. * @return {?}
  8506. */
  8507. _Tokenizer.prototype._isInExpansionForm = /**
  8508. * @return {?}
  8509. */
  8510. function () {
  8511. return this._expansionCaseStack.length > 0 &&
  8512. this._expansionCaseStack[this._expansionCaseStack.length - 1] ===
  8513. TokenType$1.EXPANSION_FORM_START;
  8514. };
  8515. return _Tokenizer;
  8516. }());
  8517. /**
  8518. * @param {?} code
  8519. * @return {?}
  8520. */
  8521. function isNotWhitespace(code) {
  8522. return !isWhitespace(code) || code === $EOF;
  8523. }
  8524. /**
  8525. * @param {?} code
  8526. * @return {?}
  8527. */
  8528. function isNameEnd(code) {
  8529. return isWhitespace(code) || code === $GT || code === $SLASH ||
  8530. code === $SQ || code === $DQ || code === $EQ;
  8531. }
  8532. /**
  8533. * @param {?} code
  8534. * @return {?}
  8535. */
  8536. function isPrefixEnd(code) {
  8537. return (code < $a || $z < code) && (code < $A || $Z < code) &&
  8538. (code < $0 || code > $9);
  8539. }
  8540. /**
  8541. * @param {?} code
  8542. * @return {?}
  8543. */
  8544. function isDigitEntityEnd(code) {
  8545. return code == $SEMICOLON || code == $EOF || !isAsciiHexDigit(code);
  8546. }
  8547. /**
  8548. * @param {?} code
  8549. * @return {?}
  8550. */
  8551. function isNamedEntityEnd(code) {
  8552. return code == $SEMICOLON || code == $EOF || !isAsciiLetter(code);
  8553. }
  8554. /**
  8555. * @param {?} input
  8556. * @param {?} offset
  8557. * @param {?} interpolationConfig
  8558. * @return {?}
  8559. */
  8560. function isExpansionFormStart(input, offset, interpolationConfig) {
  8561. var /** @type {?} */ isInterpolationStart = interpolationConfig ? input.indexOf(interpolationConfig.start, offset) == offset : false;
  8562. return input.charCodeAt(offset) == $LBRACE && !isInterpolationStart;
  8563. }
  8564. /**
  8565. * @param {?} peek
  8566. * @return {?}
  8567. */
  8568. function isExpansionCaseStart(peek) {
  8569. return peek === $EQ || isAsciiLetter(peek) || isDigit(peek);
  8570. }
  8571. /**
  8572. * @param {?} code1
  8573. * @param {?} code2
  8574. * @return {?}
  8575. */
  8576. function compareCharCodeCaseInsensitive(code1, code2) {
  8577. return toUpperCaseCharCode(code1) == toUpperCaseCharCode(code2);
  8578. }
  8579. /**
  8580. * @param {?} code
  8581. * @return {?}
  8582. */
  8583. function toUpperCaseCharCode(code) {
  8584. return code >= $a && code <= $z ? code - $a + $A : code;
  8585. }
  8586. /**
  8587. * @param {?} srcTokens
  8588. * @return {?}
  8589. */
  8590. function mergeTextTokens(srcTokens) {
  8591. var /** @type {?} */ dstTokens = [];
  8592. var /** @type {?} */ lastDstToken = undefined;
  8593. for (var /** @type {?} */ i = 0; i < srcTokens.length; i++) {
  8594. var /** @type {?} */ token = srcTokens[i];
  8595. if (lastDstToken && lastDstToken.type == TokenType$1.TEXT && token.type == TokenType$1.TEXT) {
  8596. lastDstToken.parts[0] += token.parts[0];
  8597. lastDstToken.sourceSpan.end = token.sourceSpan.end;
  8598. }
  8599. else {
  8600. lastDstToken = token;
  8601. dstTokens.push(lastDstToken);
  8602. }
  8603. }
  8604. return dstTokens;
  8605. }
  8606. /**
  8607. * @fileoverview added by tsickle
  8608. * @suppress {checkTypes} checked by tsc
  8609. */
  8610. /**
  8611. * @license
  8612. * Copyright Google Inc. All Rights Reserved.
  8613. *
  8614. * Use of this source code is governed by an MIT-style license that can be
  8615. * found in the LICENSE file at https://angular.io/license
  8616. */
  8617. var TreeError = /** @class */ (function (_super) {
  8618. __extends(TreeError, _super);
  8619. function TreeError(elementName, span, msg) {
  8620. var _this = _super.call(this, span, msg) || this;
  8621. _this.elementName = elementName;
  8622. return _this;
  8623. }
  8624. /**
  8625. * @param {?} elementName
  8626. * @param {?} span
  8627. * @param {?} msg
  8628. * @return {?}
  8629. */
  8630. TreeError.create = /**
  8631. * @param {?} elementName
  8632. * @param {?} span
  8633. * @param {?} msg
  8634. * @return {?}
  8635. */
  8636. function (elementName, span, msg) {
  8637. return new TreeError(elementName, span, msg);
  8638. };
  8639. return TreeError;
  8640. }(ParseError));
  8641. var ParseTreeResult = /** @class */ (function () {
  8642. function ParseTreeResult(rootNodes, errors) {
  8643. this.rootNodes = rootNodes;
  8644. this.errors = errors;
  8645. }
  8646. return ParseTreeResult;
  8647. }());
  8648. var Parser$1 = /** @class */ (function () {
  8649. function Parser(getTagDefinition) {
  8650. this.getTagDefinition = getTagDefinition;
  8651. }
  8652. /**
  8653. * @param {?} source
  8654. * @param {?} url
  8655. * @param {?=} parseExpansionForms
  8656. * @param {?=} interpolationConfig
  8657. * @return {?}
  8658. */
  8659. Parser.prototype.parse = /**
  8660. * @param {?} source
  8661. * @param {?} url
  8662. * @param {?=} parseExpansionForms
  8663. * @param {?=} interpolationConfig
  8664. * @return {?}
  8665. */
  8666. function (source, url, parseExpansionForms, interpolationConfig) {
  8667. if (parseExpansionForms === void 0) { parseExpansionForms = false; }
  8668. if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
  8669. var /** @type {?} */ tokensAndErrors = tokenize(source, url, this.getTagDefinition, parseExpansionForms, interpolationConfig);
  8670. var /** @type {?} */ treeAndErrors = new _TreeBuilder(tokensAndErrors.tokens, this.getTagDefinition).build();
  8671. return new ParseTreeResult(treeAndErrors.rootNodes, (/** @type {?} */ (tokensAndErrors.errors)).concat(treeAndErrors.errors));
  8672. };
  8673. return Parser;
  8674. }());
  8675. var _TreeBuilder = /** @class */ (function () {
  8676. function _TreeBuilder(tokens, getTagDefinition) {
  8677. this.tokens = tokens;
  8678. this.getTagDefinition = getTagDefinition;
  8679. this._index = -1;
  8680. this._rootNodes = [];
  8681. this._errors = [];
  8682. this._elementStack = [];
  8683. this._advance();
  8684. }
  8685. /**
  8686. * @return {?}
  8687. */
  8688. _TreeBuilder.prototype.build = /**
  8689. * @return {?}
  8690. */
  8691. function () {
  8692. while (this._peek.type !== TokenType$1.EOF) {
  8693. if (this._peek.type === TokenType$1.TAG_OPEN_START) {
  8694. this._consumeStartTag(this._advance());
  8695. }
  8696. else if (this._peek.type === TokenType$1.TAG_CLOSE) {
  8697. this._consumeEndTag(this._advance());
  8698. }
  8699. else if (this._peek.type === TokenType$1.CDATA_START) {
  8700. this._closeVoidElement();
  8701. this._consumeCdata(this._advance());
  8702. }
  8703. else if (this._peek.type === TokenType$1.COMMENT_START) {
  8704. this._closeVoidElement();
  8705. this._consumeComment(this._advance());
  8706. }
  8707. else if (this._peek.type === TokenType$1.TEXT || this._peek.type === TokenType$1.RAW_TEXT ||
  8708. this._peek.type === TokenType$1.ESCAPABLE_RAW_TEXT) {
  8709. this._closeVoidElement();
  8710. this._consumeText(this._advance());
  8711. }
  8712. else if (this._peek.type === TokenType$1.EXPANSION_FORM_START) {
  8713. this._consumeExpansion(this._advance());
  8714. }
  8715. else {
  8716. // Skip all other tokens...
  8717. this._advance();
  8718. }
  8719. }
  8720. return new ParseTreeResult(this._rootNodes, this._errors);
  8721. };
  8722. /**
  8723. * @return {?}
  8724. */
  8725. _TreeBuilder.prototype._advance = /**
  8726. * @return {?}
  8727. */
  8728. function () {
  8729. var /** @type {?} */ prev = this._peek;
  8730. if (this._index < this.tokens.length - 1) {
  8731. // Note: there is always an EOF token at the end
  8732. this._index++;
  8733. }
  8734. this._peek = this.tokens[this._index];
  8735. return prev;
  8736. };
  8737. /**
  8738. * @param {?} type
  8739. * @return {?}
  8740. */
  8741. _TreeBuilder.prototype._advanceIf = /**
  8742. * @param {?} type
  8743. * @return {?}
  8744. */
  8745. function (type) {
  8746. if (this._peek.type === type) {
  8747. return this._advance();
  8748. }
  8749. return null;
  8750. };
  8751. /**
  8752. * @param {?} startToken
  8753. * @return {?}
  8754. */
  8755. _TreeBuilder.prototype._consumeCdata = /**
  8756. * @param {?} startToken
  8757. * @return {?}
  8758. */
  8759. function (startToken) {
  8760. this._consumeText(this._advance());
  8761. this._advanceIf(TokenType$1.CDATA_END);
  8762. };
  8763. /**
  8764. * @param {?} token
  8765. * @return {?}
  8766. */
  8767. _TreeBuilder.prototype._consumeComment = /**
  8768. * @param {?} token
  8769. * @return {?}
  8770. */
  8771. function (token) {
  8772. var /** @type {?} */ text = this._advanceIf(TokenType$1.RAW_TEXT);
  8773. this._advanceIf(TokenType$1.COMMENT_END);
  8774. var /** @type {?} */ value = text != null ? text.parts[0].trim() : null;
  8775. this._addToParent(new Comment(value, token.sourceSpan));
  8776. };
  8777. /**
  8778. * @param {?} token
  8779. * @return {?}
  8780. */
  8781. _TreeBuilder.prototype._consumeExpansion = /**
  8782. * @param {?} token
  8783. * @return {?}
  8784. */
  8785. function (token) {
  8786. var /** @type {?} */ switchValue = this._advance();
  8787. var /** @type {?} */ type = this._advance();
  8788. var /** @type {?} */ cases = [];
  8789. // read =
  8790. while (this._peek.type === TokenType$1.EXPANSION_CASE_VALUE) {
  8791. var /** @type {?} */ expCase = this._parseExpansionCase();
  8792. if (!expCase)
  8793. return; // error
  8794. cases.push(expCase);
  8795. }
  8796. // read the final }
  8797. if (this._peek.type !== TokenType$1.EXPANSION_FORM_END) {
  8798. this._errors.push(TreeError.create(null, this._peek.sourceSpan, "Invalid ICU message. Missing '}'."));
  8799. return;
  8800. }
  8801. var /** @type {?} */ sourceSpan = new ParseSourceSpan(token.sourceSpan.start, this._peek.sourceSpan.end);
  8802. this._addToParent(new Expansion(switchValue.parts[0], type.parts[0], cases, sourceSpan, switchValue.sourceSpan));
  8803. this._advance();
  8804. };
  8805. /**
  8806. * @return {?}
  8807. */
  8808. _TreeBuilder.prototype._parseExpansionCase = /**
  8809. * @return {?}
  8810. */
  8811. function () {
  8812. var /** @type {?} */ value = this._advance();
  8813. // read {
  8814. if (this._peek.type !== TokenType$1.EXPANSION_CASE_EXP_START) {
  8815. this._errors.push(TreeError.create(null, this._peek.sourceSpan, "Invalid ICU message. Missing '{'."));
  8816. return null;
  8817. }
  8818. // read until }
  8819. var /** @type {?} */ start = this._advance();
  8820. var /** @type {?} */ exp = this._collectExpansionExpTokens(start);
  8821. if (!exp)
  8822. return null;
  8823. var /** @type {?} */ end = this._advance();
  8824. exp.push(new Token$1(TokenType$1.EOF, [], end.sourceSpan));
  8825. // parse everything in between { and }
  8826. var /** @type {?} */ parsedExp = new _TreeBuilder(exp, this.getTagDefinition).build();
  8827. if (parsedExp.errors.length > 0) {
  8828. this._errors = this._errors.concat(/** @type {?} */ (parsedExp.errors));
  8829. return null;
  8830. }
  8831. var /** @type {?} */ sourceSpan = new ParseSourceSpan(value.sourceSpan.start, end.sourceSpan.end);
  8832. var /** @type {?} */ expSourceSpan = new ParseSourceSpan(start.sourceSpan.start, end.sourceSpan.end);
  8833. return new ExpansionCase(value.parts[0], parsedExp.rootNodes, sourceSpan, value.sourceSpan, expSourceSpan);
  8834. };
  8835. /**
  8836. * @param {?} start
  8837. * @return {?}
  8838. */
  8839. _TreeBuilder.prototype._collectExpansionExpTokens = /**
  8840. * @param {?} start
  8841. * @return {?}
  8842. */
  8843. function (start) {
  8844. var /** @type {?} */ exp = [];
  8845. var /** @type {?} */ expansionFormStack = [TokenType$1.EXPANSION_CASE_EXP_START];
  8846. while (true) {
  8847. if (this._peek.type === TokenType$1.EXPANSION_FORM_START ||
  8848. this._peek.type === TokenType$1.EXPANSION_CASE_EXP_START) {
  8849. expansionFormStack.push(this._peek.type);
  8850. }
  8851. if (this._peek.type === TokenType$1.EXPANSION_CASE_EXP_END) {
  8852. if (lastOnStack(expansionFormStack, TokenType$1.EXPANSION_CASE_EXP_START)) {
  8853. expansionFormStack.pop();
  8854. if (expansionFormStack.length == 0)
  8855. return exp;
  8856. }
  8857. else {
  8858. this._errors.push(TreeError.create(null, start.sourceSpan, "Invalid ICU message. Missing '}'."));
  8859. return null;
  8860. }
  8861. }
  8862. if (this._peek.type === TokenType$1.EXPANSION_FORM_END) {
  8863. if (lastOnStack(expansionFormStack, TokenType$1.EXPANSION_FORM_START)) {
  8864. expansionFormStack.pop();
  8865. }
  8866. else {
  8867. this._errors.push(TreeError.create(null, start.sourceSpan, "Invalid ICU message. Missing '}'."));
  8868. return null;
  8869. }
  8870. }
  8871. if (this._peek.type === TokenType$1.EOF) {
  8872. this._errors.push(TreeError.create(null, start.sourceSpan, "Invalid ICU message. Missing '}'."));
  8873. return null;
  8874. }
  8875. exp.push(this._advance());
  8876. }
  8877. };
  8878. /**
  8879. * @param {?} token
  8880. * @return {?}
  8881. */
  8882. _TreeBuilder.prototype._consumeText = /**
  8883. * @param {?} token
  8884. * @return {?}
  8885. */
  8886. function (token) {
  8887. var /** @type {?} */ text = token.parts[0];
  8888. if (text.length > 0 && text[0] == '\n') {
  8889. var /** @type {?} */ parent_1 = this._getParentElement();
  8890. if (parent_1 != null && parent_1.children.length == 0 &&
  8891. this.getTagDefinition(parent_1.name).ignoreFirstLf) {
  8892. text = text.substring(1);
  8893. }
  8894. }
  8895. if (text.length > 0) {
  8896. this._addToParent(new Text(text, token.sourceSpan));
  8897. }
  8898. };
  8899. /**
  8900. * @return {?}
  8901. */
  8902. _TreeBuilder.prototype._closeVoidElement = /**
  8903. * @return {?}
  8904. */
  8905. function () {
  8906. var /** @type {?} */ el = this._getParentElement();
  8907. if (el && this.getTagDefinition(el.name).isVoid) {
  8908. this._elementStack.pop();
  8909. }
  8910. };
  8911. /**
  8912. * @param {?} startTagToken
  8913. * @return {?}
  8914. */
  8915. _TreeBuilder.prototype._consumeStartTag = /**
  8916. * @param {?} startTagToken
  8917. * @return {?}
  8918. */
  8919. function (startTagToken) {
  8920. var /** @type {?} */ prefix = startTagToken.parts[0];
  8921. var /** @type {?} */ name = startTagToken.parts[1];
  8922. var /** @type {?} */ attrs = [];
  8923. while (this._peek.type === TokenType$1.ATTR_NAME) {
  8924. attrs.push(this._consumeAttr(this._advance()));
  8925. }
  8926. var /** @type {?} */ fullName = this._getElementFullName(prefix, name, this._getParentElement());
  8927. var /** @type {?} */ selfClosing = false;
  8928. // Note: There could have been a tokenizer error
  8929. // so that we don't get a token for the end tag...
  8930. if (this._peek.type === TokenType$1.TAG_OPEN_END_VOID) {
  8931. this._advance();
  8932. selfClosing = true;
  8933. var /** @type {?} */ tagDef = this.getTagDefinition(fullName);
  8934. if (!(tagDef.canSelfClose || getNsPrefix(fullName) !== null || tagDef.isVoid)) {
  8935. this._errors.push(TreeError.create(fullName, startTagToken.sourceSpan, "Only void and foreign elements can be self closed \"" + startTagToken.parts[1] + "\""));
  8936. }
  8937. }
  8938. else if (this._peek.type === TokenType$1.TAG_OPEN_END) {
  8939. this._advance();
  8940. selfClosing = false;
  8941. }
  8942. var /** @type {?} */ end = this._peek.sourceSpan.start;
  8943. var /** @type {?} */ span = new ParseSourceSpan(startTagToken.sourceSpan.start, end);
  8944. var /** @type {?} */ el = new Element(fullName, attrs, [], span, span, undefined);
  8945. this._pushElement(el);
  8946. if (selfClosing) {
  8947. this._popElement(fullName);
  8948. el.endSourceSpan = span;
  8949. }
  8950. };
  8951. /**
  8952. * @param {?} el
  8953. * @return {?}
  8954. */
  8955. _TreeBuilder.prototype._pushElement = /**
  8956. * @param {?} el
  8957. * @return {?}
  8958. */
  8959. function (el) {
  8960. var /** @type {?} */ parentEl = this._getParentElement();
  8961. if (parentEl && this.getTagDefinition(parentEl.name).isClosedByChild(el.name)) {
  8962. this._elementStack.pop();
  8963. }
  8964. var /** @type {?} */ tagDef = this.getTagDefinition(el.name);
  8965. var _a = this._getParentElementSkippingContainers(), parent = _a.parent, container = _a.container;
  8966. if (parent && tagDef.requireExtraParent(parent.name)) {
  8967. var /** @type {?} */ newParent = new Element(tagDef.parentToAdd, [], [], el.sourceSpan, el.startSourceSpan, el.endSourceSpan);
  8968. this._insertBeforeContainer(parent, container, newParent);
  8969. }
  8970. this._addToParent(el);
  8971. this._elementStack.push(el);
  8972. };
  8973. /**
  8974. * @param {?} endTagToken
  8975. * @return {?}
  8976. */
  8977. _TreeBuilder.prototype._consumeEndTag = /**
  8978. * @param {?} endTagToken
  8979. * @return {?}
  8980. */
  8981. function (endTagToken) {
  8982. var /** @type {?} */ fullName = this._getElementFullName(endTagToken.parts[0], endTagToken.parts[1], this._getParentElement());
  8983. if (this._getParentElement()) {
  8984. /** @type {?} */ ((this._getParentElement())).endSourceSpan = endTagToken.sourceSpan;
  8985. }
  8986. if (this.getTagDefinition(fullName).isVoid) {
  8987. this._errors.push(TreeError.create(fullName, endTagToken.sourceSpan, "Void elements do not have end tags \"" + endTagToken.parts[1] + "\""));
  8988. }
  8989. else if (!this._popElement(fullName)) {
  8990. 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";
  8991. this._errors.push(TreeError.create(fullName, endTagToken.sourceSpan, errMsg));
  8992. }
  8993. };
  8994. /**
  8995. * @param {?} fullName
  8996. * @return {?}
  8997. */
  8998. _TreeBuilder.prototype._popElement = /**
  8999. * @param {?} fullName
  9000. * @return {?}
  9001. */
  9002. function (fullName) {
  9003. for (var /** @type {?} */ stackIndex = this._elementStack.length - 1; stackIndex >= 0; stackIndex--) {
  9004. var /** @type {?} */ el = this._elementStack[stackIndex];
  9005. if (el.name == fullName) {
  9006. this._elementStack.splice(stackIndex, this._elementStack.length - stackIndex);
  9007. return true;
  9008. }
  9009. if (!this.getTagDefinition(el.name).closedByParent) {
  9010. return false;
  9011. }
  9012. }
  9013. return false;
  9014. };
  9015. /**
  9016. * @param {?} attrName
  9017. * @return {?}
  9018. */
  9019. _TreeBuilder.prototype._consumeAttr = /**
  9020. * @param {?} attrName
  9021. * @return {?}
  9022. */
  9023. function (attrName) {
  9024. var /** @type {?} */ fullName = mergeNsAndName(attrName.parts[0], attrName.parts[1]);
  9025. var /** @type {?} */ end = attrName.sourceSpan.end;
  9026. var /** @type {?} */ value = '';
  9027. var /** @type {?} */ valueSpan = /** @type {?} */ ((undefined));
  9028. if (this._peek.type === TokenType$1.ATTR_VALUE) {
  9029. var /** @type {?} */ valueToken = this._advance();
  9030. value = valueToken.parts[0];
  9031. end = valueToken.sourceSpan.end;
  9032. valueSpan = valueToken.sourceSpan;
  9033. }
  9034. return new Attribute$1(fullName, value, new ParseSourceSpan(attrName.sourceSpan.start, end), valueSpan);
  9035. };
  9036. /**
  9037. * @return {?}
  9038. */
  9039. _TreeBuilder.prototype._getParentElement = /**
  9040. * @return {?}
  9041. */
  9042. function () {
  9043. return this._elementStack.length > 0 ? this._elementStack[this._elementStack.length - 1] : null;
  9044. };
  9045. /**
  9046. * Returns the parent in the DOM and the container.
  9047. *
  9048. * `<ng-container>` elements are skipped as they are not rendered as DOM element.
  9049. * @return {?}
  9050. */
  9051. _TreeBuilder.prototype._getParentElementSkippingContainers = /**
  9052. * Returns the parent in the DOM and the container.
  9053. *
  9054. * `<ng-container>` elements are skipped as they are not rendered as DOM element.
  9055. * @return {?}
  9056. */
  9057. function () {
  9058. var /** @type {?} */ container = null;
  9059. for (var /** @type {?} */ i = this._elementStack.length - 1; i >= 0; i--) {
  9060. if (!isNgContainer(this._elementStack[i].name)) {
  9061. return { parent: this._elementStack[i], container: container };
  9062. }
  9063. container = this._elementStack[i];
  9064. }
  9065. return { parent: null, container: container };
  9066. };
  9067. /**
  9068. * @param {?} node
  9069. * @return {?}
  9070. */
  9071. _TreeBuilder.prototype._addToParent = /**
  9072. * @param {?} node
  9073. * @return {?}
  9074. */
  9075. function (node) {
  9076. var /** @type {?} */ parent = this._getParentElement();
  9077. if (parent != null) {
  9078. parent.children.push(node);
  9079. }
  9080. else {
  9081. this._rootNodes.push(node);
  9082. }
  9083. };
  9084. /**
  9085. * Insert a node between the parent and the container.
  9086. * When no container is given, the node is appended as a child of the parent.
  9087. * Also updates the element stack accordingly.
  9088. *
  9089. * \@internal
  9090. * @param {?} parent
  9091. * @param {?} container
  9092. * @param {?} node
  9093. * @return {?}
  9094. */
  9095. _TreeBuilder.prototype._insertBeforeContainer = /**
  9096. * Insert a node between the parent and the container.
  9097. * When no container is given, the node is appended as a child of the parent.
  9098. * Also updates the element stack accordingly.
  9099. *
  9100. * \@internal
  9101. * @param {?} parent
  9102. * @param {?} container
  9103. * @param {?} node
  9104. * @return {?}
  9105. */
  9106. function (parent, container, node) {
  9107. if (!container) {
  9108. this._addToParent(node);
  9109. this._elementStack.push(node);
  9110. }
  9111. else {
  9112. if (parent) {
  9113. // replace the container with the new node in the children
  9114. var /** @type {?} */ index = parent.children.indexOf(container);
  9115. parent.children[index] = node;
  9116. }
  9117. else {
  9118. this._rootNodes.push(node);
  9119. }
  9120. node.children.push(container);
  9121. this._elementStack.splice(this._elementStack.indexOf(container), 0, node);
  9122. }
  9123. };
  9124. /**
  9125. * @param {?} prefix
  9126. * @param {?} localName
  9127. * @param {?} parentElement
  9128. * @return {?}
  9129. */
  9130. _TreeBuilder.prototype._getElementFullName = /**
  9131. * @param {?} prefix
  9132. * @param {?} localName
  9133. * @param {?} parentElement
  9134. * @return {?}
  9135. */
  9136. function (prefix, localName, parentElement) {
  9137. if (prefix == null) {
  9138. prefix = /** @type {?} */ ((this.getTagDefinition(localName).implicitNamespacePrefix));
  9139. if (prefix == null && parentElement != null) {
  9140. prefix = getNsPrefix(parentElement.name);
  9141. }
  9142. }
  9143. return mergeNsAndName(prefix, localName);
  9144. };
  9145. return _TreeBuilder;
  9146. }());
  9147. /**
  9148. * @param {?} stack
  9149. * @param {?} element
  9150. * @return {?}
  9151. */
  9152. function lastOnStack(stack, element) {
  9153. return stack.length > 0 && stack[stack.length - 1] === element;
  9154. }
  9155. /**
  9156. * @fileoverview added by tsickle
  9157. * @suppress {checkTypes} checked by tsc
  9158. */
  9159. /**
  9160. * @license
  9161. * Copyright Google Inc. All Rights Reserved.
  9162. *
  9163. * Use of this source code is governed by an MIT-style license that can be
  9164. * found in the LICENSE file at https://angular.io/license
  9165. */
  9166. /**
  9167. * @param {?} message
  9168. * @return {?}
  9169. */
  9170. function digest(message) {
  9171. return message.id || sha1(serializeNodes(message.nodes).join('') + ("[" + message.meaning + "]"));
  9172. }
  9173. /**
  9174. * @param {?} message
  9175. * @return {?}
  9176. */
  9177. function decimalDigest(message) {
  9178. if (message.id) {
  9179. return message.id;
  9180. }
  9181. var /** @type {?} */ visitor = new _SerializerIgnoreIcuExpVisitor();
  9182. var /** @type {?} */ parts = message.nodes.map(function (a) { return a.visit(visitor, null); });
  9183. return computeMsgId(parts.join(''), message.meaning);
  9184. }
  9185. /**
  9186. * Serialize the i18n ast to something xml-like in order to generate an UID.
  9187. *
  9188. * The visitor is also used in the i18n parser tests
  9189. *
  9190. * \@internal
  9191. */
  9192. var _SerializerVisitor = /** @class */ (function () {
  9193. function _SerializerVisitor() {
  9194. }
  9195. /**
  9196. * @param {?} text
  9197. * @param {?} context
  9198. * @return {?}
  9199. */
  9200. _SerializerVisitor.prototype.visitText = /**
  9201. * @param {?} text
  9202. * @param {?} context
  9203. * @return {?}
  9204. */
  9205. function (text, context) { return text.value; };
  9206. /**
  9207. * @param {?} container
  9208. * @param {?} context
  9209. * @return {?}
  9210. */
  9211. _SerializerVisitor.prototype.visitContainer = /**
  9212. * @param {?} container
  9213. * @param {?} context
  9214. * @return {?}
  9215. */
  9216. function (container, context) {
  9217. var _this = this;
  9218. return "[" + container.children.map(function (child) { return child.visit(_this); }).join(', ') + "]";
  9219. };
  9220. /**
  9221. * @param {?} icu
  9222. * @param {?} context
  9223. * @return {?}
  9224. */
  9225. _SerializerVisitor.prototype.visitIcu = /**
  9226. * @param {?} icu
  9227. * @param {?} context
  9228. * @return {?}
  9229. */
  9230. function (icu, context) {
  9231. var _this = this;
  9232. var /** @type {?} */ strCases = Object.keys(icu.cases).map(function (k) { return k + " {" + icu.cases[k].visit(_this) + "}"; });
  9233. return "{" + icu.expression + ", " + icu.type + ", " + strCases.join(', ') + "}";
  9234. };
  9235. /**
  9236. * @param {?} ph
  9237. * @param {?} context
  9238. * @return {?}
  9239. */
  9240. _SerializerVisitor.prototype.visitTagPlaceholder = /**
  9241. * @param {?} ph
  9242. * @param {?} context
  9243. * @return {?}
  9244. */
  9245. function (ph, context) {
  9246. var _this = this;
  9247. return ph.isVoid ?
  9248. "<ph tag name=\"" + ph.startName + "\"/>" :
  9249. "<ph tag name=\"" + ph.startName + "\">" + ph.children.map(function (child) { return child.visit(_this); }).join(', ') + "</ph name=\"" + ph.closeName + "\">";
  9250. };
  9251. /**
  9252. * @param {?} ph
  9253. * @param {?} context
  9254. * @return {?}
  9255. */
  9256. _SerializerVisitor.prototype.visitPlaceholder = /**
  9257. * @param {?} ph
  9258. * @param {?} context
  9259. * @return {?}
  9260. */
  9261. function (ph, context) {
  9262. return ph.value ? "<ph name=\"" + ph.name + "\">" + ph.value + "</ph>" : "<ph name=\"" + ph.name + "\"/>";
  9263. };
  9264. /**
  9265. * @param {?} ph
  9266. * @param {?=} context
  9267. * @return {?}
  9268. */
  9269. _SerializerVisitor.prototype.visitIcuPlaceholder = /**
  9270. * @param {?} ph
  9271. * @param {?=} context
  9272. * @return {?}
  9273. */
  9274. function (ph, context) {
  9275. return "<ph icu name=\"" + ph.name + "\">" + ph.value.visit(this) + "</ph>";
  9276. };
  9277. return _SerializerVisitor;
  9278. }());
  9279. var serializerVisitor = new _SerializerVisitor();
  9280. /**
  9281. * @param {?} nodes
  9282. * @return {?}
  9283. */
  9284. function serializeNodes(nodes) {
  9285. return nodes.map(function (a) { return a.visit(serializerVisitor, null); });
  9286. }
  9287. /**
  9288. * Serialize the i18n ast to something xml-like in order to generate an UID.
  9289. *
  9290. * Ignore the ICU expressions so that message IDs stays identical if only the expression changes.
  9291. *
  9292. * \@internal
  9293. */
  9294. var _SerializerIgnoreIcuExpVisitor = /** @class */ (function (_super) {
  9295. __extends(_SerializerIgnoreIcuExpVisitor, _super);
  9296. function _SerializerIgnoreIcuExpVisitor() {
  9297. return _super !== null && _super.apply(this, arguments) || this;
  9298. }
  9299. /**
  9300. * @param {?} icu
  9301. * @param {?} context
  9302. * @return {?}
  9303. */
  9304. _SerializerIgnoreIcuExpVisitor.prototype.visitIcu = /**
  9305. * @param {?} icu
  9306. * @param {?} context
  9307. * @return {?}
  9308. */
  9309. function (icu, context) {
  9310. var _this = this;
  9311. var /** @type {?} */ strCases = Object.keys(icu.cases).map(function (k) { return k + " {" + icu.cases[k].visit(_this) + "}"; });
  9312. // Do not take the expression into account
  9313. return "{" + icu.type + ", " + strCases.join(', ') + "}";
  9314. };
  9315. return _SerializerIgnoreIcuExpVisitor;
  9316. }(_SerializerVisitor));
  9317. /**
  9318. * Compute the SHA1 of the given string
  9319. *
  9320. * see http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf
  9321. *
  9322. * WARNING: this function has not been designed not tested with security in mind.
  9323. * DO NOT USE IT IN A SECURITY SENSITIVE CONTEXT.
  9324. * @param {?} str
  9325. * @return {?}
  9326. */
  9327. function sha1(str) {
  9328. var /** @type {?} */ utf8 = utf8Encode(str);
  9329. var /** @type {?} */ words32 = stringToWords32(utf8, Endian.Big);
  9330. var /** @type {?} */ len = utf8.length * 8;
  9331. var /** @type {?} */ w = new Array(80);
  9332. var _a = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0], a = _a[0], b = _a[1], c = _a[2], d = _a[3], e = _a[4];
  9333. words32[len >> 5] |= 0x80 << (24 - len % 32);
  9334. words32[((len + 64 >> 9) << 4) + 15] = len;
  9335. for (var /** @type {?} */ i = 0; i < words32.length; i += 16) {
  9336. var _b = [a, b, c, d, e], h0 = _b[0], h1 = _b[1], h2 = _b[2], h3 = _b[3], h4 = _b[4];
  9337. for (var /** @type {?} */ j = 0; j < 80; j++) {
  9338. if (j < 16) {
  9339. w[j] = words32[i + j];
  9340. }
  9341. else {
  9342. w[j] = rol32(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
  9343. }
  9344. var _c = fk(j, b, c, d), f = _c[0], k = _c[1];
  9345. var /** @type {?} */ temp = [rol32(a, 5), f, e, k, w[j]].reduce(add32);
  9346. _d = [d, c, rol32(b, 30), a, temp], e = _d[0], d = _d[1], c = _d[2], b = _d[3], a = _d[4];
  9347. }
  9348. _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];
  9349. }
  9350. return byteStringToHexString(words32ToByteString([a, b, c, d, e]));
  9351. var _d, _e;
  9352. }
  9353. /**
  9354. * @param {?} index
  9355. * @param {?} b
  9356. * @param {?} c
  9357. * @param {?} d
  9358. * @return {?}
  9359. */
  9360. function fk(index, b, c, d) {
  9361. if (index < 20) {
  9362. return [(b & c) | (~b & d), 0x5a827999];
  9363. }
  9364. if (index < 40) {
  9365. return [b ^ c ^ d, 0x6ed9eba1];
  9366. }
  9367. if (index < 60) {
  9368. return [(b & c) | (b & d) | (c & d), 0x8f1bbcdc];
  9369. }
  9370. return [b ^ c ^ d, 0xca62c1d6];
  9371. }
  9372. /**
  9373. * Compute the fingerprint of the given string
  9374. *
  9375. * The output is 64 bit number encoded as a decimal string
  9376. *
  9377. * based on:
  9378. * https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/GoogleJsMessageIdGenerator.java
  9379. * @param {?} str
  9380. * @return {?}
  9381. */
  9382. function fingerprint(str) {
  9383. var /** @type {?} */ utf8 = utf8Encode(str);
  9384. var _a = [hash32(utf8, 0), hash32(utf8, 102072)], hi = _a[0], lo = _a[1];
  9385. if (hi == 0 && (lo == 0 || lo == 1)) {
  9386. hi = hi ^ 0x130f9bef;
  9387. lo = lo ^ -0x6b5f56d8;
  9388. }
  9389. return [hi, lo];
  9390. }
  9391. /**
  9392. * @param {?} msg
  9393. * @param {?} meaning
  9394. * @return {?}
  9395. */
  9396. function computeMsgId(msg, meaning) {
  9397. var _a = fingerprint(msg), hi = _a[0], lo = _a[1];
  9398. if (meaning) {
  9399. var _b = fingerprint(meaning), him = _b[0], lom = _b[1];
  9400. _c = add64(rol64([hi, lo], 1), [him, lom]), hi = _c[0], lo = _c[1];
  9401. }
  9402. return byteStringToDecString(words32ToByteString([hi & 0x7fffffff, lo]));
  9403. var _c;
  9404. }
  9405. /**
  9406. * @param {?} str
  9407. * @param {?} c
  9408. * @return {?}
  9409. */
  9410. function hash32(str, c) {
  9411. var _a = [0x9e3779b9, 0x9e3779b9], a = _a[0], b = _a[1];
  9412. var /** @type {?} */ i;
  9413. var /** @type {?} */ len = str.length;
  9414. for (i = 0; i + 12 <= len; i += 12) {
  9415. a = add32(a, wordAt(str, i, Endian.Little));
  9416. b = add32(b, wordAt(str, i + 4, Endian.Little));
  9417. c = add32(c, wordAt(str, i + 8, Endian.Little));
  9418. _b = mix([a, b, c]), a = _b[0], b = _b[1], c = _b[2];
  9419. }
  9420. a = add32(a, wordAt(str, i, Endian.Little));
  9421. b = add32(b, wordAt(str, i + 4, Endian.Little));
  9422. // the first byte of c is reserved for the length
  9423. c = add32(c, len);
  9424. c = add32(c, wordAt(str, i + 8, Endian.Little) << 8);
  9425. return mix([a, b, c])[2];
  9426. var _b;
  9427. }
  9428. /**
  9429. * @param {?} __0
  9430. * @return {?}
  9431. */
  9432. function mix(_a) {
  9433. var a = _a[0], b = _a[1], c = _a[2];
  9434. a = sub32(a, b);
  9435. a = sub32(a, c);
  9436. a ^= c >>> 13;
  9437. b = sub32(b, c);
  9438. b = sub32(b, a);
  9439. b ^= a << 8;
  9440. c = sub32(c, a);
  9441. c = sub32(c, b);
  9442. c ^= b >>> 13;
  9443. a = sub32(a, b);
  9444. a = sub32(a, c);
  9445. a ^= c >>> 12;
  9446. b = sub32(b, c);
  9447. b = sub32(b, a);
  9448. b ^= a << 16;
  9449. c = sub32(c, a);
  9450. c = sub32(c, b);
  9451. c ^= b >>> 5;
  9452. a = sub32(a, b);
  9453. a = sub32(a, c);
  9454. a ^= c >>> 3;
  9455. b = sub32(b, c);
  9456. b = sub32(b, a);
  9457. b ^= a << 10;
  9458. c = sub32(c, a);
  9459. c = sub32(c, b);
  9460. c ^= b >>> 15;
  9461. return [a, b, c];
  9462. }
  9463. /** @enum {number} */
  9464. var Endian = {
  9465. Little: 0,
  9466. Big: 1,
  9467. };
  9468. Endian[Endian.Little] = "Little";
  9469. Endian[Endian.Big] = "Big";
  9470. /**
  9471. * @param {?} a
  9472. * @param {?} b
  9473. * @return {?}
  9474. */
  9475. function add32(a, b) {
  9476. return add32to64(a, b)[1];
  9477. }
  9478. /**
  9479. * @param {?} a
  9480. * @param {?} b
  9481. * @return {?}
  9482. */
  9483. function add32to64(a, b) {
  9484. var /** @type {?} */ low = (a & 0xffff) + (b & 0xffff);
  9485. var /** @type {?} */ high = (a >>> 16) + (b >>> 16) + (low >>> 16);
  9486. return [high >>> 16, (high << 16) | (low & 0xffff)];
  9487. }
  9488. /**
  9489. * @param {?} __0
  9490. * @param {?} __1
  9491. * @return {?}
  9492. */
  9493. function add64(_a, _b) {
  9494. var ah = _a[0], al = _a[1];
  9495. var bh = _b[0], bl = _b[1];
  9496. var _c = add32to64(al, bl), carry = _c[0], l = _c[1];
  9497. var /** @type {?} */ h = add32(add32(ah, bh), carry);
  9498. return [h, l];
  9499. }
  9500. /**
  9501. * @param {?} a
  9502. * @param {?} b
  9503. * @return {?}
  9504. */
  9505. function sub32(a, b) {
  9506. var /** @type {?} */ low = (a & 0xffff) - (b & 0xffff);
  9507. var /** @type {?} */ high = (a >> 16) - (b >> 16) + (low >> 16);
  9508. return (high << 16) | (low & 0xffff);
  9509. }
  9510. /**
  9511. * @param {?} a
  9512. * @param {?} count
  9513. * @return {?}
  9514. */
  9515. function rol32(a, count) {
  9516. return (a << count) | (a >>> (32 - count));
  9517. }
  9518. /**
  9519. * @param {?} __0
  9520. * @param {?} count
  9521. * @return {?}
  9522. */
  9523. function rol64(_a, count) {
  9524. var hi = _a[0], lo = _a[1];
  9525. var /** @type {?} */ h = (hi << count) | (lo >>> (32 - count));
  9526. var /** @type {?} */ l = (lo << count) | (hi >>> (32 - count));
  9527. return [h, l];
  9528. }
  9529. /**
  9530. * @param {?} str
  9531. * @param {?} endian
  9532. * @return {?}
  9533. */
  9534. function stringToWords32(str, endian) {
  9535. var /** @type {?} */ words32 = Array((str.length + 3) >>> 2);
  9536. for (var /** @type {?} */ i = 0; i < words32.length; i++) {
  9537. words32[i] = wordAt(str, i * 4, endian);
  9538. }
  9539. return words32;
  9540. }
  9541. /**
  9542. * @param {?} str
  9543. * @param {?} index
  9544. * @return {?}
  9545. */
  9546. function byteAt(str, index) {
  9547. return index >= str.length ? 0 : str.charCodeAt(index) & 0xff;
  9548. }
  9549. /**
  9550. * @param {?} str
  9551. * @param {?} index
  9552. * @param {?} endian
  9553. * @return {?}
  9554. */
  9555. function wordAt(str, index, endian) {
  9556. var /** @type {?} */ word = 0;
  9557. if (endian === Endian.Big) {
  9558. for (var /** @type {?} */ i = 0; i < 4; i++) {
  9559. word += byteAt(str, index + i) << (24 - 8 * i);
  9560. }
  9561. }
  9562. else {
  9563. for (var /** @type {?} */ i = 0; i < 4; i++) {
  9564. word += byteAt(str, index + i) << 8 * i;
  9565. }
  9566. }
  9567. return word;
  9568. }
  9569. /**
  9570. * @param {?} words32
  9571. * @return {?}
  9572. */
  9573. function words32ToByteString(words32) {
  9574. return words32.reduce(function (str, word) { return str + word32ToByteString(word); }, '');
  9575. }
  9576. /**
  9577. * @param {?} word
  9578. * @return {?}
  9579. */
  9580. function word32ToByteString(word) {
  9581. var /** @type {?} */ str = '';
  9582. for (var /** @type {?} */ i = 0; i < 4; i++) {
  9583. str += String.fromCharCode((word >>> 8 * (3 - i)) & 0xff);
  9584. }
  9585. return str;
  9586. }
  9587. /**
  9588. * @param {?} str
  9589. * @return {?}
  9590. */
  9591. function byteStringToHexString(str) {
  9592. var /** @type {?} */ hex = '';
  9593. for (var /** @type {?} */ i = 0; i < str.length; i++) {
  9594. var /** @type {?} */ b = byteAt(str, i);
  9595. hex += (b >>> 4).toString(16) + (b & 0x0f).toString(16);
  9596. }
  9597. return hex.toLowerCase();
  9598. }
  9599. /**
  9600. * @param {?} str
  9601. * @return {?}
  9602. */
  9603. function byteStringToDecString(str) {
  9604. var /** @type {?} */ decimal = '';
  9605. var /** @type {?} */ toThePower = '1';
  9606. for (var /** @type {?} */ i = str.length - 1; i >= 0; i--) {
  9607. decimal = addBigInt(decimal, numberTimesBigInt(byteAt(str, i), toThePower));
  9608. toThePower = numberTimesBigInt(256, toThePower);
  9609. }
  9610. return decimal.split('').reverse().join('');
  9611. }
  9612. /**
  9613. * @param {?} x
  9614. * @param {?} y
  9615. * @return {?}
  9616. */
  9617. function addBigInt(x, y) {
  9618. var /** @type {?} */ sum = '';
  9619. var /** @type {?} */ len = Math.max(x.length, y.length);
  9620. for (var /** @type {?} */ i = 0, /** @type {?} */ carry = 0; i < len || carry; i++) {
  9621. var /** @type {?} */ tmpSum = carry + +(x[i] || 0) + +(y[i] || 0);
  9622. if (tmpSum >= 10) {
  9623. carry = 1;
  9624. sum += tmpSum - 10;
  9625. }
  9626. else {
  9627. carry = 0;
  9628. sum += tmpSum;
  9629. }
  9630. }
  9631. return sum;
  9632. }
  9633. /**
  9634. * @param {?} num
  9635. * @param {?} b
  9636. * @return {?}
  9637. */
  9638. function numberTimesBigInt(num, b) {
  9639. var /** @type {?} */ product = '';
  9640. var /** @type {?} */ bToThePower = b;
  9641. for (; num !== 0; num = num >>> 1) {
  9642. if (num & 1)
  9643. product = addBigInt(product, bToThePower);
  9644. bToThePower = addBigInt(bToThePower, bToThePower);
  9645. }
  9646. return product;
  9647. }
  9648. /**
  9649. * @fileoverview added by tsickle
  9650. * @suppress {checkTypes} checked by tsc
  9651. */
  9652. /**
  9653. * @license
  9654. * Copyright Google Inc. All Rights Reserved.
  9655. *
  9656. * Use of this source code is governed by an MIT-style license that can be
  9657. * found in the LICENSE file at https://angular.io/license
  9658. */
  9659. var Message = /** @class */ (function () {
  9660. /**
  9661. * @param nodes message AST
  9662. * @param placeholders maps placeholder names to static content
  9663. * @param placeholderToMessage maps placeholder names to messages (used for nested ICU messages)
  9664. * @param meaning
  9665. * @param description
  9666. * @param id
  9667. */
  9668. function Message(nodes, placeholders, placeholderToMessage, meaning, description, id) {
  9669. this.nodes = nodes;
  9670. this.placeholders = placeholders;
  9671. this.placeholderToMessage = placeholderToMessage;
  9672. this.meaning = meaning;
  9673. this.description = description;
  9674. this.id = id;
  9675. if (nodes.length) {
  9676. this.sources = [{
  9677. filePath: nodes[0].sourceSpan.start.file.url,
  9678. startLine: nodes[0].sourceSpan.start.line + 1,
  9679. startCol: nodes[0].sourceSpan.start.col + 1,
  9680. endLine: nodes[nodes.length - 1].sourceSpan.end.line + 1,
  9681. endCol: nodes[0].sourceSpan.start.col + 1
  9682. }];
  9683. }
  9684. else {
  9685. this.sources = [];
  9686. }
  9687. }
  9688. return Message;
  9689. }());
  9690. /**
  9691. * @record
  9692. */
  9693. /**
  9694. * @record
  9695. */
  9696. var Text$1 = /** @class */ (function () {
  9697. function Text(value, sourceSpan) {
  9698. this.value = value;
  9699. this.sourceSpan = sourceSpan;
  9700. }
  9701. /**
  9702. * @param {?} visitor
  9703. * @param {?=} context
  9704. * @return {?}
  9705. */
  9706. Text.prototype.visit = /**
  9707. * @param {?} visitor
  9708. * @param {?=} context
  9709. * @return {?}
  9710. */
  9711. function (visitor, context) { return visitor.visitText(this, context); };
  9712. return Text;
  9713. }());
  9714. var Container = /** @class */ (function () {
  9715. function Container(children, sourceSpan) {
  9716. this.children = children;
  9717. this.sourceSpan = sourceSpan;
  9718. }
  9719. /**
  9720. * @param {?} visitor
  9721. * @param {?=} context
  9722. * @return {?}
  9723. */
  9724. Container.prototype.visit = /**
  9725. * @param {?} visitor
  9726. * @param {?=} context
  9727. * @return {?}
  9728. */
  9729. function (visitor, context) { return visitor.visitContainer(this, context); };
  9730. return Container;
  9731. }());
  9732. var Icu = /** @class */ (function () {
  9733. function Icu(expression, type, cases, sourceSpan) {
  9734. this.expression = expression;
  9735. this.type = type;
  9736. this.cases = cases;
  9737. this.sourceSpan = sourceSpan;
  9738. }
  9739. /**
  9740. * @param {?} visitor
  9741. * @param {?=} context
  9742. * @return {?}
  9743. */
  9744. Icu.prototype.visit = /**
  9745. * @param {?} visitor
  9746. * @param {?=} context
  9747. * @return {?}
  9748. */
  9749. function (visitor, context) { return visitor.visitIcu(this, context); };
  9750. return Icu;
  9751. }());
  9752. var TagPlaceholder = /** @class */ (function () {
  9753. function TagPlaceholder(tag, attrs, startName, closeName, children, isVoid, sourceSpan) {
  9754. this.tag = tag;
  9755. this.attrs = attrs;
  9756. this.startName = startName;
  9757. this.closeName = closeName;
  9758. this.children = children;
  9759. this.isVoid = isVoid;
  9760. this.sourceSpan = sourceSpan;
  9761. }
  9762. /**
  9763. * @param {?} visitor
  9764. * @param {?=} context
  9765. * @return {?}
  9766. */
  9767. TagPlaceholder.prototype.visit = /**
  9768. * @param {?} visitor
  9769. * @param {?=} context
  9770. * @return {?}
  9771. */
  9772. function (visitor, context) { return visitor.visitTagPlaceholder(this, context); };
  9773. return TagPlaceholder;
  9774. }());
  9775. var Placeholder = /** @class */ (function () {
  9776. function Placeholder(value, name, sourceSpan) {
  9777. this.value = value;
  9778. this.name = name;
  9779. this.sourceSpan = sourceSpan;
  9780. }
  9781. /**
  9782. * @param {?} visitor
  9783. * @param {?=} context
  9784. * @return {?}
  9785. */
  9786. Placeholder.prototype.visit = /**
  9787. * @param {?} visitor
  9788. * @param {?=} context
  9789. * @return {?}
  9790. */
  9791. function (visitor, context) { return visitor.visitPlaceholder(this, context); };
  9792. return Placeholder;
  9793. }());
  9794. var IcuPlaceholder = /** @class */ (function () {
  9795. function IcuPlaceholder(value, name, sourceSpan) {
  9796. this.value = value;
  9797. this.name = name;
  9798. this.sourceSpan = sourceSpan;
  9799. }
  9800. /**
  9801. * @param {?} visitor
  9802. * @param {?=} context
  9803. * @return {?}
  9804. */
  9805. IcuPlaceholder.prototype.visit = /**
  9806. * @param {?} visitor
  9807. * @param {?=} context
  9808. * @return {?}
  9809. */
  9810. function (visitor, context) { return visitor.visitIcuPlaceholder(this, context); };
  9811. return IcuPlaceholder;
  9812. }());
  9813. /**
  9814. * @record
  9815. */
  9816. var CloneVisitor = /** @class */ (function () {
  9817. function CloneVisitor() {
  9818. }
  9819. /**
  9820. * @param {?} text
  9821. * @param {?=} context
  9822. * @return {?}
  9823. */
  9824. CloneVisitor.prototype.visitText = /**
  9825. * @param {?} text
  9826. * @param {?=} context
  9827. * @return {?}
  9828. */
  9829. function (text, context) { return new Text$1(text.value, text.sourceSpan); };
  9830. /**
  9831. * @param {?} container
  9832. * @param {?=} context
  9833. * @return {?}
  9834. */
  9835. CloneVisitor.prototype.visitContainer = /**
  9836. * @param {?} container
  9837. * @param {?=} context
  9838. * @return {?}
  9839. */
  9840. function (container, context) {
  9841. var _this = this;
  9842. var /** @type {?} */ children = container.children.map(function (n) { return n.visit(_this, context); });
  9843. return new Container(children, container.sourceSpan);
  9844. };
  9845. /**
  9846. * @param {?} icu
  9847. * @param {?=} context
  9848. * @return {?}
  9849. */
  9850. CloneVisitor.prototype.visitIcu = /**
  9851. * @param {?} icu
  9852. * @param {?=} context
  9853. * @return {?}
  9854. */
  9855. function (icu, context) {
  9856. var _this = this;
  9857. var /** @type {?} */ cases = {};
  9858. Object.keys(icu.cases).forEach(function (key) { return cases[key] = icu.cases[key].visit(_this, context); });
  9859. var /** @type {?} */ msg = new Icu(icu.expression, icu.type, cases, icu.sourceSpan);
  9860. msg.expressionPlaceholder = icu.expressionPlaceholder;
  9861. return msg;
  9862. };
  9863. /**
  9864. * @param {?} ph
  9865. * @param {?=} context
  9866. * @return {?}
  9867. */
  9868. CloneVisitor.prototype.visitTagPlaceholder = /**
  9869. * @param {?} ph
  9870. * @param {?=} context
  9871. * @return {?}
  9872. */
  9873. function (ph, context) {
  9874. var _this = this;
  9875. var /** @type {?} */ children = ph.children.map(function (n) { return n.visit(_this, context); });
  9876. return new TagPlaceholder(ph.tag, ph.attrs, ph.startName, ph.closeName, children, ph.isVoid, ph.sourceSpan);
  9877. };
  9878. /**
  9879. * @param {?} ph
  9880. * @param {?=} context
  9881. * @return {?}
  9882. */
  9883. CloneVisitor.prototype.visitPlaceholder = /**
  9884. * @param {?} ph
  9885. * @param {?=} context
  9886. * @return {?}
  9887. */
  9888. function (ph, context) {
  9889. return new Placeholder(ph.value, ph.name, ph.sourceSpan);
  9890. };
  9891. /**
  9892. * @param {?} ph
  9893. * @param {?=} context
  9894. * @return {?}
  9895. */
  9896. CloneVisitor.prototype.visitIcuPlaceholder = /**
  9897. * @param {?} ph
  9898. * @param {?=} context
  9899. * @return {?}
  9900. */
  9901. function (ph, context) {
  9902. return new IcuPlaceholder(ph.value, ph.name, ph.sourceSpan);
  9903. };
  9904. return CloneVisitor;
  9905. }());
  9906. var RecurseVisitor = /** @class */ (function () {
  9907. function RecurseVisitor() {
  9908. }
  9909. /**
  9910. * @param {?} text
  9911. * @param {?=} context
  9912. * @return {?}
  9913. */
  9914. RecurseVisitor.prototype.visitText = /**
  9915. * @param {?} text
  9916. * @param {?=} context
  9917. * @return {?}
  9918. */
  9919. function (text, context) { };
  9920. /**
  9921. * @param {?} container
  9922. * @param {?=} context
  9923. * @return {?}
  9924. */
  9925. RecurseVisitor.prototype.visitContainer = /**
  9926. * @param {?} container
  9927. * @param {?=} context
  9928. * @return {?}
  9929. */
  9930. function (container, context) {
  9931. var _this = this;
  9932. container.children.forEach(function (child) { return child.visit(_this); });
  9933. };
  9934. /**
  9935. * @param {?} icu
  9936. * @param {?=} context
  9937. * @return {?}
  9938. */
  9939. RecurseVisitor.prototype.visitIcu = /**
  9940. * @param {?} icu
  9941. * @param {?=} context
  9942. * @return {?}
  9943. */
  9944. function (icu, context) {
  9945. var _this = this;
  9946. Object.keys(icu.cases).forEach(function (k) { icu.cases[k].visit(_this); });
  9947. };
  9948. /**
  9949. * @param {?} ph
  9950. * @param {?=} context
  9951. * @return {?}
  9952. */
  9953. RecurseVisitor.prototype.visitTagPlaceholder = /**
  9954. * @param {?} ph
  9955. * @param {?=} context
  9956. * @return {?}
  9957. */
  9958. function (ph, context) {
  9959. var _this = this;
  9960. ph.children.forEach(function (child) { return child.visit(_this); });
  9961. };
  9962. /**
  9963. * @param {?} ph
  9964. * @param {?=} context
  9965. * @return {?}
  9966. */
  9967. RecurseVisitor.prototype.visitPlaceholder = /**
  9968. * @param {?} ph
  9969. * @param {?=} context
  9970. * @return {?}
  9971. */
  9972. function (ph, context) { };
  9973. /**
  9974. * @param {?} ph
  9975. * @param {?=} context
  9976. * @return {?}
  9977. */
  9978. RecurseVisitor.prototype.visitIcuPlaceholder = /**
  9979. * @param {?} ph
  9980. * @param {?=} context
  9981. * @return {?}
  9982. */
  9983. function (ph, context) { };
  9984. return RecurseVisitor;
  9985. }());
  9986. /**
  9987. * @fileoverview added by tsickle
  9988. * @suppress {checkTypes} checked by tsc
  9989. */
  9990. /**
  9991. * @license
  9992. * Copyright Google Inc. All Rights Reserved.
  9993. *
  9994. * Use of this source code is governed by an MIT-style license that can be
  9995. * found in the LICENSE file at https://angular.io/license
  9996. */
  9997. var HtmlTagDefinition = /** @class */ (function () {
  9998. function HtmlTagDefinition(_a) {
  9999. 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;
  10000. var _this = this;
  10001. this.closedByChildren = {};
  10002. this.closedByParent = false;
  10003. this.canSelfClose = false;
  10004. if (closedByChildren && closedByChildren.length > 0) {
  10005. closedByChildren.forEach(function (tagName) { return _this.closedByChildren[tagName] = true; });
  10006. }
  10007. this.isVoid = isVoid;
  10008. this.closedByParent = closedByParent || isVoid;
  10009. if (requiredParents && requiredParents.length > 0) {
  10010. this.requiredParents = {};
  10011. // The first parent is the list is automatically when none of the listed parents are present
  10012. this.parentToAdd = requiredParents[0];
  10013. requiredParents.forEach(function (tagName) { return _this.requiredParents[tagName] = true; });
  10014. }
  10015. this.implicitNamespacePrefix = implicitNamespacePrefix || null;
  10016. this.contentType = contentType;
  10017. this.ignoreFirstLf = ignoreFirstLf;
  10018. }
  10019. /**
  10020. * @param {?} currentParent
  10021. * @return {?}
  10022. */
  10023. HtmlTagDefinition.prototype.requireExtraParent = /**
  10024. * @param {?} currentParent
  10025. * @return {?}
  10026. */
  10027. function (currentParent) {
  10028. if (!this.requiredParents) {
  10029. return false;
  10030. }
  10031. if (!currentParent) {
  10032. return true;
  10033. }
  10034. var /** @type {?} */ lcParent = currentParent.toLowerCase();
  10035. var /** @type {?} */ isParentTemplate = lcParent === 'template' || currentParent === 'ng-template';
  10036. return !isParentTemplate && this.requiredParents[lcParent] != true;
  10037. };
  10038. /**
  10039. * @param {?} name
  10040. * @return {?}
  10041. */
  10042. HtmlTagDefinition.prototype.isClosedByChild = /**
  10043. * @param {?} name
  10044. * @return {?}
  10045. */
  10046. function (name) {
  10047. return this.isVoid || name.toLowerCase() in this.closedByChildren;
  10048. };
  10049. return HtmlTagDefinition;
  10050. }());
  10051. // see http://www.w3.org/TR/html51/syntax.html#optional-tags
  10052. // This implementation does not fully conform to the HTML5 spec.
  10053. var TAG_DEFINITIONS = {
  10054. 'base': new HtmlTagDefinition({ isVoid: true }),
  10055. 'meta': new HtmlTagDefinition({ isVoid: true }),
  10056. 'area': new HtmlTagDefinition({ isVoid: true }),
  10057. 'embed': new HtmlTagDefinition({ isVoid: true }),
  10058. 'link': new HtmlTagDefinition({ isVoid: true }),
  10059. 'img': new HtmlTagDefinition({ isVoid: true }),
  10060. 'input': new HtmlTagDefinition({ isVoid: true }),
  10061. 'param': new HtmlTagDefinition({ isVoid: true }),
  10062. 'hr': new HtmlTagDefinition({ isVoid: true }),
  10063. 'br': new HtmlTagDefinition({ isVoid: true }),
  10064. 'source': new HtmlTagDefinition({ isVoid: true }),
  10065. 'track': new HtmlTagDefinition({ isVoid: true }),
  10066. 'wbr': new HtmlTagDefinition({ isVoid: true }),
  10067. 'p': new HtmlTagDefinition({
  10068. closedByChildren: [
  10069. 'address', 'article', 'aside', 'blockquote', 'div', 'dl', 'fieldset', 'footer', 'form',
  10070. 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup', 'hr',
  10071. 'main', 'nav', 'ol', 'p', 'pre', 'section', 'table', 'ul'
  10072. ],
  10073. closedByParent: true
  10074. }),
  10075. 'thead': new HtmlTagDefinition({ closedByChildren: ['tbody', 'tfoot'] }),
  10076. 'tbody': new HtmlTagDefinition({ closedByChildren: ['tbody', 'tfoot'], closedByParent: true }),
  10077. 'tfoot': new HtmlTagDefinition({ closedByChildren: ['tbody'], closedByParent: true }),
  10078. 'tr': new HtmlTagDefinition({
  10079. closedByChildren: ['tr'],
  10080. requiredParents: ['tbody', 'tfoot', 'thead'],
  10081. closedByParent: true
  10082. }),
  10083. 'td': new HtmlTagDefinition({ closedByChildren: ['td', 'th'], closedByParent: true }),
  10084. 'th': new HtmlTagDefinition({ closedByChildren: ['td', 'th'], closedByParent: true }),
  10085. 'col': new HtmlTagDefinition({ requiredParents: ['colgroup'], isVoid: true }),
  10086. 'svg': new HtmlTagDefinition({ implicitNamespacePrefix: 'svg' }),
  10087. 'math': new HtmlTagDefinition({ implicitNamespacePrefix: 'math' }),
  10088. 'li': new HtmlTagDefinition({ closedByChildren: ['li'], closedByParent: true }),
  10089. 'dt': new HtmlTagDefinition({ closedByChildren: ['dt', 'dd'] }),
  10090. 'dd': new HtmlTagDefinition({ closedByChildren: ['dt', 'dd'], closedByParent: true }),
  10091. 'rb': new HtmlTagDefinition({ closedByChildren: ['rb', 'rt', 'rtc', 'rp'], closedByParent: true }),
  10092. 'rt': new HtmlTagDefinition({ closedByChildren: ['rb', 'rt', 'rtc', 'rp'], closedByParent: true }),
  10093. 'rtc': new HtmlTagDefinition({ closedByChildren: ['rb', 'rtc', 'rp'], closedByParent: true }),
  10094. 'rp': new HtmlTagDefinition({ closedByChildren: ['rb', 'rt', 'rtc', 'rp'], closedByParent: true }),
  10095. 'optgroup': new HtmlTagDefinition({ closedByChildren: ['optgroup'], closedByParent: true }),
  10096. 'option': new HtmlTagDefinition({ closedByChildren: ['option', 'optgroup'], closedByParent: true }),
  10097. 'pre': new HtmlTagDefinition({ ignoreFirstLf: true }),
  10098. 'listing': new HtmlTagDefinition({ ignoreFirstLf: true }),
  10099. 'style': new HtmlTagDefinition({ contentType: TagContentType.RAW_TEXT }),
  10100. 'script': new HtmlTagDefinition({ contentType: TagContentType.RAW_TEXT }),
  10101. 'title': new HtmlTagDefinition({ contentType: TagContentType.ESCAPABLE_RAW_TEXT }),
  10102. 'textarea': new HtmlTagDefinition({ contentType: TagContentType.ESCAPABLE_RAW_TEXT, ignoreFirstLf: true }),
  10103. };
  10104. var _DEFAULT_TAG_DEFINITION = new HtmlTagDefinition();
  10105. /**
  10106. * @param {?} tagName
  10107. * @return {?}
  10108. */
  10109. function getHtmlTagDefinition(tagName) {
  10110. return TAG_DEFINITIONS[tagName.toLowerCase()] || _DEFAULT_TAG_DEFINITION;
  10111. }
  10112. /**
  10113. * @fileoverview added by tsickle
  10114. * @suppress {checkTypes} checked by tsc
  10115. */
  10116. /**
  10117. * @license
  10118. * Copyright Google Inc. All Rights Reserved.
  10119. *
  10120. * Use of this source code is governed by an MIT-style license that can be
  10121. * found in the LICENSE file at https://angular.io/license
  10122. */
  10123. var TAG_TO_PLACEHOLDER_NAMES = {
  10124. 'A': 'LINK',
  10125. 'B': 'BOLD_TEXT',
  10126. 'BR': 'LINE_BREAK',
  10127. 'EM': 'EMPHASISED_TEXT',
  10128. 'H1': 'HEADING_LEVEL1',
  10129. 'H2': 'HEADING_LEVEL2',
  10130. 'H3': 'HEADING_LEVEL3',
  10131. 'H4': 'HEADING_LEVEL4',
  10132. 'H5': 'HEADING_LEVEL5',
  10133. 'H6': 'HEADING_LEVEL6',
  10134. 'HR': 'HORIZONTAL_RULE',
  10135. 'I': 'ITALIC_TEXT',
  10136. 'LI': 'LIST_ITEM',
  10137. 'LINK': 'MEDIA_LINK',
  10138. 'OL': 'ORDERED_LIST',
  10139. 'P': 'PARAGRAPH',
  10140. 'Q': 'QUOTATION',
  10141. 'S': 'STRIKETHROUGH_TEXT',
  10142. 'SMALL': 'SMALL_TEXT',
  10143. 'SUB': 'SUBSTRIPT',
  10144. 'SUP': 'SUPERSCRIPT',
  10145. 'TBODY': 'TABLE_BODY',
  10146. 'TD': 'TABLE_CELL',
  10147. 'TFOOT': 'TABLE_FOOTER',
  10148. 'TH': 'TABLE_HEADER_CELL',
  10149. 'THEAD': 'TABLE_HEADER',
  10150. 'TR': 'TABLE_ROW',
  10151. 'TT': 'MONOSPACED_TEXT',
  10152. 'U': 'UNDERLINED_TEXT',
  10153. 'UL': 'UNORDERED_LIST',
  10154. };
  10155. /**
  10156. * Creates unique names for placeholder with different content.
  10157. *
  10158. * Returns the same placeholder name when the content is identical.
  10159. */
  10160. var PlaceholderRegistry = /** @class */ (function () {
  10161. function PlaceholderRegistry() {
  10162. this._placeHolderNameCounts = {};
  10163. this._signatureToName = {};
  10164. }
  10165. /**
  10166. * @param {?} tag
  10167. * @param {?} attrs
  10168. * @param {?} isVoid
  10169. * @return {?}
  10170. */
  10171. PlaceholderRegistry.prototype.getStartTagPlaceholderName = /**
  10172. * @param {?} tag
  10173. * @param {?} attrs
  10174. * @param {?} isVoid
  10175. * @return {?}
  10176. */
  10177. function (tag, attrs, isVoid) {
  10178. var /** @type {?} */ signature = this._hashTag(tag, attrs, isVoid);
  10179. if (this._signatureToName[signature]) {
  10180. return this._signatureToName[signature];
  10181. }
  10182. var /** @type {?} */ upperTag = tag.toUpperCase();
  10183. var /** @type {?} */ baseName = TAG_TO_PLACEHOLDER_NAMES[upperTag] || "TAG_" + upperTag;
  10184. var /** @type {?} */ name = this._generateUniqueName(isVoid ? baseName : "START_" + baseName);
  10185. this._signatureToName[signature] = name;
  10186. return name;
  10187. };
  10188. /**
  10189. * @param {?} tag
  10190. * @return {?}
  10191. */
  10192. PlaceholderRegistry.prototype.getCloseTagPlaceholderName = /**
  10193. * @param {?} tag
  10194. * @return {?}
  10195. */
  10196. function (tag) {
  10197. var /** @type {?} */ signature = this._hashClosingTag(tag);
  10198. if (this._signatureToName[signature]) {
  10199. return this._signatureToName[signature];
  10200. }
  10201. var /** @type {?} */ upperTag = tag.toUpperCase();
  10202. var /** @type {?} */ baseName = TAG_TO_PLACEHOLDER_NAMES[upperTag] || "TAG_" + upperTag;
  10203. var /** @type {?} */ name = this._generateUniqueName("CLOSE_" + baseName);
  10204. this._signatureToName[signature] = name;
  10205. return name;
  10206. };
  10207. /**
  10208. * @param {?} name
  10209. * @param {?} content
  10210. * @return {?}
  10211. */
  10212. PlaceholderRegistry.prototype.getPlaceholderName = /**
  10213. * @param {?} name
  10214. * @param {?} content
  10215. * @return {?}
  10216. */
  10217. function (name, content) {
  10218. var /** @type {?} */ upperName = name.toUpperCase();
  10219. var /** @type {?} */ signature = "PH: " + upperName + "=" + content;
  10220. if (this._signatureToName[signature]) {
  10221. return this._signatureToName[signature];
  10222. }
  10223. var /** @type {?} */ uniqueName = this._generateUniqueName(upperName);
  10224. this._signatureToName[signature] = uniqueName;
  10225. return uniqueName;
  10226. };
  10227. /**
  10228. * @param {?} name
  10229. * @return {?}
  10230. */
  10231. PlaceholderRegistry.prototype.getUniquePlaceholder = /**
  10232. * @param {?} name
  10233. * @return {?}
  10234. */
  10235. function (name) {
  10236. return this._generateUniqueName(name.toUpperCase());
  10237. };
  10238. /**
  10239. * @param {?} tag
  10240. * @param {?} attrs
  10241. * @param {?} isVoid
  10242. * @return {?}
  10243. */
  10244. PlaceholderRegistry.prototype._hashTag = /**
  10245. * @param {?} tag
  10246. * @param {?} attrs
  10247. * @param {?} isVoid
  10248. * @return {?}
  10249. */
  10250. function (tag, attrs, isVoid) {
  10251. var /** @type {?} */ start = "<" + tag;
  10252. var /** @type {?} */ strAttrs = Object.keys(attrs).sort().map(function (name) { return " " + name + "=" + attrs[name]; }).join('');
  10253. var /** @type {?} */ end = isVoid ? '/>' : "></" + tag + ">";
  10254. return start + strAttrs + end;
  10255. };
  10256. /**
  10257. * @param {?} tag
  10258. * @return {?}
  10259. */
  10260. PlaceholderRegistry.prototype._hashClosingTag = /**
  10261. * @param {?} tag
  10262. * @return {?}
  10263. */
  10264. function (tag) { return this._hashTag("/" + tag, {}, false); };
  10265. /**
  10266. * @param {?} base
  10267. * @return {?}
  10268. */
  10269. PlaceholderRegistry.prototype._generateUniqueName = /**
  10270. * @param {?} base
  10271. * @return {?}
  10272. */
  10273. function (base) {
  10274. var /** @type {?} */ seen = this._placeHolderNameCounts.hasOwnProperty(base);
  10275. if (!seen) {
  10276. this._placeHolderNameCounts[base] = 1;
  10277. return base;
  10278. }
  10279. var /** @type {?} */ id = this._placeHolderNameCounts[base];
  10280. this._placeHolderNameCounts[base] = id + 1;
  10281. return base + "_" + id;
  10282. };
  10283. return PlaceholderRegistry;
  10284. }());
  10285. /**
  10286. * @fileoverview added by tsickle
  10287. * @suppress {checkTypes} checked by tsc
  10288. */
  10289. /**
  10290. * @license
  10291. * Copyright Google Inc. All Rights Reserved.
  10292. *
  10293. * Use of this source code is governed by an MIT-style license that can be
  10294. * found in the LICENSE file at https://angular.io/license
  10295. */
  10296. var _expParser = new Parser(new Lexer());
  10297. /**
  10298. * Returns a function converting html nodes to an i18n Message given an interpolationConfig
  10299. * @param {?} interpolationConfig
  10300. * @return {?}
  10301. */
  10302. function createI18nMessageFactory(interpolationConfig) {
  10303. var /** @type {?} */ visitor = new _I18nVisitor(_expParser, interpolationConfig);
  10304. return function (nodes, meaning, description, id) {
  10305. return visitor.toI18nMessage(nodes, meaning, description, id);
  10306. };
  10307. }
  10308. var _I18nVisitor = /** @class */ (function () {
  10309. function _I18nVisitor(_expressionParser, _interpolationConfig) {
  10310. this._expressionParser = _expressionParser;
  10311. this._interpolationConfig = _interpolationConfig;
  10312. }
  10313. /**
  10314. * @param {?} nodes
  10315. * @param {?} meaning
  10316. * @param {?} description
  10317. * @param {?} id
  10318. * @return {?}
  10319. */
  10320. _I18nVisitor.prototype.toI18nMessage = /**
  10321. * @param {?} nodes
  10322. * @param {?} meaning
  10323. * @param {?} description
  10324. * @param {?} id
  10325. * @return {?}
  10326. */
  10327. function (nodes, meaning, description, id) {
  10328. this._isIcu = nodes.length == 1 && nodes[0] instanceof Expansion;
  10329. this._icuDepth = 0;
  10330. this._placeholderRegistry = new PlaceholderRegistry();
  10331. this._placeholderToContent = {};
  10332. this._placeholderToMessage = {};
  10333. var /** @type {?} */ i18nodes = visitAll(this, nodes, {});
  10334. return new Message(i18nodes, this._placeholderToContent, this._placeholderToMessage, meaning, description, id);
  10335. };
  10336. /**
  10337. * @param {?} el
  10338. * @param {?} context
  10339. * @return {?}
  10340. */
  10341. _I18nVisitor.prototype.visitElement = /**
  10342. * @param {?} el
  10343. * @param {?} context
  10344. * @return {?}
  10345. */
  10346. function (el, context) {
  10347. var /** @type {?} */ children = visitAll(this, el.children);
  10348. var /** @type {?} */ attrs = {};
  10349. el.attrs.forEach(function (attr) {
  10350. // Do not visit the attributes, translatable ones are top-level ASTs
  10351. attrs[attr.name] = attr.value;
  10352. });
  10353. var /** @type {?} */ isVoid = getHtmlTagDefinition(el.name).isVoid;
  10354. var /** @type {?} */ startPhName = this._placeholderRegistry.getStartTagPlaceholderName(el.name, attrs, isVoid);
  10355. this._placeholderToContent[startPhName] = /** @type {?} */ ((el.sourceSpan)).toString();
  10356. var /** @type {?} */ closePhName = '';
  10357. if (!isVoid) {
  10358. closePhName = this._placeholderRegistry.getCloseTagPlaceholderName(el.name);
  10359. this._placeholderToContent[closePhName] = "</" + el.name + ">";
  10360. }
  10361. return new TagPlaceholder(el.name, attrs, startPhName, closePhName, children, isVoid, /** @type {?} */ ((el.sourceSpan)));
  10362. };
  10363. /**
  10364. * @param {?} attribute
  10365. * @param {?} context
  10366. * @return {?}
  10367. */
  10368. _I18nVisitor.prototype.visitAttribute = /**
  10369. * @param {?} attribute
  10370. * @param {?} context
  10371. * @return {?}
  10372. */
  10373. function (attribute, context) {
  10374. return this._visitTextWithInterpolation(attribute.value, attribute.sourceSpan);
  10375. };
  10376. /**
  10377. * @param {?} text
  10378. * @param {?} context
  10379. * @return {?}
  10380. */
  10381. _I18nVisitor.prototype.visitText = /**
  10382. * @param {?} text
  10383. * @param {?} context
  10384. * @return {?}
  10385. */
  10386. function (text, context) {
  10387. return this._visitTextWithInterpolation(text.value, /** @type {?} */ ((text.sourceSpan)));
  10388. };
  10389. /**
  10390. * @param {?} comment
  10391. * @param {?} context
  10392. * @return {?}
  10393. */
  10394. _I18nVisitor.prototype.visitComment = /**
  10395. * @param {?} comment
  10396. * @param {?} context
  10397. * @return {?}
  10398. */
  10399. function (comment, context) { return null; };
  10400. /**
  10401. * @param {?} icu
  10402. * @param {?} context
  10403. * @return {?}
  10404. */
  10405. _I18nVisitor.prototype.visitExpansion = /**
  10406. * @param {?} icu
  10407. * @param {?} context
  10408. * @return {?}
  10409. */
  10410. function (icu, context) {
  10411. var _this = this;
  10412. this._icuDepth++;
  10413. var /** @type {?} */ i18nIcuCases = {};
  10414. var /** @type {?} */ i18nIcu = new Icu(icu.switchValue, icu.type, i18nIcuCases, icu.sourceSpan);
  10415. icu.cases.forEach(function (caze) {
  10416. i18nIcuCases[caze.value] = new Container(caze.expression.map(function (node) { return node.visit(_this, {}); }), caze.expSourceSpan);
  10417. });
  10418. this._icuDepth--;
  10419. if (this._isIcu || this._icuDepth > 0) {
  10420. // Returns an ICU node when:
  10421. // - the message (vs a part of the message) is an ICU message, or
  10422. // - the ICU message is nested.
  10423. var /** @type {?} */ expPh = this._placeholderRegistry.getUniquePlaceholder("VAR_" + icu.type);
  10424. i18nIcu.expressionPlaceholder = expPh;
  10425. this._placeholderToContent[expPh] = icu.switchValue;
  10426. return i18nIcu;
  10427. }
  10428. // Else returns a placeholder
  10429. // ICU placeholders should not be replaced with their original content but with the their
  10430. // translations. We need to create a new visitor (they are not re-entrant) to compute the
  10431. // message id.
  10432. // TODO(vicb): add a html.Node -> i18n.Message cache to avoid having to re-create the msg
  10433. var /** @type {?} */ phName = this._placeholderRegistry.getPlaceholderName('ICU', icu.sourceSpan.toString());
  10434. var /** @type {?} */ visitor = new _I18nVisitor(this._expressionParser, this._interpolationConfig);
  10435. this._placeholderToMessage[phName] = visitor.toI18nMessage([icu], '', '', '');
  10436. return new IcuPlaceholder(i18nIcu, phName, icu.sourceSpan);
  10437. };
  10438. /**
  10439. * @param {?} icuCase
  10440. * @param {?} context
  10441. * @return {?}
  10442. */
  10443. _I18nVisitor.prototype.visitExpansionCase = /**
  10444. * @param {?} icuCase
  10445. * @param {?} context
  10446. * @return {?}
  10447. */
  10448. function (icuCase, context) {
  10449. throw new Error('Unreachable code');
  10450. };
  10451. /**
  10452. * @param {?} text
  10453. * @param {?} sourceSpan
  10454. * @return {?}
  10455. */
  10456. _I18nVisitor.prototype._visitTextWithInterpolation = /**
  10457. * @param {?} text
  10458. * @param {?} sourceSpan
  10459. * @return {?}
  10460. */
  10461. function (text, sourceSpan) {
  10462. var /** @type {?} */ splitInterpolation = this._expressionParser.splitInterpolation(text, sourceSpan.start.toString(), this._interpolationConfig);
  10463. if (!splitInterpolation) {
  10464. // No expression, return a single text
  10465. return new Text$1(text, sourceSpan);
  10466. }
  10467. // Return a group of text + expressions
  10468. var /** @type {?} */ nodes = [];
  10469. var /** @type {?} */ container = new Container(nodes, sourceSpan);
  10470. var _a = this._interpolationConfig, sDelimiter = _a.start, eDelimiter = _a.end;
  10471. for (var /** @type {?} */ i = 0; i < splitInterpolation.strings.length - 1; i++) {
  10472. var /** @type {?} */ expression = splitInterpolation.expressions[i];
  10473. var /** @type {?} */ baseName = _extractPlaceholderName(expression) || 'INTERPOLATION';
  10474. var /** @type {?} */ phName = this._placeholderRegistry.getPlaceholderName(baseName, expression);
  10475. if (splitInterpolation.strings[i].length) {
  10476. // No need to add empty strings
  10477. nodes.push(new Text$1(splitInterpolation.strings[i], sourceSpan));
  10478. }
  10479. nodes.push(new Placeholder(expression, phName, sourceSpan));
  10480. this._placeholderToContent[phName] = sDelimiter + expression + eDelimiter;
  10481. }
  10482. // The last index contains no expression
  10483. var /** @type {?} */ lastStringIdx = splitInterpolation.strings.length - 1;
  10484. if (splitInterpolation.strings[lastStringIdx].length) {
  10485. nodes.push(new Text$1(splitInterpolation.strings[lastStringIdx], sourceSpan));
  10486. }
  10487. return container;
  10488. };
  10489. return _I18nVisitor;
  10490. }());
  10491. var _CUSTOM_PH_EXP = /\/\/[\s\S]*i18n[\s\S]*\([\s\S]*ph[\s\S]*=[\s\S]*("|')([\s\S]*?)\1[\s\S]*\)/g;
  10492. /**
  10493. * @param {?} input
  10494. * @return {?}
  10495. */
  10496. function _extractPlaceholderName(input) {
  10497. return input.split(_CUSTOM_PH_EXP)[2];
  10498. }
  10499. /**
  10500. * @fileoverview added by tsickle
  10501. * @suppress {checkTypes} checked by tsc
  10502. */
  10503. /**
  10504. * @license
  10505. * Copyright Google Inc. All Rights Reserved.
  10506. *
  10507. * Use of this source code is governed by an MIT-style license that can be
  10508. * found in the LICENSE file at https://angular.io/license
  10509. */
  10510. /**
  10511. * An i18n error.
  10512. */
  10513. var I18nError = /** @class */ (function (_super) {
  10514. __extends(I18nError, _super);
  10515. function I18nError(span, msg) {
  10516. return _super.call(this, span, msg) || this;
  10517. }
  10518. return I18nError;
  10519. }(ParseError));
  10520. /**
  10521. * @fileoverview added by tsickle
  10522. * @suppress {checkTypes} checked by tsc
  10523. */
  10524. /**
  10525. * @license
  10526. * Copyright Google Inc. All Rights Reserved.
  10527. *
  10528. * Use of this source code is governed by an MIT-style license that can be
  10529. * found in the LICENSE file at https://angular.io/license
  10530. */
  10531. var _I18N_ATTR = 'i18n';
  10532. var _I18N_ATTR_PREFIX = 'i18n-';
  10533. var _I18N_COMMENT_PREFIX_REGEXP = /^i18n:?/;
  10534. var MEANING_SEPARATOR = '|';
  10535. var ID_SEPARATOR = '@@';
  10536. var i18nCommentsWarned = false;
  10537. /**
  10538. * Extract translatable messages from an html AST
  10539. * @param {?} nodes
  10540. * @param {?} interpolationConfig
  10541. * @param {?} implicitTags
  10542. * @param {?} implicitAttrs
  10543. * @return {?}
  10544. */
  10545. function extractMessages(nodes, interpolationConfig, implicitTags, implicitAttrs) {
  10546. var /** @type {?} */ visitor = new _Visitor(implicitTags, implicitAttrs);
  10547. return visitor.extract(nodes, interpolationConfig);
  10548. }
  10549. /**
  10550. * @param {?} nodes
  10551. * @param {?} translations
  10552. * @param {?} interpolationConfig
  10553. * @param {?} implicitTags
  10554. * @param {?} implicitAttrs
  10555. * @return {?}
  10556. */
  10557. function mergeTranslations(nodes, translations, interpolationConfig, implicitTags, implicitAttrs) {
  10558. var /** @type {?} */ visitor = new _Visitor(implicitTags, implicitAttrs);
  10559. return visitor.merge(nodes, translations, interpolationConfig);
  10560. }
  10561. var ExtractionResult = /** @class */ (function () {
  10562. function ExtractionResult(messages, errors) {
  10563. this.messages = messages;
  10564. this.errors = errors;
  10565. }
  10566. return ExtractionResult;
  10567. }());
  10568. /** @enum {number} */
  10569. var _VisitorMode = {
  10570. Extract: 0,
  10571. Merge: 1,
  10572. };
  10573. _VisitorMode[_VisitorMode.Extract] = "Extract";
  10574. _VisitorMode[_VisitorMode.Merge] = "Merge";
  10575. /**
  10576. * This Visitor is used:
  10577. * 1. to extract all the translatable strings from an html AST (see `extract()`),
  10578. * 2. to replace the translatable strings with the actual translations (see `merge()`)
  10579. *
  10580. * \@internal
  10581. */
  10582. var _Visitor = /** @class */ (function () {
  10583. function _Visitor(_implicitTags, _implicitAttrs) {
  10584. this._implicitTags = _implicitTags;
  10585. this._implicitAttrs = _implicitAttrs;
  10586. }
  10587. /**
  10588. * Extracts the messages from the tree
  10589. */
  10590. /**
  10591. * Extracts the messages from the tree
  10592. * @param {?} nodes
  10593. * @param {?} interpolationConfig
  10594. * @return {?}
  10595. */
  10596. _Visitor.prototype.extract = /**
  10597. * Extracts the messages from the tree
  10598. * @param {?} nodes
  10599. * @param {?} interpolationConfig
  10600. * @return {?}
  10601. */
  10602. function (nodes, interpolationConfig) {
  10603. var _this = this;
  10604. this._init(_VisitorMode.Extract, interpolationConfig);
  10605. nodes.forEach(function (node) { return node.visit(_this, null); });
  10606. if (this._inI18nBlock) {
  10607. this._reportError(nodes[nodes.length - 1], 'Unclosed block');
  10608. }
  10609. return new ExtractionResult(this._messages, this._errors);
  10610. };
  10611. /**
  10612. * Returns a tree where all translatable nodes are translated
  10613. */
  10614. /**
  10615. * Returns a tree where all translatable nodes are translated
  10616. * @param {?} nodes
  10617. * @param {?} translations
  10618. * @param {?} interpolationConfig
  10619. * @return {?}
  10620. */
  10621. _Visitor.prototype.merge = /**
  10622. * Returns a tree where all translatable nodes are translated
  10623. * @param {?} nodes
  10624. * @param {?} translations
  10625. * @param {?} interpolationConfig
  10626. * @return {?}
  10627. */
  10628. function (nodes, translations, interpolationConfig) {
  10629. this._init(_VisitorMode.Merge, interpolationConfig);
  10630. this._translations = translations;
  10631. // Construct a single fake root element
  10632. var /** @type {?} */ wrapper = new Element('wrapper', [], nodes, /** @type {?} */ ((undefined)), undefined, undefined);
  10633. var /** @type {?} */ translatedNode = wrapper.visit(this, null);
  10634. if (this._inI18nBlock) {
  10635. this._reportError(nodes[nodes.length - 1], 'Unclosed block');
  10636. }
  10637. return new ParseTreeResult(translatedNode.children, this._errors);
  10638. };
  10639. /**
  10640. * @param {?} icuCase
  10641. * @param {?} context
  10642. * @return {?}
  10643. */
  10644. _Visitor.prototype.visitExpansionCase = /**
  10645. * @param {?} icuCase
  10646. * @param {?} context
  10647. * @return {?}
  10648. */
  10649. function (icuCase, context) {
  10650. // Parse cases for translatable html attributes
  10651. var /** @type {?} */ expression = visitAll(this, icuCase.expression, context);
  10652. if (this._mode === _VisitorMode.Merge) {
  10653. return new ExpansionCase(icuCase.value, expression, icuCase.sourceSpan, icuCase.valueSourceSpan, icuCase.expSourceSpan);
  10654. }
  10655. };
  10656. /**
  10657. * @param {?} icu
  10658. * @param {?} context
  10659. * @return {?}
  10660. */
  10661. _Visitor.prototype.visitExpansion = /**
  10662. * @param {?} icu
  10663. * @param {?} context
  10664. * @return {?}
  10665. */
  10666. function (icu, context) {
  10667. this._mayBeAddBlockChildren(icu);
  10668. var /** @type {?} */ wasInIcu = this._inIcu;
  10669. if (!this._inIcu) {
  10670. // nested ICU messages should not be extracted but top-level translated as a whole
  10671. if (this._isInTranslatableSection) {
  10672. this._addMessage([icu]);
  10673. }
  10674. this._inIcu = true;
  10675. }
  10676. var /** @type {?} */ cases = visitAll(this, icu.cases, context);
  10677. if (this._mode === _VisitorMode.Merge) {
  10678. icu = new Expansion(icu.switchValue, icu.type, cases, icu.sourceSpan, icu.switchValueSourceSpan);
  10679. }
  10680. this._inIcu = wasInIcu;
  10681. return icu;
  10682. };
  10683. /**
  10684. * @param {?} comment
  10685. * @param {?} context
  10686. * @return {?}
  10687. */
  10688. _Visitor.prototype.visitComment = /**
  10689. * @param {?} comment
  10690. * @param {?} context
  10691. * @return {?}
  10692. */
  10693. function (comment, context) {
  10694. var /** @type {?} */ isOpening = _isOpeningComment(comment);
  10695. if (isOpening && this._isInTranslatableSection) {
  10696. this._reportError(comment, 'Could not start a block inside a translatable section');
  10697. return;
  10698. }
  10699. var /** @type {?} */ isClosing = _isClosingComment(comment);
  10700. if (isClosing && !this._inI18nBlock) {
  10701. this._reportError(comment, 'Trying to close an unopened block');
  10702. return;
  10703. }
  10704. if (!this._inI18nNode && !this._inIcu) {
  10705. if (!this._inI18nBlock) {
  10706. if (isOpening) {
  10707. // deprecated from v5 you should use <ng-container i18n> instead of i18n comments
  10708. if (!i18nCommentsWarned && /** @type {?} */ (console) && /** @type {?} */ (console.warn)) {
  10709. i18nCommentsWarned = true;
  10710. var /** @type {?} */ details = comment.sourceSpan.details ? ", " + comment.sourceSpan.details : '';
  10711. // TODO(ocombe): use a log service once there is a public one available
  10712. console.warn("I18n comments are deprecated, use an <ng-container> element instead (" + comment.sourceSpan.start + details + ")");
  10713. }
  10714. this._inI18nBlock = true;
  10715. this._blockStartDepth = this._depth;
  10716. this._blockChildren = [];
  10717. this._blockMeaningAndDesc = /** @type {?} */ ((comment.value)).replace(_I18N_COMMENT_PREFIX_REGEXP, '').trim();
  10718. this._openTranslatableSection(comment);
  10719. }
  10720. }
  10721. else {
  10722. if (isClosing) {
  10723. if (this._depth == this._blockStartDepth) {
  10724. this._closeTranslatableSection(comment, this._blockChildren);
  10725. this._inI18nBlock = false;
  10726. var /** @type {?} */ message = /** @type {?} */ ((this._addMessage(this._blockChildren, this._blockMeaningAndDesc)));
  10727. // merge attributes in sections
  10728. var /** @type {?} */ nodes = this._translateMessage(comment, message);
  10729. return visitAll(this, nodes);
  10730. }
  10731. else {
  10732. this._reportError(comment, 'I18N blocks should not cross element boundaries');
  10733. return;
  10734. }
  10735. }
  10736. }
  10737. }
  10738. };
  10739. /**
  10740. * @param {?} text
  10741. * @param {?} context
  10742. * @return {?}
  10743. */
  10744. _Visitor.prototype.visitText = /**
  10745. * @param {?} text
  10746. * @param {?} context
  10747. * @return {?}
  10748. */
  10749. function (text, context) {
  10750. if (this._isInTranslatableSection) {
  10751. this._mayBeAddBlockChildren(text);
  10752. }
  10753. return text;
  10754. };
  10755. /**
  10756. * @param {?} el
  10757. * @param {?} context
  10758. * @return {?}
  10759. */
  10760. _Visitor.prototype.visitElement = /**
  10761. * @param {?} el
  10762. * @param {?} context
  10763. * @return {?}
  10764. */
  10765. function (el, context) {
  10766. var _this = this;
  10767. this._mayBeAddBlockChildren(el);
  10768. this._depth++;
  10769. var /** @type {?} */ wasInI18nNode = this._inI18nNode;
  10770. var /** @type {?} */ wasInImplicitNode = this._inImplicitNode;
  10771. var /** @type {?} */ childNodes = [];
  10772. var /** @type {?} */ translatedChildNodes = /** @type {?} */ ((undefined));
  10773. // Extract:
  10774. // - top level nodes with the (implicit) "i18n" attribute if not already in a section
  10775. // - ICU messages
  10776. var /** @type {?} */ i18nAttr = _getI18nAttr(el);
  10777. var /** @type {?} */ i18nMeta = i18nAttr ? i18nAttr.value : '';
  10778. var /** @type {?} */ isImplicit = this._implicitTags.some(function (tag) { return el.name === tag; }) && !this._inIcu &&
  10779. !this._isInTranslatableSection;
  10780. var /** @type {?} */ isTopLevelImplicit = !wasInImplicitNode && isImplicit;
  10781. this._inImplicitNode = wasInImplicitNode || isImplicit;
  10782. if (!this._isInTranslatableSection && !this._inIcu) {
  10783. if (i18nAttr || isTopLevelImplicit) {
  10784. this._inI18nNode = true;
  10785. var /** @type {?} */ message = /** @type {?} */ ((this._addMessage(el.children, i18nMeta)));
  10786. translatedChildNodes = this._translateMessage(el, message);
  10787. }
  10788. if (this._mode == _VisitorMode.Extract) {
  10789. var /** @type {?} */ isTranslatable = i18nAttr || isTopLevelImplicit;
  10790. if (isTranslatable)
  10791. this._openTranslatableSection(el);
  10792. visitAll(this, el.children);
  10793. if (isTranslatable)
  10794. this._closeTranslatableSection(el, el.children);
  10795. }
  10796. }
  10797. else {
  10798. if (i18nAttr || isTopLevelImplicit) {
  10799. this._reportError(el, 'Could not mark an element as translatable inside a translatable section');
  10800. }
  10801. if (this._mode == _VisitorMode.Extract) {
  10802. // Descend into child nodes for extraction
  10803. visitAll(this, el.children);
  10804. }
  10805. }
  10806. if (this._mode === _VisitorMode.Merge) {
  10807. var /** @type {?} */ visitNodes = translatedChildNodes || el.children;
  10808. visitNodes.forEach(function (child) {
  10809. var /** @type {?} */ visited = child.visit(_this, context);
  10810. if (visited && !_this._isInTranslatableSection) {
  10811. // Do not add the children from translatable sections (= i18n blocks here)
  10812. // They will be added later in this loop when the block closes (i.e. on `<!-- /i18n -->`)
  10813. childNodes = childNodes.concat(visited);
  10814. }
  10815. });
  10816. }
  10817. this._visitAttributesOf(el);
  10818. this._depth--;
  10819. this._inI18nNode = wasInI18nNode;
  10820. this._inImplicitNode = wasInImplicitNode;
  10821. if (this._mode === _VisitorMode.Merge) {
  10822. var /** @type {?} */ translatedAttrs = this._translateAttributes(el);
  10823. return new Element(el.name, translatedAttrs, childNodes, el.sourceSpan, el.startSourceSpan, el.endSourceSpan);
  10824. }
  10825. return null;
  10826. };
  10827. /**
  10828. * @param {?} attribute
  10829. * @param {?} context
  10830. * @return {?}
  10831. */
  10832. _Visitor.prototype.visitAttribute = /**
  10833. * @param {?} attribute
  10834. * @param {?} context
  10835. * @return {?}
  10836. */
  10837. function (attribute, context) {
  10838. throw new Error('unreachable code');
  10839. };
  10840. /**
  10841. * @param {?} mode
  10842. * @param {?} interpolationConfig
  10843. * @return {?}
  10844. */
  10845. _Visitor.prototype._init = /**
  10846. * @param {?} mode
  10847. * @param {?} interpolationConfig
  10848. * @return {?}
  10849. */
  10850. function (mode, interpolationConfig) {
  10851. this._mode = mode;
  10852. this._inI18nBlock = false;
  10853. this._inI18nNode = false;
  10854. this._depth = 0;
  10855. this._inIcu = false;
  10856. this._msgCountAtSectionStart = undefined;
  10857. this._errors = [];
  10858. this._messages = [];
  10859. this._inImplicitNode = false;
  10860. this._createI18nMessage = createI18nMessageFactory(interpolationConfig);
  10861. };
  10862. /**
  10863. * @param {?} el
  10864. * @return {?}
  10865. */
  10866. _Visitor.prototype._visitAttributesOf = /**
  10867. * @param {?} el
  10868. * @return {?}
  10869. */
  10870. function (el) {
  10871. var _this = this;
  10872. var /** @type {?} */ explicitAttrNameToValue = {};
  10873. var /** @type {?} */ implicitAttrNames = this._implicitAttrs[el.name] || [];
  10874. el.attrs.filter(function (attr) { return attr.name.startsWith(_I18N_ATTR_PREFIX); })
  10875. .forEach(function (attr) {
  10876. return explicitAttrNameToValue[attr.name.slice(_I18N_ATTR_PREFIX.length)] =
  10877. attr.value;
  10878. });
  10879. el.attrs.forEach(function (attr) {
  10880. if (attr.name in explicitAttrNameToValue) {
  10881. _this._addMessage([attr], explicitAttrNameToValue[attr.name]);
  10882. }
  10883. else if (implicitAttrNames.some(function (name) { return attr.name === name; })) {
  10884. _this._addMessage([attr]);
  10885. }
  10886. });
  10887. };
  10888. /**
  10889. * @param {?} ast
  10890. * @param {?=} msgMeta
  10891. * @return {?}
  10892. */
  10893. _Visitor.prototype._addMessage = /**
  10894. * @param {?} ast
  10895. * @param {?=} msgMeta
  10896. * @return {?}
  10897. */
  10898. function (ast, msgMeta) {
  10899. if (ast.length == 0 ||
  10900. ast.length == 1 && ast[0] instanceof Attribute$1 && !(/** @type {?} */ (ast[0])).value) {
  10901. // Do not create empty messages
  10902. return null;
  10903. }
  10904. var _a = _parseMessageMeta(msgMeta), meaning = _a.meaning, description = _a.description, id = _a.id;
  10905. var /** @type {?} */ message = this._createI18nMessage(ast, meaning, description, id);
  10906. this._messages.push(message);
  10907. return message;
  10908. };
  10909. /**
  10910. * @param {?} el
  10911. * @param {?} message
  10912. * @return {?}
  10913. */
  10914. _Visitor.prototype._translateMessage = /**
  10915. * @param {?} el
  10916. * @param {?} message
  10917. * @return {?}
  10918. */
  10919. function (el, message) {
  10920. if (message && this._mode === _VisitorMode.Merge) {
  10921. var /** @type {?} */ nodes = this._translations.get(message);
  10922. if (nodes) {
  10923. return nodes;
  10924. }
  10925. this._reportError(el, "Translation unavailable for message id=\"" + this._translations.digest(message) + "\"");
  10926. }
  10927. return [];
  10928. };
  10929. /**
  10930. * @param {?} el
  10931. * @return {?}
  10932. */
  10933. _Visitor.prototype._translateAttributes = /**
  10934. * @param {?} el
  10935. * @return {?}
  10936. */
  10937. function (el) {
  10938. var _this = this;
  10939. var /** @type {?} */ attributes = el.attrs;
  10940. var /** @type {?} */ i18nParsedMessageMeta = {};
  10941. attributes.forEach(function (attr) {
  10942. if (attr.name.startsWith(_I18N_ATTR_PREFIX)) {
  10943. i18nParsedMessageMeta[attr.name.slice(_I18N_ATTR_PREFIX.length)] =
  10944. _parseMessageMeta(attr.value);
  10945. }
  10946. });
  10947. var /** @type {?} */ translatedAttributes = [];
  10948. attributes.forEach(function (attr) {
  10949. if (attr.name === _I18N_ATTR || attr.name.startsWith(_I18N_ATTR_PREFIX)) {
  10950. // strip i18n specific attributes
  10951. return;
  10952. }
  10953. if (attr.value && attr.value != '' && i18nParsedMessageMeta.hasOwnProperty(attr.name)) {
  10954. var _a = i18nParsedMessageMeta[attr.name], meaning = _a.meaning, description = _a.description, id = _a.id;
  10955. var /** @type {?} */ message = _this._createI18nMessage([attr], meaning, description, id);
  10956. var /** @type {?} */ nodes = _this._translations.get(message);
  10957. if (nodes) {
  10958. if (nodes.length == 0) {
  10959. translatedAttributes.push(new Attribute$1(attr.name, '', attr.sourceSpan));
  10960. }
  10961. else if (nodes[0] instanceof Text) {
  10962. var /** @type {?} */ value = (/** @type {?} */ (nodes[0])).value;
  10963. translatedAttributes.push(new Attribute$1(attr.name, value, attr.sourceSpan));
  10964. }
  10965. else {
  10966. _this._reportError(el, "Unexpected translation for attribute \"" + attr.name + "\" (id=\"" + (id || _this._translations.digest(message)) + "\")");
  10967. }
  10968. }
  10969. else {
  10970. _this._reportError(el, "Translation unavailable for attribute \"" + attr.name + "\" (id=\"" + (id || _this._translations.digest(message)) + "\")");
  10971. }
  10972. }
  10973. else {
  10974. translatedAttributes.push(attr);
  10975. }
  10976. });
  10977. return translatedAttributes;
  10978. };
  10979. /**
  10980. * Add the node as a child of the block when:
  10981. * - we are in a block,
  10982. * - we are not inside a ICU message (those are handled separately),
  10983. * - the node is a "direct child" of the block
  10984. * @param {?} node
  10985. * @return {?}
  10986. */
  10987. _Visitor.prototype._mayBeAddBlockChildren = /**
  10988. * Add the node as a child of the block when:
  10989. * - we are in a block,
  10990. * - we are not inside a ICU message (those are handled separately),
  10991. * - the node is a "direct child" of the block
  10992. * @param {?} node
  10993. * @return {?}
  10994. */
  10995. function (node) {
  10996. if (this._inI18nBlock && !this._inIcu && this._depth == this._blockStartDepth) {
  10997. this._blockChildren.push(node);
  10998. }
  10999. };
  11000. /**
  11001. * Marks the start of a section, see `_closeTranslatableSection`
  11002. * @param {?} node
  11003. * @return {?}
  11004. */
  11005. _Visitor.prototype._openTranslatableSection = /**
  11006. * Marks the start of a section, see `_closeTranslatableSection`
  11007. * @param {?} node
  11008. * @return {?}
  11009. */
  11010. function (node) {
  11011. if (this._isInTranslatableSection) {
  11012. this._reportError(node, 'Unexpected section start');
  11013. }
  11014. else {
  11015. this._msgCountAtSectionStart = this._messages.length;
  11016. }
  11017. };
  11018. Object.defineProperty(_Visitor.prototype, "_isInTranslatableSection", {
  11019. get: /**
  11020. * A translatable section could be:
  11021. * - the content of translatable element,
  11022. * - nodes between `<!-- i18n -->` and `<!-- /i18n -->` comments
  11023. * @return {?}
  11024. */
  11025. function () {
  11026. return this._msgCountAtSectionStart !== void 0;
  11027. },
  11028. enumerable: true,
  11029. configurable: true
  11030. });
  11031. /**
  11032. * Terminates a section.
  11033. *
  11034. * If a section has only one significant children (comments not significant) then we should not
  11035. * keep the message from this children:
  11036. *
  11037. * `<p i18n="meaning|description">{ICU message}</p>` would produce two messages:
  11038. * - one for the <p> content with meaning and description,
  11039. * - another one for the ICU message.
  11040. *
  11041. * In this case the last message is discarded as it contains less information (the AST is
  11042. * otherwise identical).
  11043. *
  11044. * Note that we should still keep messages extracted from attributes inside the section (ie in the
  11045. * ICU message here)
  11046. * @param {?} node
  11047. * @param {?} directChildren
  11048. * @return {?}
  11049. */
  11050. _Visitor.prototype._closeTranslatableSection = /**
  11051. * Terminates a section.
  11052. *
  11053. * If a section has only one significant children (comments not significant) then we should not
  11054. * keep the message from this children:
  11055. *
  11056. * `<p i18n="meaning|description">{ICU message}</p>` would produce two messages:
  11057. * - one for the <p> content with meaning and description,
  11058. * - another one for the ICU message.
  11059. *
  11060. * In this case the last message is discarded as it contains less information (the AST is
  11061. * otherwise identical).
  11062. *
  11063. * Note that we should still keep messages extracted from attributes inside the section (ie in the
  11064. * ICU message here)
  11065. * @param {?} node
  11066. * @param {?} directChildren
  11067. * @return {?}
  11068. */
  11069. function (node, directChildren) {
  11070. if (!this._isInTranslatableSection) {
  11071. this._reportError(node, 'Unexpected section end');
  11072. return;
  11073. }
  11074. var /** @type {?} */ startIndex = this._msgCountAtSectionStart;
  11075. var /** @type {?} */ significantChildren = directChildren.reduce(function (count, node) { return count + (node instanceof Comment ? 0 : 1); }, 0);
  11076. if (significantChildren == 1) {
  11077. for (var /** @type {?} */ i = this._messages.length - 1; i >= /** @type {?} */ ((startIndex)); i--) {
  11078. var /** @type {?} */ ast = this._messages[i].nodes;
  11079. if (!(ast.length == 1 && ast[0] instanceof Text$1)) {
  11080. this._messages.splice(i, 1);
  11081. break;
  11082. }
  11083. }
  11084. }
  11085. this._msgCountAtSectionStart = undefined;
  11086. };
  11087. /**
  11088. * @param {?} node
  11089. * @param {?} msg
  11090. * @return {?}
  11091. */
  11092. _Visitor.prototype._reportError = /**
  11093. * @param {?} node
  11094. * @param {?} msg
  11095. * @return {?}
  11096. */
  11097. function (node, msg) {
  11098. this._errors.push(new I18nError(/** @type {?} */ ((node.sourceSpan)), msg));
  11099. };
  11100. return _Visitor;
  11101. }());
  11102. /**
  11103. * @param {?} n
  11104. * @return {?}
  11105. */
  11106. function _isOpeningComment(n) {
  11107. return !!(n instanceof Comment && n.value && n.value.startsWith('i18n'));
  11108. }
  11109. /**
  11110. * @param {?} n
  11111. * @return {?}
  11112. */
  11113. function _isClosingComment(n) {
  11114. return !!(n instanceof Comment && n.value && n.value === '/i18n');
  11115. }
  11116. /**
  11117. * @param {?} p
  11118. * @return {?}
  11119. */
  11120. function _getI18nAttr(p) {
  11121. return p.attrs.find(function (attr) { return attr.name === _I18N_ATTR; }) || null;
  11122. }
  11123. /**
  11124. * @param {?=} i18n
  11125. * @return {?}
  11126. */
  11127. function _parseMessageMeta(i18n) {
  11128. if (!i18n)
  11129. return { meaning: '', description: '', id: '' };
  11130. var /** @type {?} */ idIndex = i18n.indexOf(ID_SEPARATOR);
  11131. var /** @type {?} */ descIndex = i18n.indexOf(MEANING_SEPARATOR);
  11132. var _a = (idIndex > -1) ? [i18n.slice(0, idIndex), i18n.slice(idIndex + 2)] : [i18n, ''], meaningAndDesc = _a[0], id = _a[1];
  11133. var _b = (descIndex > -1) ?
  11134. [meaningAndDesc.slice(0, descIndex), meaningAndDesc.slice(descIndex + 1)] :
  11135. ['', meaningAndDesc], meaning = _b[0], description = _b[1];
  11136. return { meaning: meaning, description: description, id: id };
  11137. }
  11138. /**
  11139. * @fileoverview added by tsickle
  11140. * @suppress {checkTypes} checked by tsc
  11141. */
  11142. /**
  11143. * @license
  11144. * Copyright Google Inc. All Rights Reserved.
  11145. *
  11146. * Use of this source code is governed by an MIT-style license that can be
  11147. * found in the LICENSE file at https://angular.io/license
  11148. */
  11149. var XmlTagDefinition = /** @class */ (function () {
  11150. function XmlTagDefinition() {
  11151. this.closedByParent = false;
  11152. this.contentType = TagContentType.PARSABLE_DATA;
  11153. this.isVoid = false;
  11154. this.ignoreFirstLf = false;
  11155. this.canSelfClose = true;
  11156. }
  11157. /**
  11158. * @param {?} currentParent
  11159. * @return {?}
  11160. */
  11161. XmlTagDefinition.prototype.requireExtraParent = /**
  11162. * @param {?} currentParent
  11163. * @return {?}
  11164. */
  11165. function (currentParent) { return false; };
  11166. /**
  11167. * @param {?} name
  11168. * @return {?}
  11169. */
  11170. XmlTagDefinition.prototype.isClosedByChild = /**
  11171. * @param {?} name
  11172. * @return {?}
  11173. */
  11174. function (name) { return false; };
  11175. return XmlTagDefinition;
  11176. }());
  11177. var _TAG_DEFINITION = new XmlTagDefinition();
  11178. /**
  11179. * @param {?} tagName
  11180. * @return {?}
  11181. */
  11182. function getXmlTagDefinition(tagName) {
  11183. return _TAG_DEFINITION;
  11184. }
  11185. /**
  11186. * @fileoverview added by tsickle
  11187. * @suppress {checkTypes} checked by tsc
  11188. */
  11189. /**
  11190. * @license
  11191. * Copyright Google Inc. All Rights Reserved.
  11192. *
  11193. * Use of this source code is governed by an MIT-style license that can be
  11194. * found in the LICENSE file at https://angular.io/license
  11195. */
  11196. var XmlParser = /** @class */ (function (_super) {
  11197. __extends(XmlParser, _super);
  11198. function XmlParser() {
  11199. return _super.call(this, getXmlTagDefinition) || this;
  11200. }
  11201. /**
  11202. * @param {?} source
  11203. * @param {?} url
  11204. * @param {?=} parseExpansionForms
  11205. * @return {?}
  11206. */
  11207. XmlParser.prototype.parse = /**
  11208. * @param {?} source
  11209. * @param {?} url
  11210. * @param {?=} parseExpansionForms
  11211. * @return {?}
  11212. */
  11213. function (source, url, parseExpansionForms) {
  11214. if (parseExpansionForms === void 0) { parseExpansionForms = false; }
  11215. return _super.prototype.parse.call(this, source, url, parseExpansionForms);
  11216. };
  11217. return XmlParser;
  11218. }(Parser$1));
  11219. /**
  11220. * @fileoverview added by tsickle
  11221. * @suppress {checkTypes} checked by tsc
  11222. */
  11223. /**
  11224. * @license
  11225. * Copyright Google Inc. All Rights Reserved.
  11226. *
  11227. * Use of this source code is governed by an MIT-style license that can be
  11228. * found in the LICENSE file at https://angular.io/license
  11229. */
  11230. /**
  11231. * @abstract
  11232. */
  11233. var Serializer = /** @class */ (function () {
  11234. function Serializer() {
  11235. }
  11236. // Creates a name mapper, see `PlaceholderMapper`
  11237. // Returning `null` means that no name mapping is used.
  11238. /**
  11239. * @param {?} message
  11240. * @return {?}
  11241. */
  11242. Serializer.prototype.createNameMapper = /**
  11243. * @param {?} message
  11244. * @return {?}
  11245. */
  11246. function (message) { return null; };
  11247. return Serializer;
  11248. }());
  11249. /**
  11250. * A `PlaceholderMapper` converts placeholder names from internal to serialized representation and
  11251. * back.
  11252. *
  11253. * It should be used for serialization format that put constraints on the placeholder names.
  11254. * @record
  11255. */
  11256. /**
  11257. * A simple mapper that take a function to transform an internal name to a public name
  11258. */
  11259. var SimplePlaceholderMapper = /** @class */ (function (_super) {
  11260. __extends(SimplePlaceholderMapper, _super);
  11261. // create a mapping from the message
  11262. function SimplePlaceholderMapper(message, mapName) {
  11263. var _this = _super.call(this) || this;
  11264. _this.mapName = mapName;
  11265. _this.internalToPublic = {};
  11266. _this.publicToNextId = {};
  11267. _this.publicToInternal = {};
  11268. message.nodes.forEach(function (node) { return node.visit(_this); });
  11269. return _this;
  11270. }
  11271. /**
  11272. * @param {?} internalName
  11273. * @return {?}
  11274. */
  11275. SimplePlaceholderMapper.prototype.toPublicName = /**
  11276. * @param {?} internalName
  11277. * @return {?}
  11278. */
  11279. function (internalName) {
  11280. return this.internalToPublic.hasOwnProperty(internalName) ?
  11281. this.internalToPublic[internalName] :
  11282. null;
  11283. };
  11284. /**
  11285. * @param {?} publicName
  11286. * @return {?}
  11287. */
  11288. SimplePlaceholderMapper.prototype.toInternalName = /**
  11289. * @param {?} publicName
  11290. * @return {?}
  11291. */
  11292. function (publicName) {
  11293. return this.publicToInternal.hasOwnProperty(publicName) ? this.publicToInternal[publicName] :
  11294. null;
  11295. };
  11296. /**
  11297. * @param {?} text
  11298. * @param {?=} context
  11299. * @return {?}
  11300. */
  11301. SimplePlaceholderMapper.prototype.visitText = /**
  11302. * @param {?} text
  11303. * @param {?=} context
  11304. * @return {?}
  11305. */
  11306. function (text, context) { return null; };
  11307. /**
  11308. * @param {?} ph
  11309. * @param {?=} context
  11310. * @return {?}
  11311. */
  11312. SimplePlaceholderMapper.prototype.visitTagPlaceholder = /**
  11313. * @param {?} ph
  11314. * @param {?=} context
  11315. * @return {?}
  11316. */
  11317. function (ph, context) {
  11318. this.visitPlaceholderName(ph.startName);
  11319. _super.prototype.visitTagPlaceholder.call(this, ph, context);
  11320. this.visitPlaceholderName(ph.closeName);
  11321. };
  11322. /**
  11323. * @param {?} ph
  11324. * @param {?=} context
  11325. * @return {?}
  11326. */
  11327. SimplePlaceholderMapper.prototype.visitPlaceholder = /**
  11328. * @param {?} ph
  11329. * @param {?=} context
  11330. * @return {?}
  11331. */
  11332. function (ph, context) { this.visitPlaceholderName(ph.name); };
  11333. /**
  11334. * @param {?} ph
  11335. * @param {?=} context
  11336. * @return {?}
  11337. */
  11338. SimplePlaceholderMapper.prototype.visitIcuPlaceholder = /**
  11339. * @param {?} ph
  11340. * @param {?=} context
  11341. * @return {?}
  11342. */
  11343. function (ph, context) {
  11344. this.visitPlaceholderName(ph.name);
  11345. };
  11346. /**
  11347. * @param {?} internalName
  11348. * @return {?}
  11349. */
  11350. SimplePlaceholderMapper.prototype.visitPlaceholderName = /**
  11351. * @param {?} internalName
  11352. * @return {?}
  11353. */
  11354. function (internalName) {
  11355. if (!internalName || this.internalToPublic.hasOwnProperty(internalName)) {
  11356. return;
  11357. }
  11358. var /** @type {?} */ publicName = this.mapName(internalName);
  11359. if (this.publicToInternal.hasOwnProperty(publicName)) {
  11360. // Create a new XMB when it has already been used
  11361. var /** @type {?} */ nextId = this.publicToNextId[publicName];
  11362. this.publicToNextId[publicName] = nextId + 1;
  11363. publicName = publicName + "_" + nextId;
  11364. }
  11365. else {
  11366. this.publicToNextId[publicName] = 1;
  11367. }
  11368. this.internalToPublic[internalName] = publicName;
  11369. this.publicToInternal[publicName] = internalName;
  11370. };
  11371. return SimplePlaceholderMapper;
  11372. }(RecurseVisitor));
  11373. /**
  11374. * @fileoverview added by tsickle
  11375. * @suppress {checkTypes} checked by tsc
  11376. */
  11377. /**
  11378. * @license
  11379. * Copyright Google Inc. All Rights Reserved.
  11380. *
  11381. * Use of this source code is governed by an MIT-style license that can be
  11382. * found in the LICENSE file at https://angular.io/license
  11383. */
  11384. /**
  11385. * @record
  11386. */
  11387. var _Visitor$1 = /** @class */ (function () {
  11388. function _Visitor() {
  11389. }
  11390. /**
  11391. * @param {?} tag
  11392. * @return {?}
  11393. */
  11394. _Visitor.prototype.visitTag = /**
  11395. * @param {?} tag
  11396. * @return {?}
  11397. */
  11398. function (tag) {
  11399. var _this = this;
  11400. var /** @type {?} */ strAttrs = this._serializeAttributes(tag.attrs);
  11401. if (tag.children.length == 0) {
  11402. return "<" + tag.name + strAttrs + "/>";
  11403. }
  11404. var /** @type {?} */ strChildren = tag.children.map(function (node) { return node.visit(_this); });
  11405. return "<" + tag.name + strAttrs + ">" + strChildren.join('') + "</" + tag.name + ">";
  11406. };
  11407. /**
  11408. * @param {?} text
  11409. * @return {?}
  11410. */
  11411. _Visitor.prototype.visitText = /**
  11412. * @param {?} text
  11413. * @return {?}
  11414. */
  11415. function (text) { return text.value; };
  11416. /**
  11417. * @param {?} decl
  11418. * @return {?}
  11419. */
  11420. _Visitor.prototype.visitDeclaration = /**
  11421. * @param {?} decl
  11422. * @return {?}
  11423. */
  11424. function (decl) {
  11425. return "<?xml" + this._serializeAttributes(decl.attrs) + " ?>";
  11426. };
  11427. /**
  11428. * @param {?} attrs
  11429. * @return {?}
  11430. */
  11431. _Visitor.prototype._serializeAttributes = /**
  11432. * @param {?} attrs
  11433. * @return {?}
  11434. */
  11435. function (attrs) {
  11436. var /** @type {?} */ strAttrs = Object.keys(attrs).map(function (name) { return name + "=\"" + attrs[name] + "\""; }).join(' ');
  11437. return strAttrs.length > 0 ? ' ' + strAttrs : '';
  11438. };
  11439. /**
  11440. * @param {?} doctype
  11441. * @return {?}
  11442. */
  11443. _Visitor.prototype.visitDoctype = /**
  11444. * @param {?} doctype
  11445. * @return {?}
  11446. */
  11447. function (doctype) {
  11448. return "<!DOCTYPE " + doctype.rootTag + " [\n" + doctype.dtd + "\n]>";
  11449. };
  11450. return _Visitor;
  11451. }());
  11452. var _visitor = new _Visitor$1();
  11453. /**
  11454. * @param {?} nodes
  11455. * @return {?}
  11456. */
  11457. function serialize(nodes) {
  11458. return nodes.map(function (node) { return node.visit(_visitor); }).join('');
  11459. }
  11460. /**
  11461. * @record
  11462. */
  11463. var Declaration = /** @class */ (function () {
  11464. function Declaration(unescapedAttrs) {
  11465. var _this = this;
  11466. this.attrs = {};
  11467. Object.keys(unescapedAttrs).forEach(function (k) {
  11468. _this.attrs[k] = escapeXml(unescapedAttrs[k]);
  11469. });
  11470. }
  11471. /**
  11472. * @param {?} visitor
  11473. * @return {?}
  11474. */
  11475. Declaration.prototype.visit = /**
  11476. * @param {?} visitor
  11477. * @return {?}
  11478. */
  11479. function (visitor) { return visitor.visitDeclaration(this); };
  11480. return Declaration;
  11481. }());
  11482. var Doctype = /** @class */ (function () {
  11483. function Doctype(rootTag, dtd) {
  11484. this.rootTag = rootTag;
  11485. this.dtd = dtd;
  11486. }
  11487. /**
  11488. * @param {?} visitor
  11489. * @return {?}
  11490. */
  11491. Doctype.prototype.visit = /**
  11492. * @param {?} visitor
  11493. * @return {?}
  11494. */
  11495. function (visitor) { return visitor.visitDoctype(this); };
  11496. return Doctype;
  11497. }());
  11498. var Tag = /** @class */ (function () {
  11499. function Tag(name, unescapedAttrs, children) {
  11500. if (unescapedAttrs === void 0) { unescapedAttrs = {}; }
  11501. if (children === void 0) { children = []; }
  11502. var _this = this;
  11503. this.name = name;
  11504. this.children = children;
  11505. this.attrs = {};
  11506. Object.keys(unescapedAttrs).forEach(function (k) {
  11507. _this.attrs[k] = escapeXml(unescapedAttrs[k]);
  11508. });
  11509. }
  11510. /**
  11511. * @param {?} visitor
  11512. * @return {?}
  11513. */
  11514. Tag.prototype.visit = /**
  11515. * @param {?} visitor
  11516. * @return {?}
  11517. */
  11518. function (visitor) { return visitor.visitTag(this); };
  11519. return Tag;
  11520. }());
  11521. var Text$2 = /** @class */ (function () {
  11522. function Text(unescapedValue) {
  11523. this.value = escapeXml(unescapedValue);
  11524. }
  11525. /**
  11526. * @param {?} visitor
  11527. * @return {?}
  11528. */
  11529. Text.prototype.visit = /**
  11530. * @param {?} visitor
  11531. * @return {?}
  11532. */
  11533. function (visitor) { return visitor.visitText(this); };
  11534. return Text;
  11535. }());
  11536. var CR = /** @class */ (function (_super) {
  11537. __extends(CR, _super);
  11538. function CR(ws) {
  11539. if (ws === void 0) { ws = 0; }
  11540. return _super.call(this, "\n" + new Array(ws + 1).join(' ')) || this;
  11541. }
  11542. return CR;
  11543. }(Text$2));
  11544. var _ESCAPED_CHARS = [
  11545. [/&/g, '&amp;'],
  11546. [/"/g, '&quot;'],
  11547. [/'/g, '&apos;'],
  11548. [/</g, '&lt;'],
  11549. [/>/g, '&gt;'],
  11550. ];
  11551. /**
  11552. * @param {?} text
  11553. * @return {?}
  11554. */
  11555. function escapeXml(text) {
  11556. return _ESCAPED_CHARS.reduce(function (text, entry) { return text.replace(entry[0], entry[1]); }, text);
  11557. }
  11558. /**
  11559. * @fileoverview added by tsickle
  11560. * @suppress {checkTypes} checked by tsc
  11561. */
  11562. /**
  11563. * @license
  11564. * Copyright Google Inc. All Rights Reserved.
  11565. *
  11566. * Use of this source code is governed by an MIT-style license that can be
  11567. * found in the LICENSE file at https://angular.io/license
  11568. */
  11569. var _VERSION = '1.2';
  11570. var _XMLNS = 'urn:oasis:names:tc:xliff:document:1.2';
  11571. // TODO(vicb): make this a param (s/_/-/)
  11572. var _DEFAULT_SOURCE_LANG = 'en';
  11573. var _PLACEHOLDER_TAG = 'x';
  11574. var _MARKER_TAG = 'mrk';
  11575. var _FILE_TAG = 'file';
  11576. var _SOURCE_TAG = 'source';
  11577. var _SEGMENT_SOURCE_TAG = 'seg-source';
  11578. var _TARGET_TAG = 'target';
  11579. var _UNIT_TAG = 'trans-unit';
  11580. var _CONTEXT_GROUP_TAG = 'context-group';
  11581. var _CONTEXT_TAG = 'context';
  11582. var Xliff = /** @class */ (function (_super) {
  11583. __extends(Xliff, _super);
  11584. function Xliff() {
  11585. return _super !== null && _super.apply(this, arguments) || this;
  11586. }
  11587. /**
  11588. * @param {?} messages
  11589. * @param {?} locale
  11590. * @return {?}
  11591. */
  11592. Xliff.prototype.write = /**
  11593. * @param {?} messages
  11594. * @param {?} locale
  11595. * @return {?}
  11596. */
  11597. function (messages, locale) {
  11598. var /** @type {?} */ visitor = new _WriteVisitor();
  11599. var /** @type {?} */ transUnits = [];
  11600. messages.forEach(function (message) {
  11601. var /** @type {?} */ contextTags = [];
  11602. message.sources.forEach(function (source) {
  11603. var /** @type {?} */ contextGroupTag = new Tag(_CONTEXT_GROUP_TAG, { purpose: 'location' });
  11604. 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));
  11605. contextTags.push(new CR(8), contextGroupTag);
  11606. });
  11607. var /** @type {?} */ transUnit = new Tag(_UNIT_TAG, { id: message.id, datatype: 'html' });
  11608. (_a = transUnit.children).push.apply(_a, [new CR(8), new Tag(_SOURCE_TAG, {}, visitor.serialize(message.nodes))].concat(contextTags));
  11609. if (message.description) {
  11610. transUnit.children.push(new CR(8), new Tag('note', { priority: '1', from: 'description' }, [new Text$2(message.description)]));
  11611. }
  11612. if (message.meaning) {
  11613. transUnit.children.push(new CR(8), new Tag('note', { priority: '1', from: 'meaning' }, [new Text$2(message.meaning)]));
  11614. }
  11615. transUnit.children.push(new CR(6));
  11616. transUnits.push(new CR(6), transUnit);
  11617. var _a;
  11618. });
  11619. var /** @type {?} */ body = new Tag('body', {}, transUnits.concat([new CR(4)]));
  11620. var /** @type {?} */ file = new Tag('file', {
  11621. 'source-language': locale || _DEFAULT_SOURCE_LANG,
  11622. datatype: 'plaintext',
  11623. original: 'ng2.template',
  11624. }, [new CR(4), body, new CR(2)]);
  11625. var /** @type {?} */ xliff = new Tag('xliff', { version: _VERSION, xmlns: _XMLNS }, [new CR(2), file, new CR()]);
  11626. return serialize([
  11627. new Declaration({ version: '1.0', encoding: 'UTF-8' }), new CR(), xliff, new CR()
  11628. ]);
  11629. };
  11630. /**
  11631. * @param {?} content
  11632. * @param {?} url
  11633. * @return {?}
  11634. */
  11635. Xliff.prototype.load = /**
  11636. * @param {?} content
  11637. * @param {?} url
  11638. * @return {?}
  11639. */
  11640. function (content, url) {
  11641. // xliff to xml nodes
  11642. var /** @type {?} */ xliffParser = new XliffParser();
  11643. var _a = xliffParser.parse(content, url), locale = _a.locale, msgIdToHtml = _a.msgIdToHtml, errors = _a.errors;
  11644. // xml nodes to i18n nodes
  11645. var /** @type {?} */ i18nNodesByMsgId = {};
  11646. var /** @type {?} */ converter = new XmlToI18n();
  11647. Object.keys(msgIdToHtml).forEach(function (msgId) {
  11648. var _a = converter.convert(msgIdToHtml[msgId], url), i18nNodes = _a.i18nNodes, e = _a.errors;
  11649. errors.push.apply(errors, e);
  11650. i18nNodesByMsgId[msgId] = i18nNodes;
  11651. });
  11652. if (errors.length) {
  11653. throw new Error("xliff parse errors:\n" + errors.join('\n'));
  11654. }
  11655. return { locale: /** @type {?} */ ((locale)), i18nNodesByMsgId: i18nNodesByMsgId };
  11656. };
  11657. /**
  11658. * @param {?} message
  11659. * @return {?}
  11660. */
  11661. Xliff.prototype.digest = /**
  11662. * @param {?} message
  11663. * @return {?}
  11664. */
  11665. function (message) { return digest(message); };
  11666. return Xliff;
  11667. }(Serializer));
  11668. var _WriteVisitor = /** @class */ (function () {
  11669. function _WriteVisitor() {
  11670. }
  11671. /**
  11672. * @param {?} text
  11673. * @param {?=} context
  11674. * @return {?}
  11675. */
  11676. _WriteVisitor.prototype.visitText = /**
  11677. * @param {?} text
  11678. * @param {?=} context
  11679. * @return {?}
  11680. */
  11681. function (text, context) { return [new Text$2(text.value)]; };
  11682. /**
  11683. * @param {?} container
  11684. * @param {?=} context
  11685. * @return {?}
  11686. */
  11687. _WriteVisitor.prototype.visitContainer = /**
  11688. * @param {?} container
  11689. * @param {?=} context
  11690. * @return {?}
  11691. */
  11692. function (container, context) {
  11693. var _this = this;
  11694. var /** @type {?} */ nodes = [];
  11695. container.children.forEach(function (node) { return nodes.push.apply(nodes, node.visit(_this)); });
  11696. return nodes;
  11697. };
  11698. /**
  11699. * @param {?} icu
  11700. * @param {?=} context
  11701. * @return {?}
  11702. */
  11703. _WriteVisitor.prototype.visitIcu = /**
  11704. * @param {?} icu
  11705. * @param {?=} context
  11706. * @return {?}
  11707. */
  11708. function (icu, context) {
  11709. var _this = this;
  11710. var /** @type {?} */ nodes = [new Text$2("{" + icu.expressionPlaceholder + ", " + icu.type + ", ")];
  11711. Object.keys(icu.cases).forEach(function (c) {
  11712. nodes.push.apply(nodes, [new Text$2(c + " {")].concat(icu.cases[c].visit(_this), [new Text$2("} ")]));
  11713. });
  11714. nodes.push(new Text$2("}"));
  11715. return nodes;
  11716. };
  11717. /**
  11718. * @param {?} ph
  11719. * @param {?=} context
  11720. * @return {?}
  11721. */
  11722. _WriteVisitor.prototype.visitTagPlaceholder = /**
  11723. * @param {?} ph
  11724. * @param {?=} context
  11725. * @return {?}
  11726. */
  11727. function (ph, context) {
  11728. var /** @type {?} */ ctype = getCtypeForTag(ph.tag);
  11729. if (ph.isVoid) {
  11730. // void tags have no children nor closing tags
  11731. return [new Tag(_PLACEHOLDER_TAG, { id: ph.startName, ctype: ctype, 'equiv-text': "<" + ph.tag + "/>" })];
  11732. }
  11733. var /** @type {?} */ startTagPh = new Tag(_PLACEHOLDER_TAG, { id: ph.startName, ctype: ctype, 'equiv-text': "<" + ph.tag + ">" });
  11734. var /** @type {?} */ closeTagPh = new Tag(_PLACEHOLDER_TAG, { id: ph.closeName, ctype: ctype, 'equiv-text': "</" + ph.tag + ">" });
  11735. return [startTagPh].concat(this.serialize(ph.children), [closeTagPh]);
  11736. };
  11737. /**
  11738. * @param {?} ph
  11739. * @param {?=} context
  11740. * @return {?}
  11741. */
  11742. _WriteVisitor.prototype.visitPlaceholder = /**
  11743. * @param {?} ph
  11744. * @param {?=} context
  11745. * @return {?}
  11746. */
  11747. function (ph, context) {
  11748. return [new Tag(_PLACEHOLDER_TAG, { id: ph.name, 'equiv-text': "{{" + ph.value + "}}" })];
  11749. };
  11750. /**
  11751. * @param {?} ph
  11752. * @param {?=} context
  11753. * @return {?}
  11754. */
  11755. _WriteVisitor.prototype.visitIcuPlaceholder = /**
  11756. * @param {?} ph
  11757. * @param {?=} context
  11758. * @return {?}
  11759. */
  11760. function (ph, context) {
  11761. var /** @type {?} */ equivText = "{" + ph.value.expression + ", " + ph.value.type + ", " + Object.keys(ph.value.cases).map(function (value) { return value + ' {...}'; }).join(' ') + "}";
  11762. return [new Tag(_PLACEHOLDER_TAG, { id: ph.name, 'equiv-text': equivText })];
  11763. };
  11764. /**
  11765. * @param {?} nodes
  11766. * @return {?}
  11767. */
  11768. _WriteVisitor.prototype.serialize = /**
  11769. * @param {?} nodes
  11770. * @return {?}
  11771. */
  11772. function (nodes) {
  11773. var _this = this;
  11774. return [].concat.apply([], nodes.map(function (node) { return node.visit(_this); }));
  11775. };
  11776. return _WriteVisitor;
  11777. }());
  11778. var XliffParser = /** @class */ (function () {
  11779. function XliffParser() {
  11780. this._locale = null;
  11781. }
  11782. /**
  11783. * @param {?} xliff
  11784. * @param {?} url
  11785. * @return {?}
  11786. */
  11787. XliffParser.prototype.parse = /**
  11788. * @param {?} xliff
  11789. * @param {?} url
  11790. * @return {?}
  11791. */
  11792. function (xliff, url) {
  11793. this._unitMlString = null;
  11794. this._msgIdToHtml = {};
  11795. var /** @type {?} */ xml = new XmlParser().parse(xliff, url, false);
  11796. this._errors = xml.errors;
  11797. visitAll(this, xml.rootNodes, null);
  11798. return {
  11799. msgIdToHtml: this._msgIdToHtml,
  11800. errors: this._errors,
  11801. locale: this._locale,
  11802. };
  11803. };
  11804. /**
  11805. * @param {?} element
  11806. * @param {?} context
  11807. * @return {?}
  11808. */
  11809. XliffParser.prototype.visitElement = /**
  11810. * @param {?} element
  11811. * @param {?} context
  11812. * @return {?}
  11813. */
  11814. function (element, context) {
  11815. switch (element.name) {
  11816. case _UNIT_TAG:
  11817. this._unitMlString = /** @type {?} */ ((null));
  11818. var /** @type {?} */ idAttr = element.attrs.find(function (attr) { return attr.name === 'id'; });
  11819. if (!idAttr) {
  11820. this._addError(element, "<" + _UNIT_TAG + "> misses the \"id\" attribute");
  11821. }
  11822. else {
  11823. var /** @type {?} */ id = idAttr.value;
  11824. if (this._msgIdToHtml.hasOwnProperty(id)) {
  11825. this._addError(element, "Duplicated translations for msg " + id);
  11826. }
  11827. else {
  11828. visitAll(this, element.children, null);
  11829. if (typeof this._unitMlString === 'string') {
  11830. this._msgIdToHtml[id] = this._unitMlString;
  11831. }
  11832. else {
  11833. this._addError(element, "Message " + id + " misses a translation");
  11834. }
  11835. }
  11836. }
  11837. break;
  11838. // ignore those tags
  11839. case _SOURCE_TAG:
  11840. case _SEGMENT_SOURCE_TAG:
  11841. break;
  11842. case _TARGET_TAG:
  11843. var /** @type {?} */ innerTextStart = /** @type {?} */ ((element.startSourceSpan)).end.offset;
  11844. var /** @type {?} */ innerTextEnd = /** @type {?} */ ((element.endSourceSpan)).start.offset;
  11845. var /** @type {?} */ content = /** @type {?} */ ((element.startSourceSpan)).start.file.content;
  11846. var /** @type {?} */ innerText = content.slice(innerTextStart, innerTextEnd);
  11847. this._unitMlString = innerText;
  11848. break;
  11849. case _FILE_TAG:
  11850. var /** @type {?} */ localeAttr = element.attrs.find(function (attr) { return attr.name === 'target-language'; });
  11851. if (localeAttr) {
  11852. this._locale = localeAttr.value;
  11853. }
  11854. visitAll(this, element.children, null);
  11855. break;
  11856. default:
  11857. // TODO(vicb): assert file structure, xliff version
  11858. // For now only recurse on unhandled nodes
  11859. visitAll(this, element.children, null);
  11860. }
  11861. };
  11862. /**
  11863. * @param {?} attribute
  11864. * @param {?} context
  11865. * @return {?}
  11866. */
  11867. XliffParser.prototype.visitAttribute = /**
  11868. * @param {?} attribute
  11869. * @param {?} context
  11870. * @return {?}
  11871. */
  11872. function (attribute, context) { };
  11873. /**
  11874. * @param {?} text
  11875. * @param {?} context
  11876. * @return {?}
  11877. */
  11878. XliffParser.prototype.visitText = /**
  11879. * @param {?} text
  11880. * @param {?} context
  11881. * @return {?}
  11882. */
  11883. function (text, context) { };
  11884. /**
  11885. * @param {?} comment
  11886. * @param {?} context
  11887. * @return {?}
  11888. */
  11889. XliffParser.prototype.visitComment = /**
  11890. * @param {?} comment
  11891. * @param {?} context
  11892. * @return {?}
  11893. */
  11894. function (comment, context) { };
  11895. /**
  11896. * @param {?} expansion
  11897. * @param {?} context
  11898. * @return {?}
  11899. */
  11900. XliffParser.prototype.visitExpansion = /**
  11901. * @param {?} expansion
  11902. * @param {?} context
  11903. * @return {?}
  11904. */
  11905. function (expansion, context) { };
  11906. /**
  11907. * @param {?} expansionCase
  11908. * @param {?} context
  11909. * @return {?}
  11910. */
  11911. XliffParser.prototype.visitExpansionCase = /**
  11912. * @param {?} expansionCase
  11913. * @param {?} context
  11914. * @return {?}
  11915. */
  11916. function (expansionCase, context) { };
  11917. /**
  11918. * @param {?} node
  11919. * @param {?} message
  11920. * @return {?}
  11921. */
  11922. XliffParser.prototype._addError = /**
  11923. * @param {?} node
  11924. * @param {?} message
  11925. * @return {?}
  11926. */
  11927. function (node, message) {
  11928. this._errors.push(new I18nError(/** @type {?} */ ((node.sourceSpan)), message));
  11929. };
  11930. return XliffParser;
  11931. }());
  11932. var XmlToI18n = /** @class */ (function () {
  11933. function XmlToI18n() {
  11934. }
  11935. /**
  11936. * @param {?} message
  11937. * @param {?} url
  11938. * @return {?}
  11939. */
  11940. XmlToI18n.prototype.convert = /**
  11941. * @param {?} message
  11942. * @param {?} url
  11943. * @return {?}
  11944. */
  11945. function (message, url) {
  11946. var /** @type {?} */ xmlIcu = new XmlParser().parse(message, url, true);
  11947. this._errors = xmlIcu.errors;
  11948. var /** @type {?} */ i18nNodes = this._errors.length > 0 || xmlIcu.rootNodes.length == 0 ?
  11949. [] : [].concat.apply([], visitAll(this, xmlIcu.rootNodes));
  11950. return {
  11951. i18nNodes: i18nNodes,
  11952. errors: this._errors,
  11953. };
  11954. };
  11955. /**
  11956. * @param {?} text
  11957. * @param {?} context
  11958. * @return {?}
  11959. */
  11960. XmlToI18n.prototype.visitText = /**
  11961. * @param {?} text
  11962. * @param {?} context
  11963. * @return {?}
  11964. */
  11965. function (text, context) { return new Text$1(text.value, /** @type {?} */ ((text.sourceSpan))); };
  11966. /**
  11967. * @param {?} el
  11968. * @param {?} context
  11969. * @return {?}
  11970. */
  11971. XmlToI18n.prototype.visitElement = /**
  11972. * @param {?} el
  11973. * @param {?} context
  11974. * @return {?}
  11975. */
  11976. function (el, context) {
  11977. if (el.name === _PLACEHOLDER_TAG) {
  11978. var /** @type {?} */ nameAttr = el.attrs.find(function (attr) { return attr.name === 'id'; });
  11979. if (nameAttr) {
  11980. return new Placeholder('', nameAttr.value, /** @type {?} */ ((el.sourceSpan)));
  11981. }
  11982. this._addError(el, "<" + _PLACEHOLDER_TAG + "> misses the \"id\" attribute");
  11983. return null;
  11984. }
  11985. if (el.name === _MARKER_TAG) {
  11986. return [].concat.apply([], visitAll(this, el.children));
  11987. }
  11988. this._addError(el, "Unexpected tag");
  11989. return null;
  11990. };
  11991. /**
  11992. * @param {?} icu
  11993. * @param {?} context
  11994. * @return {?}
  11995. */
  11996. XmlToI18n.prototype.visitExpansion = /**
  11997. * @param {?} icu
  11998. * @param {?} context
  11999. * @return {?}
  12000. */
  12001. function (icu, context) {
  12002. var /** @type {?} */ caseMap = {};
  12003. visitAll(this, icu.cases).forEach(function (c) {
  12004. caseMap[c.value] = new Container(c.nodes, icu.sourceSpan);
  12005. });
  12006. return new Icu(icu.switchValue, icu.type, caseMap, icu.sourceSpan);
  12007. };
  12008. /**
  12009. * @param {?} icuCase
  12010. * @param {?} context
  12011. * @return {?}
  12012. */
  12013. XmlToI18n.prototype.visitExpansionCase = /**
  12014. * @param {?} icuCase
  12015. * @param {?} context
  12016. * @return {?}
  12017. */
  12018. function (icuCase, context) {
  12019. return {
  12020. value: icuCase.value,
  12021. nodes: visitAll(this, icuCase.expression),
  12022. };
  12023. };
  12024. /**
  12025. * @param {?} comment
  12026. * @param {?} context
  12027. * @return {?}
  12028. */
  12029. XmlToI18n.prototype.visitComment = /**
  12030. * @param {?} comment
  12031. * @param {?} context
  12032. * @return {?}
  12033. */
  12034. function (comment, context) { };
  12035. /**
  12036. * @param {?} attribute
  12037. * @param {?} context
  12038. * @return {?}
  12039. */
  12040. XmlToI18n.prototype.visitAttribute = /**
  12041. * @param {?} attribute
  12042. * @param {?} context
  12043. * @return {?}
  12044. */
  12045. function (attribute, context) { };
  12046. /**
  12047. * @param {?} node
  12048. * @param {?} message
  12049. * @return {?}
  12050. */
  12051. XmlToI18n.prototype._addError = /**
  12052. * @param {?} node
  12053. * @param {?} message
  12054. * @return {?}
  12055. */
  12056. function (node, message) {
  12057. this._errors.push(new I18nError(/** @type {?} */ ((node.sourceSpan)), message));
  12058. };
  12059. return XmlToI18n;
  12060. }());
  12061. /**
  12062. * @param {?} tag
  12063. * @return {?}
  12064. */
  12065. function getCtypeForTag(tag) {
  12066. switch (tag.toLowerCase()) {
  12067. case 'br':
  12068. return 'lb';
  12069. case 'img':
  12070. return 'image';
  12071. default:
  12072. return "x-" + tag;
  12073. }
  12074. }
  12075. /**
  12076. * @fileoverview added by tsickle
  12077. * @suppress {checkTypes} checked by tsc
  12078. */
  12079. /**
  12080. * @license
  12081. * Copyright Google Inc. All Rights Reserved.
  12082. *
  12083. * Use of this source code is governed by an MIT-style license that can be
  12084. * found in the LICENSE file at https://angular.io/license
  12085. */
  12086. var _VERSION$1 = '2.0';
  12087. var _XMLNS$1 = 'urn:oasis:names:tc:xliff:document:2.0';
  12088. // TODO(vicb): make this a param (s/_/-/)
  12089. var _DEFAULT_SOURCE_LANG$1 = 'en';
  12090. var _PLACEHOLDER_TAG$1 = 'ph';
  12091. var _PLACEHOLDER_SPANNING_TAG = 'pc';
  12092. var _MARKER_TAG$1 = 'mrk';
  12093. var _XLIFF_TAG = 'xliff';
  12094. var _SOURCE_TAG$1 = 'source';
  12095. var _TARGET_TAG$1 = 'target';
  12096. var _UNIT_TAG$1 = 'unit';
  12097. var Xliff2 = /** @class */ (function (_super) {
  12098. __extends(Xliff2, _super);
  12099. function Xliff2() {
  12100. return _super !== null && _super.apply(this, arguments) || this;
  12101. }
  12102. /**
  12103. * @param {?} messages
  12104. * @param {?} locale
  12105. * @return {?}
  12106. */
  12107. Xliff2.prototype.write = /**
  12108. * @param {?} messages
  12109. * @param {?} locale
  12110. * @return {?}
  12111. */
  12112. function (messages, locale) {
  12113. var /** @type {?} */ visitor = new _WriteVisitor$1();
  12114. var /** @type {?} */ units = [];
  12115. messages.forEach(function (message) {
  12116. var /** @type {?} */ unit = new Tag(_UNIT_TAG$1, { id: message.id });
  12117. var /** @type {?} */ notes = new Tag('notes');
  12118. if (message.description || message.meaning) {
  12119. if (message.description) {
  12120. notes.children.push(new CR(8), new Tag('note', { category: 'description' }, [new Text$2(message.description)]));
  12121. }
  12122. if (message.meaning) {
  12123. notes.children.push(new CR(8), new Tag('note', { category: 'meaning' }, [new Text$2(message.meaning)]));
  12124. }
  12125. }
  12126. message.sources.forEach(function (source) {
  12127. notes.children.push(new CR(8), new Tag('note', { category: 'location' }, [
  12128. new Text$2(source.filePath + ":" + source.startLine + (source.endLine !== source.startLine ? ',' + source.endLine : ''))
  12129. ]));
  12130. });
  12131. notes.children.push(new CR(6));
  12132. unit.children.push(new CR(6), notes);
  12133. var /** @type {?} */ segment = new Tag('segment');
  12134. segment.children.push(new CR(8), new Tag(_SOURCE_TAG$1, {}, visitor.serialize(message.nodes)), new CR(6));
  12135. unit.children.push(new CR(6), segment, new CR(4));
  12136. units.push(new CR(4), unit);
  12137. });
  12138. var /** @type {?} */ file = new Tag('file', { 'original': 'ng.template', id: 'ngi18n' }, units.concat([new CR(2)]));
  12139. 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()]);
  12140. return serialize([
  12141. new Declaration({ version: '1.0', encoding: 'UTF-8' }), new CR(), xliff, new CR()
  12142. ]);
  12143. };
  12144. /**
  12145. * @param {?} content
  12146. * @param {?} url
  12147. * @return {?}
  12148. */
  12149. Xliff2.prototype.load = /**
  12150. * @param {?} content
  12151. * @param {?} url
  12152. * @return {?}
  12153. */
  12154. function (content, url) {
  12155. // xliff to xml nodes
  12156. var /** @type {?} */ xliff2Parser = new Xliff2Parser();
  12157. var _a = xliff2Parser.parse(content, url), locale = _a.locale, msgIdToHtml = _a.msgIdToHtml, errors = _a.errors;
  12158. // xml nodes to i18n nodes
  12159. var /** @type {?} */ i18nNodesByMsgId = {};
  12160. var /** @type {?} */ converter = new XmlToI18n$1();
  12161. Object.keys(msgIdToHtml).forEach(function (msgId) {
  12162. var _a = converter.convert(msgIdToHtml[msgId], url), i18nNodes = _a.i18nNodes, e = _a.errors;
  12163. errors.push.apply(errors, e);
  12164. i18nNodesByMsgId[msgId] = i18nNodes;
  12165. });
  12166. if (errors.length) {
  12167. throw new Error("xliff2 parse errors:\n" + errors.join('\n'));
  12168. }
  12169. return { locale: /** @type {?} */ ((locale)), i18nNodesByMsgId: i18nNodesByMsgId };
  12170. };
  12171. /**
  12172. * @param {?} message
  12173. * @return {?}
  12174. */
  12175. Xliff2.prototype.digest = /**
  12176. * @param {?} message
  12177. * @return {?}
  12178. */
  12179. function (message) { return decimalDigest(message); };
  12180. return Xliff2;
  12181. }(Serializer));
  12182. var _WriteVisitor$1 = /** @class */ (function () {
  12183. function _WriteVisitor() {
  12184. }
  12185. /**
  12186. * @param {?} text
  12187. * @param {?=} context
  12188. * @return {?}
  12189. */
  12190. _WriteVisitor.prototype.visitText = /**
  12191. * @param {?} text
  12192. * @param {?=} context
  12193. * @return {?}
  12194. */
  12195. function (text, context) { return [new Text$2(text.value)]; };
  12196. /**
  12197. * @param {?} container
  12198. * @param {?=} context
  12199. * @return {?}
  12200. */
  12201. _WriteVisitor.prototype.visitContainer = /**
  12202. * @param {?} container
  12203. * @param {?=} context
  12204. * @return {?}
  12205. */
  12206. function (container, context) {
  12207. var _this = this;
  12208. var /** @type {?} */ nodes = [];
  12209. container.children.forEach(function (node) { return nodes.push.apply(nodes, node.visit(_this)); });
  12210. return nodes;
  12211. };
  12212. /**
  12213. * @param {?} icu
  12214. * @param {?=} context
  12215. * @return {?}
  12216. */
  12217. _WriteVisitor.prototype.visitIcu = /**
  12218. * @param {?} icu
  12219. * @param {?=} context
  12220. * @return {?}
  12221. */
  12222. function (icu, context) {
  12223. var _this = this;
  12224. var /** @type {?} */ nodes = [new Text$2("{" + icu.expressionPlaceholder + ", " + icu.type + ", ")];
  12225. Object.keys(icu.cases).forEach(function (c) {
  12226. nodes.push.apply(nodes, [new Text$2(c + " {")].concat(icu.cases[c].visit(_this), [new Text$2("} ")]));
  12227. });
  12228. nodes.push(new Text$2("}"));
  12229. return nodes;
  12230. };
  12231. /**
  12232. * @param {?} ph
  12233. * @param {?=} context
  12234. * @return {?}
  12235. */
  12236. _WriteVisitor.prototype.visitTagPlaceholder = /**
  12237. * @param {?} ph
  12238. * @param {?=} context
  12239. * @return {?}
  12240. */
  12241. function (ph, context) {
  12242. var _this = this;
  12243. var /** @type {?} */ type = getTypeForTag(ph.tag);
  12244. if (ph.isVoid) {
  12245. var /** @type {?} */ tagPh = new Tag(_PLACEHOLDER_TAG$1, {
  12246. id: (this._nextPlaceholderId++).toString(),
  12247. equiv: ph.startName,
  12248. type: type,
  12249. disp: "<" + ph.tag + "/>",
  12250. });
  12251. return [tagPh];
  12252. }
  12253. var /** @type {?} */ tagPc = new Tag(_PLACEHOLDER_SPANNING_TAG, {
  12254. id: (this._nextPlaceholderId++).toString(),
  12255. equivStart: ph.startName,
  12256. equivEnd: ph.closeName,
  12257. type: type,
  12258. dispStart: "<" + ph.tag + ">",
  12259. dispEnd: "</" + ph.tag + ">",
  12260. });
  12261. var /** @type {?} */ nodes = [].concat.apply([], ph.children.map(function (node) { return node.visit(_this); }));
  12262. if (nodes.length) {
  12263. nodes.forEach(function (node) { return tagPc.children.push(node); });
  12264. }
  12265. else {
  12266. tagPc.children.push(new Text$2(''));
  12267. }
  12268. return [tagPc];
  12269. };
  12270. /**
  12271. * @param {?} ph
  12272. * @param {?=} context
  12273. * @return {?}
  12274. */
  12275. _WriteVisitor.prototype.visitPlaceholder = /**
  12276. * @param {?} ph
  12277. * @param {?=} context
  12278. * @return {?}
  12279. */
  12280. function (ph, context) {
  12281. var /** @type {?} */ idStr = (this._nextPlaceholderId++).toString();
  12282. return [new Tag(_PLACEHOLDER_TAG$1, {
  12283. id: idStr,
  12284. equiv: ph.name,
  12285. disp: "{{" + ph.value + "}}",
  12286. })];
  12287. };
  12288. /**
  12289. * @param {?} ph
  12290. * @param {?=} context
  12291. * @return {?}
  12292. */
  12293. _WriteVisitor.prototype.visitIcuPlaceholder = /**
  12294. * @param {?} ph
  12295. * @param {?=} context
  12296. * @return {?}
  12297. */
  12298. function (ph, context) {
  12299. var /** @type {?} */ cases = Object.keys(ph.value.cases).map(function (value) { return value + ' {...}'; }).join(' ');
  12300. var /** @type {?} */ idStr = (this._nextPlaceholderId++).toString();
  12301. return [new Tag(_PLACEHOLDER_TAG$1, { id: idStr, equiv: ph.name, disp: "{" + ph.value.expression + ", " + ph.value.type + ", " + cases + "}" })];
  12302. };
  12303. /**
  12304. * @param {?} nodes
  12305. * @return {?}
  12306. */
  12307. _WriteVisitor.prototype.serialize = /**
  12308. * @param {?} nodes
  12309. * @return {?}
  12310. */
  12311. function (nodes) {
  12312. var _this = this;
  12313. this._nextPlaceholderId = 0;
  12314. return [].concat.apply([], nodes.map(function (node) { return node.visit(_this); }));
  12315. };
  12316. return _WriteVisitor;
  12317. }());
  12318. var Xliff2Parser = /** @class */ (function () {
  12319. function Xliff2Parser() {
  12320. this._locale = null;
  12321. }
  12322. /**
  12323. * @param {?} xliff
  12324. * @param {?} url
  12325. * @return {?}
  12326. */
  12327. Xliff2Parser.prototype.parse = /**
  12328. * @param {?} xliff
  12329. * @param {?} url
  12330. * @return {?}
  12331. */
  12332. function (xliff, url) {
  12333. this._unitMlString = null;
  12334. this._msgIdToHtml = {};
  12335. var /** @type {?} */ xml = new XmlParser().parse(xliff, url, false);
  12336. this._errors = xml.errors;
  12337. visitAll(this, xml.rootNodes, null);
  12338. return {
  12339. msgIdToHtml: this._msgIdToHtml,
  12340. errors: this._errors,
  12341. locale: this._locale,
  12342. };
  12343. };
  12344. /**
  12345. * @param {?} element
  12346. * @param {?} context
  12347. * @return {?}
  12348. */
  12349. Xliff2Parser.prototype.visitElement = /**
  12350. * @param {?} element
  12351. * @param {?} context
  12352. * @return {?}
  12353. */
  12354. function (element, context) {
  12355. switch (element.name) {
  12356. case _UNIT_TAG$1:
  12357. this._unitMlString = null;
  12358. var /** @type {?} */ idAttr = element.attrs.find(function (attr) { return attr.name === 'id'; });
  12359. if (!idAttr) {
  12360. this._addError(element, "<" + _UNIT_TAG$1 + "> misses the \"id\" attribute");
  12361. }
  12362. else {
  12363. var /** @type {?} */ id = idAttr.value;
  12364. if (this._msgIdToHtml.hasOwnProperty(id)) {
  12365. this._addError(element, "Duplicated translations for msg " + id);
  12366. }
  12367. else {
  12368. visitAll(this, element.children, null);
  12369. if (typeof this._unitMlString === 'string') {
  12370. this._msgIdToHtml[id] = this._unitMlString;
  12371. }
  12372. else {
  12373. this._addError(element, "Message " + id + " misses a translation");
  12374. }
  12375. }
  12376. }
  12377. break;
  12378. case _SOURCE_TAG$1:
  12379. // ignore source message
  12380. break;
  12381. case _TARGET_TAG$1:
  12382. var /** @type {?} */ innerTextStart = /** @type {?} */ ((element.startSourceSpan)).end.offset;
  12383. var /** @type {?} */ innerTextEnd = /** @type {?} */ ((element.endSourceSpan)).start.offset;
  12384. var /** @type {?} */ content = /** @type {?} */ ((element.startSourceSpan)).start.file.content;
  12385. var /** @type {?} */ innerText = content.slice(innerTextStart, innerTextEnd);
  12386. this._unitMlString = innerText;
  12387. break;
  12388. case _XLIFF_TAG:
  12389. var /** @type {?} */ localeAttr = element.attrs.find(function (attr) { return attr.name === 'trgLang'; });
  12390. if (localeAttr) {
  12391. this._locale = localeAttr.value;
  12392. }
  12393. var /** @type {?} */ versionAttr = element.attrs.find(function (attr) { return attr.name === 'version'; });
  12394. if (versionAttr) {
  12395. var /** @type {?} */ version = versionAttr.value;
  12396. if (version !== '2.0') {
  12397. this._addError(element, "The XLIFF file version " + version + " is not compatible with XLIFF 2.0 serializer");
  12398. }
  12399. else {
  12400. visitAll(this, element.children, null);
  12401. }
  12402. }
  12403. break;
  12404. default:
  12405. visitAll(this, element.children, null);
  12406. }
  12407. };
  12408. /**
  12409. * @param {?} attribute
  12410. * @param {?} context
  12411. * @return {?}
  12412. */
  12413. Xliff2Parser.prototype.visitAttribute = /**
  12414. * @param {?} attribute
  12415. * @param {?} context
  12416. * @return {?}
  12417. */
  12418. function (attribute, context) { };
  12419. /**
  12420. * @param {?} text
  12421. * @param {?} context
  12422. * @return {?}
  12423. */
  12424. Xliff2Parser.prototype.visitText = /**
  12425. * @param {?} text
  12426. * @param {?} context
  12427. * @return {?}
  12428. */
  12429. function (text, context) { };
  12430. /**
  12431. * @param {?} comment
  12432. * @param {?} context
  12433. * @return {?}
  12434. */
  12435. Xliff2Parser.prototype.visitComment = /**
  12436. * @param {?} comment
  12437. * @param {?} context
  12438. * @return {?}
  12439. */
  12440. function (comment, context) { };
  12441. /**
  12442. * @param {?} expansion
  12443. * @param {?} context
  12444. * @return {?}
  12445. */
  12446. Xliff2Parser.prototype.visitExpansion = /**
  12447. * @param {?} expansion
  12448. * @param {?} context
  12449. * @return {?}
  12450. */
  12451. function (expansion, context) { };
  12452. /**
  12453. * @param {?} expansionCase
  12454. * @param {?} context
  12455. * @return {?}
  12456. */
  12457. Xliff2Parser.prototype.visitExpansionCase = /**
  12458. * @param {?} expansionCase
  12459. * @param {?} context
  12460. * @return {?}
  12461. */
  12462. function (expansionCase, context) { };
  12463. /**
  12464. * @param {?} node
  12465. * @param {?} message
  12466. * @return {?}
  12467. */
  12468. Xliff2Parser.prototype._addError = /**
  12469. * @param {?} node
  12470. * @param {?} message
  12471. * @return {?}
  12472. */
  12473. function (node, message) {
  12474. this._errors.push(new I18nError(node.sourceSpan, message));
  12475. };
  12476. return Xliff2Parser;
  12477. }());
  12478. var XmlToI18n$1 = /** @class */ (function () {
  12479. function XmlToI18n() {
  12480. }
  12481. /**
  12482. * @param {?} message
  12483. * @param {?} url
  12484. * @return {?}
  12485. */
  12486. XmlToI18n.prototype.convert = /**
  12487. * @param {?} message
  12488. * @param {?} url
  12489. * @return {?}
  12490. */
  12491. function (message, url) {
  12492. var /** @type {?} */ xmlIcu = new XmlParser().parse(message, url, true);
  12493. this._errors = xmlIcu.errors;
  12494. var /** @type {?} */ i18nNodes = this._errors.length > 0 || xmlIcu.rootNodes.length == 0 ?
  12495. [] : [].concat.apply([], visitAll(this, xmlIcu.rootNodes));
  12496. return {
  12497. i18nNodes: i18nNodes,
  12498. errors: this._errors,
  12499. };
  12500. };
  12501. /**
  12502. * @param {?} text
  12503. * @param {?} context
  12504. * @return {?}
  12505. */
  12506. XmlToI18n.prototype.visitText = /**
  12507. * @param {?} text
  12508. * @param {?} context
  12509. * @return {?}
  12510. */
  12511. function (text, context) { return new Text$1(text.value, text.sourceSpan); };
  12512. /**
  12513. * @param {?} el
  12514. * @param {?} context
  12515. * @return {?}
  12516. */
  12517. XmlToI18n.prototype.visitElement = /**
  12518. * @param {?} el
  12519. * @param {?} context
  12520. * @return {?}
  12521. */
  12522. function (el, context) {
  12523. var _this = this;
  12524. switch (el.name) {
  12525. case _PLACEHOLDER_TAG$1:
  12526. var /** @type {?} */ nameAttr = el.attrs.find(function (attr) { return attr.name === 'equiv'; });
  12527. if (nameAttr) {
  12528. return [new Placeholder('', nameAttr.value, el.sourceSpan)];
  12529. }
  12530. this._addError(el, "<" + _PLACEHOLDER_TAG$1 + "> misses the \"equiv\" attribute");
  12531. break;
  12532. case _PLACEHOLDER_SPANNING_TAG:
  12533. var /** @type {?} */ startAttr = el.attrs.find(function (attr) { return attr.name === 'equivStart'; });
  12534. var /** @type {?} */ endAttr = el.attrs.find(function (attr) { return attr.name === 'equivEnd'; });
  12535. if (!startAttr) {
  12536. this._addError(el, "<" + _PLACEHOLDER_TAG$1 + "> misses the \"equivStart\" attribute");
  12537. }
  12538. else if (!endAttr) {
  12539. this._addError(el, "<" + _PLACEHOLDER_TAG$1 + "> misses the \"equivEnd\" attribute");
  12540. }
  12541. else {
  12542. var /** @type {?} */ startId = startAttr.value;
  12543. var /** @type {?} */ endId = endAttr.value;
  12544. var /** @type {?} */ nodes = [];
  12545. 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)]));
  12546. }
  12547. break;
  12548. case _MARKER_TAG$1:
  12549. return [].concat.apply([], visitAll(this, el.children));
  12550. default:
  12551. this._addError(el, "Unexpected tag");
  12552. }
  12553. return null;
  12554. };
  12555. /**
  12556. * @param {?} icu
  12557. * @param {?} context
  12558. * @return {?}
  12559. */
  12560. XmlToI18n.prototype.visitExpansion = /**
  12561. * @param {?} icu
  12562. * @param {?} context
  12563. * @return {?}
  12564. */
  12565. function (icu, context) {
  12566. var /** @type {?} */ caseMap = {};
  12567. visitAll(this, icu.cases).forEach(function (c) {
  12568. caseMap[c.value] = new Container(c.nodes, icu.sourceSpan);
  12569. });
  12570. return new Icu(icu.switchValue, icu.type, caseMap, icu.sourceSpan);
  12571. };
  12572. /**
  12573. * @param {?} icuCase
  12574. * @param {?} context
  12575. * @return {?}
  12576. */
  12577. XmlToI18n.prototype.visitExpansionCase = /**
  12578. * @param {?} icuCase
  12579. * @param {?} context
  12580. * @return {?}
  12581. */
  12582. function (icuCase, context) {
  12583. return {
  12584. value: icuCase.value,
  12585. nodes: [].concat.apply([], visitAll(this, icuCase.expression)),
  12586. };
  12587. };
  12588. /**
  12589. * @param {?} comment
  12590. * @param {?} context
  12591. * @return {?}
  12592. */
  12593. XmlToI18n.prototype.visitComment = /**
  12594. * @param {?} comment
  12595. * @param {?} context
  12596. * @return {?}
  12597. */
  12598. function (comment, context) { };
  12599. /**
  12600. * @param {?} attribute
  12601. * @param {?} context
  12602. * @return {?}
  12603. */
  12604. XmlToI18n.prototype.visitAttribute = /**
  12605. * @param {?} attribute
  12606. * @param {?} context
  12607. * @return {?}
  12608. */
  12609. function (attribute, context) { };
  12610. /**
  12611. * @param {?} node
  12612. * @param {?} message
  12613. * @return {?}
  12614. */
  12615. XmlToI18n.prototype._addError = /**
  12616. * @param {?} node
  12617. * @param {?} message
  12618. * @return {?}
  12619. */
  12620. function (node, message) {
  12621. this._errors.push(new I18nError(node.sourceSpan, message));
  12622. };
  12623. return XmlToI18n;
  12624. }());
  12625. /**
  12626. * @param {?} tag
  12627. * @return {?}
  12628. */
  12629. function getTypeForTag(tag) {
  12630. switch (tag.toLowerCase()) {
  12631. case 'br':
  12632. case 'b':
  12633. case 'i':
  12634. case 'u':
  12635. return 'fmt';
  12636. case 'img':
  12637. return 'image';
  12638. case 'a':
  12639. return 'link';
  12640. default:
  12641. return 'other';
  12642. }
  12643. }
  12644. /**
  12645. * @fileoverview added by tsickle
  12646. * @suppress {checkTypes} checked by tsc
  12647. */
  12648. /**
  12649. * @license
  12650. * Copyright Google Inc. All Rights Reserved.
  12651. *
  12652. * Use of this source code is governed by an MIT-style license that can be
  12653. * found in the LICENSE file at https://angular.io/license
  12654. */
  12655. var _MESSAGES_TAG = 'messagebundle';
  12656. var _MESSAGE_TAG = 'msg';
  12657. var _PLACEHOLDER_TAG$2 = 'ph';
  12658. var _EXEMPLE_TAG = 'ex';
  12659. var _SOURCE_TAG$2 = 'source';
  12660. 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)>";
  12661. var Xmb = /** @class */ (function (_super) {
  12662. __extends(Xmb, _super);
  12663. function Xmb() {
  12664. return _super !== null && _super.apply(this, arguments) || this;
  12665. }
  12666. /**
  12667. * @param {?} messages
  12668. * @param {?} locale
  12669. * @return {?}
  12670. */
  12671. Xmb.prototype.write = /**
  12672. * @param {?} messages
  12673. * @param {?} locale
  12674. * @return {?}
  12675. */
  12676. function (messages, locale) {
  12677. var /** @type {?} */ exampleVisitor = new ExampleVisitor();
  12678. var /** @type {?} */ visitor = new _Visitor$2();
  12679. var /** @type {?} */ rootNode = new Tag(_MESSAGES_TAG);
  12680. messages.forEach(function (message) {
  12681. var /** @type {?} */ attrs = { id: message.id };
  12682. if (message.description) {
  12683. attrs['desc'] = message.description;
  12684. }
  12685. if (message.meaning) {
  12686. attrs['meaning'] = message.meaning;
  12687. }
  12688. var /** @type {?} */ sourceTags = [];
  12689. message.sources.forEach(function (source) {
  12690. sourceTags.push(new Tag(_SOURCE_TAG$2, {}, [
  12691. new Text$2(source.filePath + ":" + source.startLine + (source.endLine !== source.startLine ? ',' + source.endLine : ''))
  12692. ]));
  12693. });
  12694. rootNode.children.push(new CR(2), new Tag(_MESSAGE_TAG, attrs, sourceTags.concat(visitor.serialize(message.nodes))));
  12695. });
  12696. rootNode.children.push(new CR());
  12697. return serialize([
  12698. new Declaration({ version: '1.0', encoding: 'UTF-8' }),
  12699. new CR(),
  12700. new Doctype(_MESSAGES_TAG, _DOCTYPE),
  12701. new CR(),
  12702. exampleVisitor.addDefaultExamples(rootNode),
  12703. new CR(),
  12704. ]);
  12705. };
  12706. /**
  12707. * @param {?} content
  12708. * @param {?} url
  12709. * @return {?}
  12710. */
  12711. Xmb.prototype.load = /**
  12712. * @param {?} content
  12713. * @param {?} url
  12714. * @return {?}
  12715. */
  12716. function (content, url) {
  12717. throw new Error('Unsupported');
  12718. };
  12719. /**
  12720. * @param {?} message
  12721. * @return {?}
  12722. */
  12723. Xmb.prototype.digest = /**
  12724. * @param {?} message
  12725. * @return {?}
  12726. */
  12727. function (message) { return digest$1(message); };
  12728. /**
  12729. * @param {?} message
  12730. * @return {?}
  12731. */
  12732. Xmb.prototype.createNameMapper = /**
  12733. * @param {?} message
  12734. * @return {?}
  12735. */
  12736. function (message) {
  12737. return new SimplePlaceholderMapper(message, toPublicName);
  12738. };
  12739. return Xmb;
  12740. }(Serializer));
  12741. var _Visitor$2 = /** @class */ (function () {
  12742. function _Visitor() {
  12743. }
  12744. /**
  12745. * @param {?} text
  12746. * @param {?=} context
  12747. * @return {?}
  12748. */
  12749. _Visitor.prototype.visitText = /**
  12750. * @param {?} text
  12751. * @param {?=} context
  12752. * @return {?}
  12753. */
  12754. function (text, context) { return [new Text$2(text.value)]; };
  12755. /**
  12756. * @param {?} container
  12757. * @param {?} context
  12758. * @return {?}
  12759. */
  12760. _Visitor.prototype.visitContainer = /**
  12761. * @param {?} container
  12762. * @param {?} context
  12763. * @return {?}
  12764. */
  12765. function (container, context) {
  12766. var _this = this;
  12767. var /** @type {?} */ nodes = [];
  12768. container.children.forEach(function (node) { return nodes.push.apply(nodes, node.visit(_this)); });
  12769. return nodes;
  12770. };
  12771. /**
  12772. * @param {?} icu
  12773. * @param {?=} context
  12774. * @return {?}
  12775. */
  12776. _Visitor.prototype.visitIcu = /**
  12777. * @param {?} icu
  12778. * @param {?=} context
  12779. * @return {?}
  12780. */
  12781. function (icu, context) {
  12782. var _this = this;
  12783. var /** @type {?} */ nodes = [new Text$2("{" + icu.expressionPlaceholder + ", " + icu.type + ", ")];
  12784. Object.keys(icu.cases).forEach(function (c) {
  12785. nodes.push.apply(nodes, [new Text$2(c + " {")].concat(icu.cases[c].visit(_this), [new Text$2("} ")]));
  12786. });
  12787. nodes.push(new Text$2("}"));
  12788. return nodes;
  12789. };
  12790. /**
  12791. * @param {?} ph
  12792. * @param {?=} context
  12793. * @return {?}
  12794. */
  12795. _Visitor.prototype.visitTagPlaceholder = /**
  12796. * @param {?} ph
  12797. * @param {?=} context
  12798. * @return {?}
  12799. */
  12800. function (ph, context) {
  12801. var /** @type {?} */ startEx = new Tag(_EXEMPLE_TAG, {}, [new Text$2("<" + ph.tag + ">")]);
  12802. var /** @type {?} */ startTagPh = new Tag(_PLACEHOLDER_TAG$2, { name: ph.startName }, [startEx]);
  12803. if (ph.isVoid) {
  12804. // void tags have no children nor closing tags
  12805. return [startTagPh];
  12806. }
  12807. var /** @type {?} */ closeEx = new Tag(_EXEMPLE_TAG, {}, [new Text$2("</" + ph.tag + ">")]);
  12808. var /** @type {?} */ closeTagPh = new Tag(_PLACEHOLDER_TAG$2, { name: ph.closeName }, [closeEx]);
  12809. return [startTagPh].concat(this.serialize(ph.children), [closeTagPh]);
  12810. };
  12811. /**
  12812. * @param {?} ph
  12813. * @param {?=} context
  12814. * @return {?}
  12815. */
  12816. _Visitor.prototype.visitPlaceholder = /**
  12817. * @param {?} ph
  12818. * @param {?=} context
  12819. * @return {?}
  12820. */
  12821. function (ph, context) {
  12822. var /** @type {?} */ exTag = new Tag(_EXEMPLE_TAG, {}, [new Text$2("{{" + ph.value + "}}")]);
  12823. return [new Tag(_PLACEHOLDER_TAG$2, { name: ph.name }, [exTag])];
  12824. };
  12825. /**
  12826. * @param {?} ph
  12827. * @param {?=} context
  12828. * @return {?}
  12829. */
  12830. _Visitor.prototype.visitIcuPlaceholder = /**
  12831. * @param {?} ph
  12832. * @param {?=} context
  12833. * @return {?}
  12834. */
  12835. function (ph, context) {
  12836. var /** @type {?} */ exTag = new Tag(_EXEMPLE_TAG, {}, [
  12837. new Text$2("{" + ph.value.expression + ", " + ph.value.type + ", " + Object.keys(ph.value.cases).map(function (value) { return value + ' {...}'; }).join(' ') + "}")
  12838. ]);
  12839. return [new Tag(_PLACEHOLDER_TAG$2, { name: ph.name }, [exTag])];
  12840. };
  12841. /**
  12842. * @param {?} nodes
  12843. * @return {?}
  12844. */
  12845. _Visitor.prototype.serialize = /**
  12846. * @param {?} nodes
  12847. * @return {?}
  12848. */
  12849. function (nodes) {
  12850. var _this = this;
  12851. return [].concat.apply([], nodes.map(function (node) { return node.visit(_this); }));
  12852. };
  12853. return _Visitor;
  12854. }());
  12855. /**
  12856. * @param {?} message
  12857. * @return {?}
  12858. */
  12859. function digest$1(message) {
  12860. return decimalDigest(message);
  12861. }
  12862. var ExampleVisitor = /** @class */ (function () {
  12863. function ExampleVisitor() {
  12864. }
  12865. /**
  12866. * @param {?} node
  12867. * @return {?}
  12868. */
  12869. ExampleVisitor.prototype.addDefaultExamples = /**
  12870. * @param {?} node
  12871. * @return {?}
  12872. */
  12873. function (node) {
  12874. node.visit(this);
  12875. return node;
  12876. };
  12877. /**
  12878. * @param {?} tag
  12879. * @return {?}
  12880. */
  12881. ExampleVisitor.prototype.visitTag = /**
  12882. * @param {?} tag
  12883. * @return {?}
  12884. */
  12885. function (tag) {
  12886. var _this = this;
  12887. if (tag.name === _PLACEHOLDER_TAG$2) {
  12888. if (!tag.children || tag.children.length == 0) {
  12889. var /** @type {?} */ exText = new Text$2(tag.attrs['name'] || '...');
  12890. tag.children = [new Tag(_EXEMPLE_TAG, {}, [exText])];
  12891. }
  12892. }
  12893. else if (tag.children) {
  12894. tag.children.forEach(function (node) { return node.visit(_this); });
  12895. }
  12896. };
  12897. /**
  12898. * @param {?} text
  12899. * @return {?}
  12900. */
  12901. ExampleVisitor.prototype.visitText = /**
  12902. * @param {?} text
  12903. * @return {?}
  12904. */
  12905. function (text) { };
  12906. /**
  12907. * @param {?} decl
  12908. * @return {?}
  12909. */
  12910. ExampleVisitor.prototype.visitDeclaration = /**
  12911. * @param {?} decl
  12912. * @return {?}
  12913. */
  12914. function (decl) { };
  12915. /**
  12916. * @param {?} doctype
  12917. * @return {?}
  12918. */
  12919. ExampleVisitor.prototype.visitDoctype = /**
  12920. * @param {?} doctype
  12921. * @return {?}
  12922. */
  12923. function (doctype) { };
  12924. return ExampleVisitor;
  12925. }());
  12926. /**
  12927. * @param {?} internalName
  12928. * @return {?}
  12929. */
  12930. function toPublicName(internalName) {
  12931. return internalName.toUpperCase().replace(/[^A-Z0-9_]/g, '_');
  12932. }
  12933. /**
  12934. * @fileoverview added by tsickle
  12935. * @suppress {checkTypes} checked by tsc
  12936. */
  12937. /**
  12938. * @license
  12939. * Copyright Google Inc. All Rights Reserved.
  12940. *
  12941. * Use of this source code is governed by an MIT-style license that can be
  12942. * found in the LICENSE file at https://angular.io/license
  12943. */
  12944. var _TRANSLATIONS_TAG = 'translationbundle';
  12945. var _TRANSLATION_TAG = 'translation';
  12946. var _PLACEHOLDER_TAG$3 = 'ph';
  12947. var Xtb = /** @class */ (function (_super) {
  12948. __extends(Xtb, _super);
  12949. function Xtb() {
  12950. return _super !== null && _super.apply(this, arguments) || this;
  12951. }
  12952. /**
  12953. * @param {?} messages
  12954. * @param {?} locale
  12955. * @return {?}
  12956. */
  12957. Xtb.prototype.write = /**
  12958. * @param {?} messages
  12959. * @param {?} locale
  12960. * @return {?}
  12961. */
  12962. function (messages, locale) { throw new Error('Unsupported'); };
  12963. /**
  12964. * @param {?} content
  12965. * @param {?} url
  12966. * @return {?}
  12967. */
  12968. Xtb.prototype.load = /**
  12969. * @param {?} content
  12970. * @param {?} url
  12971. * @return {?}
  12972. */
  12973. function (content, url) {
  12974. // xtb to xml nodes
  12975. var /** @type {?} */ xtbParser = new XtbParser();
  12976. var _a = xtbParser.parse(content, url), locale = _a.locale, msgIdToHtml = _a.msgIdToHtml, errors = _a.errors;
  12977. // xml nodes to i18n nodes
  12978. var /** @type {?} */ i18nNodesByMsgId = {};
  12979. var /** @type {?} */ converter = new XmlToI18n$2();
  12980. // Because we should be able to load xtb files that rely on features not supported by angular,
  12981. // we need to delay the conversion of html to i18n nodes so that non angular messages are not
  12982. // converted
  12983. Object.keys(msgIdToHtml).forEach(function (msgId) {
  12984. var /** @type {?} */ valueFn = function () {
  12985. var _a = converter.convert(msgIdToHtml[msgId], url), i18nNodes = _a.i18nNodes, errors = _a.errors;
  12986. if (errors.length) {
  12987. throw new Error("xtb parse errors:\n" + errors.join('\n'));
  12988. }
  12989. return i18nNodes;
  12990. };
  12991. createLazyProperty(i18nNodesByMsgId, msgId, valueFn);
  12992. });
  12993. if (errors.length) {
  12994. throw new Error("xtb parse errors:\n" + errors.join('\n'));
  12995. }
  12996. return { locale: /** @type {?} */ ((locale)), i18nNodesByMsgId: i18nNodesByMsgId };
  12997. };
  12998. /**
  12999. * @param {?} message
  13000. * @return {?}
  13001. */
  13002. Xtb.prototype.digest = /**
  13003. * @param {?} message
  13004. * @return {?}
  13005. */
  13006. function (message) { return digest$1(message); };
  13007. /**
  13008. * @param {?} message
  13009. * @return {?}
  13010. */
  13011. Xtb.prototype.createNameMapper = /**
  13012. * @param {?} message
  13013. * @return {?}
  13014. */
  13015. function (message) {
  13016. return new SimplePlaceholderMapper(message, toPublicName);
  13017. };
  13018. return Xtb;
  13019. }(Serializer));
  13020. /**
  13021. * @param {?} messages
  13022. * @param {?} id
  13023. * @param {?} valueFn
  13024. * @return {?}
  13025. */
  13026. function createLazyProperty(messages, id, valueFn) {
  13027. Object.defineProperty(messages, id, {
  13028. configurable: true,
  13029. enumerable: true,
  13030. get: function () {
  13031. var /** @type {?} */ value = valueFn();
  13032. Object.defineProperty(messages, id, { enumerable: true, value: value });
  13033. return value;
  13034. },
  13035. set: function (_) { throw new Error('Could not overwrite an XTB translation'); },
  13036. });
  13037. }
  13038. var XtbParser = /** @class */ (function () {
  13039. function XtbParser() {
  13040. this._locale = null;
  13041. }
  13042. /**
  13043. * @param {?} xtb
  13044. * @param {?} url
  13045. * @return {?}
  13046. */
  13047. XtbParser.prototype.parse = /**
  13048. * @param {?} xtb
  13049. * @param {?} url
  13050. * @return {?}
  13051. */
  13052. function (xtb, url) {
  13053. this._bundleDepth = 0;
  13054. this._msgIdToHtml = {};
  13055. // We can not parse the ICU messages at this point as some messages might not originate
  13056. // from Angular that could not be lex'd.
  13057. var /** @type {?} */ xml = new XmlParser().parse(xtb, url, false);
  13058. this._errors = xml.errors;
  13059. visitAll(this, xml.rootNodes);
  13060. return {
  13061. msgIdToHtml: this._msgIdToHtml,
  13062. errors: this._errors,
  13063. locale: this._locale,
  13064. };
  13065. };
  13066. /**
  13067. * @param {?} element
  13068. * @param {?} context
  13069. * @return {?}
  13070. */
  13071. XtbParser.prototype.visitElement = /**
  13072. * @param {?} element
  13073. * @param {?} context
  13074. * @return {?}
  13075. */
  13076. function (element, context) {
  13077. switch (element.name) {
  13078. case _TRANSLATIONS_TAG:
  13079. this._bundleDepth++;
  13080. if (this._bundleDepth > 1) {
  13081. this._addError(element, "<" + _TRANSLATIONS_TAG + "> elements can not be nested");
  13082. }
  13083. var /** @type {?} */ langAttr = element.attrs.find(function (attr) { return attr.name === 'lang'; });
  13084. if (langAttr) {
  13085. this._locale = langAttr.value;
  13086. }
  13087. visitAll(this, element.children, null);
  13088. this._bundleDepth--;
  13089. break;
  13090. case _TRANSLATION_TAG:
  13091. var /** @type {?} */ idAttr = element.attrs.find(function (attr) { return attr.name === 'id'; });
  13092. if (!idAttr) {
  13093. this._addError(element, "<" + _TRANSLATION_TAG + "> misses the \"id\" attribute");
  13094. }
  13095. else {
  13096. var /** @type {?} */ id = idAttr.value;
  13097. if (this._msgIdToHtml.hasOwnProperty(id)) {
  13098. this._addError(element, "Duplicated translations for msg " + id);
  13099. }
  13100. else {
  13101. var /** @type {?} */ innerTextStart = /** @type {?} */ ((element.startSourceSpan)).end.offset;
  13102. var /** @type {?} */ innerTextEnd = /** @type {?} */ ((element.endSourceSpan)).start.offset;
  13103. var /** @type {?} */ content = /** @type {?} */ ((element.startSourceSpan)).start.file.content;
  13104. var /** @type {?} */ innerText = content.slice(/** @type {?} */ ((innerTextStart)), /** @type {?} */ ((innerTextEnd)));
  13105. this._msgIdToHtml[id] = innerText;
  13106. }
  13107. }
  13108. break;
  13109. default:
  13110. this._addError(element, 'Unexpected tag');
  13111. }
  13112. };
  13113. /**
  13114. * @param {?} attribute
  13115. * @param {?} context
  13116. * @return {?}
  13117. */
  13118. XtbParser.prototype.visitAttribute = /**
  13119. * @param {?} attribute
  13120. * @param {?} context
  13121. * @return {?}
  13122. */
  13123. function (attribute, context) { };
  13124. /**
  13125. * @param {?} text
  13126. * @param {?} context
  13127. * @return {?}
  13128. */
  13129. XtbParser.prototype.visitText = /**
  13130. * @param {?} text
  13131. * @param {?} context
  13132. * @return {?}
  13133. */
  13134. function (text, context) { };
  13135. /**
  13136. * @param {?} comment
  13137. * @param {?} context
  13138. * @return {?}
  13139. */
  13140. XtbParser.prototype.visitComment = /**
  13141. * @param {?} comment
  13142. * @param {?} context
  13143. * @return {?}
  13144. */
  13145. function (comment, context) { };
  13146. /**
  13147. * @param {?} expansion
  13148. * @param {?} context
  13149. * @return {?}
  13150. */
  13151. XtbParser.prototype.visitExpansion = /**
  13152. * @param {?} expansion
  13153. * @param {?} context
  13154. * @return {?}
  13155. */
  13156. function (expansion, context) { };
  13157. /**
  13158. * @param {?} expansionCase
  13159. * @param {?} context
  13160. * @return {?}
  13161. */
  13162. XtbParser.prototype.visitExpansionCase = /**
  13163. * @param {?} expansionCase
  13164. * @param {?} context
  13165. * @return {?}
  13166. */
  13167. function (expansionCase, context) { };
  13168. /**
  13169. * @param {?} node
  13170. * @param {?} message
  13171. * @return {?}
  13172. */
  13173. XtbParser.prototype._addError = /**
  13174. * @param {?} node
  13175. * @param {?} message
  13176. * @return {?}
  13177. */
  13178. function (node, message) {
  13179. this._errors.push(new I18nError(/** @type {?} */ ((node.sourceSpan)), message));
  13180. };
  13181. return XtbParser;
  13182. }());
  13183. var XmlToI18n$2 = /** @class */ (function () {
  13184. function XmlToI18n() {
  13185. }
  13186. /**
  13187. * @param {?} message
  13188. * @param {?} url
  13189. * @return {?}
  13190. */
  13191. XmlToI18n.prototype.convert = /**
  13192. * @param {?} message
  13193. * @param {?} url
  13194. * @return {?}
  13195. */
  13196. function (message, url) {
  13197. var /** @type {?} */ xmlIcu = new XmlParser().parse(message, url, true);
  13198. this._errors = xmlIcu.errors;
  13199. var /** @type {?} */ i18nNodes = this._errors.length > 0 || xmlIcu.rootNodes.length == 0 ?
  13200. [] :
  13201. visitAll(this, xmlIcu.rootNodes);
  13202. return {
  13203. i18nNodes: i18nNodes,
  13204. errors: this._errors,
  13205. };
  13206. };
  13207. /**
  13208. * @param {?} text
  13209. * @param {?} context
  13210. * @return {?}
  13211. */
  13212. XmlToI18n.prototype.visitText = /**
  13213. * @param {?} text
  13214. * @param {?} context
  13215. * @return {?}
  13216. */
  13217. function (text, context) { return new Text$1(text.value, /** @type {?} */ ((text.sourceSpan))); };
  13218. /**
  13219. * @param {?} icu
  13220. * @param {?} context
  13221. * @return {?}
  13222. */
  13223. XmlToI18n.prototype.visitExpansion = /**
  13224. * @param {?} icu
  13225. * @param {?} context
  13226. * @return {?}
  13227. */
  13228. function (icu, context) {
  13229. var /** @type {?} */ caseMap = {};
  13230. visitAll(this, icu.cases).forEach(function (c) {
  13231. caseMap[c.value] = new Container(c.nodes, icu.sourceSpan);
  13232. });
  13233. return new Icu(icu.switchValue, icu.type, caseMap, icu.sourceSpan);
  13234. };
  13235. /**
  13236. * @param {?} icuCase
  13237. * @param {?} context
  13238. * @return {?}
  13239. */
  13240. XmlToI18n.prototype.visitExpansionCase = /**
  13241. * @param {?} icuCase
  13242. * @param {?} context
  13243. * @return {?}
  13244. */
  13245. function (icuCase, context) {
  13246. return {
  13247. value: icuCase.value,
  13248. nodes: visitAll(this, icuCase.expression),
  13249. };
  13250. };
  13251. /**
  13252. * @param {?} el
  13253. * @param {?} context
  13254. * @return {?}
  13255. */
  13256. XmlToI18n.prototype.visitElement = /**
  13257. * @param {?} el
  13258. * @param {?} context
  13259. * @return {?}
  13260. */
  13261. function (el, context) {
  13262. if (el.name === _PLACEHOLDER_TAG$3) {
  13263. var /** @type {?} */ nameAttr = el.attrs.find(function (attr) { return attr.name === 'name'; });
  13264. if (nameAttr) {
  13265. return new Placeholder('', nameAttr.value, /** @type {?} */ ((el.sourceSpan)));
  13266. }
  13267. this._addError(el, "<" + _PLACEHOLDER_TAG$3 + "> misses the \"name\" attribute");
  13268. }
  13269. else {
  13270. this._addError(el, "Unexpected tag");
  13271. }
  13272. return null;
  13273. };
  13274. /**
  13275. * @param {?} comment
  13276. * @param {?} context
  13277. * @return {?}
  13278. */
  13279. XmlToI18n.prototype.visitComment = /**
  13280. * @param {?} comment
  13281. * @param {?} context
  13282. * @return {?}
  13283. */
  13284. function (comment, context) { };
  13285. /**
  13286. * @param {?} attribute
  13287. * @param {?} context
  13288. * @return {?}
  13289. */
  13290. XmlToI18n.prototype.visitAttribute = /**
  13291. * @param {?} attribute
  13292. * @param {?} context
  13293. * @return {?}
  13294. */
  13295. function (attribute, context) { };
  13296. /**
  13297. * @param {?} node
  13298. * @param {?} message
  13299. * @return {?}
  13300. */
  13301. XmlToI18n.prototype._addError = /**
  13302. * @param {?} node
  13303. * @param {?} message
  13304. * @return {?}
  13305. */
  13306. function (node, message) {
  13307. this._errors.push(new I18nError(/** @type {?} */ ((node.sourceSpan)), message));
  13308. };
  13309. return XmlToI18n;
  13310. }());
  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. var HtmlParser = /** @class */ (function (_super) {
  13323. __extends(HtmlParser, _super);
  13324. function HtmlParser() {
  13325. return _super.call(this, getHtmlTagDefinition) || this;
  13326. }
  13327. /**
  13328. * @param {?} source
  13329. * @param {?} url
  13330. * @param {?=} parseExpansionForms
  13331. * @param {?=} interpolationConfig
  13332. * @return {?}
  13333. */
  13334. HtmlParser.prototype.parse = /**
  13335. * @param {?} source
  13336. * @param {?} url
  13337. * @param {?=} parseExpansionForms
  13338. * @param {?=} interpolationConfig
  13339. * @return {?}
  13340. */
  13341. function (source, url, parseExpansionForms, interpolationConfig) {
  13342. if (parseExpansionForms === void 0) { parseExpansionForms = false; }
  13343. if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
  13344. return _super.prototype.parse.call(this, source, url, parseExpansionForms, interpolationConfig);
  13345. };
  13346. return HtmlParser;
  13347. }(Parser$1));
  13348. /**
  13349. * @fileoverview added by tsickle
  13350. * @suppress {checkTypes} checked by tsc
  13351. */
  13352. /**
  13353. * @license
  13354. * Copyright Google Inc. All Rights Reserved.
  13355. *
  13356. * Use of this source code is governed by an MIT-style license that can be
  13357. * found in the LICENSE file at https://angular.io/license
  13358. */
  13359. /**
  13360. * A container for translated messages
  13361. */
  13362. var TranslationBundle = /** @class */ (function () {
  13363. function TranslationBundle(_i18nNodesByMsgId, locale, digest, mapperFactory, missingTranslationStrategy, console) {
  13364. if (_i18nNodesByMsgId === void 0) { _i18nNodesByMsgId = {}; }
  13365. if (missingTranslationStrategy === void 0) { missingTranslationStrategy = MissingTranslationStrategy.Warning; }
  13366. this._i18nNodesByMsgId = _i18nNodesByMsgId;
  13367. this.digest = digest;
  13368. this.mapperFactory = mapperFactory;
  13369. this._i18nToHtml = new I18nToHtmlVisitor(_i18nNodesByMsgId, locale, digest, /** @type {?} */ ((mapperFactory)), missingTranslationStrategy, console);
  13370. }
  13371. // Creates a `TranslationBundle` by parsing the given `content` with the `serializer`.
  13372. /**
  13373. * @param {?} content
  13374. * @param {?} url
  13375. * @param {?} serializer
  13376. * @param {?} missingTranslationStrategy
  13377. * @param {?=} console
  13378. * @return {?}
  13379. */
  13380. TranslationBundle.load = /**
  13381. * @param {?} content
  13382. * @param {?} url
  13383. * @param {?} serializer
  13384. * @param {?} missingTranslationStrategy
  13385. * @param {?=} console
  13386. * @return {?}
  13387. */
  13388. function (content, url, serializer, missingTranslationStrategy, console) {
  13389. var _a = serializer.load(content, url), locale = _a.locale, i18nNodesByMsgId = _a.i18nNodesByMsgId;
  13390. var /** @type {?} */ digestFn = function (m) { return serializer.digest(m); };
  13391. var /** @type {?} */ mapperFactory = function (m) { return ((serializer.createNameMapper(m))); };
  13392. return new TranslationBundle(i18nNodesByMsgId, locale, digestFn, mapperFactory, missingTranslationStrategy, console);
  13393. };
  13394. // Returns the translation as HTML nodes from the given source message.
  13395. /**
  13396. * @param {?} srcMsg
  13397. * @return {?}
  13398. */
  13399. TranslationBundle.prototype.get = /**
  13400. * @param {?} srcMsg
  13401. * @return {?}
  13402. */
  13403. function (srcMsg) {
  13404. var /** @type {?} */ html = this._i18nToHtml.convert(srcMsg);
  13405. if (html.errors.length) {
  13406. throw new Error(html.errors.join('\n'));
  13407. }
  13408. return html.nodes;
  13409. };
  13410. /**
  13411. * @param {?} srcMsg
  13412. * @return {?}
  13413. */
  13414. TranslationBundle.prototype.has = /**
  13415. * @param {?} srcMsg
  13416. * @return {?}
  13417. */
  13418. function (srcMsg) { return this.digest(srcMsg) in this._i18nNodesByMsgId; };
  13419. return TranslationBundle;
  13420. }());
  13421. var I18nToHtmlVisitor = /** @class */ (function () {
  13422. function I18nToHtmlVisitor(_i18nNodesByMsgId, _locale, _digest, _mapperFactory, _missingTranslationStrategy, _console) {
  13423. if (_i18nNodesByMsgId === void 0) { _i18nNodesByMsgId = {}; }
  13424. this._i18nNodesByMsgId = _i18nNodesByMsgId;
  13425. this._locale = _locale;
  13426. this._digest = _digest;
  13427. this._mapperFactory = _mapperFactory;
  13428. this._missingTranslationStrategy = _missingTranslationStrategy;
  13429. this._console = _console;
  13430. this._contextStack = [];
  13431. this._errors = [];
  13432. }
  13433. /**
  13434. * @param {?} srcMsg
  13435. * @return {?}
  13436. */
  13437. I18nToHtmlVisitor.prototype.convert = /**
  13438. * @param {?} srcMsg
  13439. * @return {?}
  13440. */
  13441. function (srcMsg) {
  13442. this._contextStack.length = 0;
  13443. this._errors.length = 0;
  13444. // i18n to text
  13445. var /** @type {?} */ text = this._convertToText(srcMsg);
  13446. // text to html
  13447. var /** @type {?} */ url = srcMsg.nodes[0].sourceSpan.start.file.url;
  13448. var /** @type {?} */ html = new HtmlParser().parse(text, url, true);
  13449. return {
  13450. nodes: html.rootNodes,
  13451. errors: this._errors.concat(html.errors),
  13452. };
  13453. };
  13454. /**
  13455. * @param {?} text
  13456. * @param {?=} context
  13457. * @return {?}
  13458. */
  13459. I18nToHtmlVisitor.prototype.visitText = /**
  13460. * @param {?} text
  13461. * @param {?=} context
  13462. * @return {?}
  13463. */
  13464. function (text, context) {
  13465. // `convert()` uses an `HtmlParser` to return `html.Node`s
  13466. // we should then make sure that any special characters are escaped
  13467. return escapeXml(text.value);
  13468. };
  13469. /**
  13470. * @param {?} container
  13471. * @param {?=} context
  13472. * @return {?}
  13473. */
  13474. I18nToHtmlVisitor.prototype.visitContainer = /**
  13475. * @param {?} container
  13476. * @param {?=} context
  13477. * @return {?}
  13478. */
  13479. function (container, context) {
  13480. var _this = this;
  13481. return container.children.map(function (n) { return n.visit(_this); }).join('');
  13482. };
  13483. /**
  13484. * @param {?} icu
  13485. * @param {?=} context
  13486. * @return {?}
  13487. */
  13488. I18nToHtmlVisitor.prototype.visitIcu = /**
  13489. * @param {?} icu
  13490. * @param {?=} context
  13491. * @return {?}
  13492. */
  13493. function (icu, context) {
  13494. var _this = this;
  13495. var /** @type {?} */ cases = Object.keys(icu.cases).map(function (k) { return k + " {" + icu.cases[k].visit(_this) + "}"; });
  13496. // TODO(vicb): Once all format switch to using expression placeholders
  13497. // we should throw when the placeholder is not in the source message
  13498. var /** @type {?} */ exp = this._srcMsg.placeholders.hasOwnProperty(icu.expression) ?
  13499. this._srcMsg.placeholders[icu.expression] :
  13500. icu.expression;
  13501. return "{" + exp + ", " + icu.type + ", " + cases.join(' ') + "}";
  13502. };
  13503. /**
  13504. * @param {?} ph
  13505. * @param {?=} context
  13506. * @return {?}
  13507. */
  13508. I18nToHtmlVisitor.prototype.visitPlaceholder = /**
  13509. * @param {?} ph
  13510. * @param {?=} context
  13511. * @return {?}
  13512. */
  13513. function (ph, context) {
  13514. var /** @type {?} */ phName = this._mapper(ph.name);
  13515. if (this._srcMsg.placeholders.hasOwnProperty(phName)) {
  13516. return this._srcMsg.placeholders[phName];
  13517. }
  13518. if (this._srcMsg.placeholderToMessage.hasOwnProperty(phName)) {
  13519. return this._convertToText(this._srcMsg.placeholderToMessage[phName]);
  13520. }
  13521. this._addError(ph, "Unknown placeholder \"" + ph.name + "\"");
  13522. return '';
  13523. };
  13524. // Loaded message contains only placeholders (vs tag and icu placeholders).
  13525. // However when a translation can not be found, we need to serialize the source message
  13526. // which can contain tag placeholders
  13527. /**
  13528. * @param {?} ph
  13529. * @param {?=} context
  13530. * @return {?}
  13531. */
  13532. I18nToHtmlVisitor.prototype.visitTagPlaceholder = /**
  13533. * @param {?} ph
  13534. * @param {?=} context
  13535. * @return {?}
  13536. */
  13537. function (ph, context) {
  13538. var _this = this;
  13539. var /** @type {?} */ tag = "" + ph.tag;
  13540. var /** @type {?} */ attrs = Object.keys(ph.attrs).map(function (name) { return name + "=\"" + ph.attrs[name] + "\""; }).join(' ');
  13541. if (ph.isVoid) {
  13542. return "<" + tag + " " + attrs + "/>";
  13543. }
  13544. var /** @type {?} */ children = ph.children.map(function (c) { return c.visit(_this); }).join('');
  13545. return "<" + tag + " " + attrs + ">" + children + "</" + tag + ">";
  13546. };
  13547. // Loaded message contains only placeholders (vs tag and icu placeholders).
  13548. // However when a translation can not be found, we need to serialize the source message
  13549. // which can contain tag placeholders
  13550. /**
  13551. * @param {?} ph
  13552. * @param {?=} context
  13553. * @return {?}
  13554. */
  13555. I18nToHtmlVisitor.prototype.visitIcuPlaceholder = /**
  13556. * @param {?} ph
  13557. * @param {?=} context
  13558. * @return {?}
  13559. */
  13560. function (ph, context) {
  13561. // An ICU placeholder references the source message to be serialized
  13562. return this._convertToText(this._srcMsg.placeholderToMessage[ph.name]);
  13563. };
  13564. /**
  13565. * Convert a source message to a translated text string:
  13566. * - text nodes are replaced with their translation,
  13567. * - placeholders are replaced with their content,
  13568. * - ICU nodes are converted to ICU expressions.
  13569. * @param {?} srcMsg
  13570. * @return {?}
  13571. */
  13572. I18nToHtmlVisitor.prototype._convertToText = /**
  13573. * Convert a source message to a translated text string:
  13574. * - text nodes are replaced with their translation,
  13575. * - placeholders are replaced with their content,
  13576. * - ICU nodes are converted to ICU expressions.
  13577. * @param {?} srcMsg
  13578. * @return {?}
  13579. */
  13580. function (srcMsg) {
  13581. var _this = this;
  13582. var /** @type {?} */ id = this._digest(srcMsg);
  13583. var /** @type {?} */ mapper = this._mapperFactory ? this._mapperFactory(srcMsg) : null;
  13584. var /** @type {?} */ nodes;
  13585. this._contextStack.push({ msg: this._srcMsg, mapper: this._mapper });
  13586. this._srcMsg = srcMsg;
  13587. if (this._i18nNodesByMsgId.hasOwnProperty(id)) {
  13588. // When there is a translation use its nodes as the source
  13589. // And create a mapper to convert serialized placeholder names to internal names
  13590. nodes = this._i18nNodesByMsgId[id];
  13591. this._mapper = function (name) { return mapper ? /** @type {?} */ ((mapper.toInternalName(name))) : name; };
  13592. }
  13593. else {
  13594. // When no translation has been found
  13595. // - report an error / a warning / nothing,
  13596. // - use the nodes from the original message
  13597. // - placeholders are already internal and need no mapper
  13598. if (this._missingTranslationStrategy === MissingTranslationStrategy.Error) {
  13599. var /** @type {?} */ ctx = this._locale ? " for locale \"" + this._locale + "\"" : '';
  13600. this._addError(srcMsg.nodes[0], "Missing translation for message \"" + id + "\"" + ctx);
  13601. }
  13602. else if (this._console &&
  13603. this._missingTranslationStrategy === MissingTranslationStrategy.Warning) {
  13604. var /** @type {?} */ ctx = this._locale ? " for locale \"" + this._locale + "\"" : '';
  13605. this._console.warn("Missing translation for message \"" + id + "\"" + ctx);
  13606. }
  13607. nodes = srcMsg.nodes;
  13608. this._mapper = function (name) { return name; };
  13609. }
  13610. var /** @type {?} */ text = nodes.map(function (node) { return node.visit(_this); }).join('');
  13611. var /** @type {?} */ context = /** @type {?} */ ((this._contextStack.pop()));
  13612. this._srcMsg = context.msg;
  13613. this._mapper = context.mapper;
  13614. return text;
  13615. };
  13616. /**
  13617. * @param {?} el
  13618. * @param {?} msg
  13619. * @return {?}
  13620. */
  13621. I18nToHtmlVisitor.prototype._addError = /**
  13622. * @param {?} el
  13623. * @param {?} msg
  13624. * @return {?}
  13625. */
  13626. function (el, msg) {
  13627. this._errors.push(new I18nError(el.sourceSpan, msg));
  13628. };
  13629. return I18nToHtmlVisitor;
  13630. }());
  13631. /**
  13632. * @fileoverview added by tsickle
  13633. * @suppress {checkTypes} checked by tsc
  13634. */
  13635. /**
  13636. * @license
  13637. * Copyright Google Inc. All Rights Reserved.
  13638. *
  13639. * Use of this source code is governed by an MIT-style license that can be
  13640. * found in the LICENSE file at https://angular.io/license
  13641. */
  13642. var I18NHtmlParser = /** @class */ (function () {
  13643. function I18NHtmlParser(_htmlParser, translations, translationsFormat, missingTranslation, console) {
  13644. if (missingTranslation === void 0) { missingTranslation = MissingTranslationStrategy.Warning; }
  13645. this._htmlParser = _htmlParser;
  13646. if (translations) {
  13647. var /** @type {?} */ serializer = createSerializer(translationsFormat);
  13648. this._translationBundle =
  13649. TranslationBundle.load(translations, 'i18n', serializer, missingTranslation, console);
  13650. }
  13651. else {
  13652. this._translationBundle =
  13653. new TranslationBundle({}, null, digest, undefined, missingTranslation, console);
  13654. }
  13655. }
  13656. /**
  13657. * @param {?} source
  13658. * @param {?} url
  13659. * @param {?=} parseExpansionForms
  13660. * @param {?=} interpolationConfig
  13661. * @return {?}
  13662. */
  13663. I18NHtmlParser.prototype.parse = /**
  13664. * @param {?} source
  13665. * @param {?} url
  13666. * @param {?=} parseExpansionForms
  13667. * @param {?=} interpolationConfig
  13668. * @return {?}
  13669. */
  13670. function (source, url, parseExpansionForms, interpolationConfig) {
  13671. if (parseExpansionForms === void 0) { parseExpansionForms = false; }
  13672. if (interpolationConfig === void 0) { interpolationConfig = DEFAULT_INTERPOLATION_CONFIG; }
  13673. var /** @type {?} */ parseResult = this._htmlParser.parse(source, url, parseExpansionForms, interpolationConfig);
  13674. if (parseResult.errors.length) {
  13675. return new ParseTreeResult(parseResult.rootNodes, parseResult.errors);
  13676. }
  13677. return mergeTranslations(parseResult.rootNodes, this._translationBundle, interpolationConfig, [], {});
  13678. };
  13679. return I18NHtmlParser;
  13680. }());
  13681. /**
  13682. * @param {?=} format
  13683. * @return {?}
  13684. */
  13685. function createSerializer(format) {
  13686. format = (format || 'xlf').toLowerCase();
  13687. switch (format) {
  13688. case 'xmb':
  13689. return new Xmb();
  13690. case 'xtb':
  13691. return new Xtb();
  13692. case 'xliff2':
  13693. case 'xlf2':
  13694. return new Xliff2();
  13695. case 'xliff':
  13696. case 'xlf':
  13697. default:
  13698. return new Xliff();
  13699. }
  13700. }
  13701. /**
  13702. * @fileoverview added by tsickle
  13703. * @suppress {checkTypes} checked by tsc
  13704. */
  13705. /**
  13706. * @license
  13707. * Copyright Google Inc. All Rights Reserved.
  13708. *
  13709. * Use of this source code is governed by an MIT-style license that can be
  13710. * found in the LICENSE file at https://angular.io/license
  13711. */
  13712. var STRIP_SRC_FILE_SUFFIXES = /(\.ts|\.d\.ts|\.js|\.jsx|\.tsx)$/;
  13713. var GENERATED_FILE = /\.ngfactory\.|\.ngsummary\./;
  13714. var JIT_SUMMARY_FILE = /\.ngsummary\./;
  13715. var JIT_SUMMARY_NAME = /NgSummary$/;
  13716. /**
  13717. * @param {?} filePath
  13718. * @param {?=} forceSourceFile
  13719. * @return {?}
  13720. */
  13721. function ngfactoryFilePath(filePath, forceSourceFile) {
  13722. if (forceSourceFile === void 0) { forceSourceFile = false; }
  13723. var /** @type {?} */ urlWithSuffix = splitTypescriptSuffix(filePath, forceSourceFile);
  13724. return urlWithSuffix[0] + ".ngfactory" + normalizeGenFileSuffix(urlWithSuffix[1]);
  13725. }
  13726. /**
  13727. * @param {?} filePath
  13728. * @return {?}
  13729. */
  13730. function stripGeneratedFileSuffix(filePath) {
  13731. return filePath.replace(GENERATED_FILE, '.');
  13732. }
  13733. /**
  13734. * @param {?} filePath
  13735. * @return {?}
  13736. */
  13737. function isGeneratedFile(filePath) {
  13738. return GENERATED_FILE.test(filePath);
  13739. }
  13740. /**
  13741. * @param {?} path
  13742. * @param {?=} forceSourceFile
  13743. * @return {?}
  13744. */
  13745. function splitTypescriptSuffix(path, forceSourceFile) {
  13746. if (forceSourceFile === void 0) { forceSourceFile = false; }
  13747. if (path.endsWith('.d.ts')) {
  13748. return [path.slice(0, -5), forceSourceFile ? '.ts' : '.d.ts'];
  13749. }
  13750. var /** @type {?} */ lastDot = path.lastIndexOf('.');
  13751. if (lastDot !== -1) {
  13752. return [path.substring(0, lastDot), path.substring(lastDot)];
  13753. }
  13754. return [path, ''];
  13755. }
  13756. /**
  13757. * @param {?} srcFileSuffix
  13758. * @return {?}
  13759. */
  13760. function normalizeGenFileSuffix(srcFileSuffix) {
  13761. return srcFileSuffix === '.tsx' ? '.ts' : srcFileSuffix;
  13762. }
  13763. /**
  13764. * @param {?} fileName
  13765. * @return {?}
  13766. */
  13767. function summaryFileName(fileName) {
  13768. var /** @type {?} */ fileNameWithoutSuffix = fileName.replace(STRIP_SRC_FILE_SUFFIXES, '');
  13769. return fileNameWithoutSuffix + ".ngsummary.json";
  13770. }
  13771. /**
  13772. * @param {?} fileName
  13773. * @param {?=} forceSourceFile
  13774. * @return {?}
  13775. */
  13776. function summaryForJitFileName(fileName, forceSourceFile) {
  13777. if (forceSourceFile === void 0) { forceSourceFile = false; }
  13778. var /** @type {?} */ urlWithSuffix = splitTypescriptSuffix(stripGeneratedFileSuffix(fileName), forceSourceFile);
  13779. return urlWithSuffix[0] + ".ngsummary" + urlWithSuffix[1];
  13780. }
  13781. /**
  13782. * @param {?} filePath
  13783. * @return {?}
  13784. */
  13785. function stripSummaryForJitFileSuffix(filePath) {
  13786. return filePath.replace(JIT_SUMMARY_FILE, '.');
  13787. }
  13788. /**
  13789. * @param {?} symbolName
  13790. * @return {?}
  13791. */
  13792. function summaryForJitName(symbolName) {
  13793. return symbolName + "NgSummary";
  13794. }
  13795. /**
  13796. * @param {?} symbolName
  13797. * @return {?}
  13798. */
  13799. function stripSummaryForJitNameSuffix(symbolName) {
  13800. return symbolName.replace(JIT_SUMMARY_NAME, '');
  13801. }
  13802. var LOWERED_SYMBOL = /\u0275\d+/;
  13803. /**
  13804. * @param {?} name
  13805. * @return {?}
  13806. */
  13807. function isLoweredSymbol(name) {
  13808. return LOWERED_SYMBOL.test(name);
  13809. }
  13810. /**
  13811. * @param {?} id
  13812. * @return {?}
  13813. */
  13814. function createLoweredSymbol(id) {
  13815. return "\u0275" + id;
  13816. }
  13817. /**
  13818. * @fileoverview added by tsickle
  13819. * @suppress {checkTypes} checked by tsc
  13820. */
  13821. /**
  13822. * @license
  13823. * Copyright Google Inc. All Rights Reserved.
  13824. *
  13825. * Use of this source code is governed by an MIT-style license that can be
  13826. * found in the LICENSE file at https://angular.io/license
  13827. */
  13828. var CORE = '@angular/core';
  13829. var Identifiers = /** @class */ (function () {
  13830. function Identifiers() {
  13831. }
  13832. Identifiers.ANALYZE_FOR_ENTRY_COMPONENTS = {
  13833. name: 'ANALYZE_FOR_ENTRY_COMPONENTS',
  13834. moduleName: CORE,
  13835. };
  13836. Identifiers.ElementRef = { name: 'ElementRef', moduleName: CORE };
  13837. Identifiers.NgModuleRef = { name: 'NgModuleRef', moduleName: CORE };
  13838. Identifiers.ViewContainerRef = { name: 'ViewContainerRef', moduleName: CORE };
  13839. Identifiers.ChangeDetectorRef = {
  13840. name: 'ChangeDetectorRef',
  13841. moduleName: CORE,
  13842. };
  13843. Identifiers.QueryList = { name: 'QueryList', moduleName: CORE };
  13844. Identifiers.TemplateRef = { name: 'TemplateRef', moduleName: CORE };
  13845. Identifiers.CodegenComponentFactoryResolver = {
  13846. name: 'ɵCodegenComponentFactoryResolver',
  13847. moduleName: CORE,
  13848. };
  13849. Identifiers.ComponentFactoryResolver = {
  13850. name: 'ComponentFactoryResolver',
  13851. moduleName: CORE,
  13852. };
  13853. Identifiers.ComponentFactory = { name: 'ComponentFactory', moduleName: CORE };
  13854. Identifiers.ComponentRef = { name: 'ComponentRef', moduleName: CORE };
  13855. Identifiers.NgModuleFactory = { name: 'NgModuleFactory', moduleName: CORE };
  13856. Identifiers.createModuleFactory = {
  13857. name: 'ɵcmf',
  13858. moduleName: CORE,
  13859. };
  13860. Identifiers.moduleDef = {
  13861. name: 'ɵmod',
  13862. moduleName: CORE,
  13863. };
  13864. Identifiers.moduleProviderDef = {
  13865. name: 'ɵmpd',
  13866. moduleName: CORE,
  13867. };
  13868. Identifiers.RegisterModuleFactoryFn = {
  13869. name: 'ɵregisterModuleFactory',
  13870. moduleName: CORE,
  13871. };
  13872. Identifiers.Injector = { name: 'Injector', moduleName: CORE };
  13873. Identifiers.ViewEncapsulation = {
  13874. name: 'ViewEncapsulation',
  13875. moduleName: CORE,
  13876. };
  13877. Identifiers.ChangeDetectionStrategy = {
  13878. name: 'ChangeDetectionStrategy',
  13879. moduleName: CORE,
  13880. };
  13881. Identifiers.SecurityContext = {
  13882. name: 'SecurityContext',
  13883. moduleName: CORE,
  13884. };
  13885. Identifiers.LOCALE_ID = { name: 'LOCALE_ID', moduleName: CORE };
  13886. Identifiers.TRANSLATIONS_FORMAT = {
  13887. name: 'TRANSLATIONS_FORMAT',
  13888. moduleName: CORE,
  13889. };
  13890. Identifiers.inlineInterpolate = {
  13891. name: 'ɵinlineInterpolate',
  13892. moduleName: CORE,
  13893. };
  13894. Identifiers.interpolate = { name: 'ɵinterpolate', moduleName: CORE };
  13895. Identifiers.EMPTY_ARRAY = { name: 'ɵEMPTY_ARRAY', moduleName: CORE };
  13896. Identifiers.EMPTY_MAP = { name: 'ɵEMPTY_MAP', moduleName: CORE };
  13897. Identifiers.Renderer = { name: 'Renderer', moduleName: CORE };
  13898. Identifiers.viewDef = { name: 'ɵvid', moduleName: CORE };
  13899. Identifiers.elementDef = { name: 'ɵeld', moduleName: CORE };
  13900. Identifiers.anchorDef = { name: 'ɵand', moduleName: CORE };
  13901. Identifiers.textDef = { name: 'ɵted', moduleName: CORE };
  13902. Identifiers.directiveDef = { name: 'ɵdid', moduleName: CORE };
  13903. Identifiers.providerDef = { name: 'ɵprd', moduleName: CORE };
  13904. Identifiers.queryDef = { name: 'ɵqud', moduleName: CORE };
  13905. Identifiers.pureArrayDef = { name: 'ɵpad', moduleName: CORE };
  13906. Identifiers.pureObjectDef = { name: 'ɵpod', moduleName: CORE };
  13907. Identifiers.purePipeDef = { name: 'ɵppd', moduleName: CORE };
  13908. Identifiers.pipeDef = { name: 'ɵpid', moduleName: CORE };
  13909. Identifiers.nodeValue = { name: 'ɵnov', moduleName: CORE };
  13910. Identifiers.ngContentDef = { name: 'ɵncd', moduleName: CORE };
  13911. Identifiers.unwrapValue = { name: 'ɵunv', moduleName: CORE };
  13912. Identifiers.createRendererType2 = { name: 'ɵcrt', moduleName: CORE };
  13913. // type only
  13914. Identifiers.RendererType2 = {
  13915. name: 'RendererType2',
  13916. moduleName: CORE,
  13917. };
  13918. // type only
  13919. Identifiers.ViewDefinition = {
  13920. name: 'ɵViewDefinition',
  13921. moduleName: CORE,
  13922. };
  13923. Identifiers.createComponentFactory = { name: 'ɵccf', moduleName: CORE };
  13924. return Identifiers;
  13925. }());
  13926. /**
  13927. * @param {?} reference
  13928. * @return {?}
  13929. */
  13930. function createTokenForReference(reference) {
  13931. return { identifier: { reference: reference } };
  13932. }
  13933. /**
  13934. * @param {?} reflector
  13935. * @param {?} reference
  13936. * @return {?}
  13937. */
  13938. function createTokenForExternalReference(reflector, reference) {
  13939. return createTokenForReference(reflector.resolveExternalReference(reference));
  13940. }
  13941. /**
  13942. * @fileoverview added by tsickle
  13943. * @suppress {checkTypes} checked by tsc
  13944. */
  13945. /**
  13946. * @license
  13947. * Copyright Google Inc. All Rights Reserved.
  13948. *
  13949. * Use of this source code is governed by an MIT-style license that can be
  13950. * found in the LICENSE file at https://angular.io/license
  13951. */
  13952. /** @enum {number} */
  13953. var LifecycleHooks = {
  13954. OnInit: 0,
  13955. OnDestroy: 1,
  13956. DoCheck: 2,
  13957. OnChanges: 3,
  13958. AfterContentInit: 4,
  13959. AfterContentChecked: 5,
  13960. AfterViewInit: 6,
  13961. AfterViewChecked: 7,
  13962. };
  13963. LifecycleHooks[LifecycleHooks.OnInit] = "OnInit";
  13964. LifecycleHooks[LifecycleHooks.OnDestroy] = "OnDestroy";
  13965. LifecycleHooks[LifecycleHooks.DoCheck] = "DoCheck";
  13966. LifecycleHooks[LifecycleHooks.OnChanges] = "OnChanges";
  13967. LifecycleHooks[LifecycleHooks.AfterContentInit] = "AfterContentInit";
  13968. LifecycleHooks[LifecycleHooks.AfterContentChecked] = "AfterContentChecked";
  13969. LifecycleHooks[LifecycleHooks.AfterViewInit] = "AfterViewInit";
  13970. LifecycleHooks[LifecycleHooks.AfterViewChecked] = "AfterViewChecked";
  13971. var LIFECYCLE_HOOKS_VALUES = [
  13972. LifecycleHooks.OnInit, LifecycleHooks.OnDestroy, LifecycleHooks.DoCheck, LifecycleHooks.OnChanges,
  13973. LifecycleHooks.AfterContentInit, LifecycleHooks.AfterContentChecked, LifecycleHooks.AfterViewInit,
  13974. LifecycleHooks.AfterViewChecked
  13975. ];
  13976. /**
  13977. * @param {?} reflector
  13978. * @param {?} hook
  13979. * @param {?} token
  13980. * @return {?}
  13981. */
  13982. function hasLifecycleHook(reflector, hook, token) {
  13983. return reflector.hasLifecycleHook(token, getHookName(hook));
  13984. }
  13985. /**
  13986. * @param {?} reflector
  13987. * @param {?} token
  13988. * @return {?}
  13989. */
  13990. function getAllLifecycleHooks(reflector, token) {
  13991. return LIFECYCLE_HOOKS_VALUES.filter(function (hook) { return hasLifecycleHook(reflector, hook, token); });
  13992. }
  13993. /**
  13994. * @param {?} hook
  13995. * @return {?}
  13996. */
  13997. function getHookName(hook) {
  13998. switch (hook) {
  13999. case LifecycleHooks.OnInit:
  14000. return 'ngOnInit';
  14001. case LifecycleHooks.OnDestroy:
  14002. return 'ngOnDestroy';
  14003. case LifecycleHooks.DoCheck:
  14004. return 'ngDoCheck';
  14005. case LifecycleHooks.OnChanges:
  14006. return 'ngOnChanges';
  14007. case LifecycleHooks.AfterContentInit:
  14008. return 'ngAfterContentInit';
  14009. case LifecycleHooks.AfterContentChecked:
  14010. return 'ngAfterContentChecked';
  14011. case LifecycleHooks.AfterViewInit:
  14012. return 'ngAfterViewInit';
  14013. case LifecycleHooks.AfterViewChecked:
  14014. return 'ngAfterViewChecked';
  14015. }
  14016. }
  14017. /**
  14018. * @fileoverview added by tsickle
  14019. * @suppress {checkTypes} checked by tsc
  14020. */
  14021. /**
  14022. * @license
  14023. * Copyright Google Inc. All Rights Reserved.
  14024. *
  14025. * Use of this source code is governed by an MIT-style license that can be
  14026. * found in the LICENSE file at https://angular.io/license
  14027. */
  14028. var _SELECTOR_REGEXP = new RegExp('(\\:not\\()|' + //":not("
  14029. '([-\\w]+)|' + // "tag"
  14030. '(?:\\.([-\\w]+))|' + // ".class"
  14031. '(?:\\[([-.\\w*]+)(?:=([\"\']?)([^\\]\"\']*)\\5)?\\])|' + // "[name]", "[name=value]",
  14032. '(\\))|' + // ")"
  14033. '(\\s*,\\s*)', // ","
  14034. 'g');
  14035. /**
  14036. * A css selector contains an element name,
  14037. * css classes and attribute/value pairs with the purpose
  14038. * of selecting subsets out of them.
  14039. */
  14040. var CssSelector = /** @class */ (function () {
  14041. function CssSelector() {
  14042. this.element = null;
  14043. this.classNames = [];
  14044. this.attrs = [];
  14045. this.notSelectors = [];
  14046. }
  14047. /**
  14048. * @param {?} selector
  14049. * @return {?}
  14050. */
  14051. CssSelector.parse = /**
  14052. * @param {?} selector
  14053. * @return {?}
  14054. */
  14055. function (selector) {
  14056. var /** @type {?} */ results = [];
  14057. var /** @type {?} */ _addResult = function (res, cssSel) {
  14058. if (cssSel.notSelectors.length > 0 && !cssSel.element && cssSel.classNames.length == 0 &&
  14059. cssSel.attrs.length == 0) {
  14060. cssSel.element = '*';
  14061. }
  14062. res.push(cssSel);
  14063. };
  14064. var /** @type {?} */ cssSelector = new CssSelector();
  14065. var /** @type {?} */ match;
  14066. var /** @type {?} */ current = cssSelector;
  14067. var /** @type {?} */ inNot = false;
  14068. _SELECTOR_REGEXP.lastIndex = 0;
  14069. while (match = _SELECTOR_REGEXP.exec(selector)) {
  14070. if (match[1]) {
  14071. if (inNot) {
  14072. throw new Error('Nesting :not is not allowed in a selector');
  14073. }
  14074. inNot = true;
  14075. current = new CssSelector();
  14076. cssSelector.notSelectors.push(current);
  14077. }
  14078. if (match[2]) {
  14079. current.setElement(match[2]);
  14080. }
  14081. if (match[3]) {
  14082. current.addClassName(match[3]);
  14083. }
  14084. if (match[4]) {
  14085. current.addAttribute(match[4], match[6]);
  14086. }
  14087. if (match[7]) {
  14088. inNot = false;
  14089. current = cssSelector;
  14090. }
  14091. if (match[8]) {
  14092. if (inNot) {
  14093. throw new Error('Multiple selectors in :not are not supported');
  14094. }
  14095. _addResult(results, cssSelector);
  14096. cssSelector = current = new CssSelector();
  14097. }
  14098. }
  14099. _addResult(results, cssSelector);
  14100. return results;
  14101. };
  14102. /**
  14103. * @return {?}
  14104. */
  14105. CssSelector.prototype.isElementSelector = /**
  14106. * @return {?}
  14107. */
  14108. function () {
  14109. return this.hasElementSelector() && this.classNames.length == 0 && this.attrs.length == 0 &&
  14110. this.notSelectors.length === 0;
  14111. };
  14112. /**
  14113. * @return {?}
  14114. */
  14115. CssSelector.prototype.hasElementSelector = /**
  14116. * @return {?}
  14117. */
  14118. function () { return !!this.element; };
  14119. /**
  14120. * @param {?=} element
  14121. * @return {?}
  14122. */
  14123. CssSelector.prototype.setElement = /**
  14124. * @param {?=} element
  14125. * @return {?}
  14126. */
  14127. function (element) {
  14128. if (element === void 0) { element = null; }
  14129. this.element = element;
  14130. };
  14131. /** Gets a template string for an element that matches the selector. */
  14132. /**
  14133. * Gets a template string for an element that matches the selector.
  14134. * @return {?}
  14135. */
  14136. CssSelector.prototype.getMatchingElementTemplate = /**
  14137. * Gets a template string for an element that matches the selector.
  14138. * @return {?}
  14139. */
  14140. function () {
  14141. var /** @type {?} */ tagName = this.element || 'div';
  14142. var /** @type {?} */ classAttr = this.classNames.length > 0 ? " class=\"" + this.classNames.join(' ') + "\"" : '';
  14143. var /** @type {?} */ attrs = '';
  14144. for (var /** @type {?} */ i = 0; i < this.attrs.length; i += 2) {
  14145. var /** @type {?} */ attrName = this.attrs[i];
  14146. var /** @type {?} */ attrValue = this.attrs[i + 1] !== '' ? "=\"" + this.attrs[i + 1] + "\"" : '';
  14147. attrs += " " + attrName + attrValue;
  14148. }
  14149. return getHtmlTagDefinition(tagName).isVoid ? "<" + tagName + classAttr + attrs + "/>" :
  14150. "<" + tagName + classAttr + attrs + "></" + tagName + ">";
  14151. };
  14152. /**
  14153. * @param {?} name
  14154. * @param {?=} value
  14155. * @return {?}
  14156. */
  14157. CssSelector.prototype.addAttribute = /**
  14158. * @param {?} name
  14159. * @param {?=} value
  14160. * @return {?}
  14161. */
  14162. function (name, value) {
  14163. if (value === void 0) { value = ''; }
  14164. this.attrs.push(name, value && value.toLowerCase() || '');
  14165. };
  14166. /**
  14167. * @param {?} name
  14168. * @return {?}
  14169. */
  14170. CssSelector.prototype.addClassName = /**
  14171. * @param {?} name
  14172. * @return {?}
  14173. */
  14174. function (name) { this.classNames.push(name.toLowerCase()); };
  14175. /**
  14176. * @return {?}
  14177. */
  14178. CssSelector.prototype.toString = /**
  14179. * @return {?}
  14180. */
  14181. function () {
  14182. var /** @type {?} */ res = this.element || '';
  14183. if (this.classNames) {
  14184. this.classNames.forEach(function (klass) { return res += "." + klass; });
  14185. }
  14186. if (this.attrs) {
  14187. for (var /** @type {?} */ i = 0; i < this.attrs.length; i += 2) {
  14188. var /** @type {?} */ name_1 = this.attrs[i];
  14189. var /** @type {?} */ value = this.attrs[i + 1];
  14190. res += "[" + name_1 + (value ? '=' + value : '') + "]";
  14191. }
  14192. }
  14193. this.notSelectors.forEach(function (notSelector) { return res += ":not(" + notSelector + ")"; });
  14194. return res;
  14195. };
  14196. return CssSelector;
  14197. }());
  14198. /**
  14199. * Reads a list of CssSelectors and allows to calculate which ones
  14200. * are contained in a given CssSelector.
  14201. */
  14202. var SelectorMatcher = /** @class */ (function () {
  14203. function SelectorMatcher() {
  14204. this._elementMap = new Map();
  14205. this._elementPartialMap = new Map();
  14206. this._classMap = new Map();
  14207. this._classPartialMap = new Map();
  14208. this._attrValueMap = new Map();
  14209. this._attrValuePartialMap = new Map();
  14210. this._listContexts = [];
  14211. }
  14212. /**
  14213. * @param {?} notSelectors
  14214. * @return {?}
  14215. */
  14216. SelectorMatcher.createNotMatcher = /**
  14217. * @param {?} notSelectors
  14218. * @return {?}
  14219. */
  14220. function (notSelectors) {
  14221. var /** @type {?} */ notMatcher = new SelectorMatcher();
  14222. notMatcher.addSelectables(notSelectors, null);
  14223. return notMatcher;
  14224. };
  14225. /**
  14226. * @param {?} cssSelectors
  14227. * @param {?=} callbackCtxt
  14228. * @return {?}
  14229. */
  14230. SelectorMatcher.prototype.addSelectables = /**
  14231. * @param {?} cssSelectors
  14232. * @param {?=} callbackCtxt
  14233. * @return {?}
  14234. */
  14235. function (cssSelectors, callbackCtxt) {
  14236. var /** @type {?} */ listContext = /** @type {?} */ ((null));
  14237. if (cssSelectors.length > 1) {
  14238. listContext = new SelectorListContext(cssSelectors);
  14239. this._listContexts.push(listContext);
  14240. }
  14241. for (var /** @type {?} */ i = 0; i < cssSelectors.length; i++) {
  14242. this._addSelectable(cssSelectors[i], callbackCtxt, listContext);
  14243. }
  14244. };
  14245. /**
  14246. * Add an object that can be found later on by calling `match`.
  14247. * @param {?} cssSelector A css selector
  14248. * @param {?} callbackCtxt An opaque object that will be given to the callback of the `match` function
  14249. * @param {?} listContext
  14250. * @return {?}
  14251. */
  14252. SelectorMatcher.prototype._addSelectable = /**
  14253. * Add an object that can be found later on by calling `match`.
  14254. * @param {?} cssSelector A css selector
  14255. * @param {?} callbackCtxt An opaque object that will be given to the callback of the `match` function
  14256. * @param {?} listContext
  14257. * @return {?}
  14258. */
  14259. function (cssSelector, callbackCtxt, listContext) {
  14260. var /** @type {?} */ matcher = this;
  14261. var /** @type {?} */ element = cssSelector.element;
  14262. var /** @type {?} */ classNames = cssSelector.classNames;
  14263. var /** @type {?} */ attrs = cssSelector.attrs;
  14264. var /** @type {?} */ selectable = new SelectorContext(cssSelector, callbackCtxt, listContext);
  14265. if (element) {
  14266. var /** @type {?} */ isTerminal = attrs.length === 0 && classNames.length === 0;
  14267. if (isTerminal) {
  14268. this._addTerminal(matcher._elementMap, element, selectable);
  14269. }
  14270. else {
  14271. matcher = this._addPartial(matcher._elementPartialMap, element);
  14272. }
  14273. }
  14274. if (classNames) {
  14275. for (var /** @type {?} */ i = 0; i < classNames.length; i++) {
  14276. var /** @type {?} */ isTerminal = attrs.length === 0 && i === classNames.length - 1;
  14277. var /** @type {?} */ className = classNames[i];
  14278. if (isTerminal) {
  14279. this._addTerminal(matcher._classMap, className, selectable);
  14280. }
  14281. else {
  14282. matcher = this._addPartial(matcher._classPartialMap, className);
  14283. }
  14284. }
  14285. }
  14286. if (attrs) {
  14287. for (var /** @type {?} */ i = 0; i < attrs.length; i += 2) {
  14288. var /** @type {?} */ isTerminal = i === attrs.length - 2;
  14289. var /** @type {?} */ name_2 = attrs[i];
  14290. var /** @type {?} */ value = attrs[i + 1];
  14291. if (isTerminal) {
  14292. var /** @type {?} */ terminalMap = matcher._attrValueMap;
  14293. var /** @type {?} */ terminalValuesMap = terminalMap.get(name_2);
  14294. if (!terminalValuesMap) {
  14295. terminalValuesMap = new Map();
  14296. terminalMap.set(name_2, terminalValuesMap);
  14297. }
  14298. this._addTerminal(terminalValuesMap, value, selectable);
  14299. }
  14300. else {
  14301. var /** @type {?} */ partialMap = matcher._attrValuePartialMap;
  14302. var /** @type {?} */ partialValuesMap = partialMap.get(name_2);
  14303. if (!partialValuesMap) {
  14304. partialValuesMap = new Map();
  14305. partialMap.set(name_2, partialValuesMap);
  14306. }
  14307. matcher = this._addPartial(partialValuesMap, value);
  14308. }
  14309. }
  14310. }
  14311. };
  14312. /**
  14313. * @param {?} map
  14314. * @param {?} name
  14315. * @param {?} selectable
  14316. * @return {?}
  14317. */
  14318. SelectorMatcher.prototype._addTerminal = /**
  14319. * @param {?} map
  14320. * @param {?} name
  14321. * @param {?} selectable
  14322. * @return {?}
  14323. */
  14324. function (map, name, selectable) {
  14325. var /** @type {?} */ terminalList = map.get(name);
  14326. if (!terminalList) {
  14327. terminalList = [];
  14328. map.set(name, terminalList);
  14329. }
  14330. terminalList.push(selectable);
  14331. };
  14332. /**
  14333. * @param {?} map
  14334. * @param {?} name
  14335. * @return {?}
  14336. */
  14337. SelectorMatcher.prototype._addPartial = /**
  14338. * @param {?} map
  14339. * @param {?} name
  14340. * @return {?}
  14341. */
  14342. function (map, name) {
  14343. var /** @type {?} */ matcher = map.get(name);
  14344. if (!matcher) {
  14345. matcher = new SelectorMatcher();
  14346. map.set(name, matcher);
  14347. }
  14348. return matcher;
  14349. };
  14350. /**
  14351. * Find the objects that have been added via `addSelectable`
  14352. * whose css selector is contained in the given css selector.
  14353. * @param cssSelector A css selector
  14354. * @param matchedCallback This callback will be called with the object handed into `addSelectable`
  14355. * @return boolean true if a match was found
  14356. */
  14357. /**
  14358. * Find the objects that have been added via `addSelectable`
  14359. * whose css selector is contained in the given css selector.
  14360. * @param {?} cssSelector A css selector
  14361. * @param {?} matchedCallback This callback will be called with the object handed into `addSelectable`
  14362. * @return {?} boolean true if a match was found
  14363. */
  14364. SelectorMatcher.prototype.match = /**
  14365. * Find the objects that have been added via `addSelectable`
  14366. * whose css selector is contained in the given css selector.
  14367. * @param {?} cssSelector A css selector
  14368. * @param {?} matchedCallback This callback will be called with the object handed into `addSelectable`
  14369. * @return {?} boolean true if a match was found
  14370. */
  14371. function (cssSelector, matchedCallback) {
  14372. var /** @type {?} */ result = false;
  14373. var /** @type {?} */ element = /** @type {?} */ ((cssSelector.element));
  14374. var /** @type {?} */ classNames = cssSelector.classNames;
  14375. var /** @type {?} */ attrs = cssSelector.attrs;
  14376. for (var /** @type {?} */ i = 0; i < this._listContexts.length; i++) {
  14377. this._listContexts[i].alreadyMatched = false;
  14378. }
  14379. result = this._matchTerminal(this._elementMap, element, cssSelector, matchedCallback) || result;
  14380. result = this._matchPartial(this._elementPartialMap, element, cssSelector, matchedCallback) ||
  14381. result;
  14382. if (classNames) {
  14383. for (var /** @type {?} */ i = 0; i < classNames.length; i++) {
  14384. var /** @type {?} */ className = classNames[i];
  14385. result =
  14386. this._matchTerminal(this._classMap, className, cssSelector, matchedCallback) || result;
  14387. result =
  14388. this._matchPartial(this._classPartialMap, className, cssSelector, matchedCallback) ||
  14389. result;
  14390. }
  14391. }
  14392. if (attrs) {
  14393. for (var /** @type {?} */ i = 0; i < attrs.length; i += 2) {
  14394. var /** @type {?} */ name_3 = attrs[i];
  14395. var /** @type {?} */ value = attrs[i + 1];
  14396. var /** @type {?} */ terminalValuesMap = /** @type {?} */ ((this._attrValueMap.get(name_3)));
  14397. if (value) {
  14398. result =
  14399. this._matchTerminal(terminalValuesMap, '', cssSelector, matchedCallback) || result;
  14400. }
  14401. result =
  14402. this._matchTerminal(terminalValuesMap, value, cssSelector, matchedCallback) || result;
  14403. var /** @type {?} */ partialValuesMap = /** @type {?} */ ((this._attrValuePartialMap.get(name_3)));
  14404. if (value) {
  14405. result = this._matchPartial(partialValuesMap, '', cssSelector, matchedCallback) || result;
  14406. }
  14407. result =
  14408. this._matchPartial(partialValuesMap, value, cssSelector, matchedCallback) || result;
  14409. }
  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._matchTerminal = /**
  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 {?} */ selectables = map.get(name) || [];
  14435. var /** @type {?} */ starSelectables = /** @type {?} */ ((map.get('*')));
  14436. if (starSelectables) {
  14437. selectables = selectables.concat(starSelectables);
  14438. }
  14439. if (selectables.length === 0) {
  14440. return false;
  14441. }
  14442. var /** @type {?} */ selectable;
  14443. var /** @type {?} */ result = false;
  14444. for (var /** @type {?} */ i = 0; i < selectables.length; i++) {
  14445. selectable = selectables[i];
  14446. result = selectable.finalize(cssSelector, matchedCallback) || result;
  14447. }
  14448. return result;
  14449. };
  14450. /** @internal */
  14451. /**
  14452. * \@internal
  14453. * @param {?} map
  14454. * @param {?} name
  14455. * @param {?} cssSelector
  14456. * @param {?} matchedCallback
  14457. * @return {?}
  14458. */
  14459. SelectorMatcher.prototype._matchPartial = /**
  14460. * \@internal
  14461. * @param {?} map
  14462. * @param {?} name
  14463. * @param {?} cssSelector
  14464. * @param {?} matchedCallback
  14465. * @return {?}
  14466. */
  14467. function (map, name, cssSelector, matchedCallback) {
  14468. if (!map || typeof name !== 'string') {
  14469. return false;
  14470. }
  14471. var /** @type {?} */ nestedSelector = map.get(name);
  14472. if (!nestedSelector) {
  14473. return false;
  14474. }
  14475. // TODO(perf): get rid of recursion and measure again
  14476. // TODO(perf): don't pass the whole selector into the recursion,
  14477. // but only the not processed parts
  14478. return nestedSelector.match(cssSelector, matchedCallback);
  14479. };
  14480. return SelectorMatcher;
  14481. }());
  14482. var SelectorListContext = /** @class */ (function () {
  14483. function SelectorListContext(selectors) {
  14484. this.selectors = selectors;
  14485. this.alreadyMatched = false;
  14486. }
  14487. return SelectorListContext;
  14488. }());
  14489. var SelectorContext = /** @class */ (function () {
  14490. function SelectorContext(selector, cbContext, listContext) {
  14491. this.selector = selector;
  14492. this.cbContext = cbContext;
  14493. this.listContext = listContext;
  14494. this.notSelectors = selector.notSelectors;
  14495. }
  14496. /**
  14497. * @param {?} cssSelector
  14498. * @param {?} callback
  14499. * @return {?}
  14500. */
  14501. SelectorContext.prototype.finalize = /**
  14502. * @param {?} cssSelector
  14503. * @param {?} callback
  14504. * @return {?}
  14505. */
  14506. function (cssSelector, callback) {
  14507. var /** @type {?} */ result = true;
  14508. if (this.notSelectors.length > 0 && (!this.listContext || !this.listContext.alreadyMatched)) {
  14509. var /** @type {?} */ notMatcher = SelectorMatcher.createNotMatcher(this.notSelectors);
  14510. result = !notMatcher.match(cssSelector, null);
  14511. }
  14512. if (result && callback && (!this.listContext || !this.listContext.alreadyMatched)) {
  14513. if (this.listContext) {
  14514. this.listContext.alreadyMatched = true;
  14515. }
  14516. callback(this.selector, this.cbContext);
  14517. }
  14518. return result;
  14519. };
  14520. return SelectorContext;
  14521. }());
  14522. /**
  14523. * @fileoverview added by tsickle
  14524. * @suppress {checkTypes} checked by tsc
  14525. */
  14526. /**
  14527. * @license
  14528. * Copyright Google Inc. All Rights Reserved.
  14529. *
  14530. * Use of this source code is governed by an MIT-style license that can be
  14531. * found in the LICENSE file at https://angular.io/license
  14532. */
  14533. var ERROR_COMPONENT_TYPE = 'ngComponentType';
  14534. var CompileMetadataResolver = /** @class */ (function () {
  14535. function CompileMetadataResolver(_config, _htmlParser, _ngModuleResolver, _directiveResolver, _pipeResolver, _summaryResolver, _schemaRegistry, _directiveNormalizer, _console, _staticSymbolCache, _reflector, _errorCollector) {
  14536. this._config = _config;
  14537. this._htmlParser = _htmlParser;
  14538. this._ngModuleResolver = _ngModuleResolver;
  14539. this._directiveResolver = _directiveResolver;
  14540. this._pipeResolver = _pipeResolver;
  14541. this._summaryResolver = _summaryResolver;
  14542. this._schemaRegistry = _schemaRegistry;
  14543. this._directiveNormalizer = _directiveNormalizer;
  14544. this._console = _console;
  14545. this._staticSymbolCache = _staticSymbolCache;
  14546. this._reflector = _reflector;
  14547. this._errorCollector = _errorCollector;
  14548. this._nonNormalizedDirectiveCache = new Map();
  14549. this._directiveCache = new Map();
  14550. this._summaryCache = new Map();
  14551. this._pipeCache = new Map();
  14552. this._ngModuleCache = new Map();
  14553. this._ngModuleOfTypes = new Map();
  14554. }
  14555. /**
  14556. * @return {?}
  14557. */
  14558. CompileMetadataResolver.prototype.getReflector = /**
  14559. * @return {?}
  14560. */
  14561. function () { return this._reflector; };
  14562. /**
  14563. * @param {?} type
  14564. * @return {?}
  14565. */
  14566. CompileMetadataResolver.prototype.clearCacheFor = /**
  14567. * @param {?} type
  14568. * @return {?}
  14569. */
  14570. function (type) {
  14571. var /** @type {?} */ dirMeta = this._directiveCache.get(type);
  14572. this._directiveCache.delete(type);
  14573. this._nonNormalizedDirectiveCache.delete(type);
  14574. this._summaryCache.delete(type);
  14575. this._pipeCache.delete(type);
  14576. this._ngModuleOfTypes.delete(type);
  14577. // Clear all of the NgModule as they contain transitive information!
  14578. this._ngModuleCache.clear();
  14579. if (dirMeta) {
  14580. this._directiveNormalizer.clearCacheFor(dirMeta);
  14581. }
  14582. };
  14583. /**
  14584. * @return {?}
  14585. */
  14586. CompileMetadataResolver.prototype.clearCache = /**
  14587. * @return {?}
  14588. */
  14589. function () {
  14590. this._directiveCache.clear();
  14591. this._nonNormalizedDirectiveCache.clear();
  14592. this._summaryCache.clear();
  14593. this._pipeCache.clear();
  14594. this._ngModuleCache.clear();
  14595. this._ngModuleOfTypes.clear();
  14596. this._directiveNormalizer.clearCache();
  14597. };
  14598. /**
  14599. * @param {?} baseType
  14600. * @param {?} name
  14601. * @return {?}
  14602. */
  14603. CompileMetadataResolver.prototype._createProxyClass = /**
  14604. * @param {?} baseType
  14605. * @param {?} name
  14606. * @return {?}
  14607. */
  14608. function (baseType, name) {
  14609. var /** @type {?} */ delegate = null;
  14610. var /** @type {?} */ proxyClass = /** @type {?} */ (function () {
  14611. if (!delegate) {
  14612. throw new Error("Illegal state: Class " + name + " for type " + stringify(baseType) + " is not compiled yet!");
  14613. }
  14614. return delegate.apply(this, arguments);
  14615. });
  14616. proxyClass.setDelegate = function (d) {
  14617. delegate = d;
  14618. (/** @type {?} */ (proxyClass)).prototype = d.prototype;
  14619. };
  14620. // Make stringify work correctly
  14621. (/** @type {?} */ (proxyClass)).overriddenName = name;
  14622. return proxyClass;
  14623. };
  14624. /**
  14625. * @param {?} dirType
  14626. * @param {?} name
  14627. * @return {?}
  14628. */
  14629. CompileMetadataResolver.prototype.getGeneratedClass = /**
  14630. * @param {?} dirType
  14631. * @param {?} name
  14632. * @return {?}
  14633. */
  14634. function (dirType, name) {
  14635. if (dirType instanceof StaticSymbol) {
  14636. return this._staticSymbolCache.get(ngfactoryFilePath(dirType.filePath), name);
  14637. }
  14638. else {
  14639. return this._createProxyClass(dirType, name);
  14640. }
  14641. };
  14642. /**
  14643. * @param {?} dirType
  14644. * @return {?}
  14645. */
  14646. CompileMetadataResolver.prototype.getComponentViewClass = /**
  14647. * @param {?} dirType
  14648. * @return {?}
  14649. */
  14650. function (dirType) {
  14651. return this.getGeneratedClass(dirType, viewClassName(dirType, 0));
  14652. };
  14653. /**
  14654. * @param {?} dirType
  14655. * @return {?}
  14656. */
  14657. CompileMetadataResolver.prototype.getHostComponentViewClass = /**
  14658. * @param {?} dirType
  14659. * @return {?}
  14660. */
  14661. function (dirType) {
  14662. return this.getGeneratedClass(dirType, hostViewClassName(dirType));
  14663. };
  14664. /**
  14665. * @param {?} dirType
  14666. * @return {?}
  14667. */
  14668. CompileMetadataResolver.prototype.getHostComponentType = /**
  14669. * @param {?} dirType
  14670. * @return {?}
  14671. */
  14672. function (dirType) {
  14673. var /** @type {?} */ name = identifierName({ reference: dirType }) + "_Host";
  14674. if (dirType instanceof StaticSymbol) {
  14675. return this._staticSymbolCache.get(dirType.filePath, name);
  14676. }
  14677. else {
  14678. var /** @type {?} */ HostClass = /** @type {?} */ (function HostClass() { });
  14679. HostClass.overriddenName = name;
  14680. return HostClass;
  14681. }
  14682. };
  14683. /**
  14684. * @param {?} dirType
  14685. * @return {?}
  14686. */
  14687. CompileMetadataResolver.prototype.getRendererType = /**
  14688. * @param {?} dirType
  14689. * @return {?}
  14690. */
  14691. function (dirType) {
  14692. if (dirType instanceof StaticSymbol) {
  14693. return this._staticSymbolCache.get(ngfactoryFilePath(dirType.filePath), rendererTypeName(dirType));
  14694. }
  14695. else {
  14696. // returning an object as proxy,
  14697. // that we fill later during runtime compilation.
  14698. return /** @type {?} */ ({});
  14699. }
  14700. };
  14701. /**
  14702. * @param {?} selector
  14703. * @param {?} dirType
  14704. * @param {?} inputs
  14705. * @param {?} outputs
  14706. * @return {?}
  14707. */
  14708. CompileMetadataResolver.prototype.getComponentFactory = /**
  14709. * @param {?} selector
  14710. * @param {?} dirType
  14711. * @param {?} inputs
  14712. * @param {?} outputs
  14713. * @return {?}
  14714. */
  14715. function (selector, dirType, inputs, outputs) {
  14716. if (dirType instanceof StaticSymbol) {
  14717. return this._staticSymbolCache.get(ngfactoryFilePath(dirType.filePath), componentFactoryName(dirType));
  14718. }
  14719. else {
  14720. var /** @type {?} */ hostView = this.getHostComponentViewClass(dirType);
  14721. // Note: ngContentSelectors will be filled later once the template is
  14722. // loaded.
  14723. var /** @type {?} */ createComponentFactory = this._reflector.resolveExternalReference(Identifiers.createComponentFactory);
  14724. return createComponentFactory(selector, dirType, /** @type {?} */ (hostView), inputs, outputs, []);
  14725. }
  14726. };
  14727. /**
  14728. * @param {?} factory
  14729. * @param {?} ngContentSelectors
  14730. * @return {?}
  14731. */
  14732. CompileMetadataResolver.prototype.initComponentFactory = /**
  14733. * @param {?} factory
  14734. * @param {?} ngContentSelectors
  14735. * @return {?}
  14736. */
  14737. function (factory, ngContentSelectors) {
  14738. if (!(factory instanceof StaticSymbol)) {
  14739. (_a = (/** @type {?} */ (factory)).ngContentSelectors).push.apply(_a, ngContentSelectors);
  14740. }
  14741. var _a;
  14742. };
  14743. /**
  14744. * @param {?} type
  14745. * @param {?} kind
  14746. * @return {?}
  14747. */
  14748. CompileMetadataResolver.prototype._loadSummary = /**
  14749. * @param {?} type
  14750. * @param {?} kind
  14751. * @return {?}
  14752. */
  14753. function (type, kind) {
  14754. var /** @type {?} */ typeSummary = this._summaryCache.get(type);
  14755. if (!typeSummary) {
  14756. var /** @type {?} */ summary = this._summaryResolver.resolveSummary(type);
  14757. typeSummary = summary ? summary.type : null;
  14758. this._summaryCache.set(type, typeSummary || null);
  14759. }
  14760. return typeSummary && typeSummary.summaryKind === kind ? typeSummary : null;
  14761. };
  14762. /**
  14763. * @param {?} compMeta
  14764. * @param {?=} hostViewType
  14765. * @return {?}
  14766. */
  14767. CompileMetadataResolver.prototype.getHostComponentMetadata = /**
  14768. * @param {?} compMeta
  14769. * @param {?=} hostViewType
  14770. * @return {?}
  14771. */
  14772. function (compMeta, hostViewType) {
  14773. var /** @type {?} */ hostType = this.getHostComponentType(compMeta.type.reference);
  14774. if (!hostViewType) {
  14775. hostViewType = this.getHostComponentViewClass(hostType);
  14776. }
  14777. // Note: ! is ok here as this method should only be called with normalized directive
  14778. // metadata, which always fills in the selector.
  14779. var /** @type {?} */ template = CssSelector.parse(/** @type {?} */ ((compMeta.selector)))[0].getMatchingElementTemplate();
  14780. var /** @type {?} */ templateUrl = '';
  14781. var /** @type {?} */ htmlAst = this._htmlParser.parse(template, templateUrl);
  14782. return CompileDirectiveMetadata.create({
  14783. isHost: true,
  14784. type: { reference: hostType, diDeps: [], lifecycleHooks: [] },
  14785. template: new CompileTemplateMetadata({
  14786. encapsulation: ViewEncapsulation.None,
  14787. template: template,
  14788. templateUrl: templateUrl,
  14789. htmlAst: htmlAst,
  14790. styles: [],
  14791. styleUrls: [],
  14792. ngContentSelectors: [],
  14793. animations: [],
  14794. isInline: true,
  14795. externalStylesheets: [],
  14796. interpolation: null,
  14797. preserveWhitespaces: false,
  14798. }),
  14799. exportAs: null,
  14800. changeDetection: ChangeDetectionStrategy.Default,
  14801. inputs: [],
  14802. outputs: [],
  14803. host: {},
  14804. isComponent: true,
  14805. selector: '*',
  14806. providers: [],
  14807. viewProviders: [],
  14808. queries: [],
  14809. guards: {},
  14810. viewQueries: [],
  14811. componentViewType: hostViewType,
  14812. rendererType: /** @type {?} */ ({ id: '__Host__', encapsulation: ViewEncapsulation.None, styles: [], data: {} }),
  14813. entryComponents: [],
  14814. componentFactory: null
  14815. });
  14816. };
  14817. /**
  14818. * @param {?} ngModuleType
  14819. * @param {?} directiveType
  14820. * @param {?} isSync
  14821. * @return {?}
  14822. */
  14823. CompileMetadataResolver.prototype.loadDirectiveMetadata = /**
  14824. * @param {?} ngModuleType
  14825. * @param {?} directiveType
  14826. * @param {?} isSync
  14827. * @return {?}
  14828. */
  14829. function (ngModuleType, directiveType, isSync) {
  14830. var _this = this;
  14831. if (this._directiveCache.has(directiveType)) {
  14832. return null;
  14833. }
  14834. directiveType = resolveForwardRef(directiveType);
  14835. var _a = /** @type {?} */ ((this.getNonNormalizedDirectiveMetadata(directiveType))), annotation = _a.annotation, metadata = _a.metadata;
  14836. var /** @type {?} */ createDirectiveMetadata = function (templateMetadata) {
  14837. var /** @type {?} */ normalizedDirMeta = new CompileDirectiveMetadata({
  14838. isHost: false,
  14839. type: metadata.type,
  14840. isComponent: metadata.isComponent,
  14841. selector: metadata.selector,
  14842. exportAs: metadata.exportAs,
  14843. changeDetection: metadata.changeDetection,
  14844. inputs: metadata.inputs,
  14845. outputs: metadata.outputs,
  14846. hostListeners: metadata.hostListeners,
  14847. hostProperties: metadata.hostProperties,
  14848. hostAttributes: metadata.hostAttributes,
  14849. providers: metadata.providers,
  14850. viewProviders: metadata.viewProviders,
  14851. queries: metadata.queries,
  14852. guards: metadata.guards,
  14853. viewQueries: metadata.viewQueries,
  14854. entryComponents: metadata.entryComponents,
  14855. componentViewType: metadata.componentViewType,
  14856. rendererType: metadata.rendererType,
  14857. componentFactory: metadata.componentFactory,
  14858. template: templateMetadata
  14859. });
  14860. if (templateMetadata) {
  14861. _this.initComponentFactory(/** @type {?} */ ((metadata.componentFactory)), templateMetadata.ngContentSelectors);
  14862. }
  14863. _this._directiveCache.set(directiveType, normalizedDirMeta);
  14864. _this._summaryCache.set(directiveType, normalizedDirMeta.toSummary());
  14865. return null;
  14866. };
  14867. if (metadata.isComponent) {
  14868. var /** @type {?} */ template = /** @type {?} */ ((metadata.template));
  14869. var /** @type {?} */ templateMeta = this._directiveNormalizer.normalizeTemplate({
  14870. ngModuleType: ngModuleType,
  14871. componentType: directiveType,
  14872. moduleUrl: this._reflector.componentModuleUrl(directiveType, annotation),
  14873. encapsulation: template.encapsulation,
  14874. template: template.template,
  14875. templateUrl: template.templateUrl,
  14876. styles: template.styles,
  14877. styleUrls: template.styleUrls,
  14878. animations: template.animations,
  14879. interpolation: template.interpolation,
  14880. preserveWhitespaces: template.preserveWhitespaces
  14881. });
  14882. if (isPromise(templateMeta) && isSync) {
  14883. this._reportError(componentStillLoadingError(directiveType), directiveType);
  14884. return null;
  14885. }
  14886. return SyncAsync.then(templateMeta, createDirectiveMetadata);
  14887. }
  14888. else {
  14889. // directive
  14890. createDirectiveMetadata(null);
  14891. return null;
  14892. }
  14893. };
  14894. /**
  14895. * @param {?} directiveType
  14896. * @return {?}
  14897. */
  14898. CompileMetadataResolver.prototype.getNonNormalizedDirectiveMetadata = /**
  14899. * @param {?} directiveType
  14900. * @return {?}
  14901. */
  14902. function (directiveType) {
  14903. var _this = this;
  14904. directiveType = resolveForwardRef(directiveType);
  14905. if (!directiveType) {
  14906. return null;
  14907. }
  14908. var /** @type {?} */ cacheEntry = this._nonNormalizedDirectiveCache.get(directiveType);
  14909. if (cacheEntry) {
  14910. return cacheEntry;
  14911. }
  14912. var /** @type {?} */ dirMeta = this._directiveResolver.resolve(directiveType, false);
  14913. if (!dirMeta) {
  14914. return null;
  14915. }
  14916. var /** @type {?} */ nonNormalizedTemplateMetadata = /** @type {?} */ ((undefined));
  14917. if (createComponent.isTypeOf(dirMeta)) {
  14918. // component
  14919. var /** @type {?} */ compMeta = /** @type {?} */ (dirMeta);
  14920. assertArrayOfStrings('styles', compMeta.styles);
  14921. assertArrayOfStrings('styleUrls', compMeta.styleUrls);
  14922. assertInterpolationSymbols('interpolation', compMeta.interpolation);
  14923. var /** @type {?} */ animations = compMeta.animations;
  14924. nonNormalizedTemplateMetadata = new CompileTemplateMetadata({
  14925. encapsulation: noUndefined(compMeta.encapsulation),
  14926. template: noUndefined(compMeta.template),
  14927. templateUrl: noUndefined(compMeta.templateUrl),
  14928. htmlAst: null,
  14929. styles: compMeta.styles || [],
  14930. styleUrls: compMeta.styleUrls || [],
  14931. animations: animations || [],
  14932. interpolation: noUndefined(compMeta.interpolation),
  14933. isInline: !!compMeta.template,
  14934. externalStylesheets: [],
  14935. ngContentSelectors: [],
  14936. preserveWhitespaces: noUndefined(dirMeta.preserveWhitespaces),
  14937. });
  14938. }
  14939. var /** @type {?} */ changeDetectionStrategy = /** @type {?} */ ((null));
  14940. var /** @type {?} */ viewProviders = [];
  14941. var /** @type {?} */ entryComponentMetadata = [];
  14942. var /** @type {?} */ selector = dirMeta.selector;
  14943. if (createComponent.isTypeOf(dirMeta)) {
  14944. // Component
  14945. var /** @type {?} */ compMeta = /** @type {?} */ (dirMeta);
  14946. changeDetectionStrategy = /** @type {?} */ ((compMeta.changeDetection));
  14947. if (compMeta.viewProviders) {
  14948. viewProviders = this._getProvidersMetadata(compMeta.viewProviders, entryComponentMetadata, "viewProviders for \"" + stringifyType(directiveType) + "\"", [], directiveType);
  14949. }
  14950. if (compMeta.entryComponents) {
  14951. entryComponentMetadata = flattenAndDedupeArray(compMeta.entryComponents)
  14952. .map(function (type) { return ((_this._getEntryComponentMetadata(type))); })
  14953. .concat(entryComponentMetadata);
  14954. }
  14955. if (!selector) {
  14956. selector = this._schemaRegistry.getDefaultComponentElementName();
  14957. }
  14958. }
  14959. else {
  14960. // Directive
  14961. if (!selector) {
  14962. this._reportError(syntaxError("Directive " + stringifyType(directiveType) + " has no selector, please add it!"), directiveType);
  14963. selector = 'error';
  14964. }
  14965. }
  14966. var /** @type {?} */ providers = [];
  14967. if (dirMeta.providers != null) {
  14968. providers = this._getProvidersMetadata(dirMeta.providers, entryComponentMetadata, "providers for \"" + stringifyType(directiveType) + "\"", [], directiveType);
  14969. }
  14970. var /** @type {?} */ queries = [];
  14971. var /** @type {?} */ viewQueries = [];
  14972. if (dirMeta.queries != null) {
  14973. queries = this._getQueriesMetadata(dirMeta.queries, false, directiveType);
  14974. viewQueries = this._getQueriesMetadata(dirMeta.queries, true, directiveType);
  14975. }
  14976. var /** @type {?} */ metadata = CompileDirectiveMetadata.create({
  14977. isHost: false,
  14978. selector: selector,
  14979. exportAs: noUndefined(dirMeta.exportAs),
  14980. isComponent: !!nonNormalizedTemplateMetadata,
  14981. type: this._getTypeMetadata(directiveType),
  14982. template: nonNormalizedTemplateMetadata,
  14983. changeDetection: changeDetectionStrategy,
  14984. inputs: dirMeta.inputs || [],
  14985. outputs: dirMeta.outputs || [],
  14986. host: dirMeta.host || {},
  14987. providers: providers || [],
  14988. viewProviders: viewProviders || [],
  14989. queries: queries || [],
  14990. guards: dirMeta.guards || {},
  14991. viewQueries: viewQueries || [],
  14992. entryComponents: entryComponentMetadata,
  14993. componentViewType: nonNormalizedTemplateMetadata ? this.getComponentViewClass(directiveType) :
  14994. null,
  14995. rendererType: nonNormalizedTemplateMetadata ? this.getRendererType(directiveType) : null,
  14996. componentFactory: null
  14997. });
  14998. if (nonNormalizedTemplateMetadata) {
  14999. metadata.componentFactory =
  15000. this.getComponentFactory(selector, directiveType, metadata.inputs, metadata.outputs);
  15001. }
  15002. cacheEntry = { metadata: metadata, annotation: dirMeta };
  15003. this._nonNormalizedDirectiveCache.set(directiveType, cacheEntry);
  15004. return cacheEntry;
  15005. };
  15006. /**
  15007. * Gets the metadata for the given directive.
  15008. * This assumes `loadNgModuleDirectiveAndPipeMetadata` has been called first.
  15009. */
  15010. /**
  15011. * Gets the metadata for the given directive.
  15012. * This assumes `loadNgModuleDirectiveAndPipeMetadata` has been called first.
  15013. * @param {?} directiveType
  15014. * @return {?}
  15015. */
  15016. CompileMetadataResolver.prototype.getDirectiveMetadata = /**
  15017. * Gets the metadata for the given directive.
  15018. * This assumes `loadNgModuleDirectiveAndPipeMetadata` has been called first.
  15019. * @param {?} directiveType
  15020. * @return {?}
  15021. */
  15022. function (directiveType) {
  15023. var /** @type {?} */ dirMeta = /** @type {?} */ ((this._directiveCache.get(directiveType)));
  15024. if (!dirMeta) {
  15025. this._reportError(syntaxError("Illegal state: getDirectiveMetadata can only be called after loadNgModuleDirectiveAndPipeMetadata for a module that declares it. Directive " + stringifyType(directiveType) + "."), directiveType);
  15026. }
  15027. return dirMeta;
  15028. };
  15029. /**
  15030. * @param {?} dirType
  15031. * @return {?}
  15032. */
  15033. CompileMetadataResolver.prototype.getDirectiveSummary = /**
  15034. * @param {?} dirType
  15035. * @return {?}
  15036. */
  15037. function (dirType) {
  15038. var /** @type {?} */ dirSummary = /** @type {?} */ (this._loadSummary(dirType, CompileSummaryKind.Directive));
  15039. if (!dirSummary) {
  15040. this._reportError(syntaxError("Illegal state: Could not load the summary for directive " + stringifyType(dirType) + "."), dirType);
  15041. }
  15042. return dirSummary;
  15043. };
  15044. /**
  15045. * @param {?} type
  15046. * @return {?}
  15047. */
  15048. CompileMetadataResolver.prototype.isDirective = /**
  15049. * @param {?} type
  15050. * @return {?}
  15051. */
  15052. function (type) {
  15053. return !!this._loadSummary(type, CompileSummaryKind.Directive) ||
  15054. this._directiveResolver.isDirective(type);
  15055. };
  15056. /**
  15057. * @param {?} type
  15058. * @return {?}
  15059. */
  15060. CompileMetadataResolver.prototype.isPipe = /**
  15061. * @param {?} type
  15062. * @return {?}
  15063. */
  15064. function (type) {
  15065. return !!this._loadSummary(type, CompileSummaryKind.Pipe) ||
  15066. this._pipeResolver.isPipe(type);
  15067. };
  15068. /**
  15069. * @param {?} type
  15070. * @return {?}
  15071. */
  15072. CompileMetadataResolver.prototype.isNgModule = /**
  15073. * @param {?} type
  15074. * @return {?}
  15075. */
  15076. function (type) {
  15077. return !!this._loadSummary(type, CompileSummaryKind.NgModule) ||
  15078. this._ngModuleResolver.isNgModule(type);
  15079. };
  15080. /**
  15081. * @param {?} moduleType
  15082. * @param {?=} alreadyCollecting
  15083. * @return {?}
  15084. */
  15085. CompileMetadataResolver.prototype.getNgModuleSummary = /**
  15086. * @param {?} moduleType
  15087. * @param {?=} alreadyCollecting
  15088. * @return {?}
  15089. */
  15090. function (moduleType, alreadyCollecting) {
  15091. if (alreadyCollecting === void 0) { alreadyCollecting = null; }
  15092. var /** @type {?} */ moduleSummary = /** @type {?} */ (this._loadSummary(moduleType, CompileSummaryKind.NgModule));
  15093. if (!moduleSummary) {
  15094. var /** @type {?} */ moduleMeta = this.getNgModuleMetadata(moduleType, false, alreadyCollecting);
  15095. moduleSummary = moduleMeta ? moduleMeta.toSummary() : null;
  15096. if (moduleSummary) {
  15097. this._summaryCache.set(moduleType, moduleSummary);
  15098. }
  15099. }
  15100. return moduleSummary;
  15101. };
  15102. /**
  15103. * Loads the declared directives and pipes of an NgModule.
  15104. */
  15105. /**
  15106. * Loads the declared directives and pipes of an NgModule.
  15107. * @param {?} moduleType
  15108. * @param {?} isSync
  15109. * @param {?=} throwIfNotFound
  15110. * @return {?}
  15111. */
  15112. CompileMetadataResolver.prototype.loadNgModuleDirectiveAndPipeMetadata = /**
  15113. * Loads the declared directives and pipes of an NgModule.
  15114. * @param {?} moduleType
  15115. * @param {?} isSync
  15116. * @param {?=} throwIfNotFound
  15117. * @return {?}
  15118. */
  15119. function (moduleType, isSync, throwIfNotFound) {
  15120. var _this = this;
  15121. if (throwIfNotFound === void 0) { throwIfNotFound = true; }
  15122. var /** @type {?} */ ngModule = this.getNgModuleMetadata(moduleType, throwIfNotFound);
  15123. var /** @type {?} */ loading = [];
  15124. if (ngModule) {
  15125. ngModule.declaredDirectives.forEach(function (id) {
  15126. var /** @type {?} */ promise = _this.loadDirectiveMetadata(moduleType, id.reference, isSync);
  15127. if (promise) {
  15128. loading.push(promise);
  15129. }
  15130. });
  15131. ngModule.declaredPipes.forEach(function (id) { return _this._loadPipeMetadata(id.reference); });
  15132. }
  15133. return Promise.all(loading);
  15134. };
  15135. /**
  15136. * @param {?} moduleType
  15137. * @param {?=} throwIfNotFound
  15138. * @param {?=} alreadyCollecting
  15139. * @return {?}
  15140. */
  15141. CompileMetadataResolver.prototype.getNgModuleMetadata = /**
  15142. * @param {?} moduleType
  15143. * @param {?=} throwIfNotFound
  15144. * @param {?=} alreadyCollecting
  15145. * @return {?}
  15146. */
  15147. function (moduleType, throwIfNotFound, alreadyCollecting) {
  15148. var _this = this;
  15149. if (throwIfNotFound === void 0) { throwIfNotFound = true; }
  15150. if (alreadyCollecting === void 0) { alreadyCollecting = null; }
  15151. moduleType = resolveForwardRef(moduleType);
  15152. var /** @type {?} */ compileMeta = this._ngModuleCache.get(moduleType);
  15153. if (compileMeta) {
  15154. return compileMeta;
  15155. }
  15156. var /** @type {?} */ meta = this._ngModuleResolver.resolve(moduleType, throwIfNotFound);
  15157. if (!meta) {
  15158. return null;
  15159. }
  15160. var /** @type {?} */ declaredDirectives = [];
  15161. var /** @type {?} */ exportedNonModuleIdentifiers = [];
  15162. var /** @type {?} */ declaredPipes = [];
  15163. var /** @type {?} */ importedModules = [];
  15164. var /** @type {?} */ exportedModules = [];
  15165. var /** @type {?} */ providers = [];
  15166. var /** @type {?} */ entryComponents = [];
  15167. var /** @type {?} */ bootstrapComponents = [];
  15168. var /** @type {?} */ schemas = [];
  15169. if (meta.imports) {
  15170. flattenAndDedupeArray(meta.imports).forEach(function (importedType) {
  15171. var /** @type {?} */ importedModuleType = /** @type {?} */ ((undefined));
  15172. if (isValidType(importedType)) {
  15173. importedModuleType = importedType;
  15174. }
  15175. else if (importedType && importedType.ngModule) {
  15176. var /** @type {?} */ moduleWithProviders = importedType;
  15177. importedModuleType = moduleWithProviders.ngModule;
  15178. if (moduleWithProviders.providers) {
  15179. providers.push.apply(providers, _this._getProvidersMetadata(moduleWithProviders.providers, entryComponents, "provider for the NgModule '" + stringifyType(importedModuleType) + "'", [], importedType));
  15180. }
  15181. }
  15182. if (importedModuleType) {
  15183. if (_this._checkSelfImport(moduleType, importedModuleType))
  15184. return;
  15185. if (!alreadyCollecting)
  15186. alreadyCollecting = new Set();
  15187. if (alreadyCollecting.has(importedModuleType)) {
  15188. _this._reportError(syntaxError(_this._getTypeDescriptor(importedModuleType) + " '" + stringifyType(importedType) + "' is imported recursively by the module '" + stringifyType(moduleType) + "'."), moduleType);
  15189. return;
  15190. }
  15191. alreadyCollecting.add(importedModuleType);
  15192. var /** @type {?} */ importedModuleSummary = _this.getNgModuleSummary(importedModuleType, alreadyCollecting);
  15193. alreadyCollecting.delete(importedModuleType);
  15194. if (!importedModuleSummary) {
  15195. _this._reportError(syntaxError("Unexpected " + _this._getTypeDescriptor(importedType) + " '" + stringifyType(importedType) + "' imported by the module '" + stringifyType(moduleType) + "'. Please add a @NgModule annotation."), moduleType);
  15196. return;
  15197. }
  15198. importedModules.push(importedModuleSummary);
  15199. }
  15200. else {
  15201. _this._reportError(syntaxError("Unexpected value '" + stringifyType(importedType) + "' imported by the module '" + stringifyType(moduleType) + "'"), moduleType);
  15202. return;
  15203. }
  15204. });
  15205. }
  15206. if (meta.exports) {
  15207. flattenAndDedupeArray(meta.exports).forEach(function (exportedType) {
  15208. if (!isValidType(exportedType)) {
  15209. _this._reportError(syntaxError("Unexpected value '" + stringifyType(exportedType) + "' exported by the module '" + stringifyType(moduleType) + "'"), moduleType);
  15210. return;
  15211. }
  15212. if (!alreadyCollecting)
  15213. alreadyCollecting = new Set();
  15214. if (alreadyCollecting.has(exportedType)) {
  15215. _this._reportError(syntaxError(_this._getTypeDescriptor(exportedType) + " '" + stringify(exportedType) + "' is exported recursively by the module '" + stringifyType(moduleType) + "'"), moduleType);
  15216. return;
  15217. }
  15218. alreadyCollecting.add(exportedType);
  15219. var /** @type {?} */ exportedModuleSummary = _this.getNgModuleSummary(exportedType, alreadyCollecting);
  15220. alreadyCollecting.delete(exportedType);
  15221. if (exportedModuleSummary) {
  15222. exportedModules.push(exportedModuleSummary);
  15223. }
  15224. else {
  15225. exportedNonModuleIdentifiers.push(_this._getIdentifierMetadata(exportedType));
  15226. }
  15227. });
  15228. }
  15229. // Note: This will be modified later, so we rely on
  15230. // getting a new instance every time!
  15231. var /** @type {?} */ transitiveModule = this._getTransitiveNgModuleMetadata(importedModules, exportedModules);
  15232. if (meta.declarations) {
  15233. flattenAndDedupeArray(meta.declarations).forEach(function (declaredType) {
  15234. if (!isValidType(declaredType)) {
  15235. _this._reportError(syntaxError("Unexpected value '" + stringifyType(declaredType) + "' declared by the module '" + stringifyType(moduleType) + "'"), moduleType);
  15236. return;
  15237. }
  15238. var /** @type {?} */ declaredIdentifier = _this._getIdentifierMetadata(declaredType);
  15239. if (_this.isDirective(declaredType)) {
  15240. transitiveModule.addDirective(declaredIdentifier);
  15241. declaredDirectives.push(declaredIdentifier);
  15242. _this._addTypeToModule(declaredType, moduleType);
  15243. }
  15244. else if (_this.isPipe(declaredType)) {
  15245. transitiveModule.addPipe(declaredIdentifier);
  15246. transitiveModule.pipes.push(declaredIdentifier);
  15247. declaredPipes.push(declaredIdentifier);
  15248. _this._addTypeToModule(declaredType, moduleType);
  15249. }
  15250. else {
  15251. _this._reportError(syntaxError("Unexpected " + _this._getTypeDescriptor(declaredType) + " '" + stringifyType(declaredType) + "' declared by the module '" + stringifyType(moduleType) + "'. Please add a @Pipe/@Directive/@Component annotation."), moduleType);
  15252. return;
  15253. }
  15254. });
  15255. }
  15256. var /** @type {?} */ exportedDirectives = [];
  15257. var /** @type {?} */ exportedPipes = [];
  15258. exportedNonModuleIdentifiers.forEach(function (exportedId) {
  15259. if (transitiveModule.directivesSet.has(exportedId.reference)) {
  15260. exportedDirectives.push(exportedId);
  15261. transitiveModule.addExportedDirective(exportedId);
  15262. }
  15263. else if (transitiveModule.pipesSet.has(exportedId.reference)) {
  15264. exportedPipes.push(exportedId);
  15265. transitiveModule.addExportedPipe(exportedId);
  15266. }
  15267. else {
  15268. _this._reportError(syntaxError("Can't export " + _this._getTypeDescriptor(exportedId.reference) + " " + stringifyType(exportedId.reference) + " from " + stringifyType(moduleType) + " as it was neither declared nor imported!"), moduleType);
  15269. return;
  15270. }
  15271. });
  15272. // The providers of the module have to go last
  15273. // so that they overwrite any other provider we already added.
  15274. if (meta.providers) {
  15275. providers.push.apply(providers, this._getProvidersMetadata(meta.providers, entryComponents, "provider for the NgModule '" + stringifyType(moduleType) + "'", [], moduleType));
  15276. }
  15277. if (meta.entryComponents) {
  15278. entryComponents.push.apply(entryComponents, flattenAndDedupeArray(meta.entryComponents)
  15279. .map(function (type) { return ((_this._getEntryComponentMetadata(type))); }));
  15280. }
  15281. if (meta.bootstrap) {
  15282. flattenAndDedupeArray(meta.bootstrap).forEach(function (type) {
  15283. if (!isValidType(type)) {
  15284. _this._reportError(syntaxError("Unexpected value '" + stringifyType(type) + "' used in the bootstrap property of module '" + stringifyType(moduleType) + "'"), moduleType);
  15285. return;
  15286. }
  15287. bootstrapComponents.push(_this._getIdentifierMetadata(type));
  15288. });
  15289. }
  15290. entryComponents.push.apply(entryComponents, bootstrapComponents.map(function (type) { return ((_this._getEntryComponentMetadata(type.reference))); }));
  15291. if (meta.schemas) {
  15292. schemas.push.apply(schemas, flattenAndDedupeArray(meta.schemas));
  15293. }
  15294. compileMeta = new CompileNgModuleMetadata({
  15295. type: this._getTypeMetadata(moduleType),
  15296. providers: providers,
  15297. entryComponents: entryComponents,
  15298. bootstrapComponents: bootstrapComponents,
  15299. schemas: schemas,
  15300. declaredDirectives: declaredDirectives,
  15301. exportedDirectives: exportedDirectives,
  15302. declaredPipes: declaredPipes,
  15303. exportedPipes: exportedPipes,
  15304. importedModules: importedModules,
  15305. exportedModules: exportedModules,
  15306. transitiveModule: transitiveModule,
  15307. id: meta.id || null,
  15308. });
  15309. entryComponents.forEach(function (id) { return transitiveModule.addEntryComponent(id); });
  15310. providers.forEach(function (provider) { return transitiveModule.addProvider(provider, /** @type {?} */ ((compileMeta)).type); });
  15311. transitiveModule.addModule(compileMeta.type);
  15312. this._ngModuleCache.set(moduleType, compileMeta);
  15313. return compileMeta;
  15314. };
  15315. /**
  15316. * @param {?} moduleType
  15317. * @param {?} importedModuleType
  15318. * @return {?}
  15319. */
  15320. CompileMetadataResolver.prototype._checkSelfImport = /**
  15321. * @param {?} moduleType
  15322. * @param {?} importedModuleType
  15323. * @return {?}
  15324. */
  15325. function (moduleType, importedModuleType) {
  15326. if (moduleType === importedModuleType) {
  15327. this._reportError(syntaxError("'" + stringifyType(moduleType) + "' module can't import itself"), moduleType);
  15328. return true;
  15329. }
  15330. return false;
  15331. };
  15332. /**
  15333. * @param {?} type
  15334. * @return {?}
  15335. */
  15336. CompileMetadataResolver.prototype._getTypeDescriptor = /**
  15337. * @param {?} type
  15338. * @return {?}
  15339. */
  15340. function (type) {
  15341. if (isValidType(type)) {
  15342. if (this.isDirective(type)) {
  15343. return 'directive';
  15344. }
  15345. if (this.isPipe(type)) {
  15346. return 'pipe';
  15347. }
  15348. if (this.isNgModule(type)) {
  15349. return 'module';
  15350. }
  15351. }
  15352. if ((/** @type {?} */ (type)).provide) {
  15353. return 'provider';
  15354. }
  15355. return 'value';
  15356. };
  15357. /**
  15358. * @param {?} type
  15359. * @param {?} moduleType
  15360. * @return {?}
  15361. */
  15362. CompileMetadataResolver.prototype._addTypeToModule = /**
  15363. * @param {?} type
  15364. * @param {?} moduleType
  15365. * @return {?}
  15366. */
  15367. function (type, moduleType) {
  15368. var /** @type {?} */ oldModule = this._ngModuleOfTypes.get(type);
  15369. if (oldModule && oldModule !== moduleType) {
  15370. this._reportError(syntaxError("Type " + stringifyType(type) + " is part of the declarations of 2 modules: " + stringifyType(oldModule) + " and " + stringifyType(moduleType) + "! " +
  15371. ("Please consider moving " + stringifyType(type) + " to a higher module that imports " + stringifyType(oldModule) + " and " + stringifyType(moduleType) + ". ") +
  15372. ("You can also create a new NgModule that exports and includes " + stringifyType(type) + " then import that NgModule in " + stringifyType(oldModule) + " and " + stringifyType(moduleType) + ".")), moduleType);
  15373. return;
  15374. }
  15375. this._ngModuleOfTypes.set(type, moduleType);
  15376. };
  15377. /**
  15378. * @param {?} importedModules
  15379. * @param {?} exportedModules
  15380. * @return {?}
  15381. */
  15382. CompileMetadataResolver.prototype._getTransitiveNgModuleMetadata = /**
  15383. * @param {?} importedModules
  15384. * @param {?} exportedModules
  15385. * @return {?}
  15386. */
  15387. function (importedModules, exportedModules) {
  15388. // collect `providers` / `entryComponents` from all imported and all exported modules
  15389. var /** @type {?} */ result = new TransitiveCompileNgModuleMetadata();
  15390. var /** @type {?} */ modulesByToken = new Map();
  15391. importedModules.concat(exportedModules).forEach(function (modSummary) {
  15392. modSummary.modules.forEach(function (mod) { return result.addModule(mod); });
  15393. modSummary.entryComponents.forEach(function (comp) { return result.addEntryComponent(comp); });
  15394. var /** @type {?} */ addedTokens = new Set();
  15395. modSummary.providers.forEach(function (entry) {
  15396. var /** @type {?} */ tokenRef = tokenReference(entry.provider.token);
  15397. var /** @type {?} */ prevModules = modulesByToken.get(tokenRef);
  15398. if (!prevModules) {
  15399. prevModules = new Set();
  15400. modulesByToken.set(tokenRef, prevModules);
  15401. }
  15402. var /** @type {?} */ moduleRef = entry.module.reference;
  15403. // Note: the providers of one module may still contain multiple providers
  15404. // per token (e.g. for multi providers), and we need to preserve these.
  15405. if (addedTokens.has(tokenRef) || !prevModules.has(moduleRef)) {
  15406. prevModules.add(moduleRef);
  15407. addedTokens.add(tokenRef);
  15408. result.addProvider(entry.provider, entry.module);
  15409. }
  15410. });
  15411. });
  15412. exportedModules.forEach(function (modSummary) {
  15413. modSummary.exportedDirectives.forEach(function (id) { return result.addExportedDirective(id); });
  15414. modSummary.exportedPipes.forEach(function (id) { return result.addExportedPipe(id); });
  15415. });
  15416. importedModules.forEach(function (modSummary) {
  15417. modSummary.exportedDirectives.forEach(function (id) { return result.addDirective(id); });
  15418. modSummary.exportedPipes.forEach(function (id) { return result.addPipe(id); });
  15419. });
  15420. return result;
  15421. };
  15422. /**
  15423. * @param {?} type
  15424. * @return {?}
  15425. */
  15426. CompileMetadataResolver.prototype._getIdentifierMetadata = /**
  15427. * @param {?} type
  15428. * @return {?}
  15429. */
  15430. function (type) {
  15431. type = resolveForwardRef(type);
  15432. return { reference: type };
  15433. };
  15434. /**
  15435. * @param {?} type
  15436. * @return {?}
  15437. */
  15438. CompileMetadataResolver.prototype.isInjectable = /**
  15439. * @param {?} type
  15440. * @return {?}
  15441. */
  15442. function (type) {
  15443. var /** @type {?} */ annotations = this._reflector.annotations(type);
  15444. return annotations.some(function (ann) { return createInjectable.isTypeOf(ann); });
  15445. };
  15446. /**
  15447. * @param {?} type
  15448. * @return {?}
  15449. */
  15450. CompileMetadataResolver.prototype.getInjectableSummary = /**
  15451. * @param {?} type
  15452. * @return {?}
  15453. */
  15454. function (type) {
  15455. return {
  15456. summaryKind: CompileSummaryKind.Injectable,
  15457. type: this._getTypeMetadata(type, null, false)
  15458. };
  15459. };
  15460. /**
  15461. * @param {?} type
  15462. * @param {?=} dependencies
  15463. * @return {?}
  15464. */
  15465. CompileMetadataResolver.prototype._getInjectableMetadata = /**
  15466. * @param {?} type
  15467. * @param {?=} dependencies
  15468. * @return {?}
  15469. */
  15470. function (type, dependencies) {
  15471. if (dependencies === void 0) { dependencies = null; }
  15472. var /** @type {?} */ typeSummary = this._loadSummary(type, CompileSummaryKind.Injectable);
  15473. if (typeSummary) {
  15474. return typeSummary.type;
  15475. }
  15476. return this._getTypeMetadata(type, dependencies);
  15477. };
  15478. /**
  15479. * @param {?} type
  15480. * @param {?=} dependencies
  15481. * @param {?=} throwOnUnknownDeps
  15482. * @return {?}
  15483. */
  15484. CompileMetadataResolver.prototype._getTypeMetadata = /**
  15485. * @param {?} type
  15486. * @param {?=} dependencies
  15487. * @param {?=} throwOnUnknownDeps
  15488. * @return {?}
  15489. */
  15490. function (type, dependencies, throwOnUnknownDeps) {
  15491. if (dependencies === void 0) { dependencies = null; }
  15492. if (throwOnUnknownDeps === void 0) { throwOnUnknownDeps = true; }
  15493. var /** @type {?} */ identifier = this._getIdentifierMetadata(type);
  15494. return {
  15495. reference: identifier.reference,
  15496. diDeps: this._getDependenciesMetadata(identifier.reference, dependencies, throwOnUnknownDeps),
  15497. lifecycleHooks: getAllLifecycleHooks(this._reflector, identifier.reference),
  15498. };
  15499. };
  15500. /**
  15501. * @param {?} factory
  15502. * @param {?=} dependencies
  15503. * @return {?}
  15504. */
  15505. CompileMetadataResolver.prototype._getFactoryMetadata = /**
  15506. * @param {?} factory
  15507. * @param {?=} dependencies
  15508. * @return {?}
  15509. */
  15510. function (factory, dependencies) {
  15511. if (dependencies === void 0) { dependencies = null; }
  15512. factory = resolveForwardRef(factory);
  15513. return { reference: factory, diDeps: this._getDependenciesMetadata(factory, dependencies) };
  15514. };
  15515. /**
  15516. * Gets the metadata for the given pipe.
  15517. * This assumes `loadNgModuleDirectiveAndPipeMetadata` has been called first.
  15518. */
  15519. /**
  15520. * Gets the metadata for the given pipe.
  15521. * This assumes `loadNgModuleDirectiveAndPipeMetadata` has been called first.
  15522. * @param {?} pipeType
  15523. * @return {?}
  15524. */
  15525. CompileMetadataResolver.prototype.getPipeMetadata = /**
  15526. * Gets the metadata for the given pipe.
  15527. * This assumes `loadNgModuleDirectiveAndPipeMetadata` has been called first.
  15528. * @param {?} pipeType
  15529. * @return {?}
  15530. */
  15531. function (pipeType) {
  15532. var /** @type {?} */ pipeMeta = this._pipeCache.get(pipeType);
  15533. if (!pipeMeta) {
  15534. this._reportError(syntaxError("Illegal state: getPipeMetadata can only be called after loadNgModuleDirectiveAndPipeMetadata for a module that declares it. Pipe " + stringifyType(pipeType) + "."), pipeType);
  15535. }
  15536. return pipeMeta || null;
  15537. };
  15538. /**
  15539. * @param {?} pipeType
  15540. * @return {?}
  15541. */
  15542. CompileMetadataResolver.prototype.getPipeSummary = /**
  15543. * @param {?} pipeType
  15544. * @return {?}
  15545. */
  15546. function (pipeType) {
  15547. var /** @type {?} */ pipeSummary = /** @type {?} */ (this._loadSummary(pipeType, CompileSummaryKind.Pipe));
  15548. if (!pipeSummary) {
  15549. this._reportError(syntaxError("Illegal state: Could not load the summary for pipe " + stringifyType(pipeType) + "."), pipeType);
  15550. }
  15551. return pipeSummary;
  15552. };
  15553. /**
  15554. * @param {?} pipeType
  15555. * @return {?}
  15556. */
  15557. CompileMetadataResolver.prototype.getOrLoadPipeMetadata = /**
  15558. * @param {?} pipeType
  15559. * @return {?}
  15560. */
  15561. function (pipeType) {
  15562. var /** @type {?} */ pipeMeta = this._pipeCache.get(pipeType);
  15563. if (!pipeMeta) {
  15564. pipeMeta = this._loadPipeMetadata(pipeType);
  15565. }
  15566. return pipeMeta;
  15567. };
  15568. /**
  15569. * @param {?} pipeType
  15570. * @return {?}
  15571. */
  15572. CompileMetadataResolver.prototype._loadPipeMetadata = /**
  15573. * @param {?} pipeType
  15574. * @return {?}
  15575. */
  15576. function (pipeType) {
  15577. pipeType = resolveForwardRef(pipeType);
  15578. var /** @type {?} */ pipeAnnotation = /** @type {?} */ ((this._pipeResolver.resolve(pipeType)));
  15579. var /** @type {?} */ pipeMeta = new CompilePipeMetadata({
  15580. type: this._getTypeMetadata(pipeType),
  15581. name: pipeAnnotation.name,
  15582. pure: !!pipeAnnotation.pure
  15583. });
  15584. this._pipeCache.set(pipeType, pipeMeta);
  15585. this._summaryCache.set(pipeType, pipeMeta.toSummary());
  15586. return pipeMeta;
  15587. };
  15588. /**
  15589. * @param {?} typeOrFunc
  15590. * @param {?} dependencies
  15591. * @param {?=} throwOnUnknownDeps
  15592. * @return {?}
  15593. */
  15594. CompileMetadataResolver.prototype._getDependenciesMetadata = /**
  15595. * @param {?} typeOrFunc
  15596. * @param {?} dependencies
  15597. * @param {?=} throwOnUnknownDeps
  15598. * @return {?}
  15599. */
  15600. function (typeOrFunc, dependencies, throwOnUnknownDeps) {
  15601. var _this = this;
  15602. if (throwOnUnknownDeps === void 0) { throwOnUnknownDeps = true; }
  15603. var /** @type {?} */ hasUnknownDeps = false;
  15604. var /** @type {?} */ params = dependencies || this._reflector.parameters(typeOrFunc) || [];
  15605. var /** @type {?} */ dependenciesMetadata = params.map(function (param) {
  15606. var /** @type {?} */ isAttribute = false;
  15607. var /** @type {?} */ isHost = false;
  15608. var /** @type {?} */ isSelf = false;
  15609. var /** @type {?} */ isSkipSelf = false;
  15610. var /** @type {?} */ isOptional = false;
  15611. var /** @type {?} */ token = null;
  15612. if (Array.isArray(param)) {
  15613. param.forEach(function (paramEntry) {
  15614. if (createHost.isTypeOf(paramEntry)) {
  15615. isHost = true;
  15616. }
  15617. else if (createSelf.isTypeOf(paramEntry)) {
  15618. isSelf = true;
  15619. }
  15620. else if (createSkipSelf.isTypeOf(paramEntry)) {
  15621. isSkipSelf = true;
  15622. }
  15623. else if (createOptional.isTypeOf(paramEntry)) {
  15624. isOptional = true;
  15625. }
  15626. else if (createAttribute.isTypeOf(paramEntry)) {
  15627. isAttribute = true;
  15628. token = paramEntry.attributeName;
  15629. }
  15630. else if (createInject.isTypeOf(paramEntry)) {
  15631. token = paramEntry.token;
  15632. }
  15633. else if (createInjectionToken.isTypeOf(paramEntry) || paramEntry instanceof StaticSymbol) {
  15634. token = paramEntry;
  15635. }
  15636. else if (isValidType(paramEntry) && token == null) {
  15637. token = paramEntry;
  15638. }
  15639. });
  15640. }
  15641. else {
  15642. token = param;
  15643. }
  15644. if (token == null) {
  15645. hasUnknownDeps = true;
  15646. return /** @type {?} */ ((null));
  15647. }
  15648. return {
  15649. isAttribute: isAttribute,
  15650. isHost: isHost,
  15651. isSelf: isSelf,
  15652. isSkipSelf: isSkipSelf,
  15653. isOptional: isOptional,
  15654. token: _this._getTokenMetadata(token)
  15655. };
  15656. });
  15657. if (hasUnknownDeps) {
  15658. var /** @type {?} */ depsTokens = dependenciesMetadata.map(function (dep) { return dep ? stringifyType(dep.token) : '?'; }).join(', ');
  15659. var /** @type {?} */ message = "Can't resolve all parameters for " + stringifyType(typeOrFunc) + ": (" + depsTokens + ").";
  15660. if (throwOnUnknownDeps || this._config.strictInjectionParameters) {
  15661. this._reportError(syntaxError(message), typeOrFunc);
  15662. }
  15663. else {
  15664. this._console.warn("Warning: " + message + " This will become an error in Angular v6.x");
  15665. }
  15666. }
  15667. return dependenciesMetadata;
  15668. };
  15669. /**
  15670. * @param {?} token
  15671. * @return {?}
  15672. */
  15673. CompileMetadataResolver.prototype._getTokenMetadata = /**
  15674. * @param {?} token
  15675. * @return {?}
  15676. */
  15677. function (token) {
  15678. token = resolveForwardRef(token);
  15679. var /** @type {?} */ compileToken;
  15680. if (typeof token === 'string') {
  15681. compileToken = { value: token };
  15682. }
  15683. else {
  15684. compileToken = { identifier: { reference: token } };
  15685. }
  15686. return compileToken;
  15687. };
  15688. /**
  15689. * @param {?} providers
  15690. * @param {?} targetEntryComponents
  15691. * @param {?=} debugInfo
  15692. * @param {?=} compileProviders
  15693. * @param {?=} type
  15694. * @return {?}
  15695. */
  15696. CompileMetadataResolver.prototype._getProvidersMetadata = /**
  15697. * @param {?} providers
  15698. * @param {?} targetEntryComponents
  15699. * @param {?=} debugInfo
  15700. * @param {?=} compileProviders
  15701. * @param {?=} type
  15702. * @return {?}
  15703. */
  15704. function (providers, targetEntryComponents, debugInfo, compileProviders, type) {
  15705. var _this = this;
  15706. if (compileProviders === void 0) { compileProviders = []; }
  15707. providers.forEach(function (provider, providerIdx) {
  15708. if (Array.isArray(provider)) {
  15709. _this._getProvidersMetadata(provider, targetEntryComponents, debugInfo, compileProviders);
  15710. }
  15711. else {
  15712. provider = resolveForwardRef(provider);
  15713. var /** @type {?} */ providerMeta = /** @type {?} */ ((undefined));
  15714. if (provider && typeof provider === 'object' && provider.hasOwnProperty('provide')) {
  15715. _this._validateProvider(provider);
  15716. providerMeta = new ProviderMeta(provider.provide, provider);
  15717. }
  15718. else if (isValidType(provider)) {
  15719. providerMeta = new ProviderMeta(provider, { useClass: provider });
  15720. }
  15721. else if (provider === void 0) {
  15722. _this._reportError(syntaxError("Encountered undefined provider! Usually this means you have a circular dependencies (might be caused by using 'barrel' index.ts files."));
  15723. return;
  15724. }
  15725. else {
  15726. var /** @type {?} */ providersInfo = (/** @type {?} */ (providers.reduce(function (soFar, seenProvider, seenProviderIdx) {
  15727. if (seenProviderIdx < providerIdx) {
  15728. soFar.push("" + stringifyType(seenProvider));
  15729. }
  15730. else if (seenProviderIdx == providerIdx) {
  15731. soFar.push("?" + stringifyType(seenProvider) + "?");
  15732. }
  15733. else if (seenProviderIdx == providerIdx + 1) {
  15734. soFar.push('...');
  15735. }
  15736. return soFar;
  15737. }, [])))
  15738. .join(', ');
  15739. _this._reportError(syntaxError("Invalid " + (debugInfo ? debugInfo : 'provider') + " - only instances of Provider and Type are allowed, got: [" + providersInfo + "]"), type);
  15740. return;
  15741. }
  15742. if (providerMeta.token ===
  15743. _this._reflector.resolveExternalReference(Identifiers.ANALYZE_FOR_ENTRY_COMPONENTS)) {
  15744. targetEntryComponents.push.apply(targetEntryComponents, _this._getEntryComponentsFromProvider(providerMeta, type));
  15745. }
  15746. else {
  15747. compileProviders.push(_this.getProviderMetadata(providerMeta));
  15748. }
  15749. }
  15750. });
  15751. return compileProviders;
  15752. };
  15753. /**
  15754. * @param {?} provider
  15755. * @return {?}
  15756. */
  15757. CompileMetadataResolver.prototype._validateProvider = /**
  15758. * @param {?} provider
  15759. * @return {?}
  15760. */
  15761. function (provider) {
  15762. if (provider.hasOwnProperty('useClass') && provider.useClass == null) {
  15763. 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."));
  15764. }
  15765. };
  15766. /**
  15767. * @param {?} provider
  15768. * @param {?=} type
  15769. * @return {?}
  15770. */
  15771. CompileMetadataResolver.prototype._getEntryComponentsFromProvider = /**
  15772. * @param {?} provider
  15773. * @param {?=} type
  15774. * @return {?}
  15775. */
  15776. function (provider, type) {
  15777. var _this = this;
  15778. var /** @type {?} */ components = [];
  15779. var /** @type {?} */ collectedIdentifiers = [];
  15780. if (provider.useFactory || provider.useExisting || provider.useClass) {
  15781. this._reportError(syntaxError("The ANALYZE_FOR_ENTRY_COMPONENTS token only supports useValue!"), type);
  15782. return [];
  15783. }
  15784. if (!provider.multi) {
  15785. this._reportError(syntaxError("The ANALYZE_FOR_ENTRY_COMPONENTS token only supports 'multi = true'!"), type);
  15786. return [];
  15787. }
  15788. extractIdentifiers(provider.useValue, collectedIdentifiers);
  15789. collectedIdentifiers.forEach(function (identifier) {
  15790. var /** @type {?} */ entry = _this._getEntryComponentMetadata(identifier.reference, false);
  15791. if (entry) {
  15792. components.push(entry);
  15793. }
  15794. });
  15795. return components;
  15796. };
  15797. /**
  15798. * @param {?} dirType
  15799. * @param {?=} throwIfNotFound
  15800. * @return {?}
  15801. */
  15802. CompileMetadataResolver.prototype._getEntryComponentMetadata = /**
  15803. * @param {?} dirType
  15804. * @param {?=} throwIfNotFound
  15805. * @return {?}
  15806. */
  15807. function (dirType, throwIfNotFound) {
  15808. if (throwIfNotFound === void 0) { throwIfNotFound = true; }
  15809. var /** @type {?} */ dirMeta = this.getNonNormalizedDirectiveMetadata(dirType);
  15810. if (dirMeta && dirMeta.metadata.isComponent) {
  15811. return { componentType: dirType, componentFactory: /** @type {?} */ ((dirMeta.metadata.componentFactory)) };
  15812. }
  15813. var /** @type {?} */ dirSummary = /** @type {?} */ (this._loadSummary(dirType, CompileSummaryKind.Directive));
  15814. if (dirSummary && dirSummary.isComponent) {
  15815. return { componentType: dirType, componentFactory: /** @type {?} */ ((dirSummary.componentFactory)) };
  15816. }
  15817. if (throwIfNotFound) {
  15818. throw syntaxError(dirType.name + " cannot be used as an entry component.");
  15819. }
  15820. return null;
  15821. };
  15822. /**
  15823. * @param {?} provider
  15824. * @return {?}
  15825. */
  15826. CompileMetadataResolver.prototype.getProviderMetadata = /**
  15827. * @param {?} provider
  15828. * @return {?}
  15829. */
  15830. function (provider) {
  15831. var /** @type {?} */ compileDeps = /** @type {?} */ ((undefined));
  15832. var /** @type {?} */ compileTypeMetadata = /** @type {?} */ ((null));
  15833. var /** @type {?} */ compileFactoryMetadata = /** @type {?} */ ((null));
  15834. var /** @type {?} */ token = this._getTokenMetadata(provider.token);
  15835. if (provider.useClass) {
  15836. compileTypeMetadata = this._getInjectableMetadata(provider.useClass, provider.dependencies);
  15837. compileDeps = compileTypeMetadata.diDeps;
  15838. if (provider.token === provider.useClass) {
  15839. // use the compileTypeMetadata as it contains information about lifecycleHooks...
  15840. token = { identifier: compileTypeMetadata };
  15841. }
  15842. }
  15843. else if (provider.useFactory) {
  15844. compileFactoryMetadata = this._getFactoryMetadata(provider.useFactory, provider.dependencies);
  15845. compileDeps = compileFactoryMetadata.diDeps;
  15846. }
  15847. return {
  15848. token: token,
  15849. useClass: compileTypeMetadata,
  15850. useValue: provider.useValue,
  15851. useFactory: compileFactoryMetadata,
  15852. useExisting: provider.useExisting ? this._getTokenMetadata(provider.useExisting) : undefined,
  15853. deps: compileDeps,
  15854. multi: provider.multi
  15855. };
  15856. };
  15857. /**
  15858. * @param {?} queries
  15859. * @param {?} isViewQuery
  15860. * @param {?} directiveType
  15861. * @return {?}
  15862. */
  15863. CompileMetadataResolver.prototype._getQueriesMetadata = /**
  15864. * @param {?} queries
  15865. * @param {?} isViewQuery
  15866. * @param {?} directiveType
  15867. * @return {?}
  15868. */
  15869. function (queries, isViewQuery, directiveType) {
  15870. var _this = this;
  15871. var /** @type {?} */ res = [];
  15872. Object.keys(queries).forEach(function (propertyName) {
  15873. var /** @type {?} */ query = queries[propertyName];
  15874. if (query.isViewQuery === isViewQuery) {
  15875. res.push(_this._getQueryMetadata(query, propertyName, directiveType));
  15876. }
  15877. });
  15878. return res;
  15879. };
  15880. /**
  15881. * @param {?} selector
  15882. * @return {?}
  15883. */
  15884. CompileMetadataResolver.prototype._queryVarBindings = /**
  15885. * @param {?} selector
  15886. * @return {?}
  15887. */
  15888. function (selector) { return selector.split(/\s*,\s*/); };
  15889. /**
  15890. * @param {?} q
  15891. * @param {?} propertyName
  15892. * @param {?} typeOrFunc
  15893. * @return {?}
  15894. */
  15895. CompileMetadataResolver.prototype._getQueryMetadata = /**
  15896. * @param {?} q
  15897. * @param {?} propertyName
  15898. * @param {?} typeOrFunc
  15899. * @return {?}
  15900. */
  15901. function (q, propertyName, typeOrFunc) {
  15902. var _this = this;
  15903. var /** @type {?} */ selectors;
  15904. if (typeof q.selector === 'string') {
  15905. selectors =
  15906. this._queryVarBindings(q.selector).map(function (varName) { return _this._getTokenMetadata(varName); });
  15907. }
  15908. else {
  15909. if (!q.selector) {
  15910. this._reportError(syntaxError("Can't construct a query for the property \"" + propertyName + "\" of \"" + stringifyType(typeOrFunc) + "\" since the query selector wasn't defined."), typeOrFunc);
  15911. selectors = [];
  15912. }
  15913. else {
  15914. selectors = [this._getTokenMetadata(q.selector)];
  15915. }
  15916. }
  15917. return {
  15918. selectors: selectors,
  15919. first: q.first,
  15920. descendants: q.descendants, propertyName: propertyName,
  15921. read: q.read ? this._getTokenMetadata(q.read) : /** @type {?} */ ((null))
  15922. };
  15923. };
  15924. /**
  15925. * @param {?} error
  15926. * @param {?=} type
  15927. * @param {?=} otherType
  15928. * @return {?}
  15929. */
  15930. CompileMetadataResolver.prototype._reportError = /**
  15931. * @param {?} error
  15932. * @param {?=} type
  15933. * @param {?=} otherType
  15934. * @return {?}
  15935. */
  15936. function (error, type, otherType) {
  15937. if (this._errorCollector) {
  15938. this._errorCollector(error, type);
  15939. if (otherType) {
  15940. this._errorCollector(error, otherType);
  15941. }
  15942. }
  15943. else {
  15944. throw error;
  15945. }
  15946. };
  15947. return CompileMetadataResolver;
  15948. }());
  15949. /**
  15950. * @param {?} tree
  15951. * @param {?=} out
  15952. * @return {?}
  15953. */
  15954. function flattenArray(tree, out) {
  15955. if (out === void 0) { out = []; }
  15956. if (tree) {
  15957. for (var /** @type {?} */ i = 0; i < tree.length; i++) {
  15958. var /** @type {?} */ item = resolveForwardRef(tree[i]);
  15959. if (Array.isArray(item)) {
  15960. flattenArray(item, out);
  15961. }
  15962. else {
  15963. out.push(item);
  15964. }
  15965. }
  15966. }
  15967. return out;
  15968. }
  15969. /**
  15970. * @param {?} array
  15971. * @return {?}
  15972. */
  15973. function dedupeArray(array) {
  15974. if (array) {
  15975. return Array.from(new Set(array));
  15976. }
  15977. return [];
  15978. }
  15979. /**
  15980. * @param {?} tree
  15981. * @return {?}
  15982. */
  15983. function flattenAndDedupeArray(tree) {
  15984. return dedupeArray(flattenArray(tree));
  15985. }
  15986. /**
  15987. * @param {?} value
  15988. * @return {?}
  15989. */
  15990. function isValidType(value) {
  15991. return (value instanceof StaticSymbol) || (value instanceof Type);
  15992. }
  15993. /**
  15994. * @param {?} value
  15995. * @param {?} targetIdentifiers
  15996. * @return {?}
  15997. */
  15998. function extractIdentifiers(value, targetIdentifiers) {
  15999. visitValue(value, new _CompileValueConverter(), targetIdentifiers);
  16000. }
  16001. var _CompileValueConverter = /** @class */ (function (_super) {
  16002. __extends(_CompileValueConverter, _super);
  16003. function _CompileValueConverter() {
  16004. return _super !== null && _super.apply(this, arguments) || this;
  16005. }
  16006. /**
  16007. * @param {?} value
  16008. * @param {?} targetIdentifiers
  16009. * @return {?}
  16010. */
  16011. _CompileValueConverter.prototype.visitOther = /**
  16012. * @param {?} value
  16013. * @param {?} targetIdentifiers
  16014. * @return {?}
  16015. */
  16016. function (value, targetIdentifiers) {
  16017. targetIdentifiers.push({ reference: value });
  16018. };
  16019. return _CompileValueConverter;
  16020. }(ValueTransformer));
  16021. /**
  16022. * @param {?} type
  16023. * @return {?}
  16024. */
  16025. function stringifyType(type) {
  16026. if (type instanceof StaticSymbol) {
  16027. return type.name + " in " + type.filePath;
  16028. }
  16029. else {
  16030. return stringify(type);
  16031. }
  16032. }
  16033. /**
  16034. * Indicates that a component is still being loaded in a synchronous compile.
  16035. * @param {?} compType
  16036. * @return {?}
  16037. */
  16038. function componentStillLoadingError(compType) {
  16039. var /** @type {?} */ error = Error("Can't compile synchronously as " + stringify(compType) + " is still being loaded!");
  16040. (/** @type {?} */ (error))[ERROR_COMPONENT_TYPE] = compType;
  16041. return error;
  16042. }
  16043. /**
  16044. * @fileoverview added by tsickle
  16045. * @suppress {checkTypes} checked by tsc
  16046. */
  16047. /**
  16048. * @license
  16049. * Copyright Google Inc. All Rights Reserved.
  16050. *
  16051. * Use of this source code is governed by an MIT-style license that can be
  16052. * found in the LICENSE file at https://angular.io/license
  16053. */
  16054. /** @enum {number} */
  16055. var TypeModifier = {
  16056. Const: 0,
  16057. };
  16058. TypeModifier[TypeModifier.Const] = "Const";
  16059. /**
  16060. * @abstract
  16061. */
  16062. var Type$1 = /** @class */ (function () {
  16063. function Type(modifiers) {
  16064. if (modifiers === void 0) { modifiers = null; }
  16065. this.modifiers = modifiers;
  16066. if (!modifiers) {
  16067. this.modifiers = [];
  16068. }
  16069. }
  16070. /**
  16071. * @param {?} modifier
  16072. * @return {?}
  16073. */
  16074. Type.prototype.hasModifier = /**
  16075. * @param {?} modifier
  16076. * @return {?}
  16077. */
  16078. function (modifier) { return /** @type {?} */ ((this.modifiers)).indexOf(modifier) !== -1; };
  16079. return Type;
  16080. }());
  16081. /** @enum {number} */
  16082. var BuiltinTypeName = {
  16083. Dynamic: 0,
  16084. Bool: 1,
  16085. String: 2,
  16086. Int: 3,
  16087. Number: 4,
  16088. Function: 5,
  16089. Inferred: 6,
  16090. };
  16091. BuiltinTypeName[BuiltinTypeName.Dynamic] = "Dynamic";
  16092. BuiltinTypeName[BuiltinTypeName.Bool] = "Bool";
  16093. BuiltinTypeName[BuiltinTypeName.String] = "String";
  16094. BuiltinTypeName[BuiltinTypeName.Int] = "Int";
  16095. BuiltinTypeName[BuiltinTypeName.Number] = "Number";
  16096. BuiltinTypeName[BuiltinTypeName.Function] = "Function";
  16097. BuiltinTypeName[BuiltinTypeName.Inferred] = "Inferred";
  16098. var BuiltinType = /** @class */ (function (_super) {
  16099. __extends(BuiltinType, _super);
  16100. function BuiltinType(name, modifiers) {
  16101. if (modifiers === void 0) { modifiers = null; }
  16102. var _this = _super.call(this, modifiers) || this;
  16103. _this.name = name;
  16104. return _this;
  16105. }
  16106. /**
  16107. * @param {?} visitor
  16108. * @param {?} context
  16109. * @return {?}
  16110. */
  16111. BuiltinType.prototype.visitType = /**
  16112. * @param {?} visitor
  16113. * @param {?} context
  16114. * @return {?}
  16115. */
  16116. function (visitor, context) {
  16117. return visitor.visitBuiltintType(this, context);
  16118. };
  16119. return BuiltinType;
  16120. }(Type$1));
  16121. var ExpressionType = /** @class */ (function (_super) {
  16122. __extends(ExpressionType, _super);
  16123. function ExpressionType(value, modifiers) {
  16124. if (modifiers === void 0) { modifiers = null; }
  16125. var _this = _super.call(this, modifiers) || this;
  16126. _this.value = value;
  16127. return _this;
  16128. }
  16129. /**
  16130. * @param {?} visitor
  16131. * @param {?} context
  16132. * @return {?}
  16133. */
  16134. ExpressionType.prototype.visitType = /**
  16135. * @param {?} visitor
  16136. * @param {?} context
  16137. * @return {?}
  16138. */
  16139. function (visitor, context) {
  16140. return visitor.visitExpressionType(this, context);
  16141. };
  16142. return ExpressionType;
  16143. }(Type$1));
  16144. var ArrayType = /** @class */ (function (_super) {
  16145. __extends(ArrayType, _super);
  16146. function ArrayType(of, modifiers) {
  16147. if (modifiers === void 0) { modifiers = null; }
  16148. var _this = _super.call(this, modifiers) || this;
  16149. _this.of = of;
  16150. return _this;
  16151. }
  16152. /**
  16153. * @param {?} visitor
  16154. * @param {?} context
  16155. * @return {?}
  16156. */
  16157. ArrayType.prototype.visitType = /**
  16158. * @param {?} visitor
  16159. * @param {?} context
  16160. * @return {?}
  16161. */
  16162. function (visitor, context) {
  16163. return visitor.visitArrayType(this, context);
  16164. };
  16165. return ArrayType;
  16166. }(Type$1));
  16167. var MapType = /** @class */ (function (_super) {
  16168. __extends(MapType, _super);
  16169. function MapType(valueType, modifiers) {
  16170. if (modifiers === void 0) { modifiers = null; }
  16171. var _this = _super.call(this, modifiers) || this;
  16172. _this.valueType = valueType || null;
  16173. return _this;
  16174. }
  16175. /**
  16176. * @param {?} visitor
  16177. * @param {?} context
  16178. * @return {?}
  16179. */
  16180. MapType.prototype.visitType = /**
  16181. * @param {?} visitor
  16182. * @param {?} context
  16183. * @return {?}
  16184. */
  16185. function (visitor, context) { return visitor.visitMapType(this, context); };
  16186. return MapType;
  16187. }(Type$1));
  16188. var DYNAMIC_TYPE = new BuiltinType(BuiltinTypeName.Dynamic);
  16189. var INFERRED_TYPE = new BuiltinType(BuiltinTypeName.Inferred);
  16190. var BOOL_TYPE = new BuiltinType(BuiltinTypeName.Bool);
  16191. var INT_TYPE = new BuiltinType(BuiltinTypeName.Int);
  16192. var NUMBER_TYPE = new BuiltinType(BuiltinTypeName.Number);
  16193. var STRING_TYPE = new BuiltinType(BuiltinTypeName.String);
  16194. var FUNCTION_TYPE = new BuiltinType(BuiltinTypeName.Function);
  16195. /**
  16196. * @record
  16197. */
  16198. /** @enum {number} */
  16199. var BinaryOperator = {
  16200. Equals: 0,
  16201. NotEquals: 1,
  16202. Identical: 2,
  16203. NotIdentical: 3,
  16204. Minus: 4,
  16205. Plus: 5,
  16206. Divide: 6,
  16207. Multiply: 7,
  16208. Modulo: 8,
  16209. And: 9,
  16210. Or: 10,
  16211. Lower: 11,
  16212. LowerEquals: 12,
  16213. Bigger: 13,
  16214. BiggerEquals: 14,
  16215. };
  16216. BinaryOperator[BinaryOperator.Equals] = "Equals";
  16217. BinaryOperator[BinaryOperator.NotEquals] = "NotEquals";
  16218. BinaryOperator[BinaryOperator.Identical] = "Identical";
  16219. BinaryOperator[BinaryOperator.NotIdentical] = "NotIdentical";
  16220. BinaryOperator[BinaryOperator.Minus] = "Minus";
  16221. BinaryOperator[BinaryOperator.Plus] = "Plus";
  16222. BinaryOperator[BinaryOperator.Divide] = "Divide";
  16223. BinaryOperator[BinaryOperator.Multiply] = "Multiply";
  16224. BinaryOperator[BinaryOperator.Modulo] = "Modulo";
  16225. BinaryOperator[BinaryOperator.And] = "And";
  16226. BinaryOperator[BinaryOperator.Or] = "Or";
  16227. BinaryOperator[BinaryOperator.Lower] = "Lower";
  16228. BinaryOperator[BinaryOperator.LowerEquals] = "LowerEquals";
  16229. BinaryOperator[BinaryOperator.Bigger] = "Bigger";
  16230. BinaryOperator[BinaryOperator.BiggerEquals] = "BiggerEquals";
  16231. /**
  16232. * @template T
  16233. * @param {?} base
  16234. * @param {?} other
  16235. * @return {?}
  16236. */
  16237. function nullSafeIsEquivalent(base, other) {
  16238. if (base == null || other == null) {
  16239. return base == other;
  16240. }
  16241. return base.isEquivalent(other);
  16242. }
  16243. /**
  16244. * @template T
  16245. * @param {?} base
  16246. * @param {?} other
  16247. * @return {?}
  16248. */
  16249. function areAllEquivalent(base, other) {
  16250. var /** @type {?} */ len = base.length;
  16251. if (len !== other.length) {
  16252. return false;
  16253. }
  16254. for (var /** @type {?} */ i = 0; i < len; i++) {
  16255. if (!base[i].isEquivalent(other[i])) {
  16256. return false;
  16257. }
  16258. }
  16259. return true;
  16260. }
  16261. /**
  16262. * @abstract
  16263. */
  16264. var Expression = /** @class */ (function () {
  16265. function Expression(type, sourceSpan) {
  16266. this.type = type || null;
  16267. this.sourceSpan = sourceSpan || null;
  16268. }
  16269. /**
  16270. * @param {?} name
  16271. * @param {?=} sourceSpan
  16272. * @return {?}
  16273. */
  16274. Expression.prototype.prop = /**
  16275. * @param {?} name
  16276. * @param {?=} sourceSpan
  16277. * @return {?}
  16278. */
  16279. function (name, sourceSpan) {
  16280. return new ReadPropExpr(this, name, null, sourceSpan);
  16281. };
  16282. /**
  16283. * @param {?} index
  16284. * @param {?=} type
  16285. * @param {?=} sourceSpan
  16286. * @return {?}
  16287. */
  16288. Expression.prototype.key = /**
  16289. * @param {?} index
  16290. * @param {?=} type
  16291. * @param {?=} sourceSpan
  16292. * @return {?}
  16293. */
  16294. function (index, type, sourceSpan) {
  16295. return new ReadKeyExpr(this, index, type, sourceSpan);
  16296. };
  16297. /**
  16298. * @param {?} name
  16299. * @param {?} params
  16300. * @param {?=} sourceSpan
  16301. * @return {?}
  16302. */
  16303. Expression.prototype.callMethod = /**
  16304. * @param {?} name
  16305. * @param {?} params
  16306. * @param {?=} sourceSpan
  16307. * @return {?}
  16308. */
  16309. function (name, params, sourceSpan) {
  16310. return new InvokeMethodExpr(this, name, params, null, sourceSpan);
  16311. };
  16312. /**
  16313. * @param {?} params
  16314. * @param {?=} sourceSpan
  16315. * @return {?}
  16316. */
  16317. Expression.prototype.callFn = /**
  16318. * @param {?} params
  16319. * @param {?=} sourceSpan
  16320. * @return {?}
  16321. */
  16322. function (params, sourceSpan) {
  16323. return new InvokeFunctionExpr(this, params, null, sourceSpan);
  16324. };
  16325. /**
  16326. * @param {?} params
  16327. * @param {?=} type
  16328. * @param {?=} sourceSpan
  16329. * @return {?}
  16330. */
  16331. Expression.prototype.instantiate = /**
  16332. * @param {?} params
  16333. * @param {?=} type
  16334. * @param {?=} sourceSpan
  16335. * @return {?}
  16336. */
  16337. function (params, type, sourceSpan) {
  16338. return new InstantiateExpr(this, params, type, sourceSpan);
  16339. };
  16340. /**
  16341. * @param {?} trueCase
  16342. * @param {?=} falseCase
  16343. * @param {?=} sourceSpan
  16344. * @return {?}
  16345. */
  16346. Expression.prototype.conditional = /**
  16347. * @param {?} trueCase
  16348. * @param {?=} falseCase
  16349. * @param {?=} sourceSpan
  16350. * @return {?}
  16351. */
  16352. function (trueCase, falseCase, sourceSpan) {
  16353. if (falseCase === void 0) { falseCase = null; }
  16354. return new ConditionalExpr(this, trueCase, falseCase, null, sourceSpan);
  16355. };
  16356. /**
  16357. * @param {?} rhs
  16358. * @param {?=} sourceSpan
  16359. * @return {?}
  16360. */
  16361. Expression.prototype.equals = /**
  16362. * @param {?} rhs
  16363. * @param {?=} sourceSpan
  16364. * @return {?}
  16365. */
  16366. function (rhs, sourceSpan) {
  16367. return new BinaryOperatorExpr(BinaryOperator.Equals, this, rhs, null, sourceSpan);
  16368. };
  16369. /**
  16370. * @param {?} rhs
  16371. * @param {?=} sourceSpan
  16372. * @return {?}
  16373. */
  16374. Expression.prototype.notEquals = /**
  16375. * @param {?} rhs
  16376. * @param {?=} sourceSpan
  16377. * @return {?}
  16378. */
  16379. function (rhs, sourceSpan) {
  16380. return new BinaryOperatorExpr(BinaryOperator.NotEquals, this, rhs, null, sourceSpan);
  16381. };
  16382. /**
  16383. * @param {?} rhs
  16384. * @param {?=} sourceSpan
  16385. * @return {?}
  16386. */
  16387. Expression.prototype.identical = /**
  16388. * @param {?} rhs
  16389. * @param {?=} sourceSpan
  16390. * @return {?}
  16391. */
  16392. function (rhs, sourceSpan) {
  16393. return new BinaryOperatorExpr(BinaryOperator.Identical, this, rhs, null, sourceSpan);
  16394. };
  16395. /**
  16396. * @param {?} rhs
  16397. * @param {?=} sourceSpan
  16398. * @return {?}
  16399. */
  16400. Expression.prototype.notIdentical = /**
  16401. * @param {?} rhs
  16402. * @param {?=} sourceSpan
  16403. * @return {?}
  16404. */
  16405. function (rhs, sourceSpan) {
  16406. return new BinaryOperatorExpr(BinaryOperator.NotIdentical, this, rhs, null, sourceSpan);
  16407. };
  16408. /**
  16409. * @param {?} rhs
  16410. * @param {?=} sourceSpan
  16411. * @return {?}
  16412. */
  16413. Expression.prototype.minus = /**
  16414. * @param {?} rhs
  16415. * @param {?=} sourceSpan
  16416. * @return {?}
  16417. */
  16418. function (rhs, sourceSpan) {
  16419. return new BinaryOperatorExpr(BinaryOperator.Minus, this, rhs, null, sourceSpan);
  16420. };
  16421. /**
  16422. * @param {?} rhs
  16423. * @param {?=} sourceSpan
  16424. * @return {?}
  16425. */
  16426. Expression.prototype.plus = /**
  16427. * @param {?} rhs
  16428. * @param {?=} sourceSpan
  16429. * @return {?}
  16430. */
  16431. function (rhs, sourceSpan) {
  16432. return new BinaryOperatorExpr(BinaryOperator.Plus, this, rhs, null, sourceSpan);
  16433. };
  16434. /**
  16435. * @param {?} rhs
  16436. * @param {?=} sourceSpan
  16437. * @return {?}
  16438. */
  16439. Expression.prototype.divide = /**
  16440. * @param {?} rhs
  16441. * @param {?=} sourceSpan
  16442. * @return {?}
  16443. */
  16444. function (rhs, sourceSpan) {
  16445. return new BinaryOperatorExpr(BinaryOperator.Divide, this, rhs, null, sourceSpan);
  16446. };
  16447. /**
  16448. * @param {?} rhs
  16449. * @param {?=} sourceSpan
  16450. * @return {?}
  16451. */
  16452. Expression.prototype.multiply = /**
  16453. * @param {?} rhs
  16454. * @param {?=} sourceSpan
  16455. * @return {?}
  16456. */
  16457. function (rhs, sourceSpan) {
  16458. return new BinaryOperatorExpr(BinaryOperator.Multiply, this, rhs, null, sourceSpan);
  16459. };
  16460. /**
  16461. * @param {?} rhs
  16462. * @param {?=} sourceSpan
  16463. * @return {?}
  16464. */
  16465. Expression.prototype.modulo = /**
  16466. * @param {?} rhs
  16467. * @param {?=} sourceSpan
  16468. * @return {?}
  16469. */
  16470. function (rhs, sourceSpan) {
  16471. return new BinaryOperatorExpr(BinaryOperator.Modulo, this, rhs, null, sourceSpan);
  16472. };
  16473. /**
  16474. * @param {?} rhs
  16475. * @param {?=} sourceSpan
  16476. * @return {?}
  16477. */
  16478. Expression.prototype.and = /**
  16479. * @param {?} rhs
  16480. * @param {?=} sourceSpan
  16481. * @return {?}
  16482. */
  16483. function (rhs, sourceSpan) {
  16484. return new BinaryOperatorExpr(BinaryOperator.And, this, rhs, null, sourceSpan);
  16485. };
  16486. /**
  16487. * @param {?} rhs
  16488. * @param {?=} sourceSpan
  16489. * @return {?}
  16490. */
  16491. Expression.prototype.or = /**
  16492. * @param {?} rhs
  16493. * @param {?=} sourceSpan
  16494. * @return {?}
  16495. */
  16496. function (rhs, sourceSpan) {
  16497. return new BinaryOperatorExpr(BinaryOperator.Or, this, rhs, null, sourceSpan);
  16498. };
  16499. /**
  16500. * @param {?} rhs
  16501. * @param {?=} sourceSpan
  16502. * @return {?}
  16503. */
  16504. Expression.prototype.lower = /**
  16505. * @param {?} rhs
  16506. * @param {?=} sourceSpan
  16507. * @return {?}
  16508. */
  16509. function (rhs, sourceSpan) {
  16510. return new BinaryOperatorExpr(BinaryOperator.Lower, this, rhs, null, sourceSpan);
  16511. };
  16512. /**
  16513. * @param {?} rhs
  16514. * @param {?=} sourceSpan
  16515. * @return {?}
  16516. */
  16517. Expression.prototype.lowerEquals = /**
  16518. * @param {?} rhs
  16519. * @param {?=} sourceSpan
  16520. * @return {?}
  16521. */
  16522. function (rhs, sourceSpan) {
  16523. return new BinaryOperatorExpr(BinaryOperator.LowerEquals, this, rhs, null, sourceSpan);
  16524. };
  16525. /**
  16526. * @param {?} rhs
  16527. * @param {?=} sourceSpan
  16528. * @return {?}
  16529. */
  16530. Expression.prototype.bigger = /**
  16531. * @param {?} rhs
  16532. * @param {?=} sourceSpan
  16533. * @return {?}
  16534. */
  16535. function (rhs, sourceSpan) {
  16536. return new BinaryOperatorExpr(BinaryOperator.Bigger, this, rhs, null, sourceSpan);
  16537. };
  16538. /**
  16539. * @param {?} rhs
  16540. * @param {?=} sourceSpan
  16541. * @return {?}
  16542. */
  16543. Expression.prototype.biggerEquals = /**
  16544. * @param {?} rhs
  16545. * @param {?=} sourceSpan
  16546. * @return {?}
  16547. */
  16548. function (rhs, sourceSpan) {
  16549. return new BinaryOperatorExpr(BinaryOperator.BiggerEquals, this, rhs, null, sourceSpan);
  16550. };
  16551. /**
  16552. * @param {?=} sourceSpan
  16553. * @return {?}
  16554. */
  16555. Expression.prototype.isBlank = /**
  16556. * @param {?=} sourceSpan
  16557. * @return {?}
  16558. */
  16559. function (sourceSpan) {
  16560. // Note: We use equals by purpose here to compare to null and undefined in JS.
  16561. // We use the typed null to allow strictNullChecks to narrow types.
  16562. return this.equals(TYPED_NULL_EXPR, sourceSpan);
  16563. };
  16564. /**
  16565. * @param {?} type
  16566. * @param {?=} sourceSpan
  16567. * @return {?}
  16568. */
  16569. Expression.prototype.cast = /**
  16570. * @param {?} type
  16571. * @param {?=} sourceSpan
  16572. * @return {?}
  16573. */
  16574. function (type, sourceSpan) {
  16575. return new CastExpr(this, type, sourceSpan);
  16576. };
  16577. /**
  16578. * @return {?}
  16579. */
  16580. Expression.prototype.toStmt = /**
  16581. * @return {?}
  16582. */
  16583. function () { return new ExpressionStatement(this, null); };
  16584. return Expression;
  16585. }());
  16586. /** @enum {number} */
  16587. var BuiltinVar = {
  16588. This: 0,
  16589. Super: 1,
  16590. CatchError: 2,
  16591. CatchStack: 3,
  16592. };
  16593. BuiltinVar[BuiltinVar.This] = "This";
  16594. BuiltinVar[BuiltinVar.Super] = "Super";
  16595. BuiltinVar[BuiltinVar.CatchError] = "CatchError";
  16596. BuiltinVar[BuiltinVar.CatchStack] = "CatchStack";
  16597. var ReadVarExpr = /** @class */ (function (_super) {
  16598. __extends(ReadVarExpr, _super);
  16599. function ReadVarExpr(name, type, sourceSpan) {
  16600. var _this = _super.call(this, type, sourceSpan) || this;
  16601. if (typeof name === 'string') {
  16602. _this.name = name;
  16603. _this.builtin = null;
  16604. }
  16605. else {
  16606. _this.name = null;
  16607. _this.builtin = /** @type {?} */ (name);
  16608. }
  16609. return _this;
  16610. }
  16611. /**
  16612. * @param {?} e
  16613. * @return {?}
  16614. */
  16615. ReadVarExpr.prototype.isEquivalent = /**
  16616. * @param {?} e
  16617. * @return {?}
  16618. */
  16619. function (e) {
  16620. return e instanceof ReadVarExpr && this.name === e.name && this.builtin === e.builtin;
  16621. };
  16622. /**
  16623. * @param {?} visitor
  16624. * @param {?} context
  16625. * @return {?}
  16626. */
  16627. ReadVarExpr.prototype.visitExpression = /**
  16628. * @param {?} visitor
  16629. * @param {?} context
  16630. * @return {?}
  16631. */
  16632. function (visitor, context) {
  16633. return visitor.visitReadVarExpr(this, context);
  16634. };
  16635. /**
  16636. * @param {?} value
  16637. * @return {?}
  16638. */
  16639. ReadVarExpr.prototype.set = /**
  16640. * @param {?} value
  16641. * @return {?}
  16642. */
  16643. function (value) {
  16644. if (!this.name) {
  16645. throw new Error("Built in variable " + this.builtin + " can not be assigned to.");
  16646. }
  16647. return new WriteVarExpr(this.name, value, null, this.sourceSpan);
  16648. };
  16649. return ReadVarExpr;
  16650. }(Expression));
  16651. var WriteVarExpr = /** @class */ (function (_super) {
  16652. __extends(WriteVarExpr, _super);
  16653. function WriteVarExpr(name, value, type, sourceSpan) {
  16654. var _this = _super.call(this, type || value.type, sourceSpan) || this;
  16655. _this.name = name;
  16656. _this.value = value;
  16657. return _this;
  16658. }
  16659. /**
  16660. * @param {?} e
  16661. * @return {?}
  16662. */
  16663. WriteVarExpr.prototype.isEquivalent = /**
  16664. * @param {?} e
  16665. * @return {?}
  16666. */
  16667. function (e) {
  16668. return e instanceof WriteVarExpr && this.name === e.name && this.value.isEquivalent(e.value);
  16669. };
  16670. /**
  16671. * @param {?} visitor
  16672. * @param {?} context
  16673. * @return {?}
  16674. */
  16675. WriteVarExpr.prototype.visitExpression = /**
  16676. * @param {?} visitor
  16677. * @param {?} context
  16678. * @return {?}
  16679. */
  16680. function (visitor, context) {
  16681. return visitor.visitWriteVarExpr(this, context);
  16682. };
  16683. /**
  16684. * @param {?=} type
  16685. * @param {?=} modifiers
  16686. * @return {?}
  16687. */
  16688. WriteVarExpr.prototype.toDeclStmt = /**
  16689. * @param {?=} type
  16690. * @param {?=} modifiers
  16691. * @return {?}
  16692. */
  16693. function (type, modifiers) {
  16694. return new DeclareVarStmt(this.name, this.value, type, modifiers, this.sourceSpan);
  16695. };
  16696. return WriteVarExpr;
  16697. }(Expression));
  16698. var WriteKeyExpr = /** @class */ (function (_super) {
  16699. __extends(WriteKeyExpr, _super);
  16700. function WriteKeyExpr(receiver, index, value, type, sourceSpan) {
  16701. var _this = _super.call(this, type || value.type, sourceSpan) || this;
  16702. _this.receiver = receiver;
  16703. _this.index = index;
  16704. _this.value = value;
  16705. return _this;
  16706. }
  16707. /**
  16708. * @param {?} e
  16709. * @return {?}
  16710. */
  16711. WriteKeyExpr.prototype.isEquivalent = /**
  16712. * @param {?} e
  16713. * @return {?}
  16714. */
  16715. function (e) {
  16716. return e instanceof WriteKeyExpr && this.receiver.isEquivalent(e.receiver) &&
  16717. this.index.isEquivalent(e.index) && this.value.isEquivalent(e.value);
  16718. };
  16719. /**
  16720. * @param {?} visitor
  16721. * @param {?} context
  16722. * @return {?}
  16723. */
  16724. WriteKeyExpr.prototype.visitExpression = /**
  16725. * @param {?} visitor
  16726. * @param {?} context
  16727. * @return {?}
  16728. */
  16729. function (visitor, context) {
  16730. return visitor.visitWriteKeyExpr(this, context);
  16731. };
  16732. return WriteKeyExpr;
  16733. }(Expression));
  16734. var WritePropExpr = /** @class */ (function (_super) {
  16735. __extends(WritePropExpr, _super);
  16736. function WritePropExpr(receiver, name, value, type, sourceSpan) {
  16737. var _this = _super.call(this, type || value.type, sourceSpan) || this;
  16738. _this.receiver = receiver;
  16739. _this.name = name;
  16740. _this.value = value;
  16741. return _this;
  16742. }
  16743. /**
  16744. * @param {?} e
  16745. * @return {?}
  16746. */
  16747. WritePropExpr.prototype.isEquivalent = /**
  16748. * @param {?} e
  16749. * @return {?}
  16750. */
  16751. function (e) {
  16752. return e instanceof WritePropExpr && this.receiver.isEquivalent(e.receiver) &&
  16753. this.name === e.name && this.value.isEquivalent(e.value);
  16754. };
  16755. /**
  16756. * @param {?} visitor
  16757. * @param {?} context
  16758. * @return {?}
  16759. */
  16760. WritePropExpr.prototype.visitExpression = /**
  16761. * @param {?} visitor
  16762. * @param {?} context
  16763. * @return {?}
  16764. */
  16765. function (visitor, context) {
  16766. return visitor.visitWritePropExpr(this, context);
  16767. };
  16768. return WritePropExpr;
  16769. }(Expression));
  16770. /** @enum {number} */
  16771. var BuiltinMethod = {
  16772. ConcatArray: 0,
  16773. SubscribeObservable: 1,
  16774. Bind: 2,
  16775. };
  16776. BuiltinMethod[BuiltinMethod.ConcatArray] = "ConcatArray";
  16777. BuiltinMethod[BuiltinMethod.SubscribeObservable] = "SubscribeObservable";
  16778. BuiltinMethod[BuiltinMethod.Bind] = "Bind";
  16779. var InvokeMethodExpr = /** @class */ (function (_super) {
  16780. __extends(InvokeMethodExpr, _super);
  16781. function InvokeMethodExpr(receiver, method, args, type, sourceSpan) {
  16782. var _this = _super.call(this, type, sourceSpan) || this;
  16783. _this.receiver = receiver;
  16784. _this.args = args;
  16785. if (typeof method === 'string') {
  16786. _this.name = method;
  16787. _this.builtin = null;
  16788. }
  16789. else {
  16790. _this.name = null;
  16791. _this.builtin = /** @type {?} */ (method);
  16792. }
  16793. return _this;
  16794. }
  16795. /**
  16796. * @param {?} e
  16797. * @return {?}
  16798. */
  16799. InvokeMethodExpr.prototype.isEquivalent = /**
  16800. * @param {?} e
  16801. * @return {?}
  16802. */
  16803. function (e) {
  16804. return e instanceof InvokeMethodExpr && this.receiver.isEquivalent(e.receiver) &&
  16805. this.name === e.name && this.builtin === e.builtin && areAllEquivalent(this.args, e.args);
  16806. };
  16807. /**
  16808. * @param {?} visitor
  16809. * @param {?} context
  16810. * @return {?}
  16811. */
  16812. InvokeMethodExpr.prototype.visitExpression = /**
  16813. * @param {?} visitor
  16814. * @param {?} context
  16815. * @return {?}
  16816. */
  16817. function (visitor, context) {
  16818. return visitor.visitInvokeMethodExpr(this, context);
  16819. };
  16820. return InvokeMethodExpr;
  16821. }(Expression));
  16822. var InvokeFunctionExpr = /** @class */ (function (_super) {
  16823. __extends(InvokeFunctionExpr, _super);
  16824. function InvokeFunctionExpr(fn, args, type, sourceSpan) {
  16825. var _this = _super.call(this, type, sourceSpan) || this;
  16826. _this.fn = fn;
  16827. _this.args = args;
  16828. return _this;
  16829. }
  16830. /**
  16831. * @param {?} e
  16832. * @return {?}
  16833. */
  16834. InvokeFunctionExpr.prototype.isEquivalent = /**
  16835. * @param {?} e
  16836. * @return {?}
  16837. */
  16838. function (e) {
  16839. return e instanceof InvokeFunctionExpr && this.fn.isEquivalent(e.fn) &&
  16840. areAllEquivalent(this.args, e.args);
  16841. };
  16842. /**
  16843. * @param {?} visitor
  16844. * @param {?} context
  16845. * @return {?}
  16846. */
  16847. InvokeFunctionExpr.prototype.visitExpression = /**
  16848. * @param {?} visitor
  16849. * @param {?} context
  16850. * @return {?}
  16851. */
  16852. function (visitor, context) {
  16853. return visitor.visitInvokeFunctionExpr(this, context);
  16854. };
  16855. return InvokeFunctionExpr;
  16856. }(Expression));
  16857. var InstantiateExpr = /** @class */ (function (_super) {
  16858. __extends(InstantiateExpr, _super);
  16859. function InstantiateExpr(classExpr, args, type, sourceSpan) {
  16860. var _this = _super.call(this, type, sourceSpan) || this;
  16861. _this.classExpr = classExpr;
  16862. _this.args = args;
  16863. return _this;
  16864. }
  16865. /**
  16866. * @param {?} e
  16867. * @return {?}
  16868. */
  16869. InstantiateExpr.prototype.isEquivalent = /**
  16870. * @param {?} e
  16871. * @return {?}
  16872. */
  16873. function (e) {
  16874. return e instanceof InstantiateExpr && this.classExpr.isEquivalent(e.classExpr) &&
  16875. areAllEquivalent(this.args, e.args);
  16876. };
  16877. /**
  16878. * @param {?} visitor
  16879. * @param {?} context
  16880. * @return {?}
  16881. */
  16882. InstantiateExpr.prototype.visitExpression = /**
  16883. * @param {?} visitor
  16884. * @param {?} context
  16885. * @return {?}
  16886. */
  16887. function (visitor, context) {
  16888. return visitor.visitInstantiateExpr(this, context);
  16889. };
  16890. return InstantiateExpr;
  16891. }(Expression));
  16892. var LiteralExpr = /** @class */ (function (_super) {
  16893. __extends(LiteralExpr, _super);
  16894. function LiteralExpr(value, type, sourceSpan) {
  16895. var _this = _super.call(this, type, sourceSpan) || this;
  16896. _this.value = value;
  16897. return _this;
  16898. }
  16899. /**
  16900. * @param {?} e
  16901. * @return {?}
  16902. */
  16903. LiteralExpr.prototype.isEquivalent = /**
  16904. * @param {?} e
  16905. * @return {?}
  16906. */
  16907. function (e) {
  16908. return e instanceof LiteralExpr && this.value === e.value;
  16909. };
  16910. /**
  16911. * @param {?} visitor
  16912. * @param {?} context
  16913. * @return {?}
  16914. */
  16915. LiteralExpr.prototype.visitExpression = /**
  16916. * @param {?} visitor
  16917. * @param {?} context
  16918. * @return {?}
  16919. */
  16920. function (visitor, context) {
  16921. return visitor.visitLiteralExpr(this, context);
  16922. };
  16923. return LiteralExpr;
  16924. }(Expression));
  16925. var ExternalExpr = /** @class */ (function (_super) {
  16926. __extends(ExternalExpr, _super);
  16927. function ExternalExpr(value, type, typeParams, sourceSpan) {
  16928. if (typeParams === void 0) { typeParams = null; }
  16929. var _this = _super.call(this, type, sourceSpan) || this;
  16930. _this.value = value;
  16931. _this.typeParams = typeParams;
  16932. return _this;
  16933. }
  16934. /**
  16935. * @param {?} e
  16936. * @return {?}
  16937. */
  16938. ExternalExpr.prototype.isEquivalent = /**
  16939. * @param {?} e
  16940. * @return {?}
  16941. */
  16942. function (e) {
  16943. return e instanceof ExternalExpr && this.value.name === e.value.name &&
  16944. this.value.moduleName === e.value.moduleName && this.value.runtime === e.value.runtime;
  16945. };
  16946. /**
  16947. * @param {?} visitor
  16948. * @param {?} context
  16949. * @return {?}
  16950. */
  16951. ExternalExpr.prototype.visitExpression = /**
  16952. * @param {?} visitor
  16953. * @param {?} context
  16954. * @return {?}
  16955. */
  16956. function (visitor, context) {
  16957. return visitor.visitExternalExpr(this, context);
  16958. };
  16959. return ExternalExpr;
  16960. }(Expression));
  16961. var ExternalReference = /** @class */ (function () {
  16962. function ExternalReference(moduleName, name, runtime) {
  16963. this.moduleName = moduleName;
  16964. this.name = name;
  16965. this.runtime = runtime;
  16966. }
  16967. return ExternalReference;
  16968. }());
  16969. var ConditionalExpr = /** @class */ (function (_super) {
  16970. __extends(ConditionalExpr, _super);
  16971. function ConditionalExpr(condition, trueCase, falseCase, type, sourceSpan) {
  16972. if (falseCase === void 0) { falseCase = null; }
  16973. var _this = _super.call(this, type || trueCase.type, sourceSpan) || this;
  16974. _this.condition = condition;
  16975. _this.falseCase = falseCase;
  16976. _this.trueCase = trueCase;
  16977. return _this;
  16978. }
  16979. /**
  16980. * @param {?} e
  16981. * @return {?}
  16982. */
  16983. ConditionalExpr.prototype.isEquivalent = /**
  16984. * @param {?} e
  16985. * @return {?}
  16986. */
  16987. function (e) {
  16988. return e instanceof ConditionalExpr && this.condition.isEquivalent(e.condition) &&
  16989. this.trueCase.isEquivalent(e.trueCase) && nullSafeIsEquivalent(this.falseCase, e.falseCase);
  16990. };
  16991. /**
  16992. * @param {?} visitor
  16993. * @param {?} context
  16994. * @return {?}
  16995. */
  16996. ConditionalExpr.prototype.visitExpression = /**
  16997. * @param {?} visitor
  16998. * @param {?} context
  16999. * @return {?}
  17000. */
  17001. function (visitor, context) {
  17002. return visitor.visitConditionalExpr(this, context);
  17003. };
  17004. return ConditionalExpr;
  17005. }(Expression));
  17006. var NotExpr = /** @class */ (function (_super) {
  17007. __extends(NotExpr, _super);
  17008. function NotExpr(condition, sourceSpan) {
  17009. var _this = _super.call(this, BOOL_TYPE, sourceSpan) || this;
  17010. _this.condition = condition;
  17011. return _this;
  17012. }
  17013. /**
  17014. * @param {?} e
  17015. * @return {?}
  17016. */
  17017. NotExpr.prototype.isEquivalent = /**
  17018. * @param {?} e
  17019. * @return {?}
  17020. */
  17021. function (e) {
  17022. return e instanceof NotExpr && this.condition.isEquivalent(e.condition);
  17023. };
  17024. /**
  17025. * @param {?} visitor
  17026. * @param {?} context
  17027. * @return {?}
  17028. */
  17029. NotExpr.prototype.visitExpression = /**
  17030. * @param {?} visitor
  17031. * @param {?} context
  17032. * @return {?}
  17033. */
  17034. function (visitor, context) {
  17035. return visitor.visitNotExpr(this, context);
  17036. };
  17037. return NotExpr;
  17038. }(Expression));
  17039. var AssertNotNull = /** @class */ (function (_super) {
  17040. __extends(AssertNotNull, _super);
  17041. function AssertNotNull(condition, sourceSpan) {
  17042. var _this = _super.call(this, condition.type, sourceSpan) || this;
  17043. _this.condition = condition;
  17044. return _this;
  17045. }
  17046. /**
  17047. * @param {?} e
  17048. * @return {?}
  17049. */
  17050. AssertNotNull.prototype.isEquivalent = /**
  17051. * @param {?} e
  17052. * @return {?}
  17053. */
  17054. function (e) {
  17055. return e instanceof AssertNotNull && this.condition.isEquivalent(e.condition);
  17056. };
  17057. /**
  17058. * @param {?} visitor
  17059. * @param {?} context
  17060. * @return {?}
  17061. */
  17062. AssertNotNull.prototype.visitExpression = /**
  17063. * @param {?} visitor
  17064. * @param {?} context
  17065. * @return {?}
  17066. */
  17067. function (visitor, context) {
  17068. return visitor.visitAssertNotNullExpr(this, context);
  17069. };
  17070. return AssertNotNull;
  17071. }(Expression));
  17072. var CastExpr = /** @class */ (function (_super) {
  17073. __extends(CastExpr, _super);
  17074. function CastExpr(value, type, sourceSpan) {
  17075. var _this = _super.call(this, type, sourceSpan) || this;
  17076. _this.value = value;
  17077. return _this;
  17078. }
  17079. /**
  17080. * @param {?} e
  17081. * @return {?}
  17082. */
  17083. CastExpr.prototype.isEquivalent = /**
  17084. * @param {?} e
  17085. * @return {?}
  17086. */
  17087. function (e) {
  17088. return e instanceof CastExpr && this.value.isEquivalent(e.value);
  17089. };
  17090. /**
  17091. * @param {?} visitor
  17092. * @param {?} context
  17093. * @return {?}
  17094. */
  17095. CastExpr.prototype.visitExpression = /**
  17096. * @param {?} visitor
  17097. * @param {?} context
  17098. * @return {?}
  17099. */
  17100. function (visitor, context) {
  17101. return visitor.visitCastExpr(this, context);
  17102. };
  17103. return CastExpr;
  17104. }(Expression));
  17105. var FnParam = /** @class */ (function () {
  17106. function FnParam(name, type) {
  17107. if (type === void 0) { type = null; }
  17108. this.name = name;
  17109. this.type = type;
  17110. }
  17111. /**
  17112. * @param {?} param
  17113. * @return {?}
  17114. */
  17115. FnParam.prototype.isEquivalent = /**
  17116. * @param {?} param
  17117. * @return {?}
  17118. */
  17119. function (param) { return this.name === param.name; };
  17120. return FnParam;
  17121. }());
  17122. var FunctionExpr = /** @class */ (function (_super) {
  17123. __extends(FunctionExpr, _super);
  17124. function FunctionExpr(params, statements, type, sourceSpan) {
  17125. var _this = _super.call(this, type, sourceSpan) || this;
  17126. _this.params = params;
  17127. _this.statements = statements;
  17128. return _this;
  17129. }
  17130. /**
  17131. * @param {?} e
  17132. * @return {?}
  17133. */
  17134. FunctionExpr.prototype.isEquivalent = /**
  17135. * @param {?} e
  17136. * @return {?}
  17137. */
  17138. function (e) {
  17139. return e instanceof FunctionExpr && areAllEquivalent(this.params, e.params) &&
  17140. areAllEquivalent(this.statements, e.statements);
  17141. };
  17142. /**
  17143. * @param {?} visitor
  17144. * @param {?} context
  17145. * @return {?}
  17146. */
  17147. FunctionExpr.prototype.visitExpression = /**
  17148. * @param {?} visitor
  17149. * @param {?} context
  17150. * @return {?}
  17151. */
  17152. function (visitor, context) {
  17153. return visitor.visitFunctionExpr(this, context);
  17154. };
  17155. /**
  17156. * @param {?} name
  17157. * @param {?=} modifiers
  17158. * @return {?}
  17159. */
  17160. FunctionExpr.prototype.toDeclStmt = /**
  17161. * @param {?} name
  17162. * @param {?=} modifiers
  17163. * @return {?}
  17164. */
  17165. function (name, modifiers) {
  17166. if (modifiers === void 0) { modifiers = null; }
  17167. return new DeclareFunctionStmt(name, this.params, this.statements, this.type, modifiers, this.sourceSpan);
  17168. };
  17169. return FunctionExpr;
  17170. }(Expression));
  17171. var BinaryOperatorExpr = /** @class */ (function (_super) {
  17172. __extends(BinaryOperatorExpr, _super);
  17173. function BinaryOperatorExpr(operator, lhs, rhs, type, sourceSpan) {
  17174. var _this = _super.call(this, type || lhs.type, sourceSpan) || this;
  17175. _this.operator = operator;
  17176. _this.rhs = rhs;
  17177. _this.lhs = lhs;
  17178. return _this;
  17179. }
  17180. /**
  17181. * @param {?} e
  17182. * @return {?}
  17183. */
  17184. BinaryOperatorExpr.prototype.isEquivalent = /**
  17185. * @param {?} e
  17186. * @return {?}
  17187. */
  17188. function (e) {
  17189. return e instanceof BinaryOperatorExpr && this.operator === e.operator &&
  17190. this.lhs.isEquivalent(e.lhs) && this.rhs.isEquivalent(e.rhs);
  17191. };
  17192. /**
  17193. * @param {?} visitor
  17194. * @param {?} context
  17195. * @return {?}
  17196. */
  17197. BinaryOperatorExpr.prototype.visitExpression = /**
  17198. * @param {?} visitor
  17199. * @param {?} context
  17200. * @return {?}
  17201. */
  17202. function (visitor, context) {
  17203. return visitor.visitBinaryOperatorExpr(this, context);
  17204. };
  17205. return BinaryOperatorExpr;
  17206. }(Expression));
  17207. var ReadPropExpr = /** @class */ (function (_super) {
  17208. __extends(ReadPropExpr, _super);
  17209. function ReadPropExpr(receiver, name, type, sourceSpan) {
  17210. var _this = _super.call(this, type, sourceSpan) || this;
  17211. _this.receiver = receiver;
  17212. _this.name = name;
  17213. return _this;
  17214. }
  17215. /**
  17216. * @param {?} e
  17217. * @return {?}
  17218. */
  17219. ReadPropExpr.prototype.isEquivalent = /**
  17220. * @param {?} e
  17221. * @return {?}
  17222. */
  17223. function (e) {
  17224. return e instanceof ReadPropExpr && this.receiver.isEquivalent(e.receiver) &&
  17225. this.name === e.name;
  17226. };
  17227. /**
  17228. * @param {?} visitor
  17229. * @param {?} context
  17230. * @return {?}
  17231. */
  17232. ReadPropExpr.prototype.visitExpression = /**
  17233. * @param {?} visitor
  17234. * @param {?} context
  17235. * @return {?}
  17236. */
  17237. function (visitor, context) {
  17238. return visitor.visitReadPropExpr(this, context);
  17239. };
  17240. /**
  17241. * @param {?} value
  17242. * @return {?}
  17243. */
  17244. ReadPropExpr.prototype.set = /**
  17245. * @param {?} value
  17246. * @return {?}
  17247. */
  17248. function (value) {
  17249. return new WritePropExpr(this.receiver, this.name, value, null, this.sourceSpan);
  17250. };
  17251. return ReadPropExpr;
  17252. }(Expression));
  17253. var ReadKeyExpr = /** @class */ (function (_super) {
  17254. __extends(ReadKeyExpr, _super);
  17255. function ReadKeyExpr(receiver, index, type, sourceSpan) {
  17256. var _this = _super.call(this, type, sourceSpan) || this;
  17257. _this.receiver = receiver;
  17258. _this.index = index;
  17259. return _this;
  17260. }
  17261. /**
  17262. * @param {?} e
  17263. * @return {?}
  17264. */
  17265. ReadKeyExpr.prototype.isEquivalent = /**
  17266. * @param {?} e
  17267. * @return {?}
  17268. */
  17269. function (e) {
  17270. return e instanceof ReadKeyExpr && this.receiver.isEquivalent(e.receiver) &&
  17271. this.index.isEquivalent(e.index);
  17272. };
  17273. /**
  17274. * @param {?} visitor
  17275. * @param {?} context
  17276. * @return {?}
  17277. */
  17278. ReadKeyExpr.prototype.visitExpression = /**
  17279. * @param {?} visitor
  17280. * @param {?} context
  17281. * @return {?}
  17282. */
  17283. function (visitor, context) {
  17284. return visitor.visitReadKeyExpr(this, context);
  17285. };
  17286. /**
  17287. * @param {?} value
  17288. * @return {?}
  17289. */
  17290. ReadKeyExpr.prototype.set = /**
  17291. * @param {?} value
  17292. * @return {?}
  17293. */
  17294. function (value) {
  17295. return new WriteKeyExpr(this.receiver, this.index, value, null, this.sourceSpan);
  17296. };
  17297. return ReadKeyExpr;
  17298. }(Expression));
  17299. var LiteralArrayExpr = /** @class */ (function (_super) {
  17300. __extends(LiteralArrayExpr, _super);
  17301. function LiteralArrayExpr(entries, type, sourceSpan) {
  17302. var _this = _super.call(this, type, sourceSpan) || this;
  17303. _this.entries = entries;
  17304. return _this;
  17305. }
  17306. /**
  17307. * @param {?} e
  17308. * @return {?}
  17309. */
  17310. LiteralArrayExpr.prototype.isEquivalent = /**
  17311. * @param {?} e
  17312. * @return {?}
  17313. */
  17314. function (e) {
  17315. return e instanceof LiteralArrayExpr && areAllEquivalent(this.entries, e.entries);
  17316. };
  17317. /**
  17318. * @param {?} visitor
  17319. * @param {?} context
  17320. * @return {?}
  17321. */
  17322. LiteralArrayExpr.prototype.visitExpression = /**
  17323. * @param {?} visitor
  17324. * @param {?} context
  17325. * @return {?}
  17326. */
  17327. function (visitor, context) {
  17328. return visitor.visitLiteralArrayExpr(this, context);
  17329. };
  17330. return LiteralArrayExpr;
  17331. }(Expression));
  17332. var LiteralMapEntry = /** @class */ (function () {
  17333. function LiteralMapEntry(key, value, quoted) {
  17334. this.key = key;
  17335. this.value = value;
  17336. this.quoted = quoted;
  17337. }
  17338. /**
  17339. * @param {?} e
  17340. * @return {?}
  17341. */
  17342. LiteralMapEntry.prototype.isEquivalent = /**
  17343. * @param {?} e
  17344. * @return {?}
  17345. */
  17346. function (e) {
  17347. return this.key === e.key && this.value.isEquivalent(e.value);
  17348. };
  17349. return LiteralMapEntry;
  17350. }());
  17351. var LiteralMapExpr = /** @class */ (function (_super) {
  17352. __extends(LiteralMapExpr, _super);
  17353. function LiteralMapExpr(entries, type, sourceSpan) {
  17354. var _this = _super.call(this, type, sourceSpan) || this;
  17355. _this.entries = entries;
  17356. _this.valueType = null;
  17357. if (type) {
  17358. _this.valueType = type.valueType;
  17359. }
  17360. return _this;
  17361. }
  17362. /**
  17363. * @param {?} e
  17364. * @return {?}
  17365. */
  17366. LiteralMapExpr.prototype.isEquivalent = /**
  17367. * @param {?} e
  17368. * @return {?}
  17369. */
  17370. function (e) {
  17371. return e instanceof LiteralMapExpr && areAllEquivalent(this.entries, e.entries);
  17372. };
  17373. /**
  17374. * @param {?} visitor
  17375. * @param {?} context
  17376. * @return {?}
  17377. */
  17378. LiteralMapExpr.prototype.visitExpression = /**
  17379. * @param {?} visitor
  17380. * @param {?} context
  17381. * @return {?}
  17382. */
  17383. function (visitor, context) {
  17384. return visitor.visitLiteralMapExpr(this, context);
  17385. };
  17386. return LiteralMapExpr;
  17387. }(Expression));
  17388. var CommaExpr = /** @class */ (function (_super) {
  17389. __extends(CommaExpr, _super);
  17390. function CommaExpr(parts, sourceSpan) {
  17391. var _this = _super.call(this, parts[parts.length - 1].type, sourceSpan) || this;
  17392. _this.parts = parts;
  17393. return _this;
  17394. }
  17395. /**
  17396. * @param {?} e
  17397. * @return {?}
  17398. */
  17399. CommaExpr.prototype.isEquivalent = /**
  17400. * @param {?} e
  17401. * @return {?}
  17402. */
  17403. function (e) {
  17404. return e instanceof CommaExpr && areAllEquivalent(this.parts, e.parts);
  17405. };
  17406. /**
  17407. * @param {?} visitor
  17408. * @param {?} context
  17409. * @return {?}
  17410. */
  17411. CommaExpr.prototype.visitExpression = /**
  17412. * @param {?} visitor
  17413. * @param {?} context
  17414. * @return {?}
  17415. */
  17416. function (visitor, context) {
  17417. return visitor.visitCommaExpr(this, context);
  17418. };
  17419. return CommaExpr;
  17420. }(Expression));
  17421. /**
  17422. * @record
  17423. */
  17424. var THIS_EXPR = new ReadVarExpr(BuiltinVar.This, null, null);
  17425. var SUPER_EXPR = new ReadVarExpr(BuiltinVar.Super, null, null);
  17426. var CATCH_ERROR_VAR = new ReadVarExpr(BuiltinVar.CatchError, null, null);
  17427. var CATCH_STACK_VAR = new ReadVarExpr(BuiltinVar.CatchStack, null, null);
  17428. var NULL_EXPR = new LiteralExpr(null, null, null);
  17429. var TYPED_NULL_EXPR = new LiteralExpr(null, INFERRED_TYPE, null);
  17430. /** @enum {number} */
  17431. var StmtModifier = {
  17432. Final: 0,
  17433. Private: 1,
  17434. Exported: 2,
  17435. };
  17436. StmtModifier[StmtModifier.Final] = "Final";
  17437. StmtModifier[StmtModifier.Private] = "Private";
  17438. StmtModifier[StmtModifier.Exported] = "Exported";
  17439. /**
  17440. * @abstract
  17441. */
  17442. var Statement = /** @class */ (function () {
  17443. function Statement(modifiers, sourceSpan) {
  17444. this.modifiers = modifiers || [];
  17445. this.sourceSpan = sourceSpan || null;
  17446. }
  17447. /**
  17448. * @param {?} modifier
  17449. * @return {?}
  17450. */
  17451. Statement.prototype.hasModifier = /**
  17452. * @param {?} modifier
  17453. * @return {?}
  17454. */
  17455. function (modifier) { return /** @type {?} */ ((this.modifiers)).indexOf(modifier) !== -1; };
  17456. return Statement;
  17457. }());
  17458. var DeclareVarStmt = /** @class */ (function (_super) {
  17459. __extends(DeclareVarStmt, _super);
  17460. function DeclareVarStmt(name, value, 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.value = value;
  17465. _this.type = type || value.type;
  17466. return _this;
  17467. }
  17468. /**
  17469. * @param {?} stmt
  17470. * @return {?}
  17471. */
  17472. DeclareVarStmt.prototype.isEquivalent = /**
  17473. * @param {?} stmt
  17474. * @return {?}
  17475. */
  17476. function (stmt) {
  17477. return stmt instanceof DeclareVarStmt && this.name === stmt.name &&
  17478. this.value.isEquivalent(stmt.value);
  17479. };
  17480. /**
  17481. * @param {?} visitor
  17482. * @param {?} context
  17483. * @return {?}
  17484. */
  17485. DeclareVarStmt.prototype.visitStatement = /**
  17486. * @param {?} visitor
  17487. * @param {?} context
  17488. * @return {?}
  17489. */
  17490. function (visitor, context) {
  17491. return visitor.visitDeclareVarStmt(this, context);
  17492. };
  17493. return DeclareVarStmt;
  17494. }(Statement));
  17495. var DeclareFunctionStmt = /** @class */ (function (_super) {
  17496. __extends(DeclareFunctionStmt, _super);
  17497. function DeclareFunctionStmt(name, params, statements, type, modifiers, sourceSpan) {
  17498. if (modifiers === void 0) { modifiers = null; }
  17499. var _this = _super.call(this, modifiers, sourceSpan) || this;
  17500. _this.name = name;
  17501. _this.params = params;
  17502. _this.statements = statements;
  17503. _this.type = type || null;
  17504. return _this;
  17505. }
  17506. /**
  17507. * @param {?} stmt
  17508. * @return {?}
  17509. */
  17510. DeclareFunctionStmt.prototype.isEquivalent = /**
  17511. * @param {?} stmt
  17512. * @return {?}
  17513. */
  17514. function (stmt) {
  17515. return stmt instanceof DeclareFunctionStmt && areAllEquivalent(this.params, stmt.params) &&
  17516. areAllEquivalent(this.statements, stmt.statements);
  17517. };
  17518. /**
  17519. * @param {?} visitor
  17520. * @param {?} context
  17521. * @return {?}
  17522. */
  17523. DeclareFunctionStmt.prototype.visitStatement = /**
  17524. * @param {?} visitor
  17525. * @param {?} context
  17526. * @return {?}
  17527. */
  17528. function (visitor, context) {
  17529. return visitor.visitDeclareFunctionStmt(this, context);
  17530. };
  17531. return DeclareFunctionStmt;
  17532. }(Statement));
  17533. var ExpressionStatement = /** @class */ (function (_super) {
  17534. __extends(ExpressionStatement, _super);
  17535. function ExpressionStatement(expr, sourceSpan) {
  17536. var _this = _super.call(this, null, sourceSpan) || this;
  17537. _this.expr = expr;
  17538. return _this;
  17539. }
  17540. /**
  17541. * @param {?} stmt
  17542. * @return {?}
  17543. */
  17544. ExpressionStatement.prototype.isEquivalent = /**
  17545. * @param {?} stmt
  17546. * @return {?}
  17547. */
  17548. function (stmt) {
  17549. return stmt instanceof ExpressionStatement && this.expr.isEquivalent(stmt.expr);
  17550. };
  17551. /**
  17552. * @param {?} visitor
  17553. * @param {?} context
  17554. * @return {?}
  17555. */
  17556. ExpressionStatement.prototype.visitStatement = /**
  17557. * @param {?} visitor
  17558. * @param {?} context
  17559. * @return {?}
  17560. */
  17561. function (visitor, context) {
  17562. return visitor.visitExpressionStmt(this, context);
  17563. };
  17564. return ExpressionStatement;
  17565. }(Statement));
  17566. var ReturnStatement = /** @class */ (function (_super) {
  17567. __extends(ReturnStatement, _super);
  17568. function ReturnStatement(value, sourceSpan) {
  17569. var _this = _super.call(this, null, sourceSpan) || this;
  17570. _this.value = value;
  17571. return _this;
  17572. }
  17573. /**
  17574. * @param {?} stmt
  17575. * @return {?}
  17576. */
  17577. ReturnStatement.prototype.isEquivalent = /**
  17578. * @param {?} stmt
  17579. * @return {?}
  17580. */
  17581. function (stmt) {
  17582. return stmt instanceof ReturnStatement && this.value.isEquivalent(stmt.value);
  17583. };
  17584. /**
  17585. * @param {?} visitor
  17586. * @param {?} context
  17587. * @return {?}
  17588. */
  17589. ReturnStatement.prototype.visitStatement = /**
  17590. * @param {?} visitor
  17591. * @param {?} context
  17592. * @return {?}
  17593. */
  17594. function (visitor, context) {
  17595. return visitor.visitReturnStmt(this, context);
  17596. };
  17597. return ReturnStatement;
  17598. }(Statement));
  17599. var AbstractClassPart = /** @class */ (function () {
  17600. function AbstractClassPart(type, modifiers) {
  17601. this.modifiers = modifiers;
  17602. if (!modifiers) {
  17603. this.modifiers = [];
  17604. }
  17605. this.type = type || null;
  17606. }
  17607. /**
  17608. * @param {?} modifier
  17609. * @return {?}
  17610. */
  17611. AbstractClassPart.prototype.hasModifier = /**
  17612. * @param {?} modifier
  17613. * @return {?}
  17614. */
  17615. function (modifier) { return /** @type {?} */ ((this.modifiers)).indexOf(modifier) !== -1; };
  17616. return AbstractClassPart;
  17617. }());
  17618. var ClassField = /** @class */ (function (_super) {
  17619. __extends(ClassField, _super);
  17620. function ClassField(name, type, modifiers) {
  17621. if (modifiers === void 0) { modifiers = null; }
  17622. var _this = _super.call(this, type, modifiers) || this;
  17623. _this.name = name;
  17624. return _this;
  17625. }
  17626. /**
  17627. * @param {?} f
  17628. * @return {?}
  17629. */
  17630. ClassField.prototype.isEquivalent = /**
  17631. * @param {?} f
  17632. * @return {?}
  17633. */
  17634. function (f) { return this.name === f.name; };
  17635. return ClassField;
  17636. }(AbstractClassPart));
  17637. var ClassMethod = /** @class */ (function (_super) {
  17638. __extends(ClassMethod, _super);
  17639. function ClassMethod(name, params, body, type, modifiers) {
  17640. if (modifiers === void 0) { modifiers = null; }
  17641. var _this = _super.call(this, type, modifiers) || this;
  17642. _this.name = name;
  17643. _this.params = params;
  17644. _this.body = body;
  17645. return _this;
  17646. }
  17647. /**
  17648. * @param {?} m
  17649. * @return {?}
  17650. */
  17651. ClassMethod.prototype.isEquivalent = /**
  17652. * @param {?} m
  17653. * @return {?}
  17654. */
  17655. function (m) {
  17656. return this.name === m.name && areAllEquivalent(this.body, m.body);
  17657. };
  17658. return ClassMethod;
  17659. }(AbstractClassPart));
  17660. var ClassGetter = /** @class */ (function (_super) {
  17661. __extends(ClassGetter, _super);
  17662. function ClassGetter(name, body, type, modifiers) {
  17663. if (modifiers === void 0) { modifiers = null; }
  17664. var _this = _super.call(this, type, modifiers) || this;
  17665. _this.name = name;
  17666. _this.body = body;
  17667. return _this;
  17668. }
  17669. /**
  17670. * @param {?} m
  17671. * @return {?}
  17672. */
  17673. ClassGetter.prototype.isEquivalent = /**
  17674. * @param {?} m
  17675. * @return {?}
  17676. */
  17677. function (m) {
  17678. return this.name === m.name && areAllEquivalent(this.body, m.body);
  17679. };
  17680. return ClassGetter;
  17681. }(AbstractClassPart));
  17682. var ClassStmt = /** @class */ (function (_super) {
  17683. __extends(ClassStmt, _super);
  17684. function ClassStmt(name, parent, fields, getters, constructorMethod, methods, modifiers, sourceSpan) {
  17685. if (modifiers === void 0) { modifiers = null; }
  17686. var _this = _super.call(this, modifiers, sourceSpan) || this;
  17687. _this.name = name;
  17688. _this.parent = parent;
  17689. _this.fields = fields;
  17690. _this.getters = getters;
  17691. _this.constructorMethod = constructorMethod;
  17692. _this.methods = methods;
  17693. return _this;
  17694. }
  17695. /**
  17696. * @param {?} stmt
  17697. * @return {?}
  17698. */
  17699. ClassStmt.prototype.isEquivalent = /**
  17700. * @param {?} stmt
  17701. * @return {?}
  17702. */
  17703. function (stmt) {
  17704. return stmt instanceof ClassStmt && this.name === stmt.name &&
  17705. nullSafeIsEquivalent(this.parent, stmt.parent) &&
  17706. areAllEquivalent(this.fields, stmt.fields) &&
  17707. areAllEquivalent(this.getters, stmt.getters) &&
  17708. this.constructorMethod.isEquivalent(stmt.constructorMethod) &&
  17709. areAllEquivalent(this.methods, stmt.methods);
  17710. };
  17711. /**
  17712. * @param {?} visitor
  17713. * @param {?} context
  17714. * @return {?}
  17715. */
  17716. ClassStmt.prototype.visitStatement = /**
  17717. * @param {?} visitor
  17718. * @param {?} context
  17719. * @return {?}
  17720. */
  17721. function (visitor, context) {
  17722. return visitor.visitDeclareClassStmt(this, context);
  17723. };
  17724. return ClassStmt;
  17725. }(Statement));
  17726. var IfStmt = /** @class */ (function (_super) {
  17727. __extends(IfStmt, _super);
  17728. function IfStmt(condition, trueCase, falseCase, sourceSpan) {
  17729. if (falseCase === void 0) { falseCase = []; }
  17730. var _this = _super.call(this, null, sourceSpan) || this;
  17731. _this.condition = condition;
  17732. _this.trueCase = trueCase;
  17733. _this.falseCase = falseCase;
  17734. return _this;
  17735. }
  17736. /**
  17737. * @param {?} stmt
  17738. * @return {?}
  17739. */
  17740. IfStmt.prototype.isEquivalent = /**
  17741. * @param {?} stmt
  17742. * @return {?}
  17743. */
  17744. function (stmt) {
  17745. return stmt instanceof IfStmt && this.condition.isEquivalent(stmt.condition) &&
  17746. areAllEquivalent(this.trueCase, stmt.trueCase) &&
  17747. areAllEquivalent(this.falseCase, stmt.falseCase);
  17748. };
  17749. /**
  17750. * @param {?} visitor
  17751. * @param {?} context
  17752. * @return {?}
  17753. */
  17754. IfStmt.prototype.visitStatement = /**
  17755. * @param {?} visitor
  17756. * @param {?} context
  17757. * @return {?}
  17758. */
  17759. function (visitor, context) {
  17760. return visitor.visitIfStmt(this, context);
  17761. };
  17762. return IfStmt;
  17763. }(Statement));
  17764. var CommentStmt = /** @class */ (function (_super) {
  17765. __extends(CommentStmt, _super);
  17766. function CommentStmt(comment, sourceSpan) {
  17767. var _this = _super.call(this, null, sourceSpan) || this;
  17768. _this.comment = comment;
  17769. return _this;
  17770. }
  17771. /**
  17772. * @param {?} stmt
  17773. * @return {?}
  17774. */
  17775. CommentStmt.prototype.isEquivalent = /**
  17776. * @param {?} stmt
  17777. * @return {?}
  17778. */
  17779. function (stmt) { return stmt instanceof CommentStmt; };
  17780. /**
  17781. * @param {?} visitor
  17782. * @param {?} context
  17783. * @return {?}
  17784. */
  17785. CommentStmt.prototype.visitStatement = /**
  17786. * @param {?} visitor
  17787. * @param {?} context
  17788. * @return {?}
  17789. */
  17790. function (visitor, context) {
  17791. return visitor.visitCommentStmt(this, context);
  17792. };
  17793. return CommentStmt;
  17794. }(Statement));
  17795. var TryCatchStmt = /** @class */ (function (_super) {
  17796. __extends(TryCatchStmt, _super);
  17797. function TryCatchStmt(bodyStmts, catchStmts, sourceSpan) {
  17798. var _this = _super.call(this, null, sourceSpan) || this;
  17799. _this.bodyStmts = bodyStmts;
  17800. _this.catchStmts = catchStmts;
  17801. return _this;
  17802. }
  17803. /**
  17804. * @param {?} stmt
  17805. * @return {?}
  17806. */
  17807. TryCatchStmt.prototype.isEquivalent = /**
  17808. * @param {?} stmt
  17809. * @return {?}
  17810. */
  17811. function (stmt) {
  17812. return stmt instanceof TryCatchStmt && areAllEquivalent(this.bodyStmts, stmt.bodyStmts) &&
  17813. areAllEquivalent(this.catchStmts, stmt.catchStmts);
  17814. };
  17815. /**
  17816. * @param {?} visitor
  17817. * @param {?} context
  17818. * @return {?}
  17819. */
  17820. TryCatchStmt.prototype.visitStatement = /**
  17821. * @param {?} visitor
  17822. * @param {?} context
  17823. * @return {?}
  17824. */
  17825. function (visitor, context) {
  17826. return visitor.visitTryCatchStmt(this, context);
  17827. };
  17828. return TryCatchStmt;
  17829. }(Statement));
  17830. var ThrowStmt = /** @class */ (function (_super) {
  17831. __extends(ThrowStmt, _super);
  17832. function ThrowStmt(error, sourceSpan) {
  17833. var _this = _super.call(this, null, sourceSpan) || this;
  17834. _this.error = error;
  17835. return _this;
  17836. }
  17837. /**
  17838. * @param {?} stmt
  17839. * @return {?}
  17840. */
  17841. ThrowStmt.prototype.isEquivalent = /**
  17842. * @param {?} stmt
  17843. * @return {?}
  17844. */
  17845. function (stmt) {
  17846. return stmt instanceof TryCatchStmt && this.error.isEquivalent(stmt.error);
  17847. };
  17848. /**
  17849. * @param {?} visitor
  17850. * @param {?} context
  17851. * @return {?}
  17852. */
  17853. ThrowStmt.prototype.visitStatement = /**
  17854. * @param {?} visitor
  17855. * @param {?} context
  17856. * @return {?}
  17857. */
  17858. function (visitor, context) {
  17859. return visitor.visitThrowStmt(this, context);
  17860. };
  17861. return ThrowStmt;
  17862. }(Statement));
  17863. /**
  17864. * @record
  17865. */
  17866. var AstTransformer$1 = /** @class */ (function () {
  17867. function AstTransformer() {
  17868. }
  17869. /**
  17870. * @param {?} expr
  17871. * @param {?} context
  17872. * @return {?}
  17873. */
  17874. AstTransformer.prototype.transformExpr = /**
  17875. * @param {?} expr
  17876. * @param {?} context
  17877. * @return {?}
  17878. */
  17879. function (expr, context) { return expr; };
  17880. /**
  17881. * @param {?} stmt
  17882. * @param {?} context
  17883. * @return {?}
  17884. */
  17885. AstTransformer.prototype.transformStmt = /**
  17886. * @param {?} stmt
  17887. * @param {?} context
  17888. * @return {?}
  17889. */
  17890. function (stmt, context) { return stmt; };
  17891. /**
  17892. * @param {?} ast
  17893. * @param {?} context
  17894. * @return {?}
  17895. */
  17896. AstTransformer.prototype.visitReadVarExpr = /**
  17897. * @param {?} ast
  17898. * @param {?} context
  17899. * @return {?}
  17900. */
  17901. function (ast, context) { return this.transformExpr(ast, context); };
  17902. /**
  17903. * @param {?} expr
  17904. * @param {?} context
  17905. * @return {?}
  17906. */
  17907. AstTransformer.prototype.visitWriteVarExpr = /**
  17908. * @param {?} expr
  17909. * @param {?} context
  17910. * @return {?}
  17911. */
  17912. function (expr, context) {
  17913. return this.transformExpr(new WriteVarExpr(expr.name, expr.value.visitExpression(this, context), expr.type, expr.sourceSpan), context);
  17914. };
  17915. /**
  17916. * @param {?} expr
  17917. * @param {?} context
  17918. * @return {?}
  17919. */
  17920. AstTransformer.prototype.visitWriteKeyExpr = /**
  17921. * @param {?} expr
  17922. * @param {?} context
  17923. * @return {?}
  17924. */
  17925. function (expr, context) {
  17926. 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);
  17927. };
  17928. /**
  17929. * @param {?} expr
  17930. * @param {?} context
  17931. * @return {?}
  17932. */
  17933. AstTransformer.prototype.visitWritePropExpr = /**
  17934. * @param {?} expr
  17935. * @param {?} context
  17936. * @return {?}
  17937. */
  17938. function (expr, context) {
  17939. return this.transformExpr(new WritePropExpr(expr.receiver.visitExpression(this, context), expr.name, expr.value.visitExpression(this, context), expr.type, expr.sourceSpan), context);
  17940. };
  17941. /**
  17942. * @param {?} ast
  17943. * @param {?} context
  17944. * @return {?}
  17945. */
  17946. AstTransformer.prototype.visitInvokeMethodExpr = /**
  17947. * @param {?} ast
  17948. * @param {?} context
  17949. * @return {?}
  17950. */
  17951. function (ast, context) {
  17952. var /** @type {?} */ method = ast.builtin || ast.name;
  17953. return this.transformExpr(new InvokeMethodExpr(ast.receiver.visitExpression(this, context), /** @type {?} */ ((method)), this.visitAllExpressions(ast.args, context), ast.type, ast.sourceSpan), context);
  17954. };
  17955. /**
  17956. * @param {?} ast
  17957. * @param {?} context
  17958. * @return {?}
  17959. */
  17960. AstTransformer.prototype.visitInvokeFunctionExpr = /**
  17961. * @param {?} ast
  17962. * @param {?} context
  17963. * @return {?}
  17964. */
  17965. function (ast, context) {
  17966. return this.transformExpr(new InvokeFunctionExpr(ast.fn.visitExpression(this, context), this.visitAllExpressions(ast.args, context), ast.type, ast.sourceSpan), context);
  17967. };
  17968. /**
  17969. * @param {?} ast
  17970. * @param {?} context
  17971. * @return {?}
  17972. */
  17973. AstTransformer.prototype.visitInstantiateExpr = /**
  17974. * @param {?} ast
  17975. * @param {?} context
  17976. * @return {?}
  17977. */
  17978. function (ast, context) {
  17979. return this.transformExpr(new InstantiateExpr(ast.classExpr.visitExpression(this, context), this.visitAllExpressions(ast.args, context), ast.type, ast.sourceSpan), context);
  17980. };
  17981. /**
  17982. * @param {?} ast
  17983. * @param {?} context
  17984. * @return {?}
  17985. */
  17986. AstTransformer.prototype.visitLiteralExpr = /**
  17987. * @param {?} ast
  17988. * @param {?} context
  17989. * @return {?}
  17990. */
  17991. function (ast, context) { return this.transformExpr(ast, context); };
  17992. /**
  17993. * @param {?} ast
  17994. * @param {?} context
  17995. * @return {?}
  17996. */
  17997. AstTransformer.prototype.visitExternalExpr = /**
  17998. * @param {?} ast
  17999. * @param {?} context
  18000. * @return {?}
  18001. */
  18002. function (ast, context) {
  18003. return this.transformExpr(ast, context);
  18004. };
  18005. /**
  18006. * @param {?} ast
  18007. * @param {?} context
  18008. * @return {?}
  18009. */
  18010. AstTransformer.prototype.visitConditionalExpr = /**
  18011. * @param {?} ast
  18012. * @param {?} context
  18013. * @return {?}
  18014. */
  18015. function (ast, context) {
  18016. 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);
  18017. };
  18018. /**
  18019. * @param {?} ast
  18020. * @param {?} context
  18021. * @return {?}
  18022. */
  18023. AstTransformer.prototype.visitNotExpr = /**
  18024. * @param {?} ast
  18025. * @param {?} context
  18026. * @return {?}
  18027. */
  18028. function (ast, context) {
  18029. return this.transformExpr(new NotExpr(ast.condition.visitExpression(this, context), ast.sourceSpan), context);
  18030. };
  18031. /**
  18032. * @param {?} ast
  18033. * @param {?} context
  18034. * @return {?}
  18035. */
  18036. AstTransformer.prototype.visitAssertNotNullExpr = /**
  18037. * @param {?} ast
  18038. * @param {?} context
  18039. * @return {?}
  18040. */
  18041. function (ast, context) {
  18042. return this.transformExpr(new AssertNotNull(ast.condition.visitExpression(this, context), ast.sourceSpan), context);
  18043. };
  18044. /**
  18045. * @param {?} ast
  18046. * @param {?} context
  18047. * @return {?}
  18048. */
  18049. AstTransformer.prototype.visitCastExpr = /**
  18050. * @param {?} ast
  18051. * @param {?} context
  18052. * @return {?}
  18053. */
  18054. function (ast, context) {
  18055. return this.transformExpr(new CastExpr(ast.value.visitExpression(this, context), ast.type, ast.sourceSpan), context);
  18056. };
  18057. /**
  18058. * @param {?} ast
  18059. * @param {?} context
  18060. * @return {?}
  18061. */
  18062. AstTransformer.prototype.visitFunctionExpr = /**
  18063. * @param {?} ast
  18064. * @param {?} context
  18065. * @return {?}
  18066. */
  18067. function (ast, context) {
  18068. return this.transformExpr(new FunctionExpr(ast.params, this.visitAllStatements(ast.statements, context), ast.type, ast.sourceSpan), context);
  18069. };
  18070. /**
  18071. * @param {?} ast
  18072. * @param {?} context
  18073. * @return {?}
  18074. */
  18075. AstTransformer.prototype.visitBinaryOperatorExpr = /**
  18076. * @param {?} ast
  18077. * @param {?} context
  18078. * @return {?}
  18079. */
  18080. function (ast, context) {
  18081. return this.transformExpr(new BinaryOperatorExpr(ast.operator, ast.lhs.visitExpression(this, context), ast.rhs.visitExpression(this, context), ast.type, ast.sourceSpan), context);
  18082. };
  18083. /**
  18084. * @param {?} ast
  18085. * @param {?} context
  18086. * @return {?}
  18087. */
  18088. AstTransformer.prototype.visitReadPropExpr = /**
  18089. * @param {?} ast
  18090. * @param {?} context
  18091. * @return {?}
  18092. */
  18093. function (ast, context) {
  18094. return this.transformExpr(new ReadPropExpr(ast.receiver.visitExpression(this, context), ast.name, ast.type, ast.sourceSpan), context);
  18095. };
  18096. /**
  18097. * @param {?} ast
  18098. * @param {?} context
  18099. * @return {?}
  18100. */
  18101. AstTransformer.prototype.visitReadKeyExpr = /**
  18102. * @param {?} ast
  18103. * @param {?} context
  18104. * @return {?}
  18105. */
  18106. function (ast, context) {
  18107. return this.transformExpr(new ReadKeyExpr(ast.receiver.visitExpression(this, context), ast.index.visitExpression(this, context), ast.type, ast.sourceSpan), context);
  18108. };
  18109. /**
  18110. * @param {?} ast
  18111. * @param {?} context
  18112. * @return {?}
  18113. */
  18114. AstTransformer.prototype.visitLiteralArrayExpr = /**
  18115. * @param {?} ast
  18116. * @param {?} context
  18117. * @return {?}
  18118. */
  18119. function (ast, context) {
  18120. return this.transformExpr(new LiteralArrayExpr(this.visitAllExpressions(ast.entries, context), ast.type, ast.sourceSpan), context);
  18121. };
  18122. /**
  18123. * @param {?} ast
  18124. * @param {?} context
  18125. * @return {?}
  18126. */
  18127. AstTransformer.prototype.visitLiteralMapExpr = /**
  18128. * @param {?} ast
  18129. * @param {?} context
  18130. * @return {?}
  18131. */
  18132. function (ast, context) {
  18133. var _this = this;
  18134. var /** @type {?} */ entries = ast.entries.map(function (entry) {
  18135. return new LiteralMapEntry(entry.key, entry.value.visitExpression(_this, context), entry.quoted);
  18136. });
  18137. var /** @type {?} */ mapType = new MapType(ast.valueType, null);
  18138. return this.transformExpr(new LiteralMapExpr(entries, mapType, ast.sourceSpan), context);
  18139. };
  18140. /**
  18141. * @param {?} ast
  18142. * @param {?} context
  18143. * @return {?}
  18144. */
  18145. AstTransformer.prototype.visitCommaExpr = /**
  18146. * @param {?} ast
  18147. * @param {?} context
  18148. * @return {?}
  18149. */
  18150. function (ast, context) {
  18151. return this.transformExpr(new CommaExpr(this.visitAllExpressions(ast.parts, context), ast.sourceSpan), context);
  18152. };
  18153. /**
  18154. * @param {?} exprs
  18155. * @param {?} context
  18156. * @return {?}
  18157. */
  18158. AstTransformer.prototype.visitAllExpressions = /**
  18159. * @param {?} exprs
  18160. * @param {?} context
  18161. * @return {?}
  18162. */
  18163. function (exprs, context) {
  18164. var _this = this;
  18165. return exprs.map(function (expr) { return expr.visitExpression(_this, context); });
  18166. };
  18167. /**
  18168. * @param {?} stmt
  18169. * @param {?} context
  18170. * @return {?}
  18171. */
  18172. AstTransformer.prototype.visitDeclareVarStmt = /**
  18173. * @param {?} stmt
  18174. * @param {?} context
  18175. * @return {?}
  18176. */
  18177. function (stmt, context) {
  18178. return this.transformStmt(new DeclareVarStmt(stmt.name, stmt.value.visitExpression(this, context), stmt.type, stmt.modifiers, stmt.sourceSpan), context);
  18179. };
  18180. /**
  18181. * @param {?} stmt
  18182. * @param {?} context
  18183. * @return {?}
  18184. */
  18185. AstTransformer.prototype.visitDeclareFunctionStmt = /**
  18186. * @param {?} stmt
  18187. * @param {?} context
  18188. * @return {?}
  18189. */
  18190. function (stmt, context) {
  18191. return this.transformStmt(new DeclareFunctionStmt(stmt.name, stmt.params, this.visitAllStatements(stmt.statements, context), stmt.type, stmt.modifiers, stmt.sourceSpan), context);
  18192. };
  18193. /**
  18194. * @param {?} stmt
  18195. * @param {?} context
  18196. * @return {?}
  18197. */
  18198. AstTransformer.prototype.visitExpressionStmt = /**
  18199. * @param {?} stmt
  18200. * @param {?} context
  18201. * @return {?}
  18202. */
  18203. function (stmt, context) {
  18204. return this.transformStmt(new ExpressionStatement(stmt.expr.visitExpression(this, context), stmt.sourceSpan), context);
  18205. };
  18206. /**
  18207. * @param {?} stmt
  18208. * @param {?} context
  18209. * @return {?}
  18210. */
  18211. AstTransformer.prototype.visitReturnStmt = /**
  18212. * @param {?} stmt
  18213. * @param {?} context
  18214. * @return {?}
  18215. */
  18216. function (stmt, context) {
  18217. return this.transformStmt(new ReturnStatement(stmt.value.visitExpression(this, context), stmt.sourceSpan), context);
  18218. };
  18219. /**
  18220. * @param {?} stmt
  18221. * @param {?} context
  18222. * @return {?}
  18223. */
  18224. AstTransformer.prototype.visitDeclareClassStmt = /**
  18225. * @param {?} stmt
  18226. * @param {?} context
  18227. * @return {?}
  18228. */
  18229. function (stmt, context) {
  18230. var _this = this;
  18231. var /** @type {?} */ parent = /** @type {?} */ ((stmt.parent)).visitExpression(this, context);
  18232. var /** @type {?} */ getters = stmt.getters.map(function (getter) {
  18233. return new ClassGetter(getter.name, _this.visitAllStatements(getter.body, context), getter.type, getter.modifiers);
  18234. });
  18235. var /** @type {?} */ ctorMethod = stmt.constructorMethod &&
  18236. new ClassMethod(stmt.constructorMethod.name, stmt.constructorMethod.params, this.visitAllStatements(stmt.constructorMethod.body, context), stmt.constructorMethod.type, stmt.constructorMethod.modifiers);
  18237. var /** @type {?} */ methods = stmt.methods.map(function (method) {
  18238. return new ClassMethod(method.name, method.params, _this.visitAllStatements(method.body, context), method.type, method.modifiers);
  18239. });
  18240. return this.transformStmt(new ClassStmt(stmt.name, parent, stmt.fields, getters, ctorMethod, methods, stmt.modifiers, stmt.sourceSpan), context);
  18241. };
  18242. /**
  18243. * @param {?} stmt
  18244. * @param {?} context
  18245. * @return {?}
  18246. */
  18247. AstTransformer.prototype.visitIfStmt = /**
  18248. * @param {?} stmt
  18249. * @param {?} context
  18250. * @return {?}
  18251. */
  18252. function (stmt, context) {
  18253. return this.transformStmt(new IfStmt(stmt.condition.visitExpression(this, context), this.visitAllStatements(stmt.trueCase, context), this.visitAllStatements(stmt.falseCase, context), stmt.sourceSpan), context);
  18254. };
  18255. /**
  18256. * @param {?} stmt
  18257. * @param {?} context
  18258. * @return {?}
  18259. */
  18260. AstTransformer.prototype.visitTryCatchStmt = /**
  18261. * @param {?} stmt
  18262. * @param {?} context
  18263. * @return {?}
  18264. */
  18265. function (stmt, context) {
  18266. return this.transformStmt(new TryCatchStmt(this.visitAllStatements(stmt.bodyStmts, context), this.visitAllStatements(stmt.catchStmts, context), stmt.sourceSpan), context);
  18267. };
  18268. /**
  18269. * @param {?} stmt
  18270. * @param {?} context
  18271. * @return {?}
  18272. */
  18273. AstTransformer.prototype.visitThrowStmt = /**
  18274. * @param {?} stmt
  18275. * @param {?} context
  18276. * @return {?}
  18277. */
  18278. function (stmt, context) {
  18279. return this.transformStmt(new ThrowStmt(stmt.error.visitExpression(this, context), stmt.sourceSpan), context);
  18280. };
  18281. /**
  18282. * @param {?} stmt
  18283. * @param {?} context
  18284. * @return {?}
  18285. */
  18286. AstTransformer.prototype.visitCommentStmt = /**
  18287. * @param {?} stmt
  18288. * @param {?} context
  18289. * @return {?}
  18290. */
  18291. function (stmt, context) {
  18292. return this.transformStmt(stmt, context);
  18293. };
  18294. /**
  18295. * @param {?} stmts
  18296. * @param {?} context
  18297. * @return {?}
  18298. */
  18299. AstTransformer.prototype.visitAllStatements = /**
  18300. * @param {?} stmts
  18301. * @param {?} context
  18302. * @return {?}
  18303. */
  18304. function (stmts, context) {
  18305. var _this = this;
  18306. return stmts.map(function (stmt) { return stmt.visitStatement(_this, context); });
  18307. };
  18308. return AstTransformer;
  18309. }());
  18310. var RecursiveAstVisitor$1 = /** @class */ (function () {
  18311. function RecursiveAstVisitor() {
  18312. }
  18313. /**
  18314. * @param {?} ast
  18315. * @param {?} context
  18316. * @return {?}
  18317. */
  18318. RecursiveAstVisitor.prototype.visitType = /**
  18319. * @param {?} ast
  18320. * @param {?} context
  18321. * @return {?}
  18322. */
  18323. function (ast, context) { return ast; };
  18324. /**
  18325. * @param {?} ast
  18326. * @param {?} context
  18327. * @return {?}
  18328. */
  18329. RecursiveAstVisitor.prototype.visitExpression = /**
  18330. * @param {?} ast
  18331. * @param {?} context
  18332. * @return {?}
  18333. */
  18334. function (ast, context) {
  18335. if (ast.type) {
  18336. ast.type.visitType(this, context);
  18337. }
  18338. return ast;
  18339. };
  18340. /**
  18341. * @param {?} type
  18342. * @param {?} context
  18343. * @return {?}
  18344. */
  18345. RecursiveAstVisitor.prototype.visitBuiltintType = /**
  18346. * @param {?} type
  18347. * @param {?} context
  18348. * @return {?}
  18349. */
  18350. function (type, context) { return this.visitType(type, context); };
  18351. /**
  18352. * @param {?} type
  18353. * @param {?} context
  18354. * @return {?}
  18355. */
  18356. RecursiveAstVisitor.prototype.visitExpressionType = /**
  18357. * @param {?} type
  18358. * @param {?} context
  18359. * @return {?}
  18360. */
  18361. function (type, context) {
  18362. type.value.visitExpression(this, context);
  18363. return this.visitType(type, context);
  18364. };
  18365. /**
  18366. * @param {?} type
  18367. * @param {?} context
  18368. * @return {?}
  18369. */
  18370. RecursiveAstVisitor.prototype.visitArrayType = /**
  18371. * @param {?} type
  18372. * @param {?} context
  18373. * @return {?}
  18374. */
  18375. function (type, context) { return this.visitType(type, context); };
  18376. /**
  18377. * @param {?} type
  18378. * @param {?} context
  18379. * @return {?}
  18380. */
  18381. RecursiveAstVisitor.prototype.visitMapType = /**
  18382. * @param {?} type
  18383. * @param {?} context
  18384. * @return {?}
  18385. */
  18386. function (type, context) { return this.visitType(type, context); };
  18387. /**
  18388. * @param {?} ast
  18389. * @param {?} context
  18390. * @return {?}
  18391. */
  18392. RecursiveAstVisitor.prototype.visitReadVarExpr = /**
  18393. * @param {?} ast
  18394. * @param {?} context
  18395. * @return {?}
  18396. */
  18397. function (ast, context) {
  18398. return this.visitExpression(ast, context);
  18399. };
  18400. /**
  18401. * @param {?} ast
  18402. * @param {?} context
  18403. * @return {?}
  18404. */
  18405. RecursiveAstVisitor.prototype.visitWriteVarExpr = /**
  18406. * @param {?} ast
  18407. * @param {?} context
  18408. * @return {?}
  18409. */
  18410. function (ast, context) {
  18411. ast.value.visitExpression(this, context);
  18412. return this.visitExpression(ast, context);
  18413. };
  18414. /**
  18415. * @param {?} ast
  18416. * @param {?} context
  18417. * @return {?}
  18418. */
  18419. RecursiveAstVisitor.prototype.visitWriteKeyExpr = /**
  18420. * @param {?} ast
  18421. * @param {?} context
  18422. * @return {?}
  18423. */
  18424. function (ast, context) {
  18425. ast.receiver.visitExpression(this, context);
  18426. ast.index.visitExpression(this, context);
  18427. ast.value.visitExpression(this, context);
  18428. return this.visitExpression(ast, context);
  18429. };
  18430. /**
  18431. * @param {?} ast
  18432. * @param {?} context
  18433. * @return {?}
  18434. */
  18435. RecursiveAstVisitor.prototype.visitWritePropExpr = /**
  18436. * @param {?} ast
  18437. * @param {?} context
  18438. * @return {?}
  18439. */
  18440. function (ast, context) {
  18441. ast.receiver.visitExpression(this, context);
  18442. ast.value.visitExpression(this, context);
  18443. return this.visitExpression(ast, context);
  18444. };
  18445. /**
  18446. * @param {?} ast
  18447. * @param {?} context
  18448. * @return {?}
  18449. */
  18450. RecursiveAstVisitor.prototype.visitInvokeMethodExpr = /**
  18451. * @param {?} ast
  18452. * @param {?} context
  18453. * @return {?}
  18454. */
  18455. function (ast, context) {
  18456. ast.receiver.visitExpression(this, context);
  18457. this.visitAllExpressions(ast.args, context);
  18458. return this.visitExpression(ast, context);
  18459. };
  18460. /**
  18461. * @param {?} ast
  18462. * @param {?} context
  18463. * @return {?}
  18464. */
  18465. RecursiveAstVisitor.prototype.visitInvokeFunctionExpr = /**
  18466. * @param {?} ast
  18467. * @param {?} context
  18468. * @return {?}
  18469. */
  18470. function (ast, context) {
  18471. ast.fn.visitExpression(this, context);
  18472. this.visitAllExpressions(ast.args, context);
  18473. return this.visitExpression(ast, context);
  18474. };
  18475. /**
  18476. * @param {?} ast
  18477. * @param {?} context
  18478. * @return {?}
  18479. */
  18480. RecursiveAstVisitor.prototype.visitInstantiateExpr = /**
  18481. * @param {?} ast
  18482. * @param {?} context
  18483. * @return {?}
  18484. */
  18485. function (ast, context) {
  18486. ast.classExpr.visitExpression(this, context);
  18487. this.visitAllExpressions(ast.args, context);
  18488. return this.visitExpression(ast, context);
  18489. };
  18490. /**
  18491. * @param {?} ast
  18492. * @param {?} context
  18493. * @return {?}
  18494. */
  18495. RecursiveAstVisitor.prototype.visitLiteralExpr = /**
  18496. * @param {?} ast
  18497. * @param {?} context
  18498. * @return {?}
  18499. */
  18500. function (ast, context) {
  18501. return this.visitExpression(ast, context);
  18502. };
  18503. /**
  18504. * @param {?} ast
  18505. * @param {?} context
  18506. * @return {?}
  18507. */
  18508. RecursiveAstVisitor.prototype.visitExternalExpr = /**
  18509. * @param {?} ast
  18510. * @param {?} context
  18511. * @return {?}
  18512. */
  18513. function (ast, context) {
  18514. var _this = this;
  18515. if (ast.typeParams) {
  18516. ast.typeParams.forEach(function (type) { return type.visitType(_this, context); });
  18517. }
  18518. return this.visitExpression(ast, context);
  18519. };
  18520. /**
  18521. * @param {?} ast
  18522. * @param {?} context
  18523. * @return {?}
  18524. */
  18525. RecursiveAstVisitor.prototype.visitConditionalExpr = /**
  18526. * @param {?} ast
  18527. * @param {?} context
  18528. * @return {?}
  18529. */
  18530. function (ast, context) {
  18531. ast.condition.visitExpression(this, context);
  18532. ast.trueCase.visitExpression(this, context); /** @type {?} */
  18533. ((ast.falseCase)).visitExpression(this, context);
  18534. return this.visitExpression(ast, context);
  18535. };
  18536. /**
  18537. * @param {?} ast
  18538. * @param {?} context
  18539. * @return {?}
  18540. */
  18541. RecursiveAstVisitor.prototype.visitNotExpr = /**
  18542. * @param {?} ast
  18543. * @param {?} context
  18544. * @return {?}
  18545. */
  18546. function (ast, context) {
  18547. ast.condition.visitExpression(this, context);
  18548. return this.visitExpression(ast, context);
  18549. };
  18550. /**
  18551. * @param {?} ast
  18552. * @param {?} context
  18553. * @return {?}
  18554. */
  18555. RecursiveAstVisitor.prototype.visitAssertNotNullExpr = /**
  18556. * @param {?} ast
  18557. * @param {?} context
  18558. * @return {?}
  18559. */
  18560. function (ast, context) {
  18561. ast.condition.visitExpression(this, context);
  18562. return this.visitExpression(ast, context);
  18563. };
  18564. /**
  18565. * @param {?} ast
  18566. * @param {?} context
  18567. * @return {?}
  18568. */
  18569. RecursiveAstVisitor.prototype.visitCastExpr = /**
  18570. * @param {?} ast
  18571. * @param {?} context
  18572. * @return {?}
  18573. */
  18574. function (ast, context) {
  18575. ast.value.visitExpression(this, context);
  18576. return this.visitExpression(ast, context);
  18577. };
  18578. /**
  18579. * @param {?} ast
  18580. * @param {?} context
  18581. * @return {?}
  18582. */
  18583. RecursiveAstVisitor.prototype.visitFunctionExpr = /**
  18584. * @param {?} ast
  18585. * @param {?} context
  18586. * @return {?}
  18587. */
  18588. function (ast, context) {
  18589. this.visitAllStatements(ast.statements, context);
  18590. return this.visitExpression(ast, context);
  18591. };
  18592. /**
  18593. * @param {?} ast
  18594. * @param {?} context
  18595. * @return {?}
  18596. */
  18597. RecursiveAstVisitor.prototype.visitBinaryOperatorExpr = /**
  18598. * @param {?} ast
  18599. * @param {?} context
  18600. * @return {?}
  18601. */
  18602. function (ast, context) {
  18603. ast.lhs.visitExpression(this, context);
  18604. ast.rhs.visitExpression(this, context);
  18605. return this.visitExpression(ast, context);
  18606. };
  18607. /**
  18608. * @param {?} ast
  18609. * @param {?} context
  18610. * @return {?}
  18611. */
  18612. RecursiveAstVisitor.prototype.visitReadPropExpr = /**
  18613. * @param {?} ast
  18614. * @param {?} context
  18615. * @return {?}
  18616. */
  18617. function (ast, context) {
  18618. ast.receiver.visitExpression(this, context);
  18619. return this.visitExpression(ast, context);
  18620. };
  18621. /**
  18622. * @param {?} ast
  18623. * @param {?} context
  18624. * @return {?}
  18625. */
  18626. RecursiveAstVisitor.prototype.visitReadKeyExpr = /**
  18627. * @param {?} ast
  18628. * @param {?} context
  18629. * @return {?}
  18630. */
  18631. function (ast, context) {
  18632. ast.receiver.visitExpression(this, context);
  18633. ast.index.visitExpression(this, context);
  18634. return this.visitExpression(ast, context);
  18635. };
  18636. /**
  18637. * @param {?} ast
  18638. * @param {?} context
  18639. * @return {?}
  18640. */
  18641. RecursiveAstVisitor.prototype.visitLiteralArrayExpr = /**
  18642. * @param {?} ast
  18643. * @param {?} context
  18644. * @return {?}
  18645. */
  18646. function (ast, context) {
  18647. this.visitAllExpressions(ast.entries, context);
  18648. return this.visitExpression(ast, context);
  18649. };
  18650. /**
  18651. * @param {?} ast
  18652. * @param {?} context
  18653. * @return {?}
  18654. */
  18655. RecursiveAstVisitor.prototype.visitLiteralMapExpr = /**
  18656. * @param {?} ast
  18657. * @param {?} context
  18658. * @return {?}
  18659. */
  18660. function (ast, context) {
  18661. var _this = this;
  18662. ast.entries.forEach(function (entry) { return entry.value.visitExpression(_this, context); });
  18663. return this.visitExpression(ast, context);
  18664. };
  18665. /**
  18666. * @param {?} ast
  18667. * @param {?} context
  18668. * @return {?}
  18669. */
  18670. RecursiveAstVisitor.prototype.visitCommaExpr = /**
  18671. * @param {?} ast
  18672. * @param {?} context
  18673. * @return {?}
  18674. */
  18675. function (ast, context) {
  18676. this.visitAllExpressions(ast.parts, context);
  18677. return this.visitExpression(ast, context);
  18678. };
  18679. /**
  18680. * @param {?} exprs
  18681. * @param {?} context
  18682. * @return {?}
  18683. */
  18684. RecursiveAstVisitor.prototype.visitAllExpressions = /**
  18685. * @param {?} exprs
  18686. * @param {?} context
  18687. * @return {?}
  18688. */
  18689. function (exprs, context) {
  18690. var _this = this;
  18691. exprs.forEach(function (expr) { return expr.visitExpression(_this, context); });
  18692. };
  18693. /**
  18694. * @param {?} stmt
  18695. * @param {?} context
  18696. * @return {?}
  18697. */
  18698. RecursiveAstVisitor.prototype.visitDeclareVarStmt = /**
  18699. * @param {?} stmt
  18700. * @param {?} context
  18701. * @return {?}
  18702. */
  18703. function (stmt, context) {
  18704. stmt.value.visitExpression(this, context);
  18705. if (stmt.type) {
  18706. stmt.type.visitType(this, context);
  18707. }
  18708. return stmt;
  18709. };
  18710. /**
  18711. * @param {?} stmt
  18712. * @param {?} context
  18713. * @return {?}
  18714. */
  18715. RecursiveAstVisitor.prototype.visitDeclareFunctionStmt = /**
  18716. * @param {?} stmt
  18717. * @param {?} context
  18718. * @return {?}
  18719. */
  18720. function (stmt, context) {
  18721. this.visitAllStatements(stmt.statements, context);
  18722. if (stmt.type) {
  18723. stmt.type.visitType(this, context);
  18724. }
  18725. return stmt;
  18726. };
  18727. /**
  18728. * @param {?} stmt
  18729. * @param {?} context
  18730. * @return {?}
  18731. */
  18732. RecursiveAstVisitor.prototype.visitExpressionStmt = /**
  18733. * @param {?} stmt
  18734. * @param {?} context
  18735. * @return {?}
  18736. */
  18737. function (stmt, context) {
  18738. stmt.expr.visitExpression(this, context);
  18739. return stmt;
  18740. };
  18741. /**
  18742. * @param {?} stmt
  18743. * @param {?} context
  18744. * @return {?}
  18745. */
  18746. RecursiveAstVisitor.prototype.visitReturnStmt = /**
  18747. * @param {?} stmt
  18748. * @param {?} context
  18749. * @return {?}
  18750. */
  18751. function (stmt, context) {
  18752. stmt.value.visitExpression(this, context);
  18753. return stmt;
  18754. };
  18755. /**
  18756. * @param {?} stmt
  18757. * @param {?} context
  18758. * @return {?}
  18759. */
  18760. RecursiveAstVisitor.prototype.visitDeclareClassStmt = /**
  18761. * @param {?} stmt
  18762. * @param {?} context
  18763. * @return {?}
  18764. */
  18765. function (stmt, context) {
  18766. var _this = this;
  18767. /** @type {?} */ ((stmt.parent)).visitExpression(this, context);
  18768. stmt.getters.forEach(function (getter) { return _this.visitAllStatements(getter.body, context); });
  18769. if (stmt.constructorMethod) {
  18770. this.visitAllStatements(stmt.constructorMethod.body, context);
  18771. }
  18772. stmt.methods.forEach(function (method) { return _this.visitAllStatements(method.body, context); });
  18773. return stmt;
  18774. };
  18775. /**
  18776. * @param {?} stmt
  18777. * @param {?} context
  18778. * @return {?}
  18779. */
  18780. RecursiveAstVisitor.prototype.visitIfStmt = /**
  18781. * @param {?} stmt
  18782. * @param {?} context
  18783. * @return {?}
  18784. */
  18785. function (stmt, context) {
  18786. stmt.condition.visitExpression(this, context);
  18787. this.visitAllStatements(stmt.trueCase, context);
  18788. this.visitAllStatements(stmt.falseCase, context);
  18789. return stmt;
  18790. };
  18791. /**
  18792. * @param {?} stmt
  18793. * @param {?} context
  18794. * @return {?}
  18795. */
  18796. RecursiveAstVisitor.prototype.visitTryCatchStmt = /**
  18797. * @param {?} stmt
  18798. * @param {?} context
  18799. * @return {?}
  18800. */
  18801. function (stmt, context) {
  18802. this.visitAllStatements(stmt.bodyStmts, context);
  18803. this.visitAllStatements(stmt.catchStmts, context);
  18804. return stmt;
  18805. };
  18806. /**
  18807. * @param {?} stmt
  18808. * @param {?} context
  18809. * @return {?}
  18810. */
  18811. RecursiveAstVisitor.prototype.visitThrowStmt = /**
  18812. * @param {?} stmt
  18813. * @param {?} context
  18814. * @return {?}
  18815. */
  18816. function (stmt, context) {
  18817. stmt.error.visitExpression(this, context);
  18818. return stmt;
  18819. };
  18820. /**
  18821. * @param {?} stmt
  18822. * @param {?} context
  18823. * @return {?}
  18824. */
  18825. RecursiveAstVisitor.prototype.visitCommentStmt = /**
  18826. * @param {?} stmt
  18827. * @param {?} context
  18828. * @return {?}
  18829. */
  18830. function (stmt, context) { return stmt; };
  18831. /**
  18832. * @param {?} stmts
  18833. * @param {?} context
  18834. * @return {?}
  18835. */
  18836. RecursiveAstVisitor.prototype.visitAllStatements = /**
  18837. * @param {?} stmts
  18838. * @param {?} context
  18839. * @return {?}
  18840. */
  18841. function (stmts, context) {
  18842. var _this = this;
  18843. stmts.forEach(function (stmt) { return stmt.visitStatement(_this, context); });
  18844. };
  18845. return RecursiveAstVisitor;
  18846. }());
  18847. /**
  18848. * @param {?} stmts
  18849. * @return {?}
  18850. */
  18851. function findReadVarNames(stmts) {
  18852. var /** @type {?} */ visitor = new _ReadVarVisitor();
  18853. visitor.visitAllStatements(stmts, null);
  18854. return visitor.varNames;
  18855. }
  18856. var _ReadVarVisitor = /** @class */ (function (_super) {
  18857. __extends(_ReadVarVisitor, _super);
  18858. function _ReadVarVisitor() {
  18859. var _this = _super !== null && _super.apply(this, arguments) || this;
  18860. _this.varNames = new Set();
  18861. return _this;
  18862. }
  18863. /**
  18864. * @param {?} stmt
  18865. * @param {?} context
  18866. * @return {?}
  18867. */
  18868. _ReadVarVisitor.prototype.visitDeclareFunctionStmt = /**
  18869. * @param {?} stmt
  18870. * @param {?} context
  18871. * @return {?}
  18872. */
  18873. function (stmt, context) {
  18874. // Don't descend into nested functions
  18875. return stmt;
  18876. };
  18877. /**
  18878. * @param {?} stmt
  18879. * @param {?} context
  18880. * @return {?}
  18881. */
  18882. _ReadVarVisitor.prototype.visitDeclareClassStmt = /**
  18883. * @param {?} stmt
  18884. * @param {?} context
  18885. * @return {?}
  18886. */
  18887. function (stmt, context) {
  18888. // Don't descend into nested classes
  18889. return stmt;
  18890. };
  18891. /**
  18892. * @param {?} ast
  18893. * @param {?} context
  18894. * @return {?}
  18895. */
  18896. _ReadVarVisitor.prototype.visitReadVarExpr = /**
  18897. * @param {?} ast
  18898. * @param {?} context
  18899. * @return {?}
  18900. */
  18901. function (ast, context) {
  18902. if (ast.name) {
  18903. this.varNames.add(ast.name);
  18904. }
  18905. return null;
  18906. };
  18907. return _ReadVarVisitor;
  18908. }(RecursiveAstVisitor$1));
  18909. /**
  18910. * @param {?} stmts
  18911. * @return {?}
  18912. */
  18913. function collectExternalReferences(stmts) {
  18914. var /** @type {?} */ visitor = new _FindExternalReferencesVisitor();
  18915. visitor.visitAllStatements(stmts, null);
  18916. return visitor.externalReferences;
  18917. }
  18918. var _FindExternalReferencesVisitor = /** @class */ (function (_super) {
  18919. __extends(_FindExternalReferencesVisitor, _super);
  18920. function _FindExternalReferencesVisitor() {
  18921. var _this = _super !== null && _super.apply(this, arguments) || this;
  18922. _this.externalReferences = [];
  18923. return _this;
  18924. }
  18925. /**
  18926. * @param {?} e
  18927. * @param {?} context
  18928. * @return {?}
  18929. */
  18930. _FindExternalReferencesVisitor.prototype.visitExternalExpr = /**
  18931. * @param {?} e
  18932. * @param {?} context
  18933. * @return {?}
  18934. */
  18935. function (e, context) {
  18936. this.externalReferences.push(e.value);
  18937. return _super.prototype.visitExternalExpr.call(this, e, context);
  18938. };
  18939. return _FindExternalReferencesVisitor;
  18940. }(RecursiveAstVisitor$1));
  18941. /**
  18942. * @param {?} stmt
  18943. * @param {?} sourceSpan
  18944. * @return {?}
  18945. */
  18946. function applySourceSpanToStatementIfNeeded(stmt, sourceSpan) {
  18947. if (!sourceSpan) {
  18948. return stmt;
  18949. }
  18950. var /** @type {?} */ transformer = new _ApplySourceSpanTransformer(sourceSpan);
  18951. return stmt.visitStatement(transformer, null);
  18952. }
  18953. /**
  18954. * @param {?} expr
  18955. * @param {?} sourceSpan
  18956. * @return {?}
  18957. */
  18958. function applySourceSpanToExpressionIfNeeded(expr, sourceSpan) {
  18959. if (!sourceSpan) {
  18960. return expr;
  18961. }
  18962. var /** @type {?} */ transformer = new _ApplySourceSpanTransformer(sourceSpan);
  18963. return expr.visitExpression(transformer, null);
  18964. }
  18965. var _ApplySourceSpanTransformer = /** @class */ (function (_super) {
  18966. __extends(_ApplySourceSpanTransformer, _super);
  18967. function _ApplySourceSpanTransformer(sourceSpan) {
  18968. var _this = _super.call(this) || this;
  18969. _this.sourceSpan = sourceSpan;
  18970. return _this;
  18971. }
  18972. /**
  18973. * @param {?} obj
  18974. * @return {?}
  18975. */
  18976. _ApplySourceSpanTransformer.prototype._clone = /**
  18977. * @param {?} obj
  18978. * @return {?}
  18979. */
  18980. function (obj) {
  18981. var /** @type {?} */ clone = Object.create(obj.constructor.prototype);
  18982. for (var /** @type {?} */ prop in obj) {
  18983. clone[prop] = obj[prop];
  18984. }
  18985. return clone;
  18986. };
  18987. /**
  18988. * @param {?} expr
  18989. * @param {?} context
  18990. * @return {?}
  18991. */
  18992. _ApplySourceSpanTransformer.prototype.transformExpr = /**
  18993. * @param {?} expr
  18994. * @param {?} context
  18995. * @return {?}
  18996. */
  18997. function (expr, context) {
  18998. if (!expr.sourceSpan) {
  18999. expr = this._clone(expr);
  19000. expr.sourceSpan = this.sourceSpan;
  19001. }
  19002. return expr;
  19003. };
  19004. /**
  19005. * @param {?} stmt
  19006. * @param {?} context
  19007. * @return {?}
  19008. */
  19009. _ApplySourceSpanTransformer.prototype.transformStmt = /**
  19010. * @param {?} stmt
  19011. * @param {?} context
  19012. * @return {?}
  19013. */
  19014. function (stmt, context) {
  19015. if (!stmt.sourceSpan) {
  19016. stmt = this._clone(stmt);
  19017. stmt.sourceSpan = this.sourceSpan;
  19018. }
  19019. return stmt;
  19020. };
  19021. return _ApplySourceSpanTransformer;
  19022. }(AstTransformer$1));
  19023. /**
  19024. * @param {?} name
  19025. * @param {?=} type
  19026. * @param {?=} sourceSpan
  19027. * @return {?}
  19028. */
  19029. function variable(name, type, sourceSpan) {
  19030. return new ReadVarExpr(name, type, sourceSpan);
  19031. }
  19032. /**
  19033. * @param {?} id
  19034. * @param {?=} typeParams
  19035. * @param {?=} sourceSpan
  19036. * @return {?}
  19037. */
  19038. function importExpr(id, typeParams, sourceSpan) {
  19039. if (typeParams === void 0) { typeParams = null; }
  19040. return new ExternalExpr(id, null, typeParams, sourceSpan);
  19041. }
  19042. /**
  19043. * @param {?} id
  19044. * @param {?=} typeParams
  19045. * @param {?=} typeModifiers
  19046. * @return {?}
  19047. */
  19048. function importType(id, typeParams, typeModifiers) {
  19049. if (typeParams === void 0) { typeParams = null; }
  19050. if (typeModifiers === void 0) { typeModifiers = null; }
  19051. return id != null ? expressionType(importExpr(id, typeParams, null), typeModifiers) : null;
  19052. }
  19053. /**
  19054. * @param {?} expr
  19055. * @param {?=} typeModifiers
  19056. * @return {?}
  19057. */
  19058. function expressionType(expr, typeModifiers) {
  19059. if (typeModifiers === void 0) { typeModifiers = null; }
  19060. return new ExpressionType(expr, typeModifiers);
  19061. }
  19062. /**
  19063. * @param {?} values
  19064. * @param {?=} type
  19065. * @param {?=} sourceSpan
  19066. * @return {?}
  19067. */
  19068. function literalArr(values, type, sourceSpan) {
  19069. return new LiteralArrayExpr(values, type, sourceSpan);
  19070. }
  19071. /**
  19072. * @param {?} values
  19073. * @param {?=} type
  19074. * @return {?}
  19075. */
  19076. function literalMap(values, type) {
  19077. if (type === void 0) { type = null; }
  19078. return new LiteralMapExpr(values.map(function (e) { return new LiteralMapEntry(e.key, e.value, e.quoted); }), type, null);
  19079. }
  19080. /**
  19081. * @param {?} expr
  19082. * @param {?=} sourceSpan
  19083. * @return {?}
  19084. */
  19085. function not(expr, sourceSpan) {
  19086. return new NotExpr(expr, sourceSpan);
  19087. }
  19088. /**
  19089. * @param {?} expr
  19090. * @param {?=} sourceSpan
  19091. * @return {?}
  19092. */
  19093. function assertNotNull(expr, sourceSpan) {
  19094. return new AssertNotNull(expr, sourceSpan);
  19095. }
  19096. /**
  19097. * @param {?} params
  19098. * @param {?} body
  19099. * @param {?=} type
  19100. * @param {?=} sourceSpan
  19101. * @return {?}
  19102. */
  19103. function fn(params, body, type, sourceSpan) {
  19104. return new FunctionExpr(params, body, type, sourceSpan);
  19105. }
  19106. /**
  19107. * @param {?} value
  19108. * @param {?=} type
  19109. * @param {?=} sourceSpan
  19110. * @return {?}
  19111. */
  19112. function literal(value, type, sourceSpan) {
  19113. return new LiteralExpr(value, type, sourceSpan);
  19114. }
  19115. /**
  19116. * @fileoverview added by tsickle
  19117. * @suppress {checkTypes} checked by tsc
  19118. */
  19119. /**
  19120. * @license
  19121. * Copyright Google Inc. All Rights Reserved.
  19122. *
  19123. * Use of this source code is governed by an MIT-style license that can be
  19124. * found in the LICENSE file at https://angular.io/license
  19125. */
  19126. var ProviderError = /** @class */ (function (_super) {
  19127. __extends(ProviderError, _super);
  19128. function ProviderError(message, span) {
  19129. return _super.call(this, span, message) || this;
  19130. }
  19131. return ProviderError;
  19132. }(ParseError));
  19133. /**
  19134. * @record
  19135. */
  19136. var ProviderViewContext = /** @class */ (function () {
  19137. function ProviderViewContext(reflector, component) {
  19138. var _this = this;
  19139. this.reflector = reflector;
  19140. this.component = component;
  19141. this.errors = [];
  19142. this.viewQueries = _getViewQueries(component);
  19143. this.viewProviders = new Map();
  19144. component.viewProviders.forEach(function (provider) {
  19145. if (_this.viewProviders.get(tokenReference(provider.token)) == null) {
  19146. _this.viewProviders.set(tokenReference(provider.token), true);
  19147. }
  19148. });
  19149. }
  19150. return ProviderViewContext;
  19151. }());
  19152. var ProviderElementContext = /** @class */ (function () {
  19153. function ProviderElementContext(viewContext, _parent, _isViewRoot, _directiveAsts, attrs, refs, isTemplate, contentQueryStartId, _sourceSpan) {
  19154. var _this = this;
  19155. this.viewContext = viewContext;
  19156. this._parent = _parent;
  19157. this._isViewRoot = _isViewRoot;
  19158. this._directiveAsts = _directiveAsts;
  19159. this._sourceSpan = _sourceSpan;
  19160. this._transformedProviders = new Map();
  19161. this._seenProviders = new Map();
  19162. this._queriedTokens = new Map();
  19163. this.transformedHasViewContainer = false;
  19164. this._attrs = {};
  19165. attrs.forEach(function (attrAst) { return _this._attrs[attrAst.name] = attrAst.value; });
  19166. var /** @type {?} */ directivesMeta = _directiveAsts.map(function (directiveAst) { return directiveAst.directive; });
  19167. this._allProviders =
  19168. _resolveProvidersFromDirectives(directivesMeta, _sourceSpan, viewContext.errors);
  19169. this._contentQueries = _getContentQueries(contentQueryStartId, directivesMeta);
  19170. Array.from(this._allProviders.values()).forEach(function (provider) {
  19171. _this._addQueryReadsTo(provider.token, provider.token, _this._queriedTokens);
  19172. });
  19173. if (isTemplate) {
  19174. var /** @type {?} */ templateRefId = createTokenForExternalReference(this.viewContext.reflector, Identifiers.TemplateRef);
  19175. this._addQueryReadsTo(templateRefId, templateRefId, this._queriedTokens);
  19176. }
  19177. refs.forEach(function (refAst) {
  19178. var /** @type {?} */ defaultQueryValue = refAst.value ||
  19179. createTokenForExternalReference(_this.viewContext.reflector, Identifiers.ElementRef);
  19180. _this._addQueryReadsTo({ value: refAst.name }, defaultQueryValue, _this._queriedTokens);
  19181. });
  19182. if (this._queriedTokens.get(this.viewContext.reflector.resolveExternalReference(Identifiers.ViewContainerRef))) {
  19183. this.transformedHasViewContainer = true;
  19184. }
  19185. // create the providers that we know are eager first
  19186. Array.from(this._allProviders.values()).forEach(function (provider) {
  19187. var /** @type {?} */ eager = provider.eager || _this._queriedTokens.get(tokenReference(provider.token));
  19188. if (eager) {
  19189. _this._getOrCreateLocalProvider(provider.providerType, provider.token, true);
  19190. }
  19191. });
  19192. }
  19193. /**
  19194. * @return {?}
  19195. */
  19196. ProviderElementContext.prototype.afterElement = /**
  19197. * @return {?}
  19198. */
  19199. function () {
  19200. var _this = this;
  19201. // collect lazy providers
  19202. Array.from(this._allProviders.values()).forEach(function (provider) {
  19203. _this._getOrCreateLocalProvider(provider.providerType, provider.token, false);
  19204. });
  19205. };
  19206. Object.defineProperty(ProviderElementContext.prototype, "transformProviders", {
  19207. get: /**
  19208. * @return {?}
  19209. */
  19210. function () {
  19211. // Note: Maps keep their insertion order.
  19212. var /** @type {?} */ lazyProviders = [];
  19213. var /** @type {?} */ eagerProviders = [];
  19214. this._transformedProviders.forEach(function (provider) {
  19215. if (provider.eager) {
  19216. eagerProviders.push(provider);
  19217. }
  19218. else {
  19219. lazyProviders.push(provider);
  19220. }
  19221. });
  19222. return lazyProviders.concat(eagerProviders);
  19223. },
  19224. enumerable: true,
  19225. configurable: true
  19226. });
  19227. Object.defineProperty(ProviderElementContext.prototype, "transformedDirectiveAsts", {
  19228. get: /**
  19229. * @return {?}
  19230. */
  19231. function () {
  19232. var /** @type {?} */ sortedProviderTypes = this.transformProviders.map(function (provider) { return provider.token.identifier; });
  19233. var /** @type {?} */ sortedDirectives = this._directiveAsts.slice();
  19234. sortedDirectives.sort(function (dir1, dir2) {
  19235. return sortedProviderTypes.indexOf(dir1.directive.type) -
  19236. sortedProviderTypes.indexOf(dir2.directive.type);
  19237. });
  19238. return sortedDirectives;
  19239. },
  19240. enumerable: true,
  19241. configurable: true
  19242. });
  19243. Object.defineProperty(ProviderElementContext.prototype, "queryMatches", {
  19244. get: /**
  19245. * @return {?}
  19246. */
  19247. function () {
  19248. var /** @type {?} */ allMatches = [];
  19249. this._queriedTokens.forEach(function (matches) { allMatches.push.apply(allMatches, matches); });
  19250. return allMatches;
  19251. },
  19252. enumerable: true,
  19253. configurable: true
  19254. });
  19255. /**
  19256. * @param {?} token
  19257. * @param {?} defaultValue
  19258. * @param {?} queryReadTokens
  19259. * @return {?}
  19260. */
  19261. ProviderElementContext.prototype._addQueryReadsTo = /**
  19262. * @param {?} token
  19263. * @param {?} defaultValue
  19264. * @param {?} queryReadTokens
  19265. * @return {?}
  19266. */
  19267. function (token, defaultValue, queryReadTokens) {
  19268. this._getQueriesFor(token).forEach(function (query) {
  19269. var /** @type {?} */ queryValue = query.meta.read || defaultValue;
  19270. var /** @type {?} */ tokenRef = tokenReference(queryValue);
  19271. var /** @type {?} */ queryMatches = queryReadTokens.get(tokenRef);
  19272. if (!queryMatches) {
  19273. queryMatches = [];
  19274. queryReadTokens.set(tokenRef, queryMatches);
  19275. }
  19276. queryMatches.push({ queryId: query.queryId, value: queryValue });
  19277. });
  19278. };
  19279. /**
  19280. * @param {?} token
  19281. * @return {?}
  19282. */
  19283. ProviderElementContext.prototype._getQueriesFor = /**
  19284. * @param {?} token
  19285. * @return {?}
  19286. */
  19287. function (token) {
  19288. var /** @type {?} */ result = [];
  19289. var /** @type {?} */ currentEl = this;
  19290. var /** @type {?} */ distance = 0;
  19291. var /** @type {?} */ queries;
  19292. while (currentEl !== null) {
  19293. queries = currentEl._contentQueries.get(tokenReference(token));
  19294. if (queries) {
  19295. result.push.apply(result, queries.filter(function (query) { return query.meta.descendants || distance <= 1; }));
  19296. }
  19297. if (currentEl._directiveAsts.length > 0) {
  19298. distance++;
  19299. }
  19300. currentEl = currentEl._parent;
  19301. }
  19302. queries = this.viewContext.viewQueries.get(tokenReference(token));
  19303. if (queries) {
  19304. result.push.apply(result, queries);
  19305. }
  19306. return result;
  19307. };
  19308. /**
  19309. * @param {?} requestingProviderType
  19310. * @param {?} token
  19311. * @param {?} eager
  19312. * @return {?}
  19313. */
  19314. ProviderElementContext.prototype._getOrCreateLocalProvider = /**
  19315. * @param {?} requestingProviderType
  19316. * @param {?} token
  19317. * @param {?} eager
  19318. * @return {?}
  19319. */
  19320. function (requestingProviderType, token, eager) {
  19321. var _this = this;
  19322. var /** @type {?} */ resolvedProvider = this._allProviders.get(tokenReference(token));
  19323. if (!resolvedProvider || ((requestingProviderType === ProviderAstType.Directive ||
  19324. requestingProviderType === ProviderAstType.PublicService) &&
  19325. resolvedProvider.providerType === ProviderAstType.PrivateService) ||
  19326. ((requestingProviderType === ProviderAstType.PrivateService ||
  19327. requestingProviderType === ProviderAstType.PublicService) &&
  19328. resolvedProvider.providerType === ProviderAstType.Builtin)) {
  19329. return null;
  19330. }
  19331. var /** @type {?} */ transformedProviderAst = this._transformedProviders.get(tokenReference(token));
  19332. if (transformedProviderAst) {
  19333. return transformedProviderAst;
  19334. }
  19335. if (this._seenProviders.get(tokenReference(token)) != null) {
  19336. this.viewContext.errors.push(new ProviderError("Cannot instantiate cyclic dependency! " + tokenName(token), this._sourceSpan));
  19337. return null;
  19338. }
  19339. this._seenProviders.set(tokenReference(token), true);
  19340. var /** @type {?} */ transformedProviders = resolvedProvider.providers.map(function (provider) {
  19341. var /** @type {?} */ transformedUseValue = provider.useValue;
  19342. var /** @type {?} */ transformedUseExisting = /** @type {?} */ ((provider.useExisting));
  19343. var /** @type {?} */ transformedDeps = /** @type {?} */ ((undefined));
  19344. if (provider.useExisting != null) {
  19345. var /** @type {?} */ existingDiDep = /** @type {?} */ ((_this._getDependency(resolvedProvider.providerType, { token: provider.useExisting }, eager)));
  19346. if (existingDiDep.token != null) {
  19347. transformedUseExisting = existingDiDep.token;
  19348. }
  19349. else {
  19350. transformedUseExisting = /** @type {?} */ ((null));
  19351. transformedUseValue = existingDiDep.value;
  19352. }
  19353. }
  19354. else if (provider.useFactory) {
  19355. var /** @type {?} */ deps = provider.deps || provider.useFactory.diDeps;
  19356. transformedDeps =
  19357. deps.map(function (dep) { return ((_this._getDependency(resolvedProvider.providerType, dep, eager))); });
  19358. }
  19359. else if (provider.useClass) {
  19360. var /** @type {?} */ deps = provider.deps || provider.useClass.diDeps;
  19361. transformedDeps =
  19362. deps.map(function (dep) { return ((_this._getDependency(resolvedProvider.providerType, dep, eager))); });
  19363. }
  19364. return _transformProvider(provider, {
  19365. useExisting: transformedUseExisting,
  19366. useValue: transformedUseValue,
  19367. deps: transformedDeps
  19368. });
  19369. });
  19370. transformedProviderAst =
  19371. _transformProviderAst(resolvedProvider, { eager: eager, providers: transformedProviders });
  19372. this._transformedProviders.set(tokenReference(token), transformedProviderAst);
  19373. return transformedProviderAst;
  19374. };
  19375. /**
  19376. * @param {?} requestingProviderType
  19377. * @param {?} dep
  19378. * @param {?=} eager
  19379. * @return {?}
  19380. */
  19381. ProviderElementContext.prototype._getLocalDependency = /**
  19382. * @param {?} requestingProviderType
  19383. * @param {?} dep
  19384. * @param {?=} eager
  19385. * @return {?}
  19386. */
  19387. function (requestingProviderType, dep, eager) {
  19388. if (eager === void 0) { eager = false; }
  19389. if (dep.isAttribute) {
  19390. var /** @type {?} */ attrValue = this._attrs[/** @type {?} */ ((dep.token)).value];
  19391. return { isValue: true, value: attrValue == null ? null : attrValue };
  19392. }
  19393. if (dep.token != null) {
  19394. // access builtints
  19395. if ((requestingProviderType === ProviderAstType.Directive ||
  19396. requestingProviderType === ProviderAstType.Component)) {
  19397. if (tokenReference(dep.token) ===
  19398. this.viewContext.reflector.resolveExternalReference(Identifiers.Renderer) ||
  19399. tokenReference(dep.token) ===
  19400. this.viewContext.reflector.resolveExternalReference(Identifiers.ElementRef) ||
  19401. tokenReference(dep.token) ===
  19402. this.viewContext.reflector.resolveExternalReference(Identifiers.ChangeDetectorRef) ||
  19403. tokenReference(dep.token) ===
  19404. this.viewContext.reflector.resolveExternalReference(Identifiers.TemplateRef)) {
  19405. return dep;
  19406. }
  19407. if (tokenReference(dep.token) ===
  19408. this.viewContext.reflector.resolveExternalReference(Identifiers.ViewContainerRef)) {
  19409. (/** @type {?} */ (this)).transformedHasViewContainer = true;
  19410. }
  19411. }
  19412. // access the injector
  19413. if (tokenReference(dep.token) ===
  19414. this.viewContext.reflector.resolveExternalReference(Identifiers.Injector)) {
  19415. return dep;
  19416. }
  19417. // access providers
  19418. if (this._getOrCreateLocalProvider(requestingProviderType, dep.token, eager) != null) {
  19419. return dep;
  19420. }
  19421. }
  19422. return null;
  19423. };
  19424. /**
  19425. * @param {?} requestingProviderType
  19426. * @param {?} dep
  19427. * @param {?=} eager
  19428. * @return {?}
  19429. */
  19430. ProviderElementContext.prototype._getDependency = /**
  19431. * @param {?} requestingProviderType
  19432. * @param {?} dep
  19433. * @param {?=} eager
  19434. * @return {?}
  19435. */
  19436. function (requestingProviderType, dep, eager) {
  19437. if (eager === void 0) { eager = false; }
  19438. var /** @type {?} */ currElement = this;
  19439. var /** @type {?} */ currEager = eager;
  19440. var /** @type {?} */ result = null;
  19441. if (!dep.isSkipSelf) {
  19442. result = this._getLocalDependency(requestingProviderType, dep, eager);
  19443. }
  19444. if (dep.isSelf) {
  19445. if (!result && dep.isOptional) {
  19446. result = { isValue: true, value: null };
  19447. }
  19448. }
  19449. else {
  19450. // check parent elements
  19451. while (!result && currElement._parent) {
  19452. var /** @type {?} */ prevElement = currElement;
  19453. currElement = currElement._parent;
  19454. if (prevElement._isViewRoot) {
  19455. currEager = false;
  19456. }
  19457. result = currElement._getLocalDependency(ProviderAstType.PublicService, dep, currEager);
  19458. }
  19459. // check @Host restriction
  19460. if (!result) {
  19461. if (!dep.isHost || this.viewContext.component.isHost ||
  19462. this.viewContext.component.type.reference === tokenReference(/** @type {?} */ ((dep.token))) ||
  19463. this.viewContext.viewProviders.get(tokenReference(/** @type {?} */ ((dep.token)))) != null) {
  19464. result = dep;
  19465. }
  19466. else {
  19467. result = dep.isOptional ? result = { isValue: true, value: null } : null;
  19468. }
  19469. }
  19470. }
  19471. if (!result) {
  19472. this.viewContext.errors.push(new ProviderError("No provider for " + tokenName((/** @type {?} */ ((dep.token)))), this._sourceSpan));
  19473. }
  19474. return result;
  19475. };
  19476. return ProviderElementContext;
  19477. }());
  19478. var NgModuleProviderAnalyzer = /** @class */ (function () {
  19479. function NgModuleProviderAnalyzer(reflector, ngModule, extraProviders, sourceSpan) {
  19480. var _this = this;
  19481. this.reflector = reflector;
  19482. this._transformedProviders = new Map();
  19483. this._seenProviders = new Map();
  19484. this._errors = [];
  19485. this._allProviders = new Map();
  19486. ngModule.transitiveModule.modules.forEach(function (ngModuleType) {
  19487. var /** @type {?} */ ngModuleProvider = { token: { identifier: ngModuleType }, useClass: ngModuleType };
  19488. _resolveProviders([ngModuleProvider], ProviderAstType.PublicService, true, sourceSpan, _this._errors, _this._allProviders);
  19489. });
  19490. _resolveProviders(ngModule.transitiveModule.providers.map(function (entry) { return entry.provider; }).concat(extraProviders), ProviderAstType.PublicService, false, sourceSpan, this._errors, this._allProviders);
  19491. }
  19492. /**
  19493. * @return {?}
  19494. */
  19495. NgModuleProviderAnalyzer.prototype.parse = /**
  19496. * @return {?}
  19497. */
  19498. function () {
  19499. var _this = this;
  19500. Array.from(this._allProviders.values()).forEach(function (provider) {
  19501. _this._getOrCreateLocalProvider(provider.token, provider.eager);
  19502. });
  19503. if (this._errors.length > 0) {
  19504. var /** @type {?} */ errorString = this._errors.join('\n');
  19505. throw new Error("Provider parse errors:\n" + errorString);
  19506. }
  19507. // Note: Maps keep their insertion order.
  19508. var /** @type {?} */ lazyProviders = [];
  19509. var /** @type {?} */ eagerProviders = [];
  19510. this._transformedProviders.forEach(function (provider) {
  19511. if (provider.eager) {
  19512. eagerProviders.push(provider);
  19513. }
  19514. else {
  19515. lazyProviders.push(provider);
  19516. }
  19517. });
  19518. return lazyProviders.concat(eagerProviders);
  19519. };
  19520. /**
  19521. * @param {?} token
  19522. * @param {?} eager
  19523. * @return {?}
  19524. */
  19525. NgModuleProviderAnalyzer.prototype._getOrCreateLocalProvider = /**
  19526. * @param {?} token
  19527. * @param {?} eager
  19528. * @return {?}
  19529. */
  19530. function (token, eager) {
  19531. var _this = this;
  19532. var /** @type {?} */ resolvedProvider = this._allProviders.get(tokenReference(token));
  19533. if (!resolvedProvider) {
  19534. return null;
  19535. }
  19536. var /** @type {?} */ transformedProviderAst = this._transformedProviders.get(tokenReference(token));
  19537. if (transformedProviderAst) {
  19538. return transformedProviderAst;
  19539. }
  19540. if (this._seenProviders.get(tokenReference(token)) != null) {
  19541. this._errors.push(new ProviderError("Cannot instantiate cyclic dependency! " + tokenName(token), resolvedProvider.sourceSpan));
  19542. return null;
  19543. }
  19544. this._seenProviders.set(tokenReference(token), true);
  19545. var /** @type {?} */ transformedProviders = resolvedProvider.providers.map(function (provider) {
  19546. var /** @type {?} */ transformedUseValue = provider.useValue;
  19547. var /** @type {?} */ transformedUseExisting = /** @type {?} */ ((provider.useExisting));
  19548. var /** @type {?} */ transformedDeps = /** @type {?} */ ((undefined));
  19549. if (provider.useExisting != null) {
  19550. var /** @type {?} */ existingDiDep = _this._getDependency({ token: provider.useExisting }, eager, resolvedProvider.sourceSpan);
  19551. if (existingDiDep.token != null) {
  19552. transformedUseExisting = existingDiDep.token;
  19553. }
  19554. else {
  19555. transformedUseExisting = /** @type {?} */ ((null));
  19556. transformedUseValue = existingDiDep.value;
  19557. }
  19558. }
  19559. else if (provider.useFactory) {
  19560. var /** @type {?} */ deps = provider.deps || provider.useFactory.diDeps;
  19561. transformedDeps =
  19562. deps.map(function (dep) { return _this._getDependency(dep, eager, resolvedProvider.sourceSpan); });
  19563. }
  19564. else if (provider.useClass) {
  19565. var /** @type {?} */ deps = provider.deps || provider.useClass.diDeps;
  19566. transformedDeps =
  19567. deps.map(function (dep) { return _this._getDependency(dep, eager, resolvedProvider.sourceSpan); });
  19568. }
  19569. return _transformProvider(provider, {
  19570. useExisting: transformedUseExisting,
  19571. useValue: transformedUseValue,
  19572. deps: transformedDeps
  19573. });
  19574. });
  19575. transformedProviderAst =
  19576. _transformProviderAst(resolvedProvider, { eager: eager, providers: transformedProviders });
  19577. this._transformedProviders.set(tokenReference(token), transformedProviderAst);
  19578. return transformedProviderAst;
  19579. };
  19580. /**
  19581. * @param {?} dep
  19582. * @param {?=} eager
  19583. * @param {?=} requestorSourceSpan
  19584. * @return {?}
  19585. */
  19586. NgModuleProviderAnalyzer.prototype._getDependency = /**
  19587. * @param {?} dep
  19588. * @param {?=} eager
  19589. * @param {?=} requestorSourceSpan
  19590. * @return {?}
  19591. */
  19592. function (dep, eager, requestorSourceSpan) {
  19593. if (eager === void 0) { eager = false; }
  19594. var /** @type {?} */ foundLocal = false;
  19595. if (!dep.isSkipSelf && dep.token != null) {
  19596. // access the injector
  19597. if (tokenReference(dep.token) ===
  19598. this.reflector.resolveExternalReference(Identifiers.Injector) ||
  19599. tokenReference(dep.token) ===
  19600. this.reflector.resolveExternalReference(Identifiers.ComponentFactoryResolver)) {
  19601. foundLocal = true;
  19602. // access providers
  19603. }
  19604. else if (this._getOrCreateLocalProvider(dep.token, eager) != null) {
  19605. foundLocal = true;
  19606. }
  19607. }
  19608. var /** @type {?} */ result = dep;
  19609. if (dep.isSelf && !foundLocal) {
  19610. if (dep.isOptional) {
  19611. result = { isValue: true, value: null };
  19612. }
  19613. else {
  19614. this._errors.push(new ProviderError("No provider for " + tokenName((/** @type {?} */ ((dep.token)))), requestorSourceSpan));
  19615. }
  19616. }
  19617. return result;
  19618. };
  19619. return NgModuleProviderAnalyzer;
  19620. }());
  19621. /**
  19622. * @param {?} provider
  19623. * @param {?} __1
  19624. * @return {?}
  19625. */
  19626. function _transformProvider(provider, _a) {
  19627. var useExisting = _a.useExisting, useValue = _a.useValue, deps = _a.deps;
  19628. return {
  19629. token: provider.token,
  19630. useClass: provider.useClass,
  19631. useExisting: useExisting,
  19632. useFactory: provider.useFactory,
  19633. useValue: useValue,
  19634. deps: deps,
  19635. multi: provider.multi
  19636. };
  19637. }
  19638. /**
  19639. * @param {?} provider
  19640. * @param {?} __1
  19641. * @return {?}
  19642. */
  19643. function _transformProviderAst(provider, _a) {
  19644. var eager = _a.eager, providers = _a.providers;
  19645. return new ProviderAst(provider.token, provider.multiProvider, provider.eager || eager, providers, provider.providerType, provider.lifecycleHooks, provider.sourceSpan);
  19646. }
  19647. /**
  19648. * @param {?} directives
  19649. * @param {?} sourceSpan
  19650. * @param {?} targetErrors
  19651. * @return {?}
  19652. */
  19653. function _resolveProvidersFromDirectives(directives, sourceSpan, targetErrors) {
  19654. var /** @type {?} */ providersByToken = new Map();
  19655. directives.forEach(function (directive) {
  19656. var /** @type {?} */ dirProvider = { token: { identifier: directive.type }, useClass: directive.type };
  19657. _resolveProviders([dirProvider], directive.isComponent ? ProviderAstType.Component : ProviderAstType.Directive, true, sourceSpan, targetErrors, providersByToken);
  19658. });
  19659. // Note: directives need to be able to overwrite providers of a component!
  19660. var /** @type {?} */ directivesWithComponentFirst = directives.filter(function (dir) { return dir.isComponent; }).concat(directives.filter(function (dir) { return !dir.isComponent; }));
  19661. directivesWithComponentFirst.forEach(function (directive) {
  19662. _resolveProviders(directive.providers, ProviderAstType.PublicService, false, sourceSpan, targetErrors, providersByToken);
  19663. _resolveProviders(directive.viewProviders, ProviderAstType.PrivateService, false, sourceSpan, targetErrors, providersByToken);
  19664. });
  19665. return providersByToken;
  19666. }
  19667. /**
  19668. * @param {?} providers
  19669. * @param {?} providerType
  19670. * @param {?} eager
  19671. * @param {?} sourceSpan
  19672. * @param {?} targetErrors
  19673. * @param {?} targetProvidersByToken
  19674. * @return {?}
  19675. */
  19676. function _resolveProviders(providers, providerType, eager, sourceSpan, targetErrors, targetProvidersByToken) {
  19677. providers.forEach(function (provider) {
  19678. var /** @type {?} */ resolvedProvider = targetProvidersByToken.get(tokenReference(provider.token));
  19679. if (resolvedProvider != null && !!resolvedProvider.multiProvider !== !!provider.multi) {
  19680. targetErrors.push(new ProviderError("Mixing multi and non multi provider is not possible for token " + tokenName(resolvedProvider.token), sourceSpan));
  19681. }
  19682. if (!resolvedProvider) {
  19683. var /** @type {?} */ lifecycleHooks = provider.token.identifier &&
  19684. (/** @type {?} */ (provider.token.identifier)).lifecycleHooks ?
  19685. (/** @type {?} */ (provider.token.identifier)).lifecycleHooks :
  19686. [];
  19687. var /** @type {?} */ isUseValue = !(provider.useClass || provider.useExisting || provider.useFactory);
  19688. resolvedProvider = new ProviderAst(provider.token, !!provider.multi, eager || isUseValue, [provider], providerType, lifecycleHooks, sourceSpan);
  19689. targetProvidersByToken.set(tokenReference(provider.token), resolvedProvider);
  19690. }
  19691. else {
  19692. if (!provider.multi) {
  19693. resolvedProvider.providers.length = 0;
  19694. }
  19695. resolvedProvider.providers.push(provider);
  19696. }
  19697. });
  19698. }
  19699. /**
  19700. * @param {?} component
  19701. * @return {?}
  19702. */
  19703. function _getViewQueries(component) {
  19704. // Note: queries start with id 1 so we can use the number in a Bloom filter!
  19705. var /** @type {?} */ viewQueryId = 1;
  19706. var /** @type {?} */ viewQueries = new Map();
  19707. if (component.viewQueries) {
  19708. component.viewQueries.forEach(function (query) { return _addQueryToTokenMap(viewQueries, { meta: query, queryId: viewQueryId++ }); });
  19709. }
  19710. return viewQueries;
  19711. }
  19712. /**
  19713. * @param {?} contentQueryStartId
  19714. * @param {?} directives
  19715. * @return {?}
  19716. */
  19717. function _getContentQueries(contentQueryStartId, directives) {
  19718. var /** @type {?} */ contentQueryId = contentQueryStartId;
  19719. var /** @type {?} */ contentQueries = new Map();
  19720. directives.forEach(function (directive, directiveIndex) {
  19721. if (directive.queries) {
  19722. directive.queries.forEach(function (query) { return _addQueryToTokenMap(contentQueries, { meta: query, queryId: contentQueryId++ }); });
  19723. }
  19724. });
  19725. return contentQueries;
  19726. }
  19727. /**
  19728. * @param {?} map
  19729. * @param {?} query
  19730. * @return {?}
  19731. */
  19732. function _addQueryToTokenMap(map, query) {
  19733. query.meta.selectors.forEach(function (token) {
  19734. var /** @type {?} */ entry = map.get(tokenReference(token));
  19735. if (!entry) {
  19736. entry = [];
  19737. map.set(tokenReference(token), entry);
  19738. }
  19739. entry.push(query);
  19740. });
  19741. }
  19742. /**
  19743. * @fileoverview added by tsickle
  19744. * @suppress {checkTypes} checked by tsc
  19745. */
  19746. /**
  19747. * @license
  19748. * Copyright Google Inc. All Rights Reserved.
  19749. *
  19750. * Use of this source code is governed by an MIT-style license that can be
  19751. * found in the LICENSE file at https://angular.io/license
  19752. */
  19753. var QUOTED_KEYS = '$quoted$';
  19754. /**
  19755. * @param {?} ctx
  19756. * @param {?} value
  19757. * @param {?=} type
  19758. * @return {?}
  19759. */
  19760. function convertValueToOutputAst(ctx, value, type) {
  19761. if (type === void 0) { type = null; }
  19762. return visitValue(value, new _ValueOutputAstTransformer(ctx), type);
  19763. }
  19764. var _ValueOutputAstTransformer = /** @class */ (function () {
  19765. function _ValueOutputAstTransformer(ctx) {
  19766. this.ctx = ctx;
  19767. }
  19768. /**
  19769. * @param {?} arr
  19770. * @param {?} type
  19771. * @return {?}
  19772. */
  19773. _ValueOutputAstTransformer.prototype.visitArray = /**
  19774. * @param {?} arr
  19775. * @param {?} type
  19776. * @return {?}
  19777. */
  19778. function (arr, type) {
  19779. var _this = this;
  19780. return literalArr(arr.map(function (value) { return visitValue(value, _this, null); }), type);
  19781. };
  19782. /**
  19783. * @param {?} map
  19784. * @param {?} type
  19785. * @return {?}
  19786. */
  19787. _ValueOutputAstTransformer.prototype.visitStringMap = /**
  19788. * @param {?} map
  19789. * @param {?} type
  19790. * @return {?}
  19791. */
  19792. function (map, type) {
  19793. var _this = this;
  19794. var /** @type {?} */ entries = [];
  19795. var /** @type {?} */ quotedSet = new Set(map && map[QUOTED_KEYS]);
  19796. Object.keys(map).forEach(function (key) {
  19797. entries.push(new LiteralMapEntry(key, visitValue(map[key], _this, null), quotedSet.has(key)));
  19798. });
  19799. return new LiteralMapExpr(entries, type);
  19800. };
  19801. /**
  19802. * @param {?} value
  19803. * @param {?} type
  19804. * @return {?}
  19805. */
  19806. _ValueOutputAstTransformer.prototype.visitPrimitive = /**
  19807. * @param {?} value
  19808. * @param {?} type
  19809. * @return {?}
  19810. */
  19811. function (value, type) { return literal(value, type); };
  19812. /**
  19813. * @param {?} value
  19814. * @param {?} type
  19815. * @return {?}
  19816. */
  19817. _ValueOutputAstTransformer.prototype.visitOther = /**
  19818. * @param {?} value
  19819. * @param {?} type
  19820. * @return {?}
  19821. */
  19822. function (value, type) {
  19823. if (value instanceof Expression) {
  19824. return value;
  19825. }
  19826. else {
  19827. return this.ctx.importExpr(value);
  19828. }
  19829. };
  19830. return _ValueOutputAstTransformer;
  19831. }());
  19832. /**
  19833. * @fileoverview added by tsickle
  19834. * @suppress {checkTypes} checked by tsc
  19835. */
  19836. /**
  19837. * @license
  19838. * Copyright Google Inc. All Rights Reserved.
  19839. *
  19840. * Use of this source code is governed by an MIT-style license that can be
  19841. * found in the LICENSE file at https://angular.io/license
  19842. */
  19843. /**
  19844. * @param {?} ctx
  19845. * @param {?} providerAst
  19846. * @return {?}
  19847. */
  19848. function providerDef(ctx, providerAst) {
  19849. var /** @type {?} */ flags = 0;
  19850. if (!providerAst.eager) {
  19851. flags |= 4096 /* LazyProvider */;
  19852. }
  19853. if (providerAst.providerType === ProviderAstType.PrivateService) {
  19854. flags |= 8192 /* PrivateProvider */;
  19855. }
  19856. providerAst.lifecycleHooks.forEach(function (lifecycleHook) {
  19857. // for regular providers, we only support ngOnDestroy
  19858. if (lifecycleHook === LifecycleHooks.OnDestroy ||
  19859. providerAst.providerType === ProviderAstType.Directive ||
  19860. providerAst.providerType === ProviderAstType.Component) {
  19861. flags |= lifecycleHookToNodeFlag(lifecycleHook);
  19862. }
  19863. });
  19864. var _a = providerAst.multiProvider ?
  19865. multiProviderDef(ctx, flags, providerAst.providers) :
  19866. singleProviderDef(ctx, flags, providerAst.providerType, providerAst.providers[0]), providerExpr = _a.providerExpr, providerFlags = _a.flags, depsExpr = _a.depsExpr;
  19867. return {
  19868. providerExpr: providerExpr,
  19869. flags: providerFlags, depsExpr: depsExpr,
  19870. tokenExpr: tokenExpr(ctx, providerAst.token),
  19871. };
  19872. }
  19873. /**
  19874. * @param {?} ctx
  19875. * @param {?} flags
  19876. * @param {?} providers
  19877. * @return {?}
  19878. */
  19879. function multiProviderDef(ctx, flags, providers) {
  19880. var /** @type {?} */ allDepDefs = [];
  19881. var /** @type {?} */ allParams = [];
  19882. var /** @type {?} */ exprs = providers.map(function (provider, providerIndex) {
  19883. var /** @type {?} */ expr;
  19884. if (provider.useClass) {
  19885. var /** @type {?} */ depExprs = convertDeps(providerIndex, provider.deps || provider.useClass.diDeps);
  19886. expr = ctx.importExpr(provider.useClass.reference).instantiate(depExprs);
  19887. }
  19888. else if (provider.useFactory) {
  19889. var /** @type {?} */ depExprs = convertDeps(providerIndex, provider.deps || provider.useFactory.diDeps);
  19890. expr = ctx.importExpr(provider.useFactory.reference).callFn(depExprs);
  19891. }
  19892. else if (provider.useExisting) {
  19893. var /** @type {?} */ depExprs = convertDeps(providerIndex, [{ token: provider.useExisting }]);
  19894. expr = depExprs[0];
  19895. }
  19896. else {
  19897. expr = convertValueToOutputAst(ctx, provider.useValue);
  19898. }
  19899. return expr;
  19900. });
  19901. var /** @type {?} */ providerExpr = fn(allParams, [new ReturnStatement(literalArr(exprs))], INFERRED_TYPE);
  19902. return {
  19903. providerExpr: providerExpr,
  19904. flags: flags | 1024 /* TypeFactoryProvider */,
  19905. depsExpr: literalArr(allDepDefs)
  19906. };
  19907. /**
  19908. * @param {?} providerIndex
  19909. * @param {?} deps
  19910. * @return {?}
  19911. */
  19912. function convertDeps(providerIndex, deps) {
  19913. return deps.map(function (dep, depIndex) {
  19914. var /** @type {?} */ paramName = "p" + providerIndex + "_" + depIndex;
  19915. allParams.push(new FnParam(paramName, DYNAMIC_TYPE));
  19916. allDepDefs.push(depDef(ctx, dep));
  19917. return variable(paramName);
  19918. });
  19919. }
  19920. }
  19921. /**
  19922. * @param {?} ctx
  19923. * @param {?} flags
  19924. * @param {?} providerType
  19925. * @param {?} providerMeta
  19926. * @return {?}
  19927. */
  19928. function singleProviderDef(ctx, flags, providerType, providerMeta) {
  19929. var /** @type {?} */ providerExpr;
  19930. var /** @type {?} */ deps;
  19931. if (providerType === ProviderAstType.Directive || providerType === ProviderAstType.Component) {
  19932. providerExpr = ctx.importExpr(/** @type {?} */ ((providerMeta.useClass)).reference);
  19933. flags |= 16384 /* TypeDirective */;
  19934. deps = providerMeta.deps || /** @type {?} */ ((providerMeta.useClass)).diDeps;
  19935. }
  19936. else {
  19937. if (providerMeta.useClass) {
  19938. providerExpr = ctx.importExpr(providerMeta.useClass.reference);
  19939. flags |= 512 /* TypeClassProvider */;
  19940. deps = providerMeta.deps || providerMeta.useClass.diDeps;
  19941. }
  19942. else if (providerMeta.useFactory) {
  19943. providerExpr = ctx.importExpr(providerMeta.useFactory.reference);
  19944. flags |= 1024 /* TypeFactoryProvider */;
  19945. deps = providerMeta.deps || providerMeta.useFactory.diDeps;
  19946. }
  19947. else if (providerMeta.useExisting) {
  19948. providerExpr = NULL_EXPR;
  19949. flags |= 2048 /* TypeUseExistingProvider */;
  19950. deps = [{ token: providerMeta.useExisting }];
  19951. }
  19952. else {
  19953. providerExpr = convertValueToOutputAst(ctx, providerMeta.useValue);
  19954. flags |= 256 /* TypeValueProvider */;
  19955. deps = [];
  19956. }
  19957. }
  19958. var /** @type {?} */ depsExpr = literalArr(deps.map(function (dep) { return depDef(ctx, dep); }));
  19959. return { providerExpr: providerExpr, flags: flags, depsExpr: depsExpr };
  19960. }
  19961. /**
  19962. * @param {?} ctx
  19963. * @param {?} tokenMeta
  19964. * @return {?}
  19965. */
  19966. function tokenExpr(ctx, tokenMeta) {
  19967. return tokenMeta.identifier ? ctx.importExpr(tokenMeta.identifier.reference) :
  19968. literal(tokenMeta.value);
  19969. }
  19970. /**
  19971. * @param {?} ctx
  19972. * @param {?} dep
  19973. * @return {?}
  19974. */
  19975. function depDef(ctx, dep) {
  19976. // Note: the following fields have already been normalized out by provider_analyzer:
  19977. // - isAttribute, isSelf, isHost
  19978. var /** @type {?} */ expr = dep.isValue ? convertValueToOutputAst(ctx, dep.value) : tokenExpr(ctx, /** @type {?} */ ((dep.token)));
  19979. var /** @type {?} */ flags = 0;
  19980. if (dep.isSkipSelf) {
  19981. flags |= 1 /* SkipSelf */;
  19982. }
  19983. if (dep.isOptional) {
  19984. flags |= 2 /* Optional */;
  19985. }
  19986. if (dep.isValue) {
  19987. flags |= 8 /* Value */;
  19988. }
  19989. return flags === 0 /* None */ ? expr : literalArr([literal(flags), expr]);
  19990. }
  19991. /**
  19992. * @param {?} lifecycleHook
  19993. * @return {?}
  19994. */
  19995. function lifecycleHookToNodeFlag(lifecycleHook) {
  19996. var /** @type {?} */ nodeFlag = 0;
  19997. switch (lifecycleHook) {
  19998. case LifecycleHooks.AfterContentChecked:
  19999. nodeFlag = 2097152 /* AfterContentChecked */;
  20000. break;
  20001. case LifecycleHooks.AfterContentInit:
  20002. nodeFlag = 1048576 /* AfterContentInit */;
  20003. break;
  20004. case LifecycleHooks.AfterViewChecked:
  20005. nodeFlag = 8388608 /* AfterViewChecked */;
  20006. break;
  20007. case LifecycleHooks.AfterViewInit:
  20008. nodeFlag = 4194304 /* AfterViewInit */;
  20009. break;
  20010. case LifecycleHooks.DoCheck:
  20011. nodeFlag = 262144 /* DoCheck */;
  20012. break;
  20013. case LifecycleHooks.OnChanges:
  20014. nodeFlag = 524288 /* OnChanges */;
  20015. break;
  20016. case LifecycleHooks.OnDestroy:
  20017. nodeFlag = 131072 /* OnDestroy */;
  20018. break;
  20019. case LifecycleHooks.OnInit:
  20020. nodeFlag = 65536 /* OnInit */;
  20021. break;
  20022. }
  20023. return nodeFlag;
  20024. }
  20025. /**
  20026. * @param {?} reflector
  20027. * @param {?} ctx
  20028. * @param {?} flags
  20029. * @param {?} entryComponents
  20030. * @return {?}
  20031. */
  20032. function componentFactoryResolverProviderDef(reflector, ctx, flags, entryComponents) {
  20033. var /** @type {?} */ entryComponentFactories = entryComponents.map(function (entryComponent) { return ctx.importExpr(entryComponent.componentFactory); });
  20034. var /** @type {?} */ token = createTokenForExternalReference(reflector, Identifiers.ComponentFactoryResolver);
  20035. var /** @type {?} */ classMeta = {
  20036. diDeps: [
  20037. { isValue: true, value: literalArr(entryComponentFactories) },
  20038. { token: token, isSkipSelf: true, isOptional: true },
  20039. { token: createTokenForExternalReference(reflector, Identifiers.NgModuleRef) },
  20040. ],
  20041. lifecycleHooks: [],
  20042. reference: reflector.resolveExternalReference(Identifiers.CodegenComponentFactoryResolver)
  20043. };
  20044. var _a = singleProviderDef(ctx, flags, ProviderAstType.PrivateService, {
  20045. token: token,
  20046. multi: false,
  20047. useClass: classMeta,
  20048. }), providerExpr = _a.providerExpr, providerFlags = _a.flags, depsExpr = _a.depsExpr;
  20049. return { providerExpr: providerExpr, flags: providerFlags, depsExpr: depsExpr, tokenExpr: tokenExpr(ctx, token) };
  20050. }
  20051. /**
  20052. * @fileoverview added by tsickle
  20053. * @suppress {checkTypes} checked by tsc
  20054. */
  20055. /**
  20056. * @license
  20057. * Copyright Google Inc. All Rights Reserved.
  20058. *
  20059. * Use of this source code is governed by an MIT-style license that can be
  20060. * found in the LICENSE file at https://angular.io/license
  20061. */
  20062. var NgModuleCompileResult = /** @class */ (function () {
  20063. function NgModuleCompileResult(ngModuleFactoryVar) {
  20064. this.ngModuleFactoryVar = ngModuleFactoryVar;
  20065. }
  20066. return NgModuleCompileResult;
  20067. }());
  20068. var LOG_VAR = variable('_l');
  20069. var NgModuleCompiler = /** @class */ (function () {
  20070. function NgModuleCompiler(reflector) {
  20071. this.reflector = reflector;
  20072. }
  20073. /**
  20074. * @param {?} ctx
  20075. * @param {?} ngModuleMeta
  20076. * @param {?} extraProviders
  20077. * @return {?}
  20078. */
  20079. NgModuleCompiler.prototype.compile = /**
  20080. * @param {?} ctx
  20081. * @param {?} ngModuleMeta
  20082. * @param {?} extraProviders
  20083. * @return {?}
  20084. */
  20085. function (ctx, ngModuleMeta, extraProviders) {
  20086. var /** @type {?} */ sourceSpan = typeSourceSpan('NgModule', ngModuleMeta.type);
  20087. var /** @type {?} */ entryComponentFactories = ngModuleMeta.transitiveModule.entryComponents;
  20088. var /** @type {?} */ bootstrapComponents = ngModuleMeta.bootstrapComponents;
  20089. var /** @type {?} */ providerParser = new NgModuleProviderAnalyzer(this.reflector, ngModuleMeta, extraProviders, sourceSpan);
  20090. var /** @type {?} */ providerDefs = [componentFactoryResolverProviderDef(this.reflector, ctx, 0 /* None */, entryComponentFactories)]
  20091. .concat(providerParser.parse().map(function (provider) { return providerDef(ctx, provider); }))
  20092. .map(function (_a) {
  20093. var providerExpr = _a.providerExpr, depsExpr = _a.depsExpr, flags = _a.flags, tokenExpr = _a.tokenExpr;
  20094. return importExpr(Identifiers.moduleProviderDef).callFn([
  20095. literal(flags), tokenExpr, providerExpr, depsExpr
  20096. ]);
  20097. });
  20098. var /** @type {?} */ ngModuleDef = importExpr(Identifiers.moduleDef).callFn([literalArr(providerDefs)]);
  20099. var /** @type {?} */ ngModuleDefFactory = fn([new FnParam(/** @type {?} */ ((LOG_VAR.name)))], [new ReturnStatement(ngModuleDef)], INFERRED_TYPE);
  20100. var /** @type {?} */ ngModuleFactoryVar = identifierName(ngModuleMeta.type) + "NgFactory";
  20101. this._createNgModuleFactory(ctx, ngModuleMeta.type.reference, importExpr(Identifiers.createModuleFactory).callFn([
  20102. ctx.importExpr(ngModuleMeta.type.reference),
  20103. literalArr(bootstrapComponents.map(function (id) { return ctx.importExpr(id.reference); })),
  20104. ngModuleDefFactory
  20105. ]));
  20106. if (ngModuleMeta.id) {
  20107. var /** @type {?} */ registerFactoryStmt = importExpr(Identifiers.RegisterModuleFactoryFn)
  20108. .callFn([literal(ngModuleMeta.id), variable(ngModuleFactoryVar)])
  20109. .toStmt();
  20110. ctx.statements.push(registerFactoryStmt);
  20111. }
  20112. return new NgModuleCompileResult(ngModuleFactoryVar);
  20113. };
  20114. /**
  20115. * @param {?} ctx
  20116. * @param {?} ngModuleReference
  20117. * @return {?}
  20118. */
  20119. NgModuleCompiler.prototype.createStub = /**
  20120. * @param {?} ctx
  20121. * @param {?} ngModuleReference
  20122. * @return {?}
  20123. */
  20124. function (ctx, ngModuleReference) {
  20125. this._createNgModuleFactory(ctx, ngModuleReference, NULL_EXPR);
  20126. };
  20127. /**
  20128. * @param {?} ctx
  20129. * @param {?} reference
  20130. * @param {?} value
  20131. * @return {?}
  20132. */
  20133. NgModuleCompiler.prototype._createNgModuleFactory = /**
  20134. * @param {?} ctx
  20135. * @param {?} reference
  20136. * @param {?} value
  20137. * @return {?}
  20138. */
  20139. function (ctx, reference, value) {
  20140. var /** @type {?} */ ngModuleFactoryVar = identifierName({ reference: reference }) + "NgFactory";
  20141. var /** @type {?} */ ngModuleFactoryStmt = variable(ngModuleFactoryVar)
  20142. .set(value)
  20143. .toDeclStmt(importType(Identifiers.NgModuleFactory, [/** @type {?} */ ((expressionType(ctx.importExpr(reference))))], [TypeModifier.Const]), [StmtModifier.Final, StmtModifier.Exported]);
  20144. ctx.statements.push(ngModuleFactoryStmt);
  20145. };
  20146. return NgModuleCompiler;
  20147. }());
  20148. /**
  20149. * @fileoverview added by tsickle
  20150. * @suppress {checkTypes} checked by tsc
  20151. */
  20152. /**
  20153. * @license
  20154. * Copyright Google Inc. All Rights Reserved.
  20155. *
  20156. * Use of this source code is governed by an MIT-style license that can be
  20157. * found in the LICENSE file at https://angular.io/license
  20158. */
  20159. /**
  20160. * Resolves types to {\@link NgModule}.
  20161. */
  20162. var NgModuleResolver = /** @class */ (function () {
  20163. function NgModuleResolver(_reflector) {
  20164. this._reflector = _reflector;
  20165. }
  20166. /**
  20167. * @param {?} type
  20168. * @return {?}
  20169. */
  20170. NgModuleResolver.prototype.isNgModule = /**
  20171. * @param {?} type
  20172. * @return {?}
  20173. */
  20174. function (type) { return this._reflector.annotations(type).some(createNgModule.isTypeOf); };
  20175. /**
  20176. * @param {?} type
  20177. * @param {?=} throwIfNotFound
  20178. * @return {?}
  20179. */
  20180. NgModuleResolver.prototype.resolve = /**
  20181. * @param {?} type
  20182. * @param {?=} throwIfNotFound
  20183. * @return {?}
  20184. */
  20185. function (type, throwIfNotFound) {
  20186. if (throwIfNotFound === void 0) { throwIfNotFound = true; }
  20187. var /** @type {?} */ ngModuleMeta = findLast(this._reflector.annotations(type), createNgModule.isTypeOf);
  20188. if (ngModuleMeta) {
  20189. return ngModuleMeta;
  20190. }
  20191. else {
  20192. if (throwIfNotFound) {
  20193. throw new Error("No NgModule metadata found for '" + stringify(type) + "'.");
  20194. }
  20195. return null;
  20196. }
  20197. };
  20198. return NgModuleResolver;
  20199. }());
  20200. /**
  20201. * @fileoverview added by tsickle
  20202. * @suppress {checkTypes} checked by tsc
  20203. */
  20204. /**
  20205. * @license
  20206. * Copyright Google Inc. All Rights Reserved.
  20207. *
  20208. * Use of this source code is governed by an MIT-style license that can be
  20209. * found in the LICENSE file at https://angular.io/license
  20210. */
  20211. // https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit
  20212. var VERSION$1 = 3;
  20213. var JS_B64_PREFIX = '# sourceMappingURL=data:application/json;base64,';
  20214. var SourceMapGenerator = /** @class */ (function () {
  20215. function SourceMapGenerator(file) {
  20216. if (file === void 0) { file = null; }
  20217. this.file = file;
  20218. this.sourcesContent = new Map();
  20219. this.lines = [];
  20220. this.lastCol0 = 0;
  20221. this.hasMappings = false;
  20222. }
  20223. // The content is `null` when the content is expected to be loaded using the URL
  20224. /**
  20225. * @param {?} url
  20226. * @param {?=} content
  20227. * @return {?}
  20228. */
  20229. SourceMapGenerator.prototype.addSource = /**
  20230. * @param {?} url
  20231. * @param {?=} content
  20232. * @return {?}
  20233. */
  20234. function (url, content) {
  20235. if (content === void 0) { content = null; }
  20236. if (!this.sourcesContent.has(url)) {
  20237. this.sourcesContent.set(url, content);
  20238. }
  20239. return this;
  20240. };
  20241. /**
  20242. * @return {?}
  20243. */
  20244. SourceMapGenerator.prototype.addLine = /**
  20245. * @return {?}
  20246. */
  20247. function () {
  20248. this.lines.push([]);
  20249. this.lastCol0 = 0;
  20250. return this;
  20251. };
  20252. /**
  20253. * @param {?} col0
  20254. * @param {?=} sourceUrl
  20255. * @param {?=} sourceLine0
  20256. * @param {?=} sourceCol0
  20257. * @return {?}
  20258. */
  20259. SourceMapGenerator.prototype.addMapping = /**
  20260. * @param {?} col0
  20261. * @param {?=} sourceUrl
  20262. * @param {?=} sourceLine0
  20263. * @param {?=} sourceCol0
  20264. * @return {?}
  20265. */
  20266. function (col0, sourceUrl, sourceLine0, sourceCol0) {
  20267. if (!this.currentLine) {
  20268. throw new Error("A line must be added before mappings can be added");
  20269. }
  20270. if (sourceUrl != null && !this.sourcesContent.has(sourceUrl)) {
  20271. throw new Error("Unknown source file \"" + sourceUrl + "\"");
  20272. }
  20273. if (col0 == null) {
  20274. throw new Error("The column in the generated code must be provided");
  20275. }
  20276. if (col0 < this.lastCol0) {
  20277. throw new Error("Mapping should be added in output order");
  20278. }
  20279. if (sourceUrl && (sourceLine0 == null || sourceCol0 == null)) {
  20280. throw new Error("The source location must be provided when a source url is provided");
  20281. }
  20282. this.hasMappings = true;
  20283. this.lastCol0 = col0;
  20284. this.currentLine.push({ col0: col0, sourceUrl: sourceUrl, sourceLine0: sourceLine0, sourceCol0: sourceCol0 });
  20285. return this;
  20286. };
  20287. Object.defineProperty(SourceMapGenerator.prototype, "currentLine", {
  20288. get: /**
  20289. * @return {?}
  20290. */
  20291. function () { return this.lines.slice(-1)[0]; },
  20292. enumerable: true,
  20293. configurable: true
  20294. });
  20295. /**
  20296. * @return {?}
  20297. */
  20298. SourceMapGenerator.prototype.toJSON = /**
  20299. * @return {?}
  20300. */
  20301. function () {
  20302. var _this = this;
  20303. if (!this.hasMappings) {
  20304. return null;
  20305. }
  20306. var /** @type {?} */ sourcesIndex = new Map();
  20307. var /** @type {?} */ sources = [];
  20308. var /** @type {?} */ sourcesContent = [];
  20309. Array.from(this.sourcesContent.keys()).forEach(function (url, i) {
  20310. sourcesIndex.set(url, i);
  20311. sources.push(url);
  20312. sourcesContent.push(_this.sourcesContent.get(url) || null);
  20313. });
  20314. var /** @type {?} */ mappings = '';
  20315. var /** @type {?} */ lastCol0 = 0;
  20316. var /** @type {?} */ lastSourceIndex = 0;
  20317. var /** @type {?} */ lastSourceLine0 = 0;
  20318. var /** @type {?} */ lastSourceCol0 = 0;
  20319. this.lines.forEach(function (segments) {
  20320. lastCol0 = 0;
  20321. mappings += segments
  20322. .map(function (segment) {
  20323. // zero-based starting column of the line in the generated code
  20324. var /** @type {?} */ segAsStr = toBase64VLQ(segment.col0 - lastCol0);
  20325. lastCol0 = segment.col0;
  20326. if (segment.sourceUrl != null) {
  20327. // zero-based index into the “sources” list
  20328. segAsStr +=
  20329. toBase64VLQ(/** @type {?} */ ((sourcesIndex.get(segment.sourceUrl))) - lastSourceIndex);
  20330. lastSourceIndex = /** @type {?} */ ((sourcesIndex.get(segment.sourceUrl)));
  20331. // the zero-based starting line in the original source
  20332. segAsStr += toBase64VLQ(/** @type {?} */ ((segment.sourceLine0)) - lastSourceLine0);
  20333. lastSourceLine0 = /** @type {?} */ ((segment.sourceLine0));
  20334. // the zero-based starting column in the original source
  20335. segAsStr += toBase64VLQ(/** @type {?} */ ((segment.sourceCol0)) - lastSourceCol0);
  20336. lastSourceCol0 = /** @type {?} */ ((segment.sourceCol0));
  20337. }
  20338. return segAsStr;
  20339. })
  20340. .join(',');
  20341. mappings += ';';
  20342. });
  20343. mappings = mappings.slice(0, -1);
  20344. return {
  20345. 'file': this.file || '',
  20346. 'version': VERSION$1,
  20347. 'sourceRoot': '',
  20348. 'sources': sources,
  20349. 'sourcesContent': sourcesContent,
  20350. 'mappings': mappings,
  20351. };
  20352. };
  20353. /**
  20354. * @return {?}
  20355. */
  20356. SourceMapGenerator.prototype.toJsComment = /**
  20357. * @return {?}
  20358. */
  20359. function () {
  20360. return this.hasMappings ? '//' + JS_B64_PREFIX + toBase64String(JSON.stringify(this, null, 0)) :
  20361. '';
  20362. };
  20363. return SourceMapGenerator;
  20364. }());
  20365. /**
  20366. * @param {?} value
  20367. * @return {?}
  20368. */
  20369. function toBase64String(value) {
  20370. var /** @type {?} */ b64 = '';
  20371. value = utf8Encode(value);
  20372. for (var /** @type {?} */ i = 0; i < value.length;) {
  20373. var /** @type {?} */ i1 = value.charCodeAt(i++);
  20374. var /** @type {?} */ i2 = value.charCodeAt(i++);
  20375. var /** @type {?} */ i3 = value.charCodeAt(i++);
  20376. b64 += toBase64Digit(i1 >> 2);
  20377. b64 += toBase64Digit(((i1 & 3) << 4) | (isNaN(i2) ? 0 : i2 >> 4));
  20378. b64 += isNaN(i2) ? '=' : toBase64Digit(((i2 & 15) << 2) | (i3 >> 6));
  20379. b64 += isNaN(i2) || isNaN(i3) ? '=' : toBase64Digit(i3 & 63);
  20380. }
  20381. return b64;
  20382. }
  20383. /**
  20384. * @param {?} value
  20385. * @return {?}
  20386. */
  20387. function toBase64VLQ(value) {
  20388. value = value < 0 ? ((-value) << 1) + 1 : value << 1;
  20389. var /** @type {?} */ out = '';
  20390. do {
  20391. var /** @type {?} */ digit = value & 31;
  20392. value = value >> 5;
  20393. if (value > 0) {
  20394. digit = digit | 32;
  20395. }
  20396. out += toBase64Digit(digit);
  20397. } while (value > 0);
  20398. return out;
  20399. }
  20400. var B64_DIGITS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  20401. /**
  20402. * @param {?} value
  20403. * @return {?}
  20404. */
  20405. function toBase64Digit(value) {
  20406. if (value < 0 || value >= 64) {
  20407. throw new Error("Can only encode value in the range [0, 63]");
  20408. }
  20409. return B64_DIGITS[value];
  20410. }
  20411. /**
  20412. * @fileoverview added by tsickle
  20413. * @suppress {checkTypes} checked by tsc
  20414. */
  20415. /**
  20416. * @license
  20417. * Copyright Google Inc. All Rights Reserved.
  20418. *
  20419. * Use of this source code is governed by an MIT-style license that can be
  20420. * found in the LICENSE file at https://angular.io/license
  20421. */
  20422. var _SINGLE_QUOTE_ESCAPE_STRING_RE = /'|\\|\n|\r|\$/g;
  20423. var _LEGAL_IDENTIFIER_RE = /^[$A-Z_][0-9A-Z_$]*$/i;
  20424. var _INDENT_WITH = ' ';
  20425. var CATCH_ERROR_VAR$1 = variable('error', null, null);
  20426. var CATCH_STACK_VAR$1 = variable('stack', null, null);
  20427. /**
  20428. * @record
  20429. */
  20430. var _EmittedLine = /** @class */ (function () {
  20431. function _EmittedLine(indent) {
  20432. this.indent = indent;
  20433. this.partsLength = 0;
  20434. this.parts = [];
  20435. this.srcSpans = [];
  20436. }
  20437. return _EmittedLine;
  20438. }());
  20439. var EmitterVisitorContext = /** @class */ (function () {
  20440. function EmitterVisitorContext(_indent) {
  20441. this._indent = _indent;
  20442. this._classes = [];
  20443. this._preambleLineCount = 0;
  20444. this._lines = [new _EmittedLine(_indent)];
  20445. }
  20446. /**
  20447. * @return {?}
  20448. */
  20449. EmitterVisitorContext.createRoot = /**
  20450. * @return {?}
  20451. */
  20452. function () { return new EmitterVisitorContext(0); };
  20453. Object.defineProperty(EmitterVisitorContext.prototype, "_currentLine", {
  20454. get: /**
  20455. * @return {?}
  20456. */
  20457. function () { return this._lines[this._lines.length - 1]; },
  20458. enumerable: true,
  20459. configurable: true
  20460. });
  20461. /**
  20462. * @param {?=} from
  20463. * @param {?=} lastPart
  20464. * @return {?}
  20465. */
  20466. EmitterVisitorContext.prototype.println = /**
  20467. * @param {?=} from
  20468. * @param {?=} lastPart
  20469. * @return {?}
  20470. */
  20471. function (from, lastPart) {
  20472. if (lastPart === void 0) { lastPart = ''; }
  20473. this.print(from || null, lastPart, true);
  20474. };
  20475. /**
  20476. * @return {?}
  20477. */
  20478. EmitterVisitorContext.prototype.lineIsEmpty = /**
  20479. * @return {?}
  20480. */
  20481. function () { return this._currentLine.parts.length === 0; };
  20482. /**
  20483. * @return {?}
  20484. */
  20485. EmitterVisitorContext.prototype.lineLength = /**
  20486. * @return {?}
  20487. */
  20488. function () {
  20489. return this._currentLine.indent * _INDENT_WITH.length + this._currentLine.partsLength;
  20490. };
  20491. /**
  20492. * @param {?} from
  20493. * @param {?} part
  20494. * @param {?=} newLine
  20495. * @return {?}
  20496. */
  20497. EmitterVisitorContext.prototype.print = /**
  20498. * @param {?} from
  20499. * @param {?} part
  20500. * @param {?=} newLine
  20501. * @return {?}
  20502. */
  20503. function (from, part, newLine) {
  20504. if (newLine === void 0) { newLine = false; }
  20505. if (part.length > 0) {
  20506. this._currentLine.parts.push(part);
  20507. this._currentLine.partsLength += part.length;
  20508. this._currentLine.srcSpans.push(from && from.sourceSpan || null);
  20509. }
  20510. if (newLine) {
  20511. this._lines.push(new _EmittedLine(this._indent));
  20512. }
  20513. };
  20514. /**
  20515. * @return {?}
  20516. */
  20517. EmitterVisitorContext.prototype.removeEmptyLastLine = /**
  20518. * @return {?}
  20519. */
  20520. function () {
  20521. if (this.lineIsEmpty()) {
  20522. this._lines.pop();
  20523. }
  20524. };
  20525. /**
  20526. * @return {?}
  20527. */
  20528. EmitterVisitorContext.prototype.incIndent = /**
  20529. * @return {?}
  20530. */
  20531. function () {
  20532. this._indent++;
  20533. if (this.lineIsEmpty()) {
  20534. this._currentLine.indent = this._indent;
  20535. }
  20536. };
  20537. /**
  20538. * @return {?}
  20539. */
  20540. EmitterVisitorContext.prototype.decIndent = /**
  20541. * @return {?}
  20542. */
  20543. function () {
  20544. this._indent--;
  20545. if (this.lineIsEmpty()) {
  20546. this._currentLine.indent = this._indent;
  20547. }
  20548. };
  20549. /**
  20550. * @param {?} clazz
  20551. * @return {?}
  20552. */
  20553. EmitterVisitorContext.prototype.pushClass = /**
  20554. * @param {?} clazz
  20555. * @return {?}
  20556. */
  20557. function (clazz) { this._classes.push(clazz); };
  20558. /**
  20559. * @return {?}
  20560. */
  20561. EmitterVisitorContext.prototype.popClass = /**
  20562. * @return {?}
  20563. */
  20564. function () { return /** @type {?} */ ((this._classes.pop())); };
  20565. Object.defineProperty(EmitterVisitorContext.prototype, "currentClass", {
  20566. get: /**
  20567. * @return {?}
  20568. */
  20569. function () {
  20570. return this._classes.length > 0 ? this._classes[this._classes.length - 1] : null;
  20571. },
  20572. enumerable: true,
  20573. configurable: true
  20574. });
  20575. /**
  20576. * @return {?}
  20577. */
  20578. EmitterVisitorContext.prototype.toSource = /**
  20579. * @return {?}
  20580. */
  20581. function () {
  20582. return this.sourceLines
  20583. .map(function (l) { return l.parts.length > 0 ? _createIndent(l.indent) + l.parts.join('') : ''; })
  20584. .join('\n');
  20585. };
  20586. /**
  20587. * @param {?} genFilePath
  20588. * @param {?=} startsAtLine
  20589. * @return {?}
  20590. */
  20591. EmitterVisitorContext.prototype.toSourceMapGenerator = /**
  20592. * @param {?} genFilePath
  20593. * @param {?=} startsAtLine
  20594. * @return {?}
  20595. */
  20596. function (genFilePath, startsAtLine) {
  20597. if (startsAtLine === void 0) { startsAtLine = 0; }
  20598. var /** @type {?} */ map = new SourceMapGenerator(genFilePath);
  20599. var /** @type {?} */ firstOffsetMapped = false;
  20600. var /** @type {?} */ mapFirstOffsetIfNeeded = function () {
  20601. if (!firstOffsetMapped) {
  20602. // Add a single space so that tools won't try to load the file from disk.
  20603. // Note: We are using virtual urls like `ng:///`, so we have to
  20604. // provide a content here.
  20605. map.addSource(genFilePath, ' ').addMapping(0, genFilePath, 0, 0);
  20606. firstOffsetMapped = true;
  20607. }
  20608. };
  20609. for (var /** @type {?} */ i = 0; i < startsAtLine; i++) {
  20610. map.addLine();
  20611. mapFirstOffsetIfNeeded();
  20612. }
  20613. this.sourceLines.forEach(function (line, lineIdx) {
  20614. map.addLine();
  20615. var /** @type {?} */ spans = line.srcSpans;
  20616. var /** @type {?} */ parts = line.parts;
  20617. var /** @type {?} */ col0 = line.indent * _INDENT_WITH.length;
  20618. var /** @type {?} */ spanIdx = 0;
  20619. // skip leading parts without source spans
  20620. while (spanIdx < spans.length && !spans[spanIdx]) {
  20621. col0 += parts[spanIdx].length;
  20622. spanIdx++;
  20623. }
  20624. if (spanIdx < spans.length && lineIdx === 0 && col0 === 0) {
  20625. firstOffsetMapped = true;
  20626. }
  20627. else {
  20628. mapFirstOffsetIfNeeded();
  20629. }
  20630. while (spanIdx < spans.length) {
  20631. var /** @type {?} */ span = /** @type {?} */ ((spans[spanIdx]));
  20632. var /** @type {?} */ source = span.start.file;
  20633. var /** @type {?} */ sourceLine = span.start.line;
  20634. var /** @type {?} */ sourceCol = span.start.col;
  20635. map.addSource(source.url, source.content)
  20636. .addMapping(col0, source.url, sourceLine, sourceCol);
  20637. col0 += parts[spanIdx].length;
  20638. spanIdx++;
  20639. // assign parts without span or the same span to the previous segment
  20640. while (spanIdx < spans.length && (span === spans[spanIdx] || !spans[spanIdx])) {
  20641. col0 += parts[spanIdx].length;
  20642. spanIdx++;
  20643. }
  20644. }
  20645. });
  20646. return map;
  20647. };
  20648. /**
  20649. * @param {?} count
  20650. * @return {?}
  20651. */
  20652. EmitterVisitorContext.prototype.setPreambleLineCount = /**
  20653. * @param {?} count
  20654. * @return {?}
  20655. */
  20656. function (count) { return this._preambleLineCount = count; };
  20657. /**
  20658. * @param {?} line
  20659. * @param {?} column
  20660. * @return {?}
  20661. */
  20662. EmitterVisitorContext.prototype.spanOf = /**
  20663. * @param {?} line
  20664. * @param {?} column
  20665. * @return {?}
  20666. */
  20667. function (line, column) {
  20668. var /** @type {?} */ emittedLine = this._lines[line - this._preambleLineCount];
  20669. if (emittedLine) {
  20670. var /** @type {?} */ columnsLeft = column - _createIndent(emittedLine.indent).length;
  20671. for (var /** @type {?} */ partIndex = 0; partIndex < emittedLine.parts.length; partIndex++) {
  20672. var /** @type {?} */ part = emittedLine.parts[partIndex];
  20673. if (part.length > columnsLeft) {
  20674. return emittedLine.srcSpans[partIndex];
  20675. }
  20676. columnsLeft -= part.length;
  20677. }
  20678. }
  20679. return null;
  20680. };
  20681. Object.defineProperty(EmitterVisitorContext.prototype, "sourceLines", {
  20682. get: /**
  20683. * @return {?}
  20684. */
  20685. function () {
  20686. if (this._lines.length && this._lines[this._lines.length - 1].parts.length === 0) {
  20687. return this._lines.slice(0, -1);
  20688. }
  20689. return this._lines;
  20690. },
  20691. enumerable: true,
  20692. configurable: true
  20693. });
  20694. return EmitterVisitorContext;
  20695. }());
  20696. /**
  20697. * @abstract
  20698. */
  20699. var AbstractEmitterVisitor = /** @class */ (function () {
  20700. function AbstractEmitterVisitor(_escapeDollarInStrings) {
  20701. this._escapeDollarInStrings = _escapeDollarInStrings;
  20702. }
  20703. /**
  20704. * @param {?} stmt
  20705. * @param {?} ctx
  20706. * @return {?}
  20707. */
  20708. AbstractEmitterVisitor.prototype.visitExpressionStmt = /**
  20709. * @param {?} stmt
  20710. * @param {?} ctx
  20711. * @return {?}
  20712. */
  20713. function (stmt, ctx) {
  20714. stmt.expr.visitExpression(this, ctx);
  20715. ctx.println(stmt, ';');
  20716. return null;
  20717. };
  20718. /**
  20719. * @param {?} stmt
  20720. * @param {?} ctx
  20721. * @return {?}
  20722. */
  20723. AbstractEmitterVisitor.prototype.visitReturnStmt = /**
  20724. * @param {?} stmt
  20725. * @param {?} ctx
  20726. * @return {?}
  20727. */
  20728. function (stmt, ctx) {
  20729. ctx.print(stmt, "return ");
  20730. stmt.value.visitExpression(this, ctx);
  20731. ctx.println(stmt, ';');
  20732. return null;
  20733. };
  20734. /**
  20735. * @param {?} stmt
  20736. * @param {?} ctx
  20737. * @return {?}
  20738. */
  20739. AbstractEmitterVisitor.prototype.visitIfStmt = /**
  20740. * @param {?} stmt
  20741. * @param {?} ctx
  20742. * @return {?}
  20743. */
  20744. function (stmt, ctx) {
  20745. ctx.print(stmt, "if (");
  20746. stmt.condition.visitExpression(this, ctx);
  20747. ctx.print(stmt, ") {");
  20748. var /** @type {?} */ hasElseCase = stmt.falseCase != null && stmt.falseCase.length > 0;
  20749. if (stmt.trueCase.length <= 1 && !hasElseCase) {
  20750. ctx.print(stmt, " ");
  20751. this.visitAllStatements(stmt.trueCase, ctx);
  20752. ctx.removeEmptyLastLine();
  20753. ctx.print(stmt, " ");
  20754. }
  20755. else {
  20756. ctx.println();
  20757. ctx.incIndent();
  20758. this.visitAllStatements(stmt.trueCase, ctx);
  20759. ctx.decIndent();
  20760. if (hasElseCase) {
  20761. ctx.println(stmt, "} else {");
  20762. ctx.incIndent();
  20763. this.visitAllStatements(stmt.falseCase, ctx);
  20764. ctx.decIndent();
  20765. }
  20766. }
  20767. ctx.println(stmt, "}");
  20768. return null;
  20769. };
  20770. /**
  20771. * @param {?} stmt
  20772. * @param {?} ctx
  20773. * @return {?}
  20774. */
  20775. AbstractEmitterVisitor.prototype.visitThrowStmt = /**
  20776. * @param {?} stmt
  20777. * @param {?} ctx
  20778. * @return {?}
  20779. */
  20780. function (stmt, ctx) {
  20781. ctx.print(stmt, "throw ");
  20782. stmt.error.visitExpression(this, ctx);
  20783. ctx.println(stmt, ";");
  20784. return null;
  20785. };
  20786. /**
  20787. * @param {?} stmt
  20788. * @param {?} ctx
  20789. * @return {?}
  20790. */
  20791. AbstractEmitterVisitor.prototype.visitCommentStmt = /**
  20792. * @param {?} stmt
  20793. * @param {?} ctx
  20794. * @return {?}
  20795. */
  20796. function (stmt, ctx) {
  20797. var /** @type {?} */ lines = stmt.comment.split('\n');
  20798. lines.forEach(function (line) { ctx.println(stmt, "// " + line); });
  20799. return null;
  20800. };
  20801. /**
  20802. * @param {?} expr
  20803. * @param {?} ctx
  20804. * @return {?}
  20805. */
  20806. AbstractEmitterVisitor.prototype.visitWriteVarExpr = /**
  20807. * @param {?} expr
  20808. * @param {?} ctx
  20809. * @return {?}
  20810. */
  20811. function (expr, ctx) {
  20812. var /** @type {?} */ lineWasEmpty = ctx.lineIsEmpty();
  20813. if (!lineWasEmpty) {
  20814. ctx.print(expr, '(');
  20815. }
  20816. ctx.print(expr, expr.name + " = ");
  20817. expr.value.visitExpression(this, ctx);
  20818. if (!lineWasEmpty) {
  20819. ctx.print(expr, ')');
  20820. }
  20821. return null;
  20822. };
  20823. /**
  20824. * @param {?} expr
  20825. * @param {?} ctx
  20826. * @return {?}
  20827. */
  20828. AbstractEmitterVisitor.prototype.visitWriteKeyExpr = /**
  20829. * @param {?} expr
  20830. * @param {?} ctx
  20831. * @return {?}
  20832. */
  20833. function (expr, ctx) {
  20834. var /** @type {?} */ lineWasEmpty = ctx.lineIsEmpty();
  20835. if (!lineWasEmpty) {
  20836. ctx.print(expr, '(');
  20837. }
  20838. expr.receiver.visitExpression(this, ctx);
  20839. ctx.print(expr, "[");
  20840. expr.index.visitExpression(this, ctx);
  20841. ctx.print(expr, "] = ");
  20842. expr.value.visitExpression(this, ctx);
  20843. if (!lineWasEmpty) {
  20844. ctx.print(expr, ')');
  20845. }
  20846. return null;
  20847. };
  20848. /**
  20849. * @param {?} expr
  20850. * @param {?} ctx
  20851. * @return {?}
  20852. */
  20853. AbstractEmitterVisitor.prototype.visitWritePropExpr = /**
  20854. * @param {?} expr
  20855. * @param {?} ctx
  20856. * @return {?}
  20857. */
  20858. function (expr, ctx) {
  20859. var /** @type {?} */ lineWasEmpty = ctx.lineIsEmpty();
  20860. if (!lineWasEmpty) {
  20861. ctx.print(expr, '(');
  20862. }
  20863. expr.receiver.visitExpression(this, ctx);
  20864. ctx.print(expr, "." + expr.name + " = ");
  20865. expr.value.visitExpression(this, ctx);
  20866. if (!lineWasEmpty) {
  20867. ctx.print(expr, ')');
  20868. }
  20869. return null;
  20870. };
  20871. /**
  20872. * @param {?} expr
  20873. * @param {?} ctx
  20874. * @return {?}
  20875. */
  20876. AbstractEmitterVisitor.prototype.visitInvokeMethodExpr = /**
  20877. * @param {?} expr
  20878. * @param {?} ctx
  20879. * @return {?}
  20880. */
  20881. function (expr, ctx) {
  20882. expr.receiver.visitExpression(this, ctx);
  20883. var /** @type {?} */ name = expr.name;
  20884. if (expr.builtin != null) {
  20885. name = this.getBuiltinMethodName(expr.builtin);
  20886. if (name == null) {
  20887. // some builtins just mean to skip the call.
  20888. return null;
  20889. }
  20890. }
  20891. ctx.print(expr, "." + name + "(");
  20892. this.visitAllExpressions(expr.args, ctx, ",");
  20893. ctx.print(expr, ")");
  20894. return null;
  20895. };
  20896. /**
  20897. * @param {?} expr
  20898. * @param {?} ctx
  20899. * @return {?}
  20900. */
  20901. AbstractEmitterVisitor.prototype.visitInvokeFunctionExpr = /**
  20902. * @param {?} expr
  20903. * @param {?} ctx
  20904. * @return {?}
  20905. */
  20906. function (expr, ctx) {
  20907. expr.fn.visitExpression(this, ctx);
  20908. ctx.print(expr, "(");
  20909. this.visitAllExpressions(expr.args, ctx, ',');
  20910. ctx.print(expr, ")");
  20911. return null;
  20912. };
  20913. /**
  20914. * @param {?} ast
  20915. * @param {?} ctx
  20916. * @return {?}
  20917. */
  20918. AbstractEmitterVisitor.prototype.visitReadVarExpr = /**
  20919. * @param {?} ast
  20920. * @param {?} ctx
  20921. * @return {?}
  20922. */
  20923. function (ast, ctx) {
  20924. var /** @type {?} */ varName = /** @type {?} */ ((ast.name));
  20925. if (ast.builtin != null) {
  20926. switch (ast.builtin) {
  20927. case BuiltinVar.Super:
  20928. varName = 'super';
  20929. break;
  20930. case BuiltinVar.This:
  20931. varName = 'this';
  20932. break;
  20933. case BuiltinVar.CatchError:
  20934. varName = /** @type {?} */ ((CATCH_ERROR_VAR$1.name));
  20935. break;
  20936. case BuiltinVar.CatchStack:
  20937. varName = /** @type {?} */ ((CATCH_STACK_VAR$1.name));
  20938. break;
  20939. default:
  20940. throw new Error("Unknown builtin variable " + ast.builtin);
  20941. }
  20942. }
  20943. ctx.print(ast, varName);
  20944. return null;
  20945. };
  20946. /**
  20947. * @param {?} ast
  20948. * @param {?} ctx
  20949. * @return {?}
  20950. */
  20951. AbstractEmitterVisitor.prototype.visitInstantiateExpr = /**
  20952. * @param {?} ast
  20953. * @param {?} ctx
  20954. * @return {?}
  20955. */
  20956. function (ast, ctx) {
  20957. ctx.print(ast, "new ");
  20958. ast.classExpr.visitExpression(this, ctx);
  20959. ctx.print(ast, "(");
  20960. this.visitAllExpressions(ast.args, ctx, ',');
  20961. ctx.print(ast, ")");
  20962. return null;
  20963. };
  20964. /**
  20965. * @param {?} ast
  20966. * @param {?} ctx
  20967. * @return {?}
  20968. */
  20969. AbstractEmitterVisitor.prototype.visitLiteralExpr = /**
  20970. * @param {?} ast
  20971. * @param {?} ctx
  20972. * @return {?}
  20973. */
  20974. function (ast, ctx) {
  20975. var /** @type {?} */ value = ast.value;
  20976. if (typeof value === 'string') {
  20977. ctx.print(ast, escapeIdentifier(value, this._escapeDollarInStrings));
  20978. }
  20979. else {
  20980. ctx.print(ast, "" + value);
  20981. }
  20982. return null;
  20983. };
  20984. /**
  20985. * @param {?} ast
  20986. * @param {?} ctx
  20987. * @return {?}
  20988. */
  20989. AbstractEmitterVisitor.prototype.visitConditionalExpr = /**
  20990. * @param {?} ast
  20991. * @param {?} ctx
  20992. * @return {?}
  20993. */
  20994. function (ast, ctx) {
  20995. ctx.print(ast, "(");
  20996. ast.condition.visitExpression(this, ctx);
  20997. ctx.print(ast, '? ');
  20998. ast.trueCase.visitExpression(this, ctx);
  20999. ctx.print(ast, ': '); /** @type {?} */
  21000. ((ast.falseCase)).visitExpression(this, ctx);
  21001. ctx.print(ast, ")");
  21002. return null;
  21003. };
  21004. /**
  21005. * @param {?} ast
  21006. * @param {?} ctx
  21007. * @return {?}
  21008. */
  21009. AbstractEmitterVisitor.prototype.visitNotExpr = /**
  21010. * @param {?} ast
  21011. * @param {?} ctx
  21012. * @return {?}
  21013. */
  21014. function (ast, ctx) {
  21015. ctx.print(ast, '!');
  21016. ast.condition.visitExpression(this, ctx);
  21017. return null;
  21018. };
  21019. /**
  21020. * @param {?} ast
  21021. * @param {?} ctx
  21022. * @return {?}
  21023. */
  21024. AbstractEmitterVisitor.prototype.visitAssertNotNullExpr = /**
  21025. * @param {?} ast
  21026. * @param {?} ctx
  21027. * @return {?}
  21028. */
  21029. function (ast, ctx) {
  21030. ast.condition.visitExpression(this, ctx);
  21031. return null;
  21032. };
  21033. /**
  21034. * @param {?} ast
  21035. * @param {?} ctx
  21036. * @return {?}
  21037. */
  21038. AbstractEmitterVisitor.prototype.visitBinaryOperatorExpr = /**
  21039. * @param {?} ast
  21040. * @param {?} ctx
  21041. * @return {?}
  21042. */
  21043. function (ast, ctx) {
  21044. var /** @type {?} */ opStr;
  21045. switch (ast.operator) {
  21046. case BinaryOperator.Equals:
  21047. opStr = '==';
  21048. break;
  21049. case BinaryOperator.Identical:
  21050. opStr = '===';
  21051. break;
  21052. case BinaryOperator.NotEquals:
  21053. opStr = '!=';
  21054. break;
  21055. case BinaryOperator.NotIdentical:
  21056. opStr = '!==';
  21057. break;
  21058. case BinaryOperator.And:
  21059. opStr = '&&';
  21060. break;
  21061. case BinaryOperator.Or:
  21062. opStr = '||';
  21063. break;
  21064. case BinaryOperator.Plus:
  21065. opStr = '+';
  21066. break;
  21067. case BinaryOperator.Minus:
  21068. opStr = '-';
  21069. break;
  21070. case BinaryOperator.Divide:
  21071. opStr = '/';
  21072. break;
  21073. case BinaryOperator.Multiply:
  21074. opStr = '*';
  21075. break;
  21076. case BinaryOperator.Modulo:
  21077. opStr = '%';
  21078. break;
  21079. case BinaryOperator.Lower:
  21080. opStr = '<';
  21081. break;
  21082. case BinaryOperator.LowerEquals:
  21083. opStr = '<=';
  21084. break;
  21085. case BinaryOperator.Bigger:
  21086. opStr = '>';
  21087. break;
  21088. case BinaryOperator.BiggerEquals:
  21089. opStr = '>=';
  21090. break;
  21091. default:
  21092. throw new Error("Unknown operator " + ast.operator);
  21093. }
  21094. ctx.print(ast, "(");
  21095. ast.lhs.visitExpression(this, ctx);
  21096. ctx.print(ast, " " + opStr + " ");
  21097. ast.rhs.visitExpression(this, ctx);
  21098. ctx.print(ast, ")");
  21099. return null;
  21100. };
  21101. /**
  21102. * @param {?} ast
  21103. * @param {?} ctx
  21104. * @return {?}
  21105. */
  21106. AbstractEmitterVisitor.prototype.visitReadPropExpr = /**
  21107. * @param {?} ast
  21108. * @param {?} ctx
  21109. * @return {?}
  21110. */
  21111. function (ast, ctx) {
  21112. ast.receiver.visitExpression(this, ctx);
  21113. ctx.print(ast, ".");
  21114. ctx.print(ast, ast.name);
  21115. return null;
  21116. };
  21117. /**
  21118. * @param {?} ast
  21119. * @param {?} ctx
  21120. * @return {?}
  21121. */
  21122. AbstractEmitterVisitor.prototype.visitReadKeyExpr = /**
  21123. * @param {?} ast
  21124. * @param {?} ctx
  21125. * @return {?}
  21126. */
  21127. function (ast, ctx) {
  21128. ast.receiver.visitExpression(this, ctx);
  21129. ctx.print(ast, "[");
  21130. ast.index.visitExpression(this, ctx);
  21131. ctx.print(ast, "]");
  21132. return null;
  21133. };
  21134. /**
  21135. * @param {?} ast
  21136. * @param {?} ctx
  21137. * @return {?}
  21138. */
  21139. AbstractEmitterVisitor.prototype.visitLiteralArrayExpr = /**
  21140. * @param {?} ast
  21141. * @param {?} ctx
  21142. * @return {?}
  21143. */
  21144. function (ast, ctx) {
  21145. ctx.print(ast, "[");
  21146. this.visitAllExpressions(ast.entries, ctx, ',');
  21147. ctx.print(ast, "]");
  21148. return null;
  21149. };
  21150. /**
  21151. * @param {?} ast
  21152. * @param {?} ctx
  21153. * @return {?}
  21154. */
  21155. AbstractEmitterVisitor.prototype.visitLiteralMapExpr = /**
  21156. * @param {?} ast
  21157. * @param {?} ctx
  21158. * @return {?}
  21159. */
  21160. function (ast, ctx) {
  21161. var _this = this;
  21162. ctx.print(ast, "{");
  21163. this.visitAllObjects(function (entry) {
  21164. ctx.print(ast, escapeIdentifier(entry.key, _this._escapeDollarInStrings, entry.quoted) + ":");
  21165. entry.value.visitExpression(_this, ctx);
  21166. }, ast.entries, ctx, ',');
  21167. ctx.print(ast, "}");
  21168. return null;
  21169. };
  21170. /**
  21171. * @param {?} ast
  21172. * @param {?} ctx
  21173. * @return {?}
  21174. */
  21175. AbstractEmitterVisitor.prototype.visitCommaExpr = /**
  21176. * @param {?} ast
  21177. * @param {?} ctx
  21178. * @return {?}
  21179. */
  21180. function (ast, ctx) {
  21181. ctx.print(ast, '(');
  21182. this.visitAllExpressions(ast.parts, ctx, ',');
  21183. ctx.print(ast, ')');
  21184. return null;
  21185. };
  21186. /**
  21187. * @param {?} expressions
  21188. * @param {?} ctx
  21189. * @param {?} separator
  21190. * @return {?}
  21191. */
  21192. AbstractEmitterVisitor.prototype.visitAllExpressions = /**
  21193. * @param {?} expressions
  21194. * @param {?} ctx
  21195. * @param {?} separator
  21196. * @return {?}
  21197. */
  21198. function (expressions, ctx, separator) {
  21199. var _this = this;
  21200. this.visitAllObjects(function (expr) { return expr.visitExpression(_this, ctx); }, expressions, ctx, separator);
  21201. };
  21202. /**
  21203. * @template T
  21204. * @param {?} handler
  21205. * @param {?} expressions
  21206. * @param {?} ctx
  21207. * @param {?} separator
  21208. * @return {?}
  21209. */
  21210. AbstractEmitterVisitor.prototype.visitAllObjects = /**
  21211. * @template T
  21212. * @param {?} handler
  21213. * @param {?} expressions
  21214. * @param {?} ctx
  21215. * @param {?} separator
  21216. * @return {?}
  21217. */
  21218. function (handler, expressions, ctx, separator) {
  21219. var /** @type {?} */ incrementedIndent = false;
  21220. for (var /** @type {?} */ i = 0; i < expressions.length; i++) {
  21221. if (i > 0) {
  21222. if (ctx.lineLength() > 80) {
  21223. ctx.print(null, separator, true);
  21224. if (!incrementedIndent) {
  21225. // continuation are marked with double indent.
  21226. ctx.incIndent();
  21227. ctx.incIndent();
  21228. incrementedIndent = true;
  21229. }
  21230. }
  21231. else {
  21232. ctx.print(null, separator, false);
  21233. }
  21234. }
  21235. handler(expressions[i]);
  21236. }
  21237. if (incrementedIndent) {
  21238. // continuation are marked with double indent.
  21239. ctx.decIndent();
  21240. ctx.decIndent();
  21241. }
  21242. };
  21243. /**
  21244. * @param {?} statements
  21245. * @param {?} ctx
  21246. * @return {?}
  21247. */
  21248. AbstractEmitterVisitor.prototype.visitAllStatements = /**
  21249. * @param {?} statements
  21250. * @param {?} ctx
  21251. * @return {?}
  21252. */
  21253. function (statements, ctx) {
  21254. var _this = this;
  21255. statements.forEach(function (stmt) { return stmt.visitStatement(_this, ctx); });
  21256. };
  21257. return AbstractEmitterVisitor;
  21258. }());
  21259. /**
  21260. * @param {?} input
  21261. * @param {?} escapeDollar
  21262. * @param {?=} alwaysQuote
  21263. * @return {?}
  21264. */
  21265. function escapeIdentifier(input, escapeDollar, alwaysQuote) {
  21266. if (alwaysQuote === void 0) { alwaysQuote = true; }
  21267. if (input == null) {
  21268. return null;
  21269. }
  21270. var /** @type {?} */ body = input.replace(_SINGLE_QUOTE_ESCAPE_STRING_RE, function () {
  21271. var match = [];
  21272. for (var _i = 0; _i < arguments.length; _i++) {
  21273. match[_i] = arguments[_i];
  21274. }
  21275. if (match[0] == '$') {
  21276. return escapeDollar ? '\\$' : '$';
  21277. }
  21278. else if (match[0] == '\n') {
  21279. return '\\n';
  21280. }
  21281. else if (match[0] == '\r') {
  21282. return '\\r';
  21283. }
  21284. else {
  21285. return "\\" + match[0];
  21286. }
  21287. });
  21288. var /** @type {?} */ requiresQuotes = alwaysQuote || !_LEGAL_IDENTIFIER_RE.test(body);
  21289. return requiresQuotes ? "'" + body + "'" : body;
  21290. }
  21291. /**
  21292. * @param {?} count
  21293. * @return {?}
  21294. */
  21295. function _createIndent(count) {
  21296. var /** @type {?} */ res = '';
  21297. for (var /** @type {?} */ i = 0; i < count; i++) {
  21298. res += _INDENT_WITH;
  21299. }
  21300. return res;
  21301. }
  21302. /**
  21303. * @fileoverview added by tsickle
  21304. * @suppress {checkTypes} checked by tsc
  21305. */
  21306. /**
  21307. * @license
  21308. * Copyright Google Inc. All Rights Reserved.
  21309. *
  21310. * Use of this source code is governed by an MIT-style license that can be
  21311. * found in the LICENSE file at https://angular.io/license
  21312. */
  21313. /**
  21314. * @param {?} ast
  21315. * @return {?}
  21316. */
  21317. function debugOutputAstAsTypeScript(ast) {
  21318. var /** @type {?} */ converter = new _TsEmitterVisitor();
  21319. var /** @type {?} */ ctx = EmitterVisitorContext.createRoot();
  21320. var /** @type {?} */ asts = Array.isArray(ast) ? ast : [ast];
  21321. asts.forEach(function (ast) {
  21322. if (ast instanceof Statement) {
  21323. ast.visitStatement(converter, ctx);
  21324. }
  21325. else if (ast instanceof Expression) {
  21326. ast.visitExpression(converter, ctx);
  21327. }
  21328. else if (ast instanceof Type$1) {
  21329. ast.visitType(converter, ctx);
  21330. }
  21331. else {
  21332. throw new Error("Don't know how to print debug info for " + ast);
  21333. }
  21334. });
  21335. return ctx.toSource();
  21336. }
  21337. var TypeScriptEmitter = /** @class */ (function () {
  21338. function TypeScriptEmitter() {
  21339. }
  21340. /**
  21341. * @param {?} genFilePath
  21342. * @param {?} stmts
  21343. * @param {?=} preamble
  21344. * @param {?=} emitSourceMaps
  21345. * @param {?=} referenceFilter
  21346. * @return {?}
  21347. */
  21348. TypeScriptEmitter.prototype.emitStatementsAndContext = /**
  21349. * @param {?} genFilePath
  21350. * @param {?} stmts
  21351. * @param {?=} preamble
  21352. * @param {?=} emitSourceMaps
  21353. * @param {?=} referenceFilter
  21354. * @return {?}
  21355. */
  21356. function (genFilePath, stmts, preamble, emitSourceMaps, referenceFilter) {
  21357. if (preamble === void 0) { preamble = ''; }
  21358. if (emitSourceMaps === void 0) { emitSourceMaps = true; }
  21359. var /** @type {?} */ converter = new _TsEmitterVisitor(referenceFilter);
  21360. var /** @type {?} */ ctx = EmitterVisitorContext.createRoot();
  21361. converter.visitAllStatements(stmts, ctx);
  21362. var /** @type {?} */ preambleLines = preamble ? preamble.split('\n') : [];
  21363. converter.reexports.forEach(function (reexports, exportedModuleName) {
  21364. var /** @type {?} */ reexportsCode = reexports.map(function (reexport) { return reexport.name + " as " + reexport.as; }).join(',');
  21365. preambleLines.push("export {" + reexportsCode + "} from '" + exportedModuleName + "';");
  21366. });
  21367. converter.importsWithPrefixes.forEach(function (prefix, importedModuleName) {
  21368. // Note: can't write the real word for import as it screws up system.js auto detection...
  21369. preambleLines.push("imp" +
  21370. ("ort * as " + prefix + " from '" + importedModuleName + "';"));
  21371. });
  21372. var /** @type {?} */ sm = emitSourceMaps ?
  21373. ctx.toSourceMapGenerator(genFilePath, preambleLines.length).toJsComment() :
  21374. '';
  21375. var /** @type {?} */ lines = preambleLines.concat([ctx.toSource(), sm]);
  21376. if (sm) {
  21377. // always add a newline at the end, as some tools have bugs without it.
  21378. lines.push('');
  21379. }
  21380. ctx.setPreambleLineCount(preambleLines.length);
  21381. return { sourceText: lines.join('\n'), context: ctx };
  21382. };
  21383. /**
  21384. * @param {?} genFilePath
  21385. * @param {?} stmts
  21386. * @param {?=} preamble
  21387. * @return {?}
  21388. */
  21389. TypeScriptEmitter.prototype.emitStatements = /**
  21390. * @param {?} genFilePath
  21391. * @param {?} stmts
  21392. * @param {?=} preamble
  21393. * @return {?}
  21394. */
  21395. function (genFilePath, stmts, preamble) {
  21396. if (preamble === void 0) { preamble = ''; }
  21397. return this.emitStatementsAndContext(genFilePath, stmts, preamble).sourceText;
  21398. };
  21399. return TypeScriptEmitter;
  21400. }());
  21401. var _TsEmitterVisitor = /** @class */ (function (_super) {
  21402. __extends(_TsEmitterVisitor, _super);
  21403. function _TsEmitterVisitor(referenceFilter) {
  21404. var _this = _super.call(this, false) || this;
  21405. _this.referenceFilter = referenceFilter;
  21406. _this.typeExpression = 0;
  21407. _this.importsWithPrefixes = new Map();
  21408. _this.reexports = new Map();
  21409. return _this;
  21410. }
  21411. /**
  21412. * @param {?} t
  21413. * @param {?} ctx
  21414. * @param {?=} defaultType
  21415. * @return {?}
  21416. */
  21417. _TsEmitterVisitor.prototype.visitType = /**
  21418. * @param {?} t
  21419. * @param {?} ctx
  21420. * @param {?=} defaultType
  21421. * @return {?}
  21422. */
  21423. function (t, ctx, defaultType) {
  21424. if (defaultType === void 0) { defaultType = 'any'; }
  21425. if (t) {
  21426. this.typeExpression++;
  21427. t.visitType(this, ctx);
  21428. this.typeExpression--;
  21429. }
  21430. else {
  21431. ctx.print(null, defaultType);
  21432. }
  21433. };
  21434. /**
  21435. * @param {?} ast
  21436. * @param {?} ctx
  21437. * @return {?}
  21438. */
  21439. _TsEmitterVisitor.prototype.visitLiteralExpr = /**
  21440. * @param {?} ast
  21441. * @param {?} ctx
  21442. * @return {?}
  21443. */
  21444. function (ast, ctx) {
  21445. var /** @type {?} */ value = ast.value;
  21446. if (value == null && ast.type != INFERRED_TYPE) {
  21447. ctx.print(ast, "(" + value + " as any)");
  21448. return null;
  21449. }
  21450. return _super.prototype.visitLiteralExpr.call(this, ast, ctx);
  21451. };
  21452. // Temporary workaround to support strictNullCheck enabled consumers of ngc emit.
  21453. // In SNC mode, [] have the type never[], so we cast here to any[].
  21454. // TODO: narrow the cast to a more explicit type, or use a pattern that does not
  21455. // start with [].concat. see https://github.com/angular/angular/pull/11846
  21456. /**
  21457. * @param {?} ast
  21458. * @param {?} ctx
  21459. * @return {?}
  21460. */
  21461. _TsEmitterVisitor.prototype.visitLiteralArrayExpr = /**
  21462. * @param {?} ast
  21463. * @param {?} ctx
  21464. * @return {?}
  21465. */
  21466. function (ast, ctx) {
  21467. if (ast.entries.length === 0) {
  21468. ctx.print(ast, '(');
  21469. }
  21470. var /** @type {?} */ result = _super.prototype.visitLiteralArrayExpr.call(this, ast, ctx);
  21471. if (ast.entries.length === 0) {
  21472. ctx.print(ast, ' as any[])');
  21473. }
  21474. return result;
  21475. };
  21476. /**
  21477. * @param {?} ast
  21478. * @param {?} ctx
  21479. * @return {?}
  21480. */
  21481. _TsEmitterVisitor.prototype.visitExternalExpr = /**
  21482. * @param {?} ast
  21483. * @param {?} ctx
  21484. * @return {?}
  21485. */
  21486. function (ast, ctx) {
  21487. this._visitIdentifier(ast.value, ast.typeParams, ctx);
  21488. return null;
  21489. };
  21490. /**
  21491. * @param {?} ast
  21492. * @param {?} ctx
  21493. * @return {?}
  21494. */
  21495. _TsEmitterVisitor.prototype.visitAssertNotNullExpr = /**
  21496. * @param {?} ast
  21497. * @param {?} ctx
  21498. * @return {?}
  21499. */
  21500. function (ast, ctx) {
  21501. var /** @type {?} */ result = _super.prototype.visitAssertNotNullExpr.call(this, ast, ctx);
  21502. ctx.print(ast, '!');
  21503. return result;
  21504. };
  21505. /**
  21506. * @param {?} stmt
  21507. * @param {?} ctx
  21508. * @return {?}
  21509. */
  21510. _TsEmitterVisitor.prototype.visitDeclareVarStmt = /**
  21511. * @param {?} stmt
  21512. * @param {?} ctx
  21513. * @return {?}
  21514. */
  21515. function (stmt, ctx) {
  21516. if (stmt.hasModifier(StmtModifier.Exported) && stmt.value instanceof ExternalExpr &&
  21517. !stmt.type) {
  21518. // check for a reexport
  21519. var _a = stmt.value.value, name_1 = _a.name, moduleName = _a.moduleName;
  21520. if (moduleName) {
  21521. var /** @type {?} */ reexports = this.reexports.get(moduleName);
  21522. if (!reexports) {
  21523. reexports = [];
  21524. this.reexports.set(moduleName, reexports);
  21525. }
  21526. reexports.push({ name: /** @type {?} */ ((name_1)), as: stmt.name });
  21527. return null;
  21528. }
  21529. }
  21530. if (stmt.hasModifier(StmtModifier.Exported)) {
  21531. ctx.print(stmt, "export ");
  21532. }
  21533. if (stmt.hasModifier(StmtModifier.Final)) {
  21534. ctx.print(stmt, "const");
  21535. }
  21536. else {
  21537. ctx.print(stmt, "var");
  21538. }
  21539. ctx.print(stmt, " " + stmt.name);
  21540. this._printColonType(stmt.type, ctx);
  21541. ctx.print(stmt, " = ");
  21542. stmt.value.visitExpression(this, ctx);
  21543. ctx.println(stmt, ";");
  21544. return null;
  21545. };
  21546. /**
  21547. * @param {?} ast
  21548. * @param {?} ctx
  21549. * @return {?}
  21550. */
  21551. _TsEmitterVisitor.prototype.visitCastExpr = /**
  21552. * @param {?} ast
  21553. * @param {?} ctx
  21554. * @return {?}
  21555. */
  21556. function (ast, ctx) {
  21557. ctx.print(ast, "(<"); /** @type {?} */
  21558. ((ast.type)).visitType(this, ctx);
  21559. ctx.print(ast, ">");
  21560. ast.value.visitExpression(this, ctx);
  21561. ctx.print(ast, ")");
  21562. return null;
  21563. };
  21564. /**
  21565. * @param {?} ast
  21566. * @param {?} ctx
  21567. * @return {?}
  21568. */
  21569. _TsEmitterVisitor.prototype.visitInstantiateExpr = /**
  21570. * @param {?} ast
  21571. * @param {?} ctx
  21572. * @return {?}
  21573. */
  21574. function (ast, ctx) {
  21575. ctx.print(ast, "new ");
  21576. this.typeExpression++;
  21577. ast.classExpr.visitExpression(this, ctx);
  21578. this.typeExpression--;
  21579. ctx.print(ast, "(");
  21580. this.visitAllExpressions(ast.args, ctx, ',');
  21581. ctx.print(ast, ")");
  21582. return null;
  21583. };
  21584. /**
  21585. * @param {?} stmt
  21586. * @param {?} ctx
  21587. * @return {?}
  21588. */
  21589. _TsEmitterVisitor.prototype.visitDeclareClassStmt = /**
  21590. * @param {?} stmt
  21591. * @param {?} ctx
  21592. * @return {?}
  21593. */
  21594. function (stmt, ctx) {
  21595. var _this = this;
  21596. ctx.pushClass(stmt);
  21597. if (stmt.hasModifier(StmtModifier.Exported)) {
  21598. ctx.print(stmt, "export ");
  21599. }
  21600. ctx.print(stmt, "class " + stmt.name);
  21601. if (stmt.parent != null) {
  21602. ctx.print(stmt, " extends ");
  21603. this.typeExpression++;
  21604. stmt.parent.visitExpression(this, ctx);
  21605. this.typeExpression--;
  21606. }
  21607. ctx.println(stmt, " {");
  21608. ctx.incIndent();
  21609. stmt.fields.forEach(function (field) { return _this._visitClassField(field, ctx); });
  21610. if (stmt.constructorMethod != null) {
  21611. this._visitClassConstructor(stmt, ctx);
  21612. }
  21613. stmt.getters.forEach(function (getter) { return _this._visitClassGetter(getter, ctx); });
  21614. stmt.methods.forEach(function (method) { return _this._visitClassMethod(method, ctx); });
  21615. ctx.decIndent();
  21616. ctx.println(stmt, "}");
  21617. ctx.popClass();
  21618. return null;
  21619. };
  21620. /**
  21621. * @param {?} field
  21622. * @param {?} ctx
  21623. * @return {?}
  21624. */
  21625. _TsEmitterVisitor.prototype._visitClassField = /**
  21626. * @param {?} field
  21627. * @param {?} ctx
  21628. * @return {?}
  21629. */
  21630. function (field, ctx) {
  21631. if (field.hasModifier(StmtModifier.Private)) {
  21632. // comment out as a workaround for #10967
  21633. ctx.print(null, "/*private*/ ");
  21634. }
  21635. ctx.print(null, field.name);
  21636. this._printColonType(field.type, ctx);
  21637. ctx.println(null, ";");
  21638. };
  21639. /**
  21640. * @param {?} getter
  21641. * @param {?} ctx
  21642. * @return {?}
  21643. */
  21644. _TsEmitterVisitor.prototype._visitClassGetter = /**
  21645. * @param {?} getter
  21646. * @param {?} ctx
  21647. * @return {?}
  21648. */
  21649. function (getter, ctx) {
  21650. if (getter.hasModifier(StmtModifier.Private)) {
  21651. ctx.print(null, "private ");
  21652. }
  21653. ctx.print(null, "get " + getter.name + "()");
  21654. this._printColonType(getter.type, ctx);
  21655. ctx.println(null, " {");
  21656. ctx.incIndent();
  21657. this.visitAllStatements(getter.body, ctx);
  21658. ctx.decIndent();
  21659. ctx.println(null, "}");
  21660. };
  21661. /**
  21662. * @param {?} stmt
  21663. * @param {?} ctx
  21664. * @return {?}
  21665. */
  21666. _TsEmitterVisitor.prototype._visitClassConstructor = /**
  21667. * @param {?} stmt
  21668. * @param {?} ctx
  21669. * @return {?}
  21670. */
  21671. function (stmt, ctx) {
  21672. ctx.print(stmt, "constructor(");
  21673. this._visitParams(stmt.constructorMethod.params, ctx);
  21674. ctx.println(stmt, ") {");
  21675. ctx.incIndent();
  21676. this.visitAllStatements(stmt.constructorMethod.body, ctx);
  21677. ctx.decIndent();
  21678. ctx.println(stmt, "}");
  21679. };
  21680. /**
  21681. * @param {?} method
  21682. * @param {?} ctx
  21683. * @return {?}
  21684. */
  21685. _TsEmitterVisitor.prototype._visitClassMethod = /**
  21686. * @param {?} method
  21687. * @param {?} ctx
  21688. * @return {?}
  21689. */
  21690. function (method, ctx) {
  21691. if (method.hasModifier(StmtModifier.Private)) {
  21692. ctx.print(null, "private ");
  21693. }
  21694. ctx.print(null, method.name + "(");
  21695. this._visitParams(method.params, ctx);
  21696. ctx.print(null, ")");
  21697. this._printColonType(method.type, ctx, 'void');
  21698. ctx.println(null, " {");
  21699. ctx.incIndent();
  21700. this.visitAllStatements(method.body, ctx);
  21701. ctx.decIndent();
  21702. ctx.println(null, "}");
  21703. };
  21704. /**
  21705. * @param {?} ast
  21706. * @param {?} ctx
  21707. * @return {?}
  21708. */
  21709. _TsEmitterVisitor.prototype.visitFunctionExpr = /**
  21710. * @param {?} ast
  21711. * @param {?} ctx
  21712. * @return {?}
  21713. */
  21714. function (ast, ctx) {
  21715. ctx.print(ast, "(");
  21716. this._visitParams(ast.params, ctx);
  21717. ctx.print(ast, ")");
  21718. this._printColonType(ast.type, ctx, 'void');
  21719. ctx.println(ast, " => {");
  21720. ctx.incIndent();
  21721. this.visitAllStatements(ast.statements, ctx);
  21722. ctx.decIndent();
  21723. ctx.print(ast, "}");
  21724. return null;
  21725. };
  21726. /**
  21727. * @param {?} stmt
  21728. * @param {?} ctx
  21729. * @return {?}
  21730. */
  21731. _TsEmitterVisitor.prototype.visitDeclareFunctionStmt = /**
  21732. * @param {?} stmt
  21733. * @param {?} ctx
  21734. * @return {?}
  21735. */
  21736. function (stmt, ctx) {
  21737. if (stmt.hasModifier(StmtModifier.Exported)) {
  21738. ctx.print(stmt, "export ");
  21739. }
  21740. ctx.print(stmt, "function " + stmt.name + "(");
  21741. this._visitParams(stmt.params, ctx);
  21742. ctx.print(stmt, ")");
  21743. this._printColonType(stmt.type, ctx, 'void');
  21744. ctx.println(stmt, " {");
  21745. ctx.incIndent();
  21746. this.visitAllStatements(stmt.statements, ctx);
  21747. ctx.decIndent();
  21748. ctx.println(stmt, "}");
  21749. return null;
  21750. };
  21751. /**
  21752. * @param {?} stmt
  21753. * @param {?} ctx
  21754. * @return {?}
  21755. */
  21756. _TsEmitterVisitor.prototype.visitTryCatchStmt = /**
  21757. * @param {?} stmt
  21758. * @param {?} ctx
  21759. * @return {?}
  21760. */
  21761. function (stmt, ctx) {
  21762. ctx.println(stmt, "try {");
  21763. ctx.incIndent();
  21764. this.visitAllStatements(stmt.bodyStmts, ctx);
  21765. ctx.decIndent();
  21766. ctx.println(stmt, "} catch (" + CATCH_ERROR_VAR$1.name + ") {");
  21767. ctx.incIndent();
  21768. var /** @type {?} */ catchStmts = [/** @type {?} */ (CATCH_STACK_VAR$1.set(CATCH_ERROR_VAR$1.prop('stack', null)).toDeclStmt(null, [
  21769. StmtModifier.Final
  21770. ]))].concat(stmt.catchStmts);
  21771. this.visitAllStatements(catchStmts, ctx);
  21772. ctx.decIndent();
  21773. ctx.println(stmt, "}");
  21774. return null;
  21775. };
  21776. /**
  21777. * @param {?} type
  21778. * @param {?} ctx
  21779. * @return {?}
  21780. */
  21781. _TsEmitterVisitor.prototype.visitBuiltintType = /**
  21782. * @param {?} type
  21783. * @param {?} ctx
  21784. * @return {?}
  21785. */
  21786. function (type, ctx) {
  21787. var /** @type {?} */ typeStr;
  21788. switch (type.name) {
  21789. case BuiltinTypeName.Bool:
  21790. typeStr = 'boolean';
  21791. break;
  21792. case BuiltinTypeName.Dynamic:
  21793. typeStr = 'any';
  21794. break;
  21795. case BuiltinTypeName.Function:
  21796. typeStr = 'Function';
  21797. break;
  21798. case BuiltinTypeName.Number:
  21799. typeStr = 'number';
  21800. break;
  21801. case BuiltinTypeName.Int:
  21802. typeStr = 'number';
  21803. break;
  21804. case BuiltinTypeName.String:
  21805. typeStr = 'string';
  21806. break;
  21807. default:
  21808. throw new Error("Unsupported builtin type " + type.name);
  21809. }
  21810. ctx.print(null, typeStr);
  21811. return null;
  21812. };
  21813. /**
  21814. * @param {?} ast
  21815. * @param {?} ctx
  21816. * @return {?}
  21817. */
  21818. _TsEmitterVisitor.prototype.visitExpressionType = /**
  21819. * @param {?} ast
  21820. * @param {?} ctx
  21821. * @return {?}
  21822. */
  21823. function (ast, ctx) {
  21824. ast.value.visitExpression(this, ctx);
  21825. return null;
  21826. };
  21827. /**
  21828. * @param {?} type
  21829. * @param {?} ctx
  21830. * @return {?}
  21831. */
  21832. _TsEmitterVisitor.prototype.visitArrayType = /**
  21833. * @param {?} type
  21834. * @param {?} ctx
  21835. * @return {?}
  21836. */
  21837. function (type, ctx) {
  21838. this.visitType(type.of, ctx);
  21839. ctx.print(null, "[]");
  21840. return null;
  21841. };
  21842. /**
  21843. * @param {?} type
  21844. * @param {?} ctx
  21845. * @return {?}
  21846. */
  21847. _TsEmitterVisitor.prototype.visitMapType = /**
  21848. * @param {?} type
  21849. * @param {?} ctx
  21850. * @return {?}
  21851. */
  21852. function (type, ctx) {
  21853. ctx.print(null, "{[key: string]:");
  21854. this.visitType(type.valueType, ctx);
  21855. ctx.print(null, "}");
  21856. return null;
  21857. };
  21858. /**
  21859. * @param {?} method
  21860. * @return {?}
  21861. */
  21862. _TsEmitterVisitor.prototype.getBuiltinMethodName = /**
  21863. * @param {?} method
  21864. * @return {?}
  21865. */
  21866. function (method) {
  21867. var /** @type {?} */ name;
  21868. switch (method) {
  21869. case BuiltinMethod.ConcatArray:
  21870. name = 'concat';
  21871. break;
  21872. case BuiltinMethod.SubscribeObservable:
  21873. name = 'subscribe';
  21874. break;
  21875. case BuiltinMethod.Bind:
  21876. name = 'bind';
  21877. break;
  21878. default:
  21879. throw new Error("Unknown builtin method: " + method);
  21880. }
  21881. return name;
  21882. };
  21883. /**
  21884. * @param {?} params
  21885. * @param {?} ctx
  21886. * @return {?}
  21887. */
  21888. _TsEmitterVisitor.prototype._visitParams = /**
  21889. * @param {?} params
  21890. * @param {?} ctx
  21891. * @return {?}
  21892. */
  21893. function (params, ctx) {
  21894. var _this = this;
  21895. this.visitAllObjects(function (param) {
  21896. ctx.print(null, param.name);
  21897. _this._printColonType(param.type, ctx);
  21898. }, params, ctx, ',');
  21899. };
  21900. /**
  21901. * @param {?} value
  21902. * @param {?} typeParams
  21903. * @param {?} ctx
  21904. * @return {?}
  21905. */
  21906. _TsEmitterVisitor.prototype._visitIdentifier = /**
  21907. * @param {?} value
  21908. * @param {?} typeParams
  21909. * @param {?} ctx
  21910. * @return {?}
  21911. */
  21912. function (value, typeParams, ctx) {
  21913. var _this = this;
  21914. var name = value.name, moduleName = value.moduleName;
  21915. if (this.referenceFilter && this.referenceFilter(value)) {
  21916. ctx.print(null, '(null as any)');
  21917. return;
  21918. }
  21919. if (moduleName) {
  21920. var /** @type {?} */ prefix = this.importsWithPrefixes.get(moduleName);
  21921. if (prefix == null) {
  21922. prefix = "i" + this.importsWithPrefixes.size;
  21923. this.importsWithPrefixes.set(moduleName, prefix);
  21924. }
  21925. ctx.print(null, prefix + ".");
  21926. }
  21927. ctx.print(null, /** @type {?} */ ((name)));
  21928. if (this.typeExpression > 0) {
  21929. // If we are in a type expression that refers to a generic type then supply
  21930. // the required type parameters. If there were not enough type parameters
  21931. // supplied, supply any as the type. Outside a type expression the reference
  21932. // should not supply type parameters and be treated as a simple value reference
  21933. // to the constructor function itself.
  21934. var /** @type {?} */ suppliedParameters = typeParams || [];
  21935. if (suppliedParameters.length > 0) {
  21936. ctx.print(null, "<");
  21937. this.visitAllObjects(function (type) { return type.visitType(_this, ctx); }, /** @type {?} */ ((typeParams)), ctx, ',');
  21938. ctx.print(null, ">");
  21939. }
  21940. }
  21941. };
  21942. /**
  21943. * @param {?} type
  21944. * @param {?} ctx
  21945. * @param {?=} defaultType
  21946. * @return {?}
  21947. */
  21948. _TsEmitterVisitor.prototype._printColonType = /**
  21949. * @param {?} type
  21950. * @param {?} ctx
  21951. * @param {?=} defaultType
  21952. * @return {?}
  21953. */
  21954. function (type, ctx, defaultType) {
  21955. if (type !== INFERRED_TYPE) {
  21956. ctx.print(null, ':');
  21957. this.visitType(type, ctx, defaultType);
  21958. }
  21959. };
  21960. return _TsEmitterVisitor;
  21961. }(AbstractEmitterVisitor));
  21962. /**
  21963. * @fileoverview added by tsickle
  21964. * @suppress {checkTypes} checked by tsc
  21965. */
  21966. /**
  21967. * @license
  21968. * Copyright Google Inc. All Rights Reserved.
  21969. *
  21970. * Use of this source code is governed by an MIT-style license that can be
  21971. * found in the LICENSE file at https://angular.io/license
  21972. */
  21973. /**
  21974. * Resolve a `Type` for {\@link Pipe}.
  21975. *
  21976. * This interface can be overridden by the application developer to create custom behavior.
  21977. *
  21978. * See {\@link Compiler}
  21979. */
  21980. var PipeResolver = /** @class */ (function () {
  21981. function PipeResolver(_reflector) {
  21982. this._reflector = _reflector;
  21983. }
  21984. /**
  21985. * @param {?} type
  21986. * @return {?}
  21987. */
  21988. PipeResolver.prototype.isPipe = /**
  21989. * @param {?} type
  21990. * @return {?}
  21991. */
  21992. function (type) {
  21993. var /** @type {?} */ typeMetadata = this._reflector.annotations(resolveForwardRef(type));
  21994. return typeMetadata && typeMetadata.some(createPipe.isTypeOf);
  21995. };
  21996. /**
  21997. * Return {@link Pipe} for a given `Type`.
  21998. */
  21999. /**
  22000. * Return {\@link Pipe} for a given `Type`.
  22001. * @param {?} type
  22002. * @param {?=} throwIfNotFound
  22003. * @return {?}
  22004. */
  22005. PipeResolver.prototype.resolve = /**
  22006. * Return {\@link Pipe} for a given `Type`.
  22007. * @param {?} type
  22008. * @param {?=} throwIfNotFound
  22009. * @return {?}
  22010. */
  22011. function (type, throwIfNotFound) {
  22012. if (throwIfNotFound === void 0) { throwIfNotFound = true; }
  22013. var /** @type {?} */ metas = this._reflector.annotations(resolveForwardRef(type));
  22014. if (metas) {
  22015. var /** @type {?} */ annotation = findLast(metas, createPipe.isTypeOf);
  22016. if (annotation) {
  22017. return annotation;
  22018. }
  22019. }
  22020. if (throwIfNotFound) {
  22021. throw new Error("No Pipe decorator found on " + stringify(type));
  22022. }
  22023. return null;
  22024. };
  22025. return PipeResolver;
  22026. }());
  22027. /**
  22028. * @fileoverview added by tsickle
  22029. * @suppress {checkTypes} checked by tsc
  22030. */
  22031. /**
  22032. * @license
  22033. * Copyright Google Inc. All Rights Reserved.
  22034. *
  22035. * Use of this source code is governed by an MIT-style license that can be
  22036. * found in the LICENSE file at https://angular.io/license
  22037. */
  22038. /**
  22039. * Map from tagName|propertyName SecurityContext. Properties applying to all tags use '*'.
  22040. */
  22041. var SECURITY_SCHEMA = {};
  22042. /**
  22043. * @param {?} ctx
  22044. * @param {?} specs
  22045. * @return {?}
  22046. */
  22047. function registerContext(ctx, specs) {
  22048. for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) {
  22049. var spec = specs_1[_i];
  22050. SECURITY_SCHEMA[spec.toLowerCase()] = ctx;
  22051. }
  22052. }
  22053. // Case is insignificant below, all element and attribute names are lower-cased for lookup.
  22054. registerContext(SecurityContext.HTML, [
  22055. 'iframe|srcdoc',
  22056. '*|innerHTML',
  22057. '*|outerHTML',
  22058. ]);
  22059. registerContext(SecurityContext.STYLE, ['*|style']);
  22060. // NB: no SCRIPT contexts here, they are never allowed due to the parser stripping them.
  22061. registerContext(SecurityContext.URL, [
  22062. '*|formAction', 'area|href', 'area|ping', 'audio|src', 'a|href',
  22063. 'a|ping', 'blockquote|cite', 'body|background', 'del|cite', 'form|action',
  22064. 'img|src', 'img|srcset', 'input|src', 'ins|cite', 'q|cite',
  22065. 'source|src', 'source|srcset', 'track|src', 'video|poster', 'video|src',
  22066. ]);
  22067. registerContext(SecurityContext.RESOURCE_URL, [
  22068. 'applet|code',
  22069. 'applet|codebase',
  22070. 'base|href',
  22071. 'embed|src',
  22072. 'frame|src',
  22073. 'head|profile',
  22074. 'html|manifest',
  22075. 'iframe|src',
  22076. 'link|href',
  22077. 'media|src',
  22078. 'object|codebase',
  22079. 'object|data',
  22080. 'script|src',
  22081. ]);
  22082. /**
  22083. * @fileoverview added by tsickle
  22084. * @suppress {checkTypes} checked by tsc
  22085. */
  22086. /**
  22087. * @license
  22088. * Copyright Google Inc. All Rights Reserved.
  22089. *
  22090. * Use of this source code is governed by an MIT-style license that can be
  22091. * found in the LICENSE file at https://angular.io/license
  22092. */
  22093. /**
  22094. * @abstract
  22095. */
  22096. var ElementSchemaRegistry = /** @class */ (function () {
  22097. function ElementSchemaRegistry() {
  22098. }
  22099. return ElementSchemaRegistry;
  22100. }());
  22101. /**
  22102. * @fileoverview added by tsickle
  22103. * @suppress {checkTypes} checked by tsc
  22104. */
  22105. /**
  22106. * @license
  22107. * Copyright Google Inc. All Rights Reserved.
  22108. *
  22109. * Use of this source code is governed by an MIT-style license that can be
  22110. * found in the LICENSE file at https://angular.io/license
  22111. */
  22112. var BOOLEAN = 'boolean';
  22113. var NUMBER = 'number';
  22114. var STRING = 'string';
  22115. var OBJECT = 'object';
  22116. /**
  22117. * This array represents the DOM schema. It encodes inheritance, properties, and events.
  22118. *
  22119. * ## Overview
  22120. *
  22121. * Each line represents one kind of element. The `element_inheritance` and properties are joined
  22122. * using `element_inheritance|properties` syntax.
  22123. *
  22124. * ## Element Inheritance
  22125. *
  22126. * The `element_inheritance` can be further subdivided as `element1,element2,...^parentElement`.
  22127. * Here the individual elements are separated by `,` (commas). Every element in the list
  22128. * has identical properties.
  22129. *
  22130. * An `element` may inherit additional properties from `parentElement` If no `^parentElement` is
  22131. * specified then `""` (blank) element is assumed.
  22132. *
  22133. * NOTE: The blank element inherits from root `[Element]` element, the super element of all
  22134. * elements.
  22135. *
  22136. * NOTE an element prefix such as `:svg:` has no special meaning to the schema.
  22137. *
  22138. * ## Properties
  22139. *
  22140. * Each element has a set of properties separated by `,` (commas). Each property can be prefixed
  22141. * by a special character designating its type:
  22142. *
  22143. * - (no prefix): property is a string.
  22144. * - `*`: property represents an event.
  22145. * - `!`: property is a boolean.
  22146. * - `#`: property is a number.
  22147. * - `%`: property is an object.
  22148. *
  22149. * ## Query
  22150. *
  22151. * The class creates an internal squas representation which allows to easily answer the query of
  22152. * if a given property exist on a given element.
  22153. *
  22154. * NOTE: We don't yet support querying for types or events.
  22155. * NOTE: This schema is auto extracted from `schema_extractor.ts` located in the test folder,
  22156. * see dom_element_schema_registry_spec.ts
  22157. */
  22158. var SCHEMA = [
  22159. '[Element]|textContent,%classList,className,id,innerHTML,*beforecopy,*beforecut,*beforepaste,*copy,*cut,*paste,*search,*selectstart,*webkitfullscreenchange,*webkitfullscreenerror,*wheel,outerHTML,#scrollLeft,#scrollTop,slot' +
  22160. ',*message,*mozfullscreenchange,*mozfullscreenerror,*mozpointerlockchange,*mozpointerlockerror,*webglcontextcreationerror,*webglcontextlost,*webglcontextrestored',
  22161. '[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',
  22162. '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',
  22163. 'media^[HTMLElement]|!autoplay,!controls,%controlsList,%crossOrigin,#currentTime,!defaultMuted,#defaultPlaybackRate,!disableRemotePlayback,!loop,!muted,*encrypted,*waitingforkey,#playbackRate,preload,src,%srcObject,#volume',
  22164. ':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',
  22165. ':svg:graphics^:svg:|',
  22166. ':svg:animation^:svg:|*begin,*end,*repeat',
  22167. ':svg:geometry^:svg:|',
  22168. ':svg:componentTransferFunction^:svg:|',
  22169. ':svg:gradient^:svg:|',
  22170. ':svg:textContent^:svg:graphics|',
  22171. ':svg:textPositioning^:svg:textContent|',
  22172. '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',
  22173. 'area^[HTMLElement]|alt,coords,download,hash,host,hostname,href,!noHref,password,pathname,ping,port,protocol,referrerPolicy,rel,search,shape,target,username',
  22174. 'audio^media|',
  22175. 'br^[HTMLElement]|clear',
  22176. 'base^[HTMLElement]|href,target',
  22177. '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',
  22178. 'button^[HTMLElement]|!autofocus,!disabled,formAction,formEnctype,formMethod,!formNoValidate,formTarget,name,type,value',
  22179. 'canvas^[HTMLElement]|#height,#width',
  22180. 'content^[HTMLElement]|select',
  22181. 'dl^[HTMLElement]|!compact',
  22182. 'datalist^[HTMLElement]|',
  22183. 'details^[HTMLElement]|!open',
  22184. 'dialog^[HTMLElement]|!open,returnValue',
  22185. 'dir^[HTMLElement]|!compact',
  22186. 'div^[HTMLElement]|align',
  22187. 'embed^[HTMLElement]|align,height,name,src,type,width',
  22188. 'fieldset^[HTMLElement]|!disabled,name',
  22189. 'font^[HTMLElement]|color,face,size',
  22190. 'form^[HTMLElement]|acceptCharset,action,autocomplete,encoding,enctype,method,name,!noValidate,target',
  22191. 'frame^[HTMLElement]|frameBorder,longDesc,marginHeight,marginWidth,name,!noResize,scrolling,src',
  22192. 'frameset^[HTMLElement]|cols,*beforeunload,*blur,*error,*focus,*hashchange,*languagechange,*load,*message,*offline,*online,*pagehide,*pageshow,*popstate,*rejectionhandled,*resize,*scroll,*storage,*unhandledrejection,*unload,rows',
  22193. 'hr^[HTMLElement]|align,color,!noShade,size,width',
  22194. 'head^[HTMLElement]|',
  22195. 'h1,h2,h3,h4,h5,h6^[HTMLElement]|align',
  22196. 'html^[HTMLElement]|version',
  22197. 'iframe^[HTMLElement]|align,!allowFullscreen,frameBorder,height,longDesc,marginHeight,marginWidth,name,referrerPolicy,%sandbox,scrolling,src,srcdoc,width',
  22198. 'img^[HTMLElement]|align,alt,border,%crossOrigin,#height,#hspace,!isMap,longDesc,lowsrc,name,referrerPolicy,sizes,src,srcset,useMap,#vspace,#width',
  22199. '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',
  22200. 'li^[HTMLElement]|type,#value',
  22201. 'label^[HTMLElement]|htmlFor',
  22202. 'legend^[HTMLElement]|align',
  22203. 'link^[HTMLElement]|as,charset,%crossOrigin,!disabled,href,hreflang,integrity,media,referrerPolicy,rel,%relList,rev,%sizes,target,type',
  22204. 'map^[HTMLElement]|name',
  22205. 'marquee^[HTMLElement]|behavior,bgColor,direction,height,#hspace,#loop,#scrollAmount,#scrollDelay,!trueSpeed,#vspace,width',
  22206. 'menu^[HTMLElement]|!compact',
  22207. 'meta^[HTMLElement]|content,httpEquiv,name,scheme',
  22208. 'meter^[HTMLElement]|#high,#low,#max,#min,#optimum,#value',
  22209. 'ins,del^[HTMLElement]|cite,dateTime',
  22210. 'ol^[HTMLElement]|!compact,!reversed,#start,type',
  22211. 'object^[HTMLElement]|align,archive,border,code,codeBase,codeType,data,!declare,height,#hspace,name,standby,type,useMap,#vspace,width',
  22212. 'optgroup^[HTMLElement]|!disabled,label',
  22213. 'option^[HTMLElement]|!defaultSelected,!disabled,label,!selected,text,value',
  22214. 'output^[HTMLElement]|defaultValue,%htmlFor,name,value',
  22215. 'p^[HTMLElement]|align',
  22216. 'param^[HTMLElement]|name,type,value,valueType',
  22217. 'picture^[HTMLElement]|',
  22218. 'pre^[HTMLElement]|#width',
  22219. 'progress^[HTMLElement]|#max,#value',
  22220. 'q,blockquote,cite^[HTMLElement]|',
  22221. 'script^[HTMLElement]|!async,charset,%crossOrigin,!defer,event,htmlFor,integrity,src,text,type',
  22222. 'select^[HTMLElement]|!autofocus,!disabled,#length,!multiple,name,!required,#selectedIndex,#size,value',
  22223. 'shadow^[HTMLElement]|',
  22224. 'slot^[HTMLElement]|name',
  22225. 'source^[HTMLElement]|media,sizes,src,srcset,type',
  22226. 'span^[HTMLElement]|',
  22227. 'style^[HTMLElement]|!disabled,media,type',
  22228. 'caption^[HTMLElement]|align',
  22229. 'th,td^[HTMLElement]|abbr,align,axis,bgColor,ch,chOff,#colSpan,headers,height,!noWrap,#rowSpan,scope,vAlign,width',
  22230. 'col,colgroup^[HTMLElement]|align,ch,chOff,#span,vAlign,width',
  22231. 'table^[HTMLElement]|align,bgColor,border,%caption,cellPadding,cellSpacing,frame,rules,summary,%tFoot,%tHead,width',
  22232. 'tr^[HTMLElement]|align,bgColor,ch,chOff,vAlign',
  22233. 'tfoot,thead,tbody^[HTMLElement]|align,ch,chOff,vAlign',
  22234. 'template^[HTMLElement]|',
  22235. 'textarea^[HTMLElement]|autocapitalize,!autofocus,#cols,defaultValue,dirName,!disabled,#maxLength,#minLength,name,placeholder,!readOnly,!required,#rows,selectionDirection,#selectionEnd,#selectionStart,value,wrap',
  22236. 'title^[HTMLElement]|text',
  22237. 'track^[HTMLElement]|!default,kind,label,src,srclang',
  22238. 'ul^[HTMLElement]|!compact,type',
  22239. 'unknown^[HTMLElement]|',
  22240. 'video^media|#height,poster,#width',
  22241. ':svg:a^:svg:graphics|',
  22242. ':svg:animate^:svg:animation|',
  22243. ':svg:animateMotion^:svg:animation|',
  22244. ':svg:animateTransform^:svg:animation|',
  22245. ':svg:circle^:svg:geometry|',
  22246. ':svg:clipPath^:svg:graphics|',
  22247. ':svg:defs^:svg:graphics|',
  22248. ':svg:desc^:svg:|',
  22249. ':svg:discard^:svg:|',
  22250. ':svg:ellipse^:svg:geometry|',
  22251. ':svg:feBlend^:svg:|',
  22252. ':svg:feColorMatrix^:svg:|',
  22253. ':svg:feComponentTransfer^:svg:|',
  22254. ':svg:feComposite^:svg:|',
  22255. ':svg:feConvolveMatrix^:svg:|',
  22256. ':svg:feDiffuseLighting^:svg:|',
  22257. ':svg:feDisplacementMap^:svg:|',
  22258. ':svg:feDistantLight^:svg:|',
  22259. ':svg:feDropShadow^:svg:|',
  22260. ':svg:feFlood^:svg:|',
  22261. ':svg:feFuncA^:svg:componentTransferFunction|',
  22262. ':svg:feFuncB^:svg:componentTransferFunction|',
  22263. ':svg:feFuncG^:svg:componentTransferFunction|',
  22264. ':svg:feFuncR^:svg:componentTransferFunction|',
  22265. ':svg:feGaussianBlur^:svg:|',
  22266. ':svg:feImage^:svg:|',
  22267. ':svg:feMerge^:svg:|',
  22268. ':svg:feMergeNode^:svg:|',
  22269. ':svg:feMorphology^:svg:|',
  22270. ':svg:feOffset^:svg:|',
  22271. ':svg:fePointLight^:svg:|',
  22272. ':svg:feSpecularLighting^:svg:|',
  22273. ':svg:feSpotLight^:svg:|',
  22274. ':svg:feTile^:svg:|',
  22275. ':svg:feTurbulence^:svg:|',
  22276. ':svg:filter^:svg:|',
  22277. ':svg:foreignObject^:svg:graphics|',
  22278. ':svg:g^:svg:graphics|',
  22279. ':svg:image^:svg:graphics|',
  22280. ':svg:line^:svg:geometry|',
  22281. ':svg:linearGradient^:svg:gradient|',
  22282. ':svg:mpath^:svg:|',
  22283. ':svg:marker^:svg:|',
  22284. ':svg:mask^:svg:|',
  22285. ':svg:metadata^:svg:|',
  22286. ':svg:path^:svg:geometry|',
  22287. ':svg:pattern^:svg:|',
  22288. ':svg:polygon^:svg:geometry|',
  22289. ':svg:polyline^:svg:geometry|',
  22290. ':svg:radialGradient^:svg:gradient|',
  22291. ':svg:rect^:svg:geometry|',
  22292. ':svg:svg^:svg:graphics|#currentScale,#zoomAndPan',
  22293. ':svg:script^:svg:|type',
  22294. ':svg:set^:svg:animation|',
  22295. ':svg:stop^:svg:|',
  22296. ':svg:style^:svg:|!disabled,media,title,type',
  22297. ':svg:switch^:svg:graphics|',
  22298. ':svg:symbol^:svg:|',
  22299. ':svg:tspan^:svg:textPositioning|',
  22300. ':svg:text^:svg:textPositioning|',
  22301. ':svg:textPath^:svg:textContent|',
  22302. ':svg:title^:svg:|',
  22303. ':svg:use^:svg:graphics|',
  22304. ':svg:view^:svg:|#zoomAndPan',
  22305. 'data^[HTMLElement]|value',
  22306. 'keygen^[HTMLElement]|!autofocus,challenge,!disabled,form,keytype,name',
  22307. 'menuitem^[HTMLElement]|type,label,icon,!disabled,!checked,radiogroup,!default',
  22308. 'summary^[HTMLElement]|',
  22309. 'time^[HTMLElement]|dateTime',
  22310. ':svg:cursor^:svg:|',
  22311. ];
  22312. var _ATTR_TO_PROP = {
  22313. 'class': 'className',
  22314. 'for': 'htmlFor',
  22315. 'formaction': 'formAction',
  22316. 'innerHtml': 'innerHTML',
  22317. 'readonly': 'readOnly',
  22318. 'tabindex': 'tabIndex',
  22319. };
  22320. var DomElementSchemaRegistry = /** @class */ (function (_super) {
  22321. __extends(DomElementSchemaRegistry, _super);
  22322. function DomElementSchemaRegistry() {
  22323. var _this = _super.call(this) || this;
  22324. _this._schema = {};
  22325. SCHEMA.forEach(function (encodedType) {
  22326. var /** @type {?} */ type = {};
  22327. var _a = encodedType.split('|'), strType = _a[0], strProperties = _a[1];
  22328. var /** @type {?} */ properties = strProperties.split(',');
  22329. var _b = strType.split('^'), typeNames = _b[0], superName = _b[1];
  22330. typeNames.split(',').forEach(function (tag) { return _this._schema[tag.toLowerCase()] = type; });
  22331. var /** @type {?} */ superType = superName && _this._schema[superName.toLowerCase()];
  22332. if (superType) {
  22333. Object.keys(superType).forEach(function (prop) { type[prop] = superType[prop]; });
  22334. }
  22335. properties.forEach(function (property) {
  22336. if (property.length > 0) {
  22337. switch (property[0]) {
  22338. case '*':
  22339. // We don't yet support events.
  22340. // If ever allowing to bind to events, GO THROUGH A SECURITY REVIEW, allowing events
  22341. // will
  22342. // almost certainly introduce bad XSS vulnerabilities.
  22343. // type[property.substring(1)] = EVENT;
  22344. break;
  22345. case '!':
  22346. type[property.substring(1)] = BOOLEAN;
  22347. break;
  22348. case '#':
  22349. type[property.substring(1)] = NUMBER;
  22350. break;
  22351. case '%':
  22352. type[property.substring(1)] = OBJECT;
  22353. break;
  22354. default:
  22355. type[property] = STRING;
  22356. }
  22357. }
  22358. });
  22359. });
  22360. return _this;
  22361. }
  22362. /**
  22363. * @param {?} tagName
  22364. * @param {?} propName
  22365. * @param {?} schemaMetas
  22366. * @return {?}
  22367. */
  22368. DomElementSchemaRegistry.prototype.hasProperty = /**
  22369. * @param {?} tagName
  22370. * @param {?} propName
  22371. * @param {?} schemaMetas
  22372. * @return {?}
  22373. */
  22374. function (tagName, propName, schemaMetas) {
  22375. if (schemaMetas.some(function (schema) { return schema.name === NO_ERRORS_SCHEMA.name; })) {
  22376. return true;
  22377. }
  22378. if (tagName.indexOf('-') > -1) {
  22379. if (isNgContainer(tagName) || isNgContent(tagName)) {
  22380. return false;
  22381. }
  22382. if (schemaMetas.some(function (schema) { return schema.name === CUSTOM_ELEMENTS_SCHEMA.name; })) {
  22383. // Can't tell now as we don't know which properties a custom element will get
  22384. // once it is instantiated
  22385. return true;
  22386. }
  22387. }
  22388. var /** @type {?} */ elementProperties = this._schema[tagName.toLowerCase()] || this._schema['unknown'];
  22389. return !!elementProperties[propName];
  22390. };
  22391. /**
  22392. * @param {?} tagName
  22393. * @param {?} schemaMetas
  22394. * @return {?}
  22395. */
  22396. DomElementSchemaRegistry.prototype.hasElement = /**
  22397. * @param {?} tagName
  22398. * @param {?} schemaMetas
  22399. * @return {?}
  22400. */
  22401. function (tagName, schemaMetas) {
  22402. if (schemaMetas.some(function (schema) { return schema.name === NO_ERRORS_SCHEMA.name; })) {
  22403. return true;
  22404. }
  22405. if (tagName.indexOf('-') > -1) {
  22406. if (isNgContainer(tagName) || isNgContent(tagName)) {
  22407. return true;
  22408. }
  22409. if (schemaMetas.some(function (schema) { return schema.name === CUSTOM_ELEMENTS_SCHEMA.name; })) {
  22410. // Allow any custom elements
  22411. return true;
  22412. }
  22413. }
  22414. return !!this._schema[tagName.toLowerCase()];
  22415. };
  22416. /**
  22417. * securityContext returns the security context for the given property on the given DOM tag.
  22418. *
  22419. * Tag and property name are statically known and cannot change at runtime, i.e. it is not
  22420. * possible to bind a value into a changing attribute or tag name.
  22421. *
  22422. * The filtering is white list based. All attributes in the schema above are assumed to have the
  22423. * 'NONE' security context, i.e. that they are safe inert string values. Only specific well known
  22424. * attack vectors are assigned their appropriate context.
  22425. */
  22426. /**
  22427. * securityContext returns the security context for the given property on the given DOM tag.
  22428. *
  22429. * Tag and property name are statically known and cannot change at runtime, i.e. it is not
  22430. * possible to bind a value into a changing attribute or tag name.
  22431. *
  22432. * The filtering is white list based. All attributes in the schema above are assumed to have the
  22433. * 'NONE' security context, i.e. that they are safe inert string values. Only specific well known
  22434. * attack vectors are assigned their appropriate context.
  22435. * @param {?} tagName
  22436. * @param {?} propName
  22437. * @param {?} isAttribute
  22438. * @return {?}
  22439. */
  22440. DomElementSchemaRegistry.prototype.securityContext = /**
  22441. * securityContext returns the security context for the given property on the given DOM tag.
  22442. *
  22443. * Tag and property name are statically known and cannot change at runtime, i.e. it is not
  22444. * possible to bind a value into a changing attribute or tag name.
  22445. *
  22446. * The filtering is white list based. All attributes in the schema above are assumed to have the
  22447. * 'NONE' security context, i.e. that they are safe inert string values. Only specific well known
  22448. * attack vectors are assigned their appropriate context.
  22449. * @param {?} tagName
  22450. * @param {?} propName
  22451. * @param {?} isAttribute
  22452. * @return {?}
  22453. */
  22454. function (tagName, propName, isAttribute) {
  22455. if (isAttribute) {
  22456. // NB: For security purposes, use the mapped property name, not the attribute name.
  22457. propName = this.getMappedPropName(propName);
  22458. }
  22459. // Make sure comparisons are case insensitive, so that case differences between attribute and
  22460. // property names do not have a security impact.
  22461. tagName = tagName.toLowerCase();
  22462. propName = propName.toLowerCase();
  22463. var /** @type {?} */ ctx = SECURITY_SCHEMA[tagName + '|' + propName];
  22464. if (ctx) {
  22465. return ctx;
  22466. }
  22467. ctx = SECURITY_SCHEMA['*|' + propName];
  22468. return ctx ? ctx : SecurityContext.NONE;
  22469. };
  22470. /**
  22471. * @param {?} propName
  22472. * @return {?}
  22473. */
  22474. DomElementSchemaRegistry.prototype.getMappedPropName = /**
  22475. * @param {?} propName
  22476. * @return {?}
  22477. */
  22478. function (propName) { return _ATTR_TO_PROP[propName] || propName; };
  22479. /**
  22480. * @return {?}
  22481. */
  22482. DomElementSchemaRegistry.prototype.getDefaultComponentElementName = /**
  22483. * @return {?}
  22484. */
  22485. function () { return 'ng-component'; };
  22486. /**
  22487. * @param {?} name
  22488. * @return {?}
  22489. */
  22490. DomElementSchemaRegistry.prototype.validateProperty = /**
  22491. * @param {?} name
  22492. * @return {?}
  22493. */
  22494. function (name) {
  22495. if (name.toLowerCase().startsWith('on')) {
  22496. var /** @type {?} */ msg = "Binding to event property '" + name + "' is disallowed for security reasons, " +
  22497. ("please use (" + name.slice(2) + ")=...") +
  22498. ("\nIf '" + name + "' is a directive input, make sure the directive is imported by the") +
  22499. " current module.";
  22500. return { error: true, msg: msg };
  22501. }
  22502. else {
  22503. return { error: false };
  22504. }
  22505. };
  22506. /**
  22507. * @param {?} name
  22508. * @return {?}
  22509. */
  22510. DomElementSchemaRegistry.prototype.validateAttribute = /**
  22511. * @param {?} name
  22512. * @return {?}
  22513. */
  22514. function (name) {
  22515. if (name.toLowerCase().startsWith('on')) {
  22516. var /** @type {?} */ msg = "Binding to event attribute '" + name + "' is disallowed for security reasons, " +
  22517. ("please use (" + name.slice(2) + ")=...");
  22518. return { error: true, msg: msg };
  22519. }
  22520. else {
  22521. return { error: false };
  22522. }
  22523. };
  22524. /**
  22525. * @return {?}
  22526. */
  22527. DomElementSchemaRegistry.prototype.allKnownElementNames = /**
  22528. * @return {?}
  22529. */
  22530. function () { return Object.keys(this._schema); };
  22531. /**
  22532. * @param {?} propName
  22533. * @return {?}
  22534. */
  22535. DomElementSchemaRegistry.prototype.normalizeAnimationStyleProperty = /**
  22536. * @param {?} propName
  22537. * @return {?}
  22538. */
  22539. function (propName) {
  22540. return dashCaseToCamelCase(propName);
  22541. };
  22542. /**
  22543. * @param {?} camelCaseProp
  22544. * @param {?} userProvidedProp
  22545. * @param {?} val
  22546. * @return {?}
  22547. */
  22548. DomElementSchemaRegistry.prototype.normalizeAnimationStyleValue = /**
  22549. * @param {?} camelCaseProp
  22550. * @param {?} userProvidedProp
  22551. * @param {?} val
  22552. * @return {?}
  22553. */
  22554. function (camelCaseProp, userProvidedProp, val) {
  22555. var /** @type {?} */ unit = '';
  22556. var /** @type {?} */ strVal = val.toString().trim();
  22557. var /** @type {?} */ errorMsg = /** @type {?} */ ((null));
  22558. if (_isPixelDimensionStyle(camelCaseProp) && val !== 0 && val !== '0') {
  22559. if (typeof val === 'number') {
  22560. unit = 'px';
  22561. }
  22562. else {
  22563. var /** @type {?} */ valAndSuffixMatch = val.match(/^[+-]?[\d\.]+([a-z]*)$/);
  22564. if (valAndSuffixMatch && valAndSuffixMatch[1].length == 0) {
  22565. errorMsg = "Please provide a CSS unit value for " + userProvidedProp + ":" + val;
  22566. }
  22567. }
  22568. }
  22569. return { error: errorMsg, value: strVal + unit };
  22570. };
  22571. return DomElementSchemaRegistry;
  22572. }(ElementSchemaRegistry));
  22573. /**
  22574. * @param {?} prop
  22575. * @return {?}
  22576. */
  22577. function _isPixelDimensionStyle(prop) {
  22578. switch (prop) {
  22579. case 'width':
  22580. case 'height':
  22581. case 'minWidth':
  22582. case 'minHeight':
  22583. case 'maxWidth':
  22584. case 'maxHeight':
  22585. case 'left':
  22586. case 'top':
  22587. case 'bottom':
  22588. case 'right':
  22589. case 'fontSize':
  22590. case 'outlineWidth':
  22591. case 'outlineOffset':
  22592. case 'paddingTop':
  22593. case 'paddingLeft':
  22594. case 'paddingBottom':
  22595. case 'paddingRight':
  22596. case 'marginTop':
  22597. case 'marginLeft':
  22598. case 'marginBottom':
  22599. case 'marginRight':
  22600. case 'borderRadius':
  22601. case 'borderWidth':
  22602. case 'borderTopWidth':
  22603. case 'borderLeftWidth':
  22604. case 'borderRightWidth':
  22605. case 'borderBottomWidth':
  22606. case 'textIndent':
  22607. return true;
  22608. default:
  22609. return false;
  22610. }
  22611. }
  22612. /**
  22613. * @fileoverview added by tsickle
  22614. * @suppress {checkTypes} checked by tsc
  22615. */
  22616. /**
  22617. * @license
  22618. * Copyright Google Inc. All Rights Reserved.
  22619. *
  22620. * Use of this source code is governed by an MIT-style license that can be
  22621. * found in the LICENSE file at https://angular.io/license
  22622. */
  22623. /**
  22624. * This file is a port of shadowCSS from webcomponents.js to TypeScript.
  22625. *
  22626. * Please make sure to keep to edits in sync with the source file.
  22627. *
  22628. * Source:
  22629. * https://github.com/webcomponents/webcomponentsjs/blob/4efecd7e0e/src/ShadowCSS/ShadowCSS.js
  22630. *
  22631. * The original file level comment is reproduced below
  22632. */
  22633. /*
  22634. This is a limited shim for ShadowDOM css styling.
  22635. https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#styles
  22636. The intention here is to support only the styling features which can be
  22637. relatively simply implemented. The goal is to allow users to avoid the
  22638. most obvious pitfalls and do so without compromising performance significantly.
  22639. For ShadowDOM styling that's not covered here, a set of best practices
  22640. can be provided that should allow users to accomplish more complex styling.
  22641. The following is a list of specific ShadowDOM styling features and a brief
  22642. discussion of the approach used to shim.
  22643. Shimmed features:
  22644. * :host, :host-context: ShadowDOM allows styling of the shadowRoot's host
  22645. element using the :host rule. To shim this feature, the :host styles are
  22646. reformatted and prefixed with a given scope name and promoted to a
  22647. document level stylesheet.
  22648. For example, given a scope name of .foo, a rule like this:
  22649. :host {
  22650. background: red;
  22651. }
  22652. }
  22653. becomes:
  22654. .foo {
  22655. background: red;
  22656. }
  22657. * encapsulation: Styles defined within ShadowDOM, apply only to
  22658. dom inside the ShadowDOM. Polymer uses one of two techniques to implement
  22659. this feature.
  22660. By default, rules are prefixed with the host element tag name
  22661. as a descendant selector. This ensures styling does not leak out of the 'top'
  22662. of the element's ShadowDOM. For example,
  22663. div {
  22664. font-weight: bold;
  22665. }
  22666. becomes:
  22667. x-foo div {
  22668. font-weight: bold;
  22669. }
  22670. becomes:
  22671. Alternatively, if WebComponents.ShadowCSS.strictStyling is set to true then
  22672. selectors are scoped by adding an attribute selector suffix to each
  22673. simple selector that contains the host element tag name. Each element
  22674. in the element's ShadowDOM template is also given the scope attribute.
  22675. Thus, these rules match only elements that have the scope attribute.
  22676. For example, given a scope name of x-foo, a rule like this:
  22677. div {
  22678. font-weight: bold;
  22679. }
  22680. becomes:
  22681. div[x-foo] {
  22682. font-weight: bold;
  22683. }
  22684. Note that elements that are dynamically added to a scope must have the scope
  22685. selector added to them manually.
  22686. * upper/lower bound encapsulation: Styles which are defined outside a
  22687. shadowRoot should not cross the ShadowDOM boundary and should not apply
  22688. inside a shadowRoot.
  22689. This styling behavior is not emulated. Some possible ways to do this that
  22690. were rejected due to complexity and/or performance concerns include: (1) reset
  22691. every possible property for every possible selector for a given scope name;
  22692. (2) re-implement css in javascript.
  22693. As an alternative, users should make sure to use selectors
  22694. specific to the scope in which they are working.
  22695. * ::distributed: This behavior is not emulated. It's often not necessary
  22696. to style the contents of a specific insertion point and instead, descendants
  22697. of the host element can be styled selectively. Users can also create an
  22698. extra node around an insertion point and style that node's contents
  22699. via descendent selectors. For example, with a shadowRoot like this:
  22700. <style>
  22701. ::content(div) {
  22702. background: red;
  22703. }
  22704. </style>
  22705. <content></content>
  22706. could become:
  22707. <style>
  22708. / *@polyfill .content-container div * /
  22709. ::content(div) {
  22710. background: red;
  22711. }
  22712. </style>
  22713. <div class="content-container">
  22714. <content></content>
  22715. </div>
  22716. Note the use of @polyfill in the comment above a ShadowDOM specific style
  22717. declaration. This is a directive to the styling shim to use the selector
  22718. in comments in lieu of the next selector when running under polyfill.
  22719. */
  22720. var ShadowCss = /** @class */ (function () {
  22721. function ShadowCss() {
  22722. this.strictStyling = true;
  22723. }
  22724. /*
  22725. * Shim some cssText with the given selector. Returns cssText that can
  22726. * be included in the document via WebComponents.ShadowCSS.addCssToDocument(css).
  22727. *
  22728. * When strictStyling is true:
  22729. * - selector is the attribute added to all elements inside the host,
  22730. * - hostSelector is the attribute added to the host itself.
  22731. */
  22732. /**
  22733. * @param {?} cssText
  22734. * @param {?} selector
  22735. * @param {?=} hostSelector
  22736. * @return {?}
  22737. */
  22738. ShadowCss.prototype.shimCssText = /**
  22739. * @param {?} cssText
  22740. * @param {?} selector
  22741. * @param {?=} hostSelector
  22742. * @return {?}
  22743. */
  22744. function (cssText, selector, hostSelector) {
  22745. if (hostSelector === void 0) { hostSelector = ''; }
  22746. var /** @type {?} */ commentsWithHash = extractCommentsWithHash(cssText);
  22747. cssText = stripComments(cssText);
  22748. cssText = this._insertDirectives(cssText);
  22749. var /** @type {?} */ scopedCssText = this._scopeCssText(cssText, selector, hostSelector);
  22750. return [scopedCssText].concat(commentsWithHash).join('\n');
  22751. };
  22752. /**
  22753. * @param {?} cssText
  22754. * @return {?}
  22755. */
  22756. ShadowCss.prototype._insertDirectives = /**
  22757. * @param {?} cssText
  22758. * @return {?}
  22759. */
  22760. function (cssText) {
  22761. cssText = this._insertPolyfillDirectivesInCssText(cssText);
  22762. return this._insertPolyfillRulesInCssText(cssText);
  22763. };
  22764. /**
  22765. * @param {?} cssText
  22766. * @return {?}
  22767. */
  22768. ShadowCss.prototype._insertPolyfillDirectivesInCssText = /**
  22769. * @param {?} cssText
  22770. * @return {?}
  22771. */
  22772. function (cssText) {
  22773. // Difference with webcomponents.js: does not handle comments
  22774. return cssText.replace(_cssContentNextSelectorRe, function () {
  22775. var m = [];
  22776. for (var _i = 0; _i < arguments.length; _i++) {
  22777. m[_i] = arguments[_i];
  22778. }
  22779. return m[2] + '{';
  22780. });
  22781. };
  22782. /**
  22783. * @param {?} cssText
  22784. * @return {?}
  22785. */
  22786. ShadowCss.prototype._insertPolyfillRulesInCssText = /**
  22787. * @param {?} cssText
  22788. * @return {?}
  22789. */
  22790. function (cssText) {
  22791. // Difference with webcomponents.js: does not handle comments
  22792. return cssText.replace(_cssContentRuleRe, function () {
  22793. var m = [];
  22794. for (var _i = 0; _i < arguments.length; _i++) {
  22795. m[_i] = arguments[_i];
  22796. }
  22797. var /** @type {?} */ rule = m[0].replace(m[1], '').replace(m[2], '');
  22798. return m[4] + rule;
  22799. });
  22800. };
  22801. /**
  22802. * @param {?} cssText
  22803. * @param {?} scopeSelector
  22804. * @param {?} hostSelector
  22805. * @return {?}
  22806. */
  22807. ShadowCss.prototype._scopeCssText = /**
  22808. * @param {?} cssText
  22809. * @param {?} scopeSelector
  22810. * @param {?} hostSelector
  22811. * @return {?}
  22812. */
  22813. function (cssText, scopeSelector, hostSelector) {
  22814. var /** @type {?} */ unscopedRules = this._extractUnscopedRulesFromCssText(cssText);
  22815. // replace :host and :host-context -shadowcsshost and -shadowcsshost respectively
  22816. cssText = this._insertPolyfillHostInCssText(cssText);
  22817. cssText = this._convertColonHost(cssText);
  22818. cssText = this._convertColonHostContext(cssText);
  22819. cssText = this._convertShadowDOMSelectors(cssText);
  22820. if (scopeSelector) {
  22821. cssText = this._scopeSelectors(cssText, scopeSelector, hostSelector);
  22822. }
  22823. cssText = cssText + '\n' + unscopedRules;
  22824. return cssText.trim();
  22825. };
  22826. /**
  22827. * @param {?} cssText
  22828. * @return {?}
  22829. */
  22830. ShadowCss.prototype._extractUnscopedRulesFromCssText = /**
  22831. * @param {?} cssText
  22832. * @return {?}
  22833. */
  22834. function (cssText) {
  22835. // Difference with webcomponents.js: does not handle comments
  22836. var /** @type {?} */ r = '';
  22837. var /** @type {?} */ m;
  22838. _cssContentUnscopedRuleRe.lastIndex = 0;
  22839. while ((m = _cssContentUnscopedRuleRe.exec(cssText)) !== null) {
  22840. var /** @type {?} */ rule = m[0].replace(m[2], '').replace(m[1], m[4]);
  22841. r += rule + '\n\n';
  22842. }
  22843. return r;
  22844. };
  22845. /**
  22846. * @param {?} cssText
  22847. * @return {?}
  22848. */
  22849. ShadowCss.prototype._convertColonHost = /**
  22850. * @param {?} cssText
  22851. * @return {?}
  22852. */
  22853. function (cssText) {
  22854. return this._convertColonRule(cssText, _cssColonHostRe, this._colonHostPartReplacer);
  22855. };
  22856. /**
  22857. * @param {?} cssText
  22858. * @return {?}
  22859. */
  22860. ShadowCss.prototype._convertColonHostContext = /**
  22861. * @param {?} cssText
  22862. * @return {?}
  22863. */
  22864. function (cssText) {
  22865. return this._convertColonRule(cssText, _cssColonHostContextRe, this._colonHostContextPartReplacer);
  22866. };
  22867. /**
  22868. * @param {?} cssText
  22869. * @param {?} regExp
  22870. * @param {?} partReplacer
  22871. * @return {?}
  22872. */
  22873. ShadowCss.prototype._convertColonRule = /**
  22874. * @param {?} cssText
  22875. * @param {?} regExp
  22876. * @param {?} partReplacer
  22877. * @return {?}
  22878. */
  22879. function (cssText, regExp, partReplacer) {
  22880. // m[1] = :host(-context), m[2] = contents of (), m[3] rest of rule
  22881. return cssText.replace(regExp, function () {
  22882. var m = [];
  22883. for (var _i = 0; _i < arguments.length; _i++) {
  22884. m[_i] = arguments[_i];
  22885. }
  22886. if (m[2]) {
  22887. var /** @type {?} */ parts = m[2].split(',');
  22888. var /** @type {?} */ r = [];
  22889. for (var /** @type {?} */ i = 0; i < parts.length; i++) {
  22890. var /** @type {?} */ p = parts[i].trim();
  22891. if (!p)
  22892. break;
  22893. r.push(partReplacer(_polyfillHostNoCombinator, p, m[3]));
  22894. }
  22895. return r.join(',');
  22896. }
  22897. else {
  22898. return _polyfillHostNoCombinator + m[3];
  22899. }
  22900. });
  22901. };
  22902. /**
  22903. * @param {?} host
  22904. * @param {?} part
  22905. * @param {?} suffix
  22906. * @return {?}
  22907. */
  22908. ShadowCss.prototype._colonHostContextPartReplacer = /**
  22909. * @param {?} host
  22910. * @param {?} part
  22911. * @param {?} suffix
  22912. * @return {?}
  22913. */
  22914. function (host, part, suffix) {
  22915. if (part.indexOf(_polyfillHost) > -1) {
  22916. return this._colonHostPartReplacer(host, part, suffix);
  22917. }
  22918. else {
  22919. return host + part + suffix + ', ' + part + ' ' + host + suffix;
  22920. }
  22921. };
  22922. /**
  22923. * @param {?} host
  22924. * @param {?} part
  22925. * @param {?} suffix
  22926. * @return {?}
  22927. */
  22928. ShadowCss.prototype._colonHostPartReplacer = /**
  22929. * @param {?} host
  22930. * @param {?} part
  22931. * @param {?} suffix
  22932. * @return {?}
  22933. */
  22934. function (host, part, suffix) {
  22935. return host + part.replace(_polyfillHost, '') + suffix;
  22936. };
  22937. /**
  22938. * @param {?} cssText
  22939. * @return {?}
  22940. */
  22941. ShadowCss.prototype._convertShadowDOMSelectors = /**
  22942. * @param {?} cssText
  22943. * @return {?}
  22944. */
  22945. function (cssText) {
  22946. return _shadowDOMSelectorsRe.reduce(function (result, pattern) { return result.replace(pattern, ' '); }, cssText);
  22947. };
  22948. /**
  22949. * @param {?} cssText
  22950. * @param {?} scopeSelector
  22951. * @param {?} hostSelector
  22952. * @return {?}
  22953. */
  22954. ShadowCss.prototype._scopeSelectors = /**
  22955. * @param {?} cssText
  22956. * @param {?} scopeSelector
  22957. * @param {?} hostSelector
  22958. * @return {?}
  22959. */
  22960. function (cssText, scopeSelector, hostSelector) {
  22961. var _this = this;
  22962. return processRules(cssText, function (rule) {
  22963. var /** @type {?} */ selector = rule.selector;
  22964. var /** @type {?} */ content = rule.content;
  22965. if (rule.selector[0] != '@') {
  22966. selector =
  22967. _this._scopeSelector(rule.selector, scopeSelector, hostSelector, _this.strictStyling);
  22968. }
  22969. else if (rule.selector.startsWith('@media') || rule.selector.startsWith('@supports') ||
  22970. rule.selector.startsWith('@page') || rule.selector.startsWith('@document')) {
  22971. content = _this._scopeSelectors(rule.content, scopeSelector, hostSelector);
  22972. }
  22973. return new CssRule(selector, content);
  22974. });
  22975. };
  22976. /**
  22977. * @param {?} selector
  22978. * @param {?} scopeSelector
  22979. * @param {?} hostSelector
  22980. * @param {?} strict
  22981. * @return {?}
  22982. */
  22983. ShadowCss.prototype._scopeSelector = /**
  22984. * @param {?} selector
  22985. * @param {?} scopeSelector
  22986. * @param {?} hostSelector
  22987. * @param {?} strict
  22988. * @return {?}
  22989. */
  22990. function (selector, scopeSelector, hostSelector, strict) {
  22991. var _this = this;
  22992. return selector.split(',')
  22993. .map(function (part) { return part.trim().split(_shadowDeepSelectors); })
  22994. .map(function (deepParts) {
  22995. var shallowPart = deepParts[0], otherParts = deepParts.slice(1);
  22996. var /** @type {?} */ applyScope = function (shallowPart) {
  22997. if (_this._selectorNeedsScoping(shallowPart, scopeSelector)) {
  22998. return strict ?
  22999. _this._applyStrictSelectorScope(shallowPart, scopeSelector, hostSelector) :
  23000. _this._applySelectorScope(shallowPart, scopeSelector, hostSelector);
  23001. }
  23002. else {
  23003. return shallowPart;
  23004. }
  23005. };
  23006. return [applyScope(shallowPart)].concat(otherParts).join(' ');
  23007. })
  23008. .join(', ');
  23009. };
  23010. /**
  23011. * @param {?} selector
  23012. * @param {?} scopeSelector
  23013. * @return {?}
  23014. */
  23015. ShadowCss.prototype._selectorNeedsScoping = /**
  23016. * @param {?} selector
  23017. * @param {?} scopeSelector
  23018. * @return {?}
  23019. */
  23020. function (selector, scopeSelector) {
  23021. var /** @type {?} */ re = this._makeScopeMatcher(scopeSelector);
  23022. return !re.test(selector);
  23023. };
  23024. /**
  23025. * @param {?} scopeSelector
  23026. * @return {?}
  23027. */
  23028. ShadowCss.prototype._makeScopeMatcher = /**
  23029. * @param {?} scopeSelector
  23030. * @return {?}
  23031. */
  23032. function (scopeSelector) {
  23033. var /** @type {?} */ lre = /\[/g;
  23034. var /** @type {?} */ rre = /\]/g;
  23035. scopeSelector = scopeSelector.replace(lre, '\\[').replace(rre, '\\]');
  23036. return new RegExp('^(' + scopeSelector + ')' + _selectorReSuffix, 'm');
  23037. };
  23038. /**
  23039. * @param {?} selector
  23040. * @param {?} scopeSelector
  23041. * @param {?} hostSelector
  23042. * @return {?}
  23043. */
  23044. ShadowCss.prototype._applySelectorScope = /**
  23045. * @param {?} selector
  23046. * @param {?} scopeSelector
  23047. * @param {?} hostSelector
  23048. * @return {?}
  23049. */
  23050. function (selector, scopeSelector, hostSelector) {
  23051. // Difference from webcomponents.js: scopeSelector could not be an array
  23052. return this._applySimpleSelectorScope(selector, scopeSelector, hostSelector);
  23053. };
  23054. /**
  23055. * @param {?} selector
  23056. * @param {?} scopeSelector
  23057. * @param {?} hostSelector
  23058. * @return {?}
  23059. */
  23060. ShadowCss.prototype._applySimpleSelectorScope = /**
  23061. * @param {?} selector
  23062. * @param {?} scopeSelector
  23063. * @param {?} hostSelector
  23064. * @return {?}
  23065. */
  23066. function (selector, scopeSelector, hostSelector) {
  23067. // In Android browser, the lastIndex is not reset when the regex is used in String.replace()
  23068. _polyfillHostRe.lastIndex = 0;
  23069. if (_polyfillHostRe.test(selector)) {
  23070. var /** @type {?} */ replaceBy_1 = this.strictStyling ? "[" + hostSelector + "]" : scopeSelector;
  23071. return selector
  23072. .replace(_polyfillHostNoCombinatorRe, function (hnc, selector) {
  23073. return selector.replace(/([^:]*)(:*)(.*)/, function (_, before, colon, after) {
  23074. return before + replaceBy_1 + colon + after;
  23075. });
  23076. })
  23077. .replace(_polyfillHostRe, replaceBy_1 + ' ');
  23078. }
  23079. return scopeSelector + ' ' + selector;
  23080. };
  23081. /**
  23082. * @param {?} selector
  23083. * @param {?} scopeSelector
  23084. * @param {?} hostSelector
  23085. * @return {?}
  23086. */
  23087. ShadowCss.prototype._applyStrictSelectorScope = /**
  23088. * @param {?} selector
  23089. * @param {?} scopeSelector
  23090. * @param {?} hostSelector
  23091. * @return {?}
  23092. */
  23093. function (selector, scopeSelector, hostSelector) {
  23094. var _this = this;
  23095. var /** @type {?} */ isRe = /\[is=([^\]]*)\]/g;
  23096. scopeSelector = scopeSelector.replace(isRe, function (_) {
  23097. var parts = [];
  23098. for (var _i = 1; _i < arguments.length; _i++) {
  23099. parts[_i - 1] = arguments[_i];
  23100. }
  23101. return parts[0];
  23102. });
  23103. var /** @type {?} */ attrName = '[' + scopeSelector + ']';
  23104. var /** @type {?} */ _scopeSelectorPart = function (p) {
  23105. var /** @type {?} */ scopedP = p.trim();
  23106. if (!scopedP) {
  23107. return '';
  23108. }
  23109. if (p.indexOf(_polyfillHostNoCombinator) > -1) {
  23110. scopedP = _this._applySimpleSelectorScope(p, scopeSelector, hostSelector);
  23111. }
  23112. else {
  23113. // remove :host since it should be unnecessary
  23114. var /** @type {?} */ t = p.replace(_polyfillHostRe, '');
  23115. if (t.length > 0) {
  23116. var /** @type {?} */ matches = t.match(/([^:]*)(:*)(.*)/);
  23117. if (matches) {
  23118. scopedP = matches[1] + attrName + matches[2] + matches[3];
  23119. }
  23120. }
  23121. }
  23122. return scopedP;
  23123. };
  23124. var /** @type {?} */ safeContent = new SafeSelector(selector);
  23125. selector = safeContent.content();
  23126. var /** @type {?} */ scopedSelector = '';
  23127. var /** @type {?} */ startIndex = 0;
  23128. var /** @type {?} */ res;
  23129. var /** @type {?} */ sep = /( |>|\+|~(?!=))\s*/g;
  23130. // If a selector appears before :host it should not be shimmed as it
  23131. // matches on ancestor elements and not on elements in the host's shadow
  23132. // `:host-context(div)` is transformed to
  23133. // `-shadowcsshost-no-combinatordiv, div -shadowcsshost-no-combinator`
  23134. // the `div` is not part of the component in the 2nd selectors and should not be scoped.
  23135. // Historically `component-tag:host` was matching the component so we also want to preserve
  23136. // this behavior to avoid breaking legacy apps (it should not match).
  23137. // The behavior should be:
  23138. // - `tag:host` -> `tag[h]` (this is to avoid breaking legacy apps, should not match anything)
  23139. // - `tag :host` -> `tag [h]` (`tag` is not scoped because it's considered part of a
  23140. // `:host-context(tag)`)
  23141. var /** @type {?} */ hasHost = selector.indexOf(_polyfillHostNoCombinator) > -1;
  23142. // Only scope parts after the first `-shadowcsshost-no-combinator` when it is present
  23143. var /** @type {?} */ shouldScope = !hasHost;
  23144. while ((res = sep.exec(selector)) !== null) {
  23145. var /** @type {?} */ separator = res[1];
  23146. var /** @type {?} */ part_1 = selector.slice(startIndex, res.index).trim();
  23147. shouldScope = shouldScope || part_1.indexOf(_polyfillHostNoCombinator) > -1;
  23148. var /** @type {?} */ scopedPart = shouldScope ? _scopeSelectorPart(part_1) : part_1;
  23149. scopedSelector += scopedPart + " " + separator + " ";
  23150. startIndex = sep.lastIndex;
  23151. }
  23152. var /** @type {?} */ part = selector.substring(startIndex);
  23153. shouldScope = shouldScope || part.indexOf(_polyfillHostNoCombinator) > -1;
  23154. scopedSelector += shouldScope ? _scopeSelectorPart(part) : part;
  23155. // replace the placeholders with their original values
  23156. return safeContent.restore(scopedSelector);
  23157. };
  23158. /**
  23159. * @param {?} selector
  23160. * @return {?}
  23161. */
  23162. ShadowCss.prototype._insertPolyfillHostInCssText = /**
  23163. * @param {?} selector
  23164. * @return {?}
  23165. */
  23166. function (selector) {
  23167. return selector.replace(_colonHostContextRe, _polyfillHostContext)
  23168. .replace(_colonHostRe, _polyfillHost);
  23169. };
  23170. return ShadowCss;
  23171. }());
  23172. var SafeSelector = /** @class */ (function () {
  23173. function SafeSelector(selector) {
  23174. var _this = this;
  23175. this.placeholders = [];
  23176. this.index = 0;
  23177. // Replaces attribute selectors with placeholders.
  23178. // The WS in [attr="va lue"] would otherwise be interpreted as a selector separator.
  23179. selector = selector.replace(/(\[[^\]]*\])/g, function (_, keep) {
  23180. var /** @type {?} */ replaceBy = "__ph-" + _this.index + "__";
  23181. _this.placeholders.push(keep);
  23182. _this.index++;
  23183. return replaceBy;
  23184. });
  23185. // Replaces the expression in `:nth-child(2n + 1)` with a placeholder.
  23186. // WS and "+" would otherwise be interpreted as selector separators.
  23187. this._content = selector.replace(/(:nth-[-\w]+)(\([^)]+\))/g, function (_, pseudo, exp) {
  23188. var /** @type {?} */ replaceBy = "__ph-" + _this.index + "__";
  23189. _this.placeholders.push(exp);
  23190. _this.index++;
  23191. return pseudo + replaceBy;
  23192. });
  23193. }
  23194. /**
  23195. * @param {?} content
  23196. * @return {?}
  23197. */
  23198. SafeSelector.prototype.restore = /**
  23199. * @param {?} content
  23200. * @return {?}
  23201. */
  23202. function (content) {
  23203. var _this = this;
  23204. return content.replace(/__ph-(\d+)__/g, function (ph, index) { return _this.placeholders[+index]; });
  23205. };
  23206. /**
  23207. * @return {?}
  23208. */
  23209. SafeSelector.prototype.content = /**
  23210. * @return {?}
  23211. */
  23212. function () { return this._content; };
  23213. return SafeSelector;
  23214. }());
  23215. var _cssContentNextSelectorRe = /polyfill-next-selector[^}]*content:[\s]*?(['"])(.*?)\1[;\s]*}([^{]*?){/gim;
  23216. var _cssContentRuleRe = /(polyfill-rule)[^}]*(content:[\s]*(['"])(.*?)\3)[;\s]*[^}]*}/gim;
  23217. var _cssContentUnscopedRuleRe = /(polyfill-unscoped-rule)[^}]*(content:[\s]*(['"])(.*?)\3)[;\s]*[^}]*}/gim;
  23218. var _polyfillHost = '-shadowcsshost';
  23219. // note: :host-context pre-processed to -shadowcsshostcontext.
  23220. var _polyfillHostContext = '-shadowcsscontext';
  23221. var _parenSuffix = ')(?:\\((' +
  23222. '(?:\\([^)(]*\\)|[^)(]*)+?' +
  23223. ')\\))?([^,{]*)';
  23224. var _cssColonHostRe = new RegExp('(' + _polyfillHost + _parenSuffix, 'gim');
  23225. var _cssColonHostContextRe = new RegExp('(' + _polyfillHostContext + _parenSuffix, 'gim');
  23226. var _polyfillHostNoCombinator = _polyfillHost + '-no-combinator';
  23227. var _polyfillHostNoCombinatorRe = /-shadowcsshost-no-combinator([^\s]*)/;
  23228. var _shadowDOMSelectorsRe = [
  23229. /::shadow/g,
  23230. /::content/g,
  23231. /\/shadow-deep\//g,
  23232. /\/shadow\//g,
  23233. ];
  23234. // The deep combinator is deprecated in the CSS spec
  23235. // Support for `>>>`, `deep`, `::ng-deep` is then also deprecated and will be removed in the future.
  23236. // see https://github.com/angular/angular/pull/17677
  23237. var _shadowDeepSelectors = /(?:>>>)|(?:\/deep\/)|(?:::ng-deep)/g;
  23238. var _selectorReSuffix = '([>\\s~+\[.,{:][\\s\\S]*)?$';
  23239. var _polyfillHostRe = /-shadowcsshost/gim;
  23240. var _colonHostRe = /:host/gim;
  23241. var _colonHostContextRe = /:host-context/gim;
  23242. var _commentRe = /\/\*\s*[\s\S]*?\*\//g;
  23243. /**
  23244. * @param {?} input
  23245. * @return {?}
  23246. */
  23247. function stripComments(input) {
  23248. return input.replace(_commentRe, '');
  23249. }
  23250. var _commentWithHashRe = /\/\*\s*#\s*source(Mapping)?URL=[\s\S]+?\*\//g;
  23251. /**
  23252. * @param {?} input
  23253. * @return {?}
  23254. */
  23255. function extractCommentsWithHash(input) {
  23256. return input.match(_commentWithHashRe) || [];
  23257. }
  23258. var _ruleRe = /(\s*)([^;\{\}]+?)(\s*)((?:{%BLOCK%}?\s*;?)|(?:\s*;))/g;
  23259. var _curlyRe = /([{}])/g;
  23260. var OPEN_CURLY = '{';
  23261. var CLOSE_CURLY = '}';
  23262. var BLOCK_PLACEHOLDER = '%BLOCK%';
  23263. var CssRule = /** @class */ (function () {
  23264. function CssRule(selector, content) {
  23265. this.selector = selector;
  23266. this.content = content;
  23267. }
  23268. return CssRule;
  23269. }());
  23270. /**
  23271. * @param {?} input
  23272. * @param {?} ruleCallback
  23273. * @return {?}
  23274. */
  23275. function processRules(input, ruleCallback) {
  23276. var /** @type {?} */ inputWithEscapedBlocks = escapeBlocks(input);
  23277. var /** @type {?} */ nextBlockIndex = 0;
  23278. return inputWithEscapedBlocks.escapedString.replace(_ruleRe, function () {
  23279. var m = [];
  23280. for (var _i = 0; _i < arguments.length; _i++) {
  23281. m[_i] = arguments[_i];
  23282. }
  23283. var /** @type {?} */ selector = m[2];
  23284. var /** @type {?} */ content = '';
  23285. var /** @type {?} */ suffix = m[4];
  23286. var /** @type {?} */ contentPrefix = '';
  23287. if (suffix && suffix.startsWith('{' + BLOCK_PLACEHOLDER)) {
  23288. content = inputWithEscapedBlocks.blocks[nextBlockIndex++];
  23289. suffix = suffix.substring(BLOCK_PLACEHOLDER.length + 1);
  23290. contentPrefix = '{';
  23291. }
  23292. var /** @type {?} */ rule = ruleCallback(new CssRule(selector, content));
  23293. return "" + m[1] + rule.selector + m[3] + contentPrefix + rule.content + suffix;
  23294. });
  23295. }
  23296. var StringWithEscapedBlocks = /** @class */ (function () {
  23297. function StringWithEscapedBlocks(escapedString, blocks) {
  23298. this.escapedString = escapedString;
  23299. this.blocks = blocks;
  23300. }
  23301. return StringWithEscapedBlocks;
  23302. }());
  23303. /**
  23304. * @param {?} input
  23305. * @return {?}
  23306. */
  23307. function escapeBlocks(input) {
  23308. var /** @type {?} */ inputParts = input.split(_curlyRe);
  23309. var /** @type {?} */ resultParts = [];
  23310. var /** @type {?} */ escapedBlocks = [];
  23311. var /** @type {?} */ bracketCount = 0;
  23312. var /** @type {?} */ currentBlockParts = [];
  23313. for (var /** @type {?} */ partIndex = 0; partIndex < inputParts.length; partIndex++) {
  23314. var /** @type {?} */ part = inputParts[partIndex];
  23315. if (part == CLOSE_CURLY) {
  23316. bracketCount--;
  23317. }
  23318. if (bracketCount > 0) {
  23319. currentBlockParts.push(part);
  23320. }
  23321. else {
  23322. if (currentBlockParts.length > 0) {
  23323. escapedBlocks.push(currentBlockParts.join(''));
  23324. resultParts.push(BLOCK_PLACEHOLDER);
  23325. currentBlockParts = [];
  23326. }
  23327. resultParts.push(part);
  23328. }
  23329. if (part == OPEN_CURLY) {
  23330. bracketCount++;
  23331. }
  23332. }
  23333. if (currentBlockParts.length > 0) {
  23334. escapedBlocks.push(currentBlockParts.join(''));
  23335. resultParts.push(BLOCK_PLACEHOLDER);
  23336. }
  23337. return new StringWithEscapedBlocks(resultParts.join(''), escapedBlocks);
  23338. }
  23339. /**
  23340. * @fileoverview added by tsickle
  23341. * @suppress {checkTypes} checked by tsc
  23342. */
  23343. /**
  23344. * @license
  23345. * Copyright Google Inc. All Rights Reserved.
  23346. *
  23347. * Use of this source code is governed by an MIT-style license that can be
  23348. * found in the LICENSE file at https://angular.io/license
  23349. */
  23350. var COMPONENT_VARIABLE = '%COMP%';
  23351. var HOST_ATTR = "_nghost-" + COMPONENT_VARIABLE;
  23352. var CONTENT_ATTR = "_ngcontent-" + COMPONENT_VARIABLE;
  23353. var StylesCompileDependency = /** @class */ (function () {
  23354. function StylesCompileDependency(name, moduleUrl, setValue) {
  23355. this.name = name;
  23356. this.moduleUrl = moduleUrl;
  23357. this.setValue = setValue;
  23358. }
  23359. return StylesCompileDependency;
  23360. }());
  23361. var CompiledStylesheet = /** @class */ (function () {
  23362. function CompiledStylesheet(outputCtx, stylesVar, dependencies, isShimmed, meta) {
  23363. this.outputCtx = outputCtx;
  23364. this.stylesVar = stylesVar;
  23365. this.dependencies = dependencies;
  23366. this.isShimmed = isShimmed;
  23367. this.meta = meta;
  23368. }
  23369. return CompiledStylesheet;
  23370. }());
  23371. var StyleCompiler = /** @class */ (function () {
  23372. function StyleCompiler(_urlResolver) {
  23373. this._urlResolver = _urlResolver;
  23374. this._shadowCss = new ShadowCss();
  23375. }
  23376. /**
  23377. * @param {?} outputCtx
  23378. * @param {?} comp
  23379. * @return {?}
  23380. */
  23381. StyleCompiler.prototype.compileComponent = /**
  23382. * @param {?} outputCtx
  23383. * @param {?} comp
  23384. * @return {?}
  23385. */
  23386. function (outputCtx, comp) {
  23387. var /** @type {?} */ template = /** @type {?} */ ((comp.template));
  23388. return this._compileStyles(outputCtx, comp, new CompileStylesheetMetadata({
  23389. styles: template.styles,
  23390. styleUrls: template.styleUrls,
  23391. moduleUrl: identifierModuleUrl(comp.type)
  23392. }), this.needsStyleShim(comp), true);
  23393. };
  23394. /**
  23395. * @param {?} outputCtx
  23396. * @param {?} comp
  23397. * @param {?} stylesheet
  23398. * @param {?=} shim
  23399. * @return {?}
  23400. */
  23401. StyleCompiler.prototype.compileStyles = /**
  23402. * @param {?} outputCtx
  23403. * @param {?} comp
  23404. * @param {?} stylesheet
  23405. * @param {?=} shim
  23406. * @return {?}
  23407. */
  23408. function (outputCtx, comp, stylesheet, shim) {
  23409. if (shim === void 0) { shim = this.needsStyleShim(comp); }
  23410. return this._compileStyles(outputCtx, comp, stylesheet, shim, false);
  23411. };
  23412. /**
  23413. * @param {?} comp
  23414. * @return {?}
  23415. */
  23416. StyleCompiler.prototype.needsStyleShim = /**
  23417. * @param {?} comp
  23418. * @return {?}
  23419. */
  23420. function (comp) {
  23421. return /** @type {?} */ ((comp.template)).encapsulation === ViewEncapsulation.Emulated;
  23422. };
  23423. /**
  23424. * @param {?} outputCtx
  23425. * @param {?} comp
  23426. * @param {?} stylesheet
  23427. * @param {?} shim
  23428. * @param {?} isComponentStylesheet
  23429. * @return {?}
  23430. */
  23431. StyleCompiler.prototype._compileStyles = /**
  23432. * @param {?} outputCtx
  23433. * @param {?} comp
  23434. * @param {?} stylesheet
  23435. * @param {?} shim
  23436. * @param {?} isComponentStylesheet
  23437. * @return {?}
  23438. */
  23439. function (outputCtx, comp, stylesheet, shim, isComponentStylesheet) {
  23440. var _this = this;
  23441. var /** @type {?} */ styleExpressions = stylesheet.styles.map(function (plainStyle) { return literal(_this._shimIfNeeded(plainStyle, shim)); });
  23442. var /** @type {?} */ dependencies = [];
  23443. stylesheet.styleUrls.forEach(function (styleUrl) {
  23444. var /** @type {?} */ exprIndex = styleExpressions.length;
  23445. // Note: This placeholder will be filled later.
  23446. styleExpressions.push(/** @type {?} */ ((null)));
  23447. dependencies.push(new StylesCompileDependency(getStylesVarName(null), styleUrl, function (value) { return styleExpressions[exprIndex] = outputCtx.importExpr(value); }));
  23448. });
  23449. // styles variable contains plain strings and arrays of other styles arrays (recursive),
  23450. // so we set its type to dynamic.
  23451. var /** @type {?} */ stylesVar = getStylesVarName(isComponentStylesheet ? comp : null);
  23452. var /** @type {?} */ stmt = variable(stylesVar)
  23453. .set(literalArr(styleExpressions, new ArrayType(DYNAMIC_TYPE, [TypeModifier.Const])))
  23454. .toDeclStmt(null, isComponentStylesheet ? [StmtModifier.Final] : [
  23455. StmtModifier.Final, StmtModifier.Exported
  23456. ]);
  23457. outputCtx.statements.push(stmt);
  23458. return new CompiledStylesheet(outputCtx, stylesVar, dependencies, shim, stylesheet);
  23459. };
  23460. /**
  23461. * @param {?} style
  23462. * @param {?} shim
  23463. * @return {?}
  23464. */
  23465. StyleCompiler.prototype._shimIfNeeded = /**
  23466. * @param {?} style
  23467. * @param {?} shim
  23468. * @return {?}
  23469. */
  23470. function (style, shim) {
  23471. return shim ? this._shadowCss.shimCssText(style, CONTENT_ATTR, HOST_ATTR) : style;
  23472. };
  23473. return StyleCompiler;
  23474. }());
  23475. /**
  23476. * @param {?} component
  23477. * @return {?}
  23478. */
  23479. function getStylesVarName(component) {
  23480. var /** @type {?} */ result = "styles";
  23481. if (component) {
  23482. result += "_" + identifierName(component.type);
  23483. }
  23484. return result;
  23485. }
  23486. /**
  23487. * @fileoverview added by tsickle
  23488. * @suppress {checkTypes} checked by tsc
  23489. */
  23490. /**
  23491. * @license
  23492. * Copyright Google Inc. All Rights Reserved.
  23493. *
  23494. * Use of this source code is governed by an MIT-style license that can be
  23495. * found in the LICENSE file at https://angular.io/license
  23496. */
  23497. var PRESERVE_WS_ATTR_NAME = 'ngPreserveWhitespaces';
  23498. var SKIP_WS_TRIM_TAGS = new Set(['pre', 'template', 'textarea', 'script', 'style']);
  23499. // Equivalent to \s with \u00a0 (non-breaking space) excluded.
  23500. // Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
  23501. var WS_CHARS = ' \f\n\r\t\v\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff';
  23502. var NO_WS_REGEXP = new RegExp("[^" + WS_CHARS + "]");
  23503. var WS_REPLACE_REGEXP = new RegExp("[" + WS_CHARS + "]{2,}", 'g');
  23504. /**
  23505. * @param {?} attrs
  23506. * @return {?}
  23507. */
  23508. function hasPreserveWhitespacesAttr(attrs) {
  23509. return attrs.some(function (attr) { return attr.name === PRESERVE_WS_ATTR_NAME; });
  23510. }
  23511. /**
  23512. * Angular Dart introduced &ngsp; as a placeholder for non-removable space, see:
  23513. * https://github.com/dart-lang/angular/blob/0bb611387d29d65b5af7f9d2515ab571fd3fbee4/_tests/test/compiler/preserve_whitespace_test.dart#L25-L32
  23514. * In Angular Dart &ngsp; is converted to the 0xE500 PUA (Private Use Areas) unicode character
  23515. * and later on replaced by a space. We are re-implementing the same idea here.
  23516. * @param {?} value
  23517. * @return {?}
  23518. */
  23519. function replaceNgsp(value) {
  23520. // lexer is replacing the &ngsp; pseudo-entity with NGSP_UNICODE
  23521. return value.replace(new RegExp(NGSP_UNICODE, 'g'), ' ');
  23522. }
  23523. /**
  23524. * This visitor can walk HTML parse tree and remove / trim text nodes using the following rules:
  23525. * - consider spaces, tabs and new lines as whitespace characters;
  23526. * - drop text nodes consisting of whitespace characters only;
  23527. * - for all other text nodes replace consecutive whitespace characters with one space;
  23528. * - convert &ngsp; pseudo-entity to a single space;
  23529. *
  23530. * Removal and trimming of whitespaces have positive performance impact (less code to generate
  23531. * while compiling templates, faster view creation). At the same time it can be "destructive"
  23532. * in some cases (whitespaces can influence layout). Because of the potential of breaking layout
  23533. * this visitor is not activated by default in Angular 5 and people need to explicitly opt-in for
  23534. * whitespace removal. The default option for whitespace removal will be revisited in Angular 6
  23535. * and might be changed to "on" by default.
  23536. */
  23537. var WhitespaceVisitor = /** @class */ (function () {
  23538. function WhitespaceVisitor() {
  23539. }
  23540. /**
  23541. * @param {?} element
  23542. * @param {?} context
  23543. * @return {?}
  23544. */
  23545. WhitespaceVisitor.prototype.visitElement = /**
  23546. * @param {?} element
  23547. * @param {?} context
  23548. * @return {?}
  23549. */
  23550. function (element, context) {
  23551. if (SKIP_WS_TRIM_TAGS.has(element.name) || hasPreserveWhitespacesAttr(element.attrs)) {
  23552. // don't descent into elements where we need to preserve whitespaces
  23553. // but still visit all attributes to eliminate one used as a market to preserve WS
  23554. return new Element(element.name, visitAll(this, element.attrs), element.children, element.sourceSpan, element.startSourceSpan, element.endSourceSpan);
  23555. }
  23556. return new Element(element.name, element.attrs, visitAll(this, element.children), element.sourceSpan, element.startSourceSpan, element.endSourceSpan);
  23557. };
  23558. /**
  23559. * @param {?} attribute
  23560. * @param {?} context
  23561. * @return {?}
  23562. */
  23563. WhitespaceVisitor.prototype.visitAttribute = /**
  23564. * @param {?} attribute
  23565. * @param {?} context
  23566. * @return {?}
  23567. */
  23568. function (attribute, context) {
  23569. return attribute.name !== PRESERVE_WS_ATTR_NAME ? attribute : null;
  23570. };
  23571. /**
  23572. * @param {?} text
  23573. * @param {?} context
  23574. * @return {?}
  23575. */
  23576. WhitespaceVisitor.prototype.visitText = /**
  23577. * @param {?} text
  23578. * @param {?} context
  23579. * @return {?}
  23580. */
  23581. function (text, context) {
  23582. var /** @type {?} */ isNotBlank = text.value.match(NO_WS_REGEXP);
  23583. if (isNotBlank) {
  23584. return new Text(replaceNgsp(text.value).replace(WS_REPLACE_REGEXP, ' '), text.sourceSpan);
  23585. }
  23586. return null;
  23587. };
  23588. /**
  23589. * @param {?} comment
  23590. * @param {?} context
  23591. * @return {?}
  23592. */
  23593. WhitespaceVisitor.prototype.visitComment = /**
  23594. * @param {?} comment
  23595. * @param {?} context
  23596. * @return {?}
  23597. */
  23598. function (comment, context) { return comment; };
  23599. /**
  23600. * @param {?} expansion
  23601. * @param {?} context
  23602. * @return {?}
  23603. */
  23604. WhitespaceVisitor.prototype.visitExpansion = /**
  23605. * @param {?} expansion
  23606. * @param {?} context
  23607. * @return {?}
  23608. */
  23609. function (expansion, context) { return expansion; };
  23610. /**
  23611. * @param {?} expansionCase
  23612. * @param {?} context
  23613. * @return {?}
  23614. */
  23615. WhitespaceVisitor.prototype.visitExpansionCase = /**
  23616. * @param {?} expansionCase
  23617. * @param {?} context
  23618. * @return {?}
  23619. */
  23620. function (expansionCase, context) { return expansionCase; };
  23621. return WhitespaceVisitor;
  23622. }());
  23623. /**
  23624. * @param {?} htmlAstWithErrors
  23625. * @return {?}
  23626. */
  23627. function removeWhitespaces(htmlAstWithErrors) {
  23628. return new ParseTreeResult(visitAll(new WhitespaceVisitor(), htmlAstWithErrors.rootNodes), htmlAstWithErrors.errors);
  23629. }
  23630. /**
  23631. * @fileoverview added by tsickle
  23632. * @suppress {checkTypes} checked by tsc
  23633. */
  23634. /**
  23635. * @license
  23636. * Copyright Google Inc. All Rights Reserved.
  23637. *
  23638. * Use of this source code is governed by an MIT-style license that can be
  23639. * found in the LICENSE file at https://angular.io/license
  23640. */
  23641. // http://cldr.unicode.org/index/cldr-spec/plural-rules
  23642. var PLURAL_CASES = ['zero', 'one', 'two', 'few', 'many', 'other'];
  23643. /**
  23644. * Expands special forms into elements.
  23645. *
  23646. * For example,
  23647. *
  23648. * ```
  23649. * { messages.length, plural,
  23650. * =0 {zero}
  23651. * =1 {one}
  23652. * other {more than one}
  23653. * }
  23654. * ```
  23655. *
  23656. * will be expanded into
  23657. *
  23658. * ```
  23659. * <ng-container [ngPlural]="messages.length">
  23660. * <ng-template ngPluralCase="=0">zero</ng-template>
  23661. * <ng-template ngPluralCase="=1">one</ng-template>
  23662. * <ng-template ngPluralCase="other">more than one</ng-template>
  23663. * </ng-container>
  23664. * ```
  23665. * @param {?} nodes
  23666. * @return {?}
  23667. */
  23668. function expandNodes(nodes) {
  23669. var /** @type {?} */ expander = new _Expander();
  23670. return new ExpansionResult(visitAll(expander, nodes), expander.isExpanded, expander.errors);
  23671. }
  23672. var ExpansionResult = /** @class */ (function () {
  23673. function ExpansionResult(nodes, expanded, errors) {
  23674. this.nodes = nodes;
  23675. this.expanded = expanded;
  23676. this.errors = errors;
  23677. }
  23678. return ExpansionResult;
  23679. }());
  23680. var ExpansionError = /** @class */ (function (_super) {
  23681. __extends(ExpansionError, _super);
  23682. function ExpansionError(span, errorMsg) {
  23683. return _super.call(this, span, errorMsg) || this;
  23684. }
  23685. return ExpansionError;
  23686. }(ParseError));
  23687. /**
  23688. * Expand expansion forms (plural, select) to directives
  23689. *
  23690. * \@internal
  23691. */
  23692. var _Expander = /** @class */ (function () {
  23693. function _Expander() {
  23694. this.isExpanded = false;
  23695. this.errors = [];
  23696. }
  23697. /**
  23698. * @param {?} element
  23699. * @param {?} context
  23700. * @return {?}
  23701. */
  23702. _Expander.prototype.visitElement = /**
  23703. * @param {?} element
  23704. * @param {?} context
  23705. * @return {?}
  23706. */
  23707. function (element, context) {
  23708. return new Element(element.name, element.attrs, visitAll(this, element.children), element.sourceSpan, element.startSourceSpan, element.endSourceSpan);
  23709. };
  23710. /**
  23711. * @param {?} attribute
  23712. * @param {?} context
  23713. * @return {?}
  23714. */
  23715. _Expander.prototype.visitAttribute = /**
  23716. * @param {?} attribute
  23717. * @param {?} context
  23718. * @return {?}
  23719. */
  23720. function (attribute, context) { return attribute; };
  23721. /**
  23722. * @param {?} text
  23723. * @param {?} context
  23724. * @return {?}
  23725. */
  23726. _Expander.prototype.visitText = /**
  23727. * @param {?} text
  23728. * @param {?} context
  23729. * @return {?}
  23730. */
  23731. function (text, context) { return text; };
  23732. /**
  23733. * @param {?} comment
  23734. * @param {?} context
  23735. * @return {?}
  23736. */
  23737. _Expander.prototype.visitComment = /**
  23738. * @param {?} comment
  23739. * @param {?} context
  23740. * @return {?}
  23741. */
  23742. function (comment, context) { return comment; };
  23743. /**
  23744. * @param {?} icu
  23745. * @param {?} context
  23746. * @return {?}
  23747. */
  23748. _Expander.prototype.visitExpansion = /**
  23749. * @param {?} icu
  23750. * @param {?} context
  23751. * @return {?}
  23752. */
  23753. function (icu, context) {
  23754. this.isExpanded = true;
  23755. return icu.type == 'plural' ? _expandPluralForm(icu, this.errors) :
  23756. _expandDefaultForm(icu, this.errors);
  23757. };
  23758. /**
  23759. * @param {?} icuCase
  23760. * @param {?} context
  23761. * @return {?}
  23762. */
  23763. _Expander.prototype.visitExpansionCase = /**
  23764. * @param {?} icuCase
  23765. * @param {?} context
  23766. * @return {?}
  23767. */
  23768. function (icuCase, context) {
  23769. throw new Error('Should not be reached');
  23770. };
  23771. return _Expander;
  23772. }());
  23773. /**
  23774. * @param {?} ast
  23775. * @param {?} errors
  23776. * @return {?}
  23777. */
  23778. function _expandPluralForm(ast, errors) {
  23779. var /** @type {?} */ children = ast.cases.map(function (c) {
  23780. if (PLURAL_CASES.indexOf(c.value) == -1 && !c.value.match(/^=\d+$/)) {
  23781. errors.push(new ExpansionError(c.valueSourceSpan, "Plural cases should be \"=<number>\" or one of " + PLURAL_CASES.join(", ")));
  23782. }
  23783. var /** @type {?} */ expansionResult = expandNodes(c.expression);
  23784. errors.push.apply(errors, expansionResult.errors);
  23785. return new Element("ng-template", [new Attribute$1('ngPluralCase', "" + c.value, c.valueSourceSpan)], expansionResult.nodes, c.sourceSpan, c.sourceSpan, c.sourceSpan);
  23786. });
  23787. var /** @type {?} */ switchAttr = new Attribute$1('[ngPlural]', ast.switchValue, ast.switchValueSourceSpan);
  23788. return new Element('ng-container', [switchAttr], children, ast.sourceSpan, ast.sourceSpan, ast.sourceSpan);
  23789. }
  23790. /**
  23791. * @param {?} ast
  23792. * @param {?} errors
  23793. * @return {?}
  23794. */
  23795. function _expandDefaultForm(ast, errors) {
  23796. var /** @type {?} */ children = ast.cases.map(function (c) {
  23797. var /** @type {?} */ expansionResult = expandNodes(c.expression);
  23798. errors.push.apply(errors, expansionResult.errors);
  23799. if (c.value === 'other') {
  23800. // other is the default case when no values match
  23801. return new Element("ng-template", [new Attribute$1('ngSwitchDefault', '', c.valueSourceSpan)], expansionResult.nodes, c.sourceSpan, c.sourceSpan, c.sourceSpan);
  23802. }
  23803. return new Element("ng-template", [new Attribute$1('ngSwitchCase', "" + c.value, c.valueSourceSpan)], expansionResult.nodes, c.sourceSpan, c.sourceSpan, c.sourceSpan);
  23804. });
  23805. var /** @type {?} */ switchAttr = new Attribute$1('[ngSwitch]', ast.switchValue, ast.switchValueSourceSpan);
  23806. return new Element('ng-container', [switchAttr], children, ast.sourceSpan, ast.sourceSpan, ast.sourceSpan);
  23807. }
  23808. /**
  23809. * @fileoverview added by tsickle
  23810. * @suppress {checkTypes} checked by tsc
  23811. */
  23812. /**
  23813. * @license
  23814. * Copyright Google Inc. All Rights Reserved.
  23815. *
  23816. * Use of this source code is governed by an MIT-style license that can be
  23817. * found in the LICENSE file at https://angular.io/license
  23818. */
  23819. var PROPERTY_PARTS_SEPARATOR = '.';
  23820. var ATTRIBUTE_PREFIX = 'attr';
  23821. var CLASS_PREFIX = 'class';
  23822. var STYLE_PREFIX = 'style';
  23823. var ANIMATE_PROP_PREFIX = 'animate-';
  23824. /** @enum {number} */
  23825. var BoundPropertyType = {
  23826. DEFAULT: 0,
  23827. LITERAL_ATTR: 1,
  23828. ANIMATION: 2,
  23829. };
  23830. BoundPropertyType[BoundPropertyType.DEFAULT] = "DEFAULT";
  23831. BoundPropertyType[BoundPropertyType.LITERAL_ATTR] = "LITERAL_ATTR";
  23832. BoundPropertyType[BoundPropertyType.ANIMATION] = "ANIMATION";
  23833. /**
  23834. * Represents a parsed property.
  23835. */
  23836. var BoundProperty = /** @class */ (function () {
  23837. function BoundProperty(name, expression, type, sourceSpan) {
  23838. this.name = name;
  23839. this.expression = expression;
  23840. this.type = type;
  23841. this.sourceSpan = sourceSpan;
  23842. this.isLiteral = this.type === BoundPropertyType.LITERAL_ATTR;
  23843. this.isAnimation = this.type === BoundPropertyType.ANIMATION;
  23844. }
  23845. return BoundProperty;
  23846. }());
  23847. /**
  23848. * Parses bindings in templates and in the directive host area.
  23849. */
  23850. var BindingParser = /** @class */ (function () {
  23851. function BindingParser(_exprParser, _interpolationConfig, _schemaRegistry, pipes, _targetErrors) {
  23852. var _this = this;
  23853. this._exprParser = _exprParser;
  23854. this._interpolationConfig = _interpolationConfig;
  23855. this._schemaRegistry = _schemaRegistry;
  23856. this._targetErrors = _targetErrors;
  23857. this.pipesByName = new Map();
  23858. this._usedPipes = new Map();
  23859. pipes.forEach(function (pipe) { return _this.pipesByName.set(pipe.name, pipe); });
  23860. }
  23861. /**
  23862. * @return {?}
  23863. */
  23864. BindingParser.prototype.getUsedPipes = /**
  23865. * @return {?}
  23866. */
  23867. function () { return Array.from(this._usedPipes.values()); };
  23868. /**
  23869. * @param {?} dirMeta
  23870. * @param {?} elementSelector
  23871. * @param {?} sourceSpan
  23872. * @return {?}
  23873. */
  23874. BindingParser.prototype.createDirectiveHostPropertyAsts = /**
  23875. * @param {?} dirMeta
  23876. * @param {?} elementSelector
  23877. * @param {?} sourceSpan
  23878. * @return {?}
  23879. */
  23880. function (dirMeta, elementSelector, sourceSpan) {
  23881. var _this = this;
  23882. if (dirMeta.hostProperties) {
  23883. var /** @type {?} */ boundProps_1 = [];
  23884. Object.keys(dirMeta.hostProperties).forEach(function (propName) {
  23885. var /** @type {?} */ expression = dirMeta.hostProperties[propName];
  23886. if (typeof expression === 'string') {
  23887. _this.parsePropertyBinding(propName, expression, true, sourceSpan, [], boundProps_1);
  23888. }
  23889. else {
  23890. _this._reportError("Value of the host property binding \"" + propName + "\" needs to be a string representing an expression but got \"" + expression + "\" (" + typeof expression + ")", sourceSpan);
  23891. }
  23892. });
  23893. return boundProps_1.map(function (prop) { return _this.createElementPropertyAst(elementSelector, prop); });
  23894. }
  23895. return null;
  23896. };
  23897. /**
  23898. * @param {?} dirMeta
  23899. * @param {?} sourceSpan
  23900. * @return {?}
  23901. */
  23902. BindingParser.prototype.createDirectiveHostEventAsts = /**
  23903. * @param {?} dirMeta
  23904. * @param {?} sourceSpan
  23905. * @return {?}
  23906. */
  23907. function (dirMeta, sourceSpan) {
  23908. var _this = this;
  23909. if (dirMeta.hostListeners) {
  23910. var /** @type {?} */ targetEventAsts_1 = [];
  23911. Object.keys(dirMeta.hostListeners).forEach(function (propName) {
  23912. var /** @type {?} */ expression = dirMeta.hostListeners[propName];
  23913. if (typeof expression === 'string') {
  23914. _this.parseEvent(propName, expression, sourceSpan, [], targetEventAsts_1);
  23915. }
  23916. else {
  23917. _this._reportError("Value of the host listener \"" + propName + "\" needs to be a string representing an expression but got \"" + expression + "\" (" + typeof expression + ")", sourceSpan);
  23918. }
  23919. });
  23920. return targetEventAsts_1;
  23921. }
  23922. return null;
  23923. };
  23924. /**
  23925. * @param {?} value
  23926. * @param {?} sourceSpan
  23927. * @return {?}
  23928. */
  23929. BindingParser.prototype.parseInterpolation = /**
  23930. * @param {?} value
  23931. * @param {?} sourceSpan
  23932. * @return {?}
  23933. */
  23934. function (value, sourceSpan) {
  23935. var /** @type {?} */ sourceInfo = sourceSpan.start.toString();
  23936. try {
  23937. var /** @type {?} */ ast = /** @type {?} */ ((this._exprParser.parseInterpolation(value, sourceInfo, this._interpolationConfig)));
  23938. if (ast)
  23939. this._reportExpressionParserErrors(ast.errors, sourceSpan);
  23940. this._checkPipes(ast, sourceSpan);
  23941. return ast;
  23942. }
  23943. catch (/** @type {?} */ e) {
  23944. this._reportError("" + e, sourceSpan);
  23945. return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo);
  23946. }
  23947. };
  23948. /**
  23949. * @param {?} prefixToken
  23950. * @param {?} value
  23951. * @param {?} sourceSpan
  23952. * @param {?} targetMatchableAttrs
  23953. * @param {?} targetProps
  23954. * @param {?} targetVars
  23955. * @return {?}
  23956. */
  23957. BindingParser.prototype.parseInlineTemplateBinding = /**
  23958. * @param {?} prefixToken
  23959. * @param {?} value
  23960. * @param {?} sourceSpan
  23961. * @param {?} targetMatchableAttrs
  23962. * @param {?} targetProps
  23963. * @param {?} targetVars
  23964. * @return {?}
  23965. */
  23966. function (prefixToken, value, sourceSpan, targetMatchableAttrs, targetProps, targetVars) {
  23967. var /** @type {?} */ bindings = this._parseTemplateBindings(prefixToken, value, sourceSpan);
  23968. for (var /** @type {?} */ i = 0; i < bindings.length; i++) {
  23969. var /** @type {?} */ binding = bindings[i];
  23970. if (binding.keyIsVar) {
  23971. targetVars.push(new VariableAst(binding.key, binding.name, sourceSpan));
  23972. }
  23973. else if (binding.expression) {
  23974. this._parsePropertyAst(binding.key, binding.expression, sourceSpan, targetMatchableAttrs, targetProps);
  23975. }
  23976. else {
  23977. targetMatchableAttrs.push([binding.key, '']);
  23978. this.parseLiteralAttr(binding.key, null, sourceSpan, targetMatchableAttrs, targetProps);
  23979. }
  23980. }
  23981. };
  23982. /**
  23983. * @param {?} prefixToken
  23984. * @param {?} value
  23985. * @param {?} sourceSpan
  23986. * @return {?}
  23987. */
  23988. BindingParser.prototype._parseTemplateBindings = /**
  23989. * @param {?} prefixToken
  23990. * @param {?} value
  23991. * @param {?} sourceSpan
  23992. * @return {?}
  23993. */
  23994. function (prefixToken, value, sourceSpan) {
  23995. var _this = this;
  23996. var /** @type {?} */ sourceInfo = sourceSpan.start.toString();
  23997. try {
  23998. var /** @type {?} */ bindingsResult = this._exprParser.parseTemplateBindings(prefixToken, value, sourceInfo);
  23999. this._reportExpressionParserErrors(bindingsResult.errors, sourceSpan);
  24000. bindingsResult.templateBindings.forEach(function (binding) {
  24001. if (binding.expression) {
  24002. _this._checkPipes(binding.expression, sourceSpan);
  24003. }
  24004. });
  24005. bindingsResult.warnings.forEach(function (warning) { _this._reportError(warning, sourceSpan, ParseErrorLevel.WARNING); });
  24006. return bindingsResult.templateBindings;
  24007. }
  24008. catch (/** @type {?} */ e) {
  24009. this._reportError("" + e, sourceSpan);
  24010. return [];
  24011. }
  24012. };
  24013. /**
  24014. * @param {?} name
  24015. * @param {?} value
  24016. * @param {?} sourceSpan
  24017. * @param {?} targetMatchableAttrs
  24018. * @param {?} targetProps
  24019. * @return {?}
  24020. */
  24021. BindingParser.prototype.parseLiteralAttr = /**
  24022. * @param {?} name
  24023. * @param {?} value
  24024. * @param {?} sourceSpan
  24025. * @param {?} targetMatchableAttrs
  24026. * @param {?} targetProps
  24027. * @return {?}
  24028. */
  24029. function (name, value, sourceSpan, targetMatchableAttrs, targetProps) {
  24030. if (_isAnimationLabel(name)) {
  24031. name = name.substring(1);
  24032. if (value) {
  24033. this._reportError("Assigning animation triggers via @prop=\"exp\" attributes with an expression is invalid." +
  24034. " Use property bindings (e.g. [@prop]=\"exp\") or use an attribute without a value (e.g. @prop) instead.", sourceSpan, ParseErrorLevel.ERROR);
  24035. }
  24036. this._parseAnimation(name, value, sourceSpan, targetMatchableAttrs, targetProps);
  24037. }
  24038. else {
  24039. targetProps.push(new BoundProperty(name, this._exprParser.wrapLiteralPrimitive(value, ''), BoundPropertyType.LITERAL_ATTR, sourceSpan));
  24040. }
  24041. };
  24042. /**
  24043. * @param {?} name
  24044. * @param {?} expression
  24045. * @param {?} isHost
  24046. * @param {?} sourceSpan
  24047. * @param {?} targetMatchableAttrs
  24048. * @param {?} targetProps
  24049. * @return {?}
  24050. */
  24051. BindingParser.prototype.parsePropertyBinding = /**
  24052. * @param {?} name
  24053. * @param {?} expression
  24054. * @param {?} isHost
  24055. * @param {?} sourceSpan
  24056. * @param {?} targetMatchableAttrs
  24057. * @param {?} targetProps
  24058. * @return {?}
  24059. */
  24060. function (name, expression, isHost, sourceSpan, targetMatchableAttrs, targetProps) {
  24061. var /** @type {?} */ isAnimationProp = false;
  24062. if (name.startsWith(ANIMATE_PROP_PREFIX)) {
  24063. isAnimationProp = true;
  24064. name = name.substring(ANIMATE_PROP_PREFIX.length);
  24065. }
  24066. else if (_isAnimationLabel(name)) {
  24067. isAnimationProp = true;
  24068. name = name.substring(1);
  24069. }
  24070. if (isAnimationProp) {
  24071. this._parseAnimation(name, expression, sourceSpan, targetMatchableAttrs, targetProps);
  24072. }
  24073. else {
  24074. this._parsePropertyAst(name, this._parseBinding(expression, isHost, sourceSpan), sourceSpan, targetMatchableAttrs, targetProps);
  24075. }
  24076. };
  24077. /**
  24078. * @param {?} name
  24079. * @param {?} value
  24080. * @param {?} sourceSpan
  24081. * @param {?} targetMatchableAttrs
  24082. * @param {?} targetProps
  24083. * @return {?}
  24084. */
  24085. BindingParser.prototype.parsePropertyInterpolation = /**
  24086. * @param {?} name
  24087. * @param {?} value
  24088. * @param {?} sourceSpan
  24089. * @param {?} targetMatchableAttrs
  24090. * @param {?} targetProps
  24091. * @return {?}
  24092. */
  24093. function (name, value, sourceSpan, targetMatchableAttrs, targetProps) {
  24094. var /** @type {?} */ expr = this.parseInterpolation(value, sourceSpan);
  24095. if (expr) {
  24096. this._parsePropertyAst(name, expr, sourceSpan, targetMatchableAttrs, targetProps);
  24097. return true;
  24098. }
  24099. return false;
  24100. };
  24101. /**
  24102. * @param {?} name
  24103. * @param {?} ast
  24104. * @param {?} sourceSpan
  24105. * @param {?} targetMatchableAttrs
  24106. * @param {?} targetProps
  24107. * @return {?}
  24108. */
  24109. BindingParser.prototype._parsePropertyAst = /**
  24110. * @param {?} name
  24111. * @param {?} ast
  24112. * @param {?} sourceSpan
  24113. * @param {?} targetMatchableAttrs
  24114. * @param {?} targetProps
  24115. * @return {?}
  24116. */
  24117. function (name, ast, sourceSpan, targetMatchableAttrs, targetProps) {
  24118. targetMatchableAttrs.push([name, /** @type {?} */ ((ast.source))]);
  24119. targetProps.push(new BoundProperty(name, ast, BoundPropertyType.DEFAULT, sourceSpan));
  24120. };
  24121. /**
  24122. * @param {?} name
  24123. * @param {?} expression
  24124. * @param {?} sourceSpan
  24125. * @param {?} targetMatchableAttrs
  24126. * @param {?} targetProps
  24127. * @return {?}
  24128. */
  24129. BindingParser.prototype._parseAnimation = /**
  24130. * @param {?} name
  24131. * @param {?} expression
  24132. * @param {?} sourceSpan
  24133. * @param {?} targetMatchableAttrs
  24134. * @param {?} targetProps
  24135. * @return {?}
  24136. */
  24137. function (name, expression, sourceSpan, targetMatchableAttrs, targetProps) {
  24138. // This will occur when a @trigger is not paired with an expression.
  24139. // For animations it is valid to not have an expression since */void
  24140. // states will be applied by angular when the element is attached/detached
  24141. var /** @type {?} */ ast = this._parseBinding(expression || 'undefined', false, sourceSpan);
  24142. targetMatchableAttrs.push([name, /** @type {?} */ ((ast.source))]);
  24143. targetProps.push(new BoundProperty(name, ast, BoundPropertyType.ANIMATION, sourceSpan));
  24144. };
  24145. /**
  24146. * @param {?} value
  24147. * @param {?} isHostBinding
  24148. * @param {?} sourceSpan
  24149. * @return {?}
  24150. */
  24151. BindingParser.prototype._parseBinding = /**
  24152. * @param {?} value
  24153. * @param {?} isHostBinding
  24154. * @param {?} sourceSpan
  24155. * @return {?}
  24156. */
  24157. function (value, isHostBinding, sourceSpan) {
  24158. var /** @type {?} */ sourceInfo = sourceSpan.start.toString();
  24159. try {
  24160. var /** @type {?} */ ast = isHostBinding ?
  24161. this._exprParser.parseSimpleBinding(value, sourceInfo, this._interpolationConfig) :
  24162. this._exprParser.parseBinding(value, sourceInfo, this._interpolationConfig);
  24163. if (ast)
  24164. this._reportExpressionParserErrors(ast.errors, sourceSpan);
  24165. this._checkPipes(ast, sourceSpan);
  24166. return ast;
  24167. }
  24168. catch (/** @type {?} */ e) {
  24169. this._reportError("" + e, sourceSpan);
  24170. return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo);
  24171. }
  24172. };
  24173. /**
  24174. * @param {?} elementSelector
  24175. * @param {?} boundProp
  24176. * @return {?}
  24177. */
  24178. BindingParser.prototype.createElementPropertyAst = /**
  24179. * @param {?} elementSelector
  24180. * @param {?} boundProp
  24181. * @return {?}
  24182. */
  24183. function (elementSelector, boundProp) {
  24184. if (boundProp.isAnimation) {
  24185. return new BoundElementPropertyAst(boundProp.name, PropertyBindingType.Animation, SecurityContext.NONE, boundProp.expression, null, boundProp.sourceSpan);
  24186. }
  24187. var /** @type {?} */ unit = null;
  24188. var /** @type {?} */ bindingType = /** @type {?} */ ((undefined));
  24189. var /** @type {?} */ boundPropertyName = null;
  24190. var /** @type {?} */ parts = boundProp.name.split(PROPERTY_PARTS_SEPARATOR);
  24191. var /** @type {?} */ securityContexts = /** @type {?} */ ((undefined));
  24192. // Check check for special cases (prefix style, attr, class)
  24193. if (parts.length > 1) {
  24194. if (parts[0] == ATTRIBUTE_PREFIX) {
  24195. boundPropertyName = parts[1];
  24196. this._validatePropertyOrAttributeName(boundPropertyName, boundProp.sourceSpan, true);
  24197. securityContexts = calcPossibleSecurityContexts(this._schemaRegistry, elementSelector, boundPropertyName, true);
  24198. var /** @type {?} */ nsSeparatorIdx = boundPropertyName.indexOf(':');
  24199. if (nsSeparatorIdx > -1) {
  24200. var /** @type {?} */ ns = boundPropertyName.substring(0, nsSeparatorIdx);
  24201. var /** @type {?} */ name_1 = boundPropertyName.substring(nsSeparatorIdx + 1);
  24202. boundPropertyName = mergeNsAndName(ns, name_1);
  24203. }
  24204. bindingType = PropertyBindingType.Attribute;
  24205. }
  24206. else if (parts[0] == CLASS_PREFIX) {
  24207. boundPropertyName = parts[1];
  24208. bindingType = PropertyBindingType.Class;
  24209. securityContexts = [SecurityContext.NONE];
  24210. }
  24211. else if (parts[0] == STYLE_PREFIX) {
  24212. unit = parts.length > 2 ? parts[2] : null;
  24213. boundPropertyName = parts[1];
  24214. bindingType = PropertyBindingType.Style;
  24215. securityContexts = [SecurityContext.STYLE];
  24216. }
  24217. }
  24218. // If not a special case, use the full property name
  24219. if (boundPropertyName === null) {
  24220. boundPropertyName = this._schemaRegistry.getMappedPropName(boundProp.name);
  24221. securityContexts = calcPossibleSecurityContexts(this._schemaRegistry, elementSelector, boundPropertyName, false);
  24222. bindingType = PropertyBindingType.Property;
  24223. this._validatePropertyOrAttributeName(boundPropertyName, boundProp.sourceSpan, false);
  24224. }
  24225. return new BoundElementPropertyAst(boundPropertyName, bindingType, securityContexts[0], boundProp.expression, unit, boundProp.sourceSpan);
  24226. };
  24227. /**
  24228. * @param {?} name
  24229. * @param {?} expression
  24230. * @param {?} sourceSpan
  24231. * @param {?} targetMatchableAttrs
  24232. * @param {?} targetEvents
  24233. * @return {?}
  24234. */
  24235. BindingParser.prototype.parseEvent = /**
  24236. * @param {?} name
  24237. * @param {?} expression
  24238. * @param {?} sourceSpan
  24239. * @param {?} targetMatchableAttrs
  24240. * @param {?} targetEvents
  24241. * @return {?}
  24242. */
  24243. function (name, expression, sourceSpan, targetMatchableAttrs, targetEvents) {
  24244. if (_isAnimationLabel(name)) {
  24245. name = name.substr(1);
  24246. this._parseAnimationEvent(name, expression, sourceSpan, targetEvents);
  24247. }
  24248. else {
  24249. this._parseEvent(name, expression, sourceSpan, targetMatchableAttrs, targetEvents);
  24250. }
  24251. };
  24252. /**
  24253. * @param {?} name
  24254. * @param {?} expression
  24255. * @param {?} sourceSpan
  24256. * @param {?} targetEvents
  24257. * @return {?}
  24258. */
  24259. BindingParser.prototype._parseAnimationEvent = /**
  24260. * @param {?} name
  24261. * @param {?} expression
  24262. * @param {?} sourceSpan
  24263. * @param {?} targetEvents
  24264. * @return {?}
  24265. */
  24266. function (name, expression, sourceSpan, targetEvents) {
  24267. var /** @type {?} */ matches = splitAtPeriod(name, [name, '']);
  24268. var /** @type {?} */ eventName = matches[0];
  24269. var /** @type {?} */ phase = matches[1].toLowerCase();
  24270. if (phase) {
  24271. switch (phase) {
  24272. case 'start':
  24273. case 'done':
  24274. var /** @type {?} */ ast = this._parseAction(expression, sourceSpan);
  24275. targetEvents.push(new BoundEventAst(eventName, null, phase, ast, sourceSpan));
  24276. break;
  24277. default:
  24278. this._reportError("The provided animation output phase value \"" + phase + "\" for \"@" + eventName + "\" is not supported (use start or done)", sourceSpan);
  24279. break;
  24280. }
  24281. }
  24282. else {
  24283. this._reportError("The animation trigger output event (@" + eventName + ") is missing its phase value name (start or done are currently supported)", sourceSpan);
  24284. }
  24285. };
  24286. /**
  24287. * @param {?} name
  24288. * @param {?} expression
  24289. * @param {?} sourceSpan
  24290. * @param {?} targetMatchableAttrs
  24291. * @param {?} targetEvents
  24292. * @return {?}
  24293. */
  24294. BindingParser.prototype._parseEvent = /**
  24295. * @param {?} name
  24296. * @param {?} expression
  24297. * @param {?} sourceSpan
  24298. * @param {?} targetMatchableAttrs
  24299. * @param {?} targetEvents
  24300. * @return {?}
  24301. */
  24302. function (name, expression, sourceSpan, targetMatchableAttrs, targetEvents) {
  24303. // long format: 'target: eventName'
  24304. var _a = splitAtColon(name, [/** @type {?} */ ((null)), name]), target = _a[0], eventName = _a[1];
  24305. var /** @type {?} */ ast = this._parseAction(expression, sourceSpan);
  24306. targetMatchableAttrs.push([/** @type {?} */ ((name)), /** @type {?} */ ((ast.source))]);
  24307. targetEvents.push(new BoundEventAst(eventName, target, null, ast, sourceSpan));
  24308. // Don't detect directives for event names for now,
  24309. // so don't add the event name to the matchableAttrs
  24310. };
  24311. /**
  24312. * @param {?} value
  24313. * @param {?} sourceSpan
  24314. * @return {?}
  24315. */
  24316. BindingParser.prototype._parseAction = /**
  24317. * @param {?} value
  24318. * @param {?} sourceSpan
  24319. * @return {?}
  24320. */
  24321. function (value, sourceSpan) {
  24322. var /** @type {?} */ sourceInfo = sourceSpan.start.toString();
  24323. try {
  24324. var /** @type {?} */ ast = this._exprParser.parseAction(value, sourceInfo, this._interpolationConfig);
  24325. if (ast) {
  24326. this._reportExpressionParserErrors(ast.errors, sourceSpan);
  24327. }
  24328. if (!ast || ast.ast instanceof EmptyExpr) {
  24329. this._reportError("Empty expressions are not allowed", sourceSpan);
  24330. return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo);
  24331. }
  24332. this._checkPipes(ast, sourceSpan);
  24333. return ast;
  24334. }
  24335. catch (/** @type {?} */ e) {
  24336. this._reportError("" + e, sourceSpan);
  24337. return this._exprParser.wrapLiteralPrimitive('ERROR', sourceInfo);
  24338. }
  24339. };
  24340. /**
  24341. * @param {?} message
  24342. * @param {?} sourceSpan
  24343. * @param {?=} level
  24344. * @return {?}
  24345. */
  24346. BindingParser.prototype._reportError = /**
  24347. * @param {?} message
  24348. * @param {?} sourceSpan
  24349. * @param {?=} level
  24350. * @return {?}
  24351. */
  24352. function (message, sourceSpan, level) {
  24353. if (level === void 0) { level = ParseErrorLevel.ERROR; }
  24354. this._targetErrors.push(new ParseError(sourceSpan, message, level));
  24355. };
  24356. /**
  24357. * @param {?} errors
  24358. * @param {?} sourceSpan
  24359. * @return {?}
  24360. */
  24361. BindingParser.prototype._reportExpressionParserErrors = /**
  24362. * @param {?} errors
  24363. * @param {?} sourceSpan
  24364. * @return {?}
  24365. */
  24366. function (errors, sourceSpan) {
  24367. for (var _i = 0, errors_1 = errors; _i < errors_1.length; _i++) {
  24368. var error = errors_1[_i];
  24369. this._reportError(error.message, sourceSpan);
  24370. }
  24371. };
  24372. /**
  24373. * @param {?} ast
  24374. * @param {?} sourceSpan
  24375. * @return {?}
  24376. */
  24377. BindingParser.prototype._checkPipes = /**
  24378. * @param {?} ast
  24379. * @param {?} sourceSpan
  24380. * @return {?}
  24381. */
  24382. function (ast, sourceSpan) {
  24383. var _this = this;
  24384. if (ast) {
  24385. var /** @type {?} */ collector = new PipeCollector();
  24386. ast.visit(collector);
  24387. collector.pipes.forEach(function (ast, pipeName) {
  24388. var /** @type {?} */ pipeMeta = _this.pipesByName.get(pipeName);
  24389. if (!pipeMeta) {
  24390. _this._reportError("The pipe '" + pipeName + "' could not be found", new ParseSourceSpan(sourceSpan.start.moveBy(ast.span.start), sourceSpan.start.moveBy(ast.span.end)));
  24391. }
  24392. else {
  24393. _this._usedPipes.set(pipeName, pipeMeta);
  24394. }
  24395. });
  24396. }
  24397. };
  24398. /**
  24399. * @param {?} propName the name of the property / attribute
  24400. * @param {?} sourceSpan
  24401. * @param {?} isAttr true when binding to an attribute
  24402. * @return {?}
  24403. */
  24404. BindingParser.prototype._validatePropertyOrAttributeName = /**
  24405. * @param {?} propName the name of the property / attribute
  24406. * @param {?} sourceSpan
  24407. * @param {?} isAttr true when binding to an attribute
  24408. * @return {?}
  24409. */
  24410. function (propName, sourceSpan, isAttr) {
  24411. var /** @type {?} */ report = isAttr ? this._schemaRegistry.validateAttribute(propName) :
  24412. this._schemaRegistry.validateProperty(propName);
  24413. if (report.error) {
  24414. this._reportError(/** @type {?} */ ((report.msg)), sourceSpan, ParseErrorLevel.ERROR);
  24415. }
  24416. };
  24417. return BindingParser;
  24418. }());
  24419. var PipeCollector = /** @class */ (function (_super) {
  24420. __extends(PipeCollector, _super);
  24421. function PipeCollector() {
  24422. var _this = _super !== null && _super.apply(this, arguments) || this;
  24423. _this.pipes = new Map();
  24424. return _this;
  24425. }
  24426. /**
  24427. * @param {?} ast
  24428. * @param {?} context
  24429. * @return {?}
  24430. */
  24431. PipeCollector.prototype.visitPipe = /**
  24432. * @param {?} ast
  24433. * @param {?} context
  24434. * @return {?}
  24435. */
  24436. function (ast, context) {
  24437. this.pipes.set(ast.name, ast);
  24438. ast.exp.visit(this);
  24439. this.visitAll(ast.args, context);
  24440. return null;
  24441. };
  24442. return PipeCollector;
  24443. }(RecursiveAstVisitor));
  24444. /**
  24445. * @param {?} name
  24446. * @return {?}
  24447. */
  24448. function _isAnimationLabel(name) {
  24449. return name[0] == '@';
  24450. }
  24451. /**
  24452. * @param {?} registry
  24453. * @param {?} selector
  24454. * @param {?} propName
  24455. * @param {?} isAttribute
  24456. * @return {?}
  24457. */
  24458. function calcPossibleSecurityContexts(registry, selector, propName, isAttribute) {
  24459. var /** @type {?} */ ctxs = [];
  24460. CssSelector.parse(selector).forEach(function (selector) {
  24461. var /** @type {?} */ elementNames = selector.element ? [selector.element] : registry.allKnownElementNames();
  24462. var /** @type {?} */ notElementNames = new Set(selector.notSelectors.filter(function (selector) { return selector.isElementSelector(); })
  24463. .map(function (selector) { return selector.element; }));
  24464. var /** @type {?} */ possibleElementNames = elementNames.filter(function (elementName) { return !notElementNames.has(elementName); });
  24465. ctxs.push.apply(ctxs, possibleElementNames.map(function (elementName) { return registry.securityContext(elementName, propName, isAttribute); }));
  24466. });
  24467. return ctxs.length === 0 ? [SecurityContext.NONE] : Array.from(new Set(ctxs)).sort();
  24468. }
  24469. /**
  24470. * @fileoverview added by tsickle
  24471. * @suppress {checkTypes} checked by tsc
  24472. */
  24473. /**
  24474. * @license
  24475. * Copyright Google Inc. All Rights Reserved.
  24476. *
  24477. * Use of this source code is governed by an MIT-style license that can be
  24478. * found in the LICENSE file at https://angular.io/license
  24479. */
  24480. var BIND_NAME_REGEXP = /^(?:(?:(?:(bind-)|(let-)|(ref-|#)|(on-)|(bindon-)|(@))(.+))|\[\(([^\)]+)\)\]|\[([^\]]+)\]|\(([^\)]+)\))$/;
  24481. // Group 1 = "bind-"
  24482. var KW_BIND_IDX = 1;
  24483. // Group 2 = "let-"
  24484. var KW_LET_IDX = 2;
  24485. // Group 3 = "ref-/#"
  24486. var KW_REF_IDX = 3;
  24487. // Group 4 = "on-"
  24488. var KW_ON_IDX = 4;
  24489. // Group 5 = "bindon-"
  24490. var KW_BINDON_IDX = 5;
  24491. // Group 6 = "@"
  24492. var KW_AT_IDX = 6;
  24493. // Group 7 = the identifier after "bind-", "let-", "ref-/#", "on-", "bindon-" or "@"
  24494. var IDENT_KW_IDX = 7;
  24495. // Group 8 = identifier inside [()]
  24496. var IDENT_BANANA_BOX_IDX = 8;
  24497. // Group 9 = identifier inside []
  24498. var IDENT_PROPERTY_IDX = 9;
  24499. // Group 10 = identifier inside ()
  24500. var IDENT_EVENT_IDX = 10;
  24501. // deprecated in 4.x
  24502. var TEMPLATE_ELEMENT = 'template';
  24503. // deprecated in 4.x
  24504. var TEMPLATE_ATTR = 'template';
  24505. var TEMPLATE_ATTR_PREFIX = '*';
  24506. var CLASS_ATTR = 'class';
  24507. var TEXT_CSS_SELECTOR = CssSelector.parse('*')[0];
  24508. var TEMPLATE_ELEMENT_DEPRECATION_WARNING = 'The <template> element is deprecated. Use <ng-template> instead';
  24509. var TEMPLATE_ATTR_DEPRECATION_WARNING = 'The template attribute is deprecated. Use an ng-template element instead.';
  24510. var warningCounts = {};
  24511. /**
  24512. * @param {?} warnings
  24513. * @return {?}
  24514. */
  24515. function warnOnlyOnce(warnings) {
  24516. return function (error) {
  24517. if (warnings.indexOf(error.msg) !== -1) {
  24518. warningCounts[error.msg] = (warningCounts[error.msg] || 0) + 1;
  24519. return warningCounts[error.msg] <= 1;
  24520. }
  24521. return true;
  24522. };
  24523. }
  24524. var TemplateParseError = /** @class */ (function (_super) {
  24525. __extends(TemplateParseError, _super);
  24526. function TemplateParseError(message, span, level) {
  24527. return _super.call(this, span, message, level) || this;
  24528. }
  24529. return TemplateParseError;
  24530. }(ParseError));
  24531. var TemplateParseResult = /** @class */ (function () {
  24532. function TemplateParseResult(templateAst, usedPipes, errors) {
  24533. this.templateAst = templateAst;
  24534. this.usedPipes = usedPipes;
  24535. this.errors = errors;
  24536. }
  24537. return TemplateParseResult;
  24538. }());
  24539. var TemplateParser = /** @class */ (function () {
  24540. function TemplateParser(_config, _reflector, _exprParser, _schemaRegistry, _htmlParser, _console, transforms) {
  24541. this._config = _config;
  24542. this._reflector = _reflector;
  24543. this._exprParser = _exprParser;
  24544. this._schemaRegistry = _schemaRegistry;
  24545. this._htmlParser = _htmlParser;
  24546. this._console = _console;
  24547. this.transforms = transforms;
  24548. }
  24549. /**
  24550. * @param {?} component
  24551. * @param {?} template
  24552. * @param {?} directives
  24553. * @param {?} pipes
  24554. * @param {?} schemas
  24555. * @param {?} templateUrl
  24556. * @param {?} preserveWhitespaces
  24557. * @return {?}
  24558. */
  24559. TemplateParser.prototype.parse = /**
  24560. * @param {?} component
  24561. * @param {?} template
  24562. * @param {?} directives
  24563. * @param {?} pipes
  24564. * @param {?} schemas
  24565. * @param {?} templateUrl
  24566. * @param {?} preserveWhitespaces
  24567. * @return {?}
  24568. */
  24569. function (component, template, directives, pipes, schemas, templateUrl, preserveWhitespaces) {
  24570. var /** @type {?} */ result = this.tryParse(component, template, directives, pipes, schemas, templateUrl, preserveWhitespaces);
  24571. var /** @type {?} */ warnings = /** @type {?} */ ((result.errors)).filter(function (error) { return error.level === ParseErrorLevel.WARNING; }).filter(warnOnlyOnce([TEMPLATE_ATTR_DEPRECATION_WARNING, TEMPLATE_ELEMENT_DEPRECATION_WARNING]));
  24572. var /** @type {?} */ errors = /** @type {?} */ ((result.errors)).filter(function (error) { return error.level === ParseErrorLevel.ERROR; });
  24573. if (warnings.length > 0) {
  24574. this._console.warn("Template parse warnings:\n" + warnings.join('\n'));
  24575. }
  24576. if (errors.length > 0) {
  24577. var /** @type {?} */ errorString = errors.join('\n');
  24578. throw syntaxError("Template parse errors:\n" + errorString, errors);
  24579. }
  24580. return { template: /** @type {?} */ ((result.templateAst)), pipes: /** @type {?} */ ((result.usedPipes)) };
  24581. };
  24582. /**
  24583. * @param {?} component
  24584. * @param {?} template
  24585. * @param {?} directives
  24586. * @param {?} pipes
  24587. * @param {?} schemas
  24588. * @param {?} templateUrl
  24589. * @param {?} preserveWhitespaces
  24590. * @return {?}
  24591. */
  24592. TemplateParser.prototype.tryParse = /**
  24593. * @param {?} component
  24594. * @param {?} template
  24595. * @param {?} directives
  24596. * @param {?} pipes
  24597. * @param {?} schemas
  24598. * @param {?} templateUrl
  24599. * @param {?} preserveWhitespaces
  24600. * @return {?}
  24601. */
  24602. function (component, template, directives, pipes, schemas, templateUrl, preserveWhitespaces) {
  24603. var /** @type {?} */ htmlParseResult = typeof template === 'string' ? /** @type {?} */ ((this._htmlParser)).parse(template, templateUrl, true, this.getInterpolationConfig(component)) :
  24604. template;
  24605. if (!preserveWhitespaces) {
  24606. htmlParseResult = removeWhitespaces(htmlParseResult);
  24607. }
  24608. return this.tryParseHtml(this.expandHtml(htmlParseResult), component, directives, pipes, schemas);
  24609. };
  24610. /**
  24611. * @param {?} htmlAstWithErrors
  24612. * @param {?} component
  24613. * @param {?} directives
  24614. * @param {?} pipes
  24615. * @param {?} schemas
  24616. * @return {?}
  24617. */
  24618. TemplateParser.prototype.tryParseHtml = /**
  24619. * @param {?} htmlAstWithErrors
  24620. * @param {?} component
  24621. * @param {?} directives
  24622. * @param {?} pipes
  24623. * @param {?} schemas
  24624. * @return {?}
  24625. */
  24626. function (htmlAstWithErrors, component, directives, pipes, schemas) {
  24627. var /** @type {?} */ result;
  24628. var /** @type {?} */ errors = htmlAstWithErrors.errors;
  24629. var /** @type {?} */ usedPipes = [];
  24630. if (htmlAstWithErrors.rootNodes.length > 0) {
  24631. var /** @type {?} */ uniqDirectives = removeSummaryDuplicates(directives);
  24632. var /** @type {?} */ uniqPipes = removeSummaryDuplicates(pipes);
  24633. var /** @type {?} */ providerViewContext = new ProviderViewContext(this._reflector, component);
  24634. var /** @type {?} */ interpolationConfig = /** @type {?} */ ((undefined));
  24635. if (component.template && component.template.interpolation) {
  24636. interpolationConfig = {
  24637. start: component.template.interpolation[0],
  24638. end: component.template.interpolation[1]
  24639. };
  24640. }
  24641. var /** @type {?} */ bindingParser = new BindingParser(this._exprParser, /** @type {?} */ ((interpolationConfig)), this._schemaRegistry, uniqPipes, errors);
  24642. var /** @type {?} */ parseVisitor = new TemplateParseVisitor(this._reflector, this._config, providerViewContext, uniqDirectives, bindingParser, this._schemaRegistry, schemas, errors);
  24643. result = visitAll(parseVisitor, htmlAstWithErrors.rootNodes, EMPTY_ELEMENT_CONTEXT);
  24644. errors.push.apply(errors, providerViewContext.errors);
  24645. usedPipes.push.apply(usedPipes, bindingParser.getUsedPipes());
  24646. }
  24647. else {
  24648. result = [];
  24649. }
  24650. this._assertNoReferenceDuplicationOnTemplate(result, errors);
  24651. if (errors.length > 0) {
  24652. return new TemplateParseResult(result, usedPipes, errors);
  24653. }
  24654. if (this.transforms) {
  24655. this.transforms.forEach(function (transform) { result = templateVisitAll(transform, result); });
  24656. }
  24657. return new TemplateParseResult(result, usedPipes, errors);
  24658. };
  24659. /**
  24660. * @param {?} htmlAstWithErrors
  24661. * @param {?=} forced
  24662. * @return {?}
  24663. */
  24664. TemplateParser.prototype.expandHtml = /**
  24665. * @param {?} htmlAstWithErrors
  24666. * @param {?=} forced
  24667. * @return {?}
  24668. */
  24669. function (htmlAstWithErrors, forced) {
  24670. if (forced === void 0) { forced = false; }
  24671. var /** @type {?} */ errors = htmlAstWithErrors.errors;
  24672. if (errors.length == 0 || forced) {
  24673. // Transform ICU messages to angular directives
  24674. var /** @type {?} */ expandedHtmlAst = expandNodes(htmlAstWithErrors.rootNodes);
  24675. errors.push.apply(errors, expandedHtmlAst.errors);
  24676. htmlAstWithErrors = new ParseTreeResult(expandedHtmlAst.nodes, errors);
  24677. }
  24678. return htmlAstWithErrors;
  24679. };
  24680. /**
  24681. * @param {?} component
  24682. * @return {?}
  24683. */
  24684. TemplateParser.prototype.getInterpolationConfig = /**
  24685. * @param {?} component
  24686. * @return {?}
  24687. */
  24688. function (component) {
  24689. if (component.template) {
  24690. return InterpolationConfig.fromArray(component.template.interpolation);
  24691. }
  24692. return undefined;
  24693. };
  24694. /** @internal */
  24695. /**
  24696. * \@internal
  24697. * @param {?} result
  24698. * @param {?} errors
  24699. * @return {?}
  24700. */
  24701. TemplateParser.prototype._assertNoReferenceDuplicationOnTemplate = /**
  24702. * \@internal
  24703. * @param {?} result
  24704. * @param {?} errors
  24705. * @return {?}
  24706. */
  24707. function (result, errors) {
  24708. var /** @type {?} */ existingReferences = [];
  24709. result.filter(function (element) { return !!(/** @type {?} */ (element)).references; })
  24710. .forEach(function (element) {
  24711. return (/** @type {?} */ (element)).references.forEach(function (reference) {
  24712. var /** @type {?} */ name = reference.name;
  24713. if (existingReferences.indexOf(name) < 0) {
  24714. existingReferences.push(name);
  24715. }
  24716. else {
  24717. var /** @type {?} */ error = new TemplateParseError("Reference \"#" + name + "\" is defined several times", reference.sourceSpan, ParseErrorLevel.ERROR);
  24718. errors.push(error);
  24719. }
  24720. });
  24721. });
  24722. };
  24723. return TemplateParser;
  24724. }());
  24725. var TemplateParseVisitor = /** @class */ (function () {
  24726. function TemplateParseVisitor(reflector, config, providerViewContext, directives, _bindingParser, _schemaRegistry, _schemas, _targetErrors) {
  24727. var _this = this;
  24728. this.reflector = reflector;
  24729. this.config = config;
  24730. this.providerViewContext = providerViewContext;
  24731. this._bindingParser = _bindingParser;
  24732. this._schemaRegistry = _schemaRegistry;
  24733. this._schemas = _schemas;
  24734. this._targetErrors = _targetErrors;
  24735. this.selectorMatcher = new SelectorMatcher();
  24736. this.directivesIndex = new Map();
  24737. this.ngContentCount = 0;
  24738. // Note: queries start with id 1 so we can use the number in a Bloom filter!
  24739. this.contentQueryStartId = providerViewContext.component.viewQueries.length + 1;
  24740. directives.forEach(function (directive, index) {
  24741. var /** @type {?} */ selector = CssSelector.parse(/** @type {?} */ ((directive.selector)));
  24742. _this.selectorMatcher.addSelectables(selector, directive);
  24743. _this.directivesIndex.set(directive, index);
  24744. });
  24745. }
  24746. /**
  24747. * @param {?} expansion
  24748. * @param {?} context
  24749. * @return {?}
  24750. */
  24751. TemplateParseVisitor.prototype.visitExpansion = /**
  24752. * @param {?} expansion
  24753. * @param {?} context
  24754. * @return {?}
  24755. */
  24756. function (expansion, context) { return null; };
  24757. /**
  24758. * @param {?} expansionCase
  24759. * @param {?} context
  24760. * @return {?}
  24761. */
  24762. TemplateParseVisitor.prototype.visitExpansionCase = /**
  24763. * @param {?} expansionCase
  24764. * @param {?} context
  24765. * @return {?}
  24766. */
  24767. function (expansionCase, context) { return null; };
  24768. /**
  24769. * @param {?} text
  24770. * @param {?} parent
  24771. * @return {?}
  24772. */
  24773. TemplateParseVisitor.prototype.visitText = /**
  24774. * @param {?} text
  24775. * @param {?} parent
  24776. * @return {?}
  24777. */
  24778. function (text, parent) {
  24779. var /** @type {?} */ ngContentIndex = /** @type {?} */ ((parent.findNgContentIndex(TEXT_CSS_SELECTOR)));
  24780. var /** @type {?} */ valueNoNgsp = replaceNgsp(text.value);
  24781. var /** @type {?} */ expr = this._bindingParser.parseInterpolation(valueNoNgsp, /** @type {?} */ ((text.sourceSpan)));
  24782. return expr ? new BoundTextAst(expr, ngContentIndex, /** @type {?} */ ((text.sourceSpan))) :
  24783. new TextAst(valueNoNgsp, ngContentIndex, /** @type {?} */ ((text.sourceSpan)));
  24784. };
  24785. /**
  24786. * @param {?} attribute
  24787. * @param {?} context
  24788. * @return {?}
  24789. */
  24790. TemplateParseVisitor.prototype.visitAttribute = /**
  24791. * @param {?} attribute
  24792. * @param {?} context
  24793. * @return {?}
  24794. */
  24795. function (attribute, context) {
  24796. return new AttrAst(attribute.name, attribute.value, attribute.sourceSpan);
  24797. };
  24798. /**
  24799. * @param {?} comment
  24800. * @param {?} context
  24801. * @return {?}
  24802. */
  24803. TemplateParseVisitor.prototype.visitComment = /**
  24804. * @param {?} comment
  24805. * @param {?} context
  24806. * @return {?}
  24807. */
  24808. function (comment, context) { return null; };
  24809. /**
  24810. * @param {?} element
  24811. * @param {?} parent
  24812. * @return {?}
  24813. */
  24814. TemplateParseVisitor.prototype.visitElement = /**
  24815. * @param {?} element
  24816. * @param {?} parent
  24817. * @return {?}
  24818. */
  24819. function (element, parent) {
  24820. var _this = this;
  24821. var /** @type {?} */ queryStartIndex = this.contentQueryStartId;
  24822. var /** @type {?} */ nodeName = element.name;
  24823. var /** @type {?} */ preparsedElement = preparseElement(element);
  24824. if (preparsedElement.type === PreparsedElementType.SCRIPT ||
  24825. preparsedElement.type === PreparsedElementType.STYLE) {
  24826. // Skipping <script> for security reasons
  24827. // Skipping <style> as we already processed them
  24828. // in the StyleCompiler
  24829. return null;
  24830. }
  24831. if (preparsedElement.type === PreparsedElementType.STYLESHEET &&
  24832. isStyleUrlResolvable(preparsedElement.hrefAttr)) {
  24833. // Skipping stylesheets with either relative urls or package scheme as we already processed
  24834. // them in the StyleCompiler
  24835. return null;
  24836. }
  24837. var /** @type {?} */ matchableAttrs = [];
  24838. var /** @type {?} */ elementOrDirectiveProps = [];
  24839. var /** @type {?} */ elementOrDirectiveRefs = [];
  24840. var /** @type {?} */ elementVars = [];
  24841. var /** @type {?} */ events = [];
  24842. var /** @type {?} */ templateElementOrDirectiveProps = [];
  24843. var /** @type {?} */ templateMatchableAttrs = [];
  24844. var /** @type {?} */ templateElementVars = [];
  24845. var /** @type {?} */ hasInlineTemplates = false;
  24846. var /** @type {?} */ attrs = [];
  24847. var /** @type {?} */ isTemplateElement = isTemplate(element, this.config.enableLegacyTemplate, function (m, span) { return _this._reportError(m, span, ParseErrorLevel.WARNING); });
  24848. element.attrs.forEach(function (attr) {
  24849. var /** @type {?} */ hasBinding = _this._parseAttr(isTemplateElement, attr, matchableAttrs, elementOrDirectiveProps, events, elementOrDirectiveRefs, elementVars);
  24850. var /** @type {?} */ templateBindingsSource;
  24851. var /** @type {?} */ prefixToken;
  24852. var /** @type {?} */ normalizedName = _this._normalizeAttributeName(attr.name);
  24853. if (_this.config.enableLegacyTemplate && normalizedName == TEMPLATE_ATTR) {
  24854. _this._reportError(TEMPLATE_ATTR_DEPRECATION_WARNING, attr.sourceSpan, ParseErrorLevel.WARNING);
  24855. templateBindingsSource = attr.value;
  24856. }
  24857. else if (normalizedName.startsWith(TEMPLATE_ATTR_PREFIX)) {
  24858. templateBindingsSource = attr.value;
  24859. prefixToken = normalizedName.substring(TEMPLATE_ATTR_PREFIX.length) + ':';
  24860. }
  24861. var /** @type {?} */ hasTemplateBinding = templateBindingsSource != null;
  24862. if (hasTemplateBinding) {
  24863. if (hasInlineTemplates) {
  24864. _this._reportError("Can't have multiple template bindings on one element. Use only one attribute named 'template' or prefixed with *", attr.sourceSpan);
  24865. }
  24866. hasInlineTemplates = true;
  24867. _this._bindingParser.parseInlineTemplateBinding(/** @type {?} */ ((prefixToken)), /** @type {?} */ ((templateBindingsSource)), attr.sourceSpan, templateMatchableAttrs, templateElementOrDirectiveProps, templateElementVars);
  24868. }
  24869. if (!hasBinding && !hasTemplateBinding) {
  24870. // don't include the bindings as attributes as well in the AST
  24871. attrs.push(_this.visitAttribute(attr, null));
  24872. matchableAttrs.push([attr.name, attr.value]);
  24873. }
  24874. });
  24875. var /** @type {?} */ elementCssSelector = createElementCssSelector(nodeName, matchableAttrs);
  24876. var _a = this._parseDirectives(this.selectorMatcher, elementCssSelector), directiveMetas = _a.directives, matchElement = _a.matchElement;
  24877. var /** @type {?} */ references = [];
  24878. var /** @type {?} */ boundDirectivePropNames = new Set();
  24879. var /** @type {?} */ directiveAsts = this._createDirectiveAsts(isTemplateElement, element.name, directiveMetas, elementOrDirectiveProps, elementOrDirectiveRefs, /** @type {?} */ ((element.sourceSpan)), references, boundDirectivePropNames);
  24880. var /** @type {?} */ elementProps = this._createElementPropertyAsts(element.name, elementOrDirectiveProps, boundDirectivePropNames);
  24881. var /** @type {?} */ isViewRoot = parent.isTemplateElement || hasInlineTemplates;
  24882. var /** @type {?} */ providerContext = new ProviderElementContext(this.providerViewContext, /** @type {?} */ ((parent.providerContext)), isViewRoot, directiveAsts, attrs, references, isTemplateElement, queryStartIndex, /** @type {?} */ ((element.sourceSpan)));
  24883. var /** @type {?} */ children = visitAll(preparsedElement.nonBindable ? NON_BINDABLE_VISITOR : this, element.children, ElementContext.create(isTemplateElement, directiveAsts, isTemplateElement ? /** @type {?} */ ((parent.providerContext)) : providerContext));
  24884. providerContext.afterElement();
  24885. // Override the actual selector when the `ngProjectAs` attribute is provided
  24886. var /** @type {?} */ projectionSelector = preparsedElement.projectAs != null ?
  24887. CssSelector.parse(preparsedElement.projectAs)[0] :
  24888. elementCssSelector;
  24889. var /** @type {?} */ ngContentIndex = /** @type {?} */ ((parent.findNgContentIndex(projectionSelector)));
  24890. var /** @type {?} */ parsedElement;
  24891. if (preparsedElement.type === PreparsedElementType.NG_CONTENT) {
  24892. if (element.children && !element.children.every(_isEmptyTextNode)) {
  24893. this._reportError("<ng-content> element cannot have content.", /** @type {?} */ ((element.sourceSpan)));
  24894. }
  24895. parsedElement = new NgContentAst(this.ngContentCount++, hasInlineTemplates ? /** @type {?} */ ((null)) : ngContentIndex, /** @type {?} */ ((element.sourceSpan)));
  24896. }
  24897. else if (isTemplateElement) {
  24898. this._assertAllEventsPublishedByDirectives(directiveAsts, events);
  24899. this._assertNoComponentsNorElementBindingsOnTemplate(directiveAsts, elementProps, /** @type {?} */ ((element.sourceSpan)));
  24900. parsedElement = new EmbeddedTemplateAst(attrs, events, references, elementVars, providerContext.transformedDirectiveAsts, providerContext.transformProviders, providerContext.transformedHasViewContainer, providerContext.queryMatches, children, hasInlineTemplates ? /** @type {?} */ ((null)) : ngContentIndex, /** @type {?} */ ((element.sourceSpan)));
  24901. }
  24902. else {
  24903. this._assertElementExists(matchElement, element);
  24904. this._assertOnlyOneComponent(directiveAsts, /** @type {?} */ ((element.sourceSpan)));
  24905. var /** @type {?} */ ngContentIndex_1 = hasInlineTemplates ? null : parent.findNgContentIndex(projectionSelector);
  24906. 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);
  24907. }
  24908. if (hasInlineTemplates) {
  24909. var /** @type {?} */ templateQueryStartIndex = this.contentQueryStartId;
  24910. var /** @type {?} */ templateSelector = createElementCssSelector(TEMPLATE_ELEMENT, templateMatchableAttrs);
  24911. var templateDirectiveMetas = this._parseDirectives(this.selectorMatcher, templateSelector).directives;
  24912. var /** @type {?} */ templateBoundDirectivePropNames = new Set();
  24913. var /** @type {?} */ templateDirectiveAsts = this._createDirectiveAsts(true, element.name, templateDirectiveMetas, templateElementOrDirectiveProps, [], /** @type {?} */ ((element.sourceSpan)), [], templateBoundDirectivePropNames);
  24914. var /** @type {?} */ templateElementProps = this._createElementPropertyAsts(element.name, templateElementOrDirectiveProps, templateBoundDirectivePropNames);
  24915. this._assertNoComponentsNorElementBindingsOnTemplate(templateDirectiveAsts, templateElementProps, /** @type {?} */ ((element.sourceSpan)));
  24916. var /** @type {?} */ templateProviderContext = new ProviderElementContext(this.providerViewContext, /** @type {?} */ ((parent.providerContext)), parent.isTemplateElement, templateDirectiveAsts, [], [], true, templateQueryStartIndex, /** @type {?} */ ((element.sourceSpan)));
  24917. templateProviderContext.afterElement();
  24918. parsedElement = new EmbeddedTemplateAst([], [], [], templateElementVars, templateProviderContext.transformedDirectiveAsts, templateProviderContext.transformProviders, templateProviderContext.transformedHasViewContainer, templateProviderContext.queryMatches, [parsedElement], ngContentIndex, /** @type {?} */ ((element.sourceSpan)));
  24919. }
  24920. return parsedElement;
  24921. };
  24922. /**
  24923. * @param {?} isTemplateElement
  24924. * @param {?} attr
  24925. * @param {?} targetMatchableAttrs
  24926. * @param {?} targetProps
  24927. * @param {?} targetEvents
  24928. * @param {?} targetRefs
  24929. * @param {?} targetVars
  24930. * @return {?}
  24931. */
  24932. TemplateParseVisitor.prototype._parseAttr = /**
  24933. * @param {?} isTemplateElement
  24934. * @param {?} attr
  24935. * @param {?} targetMatchableAttrs
  24936. * @param {?} targetProps
  24937. * @param {?} targetEvents
  24938. * @param {?} targetRefs
  24939. * @param {?} targetVars
  24940. * @return {?}
  24941. */
  24942. function (isTemplateElement, attr, targetMatchableAttrs, targetProps, targetEvents, targetRefs, targetVars) {
  24943. var /** @type {?} */ name = this._normalizeAttributeName(attr.name);
  24944. var /** @type {?} */ value = attr.value;
  24945. var /** @type {?} */ srcSpan = attr.sourceSpan;
  24946. var /** @type {?} */ bindParts = name.match(BIND_NAME_REGEXP);
  24947. var /** @type {?} */ hasBinding = false;
  24948. if (bindParts !== null) {
  24949. hasBinding = true;
  24950. if (bindParts[KW_BIND_IDX] != null) {
  24951. this._bindingParser.parsePropertyBinding(bindParts[IDENT_KW_IDX], value, false, srcSpan, targetMatchableAttrs, targetProps);
  24952. }
  24953. else if (bindParts[KW_LET_IDX]) {
  24954. if (isTemplateElement) {
  24955. var /** @type {?} */ identifier = bindParts[IDENT_KW_IDX];
  24956. this._parseVariable(identifier, value, srcSpan, targetVars);
  24957. }
  24958. else {
  24959. this._reportError("\"let-\" is only supported on ng-template elements.", srcSpan);
  24960. }
  24961. }
  24962. else if (bindParts[KW_REF_IDX]) {
  24963. var /** @type {?} */ identifier = bindParts[IDENT_KW_IDX];
  24964. this._parseReference(identifier, value, srcSpan, targetRefs);
  24965. }
  24966. else if (bindParts[KW_ON_IDX]) {
  24967. this._bindingParser.parseEvent(bindParts[IDENT_KW_IDX], value, srcSpan, targetMatchableAttrs, targetEvents);
  24968. }
  24969. else if (bindParts[KW_BINDON_IDX]) {
  24970. this._bindingParser.parsePropertyBinding(bindParts[IDENT_KW_IDX], value, false, srcSpan, targetMatchableAttrs, targetProps);
  24971. this._parseAssignmentEvent(bindParts[IDENT_KW_IDX], value, srcSpan, targetMatchableAttrs, targetEvents);
  24972. }
  24973. else if (bindParts[KW_AT_IDX]) {
  24974. this._bindingParser.parseLiteralAttr(name, value, srcSpan, targetMatchableAttrs, targetProps);
  24975. }
  24976. else if (bindParts[IDENT_BANANA_BOX_IDX]) {
  24977. this._bindingParser.parsePropertyBinding(bindParts[IDENT_BANANA_BOX_IDX], value, false, srcSpan, targetMatchableAttrs, targetProps);
  24978. this._parseAssignmentEvent(bindParts[IDENT_BANANA_BOX_IDX], value, srcSpan, targetMatchableAttrs, targetEvents);
  24979. }
  24980. else if (bindParts[IDENT_PROPERTY_IDX]) {
  24981. this._bindingParser.parsePropertyBinding(bindParts[IDENT_PROPERTY_IDX], value, false, srcSpan, targetMatchableAttrs, targetProps);
  24982. }
  24983. else if (bindParts[IDENT_EVENT_IDX]) {
  24984. this._bindingParser.parseEvent(bindParts[IDENT_EVENT_IDX], value, srcSpan, targetMatchableAttrs, targetEvents);
  24985. }
  24986. }
  24987. else {
  24988. hasBinding = this._bindingParser.parsePropertyInterpolation(name, value, srcSpan, targetMatchableAttrs, targetProps);
  24989. }
  24990. if (!hasBinding) {
  24991. this._bindingParser.parseLiteralAttr(name, value, srcSpan, targetMatchableAttrs, targetProps);
  24992. }
  24993. return hasBinding;
  24994. };
  24995. /**
  24996. * @param {?} attrName
  24997. * @return {?}
  24998. */
  24999. TemplateParseVisitor.prototype._normalizeAttributeName = /**
  25000. * @param {?} attrName
  25001. * @return {?}
  25002. */
  25003. function (attrName) {
  25004. return /^data-/i.test(attrName) ? attrName.substring(5) : attrName;
  25005. };
  25006. /**
  25007. * @param {?} identifier
  25008. * @param {?} value
  25009. * @param {?} sourceSpan
  25010. * @param {?} targetVars
  25011. * @return {?}
  25012. */
  25013. TemplateParseVisitor.prototype._parseVariable = /**
  25014. * @param {?} identifier
  25015. * @param {?} value
  25016. * @param {?} sourceSpan
  25017. * @param {?} targetVars
  25018. * @return {?}
  25019. */
  25020. function (identifier, value, sourceSpan, targetVars) {
  25021. if (identifier.indexOf('-') > -1) {
  25022. this._reportError("\"-\" is not allowed in variable names", sourceSpan);
  25023. }
  25024. targetVars.push(new VariableAst(identifier, value, sourceSpan));
  25025. };
  25026. /**
  25027. * @param {?} identifier
  25028. * @param {?} value
  25029. * @param {?} sourceSpan
  25030. * @param {?} targetRefs
  25031. * @return {?}
  25032. */
  25033. TemplateParseVisitor.prototype._parseReference = /**
  25034. * @param {?} identifier
  25035. * @param {?} value
  25036. * @param {?} sourceSpan
  25037. * @param {?} targetRefs
  25038. * @return {?}
  25039. */
  25040. function (identifier, value, sourceSpan, targetRefs) {
  25041. if (identifier.indexOf('-') > -1) {
  25042. this._reportError("\"-\" is not allowed in reference names", sourceSpan);
  25043. }
  25044. targetRefs.push(new ElementOrDirectiveRef(identifier, value, sourceSpan));
  25045. };
  25046. /**
  25047. * @param {?} name
  25048. * @param {?} expression
  25049. * @param {?} sourceSpan
  25050. * @param {?} targetMatchableAttrs
  25051. * @param {?} targetEvents
  25052. * @return {?}
  25053. */
  25054. TemplateParseVisitor.prototype._parseAssignmentEvent = /**
  25055. * @param {?} name
  25056. * @param {?} expression
  25057. * @param {?} sourceSpan
  25058. * @param {?} targetMatchableAttrs
  25059. * @param {?} targetEvents
  25060. * @return {?}
  25061. */
  25062. function (name, expression, sourceSpan, targetMatchableAttrs, targetEvents) {
  25063. this._bindingParser.parseEvent(name + "Change", expression + "=$event", sourceSpan, targetMatchableAttrs, targetEvents);
  25064. };
  25065. /**
  25066. * @param {?} selectorMatcher
  25067. * @param {?} elementCssSelector
  25068. * @return {?}
  25069. */
  25070. TemplateParseVisitor.prototype._parseDirectives = /**
  25071. * @param {?} selectorMatcher
  25072. * @param {?} elementCssSelector
  25073. * @return {?}
  25074. */
  25075. function (selectorMatcher, elementCssSelector) {
  25076. var _this = this;
  25077. // Need to sort the directives so that we get consistent results throughout,
  25078. // as selectorMatcher uses Maps inside.
  25079. // Also deduplicate directives as they might match more than one time!
  25080. var /** @type {?} */ directives = new Array(this.directivesIndex.size);
  25081. // Whether any directive selector matches on the element name
  25082. var /** @type {?} */ matchElement = false;
  25083. selectorMatcher.match(elementCssSelector, function (selector, directive) {
  25084. directives[/** @type {?} */ ((_this.directivesIndex.get(directive)))] = directive;
  25085. matchElement = matchElement || selector.hasElementSelector();
  25086. });
  25087. return {
  25088. directives: directives.filter(function (dir) { return !!dir; }),
  25089. matchElement: matchElement,
  25090. };
  25091. };
  25092. /**
  25093. * @param {?} isTemplateElement
  25094. * @param {?} elementName
  25095. * @param {?} directives
  25096. * @param {?} props
  25097. * @param {?} elementOrDirectiveRefs
  25098. * @param {?} elementSourceSpan
  25099. * @param {?} targetReferences
  25100. * @param {?} targetBoundDirectivePropNames
  25101. * @return {?}
  25102. */
  25103. TemplateParseVisitor.prototype._createDirectiveAsts = /**
  25104. * @param {?} isTemplateElement
  25105. * @param {?} elementName
  25106. * @param {?} directives
  25107. * @param {?} props
  25108. * @param {?} elementOrDirectiveRefs
  25109. * @param {?} elementSourceSpan
  25110. * @param {?} targetReferences
  25111. * @param {?} targetBoundDirectivePropNames
  25112. * @return {?}
  25113. */
  25114. function (isTemplateElement, elementName, directives, props, elementOrDirectiveRefs, elementSourceSpan, targetReferences, targetBoundDirectivePropNames) {
  25115. var _this = this;
  25116. var /** @type {?} */ matchedReferences = new Set();
  25117. var /** @type {?} */ component = /** @type {?} */ ((null));
  25118. var /** @type {?} */ directiveAsts = directives.map(function (directive) {
  25119. var /** @type {?} */ sourceSpan = new ParseSourceSpan(elementSourceSpan.start, elementSourceSpan.end, "Directive " + identifierName(directive.type));
  25120. if (directive.isComponent) {
  25121. component = directive;
  25122. }
  25123. var /** @type {?} */ directiveProperties = [];
  25124. var /** @type {?} */ hostProperties = /** @type {?} */ ((_this._bindingParser.createDirectiveHostPropertyAsts(directive, elementName, sourceSpan)));
  25125. // Note: We need to check the host properties here as well,
  25126. // as we don't know the element name in the DirectiveWrapperCompiler yet.
  25127. hostProperties = _this._checkPropertiesInSchema(elementName, hostProperties);
  25128. var /** @type {?} */ hostEvents = /** @type {?} */ ((_this._bindingParser.createDirectiveHostEventAsts(directive, sourceSpan)));
  25129. _this._createDirectivePropertyAsts(directive.inputs, props, directiveProperties, targetBoundDirectivePropNames);
  25130. elementOrDirectiveRefs.forEach(function (elOrDirRef) {
  25131. if ((elOrDirRef.value.length === 0 && directive.isComponent) ||
  25132. (elOrDirRef.isReferenceToDirective(directive))) {
  25133. targetReferences.push(new ReferenceAst(elOrDirRef.name, createTokenForReference(directive.type.reference), elOrDirRef.sourceSpan));
  25134. matchedReferences.add(elOrDirRef.name);
  25135. }
  25136. });
  25137. var /** @type {?} */ contentQueryStartId = _this.contentQueryStartId;
  25138. _this.contentQueryStartId += directive.queries.length;
  25139. return new DirectiveAst(directive, directiveProperties, hostProperties, hostEvents, contentQueryStartId, sourceSpan);
  25140. });
  25141. elementOrDirectiveRefs.forEach(function (elOrDirRef) {
  25142. if (elOrDirRef.value.length > 0) {
  25143. if (!matchedReferences.has(elOrDirRef.name)) {
  25144. _this._reportError("There is no directive with \"exportAs\" set to \"" + elOrDirRef.value + "\"", elOrDirRef.sourceSpan);
  25145. }
  25146. }
  25147. else if (!component) {
  25148. var /** @type {?} */ refToken = /** @type {?} */ ((null));
  25149. if (isTemplateElement) {
  25150. refToken = createTokenForExternalReference(_this.reflector, Identifiers.TemplateRef);
  25151. }
  25152. targetReferences.push(new ReferenceAst(elOrDirRef.name, refToken, elOrDirRef.sourceSpan));
  25153. }
  25154. });
  25155. return directiveAsts;
  25156. };
  25157. /**
  25158. * @param {?} directiveProperties
  25159. * @param {?} boundProps
  25160. * @param {?} targetBoundDirectiveProps
  25161. * @param {?} targetBoundDirectivePropNames
  25162. * @return {?}
  25163. */
  25164. TemplateParseVisitor.prototype._createDirectivePropertyAsts = /**
  25165. * @param {?} directiveProperties
  25166. * @param {?} boundProps
  25167. * @param {?} targetBoundDirectiveProps
  25168. * @param {?} targetBoundDirectivePropNames
  25169. * @return {?}
  25170. */
  25171. function (directiveProperties, boundProps, targetBoundDirectiveProps, targetBoundDirectivePropNames) {
  25172. if (directiveProperties) {
  25173. var /** @type {?} */ boundPropsByName_1 = new Map();
  25174. boundProps.forEach(function (boundProp) {
  25175. var /** @type {?} */ prevValue = boundPropsByName_1.get(boundProp.name);
  25176. if (!prevValue || prevValue.isLiteral) {
  25177. // give [a]="b" a higher precedence than a="b" on the same element
  25178. // give [a]="b" a higher precedence than a="b" on the same element
  25179. boundPropsByName_1.set(boundProp.name, boundProp);
  25180. }
  25181. });
  25182. Object.keys(directiveProperties).forEach(function (dirProp) {
  25183. var /** @type {?} */ elProp = directiveProperties[dirProp];
  25184. var /** @type {?} */ boundProp = boundPropsByName_1.get(elProp);
  25185. // Bindings are optional, so this binding only needs to be set up if an expression is given.
  25186. if (boundProp) {
  25187. targetBoundDirectivePropNames.add(boundProp.name);
  25188. if (!isEmptyExpression(boundProp.expression)) {
  25189. targetBoundDirectiveProps.push(new BoundDirectivePropertyAst(dirProp, boundProp.name, boundProp.expression, boundProp.sourceSpan));
  25190. }
  25191. }
  25192. });
  25193. }
  25194. };
  25195. /**
  25196. * @param {?} elementName
  25197. * @param {?} props
  25198. * @param {?} boundDirectivePropNames
  25199. * @return {?}
  25200. */
  25201. TemplateParseVisitor.prototype._createElementPropertyAsts = /**
  25202. * @param {?} elementName
  25203. * @param {?} props
  25204. * @param {?} boundDirectivePropNames
  25205. * @return {?}
  25206. */
  25207. function (elementName, props, boundDirectivePropNames) {
  25208. var _this = this;
  25209. var /** @type {?} */ boundElementProps = [];
  25210. props.forEach(function (prop) {
  25211. if (!prop.isLiteral && !boundDirectivePropNames.has(prop.name)) {
  25212. boundElementProps.push(_this._bindingParser.createElementPropertyAst(elementName, prop));
  25213. }
  25214. });
  25215. return this._checkPropertiesInSchema(elementName, boundElementProps);
  25216. };
  25217. /**
  25218. * @param {?} directives
  25219. * @return {?}
  25220. */
  25221. TemplateParseVisitor.prototype._findComponentDirectives = /**
  25222. * @param {?} directives
  25223. * @return {?}
  25224. */
  25225. function (directives) {
  25226. return directives.filter(function (directive) { return directive.directive.isComponent; });
  25227. };
  25228. /**
  25229. * @param {?} directives
  25230. * @return {?}
  25231. */
  25232. TemplateParseVisitor.prototype._findComponentDirectiveNames = /**
  25233. * @param {?} directives
  25234. * @return {?}
  25235. */
  25236. function (directives) {
  25237. return this._findComponentDirectives(directives)
  25238. .map(function (directive) { return ((identifierName(directive.directive.type))); });
  25239. };
  25240. /**
  25241. * @param {?} directives
  25242. * @param {?} sourceSpan
  25243. * @return {?}
  25244. */
  25245. TemplateParseVisitor.prototype._assertOnlyOneComponent = /**
  25246. * @param {?} directives
  25247. * @param {?} sourceSpan
  25248. * @return {?}
  25249. */
  25250. function (directives, sourceSpan) {
  25251. var /** @type {?} */ componentTypeNames = this._findComponentDirectiveNames(directives);
  25252. if (componentTypeNames.length > 1) {
  25253. this._reportError("More than one component matched on this element.\n" +
  25254. "Make sure that only one component's selector can match a given element.\n" +
  25255. ("Conflicting components: " + componentTypeNames.join(',')), sourceSpan);
  25256. }
  25257. };
  25258. /**
  25259. * Make sure that non-angular tags conform to the schemas.
  25260. *
  25261. * Note: An element is considered an angular tag when at least one directive selector matches the
  25262. * tag name.
  25263. *
  25264. * @param {?} matchElement Whether any directive has matched on the tag name
  25265. * @param {?} element the html element
  25266. * @return {?}
  25267. */
  25268. TemplateParseVisitor.prototype._assertElementExists = /**
  25269. * Make sure that non-angular tags conform to the schemas.
  25270. *
  25271. * Note: An element is considered an angular tag when at least one directive selector matches the
  25272. * tag name.
  25273. *
  25274. * @param {?} matchElement Whether any directive has matched on the tag name
  25275. * @param {?} element the html element
  25276. * @return {?}
  25277. */
  25278. function (matchElement, element) {
  25279. var /** @type {?} */ elName = element.name.replace(/^:xhtml:/, '');
  25280. if (!matchElement && !this._schemaRegistry.hasElement(elName, this._schemas)) {
  25281. var /** @type {?} */ errorMsg = "'" + elName + "' is not a known element:\n";
  25282. errorMsg +=
  25283. "1. If '" + elName + "' is an Angular component, then verify that it is part of this module.\n";
  25284. if (elName.indexOf('-') > -1) {
  25285. errorMsg +=
  25286. "2. If '" + elName + "' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.";
  25287. }
  25288. else {
  25289. errorMsg +=
  25290. "2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.";
  25291. }
  25292. this._reportError(errorMsg, /** @type {?} */ ((element.sourceSpan)));
  25293. }
  25294. };
  25295. /**
  25296. * @param {?} directives
  25297. * @param {?} elementProps
  25298. * @param {?} sourceSpan
  25299. * @return {?}
  25300. */
  25301. TemplateParseVisitor.prototype._assertNoComponentsNorElementBindingsOnTemplate = /**
  25302. * @param {?} directives
  25303. * @param {?} elementProps
  25304. * @param {?} sourceSpan
  25305. * @return {?}
  25306. */
  25307. function (directives, elementProps, sourceSpan) {
  25308. var _this = this;
  25309. var /** @type {?} */ componentTypeNames = this._findComponentDirectiveNames(directives);
  25310. if (componentTypeNames.length > 0) {
  25311. this._reportError("Components on an embedded template: " + componentTypeNames.join(','), sourceSpan);
  25312. }
  25313. elementProps.forEach(function (prop) {
  25314. _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);
  25315. });
  25316. };
  25317. /**
  25318. * @param {?} directives
  25319. * @param {?} events
  25320. * @return {?}
  25321. */
  25322. TemplateParseVisitor.prototype._assertAllEventsPublishedByDirectives = /**
  25323. * @param {?} directives
  25324. * @param {?} events
  25325. * @return {?}
  25326. */
  25327. function (directives, events) {
  25328. var _this = this;
  25329. var /** @type {?} */ allDirectiveEvents = new Set();
  25330. directives.forEach(function (directive) {
  25331. Object.keys(directive.directive.outputs).forEach(function (k) {
  25332. var /** @type {?} */ eventName = directive.directive.outputs[k];
  25333. allDirectiveEvents.add(eventName);
  25334. });
  25335. });
  25336. events.forEach(function (event) {
  25337. if (event.target != null || !allDirectiveEvents.has(event.name)) {
  25338. _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);
  25339. }
  25340. });
  25341. };
  25342. /**
  25343. * @param {?} elementName
  25344. * @param {?} boundProps
  25345. * @return {?}
  25346. */
  25347. TemplateParseVisitor.prototype._checkPropertiesInSchema = /**
  25348. * @param {?} elementName
  25349. * @param {?} boundProps
  25350. * @return {?}
  25351. */
  25352. function (elementName, boundProps) {
  25353. var _this = this;
  25354. // Note: We can't filter out empty expressions before this method,
  25355. // as we still want to validate them!
  25356. return boundProps.filter(function (boundProp) {
  25357. if (boundProp.type === PropertyBindingType.Property &&
  25358. !_this._schemaRegistry.hasProperty(elementName, boundProp.name, _this._schemas)) {
  25359. var /** @type {?} */ errorMsg = "Can't bind to '" + boundProp.name + "' since it isn't a known property of '" + elementName + "'.";
  25360. if (elementName.startsWith('ng-')) {
  25361. errorMsg +=
  25362. "\n1. If '" + boundProp.name + "' is an Angular directive, then add 'CommonModule' to the '@NgModule.imports' of this component." +
  25363. "\n2. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.";
  25364. }
  25365. else if (elementName.indexOf('-') > -1) {
  25366. errorMsg +=
  25367. "\n1. If '" + elementName + "' is an Angular component and it has '" + boundProp.name + "' input, then verify that it is part of this module." +
  25368. ("\n2. If '" + elementName + "' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.") +
  25369. "\n3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.";
  25370. }
  25371. _this._reportError(errorMsg, boundProp.sourceSpan);
  25372. }
  25373. return !isEmptyExpression(boundProp.value);
  25374. });
  25375. };
  25376. /**
  25377. * @param {?} message
  25378. * @param {?} sourceSpan
  25379. * @param {?=} level
  25380. * @return {?}
  25381. */
  25382. TemplateParseVisitor.prototype._reportError = /**
  25383. * @param {?} message
  25384. * @param {?} sourceSpan
  25385. * @param {?=} level
  25386. * @return {?}
  25387. */
  25388. function (message, sourceSpan, level) {
  25389. if (level === void 0) { level = ParseErrorLevel.ERROR; }
  25390. this._targetErrors.push(new ParseError(sourceSpan, message, level));
  25391. };
  25392. return TemplateParseVisitor;
  25393. }());
  25394. var NonBindableVisitor = /** @class */ (function () {
  25395. function NonBindableVisitor() {
  25396. }
  25397. /**
  25398. * @param {?} ast
  25399. * @param {?} parent
  25400. * @return {?}
  25401. */
  25402. NonBindableVisitor.prototype.visitElement = /**
  25403. * @param {?} ast
  25404. * @param {?} parent
  25405. * @return {?}
  25406. */
  25407. function (ast, parent) {
  25408. var /** @type {?} */ preparsedElement = preparseElement(ast);
  25409. if (preparsedElement.type === PreparsedElementType.SCRIPT ||
  25410. preparsedElement.type === PreparsedElementType.STYLE ||
  25411. preparsedElement.type === PreparsedElementType.STYLESHEET) {
  25412. // Skipping <script> for security reasons
  25413. // Skipping <style> and stylesheets as we already processed them
  25414. // in the StyleCompiler
  25415. return null;
  25416. }
  25417. var /** @type {?} */ attrNameAndValues = ast.attrs.map(function (attr) { return [attr.name, attr.value]; });
  25418. var /** @type {?} */ selector = createElementCssSelector(ast.name, attrNameAndValues);
  25419. var /** @type {?} */ ngContentIndex = parent.findNgContentIndex(selector);
  25420. var /** @type {?} */ children = visitAll(this, ast.children, EMPTY_ELEMENT_CONTEXT);
  25421. return new ElementAst(ast.name, visitAll(this, ast.attrs), [], [], [], [], [], false, [], children, ngContentIndex, ast.sourceSpan, ast.endSourceSpan);
  25422. };
  25423. /**
  25424. * @param {?} comment
  25425. * @param {?} context
  25426. * @return {?}
  25427. */
  25428. NonBindableVisitor.prototype.visitComment = /**
  25429. * @param {?} comment
  25430. * @param {?} context
  25431. * @return {?}
  25432. */
  25433. function (comment, context) { return null; };
  25434. /**
  25435. * @param {?} attribute
  25436. * @param {?} context
  25437. * @return {?}
  25438. */
  25439. NonBindableVisitor.prototype.visitAttribute = /**
  25440. * @param {?} attribute
  25441. * @param {?} context
  25442. * @return {?}
  25443. */
  25444. function (attribute, context) {
  25445. return new AttrAst(attribute.name, attribute.value, attribute.sourceSpan);
  25446. };
  25447. /**
  25448. * @param {?} text
  25449. * @param {?} parent
  25450. * @return {?}
  25451. */
  25452. NonBindableVisitor.prototype.visitText = /**
  25453. * @param {?} text
  25454. * @param {?} parent
  25455. * @return {?}
  25456. */
  25457. function (text, parent) {
  25458. var /** @type {?} */ ngContentIndex = /** @type {?} */ ((parent.findNgContentIndex(TEXT_CSS_SELECTOR)));
  25459. return new TextAst(text.value, ngContentIndex, /** @type {?} */ ((text.sourceSpan)));
  25460. };
  25461. /**
  25462. * @param {?} expansion
  25463. * @param {?} context
  25464. * @return {?}
  25465. */
  25466. NonBindableVisitor.prototype.visitExpansion = /**
  25467. * @param {?} expansion
  25468. * @param {?} context
  25469. * @return {?}
  25470. */
  25471. function (expansion, context) { return expansion; };
  25472. /**
  25473. * @param {?} expansionCase
  25474. * @param {?} context
  25475. * @return {?}
  25476. */
  25477. NonBindableVisitor.prototype.visitExpansionCase = /**
  25478. * @param {?} expansionCase
  25479. * @param {?} context
  25480. * @return {?}
  25481. */
  25482. function (expansionCase, context) { return expansionCase; };
  25483. return NonBindableVisitor;
  25484. }());
  25485. /**
  25486. * A reference to an element or directive in a template. E.g., the reference in this template:
  25487. *
  25488. * <div #myMenu="coolMenu">
  25489. *
  25490. * would be {name: 'myMenu', value: 'coolMenu', sourceSpan: ...}
  25491. */
  25492. var ElementOrDirectiveRef = /** @class */ (function () {
  25493. function ElementOrDirectiveRef(name, value, sourceSpan) {
  25494. this.name = name;
  25495. this.value = value;
  25496. this.sourceSpan = sourceSpan;
  25497. }
  25498. /** Gets whether this is a reference to the given directive. */
  25499. /**
  25500. * Gets whether this is a reference to the given directive.
  25501. * @param {?} directive
  25502. * @return {?}
  25503. */
  25504. ElementOrDirectiveRef.prototype.isReferenceToDirective = /**
  25505. * Gets whether this is a reference to the given directive.
  25506. * @param {?} directive
  25507. * @return {?}
  25508. */
  25509. function (directive) {
  25510. return splitExportAs(directive.exportAs).indexOf(this.value) !== -1;
  25511. };
  25512. return ElementOrDirectiveRef;
  25513. }());
  25514. /**
  25515. * Splits a raw, potentially comma-delimted `exportAs` value into an array of names.
  25516. * @param {?} exportAs
  25517. * @return {?}
  25518. */
  25519. function splitExportAs(exportAs) {
  25520. return exportAs ? exportAs.split(',').map(function (e) { return e.trim(); }) : [];
  25521. }
  25522. /**
  25523. * @param {?} classAttrValue
  25524. * @return {?}
  25525. */
  25526. function splitClasses(classAttrValue) {
  25527. return classAttrValue.trim().split(/\s+/g);
  25528. }
  25529. var ElementContext = /** @class */ (function () {
  25530. function ElementContext(isTemplateElement, _ngContentIndexMatcher, _wildcardNgContentIndex, providerContext) {
  25531. this.isTemplateElement = isTemplateElement;
  25532. this._ngContentIndexMatcher = _ngContentIndexMatcher;
  25533. this._wildcardNgContentIndex = _wildcardNgContentIndex;
  25534. this.providerContext = providerContext;
  25535. }
  25536. /**
  25537. * @param {?} isTemplateElement
  25538. * @param {?} directives
  25539. * @param {?} providerContext
  25540. * @return {?}
  25541. */
  25542. ElementContext.create = /**
  25543. * @param {?} isTemplateElement
  25544. * @param {?} directives
  25545. * @param {?} providerContext
  25546. * @return {?}
  25547. */
  25548. function (isTemplateElement, directives, providerContext) {
  25549. var /** @type {?} */ matcher = new SelectorMatcher();
  25550. var /** @type {?} */ wildcardNgContentIndex = /** @type {?} */ ((null));
  25551. var /** @type {?} */ component = directives.find(function (directive) { return directive.directive.isComponent; });
  25552. if (component) {
  25553. var /** @type {?} */ ngContentSelectors = /** @type {?} */ ((component.directive.template)).ngContentSelectors;
  25554. for (var /** @type {?} */ i = 0; i < ngContentSelectors.length; i++) {
  25555. var /** @type {?} */ selector = ngContentSelectors[i];
  25556. if (selector === '*') {
  25557. wildcardNgContentIndex = i;
  25558. }
  25559. else {
  25560. matcher.addSelectables(CssSelector.parse(ngContentSelectors[i]), i);
  25561. }
  25562. }
  25563. }
  25564. return new ElementContext(isTemplateElement, matcher, wildcardNgContentIndex, providerContext);
  25565. };
  25566. /**
  25567. * @param {?} selector
  25568. * @return {?}
  25569. */
  25570. ElementContext.prototype.findNgContentIndex = /**
  25571. * @param {?} selector
  25572. * @return {?}
  25573. */
  25574. function (selector) {
  25575. var /** @type {?} */ ngContentIndices = [];
  25576. this._ngContentIndexMatcher.match(selector, function (selector, ngContentIndex) { ngContentIndices.push(ngContentIndex); });
  25577. ngContentIndices.sort();
  25578. if (this._wildcardNgContentIndex != null) {
  25579. ngContentIndices.push(this._wildcardNgContentIndex);
  25580. }
  25581. return ngContentIndices.length > 0 ? ngContentIndices[0] : null;
  25582. };
  25583. return ElementContext;
  25584. }());
  25585. /**
  25586. * @param {?} elementName
  25587. * @param {?} attributes
  25588. * @return {?}
  25589. */
  25590. function createElementCssSelector(elementName, attributes) {
  25591. var /** @type {?} */ cssSelector = new CssSelector();
  25592. var /** @type {?} */ elNameNoNs = splitNsName(elementName)[1];
  25593. cssSelector.setElement(elNameNoNs);
  25594. for (var /** @type {?} */ i = 0; i < attributes.length; i++) {
  25595. var /** @type {?} */ attrName = attributes[i][0];
  25596. var /** @type {?} */ attrNameNoNs = splitNsName(attrName)[1];
  25597. var /** @type {?} */ attrValue = attributes[i][1];
  25598. cssSelector.addAttribute(attrNameNoNs, attrValue);
  25599. if (attrName.toLowerCase() == CLASS_ATTR) {
  25600. var /** @type {?} */ classes = splitClasses(attrValue);
  25601. classes.forEach(function (className) { return cssSelector.addClassName(className); });
  25602. }
  25603. }
  25604. return cssSelector;
  25605. }
  25606. var EMPTY_ELEMENT_CONTEXT = new ElementContext(true, new SelectorMatcher(), null, null);
  25607. var NON_BINDABLE_VISITOR = new NonBindableVisitor();
  25608. /**
  25609. * @param {?} node
  25610. * @return {?}
  25611. */
  25612. function _isEmptyTextNode(node) {
  25613. return node instanceof Text && node.value.trim().length == 0;
  25614. }
  25615. /**
  25616. * @template T
  25617. * @param {?} items
  25618. * @return {?}
  25619. */
  25620. function removeSummaryDuplicates(items) {
  25621. var /** @type {?} */ map = new Map();
  25622. items.forEach(function (item) {
  25623. if (!map.get(item.type.reference)) {
  25624. map.set(item.type.reference, item);
  25625. }
  25626. });
  25627. return Array.from(map.values());
  25628. }
  25629. /**
  25630. * @param {?} ast
  25631. * @return {?}
  25632. */
  25633. function isEmptyExpression(ast) {
  25634. if (ast instanceof ASTWithSource) {
  25635. ast = ast.ast;
  25636. }
  25637. return ast instanceof EmptyExpr;
  25638. }
  25639. /**
  25640. * @param {?} el
  25641. * @param {?} enableLegacyTemplate
  25642. * @param {?} reportDeprecation
  25643. * @return {?}
  25644. */
  25645. function isTemplate(el, enableLegacyTemplate, reportDeprecation) {
  25646. if (isNgTemplate(el.name))
  25647. return true;
  25648. var /** @type {?} */ tagNoNs = splitNsName(el.name)[1];
  25649. // `<template>` is HTML and case insensitive
  25650. if (tagNoNs.toLowerCase() === TEMPLATE_ELEMENT) {
  25651. if (enableLegacyTemplate && tagNoNs.toLowerCase() === TEMPLATE_ELEMENT) {
  25652. reportDeprecation(TEMPLATE_ELEMENT_DEPRECATION_WARNING, /** @type {?} */ ((el.sourceSpan)));
  25653. return true;
  25654. }
  25655. }
  25656. return false;
  25657. }
  25658. /**
  25659. * @fileoverview added by tsickle
  25660. * @suppress {checkTypes} checked by tsc
  25661. */
  25662. /**
  25663. * @license
  25664. * Copyright Google Inc. All Rights Reserved.
  25665. *
  25666. * Use of this source code is governed by an MIT-style license that can be
  25667. * found in the LICENSE file at https://angular.io/license
  25668. */
  25669. var EventHandlerVars = /** @class */ (function () {
  25670. function EventHandlerVars() {
  25671. }
  25672. EventHandlerVars.event = variable('$event');
  25673. return EventHandlerVars;
  25674. }());
  25675. /**
  25676. * @record
  25677. */
  25678. var ConvertActionBindingResult = /** @class */ (function () {
  25679. function ConvertActionBindingResult(stmts, allowDefault) {
  25680. this.stmts = stmts;
  25681. this.allowDefault = allowDefault;
  25682. }
  25683. return ConvertActionBindingResult;
  25684. }());
  25685. /**
  25686. * Converts the given expression AST into an executable output AST, assuming the expression is
  25687. * used in an action binding (e.g. an event handler).
  25688. * @param {?} localResolver
  25689. * @param {?} implicitReceiver
  25690. * @param {?} action
  25691. * @param {?} bindingId
  25692. * @return {?}
  25693. */
  25694. function convertActionBinding(localResolver, implicitReceiver, action, bindingId) {
  25695. if (!localResolver) {
  25696. localResolver = new DefaultLocalResolver();
  25697. }
  25698. var /** @type {?} */ actionWithoutBuiltins = convertPropertyBindingBuiltins({
  25699. createLiteralArrayConverter: function (argCount) {
  25700. // Note: no caching for literal arrays in actions.
  25701. return function (args) { return literalArr(args); };
  25702. },
  25703. createLiteralMapConverter: function (keys) {
  25704. // Note: no caching for literal maps in actions.
  25705. return function (values) {
  25706. var /** @type {?} */ entries = keys.map(function (k, i) {
  25707. return ({
  25708. key: k.key,
  25709. value: values[i],
  25710. quoted: k.quoted,
  25711. });
  25712. });
  25713. return literalMap(entries);
  25714. };
  25715. },
  25716. createPipeConverter: function (name) {
  25717. throw new Error("Illegal State: Actions are not allowed to contain pipes. Pipe: " + name);
  25718. }
  25719. }, action);
  25720. var /** @type {?} */ visitor = new _AstToIrVisitor(localResolver, implicitReceiver, bindingId);
  25721. var /** @type {?} */ actionStmts = [];
  25722. flattenStatements(actionWithoutBuiltins.visit(visitor, _Mode.Statement), actionStmts);
  25723. prependTemporaryDecls(visitor.temporaryCount, bindingId, actionStmts);
  25724. var /** @type {?} */ lastIndex = actionStmts.length - 1;
  25725. var /** @type {?} */ preventDefaultVar = /** @type {?} */ ((null));
  25726. if (lastIndex >= 0) {
  25727. var /** @type {?} */ lastStatement = actionStmts[lastIndex];
  25728. var /** @type {?} */ returnExpr = convertStmtIntoExpression(lastStatement);
  25729. if (returnExpr) {
  25730. // Note: We need to cast the result of the method call to dynamic,
  25731. // as it might be a void method!
  25732. preventDefaultVar = createPreventDefaultVar(bindingId);
  25733. actionStmts[lastIndex] =
  25734. preventDefaultVar.set(returnExpr.cast(DYNAMIC_TYPE).notIdentical(literal(false)))
  25735. .toDeclStmt(null, [StmtModifier.Final]);
  25736. }
  25737. }
  25738. return new ConvertActionBindingResult(actionStmts, preventDefaultVar);
  25739. }
  25740. /**
  25741. * @record
  25742. */
  25743. /**
  25744. * @record
  25745. */
  25746. /**
  25747. * @param {?} converterFactory
  25748. * @param {?} ast
  25749. * @return {?}
  25750. */
  25751. function convertPropertyBindingBuiltins(converterFactory, ast) {
  25752. return convertBuiltins(converterFactory, ast);
  25753. }
  25754. var ConvertPropertyBindingResult = /** @class */ (function () {
  25755. function ConvertPropertyBindingResult(stmts, currValExpr) {
  25756. this.stmts = stmts;
  25757. this.currValExpr = currValExpr;
  25758. }
  25759. return ConvertPropertyBindingResult;
  25760. }());
  25761. /** @enum {number} */
  25762. var BindingForm = {
  25763. // The general form of binding expression, supports all expressions.
  25764. General: 0,
  25765. // Try to generate a simple binding (no temporaries or statements)
  25766. // otherise generate a general binding
  25767. TrySimple: 1,
  25768. };
  25769. BindingForm[BindingForm.General] = "General";
  25770. BindingForm[BindingForm.TrySimple] = "TrySimple";
  25771. /**
  25772. * Converts the given expression AST into an executable output AST, assuming the expression
  25773. * is used in property binding. The expression has to be preprocessed via
  25774. * `convertPropertyBindingBuiltins`.
  25775. * @param {?} localResolver
  25776. * @param {?} implicitReceiver
  25777. * @param {?} expressionWithoutBuiltins
  25778. * @param {?} bindingId
  25779. * @param {?} form
  25780. * @return {?}
  25781. */
  25782. function convertPropertyBinding(localResolver, implicitReceiver, expressionWithoutBuiltins, bindingId, form) {
  25783. if (!localResolver) {
  25784. localResolver = new DefaultLocalResolver();
  25785. }
  25786. var /** @type {?} */ currValExpr = createCurrValueExpr(bindingId);
  25787. var /** @type {?} */ stmts = [];
  25788. var /** @type {?} */ visitor = new _AstToIrVisitor(localResolver, implicitReceiver, bindingId);
  25789. var /** @type {?} */ outputExpr = expressionWithoutBuiltins.visit(visitor, _Mode.Expression);
  25790. if (visitor.temporaryCount) {
  25791. for (var /** @type {?} */ i = 0; i < visitor.temporaryCount; i++) {
  25792. stmts.push(temporaryDeclaration(bindingId, i));
  25793. }
  25794. }
  25795. else if (form == BindingForm.TrySimple) {
  25796. return new ConvertPropertyBindingResult([], outputExpr);
  25797. }
  25798. stmts.push(currValExpr.set(outputExpr).toDeclStmt(DYNAMIC_TYPE, [StmtModifier.Final]));
  25799. return new ConvertPropertyBindingResult(stmts, currValExpr);
  25800. }
  25801. /**
  25802. * @param {?} converterFactory
  25803. * @param {?} ast
  25804. * @return {?}
  25805. */
  25806. function convertBuiltins(converterFactory, ast) {
  25807. var /** @type {?} */ visitor = new _BuiltinAstConverter(converterFactory);
  25808. return ast.visit(visitor);
  25809. }
  25810. /**
  25811. * @param {?} bindingId
  25812. * @param {?} temporaryNumber
  25813. * @return {?}
  25814. */
  25815. function temporaryName(bindingId, temporaryNumber) {
  25816. return "tmp_" + bindingId + "_" + temporaryNumber;
  25817. }
  25818. /**
  25819. * @param {?} bindingId
  25820. * @param {?} temporaryNumber
  25821. * @return {?}
  25822. */
  25823. function temporaryDeclaration(bindingId, temporaryNumber) {
  25824. return new DeclareVarStmt(temporaryName(bindingId, temporaryNumber), NULL_EXPR);
  25825. }
  25826. /**
  25827. * @param {?} temporaryCount
  25828. * @param {?} bindingId
  25829. * @param {?} statements
  25830. * @return {?}
  25831. */
  25832. function prependTemporaryDecls(temporaryCount, bindingId, statements) {
  25833. for (var /** @type {?} */ i = temporaryCount - 1; i >= 0; i--) {
  25834. statements.unshift(temporaryDeclaration(bindingId, i));
  25835. }
  25836. }
  25837. /** @enum {number} */
  25838. var _Mode = {
  25839. Statement: 0,
  25840. Expression: 1,
  25841. };
  25842. _Mode[_Mode.Statement] = "Statement";
  25843. _Mode[_Mode.Expression] = "Expression";
  25844. /**
  25845. * @param {?} mode
  25846. * @param {?} ast
  25847. * @return {?}
  25848. */
  25849. function ensureStatementMode(mode, ast) {
  25850. if (mode !== _Mode.Statement) {
  25851. throw new Error("Expected a statement, but saw " + ast);
  25852. }
  25853. }
  25854. /**
  25855. * @param {?} mode
  25856. * @param {?} ast
  25857. * @return {?}
  25858. */
  25859. function ensureExpressionMode(mode, ast) {
  25860. if (mode !== _Mode.Expression) {
  25861. throw new Error("Expected an expression, but saw " + ast);
  25862. }
  25863. }
  25864. /**
  25865. * @param {?} mode
  25866. * @param {?} expr
  25867. * @return {?}
  25868. */
  25869. function convertToStatementIfNeeded(mode, expr) {
  25870. if (mode === _Mode.Statement) {
  25871. return expr.toStmt();
  25872. }
  25873. else {
  25874. return expr;
  25875. }
  25876. }
  25877. var _BuiltinAstConverter = /** @class */ (function (_super) {
  25878. __extends(_BuiltinAstConverter, _super);
  25879. function _BuiltinAstConverter(_converterFactory) {
  25880. var _this = _super.call(this) || this;
  25881. _this._converterFactory = _converterFactory;
  25882. return _this;
  25883. }
  25884. /**
  25885. * @param {?} ast
  25886. * @param {?} context
  25887. * @return {?}
  25888. */
  25889. _BuiltinAstConverter.prototype.visitPipe = /**
  25890. * @param {?} ast
  25891. * @param {?} context
  25892. * @return {?}
  25893. */
  25894. function (ast, context) {
  25895. var _this = this;
  25896. var /** @type {?} */ args = [ast.exp].concat(ast.args).map(function (ast) { return ast.visit(_this, context); });
  25897. return new BuiltinFunctionCall(ast.span, args, this._converterFactory.createPipeConverter(ast.name, args.length));
  25898. };
  25899. /**
  25900. * @param {?} ast
  25901. * @param {?} context
  25902. * @return {?}
  25903. */
  25904. _BuiltinAstConverter.prototype.visitLiteralArray = /**
  25905. * @param {?} ast
  25906. * @param {?} context
  25907. * @return {?}
  25908. */
  25909. function (ast, context) {
  25910. var _this = this;
  25911. var /** @type {?} */ args = ast.expressions.map(function (ast) { return ast.visit(_this, context); });
  25912. return new BuiltinFunctionCall(ast.span, args, this._converterFactory.createLiteralArrayConverter(ast.expressions.length));
  25913. };
  25914. /**
  25915. * @param {?} ast
  25916. * @param {?} context
  25917. * @return {?}
  25918. */
  25919. _BuiltinAstConverter.prototype.visitLiteralMap = /**
  25920. * @param {?} ast
  25921. * @param {?} context
  25922. * @return {?}
  25923. */
  25924. function (ast, context) {
  25925. var _this = this;
  25926. var /** @type {?} */ args = ast.values.map(function (ast) { return ast.visit(_this, context); });
  25927. return new BuiltinFunctionCall(ast.span, args, this._converterFactory.createLiteralMapConverter(ast.keys));
  25928. };
  25929. return _BuiltinAstConverter;
  25930. }(AstTransformer));
  25931. var _AstToIrVisitor = /** @class */ (function () {
  25932. function _AstToIrVisitor(_localResolver, _implicitReceiver, bindingId) {
  25933. this._localResolver = _localResolver;
  25934. this._implicitReceiver = _implicitReceiver;
  25935. this.bindingId = bindingId;
  25936. this._nodeMap = new Map();
  25937. this._resultMap = new Map();
  25938. this._currentTemporary = 0;
  25939. this.temporaryCount = 0;
  25940. }
  25941. /**
  25942. * @param {?} ast
  25943. * @param {?} mode
  25944. * @return {?}
  25945. */
  25946. _AstToIrVisitor.prototype.visitBinary = /**
  25947. * @param {?} ast
  25948. * @param {?} mode
  25949. * @return {?}
  25950. */
  25951. function (ast, mode) {
  25952. var /** @type {?} */ op;
  25953. switch (ast.operation) {
  25954. case '+':
  25955. op = BinaryOperator.Plus;
  25956. break;
  25957. case '-':
  25958. op = BinaryOperator.Minus;
  25959. break;
  25960. case '*':
  25961. op = BinaryOperator.Multiply;
  25962. break;
  25963. case '/':
  25964. op = BinaryOperator.Divide;
  25965. break;
  25966. case '%':
  25967. op = BinaryOperator.Modulo;
  25968. break;
  25969. case '&&':
  25970. op = BinaryOperator.And;
  25971. break;
  25972. case '||':
  25973. op = BinaryOperator.Or;
  25974. break;
  25975. case '==':
  25976. op = BinaryOperator.Equals;
  25977. break;
  25978. case '!=':
  25979. op = BinaryOperator.NotEquals;
  25980. break;
  25981. case '===':
  25982. op = BinaryOperator.Identical;
  25983. break;
  25984. case '!==':
  25985. op = BinaryOperator.NotIdentical;
  25986. break;
  25987. case '<':
  25988. op = BinaryOperator.Lower;
  25989. break;
  25990. case '>':
  25991. op = BinaryOperator.Bigger;
  25992. break;
  25993. case '<=':
  25994. op = BinaryOperator.LowerEquals;
  25995. break;
  25996. case '>=':
  25997. op = BinaryOperator.BiggerEquals;
  25998. break;
  25999. default:
  26000. throw new Error("Unsupported operation " + ast.operation);
  26001. }
  26002. return convertToStatementIfNeeded(mode, new BinaryOperatorExpr(op, this._visit(ast.left, _Mode.Expression), this._visit(ast.right, _Mode.Expression)));
  26003. };
  26004. /**
  26005. * @param {?} ast
  26006. * @param {?} mode
  26007. * @return {?}
  26008. */
  26009. _AstToIrVisitor.prototype.visitChain = /**
  26010. * @param {?} ast
  26011. * @param {?} mode
  26012. * @return {?}
  26013. */
  26014. function (ast, mode) {
  26015. ensureStatementMode(mode, ast);
  26016. return this.visitAll(ast.expressions, mode);
  26017. };
  26018. /**
  26019. * @param {?} ast
  26020. * @param {?} mode
  26021. * @return {?}
  26022. */
  26023. _AstToIrVisitor.prototype.visitConditional = /**
  26024. * @param {?} ast
  26025. * @param {?} mode
  26026. * @return {?}
  26027. */
  26028. function (ast, mode) {
  26029. var /** @type {?} */ value = this._visit(ast.condition, _Mode.Expression);
  26030. return convertToStatementIfNeeded(mode, value.conditional(this._visit(ast.trueExp, _Mode.Expression), this._visit(ast.falseExp, _Mode.Expression)));
  26031. };
  26032. /**
  26033. * @param {?} ast
  26034. * @param {?} mode
  26035. * @return {?}
  26036. */
  26037. _AstToIrVisitor.prototype.visitPipe = /**
  26038. * @param {?} ast
  26039. * @param {?} mode
  26040. * @return {?}
  26041. */
  26042. function (ast, mode) {
  26043. throw new Error("Illegal state: Pipes should have been converted into functions. Pipe: " + ast.name);
  26044. };
  26045. /**
  26046. * @param {?} ast
  26047. * @param {?} mode
  26048. * @return {?}
  26049. */
  26050. _AstToIrVisitor.prototype.visitFunctionCall = /**
  26051. * @param {?} ast
  26052. * @param {?} mode
  26053. * @return {?}
  26054. */
  26055. function (ast, mode) {
  26056. var /** @type {?} */ convertedArgs = this.visitAll(ast.args, _Mode.Expression);
  26057. var /** @type {?} */ fnResult;
  26058. if (ast instanceof BuiltinFunctionCall) {
  26059. fnResult = ast.converter(convertedArgs);
  26060. }
  26061. else {
  26062. fnResult = this._visit(/** @type {?} */ ((ast.target)), _Mode.Expression).callFn(convertedArgs);
  26063. }
  26064. return convertToStatementIfNeeded(mode, fnResult);
  26065. };
  26066. /**
  26067. * @param {?} ast
  26068. * @param {?} mode
  26069. * @return {?}
  26070. */
  26071. _AstToIrVisitor.prototype.visitImplicitReceiver = /**
  26072. * @param {?} ast
  26073. * @param {?} mode
  26074. * @return {?}
  26075. */
  26076. function (ast, mode) {
  26077. ensureExpressionMode(mode, ast);
  26078. return this._implicitReceiver;
  26079. };
  26080. /**
  26081. * @param {?} ast
  26082. * @param {?} mode
  26083. * @return {?}
  26084. */
  26085. _AstToIrVisitor.prototype.visitInterpolation = /**
  26086. * @param {?} ast
  26087. * @param {?} mode
  26088. * @return {?}
  26089. */
  26090. function (ast, mode) {
  26091. ensureExpressionMode(mode, ast);
  26092. var /** @type {?} */ args = [literal(ast.expressions.length)];
  26093. for (var /** @type {?} */ i = 0; i < ast.strings.length - 1; i++) {
  26094. args.push(literal(ast.strings[i]));
  26095. args.push(this._visit(ast.expressions[i], _Mode.Expression));
  26096. }
  26097. args.push(literal(ast.strings[ast.strings.length - 1]));
  26098. return ast.expressions.length <= 9 ?
  26099. importExpr(Identifiers.inlineInterpolate).callFn(args) :
  26100. importExpr(Identifiers.interpolate).callFn([args[0], literalArr(args.slice(1))]);
  26101. };
  26102. /**
  26103. * @param {?} ast
  26104. * @param {?} mode
  26105. * @return {?}
  26106. */
  26107. _AstToIrVisitor.prototype.visitKeyedRead = /**
  26108. * @param {?} ast
  26109. * @param {?} mode
  26110. * @return {?}
  26111. */
  26112. function (ast, mode) {
  26113. var /** @type {?} */ leftMostSafe = this.leftMostSafeNode(ast);
  26114. if (leftMostSafe) {
  26115. return this.convertSafeAccess(ast, leftMostSafe, mode);
  26116. }
  26117. else {
  26118. return convertToStatementIfNeeded(mode, this._visit(ast.obj, _Mode.Expression).key(this._visit(ast.key, _Mode.Expression)));
  26119. }
  26120. };
  26121. /**
  26122. * @param {?} ast
  26123. * @param {?} mode
  26124. * @return {?}
  26125. */
  26126. _AstToIrVisitor.prototype.visitKeyedWrite = /**
  26127. * @param {?} ast
  26128. * @param {?} mode
  26129. * @return {?}
  26130. */
  26131. function (ast, mode) {
  26132. var /** @type {?} */ obj = this._visit(ast.obj, _Mode.Expression);
  26133. var /** @type {?} */ key = this._visit(ast.key, _Mode.Expression);
  26134. var /** @type {?} */ value = this._visit(ast.value, _Mode.Expression);
  26135. return convertToStatementIfNeeded(mode, obj.key(key).set(value));
  26136. };
  26137. /**
  26138. * @param {?} ast
  26139. * @param {?} mode
  26140. * @return {?}
  26141. */
  26142. _AstToIrVisitor.prototype.visitLiteralArray = /**
  26143. * @param {?} ast
  26144. * @param {?} mode
  26145. * @return {?}
  26146. */
  26147. function (ast, mode) {
  26148. throw new Error("Illegal State: literal arrays should have been converted into functions");
  26149. };
  26150. /**
  26151. * @param {?} ast
  26152. * @param {?} mode
  26153. * @return {?}
  26154. */
  26155. _AstToIrVisitor.prototype.visitLiteralMap = /**
  26156. * @param {?} ast
  26157. * @param {?} mode
  26158. * @return {?}
  26159. */
  26160. function (ast, mode) {
  26161. throw new Error("Illegal State: literal maps should have been converted into functions");
  26162. };
  26163. /**
  26164. * @param {?} ast
  26165. * @param {?} mode
  26166. * @return {?}
  26167. */
  26168. _AstToIrVisitor.prototype.visitLiteralPrimitive = /**
  26169. * @param {?} ast
  26170. * @param {?} mode
  26171. * @return {?}
  26172. */
  26173. function (ast, mode) {
  26174. // For literal values of null, undefined, true, or false allow type inteference
  26175. // to infer the type.
  26176. var /** @type {?} */ type = ast.value === null || ast.value === undefined || ast.value === true || ast.value === true ?
  26177. INFERRED_TYPE :
  26178. undefined;
  26179. return convertToStatementIfNeeded(mode, literal(ast.value, type));
  26180. };
  26181. /**
  26182. * @param {?} name
  26183. * @return {?}
  26184. */
  26185. _AstToIrVisitor.prototype._getLocal = /**
  26186. * @param {?} name
  26187. * @return {?}
  26188. */
  26189. function (name) { return this._localResolver.getLocal(name); };
  26190. /**
  26191. * @param {?} ast
  26192. * @param {?} mode
  26193. * @return {?}
  26194. */
  26195. _AstToIrVisitor.prototype.visitMethodCall = /**
  26196. * @param {?} ast
  26197. * @param {?} mode
  26198. * @return {?}
  26199. */
  26200. function (ast, mode) {
  26201. if (ast.receiver instanceof ImplicitReceiver && ast.name == '$any') {
  26202. var /** @type {?} */ args = /** @type {?} */ (this.visitAll(ast.args, _Mode.Expression));
  26203. if (args.length != 1) {
  26204. throw new Error("Invalid call to $any, expected 1 argument but received " + (args.length || 'none'));
  26205. }
  26206. return (/** @type {?} */ (args[0])).cast(DYNAMIC_TYPE);
  26207. }
  26208. var /** @type {?} */ leftMostSafe = this.leftMostSafeNode(ast);
  26209. if (leftMostSafe) {
  26210. return this.convertSafeAccess(ast, leftMostSafe, mode);
  26211. }
  26212. else {
  26213. var /** @type {?} */ args = this.visitAll(ast.args, _Mode.Expression);
  26214. var /** @type {?} */ result = null;
  26215. var /** @type {?} */ receiver = this._visit(ast.receiver, _Mode.Expression);
  26216. if (receiver === this._implicitReceiver) {
  26217. var /** @type {?} */ varExpr = this._getLocal(ast.name);
  26218. if (varExpr) {
  26219. result = varExpr.callFn(args);
  26220. }
  26221. }
  26222. if (result == null) {
  26223. result = receiver.callMethod(ast.name, args);
  26224. }
  26225. return convertToStatementIfNeeded(mode, result);
  26226. }
  26227. };
  26228. /**
  26229. * @param {?} ast
  26230. * @param {?} mode
  26231. * @return {?}
  26232. */
  26233. _AstToIrVisitor.prototype.visitPrefixNot = /**
  26234. * @param {?} ast
  26235. * @param {?} mode
  26236. * @return {?}
  26237. */
  26238. function (ast, mode) {
  26239. return convertToStatementIfNeeded(mode, not(this._visit(ast.expression, _Mode.Expression)));
  26240. };
  26241. /**
  26242. * @param {?} ast
  26243. * @param {?} mode
  26244. * @return {?}
  26245. */
  26246. _AstToIrVisitor.prototype.visitNonNullAssert = /**
  26247. * @param {?} ast
  26248. * @param {?} mode
  26249. * @return {?}
  26250. */
  26251. function (ast, mode) {
  26252. return convertToStatementIfNeeded(mode, assertNotNull(this._visit(ast.expression, _Mode.Expression)));
  26253. };
  26254. /**
  26255. * @param {?} ast
  26256. * @param {?} mode
  26257. * @return {?}
  26258. */
  26259. _AstToIrVisitor.prototype.visitPropertyRead = /**
  26260. * @param {?} ast
  26261. * @param {?} mode
  26262. * @return {?}
  26263. */
  26264. function (ast, mode) {
  26265. var /** @type {?} */ leftMostSafe = this.leftMostSafeNode(ast);
  26266. if (leftMostSafe) {
  26267. return this.convertSafeAccess(ast, leftMostSafe, mode);
  26268. }
  26269. else {
  26270. var /** @type {?} */ result = null;
  26271. var /** @type {?} */ receiver = this._visit(ast.receiver, _Mode.Expression);
  26272. if (receiver === this._implicitReceiver) {
  26273. result = this._getLocal(ast.name);
  26274. }
  26275. if (result == null) {
  26276. result = receiver.prop(ast.name);
  26277. }
  26278. return convertToStatementIfNeeded(mode, result);
  26279. }
  26280. };
  26281. /**
  26282. * @param {?} ast
  26283. * @param {?} mode
  26284. * @return {?}
  26285. */
  26286. _AstToIrVisitor.prototype.visitPropertyWrite = /**
  26287. * @param {?} ast
  26288. * @param {?} mode
  26289. * @return {?}
  26290. */
  26291. function (ast, mode) {
  26292. var /** @type {?} */ receiver = this._visit(ast.receiver, _Mode.Expression);
  26293. if (receiver === this._implicitReceiver) {
  26294. var /** @type {?} */ varExpr = this._getLocal(ast.name);
  26295. if (varExpr) {
  26296. throw new Error('Cannot assign to a reference or variable!');
  26297. }
  26298. }
  26299. return convertToStatementIfNeeded(mode, receiver.prop(ast.name).set(this._visit(ast.value, _Mode.Expression)));
  26300. };
  26301. /**
  26302. * @param {?} ast
  26303. * @param {?} mode
  26304. * @return {?}
  26305. */
  26306. _AstToIrVisitor.prototype.visitSafePropertyRead = /**
  26307. * @param {?} ast
  26308. * @param {?} mode
  26309. * @return {?}
  26310. */
  26311. function (ast, mode) {
  26312. return this.convertSafeAccess(ast, this.leftMostSafeNode(ast), mode);
  26313. };
  26314. /**
  26315. * @param {?} ast
  26316. * @param {?} mode
  26317. * @return {?}
  26318. */
  26319. _AstToIrVisitor.prototype.visitSafeMethodCall = /**
  26320. * @param {?} ast
  26321. * @param {?} mode
  26322. * @return {?}
  26323. */
  26324. function (ast, mode) {
  26325. return this.convertSafeAccess(ast, this.leftMostSafeNode(ast), mode);
  26326. };
  26327. /**
  26328. * @param {?} asts
  26329. * @param {?} mode
  26330. * @return {?}
  26331. */
  26332. _AstToIrVisitor.prototype.visitAll = /**
  26333. * @param {?} asts
  26334. * @param {?} mode
  26335. * @return {?}
  26336. */
  26337. function (asts, mode) {
  26338. var _this = this;
  26339. return asts.map(function (ast) { return _this._visit(ast, mode); });
  26340. };
  26341. /**
  26342. * @param {?} ast
  26343. * @param {?} mode
  26344. * @return {?}
  26345. */
  26346. _AstToIrVisitor.prototype.visitQuote = /**
  26347. * @param {?} ast
  26348. * @param {?} mode
  26349. * @return {?}
  26350. */
  26351. function (ast, mode) {
  26352. throw new Error("Quotes are not supported for evaluation!\n Statement: " + ast.uninterpretedExpression + " located at " + ast.location);
  26353. };
  26354. /**
  26355. * @param {?} ast
  26356. * @param {?} mode
  26357. * @return {?}
  26358. */
  26359. _AstToIrVisitor.prototype._visit = /**
  26360. * @param {?} ast
  26361. * @param {?} mode
  26362. * @return {?}
  26363. */
  26364. function (ast, mode) {
  26365. var /** @type {?} */ result = this._resultMap.get(ast);
  26366. if (result)
  26367. return result;
  26368. return (this._nodeMap.get(ast) || ast).visit(this, mode);
  26369. };
  26370. /**
  26371. * @param {?} ast
  26372. * @param {?} leftMostSafe
  26373. * @param {?} mode
  26374. * @return {?}
  26375. */
  26376. _AstToIrVisitor.prototype.convertSafeAccess = /**
  26377. * @param {?} ast
  26378. * @param {?} leftMostSafe
  26379. * @param {?} mode
  26380. * @return {?}
  26381. */
  26382. function (ast, leftMostSafe, mode) {
  26383. // If the expression contains a safe access node on the left it needs to be converted to
  26384. // an expression that guards the access to the member by checking the receiver for blank. As
  26385. // execution proceeds from left to right, the left most part of the expression must be guarded
  26386. // first but, because member access is left associative, the right side of the expression is at
  26387. // the top of the AST. The desired result requires lifting a copy of the the left part of the
  26388. // expression up to test it for blank before generating the unguarded version.
  26389. // Consider, for example the following expression: a?.b.c?.d.e
  26390. // This results in the ast:
  26391. // .
  26392. // / \
  26393. // ?. e
  26394. // / \
  26395. // . d
  26396. // / \
  26397. // ?. c
  26398. // / \
  26399. // a b
  26400. // The following tree should be generated:
  26401. //
  26402. // /---- ? ----\
  26403. // / | \
  26404. // a /--- ? ---\ null
  26405. // / | \
  26406. // . . null
  26407. // / \ / \
  26408. // . c . e
  26409. // / \ / \
  26410. // a b , d
  26411. // / \
  26412. // . c
  26413. // / \
  26414. // a b
  26415. //
  26416. // Notice that the first guard condition is the left hand of the left most safe access node
  26417. // which comes in as leftMostSafe to this routine.
  26418. var /** @type {?} */ guardedExpression = this._visit(leftMostSafe.receiver, _Mode.Expression);
  26419. var /** @type {?} */ temporary = /** @type {?} */ ((undefined));
  26420. if (this.needsTemporary(leftMostSafe.receiver)) {
  26421. // If the expression has method calls or pipes then we need to save the result into a
  26422. // temporary variable to avoid calling stateful or impure code more than once.
  26423. temporary = this.allocateTemporary();
  26424. // Preserve the result in the temporary variable
  26425. guardedExpression = temporary.set(guardedExpression);
  26426. // Ensure all further references to the guarded expression refer to the temporary instead.
  26427. this._resultMap.set(leftMostSafe.receiver, temporary);
  26428. }
  26429. var /** @type {?} */ condition = guardedExpression.isBlank();
  26430. // Convert the ast to an unguarded access to the receiver's member. The map will substitute
  26431. // leftMostNode with its unguarded version in the call to `this.visit()`.
  26432. if (leftMostSafe instanceof SafeMethodCall) {
  26433. this._nodeMap.set(leftMostSafe, new MethodCall(leftMostSafe.span, leftMostSafe.receiver, leftMostSafe.name, leftMostSafe.args));
  26434. }
  26435. else {
  26436. this._nodeMap.set(leftMostSafe, new PropertyRead(leftMostSafe.span, leftMostSafe.receiver, leftMostSafe.name));
  26437. }
  26438. // Recursively convert the node now without the guarded member access.
  26439. var /** @type {?} */ access = this._visit(ast, _Mode.Expression);
  26440. // Remove the mapping. This is not strictly required as the converter only traverses each node
  26441. // once but is safer if the conversion is changed to traverse the nodes more than once.
  26442. this._nodeMap.delete(leftMostSafe);
  26443. // If we allocated a temporary, release it.
  26444. if (temporary) {
  26445. this.releaseTemporary(temporary);
  26446. }
  26447. // Produce the conditional
  26448. return convertToStatementIfNeeded(mode, condition.conditional(literal(null), access));
  26449. };
  26450. /**
  26451. * @param {?} ast
  26452. * @return {?}
  26453. */
  26454. _AstToIrVisitor.prototype.leftMostSafeNode = /**
  26455. * @param {?} ast
  26456. * @return {?}
  26457. */
  26458. function (ast) {
  26459. var _this = this;
  26460. var /** @type {?} */ visit = function (visitor, ast) {
  26461. return (_this._nodeMap.get(ast) || ast).visit(visitor);
  26462. };
  26463. return ast.visit({
  26464. visitBinary: /**
  26465. * @param {?} ast
  26466. * @return {?}
  26467. */
  26468. function (ast) { return null; },
  26469. visitChain: /**
  26470. * @param {?} ast
  26471. * @return {?}
  26472. */
  26473. function (ast) { return null; },
  26474. visitConditional: /**
  26475. * @param {?} ast
  26476. * @return {?}
  26477. */
  26478. function (ast) { return null; },
  26479. visitFunctionCall: /**
  26480. * @param {?} ast
  26481. * @return {?}
  26482. */
  26483. function (ast) { return null; },
  26484. visitImplicitReceiver: /**
  26485. * @param {?} ast
  26486. * @return {?}
  26487. */
  26488. function (ast) { return null; },
  26489. visitInterpolation: /**
  26490. * @param {?} ast
  26491. * @return {?}
  26492. */
  26493. function (ast) { return null; },
  26494. visitKeyedRead: /**
  26495. * @param {?} ast
  26496. * @return {?}
  26497. */
  26498. function (ast) { return visit(this, ast.obj); },
  26499. visitKeyedWrite: /**
  26500. * @param {?} ast
  26501. * @return {?}
  26502. */
  26503. function (ast) { return null; },
  26504. visitLiteralArray: /**
  26505. * @param {?} ast
  26506. * @return {?}
  26507. */
  26508. function (ast) { return null; },
  26509. visitLiteralMap: /**
  26510. * @param {?} ast
  26511. * @return {?}
  26512. */
  26513. function (ast) { return null; },
  26514. visitLiteralPrimitive: /**
  26515. * @param {?} ast
  26516. * @return {?}
  26517. */
  26518. function (ast) { return null; },
  26519. visitMethodCall: /**
  26520. * @param {?} ast
  26521. * @return {?}
  26522. */
  26523. function (ast) { return visit(this, ast.receiver); },
  26524. visitPipe: /**
  26525. * @param {?} ast
  26526. * @return {?}
  26527. */
  26528. function (ast) { return null; },
  26529. visitPrefixNot: /**
  26530. * @param {?} ast
  26531. * @return {?}
  26532. */
  26533. function (ast) { return null; },
  26534. visitNonNullAssert: /**
  26535. * @param {?} ast
  26536. * @return {?}
  26537. */
  26538. function (ast) { return null; },
  26539. visitPropertyRead: /**
  26540. * @param {?} ast
  26541. * @return {?}
  26542. */
  26543. function (ast) { return visit(this, ast.receiver); },
  26544. visitPropertyWrite: /**
  26545. * @param {?} ast
  26546. * @return {?}
  26547. */
  26548. function (ast) { return null; },
  26549. visitQuote: /**
  26550. * @param {?} ast
  26551. * @return {?}
  26552. */
  26553. function (ast) { return null; },
  26554. visitSafeMethodCall: /**
  26555. * @param {?} ast
  26556. * @return {?}
  26557. */
  26558. function (ast) { return visit(this, ast.receiver) || ast; },
  26559. visitSafePropertyRead: /**
  26560. * @param {?} ast
  26561. * @return {?}
  26562. */
  26563. function (ast) {
  26564. return visit(this, ast.receiver) || ast;
  26565. }
  26566. });
  26567. };
  26568. /**
  26569. * @param {?} ast
  26570. * @return {?}
  26571. */
  26572. _AstToIrVisitor.prototype.needsTemporary = /**
  26573. * @param {?} ast
  26574. * @return {?}
  26575. */
  26576. function (ast) {
  26577. var _this = this;
  26578. var /** @type {?} */ visit = function (visitor, ast) {
  26579. return ast && (_this._nodeMap.get(ast) || ast).visit(visitor);
  26580. };
  26581. var /** @type {?} */ visitSome = function (visitor, ast) {
  26582. return ast.some(function (ast) { return visit(visitor, ast); });
  26583. };
  26584. return ast.visit({
  26585. visitBinary: /**
  26586. * @param {?} ast
  26587. * @return {?}
  26588. */
  26589. function (ast) { return visit(this, ast.left) || visit(this, ast.right); },
  26590. visitChain: /**
  26591. * @param {?} ast
  26592. * @return {?}
  26593. */
  26594. function (ast) { return false; },
  26595. visitConditional: /**
  26596. * @param {?} ast
  26597. * @return {?}
  26598. */
  26599. function (ast) {
  26600. return visit(this, ast.condition) || visit(this, ast.trueExp) ||
  26601. visit(this, ast.falseExp);
  26602. },
  26603. visitFunctionCall: /**
  26604. * @param {?} ast
  26605. * @return {?}
  26606. */
  26607. function (ast) { return true; },
  26608. visitImplicitReceiver: /**
  26609. * @param {?} ast
  26610. * @return {?}
  26611. */
  26612. function (ast) { return false; },
  26613. visitInterpolation: /**
  26614. * @param {?} ast
  26615. * @return {?}
  26616. */
  26617. function (ast) { return visitSome(this, ast.expressions); },
  26618. visitKeyedRead: /**
  26619. * @param {?} ast
  26620. * @return {?}
  26621. */
  26622. function (ast) { return false; },
  26623. visitKeyedWrite: /**
  26624. * @param {?} ast
  26625. * @return {?}
  26626. */
  26627. function (ast) { return false; },
  26628. visitLiteralArray: /**
  26629. * @param {?} ast
  26630. * @return {?}
  26631. */
  26632. function (ast) { return true; },
  26633. visitLiteralMap: /**
  26634. * @param {?} ast
  26635. * @return {?}
  26636. */
  26637. function (ast) { return true; },
  26638. visitLiteralPrimitive: /**
  26639. * @param {?} ast
  26640. * @return {?}
  26641. */
  26642. function (ast) { return false; },
  26643. visitMethodCall: /**
  26644. * @param {?} ast
  26645. * @return {?}
  26646. */
  26647. function (ast) { return true; },
  26648. visitPipe: /**
  26649. * @param {?} ast
  26650. * @return {?}
  26651. */
  26652. function (ast) { return true; },
  26653. visitPrefixNot: /**
  26654. * @param {?} ast
  26655. * @return {?}
  26656. */
  26657. function (ast) { return visit(this, ast.expression); },
  26658. visitNonNullAssert: /**
  26659. * @param {?} ast
  26660. * @return {?}
  26661. */
  26662. function (ast) { return visit(this, ast.expression); },
  26663. visitPropertyRead: /**
  26664. * @param {?} ast
  26665. * @return {?}
  26666. */
  26667. function (ast) { return false; },
  26668. visitPropertyWrite: /**
  26669. * @param {?} ast
  26670. * @return {?}
  26671. */
  26672. function (ast) { return false; },
  26673. visitQuote: /**
  26674. * @param {?} ast
  26675. * @return {?}
  26676. */
  26677. function (ast) { return false; },
  26678. visitSafeMethodCall: /**
  26679. * @param {?} ast
  26680. * @return {?}
  26681. */
  26682. function (ast) { return true; },
  26683. visitSafePropertyRead: /**
  26684. * @param {?} ast
  26685. * @return {?}
  26686. */
  26687. function (ast) { return false; }
  26688. });
  26689. };
  26690. /**
  26691. * @return {?}
  26692. */
  26693. _AstToIrVisitor.prototype.allocateTemporary = /**
  26694. * @return {?}
  26695. */
  26696. function () {
  26697. var /** @type {?} */ tempNumber = this._currentTemporary++;
  26698. this.temporaryCount = Math.max(this._currentTemporary, this.temporaryCount);
  26699. return new ReadVarExpr(temporaryName(this.bindingId, tempNumber));
  26700. };
  26701. /**
  26702. * @param {?} temporary
  26703. * @return {?}
  26704. */
  26705. _AstToIrVisitor.prototype.releaseTemporary = /**
  26706. * @param {?} temporary
  26707. * @return {?}
  26708. */
  26709. function (temporary) {
  26710. this._currentTemporary--;
  26711. if (temporary.name != temporaryName(this.bindingId, this._currentTemporary)) {
  26712. throw new Error("Temporary " + temporary.name + " released out of order");
  26713. }
  26714. };
  26715. return _AstToIrVisitor;
  26716. }());
  26717. /**
  26718. * @param {?} arg
  26719. * @param {?} output
  26720. * @return {?}
  26721. */
  26722. function flattenStatements(arg, output) {
  26723. if (Array.isArray(arg)) {
  26724. (/** @type {?} */ (arg)).forEach(function (entry) { return flattenStatements(entry, output); });
  26725. }
  26726. else {
  26727. output.push(arg);
  26728. }
  26729. }
  26730. var DefaultLocalResolver = /** @class */ (function () {
  26731. function DefaultLocalResolver() {
  26732. }
  26733. /**
  26734. * @param {?} name
  26735. * @return {?}
  26736. */
  26737. DefaultLocalResolver.prototype.getLocal = /**
  26738. * @param {?} name
  26739. * @return {?}
  26740. */
  26741. function (name) {
  26742. if (name === EventHandlerVars.event.name) {
  26743. return EventHandlerVars.event;
  26744. }
  26745. return null;
  26746. };
  26747. return DefaultLocalResolver;
  26748. }());
  26749. /**
  26750. * @param {?} bindingId
  26751. * @return {?}
  26752. */
  26753. function createCurrValueExpr(bindingId) {
  26754. return variable("currVal_" + bindingId); // fix syntax highlighting: `
  26755. }
  26756. /**
  26757. * @param {?} bindingId
  26758. * @return {?}
  26759. */
  26760. function createPreventDefaultVar(bindingId) {
  26761. return variable("pd_" + bindingId);
  26762. }
  26763. /**
  26764. * @param {?} stmt
  26765. * @return {?}
  26766. */
  26767. function convertStmtIntoExpression(stmt) {
  26768. if (stmt instanceof ExpressionStatement) {
  26769. return stmt.expr;
  26770. }
  26771. else if (stmt instanceof ReturnStatement) {
  26772. return stmt.value;
  26773. }
  26774. return null;
  26775. }
  26776. var BuiltinFunctionCall = /** @class */ (function (_super) {
  26777. __extends(BuiltinFunctionCall, _super);
  26778. function BuiltinFunctionCall(span, args, converter) {
  26779. var _this = _super.call(this, span, null, args) || this;
  26780. _this.args = args;
  26781. _this.converter = converter;
  26782. return _this;
  26783. }
  26784. return BuiltinFunctionCall;
  26785. }(FunctionCall));
  26786. /**
  26787. * @fileoverview added by tsickle
  26788. * @suppress {checkTypes} checked by tsc
  26789. */
  26790. /**
  26791. * @license
  26792. * Copyright Google Inc. All Rights Reserved.
  26793. *
  26794. * Use of this source code is governed by an MIT-style license that can be
  26795. * found in the LICENSE file at https://angular.io/license
  26796. */
  26797. /**
  26798. * Generates code that is used to type check templates.
  26799. */
  26800. var TypeCheckCompiler = /** @class */ (function () {
  26801. function TypeCheckCompiler(options, reflector) {
  26802. this.options = options;
  26803. this.reflector = reflector;
  26804. }
  26805. /**
  26806. * Important notes:
  26807. * - This must not produce new `import` statements, but only refer to types outside
  26808. * of the file via the variables provided via externalReferenceVars.
  26809. * This allows Typescript to reuse the old program's structure as no imports have changed.
  26810. * - This must not produce any exports, as this would pollute the .d.ts file
  26811. * and also violate the point above.
  26812. */
  26813. /**
  26814. * Important notes:
  26815. * - This must not produce new `import` statements, but only refer to types outside
  26816. * of the file via the variables provided via externalReferenceVars.
  26817. * This allows Typescript to reuse the old program's structure as no imports have changed.
  26818. * - This must not produce any exports, as this would pollute the .d.ts file
  26819. * and also violate the point above.
  26820. * @param {?} componentId
  26821. * @param {?} component
  26822. * @param {?} template
  26823. * @param {?} usedPipes
  26824. * @param {?} externalReferenceVars
  26825. * @param {?} ctx
  26826. * @return {?}
  26827. */
  26828. TypeCheckCompiler.prototype.compileComponent = /**
  26829. * Important notes:
  26830. * - This must not produce new `import` statements, but only refer to types outside
  26831. * of the file via the variables provided via externalReferenceVars.
  26832. * This allows Typescript to reuse the old program's structure as no imports have changed.
  26833. * - This must not produce any exports, as this would pollute the .d.ts file
  26834. * and also violate the point above.
  26835. * @param {?} componentId
  26836. * @param {?} component
  26837. * @param {?} template
  26838. * @param {?} usedPipes
  26839. * @param {?} externalReferenceVars
  26840. * @param {?} ctx
  26841. * @return {?}
  26842. */
  26843. function (componentId, component, template, usedPipes, externalReferenceVars, ctx) {
  26844. var _this = this;
  26845. var /** @type {?} */ pipes = new Map();
  26846. usedPipes.forEach(function (p) { return pipes.set(p.name, p.type.reference); });
  26847. var /** @type {?} */ embeddedViewCount = 0;
  26848. var /** @type {?} */ viewBuilderFactory = function (parent, guards) {
  26849. var /** @type {?} */ embeddedViewIndex = embeddedViewCount++;
  26850. return new ViewBuilder(_this.options, _this.reflector, externalReferenceVars, parent, component.type.reference, component.isHost, embeddedViewIndex, pipes, guards, ctx, viewBuilderFactory);
  26851. };
  26852. var /** @type {?} */ visitor = viewBuilderFactory(null, []);
  26853. visitor.visitAll([], template);
  26854. return visitor.build(componentId);
  26855. };
  26856. return TypeCheckCompiler;
  26857. }());
  26858. var DYNAMIC_VAR_NAME = '_any';
  26859. var TypeCheckLocalResolver = /** @class */ (function () {
  26860. function TypeCheckLocalResolver() {
  26861. }
  26862. /**
  26863. * @param {?} name
  26864. * @return {?}
  26865. */
  26866. TypeCheckLocalResolver.prototype.getLocal = /**
  26867. * @param {?} name
  26868. * @return {?}
  26869. */
  26870. function (name) {
  26871. if (name === EventHandlerVars.event.name) {
  26872. // References to the event should not be type-checked.
  26873. // TODO(chuckj): determine a better type for the event.
  26874. return variable(DYNAMIC_VAR_NAME);
  26875. }
  26876. return null;
  26877. };
  26878. return TypeCheckLocalResolver;
  26879. }());
  26880. var defaultResolver = new TypeCheckLocalResolver();
  26881. var ViewBuilder = /** @class */ (function () {
  26882. function ViewBuilder(options, reflector, externalReferenceVars, parent, component, isHostComponent, embeddedViewIndex, pipes, guards, ctx, viewBuilderFactory) {
  26883. this.options = options;
  26884. this.reflector = reflector;
  26885. this.externalReferenceVars = externalReferenceVars;
  26886. this.parent = parent;
  26887. this.component = component;
  26888. this.isHostComponent = isHostComponent;
  26889. this.embeddedViewIndex = embeddedViewIndex;
  26890. this.pipes = pipes;
  26891. this.guards = guards;
  26892. this.ctx = ctx;
  26893. this.viewBuilderFactory = viewBuilderFactory;
  26894. this.refOutputVars = new Map();
  26895. this.variables = [];
  26896. this.children = [];
  26897. this.updates = [];
  26898. this.actions = [];
  26899. }
  26900. /**
  26901. * @param {?} type
  26902. * @return {?}
  26903. */
  26904. ViewBuilder.prototype.getOutputVar = /**
  26905. * @param {?} type
  26906. * @return {?}
  26907. */
  26908. function (type) {
  26909. var /** @type {?} */ varName;
  26910. if (type === this.component && this.isHostComponent) {
  26911. varName = DYNAMIC_VAR_NAME;
  26912. }
  26913. else if (type instanceof StaticSymbol) {
  26914. varName = this.externalReferenceVars.get(type);
  26915. }
  26916. else {
  26917. varName = DYNAMIC_VAR_NAME;
  26918. }
  26919. if (!varName) {
  26920. throw new Error("Illegal State: referring to a type without a variable " + JSON.stringify(type));
  26921. }
  26922. return varName;
  26923. };
  26924. /**
  26925. * @param {?} ast
  26926. * @return {?}
  26927. */
  26928. ViewBuilder.prototype.getTypeGuardExpressions = /**
  26929. * @param {?} ast
  26930. * @return {?}
  26931. */
  26932. function (ast) {
  26933. var /** @type {?} */ result = this.guards.slice();
  26934. for (var _i = 0, _a = ast.directives; _i < _a.length; _i++) {
  26935. var directive = _a[_i];
  26936. for (var _b = 0, _c = directive.inputs; _b < _c.length; _b++) {
  26937. var input = _c[_b];
  26938. var /** @type {?} */ guard = directive.directive.guards[input.directiveName];
  26939. if (guard) {
  26940. var /** @type {?} */ useIf = guard === 'UseIf';
  26941. result.push({
  26942. guard: guard,
  26943. useIf: useIf,
  26944. expression: /** @type {?} */ ({ context: this.component, value: input.value })
  26945. });
  26946. }
  26947. }
  26948. }
  26949. return result;
  26950. };
  26951. /**
  26952. * @param {?} variables
  26953. * @param {?} astNodes
  26954. * @return {?}
  26955. */
  26956. ViewBuilder.prototype.visitAll = /**
  26957. * @param {?} variables
  26958. * @param {?} astNodes
  26959. * @return {?}
  26960. */
  26961. function (variables, astNodes) {
  26962. this.variables = variables;
  26963. templateVisitAll(this, astNodes);
  26964. };
  26965. /**
  26966. * @param {?} componentId
  26967. * @param {?=} targetStatements
  26968. * @return {?}
  26969. */
  26970. ViewBuilder.prototype.build = /**
  26971. * @param {?} componentId
  26972. * @param {?=} targetStatements
  26973. * @return {?}
  26974. */
  26975. function (componentId, targetStatements) {
  26976. var _this = this;
  26977. if (targetStatements === void 0) { targetStatements = []; }
  26978. this.children.forEach(function (child) { return child.build(componentId, targetStatements); });
  26979. var /** @type {?} */ viewStmts = [variable(DYNAMIC_VAR_NAME).set(NULL_EXPR).toDeclStmt(DYNAMIC_TYPE)];
  26980. var /** @type {?} */ bindingCount = 0;
  26981. this.updates.forEach(function (expression) {
  26982. var _a = _this.preprocessUpdateExpression(expression), sourceSpan = _a.sourceSpan, context = _a.context, value = _a.value;
  26983. var /** @type {?} */ bindingId = "" + bindingCount++;
  26984. var /** @type {?} */ nameResolver = context === _this.component ? _this : defaultResolver;
  26985. var _b = convertPropertyBinding(nameResolver, variable(_this.getOutputVar(context)), value, bindingId, BindingForm.General), stmts = _b.stmts, currValExpr = _b.currValExpr;
  26986. stmts.push(new ExpressionStatement(currValExpr));
  26987. viewStmts.push.apply(viewStmts, stmts.map(function (stmt) { return applySourceSpanToStatementIfNeeded(stmt, sourceSpan); }));
  26988. });
  26989. this.actions.forEach(function (_a) {
  26990. var sourceSpan = _a.sourceSpan, context = _a.context, value = _a.value;
  26991. var /** @type {?} */ bindingId = "" + bindingCount++;
  26992. var /** @type {?} */ nameResolver = context === _this.component ? _this : defaultResolver;
  26993. var stmts = convertActionBinding(nameResolver, variable(_this.getOutputVar(context)), value, bindingId).stmts;
  26994. viewStmts.push.apply(viewStmts, stmts.map(function (stmt) { return applySourceSpanToStatementIfNeeded(stmt, sourceSpan); }));
  26995. });
  26996. if (this.guards.length) {
  26997. var /** @type {?} */ guardExpression = undefined;
  26998. for (var _i = 0, _a = this.guards; _i < _a.length; _i++) {
  26999. var guard = _a[_i];
  27000. var _b = this.preprocessUpdateExpression(guard.expression), context = _b.context, value = _b.value;
  27001. var /** @type {?} */ bindingId = "" + bindingCount++;
  27002. var /** @type {?} */ nameResolver = context === this.component ? this : defaultResolver;
  27003. // We only support support simple expressions and ignore others as they
  27004. // are unlikely to affect type narrowing.
  27005. var _c = convertPropertyBinding(nameResolver, variable(this.getOutputVar(context)), value, bindingId, BindingForm.TrySimple), stmts = _c.stmts, currValExpr = _c.currValExpr;
  27006. if (stmts.length == 0) {
  27007. var /** @type {?} */ guardClause = guard.useIf ? currValExpr : this.ctx.importExpr(guard.guard).callFn([currValExpr]);
  27008. guardExpression = guardExpression ? guardExpression.and(guardClause) : guardClause;
  27009. }
  27010. }
  27011. if (guardExpression) {
  27012. viewStmts = [new IfStmt(guardExpression, viewStmts)];
  27013. }
  27014. }
  27015. var /** @type {?} */ viewName = "_View_" + componentId + "_" + this.embeddedViewIndex;
  27016. var /** @type {?} */ viewFactory = new DeclareFunctionStmt(viewName, [], viewStmts);
  27017. targetStatements.push(viewFactory);
  27018. return targetStatements;
  27019. };
  27020. /**
  27021. * @param {?} ast
  27022. * @param {?} context
  27023. * @return {?}
  27024. */
  27025. ViewBuilder.prototype.visitBoundText = /**
  27026. * @param {?} ast
  27027. * @param {?} context
  27028. * @return {?}
  27029. */
  27030. function (ast, context) {
  27031. var _this = this;
  27032. var /** @type {?} */ astWithSource = /** @type {?} */ (ast.value);
  27033. var /** @type {?} */ inter = /** @type {?} */ (astWithSource.ast);
  27034. inter.expressions.forEach(function (expr) {
  27035. return _this.updates.push({ context: _this.component, value: expr, sourceSpan: ast.sourceSpan });
  27036. });
  27037. };
  27038. /**
  27039. * @param {?} ast
  27040. * @param {?} context
  27041. * @return {?}
  27042. */
  27043. ViewBuilder.prototype.visitEmbeddedTemplate = /**
  27044. * @param {?} ast
  27045. * @param {?} context
  27046. * @return {?}
  27047. */
  27048. function (ast, context) {
  27049. this.visitElementOrTemplate(ast);
  27050. // Note: The old view compiler used to use an `any` type
  27051. // for the context in any embedded view.
  27052. // We keep this behaivor behind a flag for now.
  27053. if (this.options.fullTemplateTypeCheck) {
  27054. // Find any applicable type guards. For example, NgIf has a type guard on ngIf
  27055. // (see NgIf.ngIfTypeGuard) that can be used to indicate that a template is only
  27056. // stamped out if ngIf is truthy so any bindings in the template can assume that,
  27057. // if a nullable type is used for ngIf, that expression is not null or undefined.
  27058. var /** @type {?} */ guards = this.getTypeGuardExpressions(ast);
  27059. var /** @type {?} */ childVisitor = this.viewBuilderFactory(this, guards);
  27060. this.children.push(childVisitor);
  27061. childVisitor.visitAll(ast.variables, ast.children);
  27062. }
  27063. };
  27064. /**
  27065. * @param {?} ast
  27066. * @param {?} context
  27067. * @return {?}
  27068. */
  27069. ViewBuilder.prototype.visitElement = /**
  27070. * @param {?} ast
  27071. * @param {?} context
  27072. * @return {?}
  27073. */
  27074. function (ast, context) {
  27075. var _this = this;
  27076. this.visitElementOrTemplate(ast);
  27077. var /** @type {?} */ inputDefs = [];
  27078. var /** @type {?} */ updateRendererExpressions = [];
  27079. var /** @type {?} */ outputDefs = [];
  27080. ast.inputs.forEach(function (inputAst) {
  27081. _this.updates.push({ context: _this.component, value: inputAst.value, sourceSpan: inputAst.sourceSpan });
  27082. });
  27083. templateVisitAll(this, ast.children);
  27084. };
  27085. /**
  27086. * @param {?} ast
  27087. * @return {?}
  27088. */
  27089. ViewBuilder.prototype.visitElementOrTemplate = /**
  27090. * @param {?} ast
  27091. * @return {?}
  27092. */
  27093. function (ast) {
  27094. var _this = this;
  27095. ast.directives.forEach(function (dirAst) { _this.visitDirective(dirAst); });
  27096. ast.references.forEach(function (ref) {
  27097. var /** @type {?} */ outputVarType = /** @type {?} */ ((null));
  27098. // Note: The old view compiler used to use an `any` type
  27099. // for directives exposed via `exportAs`.
  27100. // We keep this behaivor behind a flag for now.
  27101. if (ref.value && ref.value.identifier && _this.options.fullTemplateTypeCheck) {
  27102. outputVarType = ref.value.identifier.reference;
  27103. }
  27104. else {
  27105. outputVarType = BuiltinTypeName.Dynamic;
  27106. }
  27107. _this.refOutputVars.set(ref.name, outputVarType);
  27108. });
  27109. ast.outputs.forEach(function (outputAst) {
  27110. _this.actions.push({ context: _this.component, value: outputAst.handler, sourceSpan: outputAst.sourceSpan });
  27111. });
  27112. };
  27113. /**
  27114. * @param {?} dirAst
  27115. * @return {?}
  27116. */
  27117. ViewBuilder.prototype.visitDirective = /**
  27118. * @param {?} dirAst
  27119. * @return {?}
  27120. */
  27121. function (dirAst) {
  27122. var _this = this;
  27123. var /** @type {?} */ dirType = dirAst.directive.type.reference;
  27124. dirAst.inputs.forEach(function (input) {
  27125. return _this.updates.push({ context: _this.component, value: input.value, sourceSpan: input.sourceSpan });
  27126. });
  27127. // Note: The old view compiler used to use an `any` type
  27128. // for expressions in host properties / events.
  27129. // We keep this behaivor behind a flag for now.
  27130. if (this.options.fullTemplateTypeCheck) {
  27131. dirAst.hostProperties.forEach(function (inputAst) {
  27132. return _this.updates.push({ context: dirType, value: inputAst.value, sourceSpan: inputAst.sourceSpan });
  27133. });
  27134. dirAst.hostEvents.forEach(function (hostEventAst) {
  27135. return _this.actions.push({
  27136. context: dirType,
  27137. value: hostEventAst.handler,
  27138. sourceSpan: hostEventAst.sourceSpan
  27139. });
  27140. });
  27141. }
  27142. };
  27143. /**
  27144. * @param {?} name
  27145. * @return {?}
  27146. */
  27147. ViewBuilder.prototype.getLocal = /**
  27148. * @param {?} name
  27149. * @return {?}
  27150. */
  27151. function (name) {
  27152. if (name == EventHandlerVars.event.name) {
  27153. return variable(this.getOutputVar(BuiltinTypeName.Dynamic));
  27154. }
  27155. for (var /** @type {?} */ currBuilder = this; currBuilder; currBuilder = currBuilder.parent) {
  27156. var /** @type {?} */ outputVarType = void 0;
  27157. // check references
  27158. outputVarType = currBuilder.refOutputVars.get(name);
  27159. if (outputVarType == null) {
  27160. // check variables
  27161. var /** @type {?} */ varAst = currBuilder.variables.find(function (varAst) { return varAst.name === name; });
  27162. if (varAst) {
  27163. outputVarType = BuiltinTypeName.Dynamic;
  27164. }
  27165. }
  27166. if (outputVarType != null) {
  27167. return variable(this.getOutputVar(outputVarType));
  27168. }
  27169. }
  27170. return null;
  27171. };
  27172. /**
  27173. * @param {?} name
  27174. * @return {?}
  27175. */
  27176. ViewBuilder.prototype.pipeOutputVar = /**
  27177. * @param {?} name
  27178. * @return {?}
  27179. */
  27180. function (name) {
  27181. var /** @type {?} */ pipe = this.pipes.get(name);
  27182. if (!pipe) {
  27183. throw new Error("Illegal State: Could not find pipe " + name + " in template of " + this.component);
  27184. }
  27185. return this.getOutputVar(pipe);
  27186. };
  27187. /**
  27188. * @param {?} expression
  27189. * @return {?}
  27190. */
  27191. ViewBuilder.prototype.preprocessUpdateExpression = /**
  27192. * @param {?} expression
  27193. * @return {?}
  27194. */
  27195. function (expression) {
  27196. var _this = this;
  27197. return {
  27198. sourceSpan: expression.sourceSpan,
  27199. context: expression.context,
  27200. value: convertPropertyBindingBuiltins({
  27201. createLiteralArrayConverter: function (argCount) {
  27202. return function (args) {
  27203. var /** @type {?} */ arr = literalArr(args);
  27204. // Note: The old view compiler used to use an `any` type
  27205. // for arrays.
  27206. return _this.options.fullTemplateTypeCheck ? arr : arr.cast(DYNAMIC_TYPE);
  27207. };
  27208. },
  27209. createLiteralMapConverter: function (keys) {
  27210. return function (values) {
  27211. var /** @type {?} */ entries = keys.map(function (k, i) {
  27212. return ({
  27213. key: k.key,
  27214. value: values[i],
  27215. quoted: k.quoted,
  27216. });
  27217. });
  27218. var /** @type {?} */ map = literalMap(entries);
  27219. // Note: The old view compiler used to use an `any` type
  27220. // for maps.
  27221. return _this.options.fullTemplateTypeCheck ? map : map.cast(DYNAMIC_TYPE);
  27222. };
  27223. },
  27224. createPipeConverter: function (name, argCount) {
  27225. return function (args) {
  27226. // Note: The old view compiler used to use an `any` type
  27227. // for pipes.
  27228. var /** @type {?} */ pipeExpr = _this.options.fullTemplateTypeCheck ?
  27229. variable(_this.pipeOutputVar(name)) :
  27230. variable(_this.getOutputVar(BuiltinTypeName.Dynamic));
  27231. return pipeExpr.callMethod('transform', args);
  27232. };
  27233. },
  27234. }, expression.value)
  27235. };
  27236. };
  27237. /**
  27238. * @param {?} ast
  27239. * @param {?} context
  27240. * @return {?}
  27241. */
  27242. ViewBuilder.prototype.visitNgContent = /**
  27243. * @param {?} ast
  27244. * @param {?} context
  27245. * @return {?}
  27246. */
  27247. function (ast, context) { };
  27248. /**
  27249. * @param {?} ast
  27250. * @param {?} context
  27251. * @return {?}
  27252. */
  27253. ViewBuilder.prototype.visitText = /**
  27254. * @param {?} ast
  27255. * @param {?} context
  27256. * @return {?}
  27257. */
  27258. function (ast, context) { };
  27259. /**
  27260. * @param {?} ast
  27261. * @param {?} context
  27262. * @return {?}
  27263. */
  27264. ViewBuilder.prototype.visitDirectiveProperty = /**
  27265. * @param {?} ast
  27266. * @param {?} context
  27267. * @return {?}
  27268. */
  27269. function (ast, context) { };
  27270. /**
  27271. * @param {?} ast
  27272. * @param {?} context
  27273. * @return {?}
  27274. */
  27275. ViewBuilder.prototype.visitReference = /**
  27276. * @param {?} ast
  27277. * @param {?} context
  27278. * @return {?}
  27279. */
  27280. function (ast, context) { };
  27281. /**
  27282. * @param {?} ast
  27283. * @param {?} context
  27284. * @return {?}
  27285. */
  27286. ViewBuilder.prototype.visitVariable = /**
  27287. * @param {?} ast
  27288. * @param {?} context
  27289. * @return {?}
  27290. */
  27291. function (ast, context) { };
  27292. /**
  27293. * @param {?} ast
  27294. * @param {?} context
  27295. * @return {?}
  27296. */
  27297. ViewBuilder.prototype.visitEvent = /**
  27298. * @param {?} ast
  27299. * @param {?} context
  27300. * @return {?}
  27301. */
  27302. function (ast, context) { };
  27303. /**
  27304. * @param {?} ast
  27305. * @param {?} context
  27306. * @return {?}
  27307. */
  27308. ViewBuilder.prototype.visitElementProperty = /**
  27309. * @param {?} ast
  27310. * @param {?} context
  27311. * @return {?}
  27312. */
  27313. function (ast, context) { };
  27314. /**
  27315. * @param {?} ast
  27316. * @param {?} context
  27317. * @return {?}
  27318. */
  27319. ViewBuilder.prototype.visitAttr = /**
  27320. * @param {?} ast
  27321. * @param {?} context
  27322. * @return {?}
  27323. */
  27324. function (ast, context) { };
  27325. return ViewBuilder;
  27326. }());
  27327. /**
  27328. * @fileoverview added by tsickle
  27329. * @suppress {checkTypes} checked by tsc
  27330. */
  27331. /**
  27332. * @license
  27333. * Copyright Google Inc. All Rights Reserved.
  27334. *
  27335. * Use of this source code is governed by an MIT-style license that can be
  27336. * found in the LICENSE file at https://angular.io/license
  27337. */
  27338. var CLASS_ATTR$1 = 'class';
  27339. var STYLE_ATTR = 'style';
  27340. var IMPLICIT_TEMPLATE_VAR = '\$implicit';
  27341. var ViewCompileResult = /** @class */ (function () {
  27342. function ViewCompileResult(viewClassVar, rendererTypeVar) {
  27343. this.viewClassVar = viewClassVar;
  27344. this.rendererTypeVar = rendererTypeVar;
  27345. }
  27346. return ViewCompileResult;
  27347. }());
  27348. var ViewCompiler = /** @class */ (function () {
  27349. function ViewCompiler(_reflector) {
  27350. this._reflector = _reflector;
  27351. }
  27352. /**
  27353. * @param {?} outputCtx
  27354. * @param {?} component
  27355. * @param {?} template
  27356. * @param {?} styles
  27357. * @param {?} usedPipes
  27358. * @return {?}
  27359. */
  27360. ViewCompiler.prototype.compileComponent = /**
  27361. * @param {?} outputCtx
  27362. * @param {?} component
  27363. * @param {?} template
  27364. * @param {?} styles
  27365. * @param {?} usedPipes
  27366. * @return {?}
  27367. */
  27368. function (outputCtx, component, template, styles, usedPipes) {
  27369. var _this = this;
  27370. var /** @type {?} */ embeddedViewCount = 0;
  27371. var /** @type {?} */ staticQueryIds = findStaticQueryIds(template);
  27372. var /** @type {?} */ renderComponentVarName = /** @type {?} */ ((undefined));
  27373. if (!component.isHost) {
  27374. var /** @type {?} */ template_1 = /** @type {?} */ ((component.template));
  27375. var /** @type {?} */ customRenderData = [];
  27376. if (template_1.animations && template_1.animations.length) {
  27377. customRenderData.push(new LiteralMapEntry('animation', convertValueToOutputAst(outputCtx, template_1.animations), true));
  27378. }
  27379. var /** @type {?} */ renderComponentVar = variable(rendererTypeName(component.type.reference));
  27380. renderComponentVarName = /** @type {?} */ ((renderComponentVar.name));
  27381. outputCtx.statements.push(renderComponentVar
  27382. .set(importExpr(Identifiers.createRendererType2).callFn([new LiteralMapExpr([
  27383. new LiteralMapEntry('encapsulation', literal(template_1.encapsulation), false),
  27384. new LiteralMapEntry('styles', styles, false),
  27385. new LiteralMapEntry('data', new LiteralMapExpr(customRenderData), false)
  27386. ])]))
  27387. .toDeclStmt(importType(Identifiers.RendererType2), [StmtModifier.Final, StmtModifier.Exported]));
  27388. }
  27389. var /** @type {?} */ viewBuilderFactory = function (parent) {
  27390. var /** @type {?} */ embeddedViewIndex = embeddedViewCount++;
  27391. return new ViewBuilder$1(_this._reflector, outputCtx, parent, component, embeddedViewIndex, usedPipes, staticQueryIds, viewBuilderFactory);
  27392. };
  27393. var /** @type {?} */ visitor = viewBuilderFactory(null);
  27394. visitor.visitAll([], template);
  27395. (_a = outputCtx.statements).push.apply(_a, visitor.build());
  27396. return new ViewCompileResult(visitor.viewName, renderComponentVarName);
  27397. var _a;
  27398. };
  27399. return ViewCompiler;
  27400. }());
  27401. var LOG_VAR$1 = variable('_l');
  27402. var VIEW_VAR = variable('_v');
  27403. var CHECK_VAR = variable('_ck');
  27404. var COMP_VAR = variable('_co');
  27405. var EVENT_NAME_VAR = variable('en');
  27406. var ALLOW_DEFAULT_VAR = variable("ad");
  27407. var ViewBuilder$1 = /** @class */ (function () {
  27408. function ViewBuilder(reflector, outputCtx, parent, component, embeddedViewIndex, usedPipes, staticQueryIds, viewBuilderFactory) {
  27409. this.reflector = reflector;
  27410. this.outputCtx = outputCtx;
  27411. this.parent = parent;
  27412. this.component = component;
  27413. this.embeddedViewIndex = embeddedViewIndex;
  27414. this.usedPipes = usedPipes;
  27415. this.staticQueryIds = staticQueryIds;
  27416. this.viewBuilderFactory = viewBuilderFactory;
  27417. this.nodes = [];
  27418. this.purePipeNodeIndices = Object.create(null);
  27419. this.refNodeIndices = Object.create(null);
  27420. this.variables = [];
  27421. this.children = [];
  27422. // TODO(tbosch): The old view compiler used to use an `any` type
  27423. // for the context in any embedded view. We keep this behaivor for now
  27424. // to be able to introduce the new view compiler without too many errors.
  27425. this.compType = this.embeddedViewIndex > 0 ?
  27426. DYNAMIC_TYPE : /** @type {?} */
  27427. ((expressionType(outputCtx.importExpr(this.component.type.reference))));
  27428. this.viewName = viewClassName(this.component.type.reference, this.embeddedViewIndex);
  27429. }
  27430. /**
  27431. * @param {?} variables
  27432. * @param {?} astNodes
  27433. * @return {?}
  27434. */
  27435. ViewBuilder.prototype.visitAll = /**
  27436. * @param {?} variables
  27437. * @param {?} astNodes
  27438. * @return {?}
  27439. */
  27440. function (variables, astNodes) {
  27441. var _this = this;
  27442. this.variables = variables;
  27443. // create the pipes for the pure pipes immediately, so that we know their indices.
  27444. if (!this.parent) {
  27445. this.usedPipes.forEach(function (pipe) {
  27446. if (pipe.pure) {
  27447. _this.purePipeNodeIndices[pipe.name] = _this._createPipe(null, pipe);
  27448. }
  27449. });
  27450. }
  27451. if (!this.parent) {
  27452. var /** @type {?} */ queryIds_1 = staticViewQueryIds(this.staticQueryIds);
  27453. this.component.viewQueries.forEach(function (query, queryIndex) {
  27454. // Note: queries start with id 1 so we can use the number in a Bloom filter!
  27455. var /** @type {?} */ queryId = queryIndex + 1;
  27456. var /** @type {?} */ bindingType = query.first ? 0 /* First */ : 1;
  27457. var /** @type {?} */ flags = 134217728 /* TypeViewQuery */ | calcStaticDynamicQueryFlags(queryIds_1, queryId, query.first);
  27458. _this.nodes.push(function () {
  27459. return ({
  27460. sourceSpan: null,
  27461. nodeFlags: flags,
  27462. nodeDef: importExpr(Identifiers.queryDef).callFn([
  27463. literal(flags), literal(queryId),
  27464. new LiteralMapExpr([new LiteralMapEntry(query.propertyName, literal(bindingType), false)])
  27465. ])
  27466. });
  27467. });
  27468. });
  27469. }
  27470. templateVisitAll(this, astNodes);
  27471. if (this.parent && (astNodes.length === 0 || needsAdditionalRootNode(astNodes))) {
  27472. // if the view is an embedded view, then we need to add an additional root node in some cases
  27473. this.nodes.push(function () {
  27474. return ({
  27475. sourceSpan: null,
  27476. nodeFlags: 1 /* TypeElement */,
  27477. nodeDef: importExpr(Identifiers.anchorDef).callFn([
  27478. literal(0 /* None */), NULL_EXPR, NULL_EXPR, literal(0)
  27479. ])
  27480. });
  27481. });
  27482. }
  27483. };
  27484. /**
  27485. * @param {?=} targetStatements
  27486. * @return {?}
  27487. */
  27488. ViewBuilder.prototype.build = /**
  27489. * @param {?=} targetStatements
  27490. * @return {?}
  27491. */
  27492. function (targetStatements) {
  27493. if (targetStatements === void 0) { targetStatements = []; }
  27494. this.children.forEach(function (child) { return child.build(targetStatements); });
  27495. var _a = this._createNodeExpressions(), updateRendererStmts = _a.updateRendererStmts, updateDirectivesStmts = _a.updateDirectivesStmts, nodeDefExprs = _a.nodeDefExprs;
  27496. var /** @type {?} */ updateRendererFn = this._createUpdateFn(updateRendererStmts);
  27497. var /** @type {?} */ updateDirectivesFn = this._createUpdateFn(updateDirectivesStmts);
  27498. var /** @type {?} */ viewFlags = 0;
  27499. if (!this.parent && this.component.changeDetection === ChangeDetectionStrategy.OnPush) {
  27500. viewFlags |= 2 /* OnPush */;
  27501. }
  27502. var /** @type {?} */ viewFactory = new DeclareFunctionStmt(this.viewName, [new FnParam(/** @type {?} */ ((LOG_VAR$1.name)))], [new ReturnStatement(importExpr(Identifiers.viewDef).callFn([
  27503. literal(viewFlags),
  27504. literalArr(nodeDefExprs),
  27505. updateDirectivesFn,
  27506. updateRendererFn,
  27507. ]))], importType(Identifiers.ViewDefinition), this.embeddedViewIndex === 0 ? [StmtModifier.Exported] : []);
  27508. targetStatements.push(viewFactory);
  27509. return targetStatements;
  27510. };
  27511. /**
  27512. * @param {?} updateStmts
  27513. * @return {?}
  27514. */
  27515. ViewBuilder.prototype._createUpdateFn = /**
  27516. * @param {?} updateStmts
  27517. * @return {?}
  27518. */
  27519. function (updateStmts) {
  27520. var /** @type {?} */ updateFn;
  27521. if (updateStmts.length > 0) {
  27522. var /** @type {?} */ preStmts = [];
  27523. if (!this.component.isHost && findReadVarNames(updateStmts).has(/** @type {?} */ ((COMP_VAR.name)))) {
  27524. preStmts.push(COMP_VAR.set(VIEW_VAR.prop('component')).toDeclStmt(this.compType));
  27525. }
  27526. updateFn = fn([
  27527. new FnParam(/** @type {?} */ ((CHECK_VAR.name)), INFERRED_TYPE),
  27528. new FnParam(/** @type {?} */ ((VIEW_VAR.name)), INFERRED_TYPE)
  27529. ], preStmts.concat(updateStmts), INFERRED_TYPE);
  27530. }
  27531. else {
  27532. updateFn = NULL_EXPR;
  27533. }
  27534. return updateFn;
  27535. };
  27536. /**
  27537. * @param {?} ast
  27538. * @param {?} context
  27539. * @return {?}
  27540. */
  27541. ViewBuilder.prototype.visitNgContent = /**
  27542. * @param {?} ast
  27543. * @param {?} context
  27544. * @return {?}
  27545. */
  27546. function (ast, context) {
  27547. // ngContentDef(ngContentIndex: number, index: number): NodeDef;
  27548. this.nodes.push(function () {
  27549. return ({
  27550. sourceSpan: ast.sourceSpan,
  27551. nodeFlags: 8 /* TypeNgContent */,
  27552. nodeDef: importExpr(Identifiers.ngContentDef).callFn([
  27553. literal(ast.ngContentIndex), literal(ast.index)
  27554. ])
  27555. });
  27556. });
  27557. };
  27558. /**
  27559. * @param {?} ast
  27560. * @param {?} context
  27561. * @return {?}
  27562. */
  27563. ViewBuilder.prototype.visitText = /**
  27564. * @param {?} ast
  27565. * @param {?} context
  27566. * @return {?}
  27567. */
  27568. function (ast, context) {
  27569. // Static text nodes have no check function
  27570. var /** @type {?} */ checkIndex = -1;
  27571. this.nodes.push(function () {
  27572. return ({
  27573. sourceSpan: ast.sourceSpan,
  27574. nodeFlags: 2 /* TypeText */,
  27575. nodeDef: importExpr(Identifiers.textDef).callFn([
  27576. literal(checkIndex),
  27577. literal(ast.ngContentIndex),
  27578. literalArr([literal(ast.value)]),
  27579. ])
  27580. });
  27581. });
  27582. };
  27583. /**
  27584. * @param {?} ast
  27585. * @param {?} context
  27586. * @return {?}
  27587. */
  27588. ViewBuilder.prototype.visitBoundText = /**
  27589. * @param {?} ast
  27590. * @param {?} context
  27591. * @return {?}
  27592. */
  27593. function (ast, context) {
  27594. var _this = this;
  27595. var /** @type {?} */ nodeIndex = this.nodes.length;
  27596. // reserve the space in the nodeDefs array
  27597. this.nodes.push(/** @type {?} */ ((null)));
  27598. var /** @type {?} */ astWithSource = /** @type {?} */ (ast.value);
  27599. var /** @type {?} */ inter = /** @type {?} */ (astWithSource.ast);
  27600. var /** @type {?} */ updateRendererExpressions = inter.expressions.map(function (expr, bindingIndex) {
  27601. return _this._preprocessUpdateExpression({ nodeIndex: nodeIndex, bindingIndex: bindingIndex, sourceSpan: ast.sourceSpan, context: COMP_VAR, value: expr });
  27602. });
  27603. // Check index is the same as the node index during compilation
  27604. // They might only differ at runtime
  27605. var /** @type {?} */ checkIndex = nodeIndex;
  27606. this.nodes[nodeIndex] = function () {
  27607. return ({
  27608. sourceSpan: ast.sourceSpan,
  27609. nodeFlags: 2 /* TypeText */,
  27610. nodeDef: importExpr(Identifiers.textDef).callFn([
  27611. literal(checkIndex),
  27612. literal(ast.ngContentIndex),
  27613. literalArr(inter.strings.map(function (s) { return literal(s); })),
  27614. ]),
  27615. updateRenderer: updateRendererExpressions
  27616. });
  27617. };
  27618. };
  27619. /**
  27620. * @param {?} ast
  27621. * @param {?} context
  27622. * @return {?}
  27623. */
  27624. ViewBuilder.prototype.visitEmbeddedTemplate = /**
  27625. * @param {?} ast
  27626. * @param {?} context
  27627. * @return {?}
  27628. */
  27629. function (ast, context) {
  27630. var _this = this;
  27631. var /** @type {?} */ nodeIndex = this.nodes.length;
  27632. // reserve the space in the nodeDefs array
  27633. this.nodes.push(/** @type {?} */ ((null)));
  27634. var _a = this._visitElementOrTemplate(nodeIndex, ast), flags = _a.flags, queryMatchesExpr = _a.queryMatchesExpr, hostEvents = _a.hostEvents;
  27635. var /** @type {?} */ childVisitor = this.viewBuilderFactory(this);
  27636. this.children.push(childVisitor);
  27637. childVisitor.visitAll(ast.variables, ast.children);
  27638. var /** @type {?} */ childCount = this.nodes.length - nodeIndex - 1;
  27639. // anchorDef(
  27640. // flags: NodeFlags, matchedQueries: [string, QueryValueType][], ngContentIndex: number,
  27641. // childCount: number, handleEventFn?: ElementHandleEventFn, templateFactory?:
  27642. // ViewDefinitionFactory): NodeDef;
  27643. this.nodes[nodeIndex] = function () {
  27644. return ({
  27645. sourceSpan: ast.sourceSpan,
  27646. nodeFlags: 1 /* TypeElement */ | flags,
  27647. nodeDef: importExpr(Identifiers.anchorDef).callFn([
  27648. literal(flags),
  27649. queryMatchesExpr,
  27650. literal(ast.ngContentIndex),
  27651. literal(childCount),
  27652. _this._createElementHandleEventFn(nodeIndex, hostEvents),
  27653. variable(childVisitor.viewName),
  27654. ])
  27655. });
  27656. };
  27657. };
  27658. /**
  27659. * @param {?} ast
  27660. * @param {?} context
  27661. * @return {?}
  27662. */
  27663. ViewBuilder.prototype.visitElement = /**
  27664. * @param {?} ast
  27665. * @param {?} context
  27666. * @return {?}
  27667. */
  27668. function (ast, context) {
  27669. var _this = this;
  27670. var /** @type {?} */ nodeIndex = this.nodes.length;
  27671. // reserve the space in the nodeDefs array so we can add children
  27672. this.nodes.push(/** @type {?} */ ((null)));
  27673. // Using a null element name creates an anchor.
  27674. var /** @type {?} */ elName = isNgContainer(ast.name) ? null : ast.name;
  27675. var _a = this._visitElementOrTemplate(nodeIndex, ast), flags = _a.flags, usedEvents = _a.usedEvents, queryMatchesExpr = _a.queryMatchesExpr, dirHostBindings = _a.hostBindings, hostEvents = _a.hostEvents;
  27676. var /** @type {?} */ inputDefs = [];
  27677. var /** @type {?} */ updateRendererExpressions = [];
  27678. var /** @type {?} */ outputDefs = [];
  27679. if (elName) {
  27680. var /** @type {?} */ hostBindings = ast.inputs
  27681. .map(function (inputAst) {
  27682. return ({
  27683. context: /** @type {?} */ (COMP_VAR),
  27684. inputAst: inputAst,
  27685. dirAst: /** @type {?} */ (null),
  27686. });
  27687. })
  27688. .concat(dirHostBindings);
  27689. if (hostBindings.length) {
  27690. updateRendererExpressions =
  27691. hostBindings.map(function (hostBinding, bindingIndex) {
  27692. return _this._preprocessUpdateExpression({
  27693. context: hostBinding.context,
  27694. nodeIndex: nodeIndex,
  27695. bindingIndex: bindingIndex,
  27696. sourceSpan: hostBinding.inputAst.sourceSpan,
  27697. value: hostBinding.inputAst.value
  27698. });
  27699. });
  27700. inputDefs = hostBindings.map(function (hostBinding) { return elementBindingDef(hostBinding.inputAst, hostBinding.dirAst); });
  27701. }
  27702. outputDefs = usedEvents.map(function (_a) {
  27703. var target = _a[0], eventName = _a[1];
  27704. return literalArr([literal(target), literal(eventName)]);
  27705. });
  27706. }
  27707. templateVisitAll(this, ast.children);
  27708. var /** @type {?} */ childCount = this.nodes.length - nodeIndex - 1;
  27709. var /** @type {?} */ compAst = ast.directives.find(function (dirAst) { return dirAst.directive.isComponent; });
  27710. var /** @type {?} */ compRendererType = /** @type {?} */ (NULL_EXPR);
  27711. var /** @type {?} */ compView = /** @type {?} */ (NULL_EXPR);
  27712. if (compAst) {
  27713. compView = this.outputCtx.importExpr(compAst.directive.componentViewType);
  27714. compRendererType = this.outputCtx.importExpr(compAst.directive.rendererType);
  27715. }
  27716. // Check index is the same as the node index during compilation
  27717. // They might only differ at runtime
  27718. var /** @type {?} */ checkIndex = nodeIndex;
  27719. this.nodes[nodeIndex] = function () {
  27720. return ({
  27721. sourceSpan: ast.sourceSpan,
  27722. nodeFlags: 1 /* TypeElement */ | flags,
  27723. nodeDef: importExpr(Identifiers.elementDef).callFn([
  27724. literal(checkIndex),
  27725. literal(flags),
  27726. queryMatchesExpr,
  27727. literal(ast.ngContentIndex),
  27728. literal(childCount),
  27729. literal(elName),
  27730. elName ? fixedAttrsDef(ast) : NULL_EXPR,
  27731. inputDefs.length ? literalArr(inputDefs) : NULL_EXPR,
  27732. outputDefs.length ? literalArr(outputDefs) : NULL_EXPR,
  27733. _this._createElementHandleEventFn(nodeIndex, hostEvents),
  27734. compView,
  27735. compRendererType,
  27736. ]),
  27737. updateRenderer: updateRendererExpressions
  27738. });
  27739. };
  27740. };
  27741. /**
  27742. * @param {?} nodeIndex
  27743. * @param {?} ast
  27744. * @return {?}
  27745. */
  27746. ViewBuilder.prototype._visitElementOrTemplate = /**
  27747. * @param {?} nodeIndex
  27748. * @param {?} ast
  27749. * @return {?}
  27750. */
  27751. function (nodeIndex, ast) {
  27752. var _this = this;
  27753. var /** @type {?} */ flags = 0;
  27754. if (ast.hasViewContainer) {
  27755. flags |= 16777216 /* EmbeddedViews */;
  27756. }
  27757. var /** @type {?} */ usedEvents = new Map();
  27758. ast.outputs.forEach(function (event) {
  27759. var _a = elementEventNameAndTarget(event, null), name = _a.name, target = _a.target;
  27760. usedEvents.set(elementEventFullName(target, name), [target, name]);
  27761. });
  27762. ast.directives.forEach(function (dirAst) {
  27763. dirAst.hostEvents.forEach(function (event) {
  27764. var _a = elementEventNameAndTarget(event, dirAst), name = _a.name, target = _a.target;
  27765. usedEvents.set(elementEventFullName(target, name), [target, name]);
  27766. });
  27767. });
  27768. var /** @type {?} */ hostBindings = [];
  27769. var /** @type {?} */ hostEvents = [];
  27770. this._visitComponentFactoryResolverProvider(ast.directives);
  27771. ast.providers.forEach(function (providerAst, providerIndex) {
  27772. var /** @type {?} */ dirAst = /** @type {?} */ ((undefined));
  27773. var /** @type {?} */ dirIndex = /** @type {?} */ ((undefined));
  27774. ast.directives.forEach(function (localDirAst, i) {
  27775. if (localDirAst.directive.type.reference === tokenReference(providerAst.token)) {
  27776. dirAst = localDirAst;
  27777. dirIndex = i;
  27778. }
  27779. });
  27780. if (dirAst) {
  27781. 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;
  27782. hostBindings.push.apply(hostBindings, dirHostBindings);
  27783. hostEvents.push.apply(hostEvents, dirHostEvents);
  27784. }
  27785. else {
  27786. _this._visitProvider(providerAst, ast.queryMatches);
  27787. }
  27788. });
  27789. var /** @type {?} */ queryMatchExprs = [];
  27790. ast.queryMatches.forEach(function (match) {
  27791. var /** @type {?} */ valueType = /** @type {?} */ ((undefined));
  27792. if (tokenReference(match.value) ===
  27793. _this.reflector.resolveExternalReference(Identifiers.ElementRef)) {
  27794. valueType = 0 /* ElementRef */;
  27795. }
  27796. else if (tokenReference(match.value) ===
  27797. _this.reflector.resolveExternalReference(Identifiers.ViewContainerRef)) {
  27798. valueType = 3 /* ViewContainerRef */;
  27799. }
  27800. else if (tokenReference(match.value) ===
  27801. _this.reflector.resolveExternalReference(Identifiers.TemplateRef)) {
  27802. valueType = 2 /* TemplateRef */;
  27803. }
  27804. if (valueType != null) {
  27805. queryMatchExprs.push(literalArr([literal(match.queryId), literal(valueType)]));
  27806. }
  27807. });
  27808. ast.references.forEach(function (ref) {
  27809. var /** @type {?} */ valueType = /** @type {?} */ ((undefined));
  27810. if (!ref.value) {
  27811. valueType = 1 /* RenderElement */;
  27812. }
  27813. else if (tokenReference(ref.value) ===
  27814. _this.reflector.resolveExternalReference(Identifiers.TemplateRef)) {
  27815. valueType = 2 /* TemplateRef */;
  27816. }
  27817. if (valueType != null) {
  27818. _this.refNodeIndices[ref.name] = nodeIndex;
  27819. queryMatchExprs.push(literalArr([literal(ref.name), literal(valueType)]));
  27820. }
  27821. });
  27822. ast.outputs.forEach(function (outputAst) {
  27823. hostEvents.push({ context: COMP_VAR, eventAst: outputAst, dirAst: /** @type {?} */ ((null)) });
  27824. });
  27825. return {
  27826. flags: flags,
  27827. usedEvents: Array.from(usedEvents.values()),
  27828. queryMatchesExpr: queryMatchExprs.length ? literalArr(queryMatchExprs) : NULL_EXPR,
  27829. hostBindings: hostBindings,
  27830. hostEvents: hostEvents
  27831. };
  27832. };
  27833. /**
  27834. * @param {?} providerAst
  27835. * @param {?} dirAst
  27836. * @param {?} directiveIndex
  27837. * @param {?} elementNodeIndex
  27838. * @param {?} refs
  27839. * @param {?} queryMatches
  27840. * @param {?} usedEvents
  27841. * @param {?} queryIds
  27842. * @return {?}
  27843. */
  27844. ViewBuilder.prototype._visitDirective = /**
  27845. * @param {?} providerAst
  27846. * @param {?} dirAst
  27847. * @param {?} directiveIndex
  27848. * @param {?} elementNodeIndex
  27849. * @param {?} refs
  27850. * @param {?} queryMatches
  27851. * @param {?} usedEvents
  27852. * @param {?} queryIds
  27853. * @return {?}
  27854. */
  27855. function (providerAst, dirAst, directiveIndex, elementNodeIndex, refs, queryMatches, usedEvents, queryIds) {
  27856. var _this = this;
  27857. var /** @type {?} */ nodeIndex = this.nodes.length;
  27858. // reserve the space in the nodeDefs array so we can add children
  27859. this.nodes.push(/** @type {?} */ ((null)));
  27860. dirAst.directive.queries.forEach(function (query, queryIndex) {
  27861. var /** @type {?} */ queryId = dirAst.contentQueryStartId + queryIndex;
  27862. var /** @type {?} */ flags = 67108864 /* TypeContentQuery */ | calcStaticDynamicQueryFlags(queryIds, queryId, query.first);
  27863. var /** @type {?} */ bindingType = query.first ? 0 /* First */ : 1;
  27864. _this.nodes.push(function () {
  27865. return ({
  27866. sourceSpan: dirAst.sourceSpan,
  27867. nodeFlags: flags,
  27868. nodeDef: importExpr(Identifiers.queryDef).callFn([
  27869. literal(flags), literal(queryId),
  27870. new LiteralMapExpr([new LiteralMapEntry(query.propertyName, literal(bindingType), false)])
  27871. ]),
  27872. });
  27873. });
  27874. });
  27875. // Note: the operation below might also create new nodeDefs,
  27876. // but we don't want them to be a child of a directive,
  27877. // as they might be a provider/pipe on their own.
  27878. // I.e. we only allow queries as children of directives nodes.
  27879. var /** @type {?} */ childCount = this.nodes.length - nodeIndex - 1;
  27880. var _a = this._visitProviderOrDirective(providerAst, queryMatches), flags = _a.flags, queryMatchExprs = _a.queryMatchExprs, providerExpr = _a.providerExpr, depsExpr = _a.depsExpr;
  27881. refs.forEach(function (ref) {
  27882. if (ref.value && tokenReference(ref.value) === tokenReference(providerAst.token)) {
  27883. _this.refNodeIndices[ref.name] = nodeIndex;
  27884. queryMatchExprs.push(literalArr([literal(ref.name), literal(4 /* Provider */)]));
  27885. }
  27886. });
  27887. if (dirAst.directive.isComponent) {
  27888. flags |= 32768 /* Component */;
  27889. }
  27890. var /** @type {?} */ inputDefs = dirAst.inputs.map(function (inputAst, inputIndex) {
  27891. var /** @type {?} */ mapValue = literalArr([literal(inputIndex), literal(inputAst.directiveName)]);
  27892. // Note: it's important to not quote the key so that we can capture renames by minifiers!
  27893. return new LiteralMapEntry(inputAst.directiveName, mapValue, false);
  27894. });
  27895. var /** @type {?} */ outputDefs = [];
  27896. var /** @type {?} */ dirMeta = dirAst.directive;
  27897. Object.keys(dirMeta.outputs).forEach(function (propName) {
  27898. var /** @type {?} */ eventName = dirMeta.outputs[propName];
  27899. if (usedEvents.has(eventName)) {
  27900. // Note: it's important to not quote the key so that we can capture renames by minifiers!
  27901. outputDefs.push(new LiteralMapEntry(propName, literal(eventName), false));
  27902. }
  27903. });
  27904. var /** @type {?} */ updateDirectiveExpressions = [];
  27905. if (dirAst.inputs.length || (flags & (262144 /* DoCheck */ | 65536 /* OnInit */)) > 0) {
  27906. updateDirectiveExpressions =
  27907. dirAst.inputs.map(function (input, bindingIndex) {
  27908. return _this._preprocessUpdateExpression({
  27909. nodeIndex: nodeIndex,
  27910. bindingIndex: bindingIndex,
  27911. sourceSpan: input.sourceSpan,
  27912. context: COMP_VAR,
  27913. value: input.value
  27914. });
  27915. });
  27916. }
  27917. var /** @type {?} */ dirContextExpr = importExpr(Identifiers.nodeValue).callFn([VIEW_VAR, literal(nodeIndex)]);
  27918. var /** @type {?} */ hostBindings = dirAst.hostProperties.map(function (inputAst) {
  27919. return ({
  27920. context: dirContextExpr,
  27921. dirAst: dirAst,
  27922. inputAst: inputAst,
  27923. });
  27924. });
  27925. var /** @type {?} */ hostEvents = dirAst.hostEvents.map(function (hostEventAst) {
  27926. return ({
  27927. context: dirContextExpr,
  27928. eventAst: hostEventAst, dirAst: dirAst,
  27929. });
  27930. });
  27931. // Check index is the same as the node index during compilation
  27932. // They might only differ at runtime
  27933. var /** @type {?} */ checkIndex = nodeIndex;
  27934. this.nodes[nodeIndex] = function () {
  27935. return ({
  27936. sourceSpan: dirAst.sourceSpan,
  27937. nodeFlags: 16384 /* TypeDirective */ | flags,
  27938. nodeDef: importExpr(Identifiers.directiveDef).callFn([
  27939. literal(checkIndex),
  27940. literal(flags),
  27941. queryMatchExprs.length ? literalArr(queryMatchExprs) : NULL_EXPR,
  27942. literal(childCount),
  27943. providerExpr,
  27944. depsExpr,
  27945. inputDefs.length ? new LiteralMapExpr(inputDefs) : NULL_EXPR,
  27946. outputDefs.length ? new LiteralMapExpr(outputDefs) : NULL_EXPR,
  27947. ]),
  27948. updateDirectives: updateDirectiveExpressions,
  27949. directive: dirAst.directive.type,
  27950. });
  27951. };
  27952. return { hostBindings: hostBindings, hostEvents: hostEvents };
  27953. };
  27954. /**
  27955. * @param {?} providerAst
  27956. * @param {?} queryMatches
  27957. * @return {?}
  27958. */
  27959. ViewBuilder.prototype._visitProvider = /**
  27960. * @param {?} providerAst
  27961. * @param {?} queryMatches
  27962. * @return {?}
  27963. */
  27964. function (providerAst, queryMatches) {
  27965. this._addProviderNode(this._visitProviderOrDirective(providerAst, queryMatches));
  27966. };
  27967. /**
  27968. * @param {?} directives
  27969. * @return {?}
  27970. */
  27971. ViewBuilder.prototype._visitComponentFactoryResolverProvider = /**
  27972. * @param {?} directives
  27973. * @return {?}
  27974. */
  27975. function (directives) {
  27976. var /** @type {?} */ componentDirMeta = directives.find(function (dirAst) { return dirAst.directive.isComponent; });
  27977. if (componentDirMeta && componentDirMeta.directive.entryComponents.length) {
  27978. var _a = componentFactoryResolverProviderDef(this.reflector, this.outputCtx, 8192 /* PrivateProvider */, componentDirMeta.directive.entryComponents), providerExpr = _a.providerExpr, depsExpr = _a.depsExpr, flags = _a.flags, tokenExpr = _a.tokenExpr;
  27979. this._addProviderNode({
  27980. providerExpr: providerExpr,
  27981. depsExpr: depsExpr,
  27982. flags: flags,
  27983. tokenExpr: tokenExpr,
  27984. queryMatchExprs: [],
  27985. sourceSpan: componentDirMeta.sourceSpan
  27986. });
  27987. }
  27988. };
  27989. /**
  27990. * @param {?} data
  27991. * @return {?}
  27992. */
  27993. ViewBuilder.prototype._addProviderNode = /**
  27994. * @param {?} data
  27995. * @return {?}
  27996. */
  27997. function (data) {
  27998. var /** @type {?} */ nodeIndex = this.nodes.length;
  27999. // providerDef(
  28000. // flags: NodeFlags, matchedQueries: [string, QueryValueType][], token:any,
  28001. // value: any, deps: ([DepFlags, any] | any)[]): NodeDef;
  28002. this.nodes.push(function () {
  28003. return ({
  28004. sourceSpan: data.sourceSpan,
  28005. nodeFlags: data.flags,
  28006. nodeDef: importExpr(Identifiers.providerDef).callFn([
  28007. literal(data.flags),
  28008. data.queryMatchExprs.length ? literalArr(data.queryMatchExprs) : NULL_EXPR,
  28009. data.tokenExpr, data.providerExpr, data.depsExpr
  28010. ])
  28011. });
  28012. });
  28013. };
  28014. /**
  28015. * @param {?} providerAst
  28016. * @param {?} queryMatches
  28017. * @return {?}
  28018. */
  28019. ViewBuilder.prototype._visitProviderOrDirective = /**
  28020. * @param {?} providerAst
  28021. * @param {?} queryMatches
  28022. * @return {?}
  28023. */
  28024. function (providerAst, queryMatches) {
  28025. var /** @type {?} */ flags = 0;
  28026. var /** @type {?} */ queryMatchExprs = [];
  28027. queryMatches.forEach(function (match) {
  28028. if (tokenReference(match.value) === tokenReference(providerAst.token)) {
  28029. queryMatchExprs.push(literalArr([literal(match.queryId), literal(4 /* Provider */)]));
  28030. }
  28031. });
  28032. var _a = providerDef(this.outputCtx, providerAst), providerExpr = _a.providerExpr, depsExpr = _a.depsExpr, providerFlags = _a.flags, tokenExpr = _a.tokenExpr;
  28033. return {
  28034. flags: flags | providerFlags,
  28035. queryMatchExprs: queryMatchExprs,
  28036. providerExpr: providerExpr,
  28037. depsExpr: depsExpr,
  28038. tokenExpr: tokenExpr,
  28039. sourceSpan: providerAst.sourceSpan
  28040. };
  28041. };
  28042. /**
  28043. * @param {?} name
  28044. * @return {?}
  28045. */
  28046. ViewBuilder.prototype.getLocal = /**
  28047. * @param {?} name
  28048. * @return {?}
  28049. */
  28050. function (name) {
  28051. if (name == EventHandlerVars.event.name) {
  28052. return EventHandlerVars.event;
  28053. }
  28054. var /** @type {?} */ currViewExpr = VIEW_VAR;
  28055. for (var /** @type {?} */ currBuilder = this; currBuilder; currBuilder = currBuilder.parent,
  28056. currViewExpr = currViewExpr.prop('parent').cast(DYNAMIC_TYPE)) {
  28057. // check references
  28058. var /** @type {?} */ refNodeIndex = currBuilder.refNodeIndices[name];
  28059. if (refNodeIndex != null) {
  28060. return importExpr(Identifiers.nodeValue).callFn([currViewExpr, literal(refNodeIndex)]);
  28061. }
  28062. // check variables
  28063. var /** @type {?} */ varAst = currBuilder.variables.find(function (varAst) { return varAst.name === name; });
  28064. if (varAst) {
  28065. var /** @type {?} */ varValue = varAst.value || IMPLICIT_TEMPLATE_VAR;
  28066. return currViewExpr.prop('context').prop(varValue);
  28067. }
  28068. }
  28069. return null;
  28070. };
  28071. /**
  28072. * @param {?} sourceSpan
  28073. * @param {?} argCount
  28074. * @return {?}
  28075. */
  28076. ViewBuilder.prototype._createLiteralArrayConverter = /**
  28077. * @param {?} sourceSpan
  28078. * @param {?} argCount
  28079. * @return {?}
  28080. */
  28081. function (sourceSpan, argCount) {
  28082. if (argCount === 0) {
  28083. var /** @type {?} */ valueExpr_1 = importExpr(Identifiers.EMPTY_ARRAY);
  28084. return function () { return valueExpr_1; };
  28085. }
  28086. var /** @type {?} */ checkIndex = this.nodes.length;
  28087. this.nodes.push(function () {
  28088. return ({
  28089. sourceSpan: sourceSpan,
  28090. nodeFlags: 32 /* TypePureArray */,
  28091. nodeDef: importExpr(Identifiers.pureArrayDef).callFn([
  28092. literal(checkIndex),
  28093. literal(argCount),
  28094. ])
  28095. });
  28096. });
  28097. return function (args) { return callCheckStmt(checkIndex, args); };
  28098. };
  28099. /**
  28100. * @param {?} sourceSpan
  28101. * @param {?} keys
  28102. * @return {?}
  28103. */
  28104. ViewBuilder.prototype._createLiteralMapConverter = /**
  28105. * @param {?} sourceSpan
  28106. * @param {?} keys
  28107. * @return {?}
  28108. */
  28109. function (sourceSpan, keys) {
  28110. if (keys.length === 0) {
  28111. var /** @type {?} */ valueExpr_2 = importExpr(Identifiers.EMPTY_MAP);
  28112. return function () { return valueExpr_2; };
  28113. }
  28114. var /** @type {?} */ map = literalMap(keys.map(function (e, i) { return (__assign({}, e, { value: literal(i) })); }));
  28115. var /** @type {?} */ checkIndex = this.nodes.length;
  28116. this.nodes.push(function () {
  28117. return ({
  28118. sourceSpan: sourceSpan,
  28119. nodeFlags: 64 /* TypePureObject */,
  28120. nodeDef: importExpr(Identifiers.pureObjectDef).callFn([
  28121. literal(checkIndex),
  28122. map,
  28123. ])
  28124. });
  28125. });
  28126. return function (args) { return callCheckStmt(checkIndex, args); };
  28127. };
  28128. /**
  28129. * @param {?} expression
  28130. * @param {?} name
  28131. * @param {?} argCount
  28132. * @return {?}
  28133. */
  28134. ViewBuilder.prototype._createPipeConverter = /**
  28135. * @param {?} expression
  28136. * @param {?} name
  28137. * @param {?} argCount
  28138. * @return {?}
  28139. */
  28140. function (expression, name, argCount) {
  28141. var /** @type {?} */ pipe = /** @type {?} */ ((this.usedPipes.find(function (pipeSummary) { return pipeSummary.name === name; })));
  28142. if (pipe.pure) {
  28143. var /** @type {?} */ checkIndex_1 = this.nodes.length;
  28144. this.nodes.push(function () {
  28145. return ({
  28146. sourceSpan: expression.sourceSpan,
  28147. nodeFlags: 128 /* TypePurePipe */,
  28148. nodeDef: importExpr(Identifiers.purePipeDef).callFn([
  28149. literal(checkIndex_1),
  28150. literal(argCount),
  28151. ])
  28152. });
  28153. });
  28154. // find underlying pipe in the component view
  28155. var /** @type {?} */ compViewExpr = VIEW_VAR;
  28156. var /** @type {?} */ compBuilder = this;
  28157. while (compBuilder.parent) {
  28158. compBuilder = compBuilder.parent;
  28159. compViewExpr = compViewExpr.prop('parent').cast(DYNAMIC_TYPE);
  28160. }
  28161. var /** @type {?} */ pipeNodeIndex = compBuilder.purePipeNodeIndices[name];
  28162. var /** @type {?} */ pipeValueExpr_1 = importExpr(Identifiers.nodeValue).callFn([compViewExpr, literal(pipeNodeIndex)]);
  28163. return function (args) {
  28164. return callUnwrapValue(expression.nodeIndex, expression.bindingIndex, callCheckStmt(checkIndex_1, [pipeValueExpr_1].concat(args)));
  28165. };
  28166. }
  28167. else {
  28168. var /** @type {?} */ nodeIndex = this._createPipe(expression.sourceSpan, pipe);
  28169. var /** @type {?} */ nodeValueExpr_1 = importExpr(Identifiers.nodeValue).callFn([VIEW_VAR, literal(nodeIndex)]);
  28170. return function (args) {
  28171. return callUnwrapValue(expression.nodeIndex, expression.bindingIndex, nodeValueExpr_1.callMethod('transform', args));
  28172. };
  28173. }
  28174. };
  28175. /**
  28176. * @param {?} sourceSpan
  28177. * @param {?} pipe
  28178. * @return {?}
  28179. */
  28180. ViewBuilder.prototype._createPipe = /**
  28181. * @param {?} sourceSpan
  28182. * @param {?} pipe
  28183. * @return {?}
  28184. */
  28185. function (sourceSpan, pipe) {
  28186. var _this = this;
  28187. var /** @type {?} */ nodeIndex = this.nodes.length;
  28188. var /** @type {?} */ flags = 0;
  28189. pipe.type.lifecycleHooks.forEach(function (lifecycleHook) {
  28190. // for pipes, we only support ngOnDestroy
  28191. if (lifecycleHook === LifecycleHooks.OnDestroy) {
  28192. flags |= lifecycleHookToNodeFlag(lifecycleHook);
  28193. }
  28194. });
  28195. var /** @type {?} */ depExprs = pipe.type.diDeps.map(function (diDep) { return depDef(_this.outputCtx, diDep); });
  28196. // function pipeDef(
  28197. // flags: NodeFlags, ctor: any, deps: ([DepFlags, any] | any)[]): NodeDef
  28198. this.nodes.push(function () {
  28199. return ({
  28200. sourceSpan: sourceSpan,
  28201. nodeFlags: 16 /* TypePipe */,
  28202. nodeDef: importExpr(Identifiers.pipeDef).callFn([
  28203. literal(flags), _this.outputCtx.importExpr(pipe.type.reference), literalArr(depExprs)
  28204. ])
  28205. });
  28206. });
  28207. return nodeIndex;
  28208. };
  28209. /**
  28210. * For the AST in `UpdateExpression.value`:
  28211. * - create nodes for pipes, literal arrays and, literal maps,
  28212. * - update the AST to replace pipes, literal arrays and, literal maps with calls to check fn.
  28213. *
  28214. * WARNING: This might create new nodeDefs (for pipes and literal arrays and literal maps)!
  28215. * @param {?} expression
  28216. * @return {?}
  28217. */
  28218. ViewBuilder.prototype._preprocessUpdateExpression = /**
  28219. * For the AST in `UpdateExpression.value`:
  28220. * - create nodes for pipes, literal arrays and, literal maps,
  28221. * - update the AST to replace pipes, literal arrays and, literal maps with calls to check fn.
  28222. *
  28223. * WARNING: This might create new nodeDefs (for pipes and literal arrays and literal maps)!
  28224. * @param {?} expression
  28225. * @return {?}
  28226. */
  28227. function (expression) {
  28228. var _this = this;
  28229. return {
  28230. nodeIndex: expression.nodeIndex,
  28231. bindingIndex: expression.bindingIndex,
  28232. sourceSpan: expression.sourceSpan,
  28233. context: expression.context,
  28234. value: convertPropertyBindingBuiltins({
  28235. createLiteralArrayConverter: function (argCount) {
  28236. return _this._createLiteralArrayConverter(expression.sourceSpan, argCount);
  28237. },
  28238. createLiteralMapConverter: function (keys) {
  28239. return _this._createLiteralMapConverter(expression.sourceSpan, keys);
  28240. },
  28241. createPipeConverter: function (name, argCount) {
  28242. return _this._createPipeConverter(expression, name, argCount);
  28243. }
  28244. }, expression.value)
  28245. };
  28246. };
  28247. /**
  28248. * @return {?}
  28249. */
  28250. ViewBuilder.prototype._createNodeExpressions = /**
  28251. * @return {?}
  28252. */
  28253. function () {
  28254. var /** @type {?} */ self = this;
  28255. var /** @type {?} */ updateBindingCount = 0;
  28256. var /** @type {?} */ updateRendererStmts = [];
  28257. var /** @type {?} */ updateDirectivesStmts = [];
  28258. var /** @type {?} */ nodeDefExprs = this.nodes.map(function (factory, nodeIndex) {
  28259. var _a = factory(), nodeDef = _a.nodeDef, nodeFlags = _a.nodeFlags, updateDirectives = _a.updateDirectives, updateRenderer = _a.updateRenderer, sourceSpan = _a.sourceSpan;
  28260. if (updateRenderer) {
  28261. updateRendererStmts.push.apply(updateRendererStmts, createUpdateStatements(nodeIndex, sourceSpan, updateRenderer, false));
  28262. }
  28263. if (updateDirectives) {
  28264. updateDirectivesStmts.push.apply(updateDirectivesStmts, createUpdateStatements(nodeIndex, sourceSpan, updateDirectives, (nodeFlags & (262144 /* DoCheck */ | 65536 /* OnInit */)) > 0));
  28265. }
  28266. // We use a comma expression to call the log function before
  28267. // the nodeDef function, but still use the result of the nodeDef function
  28268. // as the value.
  28269. // Note: We only add the logger to elements / text nodes,
  28270. // so we don't generate too much code.
  28271. var /** @type {?} */ logWithNodeDef = nodeFlags & 3 /* CatRenderNode */ ?
  28272. new CommaExpr([LOG_VAR$1.callFn([]).callFn([]), nodeDef]) :
  28273. nodeDef;
  28274. return applySourceSpanToExpressionIfNeeded(logWithNodeDef, sourceSpan);
  28275. });
  28276. return { updateRendererStmts: updateRendererStmts, updateDirectivesStmts: updateDirectivesStmts, nodeDefExprs: nodeDefExprs };
  28277. /**
  28278. * @param {?} nodeIndex
  28279. * @param {?} sourceSpan
  28280. * @param {?} expressions
  28281. * @param {?} allowEmptyExprs
  28282. * @return {?}
  28283. */
  28284. function createUpdateStatements(nodeIndex, sourceSpan, expressions, allowEmptyExprs) {
  28285. var /** @type {?} */ updateStmts = [];
  28286. var /** @type {?} */ exprs = expressions.map(function (_a) {
  28287. var sourceSpan = _a.sourceSpan, context = _a.context, value = _a.value;
  28288. var /** @type {?} */ bindingId = "" + updateBindingCount++;
  28289. var /** @type {?} */ nameResolver = context === COMP_VAR ? self : null;
  28290. var _b = convertPropertyBinding(nameResolver, context, value, bindingId, BindingForm.General), stmts = _b.stmts, currValExpr = _b.currValExpr;
  28291. updateStmts.push.apply(updateStmts, stmts.map(function (stmt) { return applySourceSpanToStatementIfNeeded(stmt, sourceSpan); }));
  28292. return applySourceSpanToExpressionIfNeeded(currValExpr, sourceSpan);
  28293. });
  28294. if (expressions.length || allowEmptyExprs) {
  28295. updateStmts.push(applySourceSpanToStatementIfNeeded(callCheckStmt(nodeIndex, exprs).toStmt(), sourceSpan));
  28296. }
  28297. return updateStmts;
  28298. }
  28299. };
  28300. /**
  28301. * @param {?} nodeIndex
  28302. * @param {?} handlers
  28303. * @return {?}
  28304. */
  28305. ViewBuilder.prototype._createElementHandleEventFn = /**
  28306. * @param {?} nodeIndex
  28307. * @param {?} handlers
  28308. * @return {?}
  28309. */
  28310. function (nodeIndex, handlers) {
  28311. var _this = this;
  28312. var /** @type {?} */ handleEventStmts = [];
  28313. var /** @type {?} */ handleEventBindingCount = 0;
  28314. handlers.forEach(function (_a) {
  28315. var context = _a.context, eventAst = _a.eventAst, dirAst = _a.dirAst;
  28316. var /** @type {?} */ bindingId = "" + handleEventBindingCount++;
  28317. var /** @type {?} */ nameResolver = context === COMP_VAR ? _this : null;
  28318. var _b = convertActionBinding(nameResolver, context, eventAst.handler, bindingId), stmts = _b.stmts, allowDefault = _b.allowDefault;
  28319. var /** @type {?} */ trueStmts = stmts;
  28320. if (allowDefault) {
  28321. trueStmts.push(ALLOW_DEFAULT_VAR.set(allowDefault.and(ALLOW_DEFAULT_VAR)).toStmt());
  28322. }
  28323. var _c = elementEventNameAndTarget(eventAst, dirAst), eventTarget = _c.target, eventName = _c.name;
  28324. var /** @type {?} */ fullEventName = elementEventFullName(eventTarget, eventName);
  28325. handleEventStmts.push(applySourceSpanToStatementIfNeeded(new IfStmt(literal(fullEventName).identical(EVENT_NAME_VAR), trueStmts), eventAst.sourceSpan));
  28326. });
  28327. var /** @type {?} */ handleEventFn;
  28328. if (handleEventStmts.length > 0) {
  28329. var /** @type {?} */ preStmts = [ALLOW_DEFAULT_VAR.set(literal(true)).toDeclStmt(BOOL_TYPE)];
  28330. if (!this.component.isHost && findReadVarNames(handleEventStmts).has(/** @type {?} */ ((COMP_VAR.name)))) {
  28331. preStmts.push(COMP_VAR.set(VIEW_VAR.prop('component')).toDeclStmt(this.compType));
  28332. }
  28333. handleEventFn = fn([
  28334. new FnParam(/** @type {?} */ ((VIEW_VAR.name)), INFERRED_TYPE),
  28335. new FnParam(/** @type {?} */ ((EVENT_NAME_VAR.name)), INFERRED_TYPE),
  28336. new FnParam(/** @type {?} */ ((EventHandlerVars.event.name)), INFERRED_TYPE)
  28337. ], preStmts.concat(handleEventStmts, [new ReturnStatement(ALLOW_DEFAULT_VAR)]), INFERRED_TYPE);
  28338. }
  28339. else {
  28340. handleEventFn = NULL_EXPR;
  28341. }
  28342. return handleEventFn;
  28343. };
  28344. /**
  28345. * @param {?} ast
  28346. * @param {?} context
  28347. * @return {?}
  28348. */
  28349. ViewBuilder.prototype.visitDirective = /**
  28350. * @param {?} ast
  28351. * @param {?} context
  28352. * @return {?}
  28353. */
  28354. function (ast, context) { };
  28355. /**
  28356. * @param {?} ast
  28357. * @param {?} context
  28358. * @return {?}
  28359. */
  28360. ViewBuilder.prototype.visitDirectiveProperty = /**
  28361. * @param {?} ast
  28362. * @param {?} context
  28363. * @return {?}
  28364. */
  28365. function (ast, context) { };
  28366. /**
  28367. * @param {?} ast
  28368. * @param {?} context
  28369. * @return {?}
  28370. */
  28371. ViewBuilder.prototype.visitReference = /**
  28372. * @param {?} ast
  28373. * @param {?} context
  28374. * @return {?}
  28375. */
  28376. function (ast, context) { };
  28377. /**
  28378. * @param {?} ast
  28379. * @param {?} context
  28380. * @return {?}
  28381. */
  28382. ViewBuilder.prototype.visitVariable = /**
  28383. * @param {?} ast
  28384. * @param {?} context
  28385. * @return {?}
  28386. */
  28387. function (ast, context) { };
  28388. /**
  28389. * @param {?} ast
  28390. * @param {?} context
  28391. * @return {?}
  28392. */
  28393. ViewBuilder.prototype.visitEvent = /**
  28394. * @param {?} ast
  28395. * @param {?} context
  28396. * @return {?}
  28397. */
  28398. function (ast, context) { };
  28399. /**
  28400. * @param {?} ast
  28401. * @param {?} context
  28402. * @return {?}
  28403. */
  28404. ViewBuilder.prototype.visitElementProperty = /**
  28405. * @param {?} ast
  28406. * @param {?} context
  28407. * @return {?}
  28408. */
  28409. function (ast, context) { };
  28410. /**
  28411. * @param {?} ast
  28412. * @param {?} context
  28413. * @return {?}
  28414. */
  28415. ViewBuilder.prototype.visitAttr = /**
  28416. * @param {?} ast
  28417. * @param {?} context
  28418. * @return {?}
  28419. */
  28420. function (ast, context) { };
  28421. return ViewBuilder;
  28422. }());
  28423. /**
  28424. * @param {?} astNodes
  28425. * @return {?}
  28426. */
  28427. function needsAdditionalRootNode(astNodes) {
  28428. var /** @type {?} */ lastAstNode = astNodes[astNodes.length - 1];
  28429. if (lastAstNode instanceof EmbeddedTemplateAst) {
  28430. return lastAstNode.hasViewContainer;
  28431. }
  28432. if (lastAstNode instanceof ElementAst) {
  28433. if (isNgContainer(lastAstNode.name) && lastAstNode.children.length) {
  28434. return needsAdditionalRootNode(lastAstNode.children);
  28435. }
  28436. return lastAstNode.hasViewContainer;
  28437. }
  28438. return lastAstNode instanceof NgContentAst;
  28439. }
  28440. /**
  28441. * @param {?} inputAst
  28442. * @param {?} dirAst
  28443. * @return {?}
  28444. */
  28445. function elementBindingDef(inputAst, dirAst) {
  28446. switch (inputAst.type) {
  28447. case PropertyBindingType.Attribute:
  28448. return literalArr([
  28449. literal(1 /* TypeElementAttribute */), literal(inputAst.name),
  28450. literal(inputAst.securityContext)
  28451. ]);
  28452. case PropertyBindingType.Property:
  28453. return literalArr([
  28454. literal(8 /* TypeProperty */), literal(inputAst.name),
  28455. literal(inputAst.securityContext)
  28456. ]);
  28457. case PropertyBindingType.Animation:
  28458. var /** @type {?} */ bindingType = 8 /* TypeProperty */ |
  28459. (dirAst && dirAst.directive.isComponent ? 32 /* SyntheticHostProperty */ :
  28460. 16 /* SyntheticProperty */);
  28461. return literalArr([
  28462. literal(bindingType), literal('@' + inputAst.name), literal(inputAst.securityContext)
  28463. ]);
  28464. case PropertyBindingType.Class:
  28465. return literalArr([literal(2 /* TypeElementClass */), literal(inputAst.name), NULL_EXPR]);
  28466. case PropertyBindingType.Style:
  28467. return literalArr([
  28468. literal(4 /* TypeElementStyle */), literal(inputAst.name), literal(inputAst.unit)
  28469. ]);
  28470. }
  28471. }
  28472. /**
  28473. * @param {?} elementAst
  28474. * @return {?}
  28475. */
  28476. function fixedAttrsDef(elementAst) {
  28477. var /** @type {?} */ mapResult = Object.create(null);
  28478. elementAst.attrs.forEach(function (attrAst) { mapResult[attrAst.name] = attrAst.value; });
  28479. elementAst.directives.forEach(function (dirAst) {
  28480. Object.keys(dirAst.directive.hostAttributes).forEach(function (name) {
  28481. var /** @type {?} */ value = dirAst.directive.hostAttributes[name];
  28482. var /** @type {?} */ prevValue = mapResult[name];
  28483. mapResult[name] = prevValue != null ? mergeAttributeValue(name, prevValue, value) : value;
  28484. });
  28485. });
  28486. // Note: We need to sort to get a defined output order
  28487. // for tests and for caching generated artifacts...
  28488. return literalArr(Object.keys(mapResult).sort().map(function (attrName) { return literalArr([literal(attrName), literal(mapResult[attrName])]); }));
  28489. }
  28490. /**
  28491. * @param {?} attrName
  28492. * @param {?} attrValue1
  28493. * @param {?} attrValue2
  28494. * @return {?}
  28495. */
  28496. function mergeAttributeValue(attrName, attrValue1, attrValue2) {
  28497. if (attrName == CLASS_ATTR$1 || attrName == STYLE_ATTR) {
  28498. return attrValue1 + " " + attrValue2;
  28499. }
  28500. else {
  28501. return attrValue2;
  28502. }
  28503. }
  28504. /**
  28505. * @param {?} nodeIndex
  28506. * @param {?} exprs
  28507. * @return {?}
  28508. */
  28509. function callCheckStmt(nodeIndex, exprs) {
  28510. if (exprs.length > 10) {
  28511. return CHECK_VAR.callFn([VIEW_VAR, literal(nodeIndex), literal(1 /* Dynamic */), literalArr(exprs)]);
  28512. }
  28513. else {
  28514. return CHECK_VAR.callFn([VIEW_VAR, literal(nodeIndex), literal(0 /* Inline */)].concat(exprs));
  28515. }
  28516. }
  28517. /**
  28518. * @param {?} nodeIndex
  28519. * @param {?} bindingIdx
  28520. * @param {?} expr
  28521. * @return {?}
  28522. */
  28523. function callUnwrapValue(nodeIndex, bindingIdx, expr) {
  28524. return importExpr(Identifiers.unwrapValue).callFn([
  28525. VIEW_VAR, literal(nodeIndex), literal(bindingIdx), expr
  28526. ]);
  28527. }
  28528. /**
  28529. * @param {?} nodes
  28530. * @param {?=} result
  28531. * @return {?}
  28532. */
  28533. function findStaticQueryIds(nodes, result) {
  28534. if (result === void 0) { result = new Map(); }
  28535. nodes.forEach(function (node) {
  28536. var /** @type {?} */ staticQueryIds = new Set();
  28537. var /** @type {?} */ dynamicQueryIds = new Set();
  28538. var /** @type {?} */ queryMatches = /** @type {?} */ ((undefined));
  28539. if (node instanceof ElementAst) {
  28540. findStaticQueryIds(node.children, result);
  28541. node.children.forEach(function (child) {
  28542. var /** @type {?} */ childData = /** @type {?} */ ((result.get(child)));
  28543. childData.staticQueryIds.forEach(function (queryId) { return staticQueryIds.add(queryId); });
  28544. childData.dynamicQueryIds.forEach(function (queryId) { return dynamicQueryIds.add(queryId); });
  28545. });
  28546. queryMatches = node.queryMatches;
  28547. }
  28548. else if (node instanceof EmbeddedTemplateAst) {
  28549. findStaticQueryIds(node.children, result);
  28550. node.children.forEach(function (child) {
  28551. var /** @type {?} */ childData = /** @type {?} */ ((result.get(child)));
  28552. childData.staticQueryIds.forEach(function (queryId) { return dynamicQueryIds.add(queryId); });
  28553. childData.dynamicQueryIds.forEach(function (queryId) { return dynamicQueryIds.add(queryId); });
  28554. });
  28555. queryMatches = node.queryMatches;
  28556. }
  28557. if (queryMatches) {
  28558. queryMatches.forEach(function (match) { return staticQueryIds.add(match.queryId); });
  28559. }
  28560. dynamicQueryIds.forEach(function (queryId) { return staticQueryIds.delete(queryId); });
  28561. result.set(node, { staticQueryIds: staticQueryIds, dynamicQueryIds: dynamicQueryIds });
  28562. });
  28563. return result;
  28564. }
  28565. /**
  28566. * @param {?} nodeStaticQueryIds
  28567. * @return {?}
  28568. */
  28569. function staticViewQueryIds(nodeStaticQueryIds) {
  28570. var /** @type {?} */ staticQueryIds = new Set();
  28571. var /** @type {?} */ dynamicQueryIds = new Set();
  28572. Array.from(nodeStaticQueryIds.values()).forEach(function (entry) {
  28573. entry.staticQueryIds.forEach(function (queryId) { return staticQueryIds.add(queryId); });
  28574. entry.dynamicQueryIds.forEach(function (queryId) { return dynamicQueryIds.add(queryId); });
  28575. });
  28576. dynamicQueryIds.forEach(function (queryId) { return staticQueryIds.delete(queryId); });
  28577. return { staticQueryIds: staticQueryIds, dynamicQueryIds: dynamicQueryIds };
  28578. }
  28579. /**
  28580. * @param {?} eventAst
  28581. * @param {?} dirAst
  28582. * @return {?}
  28583. */
  28584. function elementEventNameAndTarget(eventAst, dirAst) {
  28585. if (eventAst.isAnimation) {
  28586. return {
  28587. name: "@" + eventAst.name + "." + eventAst.phase,
  28588. target: dirAst && dirAst.directive.isComponent ? 'component' : null
  28589. };
  28590. }
  28591. else {
  28592. return eventAst;
  28593. }
  28594. }
  28595. /**
  28596. * @param {?} queryIds
  28597. * @param {?} queryId
  28598. * @param {?} isFirst
  28599. * @return {?}
  28600. */
  28601. function calcStaticDynamicQueryFlags(queryIds, queryId, isFirst) {
  28602. var /** @type {?} */ flags = 0;
  28603. // Note: We only make queries static that query for a single item.
  28604. // This is because of backwards compatibility with the old view compiler...
  28605. if (isFirst && (queryIds.staticQueryIds.has(queryId) || !queryIds.dynamicQueryIds.has(queryId))) {
  28606. flags |= 268435456 /* StaticQuery */;
  28607. }
  28608. else {
  28609. flags |= 536870912 /* DynamicQuery */;
  28610. }
  28611. return flags;
  28612. }
  28613. /**
  28614. * @param {?} target
  28615. * @param {?} name
  28616. * @return {?}
  28617. */
  28618. function elementEventFullName(target, name) {
  28619. return target ? target + ":" + name : name;
  28620. }
  28621. /**
  28622. * @fileoverview added by tsickle
  28623. * @suppress {checkTypes} checked by tsc
  28624. */
  28625. /**
  28626. * @license
  28627. * Copyright Google Inc. All Rights Reserved.
  28628. *
  28629. * Use of this source code is governed by an MIT-style license that can be
  28630. * found in the LICENSE file at https://angular.io/license
  28631. */
  28632. /**
  28633. * A container for message extracted from the templates.
  28634. */
  28635. var MessageBundle = /** @class */ (function () {
  28636. function MessageBundle(_htmlParser, _implicitTags, _implicitAttrs, _locale) {
  28637. if (_locale === void 0) { _locale = null; }
  28638. this._htmlParser = _htmlParser;
  28639. this._implicitTags = _implicitTags;
  28640. this._implicitAttrs = _implicitAttrs;
  28641. this._locale = _locale;
  28642. this._messages = [];
  28643. }
  28644. /**
  28645. * @param {?} html
  28646. * @param {?} url
  28647. * @param {?} interpolationConfig
  28648. * @return {?}
  28649. */
  28650. MessageBundle.prototype.updateFromTemplate = /**
  28651. * @param {?} html
  28652. * @param {?} url
  28653. * @param {?} interpolationConfig
  28654. * @return {?}
  28655. */
  28656. function (html, url, interpolationConfig) {
  28657. var /** @type {?} */ htmlParserResult = this._htmlParser.parse(html, url, true, interpolationConfig);
  28658. if (htmlParserResult.errors.length) {
  28659. return htmlParserResult.errors;
  28660. }
  28661. var /** @type {?} */ i18nParserResult = extractMessages(htmlParserResult.rootNodes, interpolationConfig, this._implicitTags, this._implicitAttrs);
  28662. if (i18nParserResult.errors.length) {
  28663. return i18nParserResult.errors;
  28664. }
  28665. (_a = this._messages).push.apply(_a, i18nParserResult.messages);
  28666. return [];
  28667. var _a;
  28668. };
  28669. // Return the message in the internal format
  28670. // The public (serialized) format might be different, see the `write` method.
  28671. /**
  28672. * @return {?}
  28673. */
  28674. MessageBundle.prototype.getMessages = /**
  28675. * @return {?}
  28676. */
  28677. function () { return this._messages; };
  28678. /**
  28679. * @param {?} serializer
  28680. * @param {?=} filterSources
  28681. * @return {?}
  28682. */
  28683. MessageBundle.prototype.write = /**
  28684. * @param {?} serializer
  28685. * @param {?=} filterSources
  28686. * @return {?}
  28687. */
  28688. function (serializer, filterSources) {
  28689. var /** @type {?} */ messages = {};
  28690. var /** @type {?} */ mapperVisitor = new MapPlaceholderNames();
  28691. // Deduplicate messages based on their ID
  28692. this._messages.forEach(function (message) {
  28693. var /** @type {?} */ id = serializer.digest(message);
  28694. if (!messages.hasOwnProperty(id)) {
  28695. messages[id] = message;
  28696. }
  28697. else {
  28698. (_a = messages[id].sources).push.apply(_a, message.sources);
  28699. }
  28700. var _a;
  28701. });
  28702. // Transform placeholder names using the serializer mapping
  28703. var /** @type {?} */ msgList = Object.keys(messages).map(function (id) {
  28704. var /** @type {?} */ mapper = serializer.createNameMapper(messages[id]);
  28705. var /** @type {?} */ src = messages[id];
  28706. var /** @type {?} */ nodes = mapper ? mapperVisitor.convert(src.nodes, mapper) : src.nodes;
  28707. var /** @type {?} */ transformedMessage = new Message(nodes, {}, {}, src.meaning, src.description, id);
  28708. transformedMessage.sources = src.sources;
  28709. if (filterSources) {
  28710. transformedMessage.sources.forEach(function (source) { return source.filePath = filterSources(source.filePath); });
  28711. }
  28712. return transformedMessage;
  28713. });
  28714. return serializer.write(msgList, this._locale);
  28715. };
  28716. return MessageBundle;
  28717. }());
  28718. var MapPlaceholderNames = /** @class */ (function (_super) {
  28719. __extends(MapPlaceholderNames, _super);
  28720. function MapPlaceholderNames() {
  28721. return _super !== null && _super.apply(this, arguments) || this;
  28722. }
  28723. /**
  28724. * @param {?} nodes
  28725. * @param {?} mapper
  28726. * @return {?}
  28727. */
  28728. MapPlaceholderNames.prototype.convert = /**
  28729. * @param {?} nodes
  28730. * @param {?} mapper
  28731. * @return {?}
  28732. */
  28733. function (nodes, mapper) {
  28734. var _this = this;
  28735. return mapper ? nodes.map(function (n) { return n.visit(_this, mapper); }) : nodes;
  28736. };
  28737. /**
  28738. * @param {?} ph
  28739. * @param {?} mapper
  28740. * @return {?}
  28741. */
  28742. MapPlaceholderNames.prototype.visitTagPlaceholder = /**
  28743. * @param {?} ph
  28744. * @param {?} mapper
  28745. * @return {?}
  28746. */
  28747. function (ph, mapper) {
  28748. var _this = this;
  28749. var /** @type {?} */ startName = /** @type {?} */ ((mapper.toPublicName(ph.startName)));
  28750. var /** @type {?} */ closeName = ph.closeName ? /** @type {?} */ ((mapper.toPublicName(ph.closeName))) : ph.closeName;
  28751. var /** @type {?} */ children = ph.children.map(function (n) { return n.visit(_this, mapper); });
  28752. return new TagPlaceholder(ph.tag, ph.attrs, startName, closeName, children, ph.isVoid, ph.sourceSpan);
  28753. };
  28754. /**
  28755. * @param {?} ph
  28756. * @param {?} mapper
  28757. * @return {?}
  28758. */
  28759. MapPlaceholderNames.prototype.visitPlaceholder = /**
  28760. * @param {?} ph
  28761. * @param {?} mapper
  28762. * @return {?}
  28763. */
  28764. function (ph, mapper) {
  28765. return new Placeholder(ph.value, /** @type {?} */ ((mapper.toPublicName(ph.name))), ph.sourceSpan);
  28766. };
  28767. /**
  28768. * @param {?} ph
  28769. * @param {?} mapper
  28770. * @return {?}
  28771. */
  28772. MapPlaceholderNames.prototype.visitIcuPlaceholder = /**
  28773. * @param {?} ph
  28774. * @param {?} mapper
  28775. * @return {?}
  28776. */
  28777. function (ph, mapper) {
  28778. return new IcuPlaceholder(ph.value, /** @type {?} */ ((mapper.toPublicName(ph.name))), ph.sourceSpan);
  28779. };
  28780. return MapPlaceholderNames;
  28781. }(CloneVisitor));
  28782. /**
  28783. * @fileoverview added by tsickle
  28784. * @suppress {checkTypes} checked by tsc
  28785. */
  28786. /**
  28787. * @license
  28788. * Copyright Google Inc. All Rights Reserved.
  28789. *
  28790. * Use of this source code is governed by an MIT-style license that can be
  28791. * found in the LICENSE file at https://angular.io/license
  28792. */
  28793. var GeneratedFile = /** @class */ (function () {
  28794. function GeneratedFile(srcFileUrl, genFileUrl, sourceOrStmts) {
  28795. this.srcFileUrl = srcFileUrl;
  28796. this.genFileUrl = genFileUrl;
  28797. if (typeof sourceOrStmts === 'string') {
  28798. this.source = sourceOrStmts;
  28799. this.stmts = null;
  28800. }
  28801. else {
  28802. this.source = null;
  28803. this.stmts = sourceOrStmts;
  28804. }
  28805. }
  28806. /**
  28807. * @param {?} other
  28808. * @return {?}
  28809. */
  28810. GeneratedFile.prototype.isEquivalent = /**
  28811. * @param {?} other
  28812. * @return {?}
  28813. */
  28814. function (other) {
  28815. if (this.genFileUrl !== other.genFileUrl) {
  28816. return false;
  28817. }
  28818. if (this.source) {
  28819. return this.source === other.source;
  28820. }
  28821. if (other.stmts == null) {
  28822. return false;
  28823. }
  28824. // Note: the constructor guarantees that if this.source is not filled,
  28825. // then this.stmts is.
  28826. return areAllEquivalent(/** @type {?} */ ((this.stmts)), /** @type {?} */ ((other.stmts)));
  28827. };
  28828. return GeneratedFile;
  28829. }());
  28830. /**
  28831. * @param {?} file
  28832. * @param {?=} preamble
  28833. * @return {?}
  28834. */
  28835. function toTypeScript(file, preamble) {
  28836. if (preamble === void 0) { preamble = ''; }
  28837. if (!file.stmts) {
  28838. throw new Error("Illegal state: No stmts present on GeneratedFile " + file.genFileUrl);
  28839. }
  28840. return new TypeScriptEmitter().emitStatements(file.genFileUrl, file.stmts, preamble);
  28841. }
  28842. /**
  28843. * @fileoverview added by tsickle
  28844. * @suppress {checkTypes} checked by tsc
  28845. */
  28846. /**
  28847. * @license
  28848. * Copyright Google Inc. All Rights Reserved.
  28849. *
  28850. * Use of this source code is governed by an MIT-style license that can be
  28851. * found in the LICENSE file at https://angular.io/license
  28852. */
  28853. /**
  28854. * @record
  28855. */
  28856. /**
  28857. * @param {?} moduleMeta
  28858. * @param {?} reflector
  28859. * @return {?}
  28860. */
  28861. function listLazyRoutes(moduleMeta, reflector) {
  28862. var /** @type {?} */ allLazyRoutes = [];
  28863. for (var _i = 0, _a = moduleMeta.transitiveModule.providers; _i < _a.length; _i++) {
  28864. var _b = _a[_i], provider = _b.provider, module = _b.module;
  28865. if (tokenReference(provider.token) === reflector.ROUTES) {
  28866. var /** @type {?} */ loadChildren = _collectLoadChildren(provider.useValue);
  28867. for (var _c = 0, loadChildren_1 = loadChildren; _c < loadChildren_1.length; _c++) {
  28868. var route = loadChildren_1[_c];
  28869. allLazyRoutes.push(parseLazyRoute(route, reflector, module.reference));
  28870. }
  28871. }
  28872. }
  28873. return allLazyRoutes;
  28874. }
  28875. /**
  28876. * @param {?} routes
  28877. * @param {?=} target
  28878. * @return {?}
  28879. */
  28880. function _collectLoadChildren(routes, target) {
  28881. if (target === void 0) { target = []; }
  28882. if (typeof routes === 'string') {
  28883. target.push(routes);
  28884. }
  28885. else if (Array.isArray(routes)) {
  28886. for (var _i = 0, routes_1 = routes; _i < routes_1.length; _i++) {
  28887. var route = routes_1[_i];
  28888. _collectLoadChildren(route, target);
  28889. }
  28890. }
  28891. else if (routes.loadChildren) {
  28892. _collectLoadChildren(routes.loadChildren, target);
  28893. }
  28894. else if (routes.children) {
  28895. _collectLoadChildren(routes.children, target);
  28896. }
  28897. return target;
  28898. }
  28899. /**
  28900. * @param {?} route
  28901. * @param {?} reflector
  28902. * @param {?=} module
  28903. * @return {?}
  28904. */
  28905. function parseLazyRoute(route, reflector, module) {
  28906. var _a = route.split('#'), routePath = _a[0], routeName = _a[1];
  28907. var /** @type {?} */ referencedModule = reflector.resolveExternalReference({
  28908. moduleName: routePath,
  28909. name: routeName,
  28910. }, module ? module.filePath : undefined);
  28911. return { route: route, module: module || referencedModule, referencedModule: referencedModule };
  28912. }
  28913. /**
  28914. * @fileoverview added by tsickle
  28915. * @suppress {checkTypes} checked by tsc
  28916. */
  28917. /**
  28918. * @license
  28919. * Copyright Google Inc. All Rights Reserved.
  28920. *
  28921. * Use of this source code is governed by an MIT-style license that can be
  28922. * found in the LICENSE file at https://angular.io/license
  28923. */
  28924. var ResolvedStaticSymbol = /** @class */ (function () {
  28925. function ResolvedStaticSymbol(symbol, metadata) {
  28926. this.symbol = symbol;
  28927. this.metadata = metadata;
  28928. }
  28929. return ResolvedStaticSymbol;
  28930. }());
  28931. /**
  28932. * The host of the SymbolResolverHost disconnects the implementation from TypeScript / other
  28933. * language
  28934. * services and from underlying file systems.
  28935. * @record
  28936. */
  28937. var SUPPORTED_SCHEMA_VERSION = 4;
  28938. /**
  28939. * This class is responsible for loading metadata per symbol,
  28940. * and normalizing references between symbols.
  28941. *
  28942. * Internally, it only uses symbols without members,
  28943. * and deduces the values for symbols with members based
  28944. * on these symbols.
  28945. */
  28946. var StaticSymbolResolver = /** @class */ (function () {
  28947. function StaticSymbolResolver(host, staticSymbolCache, summaryResolver, errorRecorder) {
  28948. this.host = host;
  28949. this.staticSymbolCache = staticSymbolCache;
  28950. this.summaryResolver = summaryResolver;
  28951. this.errorRecorder = errorRecorder;
  28952. this.metadataCache = new Map();
  28953. this.resolvedSymbols = new Map();
  28954. this.resolvedFilePaths = new Set();
  28955. this.importAs = new Map();
  28956. this.symbolResourcePaths = new Map();
  28957. this.symbolFromFile = new Map();
  28958. this.knownFileNameToModuleNames = new Map();
  28959. }
  28960. /**
  28961. * @param {?} staticSymbol
  28962. * @return {?}
  28963. */
  28964. StaticSymbolResolver.prototype.resolveSymbol = /**
  28965. * @param {?} staticSymbol
  28966. * @return {?}
  28967. */
  28968. function (staticSymbol) {
  28969. if (staticSymbol.members.length > 0) {
  28970. return /** @type {?} */ ((this._resolveSymbolMembers(staticSymbol)));
  28971. }
  28972. // Note: always ask for a summary first,
  28973. // as we might have read shallow metadata via a .d.ts file
  28974. // for the symbol.
  28975. var /** @type {?} */ resultFromSummary = /** @type {?} */ ((this._resolveSymbolFromSummary(staticSymbol)));
  28976. if (resultFromSummary) {
  28977. return resultFromSummary;
  28978. }
  28979. var /** @type {?} */ resultFromCache = this.resolvedSymbols.get(staticSymbol);
  28980. if (resultFromCache) {
  28981. return resultFromCache;
  28982. }
  28983. // Note: Some users use libraries that were not compiled with ngc, i.e. they don't
  28984. // have summaries, only .d.ts files. So we always need to check both, the summary
  28985. // and metadata.
  28986. this._createSymbolsOf(staticSymbol.filePath);
  28987. return /** @type {?} */ ((this.resolvedSymbols.get(staticSymbol)));
  28988. };
  28989. /**
  28990. * getImportAs produces a symbol that can be used to import the given symbol.
  28991. * The import might be different than the symbol if the symbol is exported from
  28992. * a library with a summary; in which case we want to import the symbol from the
  28993. * ngfactory re-export instead of directly to avoid introducing a direct dependency
  28994. * on an otherwise indirect dependency.
  28995. *
  28996. * @param staticSymbol the symbol for which to generate a import symbol
  28997. */
  28998. /**
  28999. * getImportAs produces a symbol that can be used to import the given symbol.
  29000. * The import might be different than the symbol if the symbol is exported from
  29001. * a library with a summary; in which case we want to import the symbol from the
  29002. * ngfactory re-export instead of directly to avoid introducing a direct dependency
  29003. * on an otherwise indirect dependency.
  29004. *
  29005. * @param {?} staticSymbol the symbol for which to generate a import symbol
  29006. * @param {?=} useSummaries
  29007. * @return {?}
  29008. */
  29009. StaticSymbolResolver.prototype.getImportAs = /**
  29010. * getImportAs produces a symbol that can be used to import the given symbol.
  29011. * The import might be different than the symbol if the symbol is exported from
  29012. * a library with a summary; in which case we want to import the symbol from the
  29013. * ngfactory re-export instead of directly to avoid introducing a direct dependency
  29014. * on an otherwise indirect dependency.
  29015. *
  29016. * @param {?} staticSymbol the symbol for which to generate a import symbol
  29017. * @param {?=} useSummaries
  29018. * @return {?}
  29019. */
  29020. function (staticSymbol, useSummaries) {
  29021. if (useSummaries === void 0) { useSummaries = true; }
  29022. if (staticSymbol.members.length) {
  29023. var /** @type {?} */ baseSymbol = this.getStaticSymbol(staticSymbol.filePath, staticSymbol.name);
  29024. var /** @type {?} */ baseImportAs = this.getImportAs(baseSymbol, useSummaries);
  29025. return baseImportAs ?
  29026. this.getStaticSymbol(baseImportAs.filePath, baseImportAs.name, staticSymbol.members) :
  29027. null;
  29028. }
  29029. var /** @type {?} */ summarizedFileName = stripSummaryForJitFileSuffix(staticSymbol.filePath);
  29030. if (summarizedFileName !== staticSymbol.filePath) {
  29031. var /** @type {?} */ summarizedName = stripSummaryForJitNameSuffix(staticSymbol.name);
  29032. var /** @type {?} */ baseSymbol = this.getStaticSymbol(summarizedFileName, summarizedName, staticSymbol.members);
  29033. var /** @type {?} */ baseImportAs = this.getImportAs(baseSymbol, useSummaries);
  29034. return baseImportAs ?
  29035. this.getStaticSymbol(summaryForJitFileName(baseImportAs.filePath), summaryForJitName(baseImportAs.name), baseSymbol.members) :
  29036. null;
  29037. }
  29038. var /** @type {?} */ result = (useSummaries && this.summaryResolver.getImportAs(staticSymbol)) || null;
  29039. if (!result) {
  29040. result = /** @type {?} */ ((this.importAs.get(staticSymbol)));
  29041. }
  29042. return result;
  29043. };
  29044. /**
  29045. * getResourcePath produces the path to the original location of the symbol and should
  29046. * be used to determine the relative location of resource references recorded in
  29047. * symbol metadata.
  29048. */
  29049. /**
  29050. * getResourcePath produces the path to the original location of the symbol and should
  29051. * be used to determine the relative location of resource references recorded in
  29052. * symbol metadata.
  29053. * @param {?} staticSymbol
  29054. * @return {?}
  29055. */
  29056. StaticSymbolResolver.prototype.getResourcePath = /**
  29057. * getResourcePath produces the path to the original location of the symbol and should
  29058. * be used to determine the relative location of resource references recorded in
  29059. * symbol metadata.
  29060. * @param {?} staticSymbol
  29061. * @return {?}
  29062. */
  29063. function (staticSymbol) {
  29064. return this.symbolResourcePaths.get(staticSymbol) || staticSymbol.filePath;
  29065. };
  29066. /**
  29067. * getTypeArity returns the number of generic type parameters the given symbol
  29068. * has. If the symbol is not a type the result is null.
  29069. */
  29070. /**
  29071. * getTypeArity returns the number of generic type parameters the given symbol
  29072. * has. If the symbol is not a type the result is null.
  29073. * @param {?} staticSymbol
  29074. * @return {?}
  29075. */
  29076. StaticSymbolResolver.prototype.getTypeArity = /**
  29077. * getTypeArity returns the number of generic type parameters the given symbol
  29078. * has. If the symbol is not a type the result is null.
  29079. * @param {?} staticSymbol
  29080. * @return {?}
  29081. */
  29082. function (staticSymbol) {
  29083. // If the file is a factory/ngsummary file, don't resolve the symbol as doing so would
  29084. // cause the metadata for an factory/ngsummary file to be loaded which doesn't exist.
  29085. // All references to generated classes must include the correct arity whenever
  29086. // generating code.
  29087. if (isGeneratedFile(staticSymbol.filePath)) {
  29088. return null;
  29089. }
  29090. var /** @type {?} */ resolvedSymbol = unwrapResolvedMetadata(this.resolveSymbol(staticSymbol));
  29091. while (resolvedSymbol && resolvedSymbol.metadata instanceof StaticSymbol) {
  29092. resolvedSymbol = unwrapResolvedMetadata(this.resolveSymbol(resolvedSymbol.metadata));
  29093. }
  29094. return (resolvedSymbol && resolvedSymbol.metadata && resolvedSymbol.metadata.arity) || null;
  29095. };
  29096. /**
  29097. * @param {?} filePath
  29098. * @return {?}
  29099. */
  29100. StaticSymbolResolver.prototype.getKnownModuleName = /**
  29101. * @param {?} filePath
  29102. * @return {?}
  29103. */
  29104. function (filePath) {
  29105. return this.knownFileNameToModuleNames.get(filePath) || null;
  29106. };
  29107. /**
  29108. * @param {?} sourceSymbol
  29109. * @param {?} targetSymbol
  29110. * @return {?}
  29111. */
  29112. StaticSymbolResolver.prototype.recordImportAs = /**
  29113. * @param {?} sourceSymbol
  29114. * @param {?} targetSymbol
  29115. * @return {?}
  29116. */
  29117. function (sourceSymbol, targetSymbol) {
  29118. sourceSymbol.assertNoMembers();
  29119. targetSymbol.assertNoMembers();
  29120. this.importAs.set(sourceSymbol, targetSymbol);
  29121. };
  29122. /**
  29123. * @param {?} fileName
  29124. * @param {?} moduleName
  29125. * @return {?}
  29126. */
  29127. StaticSymbolResolver.prototype.recordModuleNameForFileName = /**
  29128. * @param {?} fileName
  29129. * @param {?} moduleName
  29130. * @return {?}
  29131. */
  29132. function (fileName, moduleName) {
  29133. this.knownFileNameToModuleNames.set(fileName, moduleName);
  29134. };
  29135. /**
  29136. * Invalidate all information derived from the given file.
  29137. *
  29138. * @param fileName the file to invalidate
  29139. */
  29140. /**
  29141. * Invalidate all information derived from the given file.
  29142. *
  29143. * @param {?} fileName the file to invalidate
  29144. * @return {?}
  29145. */
  29146. StaticSymbolResolver.prototype.invalidateFile = /**
  29147. * Invalidate all information derived from the given file.
  29148. *
  29149. * @param {?} fileName the file to invalidate
  29150. * @return {?}
  29151. */
  29152. function (fileName) {
  29153. this.metadataCache.delete(fileName);
  29154. this.resolvedFilePaths.delete(fileName);
  29155. var /** @type {?} */ symbols = this.symbolFromFile.get(fileName);
  29156. if (symbols) {
  29157. this.symbolFromFile.delete(fileName);
  29158. for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
  29159. var symbol = symbols_1[_i];
  29160. this.resolvedSymbols.delete(symbol);
  29161. this.importAs.delete(symbol);
  29162. this.symbolResourcePaths.delete(symbol);
  29163. }
  29164. }
  29165. };
  29166. /* @internal */
  29167. /**
  29168. * @template T
  29169. * @param {?} cb
  29170. * @return {?}
  29171. */
  29172. StaticSymbolResolver.prototype.ignoreErrorsFor = /**
  29173. * @template T
  29174. * @param {?} cb
  29175. * @return {?}
  29176. */
  29177. function (cb) {
  29178. var /** @type {?} */ recorder = this.errorRecorder;
  29179. this.errorRecorder = function () { };
  29180. try {
  29181. return cb();
  29182. }
  29183. finally {
  29184. this.errorRecorder = recorder;
  29185. }
  29186. };
  29187. /**
  29188. * @param {?} staticSymbol
  29189. * @return {?}
  29190. */
  29191. StaticSymbolResolver.prototype._resolveSymbolMembers = /**
  29192. * @param {?} staticSymbol
  29193. * @return {?}
  29194. */
  29195. function (staticSymbol) {
  29196. var /** @type {?} */ members = staticSymbol.members;
  29197. var /** @type {?} */ baseResolvedSymbol = this.resolveSymbol(this.getStaticSymbol(staticSymbol.filePath, staticSymbol.name));
  29198. if (!baseResolvedSymbol) {
  29199. return null;
  29200. }
  29201. var /** @type {?} */ baseMetadata = unwrapResolvedMetadata(baseResolvedSymbol.metadata);
  29202. if (baseMetadata instanceof StaticSymbol) {
  29203. return new ResolvedStaticSymbol(staticSymbol, this.getStaticSymbol(baseMetadata.filePath, baseMetadata.name, members));
  29204. }
  29205. else if (baseMetadata && baseMetadata.__symbolic === 'class') {
  29206. if (baseMetadata.statics && members.length === 1) {
  29207. return new ResolvedStaticSymbol(staticSymbol, baseMetadata.statics[members[0]]);
  29208. }
  29209. }
  29210. else {
  29211. var /** @type {?} */ value = baseMetadata;
  29212. for (var /** @type {?} */ i = 0; i < members.length && value; i++) {
  29213. value = value[members[i]];
  29214. }
  29215. return new ResolvedStaticSymbol(staticSymbol, value);
  29216. }
  29217. return null;
  29218. };
  29219. /**
  29220. * @param {?} staticSymbol
  29221. * @return {?}
  29222. */
  29223. StaticSymbolResolver.prototype._resolveSymbolFromSummary = /**
  29224. * @param {?} staticSymbol
  29225. * @return {?}
  29226. */
  29227. function (staticSymbol) {
  29228. var /** @type {?} */ summary = this.summaryResolver.resolveSummary(staticSymbol);
  29229. return summary ? new ResolvedStaticSymbol(staticSymbol, summary.metadata) : null;
  29230. };
  29231. /**
  29232. * getStaticSymbol produces a Type whose metadata is known but whose implementation is not loaded.
  29233. * All types passed to the StaticResolver should be pseudo-types returned by this method.
  29234. *
  29235. * @param declarationFile the absolute path of the file where the symbol is declared
  29236. * @param name the name of the type.
  29237. * @param members a symbol for a static member of the named type
  29238. */
  29239. /**
  29240. * getStaticSymbol produces a Type whose metadata is known but whose implementation is not loaded.
  29241. * All types passed to the StaticResolver should be pseudo-types returned by this method.
  29242. *
  29243. * @param {?} declarationFile the absolute path of the file where the symbol is declared
  29244. * @param {?} name the name of the type.
  29245. * @param {?=} members a symbol for a static member of the named type
  29246. * @return {?}
  29247. */
  29248. StaticSymbolResolver.prototype.getStaticSymbol = /**
  29249. * getStaticSymbol produces a Type whose metadata is known but whose implementation is not loaded.
  29250. * All types passed to the StaticResolver should be pseudo-types returned by this method.
  29251. *
  29252. * @param {?} declarationFile the absolute path of the file where the symbol is declared
  29253. * @param {?} name the name of the type.
  29254. * @param {?=} members a symbol for a static member of the named type
  29255. * @return {?}
  29256. */
  29257. function (declarationFile, name, members) {
  29258. return this.staticSymbolCache.get(declarationFile, name, members);
  29259. };
  29260. /**
  29261. * hasDecorators checks a file's metadata for the presense of decorators without evalutating the
  29262. * metadata.
  29263. *
  29264. * @param filePath the absolute path to examine for decorators.
  29265. * @returns true if any class in the file has a decorator.
  29266. */
  29267. /**
  29268. * hasDecorators checks a file's metadata for the presense of decorators without evalutating the
  29269. * metadata.
  29270. *
  29271. * @param {?} filePath the absolute path to examine for decorators.
  29272. * @return {?} true if any class in the file has a decorator.
  29273. */
  29274. StaticSymbolResolver.prototype.hasDecorators = /**
  29275. * hasDecorators checks a file's metadata for the presense of decorators without evalutating the
  29276. * metadata.
  29277. *
  29278. * @param {?} filePath the absolute path to examine for decorators.
  29279. * @return {?} true if any class in the file has a decorator.
  29280. */
  29281. function (filePath) {
  29282. var /** @type {?} */ metadata = this.getModuleMetadata(filePath);
  29283. if (metadata['metadata']) {
  29284. return Object.keys(metadata['metadata']).some(function (metadataKey) {
  29285. var /** @type {?} */ entry = metadata['metadata'][metadataKey];
  29286. return entry && entry.__symbolic === 'class' && entry.decorators;
  29287. });
  29288. }
  29289. return false;
  29290. };
  29291. /**
  29292. * @param {?} filePath
  29293. * @return {?}
  29294. */
  29295. StaticSymbolResolver.prototype.getSymbolsOf = /**
  29296. * @param {?} filePath
  29297. * @return {?}
  29298. */
  29299. function (filePath) {
  29300. var /** @type {?} */ summarySymbols = this.summaryResolver.getSymbolsOf(filePath);
  29301. if (summarySymbols) {
  29302. return summarySymbols;
  29303. }
  29304. // Note: Some users use libraries that were not compiled with ngc, i.e. they don't
  29305. // have summaries, only .d.ts files, but `summaryResolver.isLibraryFile` returns true.
  29306. this._createSymbolsOf(filePath);
  29307. var /** @type {?} */ metadataSymbols = [];
  29308. this.resolvedSymbols.forEach(function (resolvedSymbol) {
  29309. if (resolvedSymbol.symbol.filePath === filePath) {
  29310. metadataSymbols.push(resolvedSymbol.symbol);
  29311. }
  29312. });
  29313. return metadataSymbols;
  29314. };
  29315. /**
  29316. * @param {?} filePath
  29317. * @return {?}
  29318. */
  29319. StaticSymbolResolver.prototype._createSymbolsOf = /**
  29320. * @param {?} filePath
  29321. * @return {?}
  29322. */
  29323. function (filePath) {
  29324. var _this = this;
  29325. if (this.resolvedFilePaths.has(filePath)) {
  29326. return;
  29327. }
  29328. this.resolvedFilePaths.add(filePath);
  29329. var /** @type {?} */ resolvedSymbols = [];
  29330. var /** @type {?} */ metadata = this.getModuleMetadata(filePath);
  29331. if (metadata['importAs']) {
  29332. // Index bundle indices should use the importAs module name defined
  29333. // in the bundle.
  29334. this.knownFileNameToModuleNames.set(filePath, metadata['importAs']);
  29335. }
  29336. // handle the symbols in one of the re-export location
  29337. if (metadata['exports']) {
  29338. var _loop_1 = function (moduleExport) {
  29339. // handle the symbols in the list of explicitly re-exported symbols.
  29340. if (moduleExport.export) {
  29341. moduleExport.export.forEach(function (exportSymbol) {
  29342. var /** @type {?} */ symbolName;
  29343. if (typeof exportSymbol === 'string') {
  29344. symbolName = exportSymbol;
  29345. }
  29346. else {
  29347. symbolName = exportSymbol.as;
  29348. }
  29349. symbolName = unescapeIdentifier(symbolName);
  29350. var /** @type {?} */ symName = symbolName;
  29351. if (typeof exportSymbol !== 'string') {
  29352. symName = unescapeIdentifier(exportSymbol.name);
  29353. }
  29354. var /** @type {?} */ resolvedModule = _this.resolveModule(moduleExport.from, filePath);
  29355. if (resolvedModule) {
  29356. var /** @type {?} */ targetSymbol = _this.getStaticSymbol(resolvedModule, symName);
  29357. var /** @type {?} */ sourceSymbol = _this.getStaticSymbol(filePath, symbolName);
  29358. resolvedSymbols.push(_this.createExport(sourceSymbol, targetSymbol));
  29359. }
  29360. });
  29361. }
  29362. else {
  29363. // handle the symbols via export * directives.
  29364. var /** @type {?} */ resolvedModule = this_1.resolveModule(moduleExport.from, filePath);
  29365. if (resolvedModule) {
  29366. var /** @type {?} */ nestedExports = this_1.getSymbolsOf(resolvedModule);
  29367. nestedExports.forEach(function (targetSymbol) {
  29368. var /** @type {?} */ sourceSymbol = _this.getStaticSymbol(filePath, targetSymbol.name);
  29369. resolvedSymbols.push(_this.createExport(sourceSymbol, targetSymbol));
  29370. });
  29371. }
  29372. }
  29373. };
  29374. var this_1 = this;
  29375. for (var _i = 0, _a = metadata['exports']; _i < _a.length; _i++) {
  29376. var moduleExport = _a[_i];
  29377. _loop_1(moduleExport);
  29378. }
  29379. }
  29380. // handle the actual metadata. Has to be after the exports
  29381. // as there migth be collisions in the names, and we want the symbols
  29382. // of the current module to win ofter reexports.
  29383. if (metadata['metadata']) {
  29384. // handle direct declarations of the symbol
  29385. var /** @type {?} */ topLevelSymbolNames_1 = new Set(Object.keys(metadata['metadata']).map(unescapeIdentifier));
  29386. var /** @type {?} */ origins_1 = metadata['origins'] || {};
  29387. Object.keys(metadata['metadata']).forEach(function (metadataKey) {
  29388. var /** @type {?} */ symbolMeta = metadata['metadata'][metadataKey];
  29389. var /** @type {?} */ name = unescapeIdentifier(metadataKey);
  29390. var /** @type {?} */ symbol = _this.getStaticSymbol(filePath, name);
  29391. var /** @type {?} */ origin = origins_1.hasOwnProperty(metadataKey) && origins_1[metadataKey];
  29392. if (origin) {
  29393. // If the symbol is from a bundled index, use the declaration location of the
  29394. // symbol so relative references (such as './my.html') will be calculated
  29395. // correctly.
  29396. var /** @type {?} */ originFilePath = _this.resolveModule(origin, filePath);
  29397. if (!originFilePath) {
  29398. _this.reportError(new Error("Couldn't resolve original symbol for " + origin + " from " + filePath));
  29399. }
  29400. else {
  29401. _this.symbolResourcePaths.set(symbol, originFilePath);
  29402. }
  29403. }
  29404. resolvedSymbols.push(_this.createResolvedSymbol(symbol, filePath, topLevelSymbolNames_1, symbolMeta));
  29405. });
  29406. }
  29407. resolvedSymbols.forEach(function (resolvedSymbol) { return _this.resolvedSymbols.set(resolvedSymbol.symbol, resolvedSymbol); });
  29408. this.symbolFromFile.set(filePath, resolvedSymbols.map(function (resolvedSymbol) { return resolvedSymbol.symbol; }));
  29409. };
  29410. /**
  29411. * @param {?} sourceSymbol
  29412. * @param {?} topLevelPath
  29413. * @param {?} topLevelSymbolNames
  29414. * @param {?} metadata
  29415. * @return {?}
  29416. */
  29417. StaticSymbolResolver.prototype.createResolvedSymbol = /**
  29418. * @param {?} sourceSymbol
  29419. * @param {?} topLevelPath
  29420. * @param {?} topLevelSymbolNames
  29421. * @param {?} metadata
  29422. * @return {?}
  29423. */
  29424. function (sourceSymbol, topLevelPath, topLevelSymbolNames, metadata) {
  29425. var _this = this;
  29426. // For classes that don't have Angular summaries / metadata,
  29427. // we only keep their arity, but nothing else
  29428. // (e.g. their constructor parameters).
  29429. // We do this to prevent introducing deep imports
  29430. // as we didn't generate .ngfactory.ts files with proper reexports.
  29431. if (this.summaryResolver.isLibraryFile(sourceSymbol.filePath) && metadata &&
  29432. metadata['__symbolic'] === 'class') {
  29433. var /** @type {?} */ transformedMeta_1 = { __symbolic: 'class', arity: metadata.arity };
  29434. return new ResolvedStaticSymbol(sourceSymbol, transformedMeta_1);
  29435. }
  29436. var /** @type {?} */ _originalFileMemo;
  29437. var /** @type {?} */ getOriginalName = function () {
  29438. if (!_originalFileMemo) {
  29439. // Guess what hte original file name is from the reference. If it has a `.d.ts` extension
  29440. // replace it with `.ts`. If it already has `.ts` just leave it in place. If it doesn't have
  29441. // .ts or .d.ts, append `.ts'. Also, if it is in `node_modules`, trim the `node_module`
  29442. // location as it is not important to finding the file.
  29443. _originalFileMemo =
  29444. _this.host.getOutputName(topLevelPath.replace(/((\.ts)|(\.d\.ts)|)$/, '.ts')
  29445. .replace(/^.*node_modules[/\\]/, ''));
  29446. }
  29447. return _originalFileMemo;
  29448. };
  29449. var /** @type {?} */ self = this;
  29450. var ReferenceTransformer = /** @class */ (function (_super) {
  29451. __extends(ReferenceTransformer, _super);
  29452. function ReferenceTransformer() {
  29453. return _super !== null && _super.apply(this, arguments) || this;
  29454. }
  29455. /**
  29456. * @param {?} map
  29457. * @param {?} functionParams
  29458. * @return {?}
  29459. */
  29460. ReferenceTransformer.prototype.visitStringMap = /**
  29461. * @param {?} map
  29462. * @param {?} functionParams
  29463. * @return {?}
  29464. */
  29465. function (map, functionParams) {
  29466. var /** @type {?} */ symbolic = map['__symbolic'];
  29467. if (symbolic === 'function') {
  29468. var /** @type {?} */ oldLen = functionParams.length;
  29469. functionParams.push.apply(functionParams, (map['parameters'] || []));
  29470. var /** @type {?} */ result = _super.prototype.visitStringMap.call(this, map, functionParams);
  29471. functionParams.length = oldLen;
  29472. return result;
  29473. }
  29474. else if (symbolic === 'reference') {
  29475. var /** @type {?} */ module = map['module'];
  29476. var /** @type {?} */ name_1 = map['name'] ? unescapeIdentifier(map['name']) : map['name'];
  29477. if (!name_1) {
  29478. return null;
  29479. }
  29480. var /** @type {?} */ filePath = void 0;
  29481. if (module) {
  29482. filePath = /** @type {?} */ ((self.resolveModule(module, sourceSymbol.filePath)));
  29483. if (!filePath) {
  29484. return {
  29485. __symbolic: 'error',
  29486. message: "Could not resolve " + module + " relative to " + sourceSymbol.filePath + ".",
  29487. line: map["line"],
  29488. character: map["character"],
  29489. fileName: getOriginalName()
  29490. };
  29491. }
  29492. return {
  29493. __symbolic: 'resolved',
  29494. symbol: self.getStaticSymbol(filePath, name_1),
  29495. line: map["line"],
  29496. character: map["character"],
  29497. fileName: getOriginalName()
  29498. };
  29499. }
  29500. else if (functionParams.indexOf(name_1) >= 0) {
  29501. // reference to a function parameter
  29502. return { __symbolic: 'reference', name: name_1 };
  29503. }
  29504. else {
  29505. if (topLevelSymbolNames.has(name_1)) {
  29506. return self.getStaticSymbol(topLevelPath, name_1);
  29507. }
  29508. // ambient value
  29509. null;
  29510. }
  29511. }
  29512. else if (symbolic === 'error') {
  29513. return __assign({}, map, { fileName: getOriginalName() });
  29514. }
  29515. else {
  29516. return _super.prototype.visitStringMap.call(this, map, functionParams);
  29517. }
  29518. };
  29519. return ReferenceTransformer;
  29520. }(ValueTransformer));
  29521. var /** @type {?} */ transformedMeta = visitValue(metadata, new ReferenceTransformer(), []);
  29522. var /** @type {?} */ unwrappedTransformedMeta = unwrapResolvedMetadata(transformedMeta);
  29523. if (unwrappedTransformedMeta instanceof StaticSymbol) {
  29524. return this.createExport(sourceSymbol, unwrappedTransformedMeta);
  29525. }
  29526. return new ResolvedStaticSymbol(sourceSymbol, transformedMeta);
  29527. };
  29528. /**
  29529. * @param {?} sourceSymbol
  29530. * @param {?} targetSymbol
  29531. * @return {?}
  29532. */
  29533. StaticSymbolResolver.prototype.createExport = /**
  29534. * @param {?} sourceSymbol
  29535. * @param {?} targetSymbol
  29536. * @return {?}
  29537. */
  29538. function (sourceSymbol, targetSymbol) {
  29539. sourceSymbol.assertNoMembers();
  29540. targetSymbol.assertNoMembers();
  29541. if (this.summaryResolver.isLibraryFile(sourceSymbol.filePath) &&
  29542. this.summaryResolver.isLibraryFile(targetSymbol.filePath)) {
  29543. // This case is for an ng library importing symbols from a plain ts library
  29544. // transitively.
  29545. // Note: We rely on the fact that we discover symbols in the direction
  29546. // from source files to library files
  29547. this.importAs.set(targetSymbol, this.getImportAs(sourceSymbol) || sourceSymbol);
  29548. }
  29549. return new ResolvedStaticSymbol(sourceSymbol, targetSymbol);
  29550. };
  29551. /**
  29552. * @param {?} error
  29553. * @param {?=} context
  29554. * @param {?=} path
  29555. * @return {?}
  29556. */
  29557. StaticSymbolResolver.prototype.reportError = /**
  29558. * @param {?} error
  29559. * @param {?=} context
  29560. * @param {?=} path
  29561. * @return {?}
  29562. */
  29563. function (error, context, path) {
  29564. if (this.errorRecorder) {
  29565. this.errorRecorder(error, (context && context.filePath) || path);
  29566. }
  29567. else {
  29568. throw error;
  29569. }
  29570. };
  29571. /**
  29572. * @param {?} module an absolute path to a module file.
  29573. * @return {?}
  29574. */
  29575. StaticSymbolResolver.prototype.getModuleMetadata = /**
  29576. * @param {?} module an absolute path to a module file.
  29577. * @return {?}
  29578. */
  29579. function (module) {
  29580. var /** @type {?} */ moduleMetadata = this.metadataCache.get(module);
  29581. if (!moduleMetadata) {
  29582. var /** @type {?} */ moduleMetadatas = this.host.getMetadataFor(module);
  29583. if (moduleMetadatas) {
  29584. var /** @type {?} */ maxVersion_1 = -1;
  29585. moduleMetadatas.forEach(function (md) {
  29586. if (md && md['version'] > maxVersion_1) {
  29587. maxVersion_1 = md['version'];
  29588. moduleMetadata = md;
  29589. }
  29590. });
  29591. }
  29592. if (!moduleMetadata) {
  29593. moduleMetadata =
  29594. { __symbolic: 'module', version: SUPPORTED_SCHEMA_VERSION, module: module, metadata: {} };
  29595. }
  29596. if (moduleMetadata['version'] != SUPPORTED_SCHEMA_VERSION) {
  29597. var /** @type {?} */ errorMessage = moduleMetadata['version'] == 2 ?
  29598. "Unsupported metadata version " + moduleMetadata['version'] + " for module " + module + ". This module should be compiled with a newer version of ngc" :
  29599. "Metadata version mismatch for module " + module + ", found version " + moduleMetadata['version'] + ", expected " + SUPPORTED_SCHEMA_VERSION;
  29600. this.reportError(new Error(errorMessage));
  29601. }
  29602. this.metadataCache.set(module, moduleMetadata);
  29603. }
  29604. return moduleMetadata;
  29605. };
  29606. /**
  29607. * @param {?} module
  29608. * @param {?} symbolName
  29609. * @param {?=} containingFile
  29610. * @return {?}
  29611. */
  29612. StaticSymbolResolver.prototype.getSymbolByModule = /**
  29613. * @param {?} module
  29614. * @param {?} symbolName
  29615. * @param {?=} containingFile
  29616. * @return {?}
  29617. */
  29618. function (module, symbolName, containingFile) {
  29619. var /** @type {?} */ filePath = this.resolveModule(module, containingFile);
  29620. if (!filePath) {
  29621. this.reportError(new Error("Could not resolve module " + module + (containingFile ? ' relative to ' +
  29622. containingFile : '')));
  29623. return this.getStaticSymbol("ERROR:" + module, symbolName);
  29624. }
  29625. return this.getStaticSymbol(filePath, symbolName);
  29626. };
  29627. /**
  29628. * @param {?} module
  29629. * @param {?=} containingFile
  29630. * @return {?}
  29631. */
  29632. StaticSymbolResolver.prototype.resolveModule = /**
  29633. * @param {?} module
  29634. * @param {?=} containingFile
  29635. * @return {?}
  29636. */
  29637. function (module, containingFile) {
  29638. try {
  29639. return this.host.moduleNameToFileName(module, containingFile);
  29640. }
  29641. catch (/** @type {?} */ e) {
  29642. console.error("Could not resolve module '" + module + "' relative to file " + containingFile);
  29643. this.reportError(e, undefined, containingFile);
  29644. }
  29645. return null;
  29646. };
  29647. return StaticSymbolResolver;
  29648. }());
  29649. /**
  29650. * @param {?} identifier
  29651. * @return {?}
  29652. */
  29653. function unescapeIdentifier(identifier) {
  29654. return identifier.startsWith('___') ? identifier.substr(1) : identifier;
  29655. }
  29656. /**
  29657. * @param {?} metadata
  29658. * @return {?}
  29659. */
  29660. function unwrapResolvedMetadata(metadata) {
  29661. if (metadata && metadata.__symbolic === 'resolved') {
  29662. return metadata.symbol;
  29663. }
  29664. return metadata;
  29665. }
  29666. /**
  29667. * @fileoverview added by tsickle
  29668. * @suppress {checkTypes} checked by tsc
  29669. */
  29670. /**
  29671. * @param {?} srcFileName
  29672. * @param {?} forJitCtx
  29673. * @param {?} summaryResolver
  29674. * @param {?} symbolResolver
  29675. * @param {?} symbols
  29676. * @param {?} types
  29677. * @return {?}
  29678. */
  29679. function serializeSummaries(srcFileName, forJitCtx, summaryResolver, symbolResolver, symbols, types) {
  29680. var /** @type {?} */ toJsonSerializer = new ToJsonSerializer(symbolResolver, summaryResolver, srcFileName);
  29681. // for symbols, we use everything except for the class metadata itself
  29682. // (we keep the statics though), as the class metadata is contained in the
  29683. // CompileTypeSummary.
  29684. symbols.forEach(function (resolvedSymbol) {
  29685. return toJsonSerializer.addSummary({ symbol: resolvedSymbol.symbol, metadata: resolvedSymbol.metadata });
  29686. });
  29687. // Add type summaries.
  29688. types.forEach(function (_a) {
  29689. var summary = _a.summary, metadata = _a.metadata;
  29690. toJsonSerializer.addSummary({ symbol: summary.type.reference, metadata: undefined, type: summary });
  29691. });
  29692. var _a = toJsonSerializer.serialize(), json = _a.json, exportAs = _a.exportAs;
  29693. if (forJitCtx) {
  29694. var /** @type {?} */ forJitSerializer_1 = new ForJitSerializer(forJitCtx, symbolResolver, summaryResolver);
  29695. types.forEach(function (_a) {
  29696. var summary = _a.summary, metadata = _a.metadata;
  29697. forJitSerializer_1.addSourceType(summary, metadata);
  29698. });
  29699. toJsonSerializer.unprocessedSymbolSummariesBySymbol.forEach(function (summary) {
  29700. if (summaryResolver.isLibraryFile(summary.symbol.filePath) && summary.type) {
  29701. forJitSerializer_1.addLibType(summary.type);
  29702. }
  29703. });
  29704. forJitSerializer_1.serialize(exportAs);
  29705. }
  29706. return { json: json, exportAs: exportAs };
  29707. }
  29708. /**
  29709. * @param {?} symbolCache
  29710. * @param {?} summaryResolver
  29711. * @param {?} libraryFileName
  29712. * @param {?} json
  29713. * @return {?}
  29714. */
  29715. function deserializeSummaries(symbolCache, summaryResolver, libraryFileName, json) {
  29716. var /** @type {?} */ deserializer = new FromJsonDeserializer(symbolCache, summaryResolver);
  29717. return deserializer.deserialize(libraryFileName, json);
  29718. }
  29719. /**
  29720. * @param {?} outputCtx
  29721. * @param {?} reference
  29722. * @return {?}
  29723. */
  29724. function createForJitStub(outputCtx, reference) {
  29725. return createSummaryForJitFunction(outputCtx, reference, NULL_EXPR);
  29726. }
  29727. /**
  29728. * @param {?} outputCtx
  29729. * @param {?} reference
  29730. * @param {?} value
  29731. * @return {?}
  29732. */
  29733. function createSummaryForJitFunction(outputCtx, reference, value) {
  29734. var /** @type {?} */ fnName = summaryForJitName(reference.name);
  29735. outputCtx.statements.push(fn([], [new ReturnStatement(value)], new ArrayType(DYNAMIC_TYPE)).toDeclStmt(fnName, [
  29736. StmtModifier.Final, StmtModifier.Exported
  29737. ]));
  29738. }
  29739. var ToJsonSerializer = /** @class */ (function (_super) {
  29740. __extends(ToJsonSerializer, _super);
  29741. function ToJsonSerializer(symbolResolver, summaryResolver, srcFileName) {
  29742. var _this = _super.call(this) || this;
  29743. _this.symbolResolver = symbolResolver;
  29744. _this.summaryResolver = summaryResolver;
  29745. _this.srcFileName = srcFileName;
  29746. _this.symbols = [];
  29747. _this.indexBySymbol = new Map();
  29748. _this.reexportedBy = new Map();
  29749. _this.processedSummaryBySymbol = new Map();
  29750. _this.processedSummaries = [];
  29751. _this.unprocessedSymbolSummariesBySymbol = new Map();
  29752. _this.moduleName = symbolResolver.getKnownModuleName(srcFileName);
  29753. return _this;
  29754. }
  29755. /**
  29756. * @param {?} summary
  29757. * @return {?}
  29758. */
  29759. ToJsonSerializer.prototype.addSummary = /**
  29760. * @param {?} summary
  29761. * @return {?}
  29762. */
  29763. function (summary) {
  29764. var _this = this;
  29765. var /** @type {?} */ unprocessedSummary = this.unprocessedSymbolSummariesBySymbol.get(summary.symbol);
  29766. var /** @type {?} */ processedSummary = this.processedSummaryBySymbol.get(summary.symbol);
  29767. if (!unprocessedSummary) {
  29768. unprocessedSummary = { symbol: summary.symbol, metadata: undefined };
  29769. this.unprocessedSymbolSummariesBySymbol.set(summary.symbol, unprocessedSummary);
  29770. processedSummary = { symbol: this.processValue(summary.symbol, 0 /* None */) };
  29771. this.processedSummaries.push(processedSummary);
  29772. this.processedSummaryBySymbol.set(summary.symbol, processedSummary);
  29773. }
  29774. if (!unprocessedSummary.metadata && summary.metadata) {
  29775. var /** @type {?} */ metadata_1 = summary.metadata || {};
  29776. if (metadata_1.__symbolic === 'class') {
  29777. // For classes, we keep everything except their class decorators.
  29778. // We need to keep e.g. the ctor args, method names, method decorators
  29779. // so that the class can be extended in another compilation unit.
  29780. // We don't keep the class decorators as
  29781. // 1) they refer to data
  29782. // that should not cause a rebuild of downstream compilation units
  29783. // (e.g. inline templates of @Component, or @NgModule.declarations)
  29784. // 2) their data is already captured in TypeSummaries, e.g. DirectiveSummary.
  29785. var /** @type {?} */ clone_1 = {};
  29786. Object.keys(metadata_1).forEach(function (propName) {
  29787. if (propName !== 'decorators') {
  29788. clone_1[propName] = metadata_1[propName];
  29789. }
  29790. });
  29791. metadata_1 = clone_1;
  29792. }
  29793. else if (isCall(metadata_1)) {
  29794. if (!isFunctionCall(metadata_1) && !isMethodCallOnVariable(metadata_1)) {
  29795. // Don't store complex calls as we won't be able to simplify them anyways later on.
  29796. // Don't store complex calls as we won't be able to simplify them anyways later on.
  29797. metadata_1 = {
  29798. __symbolic: 'error',
  29799. message: 'Complex function calls are not supported.',
  29800. };
  29801. }
  29802. }
  29803. // Note: We need to keep storing ctor calls for e.g.
  29804. // `export const x = new InjectionToken(...)`
  29805. unprocessedSummary.metadata = metadata_1;
  29806. processedSummary.metadata = this.processValue(metadata_1, 1 /* ResolveValue */);
  29807. if (metadata_1 instanceof StaticSymbol &&
  29808. this.summaryResolver.isLibraryFile(metadata_1.filePath)) {
  29809. var /** @type {?} */ declarationSymbol = this.symbols[/** @type {?} */ ((this.indexBySymbol.get(metadata_1)))];
  29810. if (!isLoweredSymbol(declarationSymbol.name)) {
  29811. // Note: symbols that were introduced during codegen in the user file can have a reexport
  29812. // if a user used `export *`. However, we can't rely on this as tsickle will change
  29813. // `export *` into named exports, using only the information from the typechecker.
  29814. // As we introduce the new symbols after typecheck, Tsickle does not know about them,
  29815. // and omits them when expanding `export *`.
  29816. // So we have to keep reexporting these symbols manually via .ngfactory files.
  29817. this.reexportedBy.set(declarationSymbol, summary.symbol);
  29818. }
  29819. }
  29820. }
  29821. if (!unprocessedSummary.type && summary.type) {
  29822. unprocessedSummary.type = summary.type;
  29823. // Note: We don't add the summaries of all referenced symbols as for the ResolvedSymbols,
  29824. // as the type summaries already contain the transitive data that they require
  29825. // (in a minimal way).
  29826. processedSummary.type = this.processValue(summary.type, 0 /* None */);
  29827. // except for reexported directives / pipes, so we need to store
  29828. // their summaries explicitly.
  29829. if (summary.type.summaryKind === CompileSummaryKind.NgModule) {
  29830. var /** @type {?} */ ngModuleSummary = /** @type {?} */ (summary.type);
  29831. ngModuleSummary.exportedDirectives.concat(ngModuleSummary.exportedPipes).forEach(function (id) {
  29832. var /** @type {?} */ symbol = id.reference;
  29833. if (_this.summaryResolver.isLibraryFile(symbol.filePath) &&
  29834. !_this.unprocessedSymbolSummariesBySymbol.has(symbol)) {
  29835. var /** @type {?} */ summary_1 = _this.summaryResolver.resolveSummary(symbol);
  29836. if (summary_1) {
  29837. _this.addSummary(summary_1);
  29838. }
  29839. }
  29840. });
  29841. }
  29842. }
  29843. };
  29844. /**
  29845. * @return {?}
  29846. */
  29847. ToJsonSerializer.prototype.serialize = /**
  29848. * @return {?}
  29849. */
  29850. function () {
  29851. var _this = this;
  29852. var /** @type {?} */ exportAs = [];
  29853. var /** @type {?} */ json = JSON.stringify({
  29854. moduleName: this.moduleName,
  29855. summaries: this.processedSummaries,
  29856. symbols: this.symbols.map(function (symbol, index) {
  29857. symbol.assertNoMembers();
  29858. var /** @type {?} */ importAs = /** @type {?} */ ((undefined));
  29859. if (_this.summaryResolver.isLibraryFile(symbol.filePath)) {
  29860. var /** @type {?} */ reexportSymbol = _this.reexportedBy.get(symbol);
  29861. if (reexportSymbol) {
  29862. importAs = /** @type {?} */ ((_this.indexBySymbol.get(reexportSymbol)));
  29863. }
  29864. else {
  29865. var /** @type {?} */ summary = _this.unprocessedSymbolSummariesBySymbol.get(symbol);
  29866. if (!summary || !summary.metadata || summary.metadata.__symbolic !== 'interface') {
  29867. importAs = symbol.name + "_" + index;
  29868. exportAs.push({ symbol: symbol, exportAs: importAs });
  29869. }
  29870. }
  29871. }
  29872. return {
  29873. __symbol: index,
  29874. name: symbol.name,
  29875. filePath: _this.summaryResolver.toSummaryFileName(symbol.filePath, _this.srcFileName),
  29876. importAs: importAs
  29877. };
  29878. })
  29879. });
  29880. return { json: json, exportAs: exportAs };
  29881. };
  29882. /**
  29883. * @param {?} value
  29884. * @param {?} flags
  29885. * @return {?}
  29886. */
  29887. ToJsonSerializer.prototype.processValue = /**
  29888. * @param {?} value
  29889. * @param {?} flags
  29890. * @return {?}
  29891. */
  29892. function (value, flags) {
  29893. return visitValue(value, this, flags);
  29894. };
  29895. /**
  29896. * @param {?} value
  29897. * @param {?} context
  29898. * @return {?}
  29899. */
  29900. ToJsonSerializer.prototype.visitOther = /**
  29901. * @param {?} value
  29902. * @param {?} context
  29903. * @return {?}
  29904. */
  29905. function (value, context) {
  29906. if (value instanceof StaticSymbol) {
  29907. var /** @type {?} */ baseSymbol = this.symbolResolver.getStaticSymbol(value.filePath, value.name);
  29908. var /** @type {?} */ index = this.visitStaticSymbol(baseSymbol, context);
  29909. return { __symbol: index, members: value.members };
  29910. }
  29911. };
  29912. /**
  29913. * Returns null if the options.resolveValue is true, and the summary for the symbol
  29914. * resolved to a type or could not be resolved.
  29915. * @param {?} baseSymbol
  29916. * @param {?} flags
  29917. * @return {?}
  29918. */
  29919. ToJsonSerializer.prototype.visitStaticSymbol = /**
  29920. * Returns null if the options.resolveValue is true, and the summary for the symbol
  29921. * resolved to a type or could not be resolved.
  29922. * @param {?} baseSymbol
  29923. * @param {?} flags
  29924. * @return {?}
  29925. */
  29926. function (baseSymbol, flags) {
  29927. var /** @type {?} */ index = this.indexBySymbol.get(baseSymbol);
  29928. var /** @type {?} */ summary = null;
  29929. if (flags & 1 /* ResolveValue */ &&
  29930. this.summaryResolver.isLibraryFile(baseSymbol.filePath)) {
  29931. if (this.unprocessedSymbolSummariesBySymbol.has(baseSymbol)) {
  29932. // the summary for this symbol was already added
  29933. // -> nothing to do.
  29934. return /** @type {?} */ ((index));
  29935. }
  29936. summary = this.loadSummary(baseSymbol);
  29937. if (summary && summary.metadata instanceof StaticSymbol) {
  29938. // The summary is a reexport
  29939. index = this.visitStaticSymbol(summary.metadata, flags);
  29940. // reset the summary as it is just a reexport, so we don't want to store it.
  29941. summary = null;
  29942. }
  29943. }
  29944. else if (index != null) {
  29945. // Note: == on purpose to compare with undefined!
  29946. // No summary and the symbol is already added -> nothing to do.
  29947. return index;
  29948. }
  29949. // Note: == on purpose to compare with undefined!
  29950. if (index == null) {
  29951. index = this.symbols.length;
  29952. this.symbols.push(baseSymbol);
  29953. }
  29954. this.indexBySymbol.set(baseSymbol, index);
  29955. if (summary) {
  29956. this.addSummary(summary);
  29957. }
  29958. return index;
  29959. };
  29960. /**
  29961. * @param {?} symbol
  29962. * @return {?}
  29963. */
  29964. ToJsonSerializer.prototype.loadSummary = /**
  29965. * @param {?} symbol
  29966. * @return {?}
  29967. */
  29968. function (symbol) {
  29969. var /** @type {?} */ summary = this.summaryResolver.resolveSummary(symbol);
  29970. if (!summary) {
  29971. // some symbols might originate from a plain typescript library
  29972. // that just exported .d.ts and .metadata.json files, i.e. where no summary
  29973. // files were created.
  29974. var /** @type {?} */ resolvedSymbol = this.symbolResolver.resolveSymbol(symbol);
  29975. if (resolvedSymbol) {
  29976. summary = { symbol: resolvedSymbol.symbol, metadata: resolvedSymbol.metadata };
  29977. }
  29978. }
  29979. return summary;
  29980. };
  29981. return ToJsonSerializer;
  29982. }(ValueTransformer));
  29983. var ForJitSerializer = /** @class */ (function () {
  29984. function ForJitSerializer(outputCtx, symbolResolver, summaryResolver) {
  29985. this.outputCtx = outputCtx;
  29986. this.symbolResolver = symbolResolver;
  29987. this.summaryResolver = summaryResolver;
  29988. this.data = [];
  29989. }
  29990. /**
  29991. * @param {?} summary
  29992. * @param {?} metadata
  29993. * @return {?}
  29994. */
  29995. ForJitSerializer.prototype.addSourceType = /**
  29996. * @param {?} summary
  29997. * @param {?} metadata
  29998. * @return {?}
  29999. */
  30000. function (summary, metadata) {
  30001. this.data.push({ summary: summary, metadata: metadata, isLibrary: false });
  30002. };
  30003. /**
  30004. * @param {?} summary
  30005. * @return {?}
  30006. */
  30007. ForJitSerializer.prototype.addLibType = /**
  30008. * @param {?} summary
  30009. * @return {?}
  30010. */
  30011. function (summary) {
  30012. this.data.push({ summary: summary, metadata: null, isLibrary: true });
  30013. };
  30014. /**
  30015. * @param {?} exportAsArr
  30016. * @return {?}
  30017. */
  30018. ForJitSerializer.prototype.serialize = /**
  30019. * @param {?} exportAsArr
  30020. * @return {?}
  30021. */
  30022. function (exportAsArr) {
  30023. var _this = this;
  30024. var /** @type {?} */ exportAsBySymbol = new Map();
  30025. for (var _i = 0, exportAsArr_1 = exportAsArr; _i < exportAsArr_1.length; _i++) {
  30026. var _a = exportAsArr_1[_i], symbol = _a.symbol, exportAs = _a.exportAs;
  30027. exportAsBySymbol.set(symbol, exportAs);
  30028. }
  30029. var /** @type {?} */ ngModuleSymbols = new Set();
  30030. for (var _b = 0, _c = this.data; _b < _c.length; _b++) {
  30031. var _d = _c[_b], summary = _d.summary, metadata = _d.metadata, isLibrary = _d.isLibrary;
  30032. if (summary.summaryKind === CompileSummaryKind.NgModule) {
  30033. // collect the symbols that refer to NgModule classes.
  30034. // Note: we can't just rely on `summary.type.summaryKind` to determine this as
  30035. // we don't add the summaries of all referenced symbols when we serialize type summaries.
  30036. // See serializeSummaries for details.
  30037. ngModuleSymbols.add(summary.type.reference);
  30038. var /** @type {?} */ modSummary = /** @type {?} */ (summary);
  30039. for (var _e = 0, _f = modSummary.modules; _e < _f.length; _e++) {
  30040. var mod = _f[_e];
  30041. ngModuleSymbols.add(mod.reference);
  30042. }
  30043. }
  30044. if (!isLibrary) {
  30045. var /** @type {?} */ fnName = summaryForJitName(summary.type.reference.name);
  30046. createSummaryForJitFunction(this.outputCtx, summary.type.reference, this.serializeSummaryWithDeps(summary, /** @type {?} */ ((metadata))));
  30047. }
  30048. }
  30049. ngModuleSymbols.forEach(function (ngModuleSymbol) {
  30050. if (_this.summaryResolver.isLibraryFile(ngModuleSymbol.filePath)) {
  30051. var /** @type {?} */ exportAs = exportAsBySymbol.get(ngModuleSymbol) || ngModuleSymbol.name;
  30052. var /** @type {?} */ jitExportAsName = summaryForJitName(exportAs);
  30053. _this.outputCtx.statements.push(variable(jitExportAsName)
  30054. .set(_this.serializeSummaryRef(ngModuleSymbol))
  30055. .toDeclStmt(null, [StmtModifier.Exported]));
  30056. }
  30057. });
  30058. };
  30059. /**
  30060. * @param {?} summary
  30061. * @param {?} metadata
  30062. * @return {?}
  30063. */
  30064. ForJitSerializer.prototype.serializeSummaryWithDeps = /**
  30065. * @param {?} summary
  30066. * @param {?} metadata
  30067. * @return {?}
  30068. */
  30069. function (summary, metadata) {
  30070. var _this = this;
  30071. var /** @type {?} */ expressions = [this.serializeSummary(summary)];
  30072. var /** @type {?} */ providers = [];
  30073. if (metadata instanceof CompileNgModuleMetadata) {
  30074. expressions.push.apply(expressions,
  30075. // For directives / pipes, we only add the declared ones,
  30076. // and rely on transitively importing NgModules to get the transitive
  30077. // summaries.
  30078. metadata.declaredDirectives.concat(metadata.declaredPipes)
  30079. .map(function (type) { return type.reference; })
  30080. .concat(metadata.transitiveModule.modules.map(function (type) { return type.reference; })
  30081. .filter(function (ref) { return ref !== metadata.type.reference; }))
  30082. .map(function (ref) { return _this.serializeSummaryRef(ref); }));
  30083. // Note: We don't use `NgModuleSummary.providers`, as that one is transitive,
  30084. // and we already have transitive modules.
  30085. providers = metadata.providers;
  30086. }
  30087. else if (summary.summaryKind === CompileSummaryKind.Directive) {
  30088. var /** @type {?} */ dirSummary = /** @type {?} */ (summary);
  30089. providers = dirSummary.providers.concat(dirSummary.viewProviders);
  30090. }
  30091. // Note: We can't just refer to the `ngsummary.ts` files for `useClass` providers (as we do for
  30092. // declaredDirectives / declaredPipes), as we allow
  30093. // providers without ctor arguments to skip the `@Injectable` decorator,
  30094. // i.e. we didn't generate .ngsummary.ts files for these.
  30095. expressions.push.apply(expressions, providers.filter(function (provider) { return !!provider.useClass; }).map(function (provider) {
  30096. return _this.serializeSummary(/** @type {?} */ ({
  30097. summaryKind: CompileSummaryKind.Injectable, type: provider.useClass
  30098. }));
  30099. }));
  30100. return literalArr(expressions);
  30101. };
  30102. /**
  30103. * @param {?} typeSymbol
  30104. * @return {?}
  30105. */
  30106. ForJitSerializer.prototype.serializeSummaryRef = /**
  30107. * @param {?} typeSymbol
  30108. * @return {?}
  30109. */
  30110. function (typeSymbol) {
  30111. var /** @type {?} */ jitImportedSymbol = this.symbolResolver.getStaticSymbol(summaryForJitFileName(typeSymbol.filePath), summaryForJitName(typeSymbol.name));
  30112. return this.outputCtx.importExpr(jitImportedSymbol);
  30113. };
  30114. /**
  30115. * @param {?} data
  30116. * @return {?}
  30117. */
  30118. ForJitSerializer.prototype.serializeSummary = /**
  30119. * @param {?} data
  30120. * @return {?}
  30121. */
  30122. function (data) {
  30123. var /** @type {?} */ outputCtx = this.outputCtx;
  30124. var Transformer = /** @class */ (function () {
  30125. function Transformer() {
  30126. }
  30127. /**
  30128. * @param {?} arr
  30129. * @param {?} context
  30130. * @return {?}
  30131. */
  30132. Transformer.prototype.visitArray = /**
  30133. * @param {?} arr
  30134. * @param {?} context
  30135. * @return {?}
  30136. */
  30137. function (arr, context) {
  30138. var _this = this;
  30139. return literalArr(arr.map(function (entry) { return visitValue(entry, _this, context); }));
  30140. };
  30141. /**
  30142. * @param {?} map
  30143. * @param {?} context
  30144. * @return {?}
  30145. */
  30146. Transformer.prototype.visitStringMap = /**
  30147. * @param {?} map
  30148. * @param {?} context
  30149. * @return {?}
  30150. */
  30151. function (map, context) {
  30152. var _this = this;
  30153. return new LiteralMapExpr(Object.keys(map).map(function (key) { return new LiteralMapEntry(key, visitValue(map[key], _this, context), false); }));
  30154. };
  30155. /**
  30156. * @param {?} value
  30157. * @param {?} context
  30158. * @return {?}
  30159. */
  30160. Transformer.prototype.visitPrimitive = /**
  30161. * @param {?} value
  30162. * @param {?} context
  30163. * @return {?}
  30164. */
  30165. function (value, context) { return literal(value); };
  30166. /**
  30167. * @param {?} value
  30168. * @param {?} context
  30169. * @return {?}
  30170. */
  30171. Transformer.prototype.visitOther = /**
  30172. * @param {?} value
  30173. * @param {?} context
  30174. * @return {?}
  30175. */
  30176. function (value, context) {
  30177. if (value instanceof StaticSymbol) {
  30178. return outputCtx.importExpr(value);
  30179. }
  30180. else {
  30181. throw new Error("Illegal State: Encountered value " + value);
  30182. }
  30183. };
  30184. return Transformer;
  30185. }());
  30186. return visitValue(data, new Transformer(), null);
  30187. };
  30188. return ForJitSerializer;
  30189. }());
  30190. var FromJsonDeserializer = /** @class */ (function (_super) {
  30191. __extends(FromJsonDeserializer, _super);
  30192. function FromJsonDeserializer(symbolCache, summaryResolver) {
  30193. var _this = _super.call(this) || this;
  30194. _this.symbolCache = symbolCache;
  30195. _this.summaryResolver = summaryResolver;
  30196. return _this;
  30197. }
  30198. /**
  30199. * @param {?} libraryFileName
  30200. * @param {?} json
  30201. * @return {?}
  30202. */
  30203. FromJsonDeserializer.prototype.deserialize = /**
  30204. * @param {?} libraryFileName
  30205. * @param {?} json
  30206. * @return {?}
  30207. */
  30208. function (libraryFileName, json) {
  30209. var _this = this;
  30210. var /** @type {?} */ data = JSON.parse(json);
  30211. var /** @type {?} */ allImportAs = [];
  30212. this.symbols = data.symbols.map(function (serializedSymbol) {
  30213. return _this.symbolCache.get(_this.summaryResolver.fromSummaryFileName(serializedSymbol.filePath, libraryFileName), serializedSymbol.name);
  30214. });
  30215. data.symbols.forEach(function (serializedSymbol, index) {
  30216. var /** @type {?} */ symbol = _this.symbols[index];
  30217. var /** @type {?} */ importAs = serializedSymbol.importAs;
  30218. if (typeof importAs === 'number') {
  30219. allImportAs.push({ symbol: symbol, importAs: _this.symbols[importAs] });
  30220. }
  30221. else if (typeof importAs === 'string') {
  30222. allImportAs.push({ symbol: symbol, importAs: _this.symbolCache.get(ngfactoryFilePath(libraryFileName), importAs) });
  30223. }
  30224. });
  30225. var /** @type {?} */ summaries = /** @type {?} */ (visitValue(data.summaries, this, null));
  30226. return { moduleName: data.moduleName, summaries: summaries, importAs: allImportAs };
  30227. };
  30228. /**
  30229. * @param {?} map
  30230. * @param {?} context
  30231. * @return {?}
  30232. */
  30233. FromJsonDeserializer.prototype.visitStringMap = /**
  30234. * @param {?} map
  30235. * @param {?} context
  30236. * @return {?}
  30237. */
  30238. function (map, context) {
  30239. if ('__symbol' in map) {
  30240. var /** @type {?} */ baseSymbol = this.symbols[map['__symbol']];
  30241. var /** @type {?} */ members = map['members'];
  30242. return members.length ? this.symbolCache.get(baseSymbol.filePath, baseSymbol.name, members) :
  30243. baseSymbol;
  30244. }
  30245. else {
  30246. return _super.prototype.visitStringMap.call(this, map, context);
  30247. }
  30248. };
  30249. return FromJsonDeserializer;
  30250. }(ValueTransformer));
  30251. /**
  30252. * @param {?} metadata
  30253. * @return {?}
  30254. */
  30255. function isCall(metadata) {
  30256. return metadata && metadata.__symbolic === 'call';
  30257. }
  30258. /**
  30259. * @param {?} metadata
  30260. * @return {?}
  30261. */
  30262. function isFunctionCall(metadata) {
  30263. return isCall(metadata) && unwrapResolvedMetadata(metadata.expression) instanceof StaticSymbol;
  30264. }
  30265. /**
  30266. * @param {?} metadata
  30267. * @return {?}
  30268. */
  30269. function isMethodCallOnVariable(metadata) {
  30270. return isCall(metadata) && metadata.expression && metadata.expression.__symbolic === 'select' &&
  30271. unwrapResolvedMetadata(metadata.expression.expression) instanceof StaticSymbol;
  30272. }
  30273. /**
  30274. * @fileoverview added by tsickle
  30275. * @suppress {checkTypes} checked by tsc
  30276. */
  30277. /**
  30278. * @license
  30279. * Copyright Google Inc. All Rights Reserved.
  30280. *
  30281. * Use of this source code is governed by an MIT-style license that can be
  30282. * found in the LICENSE file at https://angular.io/license
  30283. */
  30284. /** @enum {number} */
  30285. var StubEmitFlags = {
  30286. Basic: 1,
  30287. TypeCheck: 2,
  30288. All: 3,
  30289. };
  30290. StubEmitFlags[StubEmitFlags.Basic] = "Basic";
  30291. StubEmitFlags[StubEmitFlags.TypeCheck] = "TypeCheck";
  30292. StubEmitFlags[StubEmitFlags.All] = "All";
  30293. var AotCompiler = /** @class */ (function () {
  30294. function AotCompiler(_config, _options, _host, _reflector, _metadataResolver, _templateParser, _styleCompiler, _viewCompiler, _typeCheckCompiler, _ngModuleCompiler, _outputEmitter, _summaryResolver, _symbolResolver) {
  30295. this._config = _config;
  30296. this._options = _options;
  30297. this._host = _host;
  30298. this._reflector = _reflector;
  30299. this._metadataResolver = _metadataResolver;
  30300. this._templateParser = _templateParser;
  30301. this._styleCompiler = _styleCompiler;
  30302. this._viewCompiler = _viewCompiler;
  30303. this._typeCheckCompiler = _typeCheckCompiler;
  30304. this._ngModuleCompiler = _ngModuleCompiler;
  30305. this._outputEmitter = _outputEmitter;
  30306. this._summaryResolver = _summaryResolver;
  30307. this._symbolResolver = _symbolResolver;
  30308. this._templateAstCache = new Map();
  30309. this._analyzedFiles = new Map();
  30310. }
  30311. /**
  30312. * @return {?}
  30313. */
  30314. AotCompiler.prototype.clearCache = /**
  30315. * @return {?}
  30316. */
  30317. function () { this._metadataResolver.clearCache(); };
  30318. /**
  30319. * @param {?} rootFiles
  30320. * @return {?}
  30321. */
  30322. AotCompiler.prototype.analyzeModulesSync = /**
  30323. * @param {?} rootFiles
  30324. * @return {?}
  30325. */
  30326. function (rootFiles) {
  30327. var _this = this;
  30328. var /** @type {?} */ analyzeResult = analyzeAndValidateNgModules(rootFiles, this._host, this._symbolResolver, this._metadataResolver);
  30329. analyzeResult.ngModules.forEach(function (ngModule) {
  30330. return _this._metadataResolver.loadNgModuleDirectiveAndPipeMetadata(ngModule.type.reference, true);
  30331. });
  30332. return analyzeResult;
  30333. };
  30334. /**
  30335. * @param {?} rootFiles
  30336. * @return {?}
  30337. */
  30338. AotCompiler.prototype.analyzeModulesAsync = /**
  30339. * @param {?} rootFiles
  30340. * @return {?}
  30341. */
  30342. function (rootFiles) {
  30343. var _this = this;
  30344. var /** @type {?} */ analyzeResult = analyzeAndValidateNgModules(rootFiles, this._host, this._symbolResolver, this._metadataResolver);
  30345. return Promise
  30346. .all(analyzeResult.ngModules.map(function (ngModule) {
  30347. return _this._metadataResolver.loadNgModuleDirectiveAndPipeMetadata(ngModule.type.reference, false);
  30348. }))
  30349. .then(function () { return analyzeResult; });
  30350. };
  30351. /**
  30352. * @param {?} fileName
  30353. * @return {?}
  30354. */
  30355. AotCompiler.prototype._analyzeFile = /**
  30356. * @param {?} fileName
  30357. * @return {?}
  30358. */
  30359. function (fileName) {
  30360. var /** @type {?} */ analyzedFile = this._analyzedFiles.get(fileName);
  30361. if (!analyzedFile) {
  30362. analyzedFile =
  30363. analyzeFile(this._host, this._symbolResolver, this._metadataResolver, fileName);
  30364. this._analyzedFiles.set(fileName, analyzedFile);
  30365. }
  30366. return analyzedFile;
  30367. };
  30368. /**
  30369. * @param {?} fileName
  30370. * @return {?}
  30371. */
  30372. AotCompiler.prototype.findGeneratedFileNames = /**
  30373. * @param {?} fileName
  30374. * @return {?}
  30375. */
  30376. function (fileName) {
  30377. var _this = this;
  30378. var /** @type {?} */ genFileNames = [];
  30379. var /** @type {?} */ file = this._analyzeFile(fileName);
  30380. // Make sure we create a .ngfactory if we have a injectable/directive/pipe/NgModule
  30381. // or a reference to a non source file.
  30382. // Note: This is overestimating the required .ngfactory files as the real calculation is harder.
  30383. // Only do this for StubEmitFlags.Basic, as adding a type check block
  30384. // does not change this file (as we generate type check blocks based on NgModules).
  30385. if (this._options.allowEmptyCodegenFiles || file.directives.length || file.pipes.length ||
  30386. file.injectables.length || file.ngModules.length || file.exportsNonSourceFiles) {
  30387. genFileNames.push(ngfactoryFilePath(file.fileName, true));
  30388. if (this._options.enableSummariesForJit) {
  30389. genFileNames.push(summaryForJitFileName(file.fileName, true));
  30390. }
  30391. }
  30392. var /** @type {?} */ fileSuffix = normalizeGenFileSuffix(splitTypescriptSuffix(file.fileName, true)[1]);
  30393. file.directives.forEach(function (dirSymbol) {
  30394. var /** @type {?} */ compMeta = /** @type {?} */ ((_this._metadataResolver.getNonNormalizedDirectiveMetadata(dirSymbol))).metadata;
  30395. if (!compMeta.isComponent) {
  30396. return;
  30397. } /** @type {?} */
  30398. ((
  30399. // Note: compMeta is a component and therefore template is non null.
  30400. compMeta.template)).styleUrls.forEach(function (styleUrl) {
  30401. var /** @type {?} */ normalizedUrl = _this._host.resourceNameToFileName(styleUrl, file.fileName);
  30402. if (!normalizedUrl) {
  30403. throw syntaxError("Couldn't resolve resource " + styleUrl + " relative to " + file.fileName);
  30404. }
  30405. var /** @type {?} */ needsShim = (/** @type {?} */ ((compMeta.template)).encapsulation || _this._config.defaultEncapsulation) === ViewEncapsulation.Emulated;
  30406. genFileNames.push(_stylesModuleUrl(normalizedUrl, needsShim, fileSuffix));
  30407. if (_this._options.allowEmptyCodegenFiles) {
  30408. genFileNames.push(_stylesModuleUrl(normalizedUrl, !needsShim, fileSuffix));
  30409. }
  30410. });
  30411. });
  30412. return genFileNames;
  30413. };
  30414. /**
  30415. * @param {?} genFileName
  30416. * @param {?=} originalFileName
  30417. * @return {?}
  30418. */
  30419. AotCompiler.prototype.emitBasicStub = /**
  30420. * @param {?} genFileName
  30421. * @param {?=} originalFileName
  30422. * @return {?}
  30423. */
  30424. function (genFileName, originalFileName) {
  30425. var /** @type {?} */ outputCtx = this._createOutputContext(genFileName);
  30426. if (genFileName.endsWith('.ngfactory.ts')) {
  30427. if (!originalFileName) {
  30428. throw new Error("Assertion error: require the original file for .ngfactory.ts stubs. File: " + genFileName);
  30429. }
  30430. var /** @type {?} */ originalFile = this._analyzeFile(originalFileName);
  30431. this._createNgFactoryStub(outputCtx, originalFile, StubEmitFlags.Basic);
  30432. }
  30433. else if (genFileName.endsWith('.ngsummary.ts')) {
  30434. if (this._options.enableSummariesForJit) {
  30435. if (!originalFileName) {
  30436. throw new Error("Assertion error: require the original file for .ngsummary.ts stubs. File: " + genFileName);
  30437. }
  30438. var /** @type {?} */ originalFile = this._analyzeFile(originalFileName);
  30439. _createEmptyStub(outputCtx);
  30440. originalFile.ngModules.forEach(function (ngModule) {
  30441. // create exports that user code can reference
  30442. createForJitStub(outputCtx, ngModule.type.reference);
  30443. });
  30444. }
  30445. }
  30446. else if (genFileName.endsWith('.ngstyle.ts')) {
  30447. _createEmptyStub(outputCtx);
  30448. }
  30449. // Note: for the stubs, we don't need a property srcFileUrl,
  30450. // as lateron in emitAllImpls we will create the proper GeneratedFiles with the
  30451. // correct srcFileUrl.
  30452. // This is good as e.g. for .ngstyle.ts files we can't derive
  30453. // the url of components based on the genFileUrl.
  30454. return this._codegenSourceModule('unknown', outputCtx);
  30455. };
  30456. /**
  30457. * @param {?} genFileName
  30458. * @param {?} originalFileName
  30459. * @return {?}
  30460. */
  30461. AotCompiler.prototype.emitTypeCheckStub = /**
  30462. * @param {?} genFileName
  30463. * @param {?} originalFileName
  30464. * @return {?}
  30465. */
  30466. function (genFileName, originalFileName) {
  30467. var /** @type {?} */ originalFile = this._analyzeFile(originalFileName);
  30468. var /** @type {?} */ outputCtx = this._createOutputContext(genFileName);
  30469. if (genFileName.endsWith('.ngfactory.ts')) {
  30470. this._createNgFactoryStub(outputCtx, originalFile, StubEmitFlags.TypeCheck);
  30471. }
  30472. return outputCtx.statements.length > 0 ?
  30473. this._codegenSourceModule(originalFile.fileName, outputCtx) :
  30474. null;
  30475. };
  30476. /**
  30477. * @param {?} fileNames
  30478. * @return {?}
  30479. */
  30480. AotCompiler.prototype.loadFilesAsync = /**
  30481. * @param {?} fileNames
  30482. * @return {?}
  30483. */
  30484. function (fileNames) {
  30485. var _this = this;
  30486. var /** @type {?} */ files = fileNames.map(function (fileName) { return _this._analyzeFile(fileName); });
  30487. var /** @type {?} */ loadingPromises = [];
  30488. files.forEach(function (file) {
  30489. return file.ngModules.forEach(function (ngModule) {
  30490. return loadingPromises.push(_this._metadataResolver.loadNgModuleDirectiveAndPipeMetadata(ngModule.type.reference, false));
  30491. });
  30492. });
  30493. return Promise.all(loadingPromises).then(function (_) { return mergeAndValidateNgFiles(files); });
  30494. };
  30495. /**
  30496. * @param {?} fileNames
  30497. * @return {?}
  30498. */
  30499. AotCompiler.prototype.loadFilesSync = /**
  30500. * @param {?} fileNames
  30501. * @return {?}
  30502. */
  30503. function (fileNames) {
  30504. var _this = this;
  30505. var /** @type {?} */ files = fileNames.map(function (fileName) { return _this._analyzeFile(fileName); });
  30506. files.forEach(function (file) {
  30507. return file.ngModules.forEach(function (ngModule) {
  30508. return _this._metadataResolver.loadNgModuleDirectiveAndPipeMetadata(ngModule.type.reference, true);
  30509. });
  30510. });
  30511. return mergeAndValidateNgFiles(files);
  30512. };
  30513. /**
  30514. * @param {?} outputCtx
  30515. * @param {?} file
  30516. * @param {?} emitFlags
  30517. * @return {?}
  30518. */
  30519. AotCompiler.prototype._createNgFactoryStub = /**
  30520. * @param {?} outputCtx
  30521. * @param {?} file
  30522. * @param {?} emitFlags
  30523. * @return {?}
  30524. */
  30525. function (outputCtx, file, emitFlags) {
  30526. var _this = this;
  30527. var /** @type {?} */ componentId = 0;
  30528. file.ngModules.forEach(function (ngModuleMeta, ngModuleIndex) {
  30529. // Note: the code below needs to executed for StubEmitFlags.Basic and StubEmitFlags.TypeCheck,
  30530. // so we don't change the .ngfactory file too much when adding the typecheck block.
  30531. // create exports that user code can reference
  30532. // Note: the code below needs to executed for StubEmitFlags.Basic and StubEmitFlags.TypeCheck,
  30533. // so we don't change the .ngfactory file too much when adding the typecheck block.
  30534. // create exports that user code can reference
  30535. _this._ngModuleCompiler.createStub(outputCtx, ngModuleMeta.type.reference);
  30536. // add references to the symbols from the metadata.
  30537. // These can be used by the type check block for components,
  30538. // and they also cause TypeScript to include these files into the program too,
  30539. // which will make them part of the analyzedFiles.
  30540. 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]));
  30541. var /** @type {?} */ externalReferenceVars = new Map();
  30542. externalReferences.forEach(function (ref, typeIndex) {
  30543. externalReferenceVars.set(ref, "_decl" + ngModuleIndex + "_" + typeIndex);
  30544. });
  30545. externalReferenceVars.forEach(function (varName, reference) {
  30546. outputCtx.statements.push(variable(varName)
  30547. .set(NULL_EXPR.cast(DYNAMIC_TYPE))
  30548. .toDeclStmt(expressionType(outputCtx.importExpr(reference, /* typeParams */ null, /* useSummaries */ /* useSummaries */ false))));
  30549. });
  30550. if (emitFlags & StubEmitFlags.TypeCheck) {
  30551. // add the typecheck block for all components of the NgModule
  30552. ngModuleMeta.declaredDirectives.forEach(function (dirId) {
  30553. var /** @type {?} */ compMeta = _this._metadataResolver.getDirectiveMetadata(dirId.reference);
  30554. if (!compMeta.isComponent) {
  30555. return;
  30556. }
  30557. componentId++;
  30558. _this._createTypeCheckBlock(outputCtx, compMeta.type.reference.name + "_Host_" + componentId, ngModuleMeta, _this._metadataResolver.getHostComponentMetadata(compMeta), [compMeta.type], externalReferenceVars);
  30559. _this._createTypeCheckBlock(outputCtx, compMeta.type.reference.name + "_" + componentId, ngModuleMeta, compMeta, ngModuleMeta.transitiveModule.directives, externalReferenceVars);
  30560. });
  30561. }
  30562. });
  30563. if (outputCtx.statements.length === 0) {
  30564. _createEmptyStub(outputCtx);
  30565. }
  30566. };
  30567. /**
  30568. * @param {?} references
  30569. * @return {?}
  30570. */
  30571. AotCompiler.prototype._externalIdentifierReferences = /**
  30572. * @param {?} references
  30573. * @return {?}
  30574. */
  30575. function (references) {
  30576. var /** @type {?} */ result = [];
  30577. for (var _i = 0, references_1 = references; _i < references_1.length; _i++) {
  30578. var reference = references_1[_i];
  30579. var /** @type {?} */ token = createTokenForExternalReference(this._reflector, reference);
  30580. if (token.identifier) {
  30581. result.push(token.identifier.reference);
  30582. }
  30583. }
  30584. return result;
  30585. };
  30586. /**
  30587. * @param {?} ctx
  30588. * @param {?} componentId
  30589. * @param {?} moduleMeta
  30590. * @param {?} compMeta
  30591. * @param {?} directives
  30592. * @param {?} externalReferenceVars
  30593. * @return {?}
  30594. */
  30595. AotCompiler.prototype._createTypeCheckBlock = /**
  30596. * @param {?} ctx
  30597. * @param {?} componentId
  30598. * @param {?} moduleMeta
  30599. * @param {?} compMeta
  30600. * @param {?} directives
  30601. * @param {?} externalReferenceVars
  30602. * @return {?}
  30603. */
  30604. function (ctx, componentId, moduleMeta, compMeta, directives, externalReferenceVars) {
  30605. var _a = this._parseTemplate(compMeta, moduleMeta, directives), parsedTemplate = _a.template, usedPipes = _a.pipes;
  30606. (_b = ctx.statements).push.apply(_b, this._typeCheckCompiler.compileComponent(componentId, compMeta, parsedTemplate, usedPipes, externalReferenceVars, ctx));
  30607. var _b;
  30608. };
  30609. /**
  30610. * @param {?} analyzeResult
  30611. * @param {?} locale
  30612. * @return {?}
  30613. */
  30614. AotCompiler.prototype.emitMessageBundle = /**
  30615. * @param {?} analyzeResult
  30616. * @param {?} locale
  30617. * @return {?}
  30618. */
  30619. function (analyzeResult, locale) {
  30620. var _this = this;
  30621. var /** @type {?} */ errors = [];
  30622. var /** @type {?} */ htmlParser = new HtmlParser();
  30623. // TODO(vicb): implicit tags & attributes
  30624. var /** @type {?} */ messageBundle = new MessageBundle(htmlParser, [], {}, locale);
  30625. analyzeResult.files.forEach(function (file) {
  30626. var /** @type {?} */ compMetas = [];
  30627. file.directives.forEach(function (directiveType) {
  30628. var /** @type {?} */ dirMeta = _this._metadataResolver.getDirectiveMetadata(directiveType);
  30629. if (dirMeta && dirMeta.isComponent) {
  30630. compMetas.push(dirMeta);
  30631. }
  30632. });
  30633. compMetas.forEach(function (compMeta) {
  30634. var /** @type {?} */ html = /** @type {?} */ ((/** @type {?} */ ((compMeta.template)).template));
  30635. var /** @type {?} */ interpolationConfig = InterpolationConfig.fromArray(/** @type {?} */ ((compMeta.template)).interpolation);
  30636. errors.push.apply(errors, /** @type {?} */ ((messageBundle.updateFromTemplate(html, file.fileName, interpolationConfig))));
  30637. });
  30638. });
  30639. if (errors.length) {
  30640. throw new Error(errors.map(function (e) { return e.toString(); }).join('\n'));
  30641. }
  30642. return messageBundle;
  30643. };
  30644. /**
  30645. * @param {?} analyzeResult
  30646. * @return {?}
  30647. */
  30648. AotCompiler.prototype.emitAllImpls = /**
  30649. * @param {?} analyzeResult
  30650. * @return {?}
  30651. */
  30652. function (analyzeResult) {
  30653. var _this = this;
  30654. var ngModuleByPipeOrDirective = analyzeResult.ngModuleByPipeOrDirective, files = analyzeResult.files;
  30655. var /** @type {?} */ sourceModules = files.map(function (file) {
  30656. return _this._compileImplFile(file.fileName, ngModuleByPipeOrDirective, file.directives, file.pipes, file.ngModules, file.injectables);
  30657. });
  30658. return flatten(sourceModules);
  30659. };
  30660. /**
  30661. * @param {?} srcFileUrl
  30662. * @param {?} ngModuleByPipeOrDirective
  30663. * @param {?} directives
  30664. * @param {?} pipes
  30665. * @param {?} ngModules
  30666. * @param {?} injectables
  30667. * @return {?}
  30668. */
  30669. AotCompiler.prototype._compileImplFile = /**
  30670. * @param {?} srcFileUrl
  30671. * @param {?} ngModuleByPipeOrDirective
  30672. * @param {?} directives
  30673. * @param {?} pipes
  30674. * @param {?} ngModules
  30675. * @param {?} injectables
  30676. * @return {?}
  30677. */
  30678. function (srcFileUrl, ngModuleByPipeOrDirective, directives, pipes, ngModules, injectables) {
  30679. var _this = this;
  30680. var /** @type {?} */ fileSuffix = normalizeGenFileSuffix(splitTypescriptSuffix(srcFileUrl, true)[1]);
  30681. var /** @type {?} */ generatedFiles = [];
  30682. var /** @type {?} */ outputCtx = this._createOutputContext(ngfactoryFilePath(srcFileUrl, true));
  30683. generatedFiles.push.apply(generatedFiles, this._createSummary(srcFileUrl, directives, pipes, ngModules, injectables, outputCtx));
  30684. // compile all ng modules
  30685. ngModules.forEach(function (ngModuleMeta) { return _this._compileModule(outputCtx, ngModuleMeta); });
  30686. // compile components
  30687. directives.forEach(function (dirType) {
  30688. var /** @type {?} */ compMeta = _this._metadataResolver.getDirectiveMetadata(/** @type {?} */ (dirType));
  30689. if (!compMeta.isComponent) {
  30690. return;
  30691. }
  30692. var /** @type {?} */ ngModule = ngModuleByPipeOrDirective.get(dirType);
  30693. if (!ngModule) {
  30694. throw new Error("Internal Error: cannot determine the module for component " + identifierName(compMeta.type) + "!");
  30695. }
  30696. // compile styles
  30697. var /** @type {?} */ componentStylesheet = _this._styleCompiler.compileComponent(outputCtx, compMeta); /** @type {?} */
  30698. ((
  30699. // Note: compMeta is a component and therefore template is non null.
  30700. compMeta.template)).externalStylesheets.forEach(function (stylesheetMeta) {
  30701. // Note: fill non shim and shim style files as they might
  30702. // be shared by component with and without ViewEncapsulation.
  30703. var /** @type {?} */ shim = _this._styleCompiler.needsStyleShim(compMeta);
  30704. generatedFiles.push(_this._codegenStyles(srcFileUrl, compMeta, stylesheetMeta, shim, fileSuffix));
  30705. if (_this._options.allowEmptyCodegenFiles) {
  30706. generatedFiles.push(_this._codegenStyles(srcFileUrl, compMeta, stylesheetMeta, !shim, fileSuffix));
  30707. }
  30708. });
  30709. // compile components
  30710. var /** @type {?} */ compViewVars = _this._compileComponent(outputCtx, compMeta, ngModule, ngModule.transitiveModule.directives, componentStylesheet, fileSuffix);
  30711. _this._compileComponentFactory(outputCtx, compMeta, ngModule, fileSuffix);
  30712. });
  30713. if (outputCtx.statements.length > 0 || this._options.allowEmptyCodegenFiles) {
  30714. var /** @type {?} */ srcModule = this._codegenSourceModule(srcFileUrl, outputCtx);
  30715. generatedFiles.unshift(srcModule);
  30716. }
  30717. return generatedFiles;
  30718. };
  30719. /**
  30720. * @param {?} srcFileName
  30721. * @param {?} directives
  30722. * @param {?} pipes
  30723. * @param {?} ngModules
  30724. * @param {?} injectables
  30725. * @param {?} ngFactoryCtx
  30726. * @return {?}
  30727. */
  30728. AotCompiler.prototype._createSummary = /**
  30729. * @param {?} srcFileName
  30730. * @param {?} directives
  30731. * @param {?} pipes
  30732. * @param {?} ngModules
  30733. * @param {?} injectables
  30734. * @param {?} ngFactoryCtx
  30735. * @return {?}
  30736. */
  30737. function (srcFileName, directives, pipes, ngModules, injectables, ngFactoryCtx) {
  30738. var _this = this;
  30739. var /** @type {?} */ symbolSummaries = this._symbolResolver.getSymbolsOf(srcFileName)
  30740. .map(function (symbol) { return _this._symbolResolver.resolveSymbol(symbol); });
  30741. var /** @type {?} */ typeData = ngModules.map(function (meta) {
  30742. return ({
  30743. summary: /** @type {?} */ ((_this._metadataResolver.getNgModuleSummary(meta.type.reference))),
  30744. metadata: /** @type {?} */ ((_this._metadataResolver.getNgModuleMetadata(meta.type.reference)))
  30745. });
  30746. }).concat(directives.map(function (ref) {
  30747. return ({
  30748. summary: /** @type {?} */ ((_this._metadataResolver.getDirectiveSummary(ref))),
  30749. metadata: /** @type {?} */ ((_this._metadataResolver.getDirectiveMetadata(ref)))
  30750. });
  30751. }), pipes.map(function (ref) {
  30752. return ({
  30753. summary: /** @type {?} */ ((_this._metadataResolver.getPipeSummary(ref))),
  30754. metadata: /** @type {?} */ ((_this._metadataResolver.getPipeMetadata(ref)))
  30755. });
  30756. }), injectables.map(function (ref) {
  30757. return ({
  30758. summary: /** @type {?} */ ((_this._metadataResolver.getInjectableSummary(ref))),
  30759. metadata: /** @type {?} */ ((_this._metadataResolver.getInjectableSummary(ref))).type
  30760. });
  30761. }));
  30762. var /** @type {?} */ forJitOutputCtx = this._options.enableSummariesForJit ?
  30763. this._createOutputContext(summaryForJitFileName(srcFileName, true)) :
  30764. null;
  30765. var _a = serializeSummaries(srcFileName, forJitOutputCtx, this._summaryResolver, this._symbolResolver, symbolSummaries, typeData), json = _a.json, exportAs = _a.exportAs;
  30766. exportAs.forEach(function (entry) {
  30767. ngFactoryCtx.statements.push(variable(entry.exportAs).set(ngFactoryCtx.importExpr(entry.symbol)).toDeclStmt(null, [
  30768. StmtModifier.Exported
  30769. ]));
  30770. });
  30771. var /** @type {?} */ summaryJson = new GeneratedFile(srcFileName, summaryFileName(srcFileName), json);
  30772. var /** @type {?} */ result = [summaryJson];
  30773. if (forJitOutputCtx) {
  30774. result.push(this._codegenSourceModule(srcFileName, forJitOutputCtx));
  30775. }
  30776. return result;
  30777. };
  30778. /**
  30779. * @param {?} outputCtx
  30780. * @param {?} ngModule
  30781. * @return {?}
  30782. */
  30783. AotCompiler.prototype._compileModule = /**
  30784. * @param {?} outputCtx
  30785. * @param {?} ngModule
  30786. * @return {?}
  30787. */
  30788. function (outputCtx, ngModule) {
  30789. var /** @type {?} */ providers = [];
  30790. if (this._options.locale) {
  30791. var /** @type {?} */ normalizedLocale = this._options.locale.replace(/_/g, '-');
  30792. providers.push({
  30793. token: createTokenForExternalReference(this._reflector, Identifiers.LOCALE_ID),
  30794. useValue: normalizedLocale,
  30795. });
  30796. }
  30797. if (this._options.i18nFormat) {
  30798. providers.push({
  30799. token: createTokenForExternalReference(this._reflector, Identifiers.TRANSLATIONS_FORMAT),
  30800. useValue: this._options.i18nFormat
  30801. });
  30802. }
  30803. this._ngModuleCompiler.compile(outputCtx, ngModule, providers);
  30804. };
  30805. /**
  30806. * @param {?} outputCtx
  30807. * @param {?} compMeta
  30808. * @param {?} ngModule
  30809. * @param {?} fileSuffix
  30810. * @return {?}
  30811. */
  30812. AotCompiler.prototype._compileComponentFactory = /**
  30813. * @param {?} outputCtx
  30814. * @param {?} compMeta
  30815. * @param {?} ngModule
  30816. * @param {?} fileSuffix
  30817. * @return {?}
  30818. */
  30819. function (outputCtx, compMeta, ngModule, fileSuffix) {
  30820. var /** @type {?} */ hostMeta = this._metadataResolver.getHostComponentMetadata(compMeta);
  30821. var /** @type {?} */ hostViewFactoryVar = this._compileComponent(outputCtx, hostMeta, ngModule, [compMeta.type], null, fileSuffix)
  30822. .viewClassVar;
  30823. var /** @type {?} */ compFactoryVar = componentFactoryName(compMeta.type.reference);
  30824. var /** @type {?} */ inputsExprs = [];
  30825. for (var /** @type {?} */ propName in compMeta.inputs) {
  30826. var /** @type {?} */ templateName = compMeta.inputs[propName];
  30827. // Don't quote so that the key gets minified...
  30828. inputsExprs.push(new LiteralMapEntry(propName, literal(templateName), false));
  30829. }
  30830. var /** @type {?} */ outputsExprs = [];
  30831. for (var /** @type {?} */ propName in compMeta.outputs) {
  30832. var /** @type {?} */ templateName = compMeta.outputs[propName];
  30833. // Don't quote so that the key gets minified...
  30834. outputsExprs.push(new LiteralMapEntry(propName, literal(templateName), false));
  30835. }
  30836. outputCtx.statements.push(variable(compFactoryVar)
  30837. .set(importExpr(Identifiers.createComponentFactory).callFn([
  30838. literal(compMeta.selector), outputCtx.importExpr(compMeta.type.reference),
  30839. variable(hostViewFactoryVar), new LiteralMapExpr(inputsExprs),
  30840. new LiteralMapExpr(outputsExprs),
  30841. literalArr(/** @type {?} */ ((compMeta.template)).ngContentSelectors.map(function (selector) { return literal(selector); }))
  30842. ]))
  30843. .toDeclStmt(importType(Identifiers.ComponentFactory, [/** @type {?} */ ((expressionType(outputCtx.importExpr(compMeta.type.reference))))], [TypeModifier.Const]), [StmtModifier.Final, StmtModifier.Exported]));
  30844. };
  30845. /**
  30846. * @param {?} outputCtx
  30847. * @param {?} compMeta
  30848. * @param {?} ngModule
  30849. * @param {?} directiveIdentifiers
  30850. * @param {?} componentStyles
  30851. * @param {?} fileSuffix
  30852. * @return {?}
  30853. */
  30854. AotCompiler.prototype._compileComponent = /**
  30855. * @param {?} outputCtx
  30856. * @param {?} compMeta
  30857. * @param {?} ngModule
  30858. * @param {?} directiveIdentifiers
  30859. * @param {?} componentStyles
  30860. * @param {?} fileSuffix
  30861. * @return {?}
  30862. */
  30863. function (outputCtx, compMeta, ngModule, directiveIdentifiers, componentStyles, fileSuffix) {
  30864. var _a = this._parseTemplate(compMeta, ngModule, directiveIdentifiers), parsedTemplate = _a.template, usedPipes = _a.pipes;
  30865. var /** @type {?} */ stylesExpr = componentStyles ? variable(componentStyles.stylesVar) : literalArr([]);
  30866. var /** @type {?} */ viewResult = this._viewCompiler.compileComponent(outputCtx, compMeta, parsedTemplate, stylesExpr, usedPipes);
  30867. if (componentStyles) {
  30868. _resolveStyleStatements(this._symbolResolver, componentStyles, this._styleCompiler.needsStyleShim(compMeta), fileSuffix);
  30869. }
  30870. return viewResult;
  30871. };
  30872. /**
  30873. * @param {?} compMeta
  30874. * @param {?} ngModule
  30875. * @param {?} directiveIdentifiers
  30876. * @return {?}
  30877. */
  30878. AotCompiler.prototype._parseTemplate = /**
  30879. * @param {?} compMeta
  30880. * @param {?} ngModule
  30881. * @param {?} directiveIdentifiers
  30882. * @return {?}
  30883. */
  30884. function (compMeta, ngModule, directiveIdentifiers) {
  30885. var _this = this;
  30886. if (this._templateAstCache.has(compMeta.type.reference)) {
  30887. return /** @type {?} */ ((this._templateAstCache.get(compMeta.type.reference)));
  30888. }
  30889. var /** @type {?} */ preserveWhitespaces = /** @type {?} */ ((/** @type {?} */ ((compMeta)).template)).preserveWhitespaces;
  30890. var /** @type {?} */ directives = directiveIdentifiers.map(function (dir) { return _this._metadataResolver.getDirectiveSummary(dir.reference); });
  30891. var /** @type {?} */ pipes = ngModule.transitiveModule.pipes.map(function (pipe) { return _this._metadataResolver.getPipeSummary(pipe.reference); });
  30892. var /** @type {?} */ result = this._templateParser.parse(compMeta, /** @type {?} */ ((/** @type {?} */ ((compMeta.template)).htmlAst)), directives, pipes, ngModule.schemas, templateSourceUrl(ngModule.type, compMeta, /** @type {?} */ ((compMeta.template))), preserveWhitespaces);
  30893. this._templateAstCache.set(compMeta.type.reference, result);
  30894. return result;
  30895. };
  30896. /**
  30897. * @param {?} genFilePath
  30898. * @return {?}
  30899. */
  30900. AotCompiler.prototype._createOutputContext = /**
  30901. * @param {?} genFilePath
  30902. * @return {?}
  30903. */
  30904. function (genFilePath) {
  30905. var _this = this;
  30906. var /** @type {?} */ importExpr$$1 = function (symbol, typeParams, useSummaries) {
  30907. if (typeParams === void 0) { typeParams = null; }
  30908. if (useSummaries === void 0) { useSummaries = true; }
  30909. if (!(symbol instanceof StaticSymbol)) {
  30910. throw new Error("Internal error: unknown identifier " + JSON.stringify(symbol));
  30911. }
  30912. var /** @type {?} */ arity = _this._symbolResolver.getTypeArity(symbol) || 0;
  30913. var _a = _this._symbolResolver.getImportAs(symbol, useSummaries) || symbol, filePath = _a.filePath, name = _a.name, members = _a.members;
  30914. var /** @type {?} */ importModule = _this._fileNameToModuleName(filePath, genFilePath);
  30915. // It should be good enough to compare filePath to genFilePath and if they are equal
  30916. // there is a self reference. However, ngfactory files generate to .ts but their
  30917. // symbols have .d.ts so a simple compare is insufficient. They should be canonical
  30918. // and is tracked by #17705.
  30919. var /** @type {?} */ selfReference = _this._fileNameToModuleName(genFilePath, genFilePath);
  30920. var /** @type {?} */ moduleName = importModule === selfReference ? null : importModule;
  30921. // If we are in a type expression that refers to a generic type then supply
  30922. // the required type parameters. If there were not enough type parameters
  30923. // supplied, supply any as the type. Outside a type expression the reference
  30924. // should not supply type parameters and be treated as a simple value reference
  30925. // to the constructor function itself.
  30926. var /** @type {?} */ suppliedTypeParams = typeParams || [];
  30927. var /** @type {?} */ missingTypeParamsCount = arity - suppliedTypeParams.length;
  30928. var /** @type {?} */ allTypeParams = suppliedTypeParams.concat(new Array(missingTypeParamsCount).fill(DYNAMIC_TYPE));
  30929. return members.reduce(function (expr, memberName) { return expr.prop(memberName); }, /** @type {?} */ (importExpr(new ExternalReference(moduleName, name, null), allTypeParams)));
  30930. };
  30931. return { statements: [], genFilePath: genFilePath, importExpr: importExpr$$1 };
  30932. };
  30933. /**
  30934. * @param {?} importedFilePath
  30935. * @param {?} containingFilePath
  30936. * @return {?}
  30937. */
  30938. AotCompiler.prototype._fileNameToModuleName = /**
  30939. * @param {?} importedFilePath
  30940. * @param {?} containingFilePath
  30941. * @return {?}
  30942. */
  30943. function (importedFilePath, containingFilePath) {
  30944. return this._summaryResolver.getKnownModuleName(importedFilePath) ||
  30945. this._symbolResolver.getKnownModuleName(importedFilePath) ||
  30946. this._host.fileNameToModuleName(importedFilePath, containingFilePath);
  30947. };
  30948. /**
  30949. * @param {?} srcFileUrl
  30950. * @param {?} compMeta
  30951. * @param {?} stylesheetMetadata
  30952. * @param {?} isShimmed
  30953. * @param {?} fileSuffix
  30954. * @return {?}
  30955. */
  30956. AotCompiler.prototype._codegenStyles = /**
  30957. * @param {?} srcFileUrl
  30958. * @param {?} compMeta
  30959. * @param {?} stylesheetMetadata
  30960. * @param {?} isShimmed
  30961. * @param {?} fileSuffix
  30962. * @return {?}
  30963. */
  30964. function (srcFileUrl, compMeta, stylesheetMetadata, isShimmed, fileSuffix) {
  30965. var /** @type {?} */ outputCtx = this._createOutputContext(_stylesModuleUrl(/** @type {?} */ ((stylesheetMetadata.moduleUrl)), isShimmed, fileSuffix));
  30966. var /** @type {?} */ compiledStylesheet = this._styleCompiler.compileStyles(outputCtx, compMeta, stylesheetMetadata, isShimmed);
  30967. _resolveStyleStatements(this._symbolResolver, compiledStylesheet, isShimmed, fileSuffix);
  30968. return this._codegenSourceModule(srcFileUrl, outputCtx);
  30969. };
  30970. /**
  30971. * @param {?} srcFileUrl
  30972. * @param {?} ctx
  30973. * @return {?}
  30974. */
  30975. AotCompiler.prototype._codegenSourceModule = /**
  30976. * @param {?} srcFileUrl
  30977. * @param {?} ctx
  30978. * @return {?}
  30979. */
  30980. function (srcFileUrl, ctx) {
  30981. return new GeneratedFile(srcFileUrl, ctx.genFilePath, ctx.statements);
  30982. };
  30983. /**
  30984. * @param {?=} entryRoute
  30985. * @param {?=} analyzedModules
  30986. * @return {?}
  30987. */
  30988. AotCompiler.prototype.listLazyRoutes = /**
  30989. * @param {?=} entryRoute
  30990. * @param {?=} analyzedModules
  30991. * @return {?}
  30992. */
  30993. function (entryRoute, analyzedModules) {
  30994. var /** @type {?} */ self = this;
  30995. if (entryRoute) {
  30996. var /** @type {?} */ symbol = parseLazyRoute(entryRoute, this._reflector).referencedModule;
  30997. return visitLazyRoute(symbol);
  30998. }
  30999. else if (analyzedModules) {
  31000. var /** @type {?} */ allLazyRoutes = [];
  31001. for (var _i = 0, _a = analyzedModules.ngModules; _i < _a.length; _i++) {
  31002. var ngModule = _a[_i];
  31003. var /** @type {?} */ lazyRoutes = listLazyRoutes(ngModule, this._reflector);
  31004. for (var _b = 0, lazyRoutes_1 = lazyRoutes; _b < lazyRoutes_1.length; _b++) {
  31005. var lazyRoute = lazyRoutes_1[_b];
  31006. allLazyRoutes.push(lazyRoute);
  31007. }
  31008. }
  31009. return allLazyRoutes;
  31010. }
  31011. else {
  31012. throw new Error("Either route or analyzedModules has to be specified!");
  31013. }
  31014. /**
  31015. * @param {?} symbol
  31016. * @param {?=} seenRoutes
  31017. * @param {?=} allLazyRoutes
  31018. * @return {?}
  31019. */
  31020. function visitLazyRoute(symbol, seenRoutes, allLazyRoutes) {
  31021. if (seenRoutes === void 0) { seenRoutes = new Set(); }
  31022. if (allLazyRoutes === void 0) { allLazyRoutes = []; }
  31023. // Support pointing to default exports, but stop recursing there,
  31024. // as the StaticReflector does not yet support default exports.
  31025. if (seenRoutes.has(symbol) || !symbol.name) {
  31026. return allLazyRoutes;
  31027. }
  31028. seenRoutes.add(symbol);
  31029. var /** @type {?} */ lazyRoutes = listLazyRoutes(/** @type {?} */ ((self._metadataResolver.getNgModuleMetadata(symbol, true))), self._reflector);
  31030. for (var _i = 0, lazyRoutes_2 = lazyRoutes; _i < lazyRoutes_2.length; _i++) {
  31031. var lazyRoute = lazyRoutes_2[_i];
  31032. allLazyRoutes.push(lazyRoute);
  31033. visitLazyRoute(lazyRoute.referencedModule, seenRoutes, allLazyRoutes);
  31034. }
  31035. return allLazyRoutes;
  31036. }
  31037. };
  31038. return AotCompiler;
  31039. }());
  31040. /**
  31041. * @param {?} outputCtx
  31042. * @return {?}
  31043. */
  31044. function _createEmptyStub(outputCtx) {
  31045. // Note: We need to produce at least one import statement so that
  31046. // TypeScript knows that the file is an es6 module. Otherwise our generated
  31047. // exports / imports won't be emitted properly by TypeScript.
  31048. outputCtx.statements.push(importExpr(Identifiers.ComponentFactory).toStmt());
  31049. }
  31050. /**
  31051. * @param {?} symbolResolver
  31052. * @param {?} compileResult
  31053. * @param {?} needsShim
  31054. * @param {?} fileSuffix
  31055. * @return {?}
  31056. */
  31057. function _resolveStyleStatements(symbolResolver, compileResult, needsShim, fileSuffix) {
  31058. compileResult.dependencies.forEach(function (dep) {
  31059. dep.setValue(symbolResolver.getStaticSymbol(_stylesModuleUrl(dep.moduleUrl, needsShim, fileSuffix), dep.name));
  31060. });
  31061. }
  31062. /**
  31063. * @param {?} stylesheetUrl
  31064. * @param {?} shim
  31065. * @param {?} suffix
  31066. * @return {?}
  31067. */
  31068. function _stylesModuleUrl(stylesheetUrl, shim, suffix) {
  31069. return "" + stylesheetUrl + (shim ? '.shim' : '') + ".ngstyle" + suffix;
  31070. }
  31071. /**
  31072. * @record
  31073. */
  31074. /**
  31075. * @record
  31076. */
  31077. /**
  31078. * @record
  31079. */
  31080. /**
  31081. * @param {?} fileNames
  31082. * @param {?} host
  31083. * @param {?} staticSymbolResolver
  31084. * @param {?} metadataResolver
  31085. * @return {?}
  31086. */
  31087. function analyzeNgModules(fileNames, host, staticSymbolResolver, metadataResolver) {
  31088. var /** @type {?} */ files = _analyzeFilesIncludingNonProgramFiles(fileNames, host, staticSymbolResolver, metadataResolver);
  31089. return mergeAnalyzedFiles(files);
  31090. }
  31091. /**
  31092. * @param {?} fileNames
  31093. * @param {?} host
  31094. * @param {?} staticSymbolResolver
  31095. * @param {?} metadataResolver
  31096. * @return {?}
  31097. */
  31098. function analyzeAndValidateNgModules(fileNames, host, staticSymbolResolver, metadataResolver) {
  31099. return validateAnalyzedModules(analyzeNgModules(fileNames, host, staticSymbolResolver, metadataResolver));
  31100. }
  31101. /**
  31102. * @param {?} analyzedModules
  31103. * @return {?}
  31104. */
  31105. function validateAnalyzedModules(analyzedModules) {
  31106. if (analyzedModules.symbolsMissingModule && analyzedModules.symbolsMissingModule.length) {
  31107. var /** @type {?} */ messages = analyzedModules.symbolsMissingModule.map(function (s) {
  31108. return "Cannot determine the module for class " + s.name + " in " + s.filePath + "! Add " + s.name + " to the NgModule to fix it.";
  31109. });
  31110. throw syntaxError(messages.join('\n'));
  31111. }
  31112. return analyzedModules;
  31113. }
  31114. /**
  31115. * @param {?} fileNames
  31116. * @param {?} host
  31117. * @param {?} staticSymbolResolver
  31118. * @param {?} metadataResolver
  31119. * @return {?}
  31120. */
  31121. function _analyzeFilesIncludingNonProgramFiles(fileNames, host, staticSymbolResolver, metadataResolver) {
  31122. var /** @type {?} */ seenFiles = new Set();
  31123. var /** @type {?} */ files = [];
  31124. var /** @type {?} */ visitFile = function (fileName) {
  31125. if (seenFiles.has(fileName) || !host.isSourceFile(fileName)) {
  31126. return false;
  31127. }
  31128. seenFiles.add(fileName);
  31129. var /** @type {?} */ analyzedFile = analyzeFile(host, staticSymbolResolver, metadataResolver, fileName);
  31130. files.push(analyzedFile);
  31131. analyzedFile.ngModules.forEach(function (ngModule) {
  31132. ngModule.transitiveModule.modules.forEach(function (modMeta) { return visitFile(modMeta.reference.filePath); });
  31133. });
  31134. };
  31135. fileNames.forEach(function (fileName) { return visitFile(fileName); });
  31136. return files;
  31137. }
  31138. /**
  31139. * @param {?} host
  31140. * @param {?} staticSymbolResolver
  31141. * @param {?} metadataResolver
  31142. * @param {?} fileName
  31143. * @return {?}
  31144. */
  31145. function analyzeFile(host, staticSymbolResolver, metadataResolver, fileName) {
  31146. var /** @type {?} */ directives = [];
  31147. var /** @type {?} */ pipes = [];
  31148. var /** @type {?} */ injectables = [];
  31149. var /** @type {?} */ ngModules = [];
  31150. var /** @type {?} */ hasDecorators = staticSymbolResolver.hasDecorators(fileName);
  31151. var /** @type {?} */ exportsNonSourceFiles = false;
  31152. // Don't analyze .d.ts files that have no decorators as a shortcut
  31153. // to speed up the analysis. This prevents us from
  31154. // resolving the references in these files.
  31155. // Note: exportsNonSourceFiles is only needed when compiling with summaries,
  31156. // which is not the case when .d.ts files are treated as input files.
  31157. if (!fileName.endsWith('.d.ts') || hasDecorators) {
  31158. staticSymbolResolver.getSymbolsOf(fileName).forEach(function (symbol) {
  31159. var /** @type {?} */ resolvedSymbol = staticSymbolResolver.resolveSymbol(symbol);
  31160. var /** @type {?} */ symbolMeta = resolvedSymbol.metadata;
  31161. if (!symbolMeta || symbolMeta.__symbolic === 'error') {
  31162. return;
  31163. }
  31164. var /** @type {?} */ isNgSymbol = false;
  31165. if (symbolMeta.__symbolic === 'class') {
  31166. if (metadataResolver.isDirective(symbol)) {
  31167. isNgSymbol = true;
  31168. directives.push(symbol);
  31169. }
  31170. else if (metadataResolver.isPipe(symbol)) {
  31171. isNgSymbol = true;
  31172. pipes.push(symbol);
  31173. }
  31174. else if (metadataResolver.isNgModule(symbol)) {
  31175. var /** @type {?} */ ngModule = metadataResolver.getNgModuleMetadata(symbol, false);
  31176. if (ngModule) {
  31177. isNgSymbol = true;
  31178. ngModules.push(ngModule);
  31179. }
  31180. }
  31181. else if (metadataResolver.isInjectable(symbol)) {
  31182. isNgSymbol = true;
  31183. injectables.push(symbol);
  31184. }
  31185. }
  31186. if (!isNgSymbol) {
  31187. exportsNonSourceFiles =
  31188. exportsNonSourceFiles || isValueExportingNonSourceFile(host, symbolMeta);
  31189. }
  31190. });
  31191. }
  31192. return {
  31193. fileName: fileName, directives: directives, pipes: pipes, ngModules: ngModules, injectables: injectables, exportsNonSourceFiles: exportsNonSourceFiles,
  31194. };
  31195. }
  31196. /**
  31197. * @param {?} host
  31198. * @param {?} metadata
  31199. * @return {?}
  31200. */
  31201. function isValueExportingNonSourceFile(host, metadata) {
  31202. var /** @type {?} */ exportsNonSourceFiles = false;
  31203. var Visitor = /** @class */ (function () {
  31204. function Visitor() {
  31205. }
  31206. /**
  31207. * @param {?} arr
  31208. * @param {?} context
  31209. * @return {?}
  31210. */
  31211. Visitor.prototype.visitArray = /**
  31212. * @param {?} arr
  31213. * @param {?} context
  31214. * @return {?}
  31215. */
  31216. function (arr, context) {
  31217. var _this = this;
  31218. arr.forEach(function (v) { return visitValue(v, _this, context); });
  31219. };
  31220. /**
  31221. * @param {?} map
  31222. * @param {?} context
  31223. * @return {?}
  31224. */
  31225. Visitor.prototype.visitStringMap = /**
  31226. * @param {?} map
  31227. * @param {?} context
  31228. * @return {?}
  31229. */
  31230. function (map, context) {
  31231. var _this = this;
  31232. Object.keys(map).forEach(function (key) { return visitValue(map[key], _this, context); });
  31233. };
  31234. /**
  31235. * @param {?} value
  31236. * @param {?} context
  31237. * @return {?}
  31238. */
  31239. Visitor.prototype.visitPrimitive = /**
  31240. * @param {?} value
  31241. * @param {?} context
  31242. * @return {?}
  31243. */
  31244. function (value, context) { };
  31245. /**
  31246. * @param {?} value
  31247. * @param {?} context
  31248. * @return {?}
  31249. */
  31250. Visitor.prototype.visitOther = /**
  31251. * @param {?} value
  31252. * @param {?} context
  31253. * @return {?}
  31254. */
  31255. function (value, context) {
  31256. if (value instanceof StaticSymbol && !host.isSourceFile(value.filePath)) {
  31257. exportsNonSourceFiles = true;
  31258. }
  31259. };
  31260. return Visitor;
  31261. }());
  31262. visitValue(metadata, new Visitor(), null);
  31263. return exportsNonSourceFiles;
  31264. }
  31265. /**
  31266. * @param {?} analyzedFiles
  31267. * @return {?}
  31268. */
  31269. function mergeAnalyzedFiles(analyzedFiles) {
  31270. var /** @type {?} */ allNgModules = [];
  31271. var /** @type {?} */ ngModuleByPipeOrDirective = new Map();
  31272. var /** @type {?} */ allPipesAndDirectives = new Set();
  31273. analyzedFiles.forEach(function (af) {
  31274. af.ngModules.forEach(function (ngModule) {
  31275. allNgModules.push(ngModule);
  31276. ngModule.declaredDirectives.forEach(function (d) { return ngModuleByPipeOrDirective.set(d.reference, ngModule); });
  31277. ngModule.declaredPipes.forEach(function (p) { return ngModuleByPipeOrDirective.set(p.reference, ngModule); });
  31278. });
  31279. af.directives.forEach(function (d) { return allPipesAndDirectives.add(d); });
  31280. af.pipes.forEach(function (p) { return allPipesAndDirectives.add(p); });
  31281. });
  31282. var /** @type {?} */ symbolsMissingModule = [];
  31283. allPipesAndDirectives.forEach(function (ref) {
  31284. if (!ngModuleByPipeOrDirective.has(ref)) {
  31285. symbolsMissingModule.push(ref);
  31286. }
  31287. });
  31288. return {
  31289. ngModules: allNgModules,
  31290. ngModuleByPipeOrDirective: ngModuleByPipeOrDirective,
  31291. symbolsMissingModule: symbolsMissingModule,
  31292. files: analyzedFiles
  31293. };
  31294. }
  31295. /**
  31296. * @param {?} files
  31297. * @return {?}
  31298. */
  31299. function mergeAndValidateNgFiles(files) {
  31300. return validateAnalyzedModules(mergeAnalyzedFiles(files));
  31301. }
  31302. /**
  31303. * @fileoverview added by tsickle
  31304. * @suppress {checkTypes} checked by tsc
  31305. */
  31306. /**
  31307. * @license
  31308. * Copyright Google Inc. All Rights Reserved.
  31309. *
  31310. * Use of this source code is governed by an MIT-style license that can be
  31311. * found in the LICENSE file at https://angular.io/license
  31312. */
  31313. /**
  31314. * @record
  31315. */
  31316. /**
  31317. * @record
  31318. */
  31319. var FORMATTED_MESSAGE = 'ngFormattedMessage';
  31320. /**
  31321. * @param {?} level
  31322. * @return {?}
  31323. */
  31324. function indentStr(level) {
  31325. if (level <= 0)
  31326. return '';
  31327. if (level < 6)
  31328. return ['', ' ', ' ', ' ', ' ', ' '][level];
  31329. var /** @type {?} */ half = indentStr(Math.floor(level / 2));
  31330. return half + half + (level % 2 === 1 ? ' ' : '');
  31331. }
  31332. /**
  31333. * @param {?} chain
  31334. * @param {?=} indent
  31335. * @return {?}
  31336. */
  31337. function formatChain(chain, indent) {
  31338. if (indent === void 0) { indent = 0; }
  31339. if (!chain)
  31340. return '';
  31341. var /** @type {?} */ position = chain.position ?
  31342. chain.position.fileName + "(" + (chain.position.line + 1) + "," + (chain.position.column + 1) + ")" :
  31343. '';
  31344. var /** @type {?} */ prefix = position && indent === 0 ? position + ": " : '';
  31345. var /** @type {?} */ postfix = position && indent !== 0 ? " at " + position : '';
  31346. var /** @type {?} */ message = "" + prefix + chain.message + postfix;
  31347. return "" + indentStr(indent) + message + ((chain.next && ('\n' + formatChain(chain.next, indent + 2))) || '');
  31348. }
  31349. /**
  31350. * @param {?} chain
  31351. * @return {?}
  31352. */
  31353. function formattedError(chain) {
  31354. var /** @type {?} */ message = formatChain(chain) + '.';
  31355. var /** @type {?} */ error = /** @type {?} */ (syntaxError(message));
  31356. (/** @type {?} */ (error))[FORMATTED_MESSAGE] = true;
  31357. error.chain = chain;
  31358. error.position = chain.position;
  31359. return error;
  31360. }
  31361. /**
  31362. * @param {?} error
  31363. * @return {?}
  31364. */
  31365. function isFormattedError(error) {
  31366. return !!(/** @type {?} */ (error))[FORMATTED_MESSAGE];
  31367. }
  31368. /**
  31369. * @fileoverview added by tsickle
  31370. * @suppress {checkTypes} checked by tsc
  31371. */
  31372. /**
  31373. * @license
  31374. * Copyright Google Inc. All Rights Reserved.
  31375. *
  31376. * Use of this source code is governed by an MIT-style license that can be
  31377. * found in the LICENSE file at https://angular.io/license
  31378. */
  31379. var ANGULAR_CORE = '@angular/core';
  31380. var ANGULAR_ROUTER = '@angular/router';
  31381. var HIDDEN_KEY = /^\$.*\$$/;
  31382. var IGNORE = {
  31383. __symbolic: 'ignore'
  31384. };
  31385. var USE_VALUE = 'useValue';
  31386. var PROVIDE = 'provide';
  31387. var REFERENCE_SET = new Set([USE_VALUE, 'useFactory', 'data']);
  31388. var TYPEGUARD_POSTFIX = 'TypeGuard';
  31389. var USE_IF = 'UseIf';
  31390. /**
  31391. * @param {?} value
  31392. * @return {?}
  31393. */
  31394. function shouldIgnore(value) {
  31395. return value && value.__symbolic == 'ignore';
  31396. }
  31397. /**
  31398. * A static reflector implements enough of the Reflector API that is necessary to compile
  31399. * templates statically.
  31400. */
  31401. var StaticReflector = /** @class */ (function () {
  31402. function StaticReflector(summaryResolver, symbolResolver, knownMetadataClasses, knownMetadataFunctions, errorRecorder) {
  31403. if (knownMetadataClasses === void 0) { knownMetadataClasses = []; }
  31404. if (knownMetadataFunctions === void 0) { knownMetadataFunctions = []; }
  31405. var _this = this;
  31406. this.summaryResolver = summaryResolver;
  31407. this.symbolResolver = symbolResolver;
  31408. this.errorRecorder = errorRecorder;
  31409. this.annotationCache = new Map();
  31410. this.propertyCache = new Map();
  31411. this.parameterCache = new Map();
  31412. this.methodCache = new Map();
  31413. this.staticCache = new Map();
  31414. this.conversionMap = new Map();
  31415. this.resolvedExternalReferences = new Map();
  31416. this.annotationForParentClassWithSummaryKind = new Map();
  31417. this.initializeConversionMap();
  31418. knownMetadataClasses.forEach(function (kc) {
  31419. return _this._registerDecoratorOrConstructor(_this.getStaticSymbol(kc.filePath, kc.name), kc.ctor);
  31420. });
  31421. knownMetadataFunctions.forEach(function (kf) { return _this._registerFunction(_this.getStaticSymbol(kf.filePath, kf.name), kf.fn); });
  31422. this.annotationForParentClassWithSummaryKind.set(CompileSummaryKind.Directive, [createDirective, createComponent]);
  31423. this.annotationForParentClassWithSummaryKind.set(CompileSummaryKind.Pipe, [createPipe]);
  31424. this.annotationForParentClassWithSummaryKind.set(CompileSummaryKind.NgModule, [createNgModule]);
  31425. this.annotationForParentClassWithSummaryKind.set(CompileSummaryKind.Injectable, [createInjectable, createPipe, createDirective, createComponent, createNgModule]);
  31426. }
  31427. /**
  31428. * @param {?} typeOrFunc
  31429. * @return {?}
  31430. */
  31431. StaticReflector.prototype.componentModuleUrl = /**
  31432. * @param {?} typeOrFunc
  31433. * @return {?}
  31434. */
  31435. function (typeOrFunc) {
  31436. var /** @type {?} */ staticSymbol = this.findSymbolDeclaration(typeOrFunc);
  31437. return this.symbolResolver.getResourcePath(staticSymbol);
  31438. };
  31439. /**
  31440. * @param {?} ref
  31441. * @param {?=} containingFile
  31442. * @return {?}
  31443. */
  31444. StaticReflector.prototype.resolveExternalReference = /**
  31445. * @param {?} ref
  31446. * @param {?=} containingFile
  31447. * @return {?}
  31448. */
  31449. function (ref, containingFile) {
  31450. var /** @type {?} */ key = undefined;
  31451. if (!containingFile) {
  31452. key = ref.moduleName + ":" + ref.name;
  31453. var /** @type {?} */ declarationSymbol_1 = this.resolvedExternalReferences.get(key);
  31454. if (declarationSymbol_1)
  31455. return declarationSymbol_1;
  31456. }
  31457. var /** @type {?} */ refSymbol = this.symbolResolver.getSymbolByModule(/** @type {?} */ ((ref.moduleName)), /** @type {?} */ ((ref.name)), containingFile);
  31458. var /** @type {?} */ declarationSymbol = this.findSymbolDeclaration(refSymbol);
  31459. if (!containingFile) {
  31460. this.symbolResolver.recordModuleNameForFileName(refSymbol.filePath, /** @type {?} */ ((ref.moduleName)));
  31461. this.symbolResolver.recordImportAs(declarationSymbol, refSymbol);
  31462. }
  31463. if (key) {
  31464. this.resolvedExternalReferences.set(key, declarationSymbol);
  31465. }
  31466. return declarationSymbol;
  31467. };
  31468. /**
  31469. * @param {?} moduleUrl
  31470. * @param {?} name
  31471. * @param {?=} containingFile
  31472. * @return {?}
  31473. */
  31474. StaticReflector.prototype.findDeclaration = /**
  31475. * @param {?} moduleUrl
  31476. * @param {?} name
  31477. * @param {?=} containingFile
  31478. * @return {?}
  31479. */
  31480. function (moduleUrl, name, containingFile) {
  31481. return this.findSymbolDeclaration(this.symbolResolver.getSymbolByModule(moduleUrl, name, containingFile));
  31482. };
  31483. /**
  31484. * @param {?} moduleUrl
  31485. * @param {?} name
  31486. * @return {?}
  31487. */
  31488. StaticReflector.prototype.tryFindDeclaration = /**
  31489. * @param {?} moduleUrl
  31490. * @param {?} name
  31491. * @return {?}
  31492. */
  31493. function (moduleUrl, name) {
  31494. var _this = this;
  31495. return this.symbolResolver.ignoreErrorsFor(function () { return _this.findDeclaration(moduleUrl, name); });
  31496. };
  31497. /**
  31498. * @param {?} symbol
  31499. * @return {?}
  31500. */
  31501. StaticReflector.prototype.findSymbolDeclaration = /**
  31502. * @param {?} symbol
  31503. * @return {?}
  31504. */
  31505. function (symbol) {
  31506. var /** @type {?} */ resolvedSymbol = this.symbolResolver.resolveSymbol(symbol);
  31507. if (resolvedSymbol) {
  31508. var /** @type {?} */ resolvedMetadata = resolvedSymbol.metadata;
  31509. if (resolvedMetadata && resolvedMetadata.__symbolic === 'resolved') {
  31510. resolvedMetadata = resolvedMetadata.symbol;
  31511. }
  31512. if (resolvedMetadata instanceof StaticSymbol) {
  31513. return this.findSymbolDeclaration(resolvedSymbol.metadata);
  31514. }
  31515. }
  31516. return symbol;
  31517. };
  31518. /**
  31519. * @param {?} type
  31520. * @return {?}
  31521. */
  31522. StaticReflector.prototype.annotations = /**
  31523. * @param {?} type
  31524. * @return {?}
  31525. */
  31526. function (type) {
  31527. var /** @type {?} */ annotations = this.annotationCache.get(type);
  31528. if (!annotations) {
  31529. annotations = [];
  31530. var /** @type {?} */ classMetadata = this.getTypeMetadata(type);
  31531. var /** @type {?} */ parentType = this.findParentType(type, classMetadata);
  31532. if (parentType) {
  31533. var /** @type {?} */ parentAnnotations = this.annotations(parentType);
  31534. annotations.push.apply(annotations, parentAnnotations);
  31535. }
  31536. var /** @type {?} */ ownAnnotations_1 = [];
  31537. if (classMetadata['decorators']) {
  31538. ownAnnotations_1 = this.simplify(type, classMetadata['decorators']);
  31539. annotations.push.apply(annotations, ownAnnotations_1);
  31540. }
  31541. if (parentType && !this.summaryResolver.isLibraryFile(type.filePath) &&
  31542. this.summaryResolver.isLibraryFile(parentType.filePath)) {
  31543. var /** @type {?} */ summary = this.summaryResolver.resolveSummary(parentType);
  31544. if (summary && summary.type) {
  31545. var /** @type {?} */ requiredAnnotationTypes = /** @type {?} */ ((this.annotationForParentClassWithSummaryKind.get(/** @type {?} */ ((summary.type.summaryKind)))));
  31546. var /** @type {?} */ typeHasRequiredAnnotation = requiredAnnotationTypes.some(function (requiredType) { return ownAnnotations_1.some(function (ann) { return requiredType.isTypeOf(ann); }); });
  31547. if (!typeHasRequiredAnnotation) {
  31548. 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);
  31549. }
  31550. }
  31551. }
  31552. this.annotationCache.set(type, annotations.filter(function (ann) { return !!ann; }));
  31553. }
  31554. return annotations;
  31555. };
  31556. /**
  31557. * @param {?} type
  31558. * @return {?}
  31559. */
  31560. StaticReflector.prototype.propMetadata = /**
  31561. * @param {?} type
  31562. * @return {?}
  31563. */
  31564. function (type) {
  31565. var _this = this;
  31566. var /** @type {?} */ propMetadata = this.propertyCache.get(type);
  31567. if (!propMetadata) {
  31568. var /** @type {?} */ classMetadata = this.getTypeMetadata(type);
  31569. propMetadata = {};
  31570. var /** @type {?} */ parentType = this.findParentType(type, classMetadata);
  31571. if (parentType) {
  31572. var /** @type {?} */ parentPropMetadata_1 = this.propMetadata(parentType);
  31573. Object.keys(parentPropMetadata_1).forEach(function (parentProp) {
  31574. /** @type {?} */ ((propMetadata))[parentProp] = parentPropMetadata_1[parentProp];
  31575. });
  31576. }
  31577. var /** @type {?} */ members_1 = classMetadata['members'] || {};
  31578. Object.keys(members_1).forEach(function (propName) {
  31579. var /** @type {?} */ propData = members_1[propName];
  31580. var /** @type {?} */ prop = (/** @type {?} */ (propData))
  31581. .find(function (a) { return a['__symbolic'] == 'property' || a['__symbolic'] == 'method'; });
  31582. var /** @type {?} */ decorators = [];
  31583. if (/** @type {?} */ ((propMetadata))[propName]) {
  31584. decorators.push.apply(decorators, /** @type {?} */ ((propMetadata))[propName]);
  31585. } /** @type {?} */
  31586. ((propMetadata))[propName] = decorators;
  31587. if (prop && prop['decorators']) {
  31588. decorators.push.apply(decorators, _this.simplify(type, prop['decorators']));
  31589. }
  31590. });
  31591. this.propertyCache.set(type, propMetadata);
  31592. }
  31593. return propMetadata;
  31594. };
  31595. /**
  31596. * @param {?} type
  31597. * @return {?}
  31598. */
  31599. StaticReflector.prototype.parameters = /**
  31600. * @param {?} type
  31601. * @return {?}
  31602. */
  31603. function (type) {
  31604. var _this = this;
  31605. if (!(type instanceof StaticSymbol)) {
  31606. this.reportError(new Error("parameters received " + JSON.stringify(type) + " which is not a StaticSymbol"), type);
  31607. return [];
  31608. }
  31609. try {
  31610. var /** @type {?} */ parameters_1 = this.parameterCache.get(type);
  31611. if (!parameters_1) {
  31612. var /** @type {?} */ classMetadata = this.getTypeMetadata(type);
  31613. var /** @type {?} */ parentType = this.findParentType(type, classMetadata);
  31614. var /** @type {?} */ members = classMetadata ? classMetadata['members'] : null;
  31615. var /** @type {?} */ ctorData = members ? members['__ctor__'] : null;
  31616. if (ctorData) {
  31617. var /** @type {?} */ ctor = (/** @type {?} */ (ctorData)).find(function (a) { return a['__symbolic'] == 'constructor'; });
  31618. var /** @type {?} */ rawParameterTypes = /** @type {?} */ (ctor['parameters']) || [];
  31619. var /** @type {?} */ parameterDecorators_1 = /** @type {?} */ (this.simplify(type, ctor['parameterDecorators'] || []));
  31620. parameters_1 = [];
  31621. rawParameterTypes.forEach(function (rawParamType, index) {
  31622. var /** @type {?} */ nestedResult = [];
  31623. var /** @type {?} */ paramType = _this.trySimplify(type, rawParamType);
  31624. if (paramType)
  31625. nestedResult.push(paramType);
  31626. var /** @type {?} */ decorators = parameterDecorators_1 ? parameterDecorators_1[index] : null;
  31627. if (decorators) {
  31628. nestedResult.push.apply(nestedResult, decorators);
  31629. } /** @type {?} */
  31630. ((parameters_1)).push(nestedResult);
  31631. });
  31632. }
  31633. else if (parentType) {
  31634. parameters_1 = this.parameters(parentType);
  31635. }
  31636. if (!parameters_1) {
  31637. parameters_1 = [];
  31638. }
  31639. this.parameterCache.set(type, parameters_1);
  31640. }
  31641. return parameters_1;
  31642. }
  31643. catch (/** @type {?} */ e) {
  31644. console.error("Failed on type " + JSON.stringify(type) + " with error " + e);
  31645. throw e;
  31646. }
  31647. };
  31648. /**
  31649. * @param {?} type
  31650. * @return {?}
  31651. */
  31652. StaticReflector.prototype._methodNames = /**
  31653. * @param {?} type
  31654. * @return {?}
  31655. */
  31656. function (type) {
  31657. var /** @type {?} */ methodNames = this.methodCache.get(type);
  31658. if (!methodNames) {
  31659. var /** @type {?} */ classMetadata = this.getTypeMetadata(type);
  31660. methodNames = {};
  31661. var /** @type {?} */ parentType = this.findParentType(type, classMetadata);
  31662. if (parentType) {
  31663. var /** @type {?} */ parentMethodNames_1 = this._methodNames(parentType);
  31664. Object.keys(parentMethodNames_1).forEach(function (parentProp) {
  31665. /** @type {?} */ ((methodNames))[parentProp] = parentMethodNames_1[parentProp];
  31666. });
  31667. }
  31668. var /** @type {?} */ members_2 = classMetadata['members'] || {};
  31669. Object.keys(members_2).forEach(function (propName) {
  31670. var /** @type {?} */ propData = members_2[propName];
  31671. var /** @type {?} */ isMethod = (/** @type {?} */ (propData)).some(function (a) { return a['__symbolic'] == 'method'; }); /** @type {?} */
  31672. ((methodNames))[propName] = /** @type {?} */ ((methodNames))[propName] || isMethod;
  31673. });
  31674. this.methodCache.set(type, methodNames);
  31675. }
  31676. return methodNames;
  31677. };
  31678. /**
  31679. * @param {?} type
  31680. * @return {?}
  31681. */
  31682. StaticReflector.prototype._staticMembers = /**
  31683. * @param {?} type
  31684. * @return {?}
  31685. */
  31686. function (type) {
  31687. var /** @type {?} */ staticMembers = this.staticCache.get(type);
  31688. if (!staticMembers) {
  31689. var /** @type {?} */ classMetadata = this.getTypeMetadata(type);
  31690. var /** @type {?} */ staticMemberData = classMetadata['statics'] || {};
  31691. staticMembers = Object.keys(staticMemberData);
  31692. this.staticCache.set(type, staticMembers);
  31693. }
  31694. return staticMembers;
  31695. };
  31696. /**
  31697. * @param {?} type
  31698. * @param {?} classMetadata
  31699. * @return {?}
  31700. */
  31701. StaticReflector.prototype.findParentType = /**
  31702. * @param {?} type
  31703. * @param {?} classMetadata
  31704. * @return {?}
  31705. */
  31706. function (type, classMetadata) {
  31707. var /** @type {?} */ parentType = this.trySimplify(type, classMetadata['extends']);
  31708. if (parentType instanceof StaticSymbol) {
  31709. return parentType;
  31710. }
  31711. };
  31712. /**
  31713. * @param {?} type
  31714. * @param {?} lcProperty
  31715. * @return {?}
  31716. */
  31717. StaticReflector.prototype.hasLifecycleHook = /**
  31718. * @param {?} type
  31719. * @param {?} lcProperty
  31720. * @return {?}
  31721. */
  31722. function (type, lcProperty) {
  31723. if (!(type instanceof StaticSymbol)) {
  31724. this.reportError(new Error("hasLifecycleHook received " + JSON.stringify(type) + " which is not a StaticSymbol"), type);
  31725. }
  31726. try {
  31727. return !!this._methodNames(type)[lcProperty];
  31728. }
  31729. catch (/** @type {?} */ e) {
  31730. console.error("Failed on type " + JSON.stringify(type) + " with error " + e);
  31731. throw e;
  31732. }
  31733. };
  31734. /**
  31735. * @param {?} type
  31736. * @return {?}
  31737. */
  31738. StaticReflector.prototype.guards = /**
  31739. * @param {?} type
  31740. * @return {?}
  31741. */
  31742. function (type) {
  31743. if (!(type instanceof StaticSymbol)) {
  31744. this.reportError(new Error("guards received " + JSON.stringify(type) + " which is not a StaticSymbol"), type);
  31745. return {};
  31746. }
  31747. var /** @type {?} */ staticMembers = this._staticMembers(type);
  31748. var /** @type {?} */ result = {};
  31749. for (var _i = 0, staticMembers_1 = staticMembers; _i < staticMembers_1.length; _i++) {
  31750. var name_1 = staticMembers_1[_i];
  31751. if (name_1.endsWith(TYPEGUARD_POSTFIX)) {
  31752. var /** @type {?} */ property = name_1.substr(0, name_1.length - TYPEGUARD_POSTFIX.length);
  31753. var /** @type {?} */ value = void 0;
  31754. if (property.endsWith(USE_IF)) {
  31755. property = name_1.substr(0, property.length - USE_IF.length);
  31756. value = USE_IF;
  31757. }
  31758. else {
  31759. value = this.getStaticSymbol(type.filePath, type.name, [name_1]);
  31760. }
  31761. result[property] = value;
  31762. }
  31763. }
  31764. return result;
  31765. };
  31766. /**
  31767. * @param {?} type
  31768. * @param {?} ctor
  31769. * @return {?}
  31770. */
  31771. StaticReflector.prototype._registerDecoratorOrConstructor = /**
  31772. * @param {?} type
  31773. * @param {?} ctor
  31774. * @return {?}
  31775. */
  31776. function (type, ctor) {
  31777. this.conversionMap.set(type, function (context, args) { return new (ctor.bind.apply(ctor, [void 0].concat(args)))(); });
  31778. };
  31779. /**
  31780. * @param {?} type
  31781. * @param {?} fn
  31782. * @return {?}
  31783. */
  31784. StaticReflector.prototype._registerFunction = /**
  31785. * @param {?} type
  31786. * @param {?} fn
  31787. * @return {?}
  31788. */
  31789. function (type, fn) {
  31790. this.conversionMap.set(type, function (context, args) { return fn.apply(undefined, args); });
  31791. };
  31792. /**
  31793. * @return {?}
  31794. */
  31795. StaticReflector.prototype.initializeConversionMap = /**
  31796. * @return {?}
  31797. */
  31798. function () {
  31799. this.injectionToken = this.findDeclaration(ANGULAR_CORE, 'InjectionToken');
  31800. this.opaqueToken = this.findDeclaration(ANGULAR_CORE, 'OpaqueToken');
  31801. this.ROUTES = this.tryFindDeclaration(ANGULAR_ROUTER, 'ROUTES');
  31802. this.ANALYZE_FOR_ENTRY_COMPONENTS =
  31803. this.findDeclaration(ANGULAR_CORE, 'ANALYZE_FOR_ENTRY_COMPONENTS');
  31804. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Host'), createHost);
  31805. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Injectable'), createInjectable);
  31806. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Self'), createSelf);
  31807. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'SkipSelf'), createSkipSelf);
  31808. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Inject'), createInject);
  31809. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Optional'), createOptional);
  31810. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Attribute'), createAttribute);
  31811. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'ContentChild'), createContentChild);
  31812. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'ContentChildren'), createContentChildren);
  31813. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'ViewChild'), createViewChild);
  31814. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'ViewChildren'), createViewChildren);
  31815. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Input'), createInput);
  31816. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Output'), createOutput);
  31817. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Pipe'), createPipe);
  31818. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'HostBinding'), createHostBinding);
  31819. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'HostListener'), createHostListener);
  31820. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Directive'), createDirective);
  31821. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Component'), createComponent);
  31822. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'NgModule'), createNgModule);
  31823. // Note: Some metadata classes can be used directly with Provider.deps.
  31824. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Host'), createHost);
  31825. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Self'), createSelf);
  31826. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'SkipSelf'), createSkipSelf);
  31827. this._registerDecoratorOrConstructor(this.findDeclaration(ANGULAR_CORE, 'Optional'), createOptional);
  31828. };
  31829. /**
  31830. * getStaticSymbol produces a Type whose metadata is known but whose implementation is not loaded.
  31831. * All types passed to the StaticResolver should be pseudo-types returned by this method.
  31832. *
  31833. * @param declarationFile the absolute path of the file where the symbol is declared
  31834. * @param name the name of the type.
  31835. */
  31836. /**
  31837. * getStaticSymbol produces a Type whose metadata is known but whose implementation is not loaded.
  31838. * All types passed to the StaticResolver should be pseudo-types returned by this method.
  31839. *
  31840. * @param {?} declarationFile the absolute path of the file where the symbol is declared
  31841. * @param {?} name the name of the type.
  31842. * @param {?=} members
  31843. * @return {?}
  31844. */
  31845. StaticReflector.prototype.getStaticSymbol = /**
  31846. * getStaticSymbol produces a Type whose metadata is known but whose implementation is not loaded.
  31847. * All types passed to the StaticResolver should be pseudo-types returned by this method.
  31848. *
  31849. * @param {?} declarationFile the absolute path of the file where the symbol is declared
  31850. * @param {?} name the name of the type.
  31851. * @param {?=} members
  31852. * @return {?}
  31853. */
  31854. function (declarationFile, name, members) {
  31855. return this.symbolResolver.getStaticSymbol(declarationFile, name, members);
  31856. };
  31857. /**
  31858. * Simplify but discard any errors
  31859. * @param {?} context
  31860. * @param {?} value
  31861. * @return {?}
  31862. */
  31863. StaticReflector.prototype.trySimplify = /**
  31864. * Simplify but discard any errors
  31865. * @param {?} context
  31866. * @param {?} value
  31867. * @return {?}
  31868. */
  31869. function (context, value) {
  31870. var /** @type {?} */ originalRecorder = this.errorRecorder;
  31871. this.errorRecorder = function (error, fileName) { };
  31872. var /** @type {?} */ result = this.simplify(context, value);
  31873. this.errorRecorder = originalRecorder;
  31874. return result;
  31875. };
  31876. /**
  31877. * \@internal
  31878. * @param {?} context
  31879. * @param {?} value
  31880. * @return {?}
  31881. */
  31882. StaticReflector.prototype.simplify = /**
  31883. * \@internal
  31884. * @param {?} context
  31885. * @param {?} value
  31886. * @return {?}
  31887. */
  31888. function (context, value) {
  31889. var /** @type {?} */ self = this;
  31890. var /** @type {?} */ scope = BindingScope.empty;
  31891. var /** @type {?} */ calling = new Map();
  31892. var /** @type {?} */ rootContext = context;
  31893. /**
  31894. * @param {?} context
  31895. * @param {?} value
  31896. * @param {?} depth
  31897. * @param {?} references
  31898. * @return {?}
  31899. */
  31900. function simplifyInContext(context, value, depth, references) {
  31901. /**
  31902. * @param {?} staticSymbol
  31903. * @return {?}
  31904. */
  31905. function resolveReferenceValue(staticSymbol) {
  31906. var /** @type {?} */ resolvedSymbol = self.symbolResolver.resolveSymbol(staticSymbol);
  31907. return resolvedSymbol ? resolvedSymbol.metadata : null;
  31908. }
  31909. /**
  31910. * @param {?} value
  31911. * @return {?}
  31912. */
  31913. function simplifyEagerly(value) {
  31914. return simplifyInContext(context, value, depth, 0);
  31915. }
  31916. /**
  31917. * @param {?} value
  31918. * @return {?}
  31919. */
  31920. function simplifyLazily(value) {
  31921. return simplifyInContext(context, value, depth, references + 1);
  31922. }
  31923. /**
  31924. * @param {?} nestedContext
  31925. * @param {?} value
  31926. * @return {?}
  31927. */
  31928. function simplifyNested(nestedContext, value) {
  31929. if (nestedContext === context) {
  31930. // If the context hasn't changed let the exception propagate unmodified.
  31931. return simplifyInContext(nestedContext, value, depth + 1, references);
  31932. }
  31933. try {
  31934. return simplifyInContext(nestedContext, value, depth + 1, references);
  31935. }
  31936. catch (/** @type {?} */ e) {
  31937. if (isMetadataError(e)) {
  31938. // Propagate the message text up but add a message to the chain that explains how we got
  31939. // here.
  31940. // e.chain implies e.symbol
  31941. var /** @type {?} */ summaryMsg = e.chain ? 'references \'' + /** @type {?} */ ((e.symbol)).name + '\'' : errorSummary(e);
  31942. var /** @type {?} */ summary = "'" + nestedContext.name + "' " + summaryMsg;
  31943. var /** @type {?} */ chain = { message: summary, position: e.position, next: e.chain };
  31944. // TODO(chuckj): retrieve the position information indirectly from the collectors node
  31945. // map if the metadata is from a .ts file.
  31946. self.error({
  31947. message: e.message,
  31948. advise: e.advise,
  31949. context: e.context, chain: chain,
  31950. symbol: nestedContext
  31951. }, context);
  31952. }
  31953. else {
  31954. // It is probably an internal error.
  31955. throw e;
  31956. }
  31957. }
  31958. }
  31959. /**
  31960. * @param {?} functionSymbol
  31961. * @param {?} targetFunction
  31962. * @param {?} args
  31963. * @param {?} targetExpression
  31964. * @return {?}
  31965. */
  31966. function simplifyCall(functionSymbol, targetFunction, args, targetExpression) {
  31967. if (targetFunction && targetFunction['__symbolic'] == 'function') {
  31968. if (calling.get(functionSymbol)) {
  31969. self.error({
  31970. message: 'Recursion is not supported',
  31971. summary: "called '" + functionSymbol.name + "' recursively",
  31972. value: targetFunction
  31973. }, functionSymbol);
  31974. }
  31975. try {
  31976. var /** @type {?} */ value_1 = targetFunction['value'];
  31977. if (value_1 && (depth != 0 || value_1.__symbolic != 'error')) {
  31978. var /** @type {?} */ parameters = targetFunction['parameters'];
  31979. var /** @type {?} */ defaults = targetFunction.defaults;
  31980. args = args.map(function (arg) { return simplifyNested(context, arg); })
  31981. .map(function (arg) { return shouldIgnore(arg) ? undefined : arg; });
  31982. if (defaults && defaults.length > args.length) {
  31983. args.push.apply(args, defaults.slice(args.length).map(function (value) { return simplify(value); }));
  31984. }
  31985. calling.set(functionSymbol, true);
  31986. var /** @type {?} */ functionScope = BindingScope.build();
  31987. for (var /** @type {?} */ i = 0; i < parameters.length; i++) {
  31988. functionScope.define(parameters[i], args[i]);
  31989. }
  31990. var /** @type {?} */ oldScope = scope;
  31991. var /** @type {?} */ result_1;
  31992. try {
  31993. scope = functionScope.done();
  31994. result_1 = simplifyNested(functionSymbol, value_1);
  31995. }
  31996. finally {
  31997. scope = oldScope;
  31998. }
  31999. return result_1;
  32000. }
  32001. }
  32002. finally {
  32003. calling.delete(functionSymbol);
  32004. }
  32005. }
  32006. if (depth === 0) {
  32007. // If depth is 0 we are evaluating the top level expression that is describing element
  32008. // decorator. In this case, it is a decorator we don't understand, such as a custom
  32009. // non-angular decorator, and we should just ignore it.
  32010. return IGNORE;
  32011. }
  32012. var /** @type {?} */ position = undefined;
  32013. if (targetExpression && targetExpression.__symbolic == 'resolved') {
  32014. var /** @type {?} */ line = targetExpression.line;
  32015. var /** @type {?} */ character = targetExpression.character;
  32016. var /** @type {?} */ fileName = targetExpression.fileName;
  32017. if (fileName != null && line != null && character != null) {
  32018. position = { fileName: fileName, line: line, column: character };
  32019. }
  32020. }
  32021. self.error({
  32022. message: FUNCTION_CALL_NOT_SUPPORTED,
  32023. context: functionSymbol,
  32024. value: targetFunction, position: position
  32025. }, context);
  32026. }
  32027. /**
  32028. * @param {?} expression
  32029. * @return {?}
  32030. */
  32031. function simplify(expression) {
  32032. if (isPrimitive(expression)) {
  32033. return expression;
  32034. }
  32035. if (expression instanceof Array) {
  32036. var /** @type {?} */ result_2 = [];
  32037. for (var _i = 0, _a = (/** @type {?} */ (expression)); _i < _a.length; _i++) {
  32038. var item = _a[_i];
  32039. // Check for a spread expression
  32040. if (item && item.__symbolic === 'spread') {
  32041. // We call with references as 0 because we require the actual value and cannot
  32042. // tolerate a reference here.
  32043. var /** @type {?} */ spreadArray = simplifyEagerly(item.expression);
  32044. if (Array.isArray(spreadArray)) {
  32045. for (var _b = 0, spreadArray_1 = spreadArray; _b < spreadArray_1.length; _b++) {
  32046. var spreadItem = spreadArray_1[_b];
  32047. result_2.push(spreadItem);
  32048. }
  32049. continue;
  32050. }
  32051. }
  32052. var /** @type {?} */ value_2 = simplify(item);
  32053. if (shouldIgnore(value_2)) {
  32054. continue;
  32055. }
  32056. result_2.push(value_2);
  32057. }
  32058. return result_2;
  32059. }
  32060. if (expression instanceof StaticSymbol) {
  32061. // Stop simplification at builtin symbols or if we are in a reference context and
  32062. // the symbol doesn't have members.
  32063. if (expression === self.injectionToken || self.conversionMap.has(expression) ||
  32064. (references > 0 && !expression.members.length)) {
  32065. return expression;
  32066. }
  32067. else {
  32068. var /** @type {?} */ staticSymbol = expression;
  32069. var /** @type {?} */ declarationValue = resolveReferenceValue(staticSymbol);
  32070. if (declarationValue != null) {
  32071. return simplifyNested(staticSymbol, declarationValue);
  32072. }
  32073. else {
  32074. return staticSymbol;
  32075. }
  32076. }
  32077. }
  32078. if (expression) {
  32079. if (expression['__symbolic']) {
  32080. var /** @type {?} */ staticSymbol = void 0;
  32081. switch (expression['__symbolic']) {
  32082. case 'binop':
  32083. var /** @type {?} */ left = simplify(expression['left']);
  32084. if (shouldIgnore(left))
  32085. return left;
  32086. var /** @type {?} */ right = simplify(expression['right']);
  32087. if (shouldIgnore(right))
  32088. return right;
  32089. switch (expression['operator']) {
  32090. case '&&':
  32091. return left && right;
  32092. case '||':
  32093. return left || right;
  32094. case '|':
  32095. return left | right;
  32096. case '^':
  32097. return left ^ right;
  32098. case '&':
  32099. return left & right;
  32100. case '==':
  32101. return left == right;
  32102. case '!=':
  32103. return left != right;
  32104. case '===':
  32105. return left === right;
  32106. case '!==':
  32107. return left !== right;
  32108. case '<':
  32109. return left < right;
  32110. case '>':
  32111. return left > right;
  32112. case '<=':
  32113. return left <= right;
  32114. case '>=':
  32115. return left >= right;
  32116. case '<<':
  32117. return left << right;
  32118. case '>>':
  32119. return left >> right;
  32120. case '+':
  32121. return left + right;
  32122. case '-':
  32123. return left - right;
  32124. case '*':
  32125. return left * right;
  32126. case '/':
  32127. return left / right;
  32128. case '%':
  32129. return left % right;
  32130. }
  32131. return null;
  32132. case 'if':
  32133. var /** @type {?} */ condition = simplify(expression['condition']);
  32134. return condition ? simplify(expression['thenExpression']) :
  32135. simplify(expression['elseExpression']);
  32136. case 'pre':
  32137. var /** @type {?} */ operand = simplify(expression['operand']);
  32138. if (shouldIgnore(operand))
  32139. return operand;
  32140. switch (expression['operator']) {
  32141. case '+':
  32142. return operand;
  32143. case '-':
  32144. return -operand;
  32145. case '!':
  32146. return !operand;
  32147. case '~':
  32148. return ~operand;
  32149. }
  32150. return null;
  32151. case 'index':
  32152. var /** @type {?} */ indexTarget = simplifyEagerly(expression['expression']);
  32153. var /** @type {?} */ index = simplifyEagerly(expression['index']);
  32154. if (indexTarget && isPrimitive(index))
  32155. return indexTarget[index];
  32156. return null;
  32157. case 'select':
  32158. var /** @type {?} */ member = expression['member'];
  32159. var /** @type {?} */ selectContext = context;
  32160. var /** @type {?} */ selectTarget = simplify(expression['expression']);
  32161. if (selectTarget instanceof StaticSymbol) {
  32162. var /** @type {?} */ members = selectTarget.members.concat(member);
  32163. selectContext =
  32164. self.getStaticSymbol(selectTarget.filePath, selectTarget.name, members);
  32165. var /** @type {?} */ declarationValue = resolveReferenceValue(selectContext);
  32166. if (declarationValue != null) {
  32167. return simplifyNested(selectContext, declarationValue);
  32168. }
  32169. else {
  32170. return selectContext;
  32171. }
  32172. }
  32173. if (selectTarget && isPrimitive(member))
  32174. return simplifyNested(selectContext, selectTarget[member]);
  32175. return null;
  32176. case 'reference':
  32177. // Note: This only has to deal with variable references, as symbol references have
  32178. // been converted into 'resolved'
  32179. // in the StaticSymbolResolver.
  32180. var /** @type {?} */ name_2 = expression['name'];
  32181. var /** @type {?} */ localValue = scope.resolve(name_2);
  32182. if (localValue != BindingScope.missing) {
  32183. return localValue;
  32184. }
  32185. break;
  32186. case 'resolved':
  32187. try {
  32188. return simplify(expression.symbol);
  32189. }
  32190. catch (/** @type {?} */ e) {
  32191. // If an error is reported evaluating the symbol record the position of the
  32192. // reference in the error so it can
  32193. // be reported in the error message generated from the exception.
  32194. if (isMetadataError(e) && expression.fileName != null &&
  32195. expression.line != null && expression.character != null) {
  32196. e.position = {
  32197. fileName: expression.fileName,
  32198. line: expression.line,
  32199. column: expression.character
  32200. };
  32201. }
  32202. throw e;
  32203. }
  32204. case 'class':
  32205. return context;
  32206. case 'function':
  32207. return context;
  32208. case 'new':
  32209. case 'call':
  32210. // Determine if the function is a built-in conversion
  32211. staticSymbol = simplifyInContext(context, expression['expression'], depth + 1, /* references */ 0);
  32212. if (staticSymbol instanceof StaticSymbol) {
  32213. if (staticSymbol === self.injectionToken || staticSymbol === self.opaqueToken) {
  32214. // if somebody calls new InjectionToken, don't create an InjectionToken,
  32215. // but rather return the symbol to which the InjectionToken is assigned to.
  32216. // OpaqueToken is supported too as it is required by the language service to
  32217. // support v4 and prior versions of Angular.
  32218. return context;
  32219. }
  32220. var /** @type {?} */ argExpressions = expression['arguments'] || [];
  32221. var /** @type {?} */ converter = self.conversionMap.get(staticSymbol);
  32222. if (converter) {
  32223. var /** @type {?} */ args = argExpressions.map(function (arg) { return simplifyNested(context, arg); })
  32224. .map(function (arg) { return shouldIgnore(arg) ? undefined : arg; });
  32225. return converter(context, args);
  32226. }
  32227. else {
  32228. // Determine if the function is one we can simplify.
  32229. var /** @type {?} */ targetFunction = resolveReferenceValue(staticSymbol);
  32230. return simplifyCall(staticSymbol, targetFunction, argExpressions, expression['expression']);
  32231. }
  32232. }
  32233. return IGNORE;
  32234. case 'error':
  32235. var /** @type {?} */ message = expression.message;
  32236. if (expression['line'] != null) {
  32237. self.error({
  32238. message: message,
  32239. context: expression.context,
  32240. value: expression,
  32241. position: {
  32242. fileName: expression['fileName'],
  32243. line: expression['line'],
  32244. column: expression['character']
  32245. }
  32246. }, context);
  32247. }
  32248. else {
  32249. self.error({ message: message, context: expression.context }, context);
  32250. }
  32251. return IGNORE;
  32252. case 'ignore':
  32253. return expression;
  32254. }
  32255. return null;
  32256. }
  32257. return mapStringMap(expression, function (value, name) {
  32258. if (REFERENCE_SET.has(name)) {
  32259. if (name === USE_VALUE && PROVIDE in expression) {
  32260. // If this is a provider expression, check for special tokens that need the value
  32261. // during analysis.
  32262. var /** @type {?} */ provide = simplify(expression.provide);
  32263. if (provide === self.ROUTES || provide == self.ANALYZE_FOR_ENTRY_COMPONENTS) {
  32264. return simplify(value);
  32265. }
  32266. }
  32267. return simplifyLazily(value);
  32268. }
  32269. return simplify(value);
  32270. });
  32271. }
  32272. return IGNORE;
  32273. }
  32274. return simplify(value);
  32275. }
  32276. var /** @type {?} */ result;
  32277. try {
  32278. result = simplifyInContext(context, value, 0, 0);
  32279. }
  32280. catch (/** @type {?} */ e) {
  32281. if (this.errorRecorder) {
  32282. this.reportError(e, context);
  32283. }
  32284. else {
  32285. throw formatMetadataError(e, context);
  32286. }
  32287. }
  32288. if (shouldIgnore(result)) {
  32289. return undefined;
  32290. }
  32291. return result;
  32292. };
  32293. /**
  32294. * @param {?} type
  32295. * @return {?}
  32296. */
  32297. StaticReflector.prototype.getTypeMetadata = /**
  32298. * @param {?} type
  32299. * @return {?}
  32300. */
  32301. function (type) {
  32302. var /** @type {?} */ resolvedSymbol = this.symbolResolver.resolveSymbol(type);
  32303. return resolvedSymbol && resolvedSymbol.metadata ? resolvedSymbol.metadata :
  32304. { __symbolic: 'class' };
  32305. };
  32306. /**
  32307. * @param {?} error
  32308. * @param {?} context
  32309. * @param {?=} path
  32310. * @return {?}
  32311. */
  32312. StaticReflector.prototype.reportError = /**
  32313. * @param {?} error
  32314. * @param {?} context
  32315. * @param {?=} path
  32316. * @return {?}
  32317. */
  32318. function (error, context, path) {
  32319. if (this.errorRecorder) {
  32320. this.errorRecorder(formatMetadataError(error, context), (context && context.filePath) || path);
  32321. }
  32322. else {
  32323. throw error;
  32324. }
  32325. };
  32326. /**
  32327. * @param {?} __0
  32328. * @param {?} reportingContext
  32329. * @return {?}
  32330. */
  32331. StaticReflector.prototype.error = /**
  32332. * @param {?} __0
  32333. * @param {?} reportingContext
  32334. * @return {?}
  32335. */
  32336. function (_a, reportingContext) {
  32337. 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;
  32338. this.reportError(metadataError(message, summary, advise, position, symbol, context, chain), reportingContext);
  32339. };
  32340. return StaticReflector;
  32341. }());
  32342. var METADATA_ERROR = 'ngMetadataError';
  32343. /**
  32344. * @param {?} message
  32345. * @param {?=} summary
  32346. * @param {?=} advise
  32347. * @param {?=} position
  32348. * @param {?=} symbol
  32349. * @param {?=} context
  32350. * @param {?=} chain
  32351. * @return {?}
  32352. */
  32353. function metadataError(message, summary, advise, position, symbol, context, chain) {
  32354. var /** @type {?} */ error = /** @type {?} */ (syntaxError(message));
  32355. (/** @type {?} */ (error))[METADATA_ERROR] = true;
  32356. if (advise)
  32357. error.advise = advise;
  32358. if (position)
  32359. error.position = position;
  32360. if (summary)
  32361. error.summary = summary;
  32362. if (context)
  32363. error.context = context;
  32364. if (chain)
  32365. error.chain = chain;
  32366. if (symbol)
  32367. error.symbol = symbol;
  32368. return error;
  32369. }
  32370. /**
  32371. * @param {?} error
  32372. * @return {?}
  32373. */
  32374. function isMetadataError(error) {
  32375. return !!(/** @type {?} */ (error))[METADATA_ERROR];
  32376. }
  32377. var REFERENCE_TO_NONEXPORTED_CLASS = 'Reference to non-exported class';
  32378. var VARIABLE_NOT_INITIALIZED = 'Variable not initialized';
  32379. var DESTRUCTURE_NOT_SUPPORTED = 'Destructuring not supported';
  32380. var COULD_NOT_RESOLVE_TYPE = 'Could not resolve type';
  32381. var FUNCTION_CALL_NOT_SUPPORTED = 'Function call not supported';
  32382. var REFERENCE_TO_LOCAL_SYMBOL = 'Reference to a local symbol';
  32383. var LAMBDA_NOT_SUPPORTED = 'Lambda not supported';
  32384. /**
  32385. * @param {?} message
  32386. * @param {?} context
  32387. * @return {?}
  32388. */
  32389. function expandedMessage(message, context) {
  32390. switch (message) {
  32391. case REFERENCE_TO_NONEXPORTED_CLASS:
  32392. if (context && context.className) {
  32393. return "References to a non-exported class are not supported in decorators but " + context.className + " was referenced.";
  32394. }
  32395. break;
  32396. case VARIABLE_NOT_INITIALIZED:
  32397. return 'Only initialized variables and constants can be referenced in decorators because the value of this variable is needed by the template compiler';
  32398. case DESTRUCTURE_NOT_SUPPORTED:
  32399. return 'Referencing an exported destructured variable or constant is not supported in decorators and this value is needed by the template compiler';
  32400. case COULD_NOT_RESOLVE_TYPE:
  32401. if (context && context.typeName) {
  32402. return "Could not resolve type " + context.typeName;
  32403. }
  32404. break;
  32405. case FUNCTION_CALL_NOT_SUPPORTED:
  32406. if (context && context.name) {
  32407. return "Function calls are not supported in decorators but '" + context.name + "' was called";
  32408. }
  32409. return 'Function calls are not supported in decorators';
  32410. case REFERENCE_TO_LOCAL_SYMBOL:
  32411. if (context && context.name) {
  32412. return "Reference to a local (non-exported) symbols are not supported in decorators but '" + context.name + "' was referenced";
  32413. }
  32414. break;
  32415. case LAMBDA_NOT_SUPPORTED:
  32416. return "Function expressions are not supported in decorators";
  32417. }
  32418. return message;
  32419. }
  32420. /**
  32421. * @param {?} message
  32422. * @param {?} context
  32423. * @return {?}
  32424. */
  32425. function messageAdvise(message, context) {
  32426. switch (message) {
  32427. case REFERENCE_TO_NONEXPORTED_CLASS:
  32428. if (context && context.className) {
  32429. return "Consider exporting '" + context.className + "'";
  32430. }
  32431. break;
  32432. case DESTRUCTURE_NOT_SUPPORTED:
  32433. return 'Consider simplifying to avoid destructuring';
  32434. case REFERENCE_TO_LOCAL_SYMBOL:
  32435. if (context && context.name) {
  32436. return "Consider exporting '" + context.name + "'";
  32437. }
  32438. break;
  32439. case LAMBDA_NOT_SUPPORTED:
  32440. return "Consider changing the function expression into an exported function";
  32441. }
  32442. return undefined;
  32443. }
  32444. /**
  32445. * @param {?} error
  32446. * @return {?}
  32447. */
  32448. function errorSummary(error) {
  32449. if (error.summary) {
  32450. return error.summary;
  32451. }
  32452. switch (error.message) {
  32453. case REFERENCE_TO_NONEXPORTED_CLASS:
  32454. if (error.context && error.context.className) {
  32455. return "references non-exported class " + error.context.className;
  32456. }
  32457. break;
  32458. case VARIABLE_NOT_INITIALIZED:
  32459. return 'is not initialized';
  32460. case DESTRUCTURE_NOT_SUPPORTED:
  32461. return 'is a destructured variable';
  32462. case COULD_NOT_RESOLVE_TYPE:
  32463. return 'could not be resolved';
  32464. case FUNCTION_CALL_NOT_SUPPORTED:
  32465. if (error.context && error.context.name) {
  32466. return "calls '" + error.context.name + "'";
  32467. }
  32468. return "calls a function";
  32469. case REFERENCE_TO_LOCAL_SYMBOL:
  32470. if (error.context && error.context.name) {
  32471. return "references local variable " + error.context.name;
  32472. }
  32473. return "references a local variable";
  32474. }
  32475. return 'contains the error';
  32476. }
  32477. /**
  32478. * @param {?} input
  32479. * @param {?} transform
  32480. * @return {?}
  32481. */
  32482. function mapStringMap(input, transform) {
  32483. if (!input)
  32484. return {};
  32485. var /** @type {?} */ result = {};
  32486. Object.keys(input).forEach(function (key) {
  32487. var /** @type {?} */ value = transform(input[key], key);
  32488. if (!shouldIgnore(value)) {
  32489. if (HIDDEN_KEY.test(key)) {
  32490. Object.defineProperty(result, key, { enumerable: false, configurable: true, value: value });
  32491. }
  32492. else {
  32493. result[key] = value;
  32494. }
  32495. }
  32496. });
  32497. return result;
  32498. }
  32499. /**
  32500. * @param {?} o
  32501. * @return {?}
  32502. */
  32503. function isPrimitive(o) {
  32504. return o === null || (typeof o !== 'function' && typeof o !== 'object');
  32505. }
  32506. /**
  32507. * @abstract
  32508. */
  32509. var BindingScope = /** @class */ (function () {
  32510. function BindingScope() {
  32511. }
  32512. /**
  32513. * @return {?}
  32514. */
  32515. BindingScope.build = /**
  32516. * @return {?}
  32517. */
  32518. function () {
  32519. var /** @type {?} */ current = new Map();
  32520. return {
  32521. define: function (name, value) {
  32522. current.set(name, value);
  32523. return this;
  32524. },
  32525. done: function () {
  32526. return current.size > 0 ? new PopulatedScope(current) : BindingScope.empty;
  32527. }
  32528. };
  32529. };
  32530. BindingScope.missing = {};
  32531. BindingScope.empty = { resolve: function (name) { return BindingScope.missing; } };
  32532. return BindingScope;
  32533. }());
  32534. var PopulatedScope = /** @class */ (function (_super) {
  32535. __extends(PopulatedScope, _super);
  32536. function PopulatedScope(bindings) {
  32537. var _this = _super.call(this) || this;
  32538. _this.bindings = bindings;
  32539. return _this;
  32540. }
  32541. /**
  32542. * @param {?} name
  32543. * @return {?}
  32544. */
  32545. PopulatedScope.prototype.resolve = /**
  32546. * @param {?} name
  32547. * @return {?}
  32548. */
  32549. function (name) {
  32550. return this.bindings.has(name) ? this.bindings.get(name) : BindingScope.missing;
  32551. };
  32552. return PopulatedScope;
  32553. }(BindingScope));
  32554. /**
  32555. * @param {?} chain
  32556. * @param {?} advise
  32557. * @return {?}
  32558. */
  32559. function formatMetadataMessageChain(chain, advise) {
  32560. var /** @type {?} */ expanded = expandedMessage(chain.message, chain.context);
  32561. var /** @type {?} */ nesting = chain.symbol ? " in '" + chain.symbol.name + "'" : '';
  32562. var /** @type {?} */ message = "" + expanded + nesting;
  32563. var /** @type {?} */ position = chain.position;
  32564. var /** @type {?} */ next = chain.next ?
  32565. formatMetadataMessageChain(chain.next, advise) :
  32566. advise ? { message: advise } : undefined;
  32567. return { message: message, position: position, next: next };
  32568. }
  32569. /**
  32570. * @param {?} e
  32571. * @param {?} context
  32572. * @return {?}
  32573. */
  32574. function formatMetadataError(e, context) {
  32575. if (isMetadataError(e)) {
  32576. // Produce a formatted version of the and leaving enough information in the original error
  32577. // to recover the formatting information to eventually produce a diagnostic error message.
  32578. var /** @type {?} */ position = e.position;
  32579. var /** @type {?} */ chain = {
  32580. message: "Error during template compile of '" + context.name + "'",
  32581. position: position,
  32582. next: { message: e.message, next: e.chain, context: e.context, symbol: e.symbol }
  32583. };
  32584. var /** @type {?} */ advise = e.advise || messageAdvise(e.message, e.context);
  32585. return formattedError(formatMetadataMessageChain(chain, advise));
  32586. }
  32587. return e;
  32588. }
  32589. /**
  32590. * @fileoverview added by tsickle
  32591. * @suppress {checkTypes} checked by tsc
  32592. */
  32593. /**
  32594. * @license
  32595. * Copyright Google Inc. All Rights Reserved.
  32596. *
  32597. * Use of this source code is governed by an MIT-style license that can be
  32598. * found in the LICENSE file at https://angular.io/license
  32599. */
  32600. /**
  32601. * @record
  32602. */
  32603. var AotSummaryResolver = /** @class */ (function () {
  32604. function AotSummaryResolver(host, staticSymbolCache) {
  32605. this.host = host;
  32606. this.staticSymbolCache = staticSymbolCache;
  32607. this.summaryCache = new Map();
  32608. this.loadedFilePaths = new Map();
  32609. this.importAs = new Map();
  32610. this.knownFileNameToModuleNames = new Map();
  32611. }
  32612. /**
  32613. * @param {?} filePath
  32614. * @return {?}
  32615. */
  32616. AotSummaryResolver.prototype.isLibraryFile = /**
  32617. * @param {?} filePath
  32618. * @return {?}
  32619. */
  32620. function (filePath) {
  32621. // Note: We need to strip the .ngfactory. file path,
  32622. // so this method also works for generated files
  32623. // (for which host.isSourceFile will always return false).
  32624. return !this.host.isSourceFile(stripGeneratedFileSuffix(filePath));
  32625. };
  32626. /**
  32627. * @param {?} filePath
  32628. * @param {?} referringSrcFileName
  32629. * @return {?}
  32630. */
  32631. AotSummaryResolver.prototype.toSummaryFileName = /**
  32632. * @param {?} filePath
  32633. * @param {?} referringSrcFileName
  32634. * @return {?}
  32635. */
  32636. function (filePath, referringSrcFileName) {
  32637. return this.host.toSummaryFileName(filePath, referringSrcFileName);
  32638. };
  32639. /**
  32640. * @param {?} fileName
  32641. * @param {?} referringLibFileName
  32642. * @return {?}
  32643. */
  32644. AotSummaryResolver.prototype.fromSummaryFileName = /**
  32645. * @param {?} fileName
  32646. * @param {?} referringLibFileName
  32647. * @return {?}
  32648. */
  32649. function (fileName, referringLibFileName) {
  32650. return this.host.fromSummaryFileName(fileName, referringLibFileName);
  32651. };
  32652. /**
  32653. * @param {?} staticSymbol
  32654. * @return {?}
  32655. */
  32656. AotSummaryResolver.prototype.resolveSummary = /**
  32657. * @param {?} staticSymbol
  32658. * @return {?}
  32659. */
  32660. function (staticSymbol) {
  32661. var /** @type {?} */ rootSymbol = staticSymbol.members.length ?
  32662. this.staticSymbolCache.get(staticSymbol.filePath, staticSymbol.name) :
  32663. staticSymbol;
  32664. var /** @type {?} */ summary = this.summaryCache.get(rootSymbol);
  32665. if (!summary) {
  32666. this._loadSummaryFile(staticSymbol.filePath);
  32667. summary = /** @type {?} */ ((this.summaryCache.get(staticSymbol)));
  32668. }
  32669. return (rootSymbol === staticSymbol && summary) || null;
  32670. };
  32671. /**
  32672. * @param {?} filePath
  32673. * @return {?}
  32674. */
  32675. AotSummaryResolver.prototype.getSymbolsOf = /**
  32676. * @param {?} filePath
  32677. * @return {?}
  32678. */
  32679. function (filePath) {
  32680. if (this._loadSummaryFile(filePath)) {
  32681. return Array.from(this.summaryCache.keys()).filter(function (symbol) { return symbol.filePath === filePath; });
  32682. }
  32683. return null;
  32684. };
  32685. /**
  32686. * @param {?} staticSymbol
  32687. * @return {?}
  32688. */
  32689. AotSummaryResolver.prototype.getImportAs = /**
  32690. * @param {?} staticSymbol
  32691. * @return {?}
  32692. */
  32693. function (staticSymbol) {
  32694. staticSymbol.assertNoMembers();
  32695. return /** @type {?} */ ((this.importAs.get(staticSymbol)));
  32696. };
  32697. /**
  32698. * Converts a file path to a module name that can be used as an `import`.
  32699. */
  32700. /**
  32701. * Converts a file path to a module name that can be used as an `import`.
  32702. * @param {?} importedFilePath
  32703. * @return {?}
  32704. */
  32705. AotSummaryResolver.prototype.getKnownModuleName = /**
  32706. * Converts a file path to a module name that can be used as an `import`.
  32707. * @param {?} importedFilePath
  32708. * @return {?}
  32709. */
  32710. function (importedFilePath) {
  32711. return this.knownFileNameToModuleNames.get(importedFilePath) || null;
  32712. };
  32713. /**
  32714. * @param {?} summary
  32715. * @return {?}
  32716. */
  32717. AotSummaryResolver.prototype.addSummary = /**
  32718. * @param {?} summary
  32719. * @return {?}
  32720. */
  32721. function (summary) { this.summaryCache.set(summary.symbol, summary); };
  32722. /**
  32723. * @param {?} filePath
  32724. * @return {?}
  32725. */
  32726. AotSummaryResolver.prototype._loadSummaryFile = /**
  32727. * @param {?} filePath
  32728. * @return {?}
  32729. */
  32730. function (filePath) {
  32731. var _this = this;
  32732. var /** @type {?} */ hasSummary = this.loadedFilePaths.get(filePath);
  32733. if (hasSummary != null) {
  32734. return hasSummary;
  32735. }
  32736. var /** @type {?} */ json = null;
  32737. if (this.isLibraryFile(filePath)) {
  32738. var /** @type {?} */ summaryFilePath = summaryFileName(filePath);
  32739. try {
  32740. json = this.host.loadSummary(summaryFilePath);
  32741. }
  32742. catch (/** @type {?} */ e) {
  32743. console.error("Error loading summary file " + summaryFilePath);
  32744. throw e;
  32745. }
  32746. }
  32747. hasSummary = json != null;
  32748. this.loadedFilePaths.set(filePath, hasSummary);
  32749. if (json) {
  32750. var _a = deserializeSummaries(this.staticSymbolCache, this, filePath, json), moduleName = _a.moduleName, summaries = _a.summaries, importAs = _a.importAs;
  32751. summaries.forEach(function (summary) { return _this.summaryCache.set(summary.symbol, summary); });
  32752. if (moduleName) {
  32753. this.knownFileNameToModuleNames.set(filePath, moduleName);
  32754. }
  32755. importAs.forEach(function (importAs) { _this.importAs.set(importAs.symbol, importAs.importAs); });
  32756. }
  32757. return hasSummary;
  32758. };
  32759. return AotSummaryResolver;
  32760. }());
  32761. /**
  32762. * @fileoverview added by tsickle
  32763. * @suppress {checkTypes} checked by tsc
  32764. */
  32765. /**
  32766. * @license
  32767. * Copyright Google Inc. All Rights Reserved.
  32768. *
  32769. * Use of this source code is governed by an MIT-style license that can be
  32770. * found in the LICENSE file at https://angular.io/license
  32771. */
  32772. /**
  32773. * @param {?} host
  32774. * @return {?}
  32775. */
  32776. function createAotUrlResolver(host) {
  32777. return {
  32778. resolve: function (basePath, url) {
  32779. var /** @type {?} */ filePath = host.resourceNameToFileName(url, basePath);
  32780. if (!filePath) {
  32781. throw syntaxError("Couldn't resolve resource " + url + " from " + basePath);
  32782. }
  32783. return filePath;
  32784. }
  32785. };
  32786. }
  32787. /**
  32788. * Creates a new AotCompiler based on options and a host.
  32789. * @param {?} compilerHost
  32790. * @param {?} options
  32791. * @param {?=} errorCollector
  32792. * @return {?}
  32793. */
  32794. function createAotCompiler(compilerHost, options, errorCollector) {
  32795. var /** @type {?} */ translations = options.translations || '';
  32796. var /** @type {?} */ urlResolver = createAotUrlResolver(compilerHost);
  32797. var /** @type {?} */ symbolCache = new StaticSymbolCache();
  32798. var /** @type {?} */ summaryResolver = new AotSummaryResolver(compilerHost, symbolCache);
  32799. var /** @type {?} */ symbolResolver = new StaticSymbolResolver(compilerHost, symbolCache, summaryResolver);
  32800. var /** @type {?} */ staticReflector = new StaticReflector(summaryResolver, symbolResolver, [], [], errorCollector);
  32801. var /** @type {?} */ htmlParser = new I18NHtmlParser(new HtmlParser(), translations, options.i18nFormat, options.missingTranslation, console);
  32802. var /** @type {?} */ config = new CompilerConfig({
  32803. defaultEncapsulation: ViewEncapsulation.Emulated,
  32804. useJit: false,
  32805. enableLegacyTemplate: options.enableLegacyTemplate === true,
  32806. missingTranslation: options.missingTranslation,
  32807. preserveWhitespaces: options.preserveWhitespaces,
  32808. strictInjectionParameters: options.strictInjectionParameters,
  32809. });
  32810. var /** @type {?} */ normalizer = new DirectiveNormalizer({ get: function (url) { return compilerHost.loadResource(url); } }, urlResolver, htmlParser, config);
  32811. var /** @type {?} */ expressionParser = new Parser(new Lexer());
  32812. var /** @type {?} */ elementSchemaRegistry = new DomElementSchemaRegistry();
  32813. var /** @type {?} */ tmplParser = new TemplateParser(config, staticReflector, expressionParser, elementSchemaRegistry, htmlParser, console, []);
  32814. var /** @type {?} */ resolver = new CompileMetadataResolver(config, htmlParser, new NgModuleResolver(staticReflector), new DirectiveResolver(staticReflector), new PipeResolver(staticReflector), summaryResolver, elementSchemaRegistry, normalizer, console, symbolCache, staticReflector, errorCollector);
  32815. // TODO(vicb): do not pass options.i18nFormat here
  32816. var /** @type {?} */ viewCompiler = new ViewCompiler(staticReflector);
  32817. var /** @type {?} */ typeCheckCompiler = new TypeCheckCompiler(options, staticReflector);
  32818. var /** @type {?} */ compiler = new AotCompiler(config, options, compilerHost, staticReflector, resolver, tmplParser, new StyleCompiler(urlResolver), viewCompiler, typeCheckCompiler, new NgModuleCompiler(staticReflector), new TypeScriptEmitter(), summaryResolver, symbolResolver);
  32819. return { compiler: compiler, reflector: staticReflector };
  32820. }
  32821. /**
  32822. * @fileoverview added by tsickle
  32823. * @suppress {checkTypes} checked by tsc
  32824. */
  32825. /**
  32826. * @record
  32827. * @template T
  32828. */
  32829. /**
  32830. * @abstract
  32831. * @template T
  32832. */
  32833. var SummaryResolver = /** @class */ (function () {
  32834. function SummaryResolver() {
  32835. }
  32836. return SummaryResolver;
  32837. }());
  32838. var JitSummaryResolver = /** @class */ (function () {
  32839. function JitSummaryResolver() {
  32840. this._summaries = new Map();
  32841. }
  32842. /**
  32843. * @return {?}
  32844. */
  32845. JitSummaryResolver.prototype.isLibraryFile = /**
  32846. * @return {?}
  32847. */
  32848. function () { return false; };
  32849. /**
  32850. * @param {?} fileName
  32851. * @return {?}
  32852. */
  32853. JitSummaryResolver.prototype.toSummaryFileName = /**
  32854. * @param {?} fileName
  32855. * @return {?}
  32856. */
  32857. function (fileName) { return fileName; };
  32858. /**
  32859. * @param {?} fileName
  32860. * @return {?}
  32861. */
  32862. JitSummaryResolver.prototype.fromSummaryFileName = /**
  32863. * @param {?} fileName
  32864. * @return {?}
  32865. */
  32866. function (fileName) { return fileName; };
  32867. /**
  32868. * @param {?} reference
  32869. * @return {?}
  32870. */
  32871. JitSummaryResolver.prototype.resolveSummary = /**
  32872. * @param {?} reference
  32873. * @return {?}
  32874. */
  32875. function (reference) {
  32876. return this._summaries.get(reference) || null;
  32877. };
  32878. /**
  32879. * @return {?}
  32880. */
  32881. JitSummaryResolver.prototype.getSymbolsOf = /**
  32882. * @return {?}
  32883. */
  32884. function () { return []; };
  32885. /**
  32886. * @param {?} reference
  32887. * @return {?}
  32888. */
  32889. JitSummaryResolver.prototype.getImportAs = /**
  32890. * @param {?} reference
  32891. * @return {?}
  32892. */
  32893. function (reference) { return reference; };
  32894. /**
  32895. * @param {?} fileName
  32896. * @return {?}
  32897. */
  32898. JitSummaryResolver.prototype.getKnownModuleName = /**
  32899. * @param {?} fileName
  32900. * @return {?}
  32901. */
  32902. function (fileName) { return null; };
  32903. /**
  32904. * @param {?} summary
  32905. * @return {?}
  32906. */
  32907. JitSummaryResolver.prototype.addSummary = /**
  32908. * @param {?} summary
  32909. * @return {?}
  32910. */
  32911. function (summary) { this._summaries.set(summary.symbol, summary); };
  32912. return JitSummaryResolver;
  32913. }());
  32914. /**
  32915. * @fileoverview added by tsickle
  32916. * @suppress {checkTypes} checked by tsc
  32917. */
  32918. /**
  32919. * @license
  32920. * Copyright Google Inc. All Rights Reserved.
  32921. *
  32922. * Use of this source code is governed by an MIT-style license that can be
  32923. * found in the LICENSE file at https://angular.io/license
  32924. */
  32925. /**
  32926. * @param {?} statements
  32927. * @param {?} reflector
  32928. * @return {?}
  32929. */
  32930. function interpretStatements(statements, reflector) {
  32931. var /** @type {?} */ ctx = new _ExecutionContext(null, null, null, new Map());
  32932. var /** @type {?} */ visitor = new StatementInterpreter(reflector);
  32933. visitor.visitAllStatements(statements, ctx);
  32934. var /** @type {?} */ result = {};
  32935. ctx.exports.forEach(function (exportName) { result[exportName] = ctx.vars.get(exportName); });
  32936. return result;
  32937. }
  32938. /**
  32939. * @param {?} varNames
  32940. * @param {?} varValues
  32941. * @param {?} statements
  32942. * @param {?} ctx
  32943. * @param {?} visitor
  32944. * @return {?}
  32945. */
  32946. function _executeFunctionStatements(varNames, varValues, statements, ctx, visitor) {
  32947. var /** @type {?} */ childCtx = ctx.createChildWihtLocalVars();
  32948. for (var /** @type {?} */ i = 0; i < varNames.length; i++) {
  32949. childCtx.vars.set(varNames[i], varValues[i]);
  32950. }
  32951. var /** @type {?} */ result = visitor.visitAllStatements(statements, childCtx);
  32952. return result ? result.value : null;
  32953. }
  32954. var _ExecutionContext = /** @class */ (function () {
  32955. function _ExecutionContext(parent, instance, className, vars) {
  32956. this.parent = parent;
  32957. this.instance = instance;
  32958. this.className = className;
  32959. this.vars = vars;
  32960. this.exports = [];
  32961. }
  32962. /**
  32963. * @return {?}
  32964. */
  32965. _ExecutionContext.prototype.createChildWihtLocalVars = /**
  32966. * @return {?}
  32967. */
  32968. function () {
  32969. return new _ExecutionContext(this, this.instance, this.className, new Map());
  32970. };
  32971. return _ExecutionContext;
  32972. }());
  32973. var ReturnValue = /** @class */ (function () {
  32974. function ReturnValue(value) {
  32975. this.value = value;
  32976. }
  32977. return ReturnValue;
  32978. }());
  32979. /**
  32980. * @param {?} _classStmt
  32981. * @param {?} _ctx
  32982. * @param {?} _visitor
  32983. * @return {?}
  32984. */
  32985. function createDynamicClass(_classStmt, _ctx, _visitor) {
  32986. var /** @type {?} */ propertyDescriptors = {};
  32987. _classStmt.getters.forEach(function (getter) {
  32988. // Note: use `function` instead of arrow function to capture `this`
  32989. propertyDescriptors[getter.name] = {
  32990. configurable: false,
  32991. get: function () {
  32992. var /** @type {?} */ instanceCtx = new _ExecutionContext(_ctx, this, _classStmt.name, _ctx.vars);
  32993. return _executeFunctionStatements([], [], getter.body, instanceCtx, _visitor);
  32994. }
  32995. };
  32996. });
  32997. _classStmt.methods.forEach(function (method) {
  32998. var /** @type {?} */ paramNames = method.params.map(function (param) { return param.name; });
  32999. // Note: use `function` instead of arrow function to capture `this`
  33000. propertyDescriptors[/** @type {?} */ ((method.name))] = {
  33001. writable: false,
  33002. configurable: false,
  33003. value: function () {
  33004. var args = [];
  33005. for (var _i = 0; _i < arguments.length; _i++) {
  33006. args[_i] = arguments[_i];
  33007. }
  33008. var /** @type {?} */ instanceCtx = new _ExecutionContext(_ctx, this, _classStmt.name, _ctx.vars);
  33009. return _executeFunctionStatements(paramNames, args, method.body, instanceCtx, _visitor);
  33010. }
  33011. };
  33012. });
  33013. var /** @type {?} */ ctorParamNames = _classStmt.constructorMethod.params.map(function (param) { return param.name; });
  33014. // Note: use `function` instead of arrow function to capture `this`
  33015. var /** @type {?} */ ctor = function () {
  33016. var _this = this;
  33017. var args = [];
  33018. for (var _i = 0; _i < arguments.length; _i++) {
  33019. args[_i] = arguments[_i];
  33020. }
  33021. var /** @type {?} */ instanceCtx = new _ExecutionContext(_ctx, this, _classStmt.name, _ctx.vars);
  33022. _classStmt.fields.forEach(function (field) { _this[field.name] = undefined; });
  33023. _executeFunctionStatements(ctorParamNames, args, _classStmt.constructorMethod.body, instanceCtx, _visitor);
  33024. };
  33025. var /** @type {?} */ superClass = _classStmt.parent ? _classStmt.parent.visitExpression(_visitor, _ctx) : Object;
  33026. ctor.prototype = Object.create(superClass.prototype, propertyDescriptors);
  33027. return ctor;
  33028. }
  33029. var StatementInterpreter = /** @class */ (function () {
  33030. function StatementInterpreter(reflector) {
  33031. this.reflector = reflector;
  33032. }
  33033. /**
  33034. * @param {?} ast
  33035. * @return {?}
  33036. */
  33037. StatementInterpreter.prototype.debugAst = /**
  33038. * @param {?} ast
  33039. * @return {?}
  33040. */
  33041. function (ast) { return debugOutputAstAsTypeScript(ast); };
  33042. /**
  33043. * @param {?} stmt
  33044. * @param {?} ctx
  33045. * @return {?}
  33046. */
  33047. StatementInterpreter.prototype.visitDeclareVarStmt = /**
  33048. * @param {?} stmt
  33049. * @param {?} ctx
  33050. * @return {?}
  33051. */
  33052. function (stmt, ctx) {
  33053. ctx.vars.set(stmt.name, stmt.value.visitExpression(this, ctx));
  33054. if (stmt.hasModifier(StmtModifier.Exported)) {
  33055. ctx.exports.push(stmt.name);
  33056. }
  33057. return null;
  33058. };
  33059. /**
  33060. * @param {?} expr
  33061. * @param {?} ctx
  33062. * @return {?}
  33063. */
  33064. StatementInterpreter.prototype.visitWriteVarExpr = /**
  33065. * @param {?} expr
  33066. * @param {?} ctx
  33067. * @return {?}
  33068. */
  33069. function (expr, ctx) {
  33070. var /** @type {?} */ value = expr.value.visitExpression(this, ctx);
  33071. var /** @type {?} */ currCtx = ctx;
  33072. while (currCtx != null) {
  33073. if (currCtx.vars.has(expr.name)) {
  33074. currCtx.vars.set(expr.name, value);
  33075. return value;
  33076. }
  33077. currCtx = /** @type {?} */ ((currCtx.parent));
  33078. }
  33079. throw new Error("Not declared variable " + expr.name);
  33080. };
  33081. /**
  33082. * @param {?} ast
  33083. * @param {?} ctx
  33084. * @return {?}
  33085. */
  33086. StatementInterpreter.prototype.visitReadVarExpr = /**
  33087. * @param {?} ast
  33088. * @param {?} ctx
  33089. * @return {?}
  33090. */
  33091. function (ast, ctx) {
  33092. var /** @type {?} */ varName = /** @type {?} */ ((ast.name));
  33093. if (ast.builtin != null) {
  33094. switch (ast.builtin) {
  33095. case BuiltinVar.Super:
  33096. return ctx.instance.__proto__;
  33097. case BuiltinVar.This:
  33098. return ctx.instance;
  33099. case BuiltinVar.CatchError:
  33100. varName = CATCH_ERROR_VAR$2;
  33101. break;
  33102. case BuiltinVar.CatchStack:
  33103. varName = CATCH_STACK_VAR$2;
  33104. break;
  33105. default:
  33106. throw new Error("Unknown builtin variable " + ast.builtin);
  33107. }
  33108. }
  33109. var /** @type {?} */ currCtx = ctx;
  33110. while (currCtx != null) {
  33111. if (currCtx.vars.has(varName)) {
  33112. return currCtx.vars.get(varName);
  33113. }
  33114. currCtx = /** @type {?} */ ((currCtx.parent));
  33115. }
  33116. throw new Error("Not declared variable " + varName);
  33117. };
  33118. /**
  33119. * @param {?} expr
  33120. * @param {?} ctx
  33121. * @return {?}
  33122. */
  33123. StatementInterpreter.prototype.visitWriteKeyExpr = /**
  33124. * @param {?} expr
  33125. * @param {?} ctx
  33126. * @return {?}
  33127. */
  33128. function (expr, ctx) {
  33129. var /** @type {?} */ receiver = expr.receiver.visitExpression(this, ctx);
  33130. var /** @type {?} */ index = expr.index.visitExpression(this, ctx);
  33131. var /** @type {?} */ value = expr.value.visitExpression(this, ctx);
  33132. receiver[index] = value;
  33133. return value;
  33134. };
  33135. /**
  33136. * @param {?} expr
  33137. * @param {?} ctx
  33138. * @return {?}
  33139. */
  33140. StatementInterpreter.prototype.visitWritePropExpr = /**
  33141. * @param {?} expr
  33142. * @param {?} ctx
  33143. * @return {?}
  33144. */
  33145. function (expr, ctx) {
  33146. var /** @type {?} */ receiver = expr.receiver.visitExpression(this, ctx);
  33147. var /** @type {?} */ value = expr.value.visitExpression(this, ctx);
  33148. receiver[expr.name] = value;
  33149. return value;
  33150. };
  33151. /**
  33152. * @param {?} expr
  33153. * @param {?} ctx
  33154. * @return {?}
  33155. */
  33156. StatementInterpreter.prototype.visitInvokeMethodExpr = /**
  33157. * @param {?} expr
  33158. * @param {?} ctx
  33159. * @return {?}
  33160. */
  33161. function (expr, ctx) {
  33162. var /** @type {?} */ receiver = expr.receiver.visitExpression(this, ctx);
  33163. var /** @type {?} */ args = this.visitAllExpressions(expr.args, ctx);
  33164. var /** @type {?} */ result;
  33165. if (expr.builtin != null) {
  33166. switch (expr.builtin) {
  33167. case BuiltinMethod.ConcatArray:
  33168. result = receiver.concat.apply(receiver, args);
  33169. break;
  33170. case BuiltinMethod.SubscribeObservable:
  33171. result = receiver.subscribe({ next: args[0] });
  33172. break;
  33173. case BuiltinMethod.Bind:
  33174. result = receiver.bind.apply(receiver, args);
  33175. break;
  33176. default:
  33177. throw new Error("Unknown builtin method " + expr.builtin);
  33178. }
  33179. }
  33180. else {
  33181. result = receiver[/** @type {?} */ ((expr.name))].apply(receiver, args);
  33182. }
  33183. return result;
  33184. };
  33185. /**
  33186. * @param {?} stmt
  33187. * @param {?} ctx
  33188. * @return {?}
  33189. */
  33190. StatementInterpreter.prototype.visitInvokeFunctionExpr = /**
  33191. * @param {?} stmt
  33192. * @param {?} ctx
  33193. * @return {?}
  33194. */
  33195. function (stmt, ctx) {
  33196. var /** @type {?} */ args = this.visitAllExpressions(stmt.args, ctx);
  33197. var /** @type {?} */ fnExpr = stmt.fn;
  33198. if (fnExpr instanceof ReadVarExpr && fnExpr.builtin === BuiltinVar.Super) {
  33199. ctx.instance.constructor.prototype.constructor.apply(ctx.instance, args);
  33200. return null;
  33201. }
  33202. else {
  33203. var /** @type {?} */ fn$$1 = stmt.fn.visitExpression(this, ctx);
  33204. return fn$$1.apply(null, args);
  33205. }
  33206. };
  33207. /**
  33208. * @param {?} stmt
  33209. * @param {?} ctx
  33210. * @return {?}
  33211. */
  33212. StatementInterpreter.prototype.visitReturnStmt = /**
  33213. * @param {?} stmt
  33214. * @param {?} ctx
  33215. * @return {?}
  33216. */
  33217. function (stmt, ctx) {
  33218. return new ReturnValue(stmt.value.visitExpression(this, ctx));
  33219. };
  33220. /**
  33221. * @param {?} stmt
  33222. * @param {?} ctx
  33223. * @return {?}
  33224. */
  33225. StatementInterpreter.prototype.visitDeclareClassStmt = /**
  33226. * @param {?} stmt
  33227. * @param {?} ctx
  33228. * @return {?}
  33229. */
  33230. function (stmt, ctx) {
  33231. var /** @type {?} */ clazz = createDynamicClass(stmt, ctx, this);
  33232. ctx.vars.set(stmt.name, clazz);
  33233. if (stmt.hasModifier(StmtModifier.Exported)) {
  33234. ctx.exports.push(stmt.name);
  33235. }
  33236. return null;
  33237. };
  33238. /**
  33239. * @param {?} stmt
  33240. * @param {?} ctx
  33241. * @return {?}
  33242. */
  33243. StatementInterpreter.prototype.visitExpressionStmt = /**
  33244. * @param {?} stmt
  33245. * @param {?} ctx
  33246. * @return {?}
  33247. */
  33248. function (stmt, ctx) {
  33249. return stmt.expr.visitExpression(this, ctx);
  33250. };
  33251. /**
  33252. * @param {?} stmt
  33253. * @param {?} ctx
  33254. * @return {?}
  33255. */
  33256. StatementInterpreter.prototype.visitIfStmt = /**
  33257. * @param {?} stmt
  33258. * @param {?} ctx
  33259. * @return {?}
  33260. */
  33261. function (stmt, ctx) {
  33262. var /** @type {?} */ condition = stmt.condition.visitExpression(this, ctx);
  33263. if (condition) {
  33264. return this.visitAllStatements(stmt.trueCase, ctx);
  33265. }
  33266. else if (stmt.falseCase != null) {
  33267. return this.visitAllStatements(stmt.falseCase, ctx);
  33268. }
  33269. return null;
  33270. };
  33271. /**
  33272. * @param {?} stmt
  33273. * @param {?} ctx
  33274. * @return {?}
  33275. */
  33276. StatementInterpreter.prototype.visitTryCatchStmt = /**
  33277. * @param {?} stmt
  33278. * @param {?} ctx
  33279. * @return {?}
  33280. */
  33281. function (stmt, ctx) {
  33282. try {
  33283. return this.visitAllStatements(stmt.bodyStmts, ctx);
  33284. }
  33285. catch (/** @type {?} */ e) {
  33286. var /** @type {?} */ childCtx = ctx.createChildWihtLocalVars();
  33287. childCtx.vars.set(CATCH_ERROR_VAR$2, e);
  33288. childCtx.vars.set(CATCH_STACK_VAR$2, e.stack);
  33289. return this.visitAllStatements(stmt.catchStmts, childCtx);
  33290. }
  33291. };
  33292. /**
  33293. * @param {?} stmt
  33294. * @param {?} ctx
  33295. * @return {?}
  33296. */
  33297. StatementInterpreter.prototype.visitThrowStmt = /**
  33298. * @param {?} stmt
  33299. * @param {?} ctx
  33300. * @return {?}
  33301. */
  33302. function (stmt, ctx) {
  33303. throw stmt.error.visitExpression(this, ctx);
  33304. };
  33305. /**
  33306. * @param {?} stmt
  33307. * @param {?=} context
  33308. * @return {?}
  33309. */
  33310. StatementInterpreter.prototype.visitCommentStmt = /**
  33311. * @param {?} stmt
  33312. * @param {?=} context
  33313. * @return {?}
  33314. */
  33315. function (stmt, context) { return null; };
  33316. /**
  33317. * @param {?} ast
  33318. * @param {?} ctx
  33319. * @return {?}
  33320. */
  33321. StatementInterpreter.prototype.visitInstantiateExpr = /**
  33322. * @param {?} ast
  33323. * @param {?} ctx
  33324. * @return {?}
  33325. */
  33326. function (ast, ctx) {
  33327. var /** @type {?} */ args = this.visitAllExpressions(ast.args, ctx);
  33328. var /** @type {?} */ clazz = ast.classExpr.visitExpression(this, ctx);
  33329. return new (clazz.bind.apply(clazz, [void 0].concat(args)))();
  33330. };
  33331. /**
  33332. * @param {?} ast
  33333. * @param {?} ctx
  33334. * @return {?}
  33335. */
  33336. StatementInterpreter.prototype.visitLiteralExpr = /**
  33337. * @param {?} ast
  33338. * @param {?} ctx
  33339. * @return {?}
  33340. */
  33341. function (ast, ctx) { return ast.value; };
  33342. /**
  33343. * @param {?} ast
  33344. * @param {?} ctx
  33345. * @return {?}
  33346. */
  33347. StatementInterpreter.prototype.visitExternalExpr = /**
  33348. * @param {?} ast
  33349. * @param {?} ctx
  33350. * @return {?}
  33351. */
  33352. function (ast, ctx) {
  33353. return this.reflector.resolveExternalReference(ast.value);
  33354. };
  33355. /**
  33356. * @param {?} ast
  33357. * @param {?} ctx
  33358. * @return {?}
  33359. */
  33360. StatementInterpreter.prototype.visitConditionalExpr = /**
  33361. * @param {?} ast
  33362. * @param {?} ctx
  33363. * @return {?}
  33364. */
  33365. function (ast, ctx) {
  33366. if (ast.condition.visitExpression(this, ctx)) {
  33367. return ast.trueCase.visitExpression(this, ctx);
  33368. }
  33369. else if (ast.falseCase != null) {
  33370. return ast.falseCase.visitExpression(this, ctx);
  33371. }
  33372. return null;
  33373. };
  33374. /**
  33375. * @param {?} ast
  33376. * @param {?} ctx
  33377. * @return {?}
  33378. */
  33379. StatementInterpreter.prototype.visitNotExpr = /**
  33380. * @param {?} ast
  33381. * @param {?} ctx
  33382. * @return {?}
  33383. */
  33384. function (ast, ctx) {
  33385. return !ast.condition.visitExpression(this, ctx);
  33386. };
  33387. /**
  33388. * @param {?} ast
  33389. * @param {?} ctx
  33390. * @return {?}
  33391. */
  33392. StatementInterpreter.prototype.visitAssertNotNullExpr = /**
  33393. * @param {?} ast
  33394. * @param {?} ctx
  33395. * @return {?}
  33396. */
  33397. function (ast, ctx) {
  33398. return ast.condition.visitExpression(this, ctx);
  33399. };
  33400. /**
  33401. * @param {?} ast
  33402. * @param {?} ctx
  33403. * @return {?}
  33404. */
  33405. StatementInterpreter.prototype.visitCastExpr = /**
  33406. * @param {?} ast
  33407. * @param {?} ctx
  33408. * @return {?}
  33409. */
  33410. function (ast, ctx) {
  33411. return ast.value.visitExpression(this, ctx);
  33412. };
  33413. /**
  33414. * @param {?} ast
  33415. * @param {?} ctx
  33416. * @return {?}
  33417. */
  33418. StatementInterpreter.prototype.visitFunctionExpr = /**
  33419. * @param {?} ast
  33420. * @param {?} ctx
  33421. * @return {?}
  33422. */
  33423. function (ast, ctx) {
  33424. var /** @type {?} */ paramNames = ast.params.map(function (param) { return param.name; });
  33425. return _declareFn(paramNames, ast.statements, ctx, this);
  33426. };
  33427. /**
  33428. * @param {?} stmt
  33429. * @param {?} ctx
  33430. * @return {?}
  33431. */
  33432. StatementInterpreter.prototype.visitDeclareFunctionStmt = /**
  33433. * @param {?} stmt
  33434. * @param {?} ctx
  33435. * @return {?}
  33436. */
  33437. function (stmt, ctx) {
  33438. var /** @type {?} */ paramNames = stmt.params.map(function (param) { return param.name; });
  33439. ctx.vars.set(stmt.name, _declareFn(paramNames, stmt.statements, ctx, this));
  33440. if (stmt.hasModifier(StmtModifier.Exported)) {
  33441. ctx.exports.push(stmt.name);
  33442. }
  33443. return null;
  33444. };
  33445. /**
  33446. * @param {?} ast
  33447. * @param {?} ctx
  33448. * @return {?}
  33449. */
  33450. StatementInterpreter.prototype.visitBinaryOperatorExpr = /**
  33451. * @param {?} ast
  33452. * @param {?} ctx
  33453. * @return {?}
  33454. */
  33455. function (ast, ctx) {
  33456. var _this = this;
  33457. var /** @type {?} */ lhs = function () { return ast.lhs.visitExpression(_this, ctx); };
  33458. var /** @type {?} */ rhs = function () { return ast.rhs.visitExpression(_this, ctx); };
  33459. switch (ast.operator) {
  33460. case BinaryOperator.Equals:
  33461. return lhs() == rhs();
  33462. case BinaryOperator.Identical:
  33463. return lhs() === rhs();
  33464. case BinaryOperator.NotEquals:
  33465. return lhs() != rhs();
  33466. case BinaryOperator.NotIdentical:
  33467. return lhs() !== rhs();
  33468. case BinaryOperator.And:
  33469. return lhs() && rhs();
  33470. case BinaryOperator.Or:
  33471. return lhs() || rhs();
  33472. case BinaryOperator.Plus:
  33473. return lhs() + rhs();
  33474. case BinaryOperator.Minus:
  33475. return lhs() - rhs();
  33476. case BinaryOperator.Divide:
  33477. return lhs() / rhs();
  33478. case BinaryOperator.Multiply:
  33479. return lhs() * rhs();
  33480. case BinaryOperator.Modulo:
  33481. return lhs() % rhs();
  33482. case BinaryOperator.Lower:
  33483. return lhs() < rhs();
  33484. case BinaryOperator.LowerEquals:
  33485. return lhs() <= rhs();
  33486. case BinaryOperator.Bigger:
  33487. return lhs() > rhs();
  33488. case BinaryOperator.BiggerEquals:
  33489. return lhs() >= rhs();
  33490. default:
  33491. throw new Error("Unknown operator " + ast.operator);
  33492. }
  33493. };
  33494. /**
  33495. * @param {?} ast
  33496. * @param {?} ctx
  33497. * @return {?}
  33498. */
  33499. StatementInterpreter.prototype.visitReadPropExpr = /**
  33500. * @param {?} ast
  33501. * @param {?} ctx
  33502. * @return {?}
  33503. */
  33504. function (ast, ctx) {
  33505. var /** @type {?} */ result;
  33506. var /** @type {?} */ receiver = ast.receiver.visitExpression(this, ctx);
  33507. result = receiver[ast.name];
  33508. return result;
  33509. };
  33510. /**
  33511. * @param {?} ast
  33512. * @param {?} ctx
  33513. * @return {?}
  33514. */
  33515. StatementInterpreter.prototype.visitReadKeyExpr = /**
  33516. * @param {?} ast
  33517. * @param {?} ctx
  33518. * @return {?}
  33519. */
  33520. function (ast, ctx) {
  33521. var /** @type {?} */ receiver = ast.receiver.visitExpression(this, ctx);
  33522. var /** @type {?} */ prop = ast.index.visitExpression(this, ctx);
  33523. return receiver[prop];
  33524. };
  33525. /**
  33526. * @param {?} ast
  33527. * @param {?} ctx
  33528. * @return {?}
  33529. */
  33530. StatementInterpreter.prototype.visitLiteralArrayExpr = /**
  33531. * @param {?} ast
  33532. * @param {?} ctx
  33533. * @return {?}
  33534. */
  33535. function (ast, ctx) {
  33536. return this.visitAllExpressions(ast.entries, ctx);
  33537. };
  33538. /**
  33539. * @param {?} ast
  33540. * @param {?} ctx
  33541. * @return {?}
  33542. */
  33543. StatementInterpreter.prototype.visitLiteralMapExpr = /**
  33544. * @param {?} ast
  33545. * @param {?} ctx
  33546. * @return {?}
  33547. */
  33548. function (ast, ctx) {
  33549. var _this = this;
  33550. var /** @type {?} */ result = {};
  33551. ast.entries.forEach(function (entry) { return result[entry.key] = entry.value.visitExpression(_this, ctx); });
  33552. return result;
  33553. };
  33554. /**
  33555. * @param {?} ast
  33556. * @param {?} context
  33557. * @return {?}
  33558. */
  33559. StatementInterpreter.prototype.visitCommaExpr = /**
  33560. * @param {?} ast
  33561. * @param {?} context
  33562. * @return {?}
  33563. */
  33564. function (ast, context) {
  33565. var /** @type {?} */ values = this.visitAllExpressions(ast.parts, context);
  33566. return values[values.length - 1];
  33567. };
  33568. /**
  33569. * @param {?} expressions
  33570. * @param {?} ctx
  33571. * @return {?}
  33572. */
  33573. StatementInterpreter.prototype.visitAllExpressions = /**
  33574. * @param {?} expressions
  33575. * @param {?} ctx
  33576. * @return {?}
  33577. */
  33578. function (expressions, ctx) {
  33579. var _this = this;
  33580. return expressions.map(function (expr) { return expr.visitExpression(_this, ctx); });
  33581. };
  33582. /**
  33583. * @param {?} statements
  33584. * @param {?} ctx
  33585. * @return {?}
  33586. */
  33587. StatementInterpreter.prototype.visitAllStatements = /**
  33588. * @param {?} statements
  33589. * @param {?} ctx
  33590. * @return {?}
  33591. */
  33592. function (statements, ctx) {
  33593. for (var /** @type {?} */ i = 0; i < statements.length; i++) {
  33594. var /** @type {?} */ stmt = statements[i];
  33595. var /** @type {?} */ val = stmt.visitStatement(this, ctx);
  33596. if (val instanceof ReturnValue) {
  33597. return val;
  33598. }
  33599. }
  33600. return null;
  33601. };
  33602. return StatementInterpreter;
  33603. }());
  33604. /**
  33605. * @param {?} varNames
  33606. * @param {?} statements
  33607. * @param {?} ctx
  33608. * @param {?} visitor
  33609. * @return {?}
  33610. */
  33611. function _declareFn(varNames, statements, ctx, visitor) {
  33612. return function () {
  33613. var args = [];
  33614. for (var _i = 0; _i < arguments.length; _i++) {
  33615. args[_i] = arguments[_i];
  33616. }
  33617. return _executeFunctionStatements(varNames, args, statements, ctx, visitor);
  33618. };
  33619. }
  33620. var CATCH_ERROR_VAR$2 = 'error';
  33621. var CATCH_STACK_VAR$2 = 'stack';
  33622. /**
  33623. * @fileoverview added by tsickle
  33624. * @suppress {checkTypes} checked by tsc
  33625. */
  33626. /**
  33627. * @license
  33628. * Copyright Google Inc. All Rights Reserved.
  33629. *
  33630. * Use of this source code is governed by an MIT-style license that can be
  33631. * found in the LICENSE file at https://angular.io/license
  33632. */
  33633. /**
  33634. * @abstract
  33635. */
  33636. var AbstractJsEmitterVisitor = /** @class */ (function (_super) {
  33637. __extends(AbstractJsEmitterVisitor, _super);
  33638. function AbstractJsEmitterVisitor() {
  33639. return _super.call(this, false) || this;
  33640. }
  33641. /**
  33642. * @param {?} stmt
  33643. * @param {?} ctx
  33644. * @return {?}
  33645. */
  33646. AbstractJsEmitterVisitor.prototype.visitDeclareClassStmt = /**
  33647. * @param {?} stmt
  33648. * @param {?} ctx
  33649. * @return {?}
  33650. */
  33651. function (stmt, ctx) {
  33652. var _this = this;
  33653. ctx.pushClass(stmt);
  33654. this._visitClassConstructor(stmt, ctx);
  33655. if (stmt.parent != null) {
  33656. ctx.print(stmt, stmt.name + ".prototype = Object.create(");
  33657. stmt.parent.visitExpression(this, ctx);
  33658. ctx.println(stmt, ".prototype);");
  33659. }
  33660. stmt.getters.forEach(function (getter) { return _this._visitClassGetter(stmt, getter, ctx); });
  33661. stmt.methods.forEach(function (method) { return _this._visitClassMethod(stmt, method, ctx); });
  33662. ctx.popClass();
  33663. return null;
  33664. };
  33665. /**
  33666. * @param {?} stmt
  33667. * @param {?} ctx
  33668. * @return {?}
  33669. */
  33670. AbstractJsEmitterVisitor.prototype._visitClassConstructor = /**
  33671. * @param {?} stmt
  33672. * @param {?} ctx
  33673. * @return {?}
  33674. */
  33675. function (stmt, ctx) {
  33676. ctx.print(stmt, "function " + stmt.name + "(");
  33677. if (stmt.constructorMethod != null) {
  33678. this._visitParams(stmt.constructorMethod.params, ctx);
  33679. }
  33680. ctx.println(stmt, ") {");
  33681. ctx.incIndent();
  33682. if (stmt.constructorMethod != null) {
  33683. if (stmt.constructorMethod.body.length > 0) {
  33684. ctx.println(stmt, "var self = this;");
  33685. this.visitAllStatements(stmt.constructorMethod.body, ctx);
  33686. }
  33687. }
  33688. ctx.decIndent();
  33689. ctx.println(stmt, "}");
  33690. };
  33691. /**
  33692. * @param {?} stmt
  33693. * @param {?} getter
  33694. * @param {?} ctx
  33695. * @return {?}
  33696. */
  33697. AbstractJsEmitterVisitor.prototype._visitClassGetter = /**
  33698. * @param {?} stmt
  33699. * @param {?} getter
  33700. * @param {?} ctx
  33701. * @return {?}
  33702. */
  33703. function (stmt, getter, ctx) {
  33704. ctx.println(stmt, "Object.defineProperty(" + stmt.name + ".prototype, '" + getter.name + "', { get: function() {");
  33705. ctx.incIndent();
  33706. if (getter.body.length > 0) {
  33707. ctx.println(stmt, "var self = this;");
  33708. this.visitAllStatements(getter.body, ctx);
  33709. }
  33710. ctx.decIndent();
  33711. ctx.println(stmt, "}});");
  33712. };
  33713. /**
  33714. * @param {?} stmt
  33715. * @param {?} method
  33716. * @param {?} ctx
  33717. * @return {?}
  33718. */
  33719. AbstractJsEmitterVisitor.prototype._visitClassMethod = /**
  33720. * @param {?} stmt
  33721. * @param {?} method
  33722. * @param {?} ctx
  33723. * @return {?}
  33724. */
  33725. function (stmt, method, ctx) {
  33726. ctx.print(stmt, stmt.name + ".prototype." + method.name + " = function(");
  33727. this._visitParams(method.params, ctx);
  33728. ctx.println(stmt, ") {");
  33729. ctx.incIndent();
  33730. if (method.body.length > 0) {
  33731. ctx.println(stmt, "var self = this;");
  33732. this.visitAllStatements(method.body, ctx);
  33733. }
  33734. ctx.decIndent();
  33735. ctx.println(stmt, "};");
  33736. };
  33737. /**
  33738. * @param {?} ast
  33739. * @param {?} ctx
  33740. * @return {?}
  33741. */
  33742. AbstractJsEmitterVisitor.prototype.visitReadVarExpr = /**
  33743. * @param {?} ast
  33744. * @param {?} ctx
  33745. * @return {?}
  33746. */
  33747. function (ast, ctx) {
  33748. if (ast.builtin === BuiltinVar.This) {
  33749. ctx.print(ast, 'self');
  33750. }
  33751. else if (ast.builtin === BuiltinVar.Super) {
  33752. throw new Error("'super' needs to be handled at a parent ast node, not at the variable level!");
  33753. }
  33754. else {
  33755. _super.prototype.visitReadVarExpr.call(this, ast, ctx);
  33756. }
  33757. return null;
  33758. };
  33759. /**
  33760. * @param {?} stmt
  33761. * @param {?} ctx
  33762. * @return {?}
  33763. */
  33764. AbstractJsEmitterVisitor.prototype.visitDeclareVarStmt = /**
  33765. * @param {?} stmt
  33766. * @param {?} ctx
  33767. * @return {?}
  33768. */
  33769. function (stmt, ctx) {
  33770. ctx.print(stmt, "var " + stmt.name + " = ");
  33771. stmt.value.visitExpression(this, ctx);
  33772. ctx.println(stmt, ";");
  33773. return null;
  33774. };
  33775. /**
  33776. * @param {?} ast
  33777. * @param {?} ctx
  33778. * @return {?}
  33779. */
  33780. AbstractJsEmitterVisitor.prototype.visitCastExpr = /**
  33781. * @param {?} ast
  33782. * @param {?} ctx
  33783. * @return {?}
  33784. */
  33785. function (ast, ctx) {
  33786. ast.value.visitExpression(this, ctx);
  33787. return null;
  33788. };
  33789. /**
  33790. * @param {?} expr
  33791. * @param {?} ctx
  33792. * @return {?}
  33793. */
  33794. AbstractJsEmitterVisitor.prototype.visitInvokeFunctionExpr = /**
  33795. * @param {?} expr
  33796. * @param {?} ctx
  33797. * @return {?}
  33798. */
  33799. function (expr, ctx) {
  33800. var /** @type {?} */ fnExpr = expr.fn;
  33801. if (fnExpr instanceof ReadVarExpr && fnExpr.builtin === BuiltinVar.Super) {
  33802. /** @type {?} */ ((/** @type {?} */ ((ctx.currentClass)).parent)).visitExpression(this, ctx);
  33803. ctx.print(expr, ".call(this");
  33804. if (expr.args.length > 0) {
  33805. ctx.print(expr, ", ");
  33806. this.visitAllExpressions(expr.args, ctx, ',');
  33807. }
  33808. ctx.print(expr, ")");
  33809. }
  33810. else {
  33811. _super.prototype.visitInvokeFunctionExpr.call(this, expr, ctx);
  33812. }
  33813. return null;
  33814. };
  33815. /**
  33816. * @param {?} ast
  33817. * @param {?} ctx
  33818. * @return {?}
  33819. */
  33820. AbstractJsEmitterVisitor.prototype.visitFunctionExpr = /**
  33821. * @param {?} ast
  33822. * @param {?} ctx
  33823. * @return {?}
  33824. */
  33825. function (ast, ctx) {
  33826. ctx.print(ast, "function(");
  33827. this._visitParams(ast.params, ctx);
  33828. ctx.println(ast, ") {");
  33829. ctx.incIndent();
  33830. this.visitAllStatements(ast.statements, ctx);
  33831. ctx.decIndent();
  33832. ctx.print(ast, "}");
  33833. return null;
  33834. };
  33835. /**
  33836. * @param {?} stmt
  33837. * @param {?} ctx
  33838. * @return {?}
  33839. */
  33840. AbstractJsEmitterVisitor.prototype.visitDeclareFunctionStmt = /**
  33841. * @param {?} stmt
  33842. * @param {?} ctx
  33843. * @return {?}
  33844. */
  33845. function (stmt, ctx) {
  33846. ctx.print(stmt, "function " + stmt.name + "(");
  33847. this._visitParams(stmt.params, ctx);
  33848. ctx.println(stmt, ") {");
  33849. ctx.incIndent();
  33850. this.visitAllStatements(stmt.statements, ctx);
  33851. ctx.decIndent();
  33852. ctx.println(stmt, "}");
  33853. return null;
  33854. };
  33855. /**
  33856. * @param {?} stmt
  33857. * @param {?} ctx
  33858. * @return {?}
  33859. */
  33860. AbstractJsEmitterVisitor.prototype.visitTryCatchStmt = /**
  33861. * @param {?} stmt
  33862. * @param {?} ctx
  33863. * @return {?}
  33864. */
  33865. function (stmt, ctx) {
  33866. ctx.println(stmt, "try {");
  33867. ctx.incIndent();
  33868. this.visitAllStatements(stmt.bodyStmts, ctx);
  33869. ctx.decIndent();
  33870. ctx.println(stmt, "} catch (" + CATCH_ERROR_VAR$1.name + ") {");
  33871. ctx.incIndent();
  33872. var /** @type {?} */ catchStmts = [/** @type {?} */ (CATCH_STACK_VAR$1.set(CATCH_ERROR_VAR$1.prop('stack')).toDeclStmt(null, [
  33873. StmtModifier.Final
  33874. ]))].concat(stmt.catchStmts);
  33875. this.visitAllStatements(catchStmts, ctx);
  33876. ctx.decIndent();
  33877. ctx.println(stmt, "}");
  33878. return null;
  33879. };
  33880. /**
  33881. * @param {?} params
  33882. * @param {?} ctx
  33883. * @return {?}
  33884. */
  33885. AbstractJsEmitterVisitor.prototype._visitParams = /**
  33886. * @param {?} params
  33887. * @param {?} ctx
  33888. * @return {?}
  33889. */
  33890. function (params, ctx) {
  33891. this.visitAllObjects(function (param) { return ctx.print(null, param.name); }, params, ctx, ',');
  33892. };
  33893. /**
  33894. * @param {?} method
  33895. * @return {?}
  33896. */
  33897. AbstractJsEmitterVisitor.prototype.getBuiltinMethodName = /**
  33898. * @param {?} method
  33899. * @return {?}
  33900. */
  33901. function (method) {
  33902. var /** @type {?} */ name;
  33903. switch (method) {
  33904. case BuiltinMethod.ConcatArray:
  33905. name = 'concat';
  33906. break;
  33907. case BuiltinMethod.SubscribeObservable:
  33908. name = 'subscribe';
  33909. break;
  33910. case BuiltinMethod.Bind:
  33911. name = 'bind';
  33912. break;
  33913. default:
  33914. throw new Error("Unknown builtin method: " + method);
  33915. }
  33916. return name;
  33917. };
  33918. return AbstractJsEmitterVisitor;
  33919. }(AbstractEmitterVisitor));
  33920. /**
  33921. * @fileoverview added by tsickle
  33922. * @suppress {checkTypes} checked by tsc
  33923. */
  33924. /**
  33925. * @license
  33926. * Copyright Google Inc. All Rights Reserved.
  33927. *
  33928. * Use of this source code is governed by an MIT-style license that can be
  33929. * found in the LICENSE file at https://angular.io/license
  33930. */
  33931. /**
  33932. * @param {?} sourceUrl
  33933. * @param {?} ctx
  33934. * @param {?} vars
  33935. * @param {?} createSourceMap
  33936. * @return {?}
  33937. */
  33938. function evalExpression(sourceUrl, ctx, vars, createSourceMap) {
  33939. var /** @type {?} */ fnBody = ctx.toSource() + "\n//# sourceURL=" + sourceUrl;
  33940. var /** @type {?} */ fnArgNames = [];
  33941. var /** @type {?} */ fnArgValues = [];
  33942. for (var /** @type {?} */ argName in vars) {
  33943. fnArgNames.push(argName);
  33944. fnArgValues.push(vars[argName]);
  33945. }
  33946. if (createSourceMap) {
  33947. // using `new Function(...)` generates a header, 1 line of no arguments, 2 lines otherwise
  33948. // E.g. ```
  33949. // function anonymous(a,b,c
  33950. // /**/) { ... }```
  33951. // We don't want to hard code this fact, so we auto detect it via an empty function first.
  33952. var /** @type {?} */ emptyFn = new (Function.bind.apply(Function, [void 0].concat(fnArgNames.concat('return null;'))))().toString();
  33953. var /** @type {?} */ headerLines = emptyFn.slice(0, emptyFn.indexOf('return null;')).split('\n').length - 1;
  33954. fnBody += "\n" + ctx.toSourceMapGenerator(sourceUrl, headerLines).toJsComment();
  33955. }
  33956. return new (Function.bind.apply(Function, [void 0].concat(fnArgNames.concat(fnBody))))().apply(void 0, fnArgValues);
  33957. }
  33958. /**
  33959. * @param {?} sourceUrl
  33960. * @param {?} statements
  33961. * @param {?} reflector
  33962. * @param {?} createSourceMaps
  33963. * @return {?}
  33964. */
  33965. function jitStatements(sourceUrl, statements, reflector, createSourceMaps) {
  33966. var /** @type {?} */ converter = new JitEmitterVisitor(reflector);
  33967. var /** @type {?} */ ctx = EmitterVisitorContext.createRoot();
  33968. converter.visitAllStatements(statements, ctx);
  33969. converter.createReturnStmt(ctx);
  33970. return evalExpression(sourceUrl, ctx, converter.getArgs(), createSourceMaps);
  33971. }
  33972. var JitEmitterVisitor = /** @class */ (function (_super) {
  33973. __extends(JitEmitterVisitor, _super);
  33974. function JitEmitterVisitor(reflector) {
  33975. var _this = _super.call(this) || this;
  33976. _this.reflector = reflector;
  33977. _this._evalArgNames = [];
  33978. _this._evalArgValues = [];
  33979. _this._evalExportedVars = [];
  33980. return _this;
  33981. }
  33982. /**
  33983. * @param {?} ctx
  33984. * @return {?}
  33985. */
  33986. JitEmitterVisitor.prototype.createReturnStmt = /**
  33987. * @param {?} ctx
  33988. * @return {?}
  33989. */
  33990. function (ctx) {
  33991. var /** @type {?} */ stmt = new ReturnStatement(new LiteralMapExpr(this._evalExportedVars.map(function (resultVar) { return new LiteralMapEntry(resultVar, variable(resultVar), false); })));
  33992. stmt.visitStatement(this, ctx);
  33993. };
  33994. /**
  33995. * @return {?}
  33996. */
  33997. JitEmitterVisitor.prototype.getArgs = /**
  33998. * @return {?}
  33999. */
  34000. function () {
  34001. var /** @type {?} */ result = {};
  34002. for (var /** @type {?} */ i = 0; i < this._evalArgNames.length; i++) {
  34003. result[this._evalArgNames[i]] = this._evalArgValues[i];
  34004. }
  34005. return result;
  34006. };
  34007. /**
  34008. * @param {?} ast
  34009. * @param {?} ctx
  34010. * @return {?}
  34011. */
  34012. JitEmitterVisitor.prototype.visitExternalExpr = /**
  34013. * @param {?} ast
  34014. * @param {?} ctx
  34015. * @return {?}
  34016. */
  34017. function (ast, ctx) {
  34018. var /** @type {?} */ value = this.reflector.resolveExternalReference(ast.value);
  34019. var /** @type {?} */ id = this._evalArgValues.indexOf(value);
  34020. if (id === -1) {
  34021. id = this._evalArgValues.length;
  34022. this._evalArgValues.push(value);
  34023. var /** @type {?} */ name_1 = identifierName({ reference: value }) || 'val';
  34024. this._evalArgNames.push("jit_" + name_1 + "_" + id);
  34025. }
  34026. ctx.print(ast, this._evalArgNames[id]);
  34027. return null;
  34028. };
  34029. /**
  34030. * @param {?} stmt
  34031. * @param {?} ctx
  34032. * @return {?}
  34033. */
  34034. JitEmitterVisitor.prototype.visitDeclareVarStmt = /**
  34035. * @param {?} stmt
  34036. * @param {?} ctx
  34037. * @return {?}
  34038. */
  34039. function (stmt, ctx) {
  34040. if (stmt.hasModifier(StmtModifier.Exported)) {
  34041. this._evalExportedVars.push(stmt.name);
  34042. }
  34043. return _super.prototype.visitDeclareVarStmt.call(this, stmt, ctx);
  34044. };
  34045. /**
  34046. * @param {?} stmt
  34047. * @param {?} ctx
  34048. * @return {?}
  34049. */
  34050. JitEmitterVisitor.prototype.visitDeclareFunctionStmt = /**
  34051. * @param {?} stmt
  34052. * @param {?} ctx
  34053. * @return {?}
  34054. */
  34055. function (stmt, ctx) {
  34056. if (stmt.hasModifier(StmtModifier.Exported)) {
  34057. this._evalExportedVars.push(stmt.name);
  34058. }
  34059. return _super.prototype.visitDeclareFunctionStmt.call(this, stmt, ctx);
  34060. };
  34061. /**
  34062. * @param {?} stmt
  34063. * @param {?} ctx
  34064. * @return {?}
  34065. */
  34066. JitEmitterVisitor.prototype.visitDeclareClassStmt = /**
  34067. * @param {?} stmt
  34068. * @param {?} ctx
  34069. * @return {?}
  34070. */
  34071. function (stmt, ctx) {
  34072. if (stmt.hasModifier(StmtModifier.Exported)) {
  34073. this._evalExportedVars.push(stmt.name);
  34074. }
  34075. return _super.prototype.visitDeclareClassStmt.call(this, stmt, ctx);
  34076. };
  34077. return JitEmitterVisitor;
  34078. }(AbstractJsEmitterVisitor));
  34079. /**
  34080. * @fileoverview added by tsickle
  34081. * @suppress {checkTypes} checked by tsc
  34082. */
  34083. /**
  34084. * @license
  34085. * Copyright Google Inc. All Rights Reserved.
  34086. *
  34087. * Use of this source code is governed by an MIT-style license that can be
  34088. * found in the LICENSE file at https://angular.io/license
  34089. */
  34090. /**
  34091. * @record
  34092. */
  34093. /**
  34094. * An internal module of the Angular compiler that begins with component types,
  34095. * extracts templates, and eventually produces a compiled version of the component
  34096. * ready for linking into an application.
  34097. *
  34098. * \@security When compiling templates at runtime, you must ensure that the entire template comes
  34099. * from a trusted source. Attacker-controlled data introduced by a template could expose your
  34100. * application to XSS risks. For more detail, see the [Security Guide](http://g.co/ng/security).
  34101. */
  34102. var JitCompiler = /** @class */ (function () {
  34103. function JitCompiler(_metadataResolver, _templateParser, _styleCompiler, _viewCompiler, _ngModuleCompiler, _summaryResolver, _reflector, _compilerConfig, _console, getExtraNgModuleProviders) {
  34104. this._metadataResolver = _metadataResolver;
  34105. this._templateParser = _templateParser;
  34106. this._styleCompiler = _styleCompiler;
  34107. this._viewCompiler = _viewCompiler;
  34108. this._ngModuleCompiler = _ngModuleCompiler;
  34109. this._summaryResolver = _summaryResolver;
  34110. this._reflector = _reflector;
  34111. this._compilerConfig = _compilerConfig;
  34112. this._console = _console;
  34113. this.getExtraNgModuleProviders = getExtraNgModuleProviders;
  34114. this._compiledTemplateCache = new Map();
  34115. this._compiledHostTemplateCache = new Map();
  34116. this._compiledDirectiveWrapperCache = new Map();
  34117. this._compiledNgModuleCache = new Map();
  34118. this._sharedStylesheetCount = 0;
  34119. this._addedAotSummaries = new Set();
  34120. }
  34121. /**
  34122. * @param {?} moduleType
  34123. * @return {?}
  34124. */
  34125. JitCompiler.prototype.compileModuleSync = /**
  34126. * @param {?} moduleType
  34127. * @return {?}
  34128. */
  34129. function (moduleType) {
  34130. return SyncAsync.assertSync(this._compileModuleAndComponents(moduleType, true));
  34131. };
  34132. /**
  34133. * @param {?} moduleType
  34134. * @return {?}
  34135. */
  34136. JitCompiler.prototype.compileModuleAsync = /**
  34137. * @param {?} moduleType
  34138. * @return {?}
  34139. */
  34140. function (moduleType) {
  34141. return Promise.resolve(this._compileModuleAndComponents(moduleType, false));
  34142. };
  34143. /**
  34144. * @param {?} moduleType
  34145. * @return {?}
  34146. */
  34147. JitCompiler.prototype.compileModuleAndAllComponentsSync = /**
  34148. * @param {?} moduleType
  34149. * @return {?}
  34150. */
  34151. function (moduleType) {
  34152. return SyncAsync.assertSync(this._compileModuleAndAllComponents(moduleType, true));
  34153. };
  34154. /**
  34155. * @param {?} moduleType
  34156. * @return {?}
  34157. */
  34158. JitCompiler.prototype.compileModuleAndAllComponentsAsync = /**
  34159. * @param {?} moduleType
  34160. * @return {?}
  34161. */
  34162. function (moduleType) {
  34163. return Promise.resolve(this._compileModuleAndAllComponents(moduleType, false));
  34164. };
  34165. /**
  34166. * @param {?} component
  34167. * @return {?}
  34168. */
  34169. JitCompiler.prototype.getComponentFactory = /**
  34170. * @param {?} component
  34171. * @return {?}
  34172. */
  34173. function (component) {
  34174. var /** @type {?} */ summary = this._metadataResolver.getDirectiveSummary(component);
  34175. return /** @type {?} */ (summary.componentFactory);
  34176. };
  34177. /**
  34178. * @param {?} summaries
  34179. * @return {?}
  34180. */
  34181. JitCompiler.prototype.loadAotSummaries = /**
  34182. * @param {?} summaries
  34183. * @return {?}
  34184. */
  34185. function (summaries) {
  34186. this.clearCache();
  34187. this._addAotSummaries(summaries);
  34188. };
  34189. /**
  34190. * @param {?} fn
  34191. * @return {?}
  34192. */
  34193. JitCompiler.prototype._addAotSummaries = /**
  34194. * @param {?} fn
  34195. * @return {?}
  34196. */
  34197. function (fn$$1) {
  34198. if (this._addedAotSummaries.has(fn$$1)) {
  34199. return;
  34200. }
  34201. this._addedAotSummaries.add(fn$$1);
  34202. var /** @type {?} */ summaries = fn$$1();
  34203. for (var /** @type {?} */ i = 0; i < summaries.length; i++) {
  34204. var /** @type {?} */ entry = summaries[i];
  34205. if (typeof entry === 'function') {
  34206. this._addAotSummaries(entry);
  34207. }
  34208. else {
  34209. var /** @type {?} */ summary = /** @type {?} */ (entry);
  34210. this._summaryResolver.addSummary({ symbol: summary.type.reference, metadata: null, type: summary });
  34211. }
  34212. }
  34213. };
  34214. /**
  34215. * @param {?} ref
  34216. * @return {?}
  34217. */
  34218. JitCompiler.prototype.hasAotSummary = /**
  34219. * @param {?} ref
  34220. * @return {?}
  34221. */
  34222. function (ref) { return !!this._summaryResolver.resolveSummary(ref); };
  34223. /**
  34224. * @param {?} ids
  34225. * @return {?}
  34226. */
  34227. JitCompiler.prototype._filterJitIdentifiers = /**
  34228. * @param {?} ids
  34229. * @return {?}
  34230. */
  34231. function (ids) {
  34232. var _this = this;
  34233. return ids.map(function (mod) { return mod.reference; }).filter(function (ref) { return !_this.hasAotSummary(ref); });
  34234. };
  34235. /**
  34236. * @param {?} moduleType
  34237. * @param {?} isSync
  34238. * @return {?}
  34239. */
  34240. JitCompiler.prototype._compileModuleAndComponents = /**
  34241. * @param {?} moduleType
  34242. * @param {?} isSync
  34243. * @return {?}
  34244. */
  34245. function (moduleType, isSync) {
  34246. var _this = this;
  34247. return SyncAsync.then(this._loadModules(moduleType, isSync), function () {
  34248. _this._compileComponents(moduleType, null);
  34249. return _this._compileModule(moduleType);
  34250. });
  34251. };
  34252. /**
  34253. * @param {?} moduleType
  34254. * @param {?} isSync
  34255. * @return {?}
  34256. */
  34257. JitCompiler.prototype._compileModuleAndAllComponents = /**
  34258. * @param {?} moduleType
  34259. * @param {?} isSync
  34260. * @return {?}
  34261. */
  34262. function (moduleType, isSync) {
  34263. var _this = this;
  34264. return SyncAsync.then(this._loadModules(moduleType, isSync), function () {
  34265. var /** @type {?} */ componentFactories = [];
  34266. _this._compileComponents(moduleType, componentFactories);
  34267. return {
  34268. ngModuleFactory: _this._compileModule(moduleType),
  34269. componentFactories: componentFactories
  34270. };
  34271. });
  34272. };
  34273. /**
  34274. * @param {?} mainModule
  34275. * @param {?} isSync
  34276. * @return {?}
  34277. */
  34278. JitCompiler.prototype._loadModules = /**
  34279. * @param {?} mainModule
  34280. * @param {?} isSync
  34281. * @return {?}
  34282. */
  34283. function (mainModule, isSync) {
  34284. var _this = this;
  34285. var /** @type {?} */ loading = [];
  34286. var /** @type {?} */ mainNgModule = /** @type {?} */ ((this._metadataResolver.getNgModuleMetadata(mainModule)));
  34287. // Note: for runtime compilation, we want to transitively compile all modules,
  34288. // so we also need to load the declared directives / pipes for all nested modules.
  34289. this._filterJitIdentifiers(mainNgModule.transitiveModule.modules).forEach(function (nestedNgModule) {
  34290. // getNgModuleMetadata only returns null if the value passed in is not an NgModule
  34291. var /** @type {?} */ moduleMeta = /** @type {?} */ ((_this._metadataResolver.getNgModuleMetadata(nestedNgModule)));
  34292. _this._filterJitIdentifiers(moduleMeta.declaredDirectives).forEach(function (ref) {
  34293. var /** @type {?} */ promise = _this._metadataResolver.loadDirectiveMetadata(moduleMeta.type.reference, ref, isSync);
  34294. if (promise) {
  34295. loading.push(promise);
  34296. }
  34297. });
  34298. _this._filterJitIdentifiers(moduleMeta.declaredPipes)
  34299. .forEach(function (ref) { return _this._metadataResolver.getOrLoadPipeMetadata(ref); });
  34300. });
  34301. return SyncAsync.all(loading);
  34302. };
  34303. /**
  34304. * @param {?} moduleType
  34305. * @return {?}
  34306. */
  34307. JitCompiler.prototype._compileModule = /**
  34308. * @param {?} moduleType
  34309. * @return {?}
  34310. */
  34311. function (moduleType) {
  34312. var /** @type {?} */ ngModuleFactory = /** @type {?} */ ((this._compiledNgModuleCache.get(moduleType)));
  34313. if (!ngModuleFactory) {
  34314. var /** @type {?} */ moduleMeta = /** @type {?} */ ((this._metadataResolver.getNgModuleMetadata(moduleType)));
  34315. // Always provide a bound Compiler
  34316. var /** @type {?} */ extraProviders = this.getExtraNgModuleProviders(moduleMeta.type.reference);
  34317. var /** @type {?} */ outputCtx = createOutputContext();
  34318. var /** @type {?} */ compileResult = this._ngModuleCompiler.compile(outputCtx, moduleMeta, extraProviders);
  34319. ngModuleFactory = this._interpretOrJit(ngModuleJitUrl(moduleMeta), outputCtx.statements)[compileResult.ngModuleFactoryVar];
  34320. this._compiledNgModuleCache.set(moduleMeta.type.reference, ngModuleFactory);
  34321. }
  34322. return ngModuleFactory;
  34323. };
  34324. /**
  34325. * @internal
  34326. */
  34327. /**
  34328. * \@internal
  34329. * @param {?} mainModule
  34330. * @param {?} allComponentFactories
  34331. * @return {?}
  34332. */
  34333. JitCompiler.prototype._compileComponents = /**
  34334. * \@internal
  34335. * @param {?} mainModule
  34336. * @param {?} allComponentFactories
  34337. * @return {?}
  34338. */
  34339. function (mainModule, allComponentFactories) {
  34340. var _this = this;
  34341. var /** @type {?} */ ngModule = /** @type {?} */ ((this._metadataResolver.getNgModuleMetadata(mainModule)));
  34342. var /** @type {?} */ moduleByJitDirective = new Map();
  34343. var /** @type {?} */ templates = new Set();
  34344. var /** @type {?} */ transJitModules = this._filterJitIdentifiers(ngModule.transitiveModule.modules);
  34345. transJitModules.forEach(function (localMod) {
  34346. var /** @type {?} */ localModuleMeta = /** @type {?} */ ((_this._metadataResolver.getNgModuleMetadata(localMod)));
  34347. _this._filterJitIdentifiers(localModuleMeta.declaredDirectives).forEach(function (dirRef) {
  34348. moduleByJitDirective.set(dirRef, localModuleMeta);
  34349. var /** @type {?} */ dirMeta = _this._metadataResolver.getDirectiveMetadata(dirRef);
  34350. if (dirMeta.isComponent) {
  34351. templates.add(_this._createCompiledTemplate(dirMeta, localModuleMeta));
  34352. if (allComponentFactories) {
  34353. var /** @type {?} */ template = _this._createCompiledHostTemplate(dirMeta.type.reference, localModuleMeta);
  34354. templates.add(template);
  34355. allComponentFactories.push(/** @type {?} */ (dirMeta.componentFactory));
  34356. }
  34357. }
  34358. });
  34359. });
  34360. transJitModules.forEach(function (localMod) {
  34361. var /** @type {?} */ localModuleMeta = /** @type {?} */ ((_this._metadataResolver.getNgModuleMetadata(localMod)));
  34362. _this._filterJitIdentifiers(localModuleMeta.declaredDirectives).forEach(function (dirRef) {
  34363. var /** @type {?} */ dirMeta = _this._metadataResolver.getDirectiveMetadata(dirRef);
  34364. if (dirMeta.isComponent) {
  34365. dirMeta.entryComponents.forEach(function (entryComponentType) {
  34366. var /** @type {?} */ moduleMeta = /** @type {?} */ ((moduleByJitDirective.get(entryComponentType.componentType)));
  34367. templates.add(_this._createCompiledHostTemplate(entryComponentType.componentType, moduleMeta));
  34368. });
  34369. }
  34370. });
  34371. localModuleMeta.entryComponents.forEach(function (entryComponentType) {
  34372. if (!_this.hasAotSummary(entryComponentType.componentType.reference)) {
  34373. var /** @type {?} */ moduleMeta = /** @type {?} */ ((moduleByJitDirective.get(entryComponentType.componentType)));
  34374. templates.add(_this._createCompiledHostTemplate(entryComponentType.componentType, moduleMeta));
  34375. }
  34376. });
  34377. });
  34378. templates.forEach(function (template) { return _this._compileTemplate(template); });
  34379. };
  34380. /**
  34381. * @param {?} type
  34382. * @return {?}
  34383. */
  34384. JitCompiler.prototype.clearCacheFor = /**
  34385. * @param {?} type
  34386. * @return {?}
  34387. */
  34388. function (type) {
  34389. this._compiledNgModuleCache.delete(type);
  34390. this._metadataResolver.clearCacheFor(type);
  34391. this._compiledHostTemplateCache.delete(type);
  34392. var /** @type {?} */ compiledTemplate = this._compiledTemplateCache.get(type);
  34393. if (compiledTemplate) {
  34394. this._compiledTemplateCache.delete(type);
  34395. }
  34396. };
  34397. /**
  34398. * @return {?}
  34399. */
  34400. JitCompiler.prototype.clearCache = /**
  34401. * @return {?}
  34402. */
  34403. function () {
  34404. // Note: don't clear the _addedAotSummaries, as they don't change!
  34405. this._metadataResolver.clearCache();
  34406. this._compiledTemplateCache.clear();
  34407. this._compiledHostTemplateCache.clear();
  34408. this._compiledNgModuleCache.clear();
  34409. };
  34410. /**
  34411. * @param {?} compType
  34412. * @param {?} ngModule
  34413. * @return {?}
  34414. */
  34415. JitCompiler.prototype._createCompiledHostTemplate = /**
  34416. * @param {?} compType
  34417. * @param {?} ngModule
  34418. * @return {?}
  34419. */
  34420. function (compType, ngModule) {
  34421. if (!ngModule) {
  34422. throw new Error("Component " + stringify(compType) + " is not part of any NgModule or the module has not been imported into your module.");
  34423. }
  34424. var /** @type {?} */ compiledTemplate = this._compiledHostTemplateCache.get(compType);
  34425. if (!compiledTemplate) {
  34426. var /** @type {?} */ compMeta = this._metadataResolver.getDirectiveMetadata(compType);
  34427. assertComponent(compMeta);
  34428. var /** @type {?} */ hostMeta = this._metadataResolver.getHostComponentMetadata(compMeta, (/** @type {?} */ (compMeta.componentFactory)).viewDefFactory);
  34429. compiledTemplate =
  34430. new CompiledTemplate(true, compMeta.type, hostMeta, ngModule, [compMeta.type]);
  34431. this._compiledHostTemplateCache.set(compType, compiledTemplate);
  34432. }
  34433. return compiledTemplate;
  34434. };
  34435. /**
  34436. * @param {?} compMeta
  34437. * @param {?} ngModule
  34438. * @return {?}
  34439. */
  34440. JitCompiler.prototype._createCompiledTemplate = /**
  34441. * @param {?} compMeta
  34442. * @param {?} ngModule
  34443. * @return {?}
  34444. */
  34445. function (compMeta, ngModule) {
  34446. var /** @type {?} */ compiledTemplate = this._compiledTemplateCache.get(compMeta.type.reference);
  34447. if (!compiledTemplate) {
  34448. assertComponent(compMeta);
  34449. compiledTemplate = new CompiledTemplate(false, compMeta.type, compMeta, ngModule, ngModule.transitiveModule.directives);
  34450. this._compiledTemplateCache.set(compMeta.type.reference, compiledTemplate);
  34451. }
  34452. return compiledTemplate;
  34453. };
  34454. /**
  34455. * @param {?} template
  34456. * @return {?}
  34457. */
  34458. JitCompiler.prototype._compileTemplate = /**
  34459. * @param {?} template
  34460. * @return {?}
  34461. */
  34462. function (template) {
  34463. var _this = this;
  34464. if (template.isCompiled) {
  34465. return;
  34466. }
  34467. var /** @type {?} */ compMeta = template.compMeta;
  34468. var /** @type {?} */ externalStylesheetsByModuleUrl = new Map();
  34469. var /** @type {?} */ outputContext = createOutputContext();
  34470. var /** @type {?} */ componentStylesheet = this._styleCompiler.compileComponent(outputContext, compMeta); /** @type {?} */
  34471. ((compMeta.template)).externalStylesheets.forEach(function (stylesheetMeta) {
  34472. var /** @type {?} */ compiledStylesheet = _this._styleCompiler.compileStyles(createOutputContext(), compMeta, stylesheetMeta);
  34473. externalStylesheetsByModuleUrl.set(/** @type {?} */ ((stylesheetMeta.moduleUrl)), compiledStylesheet);
  34474. });
  34475. this._resolveStylesCompileResult(componentStylesheet, externalStylesheetsByModuleUrl);
  34476. var /** @type {?} */ pipes = template.ngModule.transitiveModule.pipes.map(function (pipe) { return _this._metadataResolver.getPipeSummary(pipe.reference); });
  34477. var _a = this._parseTemplate(compMeta, template.ngModule, template.directives), parsedTemplate = _a.template, usedPipes = _a.pipes;
  34478. var /** @type {?} */ compileResult = this._viewCompiler.compileComponent(outputContext, compMeta, parsedTemplate, variable(componentStylesheet.stylesVar), usedPipes);
  34479. var /** @type {?} */ evalResult = this._interpretOrJit(templateJitUrl(template.ngModule.type, template.compMeta), outputContext.statements);
  34480. var /** @type {?} */ viewClass = evalResult[compileResult.viewClassVar];
  34481. var /** @type {?} */ rendererType = evalResult[compileResult.rendererTypeVar];
  34482. template.compiled(viewClass, rendererType);
  34483. };
  34484. /**
  34485. * @param {?} compMeta
  34486. * @param {?} ngModule
  34487. * @param {?} directiveIdentifiers
  34488. * @return {?}
  34489. */
  34490. JitCompiler.prototype._parseTemplate = /**
  34491. * @param {?} compMeta
  34492. * @param {?} ngModule
  34493. * @param {?} directiveIdentifiers
  34494. * @return {?}
  34495. */
  34496. function (compMeta, ngModule, directiveIdentifiers) {
  34497. var _this = this;
  34498. // Note: ! is ok here as components always have a template.
  34499. var /** @type {?} */ preserveWhitespaces = /** @type {?} */ ((compMeta.template)).preserveWhitespaces;
  34500. var /** @type {?} */ directives = directiveIdentifiers.map(function (dir) { return _this._metadataResolver.getDirectiveSummary(dir.reference); });
  34501. var /** @type {?} */ pipes = ngModule.transitiveModule.pipes.map(function (pipe) { return _this._metadataResolver.getPipeSummary(pipe.reference); });
  34502. return this._templateParser.parse(compMeta, /** @type {?} */ ((/** @type {?} */ ((compMeta.template)).htmlAst)), directives, pipes, ngModule.schemas, templateSourceUrl(ngModule.type, compMeta, /** @type {?} */ ((compMeta.template))), preserveWhitespaces);
  34503. };
  34504. /**
  34505. * @param {?} result
  34506. * @param {?} externalStylesheetsByModuleUrl
  34507. * @return {?}
  34508. */
  34509. JitCompiler.prototype._resolveStylesCompileResult = /**
  34510. * @param {?} result
  34511. * @param {?} externalStylesheetsByModuleUrl
  34512. * @return {?}
  34513. */
  34514. function (result, externalStylesheetsByModuleUrl) {
  34515. var _this = this;
  34516. result.dependencies.forEach(function (dep, i) {
  34517. var /** @type {?} */ nestedCompileResult = /** @type {?} */ ((externalStylesheetsByModuleUrl.get(dep.moduleUrl)));
  34518. var /** @type {?} */ nestedStylesArr = _this._resolveAndEvalStylesCompileResult(nestedCompileResult, externalStylesheetsByModuleUrl);
  34519. dep.setValue(nestedStylesArr);
  34520. });
  34521. };
  34522. /**
  34523. * @param {?} result
  34524. * @param {?} externalStylesheetsByModuleUrl
  34525. * @return {?}
  34526. */
  34527. JitCompiler.prototype._resolveAndEvalStylesCompileResult = /**
  34528. * @param {?} result
  34529. * @param {?} externalStylesheetsByModuleUrl
  34530. * @return {?}
  34531. */
  34532. function (result, externalStylesheetsByModuleUrl) {
  34533. this._resolveStylesCompileResult(result, externalStylesheetsByModuleUrl);
  34534. return this._interpretOrJit(sharedStylesheetJitUrl(result.meta, this._sharedStylesheetCount++), result.outputCtx.statements)[result.stylesVar];
  34535. };
  34536. /**
  34537. * @param {?} sourceUrl
  34538. * @param {?} statements
  34539. * @return {?}
  34540. */
  34541. JitCompiler.prototype._interpretOrJit = /**
  34542. * @param {?} sourceUrl
  34543. * @param {?} statements
  34544. * @return {?}
  34545. */
  34546. function (sourceUrl, statements) {
  34547. if (!this._compilerConfig.useJit) {
  34548. return interpretStatements(statements, this._reflector);
  34549. }
  34550. else {
  34551. return jitStatements(sourceUrl, statements, this._reflector, this._compilerConfig.jitDevMode);
  34552. }
  34553. };
  34554. return JitCompiler;
  34555. }());
  34556. var CompiledTemplate = /** @class */ (function () {
  34557. function CompiledTemplate(isHost, compType, compMeta, ngModule, directives) {
  34558. this.isHost = isHost;
  34559. this.compType = compType;
  34560. this.compMeta = compMeta;
  34561. this.ngModule = ngModule;
  34562. this.directives = directives;
  34563. this._viewClass = /** @type {?} */ ((null));
  34564. this.isCompiled = false;
  34565. }
  34566. /**
  34567. * @param {?} viewClass
  34568. * @param {?} rendererType
  34569. * @return {?}
  34570. */
  34571. CompiledTemplate.prototype.compiled = /**
  34572. * @param {?} viewClass
  34573. * @param {?} rendererType
  34574. * @return {?}
  34575. */
  34576. function (viewClass, rendererType) {
  34577. this._viewClass = viewClass;
  34578. (/** @type {?} */ (this.compMeta.componentViewType)).setDelegate(viewClass);
  34579. for (var /** @type {?} */ prop in rendererType) {
  34580. (/** @type {?} */ (this.compMeta.rendererType))[prop] = rendererType[prop];
  34581. }
  34582. this.isCompiled = true;
  34583. };
  34584. return CompiledTemplate;
  34585. }());
  34586. /**
  34587. * @param {?} meta
  34588. * @return {?}
  34589. */
  34590. function assertComponent(meta) {
  34591. if (!meta.isComponent) {
  34592. throw new Error("Could not compile '" + identifierName(meta.type) + "' because it is not a component.");
  34593. }
  34594. }
  34595. /**
  34596. * @return {?}
  34597. */
  34598. function createOutputContext() {
  34599. var /** @type {?} */ importExpr$$1 = function (symbol) {
  34600. return importExpr({ name: identifierName(symbol), moduleName: null, runtime: symbol });
  34601. };
  34602. return { statements: [], genFilePath: '', importExpr: importExpr$$1 };
  34603. }
  34604. /**
  34605. * @fileoverview added by tsickle
  34606. * @suppress {checkTypes} checked by tsc
  34607. */
  34608. /**
  34609. * @license
  34610. * Copyright Google Inc. All Rights Reserved.
  34611. *
  34612. * Use of this source code is governed by an MIT-style license that can be
  34613. * found in the LICENSE file at https://angular.io/license
  34614. */
  34615. /**
  34616. * Provides access to reflection data about symbols that the compiler needs.
  34617. * @abstract
  34618. */
  34619. var CompileReflector = /** @class */ (function () {
  34620. function CompileReflector() {
  34621. }
  34622. return CompileReflector;
  34623. }());
  34624. /**
  34625. * @fileoverview added by tsickle
  34626. * @suppress {checkTypes} checked by tsc
  34627. */
  34628. /**
  34629. * @license
  34630. * Copyright Google Inc. All Rights Reserved.
  34631. *
  34632. * Use of this source code is governed by an MIT-style license that can be
  34633. * found in the LICENSE file at https://angular.io/license
  34634. */
  34635. /**
  34636. * Create a {\@link UrlResolver} with no package prefix.
  34637. * @return {?}
  34638. */
  34639. function createUrlResolverWithoutPackagePrefix() {
  34640. return new UrlResolver();
  34641. }
  34642. /**
  34643. * @return {?}
  34644. */
  34645. function createOfflineCompileUrlResolver() {
  34646. return new UrlResolver('.');
  34647. }
  34648. /**
  34649. * @record
  34650. */
  34651. var UrlResolver = /** @class */ (function () {
  34652. function UrlResolverImpl(_packagePrefix) {
  34653. if (_packagePrefix === void 0) { _packagePrefix = null; }
  34654. this._packagePrefix = _packagePrefix;
  34655. }
  34656. /**
  34657. * Resolves the `url` given the `baseUrl`:
  34658. * - when the `url` is null, the `baseUrl` is returned,
  34659. * - if `url` is relative ('path/to/here', './path/to/here'), the resolved url is a combination of
  34660. * `baseUrl` and `url`,
  34661. * - if `url` is absolute (it has a scheme: 'http://', 'https://' or start with '/'), the `url` is
  34662. * returned as is (ignoring the `baseUrl`)
  34663. */
  34664. /**
  34665. * Resolves the `url` given the `baseUrl`:
  34666. * - when the `url` is null, the `baseUrl` is returned,
  34667. * - if `url` is relative ('path/to/here', './path/to/here'), the resolved url is a combination of
  34668. * `baseUrl` and `url`,
  34669. * - if `url` is absolute (it has a scheme: 'http://', 'https://' or start with '/'), the `url` is
  34670. * returned as is (ignoring the `baseUrl`)
  34671. * @param {?} baseUrl
  34672. * @param {?} url
  34673. * @return {?}
  34674. */
  34675. UrlResolverImpl.prototype.resolve = /**
  34676. * Resolves the `url` given the `baseUrl`:
  34677. * - when the `url` is null, the `baseUrl` is returned,
  34678. * - if `url` is relative ('path/to/here', './path/to/here'), the resolved url is a combination of
  34679. * `baseUrl` and `url`,
  34680. * - if `url` is absolute (it has a scheme: 'http://', 'https://' or start with '/'), the `url` is
  34681. * returned as is (ignoring the `baseUrl`)
  34682. * @param {?} baseUrl
  34683. * @param {?} url
  34684. * @return {?}
  34685. */
  34686. function (baseUrl, url) {
  34687. var /** @type {?} */ resolvedUrl = url;
  34688. if (baseUrl != null && baseUrl.length > 0) {
  34689. resolvedUrl = _resolveUrl(baseUrl, resolvedUrl);
  34690. }
  34691. var /** @type {?} */ resolvedParts = _split(resolvedUrl);
  34692. var /** @type {?} */ prefix = this._packagePrefix;
  34693. if (prefix != null && resolvedParts != null &&
  34694. resolvedParts[_ComponentIndex.Scheme] == 'package') {
  34695. var /** @type {?} */ path = resolvedParts[_ComponentIndex.Path];
  34696. prefix = prefix.replace(/\/+$/, '');
  34697. path = path.replace(/^\/+/, '');
  34698. return prefix + "/" + path;
  34699. }
  34700. return resolvedUrl;
  34701. };
  34702. return UrlResolverImpl;
  34703. }());
  34704. /**
  34705. * Extract the scheme of a URL.
  34706. * @param {?} url
  34707. * @return {?}
  34708. */
  34709. function getUrlScheme(url) {
  34710. var /** @type {?} */ match = _split(url);
  34711. return (match && match[_ComponentIndex.Scheme]) || '';
  34712. }
  34713. /**
  34714. * Builds a URI string from already-encoded parts.
  34715. *
  34716. * No encoding is performed. Any component may be omitted as either null or
  34717. * undefined.
  34718. *
  34719. * @param {?=} opt_scheme The scheme such as 'http'.
  34720. * @param {?=} opt_userInfo The user name before the '\@'.
  34721. * @param {?=} opt_domain The domain such as 'www.google.com', already
  34722. * URI-encoded.
  34723. * @param {?=} opt_port The port number.
  34724. * @param {?=} opt_path The path, already URI-encoded. If it is not
  34725. * empty, it must begin with a slash.
  34726. * @param {?=} opt_queryData The URI-encoded query data.
  34727. * @param {?=} opt_fragment The URI-encoded fragment identifier.
  34728. * @return {?} The fully combined URI.
  34729. */
  34730. function _buildFromEncodedParts(opt_scheme, opt_userInfo, opt_domain, opt_port, opt_path, opt_queryData, opt_fragment) {
  34731. var /** @type {?} */ out = [];
  34732. if (opt_scheme != null) {
  34733. out.push(opt_scheme + ':');
  34734. }
  34735. if (opt_domain != null) {
  34736. out.push('//');
  34737. if (opt_userInfo != null) {
  34738. out.push(opt_userInfo + '@');
  34739. }
  34740. out.push(opt_domain);
  34741. if (opt_port != null) {
  34742. out.push(':' + opt_port);
  34743. }
  34744. }
  34745. if (opt_path != null) {
  34746. out.push(opt_path);
  34747. }
  34748. if (opt_queryData != null) {
  34749. out.push('?' + opt_queryData);
  34750. }
  34751. if (opt_fragment != null) {
  34752. out.push('#' + opt_fragment);
  34753. }
  34754. return out.join('');
  34755. }
  34756. /**
  34757. * A regular expression for breaking a URI into its component parts.
  34758. *
  34759. * {\@link http://www.gbiv.com/protocols/uri/rfc/rfc3986.html#RFC2234} says
  34760. * As the "first-match-wins" algorithm is identical to the "greedy"
  34761. * disambiguation method used by POSIX regular expressions, it is natural and
  34762. * commonplace to use a regular expression for parsing the potential five
  34763. * components of a URI reference.
  34764. *
  34765. * The following line is the regular expression for breaking-down a
  34766. * well-formed URI reference into its components.
  34767. *
  34768. * <pre>
  34769. * ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
  34770. * 12 3 4 5 6 7 8 9
  34771. * </pre>
  34772. *
  34773. * The numbers in the second line above are only to assist readability; they
  34774. * indicate the reference points for each subexpression (i.e., each paired
  34775. * parenthesis). We refer to the value matched for subexpression <n> as $<n>.
  34776. * For example, matching the above expression to
  34777. * <pre>
  34778. * http://www.ics.uci.edu/pub/ietf/uri/#Related
  34779. * </pre>
  34780. * results in the following subexpression matches:
  34781. * <pre>
  34782. * $1 = http:
  34783. * $2 = http
  34784. * $3 = //www.ics.uci.edu
  34785. * $4 = www.ics.uci.edu
  34786. * $5 = /pub/ietf/uri/
  34787. * $6 = <undefined>
  34788. * $7 = <undefined>
  34789. * $8 = #Related
  34790. * $9 = Related
  34791. * </pre>
  34792. * where <undefined> indicates that the component is not present, as is the
  34793. * case for the query component in the above example. Therefore, we can
  34794. * determine the value of the five components as
  34795. * <pre>
  34796. * scheme = $2
  34797. * authority = $4
  34798. * path = $5
  34799. * query = $7
  34800. * fragment = $9
  34801. * </pre>
  34802. *
  34803. * The regular expression has been modified slightly to expose the
  34804. * userInfo, domain, and port separately from the authority.
  34805. * The modified version yields
  34806. * <pre>
  34807. * $1 = http scheme
  34808. * $2 = <undefined> userInfo -\
  34809. * $3 = www.ics.uci.edu domain | authority
  34810. * $4 = <undefined> port -/
  34811. * $5 = /pub/ietf/uri/ path
  34812. * $6 = <undefined> query without ?
  34813. * $7 = Related fragment without #
  34814. * </pre>
  34815. * \@internal
  34816. */
  34817. var _splitRe = new RegExp('^' +
  34818. '(?:' +
  34819. '([^:/?#.]+)' + // scheme - ignore special characters
  34820. ':)?' +
  34821. '(?://' +
  34822. '(?:([^/?#]*)@)?' + // userInfo
  34823. '([\\w\\d\\-\\u0100-\\uffff.%]*)' + // domain - restrict to letters,
  34824. '(?::([0-9]+))?' + // port
  34825. ')?' +
  34826. '([^?#]+)?' + // path
  34827. '(?:\\?([^#]*))?' + // query
  34828. '(?:#(.*))?' + // fragment
  34829. '$');
  34830. /** @enum {number} */
  34831. var _ComponentIndex = {
  34832. Scheme: 1,
  34833. UserInfo: 2,
  34834. Domain: 3,
  34835. Port: 4,
  34836. Path: 5,
  34837. QueryData: 6,
  34838. Fragment: 7,
  34839. };
  34840. _ComponentIndex[_ComponentIndex.Scheme] = "Scheme";
  34841. _ComponentIndex[_ComponentIndex.UserInfo] = "UserInfo";
  34842. _ComponentIndex[_ComponentIndex.Domain] = "Domain";
  34843. _ComponentIndex[_ComponentIndex.Port] = "Port";
  34844. _ComponentIndex[_ComponentIndex.Path] = "Path";
  34845. _ComponentIndex[_ComponentIndex.QueryData] = "QueryData";
  34846. _ComponentIndex[_ComponentIndex.Fragment] = "Fragment";
  34847. /**
  34848. * Splits a URI into its component parts.
  34849. *
  34850. * Each component can be accessed via the component indices; for example:
  34851. * <pre>
  34852. * goog.uri.utils.split(someStr)[goog.uri.utils.CompontentIndex.QUERY_DATA];
  34853. * </pre>
  34854. *
  34855. * @param {?} uri The URI string to examine.
  34856. * @return {?} Each component still URI-encoded.
  34857. * Each component that is present will contain the encoded value, whereas
  34858. * components that are not present will be undefined or empty, depending
  34859. * on the browser's regular expression implementation. Never null, since
  34860. * arbitrary strings may still look like path names.
  34861. */
  34862. function _split(uri) {
  34863. return /** @type {?} */ ((uri.match(_splitRe)));
  34864. }
  34865. /**
  34866. * Removes dot segments in given path component, as described in
  34867. * RFC 3986, section 5.2.4.
  34868. *
  34869. * @param {?} path A non-empty path component.
  34870. * @return {?} Path component with removed dot segments.
  34871. */
  34872. function _removeDotSegments(path) {
  34873. if (path == '/')
  34874. return '/';
  34875. var /** @type {?} */ leadingSlash = path[0] == '/' ? '/' : '';
  34876. var /** @type {?} */ trailingSlash = path[path.length - 1] === '/' ? '/' : '';
  34877. var /** @type {?} */ segments = path.split('/');
  34878. var /** @type {?} */ out = [];
  34879. var /** @type {?} */ up = 0;
  34880. for (var /** @type {?} */ pos = 0; pos < segments.length; pos++) {
  34881. var /** @type {?} */ segment = segments[pos];
  34882. switch (segment) {
  34883. case '':
  34884. case '.':
  34885. break;
  34886. case '..':
  34887. if (out.length > 0) {
  34888. out.pop();
  34889. }
  34890. else {
  34891. up++;
  34892. }
  34893. break;
  34894. default:
  34895. out.push(segment);
  34896. }
  34897. }
  34898. if (leadingSlash == '') {
  34899. while (up-- > 0) {
  34900. out.unshift('..');
  34901. }
  34902. if (out.length === 0)
  34903. out.push('.');
  34904. }
  34905. return leadingSlash + out.join('/') + trailingSlash;
  34906. }
  34907. /**
  34908. * Takes an array of the parts from split and canonicalizes the path part
  34909. * and then joins all the parts.
  34910. * @param {?} parts
  34911. * @return {?}
  34912. */
  34913. function _joinAndCanonicalizePath(parts) {
  34914. var /** @type {?} */ path = parts[_ComponentIndex.Path];
  34915. path = path == null ? '' : _removeDotSegments(path);
  34916. parts[_ComponentIndex.Path] = path;
  34917. return _buildFromEncodedParts(parts[_ComponentIndex.Scheme], parts[_ComponentIndex.UserInfo], parts[_ComponentIndex.Domain], parts[_ComponentIndex.Port], path, parts[_ComponentIndex.QueryData], parts[_ComponentIndex.Fragment]);
  34918. }
  34919. /**
  34920. * Resolves a URL.
  34921. * @param {?} base The URL acting as the base URL.
  34922. * @param {?} url
  34923. * @return {?}
  34924. */
  34925. function _resolveUrl(base, url) {
  34926. var /** @type {?} */ parts = _split(encodeURI(url));
  34927. var /** @type {?} */ baseParts = _split(base);
  34928. if (parts[_ComponentIndex.Scheme] != null) {
  34929. return _joinAndCanonicalizePath(parts);
  34930. }
  34931. else {
  34932. parts[_ComponentIndex.Scheme] = baseParts[_ComponentIndex.Scheme];
  34933. }
  34934. for (var /** @type {?} */ i = _ComponentIndex.Scheme; i <= _ComponentIndex.Port; i++) {
  34935. if (parts[i] == null) {
  34936. parts[i] = baseParts[i];
  34937. }
  34938. }
  34939. if (parts[_ComponentIndex.Path][0] == '/') {
  34940. return _joinAndCanonicalizePath(parts);
  34941. }
  34942. var /** @type {?} */ path = baseParts[_ComponentIndex.Path];
  34943. if (path == null)
  34944. path = '/';
  34945. var /** @type {?} */ index = path.lastIndexOf('/');
  34946. path = path.substring(0, index + 1) + parts[_ComponentIndex.Path];
  34947. parts[_ComponentIndex.Path] = path;
  34948. return _joinAndCanonicalizePath(parts);
  34949. }
  34950. /**
  34951. * @fileoverview added by tsickle
  34952. * @suppress {checkTypes} checked by tsc
  34953. */
  34954. /**
  34955. * @license
  34956. * Copyright Google Inc. All Rights Reserved.
  34957. *
  34958. * Use of this source code is governed by an MIT-style license that can be
  34959. * found in the LICENSE file at https://angular.io/license
  34960. */
  34961. /**
  34962. * An interface for retrieving documents by URL that the compiler uses
  34963. * to load templates.
  34964. */
  34965. var ResourceLoader = /** @class */ (function () {
  34966. function ResourceLoader() {
  34967. }
  34968. /**
  34969. * @param {?} url
  34970. * @return {?}
  34971. */
  34972. ResourceLoader.prototype.get = /**
  34973. * @param {?} url
  34974. * @return {?}
  34975. */
  34976. function (url) { return ''; };
  34977. return ResourceLoader;
  34978. }());
  34979. /**
  34980. * @fileoverview added by tsickle
  34981. * @suppress {checkTypes} checked by tsc
  34982. */
  34983. /**
  34984. * @license
  34985. * Copyright Google Inc. All Rights Reserved.
  34986. *
  34987. * Use of this source code is governed by an MIT-style license that can be
  34988. * found in the LICENSE file at https://angular.io/license
  34989. */
  34990. /**
  34991. * The host of the Extractor disconnects the implementation from TypeScript / other language
  34992. * services and from underlying file systems.
  34993. * @record
  34994. */
  34995. var Extractor = /** @class */ (function () {
  34996. function Extractor(host, staticSymbolResolver, messageBundle, metadataResolver) {
  34997. this.host = host;
  34998. this.staticSymbolResolver = staticSymbolResolver;
  34999. this.messageBundle = messageBundle;
  35000. this.metadataResolver = metadataResolver;
  35001. }
  35002. /**
  35003. * @param {?} rootFiles
  35004. * @return {?}
  35005. */
  35006. Extractor.prototype.extract = /**
  35007. * @param {?} rootFiles
  35008. * @return {?}
  35009. */
  35010. function (rootFiles) {
  35011. var _this = this;
  35012. var _a = analyzeAndValidateNgModules(rootFiles, this.host, this.staticSymbolResolver, this.metadataResolver), files = _a.files, ngModules = _a.ngModules;
  35013. return Promise
  35014. .all(ngModules.map(function (ngModule) {
  35015. return _this.metadataResolver.loadNgModuleDirectiveAndPipeMetadata(ngModule.type.reference, false);
  35016. }))
  35017. .then(function () {
  35018. var /** @type {?} */ errors = [];
  35019. files.forEach(function (file) {
  35020. var /** @type {?} */ compMetas = [];
  35021. file.directives.forEach(function (directiveType) {
  35022. var /** @type {?} */ dirMeta = _this.metadataResolver.getDirectiveMetadata(directiveType);
  35023. if (dirMeta && dirMeta.isComponent) {
  35024. compMetas.push(dirMeta);
  35025. }
  35026. });
  35027. compMetas.forEach(function (compMeta) {
  35028. var /** @type {?} */ html = /** @type {?} */ ((/** @type {?} */ ((compMeta.template)).template));
  35029. var /** @type {?} */ interpolationConfig = InterpolationConfig.fromArray(/** @type {?} */ ((compMeta.template)).interpolation);
  35030. errors.push.apply(errors, /** @type {?} */ ((_this.messageBundle.updateFromTemplate(html, file.fileName, interpolationConfig))));
  35031. });
  35032. });
  35033. if (errors.length) {
  35034. throw new Error(errors.map(function (e) { return e.toString(); }).join('\n'));
  35035. }
  35036. return _this.messageBundle;
  35037. });
  35038. };
  35039. /**
  35040. * @param {?} host
  35041. * @param {?} locale
  35042. * @return {?}
  35043. */
  35044. Extractor.create = /**
  35045. * @param {?} host
  35046. * @param {?} locale
  35047. * @return {?}
  35048. */
  35049. function (host, locale) {
  35050. var /** @type {?} */ htmlParser = new HtmlParser();
  35051. var /** @type {?} */ urlResolver = createAotUrlResolver(host);
  35052. var /** @type {?} */ symbolCache = new StaticSymbolCache();
  35053. var /** @type {?} */ summaryResolver = new AotSummaryResolver(host, symbolCache);
  35054. var /** @type {?} */ staticSymbolResolver = new StaticSymbolResolver(host, symbolCache, summaryResolver);
  35055. var /** @type {?} */ staticReflector = new StaticReflector(summaryResolver, staticSymbolResolver);
  35056. var /** @type {?} */ config = new CompilerConfig({ defaultEncapsulation: ViewEncapsulation.Emulated, useJit: false });
  35057. var /** @type {?} */ normalizer = new DirectiveNormalizer({ get: function (url) { return host.loadResource(url); } }, urlResolver, htmlParser, config);
  35058. var /** @type {?} */ elementSchemaRegistry = new DomElementSchemaRegistry();
  35059. var /** @type {?} */ resolver = new CompileMetadataResolver(config, htmlParser, new NgModuleResolver(staticReflector), new DirectiveResolver(staticReflector), new PipeResolver(staticReflector), summaryResolver, elementSchemaRegistry, normalizer, console, symbolCache, staticReflector);
  35060. // TODO(vicb): implicit tags & attributes
  35061. var /** @type {?} */ messageBundle = new MessageBundle(htmlParser, [], {}, locale);
  35062. var /** @type {?} */ extractor = new Extractor(host, staticSymbolResolver, messageBundle, resolver);
  35063. return { extractor: extractor, staticReflector: staticReflector };
  35064. };
  35065. return Extractor;
  35066. }());
  35067. exports.core = core;
  35068. exports.CompilerConfig = CompilerConfig;
  35069. exports.preserveWhitespacesDefault = preserveWhitespacesDefault;
  35070. exports.isLoweredSymbol = isLoweredSymbol;
  35071. exports.createLoweredSymbol = createLoweredSymbol;
  35072. exports.Identifiers = Identifiers;
  35073. exports.JitCompiler = JitCompiler;
  35074. exports.DirectiveResolver = DirectiveResolver;
  35075. exports.PipeResolver = PipeResolver;
  35076. exports.NgModuleResolver = NgModuleResolver;
  35077. exports.DEFAULT_INTERPOLATION_CONFIG = DEFAULT_INTERPOLATION_CONFIG;
  35078. exports.InterpolationConfig = InterpolationConfig;
  35079. exports.NgModuleCompiler = NgModuleCompiler;
  35080. exports.AssertNotNull = AssertNotNull;
  35081. exports.BinaryOperator = BinaryOperator;
  35082. exports.BinaryOperatorExpr = BinaryOperatorExpr;
  35083. exports.BuiltinMethod = BuiltinMethod;
  35084. exports.BuiltinVar = BuiltinVar;
  35085. exports.CastExpr = CastExpr;
  35086. exports.ClassStmt = ClassStmt;
  35087. exports.CommaExpr = CommaExpr;
  35088. exports.CommentStmt = CommentStmt;
  35089. exports.ConditionalExpr = ConditionalExpr;
  35090. exports.DeclareFunctionStmt = DeclareFunctionStmt;
  35091. exports.DeclareVarStmt = DeclareVarStmt;
  35092. exports.ExpressionStatement = ExpressionStatement;
  35093. exports.ExternalExpr = ExternalExpr;
  35094. exports.ExternalReference = ExternalReference;
  35095. exports.FunctionExpr = FunctionExpr;
  35096. exports.IfStmt = IfStmt;
  35097. exports.InstantiateExpr = InstantiateExpr;
  35098. exports.InvokeFunctionExpr = InvokeFunctionExpr;
  35099. exports.InvokeMethodExpr = InvokeMethodExpr;
  35100. exports.LiteralArrayExpr = LiteralArrayExpr;
  35101. exports.LiteralExpr = LiteralExpr;
  35102. exports.LiteralMapExpr = LiteralMapExpr;
  35103. exports.NotExpr = NotExpr;
  35104. exports.ReadKeyExpr = ReadKeyExpr;
  35105. exports.ReadPropExpr = ReadPropExpr;
  35106. exports.ReadVarExpr = ReadVarExpr;
  35107. exports.ReturnStatement = ReturnStatement;
  35108. exports.ThrowStmt = ThrowStmt;
  35109. exports.TryCatchStmt = TryCatchStmt;
  35110. exports.WriteKeyExpr = WriteKeyExpr;
  35111. exports.WritePropExpr = WritePropExpr;
  35112. exports.WriteVarExpr = WriteVarExpr;
  35113. exports.StmtModifier = StmtModifier;
  35114. exports.Statement = Statement;
  35115. exports.collectExternalReferences = collectExternalReferences;
  35116. exports.EmitterVisitorContext = EmitterVisitorContext;
  35117. exports.ViewCompiler = ViewCompiler;
  35118. exports.getParseErrors = getParseErrors;
  35119. exports.isSyntaxError = isSyntaxError;
  35120. exports.syntaxError = syntaxError;
  35121. exports.Version = Version;
  35122. exports.VERSION = VERSION;
  35123. exports.TextAst = TextAst;
  35124. exports.BoundTextAst = BoundTextAst;
  35125. exports.AttrAst = AttrAst;
  35126. exports.BoundElementPropertyAst = BoundElementPropertyAst;
  35127. exports.BoundEventAst = BoundEventAst;
  35128. exports.ReferenceAst = ReferenceAst;
  35129. exports.VariableAst = VariableAst;
  35130. exports.ElementAst = ElementAst;
  35131. exports.EmbeddedTemplateAst = EmbeddedTemplateAst;
  35132. exports.BoundDirectivePropertyAst = BoundDirectivePropertyAst;
  35133. exports.DirectiveAst = DirectiveAst;
  35134. exports.ProviderAst = ProviderAst;
  35135. exports.ProviderAstType = ProviderAstType;
  35136. exports.NgContentAst = NgContentAst;
  35137. exports.PropertyBindingType = PropertyBindingType;
  35138. exports.NullTemplateVisitor = NullTemplateVisitor;
  35139. exports.RecursiveTemplateAstVisitor = RecursiveTemplateAstVisitor;
  35140. exports.templateVisitAll = templateVisitAll;
  35141. exports.identifierName = identifierName;
  35142. exports.identifierModuleUrl = identifierModuleUrl;
  35143. exports.viewClassName = viewClassName;
  35144. exports.rendererTypeName = rendererTypeName;
  35145. exports.hostViewClassName = hostViewClassName;
  35146. exports.componentFactoryName = componentFactoryName;
  35147. exports.CompileSummaryKind = CompileSummaryKind;
  35148. exports.tokenName = tokenName;
  35149. exports.tokenReference = tokenReference;
  35150. exports.CompileStylesheetMetadata = CompileStylesheetMetadata;
  35151. exports.CompileTemplateMetadata = CompileTemplateMetadata;
  35152. exports.CompileDirectiveMetadata = CompileDirectiveMetadata;
  35153. exports.CompilePipeMetadata = CompilePipeMetadata;
  35154. exports.CompileNgModuleMetadata = CompileNgModuleMetadata;
  35155. exports.TransitiveCompileNgModuleMetadata = TransitiveCompileNgModuleMetadata;
  35156. exports.ProviderMeta = ProviderMeta;
  35157. exports.flatten = flatten;
  35158. exports.templateSourceUrl = templateSourceUrl;
  35159. exports.sharedStylesheetJitUrl = sharedStylesheetJitUrl;
  35160. exports.ngModuleJitUrl = ngModuleJitUrl;
  35161. exports.templateJitUrl = templateJitUrl;
  35162. exports.createAotUrlResolver = createAotUrlResolver;
  35163. exports.createAotCompiler = createAotCompiler;
  35164. exports.AotCompiler = AotCompiler;
  35165. exports.analyzeNgModules = analyzeNgModules;
  35166. exports.analyzeAndValidateNgModules = analyzeAndValidateNgModules;
  35167. exports.analyzeFile = analyzeFile;
  35168. exports.mergeAnalyzedFiles = mergeAnalyzedFiles;
  35169. exports.GeneratedFile = GeneratedFile;
  35170. exports.toTypeScript = toTypeScript;
  35171. exports.formattedError = formattedError;
  35172. exports.isFormattedError = isFormattedError;
  35173. exports.StaticReflector = StaticReflector;
  35174. exports.StaticSymbol = StaticSymbol;
  35175. exports.StaticSymbolCache = StaticSymbolCache;
  35176. exports.ResolvedStaticSymbol = ResolvedStaticSymbol;
  35177. exports.StaticSymbolResolver = StaticSymbolResolver;
  35178. exports.unescapeIdentifier = unescapeIdentifier;
  35179. exports.unwrapResolvedMetadata = unwrapResolvedMetadata;
  35180. exports.AotSummaryResolver = AotSummaryResolver;
  35181. exports.AstPath = AstPath;
  35182. exports.SummaryResolver = SummaryResolver;
  35183. exports.JitSummaryResolver = JitSummaryResolver;
  35184. exports.CompileReflector = CompileReflector;
  35185. exports.createUrlResolverWithoutPackagePrefix = createUrlResolverWithoutPackagePrefix;
  35186. exports.createOfflineCompileUrlResolver = createOfflineCompileUrlResolver;
  35187. exports.UrlResolver = UrlResolver;
  35188. exports.getUrlScheme = getUrlScheme;
  35189. exports.ResourceLoader = ResourceLoader;
  35190. exports.ElementSchemaRegistry = ElementSchemaRegistry;
  35191. exports.Extractor = Extractor;
  35192. exports.I18NHtmlParser = I18NHtmlParser;
  35193. exports.MessageBundle = MessageBundle;
  35194. exports.Serializer = Serializer;
  35195. exports.Xliff = Xliff;
  35196. exports.Xliff2 = Xliff2;
  35197. exports.Xmb = Xmb;
  35198. exports.Xtb = Xtb;
  35199. exports.DirectiveNormalizer = DirectiveNormalizer;
  35200. exports.ParserError = ParserError;
  35201. exports.ParseSpan = ParseSpan;
  35202. exports.AST = AST;
  35203. exports.Quote = Quote;
  35204. exports.EmptyExpr = EmptyExpr;
  35205. exports.ImplicitReceiver = ImplicitReceiver;
  35206. exports.Chain = Chain;
  35207. exports.Conditional = Conditional;
  35208. exports.PropertyRead = PropertyRead;
  35209. exports.PropertyWrite = PropertyWrite;
  35210. exports.SafePropertyRead = SafePropertyRead;
  35211. exports.KeyedRead = KeyedRead;
  35212. exports.KeyedWrite = KeyedWrite;
  35213. exports.BindingPipe = BindingPipe;
  35214. exports.LiteralPrimitive = LiteralPrimitive;
  35215. exports.LiteralArray = LiteralArray;
  35216. exports.LiteralMap = LiteralMap;
  35217. exports.Interpolation = Interpolation;
  35218. exports.Binary = Binary;
  35219. exports.PrefixNot = PrefixNot;
  35220. exports.NonNullAssert = NonNullAssert;
  35221. exports.MethodCall = MethodCall;
  35222. exports.SafeMethodCall = SafeMethodCall;
  35223. exports.FunctionCall = FunctionCall;
  35224. exports.ASTWithSource = ASTWithSource;
  35225. exports.TemplateBinding = TemplateBinding;
  35226. exports.NullAstVisitor = NullAstVisitor;
  35227. exports.RecursiveAstVisitor = RecursiveAstVisitor;
  35228. exports.AstTransformer = AstTransformer;
  35229. exports.visitAstChildren = visitAstChildren;
  35230. exports.TokenType = TokenType;
  35231. exports.Lexer = Lexer;
  35232. exports.Token = Token;
  35233. exports.EOF = EOF;
  35234. exports.isIdentifier = isIdentifier;
  35235. exports.isQuote = isQuote;
  35236. exports.SplitInterpolation = SplitInterpolation;
  35237. exports.TemplateBindingParseResult = TemplateBindingParseResult;
  35238. exports.Parser = Parser;
  35239. exports._ParseAST = _ParseAST;
  35240. exports.ERROR_COMPONENT_TYPE = ERROR_COMPONENT_TYPE;
  35241. exports.CompileMetadataResolver = CompileMetadataResolver;
  35242. exports.Text = Text;
  35243. exports.Expansion = Expansion;
  35244. exports.ExpansionCase = ExpansionCase;
  35245. exports.Attribute = Attribute$1;
  35246. exports.Element = Element;
  35247. exports.Comment = Comment;
  35248. exports.visitAll = visitAll;
  35249. exports.RecursiveVisitor = RecursiveVisitor;
  35250. exports.findNode = findNode;
  35251. exports.ParseTreeResult = ParseTreeResult;
  35252. exports.TreeError = TreeError;
  35253. exports.HtmlParser = HtmlParser;
  35254. exports.HtmlTagDefinition = HtmlTagDefinition;
  35255. exports.getHtmlTagDefinition = getHtmlTagDefinition;
  35256. exports.TagContentType = TagContentType;
  35257. exports.splitNsName = splitNsName;
  35258. exports.isNgContainer = isNgContainer;
  35259. exports.isNgContent = isNgContent;
  35260. exports.isNgTemplate = isNgTemplate;
  35261. exports.getNsPrefix = getNsPrefix;
  35262. exports.mergeNsAndName = mergeNsAndName;
  35263. exports.NAMED_ENTITIES = NAMED_ENTITIES;
  35264. exports.NGSP_UNICODE = NGSP_UNICODE;
  35265. exports.debugOutputAstAsTypeScript = debugOutputAstAsTypeScript;
  35266. exports.TypeScriptEmitter = TypeScriptEmitter;
  35267. exports.ParseLocation = ParseLocation;
  35268. exports.ParseSourceFile = ParseSourceFile;
  35269. exports.ParseSourceSpan = ParseSourceSpan;
  35270. exports.ParseErrorLevel = ParseErrorLevel;
  35271. exports.ParseError = ParseError;
  35272. exports.typeSourceSpan = typeSourceSpan;
  35273. exports.DomElementSchemaRegistry = DomElementSchemaRegistry;
  35274. exports.CssSelector = CssSelector;
  35275. exports.SelectorMatcher = SelectorMatcher;
  35276. exports.SelectorListContext = SelectorListContext;
  35277. exports.SelectorContext = SelectorContext;
  35278. exports.StylesCompileDependency = StylesCompileDependency;
  35279. exports.CompiledStylesheet = CompiledStylesheet;
  35280. exports.StyleCompiler = StyleCompiler;
  35281. exports.TemplateParseError = TemplateParseError;
  35282. exports.TemplateParseResult = TemplateParseResult;
  35283. exports.TemplateParser = TemplateParser;
  35284. exports.splitClasses = splitClasses;
  35285. exports.createElementCssSelector = createElementCssSelector;
  35286. exports.removeSummaryDuplicates = removeSummaryDuplicates;
  35287. Object.defineProperty(exports, '__esModule', { value: true });
  35288. })));
  35289. //# sourceMappingURL=compiler.umd.js.map