chunk-YNWO773W.js 604 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631
  1. import {createRequire as __cjsCompatRequire} from 'module';
  2. const require = __cjsCompatRequire(import.meta.url);
  3. import {
  4. AmbientImport,
  5. ClassMemberAccessLevel,
  6. ClassMemberKind,
  7. ErrorCode,
  8. FatalDiagnosticError,
  9. ImportFlags,
  10. ImportManager,
  11. Reference,
  12. ReferenceEmitKind,
  13. TypeEmitter,
  14. TypeEntityToDeclarationError,
  15. addDiagnosticChain,
  16. assertSuccessfulReferenceEmit,
  17. attachDefaultImportDeclaration,
  18. canEmitType,
  19. classMemberAccessLevelToString,
  20. entityNameToValue,
  21. filterToMembersWithDecorator,
  22. getDefaultImportDeclaration,
  23. getProjectRelativePath,
  24. getSourceFile,
  25. getSourceFileOrNull,
  26. getTokenAtPosition,
  27. identifierOfNode,
  28. isAssignment,
  29. isDeclaration,
  30. isDtsPath,
  31. isFromDtsFile,
  32. isNamedClassDeclaration,
  33. isNonDeclarationTsPath,
  34. isSymbolWithValueDeclaration,
  35. makeDiagnostic,
  36. makeDiagnosticChain,
  37. makeRelatedInformation,
  38. ngErrorCode,
  39. nodeDebugInfo,
  40. nodeNameForError,
  41. presetImportManagerForceNamespaceImports,
  42. reflectObjectLiteral,
  43. reflectTypeEntityToDeclaration,
  44. toUnredirectedSourceFile,
  45. translateExpression,
  46. translateStatement,
  47. translateType,
  48. typeNodeToValueExpr
  49. } from "./chunk-KOIBHR3X.js";
  50. import {
  51. PerfCheckpoint,
  52. PerfEvent,
  53. PerfPhase
  54. } from "./chunk-I6R3GL3L.js";
  55. import {
  56. absoluteFrom,
  57. absoluteFromSourceFile,
  58. getSourceFileOrError,
  59. relative
  60. } from "./chunk-STORTTKY.js";
  61. import {
  62. __publicField
  63. } from "./chunk-KPQ72R34.js";
  64. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/common/src/util.mjs
  65. import { ExternalExpr, ParseLocation, ParseSourceFile, ParseSourceSpan, ReadPropExpr, WrappedNodeExpr } from "@angular/compiler";
  66. import ts from "typescript";
  67. var CORE_MODULE = "@angular/core";
  68. function valueReferenceToExpression(valueRef) {
  69. if (valueRef.kind === 2) {
  70. return null;
  71. } else if (valueRef.kind === 0) {
  72. const expr = new WrappedNodeExpr(valueRef.expression);
  73. if (valueRef.defaultImportStatement !== null) {
  74. attachDefaultImportDeclaration(expr, valueRef.defaultImportStatement);
  75. }
  76. return expr;
  77. } else {
  78. let importExpr = new ExternalExpr({
  79. moduleName: valueRef.moduleName,
  80. name: valueRef.importedName
  81. });
  82. if (valueRef.nestedPath !== null) {
  83. for (const property of valueRef.nestedPath) {
  84. importExpr = new ReadPropExpr(importExpr, property);
  85. }
  86. }
  87. return importExpr;
  88. }
  89. }
  90. function toR3Reference(origin, ref, context, refEmitter) {
  91. const emittedValueRef = refEmitter.emit(ref, context);
  92. assertSuccessfulReferenceEmit(emittedValueRef, origin, "class");
  93. const emittedTypeRef = refEmitter.emit(ref, context, ImportFlags.ForceNewImport | ImportFlags.AllowTypeImports);
  94. assertSuccessfulReferenceEmit(emittedTypeRef, origin, "class");
  95. return {
  96. value: emittedValueRef.expression,
  97. type: emittedTypeRef.expression
  98. };
  99. }
  100. function isAngularCore(decorator) {
  101. return decorator.import !== null && decorator.import.from === CORE_MODULE;
  102. }
  103. function isAngularCoreReferenceWithPotentialAliasing(reference, symbolName, isCore) {
  104. var _a;
  105. return (reference.ownedByModuleGuess === CORE_MODULE || isCore) && ((_a = reference.debugName) == null ? void 0 : _a.replace(/\$\d+$/, "")) === symbolName;
  106. }
  107. function findAngularDecorator(decorators, name, isCore) {
  108. return decorators.find((decorator) => isAngularDecorator(decorator, name, isCore));
  109. }
  110. function isAngularDecorator(decorator, name, isCore) {
  111. if (isCore) {
  112. return decorator.name === name;
  113. } else if (isAngularCore(decorator)) {
  114. return decorator.import.name === name;
  115. }
  116. return false;
  117. }
  118. function getAngularDecorators(decorators, names, isCore) {
  119. return decorators.filter((decorator) => {
  120. var _a;
  121. const name = isCore ? decorator.name : (_a = decorator.import) == null ? void 0 : _a.name;
  122. if (name === void 0 || !names.includes(name)) {
  123. return false;
  124. }
  125. return isCore || isAngularCore(decorator);
  126. });
  127. }
  128. function unwrapExpression(node) {
  129. while (ts.isAsExpression(node) || ts.isParenthesizedExpression(node)) {
  130. node = node.expression;
  131. }
  132. return node;
  133. }
  134. function expandForwardRef(arg) {
  135. arg = unwrapExpression(arg);
  136. if (!ts.isArrowFunction(arg) && !ts.isFunctionExpression(arg)) {
  137. return null;
  138. }
  139. const body = arg.body;
  140. if (ts.isBlock(body)) {
  141. if (body.statements.length !== 1) {
  142. return null;
  143. }
  144. const stmt = body.statements[0];
  145. if (!ts.isReturnStatement(stmt) || stmt.expression === void 0) {
  146. return null;
  147. }
  148. return stmt.expression;
  149. } else {
  150. return body;
  151. }
  152. }
  153. function tryUnwrapForwardRef(node, reflector) {
  154. node = unwrapExpression(node);
  155. if (!ts.isCallExpression(node) || node.arguments.length !== 1) {
  156. return null;
  157. }
  158. const fn = ts.isPropertyAccessExpression(node.expression) ? node.expression.name : node.expression;
  159. if (!ts.isIdentifier(fn)) {
  160. return null;
  161. }
  162. const expr = expandForwardRef(node.arguments[0]);
  163. if (expr === null) {
  164. return null;
  165. }
  166. const imp = reflector.getImportOfIdentifier(fn);
  167. if (imp === null || imp.from !== "@angular/core" || imp.name !== "forwardRef") {
  168. return null;
  169. }
  170. return expr;
  171. }
  172. function createForwardRefResolver(isCore) {
  173. return (fn, callExpr, resolve, unresolvable) => {
  174. if (!isAngularCoreReferenceWithPotentialAliasing(fn, "forwardRef", isCore) || callExpr.arguments.length !== 1) {
  175. return unresolvable;
  176. }
  177. const expanded = expandForwardRef(callExpr.arguments[0]);
  178. if (expanded !== null) {
  179. return resolve(expanded);
  180. } else {
  181. return unresolvable;
  182. }
  183. };
  184. }
  185. function combineResolvers(resolvers) {
  186. return (fn, callExpr, resolve, unresolvable) => {
  187. for (const resolver of resolvers) {
  188. const resolved = resolver(fn, callExpr, resolve, unresolvable);
  189. if (resolved !== unresolvable) {
  190. return resolved;
  191. }
  192. }
  193. return unresolvable;
  194. };
  195. }
  196. function isExpressionForwardReference(expr, context, contextSource) {
  197. if (isWrappedTsNodeExpr(expr)) {
  198. const node = ts.getOriginalNode(expr.node);
  199. return node.getSourceFile() === contextSource && context.pos < node.pos;
  200. } else {
  201. return false;
  202. }
  203. }
  204. function isWrappedTsNodeExpr(expr) {
  205. return expr instanceof WrappedNodeExpr;
  206. }
  207. function readBaseClass(node, reflector, evaluator) {
  208. const baseExpression = reflector.getBaseClassExpression(node);
  209. if (baseExpression !== null) {
  210. const baseClass = evaluator.evaluate(baseExpression);
  211. if (baseClass instanceof Reference && reflector.isClass(baseClass.node)) {
  212. return baseClass;
  213. } else {
  214. return "dynamic";
  215. }
  216. }
  217. return null;
  218. }
  219. var parensWrapperTransformerFactory = (context) => {
  220. const visitor = (node) => {
  221. const visited = ts.visitEachChild(node, visitor, context);
  222. if (ts.isArrowFunction(visited) || ts.isFunctionExpression(visited)) {
  223. return ts.factory.createParenthesizedExpression(visited);
  224. }
  225. return visited;
  226. };
  227. return (node) => ts.visitEachChild(node, visitor, context);
  228. };
  229. function wrapFunctionExpressionsInParens(expression) {
  230. return ts.transform(expression, [parensWrapperTransformerFactory]).transformed[0];
  231. }
  232. function resolveProvidersRequiringFactory(rawProviders, reflector, evaluator) {
  233. const providers = /* @__PURE__ */ new Set();
  234. const resolvedProviders = evaluator.evaluate(rawProviders);
  235. if (!Array.isArray(resolvedProviders)) {
  236. return providers;
  237. }
  238. resolvedProviders.forEach(function processProviders(provider) {
  239. let tokenClass = null;
  240. if (Array.isArray(provider)) {
  241. provider.forEach(processProviders);
  242. } else if (provider instanceof Reference) {
  243. tokenClass = provider;
  244. } else if (provider instanceof Map && provider.has("useClass") && !provider.has("deps")) {
  245. const useExisting = provider.get("useClass");
  246. if (useExisting instanceof Reference) {
  247. tokenClass = useExisting;
  248. }
  249. }
  250. if (tokenClass !== null && !tokenClass.node.getSourceFile().isDeclarationFile && reflector.isClass(tokenClass.node)) {
  251. const constructorParameters = reflector.getConstructorParameters(tokenClass.node);
  252. if (constructorParameters !== null && constructorParameters.length > 0) {
  253. providers.add(tokenClass);
  254. }
  255. }
  256. });
  257. return providers;
  258. }
  259. function wrapTypeReference(reflector, clazz) {
  260. const value = new WrappedNodeExpr(clazz.name);
  261. const type = value;
  262. return { value, type };
  263. }
  264. function createSourceSpan(node) {
  265. const sf = node.getSourceFile();
  266. const [startOffset, endOffset] = [node.getStart(), node.getEnd()];
  267. const { line: startLine, character: startCol } = sf.getLineAndCharacterOfPosition(startOffset);
  268. const { line: endLine, character: endCol } = sf.getLineAndCharacterOfPosition(endOffset);
  269. const parseSf = new ParseSourceFile(sf.getFullText(), sf.fileName);
  270. return new ParseSourceSpan(new ParseLocation(parseSf, startOffset, startLine + 1, startCol + 1), new ParseLocation(parseSf, endOffset, endLine + 1, endCol + 1));
  271. }
  272. function compileResults(fac, def, metadataStmt, propName, additionalFields, deferrableImports, debugInfo = null, hmrInitializer = null) {
  273. const statements = def.statements;
  274. if (metadataStmt !== null) {
  275. statements.push(metadataStmt);
  276. }
  277. if (debugInfo !== null) {
  278. statements.push(debugInfo);
  279. }
  280. if (hmrInitializer !== null) {
  281. statements.push(hmrInitializer);
  282. }
  283. const results = [
  284. fac,
  285. {
  286. name: propName,
  287. initializer: def.expression,
  288. statements: def.statements,
  289. type: def.type,
  290. deferrableImports
  291. }
  292. ];
  293. if (additionalFields !== null) {
  294. results.push(...additionalFields);
  295. }
  296. return results;
  297. }
  298. function toFactoryMetadata(meta, target) {
  299. return {
  300. name: meta.name,
  301. type: meta.type,
  302. typeArgumentCount: meta.typeArgumentCount,
  303. deps: meta.deps,
  304. target
  305. };
  306. }
  307. function resolveImportedFile(moduleResolver, importedFile, expr, origin) {
  308. if (importedFile !== "unknown") {
  309. return importedFile;
  310. }
  311. if (!(expr instanceof ExternalExpr)) {
  312. return null;
  313. }
  314. return moduleResolver.resolveModule(expr.value.moduleName, origin.fileName);
  315. }
  316. function getOriginNodeForDiagnostics(expr, container) {
  317. const nodeSf = expr.getSourceFile();
  318. const exprSf = container.getSourceFile();
  319. if (nodeSf === exprSf && expr.pos >= container.pos && expr.end <= container.end) {
  320. return expr;
  321. } else {
  322. return container;
  323. }
  324. }
  325. function isAbstractClassDeclaration(clazz) {
  326. return ts.canHaveModifiers(clazz) && clazz.modifiers !== void 0 ? clazz.modifiers.some((mod) => mod.kind === ts.SyntaxKind.AbstractKeyword) : false;
  327. }
  328. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/partial_evaluator/src/dynamic.mjs
  329. var DynamicValue = class {
  330. node;
  331. reason;
  332. code;
  333. constructor(node, reason, code) {
  334. this.node = node;
  335. this.reason = reason;
  336. this.code = code;
  337. }
  338. static fromDynamicInput(node, input) {
  339. return new DynamicValue(node, input, 0);
  340. }
  341. static fromDynamicString(node) {
  342. return new DynamicValue(node, void 0, 1);
  343. }
  344. static fromExternalReference(node, ref) {
  345. return new DynamicValue(node, ref, 2);
  346. }
  347. static fromUnsupportedSyntax(node) {
  348. return new DynamicValue(node, void 0, 3);
  349. }
  350. static fromUnknownIdentifier(node) {
  351. return new DynamicValue(node, void 0, 4);
  352. }
  353. static fromInvalidExpressionType(node, value) {
  354. return new DynamicValue(node, value, 5);
  355. }
  356. static fromComplexFunctionCall(node, fn) {
  357. return new DynamicValue(node, fn, 6);
  358. }
  359. static fromDynamicType(node) {
  360. return new DynamicValue(node, void 0, 7);
  361. }
  362. static fromSyntheticInput(node, value) {
  363. return new DynamicValue(node, value, 8);
  364. }
  365. static fromUnknown(node) {
  366. return new DynamicValue(node, void 0, 9);
  367. }
  368. isFromDynamicInput() {
  369. return this.code === 0;
  370. }
  371. isFromDynamicString() {
  372. return this.code === 1;
  373. }
  374. isFromExternalReference() {
  375. return this.code === 2;
  376. }
  377. isFromUnsupportedSyntax() {
  378. return this.code === 3;
  379. }
  380. isFromUnknownIdentifier() {
  381. return this.code === 4;
  382. }
  383. isFromInvalidExpressionType() {
  384. return this.code === 5;
  385. }
  386. isFromComplexFunctionCall() {
  387. return this.code === 6;
  388. }
  389. isFromDynamicType() {
  390. return this.code === 7;
  391. }
  392. isFromUnknown() {
  393. return this.code === 9;
  394. }
  395. accept(visitor) {
  396. switch (this.code) {
  397. case 0:
  398. return visitor.visitDynamicInput(this);
  399. case 1:
  400. return visitor.visitDynamicString(this);
  401. case 2:
  402. return visitor.visitExternalReference(this);
  403. case 3:
  404. return visitor.visitUnsupportedSyntax(this);
  405. case 4:
  406. return visitor.visitUnknownIdentifier(this);
  407. case 5:
  408. return visitor.visitInvalidExpressionType(this);
  409. case 6:
  410. return visitor.visitComplexFunctionCall(this);
  411. case 7:
  412. return visitor.visitDynamicType(this);
  413. case 8:
  414. return visitor.visitSyntheticInput(this);
  415. case 9:
  416. return visitor.visitUnknown(this);
  417. }
  418. }
  419. };
  420. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/partial_evaluator/src/interpreter.mjs
  421. import ts2 from "typescript";
  422. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/partial_evaluator/src/result.mjs
  423. var ResolvedModule = class {
  424. exports;
  425. evaluate;
  426. constructor(exports, evaluate) {
  427. this.exports = exports;
  428. this.evaluate = evaluate;
  429. }
  430. getExport(name) {
  431. if (!this.exports.has(name)) {
  432. return void 0;
  433. }
  434. return this.evaluate(this.exports.get(name));
  435. }
  436. getExports() {
  437. const map = /* @__PURE__ */ new Map();
  438. this.exports.forEach((decl, name) => {
  439. map.set(name, this.evaluate(decl));
  440. });
  441. return map;
  442. }
  443. };
  444. var EnumValue = class {
  445. enumRef;
  446. name;
  447. resolved;
  448. constructor(enumRef, name, resolved) {
  449. this.enumRef = enumRef;
  450. this.name = name;
  451. this.resolved = resolved;
  452. }
  453. };
  454. var KnownFn = class {
  455. };
  456. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/partial_evaluator/src/builtin.mjs
  457. var ArraySliceBuiltinFn = class extends KnownFn {
  458. lhs;
  459. constructor(lhs) {
  460. super();
  461. this.lhs = lhs;
  462. }
  463. evaluate(node, args) {
  464. if (args.length === 0) {
  465. return this.lhs;
  466. } else {
  467. return DynamicValue.fromUnknown(node);
  468. }
  469. }
  470. };
  471. var ArrayConcatBuiltinFn = class extends KnownFn {
  472. lhs;
  473. constructor(lhs) {
  474. super();
  475. this.lhs = lhs;
  476. }
  477. evaluate(node, args) {
  478. const result = [...this.lhs];
  479. for (const arg of args) {
  480. if (arg instanceof DynamicValue) {
  481. result.push(DynamicValue.fromDynamicInput(node, arg));
  482. } else if (Array.isArray(arg)) {
  483. result.push(...arg);
  484. } else {
  485. result.push(arg);
  486. }
  487. }
  488. return result;
  489. }
  490. };
  491. var StringConcatBuiltinFn = class extends KnownFn {
  492. lhs;
  493. constructor(lhs) {
  494. super();
  495. this.lhs = lhs;
  496. }
  497. evaluate(node, args) {
  498. let result = this.lhs;
  499. for (const arg of args) {
  500. const resolved = arg instanceof EnumValue ? arg.resolved : arg;
  501. if (typeof resolved === "string" || typeof resolved === "number" || typeof resolved === "boolean" || resolved == null) {
  502. result = result.concat(resolved);
  503. } else {
  504. return DynamicValue.fromUnknown(node);
  505. }
  506. }
  507. return result;
  508. }
  509. };
  510. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/partial_evaluator/src/synthetic.mjs
  511. var SyntheticValue = class {
  512. value;
  513. constructor(value) {
  514. this.value = value;
  515. }
  516. };
  517. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/partial_evaluator/src/interpreter.mjs
  518. function literalBinaryOp(op) {
  519. return { op, literal: true };
  520. }
  521. function referenceBinaryOp(op) {
  522. return { op, literal: false };
  523. }
  524. var BINARY_OPERATORS = /* @__PURE__ */ new Map([
  525. [ts2.SyntaxKind.PlusToken, literalBinaryOp((a, b) => a + b)],
  526. [ts2.SyntaxKind.MinusToken, literalBinaryOp((a, b) => a - b)],
  527. [ts2.SyntaxKind.AsteriskToken, literalBinaryOp((a, b) => a * b)],
  528. [ts2.SyntaxKind.SlashToken, literalBinaryOp((a, b) => a / b)],
  529. [ts2.SyntaxKind.PercentToken, literalBinaryOp((a, b) => a % b)],
  530. [ts2.SyntaxKind.AmpersandToken, literalBinaryOp((a, b) => a & b)],
  531. [ts2.SyntaxKind.BarToken, literalBinaryOp((a, b) => a | b)],
  532. [ts2.SyntaxKind.CaretToken, literalBinaryOp((a, b) => a ^ b)],
  533. [ts2.SyntaxKind.LessThanToken, literalBinaryOp((a, b) => a < b)],
  534. [ts2.SyntaxKind.LessThanEqualsToken, literalBinaryOp((a, b) => a <= b)],
  535. [ts2.SyntaxKind.GreaterThanToken, literalBinaryOp((a, b) => a > b)],
  536. [ts2.SyntaxKind.GreaterThanEqualsToken, literalBinaryOp((a, b) => a >= b)],
  537. [ts2.SyntaxKind.EqualsEqualsToken, literalBinaryOp((a, b) => a == b)],
  538. [ts2.SyntaxKind.EqualsEqualsEqualsToken, literalBinaryOp((a, b) => a === b)],
  539. [ts2.SyntaxKind.ExclamationEqualsToken, literalBinaryOp((a, b) => a != b)],
  540. [ts2.SyntaxKind.ExclamationEqualsEqualsToken, literalBinaryOp((a, b) => a !== b)],
  541. [ts2.SyntaxKind.LessThanLessThanToken, literalBinaryOp((a, b) => a << b)],
  542. [ts2.SyntaxKind.GreaterThanGreaterThanToken, literalBinaryOp((a, b) => a >> b)],
  543. [ts2.SyntaxKind.GreaterThanGreaterThanGreaterThanToken, literalBinaryOp((a, b) => a >>> b)],
  544. [ts2.SyntaxKind.AsteriskAsteriskToken, literalBinaryOp((a, b) => Math.pow(a, b))],
  545. [ts2.SyntaxKind.AmpersandAmpersandToken, referenceBinaryOp((a, b) => a && b)],
  546. [ts2.SyntaxKind.BarBarToken, referenceBinaryOp((a, b) => a || b)]
  547. ]);
  548. var UNARY_OPERATORS = /* @__PURE__ */ new Map([
  549. [ts2.SyntaxKind.TildeToken, (a) => ~a],
  550. [ts2.SyntaxKind.MinusToken, (a) => -a],
  551. [ts2.SyntaxKind.PlusToken, (a) => +a],
  552. [ts2.SyntaxKind.ExclamationToken, (a) => !a]
  553. ]);
  554. var StaticInterpreter = class {
  555. host;
  556. checker;
  557. dependencyTracker;
  558. constructor(host, checker, dependencyTracker) {
  559. this.host = host;
  560. this.checker = checker;
  561. this.dependencyTracker = dependencyTracker;
  562. }
  563. visit(node, context) {
  564. return this.visitExpression(node, context);
  565. }
  566. visitExpression(node, context) {
  567. let result;
  568. if (node.kind === ts2.SyntaxKind.TrueKeyword) {
  569. return true;
  570. } else if (node.kind === ts2.SyntaxKind.FalseKeyword) {
  571. return false;
  572. } else if (node.kind === ts2.SyntaxKind.NullKeyword) {
  573. return null;
  574. } else if (ts2.isStringLiteral(node)) {
  575. return node.text;
  576. } else if (ts2.isNoSubstitutionTemplateLiteral(node)) {
  577. return node.text;
  578. } else if (ts2.isTemplateExpression(node)) {
  579. result = this.visitTemplateExpression(node, context);
  580. } else if (ts2.isNumericLiteral(node)) {
  581. return parseFloat(node.text);
  582. } else if (ts2.isObjectLiteralExpression(node)) {
  583. result = this.visitObjectLiteralExpression(node, context);
  584. } else if (ts2.isIdentifier(node)) {
  585. result = this.visitIdentifier(node, context);
  586. } else if (ts2.isPropertyAccessExpression(node)) {
  587. result = this.visitPropertyAccessExpression(node, context);
  588. } else if (ts2.isCallExpression(node)) {
  589. result = this.visitCallExpression(node, context);
  590. } else if (ts2.isConditionalExpression(node)) {
  591. result = this.visitConditionalExpression(node, context);
  592. } else if (ts2.isPrefixUnaryExpression(node)) {
  593. result = this.visitPrefixUnaryExpression(node, context);
  594. } else if (ts2.isBinaryExpression(node)) {
  595. result = this.visitBinaryExpression(node, context);
  596. } else if (ts2.isArrayLiteralExpression(node)) {
  597. result = this.visitArrayLiteralExpression(node, context);
  598. } else if (ts2.isParenthesizedExpression(node)) {
  599. result = this.visitParenthesizedExpression(node, context);
  600. } else if (ts2.isElementAccessExpression(node)) {
  601. result = this.visitElementAccessExpression(node, context);
  602. } else if (ts2.isAsExpression(node)) {
  603. result = this.visitExpression(node.expression, context);
  604. } else if (ts2.isNonNullExpression(node)) {
  605. result = this.visitExpression(node.expression, context);
  606. } else if (this.host.isClass(node)) {
  607. result = this.visitDeclaration(node, context);
  608. } else {
  609. return DynamicValue.fromUnsupportedSyntax(node);
  610. }
  611. if (result instanceof DynamicValue && result.node !== node) {
  612. return DynamicValue.fromDynamicInput(node, result);
  613. }
  614. return result;
  615. }
  616. visitArrayLiteralExpression(node, context) {
  617. const array = [];
  618. for (let i = 0; i < node.elements.length; i++) {
  619. const element = node.elements[i];
  620. if (ts2.isSpreadElement(element)) {
  621. array.push(...this.visitSpreadElement(element, context));
  622. } else {
  623. array.push(this.visitExpression(element, context));
  624. }
  625. }
  626. return array;
  627. }
  628. visitObjectLiteralExpression(node, context) {
  629. const map = /* @__PURE__ */ new Map();
  630. for (let i = 0; i < node.properties.length; i++) {
  631. const property = node.properties[i];
  632. if (ts2.isPropertyAssignment(property)) {
  633. const name = this.stringNameFromPropertyName(property.name, context);
  634. if (name === void 0) {
  635. return DynamicValue.fromDynamicInput(node, DynamicValue.fromDynamicString(property.name));
  636. }
  637. map.set(name, this.visitExpression(property.initializer, context));
  638. } else if (ts2.isShorthandPropertyAssignment(property)) {
  639. const symbol = this.checker.getShorthandAssignmentValueSymbol(property);
  640. if (symbol === void 0 || symbol.valueDeclaration === void 0) {
  641. map.set(property.name.text, DynamicValue.fromUnknown(property));
  642. } else {
  643. map.set(property.name.text, this.visitDeclaration(symbol.valueDeclaration, context));
  644. }
  645. } else if (ts2.isSpreadAssignment(property)) {
  646. const spread = this.visitExpression(property.expression, context);
  647. if (spread instanceof DynamicValue) {
  648. return DynamicValue.fromDynamicInput(node, spread);
  649. } else if (spread instanceof Map) {
  650. spread.forEach((value, key) => map.set(key, value));
  651. } else if (spread instanceof ResolvedModule) {
  652. spread.getExports().forEach((value, key) => map.set(key, value));
  653. } else {
  654. return DynamicValue.fromDynamicInput(node, DynamicValue.fromInvalidExpressionType(property, spread));
  655. }
  656. } else {
  657. return DynamicValue.fromUnknown(node);
  658. }
  659. }
  660. return map;
  661. }
  662. visitTemplateExpression(node, context) {
  663. const pieces = [node.head.text];
  664. for (let i = 0; i < node.templateSpans.length; i++) {
  665. const span = node.templateSpans[i];
  666. const value = literal(this.visit(span.expression, context), () => DynamicValue.fromDynamicString(span.expression));
  667. if (value instanceof DynamicValue) {
  668. return DynamicValue.fromDynamicInput(node, value);
  669. }
  670. pieces.push(`${value}`, span.literal.text);
  671. }
  672. return pieces.join("");
  673. }
  674. visitIdentifier(node, context) {
  675. const decl = this.host.getDeclarationOfIdentifier(node);
  676. if (decl === null) {
  677. if (ts2.identifierToKeywordKind(node) === ts2.SyntaxKind.UndefinedKeyword) {
  678. return void 0;
  679. } else {
  680. if (this.dependencyTracker !== null && this.host.getImportOfIdentifier(node) !== null) {
  681. this.dependencyTracker.recordDependencyAnalysisFailure(context.originatingFile);
  682. }
  683. return DynamicValue.fromUnknownIdentifier(node);
  684. }
  685. }
  686. const declContext = { ...context, ...joinModuleContext(context, node, decl) };
  687. const result = this.visitDeclaration(decl.node, declContext);
  688. if (result instanceof Reference) {
  689. if (!result.synthetic) {
  690. result.addIdentifier(node);
  691. }
  692. } else if (result instanceof DynamicValue) {
  693. return DynamicValue.fromDynamicInput(node, result);
  694. }
  695. return result;
  696. }
  697. visitDeclaration(node, context) {
  698. if (this.dependencyTracker !== null) {
  699. this.dependencyTracker.addDependency(context.originatingFile, node.getSourceFile());
  700. }
  701. if (this.host.isClass(node)) {
  702. return this.getReference(node, context);
  703. } else if (ts2.isVariableDeclaration(node)) {
  704. return this.visitVariableDeclaration(node, context);
  705. } else if (ts2.isParameter(node) && context.scope.has(node)) {
  706. return context.scope.get(node);
  707. } else if (ts2.isExportAssignment(node)) {
  708. return this.visitExpression(node.expression, context);
  709. } else if (ts2.isEnumDeclaration(node)) {
  710. return this.visitEnumDeclaration(node, context);
  711. } else if (ts2.isSourceFile(node)) {
  712. return this.visitSourceFile(node, context);
  713. } else if (ts2.isBindingElement(node)) {
  714. return this.visitBindingElement(node, context);
  715. } else {
  716. return this.getReference(node, context);
  717. }
  718. }
  719. visitVariableDeclaration(node, context) {
  720. const value = this.host.getVariableValue(node);
  721. if (value !== null) {
  722. return this.visitExpression(value, context);
  723. } else if (isVariableDeclarationDeclared(node)) {
  724. if (node.type !== void 0) {
  725. const evaluatedType = this.visitType(node.type, context);
  726. if (!(evaluatedType instanceof DynamicValue)) {
  727. return evaluatedType;
  728. }
  729. }
  730. return this.getReference(node, context);
  731. } else {
  732. return void 0;
  733. }
  734. }
  735. visitEnumDeclaration(node, context) {
  736. const enumRef = this.getReference(node, context);
  737. const map = /* @__PURE__ */ new Map();
  738. node.members.forEach((member, index) => {
  739. const name = this.stringNameFromPropertyName(member.name, context);
  740. if (name !== void 0) {
  741. const resolved = member.initializer ? this.visit(member.initializer, context) : index;
  742. map.set(name, new EnumValue(enumRef, name, resolved));
  743. }
  744. });
  745. return map;
  746. }
  747. visitElementAccessExpression(node, context) {
  748. const lhs = this.visitExpression(node.expression, context);
  749. if (lhs instanceof DynamicValue) {
  750. return DynamicValue.fromDynamicInput(node, lhs);
  751. }
  752. const rhs = this.visitExpression(node.argumentExpression, context);
  753. if (rhs instanceof DynamicValue) {
  754. return DynamicValue.fromDynamicInput(node, rhs);
  755. }
  756. if (typeof rhs !== "string" && typeof rhs !== "number") {
  757. return DynamicValue.fromInvalidExpressionType(node, rhs);
  758. }
  759. return this.accessHelper(node, lhs, rhs, context);
  760. }
  761. visitPropertyAccessExpression(node, context) {
  762. const lhs = this.visitExpression(node.expression, context);
  763. const rhs = node.name.text;
  764. if (lhs instanceof DynamicValue) {
  765. return DynamicValue.fromDynamicInput(node, lhs);
  766. }
  767. return this.accessHelper(node, lhs, rhs, context);
  768. }
  769. visitSourceFile(node, context) {
  770. const declarations = this.host.getExportsOfModule(node);
  771. if (declarations === null) {
  772. return DynamicValue.fromUnknown(node);
  773. }
  774. return new ResolvedModule(declarations, (decl) => {
  775. const declContext = {
  776. ...context,
  777. ...joinModuleContext(context, node, decl)
  778. };
  779. return this.visitDeclaration(decl.node, declContext);
  780. });
  781. }
  782. accessHelper(node, lhs, rhs, context) {
  783. const strIndex = `${rhs}`;
  784. if (lhs instanceof Map) {
  785. if (lhs.has(strIndex)) {
  786. return lhs.get(strIndex);
  787. } else {
  788. return void 0;
  789. }
  790. } else if (lhs instanceof ResolvedModule) {
  791. return lhs.getExport(strIndex);
  792. } else if (Array.isArray(lhs)) {
  793. if (rhs === "length") {
  794. return lhs.length;
  795. } else if (rhs === "slice") {
  796. return new ArraySliceBuiltinFn(lhs);
  797. } else if (rhs === "concat") {
  798. return new ArrayConcatBuiltinFn(lhs);
  799. }
  800. if (typeof rhs !== "number" || !Number.isInteger(rhs)) {
  801. return DynamicValue.fromInvalidExpressionType(node, rhs);
  802. }
  803. return lhs[rhs];
  804. } else if (typeof lhs === "string" && rhs === "concat") {
  805. return new StringConcatBuiltinFn(lhs);
  806. } else if (lhs instanceof Reference) {
  807. const ref = lhs.node;
  808. if (this.host.isClass(ref)) {
  809. const module = owningModule(context, lhs.bestGuessOwningModule);
  810. let value = void 0;
  811. const member = this.host.getMembersOfClass(ref).find((member2) => member2.isStatic && member2.name === strIndex);
  812. if (member !== void 0) {
  813. if (member.value !== null) {
  814. value = this.visitExpression(member.value, context);
  815. } else if (member.implementation !== null) {
  816. value = new Reference(member.implementation, module);
  817. } else if (member.node) {
  818. value = new Reference(member.node, module);
  819. }
  820. }
  821. return value;
  822. } else if (isDeclaration(ref)) {
  823. return DynamicValue.fromDynamicInput(node, DynamicValue.fromExternalReference(ref, lhs));
  824. }
  825. } else if (lhs instanceof DynamicValue) {
  826. return DynamicValue.fromDynamicInput(node, lhs);
  827. } else if (lhs instanceof SyntheticValue) {
  828. return DynamicValue.fromSyntheticInput(node, lhs);
  829. }
  830. return DynamicValue.fromUnknown(node);
  831. }
  832. visitCallExpression(node, context) {
  833. const lhs = this.visitExpression(node.expression, context);
  834. if (lhs instanceof DynamicValue) {
  835. return DynamicValue.fromDynamicInput(node, lhs);
  836. }
  837. if (lhs instanceof KnownFn) {
  838. return lhs.evaluate(node, this.evaluateFunctionArguments(node, context));
  839. }
  840. if (!(lhs instanceof Reference)) {
  841. return DynamicValue.fromInvalidExpressionType(node.expression, lhs);
  842. }
  843. const fn = this.host.getDefinitionOfFunction(lhs.node);
  844. if (fn === null) {
  845. return DynamicValue.fromInvalidExpressionType(node.expression, lhs);
  846. }
  847. if (!isFunctionOrMethodReference(lhs)) {
  848. return DynamicValue.fromInvalidExpressionType(node.expression, lhs);
  849. }
  850. const resolveFfrExpr = (expr) => {
  851. let contextExtension = {};
  852. if (fn.body === null && expr.getSourceFile() !== node.expression.getSourceFile() && lhs.bestGuessOwningModule !== null) {
  853. contextExtension = {
  854. absoluteModuleName: lhs.bestGuessOwningModule.specifier,
  855. resolutionContext: lhs.bestGuessOwningModule.resolutionContext
  856. };
  857. }
  858. return this.visitFfrExpression(expr, { ...context, ...contextExtension });
  859. };
  860. if (fn.body === null && context.foreignFunctionResolver !== void 0) {
  861. const unresolvable = DynamicValue.fromDynamicInput(node, DynamicValue.fromExternalReference(node.expression, lhs));
  862. return context.foreignFunctionResolver(lhs, node, resolveFfrExpr, unresolvable);
  863. }
  864. const res = this.visitFunctionBody(node, fn, context);
  865. if (res instanceof DynamicValue && context.foreignFunctionResolver !== void 0) {
  866. const unresolvable = DynamicValue.fromComplexFunctionCall(node, fn);
  867. return context.foreignFunctionResolver(lhs, node, resolveFfrExpr, unresolvable);
  868. }
  869. return res;
  870. }
  871. visitFfrExpression(expr, context) {
  872. const res = this.visitExpression(expr, context);
  873. if (res instanceof Reference) {
  874. res.synthetic = true;
  875. }
  876. return res;
  877. }
  878. visitFunctionBody(node, fn, context) {
  879. if (fn.body === null) {
  880. return DynamicValue.fromUnknown(node);
  881. } else if (fn.body.length !== 1 || !ts2.isReturnStatement(fn.body[0])) {
  882. return DynamicValue.fromComplexFunctionCall(node, fn);
  883. }
  884. const ret = fn.body[0];
  885. const args = this.evaluateFunctionArguments(node, context);
  886. const newScope = /* @__PURE__ */ new Map();
  887. const calleeContext = { ...context, scope: newScope };
  888. fn.parameters.forEach((param, index) => {
  889. let arg = args[index];
  890. if (param.node.dotDotDotToken !== void 0) {
  891. arg = args.slice(index);
  892. }
  893. if (arg === void 0 && param.initializer !== null) {
  894. arg = this.visitExpression(param.initializer, calleeContext);
  895. }
  896. newScope.set(param.node, arg);
  897. });
  898. return ret.expression !== void 0 ? this.visitExpression(ret.expression, calleeContext) : void 0;
  899. }
  900. visitConditionalExpression(node, context) {
  901. const condition = this.visitExpression(node.condition, context);
  902. if (condition instanceof DynamicValue) {
  903. return DynamicValue.fromDynamicInput(node, condition);
  904. }
  905. if (condition) {
  906. return this.visitExpression(node.whenTrue, context);
  907. } else {
  908. return this.visitExpression(node.whenFalse, context);
  909. }
  910. }
  911. visitPrefixUnaryExpression(node, context) {
  912. const operatorKind = node.operator;
  913. if (!UNARY_OPERATORS.has(operatorKind)) {
  914. return DynamicValue.fromUnsupportedSyntax(node);
  915. }
  916. const op = UNARY_OPERATORS.get(operatorKind);
  917. const value = this.visitExpression(node.operand, context);
  918. if (value instanceof DynamicValue) {
  919. return DynamicValue.fromDynamicInput(node, value);
  920. } else {
  921. return op(value);
  922. }
  923. }
  924. visitBinaryExpression(node, context) {
  925. const tokenKind = node.operatorToken.kind;
  926. if (!BINARY_OPERATORS.has(tokenKind)) {
  927. return DynamicValue.fromUnsupportedSyntax(node);
  928. }
  929. const opRecord = BINARY_OPERATORS.get(tokenKind);
  930. let lhs, rhs;
  931. if (opRecord.literal) {
  932. lhs = literal(this.visitExpression(node.left, context), (value) => DynamicValue.fromInvalidExpressionType(node.left, value));
  933. rhs = literal(this.visitExpression(node.right, context), (value) => DynamicValue.fromInvalidExpressionType(node.right, value));
  934. } else {
  935. lhs = this.visitExpression(node.left, context);
  936. rhs = this.visitExpression(node.right, context);
  937. }
  938. if (lhs instanceof DynamicValue) {
  939. return DynamicValue.fromDynamicInput(node, lhs);
  940. } else if (rhs instanceof DynamicValue) {
  941. return DynamicValue.fromDynamicInput(node, rhs);
  942. } else {
  943. return opRecord.op(lhs, rhs);
  944. }
  945. }
  946. visitParenthesizedExpression(node, context) {
  947. return this.visitExpression(node.expression, context);
  948. }
  949. evaluateFunctionArguments(node, context) {
  950. const args = [];
  951. for (const arg of node.arguments) {
  952. if (ts2.isSpreadElement(arg)) {
  953. args.push(...this.visitSpreadElement(arg, context));
  954. } else {
  955. args.push(this.visitExpression(arg, context));
  956. }
  957. }
  958. return args;
  959. }
  960. visitSpreadElement(node, context) {
  961. const spread = this.visitExpression(node.expression, context);
  962. if (spread instanceof DynamicValue) {
  963. return [DynamicValue.fromDynamicInput(node, spread)];
  964. } else if (!Array.isArray(spread)) {
  965. return [DynamicValue.fromInvalidExpressionType(node, spread)];
  966. } else {
  967. return spread;
  968. }
  969. }
  970. visitBindingElement(node, context) {
  971. const path = [];
  972. let closestDeclaration = node;
  973. while (ts2.isBindingElement(closestDeclaration) || ts2.isArrayBindingPattern(closestDeclaration) || ts2.isObjectBindingPattern(closestDeclaration)) {
  974. if (ts2.isBindingElement(closestDeclaration)) {
  975. path.unshift(closestDeclaration);
  976. }
  977. closestDeclaration = closestDeclaration.parent;
  978. }
  979. if (!ts2.isVariableDeclaration(closestDeclaration) || closestDeclaration.initializer === void 0) {
  980. return DynamicValue.fromUnknown(node);
  981. }
  982. let value = this.visit(closestDeclaration.initializer, context);
  983. for (const element of path) {
  984. let key;
  985. if (ts2.isArrayBindingPattern(element.parent)) {
  986. key = element.parent.elements.indexOf(element);
  987. } else {
  988. const name = element.propertyName || element.name;
  989. if (ts2.isIdentifier(name)) {
  990. key = name.text;
  991. } else {
  992. return DynamicValue.fromUnknown(element);
  993. }
  994. }
  995. value = this.accessHelper(element, value, key, context);
  996. if (value instanceof DynamicValue) {
  997. return value;
  998. }
  999. }
  1000. return value;
  1001. }
  1002. stringNameFromPropertyName(node, context) {
  1003. if (ts2.isIdentifier(node) || ts2.isStringLiteral(node) || ts2.isNumericLiteral(node)) {
  1004. return node.text;
  1005. } else if (ts2.isComputedPropertyName(node)) {
  1006. const literal3 = this.visitExpression(node.expression, context);
  1007. return typeof literal3 === "string" ? literal3 : void 0;
  1008. } else {
  1009. return void 0;
  1010. }
  1011. }
  1012. getReference(node, context) {
  1013. return new Reference(node, owningModule(context));
  1014. }
  1015. visitType(node, context) {
  1016. if (ts2.isLiteralTypeNode(node)) {
  1017. return this.visitExpression(node.literal, context);
  1018. } else if (ts2.isTupleTypeNode(node)) {
  1019. return this.visitTupleType(node, context);
  1020. } else if (ts2.isNamedTupleMember(node)) {
  1021. return this.visitType(node.type, context);
  1022. } else if (ts2.isTypeOperatorNode(node) && node.operator === ts2.SyntaxKind.ReadonlyKeyword) {
  1023. return this.visitType(node.type, context);
  1024. } else if (ts2.isTypeQueryNode(node)) {
  1025. return this.visitTypeQuery(node, context);
  1026. }
  1027. return DynamicValue.fromDynamicType(node);
  1028. }
  1029. visitTupleType(node, context) {
  1030. const res = [];
  1031. for (const elem of node.elements) {
  1032. res.push(this.visitType(elem, context));
  1033. }
  1034. return res;
  1035. }
  1036. visitTypeQuery(node, context) {
  1037. if (!ts2.isIdentifier(node.exprName)) {
  1038. return DynamicValue.fromUnknown(node);
  1039. }
  1040. const decl = this.host.getDeclarationOfIdentifier(node.exprName);
  1041. if (decl === null) {
  1042. return DynamicValue.fromUnknownIdentifier(node.exprName);
  1043. }
  1044. const declContext = { ...context, ...joinModuleContext(context, node, decl) };
  1045. return this.visitDeclaration(decl.node, declContext);
  1046. }
  1047. };
  1048. function isFunctionOrMethodReference(ref) {
  1049. return ts2.isFunctionDeclaration(ref.node) || ts2.isMethodDeclaration(ref.node) || ts2.isFunctionExpression(ref.node);
  1050. }
  1051. function literal(value, reject) {
  1052. if (value instanceof EnumValue) {
  1053. value = value.resolved;
  1054. }
  1055. if (value instanceof DynamicValue || value === null || value === void 0 || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
  1056. return value;
  1057. }
  1058. return reject(value);
  1059. }
  1060. function isVariableDeclarationDeclared(node) {
  1061. if (node.parent === void 0 || !ts2.isVariableDeclarationList(node.parent)) {
  1062. return false;
  1063. }
  1064. const declList = node.parent;
  1065. if (declList.parent === void 0 || !ts2.isVariableStatement(declList.parent)) {
  1066. return false;
  1067. }
  1068. const varStmt = declList.parent;
  1069. const modifiers = ts2.getModifiers(varStmt);
  1070. return modifiers !== void 0 && modifiers.some((mod) => mod.kind === ts2.SyntaxKind.DeclareKeyword);
  1071. }
  1072. var EMPTY = {};
  1073. function joinModuleContext(existing, node, decl) {
  1074. if (typeof decl.viaModule === "string" && decl.viaModule !== existing.absoluteModuleName) {
  1075. return {
  1076. absoluteModuleName: decl.viaModule,
  1077. resolutionContext: node.getSourceFile().fileName
  1078. };
  1079. } else {
  1080. return EMPTY;
  1081. }
  1082. }
  1083. function owningModule(context, override = null) {
  1084. let specifier = context.absoluteModuleName;
  1085. if (override !== null) {
  1086. specifier = override.specifier;
  1087. }
  1088. if (specifier !== null) {
  1089. return {
  1090. specifier,
  1091. resolutionContext: context.resolutionContext
  1092. };
  1093. } else {
  1094. return null;
  1095. }
  1096. }
  1097. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/partial_evaluator/src/interface.mjs
  1098. var PartialEvaluator = class {
  1099. host;
  1100. checker;
  1101. dependencyTracker;
  1102. constructor(host, checker, dependencyTracker) {
  1103. this.host = host;
  1104. this.checker = checker;
  1105. this.dependencyTracker = dependencyTracker;
  1106. }
  1107. evaluate(expr, foreignFunctionResolver) {
  1108. const interpreter = new StaticInterpreter(this.host, this.checker, this.dependencyTracker);
  1109. const sourceFile = expr.getSourceFile();
  1110. return interpreter.visit(expr, {
  1111. originatingFile: sourceFile,
  1112. absoluteModuleName: null,
  1113. resolutionContext: sourceFile.fileName,
  1114. scope: /* @__PURE__ */ new Map(),
  1115. foreignFunctionResolver
  1116. });
  1117. }
  1118. };
  1119. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/partial_evaluator/src/diagnostics.mjs
  1120. import ts3 from "typescript";
  1121. function describeResolvedType(value, maxDepth = 1) {
  1122. var _a, _b;
  1123. if (value === null) {
  1124. return "null";
  1125. } else if (value === void 0) {
  1126. return "undefined";
  1127. } else if (typeof value === "number" || typeof value === "boolean" || typeof value === "string") {
  1128. return typeof value;
  1129. } else if (value instanceof Map) {
  1130. if (maxDepth === 0) {
  1131. return "object";
  1132. }
  1133. const entries = Array.from(value.entries()).map(([key, v]) => {
  1134. return `${quoteKey(key)}: ${describeResolvedType(v, maxDepth - 1)}`;
  1135. });
  1136. return entries.length > 0 ? `{ ${entries.join("; ")} }` : "{}";
  1137. } else if (value instanceof ResolvedModule) {
  1138. return "(module)";
  1139. } else if (value instanceof EnumValue) {
  1140. return (_a = value.enumRef.debugName) != null ? _a : "(anonymous)";
  1141. } else if (value instanceof Reference) {
  1142. return (_b = value.debugName) != null ? _b : "(anonymous)";
  1143. } else if (Array.isArray(value)) {
  1144. if (maxDepth === 0) {
  1145. return "Array";
  1146. }
  1147. return `[${value.map((v) => describeResolvedType(v, maxDepth - 1)).join(", ")}]`;
  1148. } else if (value instanceof DynamicValue) {
  1149. return "(not statically analyzable)";
  1150. } else if (value instanceof KnownFn) {
  1151. return "Function";
  1152. } else {
  1153. return "unknown";
  1154. }
  1155. }
  1156. function quoteKey(key) {
  1157. if (/^[a-z0-9_]+$/i.test(key)) {
  1158. return key;
  1159. } else {
  1160. return `'${key.replace(/'/g, "\\'")}'`;
  1161. }
  1162. }
  1163. function traceDynamicValue(node, value) {
  1164. return value.accept(new TraceDynamicValueVisitor(node));
  1165. }
  1166. var TraceDynamicValueVisitor = class {
  1167. node;
  1168. currentContainerNode = null;
  1169. constructor(node) {
  1170. this.node = node;
  1171. }
  1172. visitDynamicInput(value) {
  1173. const trace = value.reason.accept(this);
  1174. if (this.shouldTrace(value.node)) {
  1175. const info = makeRelatedInformation(value.node, "Unable to evaluate this expression statically.");
  1176. trace.unshift(info);
  1177. }
  1178. return trace;
  1179. }
  1180. visitSyntheticInput(value) {
  1181. return [makeRelatedInformation(value.node, "Unable to evaluate this expression further.")];
  1182. }
  1183. visitDynamicString(value) {
  1184. return [
  1185. makeRelatedInformation(value.node, "A string value could not be determined statically.")
  1186. ];
  1187. }
  1188. visitExternalReference(value) {
  1189. const name = value.reason.debugName;
  1190. const description = name !== null ? `'${name}'` : "an anonymous declaration";
  1191. return [
  1192. makeRelatedInformation(value.node, `A value for ${description} cannot be determined statically, as it is an external declaration.`)
  1193. ];
  1194. }
  1195. visitComplexFunctionCall(value) {
  1196. return [
  1197. makeRelatedInformation(value.node, "Unable to evaluate function call of complex function. A function must have exactly one return statement."),
  1198. makeRelatedInformation(value.reason.node, "Function is declared here.")
  1199. ];
  1200. }
  1201. visitInvalidExpressionType(value) {
  1202. return [makeRelatedInformation(value.node, "Unable to evaluate an invalid expression.")];
  1203. }
  1204. visitUnknown(value) {
  1205. return [makeRelatedInformation(value.node, "Unable to evaluate statically.")];
  1206. }
  1207. visitUnknownIdentifier(value) {
  1208. return [makeRelatedInformation(value.node, "Unknown reference.")];
  1209. }
  1210. visitDynamicType(value) {
  1211. return [makeRelatedInformation(value.node, "Dynamic type.")];
  1212. }
  1213. visitUnsupportedSyntax(value) {
  1214. return [makeRelatedInformation(value.node, "This syntax is not supported.")];
  1215. }
  1216. shouldTrace(node) {
  1217. if (node === this.node) {
  1218. return false;
  1219. }
  1220. const container = getContainerNode(node);
  1221. if (container === this.currentContainerNode) {
  1222. return false;
  1223. }
  1224. this.currentContainerNode = container;
  1225. return true;
  1226. }
  1227. };
  1228. function getContainerNode(node) {
  1229. let currentNode = node;
  1230. while (currentNode !== void 0) {
  1231. switch (currentNode.kind) {
  1232. case ts3.SyntaxKind.ExpressionStatement:
  1233. case ts3.SyntaxKind.VariableStatement:
  1234. case ts3.SyntaxKind.ReturnStatement:
  1235. case ts3.SyntaxKind.IfStatement:
  1236. case ts3.SyntaxKind.SwitchStatement:
  1237. case ts3.SyntaxKind.DoStatement:
  1238. case ts3.SyntaxKind.WhileStatement:
  1239. case ts3.SyntaxKind.ForStatement:
  1240. case ts3.SyntaxKind.ForInStatement:
  1241. case ts3.SyntaxKind.ForOfStatement:
  1242. case ts3.SyntaxKind.ContinueStatement:
  1243. case ts3.SyntaxKind.BreakStatement:
  1244. case ts3.SyntaxKind.ThrowStatement:
  1245. case ts3.SyntaxKind.ObjectBindingPattern:
  1246. case ts3.SyntaxKind.ArrayBindingPattern:
  1247. return currentNode;
  1248. }
  1249. currentNode = currentNode.parent;
  1250. }
  1251. return node.getSourceFile();
  1252. }
  1253. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/api/checker.mjs
  1254. var OptimizeFor;
  1255. (function(OptimizeFor2) {
  1256. OptimizeFor2[OptimizeFor2["SingleFile"] = 0] = "SingleFile";
  1257. OptimizeFor2[OptimizeFor2["WholeProgram"] = 1] = "WholeProgram";
  1258. })(OptimizeFor || (OptimizeFor = {}));
  1259. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/api/scope.mjs
  1260. var PotentialImportKind;
  1261. (function(PotentialImportKind2) {
  1262. PotentialImportKind2[PotentialImportKind2["NgModule"] = 0] = "NgModule";
  1263. PotentialImportKind2[PotentialImportKind2["Standalone"] = 1] = "Standalone";
  1264. })(PotentialImportKind || (PotentialImportKind = {}));
  1265. var PotentialImportMode;
  1266. (function(PotentialImportMode2) {
  1267. PotentialImportMode2[PotentialImportMode2["Normal"] = 0] = "Normal";
  1268. PotentialImportMode2[PotentialImportMode2["ForceDirect"] = 1] = "ForceDirect";
  1269. })(PotentialImportMode || (PotentialImportMode = {}));
  1270. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/api/completion.mjs
  1271. var CompletionKind;
  1272. (function(CompletionKind2) {
  1273. CompletionKind2[CompletionKind2["Reference"] = 0] = "Reference";
  1274. CompletionKind2[CompletionKind2["Variable"] = 1] = "Variable";
  1275. CompletionKind2[CompletionKind2["LetDeclaration"] = 2] = "LetDeclaration";
  1276. })(CompletionKind || (CompletionKind = {}));
  1277. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/api/symbols.mjs
  1278. var SymbolKind;
  1279. (function(SymbolKind2) {
  1280. SymbolKind2[SymbolKind2["Input"] = 0] = "Input";
  1281. SymbolKind2[SymbolKind2["Output"] = 1] = "Output";
  1282. SymbolKind2[SymbolKind2["Binding"] = 2] = "Binding";
  1283. SymbolKind2[SymbolKind2["Reference"] = 3] = "Reference";
  1284. SymbolKind2[SymbolKind2["Variable"] = 4] = "Variable";
  1285. SymbolKind2[SymbolKind2["Directive"] = 5] = "Directive";
  1286. SymbolKind2[SymbolKind2["Element"] = 6] = "Element";
  1287. SymbolKind2[SymbolKind2["Template"] = 7] = "Template";
  1288. SymbolKind2[SymbolKind2["Expression"] = 8] = "Expression";
  1289. SymbolKind2[SymbolKind2["DomBinding"] = 9] = "DomBinding";
  1290. SymbolKind2[SymbolKind2["Pipe"] = 10] = "Pipe";
  1291. SymbolKind2[SymbolKind2["LetDeclaration"] = 11] = "LetDeclaration";
  1292. })(SymbolKind || (SymbolKind = {}));
  1293. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/common/src/di.mjs
  1294. import { LiteralExpr, WrappedNodeExpr as WrappedNodeExpr2 } from "@angular/compiler";
  1295. import ts4 from "typescript";
  1296. function getConstructorDependencies(clazz, reflector, isCore) {
  1297. const deps = [];
  1298. const errors = [];
  1299. let ctorParams = reflector.getConstructorParameters(clazz);
  1300. if (ctorParams === null) {
  1301. if (reflector.hasBaseClass(clazz)) {
  1302. return null;
  1303. } else {
  1304. ctorParams = [];
  1305. }
  1306. }
  1307. ctorParams.forEach((param, idx) => {
  1308. let token = valueReferenceToExpression(param.typeValueReference);
  1309. let attributeNameType = null;
  1310. let optional = false, self = false, skipSelf = false, host = false;
  1311. (param.decorators || []).filter((dec) => isCore || isAngularCore(dec)).forEach((dec) => {
  1312. const name = isCore || dec.import === null ? dec.name : dec.import.name;
  1313. if (name === "Inject") {
  1314. if (dec.args === null || dec.args.length !== 1) {
  1315. throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARITY_WRONG, dec.node, `Unexpected number of arguments to @Inject().`);
  1316. }
  1317. token = new WrappedNodeExpr2(dec.args[0]);
  1318. } else if (name === "Optional") {
  1319. optional = true;
  1320. } else if (name === "SkipSelf") {
  1321. skipSelf = true;
  1322. } else if (name === "Self") {
  1323. self = true;
  1324. } else if (name === "Host") {
  1325. host = true;
  1326. } else if (name === "Attribute") {
  1327. if (dec.args === null || dec.args.length !== 1) {
  1328. throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARITY_WRONG, dec.node, `Unexpected number of arguments to @Attribute().`);
  1329. }
  1330. const attributeName = dec.args[0];
  1331. token = new WrappedNodeExpr2(attributeName);
  1332. if (ts4.isStringLiteralLike(attributeName)) {
  1333. attributeNameType = new LiteralExpr(attributeName.text);
  1334. } else {
  1335. attributeNameType = new WrappedNodeExpr2(ts4.factory.createKeywordTypeNode(ts4.SyntaxKind.UnknownKeyword));
  1336. }
  1337. } else {
  1338. throw new FatalDiagnosticError(ErrorCode.DECORATOR_UNEXPECTED, dec.node, `Unexpected decorator ${name} on parameter.`);
  1339. }
  1340. });
  1341. if (token === null) {
  1342. if (param.typeValueReference.kind !== 2) {
  1343. throw new Error("Illegal state: expected value reference to be unavailable if no token is present");
  1344. }
  1345. errors.push({
  1346. index: idx,
  1347. param,
  1348. reason: param.typeValueReference.reason
  1349. });
  1350. } else {
  1351. deps.push({ token, attributeNameType, optional, self, skipSelf, host });
  1352. }
  1353. });
  1354. if (errors.length === 0) {
  1355. return { deps };
  1356. } else {
  1357. return { deps: null, errors };
  1358. }
  1359. }
  1360. function unwrapConstructorDependencies(deps) {
  1361. if (deps === null) {
  1362. return null;
  1363. } else if (deps.deps !== null) {
  1364. return deps.deps;
  1365. } else {
  1366. return "invalid";
  1367. }
  1368. }
  1369. function getValidConstructorDependencies(clazz, reflector, isCore) {
  1370. return validateConstructorDependencies(clazz, getConstructorDependencies(clazz, reflector, isCore));
  1371. }
  1372. function validateConstructorDependencies(clazz, deps) {
  1373. if (deps === null) {
  1374. return null;
  1375. } else if (deps.deps !== null) {
  1376. return deps.deps;
  1377. } else {
  1378. const error = deps.errors[0];
  1379. throw createUnsuitableInjectionTokenError(clazz, error);
  1380. }
  1381. }
  1382. function createUnsuitableInjectionTokenError(clazz, error) {
  1383. const { param, index, reason } = error;
  1384. let chainMessage = void 0;
  1385. let hints = void 0;
  1386. switch (reason.kind) {
  1387. case 5:
  1388. chainMessage = "Consider using the @Inject decorator to specify an injection token.";
  1389. hints = [
  1390. makeRelatedInformation(reason.typeNode, "This type is not supported as injection token.")
  1391. ];
  1392. break;
  1393. case 1:
  1394. chainMessage = "Consider using the @Inject decorator to specify an injection token.";
  1395. hints = [
  1396. makeRelatedInformation(reason.typeNode, "This type does not have a value, so it cannot be used as injection token.")
  1397. ];
  1398. if (reason.decl !== null) {
  1399. hints.push(makeRelatedInformation(reason.decl, "The type is declared here."));
  1400. }
  1401. break;
  1402. case 2:
  1403. chainMessage = "Consider changing the type-only import to a regular import, or use the @Inject decorator to specify an injection token.";
  1404. hints = [
  1405. makeRelatedInformation(reason.typeNode, "This type is imported using a type-only import, which prevents it from being usable as an injection token."),
  1406. makeRelatedInformation(reason.node, "The type-only import occurs here.")
  1407. ];
  1408. break;
  1409. case 4:
  1410. chainMessage = "Consider using the @Inject decorator to specify an injection token.";
  1411. hints = [
  1412. makeRelatedInformation(reason.typeNode, "This type corresponds with a namespace, which cannot be used as injection token."),
  1413. makeRelatedInformation(reason.importClause, "The namespace import occurs here.")
  1414. ];
  1415. break;
  1416. case 3:
  1417. chainMessage = "The type should reference a known declaration.";
  1418. hints = [makeRelatedInformation(reason.typeNode, "This type could not be resolved.")];
  1419. break;
  1420. case 0:
  1421. chainMessage = "Consider adding a type to the parameter or use the @Inject decorator to specify an injection token.";
  1422. break;
  1423. }
  1424. const chain = {
  1425. messageText: `No suitable injection token for parameter '${param.name || index}' of class '${clazz.name.text}'.`,
  1426. category: ts4.DiagnosticCategory.Error,
  1427. code: 0,
  1428. next: [
  1429. {
  1430. messageText: chainMessage,
  1431. category: ts4.DiagnosticCategory.Message,
  1432. code: 0
  1433. }
  1434. ]
  1435. };
  1436. return new FatalDiagnosticError(ErrorCode.PARAM_MISSING_TOKEN, param.nameNode, chain, hints);
  1437. }
  1438. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/common/src/diagnostics.mjs
  1439. import ts12 from "typescript";
  1440. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/metadata/src/api.mjs
  1441. var MetaKind;
  1442. (function(MetaKind2) {
  1443. MetaKind2[MetaKind2["Directive"] = 0] = "Directive";
  1444. MetaKind2[MetaKind2["Pipe"] = 1] = "Pipe";
  1445. MetaKind2[MetaKind2["NgModule"] = 2] = "NgModule";
  1446. })(MetaKind || (MetaKind = {}));
  1447. var MatchSource;
  1448. (function(MatchSource2) {
  1449. MatchSource2[MatchSource2["Selector"] = 0] = "Selector";
  1450. MatchSource2[MatchSource2["HostDirective"] = 1] = "HostDirective";
  1451. })(MatchSource || (MatchSource = {}));
  1452. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/metadata/src/dts.mjs
  1453. import ts6 from "typescript";
  1454. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/metadata/src/property_mapping.mjs
  1455. var ClassPropertyMapping = class {
  1456. forwardMap;
  1457. reverseMap;
  1458. constructor(forwardMap) {
  1459. this.forwardMap = forwardMap;
  1460. this.reverseMap = reverseMapFromForwardMap(forwardMap);
  1461. }
  1462. static empty() {
  1463. return new ClassPropertyMapping(/* @__PURE__ */ new Map());
  1464. }
  1465. static fromMappedObject(obj) {
  1466. const forwardMap = /* @__PURE__ */ new Map();
  1467. for (const classPropertyName of Object.keys(obj)) {
  1468. const value = obj[classPropertyName];
  1469. let inputOrOutput;
  1470. if (typeof value === "string") {
  1471. inputOrOutput = {
  1472. classPropertyName,
  1473. bindingPropertyName: value,
  1474. isSignal: false
  1475. };
  1476. } else {
  1477. inputOrOutput = value;
  1478. }
  1479. forwardMap.set(classPropertyName, inputOrOutput);
  1480. }
  1481. return new ClassPropertyMapping(forwardMap);
  1482. }
  1483. static merge(a, b) {
  1484. const forwardMap = new Map(a.forwardMap.entries());
  1485. for (const [classPropertyName, inputOrOutput] of b.forwardMap) {
  1486. forwardMap.set(classPropertyName, inputOrOutput);
  1487. }
  1488. return new ClassPropertyMapping(forwardMap);
  1489. }
  1490. get classPropertyNames() {
  1491. return Array.from(this.forwardMap.keys());
  1492. }
  1493. get propertyNames() {
  1494. return Array.from(this.reverseMap.keys());
  1495. }
  1496. hasBindingPropertyName(propertyName) {
  1497. return this.reverseMap.has(propertyName);
  1498. }
  1499. getByBindingPropertyName(propertyName) {
  1500. return this.reverseMap.has(propertyName) ? this.reverseMap.get(propertyName) : null;
  1501. }
  1502. getByClassPropertyName(classPropertyName) {
  1503. return this.forwardMap.has(classPropertyName) ? this.forwardMap.get(classPropertyName) : null;
  1504. }
  1505. toDirectMappedObject() {
  1506. const obj = {};
  1507. for (const [classPropertyName, inputOrOutput] of this.forwardMap) {
  1508. obj[classPropertyName] = inputOrOutput.bindingPropertyName;
  1509. }
  1510. return obj;
  1511. }
  1512. toJointMappedObject(transform) {
  1513. const obj = {};
  1514. for (const [classPropertyName, inputOrOutput] of this.forwardMap) {
  1515. obj[classPropertyName] = transform(inputOrOutput);
  1516. }
  1517. return obj;
  1518. }
  1519. *[Symbol.iterator]() {
  1520. for (const inputOrOutput of this.forwardMap.values()) {
  1521. yield inputOrOutput;
  1522. }
  1523. }
  1524. };
  1525. function reverseMapFromForwardMap(forwardMap) {
  1526. const reverseMap = /* @__PURE__ */ new Map();
  1527. for (const [_, inputOrOutput] of forwardMap) {
  1528. if (!reverseMap.has(inputOrOutput.bindingPropertyName)) {
  1529. reverseMap.set(inputOrOutput.bindingPropertyName, []);
  1530. }
  1531. reverseMap.get(inputOrOutput.bindingPropertyName).push(inputOrOutput);
  1532. }
  1533. return reverseMap;
  1534. }
  1535. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/metadata/src/util.mjs
  1536. import ts5 from "typescript";
  1537. function extractReferencesFromType(checker, def, bestGuessOwningModule) {
  1538. if (!ts5.isTupleTypeNode(def)) {
  1539. return { result: [], isIncomplete: false };
  1540. }
  1541. const result = [];
  1542. let isIncomplete = false;
  1543. for (const element of def.elements) {
  1544. if (!ts5.isTypeQueryNode(element)) {
  1545. throw new Error(`Expected TypeQueryNode: ${nodeDebugInfo(element)}`);
  1546. }
  1547. const ref = extraReferenceFromTypeQuery(checker, element, def, bestGuessOwningModule);
  1548. if (ref === null) {
  1549. isIncomplete = true;
  1550. } else {
  1551. result.push(ref);
  1552. }
  1553. }
  1554. return { result, isIncomplete };
  1555. }
  1556. function extraReferenceFromTypeQuery(checker, typeNode, origin, bestGuessOwningModule) {
  1557. const type = typeNode.exprName;
  1558. let node;
  1559. let from;
  1560. try {
  1561. const result = reflectTypeEntityToDeclaration(type, checker);
  1562. node = result.node;
  1563. from = result.from;
  1564. } catch (e) {
  1565. if (e instanceof TypeEntityToDeclarationError) {
  1566. return null;
  1567. }
  1568. throw e;
  1569. }
  1570. if (!isNamedClassDeclaration(node)) {
  1571. throw new Error(`Expected named ClassDeclaration: ${nodeDebugInfo(node)}`);
  1572. }
  1573. if (from !== null && !from.startsWith(".")) {
  1574. return new Reference(node, {
  1575. specifier: from,
  1576. resolutionContext: origin.getSourceFile().fileName
  1577. });
  1578. }
  1579. return new Reference(node, bestGuessOwningModule);
  1580. }
  1581. function readBooleanType(type) {
  1582. if (!ts5.isLiteralTypeNode(type)) {
  1583. return null;
  1584. }
  1585. switch (type.literal.kind) {
  1586. case ts5.SyntaxKind.TrueKeyword:
  1587. return true;
  1588. case ts5.SyntaxKind.FalseKeyword:
  1589. return false;
  1590. default:
  1591. return null;
  1592. }
  1593. }
  1594. function readStringType(type) {
  1595. if (!ts5.isLiteralTypeNode(type) || !ts5.isStringLiteral(type.literal)) {
  1596. return null;
  1597. }
  1598. return type.literal.text;
  1599. }
  1600. function readMapType(type, valueTransform) {
  1601. if (!ts5.isTypeLiteralNode(type)) {
  1602. return {};
  1603. }
  1604. const obj = {};
  1605. type.members.forEach((member) => {
  1606. if (!ts5.isPropertySignature(member) || member.type === void 0 || member.name === void 0 || !ts5.isStringLiteral(member.name) && !ts5.isIdentifier(member.name)) {
  1607. return;
  1608. }
  1609. const value = valueTransform(member.type);
  1610. if (value !== null) {
  1611. obj[member.name.text] = value;
  1612. }
  1613. });
  1614. return obj;
  1615. }
  1616. function readStringArrayType(type) {
  1617. if (!ts5.isTupleTypeNode(type)) {
  1618. return [];
  1619. }
  1620. const res = [];
  1621. type.elements.forEach((el) => {
  1622. if (!ts5.isLiteralTypeNode(el) || !ts5.isStringLiteral(el.literal)) {
  1623. return;
  1624. }
  1625. res.push(el.literal.text);
  1626. });
  1627. return res;
  1628. }
  1629. function extractDirectiveTypeCheckMeta(node, inputs, reflector) {
  1630. const members = reflector.getMembersOfClass(node);
  1631. const staticMembers = members.filter((member) => member.isStatic);
  1632. const ngTemplateGuards = staticMembers.map(extractTemplateGuard).filter((guard) => guard !== null);
  1633. const hasNgTemplateContextGuard = staticMembers.some((member) => member.kind === ClassMemberKind.Method && member.name === "ngTemplateContextGuard");
  1634. const coercedInputFields = new Set(staticMembers.map(extractCoercedInput).filter((inputName) => {
  1635. var _a;
  1636. if (inputName === null || ((_a = inputs.getByClassPropertyName(inputName)) == null ? void 0 : _a.isSignal)) {
  1637. return false;
  1638. }
  1639. return true;
  1640. }));
  1641. const restrictedInputFields = /* @__PURE__ */ new Set();
  1642. const stringLiteralInputFields = /* @__PURE__ */ new Set();
  1643. const undeclaredInputFields = /* @__PURE__ */ new Set();
  1644. for (const { classPropertyName, transform } of inputs) {
  1645. const field = members.find((member) => member.name === classPropertyName);
  1646. if (field === void 0 || field.node === null) {
  1647. undeclaredInputFields.add(classPropertyName);
  1648. continue;
  1649. }
  1650. if (isRestricted(field.node)) {
  1651. restrictedInputFields.add(classPropertyName);
  1652. }
  1653. if (field.nameNode !== null && ts5.isStringLiteral(field.nameNode)) {
  1654. stringLiteralInputFields.add(classPropertyName);
  1655. }
  1656. if (transform !== null) {
  1657. coercedInputFields.add(classPropertyName);
  1658. }
  1659. }
  1660. const arity = reflector.getGenericArityOfClass(node);
  1661. return {
  1662. hasNgTemplateContextGuard,
  1663. ngTemplateGuards,
  1664. coercedInputFields,
  1665. restrictedInputFields,
  1666. stringLiteralInputFields,
  1667. undeclaredInputFields,
  1668. isGeneric: arity !== null && arity > 0
  1669. };
  1670. }
  1671. function isRestricted(node) {
  1672. const modifiers = ts5.canHaveModifiers(node) ? ts5.getModifiers(node) : void 0;
  1673. return modifiers !== void 0 && modifiers.some(({ kind }) => {
  1674. return kind === ts5.SyntaxKind.PrivateKeyword || kind === ts5.SyntaxKind.ProtectedKeyword || kind === ts5.SyntaxKind.ReadonlyKeyword;
  1675. });
  1676. }
  1677. function extractTemplateGuard(member) {
  1678. if (!member.name.startsWith("ngTemplateGuard_")) {
  1679. return null;
  1680. }
  1681. const inputName = afterUnderscore(member.name);
  1682. if (member.kind === ClassMemberKind.Property) {
  1683. let type = null;
  1684. if (member.type !== null && ts5.isLiteralTypeNode(member.type) && ts5.isStringLiteral(member.type.literal)) {
  1685. type = member.type.literal.text;
  1686. }
  1687. if (type !== "binding") {
  1688. return null;
  1689. }
  1690. return { inputName, type };
  1691. } else if (member.kind === ClassMemberKind.Method) {
  1692. return { inputName, type: "invocation" };
  1693. } else {
  1694. return null;
  1695. }
  1696. }
  1697. function extractCoercedInput(member) {
  1698. if (member.kind !== ClassMemberKind.Property || !member.name.startsWith("ngAcceptInputType_")) {
  1699. return null;
  1700. }
  1701. return afterUnderscore(member.name);
  1702. }
  1703. var CompoundMetadataReader = class {
  1704. readers;
  1705. constructor(readers) {
  1706. this.readers = readers;
  1707. }
  1708. getDirectiveMetadata(node) {
  1709. for (const reader of this.readers) {
  1710. const meta = reader.getDirectiveMetadata(node);
  1711. if (meta !== null) {
  1712. return meta;
  1713. }
  1714. }
  1715. return null;
  1716. }
  1717. getNgModuleMetadata(node) {
  1718. for (const reader of this.readers) {
  1719. const meta = reader.getNgModuleMetadata(node);
  1720. if (meta !== null) {
  1721. return meta;
  1722. }
  1723. }
  1724. return null;
  1725. }
  1726. getPipeMetadata(node) {
  1727. for (const reader of this.readers) {
  1728. const meta = reader.getPipeMetadata(node);
  1729. if (meta !== null) {
  1730. return meta;
  1731. }
  1732. }
  1733. return null;
  1734. }
  1735. };
  1736. function afterUnderscore(str) {
  1737. const pos = str.indexOf("_");
  1738. if (pos === -1) {
  1739. throw new Error(`Expected '${str}' to contain '_'`);
  1740. }
  1741. return str.slice(pos + 1);
  1742. }
  1743. function hasInjectableFields(clazz, host) {
  1744. const members = host.getMembersOfClass(clazz);
  1745. return members.some(({ isStatic, name }) => isStatic && (name === "\u0275prov" || name === "\u0275fac"));
  1746. }
  1747. function isHostDirectiveMetaForGlobalMode(hostDirectiveMeta) {
  1748. return hostDirectiveMeta.directive instanceof Reference;
  1749. }
  1750. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/metadata/src/dts.mjs
  1751. var DtsMetadataReader = class {
  1752. checker;
  1753. reflector;
  1754. constructor(checker, reflector) {
  1755. this.checker = checker;
  1756. this.reflector = reflector;
  1757. }
  1758. getNgModuleMetadata(ref) {
  1759. const clazz = ref.node;
  1760. const ngModuleDef = this.reflector.getMembersOfClass(clazz).find((member) => member.name === "\u0275mod" && member.isStatic);
  1761. if (ngModuleDef === void 0) {
  1762. return null;
  1763. } else if (ngModuleDef.type === null || !ts6.isTypeReferenceNode(ngModuleDef.type) || ngModuleDef.type.typeArguments === void 0 || ngModuleDef.type.typeArguments.length !== 4) {
  1764. return null;
  1765. }
  1766. const [_, declarationMetadata, importMetadata, exportMetadata] = ngModuleDef.type.typeArguments;
  1767. const declarations = extractReferencesFromType(this.checker, declarationMetadata, ref.bestGuessOwningModule);
  1768. const exports = extractReferencesFromType(this.checker, exportMetadata, ref.bestGuessOwningModule);
  1769. const imports = extractReferencesFromType(this.checker, importMetadata, ref.bestGuessOwningModule);
  1770. const isPoisoned = exports.isIncomplete;
  1771. return {
  1772. kind: MetaKind.NgModule,
  1773. ref,
  1774. declarations: declarations.result,
  1775. isPoisoned,
  1776. exports: exports.result,
  1777. imports: imports.result,
  1778. schemas: [],
  1779. rawDeclarations: null,
  1780. rawImports: null,
  1781. rawExports: null,
  1782. decorator: null,
  1783. mayDeclareProviders: true
  1784. };
  1785. }
  1786. getDirectiveMetadata(ref) {
  1787. var _a, _b, _c;
  1788. const clazz = ref.node;
  1789. const def = this.reflector.getMembersOfClass(clazz).find((field) => field.isStatic && (field.name === "\u0275cmp" || field.name === "\u0275dir"));
  1790. if (def === void 0) {
  1791. return null;
  1792. } else if (def.type === null || !ts6.isTypeReferenceNode(def.type) || def.type.typeArguments === void 0 || def.type.typeArguments.length < 2) {
  1793. return null;
  1794. }
  1795. const isComponent = def.name === "\u0275cmp";
  1796. const ctorParams = this.reflector.getConstructorParameters(clazz);
  1797. const isStructural = !isComponent && ctorParams !== null && ctorParams.some((param) => {
  1798. return param.typeValueReference.kind === 1 && param.typeValueReference.moduleName === "@angular/core" && param.typeValueReference.importedName === "TemplateRef";
  1799. });
  1800. const ngContentSelectors = def.type.typeArguments.length > 6 ? readStringArrayType(def.type.typeArguments[6]) : null;
  1801. const isStandalone = def.type.typeArguments.length > 7 && ((_a = readBooleanType(def.type.typeArguments[7])) != null ? _a : false);
  1802. const inputs = ClassPropertyMapping.fromMappedObject(readInputsType(def.type.typeArguments[3]));
  1803. const outputs = ClassPropertyMapping.fromMappedObject(readMapType(def.type.typeArguments[4], readStringType));
  1804. const hostDirectives = def.type.typeArguments.length > 8 ? readHostDirectivesType(this.checker, def.type.typeArguments[8], ref.bestGuessOwningModule) : null;
  1805. const isSignal = def.type.typeArguments.length > 9 && ((_b = readBooleanType(def.type.typeArguments[9])) != null ? _b : false);
  1806. const isPoisoned = hostDirectives !== null && (hostDirectives == null ? void 0 : hostDirectives.isIncomplete);
  1807. return {
  1808. kind: MetaKind.Directive,
  1809. matchSource: MatchSource.Selector,
  1810. ref,
  1811. name: clazz.name.text,
  1812. isComponent,
  1813. selector: readStringType(def.type.typeArguments[1]),
  1814. exportAs: readStringArrayType(def.type.typeArguments[2]),
  1815. inputs,
  1816. outputs,
  1817. hostDirectives: (_c = hostDirectives == null ? void 0 : hostDirectives.result) != null ? _c : null,
  1818. queries: readStringArrayType(def.type.typeArguments[5]),
  1819. ...extractDirectiveTypeCheckMeta(clazz, inputs, this.reflector),
  1820. baseClass: readBaseClass2(clazz, this.checker, this.reflector),
  1821. isPoisoned,
  1822. isStructural,
  1823. animationTriggerNames: null,
  1824. ngContentSelectors,
  1825. isStandalone,
  1826. isSignal,
  1827. inputFieldNamesFromMetadataArray: null,
  1828. imports: null,
  1829. rawImports: null,
  1830. deferredImports: null,
  1831. schemas: null,
  1832. decorator: null,
  1833. assumedToExportProviders: isComponent && isStandalone,
  1834. preserveWhitespaces: false,
  1835. isExplicitlyDeferred: false
  1836. };
  1837. }
  1838. getPipeMetadata(ref) {
  1839. var _a;
  1840. const def = this.reflector.getMembersOfClass(ref.node).find((field) => field.isStatic && field.name === "\u0275pipe");
  1841. if (def === void 0) {
  1842. return null;
  1843. } else if (def.type === null || !ts6.isTypeReferenceNode(def.type) || def.type.typeArguments === void 0 || def.type.typeArguments.length < 2) {
  1844. return null;
  1845. }
  1846. const type = def.type.typeArguments[1];
  1847. if (!ts6.isLiteralTypeNode(type) || !ts6.isStringLiteral(type.literal)) {
  1848. return null;
  1849. }
  1850. const name = type.literal.text;
  1851. const isStandalone = def.type.typeArguments.length > 2 && ((_a = readBooleanType(def.type.typeArguments[2])) != null ? _a : false);
  1852. return {
  1853. kind: MetaKind.Pipe,
  1854. ref,
  1855. name,
  1856. nameExpr: null,
  1857. isStandalone,
  1858. decorator: null,
  1859. isExplicitlyDeferred: false
  1860. };
  1861. }
  1862. };
  1863. function readInputsType(type) {
  1864. const inputsMap = {};
  1865. if (ts6.isTypeLiteralNode(type)) {
  1866. for (const member of type.members) {
  1867. if (!ts6.isPropertySignature(member) || member.type === void 0 || member.name === void 0 || !ts6.isStringLiteral(member.name) && !ts6.isIdentifier(member.name)) {
  1868. continue;
  1869. }
  1870. const stringValue = readStringType(member.type);
  1871. const classPropertyName = member.name.text;
  1872. if (stringValue != null) {
  1873. inputsMap[classPropertyName] = {
  1874. bindingPropertyName: stringValue,
  1875. classPropertyName,
  1876. required: false,
  1877. isSignal: false,
  1878. transform: null
  1879. };
  1880. } else {
  1881. const config = readMapType(member.type, (innerValue) => {
  1882. var _a;
  1883. return (_a = readStringType(innerValue)) != null ? _a : readBooleanType(innerValue);
  1884. });
  1885. inputsMap[classPropertyName] = {
  1886. classPropertyName,
  1887. bindingPropertyName: config.alias,
  1888. required: config.required,
  1889. isSignal: !!config.isSignal,
  1890. transform: null
  1891. };
  1892. }
  1893. }
  1894. }
  1895. return inputsMap;
  1896. }
  1897. function readBaseClass2(clazz, checker, reflector) {
  1898. if (!isNamedClassDeclaration(clazz)) {
  1899. return reflector.hasBaseClass(clazz) ? "dynamic" : null;
  1900. }
  1901. if (clazz.heritageClauses !== void 0) {
  1902. for (const clause of clazz.heritageClauses) {
  1903. if (clause.token === ts6.SyntaxKind.ExtendsKeyword) {
  1904. const baseExpr = clause.types[0].expression;
  1905. let symbol = checker.getSymbolAtLocation(baseExpr);
  1906. if (symbol === void 0) {
  1907. return "dynamic";
  1908. } else if (symbol.flags & ts6.SymbolFlags.Alias) {
  1909. symbol = checker.getAliasedSymbol(symbol);
  1910. }
  1911. if (symbol.valueDeclaration !== void 0 && isNamedClassDeclaration(symbol.valueDeclaration)) {
  1912. return new Reference(symbol.valueDeclaration);
  1913. } else {
  1914. return "dynamic";
  1915. }
  1916. }
  1917. }
  1918. }
  1919. return null;
  1920. }
  1921. function readHostDirectivesType(checker, type, bestGuessOwningModule) {
  1922. if (!ts6.isTupleTypeNode(type) || type.elements.length === 0) {
  1923. return null;
  1924. }
  1925. const result = [];
  1926. let isIncomplete = false;
  1927. for (const hostDirectiveType of type.elements) {
  1928. const { directive, inputs, outputs } = readMapType(hostDirectiveType, (type2) => type2);
  1929. if (directive) {
  1930. if (!ts6.isTypeQueryNode(directive)) {
  1931. throw new Error(`Expected TypeQueryNode: ${nodeDebugInfo(directive)}`);
  1932. }
  1933. const ref = extraReferenceFromTypeQuery(checker, directive, type, bestGuessOwningModule);
  1934. if (ref === null) {
  1935. isIncomplete = true;
  1936. continue;
  1937. }
  1938. result.push({
  1939. directive: ref,
  1940. isForwardReference: false,
  1941. inputs: readMapType(inputs, readStringType),
  1942. outputs: readMapType(outputs, readStringType)
  1943. });
  1944. }
  1945. }
  1946. return result.length > 0 ? { result, isIncomplete } : null;
  1947. }
  1948. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/metadata/src/inheritance.mjs
  1949. function flattenInheritedDirectiveMetadata(reader, dir) {
  1950. const topMeta = reader.getDirectiveMetadata(dir);
  1951. if (topMeta === null) {
  1952. return null;
  1953. }
  1954. if (topMeta.baseClass === null) {
  1955. return topMeta;
  1956. }
  1957. const coercedInputFields = /* @__PURE__ */ new Set();
  1958. const undeclaredInputFields = /* @__PURE__ */ new Set();
  1959. const restrictedInputFields = /* @__PURE__ */ new Set();
  1960. const stringLiteralInputFields = /* @__PURE__ */ new Set();
  1961. let hostDirectives = null;
  1962. let isDynamic = false;
  1963. let inputs = ClassPropertyMapping.empty();
  1964. let outputs = ClassPropertyMapping.empty();
  1965. let isStructural = false;
  1966. const addMetadata = (meta) => {
  1967. if (meta.baseClass === "dynamic") {
  1968. isDynamic = true;
  1969. } else if (meta.baseClass !== null) {
  1970. const baseMeta = reader.getDirectiveMetadata(meta.baseClass);
  1971. if (baseMeta !== null) {
  1972. addMetadata(baseMeta);
  1973. } else {
  1974. isDynamic = true;
  1975. }
  1976. }
  1977. isStructural = isStructural || meta.isStructural;
  1978. inputs = ClassPropertyMapping.merge(inputs, meta.inputs);
  1979. outputs = ClassPropertyMapping.merge(outputs, meta.outputs);
  1980. for (const coercedInputField of meta.coercedInputFields) {
  1981. coercedInputFields.add(coercedInputField);
  1982. }
  1983. for (const undeclaredInputField of meta.undeclaredInputFields) {
  1984. undeclaredInputFields.add(undeclaredInputField);
  1985. }
  1986. for (const restrictedInputField of meta.restrictedInputFields) {
  1987. restrictedInputFields.add(restrictedInputField);
  1988. }
  1989. for (const field of meta.stringLiteralInputFields) {
  1990. stringLiteralInputFields.add(field);
  1991. }
  1992. if (meta.hostDirectives !== null && meta.hostDirectives.length > 0) {
  1993. hostDirectives != null ? hostDirectives : hostDirectives = [];
  1994. hostDirectives.push(...meta.hostDirectives);
  1995. }
  1996. };
  1997. addMetadata(topMeta);
  1998. return {
  1999. ...topMeta,
  2000. inputs,
  2001. outputs,
  2002. coercedInputFields,
  2003. undeclaredInputFields,
  2004. restrictedInputFields,
  2005. stringLiteralInputFields,
  2006. baseClass: isDynamic ? "dynamic" : null,
  2007. isStructural,
  2008. hostDirectives
  2009. };
  2010. }
  2011. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/metadata/src/registry.mjs
  2012. var LocalMetadataRegistry = class {
  2013. directives = /* @__PURE__ */ new Map();
  2014. ngModules = /* @__PURE__ */ new Map();
  2015. pipes = /* @__PURE__ */ new Map();
  2016. getDirectiveMetadata(ref) {
  2017. return this.directives.has(ref.node) ? this.directives.get(ref.node) : null;
  2018. }
  2019. getNgModuleMetadata(ref) {
  2020. return this.ngModules.has(ref.node) ? this.ngModules.get(ref.node) : null;
  2021. }
  2022. getPipeMetadata(ref) {
  2023. return this.pipes.has(ref.node) ? this.pipes.get(ref.node) : null;
  2024. }
  2025. registerDirectiveMetadata(meta) {
  2026. this.directives.set(meta.ref.node, meta);
  2027. }
  2028. registerNgModuleMetadata(meta) {
  2029. this.ngModules.set(meta.ref.node, meta);
  2030. }
  2031. registerPipeMetadata(meta) {
  2032. this.pipes.set(meta.ref.node, meta);
  2033. }
  2034. getKnown(kind) {
  2035. switch (kind) {
  2036. case MetaKind.Directive:
  2037. return Array.from(this.directives.values()).map((v) => v.ref.node);
  2038. case MetaKind.Pipe:
  2039. return Array.from(this.pipes.values()).map((v) => v.ref.node);
  2040. case MetaKind.NgModule:
  2041. return Array.from(this.ngModules.values()).map((v) => v.ref.node);
  2042. }
  2043. }
  2044. };
  2045. var CompoundMetadataRegistry = class {
  2046. registries;
  2047. constructor(registries) {
  2048. this.registries = registries;
  2049. }
  2050. registerDirectiveMetadata(meta) {
  2051. for (const registry of this.registries) {
  2052. registry.registerDirectiveMetadata(meta);
  2053. }
  2054. }
  2055. registerNgModuleMetadata(meta) {
  2056. for (const registry of this.registries) {
  2057. registry.registerNgModuleMetadata(meta);
  2058. }
  2059. }
  2060. registerPipeMetadata(meta) {
  2061. for (const registry of this.registries) {
  2062. registry.registerPipeMetadata(meta);
  2063. }
  2064. }
  2065. };
  2066. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/metadata/src/resource_registry.mjs
  2067. var ResourceRegistry = class {
  2068. externalTemplateToComponentsMap = /* @__PURE__ */ new Map();
  2069. componentToTemplateMap = /* @__PURE__ */ new Map();
  2070. componentToStylesMap = /* @__PURE__ */ new Map();
  2071. externalStyleToComponentsMap = /* @__PURE__ */ new Map();
  2072. getComponentsWithTemplate(template) {
  2073. if (!this.externalTemplateToComponentsMap.has(template)) {
  2074. return /* @__PURE__ */ new Set();
  2075. }
  2076. return this.externalTemplateToComponentsMap.get(template);
  2077. }
  2078. registerResources(resources, directive) {
  2079. if (resources.template !== null) {
  2080. this.registerTemplate(resources.template, directive);
  2081. }
  2082. if (resources.styles !== null) {
  2083. for (const style of resources.styles) {
  2084. this.registerStyle(style, directive);
  2085. }
  2086. }
  2087. }
  2088. registerTemplate(templateResource, component) {
  2089. const { path } = templateResource;
  2090. if (path !== null) {
  2091. if (!this.externalTemplateToComponentsMap.has(path)) {
  2092. this.externalTemplateToComponentsMap.set(path, /* @__PURE__ */ new Set());
  2093. }
  2094. this.externalTemplateToComponentsMap.get(path).add(component);
  2095. }
  2096. this.componentToTemplateMap.set(component, templateResource);
  2097. }
  2098. getTemplate(component) {
  2099. if (!this.componentToTemplateMap.has(component)) {
  2100. return null;
  2101. }
  2102. return this.componentToTemplateMap.get(component);
  2103. }
  2104. registerStyle(styleResource, component) {
  2105. const { path } = styleResource;
  2106. if (!this.componentToStylesMap.has(component)) {
  2107. this.componentToStylesMap.set(component, /* @__PURE__ */ new Set());
  2108. }
  2109. if (path !== null) {
  2110. if (!this.externalStyleToComponentsMap.has(path)) {
  2111. this.externalStyleToComponentsMap.set(path, /* @__PURE__ */ new Set());
  2112. }
  2113. this.externalStyleToComponentsMap.get(path).add(component);
  2114. }
  2115. this.componentToStylesMap.get(component).add(styleResource);
  2116. }
  2117. getStyles(component) {
  2118. if (!this.componentToStylesMap.has(component)) {
  2119. return /* @__PURE__ */ new Set();
  2120. }
  2121. return this.componentToStylesMap.get(component);
  2122. }
  2123. getComponentsWithStyle(styleUrl) {
  2124. if (!this.externalStyleToComponentsMap.has(styleUrl)) {
  2125. return /* @__PURE__ */ new Set();
  2126. }
  2127. return this.externalStyleToComponentsMap.get(styleUrl);
  2128. }
  2129. };
  2130. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/metadata/src/providers.mjs
  2131. var ExportedProviderStatusResolver = class {
  2132. metaReader;
  2133. calculating = /* @__PURE__ */ new Set();
  2134. constructor(metaReader) {
  2135. this.metaReader = metaReader;
  2136. }
  2137. mayExportProviders(ref, dependencyCallback) {
  2138. var _a;
  2139. if (this.calculating.has(ref.node)) {
  2140. return false;
  2141. }
  2142. this.calculating.add(ref.node);
  2143. if (dependencyCallback !== void 0) {
  2144. dependencyCallback(ref);
  2145. }
  2146. try {
  2147. const dirMeta = this.metaReader.getDirectiveMetadata(ref);
  2148. if (dirMeta !== null) {
  2149. if (!dirMeta.isComponent || !dirMeta.isStandalone) {
  2150. return false;
  2151. }
  2152. if (dirMeta.assumedToExportProviders) {
  2153. return true;
  2154. }
  2155. return ((_a = dirMeta.imports) != null ? _a : []).some((importRef) => this.mayExportProviders(importRef, dependencyCallback));
  2156. }
  2157. const pipeMeta = this.metaReader.getPipeMetadata(ref);
  2158. if (pipeMeta !== null) {
  2159. return false;
  2160. }
  2161. const ngModuleMeta = this.metaReader.getNgModuleMetadata(ref);
  2162. if (ngModuleMeta !== null) {
  2163. if (ngModuleMeta.mayDeclareProviders) {
  2164. return true;
  2165. }
  2166. return ngModuleMeta.imports.some((importRef) => this.mayExportProviders(importRef, dependencyCallback));
  2167. }
  2168. return false;
  2169. } finally {
  2170. this.calculating.delete(ref.node);
  2171. }
  2172. }
  2173. };
  2174. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/metadata/src/host_directives_resolver.mjs
  2175. var EMPTY_ARRAY = [];
  2176. var HostDirectivesResolver = class {
  2177. metaReader;
  2178. cache = /* @__PURE__ */ new Map();
  2179. constructor(metaReader) {
  2180. this.metaReader = metaReader;
  2181. }
  2182. resolve(metadata) {
  2183. if (this.cache.has(metadata.ref.node)) {
  2184. return this.cache.get(metadata.ref.node);
  2185. }
  2186. const results = metadata.hostDirectives && metadata.hostDirectives.length > 0 ? this.walkHostDirectives(metadata.hostDirectives, []) : EMPTY_ARRAY;
  2187. this.cache.set(metadata.ref.node, results);
  2188. return results;
  2189. }
  2190. walkHostDirectives(directives, results) {
  2191. for (const current of directives) {
  2192. if (!isHostDirectiveMetaForGlobalMode(current)) {
  2193. throw new Error("Impossible state: resolving code path in local compilation mode");
  2194. }
  2195. const hostMeta = flattenInheritedDirectiveMetadata(this.metaReader, current.directive);
  2196. if (hostMeta === null) {
  2197. continue;
  2198. }
  2199. if (hostMeta.hostDirectives) {
  2200. this.walkHostDirectives(hostMeta.hostDirectives, results);
  2201. }
  2202. results.push({
  2203. ...hostMeta,
  2204. matchSource: MatchSource.HostDirective,
  2205. inputs: ClassPropertyMapping.fromMappedObject(this.filterMappings(hostMeta.inputs, current.inputs, resolveInput)),
  2206. outputs: ClassPropertyMapping.fromMappedObject(this.filterMappings(hostMeta.outputs, current.outputs, resolveOutput))
  2207. });
  2208. }
  2209. return results;
  2210. }
  2211. filterMappings(source, allowedProperties, valueResolver) {
  2212. const result = {};
  2213. if (allowedProperties !== null) {
  2214. for (const publicName in allowedProperties) {
  2215. if (allowedProperties.hasOwnProperty(publicName)) {
  2216. const bindings = source.getByBindingPropertyName(publicName);
  2217. if (bindings !== null) {
  2218. for (const binding of bindings) {
  2219. result[binding.classPropertyName] = valueResolver(allowedProperties[publicName], binding);
  2220. }
  2221. }
  2222. }
  2223. }
  2224. }
  2225. return result;
  2226. }
  2227. };
  2228. function resolveInput(bindingName, binding) {
  2229. return {
  2230. bindingPropertyName: bindingName,
  2231. classPropertyName: binding.classPropertyName,
  2232. required: binding.required,
  2233. transform: binding.transform,
  2234. isSignal: binding.isSignal
  2235. };
  2236. }
  2237. function resolveOutput(bindingName) {
  2238. return bindingName;
  2239. }
  2240. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/src/api.mjs
  2241. var CompilationMode;
  2242. (function(CompilationMode2) {
  2243. CompilationMode2[CompilationMode2["FULL"] = 0] = "FULL";
  2244. CompilationMode2[CompilationMode2["PARTIAL"] = 1] = "PARTIAL";
  2245. CompilationMode2[CompilationMode2["LOCAL"] = 2] = "LOCAL";
  2246. })(CompilationMode || (CompilationMode = {}));
  2247. var HandlerPrecedence;
  2248. (function(HandlerPrecedence2) {
  2249. HandlerPrecedence2[HandlerPrecedence2["PRIMARY"] = 0] = "PRIMARY";
  2250. HandlerPrecedence2[HandlerPrecedence2["SHARED"] = 1] = "SHARED";
  2251. HandlerPrecedence2[HandlerPrecedence2["WEAK"] = 2] = "WEAK";
  2252. })(HandlerPrecedence || (HandlerPrecedence = {}));
  2253. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/src/alias.mjs
  2254. import ts7 from "typescript";
  2255. function aliasTransformFactory(exportStatements) {
  2256. return () => {
  2257. return (file) => {
  2258. if (ts7.isBundle(file) || !exportStatements.has(file.fileName)) {
  2259. return file;
  2260. }
  2261. const statements = [...file.statements];
  2262. exportStatements.get(file.fileName).forEach(([moduleName, symbolName], aliasName) => {
  2263. const stmt = ts7.factory.createExportDeclaration(
  2264. void 0,
  2265. false,
  2266. ts7.factory.createNamedExports([
  2267. ts7.factory.createExportSpecifier(false, symbolName, aliasName)
  2268. ]),
  2269. ts7.factory.createStringLiteral(moduleName)
  2270. );
  2271. statements.push(stmt);
  2272. });
  2273. return ts7.factory.updateSourceFile(file, statements);
  2274. };
  2275. };
  2276. }
  2277. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/src/compilation.mjs
  2278. import ts8 from "typescript";
  2279. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/src/trait.mjs
  2280. var TraitState;
  2281. (function(TraitState2) {
  2282. TraitState2[TraitState2["Pending"] = 0] = "Pending";
  2283. TraitState2[TraitState2["Analyzed"] = 1] = "Analyzed";
  2284. TraitState2[TraitState2["Resolved"] = 2] = "Resolved";
  2285. TraitState2[TraitState2["Skipped"] = 3] = "Skipped";
  2286. })(TraitState || (TraitState = {}));
  2287. var Trait = {
  2288. pending: (handler, detected) => TraitImpl.pending(handler, detected)
  2289. };
  2290. var TraitImpl = class {
  2291. state = TraitState.Pending;
  2292. handler;
  2293. detected;
  2294. analysis = null;
  2295. symbol = null;
  2296. resolution = null;
  2297. analysisDiagnostics = null;
  2298. resolveDiagnostics = null;
  2299. typeCheckDiagnostics = null;
  2300. constructor(handler, detected) {
  2301. this.handler = handler;
  2302. this.detected = detected;
  2303. }
  2304. toAnalyzed(analysis, diagnostics, symbol) {
  2305. this.assertTransitionLegal(TraitState.Pending, TraitState.Analyzed);
  2306. this.analysis = analysis;
  2307. this.analysisDiagnostics = diagnostics;
  2308. this.symbol = symbol;
  2309. this.state = TraitState.Analyzed;
  2310. return this;
  2311. }
  2312. toResolved(resolution, diagnostics) {
  2313. this.assertTransitionLegal(TraitState.Analyzed, TraitState.Resolved);
  2314. if (this.analysis === null) {
  2315. throw new Error(`Cannot transition an Analyzed trait with a null analysis to Resolved`);
  2316. }
  2317. this.resolution = resolution;
  2318. this.state = TraitState.Resolved;
  2319. this.resolveDiagnostics = diagnostics;
  2320. this.typeCheckDiagnostics = null;
  2321. return this;
  2322. }
  2323. toSkipped() {
  2324. this.assertTransitionLegal(TraitState.Pending, TraitState.Skipped);
  2325. this.state = TraitState.Skipped;
  2326. return this;
  2327. }
  2328. assertTransitionLegal(allowedState, transitionTo) {
  2329. if (!(this.state === allowedState)) {
  2330. throw new Error(`Assertion failure: cannot transition from ${TraitState[this.state]} to ${TraitState[transitionTo]}.`);
  2331. }
  2332. }
  2333. static pending(handler, detected) {
  2334. return new TraitImpl(handler, detected);
  2335. }
  2336. };
  2337. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/src/compilation.mjs
  2338. var TraitCompiler = class {
  2339. handlers;
  2340. reflector;
  2341. perf;
  2342. incrementalBuild;
  2343. compileNonExportedClasses;
  2344. compilationMode;
  2345. dtsTransforms;
  2346. semanticDepGraphUpdater;
  2347. sourceFileTypeIdentifier;
  2348. classes = /* @__PURE__ */ new Map();
  2349. fileToClasses = /* @__PURE__ */ new Map();
  2350. filesWithoutTraits = /* @__PURE__ */ new Set();
  2351. reexportMap = /* @__PURE__ */ new Map();
  2352. handlersByName = /* @__PURE__ */ new Map();
  2353. constructor(handlers, reflector, perf, incrementalBuild, compileNonExportedClasses, compilationMode, dtsTransforms, semanticDepGraphUpdater, sourceFileTypeIdentifier) {
  2354. this.handlers = handlers;
  2355. this.reflector = reflector;
  2356. this.perf = perf;
  2357. this.incrementalBuild = incrementalBuild;
  2358. this.compileNonExportedClasses = compileNonExportedClasses;
  2359. this.compilationMode = compilationMode;
  2360. this.dtsTransforms = dtsTransforms;
  2361. this.semanticDepGraphUpdater = semanticDepGraphUpdater;
  2362. this.sourceFileTypeIdentifier = sourceFileTypeIdentifier;
  2363. for (const handler of handlers) {
  2364. this.handlersByName.set(handler.name, handler);
  2365. }
  2366. }
  2367. analyzeSync(sf) {
  2368. this.analyze(sf, false);
  2369. }
  2370. analyzeAsync(sf) {
  2371. return this.analyze(sf, true);
  2372. }
  2373. analyze(sf, preanalyze) {
  2374. if (sf.isDeclarationFile || this.sourceFileTypeIdentifier.isShim(sf) || this.sourceFileTypeIdentifier.isResource(sf)) {
  2375. return void 0;
  2376. }
  2377. const promises = [];
  2378. const priorWork = this.compilationMode !== CompilationMode.LOCAL ? this.incrementalBuild.priorAnalysisFor(sf) : null;
  2379. if (priorWork !== null) {
  2380. this.perf.eventCount(PerfEvent.SourceFileReuseAnalysis);
  2381. if (priorWork.length > 0) {
  2382. for (const priorRecord of priorWork) {
  2383. this.adopt(priorRecord);
  2384. }
  2385. this.perf.eventCount(PerfEvent.TraitReuseAnalysis, priorWork.length);
  2386. } else {
  2387. this.filesWithoutTraits.add(sf);
  2388. }
  2389. return;
  2390. }
  2391. const visit2 = (node) => {
  2392. if (this.reflector.isClass(node)) {
  2393. this.analyzeClass(node, preanalyze ? promises : null);
  2394. }
  2395. ts8.forEachChild(node, visit2);
  2396. };
  2397. visit2(sf);
  2398. if (!this.fileToClasses.has(sf)) {
  2399. this.filesWithoutTraits.add(sf);
  2400. }
  2401. if (preanalyze && promises.length > 0) {
  2402. return Promise.all(promises).then(() => void 0);
  2403. } else {
  2404. return void 0;
  2405. }
  2406. }
  2407. recordFor(clazz) {
  2408. if (this.classes.has(clazz)) {
  2409. return this.classes.get(clazz);
  2410. } else {
  2411. return null;
  2412. }
  2413. }
  2414. getAnalyzedRecords() {
  2415. const result = /* @__PURE__ */ new Map();
  2416. for (const [sf, classes] of this.fileToClasses) {
  2417. const records = [];
  2418. for (const clazz of classes) {
  2419. records.push(this.classes.get(clazz));
  2420. }
  2421. result.set(sf, records);
  2422. }
  2423. for (const sf of this.filesWithoutTraits) {
  2424. result.set(sf, []);
  2425. }
  2426. return result;
  2427. }
  2428. adopt(priorRecord) {
  2429. const record = {
  2430. hasPrimaryHandler: priorRecord.hasPrimaryHandler,
  2431. hasWeakHandlers: priorRecord.hasWeakHandlers,
  2432. metaDiagnostics: priorRecord.metaDiagnostics,
  2433. node: priorRecord.node,
  2434. traits: []
  2435. };
  2436. for (const priorTrait of priorRecord.traits) {
  2437. const handler = this.handlersByName.get(priorTrait.handler.name);
  2438. let trait = Trait.pending(handler, priorTrait.detected);
  2439. if (priorTrait.state === TraitState.Analyzed || priorTrait.state === TraitState.Resolved) {
  2440. const symbol = this.makeSymbolForTrait(handler, record.node, priorTrait.analysis);
  2441. trait = trait.toAnalyzed(priorTrait.analysis, priorTrait.analysisDiagnostics, symbol);
  2442. if (trait.analysis !== null && trait.handler.register !== void 0) {
  2443. trait.handler.register(record.node, trait.analysis);
  2444. }
  2445. } else if (priorTrait.state === TraitState.Skipped) {
  2446. trait = trait.toSkipped();
  2447. }
  2448. record.traits.push(trait);
  2449. }
  2450. this.classes.set(record.node, record);
  2451. const sf = record.node.getSourceFile();
  2452. if (!this.fileToClasses.has(sf)) {
  2453. this.fileToClasses.set(sf, /* @__PURE__ */ new Set());
  2454. }
  2455. this.fileToClasses.get(sf).add(record.node);
  2456. }
  2457. scanClassForTraits(clazz) {
  2458. if (!this.compileNonExportedClasses && !this.reflector.isStaticallyExported(clazz)) {
  2459. return null;
  2460. }
  2461. const decorators = this.reflector.getDecoratorsOfDeclaration(clazz);
  2462. return this.detectTraits(clazz, decorators);
  2463. }
  2464. detectTraits(clazz, decorators) {
  2465. let record = this.recordFor(clazz);
  2466. let foundTraits = [];
  2467. const nonNgDecoratorsInLocalMode = this.compilationMode === CompilationMode.LOCAL ? new Set(decorators) : null;
  2468. for (const handler of this.handlers) {
  2469. const result = handler.detect(clazz, decorators);
  2470. if (result === void 0) {
  2471. continue;
  2472. }
  2473. if (nonNgDecoratorsInLocalMode !== null && result.decorator !== null) {
  2474. nonNgDecoratorsInLocalMode.delete(result.decorator);
  2475. }
  2476. const isPrimaryHandler = handler.precedence === HandlerPrecedence.PRIMARY;
  2477. const isWeakHandler = handler.precedence === HandlerPrecedence.WEAK;
  2478. const trait = Trait.pending(handler, result);
  2479. foundTraits.push(trait);
  2480. if (record === null) {
  2481. record = {
  2482. node: clazz,
  2483. traits: [trait],
  2484. metaDiagnostics: null,
  2485. hasPrimaryHandler: isPrimaryHandler,
  2486. hasWeakHandlers: isWeakHandler
  2487. };
  2488. this.classes.set(clazz, record);
  2489. const sf = clazz.getSourceFile();
  2490. if (!this.fileToClasses.has(sf)) {
  2491. this.fileToClasses.set(sf, /* @__PURE__ */ new Set());
  2492. }
  2493. this.fileToClasses.get(sf).add(clazz);
  2494. } else {
  2495. if (!isWeakHandler && record.hasWeakHandlers) {
  2496. record.traits = record.traits.filter((field) => field.handler.precedence !== HandlerPrecedence.WEAK);
  2497. record.hasWeakHandlers = false;
  2498. } else if (isWeakHandler && !record.hasWeakHandlers) {
  2499. continue;
  2500. }
  2501. if (isPrimaryHandler && record.hasPrimaryHandler) {
  2502. record.metaDiagnostics = [
  2503. {
  2504. category: ts8.DiagnosticCategory.Error,
  2505. code: Number("-99" + ErrorCode.DECORATOR_COLLISION),
  2506. file: getSourceFile(clazz),
  2507. start: clazz.getStart(void 0, false),
  2508. length: clazz.getWidth(),
  2509. messageText: "Two incompatible decorators on class"
  2510. }
  2511. ];
  2512. record.traits = foundTraits = [];
  2513. break;
  2514. }
  2515. record.traits.push(trait);
  2516. record.hasPrimaryHandler = record.hasPrimaryHandler || isPrimaryHandler;
  2517. }
  2518. }
  2519. if (nonNgDecoratorsInLocalMode !== null && nonNgDecoratorsInLocalMode.size > 0 && record !== null && record.metaDiagnostics === null) {
  2520. record.metaDiagnostics = [...nonNgDecoratorsInLocalMode].map((decorator) => ({
  2521. category: ts8.DiagnosticCategory.Error,
  2522. code: Number("-99" + ErrorCode.DECORATOR_UNEXPECTED),
  2523. file: getSourceFile(clazz),
  2524. start: decorator.node.getStart(),
  2525. length: decorator.node.getWidth(),
  2526. messageText: "In local compilation mode, Angular does not support custom decorators. Ensure all class decorators are from Angular."
  2527. }));
  2528. record.traits = foundTraits = [];
  2529. }
  2530. return foundTraits.length > 0 ? foundTraits : null;
  2531. }
  2532. makeSymbolForTrait(handler, decl, analysis) {
  2533. if (analysis === null) {
  2534. return null;
  2535. }
  2536. const symbol = handler.symbol(decl, analysis);
  2537. if (symbol !== null && this.semanticDepGraphUpdater !== null) {
  2538. const isPrimary = handler.precedence === HandlerPrecedence.PRIMARY;
  2539. if (!isPrimary) {
  2540. throw new Error(`AssertionError: ${handler.name} returned a symbol but is not a primary handler.`);
  2541. }
  2542. this.semanticDepGraphUpdater.registerSymbol(symbol);
  2543. }
  2544. return symbol;
  2545. }
  2546. analyzeClass(clazz, preanalyzeQueue) {
  2547. const traits = this.scanClassForTraits(clazz);
  2548. if (traits === null) {
  2549. return;
  2550. }
  2551. for (const trait of traits) {
  2552. const analyze = () => this.analyzeTrait(clazz, trait);
  2553. let preanalysis = null;
  2554. if (preanalyzeQueue !== null && trait.handler.preanalyze !== void 0) {
  2555. try {
  2556. preanalysis = trait.handler.preanalyze(clazz, trait.detected.metadata) || null;
  2557. } catch (err) {
  2558. if (err instanceof FatalDiagnosticError) {
  2559. trait.toAnalyzed(null, [err.toDiagnostic()], null);
  2560. return;
  2561. } else {
  2562. throw err;
  2563. }
  2564. }
  2565. }
  2566. if (preanalysis !== null) {
  2567. preanalyzeQueue.push(preanalysis.then(analyze));
  2568. } else {
  2569. analyze();
  2570. }
  2571. }
  2572. }
  2573. analyzeTrait(clazz, trait) {
  2574. var _a, _b, _c;
  2575. if (trait.state !== TraitState.Pending) {
  2576. throw new Error(`Attempt to analyze trait of ${clazz.name.text} in state ${TraitState[trait.state]} (expected DETECTED)`);
  2577. }
  2578. this.perf.eventCount(PerfEvent.TraitAnalyze);
  2579. let result;
  2580. try {
  2581. result = trait.handler.analyze(clazz, trait.detected.metadata);
  2582. } catch (err) {
  2583. if (err instanceof FatalDiagnosticError) {
  2584. trait.toAnalyzed(null, [err.toDiagnostic()], null);
  2585. return;
  2586. } else {
  2587. throw err;
  2588. }
  2589. }
  2590. const symbol = this.makeSymbolForTrait(trait.handler, clazz, (_a = result.analysis) != null ? _a : null);
  2591. if (result.analysis !== void 0 && trait.handler.register !== void 0) {
  2592. trait.handler.register(clazz, result.analysis);
  2593. }
  2594. trait = trait.toAnalyzed((_b = result.analysis) != null ? _b : null, (_c = result.diagnostics) != null ? _c : null, symbol);
  2595. }
  2596. resolve() {
  2597. var _a, _b;
  2598. const classes = this.classes.keys();
  2599. for (const clazz of classes) {
  2600. const record = this.classes.get(clazz);
  2601. for (let trait of record.traits) {
  2602. const handler = trait.handler;
  2603. switch (trait.state) {
  2604. case TraitState.Skipped:
  2605. continue;
  2606. case TraitState.Pending:
  2607. throw new Error(`Resolving a trait that hasn't been analyzed: ${clazz.name.text} / ${trait.handler.name}`);
  2608. case TraitState.Resolved:
  2609. throw new Error(`Resolving an already resolved trait`);
  2610. }
  2611. if (trait.analysis === null) {
  2612. continue;
  2613. }
  2614. if (handler.resolve === void 0) {
  2615. trait = trait.toResolved(null, null);
  2616. continue;
  2617. }
  2618. let result;
  2619. try {
  2620. result = handler.resolve(clazz, trait.analysis, trait.symbol);
  2621. } catch (err) {
  2622. if (err instanceof FatalDiagnosticError) {
  2623. trait = trait.toResolved(null, [err.toDiagnostic()]);
  2624. continue;
  2625. } else {
  2626. throw err;
  2627. }
  2628. }
  2629. trait = trait.toResolved((_a = result.data) != null ? _a : null, (_b = result.diagnostics) != null ? _b : null);
  2630. if (result.reexports !== void 0) {
  2631. const fileName = clazz.getSourceFile().fileName;
  2632. if (!this.reexportMap.has(fileName)) {
  2633. this.reexportMap.set(fileName, /* @__PURE__ */ new Map());
  2634. }
  2635. const fileReexports = this.reexportMap.get(fileName);
  2636. for (const reexport of result.reexports) {
  2637. fileReexports.set(reexport.asAlias, [reexport.fromModule, reexport.symbolName]);
  2638. }
  2639. }
  2640. }
  2641. }
  2642. }
  2643. typeCheck(sf, ctx) {
  2644. if (!this.fileToClasses.has(sf) || this.compilationMode === CompilationMode.LOCAL) {
  2645. return;
  2646. }
  2647. for (const clazz of this.fileToClasses.get(sf)) {
  2648. const record = this.classes.get(clazz);
  2649. for (const trait of record.traits) {
  2650. if (trait.state !== TraitState.Resolved) {
  2651. continue;
  2652. } else if (trait.handler.typeCheck === void 0) {
  2653. continue;
  2654. }
  2655. if (trait.resolution !== null) {
  2656. trait.handler.typeCheck(ctx, clazz, trait.analysis, trait.resolution);
  2657. }
  2658. }
  2659. }
  2660. }
  2661. runAdditionalChecks(sf, check) {
  2662. if (this.compilationMode === CompilationMode.LOCAL) {
  2663. return [];
  2664. }
  2665. const classes = this.fileToClasses.get(sf);
  2666. if (classes === void 0) {
  2667. return [];
  2668. }
  2669. const diagnostics = [];
  2670. for (const clazz of classes) {
  2671. if (!isNamedClassDeclaration(clazz)) {
  2672. continue;
  2673. }
  2674. const record = this.classes.get(clazz);
  2675. for (const trait of record.traits) {
  2676. const result = check(clazz, trait.handler);
  2677. if (result !== null) {
  2678. diagnostics.push(...result);
  2679. }
  2680. }
  2681. }
  2682. return diagnostics;
  2683. }
  2684. index(ctx) {
  2685. for (const clazz of this.classes.keys()) {
  2686. const record = this.classes.get(clazz);
  2687. for (const trait of record.traits) {
  2688. if (trait.state !== TraitState.Resolved) {
  2689. continue;
  2690. } else if (trait.handler.index === void 0) {
  2691. continue;
  2692. }
  2693. if (trait.resolution !== null) {
  2694. trait.handler.index(ctx, clazz, trait.analysis, trait.resolution);
  2695. }
  2696. }
  2697. }
  2698. }
  2699. xi18n(bundle) {
  2700. for (const clazz of this.classes.keys()) {
  2701. const record = this.classes.get(clazz);
  2702. for (const trait of record.traits) {
  2703. if (trait.state !== TraitState.Analyzed && trait.state !== TraitState.Resolved) {
  2704. continue;
  2705. } else if (trait.handler.xi18n === void 0) {
  2706. continue;
  2707. }
  2708. if (trait.analysis !== null) {
  2709. trait.handler.xi18n(bundle, clazz, trait.analysis);
  2710. }
  2711. }
  2712. }
  2713. }
  2714. updateResources(clazz) {
  2715. if (this.compilationMode === CompilationMode.LOCAL || !this.reflector.isClass(clazz) || !this.classes.has(clazz)) {
  2716. return;
  2717. }
  2718. const record = this.classes.get(clazz);
  2719. for (const trait of record.traits) {
  2720. if (trait.state !== TraitState.Resolved || trait.handler.updateResources === void 0) {
  2721. continue;
  2722. }
  2723. trait.handler.updateResources(clazz, trait.analysis, trait.resolution);
  2724. }
  2725. }
  2726. compile(clazz, constantPool) {
  2727. const original = ts8.getOriginalNode(clazz);
  2728. if (!this.reflector.isClass(clazz) || !this.reflector.isClass(original) || !this.classes.has(original)) {
  2729. return null;
  2730. }
  2731. const record = this.classes.get(original);
  2732. let res = [];
  2733. for (const trait of record.traits) {
  2734. let compileRes;
  2735. if (trait.state !== TraitState.Resolved || containsErrors(trait.analysisDiagnostics) || containsErrors(trait.resolveDiagnostics)) {
  2736. continue;
  2737. }
  2738. if (this.compilationMode === CompilationMode.LOCAL) {
  2739. compileRes = trait.handler.compileLocal(clazz, trait.analysis, trait.resolution, constantPool);
  2740. } else {
  2741. if (this.compilationMode === CompilationMode.PARTIAL && trait.handler.compilePartial !== void 0) {
  2742. compileRes = trait.handler.compilePartial(clazz, trait.analysis, trait.resolution);
  2743. } else {
  2744. compileRes = trait.handler.compileFull(clazz, trait.analysis, trait.resolution, constantPool);
  2745. }
  2746. }
  2747. const compileMatchRes = compileRes;
  2748. if (Array.isArray(compileMatchRes)) {
  2749. for (const result of compileMatchRes) {
  2750. if (!res.some((r) => r.name === result.name)) {
  2751. res.push(result);
  2752. }
  2753. }
  2754. } else if (!res.some((result) => result.name === compileMatchRes.name)) {
  2755. res.push(compileMatchRes);
  2756. }
  2757. }
  2758. this.dtsTransforms.getIvyDeclarationTransform(original.getSourceFile()).addFields(original, res);
  2759. return res.length > 0 ? res : null;
  2760. }
  2761. compileHmrUpdateCallback(clazz) {
  2762. const original = ts8.getOriginalNode(clazz);
  2763. if (!this.reflector.isClass(clazz) || !this.reflector.isClass(original) || !this.classes.has(original)) {
  2764. return null;
  2765. }
  2766. const record = this.classes.get(original);
  2767. for (const trait of record.traits) {
  2768. if (trait.state === TraitState.Resolved && trait.handler.compileHmrUpdateDeclaration !== void 0 && !containsErrors(trait.analysisDiagnostics) && !containsErrors(trait.resolveDiagnostics)) {
  2769. return trait.handler.compileHmrUpdateDeclaration(clazz, trait.analysis, trait.resolution);
  2770. }
  2771. }
  2772. return null;
  2773. }
  2774. decoratorsFor(node) {
  2775. const original = ts8.getOriginalNode(node);
  2776. if (!this.reflector.isClass(original) || !this.classes.has(original)) {
  2777. return [];
  2778. }
  2779. const record = this.classes.get(original);
  2780. const decorators = [];
  2781. for (const trait of record.traits) {
  2782. if (this.compilationMode !== CompilationMode.LOCAL && trait.state !== TraitState.Resolved) {
  2783. continue;
  2784. }
  2785. if (trait.detected.trigger !== null && ts8.isDecorator(trait.detected.trigger)) {
  2786. decorators.push(trait.detected.trigger);
  2787. }
  2788. }
  2789. return decorators;
  2790. }
  2791. get diagnostics() {
  2792. var _a;
  2793. const diagnostics = [];
  2794. for (const clazz of this.classes.keys()) {
  2795. const record = this.classes.get(clazz);
  2796. if (record.metaDiagnostics !== null) {
  2797. diagnostics.push(...record.metaDiagnostics);
  2798. }
  2799. for (const trait of record.traits) {
  2800. if ((trait.state === TraitState.Analyzed || trait.state === TraitState.Resolved) && trait.analysisDiagnostics !== null) {
  2801. diagnostics.push(...trait.analysisDiagnostics);
  2802. }
  2803. if (trait.state === TraitState.Resolved) {
  2804. diagnostics.push(...(_a = trait.resolveDiagnostics) != null ? _a : []);
  2805. }
  2806. }
  2807. }
  2808. return diagnostics;
  2809. }
  2810. get exportStatements() {
  2811. return this.reexportMap;
  2812. }
  2813. };
  2814. function containsErrors(diagnostics) {
  2815. return diagnostics !== null && diagnostics.some((diag) => diag.category === ts8.DiagnosticCategory.Error);
  2816. }
  2817. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/src/declaration.mjs
  2818. import ts9 from "typescript";
  2819. var DtsTransformRegistry = class {
  2820. ivyDeclarationTransforms = /* @__PURE__ */ new Map();
  2821. getIvyDeclarationTransform(sf) {
  2822. if (!this.ivyDeclarationTransforms.has(sf)) {
  2823. this.ivyDeclarationTransforms.set(sf, new IvyDeclarationDtsTransform());
  2824. }
  2825. return this.ivyDeclarationTransforms.get(sf);
  2826. }
  2827. getAllTransforms(sf) {
  2828. if (!sf.isDeclarationFile) {
  2829. return null;
  2830. }
  2831. const originalSf = ts9.getOriginalNode(sf);
  2832. let transforms = null;
  2833. if (this.ivyDeclarationTransforms.has(originalSf)) {
  2834. transforms = [];
  2835. transforms.push(this.ivyDeclarationTransforms.get(originalSf));
  2836. }
  2837. return transforms;
  2838. }
  2839. };
  2840. function declarationTransformFactory(transformRegistry, reflector, refEmitter, importRewriter) {
  2841. return (context) => {
  2842. const transformer = new DtsTransformer(context, reflector, refEmitter, importRewriter);
  2843. return (fileOrBundle) => {
  2844. if (ts9.isBundle(fileOrBundle)) {
  2845. return fileOrBundle;
  2846. }
  2847. const transforms = transformRegistry.getAllTransforms(fileOrBundle);
  2848. if (transforms === null) {
  2849. return fileOrBundle;
  2850. }
  2851. return transformer.transform(fileOrBundle, transforms);
  2852. };
  2853. };
  2854. }
  2855. var DtsTransformer = class {
  2856. ctx;
  2857. reflector;
  2858. refEmitter;
  2859. importRewriter;
  2860. constructor(ctx, reflector, refEmitter, importRewriter) {
  2861. this.ctx = ctx;
  2862. this.reflector = reflector;
  2863. this.refEmitter = refEmitter;
  2864. this.importRewriter = importRewriter;
  2865. }
  2866. transform(sf, transforms) {
  2867. const imports = new ImportManager({
  2868. ...presetImportManagerForceNamespaceImports,
  2869. rewriter: this.importRewriter
  2870. });
  2871. const visitor = (node) => {
  2872. if (ts9.isClassDeclaration(node)) {
  2873. return this.transformClassDeclaration(node, transforms, imports);
  2874. } else if (ts9.isFunctionDeclaration(node)) {
  2875. return this.transformFunctionDeclaration(node, transforms, imports);
  2876. } else {
  2877. return ts9.visitEachChild(node, visitor, this.ctx);
  2878. }
  2879. };
  2880. sf = ts9.visitNode(sf, visitor, ts9.isSourceFile) || sf;
  2881. return imports.transformTsFile(this.ctx, sf);
  2882. }
  2883. transformClassDeclaration(clazz, transforms, imports) {
  2884. let elements = clazz.members;
  2885. let elementsChanged = false;
  2886. for (const transform of transforms) {
  2887. if (transform.transformClassElement !== void 0) {
  2888. for (let i = 0; i < elements.length; i++) {
  2889. const res = transform.transformClassElement(elements[i], imports);
  2890. if (res !== elements[i]) {
  2891. if (!elementsChanged) {
  2892. elements = [...elements];
  2893. elementsChanged = true;
  2894. }
  2895. elements[i] = res;
  2896. }
  2897. }
  2898. }
  2899. }
  2900. let newClazz = clazz;
  2901. for (const transform of transforms) {
  2902. if (transform.transformClass !== void 0) {
  2903. const inputMembers = clazz === newClazz ? elements : newClazz.members;
  2904. newClazz = transform.transformClass(newClazz, inputMembers, this.reflector, this.refEmitter, imports);
  2905. }
  2906. }
  2907. if (elementsChanged && clazz === newClazz) {
  2908. newClazz = ts9.factory.updateClassDeclaration(
  2909. clazz,
  2910. clazz.modifiers,
  2911. clazz.name,
  2912. clazz.typeParameters,
  2913. clazz.heritageClauses,
  2914. elements
  2915. );
  2916. }
  2917. return newClazz;
  2918. }
  2919. transformFunctionDeclaration(declaration, transforms, imports) {
  2920. let newDecl = declaration;
  2921. for (const transform of transforms) {
  2922. if (transform.transformFunctionDeclaration !== void 0) {
  2923. newDecl = transform.transformFunctionDeclaration(newDecl, imports);
  2924. }
  2925. }
  2926. return newDecl;
  2927. }
  2928. };
  2929. var IvyDeclarationDtsTransform = class {
  2930. declarationFields = /* @__PURE__ */ new Map();
  2931. addFields(decl, fields) {
  2932. this.declarationFields.set(decl, fields);
  2933. }
  2934. transformClass(clazz, members, reflector, refEmitter, imports) {
  2935. const original = ts9.getOriginalNode(clazz);
  2936. if (!this.declarationFields.has(original)) {
  2937. return clazz;
  2938. }
  2939. const fields = this.declarationFields.get(original);
  2940. const newMembers = fields.map((decl) => {
  2941. const modifiers = [ts9.factory.createModifier(ts9.SyntaxKind.StaticKeyword)];
  2942. const typeRef = translateType(decl.type, original.getSourceFile(), reflector, refEmitter, imports);
  2943. markForEmitAsSingleLine(typeRef);
  2944. return ts9.factory.createPropertyDeclaration(
  2945. modifiers,
  2946. decl.name,
  2947. void 0,
  2948. typeRef,
  2949. void 0
  2950. );
  2951. });
  2952. return ts9.factory.updateClassDeclaration(
  2953. clazz,
  2954. clazz.modifiers,
  2955. clazz.name,
  2956. clazz.typeParameters,
  2957. clazz.heritageClauses,
  2958. [...members, ...newMembers]
  2959. );
  2960. }
  2961. };
  2962. function markForEmitAsSingleLine(node) {
  2963. ts9.setEmitFlags(node, ts9.EmitFlags.SingleLine);
  2964. ts9.forEachChild(node, markForEmitAsSingleLine);
  2965. }
  2966. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/src/transform.mjs
  2967. import { ConstantPool } from "@angular/compiler";
  2968. import ts11 from "typescript";
  2969. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/util/src/visitor.mjs
  2970. import ts10 from "typescript";
  2971. function visit(node, visitor, context) {
  2972. return visitor._visit(node, context);
  2973. }
  2974. var Visitor = class {
  2975. _before = /* @__PURE__ */ new Map();
  2976. _after = /* @__PURE__ */ new Map();
  2977. _visitListEntryNode(node, visitor) {
  2978. const result = visitor(node);
  2979. if (result.before !== void 0) {
  2980. this._before.set(result.node, result.before);
  2981. }
  2982. if (result.after !== void 0) {
  2983. this._after.set(result.node, result.after);
  2984. }
  2985. return result.node;
  2986. }
  2987. visitOtherNode(node) {
  2988. return node;
  2989. }
  2990. _visit(node, context) {
  2991. let visitedNode = null;
  2992. node = ts10.visitEachChild(node, (child) => child && this._visit(child, context), context);
  2993. if (ts10.isClassDeclaration(node)) {
  2994. visitedNode = this._visitListEntryNode(node, (node2) => this.visitClassDeclaration(node2));
  2995. } else {
  2996. visitedNode = this.visitOtherNode(node);
  2997. }
  2998. if (visitedNode && (ts10.isBlock(visitedNode) || ts10.isSourceFile(visitedNode))) {
  2999. visitedNode = this._maybeProcessStatements(visitedNode);
  3000. }
  3001. return visitedNode;
  3002. }
  3003. _maybeProcessStatements(node) {
  3004. if (node.statements.every((stmt) => !this._before.has(stmt) && !this._after.has(stmt))) {
  3005. return node;
  3006. }
  3007. const newStatements = [];
  3008. node.statements.forEach((stmt) => {
  3009. if (this._before.has(stmt)) {
  3010. newStatements.push(...this._before.get(stmt));
  3011. this._before.delete(stmt);
  3012. }
  3013. newStatements.push(stmt);
  3014. if (this._after.has(stmt)) {
  3015. newStatements.push(...this._after.get(stmt));
  3016. this._after.delete(stmt);
  3017. }
  3018. });
  3019. const statementsArray = ts10.factory.createNodeArray(newStatements, node.statements.hasTrailingComma);
  3020. if (ts10.isBlock(node)) {
  3021. return ts10.factory.updateBlock(node, statementsArray);
  3022. } else {
  3023. return ts10.factory.updateSourceFile(node, statementsArray, node.isDeclarationFile, node.referencedFiles, node.typeReferenceDirectives, node.hasNoDefaultLib, node.libReferenceDirectives);
  3024. }
  3025. }
  3026. };
  3027. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/transform/src/transform.mjs
  3028. var NO_DECORATORS = /* @__PURE__ */ new Set();
  3029. var CLOSURE_FILE_OVERVIEW_REGEXP = /\s+@fileoverview\s+/i;
  3030. function ivyTransformFactory(compilation, reflector, importRewriter, defaultImportTracker, localCompilationExtraImportsTracker, perf, isCore, isClosureCompilerEnabled) {
  3031. const recordWrappedNode = createRecorderFn(defaultImportTracker);
  3032. return (context) => {
  3033. return (file) => {
  3034. return perf.inPhase(PerfPhase.Compile, () => transformIvySourceFile(compilation, context, reflector, importRewriter, localCompilationExtraImportsTracker, file, isCore, isClosureCompilerEnabled, recordWrappedNode));
  3035. };
  3036. };
  3037. }
  3038. var IvyCompilationVisitor = class extends Visitor {
  3039. compilation;
  3040. constantPool;
  3041. classCompilationMap = /* @__PURE__ */ new Map();
  3042. deferrableImports = /* @__PURE__ */ new Set();
  3043. constructor(compilation, constantPool) {
  3044. super();
  3045. this.compilation = compilation;
  3046. this.constantPool = constantPool;
  3047. }
  3048. visitClassDeclaration(node) {
  3049. const result = this.compilation.compile(node, this.constantPool);
  3050. if (result !== null) {
  3051. this.classCompilationMap.set(node, result);
  3052. for (const classResult of result) {
  3053. if (classResult.deferrableImports !== null && classResult.deferrableImports.size > 0) {
  3054. classResult.deferrableImports.forEach((importDecl) => this.deferrableImports.add(importDecl));
  3055. }
  3056. }
  3057. }
  3058. return { node };
  3059. }
  3060. };
  3061. var IvyTransformationVisitor = class extends Visitor {
  3062. compilation;
  3063. classCompilationMap;
  3064. reflector;
  3065. importManager;
  3066. recordWrappedNodeExpr;
  3067. isClosureCompilerEnabled;
  3068. isCore;
  3069. deferrableImports;
  3070. constructor(compilation, classCompilationMap, reflector, importManager, recordWrappedNodeExpr, isClosureCompilerEnabled, isCore, deferrableImports) {
  3071. super();
  3072. this.compilation = compilation;
  3073. this.classCompilationMap = classCompilationMap;
  3074. this.reflector = reflector;
  3075. this.importManager = importManager;
  3076. this.recordWrappedNodeExpr = recordWrappedNodeExpr;
  3077. this.isClosureCompilerEnabled = isClosureCompilerEnabled;
  3078. this.isCore = isCore;
  3079. this.deferrableImports = deferrableImports;
  3080. }
  3081. visitClassDeclaration(node) {
  3082. if (!this.classCompilationMap.has(node)) {
  3083. return { node };
  3084. }
  3085. const translateOptions = {
  3086. recordWrappedNode: this.recordWrappedNodeExpr,
  3087. annotateForClosureCompiler: this.isClosureCompilerEnabled
  3088. };
  3089. const statements = [];
  3090. const members = [...node.members];
  3091. const sourceFile = ts11.getOriginalNode(node).getSourceFile();
  3092. for (const field of this.classCompilationMap.get(node)) {
  3093. if (field.initializer === null) {
  3094. continue;
  3095. }
  3096. const exprNode = translateExpression(sourceFile, field.initializer, this.importManager, translateOptions);
  3097. const property = ts11.factory.createPropertyDeclaration([ts11.factory.createToken(ts11.SyntaxKind.StaticKeyword)], field.name, void 0, void 0, exprNode);
  3098. if (this.isClosureCompilerEnabled) {
  3099. ts11.addSyntheticLeadingComment(
  3100. property,
  3101. ts11.SyntaxKind.MultiLineCommentTrivia,
  3102. "* @nocollapse ",
  3103. false
  3104. );
  3105. }
  3106. field.statements.map((stmt) => translateStatement(sourceFile, stmt, this.importManager, translateOptions)).forEach((stmt) => statements.push(stmt));
  3107. members.push(property);
  3108. }
  3109. const filteredDecorators = maybeFilterDecorator(ts11.getDecorators(node), this.compilation.decoratorsFor(node));
  3110. const nodeModifiers = ts11.getModifiers(node);
  3111. let updatedModifiers;
  3112. if ((filteredDecorators == null ? void 0 : filteredDecorators.length) || (nodeModifiers == null ? void 0 : nodeModifiers.length)) {
  3113. updatedModifiers = [...filteredDecorators || [], ...nodeModifiers || []];
  3114. }
  3115. node = ts11.factory.updateClassDeclaration(
  3116. node,
  3117. updatedModifiers,
  3118. node.name,
  3119. node.typeParameters,
  3120. node.heritageClauses || [],
  3121. members.map((member) => this._stripAngularDecorators(member))
  3122. );
  3123. return { node, after: statements };
  3124. }
  3125. visitOtherNode(node) {
  3126. if (ts11.isImportDeclaration(node) && this.deferrableImports.has(node)) {
  3127. return null;
  3128. }
  3129. return node;
  3130. }
  3131. _angularCoreDecorators(decl) {
  3132. const decorators = this.reflector.getDecoratorsOfDeclaration(decl);
  3133. if (decorators === null) {
  3134. return NO_DECORATORS;
  3135. }
  3136. const coreDecorators = decorators.filter((dec) => this.isCore || isFromAngularCore(dec)).map((dec) => dec.node);
  3137. if (coreDecorators.length > 0) {
  3138. return new Set(coreDecorators);
  3139. } else {
  3140. return NO_DECORATORS;
  3141. }
  3142. }
  3143. _nonCoreDecoratorsOnly(node) {
  3144. const decorators = ts11.getDecorators(node);
  3145. if (decorators === void 0) {
  3146. return void 0;
  3147. }
  3148. const coreDecorators = this._angularCoreDecorators(node);
  3149. if (coreDecorators.size === decorators.length) {
  3150. return void 0;
  3151. } else if (coreDecorators.size === 0) {
  3152. return nodeArrayFromDecoratorsArray(decorators);
  3153. }
  3154. const filtered = decorators.filter((dec) => !coreDecorators.has(dec));
  3155. if (filtered.length === 0) {
  3156. return void 0;
  3157. }
  3158. return nodeArrayFromDecoratorsArray(filtered);
  3159. }
  3160. _stripAngularDecorators(node) {
  3161. const modifiers = ts11.canHaveModifiers(node) ? ts11.getModifiers(node) : void 0;
  3162. const nonCoreDecorators = ts11.canHaveDecorators(node) ? this._nonCoreDecoratorsOnly(node) : void 0;
  3163. const combinedModifiers = [...nonCoreDecorators || [], ...modifiers || []];
  3164. if (ts11.isParameter(node)) {
  3165. node = ts11.factory.updateParameterDeclaration(node, combinedModifiers, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer);
  3166. } else if (ts11.isMethodDeclaration(node)) {
  3167. node = ts11.factory.updateMethodDeclaration(node, combinedModifiers, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body);
  3168. } else if (ts11.isPropertyDeclaration(node)) {
  3169. node = ts11.factory.updatePropertyDeclaration(node, combinedModifiers, node.name, node.questionToken, node.type, node.initializer);
  3170. } else if (ts11.isGetAccessor(node)) {
  3171. node = ts11.factory.updateGetAccessorDeclaration(node, combinedModifiers, node.name, node.parameters, node.type, node.body);
  3172. } else if (ts11.isSetAccessor(node)) {
  3173. node = ts11.factory.updateSetAccessorDeclaration(node, combinedModifiers, node.name, node.parameters, node.body);
  3174. } else if (ts11.isConstructorDeclaration(node)) {
  3175. const parameters = node.parameters.map((param) => this._stripAngularDecorators(param));
  3176. node = ts11.factory.updateConstructorDeclaration(node, modifiers, parameters, node.body);
  3177. }
  3178. return node;
  3179. }
  3180. };
  3181. function transformIvySourceFile(compilation, context, reflector, importRewriter, localCompilationExtraImportsTracker, file, isCore, isClosureCompilerEnabled, recordWrappedNode) {
  3182. const constantPool = new ConstantPool(isClosureCompilerEnabled);
  3183. const importManager = new ImportManager({
  3184. ...presetImportManagerForceNamespaceImports,
  3185. rewriter: importRewriter
  3186. });
  3187. const compilationVisitor = new IvyCompilationVisitor(compilation, constantPool);
  3188. visit(file, compilationVisitor, context);
  3189. const transformationVisitor = new IvyTransformationVisitor(compilation, compilationVisitor.classCompilationMap, reflector, importManager, recordWrappedNode, isClosureCompilerEnabled, isCore, compilationVisitor.deferrableImports);
  3190. let sf = visit(file, transformationVisitor, context);
  3191. const downlevelTranslatedCode = getLocalizeCompileTarget(context) < ts11.ScriptTarget.ES2015;
  3192. const constants = constantPool.statements.map((stmt) => translateStatement(file, stmt, importManager, {
  3193. recordWrappedNode,
  3194. downlevelTaggedTemplates: downlevelTranslatedCode,
  3195. downlevelVariableDeclarations: downlevelTranslatedCode,
  3196. annotateForClosureCompiler: isClosureCompilerEnabled
  3197. }));
  3198. const fileOverviewMeta = isClosureCompilerEnabled ? getFileOverviewComment(sf.statements) : null;
  3199. if (localCompilationExtraImportsTracker !== null) {
  3200. for (const moduleName of localCompilationExtraImportsTracker.getImportsForFile(sf)) {
  3201. importManager.addSideEffectImport(sf, moduleName);
  3202. }
  3203. }
  3204. sf = importManager.transformTsFile(context, sf, constants);
  3205. if (fileOverviewMeta !== null) {
  3206. sf = insertFileOverviewComment(sf, fileOverviewMeta);
  3207. }
  3208. return sf;
  3209. }
  3210. function getLocalizeCompileTarget(context) {
  3211. const target = context.getCompilerOptions().target || ts11.ScriptTarget.ES2015;
  3212. return target !== ts11.ScriptTarget.JSON ? target : ts11.ScriptTarget.ES2015;
  3213. }
  3214. function getFileOverviewComment(statements) {
  3215. if (statements.length > 0) {
  3216. const host = statements[0];
  3217. let trailing = false;
  3218. let comments = ts11.getSyntheticLeadingComments(host);
  3219. if (!comments || comments.length === 0) {
  3220. trailing = true;
  3221. comments = ts11.getSyntheticTrailingComments(host);
  3222. }
  3223. if (comments && comments.length > 0 && CLOSURE_FILE_OVERVIEW_REGEXP.test(comments[0].text)) {
  3224. return { comments, host, trailing };
  3225. }
  3226. }
  3227. return null;
  3228. }
  3229. function insertFileOverviewComment(sf, fileoverview) {
  3230. const { comments, host, trailing } = fileoverview;
  3231. if (sf.statements.length > 0 && host !== sf.statements[0]) {
  3232. if (trailing) {
  3233. ts11.setSyntheticTrailingComments(host, void 0);
  3234. } else {
  3235. ts11.setSyntheticLeadingComments(host, void 0);
  3236. }
  3237. const commentNode = ts11.factory.createNotEmittedStatement(sf);
  3238. ts11.setSyntheticLeadingComments(commentNode, comments);
  3239. return ts11.factory.updateSourceFile(sf, [commentNode, ...sf.statements], sf.isDeclarationFile, sf.referencedFiles, sf.typeReferenceDirectives, sf.hasNoDefaultLib, sf.libReferenceDirectives);
  3240. }
  3241. return sf;
  3242. }
  3243. function maybeFilterDecorator(decorators, toRemove) {
  3244. if (decorators === void 0) {
  3245. return void 0;
  3246. }
  3247. const filtered = decorators.filter((dec) => toRemove.find((decToRemove) => ts11.getOriginalNode(dec) === decToRemove) === void 0);
  3248. if (filtered.length === 0) {
  3249. return void 0;
  3250. }
  3251. return ts11.factory.createNodeArray(filtered);
  3252. }
  3253. function isFromAngularCore(decorator) {
  3254. return decorator.import !== null && decorator.import.from === "@angular/core";
  3255. }
  3256. function createRecorderFn(defaultImportTracker) {
  3257. return (node) => {
  3258. const importDecl = getDefaultImportDeclaration(node);
  3259. if (importDecl !== null) {
  3260. defaultImportTracker.recordUsedImport(importDecl);
  3261. }
  3262. };
  3263. }
  3264. function nodeArrayFromDecoratorsArray(decorators) {
  3265. const array = ts11.factory.createNodeArray(decorators);
  3266. if (array.length > 0) {
  3267. array.pos = decorators[0].pos;
  3268. array.end = decorators[decorators.length - 1].end;
  3269. }
  3270. return array;
  3271. }
  3272. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/common/src/diagnostics.mjs
  3273. function makeDuplicateDeclarationError(node, data, kind) {
  3274. const context = [];
  3275. for (const decl of data) {
  3276. if (decl.rawDeclarations === null) {
  3277. continue;
  3278. }
  3279. const contextNode = decl.ref.getOriginForDiagnostics(decl.rawDeclarations, decl.ngModule.name);
  3280. context.push(makeRelatedInformation(contextNode, `'${node.name.text}' is listed in the declarations of the NgModule '${decl.ngModule.name.text}'.`));
  3281. }
  3282. return makeDiagnostic(ErrorCode.NGMODULE_DECLARATION_NOT_UNIQUE, node.name, `The ${kind} '${node.name.text}' is declared by more than one NgModule.`, context);
  3283. }
  3284. function createValueHasWrongTypeError(node, value, messageText) {
  3285. var _a;
  3286. let chainedMessage;
  3287. let relatedInformation;
  3288. if (value instanceof DynamicValue) {
  3289. chainedMessage = "Value could not be determined statically.";
  3290. relatedInformation = traceDynamicValue(node, value);
  3291. } else if (value instanceof Reference) {
  3292. const target = value.debugName !== null ? `'${value.debugName}'` : "an anonymous declaration";
  3293. chainedMessage = `Value is a reference to ${target}.`;
  3294. const referenceNode = (_a = identifierOfNode(value.node)) != null ? _a : value.node;
  3295. relatedInformation = [makeRelatedInformation(referenceNode, "Reference is declared here.")];
  3296. } else {
  3297. chainedMessage = `Value is of type '${describeResolvedType(value)}'.`;
  3298. }
  3299. const chain = {
  3300. messageText,
  3301. category: ts12.DiagnosticCategory.Error,
  3302. code: 0,
  3303. next: [
  3304. {
  3305. messageText: chainedMessage,
  3306. category: ts12.DiagnosticCategory.Message,
  3307. code: 0
  3308. }
  3309. ]
  3310. };
  3311. return new FatalDiagnosticError(ErrorCode.VALUE_HAS_WRONG_TYPE, node, chain, relatedInformation);
  3312. }
  3313. function getProviderDiagnostics(providerClasses, providersDeclaration, registry) {
  3314. const diagnostics = [];
  3315. for (const provider of providerClasses) {
  3316. const injectableMeta = registry.getInjectableMeta(provider.node);
  3317. if (injectableMeta !== null) {
  3318. continue;
  3319. }
  3320. const contextNode = provider.getOriginForDiagnostics(providersDeclaration);
  3321. diagnostics.push(makeDiagnostic(ErrorCode.UNDECORATED_PROVIDER, contextNode, `The class '${provider.node.name.text}' cannot be created via dependency injection, as it does not have an Angular decorator. This will result in an error at runtime.
  3322. Either add the @Injectable() decorator to '${provider.node.name.text}', or configure a different provider (such as a provider with 'useFactory').
  3323. `, [makeRelatedInformation(provider.node, `'${provider.node.name.text}' is declared here.`)]));
  3324. }
  3325. return diagnostics;
  3326. }
  3327. function getDirectiveDiagnostics(node, injectableRegistry, evaluator, reflector, scopeRegistry, strictInjectionParameters, kind) {
  3328. let diagnostics = [];
  3329. const addDiagnostics = (more) => {
  3330. if (more === null) {
  3331. return;
  3332. } else if (diagnostics === null) {
  3333. diagnostics = Array.isArray(more) ? more : [more];
  3334. } else if (Array.isArray(more)) {
  3335. diagnostics.push(...more);
  3336. } else {
  3337. diagnostics.push(more);
  3338. }
  3339. };
  3340. const duplicateDeclarations = scopeRegistry.getDuplicateDeclarations(node);
  3341. if (duplicateDeclarations !== null) {
  3342. addDiagnostics(makeDuplicateDeclarationError(node, duplicateDeclarations, kind));
  3343. }
  3344. addDiagnostics(checkInheritanceOfInjectable(node, injectableRegistry, reflector, evaluator, strictInjectionParameters, kind));
  3345. return diagnostics;
  3346. }
  3347. function validateHostDirectives(origin, hostDirectives, metaReader) {
  3348. const diagnostics = [];
  3349. for (const current of hostDirectives) {
  3350. if (!isHostDirectiveMetaForGlobalMode(current)) {
  3351. throw new Error("Impossible state: diagnostics code path for local compilation");
  3352. }
  3353. const hostMeta = flattenInheritedDirectiveMetadata(metaReader, current.directive);
  3354. if (hostMeta === null) {
  3355. diagnostics.push(makeDiagnostic(ErrorCode.HOST_DIRECTIVE_INVALID, current.directive.getOriginForDiagnostics(origin), `${current.directive.debugName} must be a standalone directive to be used as a host directive`));
  3356. continue;
  3357. }
  3358. if (!hostMeta.isStandalone) {
  3359. diagnostics.push(makeDiagnostic(ErrorCode.HOST_DIRECTIVE_NOT_STANDALONE, current.directive.getOriginForDiagnostics(origin), `Host directive ${hostMeta.name} must be standalone`));
  3360. }
  3361. if (hostMeta.isComponent) {
  3362. diagnostics.push(makeDiagnostic(ErrorCode.HOST_DIRECTIVE_COMPONENT, current.directive.getOriginForDiagnostics(origin), `Host directive ${hostMeta.name} cannot be a component`));
  3363. }
  3364. const requiredInputNames = Array.from(hostMeta.inputs).filter((input) => input.required).map((input) => input.classPropertyName);
  3365. validateHostDirectiveMappings("input", current, hostMeta, origin, diagnostics, requiredInputNames.length > 0 ? new Set(requiredInputNames) : null);
  3366. validateHostDirectiveMappings("output", current, hostMeta, origin, diagnostics, null);
  3367. }
  3368. return diagnostics;
  3369. }
  3370. function validateHostDirectiveMappings(bindingType, hostDirectiveMeta, meta, origin, diagnostics, requiredBindings) {
  3371. if (!isHostDirectiveMetaForGlobalMode(hostDirectiveMeta)) {
  3372. throw new Error("Impossible state: diagnostics code path for local compilation");
  3373. }
  3374. const className = meta.name;
  3375. const hostDirectiveMappings = bindingType === "input" ? hostDirectiveMeta.inputs : hostDirectiveMeta.outputs;
  3376. const existingBindings = bindingType === "input" ? meta.inputs : meta.outputs;
  3377. const exposedRequiredBindings = /* @__PURE__ */ new Set();
  3378. for (const publicName in hostDirectiveMappings) {
  3379. if (hostDirectiveMappings.hasOwnProperty(publicName)) {
  3380. const bindings = existingBindings.getByBindingPropertyName(publicName);
  3381. if (bindings === null) {
  3382. diagnostics.push(makeDiagnostic(ErrorCode.HOST_DIRECTIVE_UNDEFINED_BINDING, hostDirectiveMeta.directive.getOriginForDiagnostics(origin), `Directive ${className} does not have an ${bindingType} with a public name of ${publicName}.`));
  3383. } else if (requiredBindings !== null) {
  3384. for (const field of bindings) {
  3385. if (requiredBindings.has(field.classPropertyName)) {
  3386. exposedRequiredBindings.add(field.classPropertyName);
  3387. }
  3388. }
  3389. }
  3390. const remappedPublicName = hostDirectiveMappings[publicName];
  3391. const bindingsForPublicName = existingBindings.getByBindingPropertyName(remappedPublicName);
  3392. if (bindingsForPublicName !== null) {
  3393. for (const binding of bindingsForPublicName) {
  3394. if (binding.bindingPropertyName !== publicName) {
  3395. diagnostics.push(makeDiagnostic(ErrorCode.HOST_DIRECTIVE_CONFLICTING_ALIAS, hostDirectiveMeta.directive.getOriginForDiagnostics(origin), `Cannot alias ${bindingType} ${publicName} of host directive ${className} to ${remappedPublicName}, because it already has a different ${bindingType} with the same public name.`));
  3396. }
  3397. }
  3398. }
  3399. }
  3400. }
  3401. if (requiredBindings !== null && requiredBindings.size !== exposedRequiredBindings.size) {
  3402. const missingBindings = [];
  3403. for (const publicName of requiredBindings) {
  3404. if (!exposedRequiredBindings.has(publicName)) {
  3405. const name = existingBindings.getByClassPropertyName(publicName);
  3406. if (name) {
  3407. missingBindings.push(`'${name.bindingPropertyName}'`);
  3408. }
  3409. }
  3410. }
  3411. diagnostics.push(makeDiagnostic(ErrorCode.HOST_DIRECTIVE_MISSING_REQUIRED_BINDING, hostDirectiveMeta.directive.getOriginForDiagnostics(origin), `Required ${bindingType}${missingBindings.length === 1 ? "" : "s"} ${missingBindings.join(", ")} from host directive ${className} must be exposed.`));
  3412. }
  3413. }
  3414. function getUndecoratedClassWithAngularFeaturesDiagnostic(node) {
  3415. return makeDiagnostic(ErrorCode.UNDECORATED_CLASS_USING_ANGULAR_FEATURES, node.name, `Class is using Angular features but is not decorated. Please add an explicit Angular decorator.`);
  3416. }
  3417. function checkInheritanceOfInjectable(node, injectableRegistry, reflector, evaluator, strictInjectionParameters, kind) {
  3418. const classWithCtor = findInheritedCtor(node, injectableRegistry, reflector, evaluator);
  3419. if (classWithCtor === null || classWithCtor.isCtorValid) {
  3420. return null;
  3421. }
  3422. if (!classWithCtor.isDecorated) {
  3423. return getInheritedUndecoratedCtorDiagnostic(node, classWithCtor.ref, kind);
  3424. }
  3425. if (isFromDtsFile(classWithCtor.ref.node)) {
  3426. return null;
  3427. }
  3428. if (!strictInjectionParameters || isAbstractClassDeclaration(node)) {
  3429. return null;
  3430. }
  3431. return getInheritedInvalidCtorDiagnostic(node, classWithCtor.ref, kind);
  3432. }
  3433. function findInheritedCtor(node, injectableRegistry, reflector, evaluator) {
  3434. if (!reflector.isClass(node) || reflector.getConstructorParameters(node) !== null) {
  3435. return null;
  3436. }
  3437. let baseClass = readBaseClass(node, reflector, evaluator);
  3438. while (baseClass !== null) {
  3439. if (baseClass === "dynamic") {
  3440. return null;
  3441. }
  3442. const injectableMeta = injectableRegistry.getInjectableMeta(baseClass.node);
  3443. if (injectableMeta !== null) {
  3444. if (injectableMeta.ctorDeps !== null) {
  3445. return {
  3446. ref: baseClass,
  3447. isCtorValid: injectableMeta.ctorDeps !== "invalid",
  3448. isDecorated: true
  3449. };
  3450. }
  3451. } else {
  3452. const baseClassConstructorParams = reflector.getConstructorParameters(baseClass.node);
  3453. if (baseClassConstructorParams !== null) {
  3454. return {
  3455. ref: baseClass,
  3456. isCtorValid: baseClassConstructorParams.length === 0,
  3457. isDecorated: false
  3458. };
  3459. }
  3460. }
  3461. baseClass = readBaseClass(baseClass.node, reflector, evaluator);
  3462. }
  3463. return null;
  3464. }
  3465. function getInheritedInvalidCtorDiagnostic(node, baseClass, kind) {
  3466. const baseClassName = baseClass.debugName;
  3467. return makeDiagnostic(ErrorCode.INJECTABLE_INHERITS_INVALID_CONSTRUCTOR, node.name, `The ${kind.toLowerCase()} ${node.name.text} inherits its constructor from ${baseClassName}, but the latter has a constructor parameter that is not compatible with dependency injection. Either add an explicit constructor to ${node.name.text} or change ${baseClassName}'s constructor to use parameters that are valid for DI.`);
  3468. }
  3469. function getInheritedUndecoratedCtorDiagnostic(node, baseClass, kind) {
  3470. const baseClassName = baseClass.debugName;
  3471. const baseNeedsDecorator = kind === "Component" || kind === "Directive" ? "Directive" : "Injectable";
  3472. return makeDiagnostic(ErrorCode.DIRECTIVE_INHERITS_UNDECORATED_CTOR, node.name, `The ${kind.toLowerCase()} ${node.name.text} inherits its constructor from ${baseClassName}, but the latter does not have an Angular decorator of its own. Dependency injection will not be able to resolve the parameters of ${baseClassName}'s constructor. Either add a @${baseNeedsDecorator} decorator to ${baseClassName}, or add an explicit constructor to ${node.name.text}.`);
  3473. }
  3474. function assertLocalCompilationUnresolvedConst(compilationMode, value, nodeToHighlight, errorMessage) {
  3475. if (compilationMode === CompilationMode.LOCAL && value instanceof DynamicValue && value.isFromUnknownIdentifier()) {
  3476. throw new FatalDiagnosticError(ErrorCode.LOCAL_COMPILATION_UNRESOLVED_CONST, nodeToHighlight != null ? nodeToHighlight : value.node, errorMessage);
  3477. }
  3478. }
  3479. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/common/src/evaluation.mjs
  3480. import { ViewEncapsulation } from "@angular/compiler";
  3481. import ts13 from "typescript";
  3482. function resolveEnumValue(evaluator, metadata, field, enumSymbolName, isCore) {
  3483. let resolved = null;
  3484. if (metadata.has(field)) {
  3485. const expr = metadata.get(field);
  3486. const value = evaluator.evaluate(expr);
  3487. if (value instanceof EnumValue && isAngularCoreReferenceWithPotentialAliasing(value.enumRef, enumSymbolName, isCore)) {
  3488. resolved = value.resolved;
  3489. } else {
  3490. throw createValueHasWrongTypeError(expr, value, `${field} must be a member of ${enumSymbolName} enum from @angular/core`);
  3491. }
  3492. }
  3493. return resolved;
  3494. }
  3495. function resolveEncapsulationEnumValueLocally(expr) {
  3496. if (!expr) {
  3497. return null;
  3498. }
  3499. const exprText = expr.getText().trim();
  3500. for (const key in ViewEncapsulation) {
  3501. if (!Number.isNaN(Number(key))) {
  3502. continue;
  3503. }
  3504. const suffix = `ViewEncapsulation.${key}`;
  3505. if (exprText === suffix || exprText.endsWith(`.${suffix}`)) {
  3506. const ans = Number(ViewEncapsulation[key]);
  3507. return ans;
  3508. }
  3509. }
  3510. return null;
  3511. }
  3512. function isStringArray(resolvedValue) {
  3513. return Array.isArray(resolvedValue) && resolvedValue.every((elem) => typeof elem === "string");
  3514. }
  3515. function resolveLiteral(decorator, literalCache) {
  3516. if (literalCache.has(decorator)) {
  3517. return literalCache.get(decorator);
  3518. }
  3519. if (decorator.args === null || decorator.args.length !== 1) {
  3520. throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARITY_WRONG, decorator.node, `Incorrect number of arguments to @${decorator.name} decorator`);
  3521. }
  3522. const meta = unwrapExpression(decorator.args[0]);
  3523. if (!ts13.isObjectLiteralExpression(meta)) {
  3524. throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARG_NOT_LITERAL, meta, `Decorator argument must be literal.`);
  3525. }
  3526. literalCache.set(decorator, meta);
  3527. return meta;
  3528. }
  3529. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/common/src/factory.mjs
  3530. import { compileDeclareFactoryFunction, compileFactoryFunction } from "@angular/compiler";
  3531. function compileNgFactoryDefField(metadata) {
  3532. const res = compileFactoryFunction(metadata);
  3533. return {
  3534. name: "\u0275fac",
  3535. initializer: res.expression,
  3536. statements: res.statements,
  3537. type: res.type,
  3538. deferrableImports: null
  3539. };
  3540. }
  3541. function compileDeclareFactory(metadata) {
  3542. const res = compileDeclareFactoryFunction(metadata);
  3543. return {
  3544. name: "\u0275fac",
  3545. initializer: res.expression,
  3546. statements: res.statements,
  3547. type: res.type,
  3548. deferrableImports: null
  3549. };
  3550. }
  3551. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/common/src/injectable_registry.mjs
  3552. var InjectableClassRegistry = class {
  3553. host;
  3554. isCore;
  3555. classes = /* @__PURE__ */ new Map();
  3556. constructor(host, isCore) {
  3557. this.host = host;
  3558. this.isCore = isCore;
  3559. }
  3560. registerInjectable(declaration, meta) {
  3561. this.classes.set(declaration, meta);
  3562. }
  3563. getInjectableMeta(declaration) {
  3564. if (this.classes.has(declaration)) {
  3565. return this.classes.get(declaration);
  3566. }
  3567. if (!hasInjectableFields(declaration, this.host)) {
  3568. return null;
  3569. }
  3570. const ctorDeps = getConstructorDependencies(declaration, this.host, this.isCore);
  3571. const meta = {
  3572. ctorDeps: unwrapConstructorDependencies(ctorDeps)
  3573. };
  3574. this.classes.set(declaration, meta);
  3575. return meta;
  3576. }
  3577. };
  3578. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/common/src/metadata.mjs
  3579. import { ArrowFunctionExpr, LiteralArrayExpr, LiteralExpr as LiteralExpr2, literalMap, WrappedNodeExpr as WrappedNodeExpr3 } from "@angular/compiler";
  3580. import ts14 from "typescript";
  3581. function extractClassMetadata(clazz, reflection, isCore, annotateForClosureCompiler, angularDecoratorTransform = (dec) => dec) {
  3582. if (!reflection.isClass(clazz)) {
  3583. return null;
  3584. }
  3585. const id = clazz.name;
  3586. const classDecorators = reflection.getDecoratorsOfDeclaration(clazz);
  3587. if (classDecorators === null) {
  3588. return null;
  3589. }
  3590. const ngClassDecorators = classDecorators.filter((dec) => isAngularDecorator2(dec, isCore)).map((decorator) => decoratorToMetadata(angularDecoratorTransform(decorator), annotateForClosureCompiler)).map((decorator) => removeIdentifierReferences(decorator, id.text));
  3591. if (ngClassDecorators.length === 0) {
  3592. return null;
  3593. }
  3594. const metaDecorators = new WrappedNodeExpr3(ts14.factory.createArrayLiteralExpression(ngClassDecorators));
  3595. let metaCtorParameters = null;
  3596. const classCtorParameters = reflection.getConstructorParameters(clazz);
  3597. if (classCtorParameters !== null) {
  3598. const ctorParameters = classCtorParameters.map((param) => ctorParameterToMetadata(param, isCore));
  3599. metaCtorParameters = new ArrowFunctionExpr([], new LiteralArrayExpr(ctorParameters));
  3600. }
  3601. let metaPropDecorators = null;
  3602. const classMembers = reflection.getMembersOfClass(clazz).filter((member) => !member.isStatic && member.decorators !== null && member.decorators.length > 0);
  3603. const duplicateDecoratedMemberNames = classMembers.map((member) => member.name).filter((name, i, arr) => arr.indexOf(name) < i);
  3604. if (duplicateDecoratedMemberNames.length > 0) {
  3605. throw new Error(`Duplicate decorated properties found on class '${clazz.name.text}': ` + duplicateDecoratedMemberNames.join(", "));
  3606. }
  3607. const decoratedMembers = classMembers.map((member) => {
  3608. var _a;
  3609. return classMemberToMetadata((_a = member.nameNode) != null ? _a : member.name, member.decorators, isCore);
  3610. });
  3611. if (decoratedMembers.length > 0) {
  3612. metaPropDecorators = new WrappedNodeExpr3(ts14.factory.createObjectLiteralExpression(decoratedMembers));
  3613. }
  3614. return {
  3615. type: new WrappedNodeExpr3(id),
  3616. decorators: metaDecorators,
  3617. ctorParameters: metaCtorParameters,
  3618. propDecorators: metaPropDecorators
  3619. };
  3620. }
  3621. function ctorParameterToMetadata(param, isCore) {
  3622. const type = param.typeValueReference.kind !== 2 ? valueReferenceToExpression(param.typeValueReference) : new LiteralExpr2(void 0);
  3623. const mapEntries = [
  3624. { key: "type", value: type, quoted: false }
  3625. ];
  3626. if (param.decorators !== null) {
  3627. const ngDecorators = param.decorators.filter((dec) => isAngularDecorator2(dec, isCore)).map((decorator) => decoratorToMetadata(decorator));
  3628. const value = new WrappedNodeExpr3(ts14.factory.createArrayLiteralExpression(ngDecorators));
  3629. mapEntries.push({ key: "decorators", value, quoted: false });
  3630. }
  3631. return literalMap(mapEntries);
  3632. }
  3633. function classMemberToMetadata(name, decorators, isCore) {
  3634. const ngDecorators = decorators.filter((dec) => isAngularDecorator2(dec, isCore)).map((decorator) => decoratorToMetadata(decorator));
  3635. const decoratorMeta = ts14.factory.createArrayLiteralExpression(ngDecorators);
  3636. return ts14.factory.createPropertyAssignment(name, decoratorMeta);
  3637. }
  3638. function decoratorToMetadata(decorator, wrapFunctionsInParens) {
  3639. if (decorator.identifier === null) {
  3640. throw new Error("Illegal state: synthesized decorator cannot be emitted in class metadata.");
  3641. }
  3642. const properties = [
  3643. ts14.factory.createPropertyAssignment("type", decorator.identifier)
  3644. ];
  3645. if (decorator.args !== null && decorator.args.length > 0) {
  3646. const args = decorator.args.map((arg) => {
  3647. return wrapFunctionsInParens ? wrapFunctionExpressionsInParens(arg) : arg;
  3648. });
  3649. properties.push(ts14.factory.createPropertyAssignment("args", ts14.factory.createArrayLiteralExpression(args)));
  3650. }
  3651. return ts14.factory.createObjectLiteralExpression(properties, true);
  3652. }
  3653. function isAngularDecorator2(decorator, isCore) {
  3654. return isCore || decorator.import !== null && decorator.import.from === "@angular/core";
  3655. }
  3656. function removeIdentifierReferences(node, names) {
  3657. const result = ts14.transform(node, [
  3658. (context) => (root) => ts14.visitNode(root, function walk(current) {
  3659. return ts14.isIdentifier(current) && (typeof names === "string" ? current.text === names : names.has(current.text)) ? ts14.factory.createIdentifier(current.text) : ts14.visitEachChild(current, walk, context);
  3660. })
  3661. ]);
  3662. return result.transformed[0];
  3663. }
  3664. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/common/src/debug_info.mjs
  3665. import { literal as literal2, WrappedNodeExpr as WrappedNodeExpr4 } from "@angular/compiler";
  3666. function extractClassDebugInfo(clazz, reflection, compilerHost, rootDirs, forbidOrphanRendering) {
  3667. if (!reflection.isClass(clazz)) {
  3668. return null;
  3669. }
  3670. const srcFile = clazz.getSourceFile();
  3671. const srcFileMaybeRelativePath = getProjectRelativePath(srcFile.fileName, rootDirs, compilerHost);
  3672. return {
  3673. type: new WrappedNodeExpr4(clazz.name),
  3674. className: literal2(clazz.name.getText()),
  3675. filePath: srcFileMaybeRelativePath ? literal2(srcFileMaybeRelativePath) : null,
  3676. lineNumber: literal2(srcFile.getLineAndCharacterOfPosition(clazz.name.pos).line + 1),
  3677. forbidOrphanRendering
  3678. };
  3679. }
  3680. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/common/src/references_registry.mjs
  3681. var NoopReferencesRegistry = class {
  3682. add(source, ...references) {
  3683. }
  3684. };
  3685. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/common/src/schema.mjs
  3686. import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from "@angular/compiler";
  3687. function extractSchemas(rawExpr, evaluator, context) {
  3688. const schemas = [];
  3689. const result = evaluator.evaluate(rawExpr);
  3690. if (!Array.isArray(result)) {
  3691. throw createValueHasWrongTypeError(rawExpr, result, `${context}.schemas must be an array`);
  3692. }
  3693. for (const schemaRef of result) {
  3694. if (!(schemaRef instanceof Reference)) {
  3695. throw createValueHasWrongTypeError(rawExpr, result, `${context}.schemas must be an array of schemas`);
  3696. }
  3697. const id = schemaRef.getIdentityIn(schemaRef.node.getSourceFile());
  3698. if (id === null || schemaRef.ownedByModuleGuess !== "@angular/core") {
  3699. throw createValueHasWrongTypeError(rawExpr, result, `${context}.schemas must be an array of schemas`);
  3700. }
  3701. switch (id.text) {
  3702. case "CUSTOM_ELEMENTS_SCHEMA":
  3703. schemas.push(CUSTOM_ELEMENTS_SCHEMA);
  3704. break;
  3705. case "NO_ERRORS_SCHEMA":
  3706. schemas.push(NO_ERRORS_SCHEMA);
  3707. break;
  3708. default:
  3709. throw createValueHasWrongTypeError(rawExpr, schemaRef, `'${schemaRef.debugName}' is not a valid ${context} schema`);
  3710. }
  3711. }
  3712. return schemas;
  3713. }
  3714. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/common/src/input_transforms.mjs
  3715. import { outputAst } from "@angular/compiler";
  3716. function compileInputTransformFields(inputs) {
  3717. const extraFields = [];
  3718. for (const input of inputs) {
  3719. if (input.transform) {
  3720. extraFields.push({
  3721. name: `ngAcceptInputType_${input.classPropertyName}`,
  3722. type: outputAst.transplantedType(input.transform.type),
  3723. statements: [],
  3724. initializer: null,
  3725. deferrableImports: null
  3726. });
  3727. }
  3728. }
  3729. return extraFields;
  3730. }
  3731. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/common/src/jit_declaration_registry.mjs
  3732. var JitDeclarationRegistry = class {
  3733. jitDeclarations = /* @__PURE__ */ new Set();
  3734. };
  3735. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/component/src/handler.mjs
  3736. import { compileClassDebugInfo, compileHmrInitializer, compileComponentClassMetadata, compileComponentDeclareClassMetadata, compileComponentFromMetadata, compileDeclareComponentFromMetadata, compileDeferResolverFunction, ConstantPool as ConstantPool2, CssSelector as CssSelector4, DEFAULT_INTERPOLATION_CONFIG as DEFAULT_INTERPOLATION_CONFIG2, DomElementSchemaRegistry as DomElementSchemaRegistry3, ExternalExpr as ExternalExpr8, FactoryTarget as FactoryTarget3, makeBindingParser as makeBindingParser2, outputAst as o4, R3TargetBinder, R3TemplateDependencyKind, SelectorMatcher as SelectorMatcher3, ViewEncapsulation as ViewEncapsulation2 } from "@angular/compiler";
  3737. import ts49 from "typescript";
  3738. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/incremental/semantic_graph/src/api.mjs
  3739. import ts15 from "typescript";
  3740. var SemanticSymbol = class {
  3741. decl;
  3742. path;
  3743. identifier;
  3744. constructor(decl) {
  3745. this.decl = decl;
  3746. this.path = absoluteFromSourceFile(decl.getSourceFile());
  3747. this.identifier = getSymbolIdentifier(decl);
  3748. }
  3749. };
  3750. function getSymbolIdentifier(decl) {
  3751. if (!ts15.isSourceFile(decl.parent)) {
  3752. return null;
  3753. }
  3754. return decl.name.text;
  3755. }
  3756. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/incremental/semantic_graph/src/graph.mjs
  3757. import { ExternalExpr as ExternalExpr2 } from "@angular/compiler";
  3758. var OpaqueSymbol = class extends SemanticSymbol {
  3759. isPublicApiAffected() {
  3760. return false;
  3761. }
  3762. isTypeCheckApiAffected() {
  3763. return false;
  3764. }
  3765. };
  3766. var SemanticDepGraph = class {
  3767. files = /* @__PURE__ */ new Map();
  3768. symbolByDecl = /* @__PURE__ */ new Map();
  3769. registerSymbol(symbol) {
  3770. this.symbolByDecl.set(symbol.decl, symbol);
  3771. if (symbol.identifier !== null) {
  3772. if (!this.files.has(symbol.path)) {
  3773. this.files.set(symbol.path, /* @__PURE__ */ new Map());
  3774. }
  3775. this.files.get(symbol.path).set(symbol.identifier, symbol);
  3776. }
  3777. }
  3778. getEquivalentSymbol(symbol) {
  3779. let previousSymbol = this.getSymbolByDecl(symbol.decl);
  3780. if (previousSymbol === null && symbol.identifier !== null) {
  3781. previousSymbol = this.getSymbolByName(symbol.path, symbol.identifier);
  3782. }
  3783. return previousSymbol;
  3784. }
  3785. getSymbolByName(path, identifier) {
  3786. if (!this.files.has(path)) {
  3787. return null;
  3788. }
  3789. const file = this.files.get(path);
  3790. if (!file.has(identifier)) {
  3791. return null;
  3792. }
  3793. return file.get(identifier);
  3794. }
  3795. getSymbolByDecl(decl) {
  3796. if (!this.symbolByDecl.has(decl)) {
  3797. return null;
  3798. }
  3799. return this.symbolByDecl.get(decl);
  3800. }
  3801. };
  3802. var SemanticDepGraphUpdater = class {
  3803. priorGraph;
  3804. newGraph = new SemanticDepGraph();
  3805. opaqueSymbols = /* @__PURE__ */ new Map();
  3806. constructor(priorGraph) {
  3807. this.priorGraph = priorGraph;
  3808. }
  3809. registerSymbol(symbol) {
  3810. this.newGraph.registerSymbol(symbol);
  3811. }
  3812. finalize() {
  3813. if (this.priorGraph === null) {
  3814. return {
  3815. needsEmit: /* @__PURE__ */ new Set(),
  3816. needsTypeCheckEmit: /* @__PURE__ */ new Set(),
  3817. newGraph: this.newGraph
  3818. };
  3819. }
  3820. const needsEmit = this.determineInvalidatedFiles(this.priorGraph);
  3821. const needsTypeCheckEmit = this.determineInvalidatedTypeCheckFiles(this.priorGraph);
  3822. return {
  3823. needsEmit,
  3824. needsTypeCheckEmit,
  3825. newGraph: this.newGraph
  3826. };
  3827. }
  3828. determineInvalidatedFiles(priorGraph) {
  3829. const isPublicApiAffected = /* @__PURE__ */ new Set();
  3830. for (const symbol of this.newGraph.symbolByDecl.values()) {
  3831. const previousSymbol = priorGraph.getEquivalentSymbol(symbol);
  3832. if (previousSymbol === null || symbol.isPublicApiAffected(previousSymbol)) {
  3833. isPublicApiAffected.add(symbol);
  3834. }
  3835. }
  3836. const needsEmit = /* @__PURE__ */ new Set();
  3837. for (const symbol of this.newGraph.symbolByDecl.values()) {
  3838. if (symbol.isEmitAffected === void 0) {
  3839. continue;
  3840. }
  3841. const previousSymbol = priorGraph.getEquivalentSymbol(symbol);
  3842. if (previousSymbol === null || symbol.isEmitAffected(previousSymbol, isPublicApiAffected)) {
  3843. needsEmit.add(symbol.path);
  3844. }
  3845. }
  3846. return needsEmit;
  3847. }
  3848. determineInvalidatedTypeCheckFiles(priorGraph) {
  3849. const isTypeCheckApiAffected = /* @__PURE__ */ new Set();
  3850. for (const symbol of this.newGraph.symbolByDecl.values()) {
  3851. const previousSymbol = priorGraph.getEquivalentSymbol(symbol);
  3852. if (previousSymbol === null || symbol.isTypeCheckApiAffected(previousSymbol)) {
  3853. isTypeCheckApiAffected.add(symbol);
  3854. }
  3855. }
  3856. const needsTypeCheckEmit = /* @__PURE__ */ new Set();
  3857. for (const symbol of this.newGraph.symbolByDecl.values()) {
  3858. if (symbol.isTypeCheckBlockAffected === void 0) {
  3859. continue;
  3860. }
  3861. const previousSymbol = priorGraph.getEquivalentSymbol(symbol);
  3862. if (previousSymbol === null || symbol.isTypeCheckBlockAffected(previousSymbol, isTypeCheckApiAffected)) {
  3863. needsTypeCheckEmit.add(symbol.path);
  3864. }
  3865. }
  3866. return needsTypeCheckEmit;
  3867. }
  3868. getSemanticReference(decl, expr) {
  3869. return {
  3870. symbol: this.getSymbol(decl),
  3871. importPath: getImportPath(expr)
  3872. };
  3873. }
  3874. getSymbol(decl) {
  3875. const symbol = this.newGraph.getSymbolByDecl(decl);
  3876. if (symbol === null) {
  3877. return this.getOpaqueSymbol(decl);
  3878. }
  3879. return symbol;
  3880. }
  3881. getOpaqueSymbol(decl) {
  3882. if (this.opaqueSymbols.has(decl)) {
  3883. return this.opaqueSymbols.get(decl);
  3884. }
  3885. const symbol = new OpaqueSymbol(decl);
  3886. this.opaqueSymbols.set(decl, symbol);
  3887. return symbol;
  3888. }
  3889. };
  3890. function getImportPath(expr) {
  3891. if (expr instanceof ExternalExpr2) {
  3892. return `${expr.value.moduleName}$${expr.value.name}`;
  3893. } else {
  3894. return null;
  3895. }
  3896. }
  3897. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/incremental/semantic_graph/src/type_parameters.mjs
  3898. import ts16 from "typescript";
  3899. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/incremental/semantic_graph/src/util.mjs
  3900. function isSymbolEqual(a, b) {
  3901. if (a.decl === b.decl) {
  3902. return true;
  3903. }
  3904. if (a.identifier === null || b.identifier === null) {
  3905. return false;
  3906. }
  3907. return a.path === b.path && a.identifier === b.identifier;
  3908. }
  3909. function isReferenceEqual(a, b) {
  3910. if (!isSymbolEqual(a.symbol, b.symbol)) {
  3911. return false;
  3912. }
  3913. return a.importPath === b.importPath;
  3914. }
  3915. function referenceEquality(a, b) {
  3916. return a === b;
  3917. }
  3918. function isArrayEqual(a, b, equalityTester = referenceEquality) {
  3919. if (a === null || b === null) {
  3920. return a === b;
  3921. }
  3922. if (a.length !== b.length) {
  3923. return false;
  3924. }
  3925. return !a.some((item, index) => !equalityTester(item, b[index]));
  3926. }
  3927. function isSetEqual(a, b, equalityTester = referenceEquality) {
  3928. if (a === null || b === null) {
  3929. return a === b;
  3930. }
  3931. if (a.size !== b.size) {
  3932. return false;
  3933. }
  3934. for (const itemA of a) {
  3935. let found = false;
  3936. for (const itemB of b) {
  3937. if (equalityTester(itemA, itemB)) {
  3938. found = true;
  3939. break;
  3940. }
  3941. }
  3942. if (!found) {
  3943. return false;
  3944. }
  3945. }
  3946. return true;
  3947. }
  3948. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/incremental/semantic_graph/src/type_parameters.mjs
  3949. function extractSemanticTypeParameters(node) {
  3950. if (!ts16.isClassDeclaration(node) || node.typeParameters === void 0) {
  3951. return null;
  3952. }
  3953. return node.typeParameters.map((typeParam) => ({
  3954. hasGenericTypeBound: typeParam.constraint !== void 0
  3955. }));
  3956. }
  3957. function areTypeParametersEqual(current, previous) {
  3958. if (!isArrayEqual(current, previous, isTypeParameterEqual)) {
  3959. return false;
  3960. }
  3961. if (current !== null && current.some((typeParam) => typeParam.hasGenericTypeBound)) {
  3962. return false;
  3963. }
  3964. return true;
  3965. }
  3966. function isTypeParameterEqual(a, b) {
  3967. return a.hasGenericTypeBound === b.hasGenericTypeBound;
  3968. }
  3969. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/scope/src/api.mjs
  3970. var ComponentScopeKind;
  3971. (function(ComponentScopeKind2) {
  3972. ComponentScopeKind2[ComponentScopeKind2["NgModule"] = 0] = "NgModule";
  3973. ComponentScopeKind2[ComponentScopeKind2["Standalone"] = 1] = "Standalone";
  3974. })(ComponentScopeKind || (ComponentScopeKind = {}));
  3975. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/scope/src/component_scope.mjs
  3976. var CompoundComponentScopeReader = class {
  3977. readers;
  3978. constructor(readers) {
  3979. this.readers = readers;
  3980. }
  3981. getScopeForComponent(clazz) {
  3982. for (const reader of this.readers) {
  3983. const meta = reader.getScopeForComponent(clazz);
  3984. if (meta !== null) {
  3985. return meta;
  3986. }
  3987. }
  3988. return null;
  3989. }
  3990. getRemoteScope(clazz) {
  3991. for (const reader of this.readers) {
  3992. const remoteScope = reader.getRemoteScope(clazz);
  3993. if (remoteScope !== null) {
  3994. return remoteScope;
  3995. }
  3996. }
  3997. return null;
  3998. }
  3999. };
  4000. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/scope/src/dependency.mjs
  4001. var MetadataDtsModuleScopeResolver = class {
  4002. dtsMetaReader;
  4003. aliasingHost;
  4004. cache = /* @__PURE__ */ new Map();
  4005. constructor(dtsMetaReader, aliasingHost) {
  4006. this.dtsMetaReader = dtsMetaReader;
  4007. this.aliasingHost = aliasingHost;
  4008. }
  4009. resolve(ref) {
  4010. const clazz = ref.node;
  4011. const sourceFile = clazz.getSourceFile();
  4012. if (!sourceFile.isDeclarationFile) {
  4013. throw new Error(`Debug error: DtsModuleScopeResolver.read(${ref.debugName} from ${sourceFile.fileName}), but not a .d.ts file`);
  4014. }
  4015. if (this.cache.has(clazz)) {
  4016. return this.cache.get(clazz);
  4017. }
  4018. const dependencies = [];
  4019. const meta = this.dtsMetaReader.getNgModuleMetadata(ref);
  4020. if (meta === null) {
  4021. this.cache.set(clazz, null);
  4022. return null;
  4023. }
  4024. const declarations = /* @__PURE__ */ new Set();
  4025. for (const declRef of meta.declarations) {
  4026. declarations.add(declRef.node);
  4027. }
  4028. for (const exportRef of meta.exports) {
  4029. const directive = this.dtsMetaReader.getDirectiveMetadata(exportRef);
  4030. if (directive !== null) {
  4031. const isReExport = !declarations.has(exportRef.node);
  4032. dependencies.push(this.maybeAlias(directive, sourceFile, isReExport));
  4033. continue;
  4034. }
  4035. const pipe = this.dtsMetaReader.getPipeMetadata(exportRef);
  4036. if (pipe !== null) {
  4037. const isReExport = !declarations.has(exportRef.node);
  4038. dependencies.push(this.maybeAlias(pipe, sourceFile, isReExport));
  4039. continue;
  4040. }
  4041. const exportScope2 = this.resolve(exportRef);
  4042. if (exportScope2 !== null) {
  4043. if (this.aliasingHost === null) {
  4044. dependencies.push(...exportScope2.exported.dependencies);
  4045. } else {
  4046. for (const dep of exportScope2.exported.dependencies) {
  4047. dependencies.push(this.maybeAlias(dep, sourceFile, true));
  4048. }
  4049. }
  4050. }
  4051. continue;
  4052. }
  4053. const exportScope = {
  4054. exported: {
  4055. dependencies,
  4056. isPoisoned: meta.isPoisoned
  4057. }
  4058. };
  4059. this.cache.set(clazz, exportScope);
  4060. return exportScope;
  4061. }
  4062. maybeAlias(dirOrPipe, maybeAliasFrom, isReExport) {
  4063. const ref = dirOrPipe.ref;
  4064. if (this.aliasingHost === null || ref.node.getSourceFile() === maybeAliasFrom) {
  4065. return dirOrPipe;
  4066. }
  4067. const alias = this.aliasingHost.getAliasIn(ref.node, maybeAliasFrom, isReExport);
  4068. if (alias === null) {
  4069. return dirOrPipe;
  4070. }
  4071. return {
  4072. ...dirOrPipe,
  4073. ref: ref.cloneWithAlias(alias)
  4074. };
  4075. }
  4076. };
  4077. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/scope/src/local.mjs
  4078. import { ExternalExpr as ExternalExpr3 } from "@angular/compiler";
  4079. import ts17 from "typescript";
  4080. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/scope/src/util.mjs
  4081. function getDiagnosticNode(ref, rawExpr) {
  4082. return rawExpr !== null ? ref.getOriginForDiagnostics(rawExpr) : ref.node.name;
  4083. }
  4084. function makeNotStandaloneDiagnostic(scopeReader, ref, rawExpr, kind) {
  4085. const scope = scopeReader.getScopeForComponent(ref.node);
  4086. let message = `The ${kind} '${ref.node.name.text}' appears in 'imports', but is not standalone and cannot be imported directly.`;
  4087. let relatedInformation = void 0;
  4088. if (scope !== null && scope.kind === ComponentScopeKind.NgModule) {
  4089. const isExported = scope.exported.dependencies.some((dep) => dep.ref.node === ref.node);
  4090. const relatedInfoMessageText = isExported ? `It can be imported using its '${scope.ngModule.name.text}' NgModule instead.` : `It's declared in the '${scope.ngModule.name.text}' NgModule, but is not exported. Consider exporting it and importing the NgModule instead.`;
  4091. relatedInformation = [makeRelatedInformation(scope.ngModule.name, relatedInfoMessageText)];
  4092. } else {
  4093. }
  4094. if (relatedInformation === void 0) {
  4095. message += " It must be imported via an NgModule.";
  4096. }
  4097. return makeDiagnostic(ErrorCode.COMPONENT_IMPORT_NOT_STANDALONE, getDiagnosticNode(ref, rawExpr), message, relatedInformation);
  4098. }
  4099. function makeUnknownComponentImportDiagnostic(ref, rawExpr) {
  4100. return makeDiagnostic(ErrorCode.COMPONENT_UNKNOWN_IMPORT, getDiagnosticNode(ref, rawExpr), `Component imports must be standalone components, directives, pipes, or must be NgModules.`);
  4101. }
  4102. function makeUnknownComponentDeferredImportDiagnostic(ref, rawExpr) {
  4103. return makeDiagnostic(ErrorCode.COMPONENT_UNKNOWN_DEFERRED_IMPORT, getDiagnosticNode(ref, rawExpr), `Component deferred imports must be standalone components, directives or pipes.`);
  4104. }
  4105. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/scope/src/local.mjs
  4106. var IN_PROGRESS_RESOLUTION = {};
  4107. var LocalModuleScopeRegistry = class {
  4108. localReader;
  4109. fullReader;
  4110. dependencyScopeReader;
  4111. refEmitter;
  4112. aliasingHost;
  4113. sealed = false;
  4114. declarationToModule = /* @__PURE__ */ new Map();
  4115. duplicateDeclarations = /* @__PURE__ */ new Map();
  4116. moduleToRef = /* @__PURE__ */ new Map();
  4117. cache = /* @__PURE__ */ new Map();
  4118. remoteScoping = /* @__PURE__ */ new Map();
  4119. scopeErrors = /* @__PURE__ */ new Map();
  4120. modulesWithStructuralErrors = /* @__PURE__ */ new Set();
  4121. constructor(localReader, fullReader, dependencyScopeReader, refEmitter, aliasingHost) {
  4122. this.localReader = localReader;
  4123. this.fullReader = fullReader;
  4124. this.dependencyScopeReader = dependencyScopeReader;
  4125. this.refEmitter = refEmitter;
  4126. this.aliasingHost = aliasingHost;
  4127. }
  4128. registerNgModuleMetadata(data) {
  4129. this.assertCollecting();
  4130. const ngModule = data.ref.node;
  4131. this.moduleToRef.set(data.ref.node, data.ref);
  4132. for (const decl of data.declarations) {
  4133. this.registerDeclarationOfModule(ngModule, decl, data.rawDeclarations);
  4134. }
  4135. }
  4136. registerDirectiveMetadata(directive) {
  4137. }
  4138. registerPipeMetadata(pipe) {
  4139. }
  4140. getScopeForComponent(clazz) {
  4141. const scope = !this.declarationToModule.has(clazz) ? null : this.getScopeOfModule(this.declarationToModule.get(clazz).ngModule);
  4142. return scope;
  4143. }
  4144. getDuplicateDeclarations(node) {
  4145. if (!this.duplicateDeclarations.has(node)) {
  4146. return null;
  4147. }
  4148. return Array.from(this.duplicateDeclarations.get(node).values());
  4149. }
  4150. getScopeOfModule(clazz) {
  4151. return this.moduleToRef.has(clazz) ? this.getScopeOfModuleReference(this.moduleToRef.get(clazz)) : null;
  4152. }
  4153. getDiagnosticsOfModule(clazz) {
  4154. this.getScopeOfModule(clazz);
  4155. if (this.scopeErrors.has(clazz)) {
  4156. return this.scopeErrors.get(clazz);
  4157. } else {
  4158. return null;
  4159. }
  4160. }
  4161. registerDeclarationOfModule(ngModule, decl, rawDeclarations) {
  4162. const declData = {
  4163. ngModule,
  4164. ref: decl,
  4165. rawDeclarations
  4166. };
  4167. if (this.duplicateDeclarations.has(decl.node)) {
  4168. this.duplicateDeclarations.get(decl.node).set(ngModule, declData);
  4169. } else if (this.declarationToModule.has(decl.node) && this.declarationToModule.get(decl.node).ngModule !== ngModule) {
  4170. const duplicateDeclMap = /* @__PURE__ */ new Map();
  4171. const firstDeclData = this.declarationToModule.get(decl.node);
  4172. this.modulesWithStructuralErrors.add(firstDeclData.ngModule);
  4173. this.modulesWithStructuralErrors.add(ngModule);
  4174. duplicateDeclMap.set(firstDeclData.ngModule, firstDeclData);
  4175. duplicateDeclMap.set(ngModule, declData);
  4176. this.duplicateDeclarations.set(decl.node, duplicateDeclMap);
  4177. this.declarationToModule.delete(decl.node);
  4178. } else {
  4179. this.declarationToModule.set(decl.node, declData);
  4180. }
  4181. }
  4182. getScopeOfModuleReference(ref) {
  4183. if (this.cache.has(ref.node)) {
  4184. const cachedValue = this.cache.get(ref.node);
  4185. if (cachedValue !== IN_PROGRESS_RESOLUTION) {
  4186. return cachedValue;
  4187. }
  4188. }
  4189. this.cache.set(ref.node, IN_PROGRESS_RESOLUTION);
  4190. this.sealed = true;
  4191. const ngModule = this.localReader.getNgModuleMetadata(ref);
  4192. if (ngModule === null) {
  4193. this.cache.set(ref.node, null);
  4194. return null;
  4195. }
  4196. const diagnostics = [];
  4197. const compilationDirectives = /* @__PURE__ */ new Map();
  4198. const compilationPipes = /* @__PURE__ */ new Map();
  4199. const declared = /* @__PURE__ */ new Set();
  4200. const exportDirectives = /* @__PURE__ */ new Map();
  4201. const exportPipes = /* @__PURE__ */ new Map();
  4202. let isPoisoned = false;
  4203. if (this.modulesWithStructuralErrors.has(ngModule.ref.node)) {
  4204. isPoisoned = true;
  4205. }
  4206. for (const decl of ngModule.imports) {
  4207. const importScope = this.getExportedScope(decl, diagnostics, ref.node, "import");
  4208. if (importScope !== null) {
  4209. if (importScope === "invalid" || importScope === "cycle" || importScope.exported.isPoisoned) {
  4210. isPoisoned = true;
  4211. if (importScope !== "cycle") {
  4212. diagnostics.push(invalidTransitiveNgModuleRef(decl, ngModule.rawImports, "import"));
  4213. }
  4214. if (importScope === "invalid" || importScope === "cycle") {
  4215. continue;
  4216. }
  4217. }
  4218. for (const dep of importScope.exported.dependencies) {
  4219. if (dep.kind === MetaKind.Directive) {
  4220. compilationDirectives.set(dep.ref.node, dep);
  4221. } else if (dep.kind === MetaKind.Pipe) {
  4222. compilationPipes.set(dep.ref.node, dep);
  4223. }
  4224. }
  4225. continue;
  4226. }
  4227. const directive = this.fullReader.getDirectiveMetadata(decl);
  4228. if (directive !== null) {
  4229. if (directive.isStandalone) {
  4230. compilationDirectives.set(directive.ref.node, directive);
  4231. } else {
  4232. diagnostics.push(makeNotStandaloneDiagnostic(this, decl, ngModule.rawImports, directive.isComponent ? "component" : "directive"));
  4233. isPoisoned = true;
  4234. }
  4235. continue;
  4236. }
  4237. const pipe = this.fullReader.getPipeMetadata(decl);
  4238. if (pipe !== null) {
  4239. if (pipe.isStandalone) {
  4240. compilationPipes.set(pipe.ref.node, pipe);
  4241. } else {
  4242. diagnostics.push(makeNotStandaloneDiagnostic(this, decl, ngModule.rawImports, "pipe"));
  4243. isPoisoned = true;
  4244. }
  4245. continue;
  4246. }
  4247. diagnostics.push(invalidRef(decl, ngModule.rawImports, "import"));
  4248. isPoisoned = true;
  4249. }
  4250. for (const decl of ngModule.declarations) {
  4251. const directive = this.localReader.getDirectiveMetadata(decl);
  4252. const pipe = this.localReader.getPipeMetadata(decl);
  4253. if (directive !== null) {
  4254. if (directive.isStandalone) {
  4255. const refType = directive.isComponent ? "Component" : "Directive";
  4256. diagnostics.push(makeDiagnostic(ErrorCode.NGMODULE_DECLARATION_IS_STANDALONE, decl.getOriginForDiagnostics(ngModule.rawDeclarations), `${refType} ${decl.node.name.text} is standalone, and cannot be declared in an NgModule. Did you mean to import it instead?`));
  4257. isPoisoned = true;
  4258. continue;
  4259. }
  4260. compilationDirectives.set(decl.node, { ...directive, ref: decl });
  4261. if (directive.isPoisoned) {
  4262. isPoisoned = true;
  4263. }
  4264. } else if (pipe !== null) {
  4265. if (pipe.isStandalone) {
  4266. diagnostics.push(makeDiagnostic(ErrorCode.NGMODULE_DECLARATION_IS_STANDALONE, decl.getOriginForDiagnostics(ngModule.rawDeclarations), `Pipe ${decl.node.name.text} is standalone, and cannot be declared in an NgModule. Did you mean to import it instead?`));
  4267. isPoisoned = true;
  4268. continue;
  4269. }
  4270. compilationPipes.set(decl.node, { ...pipe, ref: decl });
  4271. } else {
  4272. const errorNode = decl.getOriginForDiagnostics(ngModule.rawDeclarations);
  4273. diagnostics.push(makeDiagnostic(ErrorCode.NGMODULE_INVALID_DECLARATION, errorNode, `The class '${decl.node.name.text}' is listed in the declarations of the NgModule '${ngModule.ref.node.name.text}', but is not a directive, a component, or a pipe. Either remove it from the NgModule's declarations, or add an appropriate Angular decorator.`, [makeRelatedInformation(decl.node.name, `'${decl.node.name.text}' is declared here.`)]));
  4274. isPoisoned = true;
  4275. continue;
  4276. }
  4277. declared.add(decl.node);
  4278. }
  4279. for (const decl of ngModule.exports) {
  4280. const exportScope = this.getExportedScope(decl, diagnostics, ref.node, "export");
  4281. if (exportScope === "invalid" || exportScope === "cycle" || exportScope !== null && exportScope.exported.isPoisoned) {
  4282. isPoisoned = true;
  4283. if (exportScope !== "cycle") {
  4284. diagnostics.push(invalidTransitiveNgModuleRef(decl, ngModule.rawExports, "export"));
  4285. }
  4286. if (exportScope === "invalid" || exportScope === "cycle") {
  4287. continue;
  4288. }
  4289. } else if (exportScope !== null) {
  4290. for (const dep of exportScope.exported.dependencies) {
  4291. if (dep.kind == MetaKind.Directive) {
  4292. exportDirectives.set(dep.ref.node, dep);
  4293. } else if (dep.kind === MetaKind.Pipe) {
  4294. exportPipes.set(dep.ref.node, dep);
  4295. }
  4296. }
  4297. } else if (compilationDirectives.has(decl.node)) {
  4298. const directive = compilationDirectives.get(decl.node);
  4299. exportDirectives.set(decl.node, directive);
  4300. } else if (compilationPipes.has(decl.node)) {
  4301. const pipe = compilationPipes.get(decl.node);
  4302. exportPipes.set(decl.node, pipe);
  4303. } else {
  4304. const dirMeta = this.fullReader.getDirectiveMetadata(decl);
  4305. const pipeMeta = this.fullReader.getPipeMetadata(decl);
  4306. if (dirMeta !== null || pipeMeta !== null) {
  4307. const isStandalone = dirMeta !== null ? dirMeta.isStandalone : pipeMeta.isStandalone;
  4308. diagnostics.push(invalidReexport(decl, ngModule.rawExports, isStandalone));
  4309. } else {
  4310. diagnostics.push(invalidRef(decl, ngModule.rawExports, "export"));
  4311. }
  4312. isPoisoned = true;
  4313. continue;
  4314. }
  4315. }
  4316. const exported = {
  4317. dependencies: [...exportDirectives.values(), ...exportPipes.values()],
  4318. isPoisoned
  4319. };
  4320. const reexports = this.getReexports(ngModule, ref, declared, exported.dependencies, diagnostics);
  4321. const scope = {
  4322. kind: ComponentScopeKind.NgModule,
  4323. ngModule: ngModule.ref.node,
  4324. compilation: {
  4325. dependencies: [...compilationDirectives.values(), ...compilationPipes.values()],
  4326. isPoisoned
  4327. },
  4328. exported,
  4329. reexports,
  4330. schemas: ngModule.schemas
  4331. };
  4332. if (diagnostics.length > 0) {
  4333. this.scopeErrors.set(ref.node, diagnostics);
  4334. this.modulesWithStructuralErrors.add(ref.node);
  4335. }
  4336. this.cache.set(ref.node, scope);
  4337. return scope;
  4338. }
  4339. getRemoteScope(node) {
  4340. return this.remoteScoping.has(node) ? this.remoteScoping.get(node) : null;
  4341. }
  4342. setComponentRemoteScope(node, directives, pipes) {
  4343. this.remoteScoping.set(node, { directives, pipes });
  4344. }
  4345. getExportedScope(ref, diagnostics, ownerForErrors, type) {
  4346. if (ref.node.getSourceFile().isDeclarationFile) {
  4347. if (!ts17.isClassDeclaration(ref.node)) {
  4348. const code = type === "import" ? ErrorCode.NGMODULE_INVALID_IMPORT : ErrorCode.NGMODULE_INVALID_EXPORT;
  4349. diagnostics.push(makeDiagnostic(code, identifierOfNode(ref.node) || ref.node, `Appears in the NgModule.${type}s of ${nodeNameForError(ownerForErrors)}, but could not be resolved to an NgModule`));
  4350. return "invalid";
  4351. }
  4352. return this.dependencyScopeReader.resolve(ref);
  4353. } else {
  4354. if (this.cache.get(ref.node) === IN_PROGRESS_RESOLUTION) {
  4355. diagnostics.push(makeDiagnostic(type === "import" ? ErrorCode.NGMODULE_INVALID_IMPORT : ErrorCode.NGMODULE_INVALID_EXPORT, identifierOfNode(ref.node) || ref.node, `NgModule "${type}" field contains a cycle`));
  4356. return "cycle";
  4357. }
  4358. return this.getScopeOfModuleReference(ref);
  4359. }
  4360. }
  4361. getReexports(ngModule, ref, declared, exported, diagnostics) {
  4362. let reexports = null;
  4363. const sourceFile = ref.node.getSourceFile();
  4364. if (this.aliasingHost === null) {
  4365. return null;
  4366. }
  4367. reexports = [];
  4368. const reexportMap = /* @__PURE__ */ new Map();
  4369. const ngModuleRef = ref;
  4370. const addReexport = (exportRef) => {
  4371. if (exportRef.node.getSourceFile() === sourceFile) {
  4372. return;
  4373. }
  4374. const isReExport = !declared.has(exportRef.node);
  4375. const exportName = this.aliasingHost.maybeAliasSymbolAs(exportRef, sourceFile, ngModule.ref.node.name.text, isReExport);
  4376. if (exportName === null) {
  4377. return;
  4378. }
  4379. if (!reexportMap.has(exportName)) {
  4380. if (exportRef.alias && exportRef.alias instanceof ExternalExpr3) {
  4381. reexports.push({
  4382. fromModule: exportRef.alias.value.moduleName,
  4383. symbolName: exportRef.alias.value.name,
  4384. asAlias: exportName
  4385. });
  4386. } else {
  4387. const emittedRef = this.refEmitter.emit(exportRef.cloneWithNoIdentifiers(), sourceFile);
  4388. assertSuccessfulReferenceEmit(emittedRef, ngModuleRef.node.name, "class");
  4389. const expr = emittedRef.expression;
  4390. if (!(expr instanceof ExternalExpr3) || expr.value.moduleName === null || expr.value.name === null) {
  4391. throw new Error("Expected ExternalExpr");
  4392. }
  4393. reexports.push({
  4394. fromModule: expr.value.moduleName,
  4395. symbolName: expr.value.name,
  4396. asAlias: exportName
  4397. });
  4398. }
  4399. reexportMap.set(exportName, exportRef);
  4400. } else {
  4401. const prevRef = reexportMap.get(exportName);
  4402. diagnostics.push(reexportCollision(ngModuleRef.node, prevRef, exportRef));
  4403. }
  4404. };
  4405. for (const { ref: ref2 } of exported) {
  4406. addReexport(ref2);
  4407. }
  4408. return reexports;
  4409. }
  4410. assertCollecting() {
  4411. if (this.sealed) {
  4412. throw new Error(`Assertion: LocalModuleScopeRegistry is not COLLECTING`);
  4413. }
  4414. }
  4415. };
  4416. function invalidRef(decl, rawExpr, type) {
  4417. const code = type === "import" ? ErrorCode.NGMODULE_INVALID_IMPORT : ErrorCode.NGMODULE_INVALID_EXPORT;
  4418. const resolveTarget = type === "import" ? "NgModule" : "NgModule, Component, Directive, or Pipe";
  4419. const message = `'${decl.node.name.text}' does not appear to be an ${resolveTarget} class.`;
  4420. const library = decl.ownedByModuleGuess !== null ? ` (${decl.ownedByModuleGuess})` : "";
  4421. const sf = decl.node.getSourceFile();
  4422. let relatedMessage;
  4423. if (!sf.isDeclarationFile) {
  4424. const annotationType = type === "import" ? "@NgModule" : "Angular";
  4425. relatedMessage = `Is it missing an ${annotationType} annotation?`;
  4426. } else if (sf.fileName.indexOf("node_modules") !== -1) {
  4427. relatedMessage = `This likely means that the library${library} which declares ${decl.debugName} is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.`;
  4428. } else {
  4429. relatedMessage = `This likely means that the dependency${library} which declares ${decl.debugName} is not compatible with Angular Ivy.`;
  4430. }
  4431. return makeDiagnostic(code, getDiagnosticNode(decl, rawExpr), message, [
  4432. makeRelatedInformation(decl.node.name, relatedMessage)
  4433. ]);
  4434. }
  4435. function invalidTransitiveNgModuleRef(decl, rawExpr, type) {
  4436. const code = type === "import" ? ErrorCode.NGMODULE_INVALID_IMPORT : ErrorCode.NGMODULE_INVALID_EXPORT;
  4437. return makeDiagnostic(code, getDiagnosticNode(decl, rawExpr), `This ${type} contains errors, which may affect components that depend on this NgModule.`);
  4438. }
  4439. function invalidReexport(decl, rawExpr, isStandalone) {
  4440. let message = `Can't be exported from this NgModule, as `;
  4441. if (isStandalone) {
  4442. message += "it must be imported first";
  4443. } else if (decl.node.getSourceFile().isDeclarationFile) {
  4444. message += "it must be imported via its NgModule first";
  4445. } else {
  4446. message += "it must be either declared by this NgModule, or imported here via its NgModule first";
  4447. }
  4448. return makeDiagnostic(ErrorCode.NGMODULE_INVALID_REEXPORT, getDiagnosticNode(decl, rawExpr), message);
  4449. }
  4450. function reexportCollision(module, refA, refB) {
  4451. const childMessageText = `This directive/pipe is part of the exports of '${module.name.text}' and shares the same name as another exported directive/pipe.`;
  4452. return makeDiagnostic(ErrorCode.NGMODULE_REEXPORT_NAME_COLLISION, module.name, `
  4453. There was a name collision between two classes named '${refA.node.name.text}', which are both part of the exports of '${module.name.text}'.
  4454. Angular generates re-exports of an NgModule's exported directives/pipes from the module's source file in certain cases, using the declared name of the class. If two classes of the same name are exported, this automatic naming does not work.
  4455. To fix this problem please re-export one or both classes directly from this file.
  4456. `.trim(), [
  4457. makeRelatedInformation(refA.node.name, childMessageText),
  4458. makeRelatedInformation(refB.node.name, childMessageText)
  4459. ]);
  4460. }
  4461. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/scope/src/typecheck.mjs
  4462. import { CssSelector, SelectorMatcher } from "@angular/compiler";
  4463. import ts18 from "typescript";
  4464. var TypeCheckScopeRegistry = class {
  4465. scopeReader;
  4466. metaReader;
  4467. hostDirectivesResolver;
  4468. flattenedDirectiveMetaCache = /* @__PURE__ */ new Map();
  4469. scopeCache = /* @__PURE__ */ new Map();
  4470. constructor(scopeReader, metaReader, hostDirectivesResolver) {
  4471. this.scopeReader = scopeReader;
  4472. this.metaReader = metaReader;
  4473. this.hostDirectivesResolver = hostDirectivesResolver;
  4474. }
  4475. getTypeCheckScope(node) {
  4476. const matcher = new SelectorMatcher();
  4477. const directives = [];
  4478. const pipes = /* @__PURE__ */ new Map();
  4479. const scope = this.scopeReader.getScopeForComponent(node);
  4480. if (scope === null) {
  4481. return {
  4482. matcher,
  4483. directives,
  4484. pipes,
  4485. schemas: [],
  4486. isPoisoned: false
  4487. };
  4488. }
  4489. const isNgModuleScope = scope.kind === ComponentScopeKind.NgModule;
  4490. const cacheKey = isNgModuleScope ? scope.ngModule : scope.component;
  4491. const dependencies = isNgModuleScope ? scope.compilation.dependencies : scope.dependencies;
  4492. if (this.scopeCache.has(cacheKey)) {
  4493. return this.scopeCache.get(cacheKey);
  4494. }
  4495. let allDependencies = dependencies;
  4496. if (!isNgModuleScope && Array.isArray(scope.deferredDependencies) && scope.deferredDependencies.length > 0) {
  4497. allDependencies = [...allDependencies, ...scope.deferredDependencies];
  4498. }
  4499. for (const meta of allDependencies) {
  4500. if (meta.kind === MetaKind.Directive && meta.selector !== null) {
  4501. const extMeta = this.getTypeCheckDirectiveMetadata(meta.ref);
  4502. if (extMeta === null) {
  4503. continue;
  4504. }
  4505. const directiveMeta = this.applyExplicitlyDeferredFlag(extMeta, meta.isExplicitlyDeferred);
  4506. matcher.addSelectables(CssSelector.parse(meta.selector), [
  4507. ...this.hostDirectivesResolver.resolve(directiveMeta),
  4508. directiveMeta
  4509. ]);
  4510. directives.push(directiveMeta);
  4511. } else if (meta.kind === MetaKind.Pipe) {
  4512. if (!ts18.isClassDeclaration(meta.ref.node)) {
  4513. throw new Error(`Unexpected non-class declaration ${ts18.SyntaxKind[meta.ref.node.kind]} for pipe ${meta.ref.debugName}`);
  4514. }
  4515. pipes.set(meta.name, meta);
  4516. }
  4517. }
  4518. const typeCheckScope = {
  4519. matcher,
  4520. directives,
  4521. pipes,
  4522. schemas: scope.schemas,
  4523. isPoisoned: scope.kind === ComponentScopeKind.NgModule ? scope.compilation.isPoisoned || scope.exported.isPoisoned : scope.isPoisoned
  4524. };
  4525. this.scopeCache.set(cacheKey, typeCheckScope);
  4526. return typeCheckScope;
  4527. }
  4528. getTypeCheckDirectiveMetadata(ref) {
  4529. const clazz = ref.node;
  4530. if (this.flattenedDirectiveMetaCache.has(clazz)) {
  4531. return this.flattenedDirectiveMetaCache.get(clazz);
  4532. }
  4533. const meta = flattenInheritedDirectiveMetadata(this.metaReader, ref);
  4534. if (meta === null) {
  4535. return null;
  4536. }
  4537. this.flattenedDirectiveMetaCache.set(clazz, meta);
  4538. return meta;
  4539. }
  4540. applyExplicitlyDeferredFlag(meta, isExplicitlyDeferred) {
  4541. return isExplicitlyDeferred === true ? { ...meta, isExplicitlyDeferred } : meta;
  4542. }
  4543. };
  4544. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/directive/src/handler.mjs
  4545. import { compileClassMetadata, compileDeclareClassMetadata, compileDeclareDirectiveFromMetadata, compileDirectiveFromMetadata, FactoryTarget, makeBindingParser, WrappedNodeExpr as WrappedNodeExpr6 } from "@angular/compiler";
  4546. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/directive/src/shared.mjs
  4547. import { createMayBeForwardRefExpression as createMayBeForwardRefExpression2, emitDistinctChangesOnlyDefaultValue, ExternalExpr as ExternalExpr4, getSafePropertyAccessString, parseHostBindings, ParserError, verifyHostBindings, WrappedNodeExpr as WrappedNodeExpr5 } from "@angular/compiler";
  4548. import ts22 from "typescript";
  4549. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/directive/src/initializer_function_access.mjs
  4550. function validateAccessOfInitializerApiMember({ api, call }, member) {
  4551. if (!api.allowedAccessLevels.includes(member.accessLevel)) {
  4552. throw new FatalDiagnosticError(ErrorCode.INITIALIZER_API_DISALLOWED_MEMBER_VISIBILITY, call, makeDiagnosticChain(`Cannot use "${api.functionName}" on a class member that is declared as ${classMemberAccessLevelToString(member.accessLevel)}.`, [
  4553. makeDiagnosticChain(`Update the class field to be either: ` + api.allowedAccessLevels.map((l) => classMemberAccessLevelToString(l)).join(", "))
  4554. ]));
  4555. }
  4556. }
  4557. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/directive/src/initializer_functions.mjs
  4558. import ts19 from "typescript";
  4559. function tryParseInitializerApi(functions, expression, reflector, importTracker) {
  4560. if (!ts19.isCallExpression(expression)) {
  4561. return null;
  4562. }
  4563. const staticResult = parseTopLevelCall(expression, functions, importTracker) || parseTopLevelRequiredCall(expression, functions, importTracker) || parseTopLevelCallFromNamespace(expression, functions, importTracker);
  4564. if (staticResult === null) {
  4565. return null;
  4566. }
  4567. const { api, apiReference, isRequired } = staticResult;
  4568. const resolvedImport = reflector.getImportOfIdentifier(apiReference);
  4569. if (resolvedImport === null || api.functionName !== resolvedImport.name || api.owningModule !== resolvedImport.from) {
  4570. return null;
  4571. }
  4572. return {
  4573. api,
  4574. call: expression,
  4575. isRequired
  4576. };
  4577. }
  4578. function parseTopLevelCall(call, functions, importTracker) {
  4579. const node = call.expression;
  4580. if (!ts19.isIdentifier(node)) {
  4581. return null;
  4582. }
  4583. const matchingApi = functions.find((fn) => importTracker.isPotentialReferenceToNamedImport(node, fn.functionName, fn.owningModule));
  4584. if (matchingApi === void 0) {
  4585. return null;
  4586. }
  4587. return { api: matchingApi, apiReference: node, isRequired: false };
  4588. }
  4589. function parseTopLevelRequiredCall(call, functions, importTracker) {
  4590. const node = call.expression;
  4591. if (!ts19.isPropertyAccessExpression(node) || !ts19.isIdentifier(node.expression) || node.name.text !== "required") {
  4592. return null;
  4593. }
  4594. const expression = node.expression;
  4595. const matchingApi = functions.find((fn) => importTracker.isPotentialReferenceToNamedImport(expression, fn.functionName, fn.owningModule));
  4596. if (matchingApi === void 0) {
  4597. return null;
  4598. }
  4599. return { api: matchingApi, apiReference: expression, isRequired: true };
  4600. }
  4601. function parseTopLevelCallFromNamespace(call, functions, importTracker) {
  4602. const node = call.expression;
  4603. if (!ts19.isPropertyAccessExpression(node)) {
  4604. return null;
  4605. }
  4606. let apiReference = null;
  4607. let matchingApi = void 0;
  4608. let isRequired = false;
  4609. if (ts19.isIdentifier(node.expression) && ts19.isIdentifier(node.name)) {
  4610. const namespaceRef = node.expression;
  4611. apiReference = node.name;
  4612. matchingApi = functions.find((fn) => node.name.text === fn.functionName && importTracker.isPotentialReferenceToNamespaceImport(namespaceRef, fn.owningModule));
  4613. } else if (ts19.isPropertyAccessExpression(node.expression) && ts19.isIdentifier(node.expression.expression) && ts19.isIdentifier(node.expression.name) && node.name.text === "required") {
  4614. const potentialName = node.expression.name.text;
  4615. const namespaceRef = node.expression.expression;
  4616. apiReference = node.expression.name;
  4617. matchingApi = functions.find((fn) => fn.functionName === potentialName && importTracker.isPotentialReferenceToNamespaceImport(namespaceRef, fn.owningModule));
  4618. isRequired = true;
  4619. }
  4620. if (matchingApi === void 0 || apiReference === null) {
  4621. return null;
  4622. }
  4623. return { api: matchingApi, apiReference, isRequired };
  4624. }
  4625. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/directive/src/input_output_parse_options.mjs
  4626. import ts20 from "typescript";
  4627. function parseAndValidateInputAndOutputOptions(optionsNode) {
  4628. if (!ts20.isObjectLiteralExpression(optionsNode)) {
  4629. throw new FatalDiagnosticError(ErrorCode.VALUE_HAS_WRONG_TYPE, optionsNode, "Argument needs to be an object literal that is statically analyzable.");
  4630. }
  4631. const options = reflectObjectLiteral(optionsNode);
  4632. let alias = void 0;
  4633. if (options.has("alias")) {
  4634. const aliasExpr = options.get("alias");
  4635. if (!ts20.isStringLiteralLike(aliasExpr)) {
  4636. throw new FatalDiagnosticError(ErrorCode.VALUE_HAS_WRONG_TYPE, aliasExpr, "Alias needs to be a string that is statically analyzable.");
  4637. }
  4638. alias = aliasExpr.text;
  4639. }
  4640. return { alias };
  4641. }
  4642. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/directive/src/input_function.mjs
  4643. var INPUT_INITIALIZER_FN = {
  4644. functionName: "input",
  4645. owningModule: "@angular/core",
  4646. allowedAccessLevels: [
  4647. ClassMemberAccessLevel.PublicWritable,
  4648. ClassMemberAccessLevel.PublicReadonly,
  4649. ClassMemberAccessLevel.Protected
  4650. ]
  4651. };
  4652. function tryParseSignalInputMapping(member, reflector, importTracker) {
  4653. var _a;
  4654. if (member.value === null) {
  4655. return null;
  4656. }
  4657. const signalInput = tryParseInitializerApi([INPUT_INITIALIZER_FN], member.value, reflector, importTracker);
  4658. if (signalInput === null) {
  4659. return null;
  4660. }
  4661. validateAccessOfInitializerApiMember(signalInput, member);
  4662. const optionsNode = signalInput.isRequired ? signalInput.call.arguments[0] : signalInput.call.arguments[1];
  4663. const options = optionsNode !== void 0 ? parseAndValidateInputAndOutputOptions(optionsNode) : null;
  4664. const classPropertyName = member.name;
  4665. return {
  4666. isSignal: true,
  4667. classPropertyName,
  4668. bindingPropertyName: (_a = options == null ? void 0 : options.alias) != null ? _a : classPropertyName,
  4669. required: signalInput.isRequired,
  4670. transform: null
  4671. };
  4672. }
  4673. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/directive/src/model_function.mjs
  4674. var MODEL_INITIALIZER_FN = {
  4675. functionName: "model",
  4676. owningModule: "@angular/core",
  4677. allowedAccessLevels: [
  4678. ClassMemberAccessLevel.PublicWritable,
  4679. ClassMemberAccessLevel.PublicReadonly,
  4680. ClassMemberAccessLevel.Protected
  4681. ]
  4682. };
  4683. function tryParseSignalModelMapping(member, reflector, importTracker) {
  4684. var _a;
  4685. if (member.value === null) {
  4686. return null;
  4687. }
  4688. const model = tryParseInitializerApi([MODEL_INITIALIZER_FN], member.value, reflector, importTracker);
  4689. if (model === null) {
  4690. return null;
  4691. }
  4692. validateAccessOfInitializerApiMember(model, member);
  4693. const optionsNode = model.isRequired ? model.call.arguments[0] : model.call.arguments[1];
  4694. const options = optionsNode !== void 0 ? parseAndValidateInputAndOutputOptions(optionsNode) : null;
  4695. const classPropertyName = member.name;
  4696. const bindingPropertyName = (_a = options == null ? void 0 : options.alias) != null ? _a : classPropertyName;
  4697. return {
  4698. call: model.call,
  4699. input: {
  4700. isSignal: true,
  4701. transform: null,
  4702. classPropertyName,
  4703. bindingPropertyName,
  4704. required: model.isRequired
  4705. },
  4706. output: {
  4707. isSignal: false,
  4708. classPropertyName,
  4709. bindingPropertyName: bindingPropertyName + "Change"
  4710. }
  4711. };
  4712. }
  4713. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/directive/src/output_function.mjs
  4714. var allowedAccessLevels = [
  4715. ClassMemberAccessLevel.PublicWritable,
  4716. ClassMemberAccessLevel.PublicReadonly,
  4717. ClassMemberAccessLevel.Protected
  4718. ];
  4719. var OUTPUT_INITIALIZER_FNS = [
  4720. {
  4721. functionName: "output",
  4722. owningModule: "@angular/core",
  4723. allowedAccessLevels
  4724. },
  4725. {
  4726. functionName: "outputFromObservable",
  4727. owningModule: "@angular/core/rxjs-interop",
  4728. allowedAccessLevels
  4729. }
  4730. ];
  4731. function tryParseInitializerBasedOutput(member, reflector, importTracker) {
  4732. var _a;
  4733. if (member.value === null) {
  4734. return null;
  4735. }
  4736. const output = tryParseInitializerApi(OUTPUT_INITIALIZER_FNS, member.value, reflector, importTracker);
  4737. if (output === null) {
  4738. return null;
  4739. }
  4740. if (output.isRequired) {
  4741. throw new FatalDiagnosticError(ErrorCode.INITIALIZER_API_NO_REQUIRED_FUNCTION, output.call, `Output does not support ".required()".`);
  4742. }
  4743. validateAccessOfInitializerApiMember(output, member);
  4744. const optionsNode = output.api.functionName === "output" ? output.call.arguments[0] : output.call.arguments[1];
  4745. const options = optionsNode !== void 0 ? parseAndValidateInputAndOutputOptions(optionsNode) : null;
  4746. const classPropertyName = member.name;
  4747. return {
  4748. call: output.call,
  4749. metadata: {
  4750. isSignal: false,
  4751. classPropertyName,
  4752. bindingPropertyName: (_a = options == null ? void 0 : options.alias) != null ? _a : classPropertyName
  4753. }
  4754. };
  4755. }
  4756. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/directive/src/query_functions.mjs
  4757. import { createMayBeForwardRefExpression, outputAst as o } from "@angular/compiler";
  4758. import ts21 from "typescript";
  4759. var queryFunctionNames = [
  4760. "viewChild",
  4761. "viewChildren",
  4762. "contentChild",
  4763. "contentChildren"
  4764. ];
  4765. var QUERY_INITIALIZER_FNS = queryFunctionNames.map((fnName) => ({
  4766. functionName: fnName,
  4767. owningModule: "@angular/core",
  4768. allowedAccessLevels: [
  4769. ClassMemberAccessLevel.PublicWritable,
  4770. ClassMemberAccessLevel.PublicReadonly,
  4771. ClassMemberAccessLevel.Protected,
  4772. ClassMemberAccessLevel.Private
  4773. ]
  4774. }));
  4775. var defaultDescendantsValue = (type) => type !== "contentChildren";
  4776. function tryParseSignalQueryFromInitializer(member, reflector, importTracker) {
  4777. if (member.value === null) {
  4778. return null;
  4779. }
  4780. const query = tryParseInitializerApi(QUERY_INITIALIZER_FNS, member.value, reflector, importTracker);
  4781. if (query === null) {
  4782. return null;
  4783. }
  4784. validateAccessOfInitializerApiMember(query, member);
  4785. const { functionName } = query.api;
  4786. const isSingleQuery = functionName === "viewChild" || functionName === "contentChild";
  4787. const predicateNode = query.call.arguments[0];
  4788. if (predicateNode === void 0) {
  4789. throw new FatalDiagnosticError(ErrorCode.VALUE_HAS_WRONG_TYPE, query.call, "No locator specified.");
  4790. }
  4791. const optionsNode = query.call.arguments[1];
  4792. if (optionsNode !== void 0 && !ts21.isObjectLiteralExpression(optionsNode)) {
  4793. throw new FatalDiagnosticError(ErrorCode.VALUE_HAS_WRONG_TYPE, optionsNode, "Argument needs to be an object literal.");
  4794. }
  4795. const options = optionsNode && reflectObjectLiteral(optionsNode);
  4796. const read = (options == null ? void 0 : options.has("read")) ? parseReadOption(options.get("read")) : null;
  4797. const descendants = (options == null ? void 0 : options.has("descendants")) ? parseDescendantsOption(options.get("descendants")) : defaultDescendantsValue(functionName);
  4798. return {
  4799. name: functionName,
  4800. call: query.call,
  4801. metadata: {
  4802. isSignal: true,
  4803. propertyName: member.name,
  4804. static: false,
  4805. emitDistinctChangesOnly: true,
  4806. predicate: parseLocator(predicateNode, reflector),
  4807. first: isSingleQuery,
  4808. read,
  4809. descendants
  4810. }
  4811. };
  4812. }
  4813. function parseLocator(expression, reflector) {
  4814. const unwrappedExpression = tryUnwrapForwardRef(expression, reflector);
  4815. if (unwrappedExpression !== null) {
  4816. expression = unwrappedExpression;
  4817. }
  4818. if (ts21.isStringLiteralLike(expression)) {
  4819. return [expression.text];
  4820. }
  4821. return createMayBeForwardRefExpression(new o.WrappedNodeExpr(expression), unwrappedExpression !== null ? 2 : 0);
  4822. }
  4823. function parseReadOption(value) {
  4824. if (ts21.isExpressionWithTypeArguments(value) || ts21.isParenthesizedExpression(value) || ts21.isAsExpression(value)) {
  4825. return parseReadOption(value.expression);
  4826. }
  4827. if (ts21.isPropertyAccessExpression(value) && ts21.isIdentifier(value.expression) || ts21.isIdentifier(value)) {
  4828. return new o.WrappedNodeExpr(value);
  4829. }
  4830. throw new FatalDiagnosticError(ErrorCode.VALUE_NOT_LITERAL, value, `Query "read" option expected a literal class reference.`);
  4831. }
  4832. function parseDescendantsOption(value) {
  4833. if (value.kind === ts21.SyntaxKind.TrueKeyword) {
  4834. return true;
  4835. } else if (value.kind === ts21.SyntaxKind.FalseKeyword) {
  4836. return false;
  4837. }
  4838. throw new FatalDiagnosticError(ErrorCode.VALUE_HAS_WRONG_TYPE, value, `Expected "descendants" option to be a boolean literal.`);
  4839. }
  4840. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/directive/src/shared.mjs
  4841. var EMPTY_OBJECT = {};
  4842. var queryDecoratorNames = [
  4843. "ViewChild",
  4844. "ViewChildren",
  4845. "ContentChild",
  4846. "ContentChildren"
  4847. ];
  4848. var QUERY_TYPES = new Set(queryDecoratorNames);
  4849. function extractDirectiveMetadata(clazz, decorator, reflector, importTracker, evaluator, refEmitter, referencesRegistry, isCore, annotateForClosureCompiler, compilationMode, defaultSelector, strictStandalone, implicitStandaloneValue) {
  4850. let directive;
  4851. if (decorator.args === null || decorator.args.length === 0) {
  4852. directive = /* @__PURE__ */ new Map();
  4853. } else if (decorator.args.length !== 1) {
  4854. throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARITY_WRONG, decorator.node, `Incorrect number of arguments to @${decorator.name} decorator`);
  4855. } else {
  4856. const meta = unwrapExpression(decorator.args[0]);
  4857. if (!ts22.isObjectLiteralExpression(meta)) {
  4858. throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARG_NOT_LITERAL, meta, `@${decorator.name} argument must be an object literal`);
  4859. }
  4860. directive = reflectObjectLiteral(meta);
  4861. }
  4862. if (directive.has("jit")) {
  4863. return { jitForced: true };
  4864. }
  4865. const members = reflector.getMembersOfClass(clazz);
  4866. const decoratedElements = members.filter((member) => !member.isStatic && member.decorators !== null);
  4867. const coreModule = isCore ? void 0 : "@angular/core";
  4868. const inputsFromMeta = parseInputsArray(clazz, directive, evaluator, reflector, refEmitter, compilationMode);
  4869. const inputsFromFields = parseInputFields(clazz, members, evaluator, reflector, importTracker, refEmitter, isCore, compilationMode, inputsFromMeta, decorator);
  4870. const inputs = ClassPropertyMapping.fromMappedObject({ ...inputsFromMeta, ...inputsFromFields });
  4871. const outputsFromMeta = parseOutputsArray(directive, evaluator);
  4872. const outputsFromFields = parseOutputFields(clazz, decorator, members, isCore, reflector, importTracker, evaluator, outputsFromMeta);
  4873. const outputs = ClassPropertyMapping.fromMappedObject({ ...outputsFromMeta, ...outputsFromFields });
  4874. const { viewQueries, contentQueries } = parseQueriesOfClassFields(members, reflector, importTracker, evaluator, isCore);
  4875. if (directive.has("queries")) {
  4876. const signalQueryFields = new Set([...viewQueries, ...contentQueries].filter((q) => q.isSignal).map((q) => q.propertyName));
  4877. const queriesFromDecorator = extractQueriesFromDecorator(directive.get("queries"), reflector, evaluator, isCore);
  4878. const checkAndUnwrapQuery = (q) => {
  4879. if (signalQueryFields.has(q.metadata.propertyName)) {
  4880. throw new FatalDiagnosticError(ErrorCode.INITIALIZER_API_DECORATOR_METADATA_COLLISION, q.expr, `Query is declared multiple times. "@${decorator.name}" declares a query for the same property.`);
  4881. }
  4882. return q.metadata;
  4883. };
  4884. contentQueries.push(...queriesFromDecorator.content.map((q) => checkAndUnwrapQuery(q)));
  4885. viewQueries.push(...queriesFromDecorator.view.map((q) => checkAndUnwrapQuery(q)));
  4886. }
  4887. let selector = defaultSelector;
  4888. if (directive.has("selector")) {
  4889. const expr = directive.get("selector");
  4890. const resolved = evaluator.evaluate(expr);
  4891. assertLocalCompilationUnresolvedConst(compilationMode, resolved, null, "Unresolved identifier found for @Component.selector field! Did you import this identifier from a file outside of the compilation unit? This is not allowed when Angular compiler runs in local mode. Possible solutions: 1) Move the declarations into a file within the compilation unit, 2) Inline the selector");
  4892. if (typeof resolved !== "string") {
  4893. throw createValueHasWrongTypeError(expr, resolved, `selector must be a string`);
  4894. }
  4895. selector = resolved === "" ? defaultSelector : resolved;
  4896. if (!selector) {
  4897. throw new FatalDiagnosticError(ErrorCode.DIRECTIVE_MISSING_SELECTOR, expr, `Directive ${clazz.name.text} has no selector, please add it!`);
  4898. }
  4899. }
  4900. const host = extractHostBindings(decoratedElements, evaluator, coreModule, compilationMode, directive);
  4901. const providers = directive.has("providers") ? new WrappedNodeExpr5(annotateForClosureCompiler ? wrapFunctionExpressionsInParens(directive.get("providers")) : directive.get("providers")) : null;
  4902. const usesOnChanges = members.some((member) => !member.isStatic && member.kind === ClassMemberKind.Method && member.name === "ngOnChanges");
  4903. let exportAs = null;
  4904. if (directive.has("exportAs")) {
  4905. const expr = directive.get("exportAs");
  4906. const resolved = evaluator.evaluate(expr);
  4907. assertLocalCompilationUnresolvedConst(compilationMode, resolved, null, "Unresolved identifier found for exportAs field! Did you import this identifier from a file outside of the compilation unit? This is not allowed when Angular compiler runs in local mode. Possible solutions: 1) Move the declarations into a file within the compilation unit, 2) Inline the selector");
  4908. if (typeof resolved !== "string") {
  4909. throw createValueHasWrongTypeError(expr, resolved, `exportAs must be a string`);
  4910. }
  4911. exportAs = resolved.split(",").map((part) => part.trim());
  4912. }
  4913. const rawCtorDeps = getConstructorDependencies(clazz, reflector, isCore);
  4914. const ctorDeps = selector !== null ? validateConstructorDependencies(clazz, rawCtorDeps) : unwrapConstructorDependencies(rawCtorDeps);
  4915. const isStructural = ctorDeps !== null && ctorDeps !== "invalid" && ctorDeps.some((dep) => dep.token instanceof ExternalExpr4 && dep.token.value.moduleName === "@angular/core" && dep.token.value.name === "TemplateRef");
  4916. let isStandalone = implicitStandaloneValue;
  4917. if (directive.has("standalone")) {
  4918. const expr = directive.get("standalone");
  4919. const resolved = evaluator.evaluate(expr);
  4920. if (typeof resolved !== "boolean") {
  4921. throw createValueHasWrongTypeError(expr, resolved, `standalone flag must be a boolean`);
  4922. }
  4923. isStandalone = resolved;
  4924. if (!isStandalone && strictStandalone) {
  4925. throw new FatalDiagnosticError(ErrorCode.NON_STANDALONE_NOT_ALLOWED, expr, `Only standalone components/directives are allowed when 'strictStandalone' is enabled.`);
  4926. }
  4927. }
  4928. let isSignal = false;
  4929. if (directive.has("signals")) {
  4930. const expr = directive.get("signals");
  4931. const resolved = evaluator.evaluate(expr);
  4932. if (typeof resolved !== "boolean") {
  4933. throw createValueHasWrongTypeError(expr, resolved, `signals flag must be a boolean`);
  4934. }
  4935. isSignal = resolved;
  4936. }
  4937. const usesInheritance = reflector.hasBaseClass(clazz);
  4938. const sourceFile = clazz.getSourceFile();
  4939. const type = wrapTypeReference(reflector, clazz);
  4940. const rawHostDirectives = directive.get("hostDirectives") || null;
  4941. const hostDirectives = rawHostDirectives === null ? null : extractHostDirectives(rawHostDirectives, evaluator, compilationMode, createForwardRefResolver(isCore));
  4942. if (compilationMode !== CompilationMode.LOCAL && hostDirectives !== null) {
  4943. referencesRegistry.add(clazz, ...hostDirectives.map((hostDir) => {
  4944. if (!isHostDirectiveMetaForGlobalMode(hostDir)) {
  4945. throw new Error("Impossible state");
  4946. }
  4947. return hostDir.directive;
  4948. }));
  4949. }
  4950. const metadata = {
  4951. name: clazz.name.text,
  4952. deps: ctorDeps,
  4953. host: {
  4954. ...host
  4955. },
  4956. lifecycle: {
  4957. usesOnChanges
  4958. },
  4959. inputs: inputs.toJointMappedObject(toR3InputMetadata),
  4960. outputs: outputs.toDirectMappedObject(),
  4961. queries: contentQueries,
  4962. viewQueries,
  4963. selector,
  4964. fullInheritance: false,
  4965. type,
  4966. typeArgumentCount: reflector.getGenericArityOfClass(clazz) || 0,
  4967. typeSourceSpan: createSourceSpan(clazz.name),
  4968. usesInheritance,
  4969. exportAs,
  4970. providers,
  4971. isStandalone,
  4972. isSignal,
  4973. hostDirectives: (hostDirectives == null ? void 0 : hostDirectives.map((hostDir) => toHostDirectiveMetadata(hostDir, sourceFile, refEmitter))) || null
  4974. };
  4975. return {
  4976. jitForced: false,
  4977. decorator: directive,
  4978. metadata,
  4979. inputs,
  4980. outputs,
  4981. isStructural,
  4982. hostDirectives,
  4983. rawHostDirectives,
  4984. inputFieldNamesFromMetadataArray: new Set(Object.values(inputsFromMeta).map((i) => i.classPropertyName))
  4985. };
  4986. }
  4987. function extractDecoratorQueryMetadata(exprNode, name, args, propertyName, reflector, evaluator) {
  4988. if (args.length === 0) {
  4989. throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARITY_WRONG, exprNode, `@${name} must have arguments`);
  4990. }
  4991. const first = name === "ViewChild" || name === "ContentChild";
  4992. const forwardReferenceTarget = tryUnwrapForwardRef(args[0], reflector);
  4993. const node = forwardReferenceTarget != null ? forwardReferenceTarget : args[0];
  4994. const arg = evaluator.evaluate(node);
  4995. let isStatic = false;
  4996. let predicate = null;
  4997. if (arg instanceof Reference || arg instanceof DynamicValue) {
  4998. predicate = createMayBeForwardRefExpression2(new WrappedNodeExpr5(node), forwardReferenceTarget !== null ? 2 : 0);
  4999. } else if (typeof arg === "string") {
  5000. predicate = [arg];
  5001. } else if (isStringArrayOrDie(arg, `@${name} predicate`, node)) {
  5002. predicate = arg;
  5003. } else {
  5004. throw createValueHasWrongTypeError(node, arg, `@${name} predicate cannot be interpreted`);
  5005. }
  5006. let read = null;
  5007. let descendants = name !== "ContentChildren";
  5008. let emitDistinctChangesOnly = emitDistinctChangesOnlyDefaultValue;
  5009. if (args.length === 2) {
  5010. const optionsExpr = unwrapExpression(args[1]);
  5011. if (!ts22.isObjectLiteralExpression(optionsExpr)) {
  5012. throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARG_NOT_LITERAL, optionsExpr, `@${name} options must be an object literal`);
  5013. }
  5014. const options = reflectObjectLiteral(optionsExpr);
  5015. if (options.has("read")) {
  5016. read = new WrappedNodeExpr5(options.get("read"));
  5017. }
  5018. if (options.has("descendants")) {
  5019. const descendantsExpr = options.get("descendants");
  5020. const descendantsValue = evaluator.evaluate(descendantsExpr);
  5021. if (typeof descendantsValue !== "boolean") {
  5022. throw createValueHasWrongTypeError(descendantsExpr, descendantsValue, `@${name} options.descendants must be a boolean`);
  5023. }
  5024. descendants = descendantsValue;
  5025. }
  5026. if (options.has("emitDistinctChangesOnly")) {
  5027. const emitDistinctChangesOnlyExpr = options.get("emitDistinctChangesOnly");
  5028. const emitDistinctChangesOnlyValue = evaluator.evaluate(emitDistinctChangesOnlyExpr);
  5029. if (typeof emitDistinctChangesOnlyValue !== "boolean") {
  5030. throw createValueHasWrongTypeError(emitDistinctChangesOnlyExpr, emitDistinctChangesOnlyValue, `@${name} options.emitDistinctChangesOnly must be a boolean`);
  5031. }
  5032. emitDistinctChangesOnly = emitDistinctChangesOnlyValue;
  5033. }
  5034. if (options.has("static")) {
  5035. const staticValue = evaluator.evaluate(options.get("static"));
  5036. if (typeof staticValue !== "boolean") {
  5037. throw createValueHasWrongTypeError(node, staticValue, `@${name} options.static must be a boolean`);
  5038. }
  5039. isStatic = staticValue;
  5040. }
  5041. } else if (args.length > 2) {
  5042. throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARITY_WRONG, node, `@${name} has too many arguments`);
  5043. }
  5044. return {
  5045. isSignal: false,
  5046. propertyName,
  5047. predicate,
  5048. first,
  5049. descendants,
  5050. read,
  5051. static: isStatic,
  5052. emitDistinctChangesOnly
  5053. };
  5054. }
  5055. function extractHostBindings(members, evaluator, coreModule, compilationMode, metadata) {
  5056. let bindings;
  5057. if (metadata && metadata.has("host")) {
  5058. bindings = evaluateHostExpressionBindings(metadata.get("host"), evaluator);
  5059. } else {
  5060. bindings = parseHostBindings({});
  5061. }
  5062. filterToMembersWithDecorator(members, "HostBinding", coreModule).forEach(({ member, decorators }) => {
  5063. decorators.forEach((decorator) => {
  5064. let hostPropertyName = member.name;
  5065. if (decorator.args !== null && decorator.args.length > 0) {
  5066. if (decorator.args.length !== 1) {
  5067. throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARITY_WRONG, decorator.node, `@HostBinding can have at most one argument, got ${decorator.args.length} argument(s)`);
  5068. }
  5069. const resolved = evaluator.evaluate(decorator.args[0]);
  5070. assertLocalCompilationUnresolvedConst(compilationMode, resolved, null, "Unresolved identifier found for @HostBinding's argument! Did you import this identifier from a file outside of the compilation unit? This is not allowed when Angular compiler runs in local mode. Possible solutions: 1) Move the declaration into a file within the compilation unit, 2) Inline the argument");
  5071. if (typeof resolved !== "string") {
  5072. throw createValueHasWrongTypeError(decorator.node, resolved, `@HostBinding's argument must be a string`);
  5073. }
  5074. hostPropertyName = resolved;
  5075. }
  5076. bindings.properties[hostPropertyName] = getSafePropertyAccessString("this", member.name);
  5077. });
  5078. });
  5079. filterToMembersWithDecorator(members, "HostListener", coreModule).forEach(({ member, decorators }) => {
  5080. decorators.forEach((decorator) => {
  5081. let eventName = member.name;
  5082. let args = [];
  5083. if (decorator.args !== null && decorator.args.length > 0) {
  5084. if (decorator.args.length > 2) {
  5085. throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARITY_WRONG, decorator.args[2], `@HostListener can have at most two arguments`);
  5086. }
  5087. const resolved = evaluator.evaluate(decorator.args[0]);
  5088. assertLocalCompilationUnresolvedConst(compilationMode, resolved, null, "Unresolved identifier found for @HostListener's event name argument! Did you import this identifier from a file outside of the compilation unit? This is not allowed when Angular compiler runs in local mode. Possible solutions: 1) Move the declaration into a file within the compilation unit, 2) Inline the argument");
  5089. if (typeof resolved !== "string") {
  5090. throw createValueHasWrongTypeError(decorator.args[0], resolved, `@HostListener's event name argument must be a string`);
  5091. }
  5092. eventName = resolved;
  5093. if (decorator.args.length === 2) {
  5094. const expression = decorator.args[1];
  5095. const resolvedArgs = evaluator.evaluate(decorator.args[1]);
  5096. if (!isStringArrayOrDie(resolvedArgs, "@HostListener.args", expression)) {
  5097. throw createValueHasWrongTypeError(decorator.args[1], resolvedArgs, `@HostListener's second argument must be a string array`);
  5098. }
  5099. args = resolvedArgs;
  5100. }
  5101. }
  5102. bindings.listeners[eventName] = `${member.name}(${args.join(",")})`;
  5103. });
  5104. });
  5105. return bindings;
  5106. }
  5107. function extractQueriesFromDecorator(queryData, reflector, evaluator, isCore) {
  5108. const content = [];
  5109. const view = [];
  5110. if (!ts22.isObjectLiteralExpression(queryData)) {
  5111. throw new FatalDiagnosticError(ErrorCode.VALUE_HAS_WRONG_TYPE, queryData, "Decorator queries metadata must be an object literal");
  5112. }
  5113. reflectObjectLiteral(queryData).forEach((queryExpr, propertyName) => {
  5114. queryExpr = unwrapExpression(queryExpr);
  5115. if (!ts22.isNewExpression(queryExpr)) {
  5116. throw new FatalDiagnosticError(ErrorCode.VALUE_HAS_WRONG_TYPE, queryData, "Decorator query metadata must be an instance of a query type");
  5117. }
  5118. const queryType = ts22.isPropertyAccessExpression(queryExpr.expression) ? queryExpr.expression.name : queryExpr.expression;
  5119. if (!ts22.isIdentifier(queryType)) {
  5120. throw new FatalDiagnosticError(ErrorCode.VALUE_HAS_WRONG_TYPE, queryData, "Decorator query metadata must be an instance of a query type");
  5121. }
  5122. const type = reflector.getImportOfIdentifier(queryType);
  5123. if (type === null || !isCore && type.from !== "@angular/core" || !QUERY_TYPES.has(type.name)) {
  5124. throw new FatalDiagnosticError(ErrorCode.VALUE_HAS_WRONG_TYPE, queryData, "Decorator query metadata must be an instance of a query type");
  5125. }
  5126. const query = extractDecoratorQueryMetadata(queryExpr, type.name, queryExpr.arguments || [], propertyName, reflector, evaluator);
  5127. if (type.name.startsWith("Content")) {
  5128. content.push({ expr: queryExpr, metadata: query });
  5129. } else {
  5130. view.push({ expr: queryExpr, metadata: query });
  5131. }
  5132. });
  5133. return { content, view };
  5134. }
  5135. function parseDirectiveStyles(directive, evaluator, compilationMode) {
  5136. var _a;
  5137. const expression = directive.get("styles");
  5138. if (!expression) {
  5139. return null;
  5140. }
  5141. const evaluated = evaluator.evaluate(expression);
  5142. const value = typeof evaluated === "string" ? [evaluated] : evaluated;
  5143. if (compilationMode === CompilationMode.LOCAL) {
  5144. let unresolvedNode = null;
  5145. if (Array.isArray(value)) {
  5146. const entry = value.find((e) => e instanceof DynamicValue && e.isFromUnknownIdentifier());
  5147. unresolvedNode = (_a = entry == null ? void 0 : entry.node) != null ? _a : null;
  5148. } else if (value instanceof DynamicValue && value.isFromUnknownIdentifier()) {
  5149. unresolvedNode = value.node;
  5150. }
  5151. if (unresolvedNode !== null) {
  5152. throw new FatalDiagnosticError(ErrorCode.LOCAL_COMPILATION_UNRESOLVED_CONST, unresolvedNode, "Unresolved identifier found for @Component.styles field! Did you import this identifier from a file outside of the compilation unit? This is not allowed when Angular compiler runs in local mode. Possible solutions: 1) Move the declarations into a file within the compilation unit, 2) Inline the styles, 3) Move the styles into separate files and include it using @Component.styleUrls");
  5153. }
  5154. }
  5155. if (!isStringArrayOrDie(value, "styles", expression)) {
  5156. throw createValueHasWrongTypeError(expression, value, `Failed to resolve @Component.styles to a string or an array of strings`);
  5157. }
  5158. return value;
  5159. }
  5160. function parseFieldStringArrayValue(directive, field, evaluator) {
  5161. if (!directive.has(field)) {
  5162. return null;
  5163. }
  5164. const expression = directive.get(field);
  5165. const value = evaluator.evaluate(expression);
  5166. if (!isStringArrayOrDie(value, field, expression)) {
  5167. throw createValueHasWrongTypeError(expression, value, `Failed to resolve @Directive.${field} to a string array`);
  5168. }
  5169. return value;
  5170. }
  5171. function isStringArrayOrDie(value, name, node) {
  5172. if (!Array.isArray(value)) {
  5173. return false;
  5174. }
  5175. for (let i = 0; i < value.length; i++) {
  5176. if (typeof value[i] !== "string") {
  5177. throw createValueHasWrongTypeError(node, value[i], `Failed to resolve ${name} at position ${i} to a string`);
  5178. }
  5179. }
  5180. return true;
  5181. }
  5182. function tryGetQueryFromFieldDecorator(member, reflector, evaluator, isCore) {
  5183. var _a, _b, _c;
  5184. const decorators = member.decorators;
  5185. if (decorators === null) {
  5186. return null;
  5187. }
  5188. const queryDecorators = getAngularDecorators(decorators, queryDecoratorNames, isCore);
  5189. if (queryDecorators.length === 0) {
  5190. return null;
  5191. }
  5192. if (queryDecorators.length !== 1) {
  5193. throw new FatalDiagnosticError(ErrorCode.DECORATOR_COLLISION, (_a = member.node) != null ? _a : queryDecorators[0].node, "Cannot combine multiple query decorators.");
  5194. }
  5195. const decorator = queryDecorators[0];
  5196. const node = member.node || decorator.node;
  5197. if (decorators.some((v) => v.name === "Input")) {
  5198. throw new FatalDiagnosticError(ErrorCode.DECORATOR_COLLISION, node, "Cannot combine @Input decorators with query decorators");
  5199. }
  5200. if (!isPropertyTypeMember(member)) {
  5201. throw new FatalDiagnosticError(ErrorCode.DECORATOR_UNEXPECTED, node, "Query decorator must go on a property-type member");
  5202. }
  5203. const name = (_c = (_b = decorator.import) == null ? void 0 : _b.name) != null ? _c : decorator.name;
  5204. return {
  5205. name,
  5206. decorator,
  5207. metadata: extractDecoratorQueryMetadata(node, name, decorator.args || [], member.name, reflector, evaluator)
  5208. };
  5209. }
  5210. function isPropertyTypeMember(member) {
  5211. return member.kind === ClassMemberKind.Getter || member.kind === ClassMemberKind.Setter || member.kind === ClassMemberKind.Property;
  5212. }
  5213. function parseMappingStringArray(values) {
  5214. return values.reduce((results, value) => {
  5215. if (typeof value !== "string") {
  5216. throw new Error("Mapping value must be a string");
  5217. }
  5218. const [bindingPropertyName, fieldName] = parseMappingString(value);
  5219. results[fieldName] = bindingPropertyName;
  5220. return results;
  5221. }, {});
  5222. }
  5223. function parseMappingString(value) {
  5224. const [fieldName, bindingPropertyName] = value.split(":", 2).map((str) => str.trim());
  5225. return [bindingPropertyName != null ? bindingPropertyName : fieldName, fieldName];
  5226. }
  5227. function parseInputsArray(clazz, decoratorMetadata, evaluator, reflector, refEmitter, compilationMode) {
  5228. const inputsField = decoratorMetadata.get("inputs");
  5229. if (inputsField === void 0) {
  5230. return {};
  5231. }
  5232. const inputs = {};
  5233. const inputsArray = evaluator.evaluate(inputsField);
  5234. if (!Array.isArray(inputsArray)) {
  5235. throw createValueHasWrongTypeError(inputsField, inputsArray, `Failed to resolve @Directive.inputs to an array`);
  5236. }
  5237. for (let i = 0; i < inputsArray.length; i++) {
  5238. const value = inputsArray[i];
  5239. if (typeof value === "string") {
  5240. const [bindingPropertyName, classPropertyName] = parseMappingString(value);
  5241. inputs[classPropertyName] = {
  5242. bindingPropertyName,
  5243. classPropertyName,
  5244. required: false,
  5245. transform: null,
  5246. isSignal: false
  5247. };
  5248. } else if (value instanceof Map) {
  5249. const name = value.get("name");
  5250. const alias = value.get("alias");
  5251. const required = value.get("required");
  5252. let transform = null;
  5253. if (typeof name !== "string") {
  5254. throw createValueHasWrongTypeError(inputsField, name, `Value at position ${i} of @Directive.inputs array must have a "name" property`);
  5255. }
  5256. if (value.has("transform")) {
  5257. const transformValue = value.get("transform");
  5258. if (!(transformValue instanceof DynamicValue) && !(transformValue instanceof Reference)) {
  5259. throw createValueHasWrongTypeError(inputsField, transformValue, `Transform of value at position ${i} of @Directive.inputs array must be a function`);
  5260. }
  5261. transform = parseDecoratorInputTransformFunction(clazz, name, transformValue, reflector, refEmitter, compilationMode);
  5262. }
  5263. inputs[name] = {
  5264. classPropertyName: name,
  5265. bindingPropertyName: typeof alias === "string" ? alias : name,
  5266. required: required === true,
  5267. isSignal: false,
  5268. transform
  5269. };
  5270. } else {
  5271. throw createValueHasWrongTypeError(inputsField, value, `@Directive.inputs array can only contain strings or object literals`);
  5272. }
  5273. }
  5274. return inputs;
  5275. }
  5276. function tryGetDecoratorOnMember(member, decoratorName, isCore) {
  5277. if (member.decorators === null) {
  5278. return null;
  5279. }
  5280. for (const decorator of member.decorators) {
  5281. if (isAngularDecorator(decorator, decoratorName, isCore)) {
  5282. return decorator;
  5283. }
  5284. }
  5285. return null;
  5286. }
  5287. function tryParseInputFieldMapping(clazz, member, evaluator, reflector, importTracker, isCore, refEmitter, compilationMode) {
  5288. const classPropertyName = member.name;
  5289. const decorator = tryGetDecoratorOnMember(member, "Input", isCore);
  5290. const signalInputMapping = tryParseSignalInputMapping(member, reflector, importTracker);
  5291. const modelInputMapping = tryParseSignalModelMapping(member, reflector, importTracker);
  5292. if (decorator !== null && signalInputMapping !== null) {
  5293. throw new FatalDiagnosticError(ErrorCode.INITIALIZER_API_WITH_DISALLOWED_DECORATOR, decorator.node, `Using @Input with a signal input is not allowed.`);
  5294. }
  5295. if (decorator !== null && modelInputMapping !== null) {
  5296. throw new FatalDiagnosticError(ErrorCode.INITIALIZER_API_WITH_DISALLOWED_DECORATOR, decorator.node, `Using @Input with a model input is not allowed.`);
  5297. }
  5298. if (decorator !== null) {
  5299. if (decorator.args !== null && decorator.args.length > 1) {
  5300. throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARITY_WRONG, decorator.node, `@${decorator.name} can have at most one argument, got ${decorator.args.length} argument(s)`);
  5301. }
  5302. const optionsNode = decorator.args !== null && decorator.args.length === 1 ? decorator.args[0] : void 0;
  5303. const options = optionsNode !== void 0 ? evaluator.evaluate(optionsNode) : null;
  5304. const required = options instanceof Map ? options.get("required") === true : false;
  5305. if (options !== null && typeof options !== "string" && !(options instanceof Map)) {
  5306. throw createValueHasWrongTypeError(decorator.node, options, `@${decorator.name} decorator argument must resolve to a string or an object literal`);
  5307. }
  5308. let alias = null;
  5309. if (typeof options === "string") {
  5310. alias = options;
  5311. } else if (options instanceof Map && typeof options.get("alias") === "string") {
  5312. alias = options.get("alias");
  5313. }
  5314. const publicInputName = alias != null ? alias : classPropertyName;
  5315. let transform = null;
  5316. if (options instanceof Map && options.has("transform")) {
  5317. const transformValue = options.get("transform");
  5318. if (!(transformValue instanceof DynamicValue) && !(transformValue instanceof Reference)) {
  5319. throw createValueHasWrongTypeError(optionsNode, transformValue, `Input transform must be a function`);
  5320. }
  5321. transform = parseDecoratorInputTransformFunction(clazz, classPropertyName, transformValue, reflector, refEmitter, compilationMode);
  5322. }
  5323. return {
  5324. isSignal: false,
  5325. classPropertyName,
  5326. bindingPropertyName: publicInputName,
  5327. transform,
  5328. required
  5329. };
  5330. }
  5331. if (signalInputMapping !== null) {
  5332. return signalInputMapping;
  5333. }
  5334. if (modelInputMapping !== null) {
  5335. return modelInputMapping.input;
  5336. }
  5337. return null;
  5338. }
  5339. function parseInputFields(clazz, members, evaluator, reflector, importTracker, refEmitter, isCore, compilationMode, inputsFromClassDecorator, classDecorator) {
  5340. var _a, _b;
  5341. const inputs = {};
  5342. for (const member of members) {
  5343. const classPropertyName = member.name;
  5344. const inputMapping = tryParseInputFieldMapping(clazz, member, evaluator, reflector, importTracker, isCore, refEmitter, compilationMode);
  5345. if (inputMapping === null) {
  5346. continue;
  5347. }
  5348. if (member.isStatic) {
  5349. throw new FatalDiagnosticError(ErrorCode.INCORRECTLY_DECLARED_ON_STATIC_MEMBER, (_a = member.node) != null ? _a : clazz, `Input "${member.name}" is incorrectly declared as static member of "${clazz.name.text}".`);
  5350. }
  5351. if (inputMapping.isSignal && inputsFromClassDecorator.hasOwnProperty(classPropertyName)) {
  5352. throw new FatalDiagnosticError(ErrorCode.INITIALIZER_API_DECORATOR_METADATA_COLLISION, (_b = member.node) != null ? _b : clazz, `Input "${member.name}" is also declared as non-signal in @${classDecorator.name}.`);
  5353. }
  5354. inputs[classPropertyName] = inputMapping;
  5355. }
  5356. return inputs;
  5357. }
  5358. function parseDecoratorInputTransformFunction(clazz, classPropertyName, value, reflector, refEmitter, compilationMode) {
  5359. var _a;
  5360. if (compilationMode === CompilationMode.LOCAL) {
  5361. const node2 = value instanceof Reference ? value.getIdentityIn(clazz.getSourceFile()) : value.node;
  5362. if (node2 === null) {
  5363. throw createValueHasWrongTypeError(value.node, value, "Input transform function could not be referenced");
  5364. }
  5365. return {
  5366. node: node2,
  5367. type: new Reference(ts22.factory.createKeywordTypeNode(ts22.SyntaxKind.UnknownKeyword))
  5368. };
  5369. }
  5370. const definition = reflector.getDefinitionOfFunction(value.node);
  5371. if (definition === null) {
  5372. throw createValueHasWrongTypeError(value.node, value, "Input transform must be a function");
  5373. }
  5374. if (definition.typeParameters !== null && definition.typeParameters.length > 0) {
  5375. throw createValueHasWrongTypeError(value.node, value, "Input transform function cannot be generic");
  5376. }
  5377. if (definition.signatureCount > 1) {
  5378. throw createValueHasWrongTypeError(value.node, value, "Input transform function cannot have multiple signatures");
  5379. }
  5380. const members = reflector.getMembersOfClass(clazz);
  5381. for (const member of members) {
  5382. const conflictingName = `ngAcceptInputType_${classPropertyName}`;
  5383. if (member.name === conflictingName && member.isStatic) {
  5384. throw new FatalDiagnosticError(ErrorCode.CONFLICTING_INPUT_TRANSFORM, value.node, `Class cannot have both a transform function on Input ${classPropertyName} and a static member called ${conflictingName}`);
  5385. }
  5386. }
  5387. const node = value instanceof Reference ? value.getIdentityIn(clazz.getSourceFile()) : value.node;
  5388. if (node === null) {
  5389. throw createValueHasWrongTypeError(value.node, value, "Input transform function could not be referenced");
  5390. }
  5391. const firstParam = ((_a = definition.parameters[0]) == null ? void 0 : _a.name) === "this" ? definition.parameters[1] : definition.parameters[0];
  5392. if (!firstParam) {
  5393. return {
  5394. node,
  5395. type: new Reference(ts22.factory.createKeywordTypeNode(ts22.SyntaxKind.UnknownKeyword))
  5396. };
  5397. }
  5398. if (!firstParam.type) {
  5399. throw createValueHasWrongTypeError(value.node, value, "Input transform function first parameter must have a type");
  5400. }
  5401. if (firstParam.node.dotDotDotToken) {
  5402. throw createValueHasWrongTypeError(value.node, value, "Input transform function first parameter cannot be a spread parameter");
  5403. }
  5404. assertEmittableInputType(firstParam.type, clazz.getSourceFile(), reflector, refEmitter);
  5405. const viaModule = value instanceof Reference ? value.bestGuessOwningModule : null;
  5406. return { node, type: new Reference(firstParam.type, viaModule) };
  5407. }
  5408. function assertEmittableInputType(type, contextFile, reflector, refEmitter) {
  5409. (function walk(node) {
  5410. if (ts22.isTypeReferenceNode(node) && ts22.isIdentifier(node.typeName)) {
  5411. const declaration = reflector.getDeclarationOfIdentifier(node.typeName);
  5412. if (declaration !== null) {
  5413. if (declaration.node.getSourceFile() !== contextFile) {
  5414. const emittedType = refEmitter.emit(new Reference(declaration.node, declaration.viaModule === AmbientImport ? AmbientImport : null), contextFile, ImportFlags.NoAliasing | ImportFlags.AllowTypeImports | ImportFlags.AllowRelativeDtsImports | ImportFlags.AllowAmbientReferences);
  5415. assertSuccessfulReferenceEmit(emittedType, node, "type");
  5416. } else if (!reflector.isStaticallyExported(declaration.node)) {
  5417. throw new FatalDiagnosticError(ErrorCode.SYMBOL_NOT_EXPORTED, type, `Symbol must be exported in order to be used as the type of an Input transform function`, [makeRelatedInformation(declaration.node, `The symbol is declared here.`)]);
  5418. }
  5419. }
  5420. }
  5421. node.forEachChild(walk);
  5422. })(type);
  5423. }
  5424. function parseQueriesOfClassFields(members, reflector, importTracker, evaluator, isCore) {
  5425. var _a;
  5426. const viewQueries = [];
  5427. const contentQueries = [];
  5428. const decoratorViewChild = [];
  5429. const decoratorViewChildren = [];
  5430. const decoratorContentChild = [];
  5431. const decoratorContentChildren = [];
  5432. for (const member of members) {
  5433. const decoratorQuery = tryGetQueryFromFieldDecorator(member, reflector, evaluator, isCore);
  5434. const signalQuery = tryParseSignalQueryFromInitializer(member, reflector, importTracker);
  5435. if (decoratorQuery !== null && signalQuery !== null) {
  5436. throw new FatalDiagnosticError(ErrorCode.INITIALIZER_API_WITH_DISALLOWED_DECORATOR, decoratorQuery.decorator.node, `Using @${decoratorQuery.name} with a signal-based query is not allowed.`);
  5437. }
  5438. const queryNode = (_a = decoratorQuery == null ? void 0 : decoratorQuery.decorator.node) != null ? _a : signalQuery == null ? void 0 : signalQuery.call;
  5439. if (queryNode !== void 0 && member.isStatic) {
  5440. throw new FatalDiagnosticError(ErrorCode.INCORRECTLY_DECLARED_ON_STATIC_MEMBER, queryNode, `Query is incorrectly declared on a static class member.`);
  5441. }
  5442. if (decoratorQuery !== null) {
  5443. switch (decoratorQuery.name) {
  5444. case "ViewChild":
  5445. decoratorViewChild.push(decoratorQuery.metadata);
  5446. break;
  5447. case "ViewChildren":
  5448. decoratorViewChildren.push(decoratorQuery.metadata);
  5449. break;
  5450. case "ContentChild":
  5451. decoratorContentChild.push(decoratorQuery.metadata);
  5452. break;
  5453. case "ContentChildren":
  5454. decoratorContentChildren.push(decoratorQuery.metadata);
  5455. break;
  5456. }
  5457. } else if (signalQuery !== null) {
  5458. switch (signalQuery.name) {
  5459. case "viewChild":
  5460. case "viewChildren":
  5461. viewQueries.push(signalQuery.metadata);
  5462. break;
  5463. case "contentChild":
  5464. case "contentChildren":
  5465. contentQueries.push(signalQuery.metadata);
  5466. break;
  5467. }
  5468. }
  5469. }
  5470. return {
  5471. viewQueries: [...viewQueries, ...decoratorViewChild, ...decoratorViewChildren],
  5472. contentQueries: [...contentQueries, ...decoratorContentChild, ...decoratorContentChildren]
  5473. };
  5474. }
  5475. function parseOutputsArray(directive, evaluator) {
  5476. const metaValues = parseFieldStringArrayValue(directive, "outputs", evaluator);
  5477. return metaValues ? parseMappingStringArray(metaValues) : EMPTY_OBJECT;
  5478. }
  5479. function parseOutputFields(clazz, classDecorator, members, isCore, reflector, importTracker, evaluator, outputsFromMeta) {
  5480. var _a, _b, _c;
  5481. const outputs = {};
  5482. for (const member of members) {
  5483. const decoratorOutput = tryParseDecoratorOutput(member, evaluator, isCore);
  5484. const initializerOutput = tryParseInitializerBasedOutput(member, reflector, importTracker);
  5485. const modelMapping = tryParseSignalModelMapping(member, reflector, importTracker);
  5486. if (decoratorOutput !== null && initializerOutput !== null) {
  5487. throw new FatalDiagnosticError(ErrorCode.INITIALIZER_API_WITH_DISALLOWED_DECORATOR, decoratorOutput.decorator.node, `Using "@Output" with "output()" is not allowed.`);
  5488. }
  5489. if (decoratorOutput !== null && modelMapping !== null) {
  5490. throw new FatalDiagnosticError(ErrorCode.INITIALIZER_API_WITH_DISALLOWED_DECORATOR, decoratorOutput.decorator.node, `Using @Output with a model input is not allowed.`);
  5491. }
  5492. const queryNode = (_b = (_a = decoratorOutput == null ? void 0 : decoratorOutput.decorator.node) != null ? _a : initializerOutput == null ? void 0 : initializerOutput.call) != null ? _b : modelMapping == null ? void 0 : modelMapping.call;
  5493. if (queryNode !== void 0 && member.isStatic) {
  5494. throw new FatalDiagnosticError(ErrorCode.INCORRECTLY_DECLARED_ON_STATIC_MEMBER, queryNode, `Output is incorrectly declared on a static class member.`);
  5495. }
  5496. let bindingPropertyName;
  5497. if (decoratorOutput !== null) {
  5498. bindingPropertyName = decoratorOutput.metadata.bindingPropertyName;
  5499. } else if (initializerOutput !== null) {
  5500. bindingPropertyName = initializerOutput.metadata.bindingPropertyName;
  5501. } else if (modelMapping !== null) {
  5502. bindingPropertyName = modelMapping.output.bindingPropertyName;
  5503. } else {
  5504. continue;
  5505. }
  5506. if ((initializerOutput !== null || modelMapping !== null) && outputsFromMeta.hasOwnProperty(member.name)) {
  5507. throw new FatalDiagnosticError(ErrorCode.INITIALIZER_API_DECORATOR_METADATA_COLLISION, (_c = member.node) != null ? _c : clazz, `Output "${member.name}" is unexpectedly declared in @${classDecorator.name} as well.`);
  5508. }
  5509. outputs[member.name] = bindingPropertyName;
  5510. }
  5511. return outputs;
  5512. }
  5513. function tryParseDecoratorOutput(member, evaluator, isCore) {
  5514. var _a;
  5515. const decorator = tryGetDecoratorOnMember(member, "Output", isCore);
  5516. if (decorator === null) {
  5517. return null;
  5518. }
  5519. if (decorator.args !== null && decorator.args.length > 1) {
  5520. throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARITY_WRONG, decorator.node, `@Output can have at most one argument, got ${decorator.args.length} argument(s)`);
  5521. }
  5522. const classPropertyName = member.name;
  5523. let alias = null;
  5524. if (((_a = decorator.args) == null ? void 0 : _a.length) === 1) {
  5525. const resolvedAlias = evaluator.evaluate(decorator.args[0]);
  5526. if (typeof resolvedAlias !== "string") {
  5527. throw createValueHasWrongTypeError(decorator.node, resolvedAlias, `@Output decorator argument must resolve to a string`);
  5528. }
  5529. alias = resolvedAlias;
  5530. }
  5531. return {
  5532. decorator,
  5533. metadata: {
  5534. isSignal: false,
  5535. classPropertyName,
  5536. bindingPropertyName: alias != null ? alias : classPropertyName
  5537. }
  5538. };
  5539. }
  5540. function evaluateHostExpressionBindings(hostExpr, evaluator) {
  5541. const hostMetaMap = evaluator.evaluate(hostExpr);
  5542. if (!(hostMetaMap instanceof Map)) {
  5543. throw createValueHasWrongTypeError(hostExpr, hostMetaMap, `Decorator host metadata must be an object`);
  5544. }
  5545. const hostMetadata = {};
  5546. hostMetaMap.forEach((value, key) => {
  5547. if (value instanceof EnumValue) {
  5548. value = value.resolved;
  5549. }
  5550. if (typeof key !== "string") {
  5551. throw createValueHasWrongTypeError(hostExpr, key, `Decorator host metadata must be a string -> string object, but found unparseable key`);
  5552. }
  5553. if (typeof value == "string") {
  5554. hostMetadata[key] = value;
  5555. } else if (value instanceof DynamicValue) {
  5556. hostMetadata[key] = new WrappedNodeExpr5(value.node);
  5557. } else {
  5558. throw createValueHasWrongTypeError(hostExpr, value, `Decorator host metadata must be a string -> string object, but found unparseable value`);
  5559. }
  5560. });
  5561. const bindings = parseHostBindings(hostMetadata);
  5562. const errors = verifyHostBindings(bindings, createSourceSpan(hostExpr));
  5563. if (errors.length > 0) {
  5564. throw new FatalDiagnosticError(ErrorCode.HOST_BINDING_PARSE_ERROR, getHostBindingErrorNode(errors[0], hostExpr), errors.map((error) => error.msg).join("\n"));
  5565. }
  5566. return bindings;
  5567. }
  5568. function getHostBindingErrorNode(error, hostExpr) {
  5569. if (ts22.isObjectLiteralExpression(hostExpr) && error.relatedError instanceof ParserError) {
  5570. for (const prop of hostExpr.properties) {
  5571. if (ts22.isPropertyAssignment(prop) && ts22.isStringLiteralLike(prop.initializer) && prop.initializer.text === error.relatedError.input) {
  5572. return prop.initializer;
  5573. }
  5574. }
  5575. }
  5576. return hostExpr;
  5577. }
  5578. function extractHostDirectives(rawHostDirectives, evaluator, compilationMode, forwardRefResolver) {
  5579. const resolved = evaluator.evaluate(rawHostDirectives, forwardRefResolver);
  5580. if (!Array.isArray(resolved)) {
  5581. throw createValueHasWrongTypeError(rawHostDirectives, resolved, "hostDirectives must be an array");
  5582. }
  5583. return resolved.map((value) => {
  5584. const hostReference = value instanceof Map ? value.get("directive") : value;
  5585. if (compilationMode !== CompilationMode.LOCAL) {
  5586. if (!(hostReference instanceof Reference)) {
  5587. throw createValueHasWrongTypeError(rawHostDirectives, hostReference, "Host directive must be a reference");
  5588. }
  5589. if (!isNamedClassDeclaration(hostReference.node)) {
  5590. throw createValueHasWrongTypeError(rawHostDirectives, hostReference, "Host directive reference must be a class");
  5591. }
  5592. }
  5593. let directive;
  5594. let nameForErrors = (fieldName) => "@Directive.hostDirectives";
  5595. if (compilationMode === CompilationMode.LOCAL && hostReference instanceof DynamicValue) {
  5596. if (!ts22.isIdentifier(hostReference.node) && !ts22.isPropertyAccessExpression(hostReference.node)) {
  5597. throw new FatalDiagnosticError(ErrorCode.LOCAL_COMPILATION_UNSUPPORTED_EXPRESSION, hostReference.node, `In local compilation mode, host directive cannot be an expression. Use an identifier instead`);
  5598. }
  5599. directive = new WrappedNodeExpr5(hostReference.node);
  5600. } else if (hostReference instanceof Reference) {
  5601. directive = hostReference;
  5602. nameForErrors = (fieldName) => `@Directive.hostDirectives.${directive.node.name.text}.${fieldName}`;
  5603. } else {
  5604. throw new Error("Impossible state");
  5605. }
  5606. const meta = {
  5607. directive,
  5608. isForwardReference: hostReference instanceof Reference && hostReference.synthetic,
  5609. inputs: parseHostDirectivesMapping("inputs", value, nameForErrors("input"), rawHostDirectives),
  5610. outputs: parseHostDirectivesMapping("outputs", value, nameForErrors("output"), rawHostDirectives)
  5611. };
  5612. return meta;
  5613. });
  5614. }
  5615. function parseHostDirectivesMapping(field, resolvedValue, nameForErrors, sourceExpression) {
  5616. if (resolvedValue instanceof Map && resolvedValue.has(field)) {
  5617. const rawInputs = resolvedValue.get(field);
  5618. if (isStringArrayOrDie(rawInputs, nameForErrors, sourceExpression)) {
  5619. return parseMappingStringArray(rawInputs);
  5620. }
  5621. }
  5622. return null;
  5623. }
  5624. function toHostDirectiveMetadata(hostDirective, context, refEmitter) {
  5625. let directive;
  5626. if (hostDirective.directive instanceof Reference) {
  5627. directive = toR3Reference(hostDirective.directive.node, hostDirective.directive, context, refEmitter);
  5628. } else {
  5629. directive = {
  5630. value: hostDirective.directive,
  5631. type: hostDirective.directive
  5632. };
  5633. }
  5634. return {
  5635. directive,
  5636. isForwardReference: hostDirective.isForwardReference,
  5637. inputs: hostDirective.inputs || null,
  5638. outputs: hostDirective.outputs || null
  5639. };
  5640. }
  5641. function toR3InputMetadata(mapping) {
  5642. return {
  5643. classPropertyName: mapping.classPropertyName,
  5644. bindingPropertyName: mapping.bindingPropertyName,
  5645. required: mapping.required,
  5646. transformFunction: mapping.transform !== null ? new WrappedNodeExpr5(mapping.transform.node) : null,
  5647. isSignal: mapping.isSignal
  5648. };
  5649. }
  5650. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/directive/src/symbol.mjs
  5651. var DirectiveSymbol = class extends SemanticSymbol {
  5652. selector;
  5653. inputs;
  5654. outputs;
  5655. exportAs;
  5656. typeCheckMeta;
  5657. typeParameters;
  5658. baseClass = null;
  5659. constructor(decl, selector, inputs, outputs, exportAs, typeCheckMeta, typeParameters) {
  5660. super(decl);
  5661. this.selector = selector;
  5662. this.inputs = inputs;
  5663. this.outputs = outputs;
  5664. this.exportAs = exportAs;
  5665. this.typeCheckMeta = typeCheckMeta;
  5666. this.typeParameters = typeParameters;
  5667. }
  5668. isPublicApiAffected(previousSymbol) {
  5669. if (!(previousSymbol instanceof DirectiveSymbol)) {
  5670. return true;
  5671. }
  5672. return this.selector !== previousSymbol.selector || !isArrayEqual(this.inputs.propertyNames, previousSymbol.inputs.propertyNames) || !isArrayEqual(this.outputs.propertyNames, previousSymbol.outputs.propertyNames) || !isArrayEqual(this.exportAs, previousSymbol.exportAs);
  5673. }
  5674. isTypeCheckApiAffected(previousSymbol) {
  5675. if (this.isPublicApiAffected(previousSymbol)) {
  5676. return true;
  5677. }
  5678. if (!(previousSymbol instanceof DirectiveSymbol)) {
  5679. return true;
  5680. }
  5681. if (!isArrayEqual(Array.from(this.inputs), Array.from(previousSymbol.inputs), isInputMappingEqual) || !isArrayEqual(Array.from(this.outputs), Array.from(previousSymbol.outputs), isInputOrOutputEqual)) {
  5682. return true;
  5683. }
  5684. if (!areTypeParametersEqual(this.typeParameters, previousSymbol.typeParameters)) {
  5685. return true;
  5686. }
  5687. if (!isTypeCheckMetaEqual(this.typeCheckMeta, previousSymbol.typeCheckMeta)) {
  5688. return true;
  5689. }
  5690. if (!isBaseClassEqual(this.baseClass, previousSymbol.baseClass)) {
  5691. return true;
  5692. }
  5693. return false;
  5694. }
  5695. };
  5696. function isInputMappingEqual(current, previous) {
  5697. return isInputOrOutputEqual(current, previous) && current.required === previous.required;
  5698. }
  5699. function isInputOrOutputEqual(current, previous) {
  5700. return current.classPropertyName === previous.classPropertyName && current.bindingPropertyName === previous.bindingPropertyName && current.isSignal === previous.isSignal;
  5701. }
  5702. function isTypeCheckMetaEqual(current, previous) {
  5703. if (current.hasNgTemplateContextGuard !== previous.hasNgTemplateContextGuard) {
  5704. return false;
  5705. }
  5706. if (current.isGeneric !== previous.isGeneric) {
  5707. return false;
  5708. }
  5709. if (!isArrayEqual(current.ngTemplateGuards, previous.ngTemplateGuards, isTemplateGuardEqual)) {
  5710. return false;
  5711. }
  5712. if (!isSetEqual(current.coercedInputFields, previous.coercedInputFields)) {
  5713. return false;
  5714. }
  5715. if (!isSetEqual(current.restrictedInputFields, previous.restrictedInputFields)) {
  5716. return false;
  5717. }
  5718. if (!isSetEqual(current.stringLiteralInputFields, previous.stringLiteralInputFields)) {
  5719. return false;
  5720. }
  5721. if (!isSetEqual(current.undeclaredInputFields, previous.undeclaredInputFields)) {
  5722. return false;
  5723. }
  5724. return true;
  5725. }
  5726. function isTemplateGuardEqual(current, previous) {
  5727. return current.inputName === previous.inputName && current.type === previous.type;
  5728. }
  5729. function isBaseClassEqual(current, previous) {
  5730. if (current === null || previous === null) {
  5731. return current === previous;
  5732. }
  5733. return isSymbolEqual(current, previous);
  5734. }
  5735. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/directive/src/handler.mjs
  5736. var FIELD_DECORATORS = [
  5737. "Input",
  5738. "Output",
  5739. "ViewChild",
  5740. "ViewChildren",
  5741. "ContentChild",
  5742. "ContentChildren",
  5743. "HostBinding",
  5744. "HostListener"
  5745. ];
  5746. var LIFECYCLE_HOOKS = /* @__PURE__ */ new Set([
  5747. "ngOnChanges",
  5748. "ngOnInit",
  5749. "ngOnDestroy",
  5750. "ngDoCheck",
  5751. "ngAfterViewInit",
  5752. "ngAfterViewChecked",
  5753. "ngAfterContentInit",
  5754. "ngAfterContentChecked"
  5755. ]);
  5756. var DirectiveDecoratorHandler = class {
  5757. reflector;
  5758. evaluator;
  5759. metaRegistry;
  5760. scopeRegistry;
  5761. metaReader;
  5762. injectableRegistry;
  5763. refEmitter;
  5764. referencesRegistry;
  5765. isCore;
  5766. strictCtorDeps;
  5767. semanticDepGraphUpdater;
  5768. annotateForClosureCompiler;
  5769. perf;
  5770. importTracker;
  5771. includeClassMetadata;
  5772. compilationMode;
  5773. jitDeclarationRegistry;
  5774. strictStandalone;
  5775. implicitStandaloneValue;
  5776. constructor(reflector, evaluator, metaRegistry, scopeRegistry, metaReader, injectableRegistry, refEmitter, referencesRegistry, isCore, strictCtorDeps, semanticDepGraphUpdater, annotateForClosureCompiler, perf, importTracker, includeClassMetadata, compilationMode, jitDeclarationRegistry, strictStandalone, implicitStandaloneValue) {
  5777. this.reflector = reflector;
  5778. this.evaluator = evaluator;
  5779. this.metaRegistry = metaRegistry;
  5780. this.scopeRegistry = scopeRegistry;
  5781. this.metaReader = metaReader;
  5782. this.injectableRegistry = injectableRegistry;
  5783. this.refEmitter = refEmitter;
  5784. this.referencesRegistry = referencesRegistry;
  5785. this.isCore = isCore;
  5786. this.strictCtorDeps = strictCtorDeps;
  5787. this.semanticDepGraphUpdater = semanticDepGraphUpdater;
  5788. this.annotateForClosureCompiler = annotateForClosureCompiler;
  5789. this.perf = perf;
  5790. this.importTracker = importTracker;
  5791. this.includeClassMetadata = includeClassMetadata;
  5792. this.compilationMode = compilationMode;
  5793. this.jitDeclarationRegistry = jitDeclarationRegistry;
  5794. this.strictStandalone = strictStandalone;
  5795. this.implicitStandaloneValue = implicitStandaloneValue;
  5796. }
  5797. precedence = HandlerPrecedence.PRIMARY;
  5798. name = "DirectiveDecoratorHandler";
  5799. detect(node, decorators) {
  5800. if (!decorators) {
  5801. const angularField = this.findClassFieldWithAngularFeatures(node);
  5802. return angularField ? { trigger: angularField.node, decorator: null, metadata: null } : void 0;
  5803. } else {
  5804. const decorator = findAngularDecorator(decorators, "Directive", this.isCore);
  5805. return decorator ? { trigger: decorator.node, decorator, metadata: decorator } : void 0;
  5806. }
  5807. }
  5808. analyze(node, decorator) {
  5809. var _a;
  5810. if (decorator === null) {
  5811. if (this.isCore) {
  5812. return {};
  5813. }
  5814. return { diagnostics: [getUndecoratedClassWithAngularFeaturesDiagnostic(node)] };
  5815. }
  5816. this.perf.eventCount(PerfEvent.AnalyzeDirective);
  5817. const directiveResult = extractDirectiveMetadata(
  5818. node,
  5819. decorator,
  5820. this.reflector,
  5821. this.importTracker,
  5822. this.evaluator,
  5823. this.refEmitter,
  5824. this.referencesRegistry,
  5825. this.isCore,
  5826. this.annotateForClosureCompiler,
  5827. this.compilationMode,
  5828. null,
  5829. this.strictStandalone,
  5830. this.implicitStandaloneValue
  5831. );
  5832. if (directiveResult.jitForced) {
  5833. this.jitDeclarationRegistry.jitDeclarations.add(node);
  5834. return {};
  5835. }
  5836. const analysis = directiveResult.metadata;
  5837. let providersRequiringFactory = null;
  5838. if (directiveResult !== void 0 && directiveResult.decorator.has("providers")) {
  5839. providersRequiringFactory = resolveProvidersRequiringFactory(directiveResult.decorator.get("providers"), this.reflector, this.evaluator);
  5840. }
  5841. return {
  5842. analysis: {
  5843. inputs: directiveResult.inputs,
  5844. inputFieldNamesFromMetadataArray: directiveResult.inputFieldNamesFromMetadataArray,
  5845. outputs: directiveResult.outputs,
  5846. meta: analysis,
  5847. hostDirectives: directiveResult.hostDirectives,
  5848. rawHostDirectives: directiveResult.rawHostDirectives,
  5849. classMetadata: this.includeClassMetadata ? extractClassMetadata(node, this.reflector, this.isCore, this.annotateForClosureCompiler) : null,
  5850. baseClass: readBaseClass(node, this.reflector, this.evaluator),
  5851. typeCheckMeta: extractDirectiveTypeCheckMeta(node, directiveResult.inputs, this.reflector),
  5852. providersRequiringFactory,
  5853. isPoisoned: false,
  5854. isStructural: directiveResult.isStructural,
  5855. decorator: (_a = decorator == null ? void 0 : decorator.node) != null ? _a : null
  5856. }
  5857. };
  5858. }
  5859. symbol(node, analysis) {
  5860. const typeParameters = extractSemanticTypeParameters(node);
  5861. return new DirectiveSymbol(node, analysis.meta.selector, analysis.inputs, analysis.outputs, analysis.meta.exportAs, analysis.typeCheckMeta, typeParameters);
  5862. }
  5863. register(node, analysis) {
  5864. const ref = new Reference(node);
  5865. this.metaRegistry.registerDirectiveMetadata({
  5866. kind: MetaKind.Directive,
  5867. matchSource: MatchSource.Selector,
  5868. ref,
  5869. name: node.name.text,
  5870. selector: analysis.meta.selector,
  5871. exportAs: analysis.meta.exportAs,
  5872. inputs: analysis.inputs,
  5873. inputFieldNamesFromMetadataArray: analysis.inputFieldNamesFromMetadataArray,
  5874. outputs: analysis.outputs,
  5875. queries: analysis.meta.queries.map((query) => query.propertyName),
  5876. isComponent: false,
  5877. baseClass: analysis.baseClass,
  5878. hostDirectives: analysis.hostDirectives,
  5879. ...analysis.typeCheckMeta,
  5880. isPoisoned: analysis.isPoisoned,
  5881. isStructural: analysis.isStructural,
  5882. animationTriggerNames: null,
  5883. isStandalone: analysis.meta.isStandalone,
  5884. isSignal: analysis.meta.isSignal,
  5885. imports: null,
  5886. rawImports: null,
  5887. deferredImports: null,
  5888. schemas: null,
  5889. ngContentSelectors: null,
  5890. decorator: analysis.decorator,
  5891. preserveWhitespaces: false,
  5892. assumedToExportProviders: false,
  5893. isExplicitlyDeferred: false
  5894. });
  5895. this.injectableRegistry.registerInjectable(node, {
  5896. ctorDeps: analysis.meta.deps
  5897. });
  5898. }
  5899. resolve(node, analysis, symbol) {
  5900. if (this.compilationMode === CompilationMode.LOCAL) {
  5901. return {};
  5902. }
  5903. if (this.semanticDepGraphUpdater !== null && analysis.baseClass instanceof Reference) {
  5904. symbol.baseClass = this.semanticDepGraphUpdater.getSymbol(analysis.baseClass.node);
  5905. }
  5906. const diagnostics = [];
  5907. if (analysis.providersRequiringFactory !== null && analysis.meta.providers instanceof WrappedNodeExpr6) {
  5908. const providerDiagnostics = getProviderDiagnostics(analysis.providersRequiringFactory, analysis.meta.providers.node, this.injectableRegistry);
  5909. diagnostics.push(...providerDiagnostics);
  5910. }
  5911. const directiveDiagnostics = getDirectiveDiagnostics(node, this.injectableRegistry, this.evaluator, this.reflector, this.scopeRegistry, this.strictCtorDeps, "Directive");
  5912. if (directiveDiagnostics !== null) {
  5913. diagnostics.push(...directiveDiagnostics);
  5914. }
  5915. const hostDirectivesDiagnotics = analysis.hostDirectives && analysis.rawHostDirectives ? validateHostDirectives(analysis.rawHostDirectives, analysis.hostDirectives, this.metaReader) : null;
  5916. if (hostDirectivesDiagnotics !== null) {
  5917. diagnostics.push(...hostDirectivesDiagnotics);
  5918. }
  5919. return { diagnostics: diagnostics.length > 0 ? diagnostics : void 0 };
  5920. }
  5921. compileFull(node, analysis, resolution, pool) {
  5922. const fac = compileNgFactoryDefField(toFactoryMetadata(analysis.meta, FactoryTarget.Directive));
  5923. const def = compileDirectiveFromMetadata(analysis.meta, pool, makeBindingParser());
  5924. const inputTransformFields = compileInputTransformFields(analysis.inputs);
  5925. const classMetadata = analysis.classMetadata !== null ? compileClassMetadata(analysis.classMetadata).toStmt() : null;
  5926. return compileResults(fac, def, classMetadata, "\u0275dir", inputTransformFields, null);
  5927. }
  5928. compilePartial(node, analysis, resolution) {
  5929. const fac = compileDeclareFactory(toFactoryMetadata(analysis.meta, FactoryTarget.Directive));
  5930. const def = compileDeclareDirectiveFromMetadata(analysis.meta);
  5931. const inputTransformFields = compileInputTransformFields(analysis.inputs);
  5932. const classMetadata = analysis.classMetadata !== null ? compileDeclareClassMetadata(analysis.classMetadata).toStmt() : null;
  5933. return compileResults(fac, def, classMetadata, "\u0275dir", inputTransformFields, null);
  5934. }
  5935. compileLocal(node, analysis, resolution, pool) {
  5936. const fac = compileNgFactoryDefField(toFactoryMetadata(analysis.meta, FactoryTarget.Directive));
  5937. const def = compileDirectiveFromMetadata(analysis.meta, pool, makeBindingParser());
  5938. const inputTransformFields = compileInputTransformFields(analysis.inputs);
  5939. const classMetadata = analysis.classMetadata !== null ? compileClassMetadata(analysis.classMetadata).toStmt() : null;
  5940. return compileResults(fac, def, classMetadata, "\u0275dir", inputTransformFields, null);
  5941. }
  5942. findClassFieldWithAngularFeatures(node) {
  5943. return this.reflector.getMembersOfClass(node).find((member) => {
  5944. if (!member.isStatic && member.kind === ClassMemberKind.Method && LIFECYCLE_HOOKS.has(member.name)) {
  5945. return true;
  5946. }
  5947. if (member.decorators) {
  5948. return member.decorators.some((decorator) => FIELD_DECORATORS.some((decoratorName) => isAngularDecorator(decorator, decoratorName, this.isCore)));
  5949. }
  5950. return false;
  5951. });
  5952. }
  5953. };
  5954. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/ng_module/src/handler.mjs
  5955. import { compileClassMetadata as compileClassMetadata2, compileDeclareClassMetadata as compileDeclareClassMetadata2, compileDeclareInjectorFromMetadata, compileDeclareNgModuleFromMetadata, compileInjector, compileNgModule, ExternalExpr as ExternalExpr5, FactoryTarget as FactoryTarget2, FunctionExpr, InvokeFunctionExpr, LiteralArrayExpr as LiteralArrayExpr2, R3Identifiers, R3NgModuleMetadataKind, R3SelectorScopeMode, ReturnStatement, WrappedNodeExpr as WrappedNodeExpr7 } from "@angular/compiler";
  5956. import ts24 from "typescript";
  5957. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/ng_module/src/module_with_providers.mjs
  5958. import ts23 from "typescript";
  5959. function createModuleWithProvidersResolver(reflector, isCore) {
  5960. function _reflectModuleFromTypeParam(type, node) {
  5961. if (!ts23.isTypeReferenceNode(type)) {
  5962. return null;
  5963. }
  5964. const typeName = type && (ts23.isIdentifier(type.typeName) && type.typeName || ts23.isQualifiedName(type.typeName) && type.typeName.right) || null;
  5965. if (typeName === null) {
  5966. return null;
  5967. }
  5968. const id = reflector.getImportOfIdentifier(typeName);
  5969. if (id === null || id.name !== "ModuleWithProviders") {
  5970. return null;
  5971. }
  5972. if (!isCore && id.from !== "@angular/core") {
  5973. return null;
  5974. }
  5975. if (type.typeArguments === void 0 || type.typeArguments.length !== 1) {
  5976. const parent = ts23.isMethodDeclaration(node) && ts23.isClassDeclaration(node.parent) ? node.parent : null;
  5977. const symbolName = (parent && parent.name ? parent.name.getText() + "." : "") + (node.name ? node.name.getText() : "anonymous");
  5978. throw new FatalDiagnosticError(ErrorCode.NGMODULE_MODULE_WITH_PROVIDERS_MISSING_GENERIC, type, `${symbolName} returns a ModuleWithProviders type without a generic type argument. Please add a generic type argument to the ModuleWithProviders type. If this occurrence is in library code you don't control, please contact the library authors.`);
  5979. }
  5980. const arg = type.typeArguments[0];
  5981. return typeNodeToValueExpr(arg);
  5982. }
  5983. function _reflectModuleFromLiteralType(type) {
  5984. if (!ts23.isIntersectionTypeNode(type)) {
  5985. return null;
  5986. }
  5987. for (const t of type.types) {
  5988. if (ts23.isTypeLiteralNode(t)) {
  5989. for (const m of t.members) {
  5990. const ngModuleType = ts23.isPropertySignature(m) && ts23.isIdentifier(m.name) && m.name.text === "ngModule" && m.type || null;
  5991. let ngModuleExpression = null;
  5992. if (ngModuleType !== null && ts23.isTypeQueryNode(ngModuleType)) {
  5993. ngModuleExpression = entityNameToValue(ngModuleType.exprName);
  5994. } else if (ngModuleType !== null) {
  5995. ngModuleExpression = typeNodeToValueExpr(ngModuleType);
  5996. }
  5997. if (ngModuleExpression) {
  5998. return ngModuleExpression;
  5999. }
  6000. }
  6001. }
  6002. }
  6003. return null;
  6004. }
  6005. return (fn, callExpr, resolve, unresolvable) => {
  6006. var _a;
  6007. const rawType = fn.node.type;
  6008. if (rawType === void 0) {
  6009. return unresolvable;
  6010. }
  6011. const type = (_a = _reflectModuleFromTypeParam(rawType, fn.node)) != null ? _a : _reflectModuleFromLiteralType(rawType);
  6012. if (type === null) {
  6013. return unresolvable;
  6014. }
  6015. const ngModule = resolve(type);
  6016. if (!(ngModule instanceof Reference) || !isNamedClassDeclaration(ngModule.node)) {
  6017. return unresolvable;
  6018. }
  6019. return new SyntheticValue({
  6020. ngModule,
  6021. mwpCall: callExpr
  6022. });
  6023. };
  6024. }
  6025. function isResolvedModuleWithProviders(sv) {
  6026. return typeof sv.value === "object" && sv.value != null && sv.value.hasOwnProperty("ngModule") && sv.value.hasOwnProperty("mwpCall");
  6027. }
  6028. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/ng_module/src/handler.mjs
  6029. var NgModuleSymbol = class extends SemanticSymbol {
  6030. hasProviders;
  6031. remotelyScopedComponents = [];
  6032. transitiveImportsFromStandaloneComponents = /* @__PURE__ */ new Set();
  6033. constructor(decl, hasProviders) {
  6034. super(decl);
  6035. this.hasProviders = hasProviders;
  6036. }
  6037. isPublicApiAffected(previousSymbol) {
  6038. if (!(previousSymbol instanceof NgModuleSymbol)) {
  6039. return true;
  6040. }
  6041. if (previousSymbol.hasProviders !== this.hasProviders) {
  6042. return true;
  6043. }
  6044. return false;
  6045. }
  6046. isEmitAffected(previousSymbol) {
  6047. if (!(previousSymbol instanceof NgModuleSymbol)) {
  6048. return true;
  6049. }
  6050. if (previousSymbol.remotelyScopedComponents.length !== this.remotelyScopedComponents.length) {
  6051. return true;
  6052. }
  6053. for (const currEntry of this.remotelyScopedComponents) {
  6054. const prevEntry = previousSymbol.remotelyScopedComponents.find((prevEntry2) => {
  6055. return isSymbolEqual(prevEntry2.component, currEntry.component);
  6056. });
  6057. if (prevEntry === void 0) {
  6058. return true;
  6059. }
  6060. if (!isArrayEqual(currEntry.usedDirectives, prevEntry.usedDirectives, isReferenceEqual)) {
  6061. return true;
  6062. }
  6063. if (!isArrayEqual(currEntry.usedPipes, prevEntry.usedPipes, isReferenceEqual)) {
  6064. return true;
  6065. }
  6066. }
  6067. if (previousSymbol.transitiveImportsFromStandaloneComponents.size !== this.transitiveImportsFromStandaloneComponents.size) {
  6068. return true;
  6069. }
  6070. const previousImports = Array.from(previousSymbol.transitiveImportsFromStandaloneComponents);
  6071. for (const transitiveImport of this.transitiveImportsFromStandaloneComponents) {
  6072. const prevEntry = previousImports.find((prevEntry2) => isSymbolEqual(prevEntry2, transitiveImport));
  6073. if (prevEntry === void 0) {
  6074. return true;
  6075. }
  6076. if (transitiveImport.isPublicApiAffected(prevEntry)) {
  6077. return true;
  6078. }
  6079. }
  6080. return false;
  6081. }
  6082. isTypeCheckApiAffected(previousSymbol) {
  6083. if (!(previousSymbol instanceof NgModuleSymbol)) {
  6084. return true;
  6085. }
  6086. return false;
  6087. }
  6088. addRemotelyScopedComponent(component, usedDirectives, usedPipes) {
  6089. this.remotelyScopedComponents.push({ component, usedDirectives, usedPipes });
  6090. }
  6091. addTransitiveImportFromStandaloneComponent(importedSymbol) {
  6092. this.transitiveImportsFromStandaloneComponents.add(importedSymbol);
  6093. }
  6094. };
  6095. var NgModuleDecoratorHandler = class {
  6096. reflector;
  6097. evaluator;
  6098. metaReader;
  6099. metaRegistry;
  6100. scopeRegistry;
  6101. referencesRegistry;
  6102. exportedProviderStatusResolver;
  6103. semanticDepGraphUpdater;
  6104. isCore;
  6105. refEmitter;
  6106. annotateForClosureCompiler;
  6107. onlyPublishPublicTypings;
  6108. injectableRegistry;
  6109. perf;
  6110. includeClassMetadata;
  6111. includeSelectorScope;
  6112. compilationMode;
  6113. localCompilationExtraImportsTracker;
  6114. jitDeclarationRegistry;
  6115. constructor(reflector, evaluator, metaReader, metaRegistry, scopeRegistry, referencesRegistry, exportedProviderStatusResolver, semanticDepGraphUpdater, isCore, refEmitter, annotateForClosureCompiler, onlyPublishPublicTypings, injectableRegistry, perf, includeClassMetadata, includeSelectorScope, compilationMode, localCompilationExtraImportsTracker, jitDeclarationRegistry) {
  6116. this.reflector = reflector;
  6117. this.evaluator = evaluator;
  6118. this.metaReader = metaReader;
  6119. this.metaRegistry = metaRegistry;
  6120. this.scopeRegistry = scopeRegistry;
  6121. this.referencesRegistry = referencesRegistry;
  6122. this.exportedProviderStatusResolver = exportedProviderStatusResolver;
  6123. this.semanticDepGraphUpdater = semanticDepGraphUpdater;
  6124. this.isCore = isCore;
  6125. this.refEmitter = refEmitter;
  6126. this.annotateForClosureCompiler = annotateForClosureCompiler;
  6127. this.onlyPublishPublicTypings = onlyPublishPublicTypings;
  6128. this.injectableRegistry = injectableRegistry;
  6129. this.perf = perf;
  6130. this.includeClassMetadata = includeClassMetadata;
  6131. this.includeSelectorScope = includeSelectorScope;
  6132. this.compilationMode = compilationMode;
  6133. this.localCompilationExtraImportsTracker = localCompilationExtraImportsTracker;
  6134. this.jitDeclarationRegistry = jitDeclarationRegistry;
  6135. }
  6136. precedence = HandlerPrecedence.PRIMARY;
  6137. name = "NgModuleDecoratorHandler";
  6138. detect(node, decorators) {
  6139. if (!decorators) {
  6140. return void 0;
  6141. }
  6142. const decorator = findAngularDecorator(decorators, "NgModule", this.isCore);
  6143. if (decorator !== void 0) {
  6144. return {
  6145. trigger: decorator.node,
  6146. decorator,
  6147. metadata: decorator
  6148. };
  6149. } else {
  6150. return void 0;
  6151. }
  6152. }
  6153. analyze(node, decorator) {
  6154. var _a, _b, _c, _d, _e;
  6155. this.perf.eventCount(PerfEvent.AnalyzeNgModule);
  6156. const name = node.name.text;
  6157. if (decorator.args === null || decorator.args.length > 1) {
  6158. throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARITY_WRONG, decorator.node, `Incorrect number of arguments to @NgModule decorator`);
  6159. }
  6160. const meta = decorator.args.length === 1 ? unwrapExpression(decorator.args[0]) : ts24.factory.createObjectLiteralExpression([]);
  6161. if (!ts24.isObjectLiteralExpression(meta)) {
  6162. throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARG_NOT_LITERAL, meta, "@NgModule argument must be an object literal");
  6163. }
  6164. const ngModule = reflectObjectLiteral(meta);
  6165. if (ngModule.has("jit")) {
  6166. this.jitDeclarationRegistry.jitDeclarations.add(node);
  6167. return {};
  6168. }
  6169. const forwardRefResolver = createForwardRefResolver(this.isCore);
  6170. const moduleResolvers = combineResolvers([
  6171. createModuleWithProvidersResolver(this.reflector, this.isCore),
  6172. forwardRefResolver
  6173. ]);
  6174. const diagnostics = [];
  6175. let declarationRefs = [];
  6176. const rawDeclarations = (_a = ngModule.get("declarations")) != null ? _a : null;
  6177. if (rawDeclarations !== null) {
  6178. const declarationMeta = this.evaluator.evaluate(rawDeclarations, forwardRefResolver);
  6179. declarationRefs = this.resolveTypeList(rawDeclarations, declarationMeta, name, "declarations", 0, this.compilationMode === CompilationMode.LOCAL).references;
  6180. for (const ref of declarationRefs) {
  6181. if (ref.node.getSourceFile().isDeclarationFile) {
  6182. const errorNode = ref.getOriginForDiagnostics(rawDeclarations);
  6183. diagnostics.push(makeDiagnostic(ErrorCode.NGMODULE_INVALID_DECLARATION, errorNode, `Cannot declare '${ref.node.name.text}' in an NgModule as it's not a part of the current compilation.`, [makeRelatedInformation(ref.node.name, `'${ref.node.name.text}' is declared here.`)]));
  6184. }
  6185. }
  6186. }
  6187. if (diagnostics.length > 0) {
  6188. return { diagnostics };
  6189. }
  6190. let importRefs = [];
  6191. let rawImports = (_b = ngModule.get("imports")) != null ? _b : null;
  6192. if (rawImports !== null) {
  6193. const importsMeta = this.evaluator.evaluate(rawImports, moduleResolvers);
  6194. const result = this.resolveTypeList(rawImports, importsMeta, name, "imports", 0, this.compilationMode === CompilationMode.LOCAL);
  6195. if (this.compilationMode === CompilationMode.LOCAL && this.localCompilationExtraImportsTracker !== null) {
  6196. for (const d of result.dynamicValues) {
  6197. this.localCompilationExtraImportsTracker.addGlobalImportFromIdentifier(d.node);
  6198. }
  6199. }
  6200. importRefs = result.references;
  6201. }
  6202. let exportRefs = [];
  6203. const rawExports = (_c = ngModule.get("exports")) != null ? _c : null;
  6204. if (rawExports !== null) {
  6205. const exportsMeta = this.evaluator.evaluate(rawExports, moduleResolvers);
  6206. exportRefs = this.resolveTypeList(rawExports, exportsMeta, name, "exports", 0, this.compilationMode === CompilationMode.LOCAL).references;
  6207. this.referencesRegistry.add(node, ...exportRefs);
  6208. }
  6209. let bootstrapRefs = [];
  6210. const rawBootstrap = (_d = ngModule.get("bootstrap")) != null ? _d : null;
  6211. if (this.compilationMode !== CompilationMode.LOCAL && rawBootstrap !== null) {
  6212. const bootstrapMeta = this.evaluator.evaluate(rawBootstrap, forwardRefResolver);
  6213. bootstrapRefs = this.resolveTypeList(
  6214. rawBootstrap,
  6215. bootstrapMeta,
  6216. name,
  6217. "bootstrap",
  6218. 0,
  6219. false
  6220. ).references;
  6221. for (const ref of bootstrapRefs) {
  6222. const dirMeta = this.metaReader.getDirectiveMetadata(ref);
  6223. if (dirMeta == null ? void 0 : dirMeta.isStandalone) {
  6224. diagnostics.push(makeStandaloneBootstrapDiagnostic(node, ref, rawBootstrap));
  6225. }
  6226. }
  6227. }
  6228. const schemas = this.compilationMode !== CompilationMode.LOCAL && ngModule.has("schemas") ? extractSchemas(ngModule.get("schemas"), this.evaluator, "NgModule") : [];
  6229. let id = null;
  6230. if (ngModule.has("id")) {
  6231. const idExpr = ngModule.get("id");
  6232. if (!isModuleIdExpression(idExpr)) {
  6233. id = new WrappedNodeExpr7(idExpr);
  6234. } else {
  6235. const diag = makeDiagnostic(ErrorCode.WARN_NGMODULE_ID_UNNECESSARY, idExpr, `Using 'module.id' for NgModule.id is a common anti-pattern that is ignored by the Angular compiler.`);
  6236. diag.category = ts24.DiagnosticCategory.Warning;
  6237. diagnostics.push(diag);
  6238. }
  6239. }
  6240. const valueContext = node.getSourceFile();
  6241. const exportedNodes = new Set(exportRefs.map((ref) => ref.node));
  6242. const declarations = [];
  6243. const exportedDeclarations = [];
  6244. const bootstrap = bootstrapRefs.map((bootstrap2) => this._toR3Reference(bootstrap2.getOriginForDiagnostics(meta, node.name), bootstrap2, valueContext));
  6245. for (const ref of declarationRefs) {
  6246. const decl = this._toR3Reference(ref.getOriginForDiagnostics(meta, node.name), ref, valueContext);
  6247. declarations.push(decl);
  6248. if (exportedNodes.has(ref.node)) {
  6249. exportedDeclarations.push(decl.type);
  6250. }
  6251. }
  6252. const imports = importRefs.map((imp) => this._toR3Reference(imp.getOriginForDiagnostics(meta, node.name), imp, valueContext));
  6253. const exports = exportRefs.map((exp) => this._toR3Reference(exp.getOriginForDiagnostics(meta, node.name), exp, valueContext));
  6254. const isForwardReference = (ref) => isExpressionForwardReference(ref.value, node.name, valueContext);
  6255. const containsForwardDecls = bootstrap.some(isForwardReference) || declarations.some(isForwardReference) || imports.some(isForwardReference) || exports.some(isForwardReference);
  6256. const type = wrapTypeReference(this.reflector, node);
  6257. let ngModuleMetadata;
  6258. if (this.compilationMode === CompilationMode.LOCAL) {
  6259. ngModuleMetadata = {
  6260. kind: R3NgModuleMetadataKind.Local,
  6261. type,
  6262. bootstrapExpression: rawBootstrap ? new WrappedNodeExpr7(rawBootstrap) : null,
  6263. declarationsExpression: rawDeclarations ? new WrappedNodeExpr7(rawDeclarations) : null,
  6264. exportsExpression: rawExports ? new WrappedNodeExpr7(rawExports) : null,
  6265. importsExpression: rawImports ? new WrappedNodeExpr7(rawImports) : null,
  6266. id,
  6267. selectorScopeMode: R3SelectorScopeMode.SideEffect,
  6268. schemas: []
  6269. };
  6270. } else {
  6271. ngModuleMetadata = {
  6272. kind: R3NgModuleMetadataKind.Global,
  6273. type,
  6274. bootstrap,
  6275. declarations,
  6276. publicDeclarationTypes: this.onlyPublishPublicTypings ? exportedDeclarations : null,
  6277. exports,
  6278. imports,
  6279. includeImportTypes: !this.onlyPublishPublicTypings,
  6280. containsForwardDecls,
  6281. id,
  6282. selectorScopeMode: this.includeSelectorScope ? R3SelectorScopeMode.SideEffect : R3SelectorScopeMode.Omit,
  6283. schemas: []
  6284. };
  6285. }
  6286. const rawProviders = ngModule.has("providers") ? ngModule.get("providers") : null;
  6287. let wrappedProviders = null;
  6288. if (rawProviders !== null && (!ts24.isArrayLiteralExpression(rawProviders) || rawProviders.elements.length > 0)) {
  6289. wrappedProviders = new WrappedNodeExpr7(this.annotateForClosureCompiler ? wrapFunctionExpressionsInParens(rawProviders) : rawProviders);
  6290. }
  6291. const topLevelImports = [];
  6292. if (this.compilationMode !== CompilationMode.LOCAL && ngModule.has("imports")) {
  6293. const rawImports2 = unwrapExpression(ngModule.get("imports"));
  6294. let topLevelExpressions = [];
  6295. if (ts24.isArrayLiteralExpression(rawImports2)) {
  6296. for (const element of rawImports2.elements) {
  6297. if (ts24.isSpreadElement(element)) {
  6298. topLevelExpressions.push(element.expression);
  6299. continue;
  6300. }
  6301. topLevelExpressions.push(element);
  6302. }
  6303. } else {
  6304. topLevelExpressions.push(rawImports2);
  6305. }
  6306. let absoluteIndex = 0;
  6307. for (const importExpr of topLevelExpressions) {
  6308. const resolved = this.evaluator.evaluate(importExpr, moduleResolvers);
  6309. const { references, hasModuleWithProviders } = this.resolveTypeList(
  6310. importExpr,
  6311. [resolved],
  6312. node.name.text,
  6313. "imports",
  6314. absoluteIndex,
  6315. false
  6316. );
  6317. absoluteIndex += references.length;
  6318. topLevelImports.push({
  6319. expression: importExpr,
  6320. resolvedReferences: references,
  6321. hasModuleWithProviders
  6322. });
  6323. }
  6324. }
  6325. const injectorMetadata = {
  6326. name,
  6327. type,
  6328. providers: wrappedProviders,
  6329. imports: []
  6330. };
  6331. if (this.compilationMode === CompilationMode.LOCAL) {
  6332. for (const exp of [rawImports, rawExports]) {
  6333. if (exp === null) {
  6334. continue;
  6335. }
  6336. if (ts24.isArrayLiteralExpression(exp)) {
  6337. if (exp.elements) {
  6338. injectorMetadata.imports.push(...exp.elements.map((n2) => new WrappedNodeExpr7(n2)));
  6339. }
  6340. } else {
  6341. injectorMetadata.imports.push(new WrappedNodeExpr7(exp));
  6342. }
  6343. }
  6344. }
  6345. const factoryMetadata = {
  6346. name,
  6347. type,
  6348. typeArgumentCount: 0,
  6349. deps: getValidConstructorDependencies(node, this.reflector, this.isCore),
  6350. target: FactoryTarget2.NgModule
  6351. };
  6352. const remoteScopesMayRequireCycleProtection = declarationRefs.some(isSyntheticReference) || importRefs.some(isSyntheticReference);
  6353. return {
  6354. diagnostics: diagnostics.length > 0 ? diagnostics : void 0,
  6355. analysis: {
  6356. id,
  6357. schemas,
  6358. mod: ngModuleMetadata,
  6359. inj: injectorMetadata,
  6360. fac: factoryMetadata,
  6361. declarations: declarationRefs,
  6362. rawDeclarations,
  6363. imports: topLevelImports,
  6364. rawImports,
  6365. importRefs,
  6366. exports: exportRefs,
  6367. rawExports,
  6368. providers: rawProviders,
  6369. providersRequiringFactory: rawProviders ? resolveProvidersRequiringFactory(rawProviders, this.reflector, this.evaluator) : null,
  6370. classMetadata: this.includeClassMetadata ? extractClassMetadata(node, this.reflector, this.isCore, this.annotateForClosureCompiler) : null,
  6371. factorySymbolName: node.name.text,
  6372. remoteScopesMayRequireCycleProtection,
  6373. decorator: (_e = decorator == null ? void 0 : decorator.node) != null ? _e : null
  6374. }
  6375. };
  6376. }
  6377. symbol(node, analysis) {
  6378. return new NgModuleSymbol(node, analysis.providers !== null);
  6379. }
  6380. register(node, analysis) {
  6381. this.metaRegistry.registerNgModuleMetadata({
  6382. kind: MetaKind.NgModule,
  6383. ref: new Reference(node),
  6384. schemas: analysis.schemas,
  6385. declarations: analysis.declarations,
  6386. imports: analysis.importRefs,
  6387. exports: analysis.exports,
  6388. rawDeclarations: analysis.rawDeclarations,
  6389. rawImports: analysis.rawImports,
  6390. rawExports: analysis.rawExports,
  6391. decorator: analysis.decorator,
  6392. mayDeclareProviders: analysis.providers !== null,
  6393. isPoisoned: false
  6394. });
  6395. this.injectableRegistry.registerInjectable(node, {
  6396. ctorDeps: analysis.fac.deps
  6397. });
  6398. }
  6399. resolve(node, analysis) {
  6400. if (this.compilationMode === CompilationMode.LOCAL) {
  6401. return {};
  6402. }
  6403. const scope = this.scopeRegistry.getScopeOfModule(node);
  6404. const diagnostics = [];
  6405. const scopeDiagnostics = this.scopeRegistry.getDiagnosticsOfModule(node);
  6406. if (scopeDiagnostics !== null) {
  6407. diagnostics.push(...scopeDiagnostics);
  6408. }
  6409. if (analysis.providersRequiringFactory !== null) {
  6410. const providerDiagnostics = getProviderDiagnostics(analysis.providersRequiringFactory, analysis.providers, this.injectableRegistry);
  6411. diagnostics.push(...providerDiagnostics);
  6412. }
  6413. const data = {
  6414. injectorImports: []
  6415. };
  6416. for (const topLevelImport of analysis.imports) {
  6417. if (topLevelImport.hasModuleWithProviders) {
  6418. data.injectorImports.push(new WrappedNodeExpr7(topLevelImport.expression));
  6419. continue;
  6420. }
  6421. const refsToEmit = [];
  6422. let symbol = null;
  6423. if (this.semanticDepGraphUpdater !== null) {
  6424. const sym = this.semanticDepGraphUpdater.getSymbol(node);
  6425. if (sym instanceof NgModuleSymbol) {
  6426. symbol = sym;
  6427. }
  6428. }
  6429. for (const ref of topLevelImport.resolvedReferences) {
  6430. const dirMeta = this.metaReader.getDirectiveMetadata(ref);
  6431. if (dirMeta !== null) {
  6432. if (!dirMeta.isComponent) {
  6433. continue;
  6434. }
  6435. const mayExportProviders = this.exportedProviderStatusResolver.mayExportProviders(dirMeta.ref, (importRef) => {
  6436. if (symbol !== null && this.semanticDepGraphUpdater !== null) {
  6437. const importSymbol = this.semanticDepGraphUpdater.getSymbol(importRef.node);
  6438. symbol.addTransitiveImportFromStandaloneComponent(importSymbol);
  6439. }
  6440. });
  6441. if (!mayExportProviders) {
  6442. continue;
  6443. }
  6444. }
  6445. const pipeMeta = dirMeta === null ? this.metaReader.getPipeMetadata(ref) : null;
  6446. if (pipeMeta !== null) {
  6447. continue;
  6448. }
  6449. refsToEmit.push(ref);
  6450. }
  6451. if (refsToEmit.length === topLevelImport.resolvedReferences.length) {
  6452. data.injectorImports.push(new WrappedNodeExpr7(topLevelImport.expression));
  6453. } else {
  6454. const context = node.getSourceFile();
  6455. for (const ref of refsToEmit) {
  6456. const emittedRef = this.refEmitter.emit(ref, context);
  6457. assertSuccessfulReferenceEmit(emittedRef, topLevelImport.expression, "class");
  6458. data.injectorImports.push(emittedRef.expression);
  6459. }
  6460. }
  6461. }
  6462. if (scope !== null && !scope.compilation.isPoisoned) {
  6463. const context = getSourceFile(node);
  6464. for (const exportRef of analysis.exports) {
  6465. if (isNgModule(exportRef.node, scope.compilation)) {
  6466. const type = this.refEmitter.emit(exportRef, context);
  6467. assertSuccessfulReferenceEmit(type, node, "NgModule");
  6468. data.injectorImports.push(type.expression);
  6469. }
  6470. }
  6471. for (const decl of analysis.declarations) {
  6472. const dirMeta = this.metaReader.getDirectiveMetadata(decl);
  6473. if (dirMeta !== null) {
  6474. const refType = dirMeta.isComponent ? "Component" : "Directive";
  6475. if (dirMeta.selector === null) {
  6476. throw new FatalDiagnosticError(ErrorCode.DIRECTIVE_MISSING_SELECTOR, decl.node, `${refType} ${decl.node.name.text} has no selector, please add it!`);
  6477. }
  6478. continue;
  6479. }
  6480. }
  6481. }
  6482. if (diagnostics.length > 0) {
  6483. return { diagnostics };
  6484. }
  6485. if (scope === null || scope.compilation.isPoisoned || scope.exported.isPoisoned || scope.reexports === null) {
  6486. return { data };
  6487. } else {
  6488. return {
  6489. data,
  6490. reexports: scope.reexports
  6491. };
  6492. }
  6493. }
  6494. compileFull(node, { inj, mod, fac, classMetadata, declarations, remoteScopesMayRequireCycleProtection }, { injectorImports }) {
  6495. const factoryFn = compileNgFactoryDefField(fac);
  6496. const ngInjectorDef = compileInjector({
  6497. ...inj,
  6498. imports: injectorImports
  6499. });
  6500. const ngModuleDef = compileNgModule(mod);
  6501. const statements = ngModuleDef.statements;
  6502. const metadata = classMetadata !== null ? compileClassMetadata2(classMetadata) : null;
  6503. this.insertMetadataStatement(statements, metadata);
  6504. this.appendRemoteScopingStatements(statements, node, declarations, remoteScopesMayRequireCycleProtection);
  6505. return this.compileNgModule(factoryFn, ngInjectorDef, ngModuleDef);
  6506. }
  6507. compilePartial(node, { inj, fac, mod, classMetadata }, { injectorImports }) {
  6508. const factoryFn = compileDeclareFactory(fac);
  6509. const injectorDef = compileDeclareInjectorFromMetadata({
  6510. ...inj,
  6511. imports: injectorImports
  6512. });
  6513. const ngModuleDef = compileDeclareNgModuleFromMetadata(mod);
  6514. const metadata = classMetadata !== null ? compileDeclareClassMetadata2(classMetadata) : null;
  6515. this.insertMetadataStatement(ngModuleDef.statements, metadata);
  6516. return this.compileNgModule(factoryFn, injectorDef, ngModuleDef);
  6517. }
  6518. compileLocal(node, { inj, mod, fac, classMetadata, declarations, remoteScopesMayRequireCycleProtection }) {
  6519. const factoryFn = compileNgFactoryDefField(fac);
  6520. const ngInjectorDef = compileInjector({
  6521. ...inj
  6522. });
  6523. const ngModuleDef = compileNgModule(mod);
  6524. const statements = ngModuleDef.statements;
  6525. const metadata = classMetadata !== null ? compileClassMetadata2(classMetadata) : null;
  6526. this.insertMetadataStatement(statements, metadata);
  6527. this.appendRemoteScopingStatements(statements, node, declarations, remoteScopesMayRequireCycleProtection);
  6528. return this.compileNgModule(factoryFn, ngInjectorDef, ngModuleDef);
  6529. }
  6530. insertMetadataStatement(ngModuleStatements, metadata) {
  6531. if (metadata !== null) {
  6532. ngModuleStatements.unshift(metadata.toStmt());
  6533. }
  6534. }
  6535. appendRemoteScopingStatements(ngModuleStatements, node, declarations, remoteScopesMayRequireCycleProtection) {
  6536. if (this.compilationMode === CompilationMode.LOCAL) {
  6537. return;
  6538. }
  6539. const context = getSourceFile(node);
  6540. for (const decl of declarations) {
  6541. const remoteScope = this.scopeRegistry.getRemoteScope(decl.node);
  6542. if (remoteScope !== null) {
  6543. const directives = remoteScope.directives.map((directive) => {
  6544. const type = this.refEmitter.emit(directive, context);
  6545. assertSuccessfulReferenceEmit(type, node, "directive");
  6546. return type.expression;
  6547. });
  6548. const pipes = remoteScope.pipes.map((pipe) => {
  6549. const type = this.refEmitter.emit(pipe, context);
  6550. assertSuccessfulReferenceEmit(type, node, "pipe");
  6551. return type.expression;
  6552. });
  6553. const directiveArray = new LiteralArrayExpr2(directives);
  6554. const pipesArray = new LiteralArrayExpr2(pipes);
  6555. const directiveExpr = remoteScopesMayRequireCycleProtection && directives.length > 0 ? new FunctionExpr([], [new ReturnStatement(directiveArray)]) : directiveArray;
  6556. const pipesExpr = remoteScopesMayRequireCycleProtection && pipes.length > 0 ? new FunctionExpr([], [new ReturnStatement(pipesArray)]) : pipesArray;
  6557. const componentType = this.refEmitter.emit(decl, context);
  6558. assertSuccessfulReferenceEmit(componentType, node, "component");
  6559. const declExpr = componentType.expression;
  6560. const setComponentScope = new ExternalExpr5(R3Identifiers.setComponentScope);
  6561. const callExpr = new InvokeFunctionExpr(setComponentScope, [
  6562. declExpr,
  6563. directiveExpr,
  6564. pipesExpr
  6565. ]);
  6566. ngModuleStatements.push(callExpr.toStmt());
  6567. }
  6568. }
  6569. }
  6570. compileNgModule(factoryFn, injectorDef, ngModuleDef) {
  6571. const res = [
  6572. factoryFn,
  6573. {
  6574. name: "\u0275mod",
  6575. initializer: ngModuleDef.expression,
  6576. statements: ngModuleDef.statements,
  6577. type: ngModuleDef.type,
  6578. deferrableImports: null
  6579. },
  6580. {
  6581. name: "\u0275inj",
  6582. initializer: injectorDef.expression,
  6583. statements: injectorDef.statements,
  6584. type: injectorDef.type,
  6585. deferrableImports: null
  6586. }
  6587. ];
  6588. return res;
  6589. }
  6590. _toR3Reference(origin, valueRef, valueContext) {
  6591. if (valueRef.hasOwningModuleGuess) {
  6592. return toR3Reference(origin, valueRef, valueContext, this.refEmitter);
  6593. } else {
  6594. return toR3Reference(origin, valueRef, valueContext, this.refEmitter);
  6595. }
  6596. }
  6597. isClassDeclarationReference(ref) {
  6598. return this.reflector.isClass(ref.node);
  6599. }
  6600. resolveTypeList(expr, resolvedList, className, arrayName, absoluteIndex, allowUnresolvedReferences) {
  6601. let hasModuleWithProviders = false;
  6602. const refList = [];
  6603. const dynamicValueSet = /* @__PURE__ */ new Set();
  6604. if (!Array.isArray(resolvedList)) {
  6605. if (allowUnresolvedReferences) {
  6606. return {
  6607. references: [],
  6608. hasModuleWithProviders: false,
  6609. dynamicValues: []
  6610. };
  6611. }
  6612. throw createValueHasWrongTypeError(expr, resolvedList, `Expected array when reading the NgModule.${arrayName} of ${className}`);
  6613. }
  6614. for (let idx = 0; idx < resolvedList.length; idx++) {
  6615. let entry = resolvedList[idx];
  6616. if (entry instanceof SyntheticValue && isResolvedModuleWithProviders(entry)) {
  6617. entry = entry.value.ngModule;
  6618. hasModuleWithProviders = true;
  6619. } else if (entry instanceof Map && entry.has("ngModule")) {
  6620. entry = entry.get("ngModule");
  6621. hasModuleWithProviders = true;
  6622. }
  6623. if (Array.isArray(entry)) {
  6624. const recursiveResult = this.resolveTypeList(expr, entry, className, arrayName, absoluteIndex, allowUnresolvedReferences);
  6625. refList.push(...recursiveResult.references);
  6626. for (const d of recursiveResult.dynamicValues) {
  6627. dynamicValueSet.add(d);
  6628. }
  6629. absoluteIndex += recursiveResult.references.length;
  6630. hasModuleWithProviders = hasModuleWithProviders || recursiveResult.hasModuleWithProviders;
  6631. } else if (entry instanceof Reference) {
  6632. if (!this.isClassDeclarationReference(entry)) {
  6633. throw createValueHasWrongTypeError(entry.node, entry, `Value at position ${absoluteIndex} in the NgModule.${arrayName} of ${className} is not a class`);
  6634. }
  6635. refList.push(entry);
  6636. absoluteIndex += 1;
  6637. } else if (entry instanceof DynamicValue && allowUnresolvedReferences) {
  6638. dynamicValueSet.add(entry);
  6639. continue;
  6640. } else {
  6641. throw createValueHasWrongTypeError(expr, entry, `Value at position ${absoluteIndex} in the NgModule.${arrayName} of ${className} is not a reference`);
  6642. }
  6643. }
  6644. return {
  6645. references: refList,
  6646. hasModuleWithProviders,
  6647. dynamicValues: [...dynamicValueSet]
  6648. };
  6649. }
  6650. };
  6651. function isNgModule(node, compilation) {
  6652. return !compilation.dependencies.some((dep) => dep.ref.node === node);
  6653. }
  6654. function isModuleIdExpression(expr) {
  6655. return ts24.isPropertyAccessExpression(expr) && ts24.isIdentifier(expr.expression) && expr.expression.text === "module" && expr.name.text === "id";
  6656. }
  6657. function makeStandaloneBootstrapDiagnostic(ngModuleClass, bootstrappedClassRef, rawBootstrapExpr) {
  6658. const componentClassName = bootstrappedClassRef.node.name.text;
  6659. const message = `The \`${componentClassName}\` class is a standalone component, which can not be used in the \`@NgModule.bootstrap\` array. Use the \`bootstrapApplication\` function for bootstrap instead.`;
  6660. const relatedInformation = [
  6661. makeRelatedInformation(ngModuleClass, `The 'bootstrap' array is present on this NgModule.`)
  6662. ];
  6663. return makeDiagnostic(ErrorCode.NGMODULE_BOOTSTRAP_IS_STANDALONE, getDiagnosticNode(bootstrappedClassRef, rawBootstrapExpr), message, relatedInformation);
  6664. }
  6665. function isSyntheticReference(ref) {
  6666. return ref.synthetic;
  6667. }
  6668. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/component/src/diagnostics.mjs
  6669. function makeCyclicImportInfo(ref, type, cycle) {
  6670. const name = ref.debugName || "(unknown)";
  6671. const path = cycle.getPath().map((sf) => sf.fileName).join(" -> ");
  6672. const message = `The ${type} '${name}' is used in the template but importing it would create a cycle: `;
  6673. return makeRelatedInformation(ref.node, message + path);
  6674. }
  6675. function checkCustomElementSelectorForErrors(selector) {
  6676. if (selector.includes(".") || selector.includes("[") && selector.includes("]")) {
  6677. return null;
  6678. }
  6679. if (!/^[a-z]/.test(selector)) {
  6680. return "Selector of a ShadowDom-encapsulated component must start with a lower case letter.";
  6681. }
  6682. if (/[A-Z]/.test(selector)) {
  6683. return "Selector of a ShadowDom-encapsulated component must all be in lower case.";
  6684. }
  6685. if (!selector.includes("-")) {
  6686. return "Selector of a component that uses ViewEncapsulation.ShadowDom must contain a hyphen.";
  6687. }
  6688. return null;
  6689. }
  6690. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/component/src/resources.mjs
  6691. import { DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig, ParseSourceFile as ParseSourceFile2, parseTemplate } from "@angular/compiler";
  6692. import ts25 from "typescript";
  6693. function getTemplateDeclarationNodeForError(declaration) {
  6694. return declaration.isInline ? declaration.expression : declaration.templateUrlExpression;
  6695. }
  6696. function extractTemplate(node, template, evaluator, depTracker, resourceLoader, options, compilationMode) {
  6697. if (template.isInline) {
  6698. let sourceStr;
  6699. let sourceParseRange = null;
  6700. let templateContent;
  6701. let sourceMapping;
  6702. let escapedString = false;
  6703. let sourceMapUrl;
  6704. if (ts25.isStringLiteral(template.expression) || ts25.isNoSubstitutionTemplateLiteral(template.expression)) {
  6705. sourceParseRange = getTemplateRange(template.expression);
  6706. sourceStr = template.expression.getSourceFile().text;
  6707. templateContent = template.expression.text;
  6708. escapedString = true;
  6709. sourceMapping = {
  6710. type: "direct",
  6711. node: template.expression
  6712. };
  6713. sourceMapUrl = template.resolvedTemplateUrl;
  6714. } else {
  6715. const resolvedTemplate = evaluator.evaluate(template.expression);
  6716. assertLocalCompilationUnresolvedConst(compilationMode, resolvedTemplate, template.expression, "Unresolved identifier found for @Component.template field! Did you import this identifier from a file outside of the compilation unit? This is not allowed when Angular compiler runs in local mode. Possible solutions: 1) Move the declaration into a file within the compilation unit, 2) Inline the template, 3) Move the template into a separate .html file and include it using @Component.templateUrl");
  6717. if (typeof resolvedTemplate !== "string") {
  6718. throw createValueHasWrongTypeError(template.expression, resolvedTemplate, "template must be a string");
  6719. }
  6720. sourceStr = resolvedTemplate;
  6721. templateContent = resolvedTemplate;
  6722. sourceMapping = {
  6723. type: "indirect",
  6724. node: template.expression,
  6725. componentClass: node,
  6726. template: templateContent
  6727. };
  6728. sourceMapUrl = null;
  6729. }
  6730. return {
  6731. ...parseExtractedTemplate(template, sourceStr, sourceParseRange, escapedString, sourceMapUrl, options),
  6732. content: templateContent,
  6733. sourceMapping,
  6734. declaration: template
  6735. };
  6736. } else {
  6737. const templateContent = resourceLoader.load(template.resolvedTemplateUrl);
  6738. if (depTracker !== null) {
  6739. depTracker.addResourceDependency(node.getSourceFile(), absoluteFrom(template.resolvedTemplateUrl));
  6740. }
  6741. return {
  6742. ...parseExtractedTemplate(
  6743. template,
  6744. templateContent,
  6745. null,
  6746. false,
  6747. template.resolvedTemplateUrl,
  6748. options
  6749. ),
  6750. content: templateContent,
  6751. sourceMapping: {
  6752. type: "external",
  6753. componentClass: node,
  6754. node: template.templateUrlExpression,
  6755. template: templateContent,
  6756. templateUrl: template.resolvedTemplateUrl
  6757. },
  6758. declaration: template
  6759. };
  6760. }
  6761. }
  6762. function parseExtractedTemplate(template, sourceStr, sourceParseRange, escapedString, sourceMapUrl, options) {
  6763. const i18nNormalizeLineEndingsInICUs = escapedString || options.i18nNormalizeLineEndingsInICUs;
  6764. const commonParseOptions = {
  6765. interpolationConfig: template.interpolationConfig,
  6766. range: sourceParseRange != null ? sourceParseRange : void 0,
  6767. enableI18nLegacyMessageIdFormat: options.enableI18nLegacyMessageIdFormat,
  6768. i18nNormalizeLineEndingsInICUs,
  6769. alwaysAttemptHtmlToR3AstConversion: options.usePoisonedData,
  6770. escapedString,
  6771. enableBlockSyntax: options.enableBlockSyntax,
  6772. enableLetSyntax: options.enableLetSyntax
  6773. };
  6774. const parsedTemplate = parseTemplate(sourceStr, sourceMapUrl != null ? sourceMapUrl : "", {
  6775. ...commonParseOptions,
  6776. preserveWhitespaces: template.preserveWhitespaces,
  6777. preserveSignificantWhitespace: options.preserveSignificantWhitespace
  6778. });
  6779. const { nodes: diagNodes } = parseTemplate(sourceStr, sourceMapUrl != null ? sourceMapUrl : "", {
  6780. ...commonParseOptions,
  6781. preserveWhitespaces: true,
  6782. preserveLineEndings: true,
  6783. preserveSignificantWhitespace: true,
  6784. leadingTriviaChars: []
  6785. });
  6786. return {
  6787. ...parsedTemplate,
  6788. diagNodes,
  6789. file: new ParseSourceFile2(sourceStr, sourceMapUrl != null ? sourceMapUrl : "")
  6790. };
  6791. }
  6792. function parseTemplateDeclaration(node, decorator, component, containingFile, evaluator, depTracker, resourceLoader, defaultPreserveWhitespaces) {
  6793. let preserveWhitespaces = defaultPreserveWhitespaces;
  6794. if (component.has("preserveWhitespaces")) {
  6795. const expr = component.get("preserveWhitespaces");
  6796. const value = evaluator.evaluate(expr);
  6797. if (typeof value !== "boolean") {
  6798. throw createValueHasWrongTypeError(expr, value, "preserveWhitespaces must be a boolean");
  6799. }
  6800. preserveWhitespaces = value;
  6801. }
  6802. let interpolationConfig = DEFAULT_INTERPOLATION_CONFIG;
  6803. if (component.has("interpolation")) {
  6804. const expr = component.get("interpolation");
  6805. const value = evaluator.evaluate(expr);
  6806. if (!Array.isArray(value) || value.length !== 2 || !value.every((element) => typeof element === "string")) {
  6807. throw createValueHasWrongTypeError(expr, value, "interpolation must be an array with 2 elements of string type");
  6808. }
  6809. interpolationConfig = InterpolationConfig.fromArray(value);
  6810. }
  6811. if (component.has("templateUrl")) {
  6812. const templateUrlExpr = component.get("templateUrl");
  6813. const templateUrl = evaluator.evaluate(templateUrlExpr);
  6814. if (typeof templateUrl !== "string") {
  6815. throw createValueHasWrongTypeError(templateUrlExpr, templateUrl, "templateUrl must be a string");
  6816. }
  6817. try {
  6818. const resourceUrl = resourceLoader.resolve(templateUrl, containingFile);
  6819. return {
  6820. isInline: false,
  6821. interpolationConfig,
  6822. preserveWhitespaces,
  6823. templateUrl,
  6824. templateUrlExpression: templateUrlExpr,
  6825. resolvedTemplateUrl: resourceUrl
  6826. };
  6827. } catch (e) {
  6828. if (depTracker !== null) {
  6829. depTracker.recordDependencyAnalysisFailure(node.getSourceFile());
  6830. }
  6831. throw makeResourceNotFoundError(templateUrl, templateUrlExpr, 0);
  6832. }
  6833. } else if (component.has("template")) {
  6834. return {
  6835. isInline: true,
  6836. interpolationConfig,
  6837. preserveWhitespaces,
  6838. expression: component.get("template"),
  6839. templateUrl: containingFile,
  6840. resolvedTemplateUrl: containingFile
  6841. };
  6842. } else {
  6843. throw new FatalDiagnosticError(ErrorCode.COMPONENT_MISSING_TEMPLATE, decorator.node, "component is missing a template");
  6844. }
  6845. }
  6846. function preloadAndParseTemplate(evaluator, resourceLoader, depTracker, preanalyzeTemplateCache, node, decorator, component, containingFile, defaultPreserveWhitespaces, options, compilationMode) {
  6847. if (component.has("templateUrl")) {
  6848. const templateUrlExpr = component.get("templateUrl");
  6849. const templateUrl = evaluator.evaluate(templateUrlExpr);
  6850. if (typeof templateUrl !== "string") {
  6851. throw createValueHasWrongTypeError(templateUrlExpr, templateUrl, "templateUrl must be a string");
  6852. }
  6853. try {
  6854. const resourceUrl = resourceLoader.resolve(templateUrl, containingFile);
  6855. const templatePromise = resourceLoader.preload(resourceUrl, {
  6856. type: "template",
  6857. containingFile,
  6858. className: node.name.text
  6859. });
  6860. if (templatePromise !== void 0) {
  6861. return templatePromise.then(() => {
  6862. const templateDecl = parseTemplateDeclaration(node, decorator, component, containingFile, evaluator, depTracker, resourceLoader, defaultPreserveWhitespaces);
  6863. const template = extractTemplate(node, templateDecl, evaluator, depTracker, resourceLoader, options, compilationMode);
  6864. preanalyzeTemplateCache.set(node, template);
  6865. return template;
  6866. });
  6867. } else {
  6868. return Promise.resolve(null);
  6869. }
  6870. } catch (e) {
  6871. if (depTracker !== null) {
  6872. depTracker.recordDependencyAnalysisFailure(node.getSourceFile());
  6873. }
  6874. throw makeResourceNotFoundError(templateUrl, templateUrlExpr, 0);
  6875. }
  6876. } else {
  6877. const templateDecl = parseTemplateDeclaration(node, decorator, component, containingFile, evaluator, depTracker, resourceLoader, defaultPreserveWhitespaces);
  6878. const template = extractTemplate(node, templateDecl, evaluator, depTracker, resourceLoader, options, compilationMode);
  6879. preanalyzeTemplateCache.set(node, template);
  6880. return Promise.resolve(template);
  6881. }
  6882. }
  6883. function getTemplateRange(templateExpr) {
  6884. const startPos = templateExpr.getStart() + 1;
  6885. const { line, character } = ts25.getLineAndCharacterOfPosition(templateExpr.getSourceFile(), startPos);
  6886. return {
  6887. startPos,
  6888. startLine: line,
  6889. startCol: character,
  6890. endPos: templateExpr.getEnd() - 1
  6891. };
  6892. }
  6893. function makeResourceNotFoundError(file, nodeForError, resourceType) {
  6894. let errorText;
  6895. switch (resourceType) {
  6896. case 0:
  6897. errorText = `Could not find template file '${file}'.`;
  6898. break;
  6899. case 1:
  6900. errorText = `Could not find stylesheet file '${file}' linked from the template.`;
  6901. break;
  6902. case 2:
  6903. errorText = `Could not find stylesheet file '${file}'.`;
  6904. break;
  6905. }
  6906. return new FatalDiagnosticError(ErrorCode.COMPONENT_RESOURCE_NOT_FOUND, nodeForError, errorText);
  6907. }
  6908. function transformDecoratorResources(dec, component, styles, template) {
  6909. if (dec.name !== "Component") {
  6910. return dec;
  6911. }
  6912. if (!component.has("templateUrl") && !component.has("styleUrls") && !component.has("styleUrl") && !component.has("styles")) {
  6913. return dec;
  6914. }
  6915. const metadata = new Map(component);
  6916. if (metadata.has("templateUrl")) {
  6917. metadata.delete("templateUrl");
  6918. metadata.set("template", ts25.factory.createStringLiteral(template.content));
  6919. }
  6920. if (metadata.has("styleUrls") || metadata.has("styleUrl") || metadata.has("styles")) {
  6921. metadata.delete("styles");
  6922. metadata.delete("styleUrls");
  6923. metadata.delete("styleUrl");
  6924. if (styles.length > 0) {
  6925. const styleNodes = styles.reduce((result, style) => {
  6926. if (style.trim().length > 0) {
  6927. result.push(ts25.factory.createStringLiteral(style));
  6928. }
  6929. return result;
  6930. }, []);
  6931. if (styleNodes.length > 0) {
  6932. metadata.set("styles", ts25.factory.createArrayLiteralExpression(styleNodes));
  6933. }
  6934. }
  6935. }
  6936. const newMetadataFields = [];
  6937. for (const [name, value] of metadata.entries()) {
  6938. newMetadataFields.push(ts25.factory.createPropertyAssignment(name, value));
  6939. }
  6940. return { ...dec, args: [ts25.factory.createObjectLiteralExpression(newMetadataFields)] };
  6941. }
  6942. function extractComponentStyleUrls(evaluator, component) {
  6943. const styleUrlsExpr = component.get("styleUrls");
  6944. const styleUrlExpr = component.get("styleUrl");
  6945. if (styleUrlsExpr !== void 0 && styleUrlExpr !== void 0) {
  6946. throw new FatalDiagnosticError(ErrorCode.COMPONENT_INVALID_STYLE_URLS, styleUrlExpr, "@Component cannot define both `styleUrl` and `styleUrls`. Use `styleUrl` if the component has one stylesheet, or `styleUrls` if it has multiple");
  6947. }
  6948. if (styleUrlsExpr !== void 0) {
  6949. return extractStyleUrlsFromExpression(evaluator, component.get("styleUrls"));
  6950. }
  6951. if (styleUrlExpr !== void 0) {
  6952. const styleUrl = evaluator.evaluate(styleUrlExpr);
  6953. if (typeof styleUrl !== "string") {
  6954. throw createValueHasWrongTypeError(styleUrlExpr, styleUrl, "styleUrl must be a string");
  6955. }
  6956. return [
  6957. {
  6958. url: styleUrl,
  6959. source: 2,
  6960. expression: styleUrlExpr
  6961. }
  6962. ];
  6963. }
  6964. return [];
  6965. }
  6966. function extractStyleUrlsFromExpression(evaluator, styleUrlsExpr) {
  6967. const styleUrls = [];
  6968. if (ts25.isArrayLiteralExpression(styleUrlsExpr)) {
  6969. for (const styleUrlExpr of styleUrlsExpr.elements) {
  6970. if (ts25.isSpreadElement(styleUrlExpr)) {
  6971. styleUrls.push(...extractStyleUrlsFromExpression(evaluator, styleUrlExpr.expression));
  6972. } else {
  6973. const styleUrl = evaluator.evaluate(styleUrlExpr);
  6974. if (typeof styleUrl !== "string") {
  6975. throw createValueHasWrongTypeError(styleUrlExpr, styleUrl, "styleUrl must be a string");
  6976. }
  6977. styleUrls.push({
  6978. url: styleUrl,
  6979. source: 2,
  6980. expression: styleUrlExpr
  6981. });
  6982. }
  6983. }
  6984. } else {
  6985. const evaluatedStyleUrls = evaluator.evaluate(styleUrlsExpr);
  6986. if (!isStringArray(evaluatedStyleUrls)) {
  6987. throw createValueHasWrongTypeError(styleUrlsExpr, evaluatedStyleUrls, "styleUrls must be an array of strings");
  6988. }
  6989. for (const styleUrl of evaluatedStyleUrls) {
  6990. styleUrls.push({
  6991. url: styleUrl,
  6992. source: 2,
  6993. expression: styleUrlsExpr
  6994. });
  6995. }
  6996. }
  6997. return styleUrls;
  6998. }
  6999. function extractInlineStyleResources(component) {
  7000. const styles = /* @__PURE__ */ new Set();
  7001. function stringLiteralElements(array) {
  7002. return array.elements.filter((e) => ts25.isStringLiteralLike(e));
  7003. }
  7004. const stylesExpr = component.get("styles");
  7005. if (stylesExpr !== void 0) {
  7006. if (ts25.isArrayLiteralExpression(stylesExpr)) {
  7007. for (const expression of stringLiteralElements(stylesExpr)) {
  7008. styles.add({ path: null, expression });
  7009. }
  7010. } else if (ts25.isStringLiteralLike(stylesExpr)) {
  7011. styles.add({ path: null, expression: stylesExpr });
  7012. }
  7013. }
  7014. return styles;
  7015. }
  7016. function _extractTemplateStyleUrls(template) {
  7017. if (template.styleUrls === null) {
  7018. return [];
  7019. }
  7020. const expression = getTemplateDeclarationNodeForError(template.declaration);
  7021. return template.styleUrls.map((url) => ({
  7022. url,
  7023. source: 1,
  7024. expression
  7025. }));
  7026. }
  7027. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/component/src/symbol.mjs
  7028. var ComponentSymbol = class extends DirectiveSymbol {
  7029. usedDirectives = [];
  7030. usedPipes = [];
  7031. isRemotelyScoped = false;
  7032. isEmitAffected(previousSymbol, publicApiAffected) {
  7033. if (!(previousSymbol instanceof ComponentSymbol)) {
  7034. return true;
  7035. }
  7036. const isSymbolUnaffected = (current, previous) => isReferenceEqual(current, previous) && !publicApiAffected.has(current.symbol);
  7037. return this.isRemotelyScoped !== previousSymbol.isRemotelyScoped || !isArrayEqual(this.usedDirectives, previousSymbol.usedDirectives, isSymbolUnaffected) || !isArrayEqual(this.usedPipes, previousSymbol.usedPipes, isSymbolUnaffected);
  7038. }
  7039. isTypeCheckBlockAffected(previousSymbol, typeCheckApiAffected) {
  7040. if (!(previousSymbol instanceof ComponentSymbol)) {
  7041. return true;
  7042. }
  7043. const isInheritanceChainAffected = (symbol) => {
  7044. let currentSymbol = symbol;
  7045. while (currentSymbol instanceof DirectiveSymbol) {
  7046. if (typeCheckApiAffected.has(currentSymbol)) {
  7047. return true;
  7048. }
  7049. currentSymbol = currentSymbol.baseClass;
  7050. }
  7051. return false;
  7052. };
  7053. const isDirectiveUnaffected = (current, previous) => isReferenceEqual(current, previous) && !isInheritanceChainAffected(current.symbol);
  7054. const isPipeUnaffected = (current, previous) => isReferenceEqual(current, previous) && !typeCheckApiAffected.has(current.symbol);
  7055. return !isArrayEqual(this.usedDirectives, previousSymbol.usedDirectives, isDirectiveUnaffected) || !isArrayEqual(this.usedPipes, previousSymbol.usedPipes, isPipeUnaffected);
  7056. }
  7057. };
  7058. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/component/src/util.mjs
  7059. import ts26 from "typescript";
  7060. function collectAnimationNames(value, animationTriggerNames) {
  7061. if (value instanceof Map) {
  7062. const name = value.get("name");
  7063. if (typeof name === "string") {
  7064. animationTriggerNames.staticTriggerNames.push(name);
  7065. } else {
  7066. animationTriggerNames.includesDynamicAnimations = true;
  7067. }
  7068. } else if (Array.isArray(value)) {
  7069. for (const resolvedValue of value) {
  7070. collectAnimationNames(resolvedValue, animationTriggerNames);
  7071. }
  7072. } else {
  7073. animationTriggerNames.includesDynamicAnimations = true;
  7074. }
  7075. }
  7076. function isAngularAnimationsReference(reference, symbolName) {
  7077. return reference.ownedByModuleGuess === "@angular/animations" && reference.debugName === symbolName;
  7078. }
  7079. var animationTriggerResolver = (fn, node, resolve, unresolvable) => {
  7080. const animationTriggerMethodName = "trigger";
  7081. if (!isAngularAnimationsReference(fn, animationTriggerMethodName)) {
  7082. return unresolvable;
  7083. }
  7084. const triggerNameExpression = node.arguments[0];
  7085. if (!triggerNameExpression) {
  7086. return unresolvable;
  7087. }
  7088. const res = /* @__PURE__ */ new Map();
  7089. res.set("name", resolve(triggerNameExpression));
  7090. return res;
  7091. };
  7092. function validateAndFlattenComponentImports(imports, expr, isDeferred) {
  7093. const flattened = [];
  7094. const errorMessage = isDeferred ? `'deferredImports' must be an array of components, directives, or pipes.` : `'imports' must be an array of components, directives, pipes, or NgModules.`;
  7095. if (!Array.isArray(imports)) {
  7096. const error = createValueHasWrongTypeError(expr, imports, errorMessage).toDiagnostic();
  7097. return {
  7098. imports: [],
  7099. diagnostics: [error]
  7100. };
  7101. }
  7102. const diagnostics = [];
  7103. for (let i = 0; i < imports.length; i++) {
  7104. const ref = imports[i];
  7105. if (Array.isArray(ref)) {
  7106. const { imports: childImports, diagnostics: childDiagnostics } = validateAndFlattenComponentImports(ref, expr, isDeferred);
  7107. flattened.push(...childImports);
  7108. diagnostics.push(...childDiagnostics);
  7109. } else if (ref instanceof Reference) {
  7110. if (isNamedClassDeclaration(ref.node)) {
  7111. flattened.push(ref);
  7112. } else {
  7113. diagnostics.push(createValueHasWrongTypeError(ref.getOriginForDiagnostics(expr), ref, errorMessage).toDiagnostic());
  7114. }
  7115. } else if (isLikelyModuleWithProviders(ref)) {
  7116. let origin = expr;
  7117. if (ref instanceof SyntheticValue) {
  7118. origin = getOriginNodeForDiagnostics(ref.value.mwpCall, expr);
  7119. }
  7120. diagnostics.push(makeDiagnostic(ErrorCode.COMPONENT_UNKNOWN_IMPORT, origin, `Component imports contains a ModuleWithProviders value, likely the result of a 'Module.forRoot()'-style call. These calls are not used to configure components and are not valid in standalone component imports - consider importing them in the application bootstrap instead.`));
  7121. } else {
  7122. let diagnosticNode;
  7123. let diagnosticValue;
  7124. if (ref instanceof DynamicValue) {
  7125. diagnosticNode = ref.node;
  7126. diagnosticValue = ref;
  7127. } else if (ts26.isArrayLiteralExpression(expr) && expr.elements.length === imports.length && !expr.elements.some(ts26.isSpreadAssignment) && !imports.some(Array.isArray)) {
  7128. diagnosticNode = expr.elements[i];
  7129. diagnosticValue = ref;
  7130. } else {
  7131. diagnosticNode = expr;
  7132. diagnosticValue = imports;
  7133. }
  7134. diagnostics.push(createValueHasWrongTypeError(diagnosticNode, diagnosticValue, errorMessage).toDiagnostic());
  7135. }
  7136. }
  7137. return { imports: flattened, diagnostics };
  7138. }
  7139. function isLikelyModuleWithProviders(value) {
  7140. if (value instanceof SyntheticValue && isResolvedModuleWithProviders(value)) {
  7141. return true;
  7142. }
  7143. if (value instanceof Map && value.has("ngModule")) {
  7144. return true;
  7145. }
  7146. return false;
  7147. }
  7148. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/checker.mjs
  7149. import { CssSelector as CssSelector3, DomElementSchemaRegistry as DomElementSchemaRegistry2, ExternalExpr as ExternalExpr7, WrappedNodeExpr as WrappedNodeExpr9 } from "@angular/compiler";
  7150. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/program_driver/src/api.mjs
  7151. var NgOriginalFile = Symbol("NgOriginalFile");
  7152. var UpdateMode;
  7153. (function(UpdateMode2) {
  7154. UpdateMode2[UpdateMode2["Complete"] = 0] = "Complete";
  7155. UpdateMode2[UpdateMode2["Incremental"] = 1] = "Incremental";
  7156. })(UpdateMode || (UpdateMode = {}));
  7157. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/program_driver/src/ts_create_program_driver.mjs
  7158. import ts28 from "typescript";
  7159. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/shims/src/adapter.mjs
  7160. import ts27 from "typescript";
  7161. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/shims/src/expando.mjs
  7162. var NgExtension = Symbol("NgExtension");
  7163. function isExtended(sf) {
  7164. return sf[NgExtension] !== void 0;
  7165. }
  7166. function sfExtensionData(sf) {
  7167. const extSf = sf;
  7168. if (extSf[NgExtension] !== void 0) {
  7169. return extSf[NgExtension];
  7170. }
  7171. const extension = {
  7172. isTopLevelShim: false,
  7173. fileShim: null,
  7174. originalReferencedFiles: null,
  7175. taggedReferenceFiles: null
  7176. };
  7177. extSf[NgExtension] = extension;
  7178. return extension;
  7179. }
  7180. function isFileShimSourceFile(sf) {
  7181. return isExtended(sf) && sf[NgExtension].fileShim !== null;
  7182. }
  7183. function isShim(sf) {
  7184. return isExtended(sf) && (sf[NgExtension].fileShim !== null || sf[NgExtension].isTopLevelShim);
  7185. }
  7186. function copyFileShimData(from, to) {
  7187. if (!isFileShimSourceFile(from)) {
  7188. return;
  7189. }
  7190. sfExtensionData(to).fileShim = sfExtensionData(from).fileShim;
  7191. }
  7192. function untagAllTsFiles(program) {
  7193. for (const sf of program.getSourceFiles()) {
  7194. untagTsFile(sf);
  7195. }
  7196. }
  7197. function retagAllTsFiles(program) {
  7198. for (const sf of program.getSourceFiles()) {
  7199. retagTsFile(sf);
  7200. }
  7201. }
  7202. function untagTsFile(sf) {
  7203. if (sf.isDeclarationFile || !isExtended(sf)) {
  7204. return;
  7205. }
  7206. const ext = sfExtensionData(sf);
  7207. if (ext.originalReferencedFiles !== null) {
  7208. sf.referencedFiles = ext.originalReferencedFiles;
  7209. }
  7210. }
  7211. function retagTsFile(sf) {
  7212. if (sf.isDeclarationFile || !isExtended(sf)) {
  7213. return;
  7214. }
  7215. const ext = sfExtensionData(sf);
  7216. if (ext.taggedReferenceFiles !== null) {
  7217. sf.referencedFiles = ext.taggedReferenceFiles;
  7218. }
  7219. }
  7220. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/shims/src/util.mjs
  7221. var TS_EXTENSIONS = /\.tsx?$/i;
  7222. function makeShimFileName(fileName, suffix) {
  7223. return absoluteFrom(fileName.replace(TS_EXTENSIONS, suffix));
  7224. }
  7225. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/shims/src/adapter.mjs
  7226. var ShimAdapter = class {
  7227. delegate;
  7228. shims = /* @__PURE__ */ new Map();
  7229. priorShims = /* @__PURE__ */ new Map();
  7230. notShims = /* @__PURE__ */ new Set();
  7231. generators = [];
  7232. ignoreForEmit = /* @__PURE__ */ new Set();
  7233. extraInputFiles;
  7234. extensionPrefixes = [];
  7235. constructor(delegate, tsRootFiles, topLevelGenerators, perFileGenerators, oldProgram) {
  7236. this.delegate = delegate;
  7237. for (const gen of perFileGenerators) {
  7238. const pattern = `^(.*)\\.${gen.extensionPrefix}\\.ts$`;
  7239. const regexp = new RegExp(pattern, "i");
  7240. this.generators.push({
  7241. generator: gen,
  7242. test: regexp,
  7243. suffix: `.${gen.extensionPrefix}.ts`
  7244. });
  7245. this.extensionPrefixes.push(gen.extensionPrefix);
  7246. }
  7247. const extraInputFiles = [];
  7248. for (const gen of topLevelGenerators) {
  7249. const sf = gen.makeTopLevelShim();
  7250. sfExtensionData(sf).isTopLevelShim = true;
  7251. if (!gen.shouldEmit) {
  7252. this.ignoreForEmit.add(sf);
  7253. }
  7254. const fileName = absoluteFromSourceFile(sf);
  7255. this.shims.set(fileName, sf);
  7256. extraInputFiles.push(fileName);
  7257. }
  7258. for (const rootFile of tsRootFiles) {
  7259. for (const gen of this.generators) {
  7260. extraInputFiles.push(makeShimFileName(rootFile, gen.suffix));
  7261. }
  7262. }
  7263. this.extraInputFiles = extraInputFiles;
  7264. if (oldProgram !== null) {
  7265. for (const oldSf of oldProgram.getSourceFiles()) {
  7266. if (oldSf.isDeclarationFile || !isFileShimSourceFile(oldSf)) {
  7267. continue;
  7268. }
  7269. this.priorShims.set(absoluteFromSourceFile(oldSf), oldSf);
  7270. }
  7271. }
  7272. }
  7273. maybeGenerate(fileName) {
  7274. if (this.notShims.has(fileName)) {
  7275. return null;
  7276. } else if (this.shims.has(fileName)) {
  7277. return this.shims.get(fileName);
  7278. }
  7279. if (isDtsPath(fileName)) {
  7280. this.notShims.add(fileName);
  7281. return null;
  7282. }
  7283. for (const record of this.generators) {
  7284. const match = record.test.exec(fileName);
  7285. if (match === null) {
  7286. continue;
  7287. }
  7288. const prefix = match[1];
  7289. let baseFileName = absoluteFrom(prefix + ".ts");
  7290. let inputFile = this.delegate.getSourceFile(baseFileName, ts27.ScriptTarget.Latest);
  7291. if (inputFile === void 0) {
  7292. baseFileName = absoluteFrom(prefix + ".tsx");
  7293. inputFile = this.delegate.getSourceFile(baseFileName, ts27.ScriptTarget.Latest);
  7294. }
  7295. if (inputFile === void 0 || isShim(inputFile)) {
  7296. return void 0;
  7297. }
  7298. return this.generateSpecific(fileName, record.generator, inputFile);
  7299. }
  7300. this.notShims.add(fileName);
  7301. return null;
  7302. }
  7303. generateSpecific(fileName, generator, inputFile) {
  7304. let priorShimSf = null;
  7305. if (this.priorShims.has(fileName)) {
  7306. priorShimSf = this.priorShims.get(fileName);
  7307. this.priorShims.delete(fileName);
  7308. }
  7309. const shimSf = generator.generateShimForFile(inputFile, fileName, priorShimSf);
  7310. sfExtensionData(shimSf).fileShim = {
  7311. extension: generator.extensionPrefix,
  7312. generatedFrom: absoluteFromSourceFile(inputFile)
  7313. };
  7314. if (!generator.shouldEmit) {
  7315. this.ignoreForEmit.add(shimSf);
  7316. }
  7317. this.shims.set(fileName, shimSf);
  7318. return shimSf;
  7319. }
  7320. };
  7321. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/shims/src/reference_tagger.mjs
  7322. var ShimReferenceTagger = class {
  7323. suffixes;
  7324. tagged = /* @__PURE__ */ new Set();
  7325. enabled = true;
  7326. constructor(shimExtensions) {
  7327. this.suffixes = shimExtensions.map((extension) => `.${extension}.ts`);
  7328. }
  7329. tag(sf) {
  7330. if (!this.enabled || sf.isDeclarationFile || isShim(sf) || this.tagged.has(sf) || !isNonDeclarationTsPath(sf.fileName)) {
  7331. return;
  7332. }
  7333. const ext = sfExtensionData(sf);
  7334. if (ext.originalReferencedFiles === null) {
  7335. ext.originalReferencedFiles = sf.referencedFiles;
  7336. }
  7337. const referencedFiles = [...ext.originalReferencedFiles];
  7338. const sfPath = absoluteFromSourceFile(sf);
  7339. for (const suffix of this.suffixes) {
  7340. referencedFiles.push({
  7341. fileName: makeShimFileName(sfPath, suffix),
  7342. pos: 0,
  7343. end: 0
  7344. });
  7345. }
  7346. ext.taggedReferenceFiles = referencedFiles;
  7347. sf.referencedFiles = referencedFiles;
  7348. this.tagged.add(sf);
  7349. }
  7350. finalize() {
  7351. this.enabled = false;
  7352. this.tagged.clear();
  7353. }
  7354. };
  7355. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/program_driver/src/ts_create_program_driver.mjs
  7356. var DelegatingCompilerHost = class {
  7357. delegate;
  7358. createHash;
  7359. directoryExists;
  7360. getCancellationToken;
  7361. getCanonicalFileName;
  7362. getCurrentDirectory;
  7363. getDefaultLibFileName;
  7364. getDefaultLibLocation;
  7365. getDirectories;
  7366. getEnvironmentVariable;
  7367. getNewLine;
  7368. getParsedCommandLine;
  7369. getSourceFileByPath;
  7370. readDirectory;
  7371. readFile;
  7372. realpath;
  7373. resolveModuleNames;
  7374. resolveTypeReferenceDirectives;
  7375. trace;
  7376. useCaseSensitiveFileNames;
  7377. getModuleResolutionCache;
  7378. hasInvalidatedResolutions;
  7379. resolveModuleNameLiterals;
  7380. resolveTypeReferenceDirectiveReferences;
  7381. get jsDocParsingMode() {
  7382. return this.delegate.jsDocParsingMode;
  7383. }
  7384. set jsDocParsingMode(mode) {
  7385. this.delegate.jsDocParsingMode = mode;
  7386. }
  7387. constructor(delegate) {
  7388. this.delegate = delegate;
  7389. this.createHash = this.delegateMethod("createHash");
  7390. this.directoryExists = this.delegateMethod("directoryExists");
  7391. this.getCancellationToken = this.delegateMethod("getCancellationToken");
  7392. this.getCanonicalFileName = this.delegateMethod("getCanonicalFileName");
  7393. this.getCurrentDirectory = this.delegateMethod("getCurrentDirectory");
  7394. this.getDefaultLibFileName = this.delegateMethod("getDefaultLibFileName");
  7395. this.getDefaultLibLocation = this.delegateMethod("getDefaultLibLocation");
  7396. this.getDirectories = this.delegateMethod("getDirectories");
  7397. this.getEnvironmentVariable = this.delegateMethod("getEnvironmentVariable");
  7398. this.getNewLine = this.delegateMethod("getNewLine");
  7399. this.getParsedCommandLine = this.delegateMethod("getParsedCommandLine");
  7400. this.getSourceFileByPath = this.delegateMethod("getSourceFileByPath");
  7401. this.readDirectory = this.delegateMethod("readDirectory");
  7402. this.readFile = this.delegateMethod("readFile");
  7403. this.realpath = this.delegateMethod("realpath");
  7404. this.resolveModuleNames = this.delegateMethod("resolveModuleNames");
  7405. this.resolveTypeReferenceDirectives = this.delegateMethod("resolveTypeReferenceDirectives");
  7406. this.trace = this.delegateMethod("trace");
  7407. this.useCaseSensitiveFileNames = this.delegateMethod("useCaseSensitiveFileNames");
  7408. this.getModuleResolutionCache = this.delegateMethod("getModuleResolutionCache");
  7409. this.hasInvalidatedResolutions = this.delegateMethod("hasInvalidatedResolutions");
  7410. this.resolveModuleNameLiterals = this.delegateMethod("resolveModuleNameLiterals");
  7411. this.resolveTypeReferenceDirectiveReferences = this.delegateMethod("resolveTypeReferenceDirectiveReferences");
  7412. }
  7413. delegateMethod(name) {
  7414. return this.delegate[name] !== void 0 ? this.delegate[name].bind(this.delegate) : void 0;
  7415. }
  7416. };
  7417. var UpdatedProgramHost = class extends DelegatingCompilerHost {
  7418. originalProgram;
  7419. shimExtensionPrefixes;
  7420. sfMap;
  7421. shimTagger;
  7422. constructor(sfMap, originalProgram, delegate, shimExtensionPrefixes) {
  7423. super(delegate);
  7424. this.originalProgram = originalProgram;
  7425. this.shimExtensionPrefixes = shimExtensionPrefixes;
  7426. this.shimTagger = new ShimReferenceTagger(this.shimExtensionPrefixes);
  7427. this.sfMap = sfMap;
  7428. }
  7429. getSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) {
  7430. let delegateSf = this.originalProgram.getSourceFile(fileName);
  7431. if (delegateSf === void 0) {
  7432. delegateSf = this.delegate.getSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile);
  7433. }
  7434. if (delegateSf === void 0) {
  7435. return void 0;
  7436. }
  7437. let sf;
  7438. if (this.sfMap.has(fileName)) {
  7439. sf = this.sfMap.get(fileName);
  7440. copyFileShimData(delegateSf, sf);
  7441. } else {
  7442. sf = delegateSf;
  7443. }
  7444. sf = toUnredirectedSourceFile(sf);
  7445. this.shimTagger.tag(sf);
  7446. return sf;
  7447. }
  7448. postProgramCreationCleanup() {
  7449. this.shimTagger.finalize();
  7450. }
  7451. writeFile() {
  7452. throw new Error(`TypeCheckProgramHost should never write files`);
  7453. }
  7454. fileExists(fileName) {
  7455. return this.sfMap.has(fileName) || this.delegate.fileExists(fileName);
  7456. }
  7457. };
  7458. var TsCreateProgramDriver = class {
  7459. originalProgram;
  7460. originalHost;
  7461. options;
  7462. shimExtensionPrefixes;
  7463. sfMap = /* @__PURE__ */ new Map();
  7464. program;
  7465. constructor(originalProgram, originalHost, options, shimExtensionPrefixes) {
  7466. this.originalProgram = originalProgram;
  7467. this.originalHost = originalHost;
  7468. this.options = options;
  7469. this.shimExtensionPrefixes = shimExtensionPrefixes;
  7470. this.program = this.originalProgram;
  7471. }
  7472. supportsInlineOperations = true;
  7473. getProgram() {
  7474. return this.program;
  7475. }
  7476. updateFiles(contents, updateMode) {
  7477. if (contents.size === 0) {
  7478. if (updateMode !== UpdateMode.Complete || this.sfMap.size === 0) {
  7479. return;
  7480. }
  7481. }
  7482. if (updateMode === UpdateMode.Complete) {
  7483. this.sfMap.clear();
  7484. }
  7485. for (const [filePath, { newText, originalFile }] of contents.entries()) {
  7486. const sf = ts28.createSourceFile(filePath, newText, ts28.ScriptTarget.Latest, true);
  7487. if (originalFile !== null) {
  7488. sf[NgOriginalFile] = originalFile;
  7489. }
  7490. this.sfMap.set(filePath, sf);
  7491. }
  7492. const host = new UpdatedProgramHost(this.sfMap, this.originalProgram, this.originalHost, this.shimExtensionPrefixes);
  7493. const oldProgram = this.program;
  7494. retagAllTsFiles(oldProgram);
  7495. this.program = ts28.createProgram({
  7496. host,
  7497. rootNames: this.program.getRootFileNames(),
  7498. options: this.options,
  7499. oldProgram
  7500. });
  7501. host.postProgramCreationCleanup();
  7502. untagAllTsFiles(oldProgram);
  7503. }
  7504. };
  7505. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/diagnostics/src/diagnostic.mjs
  7506. import ts29 from "typescript";
  7507. function makeTemplateDiagnostic(id, mapping, span, category, code, messageText, relatedMessages) {
  7508. var _a;
  7509. if (mapping.type === "direct") {
  7510. let relatedInformation = void 0;
  7511. if (relatedMessages !== void 0) {
  7512. relatedInformation = [];
  7513. for (const relatedMessage of relatedMessages) {
  7514. relatedInformation.push({
  7515. category: ts29.DiagnosticCategory.Message,
  7516. code: 0,
  7517. file: relatedMessage.sourceFile,
  7518. start: relatedMessage.start,
  7519. length: relatedMessage.end - relatedMessage.start,
  7520. messageText: relatedMessage.text
  7521. });
  7522. }
  7523. }
  7524. return {
  7525. source: "ngtsc",
  7526. code,
  7527. category,
  7528. messageText,
  7529. file: mapping.node.getSourceFile(),
  7530. sourceFile: mapping.node.getSourceFile(),
  7531. typeCheckId: id,
  7532. start: span.start.offset,
  7533. length: span.end.offset - span.start.offset,
  7534. relatedInformation
  7535. };
  7536. } else if (mapping.type === "indirect" || mapping.type === "external") {
  7537. const componentSf = mapping.componentClass.getSourceFile();
  7538. const componentName = mapping.componentClass.name.text;
  7539. const fileName = mapping.type === "indirect" ? `${componentSf.fileName} (${componentName} template)` : mapping.templateUrl;
  7540. let relatedInformation = [];
  7541. if (relatedMessages !== void 0) {
  7542. for (const relatedMessage of relatedMessages) {
  7543. relatedInformation.push({
  7544. category: ts29.DiagnosticCategory.Message,
  7545. code: 0,
  7546. file: relatedMessage.sourceFile,
  7547. start: relatedMessage.start,
  7548. length: relatedMessage.end - relatedMessage.start,
  7549. messageText: relatedMessage.text
  7550. });
  7551. }
  7552. }
  7553. let sf;
  7554. try {
  7555. sf = getParsedTemplateSourceFile(fileName, mapping);
  7556. } catch (e) {
  7557. const failureChain = makeDiagnosticChain(`Failed to report an error in '${fileName}' at ${span.start.line + 1}:${span.start.col + 1}`, [makeDiagnosticChain((_a = e == null ? void 0 : e.stack) != null ? _a : `${e}`)]);
  7558. return {
  7559. source: "ngtsc",
  7560. category,
  7561. code,
  7562. messageText: addDiagnosticChain(messageText, [failureChain]),
  7563. file: componentSf,
  7564. sourceFile: componentSf,
  7565. typeCheckId: id,
  7566. start: mapping.node.getStart(),
  7567. length: mapping.node.getEnd() - mapping.node.getStart(),
  7568. relatedInformation
  7569. };
  7570. }
  7571. relatedInformation.push({
  7572. category: ts29.DiagnosticCategory.Message,
  7573. code: 0,
  7574. file: componentSf,
  7575. start: mapping.node.getStart(),
  7576. length: mapping.node.getEnd() - mapping.node.getStart(),
  7577. messageText: `Error occurs in the template of component ${componentName}.`
  7578. });
  7579. return {
  7580. source: "ngtsc",
  7581. category,
  7582. code,
  7583. messageText,
  7584. file: sf,
  7585. sourceFile: componentSf,
  7586. typeCheckId: id,
  7587. start: span.start.offset,
  7588. length: span.end.offset - span.start.offset,
  7589. relatedInformation
  7590. };
  7591. } else {
  7592. throw new Error(`Unexpected source mapping type: ${mapping.type}`);
  7593. }
  7594. }
  7595. var TemplateSourceFile = Symbol("TemplateSourceFile");
  7596. function getParsedTemplateSourceFile(fileName, mapping) {
  7597. if (mapping[TemplateSourceFile] === void 0) {
  7598. mapping[TemplateSourceFile] = parseTemplateAsSourceFile(fileName, mapping.template);
  7599. }
  7600. return mapping[TemplateSourceFile];
  7601. }
  7602. var parseTemplateAsSourceFileForTest = null;
  7603. function parseTemplateAsSourceFile(fileName, template) {
  7604. if (parseTemplateAsSourceFileForTest !== null) {
  7605. return parseTemplateAsSourceFileForTest(fileName, template);
  7606. }
  7607. return ts29.createSourceFile(
  7608. fileName,
  7609. template,
  7610. ts29.ScriptTarget.Latest,
  7611. false,
  7612. ts29.ScriptKind.JSX
  7613. );
  7614. }
  7615. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/diagnostics/src/id.mjs
  7616. var TYPE_CHECK_ID_MAP = Symbol("TypeCheckId");
  7617. function getTypeCheckId(clazz) {
  7618. const sf = clazz.getSourceFile();
  7619. if (sf[TYPE_CHECK_ID_MAP] === void 0) {
  7620. sf[TYPE_CHECK_ID_MAP] = /* @__PURE__ */ new Map();
  7621. }
  7622. if (sf[TYPE_CHECK_ID_MAP].get(clazz) === void 0) {
  7623. sf[TYPE_CHECK_ID_MAP].set(clazz, `tcb${sf[TYPE_CHECK_ID_MAP].size + 1}`);
  7624. }
  7625. return sf[TYPE_CHECK_ID_MAP].get(clazz);
  7626. }
  7627. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/completion.mjs
  7628. import { EmptyExpr, ImplicitReceiver, PropertyRead, PropertyWrite, SafePropertyRead, TmplAstLetDeclaration, TmplAstReference, TmplAstTextAttribute } from "@angular/compiler";
  7629. import ts31 from "typescript";
  7630. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/comments.mjs
  7631. import { AbsoluteSourceSpan } from "@angular/compiler";
  7632. import ts30 from "typescript";
  7633. var parseSpanComment = /^(\d+),(\d+)$/;
  7634. function readSpanComment(node, sourceFile = node.getSourceFile()) {
  7635. return ts30.forEachTrailingCommentRange(sourceFile.text, node.getEnd(), (pos, end, kind) => {
  7636. if (kind !== ts30.SyntaxKind.MultiLineCommentTrivia) {
  7637. return null;
  7638. }
  7639. const commentText = sourceFile.text.substring(pos + 2, end - 2);
  7640. const match = commentText.match(parseSpanComment);
  7641. if (match === null) {
  7642. return null;
  7643. }
  7644. return new AbsoluteSourceSpan(+match[1], +match[2]);
  7645. }) || null;
  7646. }
  7647. var CommentTriviaType;
  7648. (function(CommentTriviaType2) {
  7649. CommentTriviaType2["DIAGNOSTIC"] = "D";
  7650. CommentTriviaType2["EXPRESSION_TYPE_IDENTIFIER"] = "T";
  7651. })(CommentTriviaType || (CommentTriviaType = {}));
  7652. var ExpressionIdentifier;
  7653. (function(ExpressionIdentifier2) {
  7654. ExpressionIdentifier2["DIRECTIVE"] = "DIR";
  7655. ExpressionIdentifier2["COMPONENT_COMPLETION"] = "COMPCOMP";
  7656. ExpressionIdentifier2["EVENT_PARAMETER"] = "EP";
  7657. ExpressionIdentifier2["VARIABLE_AS_EXPRESSION"] = "VAE";
  7658. })(ExpressionIdentifier || (ExpressionIdentifier = {}));
  7659. function addExpressionIdentifier(node, identifier) {
  7660. ts30.addSyntheticTrailingComment(
  7661. node,
  7662. ts30.SyntaxKind.MultiLineCommentTrivia,
  7663. `${CommentTriviaType.EXPRESSION_TYPE_IDENTIFIER}:${identifier}`,
  7664. false
  7665. );
  7666. }
  7667. var IGNORE_FOR_DIAGNOSTICS_MARKER = `${CommentTriviaType.DIAGNOSTIC}:ignore`;
  7668. function markIgnoreDiagnostics(node) {
  7669. ts30.addSyntheticTrailingComment(
  7670. node,
  7671. ts30.SyntaxKind.MultiLineCommentTrivia,
  7672. IGNORE_FOR_DIAGNOSTICS_MARKER,
  7673. false
  7674. );
  7675. }
  7676. function hasIgnoreForDiagnosticsMarker(node, sourceFile) {
  7677. return ts30.forEachTrailingCommentRange(sourceFile.text, node.getEnd(), (pos, end, kind) => {
  7678. if (kind !== ts30.SyntaxKind.MultiLineCommentTrivia) {
  7679. return null;
  7680. }
  7681. const commentText = sourceFile.text.substring(pos + 2, end - 2);
  7682. return commentText === IGNORE_FOR_DIAGNOSTICS_MARKER;
  7683. }) === true;
  7684. }
  7685. function makeRecursiveVisitor(visitor) {
  7686. function recursiveVisitor(node) {
  7687. const res = visitor(node);
  7688. return res !== null ? res : node.forEachChild(recursiveVisitor);
  7689. }
  7690. return recursiveVisitor;
  7691. }
  7692. function getSpanFromOptions(opts) {
  7693. let withSpan = null;
  7694. if (opts.withSpan !== void 0) {
  7695. if (opts.withSpan instanceof AbsoluteSourceSpan) {
  7696. withSpan = opts.withSpan;
  7697. } else {
  7698. withSpan = { start: opts.withSpan.start.offset, end: opts.withSpan.end.offset };
  7699. }
  7700. }
  7701. return withSpan;
  7702. }
  7703. function findFirstMatchingNode(tcb, opts) {
  7704. var _a;
  7705. const withSpan = getSpanFromOptions(opts);
  7706. const withExpressionIdentifier = opts.withExpressionIdentifier;
  7707. const sf = tcb.getSourceFile();
  7708. const visitor = makeRecursiveVisitor((node) => {
  7709. if (!opts.filter(node)) {
  7710. return null;
  7711. }
  7712. if (withSpan !== null) {
  7713. const comment = readSpanComment(node, sf);
  7714. if (comment === null || withSpan.start !== comment.start || withSpan.end !== comment.end) {
  7715. return null;
  7716. }
  7717. }
  7718. if (withExpressionIdentifier !== void 0 && !hasExpressionIdentifier(sf, node, withExpressionIdentifier)) {
  7719. return null;
  7720. }
  7721. return node;
  7722. });
  7723. return (_a = tcb.forEachChild(visitor)) != null ? _a : null;
  7724. }
  7725. function findAllMatchingNodes(tcb, opts) {
  7726. const withSpan = getSpanFromOptions(opts);
  7727. const withExpressionIdentifier = opts.withExpressionIdentifier;
  7728. const results = [];
  7729. const stack = [tcb];
  7730. const sf = tcb.getSourceFile();
  7731. while (stack.length > 0) {
  7732. const node = stack.pop();
  7733. if (!opts.filter(node)) {
  7734. stack.push(...node.getChildren());
  7735. continue;
  7736. }
  7737. if (withSpan !== null) {
  7738. const comment = readSpanComment(node, sf);
  7739. if (comment === null || withSpan.start !== comment.start || withSpan.end !== comment.end) {
  7740. stack.push(...node.getChildren());
  7741. continue;
  7742. }
  7743. }
  7744. if (withExpressionIdentifier !== void 0 && !hasExpressionIdentifier(sf, node, withExpressionIdentifier)) {
  7745. continue;
  7746. }
  7747. results.push(node);
  7748. }
  7749. return results;
  7750. }
  7751. function hasExpressionIdentifier(sourceFile, node, identifier) {
  7752. return ts30.forEachTrailingCommentRange(sourceFile.text, node.getEnd(), (pos, end, kind) => {
  7753. if (kind !== ts30.SyntaxKind.MultiLineCommentTrivia) {
  7754. return false;
  7755. }
  7756. const commentText = sourceFile.text.substring(pos + 2, end - 2);
  7757. return commentText === `${CommentTriviaType.EXPRESSION_TYPE_IDENTIFIER}:${identifier}`;
  7758. }) || false;
  7759. }
  7760. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/completion.mjs
  7761. var CompletionEngine = class {
  7762. tcb;
  7763. data;
  7764. tcbPath;
  7765. tcbIsShim;
  7766. componentContext;
  7767. templateContextCache = /* @__PURE__ */ new Map();
  7768. expressionCompletionCache = /* @__PURE__ */ new Map();
  7769. constructor(tcb, data, tcbPath, tcbIsShim) {
  7770. this.tcb = tcb;
  7771. this.data = data;
  7772. this.tcbPath = tcbPath;
  7773. this.tcbIsShim = tcbIsShim;
  7774. const globalRead = findFirstMatchingNode(this.tcb, {
  7775. filter: ts31.isPropertyAccessExpression,
  7776. withExpressionIdentifier: ExpressionIdentifier.COMPONENT_COMPLETION
  7777. });
  7778. if (globalRead !== null) {
  7779. this.componentContext = {
  7780. tcbPath: this.tcbPath,
  7781. isShimFile: this.tcbIsShim,
  7782. positionInFile: globalRead.name.getStart()
  7783. };
  7784. } else {
  7785. this.componentContext = null;
  7786. }
  7787. }
  7788. getGlobalCompletions(context, node) {
  7789. if (this.componentContext === null) {
  7790. return null;
  7791. }
  7792. const templateContext = this.getTemplateContextCompletions(context);
  7793. if (templateContext === null) {
  7794. return null;
  7795. }
  7796. let nodeContext = null;
  7797. if (node instanceof EmptyExpr) {
  7798. const nodeLocation = findFirstMatchingNode(this.tcb, {
  7799. filter: ts31.isIdentifier,
  7800. withSpan: node.sourceSpan
  7801. });
  7802. if (nodeLocation !== null) {
  7803. nodeContext = {
  7804. tcbPath: this.tcbPath,
  7805. isShimFile: this.tcbIsShim,
  7806. positionInFile: nodeLocation.getStart()
  7807. };
  7808. }
  7809. }
  7810. if (node instanceof PropertyRead && node.receiver instanceof ImplicitReceiver) {
  7811. const nodeLocation = findFirstMatchingNode(this.tcb, {
  7812. filter: ts31.isPropertyAccessExpression,
  7813. withSpan: node.sourceSpan
  7814. });
  7815. if (nodeLocation) {
  7816. nodeContext = {
  7817. tcbPath: this.tcbPath,
  7818. isShimFile: this.tcbIsShim,
  7819. positionInFile: nodeLocation.getStart()
  7820. };
  7821. }
  7822. }
  7823. return {
  7824. componentContext: this.componentContext,
  7825. templateContext,
  7826. nodeContext
  7827. };
  7828. }
  7829. getExpressionCompletionLocation(expr) {
  7830. if (this.expressionCompletionCache.has(expr)) {
  7831. return this.expressionCompletionCache.get(expr);
  7832. }
  7833. let tsExpr = null;
  7834. if (expr instanceof PropertyRead || expr instanceof PropertyWrite) {
  7835. tsExpr = findFirstMatchingNode(this.tcb, {
  7836. filter: ts31.isPropertyAccessExpression,
  7837. withSpan: expr.nameSpan
  7838. });
  7839. } else if (expr instanceof SafePropertyRead) {
  7840. const ternaryExpr = findFirstMatchingNode(this.tcb, {
  7841. filter: ts31.isParenthesizedExpression,
  7842. withSpan: expr.sourceSpan
  7843. });
  7844. if (ternaryExpr === null || !ts31.isConditionalExpression(ternaryExpr.expression)) {
  7845. return null;
  7846. }
  7847. const whenTrue = ternaryExpr.expression.whenTrue;
  7848. if (ts31.isPropertyAccessExpression(whenTrue)) {
  7849. tsExpr = whenTrue;
  7850. } else if (ts31.isCallExpression(whenTrue) && ts31.isPropertyAccessExpression(whenTrue.expression)) {
  7851. tsExpr = whenTrue.expression;
  7852. }
  7853. }
  7854. if (tsExpr === null) {
  7855. return null;
  7856. }
  7857. const res = {
  7858. tcbPath: this.tcbPath,
  7859. isShimFile: this.tcbIsShim,
  7860. positionInFile: tsExpr.name.getEnd()
  7861. };
  7862. this.expressionCompletionCache.set(expr, res);
  7863. return res;
  7864. }
  7865. getLiteralCompletionLocation(expr) {
  7866. if (this.expressionCompletionCache.has(expr)) {
  7867. return this.expressionCompletionCache.get(expr);
  7868. }
  7869. let tsExpr = null;
  7870. if (expr instanceof TmplAstTextAttribute) {
  7871. const strNode = findFirstMatchingNode(this.tcb, {
  7872. filter: ts31.isParenthesizedExpression,
  7873. withSpan: expr.sourceSpan
  7874. });
  7875. if (strNode !== null && ts31.isStringLiteral(strNode.expression)) {
  7876. tsExpr = strNode.expression;
  7877. }
  7878. } else {
  7879. tsExpr = findFirstMatchingNode(this.tcb, {
  7880. filter: (n2) => ts31.isStringLiteral(n2) || ts31.isNumericLiteral(n2),
  7881. withSpan: expr.sourceSpan
  7882. });
  7883. }
  7884. if (tsExpr === null) {
  7885. return null;
  7886. }
  7887. let positionInShimFile = tsExpr.getEnd();
  7888. if (ts31.isStringLiteral(tsExpr)) {
  7889. positionInShimFile -= 1;
  7890. }
  7891. const res = {
  7892. tcbPath: this.tcbPath,
  7893. isShimFile: this.tcbIsShim,
  7894. positionInFile: positionInShimFile
  7895. };
  7896. this.expressionCompletionCache.set(expr, res);
  7897. return res;
  7898. }
  7899. getTemplateContextCompletions(context) {
  7900. if (this.templateContextCache.has(context)) {
  7901. return this.templateContextCache.get(context);
  7902. }
  7903. const templateContext = /* @__PURE__ */ new Map();
  7904. for (const node of this.data.boundTarget.getEntitiesInScope(context)) {
  7905. if (node instanceof TmplAstReference) {
  7906. templateContext.set(node.name, {
  7907. kind: CompletionKind.Reference,
  7908. node
  7909. });
  7910. } else if (node instanceof TmplAstLetDeclaration) {
  7911. templateContext.set(node.name, {
  7912. kind: CompletionKind.LetDeclaration,
  7913. node
  7914. });
  7915. } else {
  7916. templateContext.set(node.name, {
  7917. kind: CompletionKind.Variable,
  7918. node
  7919. });
  7920. }
  7921. }
  7922. this.templateContextCache.set(context, templateContext);
  7923. return templateContext;
  7924. }
  7925. };
  7926. // node_modules/magic-string/dist/magic-string.es.mjs
  7927. import { encode } from "@jridgewell/sourcemap-codec";
  7928. var BitSet = class {
  7929. constructor(arg) {
  7930. this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
  7931. }
  7932. add(n2) {
  7933. this.bits[n2 >> 5] |= 1 << (n2 & 31);
  7934. }
  7935. has(n2) {
  7936. return !!(this.bits[n2 >> 5] & 1 << (n2 & 31));
  7937. }
  7938. };
  7939. var Chunk = class {
  7940. constructor(start, end, content) {
  7941. this.start = start;
  7942. this.end = end;
  7943. this.original = content;
  7944. this.intro = "";
  7945. this.outro = "";
  7946. this.content = content;
  7947. this.storeName = false;
  7948. this.edited = false;
  7949. {
  7950. this.previous = null;
  7951. this.next = null;
  7952. }
  7953. }
  7954. appendLeft(content) {
  7955. this.outro += content;
  7956. }
  7957. appendRight(content) {
  7958. this.intro = this.intro + content;
  7959. }
  7960. clone() {
  7961. const chunk = new Chunk(this.start, this.end, this.original);
  7962. chunk.intro = this.intro;
  7963. chunk.outro = this.outro;
  7964. chunk.content = this.content;
  7965. chunk.storeName = this.storeName;
  7966. chunk.edited = this.edited;
  7967. return chunk;
  7968. }
  7969. contains(index) {
  7970. return this.start < index && index < this.end;
  7971. }
  7972. eachNext(fn) {
  7973. let chunk = this;
  7974. while (chunk) {
  7975. fn(chunk);
  7976. chunk = chunk.next;
  7977. }
  7978. }
  7979. eachPrevious(fn) {
  7980. let chunk = this;
  7981. while (chunk) {
  7982. fn(chunk);
  7983. chunk = chunk.previous;
  7984. }
  7985. }
  7986. edit(content, storeName, contentOnly) {
  7987. this.content = content;
  7988. if (!contentOnly) {
  7989. this.intro = "";
  7990. this.outro = "";
  7991. }
  7992. this.storeName = storeName;
  7993. this.edited = true;
  7994. return this;
  7995. }
  7996. prependLeft(content) {
  7997. this.outro = content + this.outro;
  7998. }
  7999. prependRight(content) {
  8000. this.intro = content + this.intro;
  8001. }
  8002. reset() {
  8003. this.intro = "";
  8004. this.outro = "";
  8005. if (this.edited) {
  8006. this.content = this.original;
  8007. this.storeName = false;
  8008. this.edited = false;
  8009. }
  8010. }
  8011. split(index) {
  8012. const sliceIndex = index - this.start;
  8013. const originalBefore = this.original.slice(0, sliceIndex);
  8014. const originalAfter = this.original.slice(sliceIndex);
  8015. this.original = originalBefore;
  8016. const newChunk = new Chunk(index, this.end, originalAfter);
  8017. newChunk.outro = this.outro;
  8018. this.outro = "";
  8019. this.end = index;
  8020. if (this.edited) {
  8021. newChunk.edit("", false);
  8022. this.content = "";
  8023. } else {
  8024. this.content = originalBefore;
  8025. }
  8026. newChunk.next = this.next;
  8027. if (newChunk.next)
  8028. newChunk.next.previous = newChunk;
  8029. newChunk.previous = this;
  8030. this.next = newChunk;
  8031. return newChunk;
  8032. }
  8033. toString() {
  8034. return this.intro + this.content + this.outro;
  8035. }
  8036. trimEnd(rx) {
  8037. this.outro = this.outro.replace(rx, "");
  8038. if (this.outro.length)
  8039. return true;
  8040. const trimmed = this.content.replace(rx, "");
  8041. if (trimmed.length) {
  8042. if (trimmed !== this.content) {
  8043. this.split(this.start + trimmed.length).edit("", void 0, true);
  8044. if (this.edited) {
  8045. this.edit(trimmed, this.storeName, true);
  8046. }
  8047. }
  8048. return true;
  8049. } else {
  8050. this.edit("", void 0, true);
  8051. this.intro = this.intro.replace(rx, "");
  8052. if (this.intro.length)
  8053. return true;
  8054. }
  8055. }
  8056. trimStart(rx) {
  8057. this.intro = this.intro.replace(rx, "");
  8058. if (this.intro.length)
  8059. return true;
  8060. const trimmed = this.content.replace(rx, "");
  8061. if (trimmed.length) {
  8062. if (trimmed !== this.content) {
  8063. const newChunk = this.split(this.end - trimmed.length);
  8064. if (this.edited) {
  8065. newChunk.edit(trimmed, this.storeName, true);
  8066. }
  8067. this.edit("", void 0, true);
  8068. }
  8069. return true;
  8070. } else {
  8071. this.edit("", void 0, true);
  8072. this.outro = this.outro.replace(rx, "");
  8073. if (this.outro.length)
  8074. return true;
  8075. }
  8076. }
  8077. };
  8078. function getBtoa() {
  8079. if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") {
  8080. return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
  8081. } else if (typeof Buffer === "function") {
  8082. return (str) => Buffer.from(str, "utf-8").toString("base64");
  8083. } else {
  8084. return () => {
  8085. throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.");
  8086. };
  8087. }
  8088. }
  8089. var btoa = /* @__PURE__ */ getBtoa();
  8090. var SourceMap = class {
  8091. constructor(properties) {
  8092. this.version = 3;
  8093. this.file = properties.file;
  8094. this.sources = properties.sources;
  8095. this.sourcesContent = properties.sourcesContent;
  8096. this.names = properties.names;
  8097. this.mappings = encode(properties.mappings);
  8098. if (typeof properties.x_google_ignoreList !== "undefined") {
  8099. this.x_google_ignoreList = properties.x_google_ignoreList;
  8100. }
  8101. if (typeof properties.debugId !== "undefined") {
  8102. this.debugId = properties.debugId;
  8103. }
  8104. }
  8105. toString() {
  8106. return JSON.stringify(this);
  8107. }
  8108. toUrl() {
  8109. return "data:application/json;charset=utf-8;base64," + btoa(this.toString());
  8110. }
  8111. };
  8112. function guessIndent(code) {
  8113. const lines = code.split("\n");
  8114. const tabbed = lines.filter((line) => /^\t+/.test(line));
  8115. const spaced = lines.filter((line) => /^ {2,}/.test(line));
  8116. if (tabbed.length === 0 && spaced.length === 0) {
  8117. return null;
  8118. }
  8119. if (tabbed.length >= spaced.length) {
  8120. return " ";
  8121. }
  8122. const min = spaced.reduce((previous, current) => {
  8123. const numSpaces = /^ +/.exec(current)[0].length;
  8124. return Math.min(numSpaces, previous);
  8125. }, Infinity);
  8126. return new Array(min + 1).join(" ");
  8127. }
  8128. function getRelativePath(from, to) {
  8129. const fromParts = from.split(/[/\\]/);
  8130. const toParts = to.split(/[/\\]/);
  8131. fromParts.pop();
  8132. while (fromParts[0] === toParts[0]) {
  8133. fromParts.shift();
  8134. toParts.shift();
  8135. }
  8136. if (fromParts.length) {
  8137. let i = fromParts.length;
  8138. while (i--)
  8139. fromParts[i] = "..";
  8140. }
  8141. return fromParts.concat(toParts).join("/");
  8142. }
  8143. var toString = Object.prototype.toString;
  8144. function isObject(thing) {
  8145. return toString.call(thing) === "[object Object]";
  8146. }
  8147. function getLocator(source) {
  8148. const originalLines = source.split("\n");
  8149. const lineOffsets = [];
  8150. for (let i = 0, pos = 0; i < originalLines.length; i++) {
  8151. lineOffsets.push(pos);
  8152. pos += originalLines[i].length + 1;
  8153. }
  8154. return function locate(index) {
  8155. let i = 0;
  8156. let j = lineOffsets.length;
  8157. while (i < j) {
  8158. const m = i + j >> 1;
  8159. if (index < lineOffsets[m]) {
  8160. j = m;
  8161. } else {
  8162. i = m + 1;
  8163. }
  8164. }
  8165. const line = i - 1;
  8166. const column = index - lineOffsets[line];
  8167. return { line, column };
  8168. };
  8169. }
  8170. var wordRegex = /\w/;
  8171. var Mappings = class {
  8172. constructor(hires) {
  8173. this.hires = hires;
  8174. this.generatedCodeLine = 0;
  8175. this.generatedCodeColumn = 0;
  8176. this.raw = [];
  8177. this.rawSegments = this.raw[this.generatedCodeLine] = [];
  8178. this.pending = null;
  8179. }
  8180. addEdit(sourceIndex, content, loc, nameIndex) {
  8181. if (content.length) {
  8182. const contentLengthMinusOne = content.length - 1;
  8183. let contentLineEnd = content.indexOf("\n", 0);
  8184. let previousContentLineEnd = -1;
  8185. while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
  8186. const segment2 = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  8187. if (nameIndex >= 0) {
  8188. segment2.push(nameIndex);
  8189. }
  8190. this.rawSegments.push(segment2);
  8191. this.generatedCodeLine += 1;
  8192. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  8193. this.generatedCodeColumn = 0;
  8194. previousContentLineEnd = contentLineEnd;
  8195. contentLineEnd = content.indexOf("\n", contentLineEnd + 1);
  8196. }
  8197. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  8198. if (nameIndex >= 0) {
  8199. segment.push(nameIndex);
  8200. }
  8201. this.rawSegments.push(segment);
  8202. this.advance(content.slice(previousContentLineEnd + 1));
  8203. } else if (this.pending) {
  8204. this.rawSegments.push(this.pending);
  8205. this.advance(content);
  8206. }
  8207. this.pending = null;
  8208. }
  8209. addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
  8210. let originalCharIndex = chunk.start;
  8211. let first = true;
  8212. let charInHiresBoundary = false;
  8213. while (originalCharIndex < chunk.end) {
  8214. if (original[originalCharIndex] === "\n") {
  8215. loc.line += 1;
  8216. loc.column = 0;
  8217. this.generatedCodeLine += 1;
  8218. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  8219. this.generatedCodeColumn = 0;
  8220. first = true;
  8221. charInHiresBoundary = false;
  8222. } else {
  8223. if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
  8224. const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  8225. if (this.hires === "boundary") {
  8226. if (wordRegex.test(original[originalCharIndex])) {
  8227. if (!charInHiresBoundary) {
  8228. this.rawSegments.push(segment);
  8229. charInHiresBoundary = true;
  8230. }
  8231. } else {
  8232. this.rawSegments.push(segment);
  8233. charInHiresBoundary = false;
  8234. }
  8235. } else {
  8236. this.rawSegments.push(segment);
  8237. }
  8238. }
  8239. loc.column += 1;
  8240. this.generatedCodeColumn += 1;
  8241. first = false;
  8242. }
  8243. originalCharIndex += 1;
  8244. }
  8245. this.pending = null;
  8246. }
  8247. advance(str) {
  8248. if (!str)
  8249. return;
  8250. const lines = str.split("\n");
  8251. if (lines.length > 1) {
  8252. for (let i = 0; i < lines.length - 1; i++) {
  8253. this.generatedCodeLine++;
  8254. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  8255. }
  8256. this.generatedCodeColumn = 0;
  8257. }
  8258. this.generatedCodeColumn += lines[lines.length - 1].length;
  8259. }
  8260. };
  8261. var n = "\n";
  8262. var warned = {
  8263. insertLeft: false,
  8264. insertRight: false,
  8265. storeName: false
  8266. };
  8267. var MagicString = class {
  8268. constructor(string, options = {}) {
  8269. const chunk = new Chunk(0, string.length, string);
  8270. Object.defineProperties(this, {
  8271. original: { writable: true, value: string },
  8272. outro: { writable: true, value: "" },
  8273. intro: { writable: true, value: "" },
  8274. firstChunk: { writable: true, value: chunk },
  8275. lastChunk: { writable: true, value: chunk },
  8276. lastSearchedChunk: { writable: true, value: chunk },
  8277. byStart: { writable: true, value: {} },
  8278. byEnd: { writable: true, value: {} },
  8279. filename: { writable: true, value: options.filename },
  8280. indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
  8281. sourcemapLocations: { writable: true, value: new BitSet() },
  8282. storedNames: { writable: true, value: {} },
  8283. indentStr: { writable: true, value: void 0 },
  8284. ignoreList: { writable: true, value: options.ignoreList },
  8285. offset: { writable: true, value: options.offset || 0 }
  8286. });
  8287. this.byStart[0] = chunk;
  8288. this.byEnd[string.length] = chunk;
  8289. }
  8290. addSourcemapLocation(char) {
  8291. this.sourcemapLocations.add(char);
  8292. }
  8293. append(content) {
  8294. if (typeof content !== "string")
  8295. throw new TypeError("outro content must be a string");
  8296. this.outro += content;
  8297. return this;
  8298. }
  8299. appendLeft(index, content) {
  8300. index = index + this.offset;
  8301. if (typeof content !== "string")
  8302. throw new TypeError("inserted content must be a string");
  8303. this._split(index);
  8304. const chunk = this.byEnd[index];
  8305. if (chunk) {
  8306. chunk.appendLeft(content);
  8307. } else {
  8308. this.intro += content;
  8309. }
  8310. return this;
  8311. }
  8312. appendRight(index, content) {
  8313. index = index + this.offset;
  8314. if (typeof content !== "string")
  8315. throw new TypeError("inserted content must be a string");
  8316. this._split(index);
  8317. const chunk = this.byStart[index];
  8318. if (chunk) {
  8319. chunk.appendRight(content);
  8320. } else {
  8321. this.outro += content;
  8322. }
  8323. return this;
  8324. }
  8325. clone() {
  8326. const cloned = new MagicString(this.original, { filename: this.filename, offset: this.offset });
  8327. let originalChunk = this.firstChunk;
  8328. let clonedChunk = cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone();
  8329. while (originalChunk) {
  8330. cloned.byStart[clonedChunk.start] = clonedChunk;
  8331. cloned.byEnd[clonedChunk.end] = clonedChunk;
  8332. const nextOriginalChunk = originalChunk.next;
  8333. const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
  8334. if (nextClonedChunk) {
  8335. clonedChunk.next = nextClonedChunk;
  8336. nextClonedChunk.previous = clonedChunk;
  8337. clonedChunk = nextClonedChunk;
  8338. }
  8339. originalChunk = nextOriginalChunk;
  8340. }
  8341. cloned.lastChunk = clonedChunk;
  8342. if (this.indentExclusionRanges) {
  8343. cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
  8344. }
  8345. cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
  8346. cloned.intro = this.intro;
  8347. cloned.outro = this.outro;
  8348. return cloned;
  8349. }
  8350. generateDecodedMap(options) {
  8351. options = options || {};
  8352. const sourceIndex = 0;
  8353. const names = Object.keys(this.storedNames);
  8354. const mappings = new Mappings(options.hires);
  8355. const locate = getLocator(this.original);
  8356. if (this.intro) {
  8357. mappings.advance(this.intro);
  8358. }
  8359. this.firstChunk.eachNext((chunk) => {
  8360. const loc = locate(chunk.start);
  8361. if (chunk.intro.length)
  8362. mappings.advance(chunk.intro);
  8363. if (chunk.edited) {
  8364. mappings.addEdit(
  8365. sourceIndex,
  8366. chunk.content,
  8367. loc,
  8368. chunk.storeName ? names.indexOf(chunk.original) : -1
  8369. );
  8370. } else {
  8371. mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
  8372. }
  8373. if (chunk.outro.length)
  8374. mappings.advance(chunk.outro);
  8375. });
  8376. return {
  8377. file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
  8378. sources: [
  8379. options.source ? getRelativePath(options.file || "", options.source) : options.file || ""
  8380. ],
  8381. sourcesContent: options.includeContent ? [this.original] : void 0,
  8382. names,
  8383. mappings: mappings.raw,
  8384. x_google_ignoreList: this.ignoreList ? [sourceIndex] : void 0
  8385. };
  8386. }
  8387. generateMap(options) {
  8388. return new SourceMap(this.generateDecodedMap(options));
  8389. }
  8390. _ensureindentStr() {
  8391. if (this.indentStr === void 0) {
  8392. this.indentStr = guessIndent(this.original);
  8393. }
  8394. }
  8395. _getRawIndentString() {
  8396. this._ensureindentStr();
  8397. return this.indentStr;
  8398. }
  8399. getIndentString() {
  8400. this._ensureindentStr();
  8401. return this.indentStr === null ? " " : this.indentStr;
  8402. }
  8403. indent(indentStr, options) {
  8404. const pattern = /^[^\r\n]/gm;
  8405. if (isObject(indentStr)) {
  8406. options = indentStr;
  8407. indentStr = void 0;
  8408. }
  8409. if (indentStr === void 0) {
  8410. this._ensureindentStr();
  8411. indentStr = this.indentStr || " ";
  8412. }
  8413. if (indentStr === "")
  8414. return this;
  8415. options = options || {};
  8416. const isExcluded = {};
  8417. if (options.exclude) {
  8418. const exclusions = typeof options.exclude[0] === "number" ? [options.exclude] : options.exclude;
  8419. exclusions.forEach((exclusion) => {
  8420. for (let i = exclusion[0]; i < exclusion[1]; i += 1) {
  8421. isExcluded[i] = true;
  8422. }
  8423. });
  8424. }
  8425. let shouldIndentNextCharacter = options.indentStart !== false;
  8426. const replacer = (match) => {
  8427. if (shouldIndentNextCharacter)
  8428. return `${indentStr}${match}`;
  8429. shouldIndentNextCharacter = true;
  8430. return match;
  8431. };
  8432. this.intro = this.intro.replace(pattern, replacer);
  8433. let charIndex = 0;
  8434. let chunk = this.firstChunk;
  8435. while (chunk) {
  8436. const end = chunk.end;
  8437. if (chunk.edited) {
  8438. if (!isExcluded[charIndex]) {
  8439. chunk.content = chunk.content.replace(pattern, replacer);
  8440. if (chunk.content.length) {
  8441. shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === "\n";
  8442. }
  8443. }
  8444. } else {
  8445. charIndex = chunk.start;
  8446. while (charIndex < end) {
  8447. if (!isExcluded[charIndex]) {
  8448. const char = this.original[charIndex];
  8449. if (char === "\n") {
  8450. shouldIndentNextCharacter = true;
  8451. } else if (char !== "\r" && shouldIndentNextCharacter) {
  8452. shouldIndentNextCharacter = false;
  8453. if (charIndex === chunk.start) {
  8454. chunk.prependRight(indentStr);
  8455. } else {
  8456. this._splitChunk(chunk, charIndex);
  8457. chunk = chunk.next;
  8458. chunk.prependRight(indentStr);
  8459. }
  8460. }
  8461. }
  8462. charIndex += 1;
  8463. }
  8464. }
  8465. charIndex = chunk.end;
  8466. chunk = chunk.next;
  8467. }
  8468. this.outro = this.outro.replace(pattern, replacer);
  8469. return this;
  8470. }
  8471. insert() {
  8472. throw new Error(
  8473. "magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)"
  8474. );
  8475. }
  8476. insertLeft(index, content) {
  8477. if (!warned.insertLeft) {
  8478. console.warn(
  8479. "magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"
  8480. );
  8481. warned.insertLeft = true;
  8482. }
  8483. return this.appendLeft(index, content);
  8484. }
  8485. insertRight(index, content) {
  8486. if (!warned.insertRight) {
  8487. console.warn(
  8488. "magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"
  8489. );
  8490. warned.insertRight = true;
  8491. }
  8492. return this.prependRight(index, content);
  8493. }
  8494. move(start, end, index) {
  8495. start = start + this.offset;
  8496. end = end + this.offset;
  8497. index = index + this.offset;
  8498. if (index >= start && index <= end)
  8499. throw new Error("Cannot move a selection inside itself");
  8500. this._split(start);
  8501. this._split(end);
  8502. this._split(index);
  8503. const first = this.byStart[start];
  8504. const last = this.byEnd[end];
  8505. const oldLeft = first.previous;
  8506. const oldRight = last.next;
  8507. const newRight = this.byStart[index];
  8508. if (!newRight && last === this.lastChunk)
  8509. return this;
  8510. const newLeft = newRight ? newRight.previous : this.lastChunk;
  8511. if (oldLeft)
  8512. oldLeft.next = oldRight;
  8513. if (oldRight)
  8514. oldRight.previous = oldLeft;
  8515. if (newLeft)
  8516. newLeft.next = first;
  8517. if (newRight)
  8518. newRight.previous = last;
  8519. if (!first.previous)
  8520. this.firstChunk = last.next;
  8521. if (!last.next) {
  8522. this.lastChunk = first.previous;
  8523. this.lastChunk.next = null;
  8524. }
  8525. first.previous = newLeft;
  8526. last.next = newRight || null;
  8527. if (!newLeft)
  8528. this.firstChunk = first;
  8529. if (!newRight)
  8530. this.lastChunk = last;
  8531. return this;
  8532. }
  8533. overwrite(start, end, content, options) {
  8534. options = options || {};
  8535. return this.update(start, end, content, { ...options, overwrite: !options.contentOnly });
  8536. }
  8537. update(start, end, content, options) {
  8538. start = start + this.offset;
  8539. end = end + this.offset;
  8540. if (typeof content !== "string")
  8541. throw new TypeError("replacement content must be a string");
  8542. if (this.original.length !== 0) {
  8543. while (start < 0)
  8544. start += this.original.length;
  8545. while (end < 0)
  8546. end += this.original.length;
  8547. }
  8548. if (end > this.original.length)
  8549. throw new Error("end is out of bounds");
  8550. if (start === end)
  8551. throw new Error(
  8552. "Cannot overwrite a zero-length range \u2013 use appendLeft or prependRight instead"
  8553. );
  8554. this._split(start);
  8555. this._split(end);
  8556. if (options === true) {
  8557. if (!warned.storeName) {
  8558. console.warn(
  8559. "The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"
  8560. );
  8561. warned.storeName = true;
  8562. }
  8563. options = { storeName: true };
  8564. }
  8565. const storeName = options !== void 0 ? options.storeName : false;
  8566. const overwrite = options !== void 0 ? options.overwrite : false;
  8567. if (storeName) {
  8568. const original = this.original.slice(start, end);
  8569. Object.defineProperty(this.storedNames, original, {
  8570. writable: true,
  8571. value: true,
  8572. enumerable: true
  8573. });
  8574. }
  8575. const first = this.byStart[start];
  8576. const last = this.byEnd[end];
  8577. if (first) {
  8578. let chunk = first;
  8579. while (chunk !== last) {
  8580. if (chunk.next !== this.byStart[chunk.end]) {
  8581. throw new Error("Cannot overwrite across a split point");
  8582. }
  8583. chunk = chunk.next;
  8584. chunk.edit("", false);
  8585. }
  8586. first.edit(content, storeName, !overwrite);
  8587. } else {
  8588. const newChunk = new Chunk(start, end, "").edit(content, storeName);
  8589. last.next = newChunk;
  8590. newChunk.previous = last;
  8591. }
  8592. return this;
  8593. }
  8594. prepend(content) {
  8595. if (typeof content !== "string")
  8596. throw new TypeError("outro content must be a string");
  8597. this.intro = content + this.intro;
  8598. return this;
  8599. }
  8600. prependLeft(index, content) {
  8601. index = index + this.offset;
  8602. if (typeof content !== "string")
  8603. throw new TypeError("inserted content must be a string");
  8604. this._split(index);
  8605. const chunk = this.byEnd[index];
  8606. if (chunk) {
  8607. chunk.prependLeft(content);
  8608. } else {
  8609. this.intro = content + this.intro;
  8610. }
  8611. return this;
  8612. }
  8613. prependRight(index, content) {
  8614. index = index + this.offset;
  8615. if (typeof content !== "string")
  8616. throw new TypeError("inserted content must be a string");
  8617. this._split(index);
  8618. const chunk = this.byStart[index];
  8619. if (chunk) {
  8620. chunk.prependRight(content);
  8621. } else {
  8622. this.outro = content + this.outro;
  8623. }
  8624. return this;
  8625. }
  8626. remove(start, end) {
  8627. start = start + this.offset;
  8628. end = end + this.offset;
  8629. if (this.original.length !== 0) {
  8630. while (start < 0)
  8631. start += this.original.length;
  8632. while (end < 0)
  8633. end += this.original.length;
  8634. }
  8635. if (start === end)
  8636. return this;
  8637. if (start < 0 || end > this.original.length)
  8638. throw new Error("Character is out of bounds");
  8639. if (start > end)
  8640. throw new Error("end must be greater than start");
  8641. this._split(start);
  8642. this._split(end);
  8643. let chunk = this.byStart[start];
  8644. while (chunk) {
  8645. chunk.intro = "";
  8646. chunk.outro = "";
  8647. chunk.edit("");
  8648. chunk = end > chunk.end ? this.byStart[chunk.end] : null;
  8649. }
  8650. return this;
  8651. }
  8652. reset(start, end) {
  8653. start = start + this.offset;
  8654. end = end + this.offset;
  8655. if (this.original.length !== 0) {
  8656. while (start < 0)
  8657. start += this.original.length;
  8658. while (end < 0)
  8659. end += this.original.length;
  8660. }
  8661. if (start === end)
  8662. return this;
  8663. if (start < 0 || end > this.original.length)
  8664. throw new Error("Character is out of bounds");
  8665. if (start > end)
  8666. throw new Error("end must be greater than start");
  8667. this._split(start);
  8668. this._split(end);
  8669. let chunk = this.byStart[start];
  8670. while (chunk) {
  8671. chunk.reset();
  8672. chunk = end > chunk.end ? this.byStart[chunk.end] : null;
  8673. }
  8674. return this;
  8675. }
  8676. lastChar() {
  8677. if (this.outro.length)
  8678. return this.outro[this.outro.length - 1];
  8679. let chunk = this.lastChunk;
  8680. do {
  8681. if (chunk.outro.length)
  8682. return chunk.outro[chunk.outro.length - 1];
  8683. if (chunk.content.length)
  8684. return chunk.content[chunk.content.length - 1];
  8685. if (chunk.intro.length)
  8686. return chunk.intro[chunk.intro.length - 1];
  8687. } while (chunk = chunk.previous);
  8688. if (this.intro.length)
  8689. return this.intro[this.intro.length - 1];
  8690. return "";
  8691. }
  8692. lastLine() {
  8693. let lineIndex = this.outro.lastIndexOf(n);
  8694. if (lineIndex !== -1)
  8695. return this.outro.substr(lineIndex + 1);
  8696. let lineStr = this.outro;
  8697. let chunk = this.lastChunk;
  8698. do {
  8699. if (chunk.outro.length > 0) {
  8700. lineIndex = chunk.outro.lastIndexOf(n);
  8701. if (lineIndex !== -1)
  8702. return chunk.outro.substr(lineIndex + 1) + lineStr;
  8703. lineStr = chunk.outro + lineStr;
  8704. }
  8705. if (chunk.content.length > 0) {
  8706. lineIndex = chunk.content.lastIndexOf(n);
  8707. if (lineIndex !== -1)
  8708. return chunk.content.substr(lineIndex + 1) + lineStr;
  8709. lineStr = chunk.content + lineStr;
  8710. }
  8711. if (chunk.intro.length > 0) {
  8712. lineIndex = chunk.intro.lastIndexOf(n);
  8713. if (lineIndex !== -1)
  8714. return chunk.intro.substr(lineIndex + 1) + lineStr;
  8715. lineStr = chunk.intro + lineStr;
  8716. }
  8717. } while (chunk = chunk.previous);
  8718. lineIndex = this.intro.lastIndexOf(n);
  8719. if (lineIndex !== -1)
  8720. return this.intro.substr(lineIndex + 1) + lineStr;
  8721. return this.intro + lineStr;
  8722. }
  8723. slice(start = 0, end = this.original.length - this.offset) {
  8724. start = start + this.offset;
  8725. end = end + this.offset;
  8726. if (this.original.length !== 0) {
  8727. while (start < 0)
  8728. start += this.original.length;
  8729. while (end < 0)
  8730. end += this.original.length;
  8731. }
  8732. let result = "";
  8733. let chunk = this.firstChunk;
  8734. while (chunk && (chunk.start > start || chunk.end <= start)) {
  8735. if (chunk.start < end && chunk.end >= end) {
  8736. return result;
  8737. }
  8738. chunk = chunk.next;
  8739. }
  8740. if (chunk && chunk.edited && chunk.start !== start)
  8741. throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
  8742. const startChunk = chunk;
  8743. while (chunk) {
  8744. if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
  8745. result += chunk.intro;
  8746. }
  8747. const containsEnd = chunk.start < end && chunk.end >= end;
  8748. if (containsEnd && chunk.edited && chunk.end !== end)
  8749. throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
  8750. const sliceStart = startChunk === chunk ? start - chunk.start : 0;
  8751. const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
  8752. result += chunk.content.slice(sliceStart, sliceEnd);
  8753. if (chunk.outro && (!containsEnd || chunk.end === end)) {
  8754. result += chunk.outro;
  8755. }
  8756. if (containsEnd) {
  8757. break;
  8758. }
  8759. chunk = chunk.next;
  8760. }
  8761. return result;
  8762. }
  8763. snip(start, end) {
  8764. const clone = this.clone();
  8765. clone.remove(0, start);
  8766. clone.remove(end, clone.original.length);
  8767. return clone;
  8768. }
  8769. _split(index) {
  8770. if (this.byStart[index] || this.byEnd[index])
  8771. return;
  8772. let chunk = this.lastSearchedChunk;
  8773. const searchForward = index > chunk.end;
  8774. while (chunk) {
  8775. if (chunk.contains(index))
  8776. return this._splitChunk(chunk, index);
  8777. chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
  8778. }
  8779. }
  8780. _splitChunk(chunk, index) {
  8781. if (chunk.edited && chunk.content.length) {
  8782. const loc = getLocator(this.original)(index);
  8783. throw new Error(
  8784. `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} \u2013 "${chunk.original}")`
  8785. );
  8786. }
  8787. const newChunk = chunk.split(index);
  8788. this.byEnd[index] = chunk;
  8789. this.byStart[index] = newChunk;
  8790. this.byEnd[newChunk.end] = newChunk;
  8791. if (chunk === this.lastChunk)
  8792. this.lastChunk = newChunk;
  8793. this.lastSearchedChunk = chunk;
  8794. return true;
  8795. }
  8796. toString() {
  8797. let str = this.intro;
  8798. let chunk = this.firstChunk;
  8799. while (chunk) {
  8800. str += chunk.toString();
  8801. chunk = chunk.next;
  8802. }
  8803. return str + this.outro;
  8804. }
  8805. isEmpty() {
  8806. let chunk = this.firstChunk;
  8807. do {
  8808. if (chunk.intro.length && chunk.intro.trim() || chunk.content.length && chunk.content.trim() || chunk.outro.length && chunk.outro.trim())
  8809. return false;
  8810. } while (chunk = chunk.next);
  8811. return true;
  8812. }
  8813. length() {
  8814. let chunk = this.firstChunk;
  8815. let length = 0;
  8816. do {
  8817. length += chunk.intro.length + chunk.content.length + chunk.outro.length;
  8818. } while (chunk = chunk.next);
  8819. return length;
  8820. }
  8821. trimLines() {
  8822. return this.trim("[\\r\\n]");
  8823. }
  8824. trim(charType) {
  8825. return this.trimStart(charType).trimEnd(charType);
  8826. }
  8827. trimEndAborted(charType) {
  8828. const rx = new RegExp((charType || "\\s") + "+$");
  8829. this.outro = this.outro.replace(rx, "");
  8830. if (this.outro.length)
  8831. return true;
  8832. let chunk = this.lastChunk;
  8833. do {
  8834. const end = chunk.end;
  8835. const aborted = chunk.trimEnd(rx);
  8836. if (chunk.end !== end) {
  8837. if (this.lastChunk === chunk) {
  8838. this.lastChunk = chunk.next;
  8839. }
  8840. this.byEnd[chunk.end] = chunk;
  8841. this.byStart[chunk.next.start] = chunk.next;
  8842. this.byEnd[chunk.next.end] = chunk.next;
  8843. }
  8844. if (aborted)
  8845. return true;
  8846. chunk = chunk.previous;
  8847. } while (chunk);
  8848. return false;
  8849. }
  8850. trimEnd(charType) {
  8851. this.trimEndAborted(charType);
  8852. return this;
  8853. }
  8854. trimStartAborted(charType) {
  8855. const rx = new RegExp("^" + (charType || "\\s") + "+");
  8856. this.intro = this.intro.replace(rx, "");
  8857. if (this.intro.length)
  8858. return true;
  8859. let chunk = this.firstChunk;
  8860. do {
  8861. const end = chunk.end;
  8862. const aborted = chunk.trimStart(rx);
  8863. if (chunk.end !== end) {
  8864. if (chunk === this.lastChunk)
  8865. this.lastChunk = chunk.next;
  8866. this.byEnd[chunk.end] = chunk;
  8867. this.byStart[chunk.next.start] = chunk.next;
  8868. this.byEnd[chunk.next.end] = chunk.next;
  8869. }
  8870. if (aborted)
  8871. return true;
  8872. chunk = chunk.next;
  8873. } while (chunk);
  8874. return false;
  8875. }
  8876. trimStart(charType) {
  8877. this.trimStartAborted(charType);
  8878. return this;
  8879. }
  8880. hasChanged() {
  8881. return this.original !== this.toString();
  8882. }
  8883. _replaceRegexp(searchValue, replacement) {
  8884. function getReplacement(match, str) {
  8885. if (typeof replacement === "string") {
  8886. return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
  8887. if (i === "$")
  8888. return "$";
  8889. if (i === "&")
  8890. return match[0];
  8891. const num = +i;
  8892. if (num < match.length)
  8893. return match[+i];
  8894. return `$${i}`;
  8895. });
  8896. } else {
  8897. return replacement(...match, match.index, str, match.groups);
  8898. }
  8899. }
  8900. function matchAll(re, str) {
  8901. let match;
  8902. const matches = [];
  8903. while (match = re.exec(str)) {
  8904. matches.push(match);
  8905. }
  8906. return matches;
  8907. }
  8908. if (searchValue.global) {
  8909. const matches = matchAll(searchValue, this.original);
  8910. matches.forEach((match) => {
  8911. if (match.index != null) {
  8912. const replacement2 = getReplacement(match, this.original);
  8913. if (replacement2 !== match[0]) {
  8914. this.overwrite(match.index, match.index + match[0].length, replacement2);
  8915. }
  8916. }
  8917. });
  8918. } else {
  8919. const match = this.original.match(searchValue);
  8920. if (match && match.index != null) {
  8921. const replacement2 = getReplacement(match, this.original);
  8922. if (replacement2 !== match[0]) {
  8923. this.overwrite(match.index, match.index + match[0].length, replacement2);
  8924. }
  8925. }
  8926. }
  8927. return this;
  8928. }
  8929. _replaceString(string, replacement) {
  8930. const { original } = this;
  8931. const index = original.indexOf(string);
  8932. if (index !== -1) {
  8933. this.overwrite(index, index + string.length, replacement);
  8934. }
  8935. return this;
  8936. }
  8937. replace(searchValue, replacement) {
  8938. if (typeof searchValue === "string") {
  8939. return this._replaceString(searchValue, replacement);
  8940. }
  8941. return this._replaceRegexp(searchValue, replacement);
  8942. }
  8943. _replaceAllString(string, replacement) {
  8944. const { original } = this;
  8945. const stringLength = string.length;
  8946. for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
  8947. const previous = original.slice(index, index + stringLength);
  8948. if (previous !== replacement)
  8949. this.overwrite(index, index + stringLength, replacement);
  8950. }
  8951. return this;
  8952. }
  8953. replaceAll(searchValue, replacement) {
  8954. if (typeof searchValue === "string") {
  8955. return this._replaceAllString(searchValue, replacement);
  8956. }
  8957. if (!searchValue.global) {
  8958. throw new TypeError(
  8959. "MagicString.prototype.replaceAll called with a non-global RegExp argument"
  8960. );
  8961. }
  8962. return this._replaceRegexp(searchValue, replacement);
  8963. }
  8964. };
  8965. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/context.mjs
  8966. import ts44 from "typescript";
  8967. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/dom.mjs
  8968. import { DomElementSchemaRegistry } from "@angular/compiler";
  8969. import ts32 from "typescript";
  8970. var REGISTRY = new DomElementSchemaRegistry();
  8971. var REMOVE_XHTML_REGEX = /^:xhtml:/;
  8972. var RegistryDomSchemaChecker = class {
  8973. resolver;
  8974. _diagnostics = [];
  8975. get diagnostics() {
  8976. return this._diagnostics;
  8977. }
  8978. constructor(resolver) {
  8979. this.resolver = resolver;
  8980. }
  8981. checkElement(id, element, schemas, hostIsStandalone) {
  8982. const name = element.name.replace(REMOVE_XHTML_REGEX, "");
  8983. if (!REGISTRY.hasElement(name, schemas)) {
  8984. const mapping = this.resolver.getTemplateSourceMapping(id);
  8985. const schemas2 = `'${hostIsStandalone ? "@Component" : "@NgModule"}.schemas'`;
  8986. let errorMsg = `'${name}' is not a known element:
  8987. `;
  8988. errorMsg += `1. If '${name}' is an Angular component, then verify that it is ${hostIsStandalone ? "included in the '@Component.imports' of this component" : "part of this module"}.
  8989. `;
  8990. if (name.indexOf("-") > -1) {
  8991. errorMsg += `2. If '${name}' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the ${schemas2} of this component to suppress this message.`;
  8992. } else {
  8993. errorMsg += `2. To allow any element add 'NO_ERRORS_SCHEMA' to the ${schemas2} of this component.`;
  8994. }
  8995. const diag = makeTemplateDiagnostic(id, mapping, element.startSourceSpan, ts32.DiagnosticCategory.Error, ngErrorCode(ErrorCode.SCHEMA_INVALID_ELEMENT), errorMsg);
  8996. this._diagnostics.push(diag);
  8997. }
  8998. }
  8999. checkProperty(id, element, name, span, schemas, hostIsStandalone) {
  9000. if (!REGISTRY.hasProperty(element.name, name, schemas)) {
  9001. const mapping = this.resolver.getTemplateSourceMapping(id);
  9002. const decorator = hostIsStandalone ? "@Component" : "@NgModule";
  9003. const schemas2 = `'${decorator}.schemas'`;
  9004. let errorMsg = `Can't bind to '${name}' since it isn't a known property of '${element.name}'.`;
  9005. if (element.name.startsWith("ng-")) {
  9006. errorMsg += `
  9007. 1. If '${name}' is an Angular directive, then add 'CommonModule' to the '${decorator}.imports' of this component.
  9008. 2. To allow any property add 'NO_ERRORS_SCHEMA' to the ${schemas2} of this component.`;
  9009. } else if (element.name.indexOf("-") > -1) {
  9010. errorMsg += `
  9011. 1. If '${element.name}' is an Angular component and it has '${name}' input, then verify that it is ${hostIsStandalone ? "included in the '@Component.imports' of this component" : "part of this module"}.
  9012. 2. If '${element.name}' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the ${schemas2} of this component to suppress this message.
  9013. 3. To allow any property add 'NO_ERRORS_SCHEMA' to the ${schemas2} of this component.`;
  9014. }
  9015. const diag = makeTemplateDiagnostic(id, mapping, span, ts32.DiagnosticCategory.Error, ngErrorCode(ErrorCode.SCHEMA_INVALID_ATTRIBUTE), errorMsg);
  9016. this._diagnostics.push(diag);
  9017. }
  9018. }
  9019. };
  9020. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/environment.mjs
  9021. import ts37 from "typescript";
  9022. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/reference_emit_environment.mjs
  9023. import { ExpressionType, ExternalExpr as ExternalExpr6, TypeModifier } from "@angular/compiler";
  9024. var ReferenceEmitEnvironment = class {
  9025. importManager;
  9026. refEmitter;
  9027. reflector;
  9028. contextFile;
  9029. constructor(importManager, refEmitter, reflector, contextFile) {
  9030. this.importManager = importManager;
  9031. this.refEmitter = refEmitter;
  9032. this.reflector = reflector;
  9033. this.contextFile = contextFile;
  9034. }
  9035. canReferenceType(ref, flags = ImportFlags.NoAliasing | ImportFlags.AllowTypeImports | ImportFlags.AllowRelativeDtsImports) {
  9036. const result = this.refEmitter.emit(ref, this.contextFile, flags);
  9037. return result.kind === ReferenceEmitKind.Success;
  9038. }
  9039. referenceType(ref, flags = ImportFlags.NoAliasing | ImportFlags.AllowTypeImports | ImportFlags.AllowRelativeDtsImports) {
  9040. const ngExpr = this.refEmitter.emit(ref, this.contextFile, flags);
  9041. assertSuccessfulReferenceEmit(ngExpr, this.contextFile, "symbol");
  9042. return translateType(new ExpressionType(ngExpr.expression), this.contextFile, this.reflector, this.refEmitter, this.importManager);
  9043. }
  9044. referenceExternalSymbol(moduleName, name) {
  9045. const external = new ExternalExpr6({ moduleName, name });
  9046. return translateExpression(this.contextFile, external, this.importManager);
  9047. }
  9048. referenceExternalType(moduleName, name, typeParams) {
  9049. const external = new ExternalExpr6({ moduleName, name });
  9050. return translateType(new ExpressionType(external, TypeModifier.None, typeParams), this.contextFile, this.reflector, this.refEmitter, this.importManager);
  9051. }
  9052. referenceTransplantedType(type) {
  9053. return translateType(type, this.contextFile, this.reflector, this.refEmitter, this.importManager);
  9054. }
  9055. };
  9056. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/ts_util.mjs
  9057. import ts33 from "typescript";
  9058. var SAFE_TO_CAST_WITHOUT_PARENS = /* @__PURE__ */ new Set([
  9059. ts33.SyntaxKind.ParenthesizedExpression,
  9060. ts33.SyntaxKind.Identifier,
  9061. ts33.SyntaxKind.CallExpression,
  9062. ts33.SyntaxKind.NonNullExpression,
  9063. ts33.SyntaxKind.ElementAccessExpression,
  9064. ts33.SyntaxKind.PropertyAccessExpression,
  9065. ts33.SyntaxKind.ArrayLiteralExpression,
  9066. ts33.SyntaxKind.ObjectLiteralExpression,
  9067. ts33.SyntaxKind.StringLiteral,
  9068. ts33.SyntaxKind.NumericLiteral,
  9069. ts33.SyntaxKind.TrueKeyword,
  9070. ts33.SyntaxKind.FalseKeyword,
  9071. ts33.SyntaxKind.NullKeyword,
  9072. ts33.SyntaxKind.UndefinedKeyword
  9073. ]);
  9074. function tsCastToAny(expr) {
  9075. if (!SAFE_TO_CAST_WITHOUT_PARENS.has(expr.kind)) {
  9076. expr = ts33.factory.createParenthesizedExpression(expr);
  9077. }
  9078. return ts33.factory.createParenthesizedExpression(ts33.factory.createAsExpression(expr, ts33.factory.createKeywordTypeNode(ts33.SyntaxKind.AnyKeyword)));
  9079. }
  9080. function tsCreateElement(tagName) {
  9081. const createElement = ts33.factory.createPropertyAccessExpression(
  9082. ts33.factory.createIdentifier("document"),
  9083. "createElement"
  9084. );
  9085. return ts33.factory.createCallExpression(
  9086. createElement,
  9087. void 0,
  9088. [ts33.factory.createStringLiteral(tagName)]
  9089. );
  9090. }
  9091. function tsDeclareVariable(id, type) {
  9092. addExpressionIdentifier(type, ExpressionIdentifier.VARIABLE_AS_EXPRESSION);
  9093. const initializer = ts33.factory.createAsExpression(ts33.factory.createNonNullExpression(ts33.factory.createNull()), type);
  9094. const decl = ts33.factory.createVariableDeclaration(
  9095. id,
  9096. void 0,
  9097. void 0,
  9098. initializer
  9099. );
  9100. return ts33.factory.createVariableStatement(
  9101. void 0,
  9102. [decl]
  9103. );
  9104. }
  9105. function tsCreateTypeQueryForCoercedInput(typeName, coercedInputName) {
  9106. return ts33.factory.createTypeQueryNode(ts33.factory.createQualifiedName(typeName, `ngAcceptInputType_${coercedInputName}`));
  9107. }
  9108. function tsCreateVariable(id, initializer, flags = null) {
  9109. const decl = ts33.factory.createVariableDeclaration(
  9110. id,
  9111. void 0,
  9112. void 0,
  9113. initializer
  9114. );
  9115. return ts33.factory.createVariableStatement(
  9116. void 0,
  9117. flags === null ? [decl] : ts33.factory.createVariableDeclarationList([decl], flags)
  9118. );
  9119. }
  9120. function tsCallMethod(receiver, methodName, args = []) {
  9121. const methodAccess = ts33.factory.createPropertyAccessExpression(receiver, methodName);
  9122. return ts33.factory.createCallExpression(
  9123. methodAccess,
  9124. void 0,
  9125. args
  9126. );
  9127. }
  9128. function isAccessExpression(node) {
  9129. return ts33.isPropertyAccessExpression(node) || ts33.isElementAccessExpression(node);
  9130. }
  9131. function tsNumericExpression(value) {
  9132. if (value < 0) {
  9133. const operand = ts33.factory.createNumericLiteral(Math.abs(value));
  9134. return ts33.factory.createPrefixUnaryExpression(ts33.SyntaxKind.MinusToken, operand);
  9135. }
  9136. return ts33.factory.createNumericLiteral(value);
  9137. }
  9138. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/type_constructor.mjs
  9139. import { ExpressionType as ExpressionType2, R3Identifiers as R3Identifiers3, WrappedNodeExpr as WrappedNodeExpr8 } from "@angular/compiler";
  9140. import ts36 from "typescript";
  9141. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/tcb_util.mjs
  9142. import { R3Identifiers as R3Identifiers2 } from "@angular/compiler";
  9143. import ts35 from "typescript";
  9144. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/type_parameter_emitter.mjs
  9145. import ts34 from "typescript";
  9146. var TypeParameterEmitter = class {
  9147. typeParameters;
  9148. reflector;
  9149. constructor(typeParameters, reflector) {
  9150. this.typeParameters = typeParameters;
  9151. this.reflector = reflector;
  9152. }
  9153. canEmit(canEmitReference) {
  9154. if (this.typeParameters === void 0) {
  9155. return true;
  9156. }
  9157. return this.typeParameters.every((typeParam) => {
  9158. return this.canEmitType(typeParam.constraint, canEmitReference) && this.canEmitType(typeParam.default, canEmitReference);
  9159. });
  9160. }
  9161. canEmitType(type, canEmitReference) {
  9162. if (type === void 0) {
  9163. return true;
  9164. }
  9165. return canEmitType(type, (typeReference) => {
  9166. const reference = this.resolveTypeReference(typeReference);
  9167. if (reference === null) {
  9168. return false;
  9169. }
  9170. if (reference instanceof Reference) {
  9171. return canEmitReference(reference);
  9172. }
  9173. return true;
  9174. });
  9175. }
  9176. emit(emitReference) {
  9177. if (this.typeParameters === void 0) {
  9178. return void 0;
  9179. }
  9180. const emitter = new TypeEmitter((type) => this.translateTypeReference(type, emitReference));
  9181. return this.typeParameters.map((typeParam) => {
  9182. const constraint = typeParam.constraint !== void 0 ? emitter.emitType(typeParam.constraint) : void 0;
  9183. const defaultType = typeParam.default !== void 0 ? emitter.emitType(typeParam.default) : void 0;
  9184. return ts34.factory.updateTypeParameterDeclaration(typeParam, typeParam.modifiers, typeParam.name, constraint, defaultType);
  9185. });
  9186. }
  9187. resolveTypeReference(type) {
  9188. const target = ts34.isIdentifier(type.typeName) ? type.typeName : type.typeName.right;
  9189. const declaration = this.reflector.getDeclarationOfIdentifier(target);
  9190. if (declaration === null || declaration.node === null) {
  9191. return null;
  9192. }
  9193. if (this.isLocalTypeParameter(declaration.node)) {
  9194. return type;
  9195. }
  9196. let owningModule2 = null;
  9197. if (typeof declaration.viaModule === "string") {
  9198. owningModule2 = {
  9199. specifier: declaration.viaModule,
  9200. resolutionContext: type.getSourceFile().fileName
  9201. };
  9202. }
  9203. return new Reference(declaration.node, declaration.viaModule === AmbientImport ? AmbientImport : owningModule2);
  9204. }
  9205. translateTypeReference(type, emitReference) {
  9206. const reference = this.resolveTypeReference(type);
  9207. if (!(reference instanceof Reference)) {
  9208. return reference;
  9209. }
  9210. const typeNode = emitReference(reference);
  9211. if (typeNode === null) {
  9212. return null;
  9213. }
  9214. if (!ts34.isTypeReferenceNode(typeNode)) {
  9215. throw new Error(`Expected TypeReferenceNode for emitted reference, got ${ts34.SyntaxKind[typeNode.kind]}.`);
  9216. }
  9217. return typeNode;
  9218. }
  9219. isLocalTypeParameter(decl) {
  9220. return this.typeParameters.some((param) => param === decl);
  9221. }
  9222. };
  9223. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/tcb_util.mjs
  9224. var TCB_FILE_IMPORT_GRAPH_PREPARE_IDENTIFIERS = [
  9225. R3Identifiers2.InputSignalBrandWriteType
  9226. ];
  9227. var TcbInliningRequirement;
  9228. (function(TcbInliningRequirement2) {
  9229. TcbInliningRequirement2[TcbInliningRequirement2["MustInline"] = 0] = "MustInline";
  9230. TcbInliningRequirement2[TcbInliningRequirement2["ShouldInlineForGenericBounds"] = 1] = "ShouldInlineForGenericBounds";
  9231. TcbInliningRequirement2[TcbInliningRequirement2["None"] = 2] = "None";
  9232. })(TcbInliningRequirement || (TcbInliningRequirement = {}));
  9233. function requiresInlineTypeCheckBlock(ref, env, usedPipes, reflector) {
  9234. if (!env.canReferenceType(ref)) {
  9235. return TcbInliningRequirement.MustInline;
  9236. } else if (!checkIfGenericTypeBoundsCanBeEmitted(ref.node, reflector, env)) {
  9237. return TcbInliningRequirement.ShouldInlineForGenericBounds;
  9238. } else if (usedPipes.some((pipeRef) => !env.canReferenceType(pipeRef))) {
  9239. return TcbInliningRequirement.MustInline;
  9240. } else {
  9241. return TcbInliningRequirement.None;
  9242. }
  9243. }
  9244. function getSourceMapping(shimSf, position, resolver, isDiagnosticRequest) {
  9245. const node = getTokenAtPosition(shimSf, position);
  9246. const sourceLocation = findSourceLocation(node, shimSf, isDiagnosticRequest);
  9247. if (sourceLocation === null) {
  9248. return null;
  9249. }
  9250. const mapping = resolver.getTemplateSourceMapping(sourceLocation.id);
  9251. const span = resolver.toTemplateParseSourceSpan(sourceLocation.id, sourceLocation.span);
  9252. if (span === null) {
  9253. return null;
  9254. }
  9255. return { sourceLocation, sourceMapping: mapping, span };
  9256. }
  9257. function findTypeCheckBlock(file, id, isDiagnosticRequest) {
  9258. for (const stmt of file.statements) {
  9259. if (ts35.isFunctionDeclaration(stmt) && getTemplateId(stmt, file, isDiagnosticRequest) === id) {
  9260. return stmt;
  9261. }
  9262. }
  9263. return null;
  9264. }
  9265. function findSourceLocation(node, sourceFile, isDiagnosticsRequest) {
  9266. while (node !== void 0 && !ts35.isFunctionDeclaration(node)) {
  9267. if (hasIgnoreForDiagnosticsMarker(node, sourceFile) && isDiagnosticsRequest) {
  9268. return null;
  9269. }
  9270. const span = readSpanComment(node, sourceFile);
  9271. if (span !== null) {
  9272. const id = getTemplateId(node, sourceFile, isDiagnosticsRequest);
  9273. if (id === null) {
  9274. return null;
  9275. }
  9276. return { id, span };
  9277. }
  9278. node = node.parent;
  9279. }
  9280. return null;
  9281. }
  9282. function getTemplateId(node, sourceFile, isDiagnosticRequest) {
  9283. while (!ts35.isFunctionDeclaration(node)) {
  9284. if (hasIgnoreForDiagnosticsMarker(node, sourceFile) && isDiagnosticRequest) {
  9285. return null;
  9286. }
  9287. node = node.parent;
  9288. if (node === void 0) {
  9289. return null;
  9290. }
  9291. }
  9292. const start = node.getFullStart();
  9293. return ts35.forEachLeadingCommentRange(sourceFile.text, start, (pos, end, kind) => {
  9294. if (kind !== ts35.SyntaxKind.MultiLineCommentTrivia) {
  9295. return null;
  9296. }
  9297. const commentText = sourceFile.text.substring(pos + 2, end - 2);
  9298. return commentText;
  9299. }) || null;
  9300. }
  9301. function ensureTypeCheckFilePreparationImports(env) {
  9302. for (const identifier of TCB_FILE_IMPORT_GRAPH_PREPARE_IDENTIFIERS) {
  9303. env.importManager.addImport({
  9304. exportModuleSpecifier: identifier.moduleName,
  9305. exportSymbolName: identifier.name,
  9306. requestedFile: env.contextFile
  9307. });
  9308. }
  9309. }
  9310. function checkIfGenericTypeBoundsCanBeEmitted(node, reflector, env) {
  9311. const emitter = new TypeParameterEmitter(node.typeParameters, reflector);
  9312. return emitter.canEmit((ref) => env.canReferenceType(ref));
  9313. }
  9314. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/type_constructor.mjs
  9315. function generateTypeCtorDeclarationFn(env, meta, nodeTypeRef, typeParams) {
  9316. const rawTypeArgs = typeParams !== void 0 ? generateGenericArgs(typeParams) : void 0;
  9317. const rawType = ts36.factory.createTypeReferenceNode(nodeTypeRef, rawTypeArgs);
  9318. const initParam = constructTypeCtorParameter(env, meta, rawType);
  9319. const typeParameters = typeParametersWithDefaultTypes(typeParams);
  9320. if (meta.body) {
  9321. const fnType = ts36.factory.createFunctionTypeNode(
  9322. typeParameters,
  9323. [initParam],
  9324. rawType
  9325. );
  9326. const decl = ts36.factory.createVariableDeclaration(
  9327. meta.fnName,
  9328. void 0,
  9329. fnType,
  9330. ts36.factory.createNonNullExpression(ts36.factory.createNull())
  9331. );
  9332. const declList = ts36.factory.createVariableDeclarationList([decl], ts36.NodeFlags.Const);
  9333. return ts36.factory.createVariableStatement(
  9334. void 0,
  9335. declList
  9336. );
  9337. } else {
  9338. return ts36.factory.createFunctionDeclaration(
  9339. [ts36.factory.createModifier(ts36.SyntaxKind.DeclareKeyword)],
  9340. void 0,
  9341. meta.fnName,
  9342. typeParameters,
  9343. [initParam],
  9344. rawType,
  9345. void 0
  9346. );
  9347. }
  9348. }
  9349. function generateInlineTypeCtor(env, node, meta) {
  9350. const rawTypeArgs = node.typeParameters !== void 0 ? generateGenericArgs(node.typeParameters) : void 0;
  9351. const rawType = ts36.factory.createTypeReferenceNode(node.name, rawTypeArgs);
  9352. const initParam = constructTypeCtorParameter(env, meta, rawType);
  9353. let body = void 0;
  9354. if (meta.body) {
  9355. body = ts36.factory.createBlock([
  9356. ts36.factory.createReturnStatement(ts36.factory.createNonNullExpression(ts36.factory.createNull()))
  9357. ]);
  9358. }
  9359. return ts36.factory.createMethodDeclaration(
  9360. [ts36.factory.createModifier(ts36.SyntaxKind.StaticKeyword)],
  9361. void 0,
  9362. meta.fnName,
  9363. void 0,
  9364. typeParametersWithDefaultTypes(node.typeParameters),
  9365. [initParam],
  9366. rawType,
  9367. body
  9368. );
  9369. }
  9370. function constructTypeCtorParameter(env, meta, rawType) {
  9371. let initType = null;
  9372. const plainKeys = [];
  9373. const coercedKeys = [];
  9374. const signalInputKeys = [];
  9375. for (const { classPropertyName, transform, isSignal } of meta.fields.inputs) {
  9376. if (isSignal) {
  9377. signalInputKeys.push(ts36.factory.createLiteralTypeNode(ts36.factory.createStringLiteral(classPropertyName)));
  9378. } else if (!meta.coercedInputFields.has(classPropertyName)) {
  9379. plainKeys.push(ts36.factory.createLiteralTypeNode(ts36.factory.createStringLiteral(classPropertyName)));
  9380. } else {
  9381. const coercionType = transform != null ? transform.type.node : tsCreateTypeQueryForCoercedInput(rawType.typeName, classPropertyName);
  9382. coercedKeys.push(ts36.factory.createPropertySignature(
  9383. void 0,
  9384. classPropertyName,
  9385. void 0,
  9386. coercionType
  9387. ));
  9388. }
  9389. }
  9390. if (plainKeys.length > 0) {
  9391. const keyTypeUnion = ts36.factory.createUnionTypeNode(plainKeys);
  9392. initType = ts36.factory.createTypeReferenceNode("Pick", [rawType, keyTypeUnion]);
  9393. }
  9394. if (coercedKeys.length > 0) {
  9395. const coercedLiteral = ts36.factory.createTypeLiteralNode(coercedKeys);
  9396. initType = initType !== null ? ts36.factory.createIntersectionTypeNode([initType, coercedLiteral]) : coercedLiteral;
  9397. }
  9398. if (signalInputKeys.length > 0) {
  9399. const keyTypeUnion = ts36.factory.createUnionTypeNode(signalInputKeys);
  9400. const unwrapDirectiveSignalInputsExpr = env.referenceExternalType(R3Identifiers3.UnwrapDirectiveSignalInputs.moduleName, R3Identifiers3.UnwrapDirectiveSignalInputs.name, [
  9401. new ExpressionType2(new WrappedNodeExpr8(rawType)),
  9402. new ExpressionType2(new WrappedNodeExpr8(keyTypeUnion))
  9403. ]);
  9404. initType = initType !== null ? ts36.factory.createIntersectionTypeNode([initType, unwrapDirectiveSignalInputsExpr]) : unwrapDirectiveSignalInputsExpr;
  9405. }
  9406. if (initType === null) {
  9407. initType = ts36.factory.createTypeLiteralNode([]);
  9408. }
  9409. return ts36.factory.createParameterDeclaration(
  9410. void 0,
  9411. void 0,
  9412. "init",
  9413. void 0,
  9414. initType,
  9415. void 0
  9416. );
  9417. }
  9418. function generateGenericArgs(params) {
  9419. return params.map((param) => ts36.factory.createTypeReferenceNode(param.name, void 0));
  9420. }
  9421. function requiresInlineTypeCtor(node, host, env) {
  9422. return !checkIfGenericTypeBoundsCanBeEmitted(node, host, env);
  9423. }
  9424. function typeParametersWithDefaultTypes(params) {
  9425. if (params === void 0) {
  9426. return void 0;
  9427. }
  9428. return params.map((param) => {
  9429. if (param.default === void 0) {
  9430. return ts36.factory.updateTypeParameterDeclaration(param, param.modifiers, param.name, param.constraint, ts36.factory.createKeywordTypeNode(ts36.SyntaxKind.AnyKeyword));
  9431. } else {
  9432. return param;
  9433. }
  9434. });
  9435. }
  9436. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/environment.mjs
  9437. var Environment = class extends ReferenceEmitEnvironment {
  9438. config;
  9439. nextIds = {
  9440. pipeInst: 1,
  9441. typeCtor: 1
  9442. };
  9443. typeCtors = /* @__PURE__ */ new Map();
  9444. typeCtorStatements = [];
  9445. pipeInsts = /* @__PURE__ */ new Map();
  9446. pipeInstStatements = [];
  9447. constructor(config, importManager, refEmitter, reflector, contextFile) {
  9448. super(importManager, refEmitter, reflector, contextFile);
  9449. this.config = config;
  9450. }
  9451. typeCtorFor(dir) {
  9452. const dirRef = dir.ref;
  9453. const node = dirRef.node;
  9454. if (this.typeCtors.has(node)) {
  9455. return this.typeCtors.get(node);
  9456. }
  9457. if (requiresInlineTypeCtor(node, this.reflector, this)) {
  9458. const ref = this.reference(dirRef);
  9459. const typeCtorExpr = ts37.factory.createPropertyAccessExpression(ref, "ngTypeCtor");
  9460. this.typeCtors.set(node, typeCtorExpr);
  9461. return typeCtorExpr;
  9462. } else {
  9463. const fnName = `_ctor${this.nextIds.typeCtor++}`;
  9464. const nodeTypeRef = this.referenceType(dirRef);
  9465. if (!ts37.isTypeReferenceNode(nodeTypeRef)) {
  9466. throw new Error(`Expected TypeReferenceNode from reference to ${dirRef.debugName}`);
  9467. }
  9468. const meta = {
  9469. fnName,
  9470. body: true,
  9471. fields: {
  9472. inputs: dir.inputs,
  9473. queries: dir.queries
  9474. },
  9475. coercedInputFields: dir.coercedInputFields
  9476. };
  9477. const typeParams = this.emitTypeParameters(node);
  9478. const typeCtor = generateTypeCtorDeclarationFn(this, meta, nodeTypeRef.typeName, typeParams);
  9479. this.typeCtorStatements.push(typeCtor);
  9480. const fnId = ts37.factory.createIdentifier(fnName);
  9481. this.typeCtors.set(node, fnId);
  9482. return fnId;
  9483. }
  9484. }
  9485. pipeInst(ref) {
  9486. if (this.pipeInsts.has(ref.node)) {
  9487. return this.pipeInsts.get(ref.node);
  9488. }
  9489. const pipeType = this.referenceType(ref);
  9490. const pipeInstId = ts37.factory.createIdentifier(`_pipe${this.nextIds.pipeInst++}`);
  9491. this.pipeInstStatements.push(tsDeclareVariable(pipeInstId, pipeType));
  9492. this.pipeInsts.set(ref.node, pipeInstId);
  9493. return pipeInstId;
  9494. }
  9495. reference(ref) {
  9496. const ngExpr = this.refEmitter.emit(ref, this.contextFile, ImportFlags.NoAliasing);
  9497. assertSuccessfulReferenceEmit(ngExpr, this.contextFile, "class");
  9498. return translateExpression(this.contextFile, ngExpr.expression, this.importManager);
  9499. }
  9500. emitTypeParameters(declaration) {
  9501. const emitter = new TypeParameterEmitter(declaration.typeParameters, this.reflector);
  9502. return emitter.emit((ref) => this.referenceType(ref));
  9503. }
  9504. getPreludeStatements() {
  9505. return [...this.pipeInstStatements, ...this.typeCtorStatements];
  9506. }
  9507. };
  9508. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/oob.mjs
  9509. import { AbsoluteSourceSpan as AbsoluteSourceSpan2, TmplAstElement } from "@angular/compiler";
  9510. import ts38 from "typescript";
  9511. var OutOfBandDiagnosticRecorderImpl = class {
  9512. resolver;
  9513. _diagnostics = [];
  9514. recordedPipes = /* @__PURE__ */ new Set();
  9515. constructor(resolver) {
  9516. this.resolver = resolver;
  9517. }
  9518. get diagnostics() {
  9519. return this._diagnostics;
  9520. }
  9521. missingReferenceTarget(id, ref) {
  9522. const mapping = this.resolver.getTemplateSourceMapping(id);
  9523. const value = ref.value.trim();
  9524. const errorMsg = `No directive found with exportAs '${value}'.`;
  9525. this._diagnostics.push(makeTemplateDiagnostic(id, mapping, ref.valueSpan || ref.sourceSpan, ts38.DiagnosticCategory.Error, ngErrorCode(ErrorCode.MISSING_REFERENCE_TARGET), errorMsg));
  9526. }
  9527. missingPipe(id, ast) {
  9528. if (this.recordedPipes.has(ast)) {
  9529. return;
  9530. }
  9531. const mapping = this.resolver.getTemplateSourceMapping(id);
  9532. const errorMsg = `No pipe found with name '${ast.name}'.`;
  9533. const sourceSpan = this.resolver.toTemplateParseSourceSpan(id, ast.nameSpan);
  9534. if (sourceSpan === null) {
  9535. throw new Error(`Assertion failure: no SourceLocation found for usage of pipe '${ast.name}'.`);
  9536. }
  9537. this._diagnostics.push(makeTemplateDiagnostic(id, mapping, sourceSpan, ts38.DiagnosticCategory.Error, ngErrorCode(ErrorCode.MISSING_PIPE), errorMsg));
  9538. this.recordedPipes.add(ast);
  9539. }
  9540. deferredPipeUsedEagerly(id, ast) {
  9541. if (this.recordedPipes.has(ast)) {
  9542. return;
  9543. }
  9544. const mapping = this.resolver.getTemplateSourceMapping(id);
  9545. const errorMsg = `Pipe '${ast.name}' was imported via \`@Component.deferredImports\`, but was used outside of a \`@defer\` block in a template. To fix this, either use the '${ast.name}' pipe inside of a \`@defer\` block or import this dependency using the \`@Component.imports\` field.`;
  9546. const sourceSpan = this.resolver.toTemplateParseSourceSpan(id, ast.nameSpan);
  9547. if (sourceSpan === null) {
  9548. throw new Error(`Assertion failure: no SourceLocation found for usage of pipe '${ast.name}'.`);
  9549. }
  9550. this._diagnostics.push(makeTemplateDiagnostic(id, mapping, sourceSpan, ts38.DiagnosticCategory.Error, ngErrorCode(ErrorCode.DEFERRED_PIPE_USED_EAGERLY), errorMsg));
  9551. this.recordedPipes.add(ast);
  9552. }
  9553. deferredComponentUsedEagerly(id, element) {
  9554. const mapping = this.resolver.getTemplateSourceMapping(id);
  9555. const errorMsg = `Element '${element.name}' contains a component or a directive that was imported via \`@Component.deferredImports\`, but the element itself is located outside of a \`@defer\` block in a template. To fix this, either use the '${element.name}' element inside of a \`@defer\` block or import referenced component/directive dependency using the \`@Component.imports\` field.`;
  9556. const { start, end } = element.startSourceSpan;
  9557. const absoluteSourceSpan = new AbsoluteSourceSpan2(start.offset, end.offset);
  9558. const sourceSpan = this.resolver.toTemplateParseSourceSpan(id, absoluteSourceSpan);
  9559. if (sourceSpan === null) {
  9560. throw new Error(`Assertion failure: no SourceLocation found for usage of pipe '${element.name}'.`);
  9561. }
  9562. this._diagnostics.push(makeTemplateDiagnostic(id, mapping, sourceSpan, ts38.DiagnosticCategory.Error, ngErrorCode(ErrorCode.DEFERRED_DIRECTIVE_USED_EAGERLY), errorMsg));
  9563. }
  9564. duplicateTemplateVar(id, variable, firstDecl) {
  9565. const mapping = this.resolver.getTemplateSourceMapping(id);
  9566. const errorMsg = `Cannot redeclare variable '${variable.name}' as it was previously declared elsewhere for the same template.`;
  9567. this._diagnostics.push(makeTemplateDiagnostic(id, mapping, variable.sourceSpan, ts38.DiagnosticCategory.Error, ngErrorCode(ErrorCode.DUPLICATE_VARIABLE_DECLARATION), errorMsg, [
  9568. {
  9569. text: `The variable '${firstDecl.name}' was first declared here.`,
  9570. start: firstDecl.sourceSpan.start.offset,
  9571. end: firstDecl.sourceSpan.end.offset,
  9572. sourceFile: mapping.node.getSourceFile()
  9573. }
  9574. ]));
  9575. }
  9576. requiresInlineTcb(id, node) {
  9577. this._diagnostics.push(makeInlineDiagnostic(id, ErrorCode.INLINE_TCB_REQUIRED, node.name, `This component requires inline template type-checking, which is not supported by the current environment.`));
  9578. }
  9579. requiresInlineTypeConstructors(id, node, directives) {
  9580. let message;
  9581. if (directives.length > 1) {
  9582. message = `This component uses directives which require inline type constructors, which are not supported by the current environment.`;
  9583. } else {
  9584. message = `This component uses a directive which requires an inline type constructor, which is not supported by the current environment.`;
  9585. }
  9586. this._diagnostics.push(makeInlineDiagnostic(id, ErrorCode.INLINE_TYPE_CTOR_REQUIRED, node.name, message, directives.map((dir) => makeRelatedInformation(dir.name, `Requires an inline type constructor.`))));
  9587. }
  9588. suboptimalTypeInference(id, variables) {
  9589. const mapping = this.resolver.getTemplateSourceMapping(id);
  9590. let diagnosticVar = null;
  9591. for (const variable of variables) {
  9592. if (diagnosticVar === null || variable.value === "" || variable.value === "$implicit") {
  9593. diagnosticVar = variable;
  9594. }
  9595. }
  9596. if (diagnosticVar === null) {
  9597. return;
  9598. }
  9599. let varIdentification = `'${diagnosticVar.name}'`;
  9600. if (variables.length === 2) {
  9601. varIdentification += ` (and 1 other)`;
  9602. } else if (variables.length > 2) {
  9603. varIdentification += ` (and ${variables.length - 1} others)`;
  9604. }
  9605. const message = `This structural directive supports advanced type inference, but the current compiler configuration prevents its usage. The variable ${varIdentification} will have type 'any' as a result.
  9606. Consider enabling the 'strictTemplates' option in your tsconfig.json for better type inference within this template.`;
  9607. this._diagnostics.push(makeTemplateDiagnostic(id, mapping, diagnosticVar.keySpan, ts38.DiagnosticCategory.Suggestion, ngErrorCode(ErrorCode.SUGGEST_SUBOPTIMAL_TYPE_INFERENCE), message));
  9608. }
  9609. splitTwoWayBinding(id, input, output, inputConsumer, outputConsumer) {
  9610. const mapping = this.resolver.getTemplateSourceMapping(id);
  9611. const errorMsg = `The property and event halves of the two-way binding '${input.name}' are not bound to the same target.
  9612. Find more at https://angular.dev/guide/templates/two-way-binding#how-two-way-binding-works`;
  9613. const relatedMessages = [];
  9614. relatedMessages.push({
  9615. text: `The property half of the binding is to the '${inputConsumer.name.text}' component.`,
  9616. start: inputConsumer.name.getStart(),
  9617. end: inputConsumer.name.getEnd(),
  9618. sourceFile: inputConsumer.name.getSourceFile()
  9619. });
  9620. if (outputConsumer instanceof TmplAstElement) {
  9621. let message = `The event half of the binding is to a native event called '${input.name}' on the <${outputConsumer.name}> DOM element.`;
  9622. if (!mapping.node.getSourceFile().isDeclarationFile) {
  9623. message += `
  9624. Are you missing an output declaration called '${output.name}'?`;
  9625. }
  9626. relatedMessages.push({
  9627. text: message,
  9628. start: outputConsumer.sourceSpan.start.offset + 1,
  9629. end: outputConsumer.sourceSpan.start.offset + outputConsumer.name.length + 1,
  9630. sourceFile: mapping.node.getSourceFile()
  9631. });
  9632. } else {
  9633. relatedMessages.push({
  9634. text: `The event half of the binding is to the '${outputConsumer.name.text}' component.`,
  9635. start: outputConsumer.name.getStart(),
  9636. end: outputConsumer.name.getEnd(),
  9637. sourceFile: outputConsumer.name.getSourceFile()
  9638. });
  9639. }
  9640. this._diagnostics.push(makeTemplateDiagnostic(id, mapping, input.keySpan, ts38.DiagnosticCategory.Error, ngErrorCode(ErrorCode.SPLIT_TWO_WAY_BINDING), errorMsg, relatedMessages));
  9641. }
  9642. missingRequiredInputs(id, element, directiveName, isComponent, inputAliases) {
  9643. const message = `Required input${inputAliases.length === 1 ? "" : "s"} ${inputAliases.map((n2) => `'${n2}'`).join(", ")} from ${isComponent ? "component" : "directive"} ${directiveName} must be specified.`;
  9644. this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), element.startSourceSpan, ts38.DiagnosticCategory.Error, ngErrorCode(ErrorCode.MISSING_REQUIRED_INPUTS), message));
  9645. }
  9646. illegalForLoopTrackAccess(id, block, access) {
  9647. const sourceSpan = this.resolver.toTemplateParseSourceSpan(id, access.sourceSpan);
  9648. if (sourceSpan === null) {
  9649. throw new Error(`Assertion failure: no SourceLocation found for property read.`);
  9650. }
  9651. const messageVars = [block.item, ...block.contextVariables.filter((v) => v.value === "$index")].map((v) => `'${v.name}'`).join(", ");
  9652. const message = `Cannot access '${access.name}' inside of a track expression. Only ${messageVars} and properties on the containing component are available to this expression.`;
  9653. this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), sourceSpan, ts38.DiagnosticCategory.Error, ngErrorCode(ErrorCode.ILLEGAL_FOR_LOOP_TRACK_ACCESS), message));
  9654. }
  9655. inaccessibleDeferredTriggerElement(id, trigger) {
  9656. let message;
  9657. if (trigger.reference === null) {
  9658. message = `Trigger cannot find reference. Make sure that the @defer block has a @placeholder with at least one root element node.`;
  9659. } else {
  9660. message = `Trigger cannot find reference "${trigger.reference}".
  9661. Check that an element with #${trigger.reference} exists in the same template and it's accessible from the @defer block.
  9662. Deferred blocks can only access triggers in same view, a parent embedded view or the root view of the @placeholder block.`;
  9663. }
  9664. this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), trigger.sourceSpan, ts38.DiagnosticCategory.Error, ngErrorCode(ErrorCode.INACCESSIBLE_DEFERRED_TRIGGER_ELEMENT), message));
  9665. }
  9666. controlFlowPreventingContentProjection(id, category, projectionNode, componentName, slotSelector, controlFlowNode, preservesWhitespaces) {
  9667. const blockName = controlFlowNode.nameSpan.toString().trim();
  9668. const lines = [
  9669. `Node matches the "${slotSelector}" slot of the "${componentName}" component, but will not be projected into the specific slot because the surrounding ${blockName} has more than one node at its root. To project the node in the right slot, you can:
  9670. `,
  9671. `1. Wrap the content of the ${blockName} block in an <ng-container/> that matches the "${slotSelector}" selector.`,
  9672. `2. Split the content of the ${blockName} block across multiple ${blockName} blocks such that each one only has a single projectable node at its root.`,
  9673. `3. Remove all content from the ${blockName} block, except for the node being projected.`
  9674. ];
  9675. if (preservesWhitespaces) {
  9676. lines.push("Note: the host component has `preserveWhitespaces: true` which may cause whitespace to affect content projection.");
  9677. }
  9678. lines.push("", 'This check can be disabled using the `extendedDiagnostics.checks.controlFlowPreventingContentProjection = "suppress" compiler option.`');
  9679. this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), projectionNode.startSourceSpan, category, ngErrorCode(ErrorCode.CONTROL_FLOW_PREVENTING_CONTENT_PROJECTION), lines.join("\n")));
  9680. }
  9681. illegalWriteToLetDeclaration(id, node, target) {
  9682. const sourceSpan = this.resolver.toTemplateParseSourceSpan(id, node.sourceSpan);
  9683. if (sourceSpan === null) {
  9684. throw new Error(`Assertion failure: no SourceLocation found for property write.`);
  9685. }
  9686. this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), sourceSpan, ts38.DiagnosticCategory.Error, ngErrorCode(ErrorCode.ILLEGAL_LET_WRITE), `Cannot assign to @let declaration '${target.name}'.`));
  9687. }
  9688. letUsedBeforeDefinition(id, node, target) {
  9689. const sourceSpan = this.resolver.toTemplateParseSourceSpan(id, node.sourceSpan);
  9690. if (sourceSpan === null) {
  9691. throw new Error(`Assertion failure: no SourceLocation found for property read.`);
  9692. }
  9693. this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), sourceSpan, ts38.DiagnosticCategory.Error, ngErrorCode(ErrorCode.LET_USED_BEFORE_DEFINITION), `Cannot read @let declaration '${target.name}' before it has been defined.`));
  9694. }
  9695. conflictingDeclaration(id, decl) {
  9696. const mapping = this.resolver.getTemplateSourceMapping(id);
  9697. const errorMsg = `Cannot declare @let called '${decl.name}' as there is another symbol in the template with the same name.`;
  9698. this._diagnostics.push(makeTemplateDiagnostic(id, mapping, decl.sourceSpan, ts38.DiagnosticCategory.Error, ngErrorCode(ErrorCode.CONFLICTING_LET_DECLARATION), errorMsg));
  9699. }
  9700. };
  9701. function makeInlineDiagnostic(id, code, node, messageText, relatedInformation) {
  9702. return {
  9703. ...makeDiagnostic(code, node, messageText, relatedInformation),
  9704. sourceFile: node.getSourceFile(),
  9705. typeCheckId: id
  9706. };
  9707. }
  9708. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/shim.mjs
  9709. import ts39 from "typescript";
  9710. var TypeCheckShimGenerator = class {
  9711. extensionPrefix = "ngtypecheck";
  9712. shouldEmit = false;
  9713. generateShimForFile(sf, genFilePath, priorShimSf) {
  9714. if (priorShimSf !== null) {
  9715. return priorShimSf;
  9716. }
  9717. return ts39.createSourceFile(genFilePath, "export const USED_FOR_NG_TYPE_CHECKING = true;", ts39.ScriptTarget.Latest, true, ts39.ScriptKind.TS);
  9718. }
  9719. static shimFor(fileName) {
  9720. return absoluteFrom(fileName.replace(/\.tsx?$/, ".ngtypecheck.ts"));
  9721. }
  9722. };
  9723. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/type_check_block.mjs
  9724. import { BindingPipe, BindingType, Call as Call2, createCssSelectorFromNode, CssSelector as CssSelector2, DYNAMIC_TYPE, ImplicitReceiver as ImplicitReceiver2, ParsedEventType, PropertyRead as PropertyRead3, PropertyWrite as PropertyWrite2, R3Identifiers as R3Identifiers4, SafeCall, SafePropertyRead as SafePropertyRead3, SelectorMatcher as SelectorMatcher2, ThisReceiver, TmplAstBoundAttribute, TmplAstBoundText, TmplAstContent, TmplAstDeferredBlock, TmplAstElement as TmplAstElement2, TmplAstForLoopBlock, TmplAstIcu, TmplAstIfBlock, TmplAstIfBlockBranch, TmplAstLetDeclaration as TmplAstLetDeclaration2, TmplAstReference as TmplAstReference2, TmplAstSwitchBlock, TmplAstTemplate, TmplAstText, TmplAstTextAttribute as TmplAstTextAttribute2, TmplAstVariable, TransplantedType } from "@angular/compiler";
  9725. import ts42 from "typescript";
  9726. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/diagnostics.mjs
  9727. import { AbsoluteSourceSpan as AbsoluteSourceSpan3 } from "@angular/compiler";
  9728. import ts40 from "typescript";
  9729. function wrapForDiagnostics(expr) {
  9730. return ts40.factory.createParenthesizedExpression(expr);
  9731. }
  9732. function wrapForTypeChecker(expr) {
  9733. return ts40.factory.createParenthesizedExpression(expr);
  9734. }
  9735. function addParseSpanInfo(node, span) {
  9736. let commentText;
  9737. if (span instanceof AbsoluteSourceSpan3) {
  9738. commentText = `${span.start},${span.end}`;
  9739. } else {
  9740. commentText = `${span.start.offset},${span.end.offset}`;
  9741. }
  9742. ts40.addSyntheticTrailingComment(
  9743. node,
  9744. ts40.SyntaxKind.MultiLineCommentTrivia,
  9745. commentText,
  9746. false
  9747. );
  9748. }
  9749. function addTypeCheckId(tcb, id) {
  9750. ts40.addSyntheticLeadingComment(tcb, ts40.SyntaxKind.MultiLineCommentTrivia, id, true);
  9751. }
  9752. function shouldReportDiagnostic(diagnostic) {
  9753. const { code } = diagnostic;
  9754. if (code === 6133) {
  9755. return false;
  9756. } else if (code === 6199) {
  9757. return false;
  9758. } else if (code === 2695) {
  9759. return false;
  9760. } else if (code === 7006) {
  9761. return false;
  9762. }
  9763. return true;
  9764. }
  9765. function translateDiagnostic(diagnostic, resolver) {
  9766. if (diagnostic.file === void 0 || diagnostic.start === void 0) {
  9767. return null;
  9768. }
  9769. const fullMapping = getSourceMapping(
  9770. diagnostic.file,
  9771. diagnostic.start,
  9772. resolver,
  9773. true
  9774. );
  9775. if (fullMapping === null) {
  9776. return null;
  9777. }
  9778. const { sourceLocation, sourceMapping: templateSourceMapping, span } = fullMapping;
  9779. return makeTemplateDiagnostic(sourceLocation.id, templateSourceMapping, span, diagnostic.category, diagnostic.code, diagnostic.messageText);
  9780. }
  9781. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/expression.mjs
  9782. import { ASTWithSource, Call, EmptyExpr as EmptyExpr2, PropertyRead as PropertyRead2, SafeKeyedRead, SafePropertyRead as SafePropertyRead2 } from "@angular/compiler";
  9783. import ts41 from "typescript";
  9784. var ANY_EXPRESSION = ts41.factory.createAsExpression(ts41.factory.createNumericLiteral("0"), ts41.factory.createKeywordTypeNode(ts41.SyntaxKind.AnyKeyword));
  9785. var UNDEFINED = ts41.factory.createIdentifier("undefined");
  9786. var UNARY_OPS = /* @__PURE__ */ new Map([
  9787. ["+", ts41.SyntaxKind.PlusToken],
  9788. ["-", ts41.SyntaxKind.MinusToken]
  9789. ]);
  9790. var BINARY_OPS = /* @__PURE__ */ new Map([
  9791. ["+", ts41.SyntaxKind.PlusToken],
  9792. ["-", ts41.SyntaxKind.MinusToken],
  9793. ["<", ts41.SyntaxKind.LessThanToken],
  9794. [">", ts41.SyntaxKind.GreaterThanToken],
  9795. ["<=", ts41.SyntaxKind.LessThanEqualsToken],
  9796. [">=", ts41.SyntaxKind.GreaterThanEqualsToken],
  9797. ["==", ts41.SyntaxKind.EqualsEqualsToken],
  9798. ["===", ts41.SyntaxKind.EqualsEqualsEqualsToken],
  9799. ["*", ts41.SyntaxKind.AsteriskToken],
  9800. ["/", ts41.SyntaxKind.SlashToken],
  9801. ["%", ts41.SyntaxKind.PercentToken],
  9802. ["!=", ts41.SyntaxKind.ExclamationEqualsToken],
  9803. ["!==", ts41.SyntaxKind.ExclamationEqualsEqualsToken],
  9804. ["||", ts41.SyntaxKind.BarBarToken],
  9805. ["&&", ts41.SyntaxKind.AmpersandAmpersandToken],
  9806. ["&", ts41.SyntaxKind.AmpersandToken],
  9807. ["|", ts41.SyntaxKind.BarToken],
  9808. ["??", ts41.SyntaxKind.QuestionQuestionToken]
  9809. ]);
  9810. function astToTypescript(ast, maybeResolve, config) {
  9811. const translator = new AstTranslator(maybeResolve, config);
  9812. return translator.translate(ast);
  9813. }
  9814. var AstTranslator = class {
  9815. maybeResolve;
  9816. config;
  9817. constructor(maybeResolve, config) {
  9818. this.maybeResolve = maybeResolve;
  9819. this.config = config;
  9820. }
  9821. translate(ast) {
  9822. if (ast instanceof ASTWithSource) {
  9823. ast = ast.ast;
  9824. }
  9825. if (ast instanceof EmptyExpr2) {
  9826. const res = ts41.factory.createIdentifier("undefined");
  9827. addParseSpanInfo(res, ast.sourceSpan);
  9828. return res;
  9829. }
  9830. const resolved = this.maybeResolve(ast);
  9831. if (resolved !== null) {
  9832. return resolved;
  9833. }
  9834. return ast.visit(this);
  9835. }
  9836. visitUnary(ast) {
  9837. const expr = this.translate(ast.expr);
  9838. const op = UNARY_OPS.get(ast.operator);
  9839. if (op === void 0) {
  9840. throw new Error(`Unsupported Unary.operator: ${ast.operator}`);
  9841. }
  9842. const node = wrapForDiagnostics(ts41.factory.createPrefixUnaryExpression(op, expr));
  9843. addParseSpanInfo(node, ast.sourceSpan);
  9844. return node;
  9845. }
  9846. visitBinary(ast) {
  9847. const lhs = wrapForDiagnostics(this.translate(ast.left));
  9848. const rhs = wrapForDiagnostics(this.translate(ast.right));
  9849. const op = BINARY_OPS.get(ast.operation);
  9850. if (op === void 0) {
  9851. throw new Error(`Unsupported Binary.operation: ${ast.operation}`);
  9852. }
  9853. const node = ts41.factory.createBinaryExpression(lhs, op, rhs);
  9854. addParseSpanInfo(node, ast.sourceSpan);
  9855. return node;
  9856. }
  9857. visitChain(ast) {
  9858. const elements = ast.expressions.map((expr) => this.translate(expr));
  9859. const node = wrapForDiagnostics(ts41.factory.createCommaListExpression(elements));
  9860. addParseSpanInfo(node, ast.sourceSpan);
  9861. return node;
  9862. }
  9863. visitConditional(ast) {
  9864. const condExpr = this.translate(ast.condition);
  9865. const trueExpr = this.translate(ast.trueExp);
  9866. const falseExpr = wrapForTypeChecker(this.translate(ast.falseExp));
  9867. const node = ts41.factory.createParenthesizedExpression(ts41.factory.createConditionalExpression(condExpr, void 0, trueExpr, void 0, falseExpr));
  9868. addParseSpanInfo(node, ast.sourceSpan);
  9869. return node;
  9870. }
  9871. visitImplicitReceiver(ast) {
  9872. throw new Error("Method not implemented.");
  9873. }
  9874. visitThisReceiver(ast) {
  9875. throw new Error("Method not implemented.");
  9876. }
  9877. visitInterpolation(ast) {
  9878. return ast.expressions.reduce((lhs, ast2) => ts41.factory.createBinaryExpression(lhs, ts41.SyntaxKind.PlusToken, wrapForTypeChecker(this.translate(ast2))), ts41.factory.createStringLiteral(""));
  9879. }
  9880. visitKeyedRead(ast) {
  9881. const receiver = wrapForDiagnostics(this.translate(ast.receiver));
  9882. const key = this.translate(ast.key);
  9883. const node = ts41.factory.createElementAccessExpression(receiver, key);
  9884. addParseSpanInfo(node, ast.sourceSpan);
  9885. return node;
  9886. }
  9887. visitKeyedWrite(ast) {
  9888. const receiver = wrapForDiagnostics(this.translate(ast.receiver));
  9889. const left = ts41.factory.createElementAccessExpression(receiver, this.translate(ast.key));
  9890. const right = wrapForTypeChecker(this.translate(ast.value));
  9891. const node = wrapForDiagnostics(ts41.factory.createBinaryExpression(left, ts41.SyntaxKind.EqualsToken, right));
  9892. addParseSpanInfo(node, ast.sourceSpan);
  9893. return node;
  9894. }
  9895. visitLiteralArray(ast) {
  9896. const elements = ast.expressions.map((expr) => this.translate(expr));
  9897. const literal3 = ts41.factory.createArrayLiteralExpression(elements);
  9898. const node = this.config.strictLiteralTypes ? literal3 : tsCastToAny(literal3);
  9899. addParseSpanInfo(node, ast.sourceSpan);
  9900. return node;
  9901. }
  9902. visitLiteralMap(ast) {
  9903. const properties = ast.keys.map(({ key }, idx) => {
  9904. const value = this.translate(ast.values[idx]);
  9905. return ts41.factory.createPropertyAssignment(ts41.factory.createStringLiteral(key), value);
  9906. });
  9907. const literal3 = ts41.factory.createObjectLiteralExpression(properties, true);
  9908. const node = this.config.strictLiteralTypes ? literal3 : tsCastToAny(literal3);
  9909. addParseSpanInfo(node, ast.sourceSpan);
  9910. return node;
  9911. }
  9912. visitLiteralPrimitive(ast) {
  9913. let node;
  9914. if (ast.value === void 0) {
  9915. node = ts41.factory.createIdentifier("undefined");
  9916. } else if (ast.value === null) {
  9917. node = ts41.factory.createNull();
  9918. } else if (typeof ast.value === "string") {
  9919. node = ts41.factory.createStringLiteral(ast.value);
  9920. } else if (typeof ast.value === "number") {
  9921. node = tsNumericExpression(ast.value);
  9922. } else if (typeof ast.value === "boolean") {
  9923. node = ast.value ? ts41.factory.createTrue() : ts41.factory.createFalse();
  9924. } else {
  9925. throw Error(`Unsupported AST value of type ${typeof ast.value}`);
  9926. }
  9927. addParseSpanInfo(node, ast.sourceSpan);
  9928. return node;
  9929. }
  9930. visitNonNullAssert(ast) {
  9931. const expr = wrapForDiagnostics(this.translate(ast.expression));
  9932. const node = ts41.factory.createNonNullExpression(expr);
  9933. addParseSpanInfo(node, ast.sourceSpan);
  9934. return node;
  9935. }
  9936. visitPipe(ast) {
  9937. throw new Error("Method not implemented.");
  9938. }
  9939. visitPrefixNot(ast) {
  9940. const expression = wrapForDiagnostics(this.translate(ast.expression));
  9941. const node = ts41.factory.createLogicalNot(expression);
  9942. addParseSpanInfo(node, ast.sourceSpan);
  9943. return node;
  9944. }
  9945. visitTypeofExpression(ast) {
  9946. const expression = wrapForDiagnostics(this.translate(ast.expression));
  9947. const node = ts41.factory.createTypeOfExpression(expression);
  9948. addParseSpanInfo(node, ast.sourceSpan);
  9949. return node;
  9950. }
  9951. visitPropertyRead(ast) {
  9952. const receiver = wrapForDiagnostics(this.translate(ast.receiver));
  9953. const name = ts41.factory.createPropertyAccessExpression(receiver, ast.name);
  9954. addParseSpanInfo(name, ast.nameSpan);
  9955. const node = wrapForDiagnostics(name);
  9956. addParseSpanInfo(node, ast.sourceSpan);
  9957. return node;
  9958. }
  9959. visitPropertyWrite(ast) {
  9960. const receiver = wrapForDiagnostics(this.translate(ast.receiver));
  9961. const left = ts41.factory.createPropertyAccessExpression(receiver, ast.name);
  9962. addParseSpanInfo(left, ast.nameSpan);
  9963. const leftWithPath = wrapForDiagnostics(left);
  9964. addParseSpanInfo(leftWithPath, ast.sourceSpan);
  9965. const right = wrapForTypeChecker(this.translate(ast.value));
  9966. const node = wrapForDiagnostics(ts41.factory.createBinaryExpression(leftWithPath, ts41.SyntaxKind.EqualsToken, right));
  9967. addParseSpanInfo(node, ast.sourceSpan);
  9968. return node;
  9969. }
  9970. visitSafePropertyRead(ast) {
  9971. let node;
  9972. const receiver = wrapForDiagnostics(this.translate(ast.receiver));
  9973. if (this.config.strictSafeNavigationTypes) {
  9974. const expr = ts41.factory.createPropertyAccessExpression(ts41.factory.createNonNullExpression(receiver), ast.name);
  9975. addParseSpanInfo(expr, ast.nameSpan);
  9976. node = ts41.factory.createParenthesizedExpression(ts41.factory.createConditionalExpression(ANY_EXPRESSION, void 0, expr, void 0, UNDEFINED));
  9977. } else if (VeSafeLhsInferenceBugDetector.veWillInferAnyFor(ast)) {
  9978. node = ts41.factory.createPropertyAccessExpression(tsCastToAny(receiver), ast.name);
  9979. } else {
  9980. const expr = ts41.factory.createPropertyAccessExpression(ts41.factory.createNonNullExpression(receiver), ast.name);
  9981. addParseSpanInfo(expr, ast.nameSpan);
  9982. node = tsCastToAny(expr);
  9983. }
  9984. addParseSpanInfo(node, ast.sourceSpan);
  9985. return node;
  9986. }
  9987. visitSafeKeyedRead(ast) {
  9988. const receiver = wrapForDiagnostics(this.translate(ast.receiver));
  9989. const key = this.translate(ast.key);
  9990. let node;
  9991. if (this.config.strictSafeNavigationTypes) {
  9992. const expr = ts41.factory.createElementAccessExpression(ts41.factory.createNonNullExpression(receiver), key);
  9993. addParseSpanInfo(expr, ast.sourceSpan);
  9994. node = ts41.factory.createParenthesizedExpression(ts41.factory.createConditionalExpression(ANY_EXPRESSION, void 0, expr, void 0, UNDEFINED));
  9995. } else if (VeSafeLhsInferenceBugDetector.veWillInferAnyFor(ast)) {
  9996. node = ts41.factory.createElementAccessExpression(tsCastToAny(receiver), key);
  9997. } else {
  9998. const expr = ts41.factory.createElementAccessExpression(ts41.factory.createNonNullExpression(receiver), key);
  9999. addParseSpanInfo(expr, ast.sourceSpan);
  10000. node = tsCastToAny(expr);
  10001. }
  10002. addParseSpanInfo(node, ast.sourceSpan);
  10003. return node;
  10004. }
  10005. visitCall(ast) {
  10006. const args = ast.args.map((expr2) => this.translate(expr2));
  10007. let expr;
  10008. const receiver = ast.receiver;
  10009. if (receiver instanceof PropertyRead2) {
  10010. const resolved = this.maybeResolve(receiver);
  10011. if (resolved !== null) {
  10012. expr = resolved;
  10013. } else {
  10014. const propertyReceiver = wrapForDiagnostics(this.translate(receiver.receiver));
  10015. expr = ts41.factory.createPropertyAccessExpression(propertyReceiver, receiver.name);
  10016. addParseSpanInfo(expr, receiver.nameSpan);
  10017. }
  10018. } else {
  10019. expr = this.translate(receiver);
  10020. }
  10021. let node;
  10022. if (ast.receiver instanceof SafePropertyRead2 || ast.receiver instanceof SafeKeyedRead) {
  10023. node = this.convertToSafeCall(ast, expr, args);
  10024. } else {
  10025. node = ts41.factory.createCallExpression(expr, void 0, args);
  10026. }
  10027. addParseSpanInfo(node, ast.sourceSpan);
  10028. return node;
  10029. }
  10030. visitSafeCall(ast) {
  10031. const args = ast.args.map((expr2) => this.translate(expr2));
  10032. const expr = wrapForDiagnostics(this.translate(ast.receiver));
  10033. const node = this.convertToSafeCall(ast, expr, args);
  10034. addParseSpanInfo(node, ast.sourceSpan);
  10035. return node;
  10036. }
  10037. visitTemplateLiteral(ast) {
  10038. const length = ast.elements.length;
  10039. const head = ast.elements[0];
  10040. let result;
  10041. if (length === 1) {
  10042. result = ts41.factory.createNoSubstitutionTemplateLiteral(head.text);
  10043. } else {
  10044. const spans = [];
  10045. const tailIndex = length - 1;
  10046. for (let i = 1; i < tailIndex; i++) {
  10047. const middle = ts41.factory.createTemplateMiddle(ast.elements[i].text);
  10048. spans.push(ts41.factory.createTemplateSpan(this.translate(ast.expressions[i - 1]), middle));
  10049. }
  10050. const resolvedExpression = this.translate(ast.expressions[tailIndex - 1]);
  10051. const templateTail = ts41.factory.createTemplateTail(ast.elements[tailIndex].text);
  10052. spans.push(ts41.factory.createTemplateSpan(resolvedExpression, templateTail));
  10053. result = ts41.factory.createTemplateExpression(ts41.factory.createTemplateHead(head.text), spans);
  10054. }
  10055. return result;
  10056. }
  10057. visitTemplateLiteralElement(ast, context) {
  10058. throw new Error("Method not implemented");
  10059. }
  10060. convertToSafeCall(ast, expr, args) {
  10061. if (this.config.strictSafeNavigationTypes) {
  10062. const call = ts41.factory.createCallExpression(ts41.factory.createNonNullExpression(expr), void 0, args);
  10063. return ts41.factory.createParenthesizedExpression(ts41.factory.createConditionalExpression(ANY_EXPRESSION, void 0, call, void 0, UNDEFINED));
  10064. }
  10065. if (VeSafeLhsInferenceBugDetector.veWillInferAnyFor(ast)) {
  10066. return ts41.factory.createCallExpression(tsCastToAny(expr), void 0, args);
  10067. }
  10068. return tsCastToAny(ts41.factory.createCallExpression(ts41.factory.createNonNullExpression(expr), void 0, args));
  10069. }
  10070. };
  10071. var _VeSafeLhsInferenceBugDetector = class {
  10072. static veWillInferAnyFor(ast) {
  10073. const visitor = _VeSafeLhsInferenceBugDetector.SINGLETON;
  10074. return ast instanceof Call ? ast.visit(visitor) : ast.receiver.visit(visitor);
  10075. }
  10076. visitUnary(ast) {
  10077. return ast.expr.visit(this);
  10078. }
  10079. visitBinary(ast) {
  10080. return ast.left.visit(this) || ast.right.visit(this);
  10081. }
  10082. visitChain(ast) {
  10083. return false;
  10084. }
  10085. visitConditional(ast) {
  10086. return ast.condition.visit(this) || ast.trueExp.visit(this) || ast.falseExp.visit(this);
  10087. }
  10088. visitCall(ast) {
  10089. return true;
  10090. }
  10091. visitSafeCall(ast) {
  10092. return false;
  10093. }
  10094. visitImplicitReceiver(ast) {
  10095. return false;
  10096. }
  10097. visitThisReceiver(ast) {
  10098. return false;
  10099. }
  10100. visitInterpolation(ast) {
  10101. return ast.expressions.some((exp) => exp.visit(this));
  10102. }
  10103. visitKeyedRead(ast) {
  10104. return false;
  10105. }
  10106. visitKeyedWrite(ast) {
  10107. return false;
  10108. }
  10109. visitLiteralArray(ast) {
  10110. return true;
  10111. }
  10112. visitLiteralMap(ast) {
  10113. return true;
  10114. }
  10115. visitLiteralPrimitive(ast) {
  10116. return false;
  10117. }
  10118. visitPipe(ast) {
  10119. return true;
  10120. }
  10121. visitPrefixNot(ast) {
  10122. return ast.expression.visit(this);
  10123. }
  10124. visitTypeofExpression(ast) {
  10125. return ast.expression.visit(this);
  10126. }
  10127. visitNonNullAssert(ast) {
  10128. return ast.expression.visit(this);
  10129. }
  10130. visitPropertyRead(ast) {
  10131. return false;
  10132. }
  10133. visitPropertyWrite(ast) {
  10134. return false;
  10135. }
  10136. visitSafePropertyRead(ast) {
  10137. return false;
  10138. }
  10139. visitSafeKeyedRead(ast) {
  10140. return false;
  10141. }
  10142. visitTemplateLiteral(ast, context) {
  10143. return false;
  10144. }
  10145. visitTemplateLiteralElement(ast, context) {
  10146. return false;
  10147. }
  10148. };
  10149. var VeSafeLhsInferenceBugDetector = _VeSafeLhsInferenceBugDetector;
  10150. __publicField(VeSafeLhsInferenceBugDetector, "SINGLETON", new _VeSafeLhsInferenceBugDetector());
  10151. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/type_check_block.mjs
  10152. var TcbGenericContextBehavior;
  10153. (function(TcbGenericContextBehavior2) {
  10154. TcbGenericContextBehavior2[TcbGenericContextBehavior2["UseEmitter"] = 0] = "UseEmitter";
  10155. TcbGenericContextBehavior2[TcbGenericContextBehavior2["CopyClassNodes"] = 1] = "CopyClassNodes";
  10156. TcbGenericContextBehavior2[TcbGenericContextBehavior2["FallbackToAny"] = 2] = "FallbackToAny";
  10157. })(TcbGenericContextBehavior || (TcbGenericContextBehavior = {}));
  10158. function generateTypeCheckBlock(env, ref, name, meta, domSchemaChecker, oobRecorder, genericContextBehavior) {
  10159. const tcb = new Context(env, domSchemaChecker, oobRecorder, meta.id, meta.boundTarget, meta.pipes, meta.schemas, meta.isStandalone, meta.preserveWhitespaces);
  10160. const scope = Scope.forNodes(tcb, null, null, tcb.boundTarget.target.template, null);
  10161. const ctxRawType = env.referenceType(ref);
  10162. if (!ts42.isTypeReferenceNode(ctxRawType)) {
  10163. throw new Error(`Expected TypeReferenceNode when referencing the ctx param for ${ref.debugName}`);
  10164. }
  10165. let typeParameters = void 0;
  10166. let typeArguments = void 0;
  10167. if (ref.node.typeParameters !== void 0) {
  10168. if (!env.config.useContextGenericType) {
  10169. genericContextBehavior = TcbGenericContextBehavior.FallbackToAny;
  10170. }
  10171. switch (genericContextBehavior) {
  10172. case TcbGenericContextBehavior.UseEmitter:
  10173. typeParameters = new TypeParameterEmitter(ref.node.typeParameters, env.reflector).emit((typeRef) => env.referenceType(typeRef));
  10174. typeArguments = typeParameters.map((param) => ts42.factory.createTypeReferenceNode(param.name));
  10175. break;
  10176. case TcbGenericContextBehavior.CopyClassNodes:
  10177. typeParameters = [...ref.node.typeParameters];
  10178. typeArguments = typeParameters.map((param) => ts42.factory.createTypeReferenceNode(param.name));
  10179. break;
  10180. case TcbGenericContextBehavior.FallbackToAny:
  10181. typeArguments = ref.node.typeParameters.map(() => ts42.factory.createKeywordTypeNode(ts42.SyntaxKind.AnyKeyword));
  10182. break;
  10183. }
  10184. }
  10185. const paramList = [tcbThisParam(ctxRawType.typeName, typeArguments)];
  10186. const scopeStatements = scope.render();
  10187. const innerBody = ts42.factory.createBlock([...env.getPreludeStatements(), ...scopeStatements]);
  10188. const body = ts42.factory.createBlock([
  10189. ts42.factory.createIfStatement(ts42.factory.createTrue(), innerBody, void 0)
  10190. ]);
  10191. const fnDecl = ts42.factory.createFunctionDeclaration(
  10192. void 0,
  10193. void 0,
  10194. name,
  10195. env.config.useContextGenericType ? typeParameters : void 0,
  10196. paramList,
  10197. void 0,
  10198. body
  10199. );
  10200. addTypeCheckId(fnDecl, meta.id);
  10201. return fnDecl;
  10202. }
  10203. var TcbOp = class {
  10204. circularFallback() {
  10205. return INFER_TYPE_FOR_CIRCULAR_OP_EXPR;
  10206. }
  10207. };
  10208. var TcbElementOp = class extends TcbOp {
  10209. tcb;
  10210. scope;
  10211. element;
  10212. constructor(tcb, scope, element) {
  10213. super();
  10214. this.tcb = tcb;
  10215. this.scope = scope;
  10216. this.element = element;
  10217. }
  10218. get optional() {
  10219. return true;
  10220. }
  10221. execute() {
  10222. const id = this.tcb.allocateId();
  10223. const initializer = tsCreateElement(this.element.name);
  10224. addParseSpanInfo(initializer, this.element.startSourceSpan || this.element.sourceSpan);
  10225. this.scope.addStatement(tsCreateVariable(id, initializer));
  10226. return id;
  10227. }
  10228. };
  10229. var TcbTemplateVariableOp = class extends TcbOp {
  10230. tcb;
  10231. scope;
  10232. template;
  10233. variable;
  10234. constructor(tcb, scope, template, variable) {
  10235. super();
  10236. this.tcb = tcb;
  10237. this.scope = scope;
  10238. this.template = template;
  10239. this.variable = variable;
  10240. }
  10241. get optional() {
  10242. return false;
  10243. }
  10244. execute() {
  10245. const ctx = this.scope.resolve(this.template);
  10246. const id = this.tcb.allocateId();
  10247. const initializer = ts42.factory.createPropertyAccessExpression(
  10248. ctx,
  10249. this.variable.value || "$implicit"
  10250. );
  10251. addParseSpanInfo(id, this.variable.keySpan);
  10252. let variable;
  10253. if (this.variable.valueSpan !== void 0) {
  10254. addParseSpanInfo(initializer, this.variable.valueSpan);
  10255. variable = tsCreateVariable(id, wrapForTypeChecker(initializer));
  10256. } else {
  10257. variable = tsCreateVariable(id, initializer);
  10258. }
  10259. addParseSpanInfo(variable.declarationList.declarations[0], this.variable.sourceSpan);
  10260. this.scope.addStatement(variable);
  10261. return id;
  10262. }
  10263. };
  10264. var TcbTemplateContextOp = class extends TcbOp {
  10265. tcb;
  10266. scope;
  10267. constructor(tcb, scope) {
  10268. super();
  10269. this.tcb = tcb;
  10270. this.scope = scope;
  10271. }
  10272. optional = true;
  10273. execute() {
  10274. const ctx = this.tcb.allocateId();
  10275. const type = ts42.factory.createKeywordTypeNode(ts42.SyntaxKind.AnyKeyword);
  10276. this.scope.addStatement(tsDeclareVariable(ctx, type));
  10277. return ctx;
  10278. }
  10279. };
  10280. var TcbLetDeclarationOp = class extends TcbOp {
  10281. tcb;
  10282. scope;
  10283. node;
  10284. constructor(tcb, scope, node) {
  10285. super();
  10286. this.tcb = tcb;
  10287. this.scope = scope;
  10288. this.node = node;
  10289. }
  10290. optional = false;
  10291. execute() {
  10292. const id = this.tcb.allocateId();
  10293. addParseSpanInfo(id, this.node.nameSpan);
  10294. const value = tcbExpression(this.node.value, this.tcb, this.scope);
  10295. const varStatement = tsCreateVariable(id, wrapForTypeChecker(value), ts42.NodeFlags.Const);
  10296. addParseSpanInfo(varStatement.declarationList.declarations[0], this.node.sourceSpan);
  10297. this.scope.addStatement(varStatement);
  10298. return id;
  10299. }
  10300. };
  10301. var TcbTemplateBodyOp = class extends TcbOp {
  10302. tcb;
  10303. scope;
  10304. template;
  10305. constructor(tcb, scope, template) {
  10306. super();
  10307. this.tcb = tcb;
  10308. this.scope = scope;
  10309. this.template = template;
  10310. }
  10311. get optional() {
  10312. return false;
  10313. }
  10314. execute() {
  10315. const directiveGuards = [];
  10316. const directives = this.tcb.boundTarget.getDirectivesOfNode(this.template);
  10317. if (directives !== null) {
  10318. for (const dir of directives) {
  10319. const dirInstId = this.scope.resolve(this.template, dir);
  10320. const dirId = this.tcb.env.reference(dir.ref);
  10321. dir.ngTemplateGuards.forEach((guard2) => {
  10322. const boundInput = this.template.inputs.find((i) => i.name === guard2.inputName) || this.template.templateAttrs.find((i) => i instanceof TmplAstBoundAttribute && i.name === guard2.inputName);
  10323. if (boundInput !== void 0) {
  10324. const expr = tcbExpression(boundInput.value, this.tcb, this.scope);
  10325. markIgnoreDiagnostics(expr);
  10326. if (guard2.type === "binding") {
  10327. directiveGuards.push(expr);
  10328. } else {
  10329. const guardInvoke = tsCallMethod(dirId, `ngTemplateGuard_${guard2.inputName}`, [
  10330. dirInstId,
  10331. expr
  10332. ]);
  10333. addParseSpanInfo(guardInvoke, boundInput.value.sourceSpan);
  10334. directiveGuards.push(guardInvoke);
  10335. }
  10336. }
  10337. });
  10338. if (dir.hasNgTemplateContextGuard) {
  10339. if (this.tcb.env.config.applyTemplateContextGuards) {
  10340. const ctx = this.scope.resolve(this.template);
  10341. const guardInvoke = tsCallMethod(dirId, "ngTemplateContextGuard", [dirInstId, ctx]);
  10342. addParseSpanInfo(guardInvoke, this.template.sourceSpan);
  10343. directiveGuards.push(guardInvoke);
  10344. } else if (this.template.variables.length > 0 && this.tcb.env.config.suggestionsForSuboptimalTypeInference) {
  10345. this.tcb.oobRecorder.suboptimalTypeInference(this.tcb.id, this.template.variables);
  10346. }
  10347. }
  10348. }
  10349. }
  10350. let guard = null;
  10351. if (directiveGuards.length > 0) {
  10352. guard = directiveGuards.reduce((expr, dirGuard) => ts42.factory.createBinaryExpression(expr, ts42.SyntaxKind.AmpersandAmpersandToken, dirGuard), directiveGuards.pop());
  10353. }
  10354. const tmplScope = Scope.forNodes(this.tcb, this.scope, this.template, this.template.children, guard);
  10355. const statements = tmplScope.render();
  10356. if (statements.length === 0) {
  10357. return null;
  10358. }
  10359. let tmplBlock = ts42.factory.createBlock(statements);
  10360. if (guard !== null) {
  10361. tmplBlock = ts42.factory.createIfStatement(
  10362. guard,
  10363. tmplBlock
  10364. );
  10365. }
  10366. this.scope.addStatement(tmplBlock);
  10367. return null;
  10368. }
  10369. };
  10370. var TcbExpressionOp = class extends TcbOp {
  10371. tcb;
  10372. scope;
  10373. expression;
  10374. constructor(tcb, scope, expression) {
  10375. super();
  10376. this.tcb = tcb;
  10377. this.scope = scope;
  10378. this.expression = expression;
  10379. }
  10380. get optional() {
  10381. return false;
  10382. }
  10383. execute() {
  10384. const expr = tcbExpression(this.expression, this.tcb, this.scope);
  10385. this.scope.addStatement(ts42.factory.createExpressionStatement(expr));
  10386. return null;
  10387. }
  10388. };
  10389. var TcbDirectiveTypeOpBase = class extends TcbOp {
  10390. tcb;
  10391. scope;
  10392. node;
  10393. dir;
  10394. constructor(tcb, scope, node, dir) {
  10395. super();
  10396. this.tcb = tcb;
  10397. this.scope = scope;
  10398. this.node = node;
  10399. this.dir = dir;
  10400. }
  10401. get optional() {
  10402. return true;
  10403. }
  10404. execute() {
  10405. const dirRef = this.dir.ref;
  10406. const rawType = this.tcb.env.referenceType(this.dir.ref);
  10407. let type;
  10408. if (this.dir.isGeneric === false || dirRef.node.typeParameters === void 0) {
  10409. type = rawType;
  10410. } else {
  10411. if (!ts42.isTypeReferenceNode(rawType)) {
  10412. throw new Error(`Expected TypeReferenceNode when referencing the type for ${this.dir.ref.debugName}`);
  10413. }
  10414. const typeArguments = dirRef.node.typeParameters.map(() => ts42.factory.createKeywordTypeNode(ts42.SyntaxKind.AnyKeyword));
  10415. type = ts42.factory.createTypeReferenceNode(rawType.typeName, typeArguments);
  10416. }
  10417. const id = this.tcb.allocateId();
  10418. addExpressionIdentifier(id, ExpressionIdentifier.DIRECTIVE);
  10419. addParseSpanInfo(id, this.node.startSourceSpan || this.node.sourceSpan);
  10420. this.scope.addStatement(tsDeclareVariable(id, type));
  10421. return id;
  10422. }
  10423. };
  10424. var TcbNonGenericDirectiveTypeOp = class extends TcbDirectiveTypeOpBase {
  10425. execute() {
  10426. const dirRef = this.dir.ref;
  10427. if (this.dir.isGeneric) {
  10428. throw new Error(`Assertion Error: expected ${dirRef.debugName} not to be generic.`);
  10429. }
  10430. return super.execute();
  10431. }
  10432. };
  10433. var TcbGenericDirectiveTypeWithAnyParamsOp = class extends TcbDirectiveTypeOpBase {
  10434. execute() {
  10435. const dirRef = this.dir.ref;
  10436. if (dirRef.node.typeParameters === void 0) {
  10437. throw new Error(`Assertion Error: expected typeParameters when creating a declaration for ${dirRef.debugName}`);
  10438. }
  10439. return super.execute();
  10440. }
  10441. };
  10442. var TcbReferenceOp = class extends TcbOp {
  10443. tcb;
  10444. scope;
  10445. node;
  10446. host;
  10447. target;
  10448. constructor(tcb, scope, node, host, target) {
  10449. super();
  10450. this.tcb = tcb;
  10451. this.scope = scope;
  10452. this.node = node;
  10453. this.host = host;
  10454. this.target = target;
  10455. }
  10456. optional = true;
  10457. execute() {
  10458. const id = this.tcb.allocateId();
  10459. let initializer = this.target instanceof TmplAstTemplate || this.target instanceof TmplAstElement2 ? this.scope.resolve(this.target) : this.scope.resolve(this.host, this.target);
  10460. if (this.target instanceof TmplAstElement2 && !this.tcb.env.config.checkTypeOfDomReferences || !this.tcb.env.config.checkTypeOfNonDomReferences) {
  10461. initializer = ts42.factory.createAsExpression(initializer, ts42.factory.createKeywordTypeNode(ts42.SyntaxKind.AnyKeyword));
  10462. } else if (this.target instanceof TmplAstTemplate) {
  10463. initializer = ts42.factory.createAsExpression(initializer, ts42.factory.createKeywordTypeNode(ts42.SyntaxKind.AnyKeyword));
  10464. initializer = ts42.factory.createAsExpression(initializer, this.tcb.env.referenceExternalType("@angular/core", "TemplateRef", [DYNAMIC_TYPE]));
  10465. initializer = ts42.factory.createParenthesizedExpression(initializer);
  10466. }
  10467. addParseSpanInfo(initializer, this.node.sourceSpan);
  10468. addParseSpanInfo(id, this.node.keySpan);
  10469. this.scope.addStatement(tsCreateVariable(id, initializer));
  10470. return id;
  10471. }
  10472. };
  10473. var TcbInvalidReferenceOp = class extends TcbOp {
  10474. tcb;
  10475. scope;
  10476. constructor(tcb, scope) {
  10477. super();
  10478. this.tcb = tcb;
  10479. this.scope = scope;
  10480. }
  10481. optional = true;
  10482. execute() {
  10483. const id = this.tcb.allocateId();
  10484. this.scope.addStatement(tsCreateVariable(id, ANY_EXPRESSION));
  10485. return id;
  10486. }
  10487. };
  10488. var TcbDirectiveCtorOp = class extends TcbOp {
  10489. tcb;
  10490. scope;
  10491. node;
  10492. dir;
  10493. constructor(tcb, scope, node, dir) {
  10494. super();
  10495. this.tcb = tcb;
  10496. this.scope = scope;
  10497. this.node = node;
  10498. this.dir = dir;
  10499. }
  10500. get optional() {
  10501. return true;
  10502. }
  10503. execute() {
  10504. const id = this.tcb.allocateId();
  10505. addExpressionIdentifier(id, ExpressionIdentifier.DIRECTIVE);
  10506. addParseSpanInfo(id, this.node.startSourceSpan || this.node.sourceSpan);
  10507. const genericInputs = /* @__PURE__ */ new Map();
  10508. const boundAttrs = getBoundAttributes(this.dir, this.node);
  10509. for (const attr of boundAttrs) {
  10510. if (!this.tcb.env.config.checkTypeOfAttributes && attr.attribute instanceof TmplAstTextAttribute2) {
  10511. continue;
  10512. }
  10513. for (const { fieldName, isTwoWayBinding } of attr.inputs) {
  10514. if (genericInputs.has(fieldName)) {
  10515. continue;
  10516. }
  10517. const expression = translateInput(attr.attribute, this.tcb, this.scope);
  10518. genericInputs.set(fieldName, {
  10519. type: "binding",
  10520. field: fieldName,
  10521. expression,
  10522. sourceSpan: attr.attribute.sourceSpan,
  10523. isTwoWayBinding
  10524. });
  10525. }
  10526. }
  10527. for (const { classPropertyName } of this.dir.inputs) {
  10528. if (!genericInputs.has(classPropertyName)) {
  10529. genericInputs.set(classPropertyName, { type: "unset", field: classPropertyName });
  10530. }
  10531. }
  10532. const typeCtor = tcbCallTypeCtor(this.dir, this.tcb, Array.from(genericInputs.values()));
  10533. markIgnoreDiagnostics(typeCtor);
  10534. this.scope.addStatement(tsCreateVariable(id, typeCtor));
  10535. return id;
  10536. }
  10537. circularFallback() {
  10538. return new TcbDirectiveCtorCircularFallbackOp(this.tcb, this.scope, this.node, this.dir);
  10539. }
  10540. };
  10541. var TcbDirectiveInputsOp = class extends TcbOp {
  10542. tcb;
  10543. scope;
  10544. node;
  10545. dir;
  10546. constructor(tcb, scope, node, dir) {
  10547. super();
  10548. this.tcb = tcb;
  10549. this.scope = scope;
  10550. this.node = node;
  10551. this.dir = dir;
  10552. }
  10553. get optional() {
  10554. return false;
  10555. }
  10556. execute() {
  10557. let dirId = null;
  10558. const boundAttrs = getBoundAttributes(this.dir, this.node);
  10559. const seenRequiredInputs = /* @__PURE__ */ new Set();
  10560. for (const attr of boundAttrs) {
  10561. const expr = widenBinding(translateInput(attr.attribute, this.tcb, this.scope), this.tcb);
  10562. let assignment = wrapForDiagnostics(expr);
  10563. for (const { fieldName, required, transformType, isSignal, isTwoWayBinding } of attr.inputs) {
  10564. let target;
  10565. if (required) {
  10566. seenRequiredInputs.add(fieldName);
  10567. }
  10568. if (this.dir.coercedInputFields.has(fieldName)) {
  10569. let type;
  10570. if (transformType !== null) {
  10571. type = this.tcb.env.referenceTransplantedType(new TransplantedType(transformType));
  10572. } else {
  10573. const dirTypeRef = this.tcb.env.referenceType(this.dir.ref);
  10574. if (!ts42.isTypeReferenceNode(dirTypeRef)) {
  10575. throw new Error(`Expected TypeReferenceNode from reference to ${this.dir.ref.debugName}`);
  10576. }
  10577. type = tsCreateTypeQueryForCoercedInput(dirTypeRef.typeName, fieldName);
  10578. }
  10579. const id = this.tcb.allocateId();
  10580. this.scope.addStatement(tsDeclareVariable(id, type));
  10581. target = id;
  10582. } else if (this.dir.undeclaredInputFields.has(fieldName)) {
  10583. continue;
  10584. } else if (!this.tcb.env.config.honorAccessModifiersForInputBindings && this.dir.restrictedInputFields.has(fieldName)) {
  10585. if (dirId === null) {
  10586. dirId = this.scope.resolve(this.node, this.dir);
  10587. }
  10588. const id = this.tcb.allocateId();
  10589. const dirTypeRef = this.tcb.env.referenceType(this.dir.ref);
  10590. if (!ts42.isTypeReferenceNode(dirTypeRef)) {
  10591. throw new Error(`Expected TypeReferenceNode from reference to ${this.dir.ref.debugName}`);
  10592. }
  10593. const type = ts42.factory.createIndexedAccessTypeNode(ts42.factory.createTypeQueryNode(dirId), ts42.factory.createLiteralTypeNode(ts42.factory.createStringLiteral(fieldName)));
  10594. const temp = tsDeclareVariable(id, type);
  10595. this.scope.addStatement(temp);
  10596. target = id;
  10597. } else {
  10598. if (dirId === null) {
  10599. dirId = this.scope.resolve(this.node, this.dir);
  10600. }
  10601. target = this.dir.stringLiteralInputFields.has(fieldName) ? ts42.factory.createElementAccessExpression(dirId, ts42.factory.createStringLiteral(fieldName)) : ts42.factory.createPropertyAccessExpression(dirId, ts42.factory.createIdentifier(fieldName));
  10602. }
  10603. if (isSignal) {
  10604. const inputSignalBrandWriteSymbol = this.tcb.env.referenceExternalSymbol(R3Identifiers4.InputSignalBrandWriteType.moduleName, R3Identifiers4.InputSignalBrandWriteType.name);
  10605. if (!ts42.isIdentifier(inputSignalBrandWriteSymbol) && !ts42.isPropertyAccessExpression(inputSignalBrandWriteSymbol)) {
  10606. throw new Error(`Expected identifier or property access for reference to ${R3Identifiers4.InputSignalBrandWriteType.name}`);
  10607. }
  10608. target = ts42.factory.createElementAccessExpression(target, inputSignalBrandWriteSymbol);
  10609. }
  10610. if (attr.attribute.keySpan !== void 0) {
  10611. addParseSpanInfo(target, attr.attribute.keySpan);
  10612. }
  10613. if (isTwoWayBinding && this.tcb.env.config.allowSignalsInTwoWayBindings) {
  10614. assignment = unwrapWritableSignal(assignment, this.tcb);
  10615. }
  10616. assignment = ts42.factory.createBinaryExpression(target, ts42.SyntaxKind.EqualsToken, assignment);
  10617. }
  10618. addParseSpanInfo(assignment, attr.attribute.sourceSpan);
  10619. if (!this.tcb.env.config.checkTypeOfAttributes && attr.attribute instanceof TmplAstTextAttribute2) {
  10620. markIgnoreDiagnostics(assignment);
  10621. }
  10622. this.scope.addStatement(ts42.factory.createExpressionStatement(assignment));
  10623. }
  10624. this.checkRequiredInputs(seenRequiredInputs);
  10625. return null;
  10626. }
  10627. checkRequiredInputs(seenRequiredInputs) {
  10628. const missing = [];
  10629. for (const input of this.dir.inputs) {
  10630. if (input.required && !seenRequiredInputs.has(input.classPropertyName)) {
  10631. missing.push(input.bindingPropertyName);
  10632. }
  10633. }
  10634. if (missing.length > 0) {
  10635. this.tcb.oobRecorder.missingRequiredInputs(this.tcb.id, this.node, this.dir.name, this.dir.isComponent, missing);
  10636. }
  10637. }
  10638. };
  10639. var TcbDirectiveCtorCircularFallbackOp = class extends TcbOp {
  10640. tcb;
  10641. scope;
  10642. node;
  10643. dir;
  10644. constructor(tcb, scope, node, dir) {
  10645. super();
  10646. this.tcb = tcb;
  10647. this.scope = scope;
  10648. this.node = node;
  10649. this.dir = dir;
  10650. }
  10651. get optional() {
  10652. return false;
  10653. }
  10654. execute() {
  10655. const id = this.tcb.allocateId();
  10656. const typeCtor = this.tcb.env.typeCtorFor(this.dir);
  10657. const circularPlaceholder = ts42.factory.createCallExpression(
  10658. typeCtor,
  10659. void 0,
  10660. [ts42.factory.createNonNullExpression(ts42.factory.createNull())]
  10661. );
  10662. this.scope.addStatement(tsCreateVariable(id, circularPlaceholder));
  10663. return id;
  10664. }
  10665. };
  10666. var TcbDomSchemaCheckerOp = class extends TcbOp {
  10667. tcb;
  10668. element;
  10669. checkElement;
  10670. claimedInputs;
  10671. constructor(tcb, element, checkElement, claimedInputs) {
  10672. super();
  10673. this.tcb = tcb;
  10674. this.element = element;
  10675. this.checkElement = checkElement;
  10676. this.claimedInputs = claimedInputs;
  10677. }
  10678. get optional() {
  10679. return false;
  10680. }
  10681. execute() {
  10682. var _a;
  10683. if (this.checkElement) {
  10684. this.tcb.domSchemaChecker.checkElement(this.tcb.id, this.element, this.tcb.schemas, this.tcb.hostIsStandalone);
  10685. }
  10686. for (const binding of this.element.inputs) {
  10687. const isPropertyBinding = binding.type === BindingType.Property || binding.type === BindingType.TwoWay;
  10688. if (isPropertyBinding && this.claimedInputs.has(binding.name)) {
  10689. continue;
  10690. }
  10691. if (isPropertyBinding && binding.name !== "style" && binding.name !== "class") {
  10692. const propertyName = (_a = ATTR_TO_PROP.get(binding.name)) != null ? _a : binding.name;
  10693. this.tcb.domSchemaChecker.checkProperty(this.tcb.id, this.element, propertyName, binding.sourceSpan, this.tcb.schemas, this.tcb.hostIsStandalone);
  10694. }
  10695. }
  10696. return null;
  10697. }
  10698. };
  10699. var TcbControlFlowContentProjectionOp = class extends TcbOp {
  10700. tcb;
  10701. element;
  10702. ngContentSelectors;
  10703. componentName;
  10704. category;
  10705. constructor(tcb, element, ngContentSelectors, componentName) {
  10706. super();
  10707. this.tcb = tcb;
  10708. this.element = element;
  10709. this.ngContentSelectors = ngContentSelectors;
  10710. this.componentName = componentName;
  10711. this.category = tcb.env.config.controlFlowPreventingContentProjection === "error" ? ts42.DiagnosticCategory.Error : ts42.DiagnosticCategory.Warning;
  10712. }
  10713. optional = false;
  10714. execute() {
  10715. const controlFlowToCheck = this.findPotentialControlFlowNodes();
  10716. if (controlFlowToCheck.length > 0) {
  10717. const matcher = new SelectorMatcher2();
  10718. for (const selector of this.ngContentSelectors) {
  10719. if (selector !== "*") {
  10720. matcher.addSelectables(CssSelector2.parse(selector), selector);
  10721. }
  10722. }
  10723. for (const root of controlFlowToCheck) {
  10724. for (const child of root.children) {
  10725. if (child instanceof TmplAstElement2 || child instanceof TmplAstTemplate) {
  10726. matcher.match(createCssSelectorFromNode(child), (_, originalSelector) => {
  10727. this.tcb.oobRecorder.controlFlowPreventingContentProjection(this.tcb.id, this.category, child, this.componentName, originalSelector, root, this.tcb.hostPreserveWhitespaces);
  10728. });
  10729. }
  10730. }
  10731. }
  10732. }
  10733. return null;
  10734. }
  10735. findPotentialControlFlowNodes() {
  10736. const result = [];
  10737. for (const child of this.element.children) {
  10738. if (child instanceof TmplAstForLoopBlock) {
  10739. if (this.shouldCheck(child)) {
  10740. result.push(child);
  10741. }
  10742. if (child.empty !== null && this.shouldCheck(child.empty)) {
  10743. result.push(child.empty);
  10744. }
  10745. } else if (child instanceof TmplAstIfBlock) {
  10746. for (const branch of child.branches) {
  10747. if (this.shouldCheck(branch)) {
  10748. result.push(branch);
  10749. }
  10750. }
  10751. } else if (child instanceof TmplAstSwitchBlock) {
  10752. for (const current of child.cases) {
  10753. if (this.shouldCheck(current)) {
  10754. result.push(current);
  10755. }
  10756. }
  10757. }
  10758. }
  10759. return result;
  10760. }
  10761. shouldCheck(node) {
  10762. if (node.children.length < 2) {
  10763. return false;
  10764. }
  10765. let hasSeenRootNode = false;
  10766. for (const child of node.children) {
  10767. if (!(child instanceof TmplAstText) || this.tcb.hostPreserveWhitespaces || child.value.trim().length > 0) {
  10768. if (hasSeenRootNode) {
  10769. return true;
  10770. }
  10771. hasSeenRootNode = true;
  10772. }
  10773. }
  10774. return false;
  10775. }
  10776. };
  10777. var ATTR_TO_PROP = new Map(Object.entries({
  10778. "class": "className",
  10779. "for": "htmlFor",
  10780. "formaction": "formAction",
  10781. "innerHtml": "innerHTML",
  10782. "readonly": "readOnly",
  10783. "tabindex": "tabIndex"
  10784. }));
  10785. var TcbUnclaimedInputsOp = class extends TcbOp {
  10786. tcb;
  10787. scope;
  10788. element;
  10789. claimedInputs;
  10790. constructor(tcb, scope, element, claimedInputs) {
  10791. super();
  10792. this.tcb = tcb;
  10793. this.scope = scope;
  10794. this.element = element;
  10795. this.claimedInputs = claimedInputs;
  10796. }
  10797. get optional() {
  10798. return false;
  10799. }
  10800. execute() {
  10801. var _a;
  10802. let elId = null;
  10803. for (const binding of this.element.inputs) {
  10804. const isPropertyBinding = binding.type === BindingType.Property || binding.type === BindingType.TwoWay;
  10805. if (isPropertyBinding && this.claimedInputs.has(binding.name)) {
  10806. continue;
  10807. }
  10808. const expr = widenBinding(tcbExpression(binding.value, this.tcb, this.scope), this.tcb);
  10809. if (this.tcb.env.config.checkTypeOfDomBindings && isPropertyBinding) {
  10810. if (binding.name !== "style" && binding.name !== "class") {
  10811. if (elId === null) {
  10812. elId = this.scope.resolve(this.element);
  10813. }
  10814. const propertyName = (_a = ATTR_TO_PROP.get(binding.name)) != null ? _a : binding.name;
  10815. const prop = ts42.factory.createElementAccessExpression(elId, ts42.factory.createStringLiteral(propertyName));
  10816. const stmt = ts42.factory.createBinaryExpression(prop, ts42.SyntaxKind.EqualsToken, wrapForDiagnostics(expr));
  10817. addParseSpanInfo(stmt, binding.sourceSpan);
  10818. this.scope.addStatement(ts42.factory.createExpressionStatement(stmt));
  10819. } else {
  10820. this.scope.addStatement(ts42.factory.createExpressionStatement(expr));
  10821. }
  10822. } else {
  10823. this.scope.addStatement(ts42.factory.createExpressionStatement(expr));
  10824. }
  10825. }
  10826. return null;
  10827. }
  10828. };
  10829. var TcbDirectiveOutputsOp = class extends TcbOp {
  10830. tcb;
  10831. scope;
  10832. node;
  10833. dir;
  10834. constructor(tcb, scope, node, dir) {
  10835. super();
  10836. this.tcb = tcb;
  10837. this.scope = scope;
  10838. this.node = node;
  10839. this.dir = dir;
  10840. }
  10841. get optional() {
  10842. return false;
  10843. }
  10844. execute() {
  10845. let dirId = null;
  10846. const outputs = this.dir.outputs;
  10847. for (const output of this.node.outputs) {
  10848. if (output.type === ParsedEventType.Animation || !outputs.hasBindingPropertyName(output.name)) {
  10849. continue;
  10850. }
  10851. if (this.tcb.env.config.checkTypeOfOutputEvents && output.name.endsWith("Change")) {
  10852. const inputName = output.name.slice(0, -6);
  10853. checkSplitTwoWayBinding(inputName, output, this.node.inputs, this.tcb);
  10854. }
  10855. const field = outputs.getByBindingPropertyName(output.name)[0].classPropertyName;
  10856. if (dirId === null) {
  10857. dirId = this.scope.resolve(this.node, this.dir);
  10858. }
  10859. const outputField = ts42.factory.createElementAccessExpression(dirId, ts42.factory.createStringLiteral(field));
  10860. addParseSpanInfo(outputField, output.keySpan);
  10861. if (this.tcb.env.config.checkTypeOfOutputEvents) {
  10862. const handler = tcbCreateEventHandler(output, this.tcb, this.scope, 0);
  10863. const subscribeFn = ts42.factory.createPropertyAccessExpression(outputField, "subscribe");
  10864. const call = ts42.factory.createCallExpression(subscribeFn, void 0, [
  10865. handler
  10866. ]);
  10867. addParseSpanInfo(call, output.sourceSpan);
  10868. this.scope.addStatement(ts42.factory.createExpressionStatement(call));
  10869. } else {
  10870. this.scope.addStatement(ts42.factory.createExpressionStatement(outputField));
  10871. const handler = tcbCreateEventHandler(output, this.tcb, this.scope, 1);
  10872. this.scope.addStatement(ts42.factory.createExpressionStatement(handler));
  10873. }
  10874. }
  10875. return null;
  10876. }
  10877. };
  10878. var TcbUnclaimedOutputsOp = class extends TcbOp {
  10879. tcb;
  10880. scope;
  10881. element;
  10882. claimedOutputs;
  10883. constructor(tcb, scope, element, claimedOutputs) {
  10884. super();
  10885. this.tcb = tcb;
  10886. this.scope = scope;
  10887. this.element = element;
  10888. this.claimedOutputs = claimedOutputs;
  10889. }
  10890. get optional() {
  10891. return false;
  10892. }
  10893. execute() {
  10894. let elId = null;
  10895. for (const output of this.element.outputs) {
  10896. if (this.claimedOutputs.has(output.name)) {
  10897. continue;
  10898. }
  10899. if (this.tcb.env.config.checkTypeOfOutputEvents && output.name.endsWith("Change")) {
  10900. const inputName = output.name.slice(0, -6);
  10901. if (checkSplitTwoWayBinding(inputName, output, this.element.inputs, this.tcb)) {
  10902. continue;
  10903. }
  10904. }
  10905. if (output.type === ParsedEventType.Animation) {
  10906. const eventType = this.tcb.env.config.checkTypeOfAnimationEvents ? this.tcb.env.referenceExternalType("@angular/animations", "AnimationEvent") : 1;
  10907. const handler = tcbCreateEventHandler(output, this.tcb, this.scope, eventType);
  10908. this.scope.addStatement(ts42.factory.createExpressionStatement(handler));
  10909. } else if (this.tcb.env.config.checkTypeOfDomEvents) {
  10910. const handler = tcbCreateEventHandler(output, this.tcb, this.scope, 0);
  10911. if (elId === null) {
  10912. elId = this.scope.resolve(this.element);
  10913. }
  10914. const propertyAccess = ts42.factory.createPropertyAccessExpression(elId, "addEventListener");
  10915. addParseSpanInfo(propertyAccess, output.keySpan);
  10916. const call = ts42.factory.createCallExpression(
  10917. propertyAccess,
  10918. void 0,
  10919. [ts42.factory.createStringLiteral(output.name), handler]
  10920. );
  10921. addParseSpanInfo(call, output.sourceSpan);
  10922. this.scope.addStatement(ts42.factory.createExpressionStatement(call));
  10923. } else {
  10924. const handler = tcbCreateEventHandler(output, this.tcb, this.scope, 1);
  10925. this.scope.addStatement(ts42.factory.createExpressionStatement(handler));
  10926. }
  10927. }
  10928. return null;
  10929. }
  10930. };
  10931. var TcbComponentContextCompletionOp = class extends TcbOp {
  10932. scope;
  10933. constructor(scope) {
  10934. super();
  10935. this.scope = scope;
  10936. }
  10937. optional = false;
  10938. execute() {
  10939. const ctx = ts42.factory.createThis();
  10940. const ctxDot = ts42.factory.createPropertyAccessExpression(ctx, "");
  10941. markIgnoreDiagnostics(ctxDot);
  10942. addExpressionIdentifier(ctxDot, ExpressionIdentifier.COMPONENT_COMPLETION);
  10943. this.scope.addStatement(ts42.factory.createExpressionStatement(ctxDot));
  10944. return null;
  10945. }
  10946. };
  10947. var TcbBlockVariableOp = class extends TcbOp {
  10948. tcb;
  10949. scope;
  10950. initializer;
  10951. variable;
  10952. constructor(tcb, scope, initializer, variable) {
  10953. super();
  10954. this.tcb = tcb;
  10955. this.scope = scope;
  10956. this.initializer = initializer;
  10957. this.variable = variable;
  10958. }
  10959. get optional() {
  10960. return false;
  10961. }
  10962. execute() {
  10963. const id = this.tcb.allocateId();
  10964. addParseSpanInfo(id, this.variable.keySpan);
  10965. const variable = tsCreateVariable(id, wrapForTypeChecker(this.initializer));
  10966. addParseSpanInfo(variable.declarationList.declarations[0], this.variable.sourceSpan);
  10967. this.scope.addStatement(variable);
  10968. return id;
  10969. }
  10970. };
  10971. var TcbBlockImplicitVariableOp = class extends TcbOp {
  10972. tcb;
  10973. scope;
  10974. type;
  10975. variable;
  10976. constructor(tcb, scope, type, variable) {
  10977. super();
  10978. this.tcb = tcb;
  10979. this.scope = scope;
  10980. this.type = type;
  10981. this.variable = variable;
  10982. }
  10983. optional = true;
  10984. execute() {
  10985. const id = this.tcb.allocateId();
  10986. addParseSpanInfo(id, this.variable.keySpan);
  10987. const variable = tsDeclareVariable(id, this.type);
  10988. addParseSpanInfo(variable.declarationList.declarations[0], this.variable.sourceSpan);
  10989. this.scope.addStatement(variable);
  10990. return id;
  10991. }
  10992. };
  10993. var TcbIfOp = class extends TcbOp {
  10994. tcb;
  10995. scope;
  10996. block;
  10997. expressionScopes = /* @__PURE__ */ new Map();
  10998. constructor(tcb, scope, block) {
  10999. super();
  11000. this.tcb = tcb;
  11001. this.scope = scope;
  11002. this.block = block;
  11003. }
  11004. get optional() {
  11005. return false;
  11006. }
  11007. execute() {
  11008. const root = this.generateBranch(0);
  11009. root && this.scope.addStatement(root);
  11010. return null;
  11011. }
  11012. generateBranch(index) {
  11013. const branch = this.block.branches[index];
  11014. if (!branch) {
  11015. return void 0;
  11016. }
  11017. if (branch.expression === null) {
  11018. const branchScope = this.getBranchScope(this.scope, branch, index);
  11019. return ts42.factory.createBlock(branchScope.render());
  11020. }
  11021. const outerScope = Scope.forNodes(this.tcb, this.scope, branch, [], null);
  11022. outerScope.render().forEach((stmt) => this.scope.addStatement(stmt));
  11023. this.expressionScopes.set(branch, outerScope);
  11024. let expression = tcbExpression(branch.expression, this.tcb, this.scope);
  11025. if (branch.expressionAlias !== null) {
  11026. expression = ts42.factory.createBinaryExpression(ts42.factory.createParenthesizedExpression(expression), ts42.SyntaxKind.AmpersandAmpersandToken, outerScope.resolve(branch.expressionAlias));
  11027. }
  11028. const bodyScope = this.getBranchScope(outerScope, branch, index);
  11029. return ts42.factory.createIfStatement(expression, ts42.factory.createBlock(bodyScope.render()), this.generateBranch(index + 1));
  11030. }
  11031. getBranchScope(parentScope, branch, index) {
  11032. const checkBody = this.tcb.env.config.checkControlFlowBodies;
  11033. return Scope.forNodes(this.tcb, parentScope, null, checkBody ? branch.children : [], checkBody ? this.generateBranchGuard(index) : null);
  11034. }
  11035. generateBranchGuard(index) {
  11036. let guard = null;
  11037. for (let i = 0; i <= index; i++) {
  11038. const branch = this.block.branches[i];
  11039. if (branch.expression === null) {
  11040. continue;
  11041. }
  11042. if (!this.expressionScopes.has(branch)) {
  11043. throw new Error(`Could not determine expression scope of branch at index ${i}`);
  11044. }
  11045. const expressionScope = this.expressionScopes.get(branch);
  11046. let expression;
  11047. expression = tcbExpression(branch.expression, this.tcb, expressionScope);
  11048. if (branch.expressionAlias !== null) {
  11049. expression = ts42.factory.createBinaryExpression(ts42.factory.createParenthesizedExpression(expression), ts42.SyntaxKind.AmpersandAmpersandToken, expressionScope.resolve(branch.expressionAlias));
  11050. }
  11051. markIgnoreDiagnostics(expression);
  11052. const comparisonExpression = i === index ? expression : ts42.factory.createPrefixUnaryExpression(ts42.SyntaxKind.ExclamationToken, ts42.factory.createParenthesizedExpression(expression));
  11053. guard = guard === null ? comparisonExpression : ts42.factory.createBinaryExpression(guard, ts42.SyntaxKind.AmpersandAmpersandToken, comparisonExpression);
  11054. }
  11055. return guard;
  11056. }
  11057. };
  11058. var TcbSwitchOp = class extends TcbOp {
  11059. tcb;
  11060. scope;
  11061. block;
  11062. constructor(tcb, scope, block) {
  11063. super();
  11064. this.tcb = tcb;
  11065. this.scope = scope;
  11066. this.block = block;
  11067. }
  11068. get optional() {
  11069. return false;
  11070. }
  11071. execute() {
  11072. const switchExpression = tcbExpression(this.block.expression, this.tcb, this.scope);
  11073. const clauses = this.block.cases.map((current) => {
  11074. const checkBody = this.tcb.env.config.checkControlFlowBodies;
  11075. const clauseScope = Scope.forNodes(this.tcb, this.scope, null, checkBody ? current.children : [], checkBody ? this.generateGuard(current, switchExpression) : null);
  11076. const statements = [...clauseScope.render(), ts42.factory.createBreakStatement()];
  11077. return current.expression === null ? ts42.factory.createDefaultClause(statements) : ts42.factory.createCaseClause(tcbExpression(current.expression, this.tcb, clauseScope), statements);
  11078. });
  11079. this.scope.addStatement(ts42.factory.createSwitchStatement(switchExpression, ts42.factory.createCaseBlock(clauses)));
  11080. return null;
  11081. }
  11082. generateGuard(node, switchValue) {
  11083. if (node.expression !== null) {
  11084. const expression = tcbExpression(node.expression, this.tcb, this.scope);
  11085. markIgnoreDiagnostics(expression);
  11086. return ts42.factory.createBinaryExpression(switchValue, ts42.SyntaxKind.EqualsEqualsEqualsToken, expression);
  11087. }
  11088. let guard = null;
  11089. for (const current of this.block.cases) {
  11090. if (current.expression === null) {
  11091. continue;
  11092. }
  11093. const expression = tcbExpression(current.expression, this.tcb, this.scope);
  11094. markIgnoreDiagnostics(expression);
  11095. const comparison = ts42.factory.createBinaryExpression(switchValue, ts42.SyntaxKind.ExclamationEqualsEqualsToken, expression);
  11096. if (guard === null) {
  11097. guard = comparison;
  11098. } else {
  11099. guard = ts42.factory.createBinaryExpression(guard, ts42.SyntaxKind.AmpersandAmpersandToken, comparison);
  11100. }
  11101. }
  11102. return guard;
  11103. }
  11104. };
  11105. var TcbForOfOp = class extends TcbOp {
  11106. tcb;
  11107. scope;
  11108. block;
  11109. constructor(tcb, scope, block) {
  11110. super();
  11111. this.tcb = tcb;
  11112. this.scope = scope;
  11113. this.block = block;
  11114. }
  11115. get optional() {
  11116. return false;
  11117. }
  11118. execute() {
  11119. const loopScope = Scope.forNodes(this.tcb, this.scope, this.block, this.tcb.env.config.checkControlFlowBodies ? this.block.children : [], null);
  11120. const initializerId = loopScope.resolve(this.block.item);
  11121. if (!ts42.isIdentifier(initializerId)) {
  11122. throw new Error(`Could not resolve for loop variable ${this.block.item.name} to an identifier`);
  11123. }
  11124. const initializer = ts42.factory.createVariableDeclarationList([ts42.factory.createVariableDeclaration(initializerId)], ts42.NodeFlags.Const);
  11125. addParseSpanInfo(initializer, this.block.item.keySpan);
  11126. const expression = ts42.factory.createNonNullExpression(tcbExpression(this.block.expression, this.tcb, this.scope));
  11127. const trackTranslator = new TcbForLoopTrackTranslator(this.tcb, loopScope, this.block);
  11128. const trackExpression = trackTranslator.translate(this.block.trackBy);
  11129. const statements = [
  11130. ...loopScope.render(),
  11131. ts42.factory.createExpressionStatement(trackExpression)
  11132. ];
  11133. this.scope.addStatement(ts42.factory.createForOfStatement(void 0, initializer, expression, ts42.factory.createBlock(statements)));
  11134. return null;
  11135. }
  11136. };
  11137. var INFER_TYPE_FOR_CIRCULAR_OP_EXPR = ts42.factory.createNonNullExpression(ts42.factory.createNull());
  11138. var Context = class {
  11139. env;
  11140. domSchemaChecker;
  11141. oobRecorder;
  11142. id;
  11143. boundTarget;
  11144. pipes;
  11145. schemas;
  11146. hostIsStandalone;
  11147. hostPreserveWhitespaces;
  11148. nextId = 1;
  11149. constructor(env, domSchemaChecker, oobRecorder, id, boundTarget, pipes, schemas, hostIsStandalone, hostPreserveWhitespaces) {
  11150. this.env = env;
  11151. this.domSchemaChecker = domSchemaChecker;
  11152. this.oobRecorder = oobRecorder;
  11153. this.id = id;
  11154. this.boundTarget = boundTarget;
  11155. this.pipes = pipes;
  11156. this.schemas = schemas;
  11157. this.hostIsStandalone = hostIsStandalone;
  11158. this.hostPreserveWhitespaces = hostPreserveWhitespaces;
  11159. }
  11160. allocateId() {
  11161. return ts42.factory.createIdentifier(`_t${this.nextId++}`);
  11162. }
  11163. getPipeByName(name) {
  11164. if (this.pipes === null || !this.pipes.has(name)) {
  11165. return null;
  11166. }
  11167. return this.pipes.get(name);
  11168. }
  11169. };
  11170. var _Scope = class {
  11171. tcb;
  11172. parent;
  11173. guard;
  11174. opQueue = [];
  11175. elementOpMap = /* @__PURE__ */ new Map();
  11176. directiveOpMap = /* @__PURE__ */ new Map();
  11177. referenceOpMap = /* @__PURE__ */ new Map();
  11178. templateCtxOpMap = /* @__PURE__ */ new Map();
  11179. varMap = /* @__PURE__ */ new Map();
  11180. letDeclOpMap = /* @__PURE__ */ new Map();
  11181. statements = [];
  11182. constructor(tcb, parent = null, guard = null) {
  11183. this.tcb = tcb;
  11184. this.parent = parent;
  11185. this.guard = guard;
  11186. }
  11187. static forNodes(tcb, parentScope, scopedNode, children, guard) {
  11188. const scope = new _Scope(tcb, parentScope, guard);
  11189. if (parentScope === null && tcb.env.config.enableTemplateTypeChecker) {
  11190. scope.opQueue.push(new TcbComponentContextCompletionOp(scope));
  11191. }
  11192. if (scopedNode instanceof TmplAstTemplate) {
  11193. const varMap = /* @__PURE__ */ new Map();
  11194. for (const v of scopedNode.variables) {
  11195. if (!varMap.has(v.name)) {
  11196. varMap.set(v.name, v);
  11197. } else {
  11198. const firstDecl = varMap.get(v.name);
  11199. tcb.oobRecorder.duplicateTemplateVar(tcb.id, v, firstDecl);
  11200. }
  11201. this.registerVariable(scope, v, new TcbTemplateVariableOp(tcb, scope, scopedNode, v));
  11202. }
  11203. } else if (scopedNode instanceof TmplAstIfBlockBranch) {
  11204. const { expression, expressionAlias } = scopedNode;
  11205. if (expression !== null && expressionAlias !== null) {
  11206. this.registerVariable(scope, expressionAlias, new TcbBlockVariableOp(tcb, scope, tcbExpression(expression, tcb, scope), expressionAlias));
  11207. }
  11208. } else if (scopedNode instanceof TmplAstForLoopBlock) {
  11209. const loopInitializer = tcb.allocateId();
  11210. addParseSpanInfo(loopInitializer, scopedNode.item.sourceSpan);
  11211. scope.varMap.set(scopedNode.item, loopInitializer);
  11212. for (const variable of scopedNode.contextVariables) {
  11213. if (!this.forLoopContextVariableTypes.has(variable.value)) {
  11214. throw new Error(`Unrecognized for loop context variable ${variable.name}`);
  11215. }
  11216. const type = ts42.factory.createKeywordTypeNode(this.forLoopContextVariableTypes.get(variable.value));
  11217. this.registerVariable(scope, variable, new TcbBlockImplicitVariableOp(tcb, scope, type, variable));
  11218. }
  11219. }
  11220. for (const node of children) {
  11221. scope.appendNode(node);
  11222. }
  11223. for (const variable of scope.varMap.keys()) {
  11224. _Scope.checkConflictingLet(scope, variable);
  11225. }
  11226. for (const ref of scope.referenceOpMap.keys()) {
  11227. _Scope.checkConflictingLet(scope, ref);
  11228. }
  11229. return scope;
  11230. }
  11231. static registerVariable(scope, variable, op) {
  11232. const opIndex = scope.opQueue.push(op) - 1;
  11233. scope.varMap.set(variable, opIndex);
  11234. }
  11235. resolve(node, directive) {
  11236. const res = this.resolveLocal(node, directive);
  11237. if (res !== null) {
  11238. let clone;
  11239. if (ts42.isIdentifier(res)) {
  11240. clone = ts42.factory.createIdentifier(res.text);
  11241. } else if (ts42.isNonNullExpression(res)) {
  11242. clone = ts42.factory.createNonNullExpression(res.expression);
  11243. } else {
  11244. throw new Error(`Could not resolve ${node} to an Identifier or a NonNullExpression`);
  11245. }
  11246. ts42.setOriginalNode(clone, res);
  11247. clone.parent = clone.parent;
  11248. return ts42.setSyntheticTrailingComments(clone, []);
  11249. } else if (this.parent !== null) {
  11250. return this.parent.resolve(node, directive);
  11251. } else {
  11252. throw new Error(`Could not resolve ${node} / ${directive}`);
  11253. }
  11254. }
  11255. addStatement(stmt) {
  11256. this.statements.push(stmt);
  11257. }
  11258. render() {
  11259. for (let i = 0; i < this.opQueue.length; i++) {
  11260. const skipOptional = !this.tcb.env.config.enableTemplateTypeChecker;
  11261. this.executeOp(i, skipOptional);
  11262. }
  11263. return this.statements;
  11264. }
  11265. guards() {
  11266. let parentGuards = null;
  11267. if (this.parent !== null) {
  11268. parentGuards = this.parent.guards();
  11269. }
  11270. if (this.guard === null) {
  11271. return parentGuards;
  11272. } else if (parentGuards === null) {
  11273. return this.guard;
  11274. } else {
  11275. return ts42.factory.createBinaryExpression(parentGuards, ts42.SyntaxKind.AmpersandAmpersandToken, this.guard);
  11276. }
  11277. }
  11278. isLocal(node) {
  11279. if (node instanceof TmplAstVariable) {
  11280. return this.varMap.has(node);
  11281. }
  11282. if (node instanceof TmplAstLetDeclaration2) {
  11283. return this.letDeclOpMap.has(node.name);
  11284. }
  11285. return this.referenceOpMap.has(node);
  11286. }
  11287. resolveLocal(ref, directive) {
  11288. if (ref instanceof TmplAstReference2 && this.referenceOpMap.has(ref)) {
  11289. return this.resolveOp(this.referenceOpMap.get(ref));
  11290. } else if (ref instanceof TmplAstLetDeclaration2 && this.letDeclOpMap.has(ref.name)) {
  11291. return this.resolveOp(this.letDeclOpMap.get(ref.name).opIndex);
  11292. } else if (ref instanceof TmplAstVariable && this.varMap.has(ref)) {
  11293. const opIndexOrNode = this.varMap.get(ref);
  11294. return typeof opIndexOrNode === "number" ? this.resolveOp(opIndexOrNode) : opIndexOrNode;
  11295. } else if (ref instanceof TmplAstTemplate && directive === void 0 && this.templateCtxOpMap.has(ref)) {
  11296. return this.resolveOp(this.templateCtxOpMap.get(ref));
  11297. } else if ((ref instanceof TmplAstElement2 || ref instanceof TmplAstTemplate) && directive !== void 0 && this.directiveOpMap.has(ref)) {
  11298. const dirMap = this.directiveOpMap.get(ref);
  11299. if (dirMap.has(directive)) {
  11300. return this.resolveOp(dirMap.get(directive));
  11301. } else {
  11302. return null;
  11303. }
  11304. } else if (ref instanceof TmplAstElement2 && this.elementOpMap.has(ref)) {
  11305. return this.resolveOp(this.elementOpMap.get(ref));
  11306. } else {
  11307. return null;
  11308. }
  11309. }
  11310. resolveOp(opIndex) {
  11311. const res = this.executeOp(opIndex, false);
  11312. if (res === null) {
  11313. throw new Error(`Error resolving operation, got null`);
  11314. }
  11315. return res;
  11316. }
  11317. executeOp(opIndex, skipOptional) {
  11318. const op = this.opQueue[opIndex];
  11319. if (!(op instanceof TcbOp)) {
  11320. return op;
  11321. }
  11322. if (skipOptional && op.optional) {
  11323. return null;
  11324. }
  11325. this.opQueue[opIndex] = op.circularFallback();
  11326. const res = op.execute();
  11327. this.opQueue[opIndex] = res;
  11328. return res;
  11329. }
  11330. appendNode(node) {
  11331. if (node instanceof TmplAstElement2) {
  11332. const opIndex = this.opQueue.push(new TcbElementOp(this.tcb, this, node)) - 1;
  11333. this.elementOpMap.set(node, opIndex);
  11334. if (this.tcb.env.config.controlFlowPreventingContentProjection !== "suppress") {
  11335. this.appendContentProjectionCheckOp(node);
  11336. }
  11337. this.appendDirectivesAndInputsOfNode(node);
  11338. this.appendOutputsOfNode(node);
  11339. this.appendChildren(node);
  11340. this.checkAndAppendReferencesOfNode(node);
  11341. } else if (node instanceof TmplAstTemplate) {
  11342. this.appendDirectivesAndInputsOfNode(node);
  11343. this.appendOutputsOfNode(node);
  11344. const ctxIndex = this.opQueue.push(new TcbTemplateContextOp(this.tcb, this)) - 1;
  11345. this.templateCtxOpMap.set(node, ctxIndex);
  11346. if (this.tcb.env.config.checkTemplateBodies) {
  11347. this.opQueue.push(new TcbTemplateBodyOp(this.tcb, this, node));
  11348. } else if (this.tcb.env.config.alwaysCheckSchemaInTemplateBodies) {
  11349. this.appendDeepSchemaChecks(node.children);
  11350. }
  11351. this.checkAndAppendReferencesOfNode(node);
  11352. } else if (node instanceof TmplAstDeferredBlock) {
  11353. this.appendDeferredBlock(node);
  11354. } else if (node instanceof TmplAstIfBlock) {
  11355. this.opQueue.push(new TcbIfOp(this.tcb, this, node));
  11356. } else if (node instanceof TmplAstSwitchBlock) {
  11357. this.opQueue.push(new TcbSwitchOp(this.tcb, this, node));
  11358. } else if (node instanceof TmplAstForLoopBlock) {
  11359. this.opQueue.push(new TcbForOfOp(this.tcb, this, node));
  11360. node.empty && this.tcb.env.config.checkControlFlowBodies && this.appendChildren(node.empty);
  11361. } else if (node instanceof TmplAstBoundText) {
  11362. this.opQueue.push(new TcbExpressionOp(this.tcb, this, node.value));
  11363. } else if (node instanceof TmplAstIcu) {
  11364. this.appendIcuExpressions(node);
  11365. } else if (node instanceof TmplAstContent) {
  11366. this.appendChildren(node);
  11367. } else if (node instanceof TmplAstLetDeclaration2) {
  11368. const opIndex = this.opQueue.push(new TcbLetDeclarationOp(this.tcb, this, node)) - 1;
  11369. if (this.isLocal(node)) {
  11370. this.tcb.oobRecorder.conflictingDeclaration(this.tcb.id, node);
  11371. } else {
  11372. this.letDeclOpMap.set(node.name, { opIndex, node });
  11373. }
  11374. }
  11375. }
  11376. appendChildren(node) {
  11377. for (const child of node.children) {
  11378. this.appendNode(child);
  11379. }
  11380. }
  11381. checkAndAppendReferencesOfNode(node) {
  11382. for (const ref of node.references) {
  11383. const target = this.tcb.boundTarget.getReferenceTarget(ref);
  11384. let ctxIndex;
  11385. if (target === null) {
  11386. this.tcb.oobRecorder.missingReferenceTarget(this.tcb.id, ref);
  11387. ctxIndex = this.opQueue.push(new TcbInvalidReferenceOp(this.tcb, this)) - 1;
  11388. } else if (target instanceof TmplAstTemplate || target instanceof TmplAstElement2) {
  11389. ctxIndex = this.opQueue.push(new TcbReferenceOp(this.tcb, this, ref, node, target)) - 1;
  11390. } else {
  11391. ctxIndex = this.opQueue.push(new TcbReferenceOp(this.tcb, this, ref, node, target.directive)) - 1;
  11392. }
  11393. this.referenceOpMap.set(ref, ctxIndex);
  11394. }
  11395. }
  11396. appendDirectivesAndInputsOfNode(node) {
  11397. const claimedInputs = /* @__PURE__ */ new Set();
  11398. const directives = this.tcb.boundTarget.getDirectivesOfNode(node);
  11399. if (directives === null || directives.length === 0) {
  11400. if (node instanceof TmplAstElement2) {
  11401. this.opQueue.push(new TcbUnclaimedInputsOp(this.tcb, this, node, claimedInputs));
  11402. this.opQueue.push(new TcbDomSchemaCheckerOp(this.tcb, node, true, claimedInputs));
  11403. }
  11404. return;
  11405. } else {
  11406. if (node instanceof TmplAstElement2) {
  11407. const isDeferred = this.tcb.boundTarget.isDeferred(node);
  11408. if (!isDeferred && directives.some((dirMeta) => dirMeta.isExplicitlyDeferred)) {
  11409. this.tcb.oobRecorder.deferredComponentUsedEagerly(this.tcb.id, node);
  11410. }
  11411. }
  11412. }
  11413. const dirMap = /* @__PURE__ */ new Map();
  11414. for (const dir of directives) {
  11415. let directiveOp;
  11416. const host = this.tcb.env.reflector;
  11417. const dirRef = dir.ref;
  11418. if (!dir.isGeneric) {
  11419. directiveOp = new TcbNonGenericDirectiveTypeOp(this.tcb, this, node, dir);
  11420. } else if (!requiresInlineTypeCtor(dirRef.node, host, this.tcb.env) || this.tcb.env.config.useInlineTypeConstructors) {
  11421. directiveOp = new TcbDirectiveCtorOp(this.tcb, this, node, dir);
  11422. } else {
  11423. directiveOp = new TcbGenericDirectiveTypeWithAnyParamsOp(this.tcb, this, node, dir);
  11424. }
  11425. const dirIndex = this.opQueue.push(directiveOp) - 1;
  11426. dirMap.set(dir, dirIndex);
  11427. this.opQueue.push(new TcbDirectiveInputsOp(this.tcb, this, node, dir));
  11428. }
  11429. this.directiveOpMap.set(node, dirMap);
  11430. if (node instanceof TmplAstElement2) {
  11431. for (const dir of directives) {
  11432. for (const propertyName of dir.inputs.propertyNames) {
  11433. claimedInputs.add(propertyName);
  11434. }
  11435. }
  11436. this.opQueue.push(new TcbUnclaimedInputsOp(this.tcb, this, node, claimedInputs));
  11437. const checkElement = directives.length === 0;
  11438. this.opQueue.push(new TcbDomSchemaCheckerOp(this.tcb, node, checkElement, claimedInputs));
  11439. }
  11440. }
  11441. appendOutputsOfNode(node) {
  11442. const claimedOutputs = /* @__PURE__ */ new Set();
  11443. const directives = this.tcb.boundTarget.getDirectivesOfNode(node);
  11444. if (directives === null || directives.length === 0) {
  11445. if (node instanceof TmplAstElement2) {
  11446. this.opQueue.push(new TcbUnclaimedOutputsOp(this.tcb, this, node, claimedOutputs));
  11447. }
  11448. return;
  11449. }
  11450. for (const dir of directives) {
  11451. this.opQueue.push(new TcbDirectiveOutputsOp(this.tcb, this, node, dir));
  11452. }
  11453. if (node instanceof TmplAstElement2) {
  11454. for (const dir of directives) {
  11455. for (const outputProperty of dir.outputs.propertyNames) {
  11456. claimedOutputs.add(outputProperty);
  11457. }
  11458. }
  11459. this.opQueue.push(new TcbUnclaimedOutputsOp(this.tcb, this, node, claimedOutputs));
  11460. }
  11461. }
  11462. appendDeepSchemaChecks(nodes) {
  11463. for (const node of nodes) {
  11464. if (!(node instanceof TmplAstElement2 || node instanceof TmplAstTemplate)) {
  11465. continue;
  11466. }
  11467. if (node instanceof TmplAstElement2) {
  11468. const claimedInputs = /* @__PURE__ */ new Set();
  11469. const directives = this.tcb.boundTarget.getDirectivesOfNode(node);
  11470. let hasDirectives;
  11471. if (directives === null || directives.length === 0) {
  11472. hasDirectives = false;
  11473. } else {
  11474. hasDirectives = true;
  11475. for (const dir of directives) {
  11476. for (const propertyName of dir.inputs.propertyNames) {
  11477. claimedInputs.add(propertyName);
  11478. }
  11479. }
  11480. }
  11481. this.opQueue.push(new TcbDomSchemaCheckerOp(this.tcb, node, !hasDirectives, claimedInputs));
  11482. }
  11483. this.appendDeepSchemaChecks(node.children);
  11484. }
  11485. }
  11486. appendIcuExpressions(node) {
  11487. for (const variable of Object.values(node.vars)) {
  11488. this.opQueue.push(new TcbExpressionOp(this.tcb, this, variable.value));
  11489. }
  11490. for (const placeholder of Object.values(node.placeholders)) {
  11491. if (placeholder instanceof TmplAstBoundText) {
  11492. this.opQueue.push(new TcbExpressionOp(this.tcb, this, placeholder.value));
  11493. }
  11494. }
  11495. }
  11496. appendContentProjectionCheckOp(root) {
  11497. var _a;
  11498. const meta = ((_a = this.tcb.boundTarget.getDirectivesOfNode(root)) == null ? void 0 : _a.find((meta2) => meta2.isComponent)) || null;
  11499. if (meta !== null && meta.ngContentSelectors !== null && meta.ngContentSelectors.length > 0) {
  11500. const selectors = meta.ngContentSelectors;
  11501. if (selectors.length > 1 || selectors.length === 1 && selectors[0] !== "*") {
  11502. this.opQueue.push(new TcbControlFlowContentProjectionOp(this.tcb, root, selectors, meta.name));
  11503. }
  11504. }
  11505. }
  11506. appendDeferredBlock(block) {
  11507. this.appendDeferredTriggers(block, block.triggers);
  11508. this.appendDeferredTriggers(block, block.prefetchTriggers);
  11509. if (block.hydrateTriggers.when) {
  11510. this.opQueue.push(new TcbExpressionOp(this.tcb, this, block.hydrateTriggers.when.value));
  11511. }
  11512. this.appendChildren(block);
  11513. if (block.placeholder !== null) {
  11514. this.appendChildren(block.placeholder);
  11515. }
  11516. if (block.loading !== null) {
  11517. this.appendChildren(block.loading);
  11518. }
  11519. if (block.error !== null) {
  11520. this.appendChildren(block.error);
  11521. }
  11522. }
  11523. appendDeferredTriggers(block, triggers) {
  11524. if (triggers.when !== void 0) {
  11525. this.opQueue.push(new TcbExpressionOp(this.tcb, this, triggers.when.value));
  11526. }
  11527. if (triggers.hover !== void 0) {
  11528. this.appendReferenceBasedDeferredTrigger(block, triggers.hover);
  11529. }
  11530. if (triggers.interaction !== void 0) {
  11531. this.appendReferenceBasedDeferredTrigger(block, triggers.interaction);
  11532. }
  11533. if (triggers.viewport !== void 0) {
  11534. this.appendReferenceBasedDeferredTrigger(block, triggers.viewport);
  11535. }
  11536. }
  11537. appendReferenceBasedDeferredTrigger(block, trigger) {
  11538. if (this.tcb.boundTarget.getDeferredTriggerTarget(block, trigger) === null) {
  11539. this.tcb.oobRecorder.inaccessibleDeferredTriggerElement(this.tcb.id, trigger);
  11540. }
  11541. }
  11542. static checkConflictingLet(scope, node) {
  11543. if (scope.letDeclOpMap.has(node.name)) {
  11544. scope.tcb.oobRecorder.conflictingDeclaration(scope.tcb.id, scope.letDeclOpMap.get(node.name).node);
  11545. }
  11546. }
  11547. };
  11548. var Scope = _Scope;
  11549. __publicField(Scope, "forLoopContextVariableTypes", /* @__PURE__ */ new Map([
  11550. ["$first", ts42.SyntaxKind.BooleanKeyword],
  11551. ["$last", ts42.SyntaxKind.BooleanKeyword],
  11552. ["$even", ts42.SyntaxKind.BooleanKeyword],
  11553. ["$odd", ts42.SyntaxKind.BooleanKeyword],
  11554. ["$index", ts42.SyntaxKind.NumberKeyword],
  11555. ["$count", ts42.SyntaxKind.NumberKeyword]
  11556. ]));
  11557. function tcbThisParam(name, typeArguments) {
  11558. return ts42.factory.createParameterDeclaration(
  11559. void 0,
  11560. void 0,
  11561. "this",
  11562. void 0,
  11563. ts42.factory.createTypeReferenceNode(name, typeArguments),
  11564. void 0
  11565. );
  11566. }
  11567. function tcbExpression(ast, tcb, scope) {
  11568. const translator = new TcbExpressionTranslator(tcb, scope);
  11569. return translator.translate(ast);
  11570. }
  11571. var TcbExpressionTranslator = class {
  11572. tcb;
  11573. scope;
  11574. constructor(tcb, scope) {
  11575. this.tcb = tcb;
  11576. this.scope = scope;
  11577. }
  11578. translate(ast) {
  11579. return astToTypescript(ast, (ast2) => this.resolve(ast2), this.tcb.env.config);
  11580. }
  11581. resolve(ast) {
  11582. if (ast instanceof PropertyRead3 && ast.receiver instanceof ImplicitReceiver2 && !(ast.receiver instanceof ThisReceiver)) {
  11583. const target = this.tcb.boundTarget.getExpressionTarget(ast);
  11584. const targetExpression = target === null ? null : this.getTargetNodeExpression(target, ast);
  11585. if (target instanceof TmplAstLetDeclaration2 && !this.isValidLetDeclarationAccess(target, ast)) {
  11586. this.tcb.oobRecorder.letUsedBeforeDefinition(this.tcb.id, ast, target);
  11587. if (targetExpression !== null) {
  11588. return ts42.factory.createAsExpression(targetExpression, ts42.factory.createKeywordTypeNode(ts42.SyntaxKind.AnyKeyword));
  11589. }
  11590. }
  11591. return targetExpression;
  11592. } else if (ast instanceof PropertyWrite2 && ast.receiver instanceof ImplicitReceiver2) {
  11593. const target = this.tcb.boundTarget.getExpressionTarget(ast);
  11594. if (target === null) {
  11595. return null;
  11596. }
  11597. const targetExpression = this.getTargetNodeExpression(target, ast);
  11598. const expr = this.translate(ast.value);
  11599. const result = ts42.factory.createParenthesizedExpression(ts42.factory.createBinaryExpression(targetExpression, ts42.SyntaxKind.EqualsToken, expr));
  11600. addParseSpanInfo(result, ast.sourceSpan);
  11601. if (target instanceof TmplAstLetDeclaration2) {
  11602. markIgnoreDiagnostics(result);
  11603. this.tcb.oobRecorder.illegalWriteToLetDeclaration(this.tcb.id, ast, target);
  11604. }
  11605. return result;
  11606. } else if (ast instanceof ImplicitReceiver2) {
  11607. return ts42.factory.createThis();
  11608. } else if (ast instanceof BindingPipe) {
  11609. const expr = this.translate(ast.exp);
  11610. const pipeMeta = this.tcb.getPipeByName(ast.name);
  11611. let pipe;
  11612. if (pipeMeta === null) {
  11613. this.tcb.oobRecorder.missingPipe(this.tcb.id, ast);
  11614. pipe = ANY_EXPRESSION;
  11615. } else if (pipeMeta.isExplicitlyDeferred && this.tcb.boundTarget.getEagerlyUsedPipes().includes(ast.name)) {
  11616. this.tcb.oobRecorder.deferredPipeUsedEagerly(this.tcb.id, ast);
  11617. pipe = ANY_EXPRESSION;
  11618. } else {
  11619. pipe = this.tcb.env.pipeInst(pipeMeta.ref);
  11620. }
  11621. const args = ast.args.map((arg) => this.translate(arg));
  11622. let methodAccess = ts42.factory.createPropertyAccessExpression(pipe, "transform");
  11623. addParseSpanInfo(methodAccess, ast.nameSpan);
  11624. if (!this.tcb.env.config.checkTypeOfPipes) {
  11625. methodAccess = ts42.factory.createAsExpression(methodAccess, ts42.factory.createKeywordTypeNode(ts42.SyntaxKind.AnyKeyword));
  11626. }
  11627. const result = ts42.factory.createCallExpression(
  11628. methodAccess,
  11629. void 0,
  11630. [expr, ...args]
  11631. );
  11632. addParseSpanInfo(result, ast.sourceSpan);
  11633. return result;
  11634. } else if ((ast instanceof Call2 || ast instanceof SafeCall) && (ast.receiver instanceof PropertyRead3 || ast.receiver instanceof SafePropertyRead3)) {
  11635. if (ast.receiver.receiver instanceof ImplicitReceiver2 && !(ast.receiver.receiver instanceof ThisReceiver) && ast.receiver.name === "$any" && ast.args.length === 1) {
  11636. const expr = this.translate(ast.args[0]);
  11637. const exprAsAny = ts42.factory.createAsExpression(expr, ts42.factory.createKeywordTypeNode(ts42.SyntaxKind.AnyKeyword));
  11638. const result = ts42.factory.createParenthesizedExpression(exprAsAny);
  11639. addParseSpanInfo(result, ast.sourceSpan);
  11640. return result;
  11641. }
  11642. const target = this.tcb.boundTarget.getExpressionTarget(ast);
  11643. if (target === null) {
  11644. return null;
  11645. }
  11646. const receiver = this.getTargetNodeExpression(target, ast);
  11647. const method = wrapForDiagnostics(receiver);
  11648. addParseSpanInfo(method, ast.receiver.nameSpan);
  11649. const args = ast.args.map((arg) => this.translate(arg));
  11650. const node = ts42.factory.createCallExpression(method, void 0, args);
  11651. addParseSpanInfo(node, ast.sourceSpan);
  11652. return node;
  11653. } else {
  11654. return null;
  11655. }
  11656. }
  11657. getTargetNodeExpression(targetNode, expressionNode) {
  11658. const expr = this.scope.resolve(targetNode);
  11659. addParseSpanInfo(expr, expressionNode.sourceSpan);
  11660. return expr;
  11661. }
  11662. isValidLetDeclarationAccess(target, ast) {
  11663. const targetStart = target.sourceSpan.start.offset;
  11664. const targetEnd = target.sourceSpan.end.offset;
  11665. const astStart = ast.sourceSpan.start;
  11666. return targetStart < astStart && astStart > targetEnd || !this.scope.isLocal(target);
  11667. }
  11668. };
  11669. function tcbCallTypeCtor(dir, tcb, inputs) {
  11670. const typeCtor = tcb.env.typeCtorFor(dir);
  11671. const members = inputs.map((input) => {
  11672. const propertyName = ts42.factory.createStringLiteral(input.field);
  11673. if (input.type === "binding") {
  11674. let expr = widenBinding(input.expression, tcb);
  11675. if (input.isTwoWayBinding && tcb.env.config.allowSignalsInTwoWayBindings) {
  11676. expr = unwrapWritableSignal(expr, tcb);
  11677. }
  11678. const assignment = ts42.factory.createPropertyAssignment(propertyName, wrapForDiagnostics(expr));
  11679. addParseSpanInfo(assignment, input.sourceSpan);
  11680. return assignment;
  11681. } else {
  11682. return ts42.factory.createPropertyAssignment(propertyName, ANY_EXPRESSION);
  11683. }
  11684. });
  11685. return ts42.factory.createCallExpression(
  11686. typeCtor,
  11687. void 0,
  11688. [ts42.factory.createObjectLiteralExpression(members)]
  11689. );
  11690. }
  11691. function getBoundAttributes(directive, node) {
  11692. const boundInputs = [];
  11693. const processAttribute = (attr) => {
  11694. if (attr instanceof TmplAstBoundAttribute && attr.type !== BindingType.Property && attr.type !== BindingType.TwoWay) {
  11695. return;
  11696. }
  11697. const inputs = directive.inputs.getByBindingPropertyName(attr.name);
  11698. if (inputs !== null) {
  11699. boundInputs.push({
  11700. attribute: attr,
  11701. inputs: inputs.map((input) => {
  11702. var _a;
  11703. return {
  11704. fieldName: input.classPropertyName,
  11705. required: input.required,
  11706. transformType: ((_a = input.transform) == null ? void 0 : _a.type) || null,
  11707. isSignal: input.isSignal,
  11708. isTwoWayBinding: attr instanceof TmplAstBoundAttribute && attr.type === BindingType.TwoWay
  11709. };
  11710. })
  11711. });
  11712. }
  11713. };
  11714. node.inputs.forEach(processAttribute);
  11715. node.attributes.forEach(processAttribute);
  11716. if (node instanceof TmplAstTemplate) {
  11717. node.templateAttrs.forEach(processAttribute);
  11718. }
  11719. return boundInputs;
  11720. }
  11721. function translateInput(attr, tcb, scope) {
  11722. if (attr instanceof TmplAstBoundAttribute) {
  11723. return tcbExpression(attr.value, tcb, scope);
  11724. } else {
  11725. return ts42.factory.createStringLiteral(attr.value);
  11726. }
  11727. }
  11728. function widenBinding(expr, tcb) {
  11729. if (!tcb.env.config.checkTypeOfInputBindings) {
  11730. return tsCastToAny(expr);
  11731. } else if (!tcb.env.config.strictNullInputBindings) {
  11732. if (ts42.isObjectLiteralExpression(expr) || ts42.isArrayLiteralExpression(expr)) {
  11733. return expr;
  11734. } else {
  11735. return ts42.factory.createNonNullExpression(expr);
  11736. }
  11737. } else {
  11738. return expr;
  11739. }
  11740. }
  11741. function unwrapWritableSignal(expression, tcb) {
  11742. const unwrapRef = tcb.env.referenceExternalSymbol(R3Identifiers4.unwrapWritableSignal.moduleName, R3Identifiers4.unwrapWritableSignal.name);
  11743. return ts42.factory.createCallExpression(unwrapRef, void 0, [expression]);
  11744. }
  11745. var EVENT_PARAMETER = "$event";
  11746. function tcbCreateEventHandler(event, tcb, scope, eventType) {
  11747. const handler = tcbEventHandlerExpression(event.handler, tcb, scope);
  11748. const statements = [];
  11749. if (event.type === ParsedEventType.TwoWay && tcb.env.config.checkTwoWayBoundEvents) {
  11750. const target = tcb.allocateId();
  11751. const assignment = ts42.factory.createBinaryExpression(target, ts42.SyntaxKind.EqualsToken, ts42.factory.createIdentifier(EVENT_PARAMETER));
  11752. statements.push(tsCreateVariable(target, tcb.env.config.allowSignalsInTwoWayBindings ? unwrapWritableSignal(handler, tcb) : handler), ts42.factory.createExpressionStatement(assignment));
  11753. } else {
  11754. statements.push(ts42.factory.createExpressionStatement(handler));
  11755. }
  11756. let eventParamType;
  11757. if (eventType === 0) {
  11758. eventParamType = void 0;
  11759. } else if (eventType === 1) {
  11760. eventParamType = ts42.factory.createKeywordTypeNode(ts42.SyntaxKind.AnyKeyword);
  11761. } else {
  11762. eventParamType = eventType;
  11763. }
  11764. const guards = scope.guards();
  11765. let body = ts42.factory.createBlock(statements);
  11766. if (guards !== null) {
  11767. body = ts42.factory.createBlock([ts42.factory.createIfStatement(guards, body)]);
  11768. }
  11769. const eventParam = ts42.factory.createParameterDeclaration(
  11770. void 0,
  11771. void 0,
  11772. EVENT_PARAMETER,
  11773. void 0,
  11774. eventParamType
  11775. );
  11776. addExpressionIdentifier(eventParam, ExpressionIdentifier.EVENT_PARAMETER);
  11777. return ts42.factory.createArrowFunction(
  11778. void 0,
  11779. void 0,
  11780. [eventParam],
  11781. ts42.factory.createKeywordTypeNode(ts42.SyntaxKind.AnyKeyword),
  11782. void 0,
  11783. body
  11784. );
  11785. }
  11786. function tcbEventHandlerExpression(ast, tcb, scope) {
  11787. const translator = new TcbEventHandlerTranslator(tcb, scope);
  11788. return translator.translate(ast);
  11789. }
  11790. function checkSplitTwoWayBinding(inputName, output, inputs, tcb) {
  11791. const input = inputs.find((input2) => input2.name === inputName);
  11792. if (input === void 0 || input.sourceSpan !== output.sourceSpan) {
  11793. return false;
  11794. }
  11795. const inputConsumer = tcb.boundTarget.getConsumerOfBinding(input);
  11796. const outputConsumer = tcb.boundTarget.getConsumerOfBinding(output);
  11797. if (outputConsumer === null || inputConsumer.ref === void 0 || outputConsumer instanceof TmplAstTemplate) {
  11798. return false;
  11799. }
  11800. if (outputConsumer instanceof TmplAstElement2) {
  11801. tcb.oobRecorder.splitTwoWayBinding(tcb.id, input, output, inputConsumer.ref.node, outputConsumer);
  11802. return true;
  11803. } else if (outputConsumer.ref !== inputConsumer.ref) {
  11804. tcb.oobRecorder.splitTwoWayBinding(tcb.id, input, output, inputConsumer.ref.node, outputConsumer.ref.node);
  11805. return true;
  11806. }
  11807. return false;
  11808. }
  11809. var TcbEventHandlerTranslator = class extends TcbExpressionTranslator {
  11810. resolve(ast) {
  11811. if (ast instanceof PropertyRead3 && ast.receiver instanceof ImplicitReceiver2 && !(ast.receiver instanceof ThisReceiver) && ast.name === EVENT_PARAMETER) {
  11812. const event = ts42.factory.createIdentifier(EVENT_PARAMETER);
  11813. addParseSpanInfo(event, ast.nameSpan);
  11814. return event;
  11815. }
  11816. return super.resolve(ast);
  11817. }
  11818. isValidLetDeclarationAccess() {
  11819. return true;
  11820. }
  11821. };
  11822. var TcbForLoopTrackTranslator = class extends TcbExpressionTranslator {
  11823. block;
  11824. allowedVariables;
  11825. constructor(tcb, scope, block) {
  11826. super(tcb, scope);
  11827. this.block = block;
  11828. this.allowedVariables = /* @__PURE__ */ new Set([block.item]);
  11829. for (const variable of block.contextVariables) {
  11830. if (variable.value === "$index") {
  11831. this.allowedVariables.add(variable);
  11832. }
  11833. }
  11834. }
  11835. resolve(ast) {
  11836. if (ast instanceof PropertyRead3 && ast.receiver instanceof ImplicitReceiver2) {
  11837. const target = this.tcb.boundTarget.getExpressionTarget(ast);
  11838. if (target !== null && (!(target instanceof TmplAstVariable) || !this.allowedVariables.has(target))) {
  11839. this.tcb.oobRecorder.illegalForLoopTrackAccess(this.tcb.id, this.block, ast);
  11840. }
  11841. }
  11842. return super.resolve(ast);
  11843. }
  11844. };
  11845. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/type_check_file.mjs
  11846. import ts43 from "typescript";
  11847. var TypeCheckFile = class extends Environment {
  11848. fileName;
  11849. nextTcbId = 1;
  11850. tcbStatements = [];
  11851. constructor(fileName, config, refEmitter, reflector, compilerHost) {
  11852. super(config, new ImportManager({
  11853. forceGenerateNamespacesForNewImports: true,
  11854. shouldUseSingleQuotes: () => true
  11855. }), refEmitter, reflector, ts43.createSourceFile(compilerHost.getCanonicalFileName(fileName), "", ts43.ScriptTarget.Latest, true));
  11856. this.fileName = fileName;
  11857. }
  11858. addTypeCheckBlock(ref, meta, domSchemaChecker, oobRecorder, genericContextBehavior) {
  11859. const fnId = ts43.factory.createIdentifier(`_tcb${this.nextTcbId++}`);
  11860. const fn = generateTypeCheckBlock(this, ref, fnId, meta, domSchemaChecker, oobRecorder, genericContextBehavior);
  11861. this.tcbStatements.push(fn);
  11862. }
  11863. render(removeComments) {
  11864. ensureTypeCheckFilePreparationImports(this);
  11865. const importChanges = this.importManager.finalize();
  11866. if (importChanges.updatedImports.size > 0) {
  11867. throw new Error("AssertionError: Expected no imports to be updated for a new type check file.");
  11868. }
  11869. const printer = ts43.createPrinter({ removeComments });
  11870. let source = "";
  11871. const newImports = importChanges.newImports.get(this.contextFile.fileName);
  11872. if (newImports !== void 0) {
  11873. source += newImports.map((i) => printer.printNode(ts43.EmitHint.Unspecified, i, this.contextFile)).join("\n");
  11874. }
  11875. source += "\n";
  11876. for (const stmt of this.pipeInstStatements) {
  11877. source += printer.printNode(ts43.EmitHint.Unspecified, stmt, this.contextFile) + "\n";
  11878. }
  11879. for (const stmt of this.typeCtorStatements) {
  11880. source += printer.printNode(ts43.EmitHint.Unspecified, stmt, this.contextFile) + "\n";
  11881. }
  11882. source += "\n";
  11883. for (const stmt of this.tcbStatements) {
  11884. source += printer.printNode(ts43.EmitHint.Unspecified, stmt, this.contextFile) + "\n";
  11885. }
  11886. source += "\nexport const IS_A_MODULE = true;\n";
  11887. return source;
  11888. }
  11889. getPreludeStatements() {
  11890. return [];
  11891. }
  11892. };
  11893. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/context.mjs
  11894. var InliningMode;
  11895. (function(InliningMode2) {
  11896. InliningMode2[InliningMode2["InlineOps"] = 0] = "InlineOps";
  11897. InliningMode2[InliningMode2["Error"] = 1] = "Error";
  11898. })(InliningMode || (InliningMode = {}));
  11899. var TypeCheckContextImpl = class {
  11900. config;
  11901. compilerHost;
  11902. refEmitter;
  11903. reflector;
  11904. host;
  11905. inlining;
  11906. perf;
  11907. fileMap = /* @__PURE__ */ new Map();
  11908. constructor(config, compilerHost, refEmitter, reflector, host, inlining, perf) {
  11909. this.config = config;
  11910. this.compilerHost = compilerHost;
  11911. this.refEmitter = refEmitter;
  11912. this.reflector = reflector;
  11913. this.host = host;
  11914. this.inlining = inlining;
  11915. this.perf = perf;
  11916. if (inlining === InliningMode.Error && config.useInlineTypeConstructors) {
  11917. throw new Error(`AssertionError: invalid inlining configuration.`);
  11918. }
  11919. }
  11920. opMap = /* @__PURE__ */ new Map();
  11921. typeCtorPending = /* @__PURE__ */ new Set();
  11922. addDirective(ref, binder, schemas, templateContext, isStandalone) {
  11923. var _a;
  11924. if (!this.host.shouldCheckClass(ref.node)) {
  11925. return;
  11926. }
  11927. const fileData = this.dataForFile(ref.node.getSourceFile());
  11928. const shimData = this.pendingShimForClass(ref.node);
  11929. const id = fileData.sourceManager.getTypeCheckId(ref.node);
  11930. const templateParsingDiagnostics = [];
  11931. if (templateContext !== null && templateContext.parseErrors !== null) {
  11932. templateParsingDiagnostics.push(...getTemplateDiagnostics(templateContext.parseErrors, id, templateContext.sourceMapping));
  11933. }
  11934. const boundTarget = binder.bind({ template: templateContext == null ? void 0 : templateContext.nodes });
  11935. if (this.inlining === InliningMode.InlineOps) {
  11936. for (const dir of boundTarget.getUsedDirectives()) {
  11937. const dirRef = dir.ref;
  11938. const dirNode = dirRef.node;
  11939. if (!dir.isGeneric || !requiresInlineTypeCtor(dirNode, this.reflector, shimData.file)) {
  11940. continue;
  11941. }
  11942. this.addInlineTypeCtor(fileData, dirNode.getSourceFile(), dirRef, {
  11943. fnName: "ngTypeCtor",
  11944. body: !dirNode.getSourceFile().isDeclarationFile,
  11945. fields: {
  11946. inputs: dir.inputs,
  11947. queries: dir.queries
  11948. },
  11949. coercedInputFields: dir.coercedInputFields
  11950. });
  11951. }
  11952. }
  11953. shimData.data.set(id, {
  11954. template: (templateContext == null ? void 0 : templateContext.nodes) || null,
  11955. boundTarget,
  11956. templateParsingDiagnostics
  11957. });
  11958. const usedPipes = [];
  11959. if (templateContext !== null) {
  11960. for (const name of boundTarget.getUsedPipes()) {
  11961. if (templateContext.pipes.has(name)) {
  11962. usedPipes.push(templateContext.pipes.get(name).ref);
  11963. }
  11964. }
  11965. }
  11966. const inliningRequirement = requiresInlineTypeCheckBlock(ref, shimData.file, usedPipes, this.reflector);
  11967. if (this.inlining === InliningMode.Error && inliningRequirement === TcbInliningRequirement.MustInline) {
  11968. shimData.oobRecorder.requiresInlineTcb(id, ref.node);
  11969. this.perf.eventCount(PerfEvent.SkipGenerateTcbNoInline);
  11970. return;
  11971. }
  11972. if (templateContext !== null) {
  11973. fileData.sourceManager.captureTemplateSource(id, templateContext.sourceMapping, templateContext.file);
  11974. }
  11975. const meta = {
  11976. id,
  11977. boundTarget,
  11978. pipes: (templateContext == null ? void 0 : templateContext.pipes) || null,
  11979. schemas,
  11980. isStandalone,
  11981. preserveWhitespaces: (_a = templateContext == null ? void 0 : templateContext.preserveWhitespaces) != null ? _a : false
  11982. };
  11983. this.perf.eventCount(PerfEvent.GenerateTcb);
  11984. if (inliningRequirement !== TcbInliningRequirement.None && this.inlining === InliningMode.InlineOps) {
  11985. this.addInlineTypeCheckBlock(fileData, shimData, ref, meta);
  11986. } else if (inliningRequirement === TcbInliningRequirement.ShouldInlineForGenericBounds && this.inlining === InliningMode.Error) {
  11987. shimData.file.addTypeCheckBlock(ref, meta, shimData.domSchemaChecker, shimData.oobRecorder, TcbGenericContextBehavior.FallbackToAny);
  11988. } else {
  11989. shimData.file.addTypeCheckBlock(ref, meta, shimData.domSchemaChecker, shimData.oobRecorder, TcbGenericContextBehavior.UseEmitter);
  11990. }
  11991. }
  11992. addInlineTypeCtor(fileData, sf, ref, ctorMeta) {
  11993. if (this.typeCtorPending.has(ref.node)) {
  11994. return;
  11995. }
  11996. this.typeCtorPending.add(ref.node);
  11997. if (!this.opMap.has(sf)) {
  11998. this.opMap.set(sf, []);
  11999. }
  12000. const ops = this.opMap.get(sf);
  12001. ops.push(new TypeCtorOp(ref, this.reflector, ctorMeta));
  12002. fileData.hasInlines = true;
  12003. }
  12004. transform(sf) {
  12005. if (!this.opMap.has(sf)) {
  12006. return null;
  12007. }
  12008. const printer = ts44.createPrinter({ omitTrailingSemicolon: true });
  12009. const importManager = new ImportManager({
  12010. forceGenerateNamespacesForNewImports: true,
  12011. shouldUseSingleQuotes: () => true
  12012. });
  12013. const updates = this.opMap.get(sf).map((op) => {
  12014. return {
  12015. pos: op.splitPoint,
  12016. text: op.execute(importManager, sf, this.refEmitter, printer)
  12017. };
  12018. });
  12019. const { newImports, updatedImports } = importManager.finalize();
  12020. if (newImports.has(sf.fileName)) {
  12021. newImports.get(sf.fileName).forEach((newImport) => {
  12022. updates.push({
  12023. pos: 0,
  12024. text: printer.printNode(ts44.EmitHint.Unspecified, newImport, sf)
  12025. });
  12026. });
  12027. }
  12028. for (const [oldBindings, newBindings] of updatedImports.entries()) {
  12029. if (oldBindings.getSourceFile() !== sf) {
  12030. throw new Error("Unexpected updates to unrelated source files.");
  12031. }
  12032. updates.push({
  12033. pos: oldBindings.getStart(),
  12034. deletePos: oldBindings.getEnd(),
  12035. text: printer.printNode(ts44.EmitHint.Unspecified, newBindings, sf)
  12036. });
  12037. }
  12038. const result = new MagicString(sf.text, { filename: sf.fileName });
  12039. for (const update of updates) {
  12040. if (update.deletePos !== void 0) {
  12041. result.remove(update.pos, update.deletePos);
  12042. }
  12043. result.appendLeft(update.pos, update.text);
  12044. }
  12045. return result.toString();
  12046. }
  12047. finalize() {
  12048. const updates = /* @__PURE__ */ new Map();
  12049. for (const originalSf of this.opMap.keys()) {
  12050. const newText = this.transform(originalSf);
  12051. if (newText !== null) {
  12052. updates.set(absoluteFromSourceFile(originalSf), {
  12053. newText,
  12054. originalFile: originalSf
  12055. });
  12056. }
  12057. }
  12058. for (const [sfPath, pendingFileData] of this.fileMap) {
  12059. for (const pendingShimData of pendingFileData.shimData.values()) {
  12060. this.host.recordShimData(sfPath, {
  12061. genesisDiagnostics: [
  12062. ...pendingShimData.domSchemaChecker.diagnostics,
  12063. ...pendingShimData.oobRecorder.diagnostics
  12064. ],
  12065. hasInlines: pendingFileData.hasInlines,
  12066. path: pendingShimData.file.fileName,
  12067. data: pendingShimData.data
  12068. });
  12069. const sfText = pendingShimData.file.render(false);
  12070. updates.set(pendingShimData.file.fileName, {
  12071. newText: sfText,
  12072. originalFile: null
  12073. });
  12074. }
  12075. }
  12076. return updates;
  12077. }
  12078. addInlineTypeCheckBlock(fileData, shimData, ref, tcbMeta) {
  12079. const sf = ref.node.getSourceFile();
  12080. if (!this.opMap.has(sf)) {
  12081. this.opMap.set(sf, []);
  12082. }
  12083. const ops = this.opMap.get(sf);
  12084. ops.push(new InlineTcbOp(ref, tcbMeta, this.config, this.reflector, shimData.domSchemaChecker, shimData.oobRecorder));
  12085. fileData.hasInlines = true;
  12086. }
  12087. pendingShimForClass(node) {
  12088. const fileData = this.dataForFile(node.getSourceFile());
  12089. const shimPath = TypeCheckShimGenerator.shimFor(absoluteFromSourceFile(node.getSourceFile()));
  12090. if (!fileData.shimData.has(shimPath)) {
  12091. fileData.shimData.set(shimPath, {
  12092. domSchemaChecker: new RegistryDomSchemaChecker(fileData.sourceManager),
  12093. oobRecorder: new OutOfBandDiagnosticRecorderImpl(fileData.sourceManager),
  12094. file: new TypeCheckFile(shimPath, this.config, this.refEmitter, this.reflector, this.compilerHost),
  12095. data: /* @__PURE__ */ new Map()
  12096. });
  12097. }
  12098. return fileData.shimData.get(shimPath);
  12099. }
  12100. dataForFile(sf) {
  12101. const sfPath = absoluteFromSourceFile(sf);
  12102. if (!this.fileMap.has(sfPath)) {
  12103. const data = {
  12104. hasInlines: false,
  12105. sourceManager: this.host.getSourceManager(sfPath),
  12106. shimData: /* @__PURE__ */ new Map()
  12107. };
  12108. this.fileMap.set(sfPath, data);
  12109. }
  12110. return this.fileMap.get(sfPath);
  12111. }
  12112. };
  12113. function getTemplateDiagnostics(parseErrors, templateId, sourceMapping) {
  12114. return parseErrors.map((error) => {
  12115. const span = error.span;
  12116. if (span.start.offset === span.end.offset) {
  12117. span.end.offset++;
  12118. }
  12119. return makeTemplateDiagnostic(templateId, sourceMapping, span, ts44.DiagnosticCategory.Error, ngErrorCode(ErrorCode.TEMPLATE_PARSE_ERROR), error.msg);
  12120. });
  12121. }
  12122. var InlineTcbOp = class {
  12123. ref;
  12124. meta;
  12125. config;
  12126. reflector;
  12127. domSchemaChecker;
  12128. oobRecorder;
  12129. constructor(ref, meta, config, reflector, domSchemaChecker, oobRecorder) {
  12130. this.ref = ref;
  12131. this.meta = meta;
  12132. this.config = config;
  12133. this.reflector = reflector;
  12134. this.domSchemaChecker = domSchemaChecker;
  12135. this.oobRecorder = oobRecorder;
  12136. }
  12137. get splitPoint() {
  12138. return this.ref.node.end + 1;
  12139. }
  12140. execute(im, sf, refEmitter, printer) {
  12141. const env = new Environment(this.config, im, refEmitter, this.reflector, sf);
  12142. const fnName = ts44.factory.createIdentifier(`_tcb_${this.ref.node.pos}`);
  12143. const fn = generateTypeCheckBlock(env, this.ref, fnName, this.meta, this.domSchemaChecker, this.oobRecorder, TcbGenericContextBehavior.CopyClassNodes);
  12144. return printer.printNode(ts44.EmitHint.Unspecified, fn, sf);
  12145. }
  12146. };
  12147. var TypeCtorOp = class {
  12148. ref;
  12149. reflector;
  12150. meta;
  12151. constructor(ref, reflector, meta) {
  12152. this.ref = ref;
  12153. this.reflector = reflector;
  12154. this.meta = meta;
  12155. }
  12156. get splitPoint() {
  12157. return this.ref.node.end - 1;
  12158. }
  12159. execute(im, sf, refEmitter, printer) {
  12160. const emitEnv = new ReferenceEmitEnvironment(im, refEmitter, this.reflector, sf);
  12161. const tcb = generateInlineTypeCtor(emitEnv, this.ref.node, this.meta);
  12162. return printer.printNode(ts44.EmitHint.Unspecified, tcb, sf);
  12163. }
  12164. };
  12165. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/source.mjs
  12166. import { ParseLocation as ParseLocation2, ParseSourceSpan as ParseSourceSpan2 } from "@angular/compiler";
  12167. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/line_mappings.mjs
  12168. var LF_CHAR = 10;
  12169. var CR_CHAR = 13;
  12170. var LINE_SEP_CHAR = 8232;
  12171. var PARAGRAPH_CHAR = 8233;
  12172. function getLineAndCharacterFromPosition(lineStartsMap, position) {
  12173. const lineIndex = findClosestLineStartPosition(lineStartsMap, position);
  12174. return { character: position - lineStartsMap[lineIndex], line: lineIndex };
  12175. }
  12176. function computeLineStartsMap(text) {
  12177. const result = [0];
  12178. let pos = 0;
  12179. while (pos < text.length) {
  12180. const char = text.charCodeAt(pos++);
  12181. if (char === CR_CHAR) {
  12182. if (text.charCodeAt(pos) === LF_CHAR) {
  12183. pos++;
  12184. }
  12185. result.push(pos);
  12186. } else if (char === LF_CHAR || char === LINE_SEP_CHAR || char === PARAGRAPH_CHAR) {
  12187. result.push(pos);
  12188. }
  12189. }
  12190. result.push(pos);
  12191. return result;
  12192. }
  12193. function findClosestLineStartPosition(linesMap, position, low = 0, high = linesMap.length - 1) {
  12194. while (low <= high) {
  12195. const pivotIdx = Math.floor((low + high) / 2);
  12196. const pivotEl = linesMap[pivotIdx];
  12197. if (pivotEl === position) {
  12198. return pivotIdx;
  12199. } else if (position > pivotEl) {
  12200. low = pivotIdx + 1;
  12201. } else {
  12202. high = pivotIdx - 1;
  12203. }
  12204. }
  12205. return low - 1;
  12206. }
  12207. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/source.mjs
  12208. var TemplateSource = class {
  12209. mapping;
  12210. file;
  12211. lineStarts = null;
  12212. constructor(mapping, file) {
  12213. this.mapping = mapping;
  12214. this.file = file;
  12215. }
  12216. toParseSourceSpan(start, end) {
  12217. const startLoc = this.toParseLocation(start);
  12218. const endLoc = this.toParseLocation(end);
  12219. return new ParseSourceSpan2(startLoc, endLoc);
  12220. }
  12221. toParseLocation(position) {
  12222. const lineStarts = this.acquireLineStarts();
  12223. const { line, character } = getLineAndCharacterFromPosition(lineStarts, position);
  12224. return new ParseLocation2(this.file, position, line, character);
  12225. }
  12226. acquireLineStarts() {
  12227. if (this.lineStarts === null) {
  12228. this.lineStarts = computeLineStartsMap(this.file.content);
  12229. }
  12230. return this.lineStarts;
  12231. }
  12232. };
  12233. var DirectiveSourceManager = class {
  12234. templateSources = /* @__PURE__ */ new Map();
  12235. getTypeCheckId(node) {
  12236. return getTypeCheckId(node);
  12237. }
  12238. captureTemplateSource(id, mapping, file) {
  12239. this.templateSources.set(id, new TemplateSource(mapping, file));
  12240. }
  12241. getTemplateSourceMapping(id) {
  12242. if (!this.templateSources.has(id)) {
  12243. throw new Error(`Unexpected unknown type check ID: ${id}`);
  12244. }
  12245. return this.templateSources.get(id).mapping;
  12246. }
  12247. toTemplateParseSourceSpan(id, span) {
  12248. if (!this.templateSources.has(id)) {
  12249. return null;
  12250. }
  12251. const templateSource = this.templateSources.get(id);
  12252. return templateSource.toParseSourceSpan(span.start, span.end);
  12253. }
  12254. };
  12255. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/template_symbol_builder.mjs
  12256. import { AST, ASTWithName, ASTWithSource as ASTWithSource2, BindingPipe as BindingPipe2, PropertyRead as PropertyRead4, PropertyWrite as PropertyWrite3, R3Identifiers as R3Identifiers5, SafePropertyRead as SafePropertyRead4, TmplAstBoundAttribute as TmplAstBoundAttribute2, TmplAstBoundEvent, TmplAstElement as TmplAstElement3, TmplAstLetDeclaration as TmplAstLetDeclaration3, TmplAstReference as TmplAstReference3, TmplAstTemplate as TmplAstTemplate2, TmplAstTextAttribute as TmplAstTextAttribute3, TmplAstVariable as TmplAstVariable2 } from "@angular/compiler";
  12257. import ts45 from "typescript";
  12258. var SymbolBuilder = class {
  12259. tcbPath;
  12260. tcbIsShim;
  12261. typeCheckBlock;
  12262. typeCheckData;
  12263. componentScopeReader;
  12264. getTypeChecker;
  12265. symbolCache = /* @__PURE__ */ new Map();
  12266. constructor(tcbPath, tcbIsShim, typeCheckBlock, typeCheckData, componentScopeReader, getTypeChecker) {
  12267. this.tcbPath = tcbPath;
  12268. this.tcbIsShim = tcbIsShim;
  12269. this.typeCheckBlock = typeCheckBlock;
  12270. this.typeCheckData = typeCheckData;
  12271. this.componentScopeReader = componentScopeReader;
  12272. this.getTypeChecker = getTypeChecker;
  12273. }
  12274. getSymbol(node) {
  12275. if (this.symbolCache.has(node)) {
  12276. return this.symbolCache.get(node);
  12277. }
  12278. let symbol = null;
  12279. if (node instanceof TmplAstBoundAttribute2 || node instanceof TmplAstTextAttribute3) {
  12280. symbol = this.getSymbolOfInputBinding(node);
  12281. } else if (node instanceof TmplAstBoundEvent) {
  12282. symbol = this.getSymbolOfBoundEvent(node);
  12283. } else if (node instanceof TmplAstElement3) {
  12284. symbol = this.getSymbolOfElement(node);
  12285. } else if (node instanceof TmplAstTemplate2) {
  12286. symbol = this.getSymbolOfAstTemplate(node);
  12287. } else if (node instanceof TmplAstVariable2) {
  12288. symbol = this.getSymbolOfVariable(node);
  12289. } else if (node instanceof TmplAstLetDeclaration3) {
  12290. symbol = this.getSymbolOfLetDeclaration(node);
  12291. } else if (node instanceof TmplAstReference3) {
  12292. symbol = this.getSymbolOfReference(node);
  12293. } else if (node instanceof BindingPipe2) {
  12294. symbol = this.getSymbolOfPipe(node);
  12295. } else if (node instanceof AST) {
  12296. symbol = this.getSymbolOfTemplateExpression(node);
  12297. } else {
  12298. }
  12299. this.symbolCache.set(node, symbol);
  12300. return symbol;
  12301. }
  12302. getSymbolOfAstTemplate(template) {
  12303. const directives = this.getDirectivesOfNode(template);
  12304. return { kind: SymbolKind.Template, directives, templateNode: template };
  12305. }
  12306. getSymbolOfElement(element) {
  12307. var _a;
  12308. const elementSourceSpan = (_a = element.startSourceSpan) != null ? _a : element.sourceSpan;
  12309. const node = findFirstMatchingNode(this.typeCheckBlock, {
  12310. withSpan: elementSourceSpan,
  12311. filter: ts45.isVariableDeclaration
  12312. });
  12313. if (node === null) {
  12314. return null;
  12315. }
  12316. const symbolFromDeclaration = this.getSymbolOfTsNode(node);
  12317. if (symbolFromDeclaration === null || symbolFromDeclaration.tsSymbol === null) {
  12318. return null;
  12319. }
  12320. const directives = this.getDirectivesOfNode(element);
  12321. return {
  12322. ...symbolFromDeclaration,
  12323. kind: SymbolKind.Element,
  12324. directives,
  12325. templateNode: element
  12326. };
  12327. }
  12328. getDirectivesOfNode(element) {
  12329. var _a;
  12330. const elementSourceSpan = (_a = element.startSourceSpan) != null ? _a : element.sourceSpan;
  12331. const tcbSourceFile = this.typeCheckBlock.getSourceFile();
  12332. const isDirectiveDeclaration = (node) => (ts45.isTypeNode(node) || ts45.isIdentifier(node)) && ts45.isVariableDeclaration(node.parent) && hasExpressionIdentifier(tcbSourceFile, node, ExpressionIdentifier.DIRECTIVE);
  12333. const nodes = findAllMatchingNodes(this.typeCheckBlock, {
  12334. withSpan: elementSourceSpan,
  12335. filter: isDirectiveDeclaration
  12336. });
  12337. const symbols = [];
  12338. for (const node of nodes) {
  12339. const symbol = this.getSymbolOfTsNode(node.parent);
  12340. if (symbol === null || !isSymbolWithValueDeclaration(symbol.tsSymbol) || !ts45.isClassDeclaration(symbol.tsSymbol.valueDeclaration)) {
  12341. continue;
  12342. }
  12343. const meta = this.getDirectiveMeta(element, symbol.tsSymbol.valueDeclaration);
  12344. if (meta !== null && meta.selector !== null) {
  12345. const ref = new Reference(symbol.tsSymbol.valueDeclaration);
  12346. if (meta.hostDirectives !== null) {
  12347. this.addHostDirectiveSymbols(element, meta.hostDirectives, symbols);
  12348. }
  12349. const directiveSymbol = {
  12350. ...symbol,
  12351. ref,
  12352. tsSymbol: symbol.tsSymbol,
  12353. selector: meta.selector,
  12354. isComponent: meta.isComponent,
  12355. ngModule: this.getDirectiveModule(symbol.tsSymbol.valueDeclaration),
  12356. kind: SymbolKind.Directive,
  12357. isStructural: meta.isStructural,
  12358. isInScope: true,
  12359. isHostDirective: false
  12360. };
  12361. symbols.push(directiveSymbol);
  12362. }
  12363. }
  12364. return symbols;
  12365. }
  12366. addHostDirectiveSymbols(host, hostDirectives, symbols) {
  12367. for (const current of hostDirectives) {
  12368. if (!isHostDirectiveMetaForGlobalMode(current)) {
  12369. throw new Error("Impossible state: typecheck code path in local compilation mode.");
  12370. }
  12371. if (!ts45.isClassDeclaration(current.directive.node)) {
  12372. continue;
  12373. }
  12374. const symbol = this.getSymbolOfTsNode(current.directive.node);
  12375. const meta = this.getDirectiveMeta(host, current.directive.node);
  12376. if (meta !== null && symbol !== null && isSymbolWithValueDeclaration(symbol.tsSymbol)) {
  12377. if (meta.hostDirectives !== null) {
  12378. this.addHostDirectiveSymbols(host, meta.hostDirectives, symbols);
  12379. }
  12380. const directiveSymbol = {
  12381. ...symbol,
  12382. isHostDirective: true,
  12383. ref: current.directive,
  12384. tsSymbol: symbol.tsSymbol,
  12385. exposedInputs: current.inputs,
  12386. exposedOutputs: current.outputs,
  12387. selector: meta.selector,
  12388. isComponent: meta.isComponent,
  12389. ngModule: this.getDirectiveModule(current.directive.node),
  12390. kind: SymbolKind.Directive,
  12391. isStructural: meta.isStructural,
  12392. isInScope: true
  12393. };
  12394. symbols.push(directiveSymbol);
  12395. }
  12396. }
  12397. }
  12398. getDirectiveMeta(host, directiveDeclaration) {
  12399. var _a;
  12400. let directives = this.typeCheckData.boundTarget.getDirectivesOfNode(host);
  12401. const firstChild = host.children[0];
  12402. if (firstChild instanceof TmplAstElement3) {
  12403. const isMicrosyntaxTemplate = host instanceof TmplAstTemplate2 && sourceSpanEqual(firstChild.sourceSpan, host.sourceSpan);
  12404. if (isMicrosyntaxTemplate) {
  12405. const firstChildDirectives = this.typeCheckData.boundTarget.getDirectivesOfNode(firstChild);
  12406. if (firstChildDirectives !== null && directives !== null) {
  12407. directives = directives.concat(firstChildDirectives);
  12408. } else {
  12409. directives = directives != null ? directives : firstChildDirectives;
  12410. }
  12411. }
  12412. }
  12413. if (directives === null) {
  12414. return null;
  12415. }
  12416. return (_a = directives.find((m) => m.ref.node === directiveDeclaration)) != null ? _a : null;
  12417. }
  12418. getDirectiveModule(declaration) {
  12419. const scope = this.componentScopeReader.getScopeForComponent(declaration);
  12420. if (scope === null || scope.kind !== ComponentScopeKind.NgModule) {
  12421. return null;
  12422. }
  12423. return scope.ngModule;
  12424. }
  12425. getSymbolOfBoundEvent(eventBinding) {
  12426. const consumer = this.typeCheckData.boundTarget.getConsumerOfBinding(eventBinding);
  12427. if (consumer === null) {
  12428. return null;
  12429. }
  12430. let expectedAccess;
  12431. if (consumer instanceof TmplAstTemplate2 || consumer instanceof TmplAstElement3) {
  12432. expectedAccess = "addEventListener";
  12433. } else {
  12434. const bindingPropertyNames = consumer.outputs.getByBindingPropertyName(eventBinding.name);
  12435. if (bindingPropertyNames === null || bindingPropertyNames.length === 0) {
  12436. return null;
  12437. }
  12438. expectedAccess = bindingPropertyNames[0].classPropertyName;
  12439. }
  12440. function filter(n2) {
  12441. if (!isAccessExpression(n2)) {
  12442. return false;
  12443. }
  12444. if (ts45.isPropertyAccessExpression(n2)) {
  12445. return n2.name.getText() === expectedAccess;
  12446. } else {
  12447. return ts45.isStringLiteral(n2.argumentExpression) && n2.argumentExpression.text === expectedAccess;
  12448. }
  12449. }
  12450. const outputFieldAccesses = findAllMatchingNodes(this.typeCheckBlock, {
  12451. withSpan: eventBinding.keySpan,
  12452. filter
  12453. });
  12454. const bindings = [];
  12455. for (const outputFieldAccess of outputFieldAccesses) {
  12456. if (consumer instanceof TmplAstTemplate2 || consumer instanceof TmplAstElement3) {
  12457. if (!ts45.isPropertyAccessExpression(outputFieldAccess)) {
  12458. continue;
  12459. }
  12460. const addEventListener = outputFieldAccess.name;
  12461. const tsSymbol = this.getTypeChecker().getSymbolAtLocation(addEventListener);
  12462. const tsType = this.getTypeChecker().getTypeAtLocation(addEventListener);
  12463. const positionInFile = this.getTcbPositionForNode(addEventListener);
  12464. const target = this.getSymbol(consumer);
  12465. if (target === null || tsSymbol === void 0) {
  12466. continue;
  12467. }
  12468. bindings.push({
  12469. kind: SymbolKind.Binding,
  12470. tsSymbol,
  12471. tsType,
  12472. target,
  12473. tcbLocation: {
  12474. tcbPath: this.tcbPath,
  12475. isShimFile: this.tcbIsShim,
  12476. positionInFile
  12477. }
  12478. });
  12479. } else {
  12480. if (!ts45.isElementAccessExpression(outputFieldAccess)) {
  12481. continue;
  12482. }
  12483. const tsSymbol = this.getTypeChecker().getSymbolAtLocation(outputFieldAccess.argumentExpression);
  12484. if (tsSymbol === void 0) {
  12485. continue;
  12486. }
  12487. const target = this.getDirectiveSymbolForAccessExpression(outputFieldAccess, consumer);
  12488. if (target === null) {
  12489. continue;
  12490. }
  12491. const positionInFile = this.getTcbPositionForNode(outputFieldAccess);
  12492. const tsType = this.getTypeChecker().getTypeAtLocation(outputFieldAccess);
  12493. bindings.push({
  12494. kind: SymbolKind.Binding,
  12495. tsSymbol,
  12496. tsType,
  12497. target,
  12498. tcbLocation: {
  12499. tcbPath: this.tcbPath,
  12500. isShimFile: this.tcbIsShim,
  12501. positionInFile
  12502. }
  12503. });
  12504. }
  12505. }
  12506. if (bindings.length === 0) {
  12507. return null;
  12508. }
  12509. return { kind: SymbolKind.Output, bindings };
  12510. }
  12511. getSymbolOfInputBinding(binding) {
  12512. const consumer = this.typeCheckData.boundTarget.getConsumerOfBinding(binding);
  12513. if (consumer === null) {
  12514. return null;
  12515. }
  12516. if (consumer instanceof TmplAstElement3 || consumer instanceof TmplAstTemplate2) {
  12517. const host = this.getSymbol(consumer);
  12518. return host !== null ? { kind: SymbolKind.DomBinding, host } : null;
  12519. }
  12520. const nodes = findAllMatchingNodes(this.typeCheckBlock, {
  12521. withSpan: binding.sourceSpan,
  12522. filter: isAssignment
  12523. });
  12524. const bindings = [];
  12525. for (const node of nodes) {
  12526. if (!isAccessExpression(node.left)) {
  12527. continue;
  12528. }
  12529. const signalInputAssignment = unwrapSignalInputWriteTAccessor(node.left);
  12530. let fieldAccessExpr;
  12531. let symbolInfo = null;
  12532. if (signalInputAssignment !== null) {
  12533. if (ts45.isIdentifier(signalInputAssignment.fieldExpr)) {
  12534. continue;
  12535. }
  12536. const fieldSymbol = this.getSymbolOfTsNode(signalInputAssignment.fieldExpr);
  12537. const typeSymbol = this.getSymbolOfTsNode(signalInputAssignment.typeExpr);
  12538. fieldAccessExpr = signalInputAssignment.fieldExpr;
  12539. symbolInfo = fieldSymbol === null || typeSymbol === null ? null : {
  12540. tcbLocation: fieldSymbol.tcbLocation,
  12541. tsSymbol: fieldSymbol.tsSymbol,
  12542. tsType: typeSymbol.tsType
  12543. };
  12544. } else {
  12545. fieldAccessExpr = node.left;
  12546. symbolInfo = this.getSymbolOfTsNode(node.left);
  12547. }
  12548. if (symbolInfo === null || symbolInfo.tsSymbol === null) {
  12549. continue;
  12550. }
  12551. const target = this.getDirectiveSymbolForAccessExpression(fieldAccessExpr, consumer);
  12552. if (target === null) {
  12553. continue;
  12554. }
  12555. bindings.push({
  12556. ...symbolInfo,
  12557. tsSymbol: symbolInfo.tsSymbol,
  12558. kind: SymbolKind.Binding,
  12559. target
  12560. });
  12561. }
  12562. if (bindings.length === 0) {
  12563. return null;
  12564. }
  12565. return { kind: SymbolKind.Input, bindings };
  12566. }
  12567. getDirectiveSymbolForAccessExpression(fieldAccessExpr, { isComponent, selector, isStructural }) {
  12568. var _a;
  12569. const tsSymbol = this.getTypeChecker().getSymbolAtLocation(fieldAccessExpr.expression);
  12570. if ((tsSymbol == null ? void 0 : tsSymbol.declarations) === void 0 || tsSymbol.declarations.length === 0 || selector === null) {
  12571. return null;
  12572. }
  12573. const [declaration] = tsSymbol.declarations;
  12574. if (!ts45.isVariableDeclaration(declaration) || !hasExpressionIdentifier(
  12575. declaration.getSourceFile(),
  12576. (_a = declaration.type) != null ? _a : declaration.name,
  12577. ExpressionIdentifier.DIRECTIVE
  12578. )) {
  12579. return null;
  12580. }
  12581. const symbol = this.getSymbolOfTsNode(declaration);
  12582. if (symbol === null || !isSymbolWithValueDeclaration(symbol.tsSymbol) || !ts45.isClassDeclaration(symbol.tsSymbol.valueDeclaration)) {
  12583. return null;
  12584. }
  12585. const ref = new Reference(symbol.tsSymbol.valueDeclaration);
  12586. const ngModule = this.getDirectiveModule(symbol.tsSymbol.valueDeclaration);
  12587. return {
  12588. ref,
  12589. kind: SymbolKind.Directive,
  12590. tsSymbol: symbol.tsSymbol,
  12591. tsType: symbol.tsType,
  12592. tcbLocation: symbol.tcbLocation,
  12593. isComponent,
  12594. isStructural,
  12595. selector,
  12596. ngModule,
  12597. isHostDirective: false,
  12598. isInScope: true
  12599. };
  12600. }
  12601. getSymbolOfVariable(variable) {
  12602. const node = findFirstMatchingNode(this.typeCheckBlock, {
  12603. withSpan: variable.sourceSpan,
  12604. filter: ts45.isVariableDeclaration
  12605. });
  12606. if (node === null) {
  12607. return null;
  12608. }
  12609. let nodeValueSymbol = null;
  12610. if (ts45.isForOfStatement(node.parent.parent)) {
  12611. nodeValueSymbol = this.getSymbolOfTsNode(node);
  12612. } else if (node.initializer !== void 0) {
  12613. nodeValueSymbol = this.getSymbolOfTsNode(node.initializer);
  12614. }
  12615. if (nodeValueSymbol === null) {
  12616. return null;
  12617. }
  12618. return {
  12619. tsType: nodeValueSymbol.tsType,
  12620. tsSymbol: nodeValueSymbol.tsSymbol,
  12621. initializerLocation: nodeValueSymbol.tcbLocation,
  12622. kind: SymbolKind.Variable,
  12623. declaration: variable,
  12624. localVarLocation: {
  12625. tcbPath: this.tcbPath,
  12626. isShimFile: this.tcbIsShim,
  12627. positionInFile: this.getTcbPositionForNode(node.name)
  12628. }
  12629. };
  12630. }
  12631. getSymbolOfReference(ref) {
  12632. const target = this.typeCheckData.boundTarget.getReferenceTarget(ref);
  12633. let node = findFirstMatchingNode(this.typeCheckBlock, {
  12634. withSpan: ref.sourceSpan,
  12635. filter: ts45.isVariableDeclaration
  12636. });
  12637. if (node === null || target === null || node.initializer === void 0) {
  12638. return null;
  12639. }
  12640. const originalDeclaration = ts45.isParenthesizedExpression(node.initializer) && ts45.isAsExpression(node.initializer.expression) ? this.getTypeChecker().getSymbolAtLocation(node.name) : this.getTypeChecker().getSymbolAtLocation(node.initializer);
  12641. if (originalDeclaration === void 0 || originalDeclaration.valueDeclaration === void 0) {
  12642. return null;
  12643. }
  12644. const symbol = this.getSymbolOfTsNode(originalDeclaration.valueDeclaration);
  12645. if (symbol === null || symbol.tsSymbol === null) {
  12646. return null;
  12647. }
  12648. const referenceVarTcbLocation = {
  12649. tcbPath: this.tcbPath,
  12650. isShimFile: this.tcbIsShim,
  12651. positionInFile: this.getTcbPositionForNode(node)
  12652. };
  12653. if (target instanceof TmplAstTemplate2 || target instanceof TmplAstElement3) {
  12654. return {
  12655. kind: SymbolKind.Reference,
  12656. tsSymbol: symbol.tsSymbol,
  12657. tsType: symbol.tsType,
  12658. target,
  12659. declaration: ref,
  12660. targetLocation: symbol.tcbLocation,
  12661. referenceVarLocation: referenceVarTcbLocation
  12662. };
  12663. } else {
  12664. if (!ts45.isClassDeclaration(target.directive.ref.node)) {
  12665. return null;
  12666. }
  12667. return {
  12668. kind: SymbolKind.Reference,
  12669. tsSymbol: symbol.tsSymbol,
  12670. tsType: symbol.tsType,
  12671. declaration: ref,
  12672. target: target.directive.ref.node,
  12673. targetLocation: symbol.tcbLocation,
  12674. referenceVarLocation: referenceVarTcbLocation
  12675. };
  12676. }
  12677. }
  12678. getSymbolOfLetDeclaration(decl) {
  12679. const node = findFirstMatchingNode(this.typeCheckBlock, {
  12680. withSpan: decl.sourceSpan,
  12681. filter: ts45.isVariableDeclaration
  12682. });
  12683. if (node === null) {
  12684. return null;
  12685. }
  12686. const nodeValueSymbol = this.getSymbolOfTsNode(node.initializer);
  12687. if (nodeValueSymbol === null) {
  12688. return null;
  12689. }
  12690. return {
  12691. tsType: nodeValueSymbol.tsType,
  12692. tsSymbol: nodeValueSymbol.tsSymbol,
  12693. initializerLocation: nodeValueSymbol.tcbLocation,
  12694. kind: SymbolKind.LetDeclaration,
  12695. declaration: decl,
  12696. localVarLocation: {
  12697. tcbPath: this.tcbPath,
  12698. isShimFile: this.tcbIsShim,
  12699. positionInFile: this.getTcbPositionForNode(node.name)
  12700. }
  12701. };
  12702. }
  12703. getSymbolOfPipe(expression) {
  12704. const methodAccess = findFirstMatchingNode(this.typeCheckBlock, {
  12705. withSpan: expression.nameSpan,
  12706. filter: ts45.isPropertyAccessExpression
  12707. });
  12708. if (methodAccess === null) {
  12709. return null;
  12710. }
  12711. const pipeVariableNode = methodAccess.expression;
  12712. const pipeDeclaration = this.getTypeChecker().getSymbolAtLocation(pipeVariableNode);
  12713. if (pipeDeclaration === void 0 || pipeDeclaration.valueDeclaration === void 0) {
  12714. return null;
  12715. }
  12716. const pipeInstance = this.getSymbolOfTsNode(pipeDeclaration.valueDeclaration);
  12717. if (pipeInstance === null || !isSymbolWithValueDeclaration(pipeInstance.tsSymbol)) {
  12718. return null;
  12719. }
  12720. const symbolInfo = this.getSymbolOfTsNode(methodAccess);
  12721. if (symbolInfo === null) {
  12722. return null;
  12723. }
  12724. return {
  12725. kind: SymbolKind.Pipe,
  12726. ...symbolInfo,
  12727. classSymbol: {
  12728. ...pipeInstance,
  12729. tsSymbol: pipeInstance.tsSymbol
  12730. }
  12731. };
  12732. }
  12733. getSymbolOfTemplateExpression(expression) {
  12734. if (expression instanceof ASTWithSource2) {
  12735. expression = expression.ast;
  12736. }
  12737. const expressionTarget = this.typeCheckData.boundTarget.getExpressionTarget(expression);
  12738. if (expressionTarget !== null) {
  12739. return this.getSymbol(expressionTarget);
  12740. }
  12741. let withSpan = expression.sourceSpan;
  12742. if (expression instanceof PropertyWrite3 || expression instanceof ASTWithName && !(expression instanceof SafePropertyRead4)) {
  12743. withSpan = expression.nameSpan;
  12744. }
  12745. let node = null;
  12746. if (expression instanceof PropertyRead4) {
  12747. node = findFirstMatchingNode(this.typeCheckBlock, {
  12748. withSpan,
  12749. filter: ts45.isPropertyAccessExpression
  12750. });
  12751. }
  12752. if (node === null) {
  12753. node = findFirstMatchingNode(this.typeCheckBlock, { withSpan, filter: anyNodeFilter });
  12754. }
  12755. if (node === null) {
  12756. return null;
  12757. }
  12758. while (ts45.isParenthesizedExpression(node)) {
  12759. node = node.expression;
  12760. }
  12761. if (expression instanceof SafePropertyRead4 && ts45.isConditionalExpression(node)) {
  12762. const whenTrueSymbol = this.getSymbolOfTsNode(node.whenTrue);
  12763. if (whenTrueSymbol === null) {
  12764. return null;
  12765. }
  12766. return {
  12767. ...whenTrueSymbol,
  12768. kind: SymbolKind.Expression,
  12769. tsType: this.getTypeChecker().getTypeAtLocation(node)
  12770. };
  12771. } else {
  12772. const symbolInfo = this.getSymbolOfTsNode(node);
  12773. return symbolInfo === null ? null : { ...symbolInfo, kind: SymbolKind.Expression };
  12774. }
  12775. }
  12776. getSymbolOfTsNode(node) {
  12777. var _a;
  12778. while (ts45.isParenthesizedExpression(node)) {
  12779. node = node.expression;
  12780. }
  12781. let tsSymbol;
  12782. if (ts45.isPropertyAccessExpression(node)) {
  12783. tsSymbol = this.getTypeChecker().getSymbolAtLocation(node.name);
  12784. } else if (ts45.isCallExpression(node)) {
  12785. tsSymbol = this.getTypeChecker().getSymbolAtLocation(node.expression);
  12786. } else {
  12787. tsSymbol = this.getTypeChecker().getSymbolAtLocation(node);
  12788. }
  12789. const positionInFile = this.getTcbPositionForNode(node);
  12790. const type = this.getTypeChecker().getTypeAtLocation(node);
  12791. return {
  12792. tsSymbol: (_a = tsSymbol != null ? tsSymbol : type.symbol) != null ? _a : null,
  12793. tsType: type,
  12794. tcbLocation: {
  12795. tcbPath: this.tcbPath,
  12796. isShimFile: this.tcbIsShim,
  12797. positionInFile
  12798. }
  12799. };
  12800. }
  12801. getTcbPositionForNode(node) {
  12802. if (ts45.isTypeReferenceNode(node)) {
  12803. return this.getTcbPositionForNode(node.typeName);
  12804. } else if (ts45.isQualifiedName(node)) {
  12805. return node.right.getStart();
  12806. } else if (ts45.isPropertyAccessExpression(node)) {
  12807. return node.name.getStart();
  12808. } else if (ts45.isElementAccessExpression(node)) {
  12809. return node.argumentExpression.getStart();
  12810. } else {
  12811. return node.getStart();
  12812. }
  12813. }
  12814. };
  12815. function anyNodeFilter(n2) {
  12816. return true;
  12817. }
  12818. function sourceSpanEqual(a, b) {
  12819. return a.start.offset === b.start.offset && a.end.offset === b.end.offset;
  12820. }
  12821. function unwrapSignalInputWriteTAccessor(expr) {
  12822. if (!ts45.isElementAccessExpression(expr) || !ts45.isPropertyAccessExpression(expr.argumentExpression)) {
  12823. return null;
  12824. }
  12825. if (!ts45.isIdentifier(expr.argumentExpression.name) || expr.argumentExpression.name.text !== R3Identifiers5.InputSignalBrandWriteType.name) {
  12826. return null;
  12827. }
  12828. if (!ts45.isPropertyAccessExpression(expr.expression) && !ts45.isElementAccessExpression(expr.expression) && !ts45.isIdentifier(expr.expression)) {
  12829. throw new Error("Unexpected expression for signal input write type.");
  12830. }
  12831. return {
  12832. fieldExpr: expr.expression,
  12833. typeExpr: expr
  12834. };
  12835. }
  12836. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/typecheck/src/checker.mjs
  12837. var REGISTRY2 = new DomElementSchemaRegistry2();
  12838. var TemplateTypeCheckerImpl = class {
  12839. originalProgram;
  12840. programDriver;
  12841. typeCheckAdapter;
  12842. config;
  12843. refEmitter;
  12844. reflector;
  12845. compilerHost;
  12846. priorBuild;
  12847. metaReader;
  12848. localMetaReader;
  12849. ngModuleIndex;
  12850. componentScopeReader;
  12851. typeCheckScopeRegistry;
  12852. perf;
  12853. state = /* @__PURE__ */ new Map();
  12854. completionCache = /* @__PURE__ */ new Map();
  12855. symbolBuilderCache = /* @__PURE__ */ new Map();
  12856. scopeCache = /* @__PURE__ */ new Map();
  12857. elementTagCache = /* @__PURE__ */ new Map();
  12858. isComplete = false;
  12859. constructor(originalProgram, programDriver, typeCheckAdapter, config, refEmitter, reflector, compilerHost, priorBuild, metaReader, localMetaReader, ngModuleIndex, componentScopeReader, typeCheckScopeRegistry, perf) {
  12860. this.originalProgram = originalProgram;
  12861. this.programDriver = programDriver;
  12862. this.typeCheckAdapter = typeCheckAdapter;
  12863. this.config = config;
  12864. this.refEmitter = refEmitter;
  12865. this.reflector = reflector;
  12866. this.compilerHost = compilerHost;
  12867. this.priorBuild = priorBuild;
  12868. this.metaReader = metaReader;
  12869. this.localMetaReader = localMetaReader;
  12870. this.ngModuleIndex = ngModuleIndex;
  12871. this.componentScopeReader = componentScopeReader;
  12872. this.typeCheckScopeRegistry = typeCheckScopeRegistry;
  12873. this.perf = perf;
  12874. }
  12875. getTemplate(component, optimizeFor) {
  12876. const { data } = this.getLatestComponentState(component, optimizeFor);
  12877. if (data === null) {
  12878. return null;
  12879. }
  12880. return data.template;
  12881. }
  12882. getUsedDirectives(component) {
  12883. var _a;
  12884. return ((_a = this.getLatestComponentState(component).data) == null ? void 0 : _a.boundTarget.getUsedDirectives()) || null;
  12885. }
  12886. getUsedPipes(component) {
  12887. var _a;
  12888. return ((_a = this.getLatestComponentState(component).data) == null ? void 0 : _a.boundTarget.getUsedPipes()) || null;
  12889. }
  12890. getLatestComponentState(component, optimizeFor = OptimizeFor.SingleFile) {
  12891. switch (optimizeFor) {
  12892. case OptimizeFor.WholeProgram:
  12893. this.ensureAllShimsForAllFiles();
  12894. break;
  12895. case OptimizeFor.SingleFile:
  12896. this.ensureShimForComponent(component);
  12897. break;
  12898. }
  12899. const sf = component.getSourceFile();
  12900. const sfPath = absoluteFromSourceFile(sf);
  12901. const shimPath = TypeCheckShimGenerator.shimFor(sfPath);
  12902. const fileRecord = this.getFileData(sfPath);
  12903. if (!fileRecord.shimData.has(shimPath)) {
  12904. return { data: null, tcb: null, tcbPath: shimPath, tcbIsShim: true };
  12905. }
  12906. const id = fileRecord.sourceManager.getTypeCheckId(component);
  12907. const shimRecord = fileRecord.shimData.get(shimPath);
  12908. const program = this.programDriver.getProgram();
  12909. const shimSf = getSourceFileOrNull(program, shimPath);
  12910. if (shimSf === null || !fileRecord.shimData.has(shimPath)) {
  12911. throw new Error(`Error: no shim file in program: ${shimPath}`);
  12912. }
  12913. let tcb = findTypeCheckBlock(shimSf, id, false);
  12914. let tcbPath = shimPath;
  12915. if (tcb === null) {
  12916. const inlineSf = getSourceFileOrError(program, sfPath);
  12917. tcb = findTypeCheckBlock(inlineSf, id, false);
  12918. if (tcb !== null) {
  12919. tcbPath = sfPath;
  12920. }
  12921. }
  12922. let data = null;
  12923. if (shimRecord.data.has(id)) {
  12924. data = shimRecord.data.get(id);
  12925. }
  12926. return { data, tcb, tcbPath, tcbIsShim: tcbPath === shimPath };
  12927. }
  12928. isTrackedTypeCheckFile(filePath) {
  12929. return this.getFileAndShimRecordsForPath(filePath) !== null;
  12930. }
  12931. getFileRecordForTcbLocation({ tcbPath, isShimFile }) {
  12932. if (!isShimFile) {
  12933. if (this.state.has(tcbPath)) {
  12934. return this.state.get(tcbPath);
  12935. } else {
  12936. return null;
  12937. }
  12938. }
  12939. const records = this.getFileAndShimRecordsForPath(tcbPath);
  12940. if (records !== null) {
  12941. return records.fileRecord;
  12942. } else {
  12943. return null;
  12944. }
  12945. }
  12946. getFileAndShimRecordsForPath(shimPath) {
  12947. for (const fileRecord of this.state.values()) {
  12948. if (fileRecord.shimData.has(shimPath)) {
  12949. return { fileRecord, shimRecord: fileRecord.shimData.get(shimPath) };
  12950. }
  12951. }
  12952. return null;
  12953. }
  12954. getSourceMappingAtTcbLocation(tcbLocation) {
  12955. const fileRecord = this.getFileRecordForTcbLocation(tcbLocation);
  12956. if (fileRecord === null) {
  12957. return null;
  12958. }
  12959. const shimSf = this.programDriver.getProgram().getSourceFile(tcbLocation.tcbPath);
  12960. if (shimSf === void 0) {
  12961. return null;
  12962. }
  12963. return getSourceMapping(
  12964. shimSf,
  12965. tcbLocation.positionInFile,
  12966. fileRecord.sourceManager,
  12967. false
  12968. );
  12969. }
  12970. generateAllTypeCheckBlocks() {
  12971. this.ensureAllShimsForAllFiles();
  12972. }
  12973. getDiagnosticsForFile(sf, optimizeFor) {
  12974. switch (optimizeFor) {
  12975. case OptimizeFor.WholeProgram:
  12976. this.ensureAllShimsForAllFiles();
  12977. break;
  12978. case OptimizeFor.SingleFile:
  12979. this.ensureAllShimsForOneFile(sf);
  12980. break;
  12981. }
  12982. return this.perf.inPhase(PerfPhase.TtcDiagnostics, () => {
  12983. const sfPath = absoluteFromSourceFile(sf);
  12984. const fileRecord = this.state.get(sfPath);
  12985. const typeCheckProgram = this.programDriver.getProgram();
  12986. const diagnostics = [];
  12987. if (fileRecord.hasInlines) {
  12988. const inlineSf = getSourceFileOrError(typeCheckProgram, sfPath);
  12989. diagnostics.push(...typeCheckProgram.getSemanticDiagnostics(inlineSf).map((diag) => convertDiagnostic(diag, fileRecord.sourceManager)));
  12990. }
  12991. for (const [shimPath, shimRecord] of fileRecord.shimData) {
  12992. const shimSf = getSourceFileOrError(typeCheckProgram, shimPath);
  12993. diagnostics.push(...typeCheckProgram.getSemanticDiagnostics(shimSf).map((diag) => convertDiagnostic(diag, fileRecord.sourceManager)));
  12994. diagnostics.push(...shimRecord.genesisDiagnostics);
  12995. for (const templateData of shimRecord.data.values()) {
  12996. diagnostics.push(...templateData.templateParsingDiagnostics);
  12997. }
  12998. }
  12999. return diagnostics.filter((diag) => diag !== null);
  13000. });
  13001. }
  13002. getDiagnosticsForComponent(component) {
  13003. this.ensureShimForComponent(component);
  13004. return this.perf.inPhase(PerfPhase.TtcDiagnostics, () => {
  13005. const sf = component.getSourceFile();
  13006. const sfPath = absoluteFromSourceFile(sf);
  13007. const shimPath = TypeCheckShimGenerator.shimFor(sfPath);
  13008. const fileRecord = this.getFileData(sfPath);
  13009. if (!fileRecord.shimData.has(shimPath)) {
  13010. return [];
  13011. }
  13012. const id = fileRecord.sourceManager.getTypeCheckId(component);
  13013. const shimRecord = fileRecord.shimData.get(shimPath);
  13014. const typeCheckProgram = this.programDriver.getProgram();
  13015. const diagnostics = [];
  13016. if (shimRecord.hasInlines) {
  13017. const inlineSf = getSourceFileOrError(typeCheckProgram, sfPath);
  13018. diagnostics.push(...typeCheckProgram.getSemanticDiagnostics(inlineSf).map((diag) => convertDiagnostic(diag, fileRecord.sourceManager)));
  13019. }
  13020. const shimSf = getSourceFileOrError(typeCheckProgram, shimPath);
  13021. diagnostics.push(...typeCheckProgram.getSemanticDiagnostics(shimSf).map((diag) => convertDiagnostic(diag, fileRecord.sourceManager)));
  13022. diagnostics.push(...shimRecord.genesisDiagnostics);
  13023. for (const templateData of shimRecord.data.values()) {
  13024. diagnostics.push(...templateData.templateParsingDiagnostics);
  13025. }
  13026. return diagnostics.filter((diag) => diag !== null && diag.typeCheckId === id);
  13027. });
  13028. }
  13029. getTypeCheckBlock(component) {
  13030. return this.getLatestComponentState(component).tcb;
  13031. }
  13032. getGlobalCompletions(context, component, node) {
  13033. const engine = this.getOrCreateCompletionEngine(component);
  13034. if (engine === null) {
  13035. return null;
  13036. }
  13037. return this.perf.inPhase(PerfPhase.TtcAutocompletion, () => engine.getGlobalCompletions(context, node));
  13038. }
  13039. getExpressionCompletionLocation(ast, component) {
  13040. const engine = this.getOrCreateCompletionEngine(component);
  13041. if (engine === null) {
  13042. return null;
  13043. }
  13044. return this.perf.inPhase(PerfPhase.TtcAutocompletion, () => engine.getExpressionCompletionLocation(ast));
  13045. }
  13046. getLiteralCompletionLocation(node, component) {
  13047. const engine = this.getOrCreateCompletionEngine(component);
  13048. if (engine === null) {
  13049. return null;
  13050. }
  13051. return this.perf.inPhase(PerfPhase.TtcAutocompletion, () => engine.getLiteralCompletionLocation(node));
  13052. }
  13053. invalidateClass(clazz) {
  13054. this.completionCache.delete(clazz);
  13055. this.symbolBuilderCache.delete(clazz);
  13056. this.scopeCache.delete(clazz);
  13057. this.elementTagCache.delete(clazz);
  13058. const sf = clazz.getSourceFile();
  13059. const sfPath = absoluteFromSourceFile(sf);
  13060. const shimPath = TypeCheckShimGenerator.shimFor(sfPath);
  13061. const fileData = this.getFileData(sfPath);
  13062. const id = fileData.sourceManager.getTypeCheckId(clazz);
  13063. fileData.shimData.delete(shimPath);
  13064. fileData.isComplete = false;
  13065. this.isComplete = false;
  13066. }
  13067. getExpressionTarget(expression, clazz) {
  13068. var _a;
  13069. return ((_a = this.getLatestComponentState(clazz).data) == null ? void 0 : _a.boundTarget.getExpressionTarget(expression)) || null;
  13070. }
  13071. makeTemplateDiagnostic(clazz, sourceSpan, category, errorCode, message, relatedInformation) {
  13072. const sfPath = absoluteFromSourceFile(clazz.getSourceFile());
  13073. const fileRecord = this.state.get(sfPath);
  13074. const id = fileRecord.sourceManager.getTypeCheckId(clazz);
  13075. const mapping = fileRecord.sourceManager.getTemplateSourceMapping(id);
  13076. return {
  13077. ...makeTemplateDiagnostic(id, mapping, sourceSpan, category, ngErrorCode(errorCode), message, relatedInformation),
  13078. __ngCode: errorCode
  13079. };
  13080. }
  13081. getOrCreateCompletionEngine(component) {
  13082. if (this.completionCache.has(component)) {
  13083. return this.completionCache.get(component);
  13084. }
  13085. const { tcb, data, tcbPath, tcbIsShim } = this.getLatestComponentState(component);
  13086. if (tcb === null || data === null) {
  13087. return null;
  13088. }
  13089. const engine = new CompletionEngine(tcb, data, tcbPath, tcbIsShim);
  13090. this.completionCache.set(component, engine);
  13091. return engine;
  13092. }
  13093. maybeAdoptPriorResultsForFile(sf) {
  13094. const sfPath = absoluteFromSourceFile(sf);
  13095. if (this.state.has(sfPath)) {
  13096. const existingResults = this.state.get(sfPath);
  13097. if (existingResults.isComplete) {
  13098. return;
  13099. }
  13100. }
  13101. const previousResults = this.priorBuild.priorTypeCheckingResultsFor(sf);
  13102. if (previousResults === null || !previousResults.isComplete) {
  13103. return;
  13104. }
  13105. this.perf.eventCount(PerfEvent.ReuseTypeCheckFile);
  13106. this.state.set(sfPath, previousResults);
  13107. }
  13108. ensureAllShimsForAllFiles() {
  13109. if (this.isComplete) {
  13110. return;
  13111. }
  13112. this.perf.inPhase(PerfPhase.TcbGeneration, () => {
  13113. const host = new WholeProgramTypeCheckingHost(this);
  13114. const ctx = this.newContext(host);
  13115. for (const sf of this.originalProgram.getSourceFiles()) {
  13116. if (sf.isDeclarationFile || isShim(sf)) {
  13117. continue;
  13118. }
  13119. this.maybeAdoptPriorResultsForFile(sf);
  13120. const sfPath = absoluteFromSourceFile(sf);
  13121. const fileData = this.getFileData(sfPath);
  13122. if (fileData.isComplete) {
  13123. continue;
  13124. }
  13125. this.typeCheckAdapter.typeCheck(sf, ctx);
  13126. fileData.isComplete = true;
  13127. }
  13128. this.updateFromContext(ctx);
  13129. this.isComplete = true;
  13130. });
  13131. }
  13132. ensureAllShimsForOneFile(sf) {
  13133. this.perf.inPhase(PerfPhase.TcbGeneration, () => {
  13134. this.maybeAdoptPriorResultsForFile(sf);
  13135. const sfPath = absoluteFromSourceFile(sf);
  13136. const fileData = this.getFileData(sfPath);
  13137. if (fileData.isComplete) {
  13138. return;
  13139. }
  13140. const host = new SingleFileTypeCheckingHost(sfPath, fileData, this);
  13141. const ctx = this.newContext(host);
  13142. this.typeCheckAdapter.typeCheck(sf, ctx);
  13143. fileData.isComplete = true;
  13144. this.updateFromContext(ctx);
  13145. });
  13146. }
  13147. ensureShimForComponent(component) {
  13148. const sf = component.getSourceFile();
  13149. const sfPath = absoluteFromSourceFile(sf);
  13150. const shimPath = TypeCheckShimGenerator.shimFor(sfPath);
  13151. this.maybeAdoptPriorResultsForFile(sf);
  13152. const fileData = this.getFileData(sfPath);
  13153. if (fileData.shimData.has(shimPath)) {
  13154. return;
  13155. }
  13156. const host = new SingleShimTypeCheckingHost(sfPath, fileData, this, shimPath);
  13157. const ctx = this.newContext(host);
  13158. this.typeCheckAdapter.typeCheck(sf, ctx);
  13159. this.updateFromContext(ctx);
  13160. }
  13161. newContext(host) {
  13162. const inlining = this.programDriver.supportsInlineOperations ? InliningMode.InlineOps : InliningMode.Error;
  13163. return new TypeCheckContextImpl(this.config, this.compilerHost, this.refEmitter, this.reflector, host, inlining, this.perf);
  13164. }
  13165. clearAllShimDataUsingInlines() {
  13166. for (const fileData of this.state.values()) {
  13167. if (!fileData.hasInlines) {
  13168. continue;
  13169. }
  13170. for (const [shimFile, shimData] of fileData.shimData.entries()) {
  13171. if (shimData.hasInlines) {
  13172. fileData.shimData.delete(shimFile);
  13173. }
  13174. }
  13175. fileData.hasInlines = false;
  13176. fileData.isComplete = false;
  13177. this.isComplete = false;
  13178. }
  13179. }
  13180. updateFromContext(ctx) {
  13181. const updates = ctx.finalize();
  13182. return this.perf.inPhase(PerfPhase.TcbUpdateProgram, () => {
  13183. if (updates.size > 0) {
  13184. this.perf.eventCount(PerfEvent.UpdateTypeCheckProgram);
  13185. }
  13186. this.programDriver.updateFiles(updates, UpdateMode.Incremental);
  13187. this.priorBuild.recordSuccessfulTypeCheck(this.state);
  13188. this.perf.memory(PerfCheckpoint.TtcUpdateProgram);
  13189. });
  13190. }
  13191. getFileData(path) {
  13192. if (!this.state.has(path)) {
  13193. this.state.set(path, {
  13194. hasInlines: false,
  13195. sourceManager: new DirectiveSourceManager(),
  13196. isComplete: false,
  13197. shimData: /* @__PURE__ */ new Map()
  13198. });
  13199. }
  13200. return this.state.get(path);
  13201. }
  13202. getSymbolOfNode(node, component) {
  13203. const builder = this.getOrCreateSymbolBuilder(component);
  13204. if (builder === null) {
  13205. return null;
  13206. }
  13207. return this.perf.inPhase(PerfPhase.TtcSymbol, () => builder.getSymbol(node));
  13208. }
  13209. getOrCreateSymbolBuilder(component) {
  13210. if (this.symbolBuilderCache.has(component)) {
  13211. return this.symbolBuilderCache.get(component);
  13212. }
  13213. const { tcb, data, tcbPath, tcbIsShim } = this.getLatestComponentState(component);
  13214. if (tcb === null || data === null) {
  13215. return null;
  13216. }
  13217. const builder = new SymbolBuilder(tcbPath, tcbIsShim, tcb, data, this.componentScopeReader, () => this.programDriver.getProgram().getTypeChecker());
  13218. this.symbolBuilderCache.set(component, builder);
  13219. return builder;
  13220. }
  13221. getPotentialTemplateDirectives(component) {
  13222. var _a, _b;
  13223. const typeChecker = this.programDriver.getProgram().getTypeChecker();
  13224. const inScopeDirectives = (_b = (_a = this.getScopeData(component)) == null ? void 0 : _a.directives) != null ? _b : [];
  13225. const resultingDirectives = /* @__PURE__ */ new Map();
  13226. for (const d of inScopeDirectives) {
  13227. resultingDirectives.set(d.ref.node, d);
  13228. }
  13229. for (const directiveClass of this.localMetaReader.getKnown(MetaKind.Directive)) {
  13230. const directiveMeta = this.metaReader.getDirectiveMetadata(new Reference(directiveClass));
  13231. if (directiveMeta === null)
  13232. continue;
  13233. if (resultingDirectives.has(directiveClass))
  13234. continue;
  13235. const withScope = this.scopeDataOfDirectiveMeta(typeChecker, directiveMeta);
  13236. if (withScope === null)
  13237. continue;
  13238. resultingDirectives.set(directiveClass, { ...withScope, isInScope: false });
  13239. }
  13240. return Array.from(resultingDirectives.values());
  13241. }
  13242. getPotentialPipes(component) {
  13243. var _a, _b;
  13244. const typeChecker = this.programDriver.getProgram().getTypeChecker();
  13245. const inScopePipes = (_b = (_a = this.getScopeData(component)) == null ? void 0 : _a.pipes) != null ? _b : [];
  13246. const resultingPipes = /* @__PURE__ */ new Map();
  13247. for (const p of inScopePipes) {
  13248. resultingPipes.set(p.ref.node, p);
  13249. }
  13250. for (const pipeClass of this.localMetaReader.getKnown(MetaKind.Pipe)) {
  13251. const pipeMeta = this.metaReader.getPipeMetadata(new Reference(pipeClass));
  13252. if (pipeMeta === null)
  13253. continue;
  13254. if (resultingPipes.has(pipeClass))
  13255. continue;
  13256. const withScope = this.scopeDataOfPipeMeta(typeChecker, pipeMeta);
  13257. if (withScope === null)
  13258. continue;
  13259. resultingPipes.set(pipeClass, { ...withScope, isInScope: false });
  13260. }
  13261. return Array.from(resultingPipes.values());
  13262. }
  13263. getDirectiveMetadata(dir) {
  13264. if (!isNamedClassDeclaration(dir)) {
  13265. return null;
  13266. }
  13267. return this.typeCheckScopeRegistry.getTypeCheckDirectiveMetadata(new Reference(dir));
  13268. }
  13269. getNgModuleMetadata(module) {
  13270. if (!isNamedClassDeclaration(module)) {
  13271. return null;
  13272. }
  13273. return this.metaReader.getNgModuleMetadata(new Reference(module));
  13274. }
  13275. getPipeMetadata(pipe) {
  13276. if (!isNamedClassDeclaration(pipe)) {
  13277. return null;
  13278. }
  13279. return this.metaReader.getPipeMetadata(new Reference(pipe));
  13280. }
  13281. getPotentialElementTags(component) {
  13282. if (this.elementTagCache.has(component)) {
  13283. return this.elementTagCache.get(component);
  13284. }
  13285. const tagMap = /* @__PURE__ */ new Map();
  13286. for (const tag of REGISTRY2.allKnownElementNames()) {
  13287. tagMap.set(tag, null);
  13288. }
  13289. const potentialDirectives = this.getPotentialTemplateDirectives(component);
  13290. for (const directive of potentialDirectives) {
  13291. if (directive.selector === null) {
  13292. continue;
  13293. }
  13294. for (const selector of CssSelector3.parse(directive.selector)) {
  13295. if (selector.element === null || tagMap.has(selector.element)) {
  13296. continue;
  13297. }
  13298. tagMap.set(selector.element, directive);
  13299. }
  13300. }
  13301. this.elementTagCache.set(component, tagMap);
  13302. return tagMap;
  13303. }
  13304. getPotentialDomBindings(tagName) {
  13305. const attributes = REGISTRY2.allKnownAttributesOfElement(tagName);
  13306. return attributes.map((attribute) => ({
  13307. attribute,
  13308. property: REGISTRY2.getMappedPropName(attribute)
  13309. }));
  13310. }
  13311. getPotentialDomEvents(tagName) {
  13312. return REGISTRY2.allKnownEventsOfElement(tagName);
  13313. }
  13314. getPrimaryAngularDecorator(target) {
  13315. this.ensureAllShimsForOneFile(target.getSourceFile());
  13316. if (!isNamedClassDeclaration(target)) {
  13317. return null;
  13318. }
  13319. const ref = new Reference(target);
  13320. const dirMeta = this.metaReader.getDirectiveMetadata(ref);
  13321. if (dirMeta !== null) {
  13322. return dirMeta.decorator;
  13323. }
  13324. const pipeMeta = this.metaReader.getPipeMetadata(ref);
  13325. if (pipeMeta !== null) {
  13326. return pipeMeta.decorator;
  13327. }
  13328. const ngModuleMeta = this.metaReader.getNgModuleMetadata(ref);
  13329. if (ngModuleMeta !== null) {
  13330. return ngModuleMeta.decorator;
  13331. }
  13332. return null;
  13333. }
  13334. getOwningNgModule(component) {
  13335. if (!isNamedClassDeclaration(component)) {
  13336. return null;
  13337. }
  13338. const dirMeta = this.metaReader.getDirectiveMetadata(new Reference(component));
  13339. if (dirMeta !== null && dirMeta.isStandalone) {
  13340. return null;
  13341. }
  13342. const scope = this.componentScopeReader.getScopeForComponent(component);
  13343. if (scope === null || scope.kind !== ComponentScopeKind.NgModule || !isNamedClassDeclaration(scope.ngModule)) {
  13344. return null;
  13345. }
  13346. return scope.ngModule;
  13347. }
  13348. emit(kind, refTo, inContext) {
  13349. var _a, _b;
  13350. const emittedRef = this.refEmitter.emit(refTo, inContext.getSourceFile());
  13351. if (emittedRef.kind === ReferenceEmitKind.Failed) {
  13352. return null;
  13353. }
  13354. const emitted = emittedRef.expression;
  13355. if (emitted instanceof WrappedNodeExpr9) {
  13356. if (refTo.node === inContext) {
  13357. return null;
  13358. }
  13359. let isForwardReference = false;
  13360. if (emitted.node.getStart() > inContext.getStart()) {
  13361. const declaration = (_b = (_a = this.programDriver.getProgram().getTypeChecker().getTypeAtLocation(emitted.node).getSymbol()) == null ? void 0 : _a.declarations) == null ? void 0 : _b[0];
  13362. if (declaration && declaration.getSourceFile() === inContext.getSourceFile()) {
  13363. isForwardReference = true;
  13364. }
  13365. }
  13366. return { kind, symbolName: emitted.node.text, isForwardReference };
  13367. } else if (emitted instanceof ExternalExpr7 && emitted.value.moduleName !== null && emitted.value.name !== null) {
  13368. return {
  13369. kind,
  13370. moduleSpecifier: emitted.value.moduleName,
  13371. symbolName: emitted.value.name,
  13372. isForwardReference: false
  13373. };
  13374. }
  13375. return null;
  13376. }
  13377. getPotentialImportsFor(toImport, inContext, importMode) {
  13378. var _a;
  13379. const imports = [];
  13380. const meta = (_a = this.metaReader.getDirectiveMetadata(toImport)) != null ? _a : this.metaReader.getPipeMetadata(toImport);
  13381. if (meta === null) {
  13382. return imports;
  13383. }
  13384. if (meta.isStandalone || importMode === PotentialImportMode.ForceDirect) {
  13385. const emitted = this.emit(PotentialImportKind.Standalone, toImport, inContext);
  13386. if (emitted !== null) {
  13387. imports.push(emitted);
  13388. }
  13389. }
  13390. const exportingNgModules = this.ngModuleIndex.getNgModulesExporting(meta.ref.node);
  13391. if (exportingNgModules !== null) {
  13392. for (const exporter of exportingNgModules) {
  13393. const emittedRef = this.emit(PotentialImportKind.NgModule, exporter, inContext);
  13394. if (emittedRef !== null) {
  13395. imports.push(emittedRef);
  13396. }
  13397. }
  13398. }
  13399. return imports;
  13400. }
  13401. getScopeData(component) {
  13402. if (this.scopeCache.has(component)) {
  13403. return this.scopeCache.get(component);
  13404. }
  13405. if (!isNamedClassDeclaration(component)) {
  13406. throw new Error(`AssertionError: components must have names`);
  13407. }
  13408. const scope = this.componentScopeReader.getScopeForComponent(component);
  13409. if (scope === null) {
  13410. return null;
  13411. }
  13412. const dependencies = scope.kind === ComponentScopeKind.NgModule ? scope.compilation.dependencies : scope.dependencies;
  13413. const data = {
  13414. directives: [],
  13415. pipes: [],
  13416. isPoisoned: scope.kind === ComponentScopeKind.NgModule ? scope.compilation.isPoisoned : scope.isPoisoned
  13417. };
  13418. const typeChecker = this.programDriver.getProgram().getTypeChecker();
  13419. for (const dep of dependencies) {
  13420. if (dep.kind === MetaKind.Directive) {
  13421. const dirScope = this.scopeDataOfDirectiveMeta(typeChecker, dep);
  13422. if (dirScope === null)
  13423. continue;
  13424. data.directives.push({ ...dirScope, isInScope: true });
  13425. } else if (dep.kind === MetaKind.Pipe) {
  13426. const pipeScope = this.scopeDataOfPipeMeta(typeChecker, dep);
  13427. if (pipeScope === null)
  13428. continue;
  13429. data.pipes.push({ ...pipeScope, isInScope: true });
  13430. }
  13431. }
  13432. this.scopeCache.set(component, data);
  13433. return data;
  13434. }
  13435. scopeDataOfDirectiveMeta(typeChecker, dep) {
  13436. if (dep.selector === null) {
  13437. return null;
  13438. }
  13439. const tsSymbol = typeChecker.getSymbolAtLocation(dep.ref.node.name);
  13440. if (!isSymbolWithValueDeclaration(tsSymbol)) {
  13441. return null;
  13442. }
  13443. let ngModule = null;
  13444. const moduleScopeOfDir = this.componentScopeReader.getScopeForComponent(dep.ref.node);
  13445. if (moduleScopeOfDir !== null && moduleScopeOfDir.kind === ComponentScopeKind.NgModule) {
  13446. ngModule = moduleScopeOfDir.ngModule;
  13447. }
  13448. return {
  13449. ref: dep.ref,
  13450. isComponent: dep.isComponent,
  13451. isStructural: dep.isStructural,
  13452. selector: dep.selector,
  13453. tsSymbol,
  13454. ngModule
  13455. };
  13456. }
  13457. scopeDataOfPipeMeta(typeChecker, dep) {
  13458. const tsSymbol = typeChecker.getSymbolAtLocation(dep.ref.node.name);
  13459. if (tsSymbol === void 0) {
  13460. return null;
  13461. }
  13462. return {
  13463. ref: dep.ref,
  13464. name: dep.name,
  13465. tsSymbol
  13466. };
  13467. }
  13468. };
  13469. function convertDiagnostic(diag, sourceResolver) {
  13470. if (!shouldReportDiagnostic(diag)) {
  13471. return null;
  13472. }
  13473. return translateDiagnostic(diag, sourceResolver);
  13474. }
  13475. var WholeProgramTypeCheckingHost = class {
  13476. impl;
  13477. constructor(impl) {
  13478. this.impl = impl;
  13479. }
  13480. getSourceManager(sfPath) {
  13481. return this.impl.getFileData(sfPath).sourceManager;
  13482. }
  13483. shouldCheckClass(node) {
  13484. const sfPath = absoluteFromSourceFile(node.getSourceFile());
  13485. const shimPath = TypeCheckShimGenerator.shimFor(sfPath);
  13486. const fileData = this.impl.getFileData(sfPath);
  13487. return !fileData.shimData.has(shimPath);
  13488. }
  13489. recordShimData(sfPath, data) {
  13490. const fileData = this.impl.getFileData(sfPath);
  13491. fileData.shimData.set(data.path, data);
  13492. if (data.hasInlines) {
  13493. fileData.hasInlines = true;
  13494. }
  13495. }
  13496. recordComplete(sfPath) {
  13497. this.impl.getFileData(sfPath).isComplete = true;
  13498. }
  13499. };
  13500. var SingleFileTypeCheckingHost = class {
  13501. sfPath;
  13502. fileData;
  13503. impl;
  13504. seenInlines = false;
  13505. constructor(sfPath, fileData, impl) {
  13506. this.sfPath = sfPath;
  13507. this.fileData = fileData;
  13508. this.impl = impl;
  13509. }
  13510. assertPath(sfPath) {
  13511. if (this.sfPath !== sfPath) {
  13512. throw new Error(`AssertionError: querying TypeCheckingHost outside of assigned file`);
  13513. }
  13514. }
  13515. getSourceManager(sfPath) {
  13516. this.assertPath(sfPath);
  13517. return this.fileData.sourceManager;
  13518. }
  13519. shouldCheckClass(node) {
  13520. if (this.sfPath !== absoluteFromSourceFile(node.getSourceFile())) {
  13521. return false;
  13522. }
  13523. const shimPath = TypeCheckShimGenerator.shimFor(this.sfPath);
  13524. return !this.fileData.shimData.has(shimPath);
  13525. }
  13526. recordShimData(sfPath, data) {
  13527. this.assertPath(sfPath);
  13528. if (data.hasInlines && !this.seenInlines) {
  13529. this.impl.clearAllShimDataUsingInlines();
  13530. this.seenInlines = true;
  13531. }
  13532. this.fileData.shimData.set(data.path, data);
  13533. if (data.hasInlines) {
  13534. this.fileData.hasInlines = true;
  13535. }
  13536. }
  13537. recordComplete(sfPath) {
  13538. this.assertPath(sfPath);
  13539. this.fileData.isComplete = true;
  13540. }
  13541. };
  13542. var SingleShimTypeCheckingHost = class extends SingleFileTypeCheckingHost {
  13543. shimPath;
  13544. constructor(sfPath, fileData, impl, shimPath) {
  13545. super(sfPath, fileData, impl);
  13546. this.shimPath = shimPath;
  13547. }
  13548. shouldCheckNode(node) {
  13549. if (this.sfPath !== absoluteFromSourceFile(node.getSourceFile())) {
  13550. return false;
  13551. }
  13552. const shimPath = TypeCheckShimGenerator.shimFor(this.sfPath);
  13553. if (shimPath !== this.shimPath) {
  13554. return false;
  13555. }
  13556. return !this.fileData.shimData.has(shimPath);
  13557. }
  13558. };
  13559. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/hmr/src/metadata.mjs
  13560. import { outputAst as o3 } from "@angular/compiler";
  13561. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/hmr/src/extract_dependencies.mjs
  13562. import { outputAst as o2 } from "@angular/compiler";
  13563. import ts46 from "typescript";
  13564. function extractHmrDependencies(node, definition, factory, deferBlockMetadata, classMetadata, debugInfo, reflection, evaluator) {
  13565. var _a, _b;
  13566. const name = ts46.isClassDeclaration(node) && node.name ? node.name.text : null;
  13567. const visitor = new PotentialTopLevelReadsVisitor();
  13568. const sourceFile = ts46.getOriginalNode(node).getSourceFile();
  13569. definition.expression.visitExpression(visitor, null);
  13570. definition.statements.forEach((statement) => statement.visitStatement(visitor, null));
  13571. (_a = factory.initializer) == null ? void 0 : _a.visitExpression(visitor, null);
  13572. factory.statements.forEach((statement) => statement.visitStatement(visitor, null));
  13573. classMetadata == null ? void 0 : classMetadata.visitStatement(visitor, null);
  13574. debugInfo == null ? void 0 : debugInfo.visitStatement(visitor, null);
  13575. if (deferBlockMetadata.mode === 0) {
  13576. deferBlockMetadata.blocks.forEach((loader) => loader == null ? void 0 : loader.visitExpression(visitor, null));
  13577. } else {
  13578. (_b = deferBlockMetadata.dependenciesFn) == null ? void 0 : _b.visitExpression(visitor, null);
  13579. }
  13580. const availableTopLevel = getTopLevelDeclarationNames(sourceFile);
  13581. const local = [];
  13582. const seenLocals = /* @__PURE__ */ new Set();
  13583. for (const readNode of visitor.allReads) {
  13584. const readName = readNode instanceof o2.ReadVarExpr ? readNode.name : readNode.text;
  13585. if (readName !== name && !seenLocals.has(readName) && availableTopLevel.has(readName)) {
  13586. const runtimeRepresentation = getRuntimeRepresentation(readNode, reflection, evaluator);
  13587. if (runtimeRepresentation === null) {
  13588. return null;
  13589. }
  13590. local.push({ name: readName, runtimeRepresentation });
  13591. seenLocals.add(readName);
  13592. }
  13593. }
  13594. return {
  13595. local,
  13596. external: Array.from(visitor.namespaceReads, (name2, index) => ({
  13597. moduleName: name2,
  13598. assignedName: `\u0275hmr${index}`
  13599. }))
  13600. };
  13601. }
  13602. function getRuntimeRepresentation(node, reflection, evaluator) {
  13603. if (node instanceof o2.ReadVarExpr) {
  13604. return o2.variable(node.name);
  13605. }
  13606. if (isConstEnumReference(node, reflection)) {
  13607. const evaluated = evaluator.evaluate(node);
  13608. if (evaluated instanceof Map) {
  13609. const members = [];
  13610. for (const [name, value] of evaluated.entries()) {
  13611. if (value instanceof EnumValue && (value.resolved == null || typeof value.resolved === "string" || typeof value.resolved === "boolean" || typeof value.resolved === "number")) {
  13612. members.push({
  13613. key: name,
  13614. quoted: false,
  13615. value: o2.literal(value.resolved)
  13616. });
  13617. } else {
  13618. return null;
  13619. }
  13620. }
  13621. return o2.literalMap(members);
  13622. }
  13623. }
  13624. return o2.variable(node.text);
  13625. }
  13626. function getTopLevelDeclarationNames(sourceFile) {
  13627. const results = /* @__PURE__ */ new Set();
  13628. for (const node of sourceFile.statements) {
  13629. if (ts46.isClassDeclaration(node) || ts46.isFunctionDeclaration(node) || ts46.isEnumDeclaration(node)) {
  13630. if (node.name) {
  13631. results.add(node.name.text);
  13632. }
  13633. continue;
  13634. }
  13635. if (ts46.isVariableStatement(node)) {
  13636. for (const decl of node.declarationList.declarations) {
  13637. trackBindingName(decl.name, results);
  13638. }
  13639. continue;
  13640. }
  13641. if (ts46.isImportDeclaration(node) && node.importClause) {
  13642. const importClause = node.importClause;
  13643. if (importClause.isTypeOnly) {
  13644. continue;
  13645. }
  13646. if (importClause.name) {
  13647. results.add(importClause.name.text);
  13648. }
  13649. if (importClause.namedBindings) {
  13650. const namedBindings = importClause.namedBindings;
  13651. if (ts46.isNamespaceImport(namedBindings)) {
  13652. results.add(namedBindings.name.text);
  13653. } else {
  13654. namedBindings.elements.forEach((el) => {
  13655. if (!el.isTypeOnly) {
  13656. results.add(el.name.text);
  13657. }
  13658. });
  13659. }
  13660. }
  13661. continue;
  13662. }
  13663. }
  13664. return results;
  13665. }
  13666. function trackBindingName(node, results) {
  13667. if (ts46.isIdentifier(node)) {
  13668. results.add(node.text);
  13669. } else {
  13670. for (const el of node.elements) {
  13671. if (!ts46.isOmittedExpression(el)) {
  13672. trackBindingName(el.name, results);
  13673. }
  13674. }
  13675. }
  13676. }
  13677. var PotentialTopLevelReadsVisitor = class extends o2.RecursiveAstVisitor {
  13678. allReads = /* @__PURE__ */ new Set();
  13679. namespaceReads = /* @__PURE__ */ new Set();
  13680. visitExternalExpr(ast, context) {
  13681. if (ast.value.moduleName !== null) {
  13682. this.namespaceReads.add(ast.value.moduleName);
  13683. }
  13684. super.visitExternalExpr(ast, context);
  13685. }
  13686. visitReadVarExpr(ast, context) {
  13687. this.allReads.add(ast);
  13688. super.visitReadVarExpr(ast, context);
  13689. }
  13690. visitWrappedNodeExpr(ast, context) {
  13691. if (this.isTypeScriptNode(ast.node)) {
  13692. this.addAllTopLevelIdentifiers(ast.node);
  13693. }
  13694. super.visitWrappedNodeExpr(ast, context);
  13695. }
  13696. addAllTopLevelIdentifiers = (node) => {
  13697. if (ts46.isIdentifier(node) && this.isTopLevelIdentifierReference(node)) {
  13698. this.allReads.add(node);
  13699. } else {
  13700. ts46.forEachChild(node, this.addAllTopLevelIdentifiers);
  13701. }
  13702. };
  13703. isTopLevelIdentifierReference(identifier) {
  13704. let node = identifier;
  13705. let parent = node.parent;
  13706. if (!parent) {
  13707. return false;
  13708. }
  13709. if (ts46.isParenthesizedExpression(parent) && parent.expression === node) {
  13710. while (parent && ts46.isParenthesizedExpression(parent)) {
  13711. node = parent;
  13712. parent = parent.parent;
  13713. }
  13714. }
  13715. if (ts46.isSourceFile(parent)) {
  13716. return true;
  13717. }
  13718. if (ts46.isCallExpression(parent)) {
  13719. return parent.expression === node || parent.arguments.includes(node);
  13720. }
  13721. if (ts46.isExpressionStatement(parent) || ts46.isPropertyAccessExpression(parent) || ts46.isComputedPropertyName(parent) || ts46.isTemplateSpan(parent) || ts46.isSpreadAssignment(parent) || ts46.isSpreadElement(parent) || ts46.isAwaitExpression(parent) || ts46.isNonNullExpression(parent) || ts46.isIfStatement(parent) || ts46.isDoStatement(parent) || ts46.isWhileStatement(parent) || ts46.isSwitchStatement(parent) || ts46.isCaseClause(parent) || ts46.isThrowStatement(parent) || ts46.isNewExpression(parent)) {
  13722. return parent.expression === node;
  13723. }
  13724. if (ts46.isArrayLiteralExpression(parent)) {
  13725. return parent.elements.includes(node);
  13726. }
  13727. if (ts46.isPropertyAssignment(parent) || ts46.isParameter(parent) || ts46.isBindingElement(parent) || ts46.isPropertyDeclaration(parent) || ts46.isEnumMember(parent)) {
  13728. return parent.initializer === node;
  13729. }
  13730. if (ts46.isVariableDeclaration(parent)) {
  13731. return parent.name === node || parent.initializer === node;
  13732. }
  13733. if (ts46.isClassDeclaration(parent) || ts46.isFunctionDeclaration(parent) || ts46.isShorthandPropertyAssignment(parent)) {
  13734. return parent.name === node;
  13735. }
  13736. if (ts46.isElementAccessExpression(parent)) {
  13737. return parent.expression === node || parent.argumentExpression === node;
  13738. }
  13739. if (ts46.isBinaryExpression(parent)) {
  13740. return parent.left === node || parent.right === node;
  13741. }
  13742. if (ts46.isForInStatement(parent) || ts46.isForOfStatement(parent)) {
  13743. return parent.expression === node || parent.initializer === node;
  13744. }
  13745. if (ts46.isForStatement(parent)) {
  13746. return parent.condition === node || parent.initializer === node || parent.incrementor === node;
  13747. }
  13748. if (ts46.isArrowFunction(parent)) {
  13749. return parent.body === node;
  13750. }
  13751. if (ts46.isImportSpecifier(parent) || ts46.isExportSpecifier(parent)) {
  13752. return (parent.propertyName || parent.name) === node;
  13753. }
  13754. if (ts46.isConditionalExpression(parent)) {
  13755. return parent.condition === node || parent.whenFalse === node || parent.whenTrue === node;
  13756. }
  13757. return false;
  13758. }
  13759. isTypeScriptNode(value) {
  13760. return !!value && typeof value.kind === "number";
  13761. }
  13762. };
  13763. function isConstEnumReference(node, reflection) {
  13764. var _a;
  13765. const parent = node.parent;
  13766. if (!parent || !ts46.isPropertyAccessExpression(parent) || parent.expression !== node || !ts46.isIdentifier(parent.name)) {
  13767. return false;
  13768. }
  13769. const declaration = reflection.getDeclarationOfIdentifier(node);
  13770. return declaration !== null && ts46.isEnumDeclaration(declaration.node) && !!((_a = declaration.node.modifiers) == null ? void 0 : _a.some((m) => m.kind === ts46.SyntaxKind.ConstKeyword));
  13771. }
  13772. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/hmr/src/metadata.mjs
  13773. import ts47 from "typescript";
  13774. function extractHmrMetatadata(clazz, reflection, evaluator, compilerHost, rootDirs, definition, factory, deferBlockMetadata, classMetadata, debugInfo) {
  13775. if (!reflection.isClass(clazz)) {
  13776. return null;
  13777. }
  13778. const sourceFile = ts47.getOriginalNode(clazz).getSourceFile();
  13779. const filePath = getProjectRelativePath(sourceFile.fileName, rootDirs, compilerHost) || compilerHost.getCanonicalFileName(sourceFile.fileName);
  13780. const dependencies = extractHmrDependencies(clazz, definition, factory, deferBlockMetadata, classMetadata, debugInfo, reflection, evaluator);
  13781. if (dependencies === null) {
  13782. return null;
  13783. }
  13784. const meta = {
  13785. type: new o3.WrappedNodeExpr(clazz.name),
  13786. className: clazz.name.text,
  13787. filePath,
  13788. localDependencies: dependencies.local,
  13789. namespaceDependencies: dependencies.external
  13790. };
  13791. return meta;
  13792. }
  13793. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/hmr/src/update_declaration.mjs
  13794. import { compileHmrUpdateCallback } from "@angular/compiler";
  13795. import ts48 from "typescript";
  13796. function getHmrUpdateDeclaration(compilationResults, constantStatements, meta, declaration) {
  13797. const namespaceSpecifiers = meta.namespaceDependencies.reduce((result, current) => {
  13798. result.set(current.moduleName, current.assignedName);
  13799. return result;
  13800. }, /* @__PURE__ */ new Map());
  13801. const importRewriter = new HmrModuleImportRewriter(namespaceSpecifiers);
  13802. const importManager = new ImportManager({
  13803. ...presetImportManagerForceNamespaceImports,
  13804. rewriter: importRewriter
  13805. });
  13806. const callback = compileHmrUpdateCallback(compilationResults, constantStatements, meta);
  13807. const sourceFile = ts48.getOriginalNode(declaration).getSourceFile();
  13808. const node = translateStatement(sourceFile, callback, importManager);
  13809. return ts48.factory.updateFunctionDeclaration(node, [
  13810. ts48.factory.createToken(ts48.SyntaxKind.ExportKeyword),
  13811. ts48.factory.createToken(ts48.SyntaxKind.DefaultKeyword)
  13812. ], node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body);
  13813. }
  13814. var HmrModuleImportRewriter = class {
  13815. lookup;
  13816. constructor(lookup) {
  13817. this.lookup = lookup;
  13818. }
  13819. rewriteNamespaceImportIdentifier(specifier, moduleName) {
  13820. return this.lookup.has(moduleName) ? this.lookup.get(moduleName) : specifier;
  13821. }
  13822. rewriteSymbol(symbol) {
  13823. return symbol;
  13824. }
  13825. rewriteSpecifier(specifier) {
  13826. return specifier;
  13827. }
  13828. };
  13829. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/component/src/handler.mjs
  13830. var EMPTY_ARRAY2 = [];
  13831. var isUsedDirective = (decl) => decl.kind === R3TemplateDependencyKind.Directive;
  13832. var isUsedPipe = (decl) => decl.kind === R3TemplateDependencyKind.Pipe;
  13833. var ComponentDecoratorHandler = class {
  13834. reflector;
  13835. evaluator;
  13836. metaRegistry;
  13837. metaReader;
  13838. scopeReader;
  13839. compilerHost;
  13840. scopeRegistry;
  13841. typeCheckScopeRegistry;
  13842. resourceRegistry;
  13843. isCore;
  13844. strictCtorDeps;
  13845. resourceLoader;
  13846. rootDirs;
  13847. defaultPreserveWhitespaces;
  13848. i18nUseExternalIds;
  13849. enableI18nLegacyMessageIdFormat;
  13850. usePoisonedData;
  13851. i18nNormalizeLineEndingsInICUs;
  13852. moduleResolver;
  13853. cycleAnalyzer;
  13854. cycleHandlingStrategy;
  13855. refEmitter;
  13856. referencesRegistry;
  13857. depTracker;
  13858. injectableRegistry;
  13859. semanticDepGraphUpdater;
  13860. annotateForClosureCompiler;
  13861. perf;
  13862. hostDirectivesResolver;
  13863. importTracker;
  13864. includeClassMetadata;
  13865. compilationMode;
  13866. deferredSymbolTracker;
  13867. forbidOrphanRendering;
  13868. enableBlockSyntax;
  13869. enableLetSyntax;
  13870. externalRuntimeStyles;
  13871. localCompilationExtraImportsTracker;
  13872. jitDeclarationRegistry;
  13873. i18nPreserveSignificantWhitespace;
  13874. strictStandalone;
  13875. enableHmr;
  13876. implicitStandaloneValue;
  13877. constructor(reflector, evaluator, metaRegistry, metaReader, scopeReader, compilerHost, scopeRegistry, typeCheckScopeRegistry, resourceRegistry, isCore, strictCtorDeps, resourceLoader, rootDirs, defaultPreserveWhitespaces, i18nUseExternalIds, enableI18nLegacyMessageIdFormat, usePoisonedData, i18nNormalizeLineEndingsInICUs, moduleResolver, cycleAnalyzer, cycleHandlingStrategy, refEmitter, referencesRegistry, depTracker, injectableRegistry, semanticDepGraphUpdater, annotateForClosureCompiler, perf, hostDirectivesResolver, importTracker, includeClassMetadata, compilationMode, deferredSymbolTracker, forbidOrphanRendering, enableBlockSyntax, enableLetSyntax, externalRuntimeStyles, localCompilationExtraImportsTracker, jitDeclarationRegistry, i18nPreserveSignificantWhitespace, strictStandalone, enableHmr, implicitStandaloneValue) {
  13878. this.reflector = reflector;
  13879. this.evaluator = evaluator;
  13880. this.metaRegistry = metaRegistry;
  13881. this.metaReader = metaReader;
  13882. this.scopeReader = scopeReader;
  13883. this.compilerHost = compilerHost;
  13884. this.scopeRegistry = scopeRegistry;
  13885. this.typeCheckScopeRegistry = typeCheckScopeRegistry;
  13886. this.resourceRegistry = resourceRegistry;
  13887. this.isCore = isCore;
  13888. this.strictCtorDeps = strictCtorDeps;
  13889. this.resourceLoader = resourceLoader;
  13890. this.rootDirs = rootDirs;
  13891. this.defaultPreserveWhitespaces = defaultPreserveWhitespaces;
  13892. this.i18nUseExternalIds = i18nUseExternalIds;
  13893. this.enableI18nLegacyMessageIdFormat = enableI18nLegacyMessageIdFormat;
  13894. this.usePoisonedData = usePoisonedData;
  13895. this.i18nNormalizeLineEndingsInICUs = i18nNormalizeLineEndingsInICUs;
  13896. this.moduleResolver = moduleResolver;
  13897. this.cycleAnalyzer = cycleAnalyzer;
  13898. this.cycleHandlingStrategy = cycleHandlingStrategy;
  13899. this.refEmitter = refEmitter;
  13900. this.referencesRegistry = referencesRegistry;
  13901. this.depTracker = depTracker;
  13902. this.injectableRegistry = injectableRegistry;
  13903. this.semanticDepGraphUpdater = semanticDepGraphUpdater;
  13904. this.annotateForClosureCompiler = annotateForClosureCompiler;
  13905. this.perf = perf;
  13906. this.hostDirectivesResolver = hostDirectivesResolver;
  13907. this.importTracker = importTracker;
  13908. this.includeClassMetadata = includeClassMetadata;
  13909. this.compilationMode = compilationMode;
  13910. this.deferredSymbolTracker = deferredSymbolTracker;
  13911. this.forbidOrphanRendering = forbidOrphanRendering;
  13912. this.enableBlockSyntax = enableBlockSyntax;
  13913. this.enableLetSyntax = enableLetSyntax;
  13914. this.externalRuntimeStyles = externalRuntimeStyles;
  13915. this.localCompilationExtraImportsTracker = localCompilationExtraImportsTracker;
  13916. this.jitDeclarationRegistry = jitDeclarationRegistry;
  13917. this.i18nPreserveSignificantWhitespace = i18nPreserveSignificantWhitespace;
  13918. this.strictStandalone = strictStandalone;
  13919. this.enableHmr = enableHmr;
  13920. this.implicitStandaloneValue = implicitStandaloneValue;
  13921. this.extractTemplateOptions = {
  13922. enableI18nLegacyMessageIdFormat: this.enableI18nLegacyMessageIdFormat,
  13923. i18nNormalizeLineEndingsInICUs: this.i18nNormalizeLineEndingsInICUs,
  13924. usePoisonedData: this.usePoisonedData,
  13925. enableBlockSyntax: this.enableBlockSyntax,
  13926. enableLetSyntax: this.enableLetSyntax,
  13927. preserveSignificantWhitespace: this.i18nPreserveSignificantWhitespace
  13928. };
  13929. this.canDeferDeps = !enableHmr;
  13930. }
  13931. literalCache = /* @__PURE__ */ new Map();
  13932. elementSchemaRegistry = new DomElementSchemaRegistry3();
  13933. preanalyzeTemplateCache = /* @__PURE__ */ new Map();
  13934. preanalyzeStylesCache = /* @__PURE__ */ new Map();
  13935. canDeferDeps;
  13936. extractTemplateOptions;
  13937. precedence = HandlerPrecedence.PRIMARY;
  13938. name = "ComponentDecoratorHandler";
  13939. detect(node, decorators) {
  13940. if (!decorators) {
  13941. return void 0;
  13942. }
  13943. const decorator = findAngularDecorator(decorators, "Component", this.isCore);
  13944. if (decorator !== void 0) {
  13945. return {
  13946. trigger: decorator.node,
  13947. decorator,
  13948. metadata: decorator
  13949. };
  13950. } else {
  13951. return void 0;
  13952. }
  13953. }
  13954. preanalyze(node, decorator) {
  13955. if (!this.resourceLoader.canPreload) {
  13956. return void 0;
  13957. }
  13958. const meta = resolveLiteral(decorator, this.literalCache);
  13959. const component = reflectObjectLiteral(meta);
  13960. const containingFile = node.getSourceFile().fileName;
  13961. const resolveStyleUrl = (styleUrl) => {
  13962. try {
  13963. const resourceUrl = this.resourceLoader.resolve(styleUrl, containingFile);
  13964. return this.resourceLoader.preload(resourceUrl, {
  13965. type: "style",
  13966. containingFile,
  13967. className: node.name.text
  13968. });
  13969. } catch {
  13970. return void 0;
  13971. }
  13972. };
  13973. const templateAndTemplateStyleResources = preloadAndParseTemplate(this.evaluator, this.resourceLoader, this.depTracker, this.preanalyzeTemplateCache, node, decorator, component, containingFile, this.defaultPreserveWhitespaces, this.extractTemplateOptions, this.compilationMode).then((template) => {
  13974. if (template === null) {
  13975. return { templateStyles: [], templateStyleUrls: [] };
  13976. }
  13977. let templateUrl;
  13978. if (template.sourceMapping.type === "external") {
  13979. templateUrl = template.sourceMapping.templateUrl;
  13980. }
  13981. return {
  13982. templateUrl,
  13983. templateStyles: template.styles,
  13984. templateStyleUrls: template.styleUrls
  13985. };
  13986. });
  13987. const componentStyleUrls = extractComponentStyleUrls(this.evaluator, component);
  13988. return templateAndTemplateStyleResources.then(async (templateInfo) => {
  13989. let styles = null;
  13990. let orderOffset = 0;
  13991. const rawStyles = parseDirectiveStyles(component, this.evaluator, this.compilationMode);
  13992. if (rawStyles == null ? void 0 : rawStyles.length) {
  13993. styles = await Promise.all(rawStyles.map((style) => this.resourceLoader.preprocessInline(style, {
  13994. type: "style",
  13995. containingFile,
  13996. order: orderOffset++,
  13997. className: node.name.text
  13998. })));
  13999. }
  14000. if (templateInfo.templateStyles) {
  14001. styles != null ? styles : styles = [];
  14002. styles.push(...await Promise.all(templateInfo.templateStyles.map((style) => {
  14003. var _a;
  14004. return this.resourceLoader.preprocessInline(style, {
  14005. type: "style",
  14006. containingFile: (_a = templateInfo.templateUrl) != null ? _a : containingFile,
  14007. order: orderOffset++,
  14008. className: node.name.text
  14009. });
  14010. })));
  14011. }
  14012. this.preanalyzeStylesCache.set(node, styles);
  14013. if (this.externalRuntimeStyles) {
  14014. return;
  14015. }
  14016. await Promise.all([
  14017. ...componentStyleUrls.map((styleUrl) => resolveStyleUrl(styleUrl.url)),
  14018. ...templateInfo.templateStyleUrls.map((url) => resolveStyleUrl(url))
  14019. ]);
  14020. });
  14021. }
  14022. analyze(node, decorator) {
  14023. var _a, _b, _c, _d, _e, _f;
  14024. this.perf.eventCount(PerfEvent.AnalyzeComponent);
  14025. const containingFile = node.getSourceFile().fileName;
  14026. this.literalCache.delete(decorator);
  14027. let diagnostics;
  14028. let isPoisoned = false;
  14029. const directiveResult = extractDirectiveMetadata(node, decorator, this.reflector, this.importTracker, this.evaluator, this.refEmitter, this.referencesRegistry, this.isCore, this.annotateForClosureCompiler, this.compilationMode, this.elementSchemaRegistry.getDefaultComponentElementName(), this.strictStandalone, this.implicitStandaloneValue);
  14030. if (directiveResult.jitForced) {
  14031. this.jitDeclarationRegistry.jitDeclarations.add(node);
  14032. return {};
  14033. }
  14034. const { decorator: component, metadata, inputs, outputs, hostDirectives, rawHostDirectives } = directiveResult;
  14035. const encapsulation = (_a = this.compilationMode !== CompilationMode.LOCAL ? resolveEnumValue(this.evaluator, component, "encapsulation", "ViewEncapsulation", this.isCore) : resolveEncapsulationEnumValueLocally(component.get("encapsulation"))) != null ? _a : ViewEncapsulation2.Emulated;
  14036. let changeDetection = null;
  14037. if (this.compilationMode !== CompilationMode.LOCAL) {
  14038. changeDetection = resolveEnumValue(this.evaluator, component, "changeDetection", "ChangeDetectionStrategy", this.isCore);
  14039. } else if (component.has("changeDetection")) {
  14040. changeDetection = new o4.WrappedNodeExpr(component.get("changeDetection"));
  14041. }
  14042. let animations = null;
  14043. let animationTriggerNames = null;
  14044. if (component.has("animations")) {
  14045. const animationExpression = component.get("animations");
  14046. animations = new o4.WrappedNodeExpr(animationExpression);
  14047. const animationsValue = this.evaluator.evaluate(animationExpression, animationTriggerResolver);
  14048. animationTriggerNames = { includesDynamicAnimations: false, staticTriggerNames: [] };
  14049. collectAnimationNames(animationsValue, animationTriggerNames);
  14050. }
  14051. const relativeContextFilePath = this.rootDirs.reduce((previous, rootDir) => {
  14052. const candidate = relative(absoluteFrom(rootDir), absoluteFrom(containingFile));
  14053. if (previous === void 0 || candidate.length < previous.length) {
  14054. return candidate;
  14055. } else {
  14056. return previous;
  14057. }
  14058. }, void 0);
  14059. let viewProvidersRequiringFactory = null;
  14060. let providersRequiringFactory = null;
  14061. let wrappedViewProviders = null;
  14062. if (component.has("viewProviders")) {
  14063. const viewProviders = component.get("viewProviders");
  14064. viewProvidersRequiringFactory = resolveProvidersRequiringFactory(viewProviders, this.reflector, this.evaluator);
  14065. wrappedViewProviders = new o4.WrappedNodeExpr(this.annotateForClosureCompiler ? wrapFunctionExpressionsInParens(viewProviders) : viewProviders);
  14066. }
  14067. if (component.has("providers")) {
  14068. providersRequiringFactory = resolveProvidersRequiringFactory(component.get("providers"), this.reflector, this.evaluator);
  14069. }
  14070. let resolvedImports = null;
  14071. let resolvedDeferredImports = null;
  14072. let rawImports = (_b = component.get("imports")) != null ? _b : null;
  14073. let rawDeferredImports = (_c = component.get("deferredImports")) != null ? _c : null;
  14074. if ((rawImports || rawDeferredImports) && !metadata.isStandalone) {
  14075. if (diagnostics === void 0) {
  14076. diagnostics = [];
  14077. }
  14078. const importsField = rawImports ? "imports" : "deferredImports";
  14079. diagnostics.push(makeDiagnostic(ErrorCode.COMPONENT_NOT_STANDALONE, component.get(importsField), `'${importsField}' is only valid on a component that is standalone.`, [
  14080. makeRelatedInformation(node.name, `Did you forget to add 'standalone: true' to this @Component?`)
  14081. ]));
  14082. isPoisoned = true;
  14083. } else if (this.compilationMode !== CompilationMode.LOCAL && (rawImports || rawDeferredImports)) {
  14084. const importResolvers = combineResolvers([
  14085. createModuleWithProvidersResolver(this.reflector, this.isCore),
  14086. createForwardRefResolver(this.isCore)
  14087. ]);
  14088. const importDiagnostics = [];
  14089. if (rawImports) {
  14090. const expr = rawImports;
  14091. const imported = this.evaluator.evaluate(expr, importResolvers);
  14092. const { imports: flattened, diagnostics: diagnostics2 } = validateAndFlattenComponentImports(imported, expr, false);
  14093. importDiagnostics.push(...diagnostics2);
  14094. resolvedImports = flattened;
  14095. rawImports = expr;
  14096. }
  14097. if (rawDeferredImports) {
  14098. const expr = rawDeferredImports;
  14099. const imported = this.evaluator.evaluate(expr, importResolvers);
  14100. const { imports: flattened, diagnostics: diagnostics2 } = validateAndFlattenComponentImports(imported, expr, true);
  14101. importDiagnostics.push(...diagnostics2);
  14102. resolvedDeferredImports = flattened;
  14103. rawDeferredImports = expr;
  14104. }
  14105. if (importDiagnostics.length > 0) {
  14106. isPoisoned = true;
  14107. if (diagnostics === void 0) {
  14108. diagnostics = [];
  14109. }
  14110. diagnostics.push(...importDiagnostics);
  14111. }
  14112. }
  14113. let schemas = null;
  14114. if (component.has("schemas") && !metadata.isStandalone) {
  14115. if (diagnostics === void 0) {
  14116. diagnostics = [];
  14117. }
  14118. diagnostics.push(makeDiagnostic(ErrorCode.COMPONENT_NOT_STANDALONE, component.get("schemas"), `'schemas' is only valid on a component that is standalone.`));
  14119. } else if (this.compilationMode !== CompilationMode.LOCAL && component.has("schemas")) {
  14120. schemas = extractSchemas(component.get("schemas"), this.evaluator, "Component");
  14121. } else if (metadata.isStandalone) {
  14122. schemas = [];
  14123. }
  14124. let template;
  14125. if (this.preanalyzeTemplateCache.has(node)) {
  14126. const preanalyzed = this.preanalyzeTemplateCache.get(node);
  14127. this.preanalyzeTemplateCache.delete(node);
  14128. template = preanalyzed;
  14129. } else {
  14130. const templateDecl = parseTemplateDeclaration(node, decorator, component, containingFile, this.evaluator, this.depTracker, this.resourceLoader, this.defaultPreserveWhitespaces);
  14131. template = extractTemplate(node, templateDecl, this.evaluator, this.depTracker, this.resourceLoader, {
  14132. enableI18nLegacyMessageIdFormat: this.enableI18nLegacyMessageIdFormat,
  14133. i18nNormalizeLineEndingsInICUs: this.i18nNormalizeLineEndingsInICUs,
  14134. usePoisonedData: this.usePoisonedData,
  14135. enableBlockSyntax: this.enableBlockSyntax,
  14136. enableLetSyntax: this.enableLetSyntax,
  14137. preserveSignificantWhitespace: this.i18nPreserveSignificantWhitespace
  14138. }, this.compilationMode);
  14139. if (this.compilationMode === CompilationMode.LOCAL && template.errors && template.errors.length > 0) {
  14140. if (diagnostics === void 0) {
  14141. diagnostics = [];
  14142. }
  14143. diagnostics.push(...getTemplateDiagnostics(
  14144. template.errors,
  14145. "",
  14146. template.sourceMapping
  14147. ));
  14148. }
  14149. }
  14150. const templateResource = template.declaration.isInline ? { path: null, expression: component.get("template") } : {
  14151. path: absoluteFrom(template.declaration.resolvedTemplateUrl),
  14152. expression: template.sourceMapping.node
  14153. };
  14154. const relativeTemplatePath = getProjectRelativePath((_d = templateResource.path) != null ? _d : ts49.getOriginalNode(node).getSourceFile().fileName, this.rootDirs, this.compilerHost);
  14155. let styles = [];
  14156. const externalStyles = [];
  14157. const styleResources = extractInlineStyleResources(component);
  14158. const styleUrls = [
  14159. ...extractComponentStyleUrls(this.evaluator, component),
  14160. ..._extractTemplateStyleUrls(template)
  14161. ];
  14162. for (const styleUrl of styleUrls) {
  14163. try {
  14164. const resourceUrl = this.resourceLoader.resolve(styleUrl.url, containingFile);
  14165. if (this.externalRuntimeStyles) {
  14166. externalStyles.push(resourceUrl);
  14167. continue;
  14168. }
  14169. if (styleUrl.source === 2 && ts49.isStringLiteralLike(styleUrl.expression)) {
  14170. styleResources.add({
  14171. path: absoluteFrom(resourceUrl),
  14172. expression: styleUrl.expression
  14173. });
  14174. }
  14175. const resourceStr = this.resourceLoader.load(resourceUrl);
  14176. styles.push(resourceStr);
  14177. if (this.depTracker !== null) {
  14178. this.depTracker.addResourceDependency(node.getSourceFile(), absoluteFrom(resourceUrl));
  14179. }
  14180. } catch {
  14181. if (this.depTracker !== null) {
  14182. this.depTracker.recordDependencyAnalysisFailure(node.getSourceFile());
  14183. }
  14184. if (diagnostics === void 0) {
  14185. diagnostics = [];
  14186. }
  14187. const resourceType = styleUrl.source === 2 ? 2 : 1;
  14188. diagnostics.push(makeResourceNotFoundError(styleUrl.url, styleUrl.expression, resourceType).toDiagnostic());
  14189. }
  14190. }
  14191. if (encapsulation === ViewEncapsulation2.ShadowDom && metadata.selector !== null) {
  14192. const selectorError = checkCustomElementSelectorForErrors(metadata.selector);
  14193. if (selectorError !== null) {
  14194. if (diagnostics === void 0) {
  14195. diagnostics = [];
  14196. }
  14197. diagnostics.push(makeDiagnostic(ErrorCode.COMPONENT_INVALID_SHADOW_DOM_SELECTOR, component.get("selector"), selectorError));
  14198. }
  14199. }
  14200. let inlineStyles = null;
  14201. if (this.preanalyzeStylesCache.has(node)) {
  14202. inlineStyles = this.preanalyzeStylesCache.get(node);
  14203. this.preanalyzeStylesCache.delete(node);
  14204. if (inlineStyles == null ? void 0 : inlineStyles.length) {
  14205. if (this.externalRuntimeStyles) {
  14206. externalStyles.push(...inlineStyles);
  14207. } else {
  14208. styles.push(...inlineStyles);
  14209. }
  14210. }
  14211. } else {
  14212. if (this.resourceLoader.canPreprocess) {
  14213. throw new Error("Inline resource processing requires asynchronous preanalyze.");
  14214. }
  14215. if (component.has("styles")) {
  14216. const litStyles = parseDirectiveStyles(component, this.evaluator, this.compilationMode);
  14217. if (litStyles !== null) {
  14218. inlineStyles = [...litStyles];
  14219. styles.push(...litStyles);
  14220. }
  14221. }
  14222. if (template.styles.length > 0) {
  14223. styles.push(...template.styles);
  14224. }
  14225. }
  14226. let explicitlyDeferredTypes = null;
  14227. if (metadata.isStandalone && rawDeferredImports !== null) {
  14228. const deferredTypes = this.collectExplicitlyDeferredSymbols(rawDeferredImports);
  14229. for (const [deferredType, importDetails] of deferredTypes) {
  14230. explicitlyDeferredTypes != null ? explicitlyDeferredTypes : explicitlyDeferredTypes = [];
  14231. explicitlyDeferredTypes.push({
  14232. symbolName: importDetails.name,
  14233. importPath: importDetails.from,
  14234. isDefaultImport: isDefaultImport(importDetails.node)
  14235. });
  14236. this.deferredSymbolTracker.markAsDeferrableCandidate(deferredType, importDetails.node, node, true);
  14237. }
  14238. }
  14239. const output = {
  14240. analysis: {
  14241. baseClass: readBaseClass(node, this.reflector, this.evaluator),
  14242. inputs,
  14243. inputFieldNamesFromMetadataArray: directiveResult.inputFieldNamesFromMetadataArray,
  14244. outputs,
  14245. hostDirectives,
  14246. rawHostDirectives,
  14247. meta: {
  14248. ...metadata,
  14249. template,
  14250. encapsulation,
  14251. changeDetection,
  14252. interpolation: (_e = template.interpolationConfig) != null ? _e : DEFAULT_INTERPOLATION_CONFIG2,
  14253. styles,
  14254. externalStyles,
  14255. animations,
  14256. viewProviders: wrappedViewProviders,
  14257. i18nUseExternalIds: this.i18nUseExternalIds,
  14258. relativeContextFilePath,
  14259. rawImports: rawImports !== null ? new o4.WrappedNodeExpr(rawImports) : void 0,
  14260. relativeTemplatePath
  14261. },
  14262. typeCheckMeta: extractDirectiveTypeCheckMeta(node, inputs, this.reflector),
  14263. classMetadata: this.includeClassMetadata ? extractClassMetadata(node, this.reflector, this.isCore, this.annotateForClosureCompiler, (dec) => transformDecoratorResources(dec, component, styles, template)) : null,
  14264. classDebugInfo: extractClassDebugInfo(
  14265. node,
  14266. this.reflector,
  14267. this.compilerHost,
  14268. this.rootDirs,
  14269. this.forbidOrphanRendering
  14270. ),
  14271. template,
  14272. providersRequiringFactory,
  14273. viewProvidersRequiringFactory,
  14274. inlineStyles,
  14275. styleUrls,
  14276. resources: {
  14277. styles: styleResources,
  14278. template: templateResource
  14279. },
  14280. isPoisoned,
  14281. animationTriggerNames,
  14282. rawImports,
  14283. resolvedImports,
  14284. rawDeferredImports,
  14285. resolvedDeferredImports,
  14286. explicitlyDeferredTypes,
  14287. schemas,
  14288. decorator: (_f = decorator == null ? void 0 : decorator.node) != null ? _f : null
  14289. },
  14290. diagnostics
  14291. };
  14292. return output;
  14293. }
  14294. symbol(node, analysis) {
  14295. const typeParameters = extractSemanticTypeParameters(node);
  14296. return new ComponentSymbol(node, analysis.meta.selector, analysis.inputs, analysis.outputs, analysis.meta.exportAs, analysis.typeCheckMeta, typeParameters);
  14297. }
  14298. register(node, analysis) {
  14299. var _a;
  14300. const ref = new Reference(node);
  14301. this.metaRegistry.registerDirectiveMetadata({
  14302. kind: MetaKind.Directive,
  14303. matchSource: MatchSource.Selector,
  14304. ref,
  14305. name: node.name.text,
  14306. selector: analysis.meta.selector,
  14307. exportAs: analysis.meta.exportAs,
  14308. inputs: analysis.inputs,
  14309. inputFieldNamesFromMetadataArray: analysis.inputFieldNamesFromMetadataArray,
  14310. outputs: analysis.outputs,
  14311. queries: analysis.meta.queries.map((query) => query.propertyName),
  14312. isComponent: true,
  14313. baseClass: analysis.baseClass,
  14314. hostDirectives: analysis.hostDirectives,
  14315. ...analysis.typeCheckMeta,
  14316. isPoisoned: analysis.isPoisoned,
  14317. isStructural: false,
  14318. isStandalone: analysis.meta.isStandalone,
  14319. isSignal: analysis.meta.isSignal,
  14320. imports: analysis.resolvedImports,
  14321. rawImports: analysis.rawImports,
  14322. deferredImports: analysis.resolvedDeferredImports,
  14323. animationTriggerNames: analysis.animationTriggerNames,
  14324. schemas: analysis.schemas,
  14325. decorator: analysis.decorator,
  14326. assumedToExportProviders: false,
  14327. ngContentSelectors: analysis.template.ngContentSelectors,
  14328. preserveWhitespaces: (_a = analysis.template.preserveWhitespaces) != null ? _a : false,
  14329. isExplicitlyDeferred: false
  14330. });
  14331. this.resourceRegistry.registerResources(analysis.resources, node);
  14332. this.injectableRegistry.registerInjectable(node, {
  14333. ctorDeps: analysis.meta.deps
  14334. });
  14335. }
  14336. index(context, node, analysis) {
  14337. if (analysis.isPoisoned && !this.usePoisonedData) {
  14338. return null;
  14339. }
  14340. const scope = this.scopeReader.getScopeForComponent(node);
  14341. const selector = analysis.meta.selector;
  14342. const matcher = new SelectorMatcher3();
  14343. if (scope !== null) {
  14344. let { dependencies, isPoisoned } = scope.kind === ComponentScopeKind.NgModule ? scope.compilation : scope;
  14345. if ((isPoisoned || scope.kind === ComponentScopeKind.NgModule && scope.exported.isPoisoned) && !this.usePoisonedData) {
  14346. return null;
  14347. }
  14348. for (const dep of dependencies) {
  14349. if (dep.kind === MetaKind.Directive && dep.selector !== null) {
  14350. matcher.addSelectables(CssSelector4.parse(dep.selector), [
  14351. ...this.hostDirectivesResolver.resolve(dep),
  14352. dep
  14353. ]);
  14354. }
  14355. }
  14356. }
  14357. const binder = new R3TargetBinder(matcher);
  14358. const boundTemplate = binder.bind({ template: analysis.template.diagNodes });
  14359. context.addComponent({
  14360. declaration: node,
  14361. selector,
  14362. boundTemplate,
  14363. templateMeta: {
  14364. isInline: analysis.template.declaration.isInline,
  14365. file: analysis.template.file
  14366. }
  14367. });
  14368. return null;
  14369. }
  14370. typeCheck(ctx, node, meta) {
  14371. var _a;
  14372. if (this.typeCheckScopeRegistry === null || !ts49.isClassDeclaration(node)) {
  14373. return;
  14374. }
  14375. if (meta.isPoisoned && !this.usePoisonedData) {
  14376. return;
  14377. }
  14378. const scope = this.typeCheckScopeRegistry.getTypeCheckScope(node);
  14379. if (scope.isPoisoned && !this.usePoisonedData) {
  14380. return;
  14381. }
  14382. const binder = new R3TargetBinder(scope.matcher);
  14383. const templateContext = {
  14384. nodes: meta.template.diagNodes,
  14385. pipes: scope.pipes,
  14386. sourceMapping: meta.template.sourceMapping,
  14387. file: meta.template.file,
  14388. parseErrors: meta.template.errors,
  14389. preserveWhitespaces: (_a = meta.meta.template.preserveWhitespaces) != null ? _a : false
  14390. };
  14391. ctx.addDirective(new Reference(node), binder, scope.schemas, templateContext, meta.meta.isStandalone);
  14392. }
  14393. extendedTemplateCheck(component, extendedTemplateChecker) {
  14394. return extendedTemplateChecker.getDiagnosticsForComponent(component);
  14395. }
  14396. templateSemanticsCheck(component, templateSemanticsChecker) {
  14397. return templateSemanticsChecker.getDiagnosticsForComponent(component);
  14398. }
  14399. resolve(node, analysis, symbol) {
  14400. var _a, _b;
  14401. const metadata = analysis.meta;
  14402. const diagnostics = [];
  14403. const context = getSourceFile(node);
  14404. const nonRemovableImports = this.deferredSymbolTracker.getNonRemovableDeferredImports(context, node);
  14405. if (nonRemovableImports.length > 0) {
  14406. for (const importDecl of nonRemovableImports) {
  14407. const diagnostic = makeDiagnostic(ErrorCode.DEFERRED_DEPENDENCY_IMPORTED_EAGERLY, importDecl, `This import contains symbols that are used both inside and outside of the \`@Component.deferredImports\` fields in the file. This renders all these defer imports useless as this import remains and its module is eagerly loaded. To fix this, make sure that all symbols from the import are *only* used within \`@Component.deferredImports\` arrays and there are no other references to those symbols present in this file.`);
  14408. diagnostics.push(diagnostic);
  14409. }
  14410. return { diagnostics };
  14411. }
  14412. let data;
  14413. if (this.compilationMode === CompilationMode.LOCAL) {
  14414. data = {
  14415. declarations: EMPTY_ARRAY2,
  14416. declarationListEmitMode: !analysis.meta.isStandalone || analysis.rawImports !== null ? 3 : 0,
  14417. deferPerBlockDependencies: this.locateDeferBlocksWithoutScope(analysis.template),
  14418. deferBlockDepsEmitMode: 1,
  14419. deferrableDeclToImportDecl: /* @__PURE__ */ new Map(),
  14420. deferPerComponentDependencies: (_a = analysis.explicitlyDeferredTypes) != null ? _a : []
  14421. };
  14422. if (this.localCompilationExtraImportsTracker === null) {
  14423. return { data };
  14424. }
  14425. } else {
  14426. data = {
  14427. declarations: EMPTY_ARRAY2,
  14428. declarationListEmitMode: 0,
  14429. deferPerBlockDependencies: /* @__PURE__ */ new Map(),
  14430. deferBlockDepsEmitMode: 0,
  14431. deferrableDeclToImportDecl: /* @__PURE__ */ new Map(),
  14432. deferPerComponentDependencies: []
  14433. };
  14434. }
  14435. if (this.semanticDepGraphUpdater !== null && analysis.baseClass instanceof Reference) {
  14436. symbol.baseClass = this.semanticDepGraphUpdater.getSymbol(analysis.baseClass.node);
  14437. }
  14438. if (analysis.isPoisoned && !this.usePoisonedData) {
  14439. return {};
  14440. }
  14441. const scope = this.scopeReader.getScopeForComponent(node);
  14442. if (scope !== null) {
  14443. const isModuleScope = scope.kind === ComponentScopeKind.NgModule;
  14444. const dependencies = isModuleScope ? scope.compilation.dependencies : scope.dependencies;
  14445. const explicitlyDeferredDependencies = getExplicitlyDeferredDeps(scope);
  14446. if (isModuleScope && context.fileName !== getSourceFile(scope.ngModule).fileName) {
  14447. (_b = this.localCompilationExtraImportsTracker) == null ? void 0 : _b.markFileForExtraImportGeneration(context);
  14448. }
  14449. if (metadata.isStandalone && analysis.rawDeferredImports !== null && explicitlyDeferredDependencies.length > 0) {
  14450. const diagnostic = validateNoImportOverlap(dependencies, explicitlyDeferredDependencies, analysis.rawDeferredImports);
  14451. if (diagnostic !== null) {
  14452. diagnostics.push(diagnostic);
  14453. }
  14454. }
  14455. const binder = createTargetBinder(dependencies);
  14456. const pipes = extractPipes(dependencies);
  14457. let allDependencies = dependencies;
  14458. let deferBlockBinder = binder;
  14459. if (explicitlyDeferredDependencies.length > 0) {
  14460. allDependencies = [...explicitlyDeferredDependencies, ...dependencies];
  14461. deferBlockBinder = createTargetBinder(allDependencies);
  14462. }
  14463. const bound = binder.bind({ template: metadata.template.nodes });
  14464. const deferBlocks = /* @__PURE__ */ new Map();
  14465. for (const deferBlock of bound.getDeferBlocks()) {
  14466. deferBlocks.set(deferBlock, deferBlockBinder.bind({ template: deferBlock.children }));
  14467. }
  14468. const eagerlyUsed = /* @__PURE__ */ new Set();
  14469. if (this.enableHmr) {
  14470. for (const dep of dependencies) {
  14471. if (dep.ref.node !== node) {
  14472. eagerlyUsed.add(dep.ref.node);
  14473. } else {
  14474. const used = bound.getEagerlyUsedDirectives();
  14475. if (used.some((current) => current.ref.node === node)) {
  14476. eagerlyUsed.add(node);
  14477. }
  14478. }
  14479. }
  14480. } else {
  14481. for (const dir of bound.getEagerlyUsedDirectives()) {
  14482. eagerlyUsed.add(dir.ref.node);
  14483. }
  14484. for (const name of bound.getEagerlyUsedPipes()) {
  14485. if (!pipes.has(name)) {
  14486. continue;
  14487. }
  14488. eagerlyUsed.add(pipes.get(name).ref.node);
  14489. }
  14490. }
  14491. const wholeTemplateUsed = new Set(eagerlyUsed);
  14492. for (const bound2 of deferBlocks.values()) {
  14493. for (const dir of bound2.getEagerlyUsedDirectives()) {
  14494. wholeTemplateUsed.add(dir.ref.node);
  14495. }
  14496. for (const name of bound2.getEagerlyUsedPipes()) {
  14497. if (!pipes.has(name)) {
  14498. continue;
  14499. }
  14500. wholeTemplateUsed.add(pipes.get(name).ref.node);
  14501. }
  14502. }
  14503. const declarations = /* @__PURE__ */ new Map();
  14504. for (const dep of allDependencies) {
  14505. if (declarations.has(dep.ref.node)) {
  14506. continue;
  14507. }
  14508. switch (dep.kind) {
  14509. case MetaKind.Directive:
  14510. if (!wholeTemplateUsed.has(dep.ref.node) || dep.matchSource !== MatchSource.Selector) {
  14511. continue;
  14512. }
  14513. const dirType = this.refEmitter.emit(dep.ref, context);
  14514. assertSuccessfulReferenceEmit(dirType, node.name, dep.isComponent ? "component" : "directive");
  14515. declarations.set(dep.ref.node, {
  14516. kind: R3TemplateDependencyKind.Directive,
  14517. ref: dep.ref,
  14518. type: dirType.expression,
  14519. importedFile: dirType.importedFile,
  14520. selector: dep.selector,
  14521. inputs: dep.inputs.propertyNames,
  14522. outputs: dep.outputs.propertyNames,
  14523. exportAs: dep.exportAs,
  14524. isComponent: dep.isComponent
  14525. });
  14526. break;
  14527. case MetaKind.Pipe:
  14528. if (!wholeTemplateUsed.has(dep.ref.node)) {
  14529. continue;
  14530. }
  14531. const pipeType = this.refEmitter.emit(dep.ref, context);
  14532. assertSuccessfulReferenceEmit(pipeType, node.name, "pipe");
  14533. declarations.set(dep.ref.node, {
  14534. kind: R3TemplateDependencyKind.Pipe,
  14535. type: pipeType.expression,
  14536. name: dep.name,
  14537. ref: dep.ref,
  14538. importedFile: pipeType.importedFile
  14539. });
  14540. break;
  14541. case MetaKind.NgModule:
  14542. const ngModuleType = this.refEmitter.emit(dep.ref, context);
  14543. assertSuccessfulReferenceEmit(ngModuleType, node.name, "NgModule");
  14544. declarations.set(dep.ref.node, {
  14545. kind: R3TemplateDependencyKind.NgModule,
  14546. type: ngModuleType.expression,
  14547. importedFile: ngModuleType.importedFile
  14548. });
  14549. break;
  14550. }
  14551. }
  14552. const getSemanticReference = (decl) => this.semanticDepGraphUpdater.getSemanticReference(decl.ref.node, decl.type);
  14553. if (this.semanticDepGraphUpdater !== null) {
  14554. symbol.usedDirectives = Array.from(declarations.values()).filter(isUsedDirective).map(getSemanticReference);
  14555. symbol.usedPipes = Array.from(declarations.values()).filter(isUsedPipe).map(getSemanticReference);
  14556. }
  14557. const eagerDeclarations = Array.from(declarations.values()).filter((decl) => decl.kind === R3TemplateDependencyKind.NgModule || eagerlyUsed.has(decl.ref.node));
  14558. if (this.compilationMode !== CompilationMode.LOCAL) {
  14559. this.resolveDeferBlocks(node, deferBlocks, declarations, data, analysis, eagerlyUsed);
  14560. }
  14561. const cyclesFromDirectives = /* @__PURE__ */ new Map();
  14562. const cyclesFromPipes = /* @__PURE__ */ new Map();
  14563. if (!metadata.isStandalone) {
  14564. for (const usedDep of eagerDeclarations) {
  14565. const cycle = this._checkForCyclicImport(usedDep.importedFile, usedDep.type, context);
  14566. if (cycle !== null) {
  14567. switch (usedDep.kind) {
  14568. case R3TemplateDependencyKind.Directive:
  14569. cyclesFromDirectives.set(usedDep, cycle);
  14570. break;
  14571. case R3TemplateDependencyKind.Pipe:
  14572. cyclesFromPipes.set(usedDep, cycle);
  14573. break;
  14574. }
  14575. }
  14576. }
  14577. }
  14578. const standaloneImportMayBeForwardDeclared = analysis.resolvedImports !== null && analysis.resolvedImports.some((ref) => ref.synthetic);
  14579. const cycleDetected = cyclesFromDirectives.size !== 0 || cyclesFromPipes.size !== 0;
  14580. if (!cycleDetected) {
  14581. for (const { type, importedFile } of eagerDeclarations) {
  14582. this.maybeRecordSyntheticImport(importedFile, type, context);
  14583. }
  14584. const declarationIsForwardDeclared = eagerDeclarations.some((decl) => isExpressionForwardReference(decl.type, node.name, context));
  14585. if (this.compilationMode !== CompilationMode.LOCAL && (declarationIsForwardDeclared || standaloneImportMayBeForwardDeclared)) {
  14586. data.declarationListEmitMode = 1;
  14587. }
  14588. data.declarations = eagerDeclarations;
  14589. if (this.compilationMode === CompilationMode.LOCAL && this.localCompilationExtraImportsTracker !== null) {
  14590. for (const { type } of eagerDeclarations) {
  14591. if (type instanceof ExternalExpr8 && type.value.moduleName) {
  14592. this.localCompilationExtraImportsTracker.addImportForFile(context, type.value.moduleName);
  14593. }
  14594. }
  14595. }
  14596. } else {
  14597. if (this.cycleHandlingStrategy === 0) {
  14598. this.scopeRegistry.setComponentRemoteScope(node, eagerDeclarations.filter(isUsedDirective).map((dir) => dir.ref), eagerDeclarations.filter(isUsedPipe).map((pipe) => pipe.ref));
  14599. symbol.isRemotelyScoped = true;
  14600. if (this.semanticDepGraphUpdater !== null && scope.kind === ComponentScopeKind.NgModule && scope.ngModule !== null) {
  14601. const moduleSymbol = this.semanticDepGraphUpdater.getSymbol(scope.ngModule);
  14602. if (!(moduleSymbol instanceof NgModuleSymbol)) {
  14603. throw new Error(`AssertionError: Expected ${scope.ngModule.name} to be an NgModuleSymbol.`);
  14604. }
  14605. moduleSymbol.addRemotelyScopedComponent(symbol, symbol.usedDirectives, symbol.usedPipes);
  14606. }
  14607. } else {
  14608. const relatedMessages = [];
  14609. for (const [dir, cycle] of cyclesFromDirectives) {
  14610. relatedMessages.push(makeCyclicImportInfo(dir.ref, dir.isComponent ? "component" : "directive", cycle));
  14611. }
  14612. for (const [pipe, cycle] of cyclesFromPipes) {
  14613. relatedMessages.push(makeCyclicImportInfo(pipe.ref, "pipe", cycle));
  14614. }
  14615. throw new FatalDiagnosticError(ErrorCode.IMPORT_CYCLE_DETECTED, node, "One or more import cycles would need to be created to compile this component, which is not supported by the current compiler configuration.", relatedMessages);
  14616. }
  14617. }
  14618. } else {
  14619. data.deferPerBlockDependencies = this.locateDeferBlocksWithoutScope(metadata.template);
  14620. }
  14621. if (this.compilationMode !== CompilationMode.LOCAL) {
  14622. if (analysis.resolvedImports !== null && analysis.rawImports !== null) {
  14623. const importDiagnostics = validateStandaloneImports(analysis.resolvedImports, analysis.rawImports, this.metaReader, this.scopeReader, false);
  14624. diagnostics.push(...importDiagnostics);
  14625. }
  14626. if (analysis.resolvedDeferredImports !== null && analysis.rawDeferredImports !== null) {
  14627. const importDiagnostics = validateStandaloneImports(analysis.resolvedDeferredImports, analysis.rawDeferredImports, this.metaReader, this.scopeReader, true);
  14628. diagnostics.push(...importDiagnostics);
  14629. }
  14630. if (analysis.providersRequiringFactory !== null && analysis.meta.providers instanceof o4.WrappedNodeExpr) {
  14631. const providerDiagnostics = getProviderDiagnostics(analysis.providersRequiringFactory, analysis.meta.providers.node, this.injectableRegistry);
  14632. diagnostics.push(...providerDiagnostics);
  14633. }
  14634. if (analysis.viewProvidersRequiringFactory !== null && analysis.meta.viewProviders instanceof o4.WrappedNodeExpr) {
  14635. const viewProviderDiagnostics = getProviderDiagnostics(analysis.viewProvidersRequiringFactory, analysis.meta.viewProviders.node, this.injectableRegistry);
  14636. diagnostics.push(...viewProviderDiagnostics);
  14637. }
  14638. const directiveDiagnostics = getDirectiveDiagnostics(node, this.injectableRegistry, this.evaluator, this.reflector, this.scopeRegistry, this.strictCtorDeps, "Component");
  14639. if (directiveDiagnostics !== null) {
  14640. diagnostics.push(...directiveDiagnostics);
  14641. }
  14642. const hostDirectivesDiagnostics = analysis.hostDirectives && analysis.rawHostDirectives ? validateHostDirectives(analysis.rawHostDirectives, analysis.hostDirectives, this.metaReader) : null;
  14643. if (hostDirectivesDiagnostics !== null) {
  14644. diagnostics.push(...hostDirectivesDiagnostics);
  14645. }
  14646. }
  14647. if (diagnostics.length > 0) {
  14648. return { diagnostics };
  14649. }
  14650. return { data };
  14651. }
  14652. xi18n(ctx, node, analysis) {
  14653. var _a;
  14654. ctx.updateFromTemplate(analysis.template.content, analysis.template.declaration.resolvedTemplateUrl, (_a = analysis.template.interpolationConfig) != null ? _a : DEFAULT_INTERPOLATION_CONFIG2);
  14655. }
  14656. updateResources(node, analysis) {
  14657. const containingFile = node.getSourceFile().fileName;
  14658. const templateDecl = analysis.template.declaration;
  14659. if (!templateDecl.isInline) {
  14660. analysis.template = extractTemplate(node, templateDecl, this.evaluator, this.depTracker, this.resourceLoader, this.extractTemplateOptions, this.compilationMode);
  14661. }
  14662. let styles = [];
  14663. if (analysis.styleUrls !== null) {
  14664. for (const styleUrl of analysis.styleUrls) {
  14665. try {
  14666. const resolvedStyleUrl = this.resourceLoader.resolve(styleUrl.url, containingFile);
  14667. const styleText = this.resourceLoader.load(resolvedStyleUrl);
  14668. styles.push(styleText);
  14669. } catch (e) {
  14670. }
  14671. }
  14672. }
  14673. if (analysis.inlineStyles !== null) {
  14674. for (const styleText of analysis.inlineStyles) {
  14675. styles.push(styleText);
  14676. }
  14677. }
  14678. for (const styleText of analysis.template.styles) {
  14679. styles.push(styleText);
  14680. }
  14681. analysis.meta.styles = styles.filter((s) => s.trim().length > 0);
  14682. }
  14683. compileFull(node, analysis, resolution, pool) {
  14684. if (analysis.template.errors !== null && analysis.template.errors.length > 0) {
  14685. return [];
  14686. }
  14687. const perComponentDeferredDeps = this.canDeferDeps ? this.resolveAllDeferredDependencies(resolution) : null;
  14688. const defer = this.compileDeferBlocks(resolution);
  14689. const meta = {
  14690. ...analysis.meta,
  14691. ...resolution,
  14692. defer
  14693. };
  14694. const fac = compileNgFactoryDefField(toFactoryMetadata(meta, FactoryTarget3.Component));
  14695. if (perComponentDeferredDeps !== null) {
  14696. removeDeferrableTypesFromComponentDecorator(analysis, perComponentDeferredDeps);
  14697. }
  14698. const def = compileComponentFromMetadata(meta, pool, makeBindingParser2());
  14699. const inputTransformFields = compileInputTransformFields(analysis.inputs);
  14700. const classMetadata = analysis.classMetadata !== null ? compileComponentClassMetadata(analysis.classMetadata, perComponentDeferredDeps).toStmt() : null;
  14701. const debugInfo = analysis.classDebugInfo !== null ? compileClassDebugInfo(analysis.classDebugInfo).toStmt() : null;
  14702. const hmrMeta = this.enableHmr ? extractHmrMetatadata(node, this.reflector, this.evaluator, this.compilerHost, this.rootDirs, def, fac, defer, classMetadata, debugInfo) : null;
  14703. const hmrInitializer = hmrMeta ? compileHmrInitializer(hmrMeta).toStmt() : null;
  14704. const deferrableImports = this.canDeferDeps ? this.deferredSymbolTracker.getDeferrableImportDecls() : null;
  14705. return compileResults(fac, def, classMetadata, "\u0275cmp", inputTransformFields, deferrableImports, debugInfo, hmrInitializer);
  14706. }
  14707. compilePartial(node, analysis, resolution) {
  14708. if (analysis.template.errors !== null && analysis.template.errors.length > 0) {
  14709. return [];
  14710. }
  14711. const templateInfo = {
  14712. content: analysis.template.content,
  14713. sourceUrl: analysis.template.declaration.resolvedTemplateUrl,
  14714. isInline: analysis.template.declaration.isInline,
  14715. inlineTemplateLiteralExpression: analysis.template.sourceMapping.type === "direct" ? new o4.WrappedNodeExpr(analysis.template.sourceMapping.node) : null
  14716. };
  14717. const perComponentDeferredDeps = this.canDeferDeps ? this.resolveAllDeferredDependencies(resolution) : null;
  14718. const defer = this.compileDeferBlocks(resolution);
  14719. const meta = {
  14720. ...analysis.meta,
  14721. ...resolution,
  14722. defer
  14723. };
  14724. const fac = compileDeclareFactory(toFactoryMetadata(meta, FactoryTarget3.Component));
  14725. const inputTransformFields = compileInputTransformFields(analysis.inputs);
  14726. const def = compileDeclareComponentFromMetadata(meta, analysis.template, templateInfo);
  14727. const classMetadata = analysis.classMetadata !== null ? compileComponentDeclareClassMetadata(analysis.classMetadata, perComponentDeferredDeps).toStmt() : null;
  14728. const hmrMeta = this.enableHmr ? extractHmrMetatadata(node, this.reflector, this.evaluator, this.compilerHost, this.rootDirs, def, fac, defer, classMetadata, null) : null;
  14729. const hmrInitializer = hmrMeta ? compileHmrInitializer(hmrMeta).toStmt() : null;
  14730. const deferrableImports = this.canDeferDeps ? this.deferredSymbolTracker.getDeferrableImportDecls() : null;
  14731. return compileResults(fac, def, classMetadata, "\u0275cmp", inputTransformFields, deferrableImports, null, hmrInitializer);
  14732. }
  14733. compileLocal(node, analysis, resolution, pool) {
  14734. const deferrableTypes = this.canDeferDeps ? analysis.explicitlyDeferredTypes : null;
  14735. const defer = this.compileDeferBlocks(resolution);
  14736. const meta = {
  14737. ...analysis.meta,
  14738. ...resolution,
  14739. defer
  14740. };
  14741. if (deferrableTypes !== null) {
  14742. removeDeferrableTypesFromComponentDecorator(analysis, deferrableTypes);
  14743. }
  14744. const fac = compileNgFactoryDefField(toFactoryMetadata(meta, FactoryTarget3.Component));
  14745. const def = compileComponentFromMetadata(meta, pool, makeBindingParser2());
  14746. const inputTransformFields = compileInputTransformFields(analysis.inputs);
  14747. const classMetadata = analysis.classMetadata !== null ? compileComponentClassMetadata(analysis.classMetadata, deferrableTypes).toStmt() : null;
  14748. const debugInfo = analysis.classDebugInfo !== null ? compileClassDebugInfo(analysis.classDebugInfo).toStmt() : null;
  14749. const hmrMeta = this.enableHmr ? extractHmrMetatadata(node, this.reflector, this.evaluator, this.compilerHost, this.rootDirs, def, fac, defer, classMetadata, debugInfo) : null;
  14750. const hmrInitializer = hmrMeta ? compileHmrInitializer(hmrMeta).toStmt() : null;
  14751. const deferrableImports = this.canDeferDeps ? this.deferredSymbolTracker.getDeferrableImportDecls() : null;
  14752. return compileResults(fac, def, classMetadata, "\u0275cmp", inputTransformFields, deferrableImports, debugInfo, hmrInitializer);
  14753. }
  14754. compileHmrUpdateDeclaration(node, analysis, resolution) {
  14755. if (analysis.template.errors !== null && analysis.template.errors.length > 0) {
  14756. return null;
  14757. }
  14758. const pool = new ConstantPool2();
  14759. const defer = this.compileDeferBlocks(resolution);
  14760. const meta = {
  14761. ...analysis.meta,
  14762. ...resolution,
  14763. defer
  14764. };
  14765. const fac = compileNgFactoryDefField(toFactoryMetadata(meta, FactoryTarget3.Component));
  14766. const def = compileComponentFromMetadata(meta, pool, makeBindingParser2());
  14767. const classMetadata = analysis.classMetadata !== null ? compileComponentClassMetadata(analysis.classMetadata, null).toStmt() : null;
  14768. const debugInfo = analysis.classDebugInfo !== null ? compileClassDebugInfo(analysis.classDebugInfo).toStmt() : null;
  14769. const hmrMeta = this.enableHmr ? extractHmrMetatadata(node, this.reflector, this.evaluator, this.compilerHost, this.rootDirs, def, fac, defer, classMetadata, debugInfo) : null;
  14770. const res = compileResults(fac, def, classMetadata, "\u0275cmp", null, null, debugInfo, null);
  14771. return hmrMeta === null || res.length === 0 ? null : getHmrUpdateDeclaration(res, pool.statements, hmrMeta, node);
  14772. }
  14773. locateDeferBlocksWithoutScope(template) {
  14774. const deferBlocks = /* @__PURE__ */ new Map();
  14775. const directivelessBinder = new R3TargetBinder(new SelectorMatcher3());
  14776. const bound = directivelessBinder.bind({ template: template.nodes });
  14777. const deferredBlocks = bound.getDeferBlocks();
  14778. for (const block of deferredBlocks) {
  14779. deferBlocks.set(block, []);
  14780. }
  14781. return deferBlocks;
  14782. }
  14783. resolveAllDeferredDependencies(resolution) {
  14784. var _a;
  14785. const seenDeps = /* @__PURE__ */ new Set();
  14786. const deferrableTypes = [];
  14787. for (const [_, deps] of resolution.deferPerBlockDependencies) {
  14788. for (const deferBlockDep of deps) {
  14789. const node = deferBlockDep.declaration.node;
  14790. const importDecl = (_a = resolution.deferrableDeclToImportDecl.get(node)) != null ? _a : null;
  14791. if (importDecl !== null && this.deferredSymbolTracker.canDefer(importDecl)) {
  14792. deferBlockDep.isDeferrable = true;
  14793. deferBlockDep.importPath = importDecl.moduleSpecifier.text;
  14794. deferBlockDep.isDefaultImport = isDefaultImport(importDecl);
  14795. if (!seenDeps.has(node)) {
  14796. seenDeps.add(node);
  14797. deferrableTypes.push(deferBlockDep);
  14798. }
  14799. }
  14800. }
  14801. }
  14802. return deferrableTypes;
  14803. }
  14804. collectExplicitlyDeferredSymbols(rawDeferredImports) {
  14805. const deferredTypes = /* @__PURE__ */ new Map();
  14806. if (!ts49.isArrayLiteralExpression(rawDeferredImports)) {
  14807. return deferredTypes;
  14808. }
  14809. for (const element of rawDeferredImports.elements) {
  14810. const node = tryUnwrapForwardRef(element, this.reflector) || element;
  14811. if (!ts49.isIdentifier(node)) {
  14812. continue;
  14813. }
  14814. const imp = this.reflector.getImportOfIdentifier(node);
  14815. if (imp !== null) {
  14816. deferredTypes.set(node, imp);
  14817. }
  14818. }
  14819. return deferredTypes;
  14820. }
  14821. _checkForCyclicImport(importedFile, expr, origin) {
  14822. const imported = resolveImportedFile(this.moduleResolver, importedFile, expr, origin);
  14823. if (imported === null) {
  14824. return null;
  14825. }
  14826. return this.cycleAnalyzer.wouldCreateCycle(origin, imported);
  14827. }
  14828. maybeRecordSyntheticImport(importedFile, expr, origin) {
  14829. const imported = resolveImportedFile(this.moduleResolver, importedFile, expr, origin);
  14830. if (imported === null) {
  14831. return;
  14832. }
  14833. this.cycleAnalyzer.recordSyntheticImport(origin, imported);
  14834. }
  14835. resolveDeferBlocks(componentClassDecl, deferBlocks, deferrableDecls, resolutionData, analysisData, eagerlyUsedDecls) {
  14836. const allDeferredDecls = /* @__PURE__ */ new Set();
  14837. for (const [deferBlock, bound] of deferBlocks) {
  14838. const usedDirectives = new Set(bound.getEagerlyUsedDirectives().map((d) => d.ref.node));
  14839. const usedPipes = new Set(bound.getEagerlyUsedPipes());
  14840. let deps;
  14841. if (resolutionData.deferPerBlockDependencies.has(deferBlock)) {
  14842. deps = resolutionData.deferPerBlockDependencies.get(deferBlock);
  14843. } else {
  14844. deps = [];
  14845. resolutionData.deferPerBlockDependencies.set(deferBlock, deps);
  14846. }
  14847. for (const decl of Array.from(deferrableDecls.values())) {
  14848. if (decl.kind === R3TemplateDependencyKind.NgModule) {
  14849. continue;
  14850. }
  14851. if (decl.kind === R3TemplateDependencyKind.Directive && !usedDirectives.has(decl.ref.node)) {
  14852. continue;
  14853. }
  14854. if (decl.kind === R3TemplateDependencyKind.Pipe && !usedPipes.has(decl.name)) {
  14855. continue;
  14856. }
  14857. deps.push({
  14858. typeReference: decl.type,
  14859. symbolName: decl.ref.node.name.text,
  14860. isDeferrable: false,
  14861. importPath: null,
  14862. isDefaultImport: false,
  14863. declaration: decl.ref
  14864. });
  14865. allDeferredDecls.add(decl.ref.node);
  14866. }
  14867. }
  14868. if (analysisData.meta.isStandalone) {
  14869. if (analysisData.rawImports !== null) {
  14870. this.registerDeferrableCandidates(componentClassDecl, analysisData.rawImports, false, allDeferredDecls, eagerlyUsedDecls, resolutionData);
  14871. }
  14872. if (analysisData.rawDeferredImports !== null) {
  14873. this.registerDeferrableCandidates(componentClassDecl, analysisData.rawDeferredImports, true, allDeferredDecls, eagerlyUsedDecls, resolutionData);
  14874. }
  14875. }
  14876. }
  14877. registerDeferrableCandidates(componentClassDecl, importsExpr, isDeferredImport, allDeferredDecls, eagerlyUsedDecls, resolutionData) {
  14878. if (!ts49.isArrayLiteralExpression(importsExpr)) {
  14879. return;
  14880. }
  14881. for (const element of importsExpr.elements) {
  14882. const node = tryUnwrapForwardRef(element, this.reflector) || element;
  14883. if (!ts49.isIdentifier(node)) {
  14884. continue;
  14885. }
  14886. const imp = this.reflector.getImportOfIdentifier(node);
  14887. if (imp === null) {
  14888. continue;
  14889. }
  14890. const decl = this.reflector.getDeclarationOfIdentifier(node);
  14891. if (decl === null) {
  14892. continue;
  14893. }
  14894. if (!isNamedClassDeclaration(decl.node)) {
  14895. continue;
  14896. }
  14897. if (!allDeferredDecls.has(decl.node)) {
  14898. continue;
  14899. }
  14900. if (eagerlyUsedDecls.has(decl.node)) {
  14901. continue;
  14902. }
  14903. const dirMeta = this.metaReader.getDirectiveMetadata(new Reference(decl.node));
  14904. if (dirMeta !== null && !dirMeta.isStandalone) {
  14905. continue;
  14906. }
  14907. const pipeMeta = this.metaReader.getPipeMetadata(new Reference(decl.node));
  14908. if (pipeMeta !== null && !pipeMeta.isStandalone) {
  14909. continue;
  14910. }
  14911. if (dirMeta === null && pipeMeta === null) {
  14912. continue;
  14913. }
  14914. resolutionData.deferrableDeclToImportDecl.set(decl.node, imp.node);
  14915. this.deferredSymbolTracker.markAsDeferrableCandidate(node, imp.node, componentClassDecl, isDeferredImport);
  14916. }
  14917. }
  14918. compileDeferBlocks(resolution) {
  14919. const { deferBlockDepsEmitMode: mode, deferPerBlockDependencies: perBlockDeps, deferPerComponentDependencies: perComponentDeps } = resolution;
  14920. if (mode === 0) {
  14921. if (!perBlockDeps) {
  14922. throw new Error("Internal error: deferPerBlockDependencies must be present when compiling in PerBlock mode");
  14923. }
  14924. const blocks = /* @__PURE__ */ new Map();
  14925. for (const [block, dependencies] of perBlockDeps) {
  14926. blocks.set(block, dependencies.length === 0 ? null : compileDeferResolverFunction({ mode, dependencies }));
  14927. }
  14928. return { mode, blocks };
  14929. }
  14930. if (mode === 1) {
  14931. if (!perComponentDeps) {
  14932. throw new Error("Internal error: deferPerComponentDependencies must be present in PerComponent mode");
  14933. }
  14934. return {
  14935. mode,
  14936. dependenciesFn: perComponentDeps.length === 0 ? null : compileDeferResolverFunction({ mode, dependencies: perComponentDeps })
  14937. };
  14938. }
  14939. throw new Error(`Invalid deferBlockDepsEmitMode. Cannot compile deferred block metadata.`);
  14940. }
  14941. };
  14942. function createTargetBinder(dependencies) {
  14943. const matcher = new SelectorMatcher3();
  14944. for (const dep of dependencies) {
  14945. if (dep.kind === MetaKind.Directive && dep.selector !== null) {
  14946. matcher.addSelectables(CssSelector4.parse(dep.selector), [dep]);
  14947. }
  14948. }
  14949. return new R3TargetBinder(matcher);
  14950. }
  14951. function getExplicitlyDeferredDeps(scope) {
  14952. return scope.kind === ComponentScopeKind.NgModule ? [] : scope.deferredDependencies;
  14953. }
  14954. function extractPipes(dependencies) {
  14955. const pipes = /* @__PURE__ */ new Map();
  14956. for (const dep of dependencies) {
  14957. if (dep.kind === MetaKind.Pipe) {
  14958. pipes.set(dep.name, dep);
  14959. }
  14960. }
  14961. return pipes;
  14962. }
  14963. function removeDeferrableTypesFromComponentDecorator(analysis, deferrableTypes) {
  14964. if (analysis.classMetadata) {
  14965. const deferrableSymbols = new Set(deferrableTypes.map((t) => t.symbolName));
  14966. const rewrittenDecoratorsNode = removeIdentifierReferences(analysis.classMetadata.decorators.node, deferrableSymbols);
  14967. analysis.classMetadata.decorators = new o4.WrappedNodeExpr(rewrittenDecoratorsNode);
  14968. }
  14969. }
  14970. function validateNoImportOverlap(eagerDeps, deferredDeps, rawDeferredImports) {
  14971. let diagnostic = null;
  14972. const eagerDepsSet = /* @__PURE__ */ new Set();
  14973. for (const eagerDep of eagerDeps) {
  14974. eagerDepsSet.add(eagerDep.ref.node);
  14975. }
  14976. for (const deferredDep of deferredDeps) {
  14977. if (eagerDepsSet.has(deferredDep.ref.node)) {
  14978. const classInfo = deferredDep.ref.debugName ? `The \`${deferredDep.ref.debugName}\`` : "One of the dependencies";
  14979. diagnostic = makeDiagnostic(ErrorCode.DEFERRED_DEPENDENCY_IMPORTED_EAGERLY, getDiagnosticNode(deferredDep.ref, rawDeferredImports), `\`${classInfo}\` is imported via both \`@Component.imports\` and \`@Component.deferredImports\`. To fix this, make sure that dependencies are imported only once.`);
  14980. break;
  14981. }
  14982. }
  14983. return diagnostic;
  14984. }
  14985. function validateStandaloneImports(importRefs, importExpr, metaReader, scopeReader, isDeferredImport) {
  14986. const diagnostics = [];
  14987. for (const ref of importRefs) {
  14988. const dirMeta = metaReader.getDirectiveMetadata(ref);
  14989. if (dirMeta !== null) {
  14990. if (!dirMeta.isStandalone) {
  14991. diagnostics.push(makeNotStandaloneDiagnostic(scopeReader, ref, importExpr, dirMeta.isComponent ? "component" : "directive"));
  14992. }
  14993. continue;
  14994. }
  14995. const pipeMeta = metaReader.getPipeMetadata(ref);
  14996. if (pipeMeta !== null) {
  14997. if (!pipeMeta.isStandalone) {
  14998. diagnostics.push(makeNotStandaloneDiagnostic(scopeReader, ref, importExpr, "pipe"));
  14999. }
  15000. continue;
  15001. }
  15002. const ngModuleMeta = metaReader.getNgModuleMetadata(ref);
  15003. if (!isDeferredImport && ngModuleMeta !== null) {
  15004. continue;
  15005. }
  15006. const error = isDeferredImport ? makeUnknownComponentDeferredImportDiagnostic(ref, importExpr) : makeUnknownComponentImportDiagnostic(ref, importExpr);
  15007. diagnostics.push(error);
  15008. }
  15009. return diagnostics;
  15010. }
  15011. function isDefaultImport(node) {
  15012. return node.importClause !== void 0 && node.importClause.namedBindings === void 0;
  15013. }
  15014. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/src/injectable.mjs
  15015. import { compileClassMetadata as compileClassMetadata3, compileDeclareClassMetadata as compileDeclareClassMetadata3, compileDeclareInjectableFromMetadata, compileInjectable, createMayBeForwardRefExpression as createMayBeForwardRefExpression3, FactoryTarget as FactoryTarget4, LiteralExpr as LiteralExpr3, WrappedNodeExpr as WrappedNodeExpr10 } from "@angular/compiler";
  15016. import ts50 from "typescript";
  15017. var InjectableDecoratorHandler = class {
  15018. reflector;
  15019. evaluator;
  15020. isCore;
  15021. strictCtorDeps;
  15022. injectableRegistry;
  15023. perf;
  15024. includeClassMetadata;
  15025. compilationMode;
  15026. errorOnDuplicateProv;
  15027. constructor(reflector, evaluator, isCore, strictCtorDeps, injectableRegistry, perf, includeClassMetadata, compilationMode, errorOnDuplicateProv = true) {
  15028. this.reflector = reflector;
  15029. this.evaluator = evaluator;
  15030. this.isCore = isCore;
  15031. this.strictCtorDeps = strictCtorDeps;
  15032. this.injectableRegistry = injectableRegistry;
  15033. this.perf = perf;
  15034. this.includeClassMetadata = includeClassMetadata;
  15035. this.compilationMode = compilationMode;
  15036. this.errorOnDuplicateProv = errorOnDuplicateProv;
  15037. }
  15038. precedence = HandlerPrecedence.SHARED;
  15039. name = "InjectableDecoratorHandler";
  15040. detect(node, decorators) {
  15041. if (!decorators) {
  15042. return void 0;
  15043. }
  15044. const decorator = findAngularDecorator(decorators, "Injectable", this.isCore);
  15045. if (decorator !== void 0) {
  15046. return {
  15047. trigger: decorator.node,
  15048. decorator,
  15049. metadata: decorator
  15050. };
  15051. } else {
  15052. return void 0;
  15053. }
  15054. }
  15055. analyze(node, decorator) {
  15056. this.perf.eventCount(PerfEvent.AnalyzeInjectable);
  15057. const meta = extractInjectableMetadata(node, decorator, this.reflector);
  15058. const decorators = this.reflector.getDecoratorsOfDeclaration(node);
  15059. return {
  15060. analysis: {
  15061. meta,
  15062. ctorDeps: extractInjectableCtorDeps(node, meta, decorator, this.reflector, this.isCore, this.strictCtorDeps),
  15063. classMetadata: this.includeClassMetadata ? extractClassMetadata(node, this.reflector, this.isCore) : null,
  15064. needsFactory: !decorators || decorators.every((current) => !isAngularCore(current) || current.name === "Injectable")
  15065. }
  15066. };
  15067. }
  15068. symbol() {
  15069. return null;
  15070. }
  15071. register(node, analysis) {
  15072. if (this.compilationMode === CompilationMode.LOCAL) {
  15073. return;
  15074. }
  15075. this.injectableRegistry.registerInjectable(node, {
  15076. ctorDeps: analysis.ctorDeps
  15077. });
  15078. }
  15079. resolve(node, analysis) {
  15080. if (this.compilationMode === CompilationMode.LOCAL) {
  15081. return {};
  15082. }
  15083. if (requiresValidCtor(analysis.meta)) {
  15084. const diagnostic = checkInheritanceOfInjectable(node, this.injectableRegistry, this.reflector, this.evaluator, this.strictCtorDeps, "Injectable");
  15085. if (diagnostic !== null) {
  15086. return {
  15087. diagnostics: [diagnostic]
  15088. };
  15089. }
  15090. }
  15091. return {};
  15092. }
  15093. compileFull(node, analysis) {
  15094. return this.compile(compileNgFactoryDefField, (meta) => compileInjectable(meta, false), compileClassMetadata3, node, analysis);
  15095. }
  15096. compilePartial(node, analysis) {
  15097. return this.compile(compileDeclareFactory, compileDeclareInjectableFromMetadata, compileDeclareClassMetadata3, node, analysis);
  15098. }
  15099. compileLocal(node, analysis) {
  15100. return this.compile(compileNgFactoryDefField, (meta) => compileInjectable(meta, false), compileClassMetadata3, node, analysis);
  15101. }
  15102. compile(compileFactoryFn, compileInjectableFn, compileClassMetadataFn, node, analysis) {
  15103. const results = [];
  15104. if (analysis.needsFactory) {
  15105. const meta = analysis.meta;
  15106. const factoryRes = compileFactoryFn(toFactoryMetadata({ ...meta, deps: analysis.ctorDeps }, FactoryTarget4.Injectable));
  15107. if (analysis.classMetadata !== null) {
  15108. factoryRes.statements.push(compileClassMetadataFn(analysis.classMetadata).toStmt());
  15109. }
  15110. results.push(factoryRes);
  15111. }
  15112. const \u0275prov = this.reflector.getMembersOfClass(node).find((member) => member.name === "\u0275prov");
  15113. if (\u0275prov !== void 0 && this.errorOnDuplicateProv) {
  15114. throw new FatalDiagnosticError(ErrorCode.INJECTABLE_DUPLICATE_PROV, \u0275prov.nameNode || \u0275prov.node || node, "Injectables cannot contain a static \u0275prov property, because the compiler is going to generate one.");
  15115. }
  15116. if (\u0275prov === void 0) {
  15117. const res = compileInjectableFn(analysis.meta);
  15118. results.push({
  15119. name: "\u0275prov",
  15120. initializer: res.expression,
  15121. statements: res.statements,
  15122. type: res.type,
  15123. deferrableImports: null
  15124. });
  15125. }
  15126. return results;
  15127. }
  15128. };
  15129. function extractInjectableMetadata(clazz, decorator, reflector) {
  15130. const name = clazz.name.text;
  15131. const type = wrapTypeReference(reflector, clazz);
  15132. const typeArgumentCount = reflector.getGenericArityOfClass(clazz) || 0;
  15133. if (decorator.args === null) {
  15134. throw new FatalDiagnosticError(ErrorCode.DECORATOR_NOT_CALLED, decorator.node, "@Injectable must be called");
  15135. }
  15136. if (decorator.args.length === 0) {
  15137. return {
  15138. name,
  15139. type,
  15140. typeArgumentCount,
  15141. providedIn: createMayBeForwardRefExpression3(new LiteralExpr3(null), 0)
  15142. };
  15143. } else if (decorator.args.length === 1) {
  15144. const metaNode = decorator.args[0];
  15145. if (!ts50.isObjectLiteralExpression(metaNode)) {
  15146. throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARG_NOT_LITERAL, metaNode, `@Injectable argument must be an object literal`);
  15147. }
  15148. const meta = reflectObjectLiteral(metaNode);
  15149. const providedIn = meta.has("providedIn") ? getProviderExpression(meta.get("providedIn"), reflector) : createMayBeForwardRefExpression3(new LiteralExpr3(null), 0);
  15150. let deps = void 0;
  15151. if ((meta.has("useClass") || meta.has("useFactory")) && meta.has("deps")) {
  15152. const depsExpr = meta.get("deps");
  15153. if (!ts50.isArrayLiteralExpression(depsExpr)) {
  15154. throw new FatalDiagnosticError(ErrorCode.VALUE_NOT_LITERAL, depsExpr, `@Injectable deps metadata must be an inline array`);
  15155. }
  15156. deps = depsExpr.elements.map((dep) => getDep(dep, reflector));
  15157. }
  15158. const result = { name, type, typeArgumentCount, providedIn };
  15159. if (meta.has("useValue")) {
  15160. result.useValue = getProviderExpression(meta.get("useValue"), reflector);
  15161. } else if (meta.has("useExisting")) {
  15162. result.useExisting = getProviderExpression(meta.get("useExisting"), reflector);
  15163. } else if (meta.has("useClass")) {
  15164. result.useClass = getProviderExpression(meta.get("useClass"), reflector);
  15165. result.deps = deps;
  15166. } else if (meta.has("useFactory")) {
  15167. result.useFactory = new WrappedNodeExpr10(meta.get("useFactory"));
  15168. result.deps = deps;
  15169. }
  15170. return result;
  15171. } else {
  15172. throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARITY_WRONG, decorator.args[2], "Too many arguments to @Injectable");
  15173. }
  15174. }
  15175. function getProviderExpression(expression, reflector) {
  15176. const forwardRefValue = tryUnwrapForwardRef(expression, reflector);
  15177. return createMayBeForwardRefExpression3(new WrappedNodeExpr10(forwardRefValue != null ? forwardRefValue : expression), forwardRefValue !== null ? 2 : 0);
  15178. }
  15179. function extractInjectableCtorDeps(clazz, meta, decorator, reflector, isCore, strictCtorDeps) {
  15180. if (decorator.args === null) {
  15181. throw new FatalDiagnosticError(ErrorCode.DECORATOR_NOT_CALLED, decorator.node, "@Injectable must be called");
  15182. }
  15183. let ctorDeps = null;
  15184. if (decorator.args.length === 0) {
  15185. if (strictCtorDeps && !isAbstractClassDeclaration(clazz)) {
  15186. ctorDeps = getValidConstructorDependencies(clazz, reflector, isCore);
  15187. } else {
  15188. ctorDeps = unwrapConstructorDependencies(getConstructorDependencies(clazz, reflector, isCore));
  15189. }
  15190. return ctorDeps;
  15191. } else if (decorator.args.length === 1) {
  15192. const rawCtorDeps = getConstructorDependencies(clazz, reflector, isCore);
  15193. if (strictCtorDeps && !isAbstractClassDeclaration(clazz) && requiresValidCtor(meta)) {
  15194. ctorDeps = validateConstructorDependencies(clazz, rawCtorDeps);
  15195. } else {
  15196. ctorDeps = unwrapConstructorDependencies(rawCtorDeps);
  15197. }
  15198. }
  15199. return ctorDeps;
  15200. }
  15201. function requiresValidCtor(meta) {
  15202. return meta.useValue === void 0 && meta.useExisting === void 0 && meta.useClass === void 0 && meta.useFactory === void 0;
  15203. }
  15204. function getDep(dep, reflector) {
  15205. const meta = {
  15206. token: new WrappedNodeExpr10(dep),
  15207. attributeNameType: null,
  15208. host: false,
  15209. optional: false,
  15210. self: false,
  15211. skipSelf: false
  15212. };
  15213. function maybeUpdateDecorator(dec, reflector2, token) {
  15214. const source = reflector2.getImportOfIdentifier(dec);
  15215. if (source === null || source.from !== "@angular/core") {
  15216. return false;
  15217. }
  15218. switch (source.name) {
  15219. case "Inject":
  15220. if (token !== void 0) {
  15221. meta.token = new WrappedNodeExpr10(token);
  15222. }
  15223. break;
  15224. case "Optional":
  15225. meta.optional = true;
  15226. break;
  15227. case "SkipSelf":
  15228. meta.skipSelf = true;
  15229. break;
  15230. case "Self":
  15231. meta.self = true;
  15232. break;
  15233. default:
  15234. return false;
  15235. }
  15236. return true;
  15237. }
  15238. if (ts50.isArrayLiteralExpression(dep)) {
  15239. dep.elements.forEach((el) => {
  15240. let isDecorator = false;
  15241. if (ts50.isIdentifier(el)) {
  15242. isDecorator = maybeUpdateDecorator(el, reflector);
  15243. } else if (ts50.isNewExpression(el) && ts50.isIdentifier(el.expression)) {
  15244. const token = el.arguments && el.arguments.length > 0 && el.arguments[0] || void 0;
  15245. isDecorator = maybeUpdateDecorator(el.expression, reflector, token);
  15246. }
  15247. if (!isDecorator) {
  15248. meta.token = new WrappedNodeExpr10(el);
  15249. }
  15250. });
  15251. }
  15252. return meta;
  15253. }
  15254. // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler-cli/src/ngtsc/annotations/src/pipe.mjs
  15255. import { compileClassMetadata as compileClassMetadata4, compileDeclareClassMetadata as compileDeclareClassMetadata4, compileDeclarePipeFromMetadata, compilePipeFromMetadata, FactoryTarget as FactoryTarget5 } from "@angular/compiler";
  15256. import ts51 from "typescript";
  15257. var PipeSymbol = class extends SemanticSymbol {
  15258. name;
  15259. constructor(decl, name) {
  15260. super(decl);
  15261. this.name = name;
  15262. }
  15263. isPublicApiAffected(previousSymbol) {
  15264. if (!(previousSymbol instanceof PipeSymbol)) {
  15265. return true;
  15266. }
  15267. return this.name !== previousSymbol.name;
  15268. }
  15269. isTypeCheckApiAffected(previousSymbol) {
  15270. return this.isPublicApiAffected(previousSymbol);
  15271. }
  15272. };
  15273. var PipeDecoratorHandler = class {
  15274. reflector;
  15275. evaluator;
  15276. metaRegistry;
  15277. scopeRegistry;
  15278. injectableRegistry;
  15279. isCore;
  15280. perf;
  15281. includeClassMetadata;
  15282. compilationMode;
  15283. generateExtraImportsInLocalMode;
  15284. strictStandalone;
  15285. implicitStandaloneValue;
  15286. constructor(reflector, evaluator, metaRegistry, scopeRegistry, injectableRegistry, isCore, perf, includeClassMetadata, compilationMode, generateExtraImportsInLocalMode, strictStandalone, implicitStandaloneValue) {
  15287. this.reflector = reflector;
  15288. this.evaluator = evaluator;
  15289. this.metaRegistry = metaRegistry;
  15290. this.scopeRegistry = scopeRegistry;
  15291. this.injectableRegistry = injectableRegistry;
  15292. this.isCore = isCore;
  15293. this.perf = perf;
  15294. this.includeClassMetadata = includeClassMetadata;
  15295. this.compilationMode = compilationMode;
  15296. this.generateExtraImportsInLocalMode = generateExtraImportsInLocalMode;
  15297. this.strictStandalone = strictStandalone;
  15298. this.implicitStandaloneValue = implicitStandaloneValue;
  15299. }
  15300. precedence = HandlerPrecedence.PRIMARY;
  15301. name = "PipeDecoratorHandler";
  15302. detect(node, decorators) {
  15303. if (!decorators) {
  15304. return void 0;
  15305. }
  15306. const decorator = findAngularDecorator(decorators, "Pipe", this.isCore);
  15307. if (decorator !== void 0) {
  15308. return {
  15309. trigger: decorator.node,
  15310. decorator,
  15311. metadata: decorator
  15312. };
  15313. } else {
  15314. return void 0;
  15315. }
  15316. }
  15317. analyze(clazz, decorator) {
  15318. var _a;
  15319. this.perf.eventCount(PerfEvent.AnalyzePipe);
  15320. const name = clazz.name.text;
  15321. const type = wrapTypeReference(this.reflector, clazz);
  15322. if (decorator.args === null) {
  15323. throw new FatalDiagnosticError(ErrorCode.DECORATOR_NOT_CALLED, decorator.node, `@Pipe must be called`);
  15324. }
  15325. if (decorator.args.length !== 1) {
  15326. throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARITY_WRONG, decorator.node, "@Pipe must have exactly one argument");
  15327. }
  15328. const meta = unwrapExpression(decorator.args[0]);
  15329. if (!ts51.isObjectLiteralExpression(meta)) {
  15330. throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARG_NOT_LITERAL, meta, "@Pipe must have a literal argument");
  15331. }
  15332. const pipe = reflectObjectLiteral(meta);
  15333. if (!pipe.has("name")) {
  15334. throw new FatalDiagnosticError(ErrorCode.PIPE_MISSING_NAME, meta, `@Pipe decorator is missing name field`);
  15335. }
  15336. const pipeNameExpr = pipe.get("name");
  15337. const pipeName = this.evaluator.evaluate(pipeNameExpr);
  15338. if (typeof pipeName !== "string") {
  15339. throw createValueHasWrongTypeError(pipeNameExpr, pipeName, `@Pipe.name must be a string`);
  15340. }
  15341. let pure = true;
  15342. if (pipe.has("pure")) {
  15343. const expr = pipe.get("pure");
  15344. const pureValue = this.evaluator.evaluate(expr);
  15345. if (typeof pureValue !== "boolean") {
  15346. throw createValueHasWrongTypeError(expr, pureValue, `@Pipe.pure must be a boolean`);
  15347. }
  15348. pure = pureValue;
  15349. }
  15350. let isStandalone = this.implicitStandaloneValue;
  15351. if (pipe.has("standalone")) {
  15352. const expr = pipe.get("standalone");
  15353. const resolved = this.evaluator.evaluate(expr);
  15354. if (typeof resolved !== "boolean") {
  15355. throw createValueHasWrongTypeError(expr, resolved, `standalone flag must be a boolean`);
  15356. }
  15357. isStandalone = resolved;
  15358. if (!isStandalone && this.strictStandalone) {
  15359. throw new FatalDiagnosticError(ErrorCode.NON_STANDALONE_NOT_ALLOWED, expr, `Only standalone pipes are allowed when 'strictStandalone' is enabled.`);
  15360. }
  15361. }
  15362. return {
  15363. analysis: {
  15364. meta: {
  15365. name,
  15366. type,
  15367. typeArgumentCount: this.reflector.getGenericArityOfClass(clazz) || 0,
  15368. pipeName,
  15369. deps: getValidConstructorDependencies(clazz, this.reflector, this.isCore),
  15370. pure,
  15371. isStandalone
  15372. },
  15373. classMetadata: this.includeClassMetadata ? extractClassMetadata(clazz, this.reflector, this.isCore) : null,
  15374. pipeNameExpr,
  15375. decorator: (_a = decorator == null ? void 0 : decorator.node) != null ? _a : null
  15376. }
  15377. };
  15378. }
  15379. symbol(node, analysis) {
  15380. return new PipeSymbol(node, analysis.meta.pipeName);
  15381. }
  15382. register(node, analysis) {
  15383. const ref = new Reference(node);
  15384. this.metaRegistry.registerPipeMetadata({
  15385. kind: MetaKind.Pipe,
  15386. ref,
  15387. name: analysis.meta.pipeName,
  15388. nameExpr: analysis.pipeNameExpr,
  15389. isStandalone: analysis.meta.isStandalone,
  15390. decorator: analysis.decorator,
  15391. isExplicitlyDeferred: false
  15392. });
  15393. this.injectableRegistry.registerInjectable(node, {
  15394. ctorDeps: analysis.meta.deps
  15395. });
  15396. }
  15397. resolve(node) {
  15398. if (this.compilationMode === CompilationMode.LOCAL) {
  15399. return {};
  15400. }
  15401. const duplicateDeclData = this.scopeRegistry.getDuplicateDeclarations(node);
  15402. if (duplicateDeclData !== null) {
  15403. return {
  15404. diagnostics: [makeDuplicateDeclarationError(node, duplicateDeclData, "Pipe")]
  15405. };
  15406. }
  15407. return {};
  15408. }
  15409. compileFull(node, analysis) {
  15410. const fac = compileNgFactoryDefField(toFactoryMetadata(analysis.meta, FactoryTarget5.Pipe));
  15411. const def = compilePipeFromMetadata(analysis.meta);
  15412. const classMetadata = analysis.classMetadata !== null ? compileClassMetadata4(analysis.classMetadata).toStmt() : null;
  15413. return compileResults(fac, def, classMetadata, "\u0275pipe", null, null);
  15414. }
  15415. compilePartial(node, analysis) {
  15416. const fac = compileDeclareFactory(toFactoryMetadata(analysis.meta, FactoryTarget5.Pipe));
  15417. const def = compileDeclarePipeFromMetadata(analysis.meta);
  15418. const classMetadata = analysis.classMetadata !== null ? compileDeclareClassMetadata4(analysis.classMetadata).toStmt() : null;
  15419. return compileResults(fac, def, classMetadata, "\u0275pipe", null, null);
  15420. }
  15421. compileLocal(node, analysis) {
  15422. const fac = compileNgFactoryDefField(toFactoryMetadata(analysis.meta, FactoryTarget5.Pipe));
  15423. const def = compilePipeFromMetadata(analysis.meta);
  15424. const classMetadata = analysis.classMetadata !== null ? compileClassMetadata4(analysis.classMetadata).toStmt() : null;
  15425. return compileResults(fac, def, classMetadata, "\u0275pipe", null, null);
  15426. }
  15427. };
  15428. export {
  15429. isAngularDecorator,
  15430. getAngularDecorators,
  15431. createForwardRefResolver,
  15432. MetaKind,
  15433. CompoundMetadataReader,
  15434. DtsMetadataReader,
  15435. LocalMetadataRegistry,
  15436. CompoundMetadataRegistry,
  15437. ResourceRegistry,
  15438. ExportedProviderStatusResolver,
  15439. HostDirectivesResolver,
  15440. DynamicValue,
  15441. StaticInterpreter,
  15442. PartialEvaluator,
  15443. CompilationMode,
  15444. aliasTransformFactory,
  15445. TraitCompiler,
  15446. DtsTransformRegistry,
  15447. declarationTransformFactory,
  15448. ivyTransformFactory,
  15449. InjectableClassRegistry,
  15450. NoopReferencesRegistry,
  15451. JitDeclarationRegistry,
  15452. SemanticDepGraphUpdater,
  15453. ComponentScopeKind,
  15454. CompoundComponentScopeReader,
  15455. MetadataDtsModuleScopeResolver,
  15456. LocalModuleScopeRegistry,
  15457. TypeCheckScopeRegistry,
  15458. tryParseInitializerApi,
  15459. INPUT_INITIALIZER_FN,
  15460. tryParseSignalInputMapping,
  15461. MODEL_INITIALIZER_FN,
  15462. tryParseSignalModelMapping,
  15463. OUTPUT_INITIALIZER_FNS,
  15464. tryParseInitializerBasedOutput,
  15465. QUERY_INITIALIZER_FNS,
  15466. tryParseSignalQueryFromInitializer,
  15467. queryDecoratorNames,
  15468. DirectiveDecoratorHandler,
  15469. NgModuleDecoratorHandler,
  15470. NgOriginalFile,
  15471. isShim,
  15472. untagAllTsFiles,
  15473. retagAllTsFiles,
  15474. ShimAdapter,
  15475. ShimReferenceTagger,
  15476. TsCreateProgramDriver,
  15477. OptimizeFor,
  15478. PotentialImportKind,
  15479. PotentialImportMode,
  15480. SymbolKind,
  15481. TypeCheckShimGenerator,
  15482. TemplateTypeCheckerImpl,
  15483. ComponentDecoratorHandler,
  15484. InjectableDecoratorHandler,
  15485. PipeDecoratorHandler
  15486. };
  15487. /*!
  15488. * @license
  15489. * Copyright Google LLC All Rights Reserved.
  15490. *
  15491. * Use of this source code is governed by an MIT-style license that can be
  15492. * found in the LICENSE file at https://angular.dev/license
  15493. */
  15494. /**
  15495. * @license
  15496. * Copyright Google LLC All Rights Reserved.
  15497. *
  15498. * Use of this source code is governed by an MIT-style license that can be
  15499. * found in the LICENSE file at https://angular.dev/license
  15500. */
  15501. //# sourceMappingURL=chunk-YNWO773W.js.map