common.js 258 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647
  1. /**
  2. * @license Angular v8.1.0
  3. * (c) 2010-2019 Google LLC. https://angular.io/
  4. * License: MIT
  5. */
  6. import { InjectionToken, Injectable, EventEmitter, Optional, Inject, ɵfindLocaleData, ɵLocaleDataIndex, ɵgetLocalePluralCase, LOCALE_ID, ɵLOCALE_DATA, ɵisListLikeIterable, ɵstringify, IterableDiffers, KeyValueDiffers, ElementRef, Renderer2, ɵɵdefineDirective, Input, Directive, ɵɵstyling, ɵɵclassMap, ɵɵstylingApply, NgModuleRef, ComponentFactoryResolver, Type, Injector, NgModuleFactory, ViewContainerRef, isDevMode, TemplateRef, Host, Attribute, ɵɵstyleMap, Pipe, ɵlooseIdentical, WrappedValue, ɵisPromise, ɵisObservable, ChangeDetectorRef, NgModule, Version, ɵɵdefineInjectable, ɵɵinject, ErrorHandler } from '@angular/core';
  7. import { __decorate, __metadata, __extends, __param, __read, __values, __assign } from 'tslib';
  8. /**
  9. * @license
  10. * Copyright Google Inc. All Rights Reserved.
  11. *
  12. * Use of this source code is governed by an MIT-style license that can be
  13. * found in the LICENSE file at https://angular.io/license
  14. */
  15. /**
  16. * This class should not be used directly by an application developer. Instead, use
  17. * {@link Location}.
  18. *
  19. * `PlatformLocation` encapsulates all calls to DOM apis, which allows the Router to be platform
  20. * agnostic.
  21. * This means that we can have different implementation of `PlatformLocation` for the different
  22. * platforms that angular supports. For example, `@angular/platform-browser` provides an
  23. * implementation specific to the browser environment, while `@angular/platform-webworker` provides
  24. * one suitable for use with web workers.
  25. *
  26. * The `PlatformLocation` class is used directly by all implementations of {@link LocationStrategy}
  27. * when they need to interact with the DOM apis like pushState, popState, etc...
  28. *
  29. * {@link LocationStrategy} in turn is used by the {@link Location} service which is used directly
  30. * by the {@link Router} in order to navigate between routes. Since all interactions between {@link
  31. * Router} /
  32. * {@link Location} / {@link LocationStrategy} and DOM apis flow through the `PlatformLocation`
  33. * class they are all platform independent.
  34. *
  35. * @publicApi
  36. */
  37. var PlatformLocation = /** @class */ (function () {
  38. function PlatformLocation() {
  39. }
  40. return PlatformLocation;
  41. }());
  42. /**
  43. * @description
  44. * Indicates when a location is initialized.
  45. *
  46. * @publicApi
  47. */
  48. var LOCATION_INITIALIZED = new InjectionToken('Location Initialized');
  49. /**
  50. * @license
  51. * Copyright Google Inc. All Rights Reserved.
  52. *
  53. * Use of this source code is governed by an MIT-style license that can be
  54. * found in the LICENSE file at https://angular.io/license
  55. */
  56. /**
  57. * Enables the `Location` service to read route state from the browser's URL.
  58. * Angular provides two strategies:
  59. * `HashLocationStrategy` and `PathLocationStrategy`.
  60. *
  61. * Applications should use the `Router` or `Location` services to
  62. * interact with application route state.
  63. *
  64. * For instance, `HashLocationStrategy` produces URLs like
  65. * <code class="no-auto-link">http://example.com#/foo</code>,
  66. * and `PathLocationStrategy` produces
  67. * <code class="no-auto-link">http://example.com/foo</code> as an equivalent URL.
  68. *
  69. * See these two classes for more.
  70. *
  71. * @publicApi
  72. */
  73. var LocationStrategy = /** @class */ (function () {
  74. function LocationStrategy() {
  75. }
  76. return LocationStrategy;
  77. }());
  78. /**
  79. * A predefined [DI token](guide/glossary#di-token) for the base href
  80. * to be used with the `PathLocationStrategy`.
  81. * The base href is the URL prefix that should be preserved when generating
  82. * and recognizing URLs.
  83. *
  84. * @usageNotes
  85. *
  86. * The following example shows how to use this token to configure the root app injector
  87. * with a base href value, so that the DI framework can supply the dependency anywhere in the app.
  88. *
  89. * ```typescript
  90. * import {Component, NgModule} from '@angular/core';
  91. * import {APP_BASE_HREF} from '@angular/common';
  92. *
  93. * @NgModule({
  94. * providers: [{provide: APP_BASE_HREF, useValue: '/my/app'}]
  95. * })
  96. * class AppModule {}
  97. * ```
  98. *
  99. * @publicApi
  100. */
  101. var APP_BASE_HREF = new InjectionToken('appBaseHref');
  102. /**
  103. * @license
  104. * Copyright Google Inc. All Rights Reserved.
  105. *
  106. * Use of this source code is governed by an MIT-style license that can be
  107. * found in the LICENSE file at https://angular.io/license
  108. */
  109. /**
  110. * @description
  111. *
  112. * A service that applications can use to interact with a browser's URL.
  113. *
  114. * Depending on the `LocationStrategy` used, `Location` will either persist
  115. * to the URL's path or the URL's hash segment.
  116. *
  117. * @usageNotes
  118. *
  119. * It's better to use the {@link Router#navigate} service to trigger route changes. Use
  120. * `Location` only if you need to interact with or create normalized URLs outside of
  121. * routing.
  122. *
  123. * `Location` is responsible for normalizing the URL against the application's base href.
  124. * A normalized URL is absolute from the URL host, includes the application's base href, and has no
  125. * trailing slash:
  126. * - `/my/app/user/123` is normalized
  127. * - `my/app/user/123` **is not** normalized
  128. * - `/my/app/user/123/` **is not** normalized
  129. *
  130. * ### Example
  131. *
  132. * <code-example path='common/location/ts/path_location_component.ts'
  133. * region='LocationComponent'></code-example>
  134. *
  135. * @publicApi
  136. */
  137. var Location = /** @class */ (function () {
  138. function Location(platformStrategy, platformLocation) {
  139. var _this = this;
  140. /** @internal */
  141. this._subject = new EventEmitter();
  142. /** @internal */
  143. this._urlChangeListeners = [];
  144. this._platformStrategy = platformStrategy;
  145. var browserBaseHref = this._platformStrategy.getBaseHref();
  146. this._platformLocation = platformLocation;
  147. this._baseHref = Location_1.stripTrailingSlash(_stripIndexHtml(browserBaseHref));
  148. this._platformStrategy.onPopState(function (ev) {
  149. _this._subject.emit({
  150. 'url': _this.path(true),
  151. 'pop': true,
  152. 'state': ev.state,
  153. 'type': ev.type,
  154. });
  155. });
  156. }
  157. Location_1 = Location;
  158. /**
  159. * Returns the normalized URL path.
  160. *
  161. * @param includeHash Whether path has an anchor fragment.
  162. *
  163. * @returns The normalized URL path.
  164. */
  165. // TODO: vsavkin. Remove the boolean flag and always include hash once the deprecated router is
  166. // removed.
  167. Location.prototype.path = function (includeHash) {
  168. if (includeHash === void 0) { includeHash = false; }
  169. return this.normalize(this._platformStrategy.path(includeHash));
  170. };
  171. /**
  172. * Returns the current value of the history.state object.
  173. */
  174. Location.prototype.getState = function () { return this._platformLocation.getState(); };
  175. /**
  176. * Normalizes the given path and compares to the current normalized path.
  177. *
  178. * @param path The given URL path
  179. * @param query Query parameters
  180. *
  181. * @returns `true` if the given URL path is equal to the current normalized path, `false`
  182. * otherwise.
  183. */
  184. Location.prototype.isCurrentPathEqualTo = function (path, query) {
  185. if (query === void 0) { query = ''; }
  186. return this.path() == this.normalize(path + Location_1.normalizeQueryParams(query));
  187. };
  188. /**
  189. * Given a string representing a URL, returns the URL path after stripping the
  190. * trailing slashes.
  191. *
  192. * @param url String representing a URL.
  193. *
  194. * @returns Normalized URL string.
  195. */
  196. Location.prototype.normalize = function (url) {
  197. return Location_1.stripTrailingSlash(_stripBaseHref(this._baseHref, _stripIndexHtml(url)));
  198. };
  199. /**
  200. * Given a string representing a URL, returns the platform-specific external URL path.
  201. * If the given URL doesn't begin with a leading slash (`'/'`), this method adds one
  202. * before normalizing. This method also adds a hash if `HashLocationStrategy` is
  203. * used, or the `APP_BASE_HREF` if the `PathLocationStrategy` is in use.
  204. *
  205. *
  206. * @param url String representing a URL.
  207. *
  208. * @returns A normalized platform-specific URL.
  209. */
  210. Location.prototype.prepareExternalUrl = function (url) {
  211. if (url && url[0] !== '/') {
  212. url = '/' + url;
  213. }
  214. return this._platformStrategy.prepareExternalUrl(url);
  215. };
  216. // TODO: rename this method to pushState
  217. /**
  218. * Changes the browsers URL to a normalized version of the given URL, and pushes a
  219. * new item onto the platform's history.
  220. *
  221. * @param path URL path to normalizze
  222. * @param query Query parameters
  223. * @param state Location history state
  224. *
  225. */
  226. Location.prototype.go = function (path, query, state) {
  227. if (query === void 0) { query = ''; }
  228. if (state === void 0) { state = null; }
  229. this._platformStrategy.pushState(state, '', path, query);
  230. this._notifyUrlChangeListeners(this.prepareExternalUrl(path + Location_1.normalizeQueryParams(query)), state);
  231. };
  232. /**
  233. * Changes the browser's URL to a normalized version of the given URL, and replaces
  234. * the top item on the platform's history stack.
  235. *
  236. * @param path URL path to normalizze
  237. * @param query Query parameters
  238. * @param state Location history state
  239. */
  240. Location.prototype.replaceState = function (path, query, state) {
  241. if (query === void 0) { query = ''; }
  242. if (state === void 0) { state = null; }
  243. this._platformStrategy.replaceState(state, '', path, query);
  244. this._notifyUrlChangeListeners(this.prepareExternalUrl(path + Location_1.normalizeQueryParams(query)), state);
  245. };
  246. /**
  247. * Navigates forward in the platform's history.
  248. */
  249. Location.prototype.forward = function () { this._platformStrategy.forward(); };
  250. /**
  251. * Navigates back in the platform's history.
  252. */
  253. Location.prototype.back = function () { this._platformStrategy.back(); };
  254. /**
  255. * Register URL change listeners. This API can be used to catch updates performed by the Angular
  256. * framework. These are not detectible through "popstate" or "hashchange" events.
  257. */
  258. Location.prototype.onUrlChange = function (fn) {
  259. var _this = this;
  260. this._urlChangeListeners.push(fn);
  261. this.subscribe(function (v) { _this._notifyUrlChangeListeners(v.url, v.state); });
  262. };
  263. /** @internal */
  264. Location.prototype._notifyUrlChangeListeners = function (url, state) {
  265. if (url === void 0) { url = ''; }
  266. this._urlChangeListeners.forEach(function (fn) { return fn(url, state); });
  267. };
  268. /**
  269. * Subscribe to the platform's `popState` events.
  270. *
  271. * @param value Event that is triggered when the state history changes.
  272. * @param exception The exception to throw.
  273. *
  274. * @returns Subscribed events.
  275. */
  276. Location.prototype.subscribe = function (onNext, onThrow, onReturn) {
  277. return this._subject.subscribe({ next: onNext, error: onThrow, complete: onReturn });
  278. };
  279. /**
  280. * Given a string of url parameters, prepend with `?` if needed, otherwise return the
  281. * parameters as is.
  282. *
  283. * @param params String of URL parameters
  284. *
  285. * @returns URL parameters prepended with `?` or the parameters as is.
  286. */
  287. Location.normalizeQueryParams = function (params) {
  288. return params && params[0] !== '?' ? '?' + params : params;
  289. };
  290. /**
  291. * Given 2 parts of a URL, join them with a slash if needed.
  292. *
  293. * @param start URL string
  294. * @param end URL string
  295. *
  296. *
  297. * @returns Given URL strings joined with a slash, if needed.
  298. */
  299. Location.joinWithSlash = function (start, end) {
  300. if (start.length == 0) {
  301. return end;
  302. }
  303. if (end.length == 0) {
  304. return start;
  305. }
  306. var slashes = 0;
  307. if (start.endsWith('/')) {
  308. slashes++;
  309. }
  310. if (end.startsWith('/')) {
  311. slashes++;
  312. }
  313. if (slashes == 2) {
  314. return start + end.substring(1);
  315. }
  316. if (slashes == 1) {
  317. return start + end;
  318. }
  319. return start + '/' + end;
  320. };
  321. /**
  322. * If URL has a trailing slash, remove it, otherwise return the URL as is. The
  323. * method looks for the first occurrence of either `#`, `?`, or the end of the
  324. * line as `/` characters and removes the trailing slash if one exists.
  325. *
  326. * @param url URL string
  327. *
  328. * @returns Returns a URL string after removing the trailing slash if one exists, otherwise
  329. * returns the string as is.
  330. */
  331. Location.stripTrailingSlash = function (url) {
  332. var match = url.match(/#|\?|$/);
  333. var pathEndIdx = match && match.index || url.length;
  334. var droppedSlashIdx = pathEndIdx - (url[pathEndIdx - 1] === '/' ? 1 : 0);
  335. return url.slice(0, droppedSlashIdx) + url.slice(pathEndIdx);
  336. };
  337. var Location_1;
  338. Location = Location_1 = __decorate([
  339. Injectable(),
  340. __metadata("design:paramtypes", [LocationStrategy, PlatformLocation])
  341. ], Location);
  342. return Location;
  343. }());
  344. function _stripBaseHref(baseHref, url) {
  345. return baseHref && url.startsWith(baseHref) ? url.substring(baseHref.length) : url;
  346. }
  347. function _stripIndexHtml(url) {
  348. return url.replace(/\/index.html$/, '');
  349. }
  350. /**
  351. * @license
  352. * Copyright Google Inc. All Rights Reserved.
  353. *
  354. * Use of this source code is governed by an MIT-style license that can be
  355. * found in the LICENSE file at https://angular.io/license
  356. */
  357. /**
  358. * @description
  359. * A {@link LocationStrategy} used to configure the {@link Location} service to
  360. * represent its state in the
  361. * [hash fragment](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax)
  362. * of the browser's URL.
  363. *
  364. * For instance, if you call `location.go('/foo')`, the browser's URL will become
  365. * `example.com#/foo`.
  366. *
  367. * @usageNotes
  368. *
  369. * ### Example
  370. *
  371. * {@example common/location/ts/hash_location_component.ts region='LocationComponent'}
  372. *
  373. * @publicApi
  374. */
  375. var HashLocationStrategy = /** @class */ (function (_super) {
  376. __extends(HashLocationStrategy, _super);
  377. function HashLocationStrategy(_platformLocation, _baseHref) {
  378. var _this = _super.call(this) || this;
  379. _this._platformLocation = _platformLocation;
  380. _this._baseHref = '';
  381. if (_baseHref != null) {
  382. _this._baseHref = _baseHref;
  383. }
  384. return _this;
  385. }
  386. HashLocationStrategy.prototype.onPopState = function (fn) {
  387. this._platformLocation.onPopState(fn);
  388. this._platformLocation.onHashChange(fn);
  389. };
  390. HashLocationStrategy.prototype.getBaseHref = function () { return this._baseHref; };
  391. HashLocationStrategy.prototype.path = function (includeHash) {
  392. if (includeHash === void 0) { includeHash = false; }
  393. // the hash value is always prefixed with a `#`
  394. // and if it is empty then it will stay empty
  395. var path = this._platformLocation.hash;
  396. if (path == null)
  397. path = '#';
  398. return path.length > 0 ? path.substring(1) : path;
  399. };
  400. HashLocationStrategy.prototype.prepareExternalUrl = function (internal) {
  401. var url = Location.joinWithSlash(this._baseHref, internal);
  402. return url.length > 0 ? ('#' + url) : url;
  403. };
  404. HashLocationStrategy.prototype.pushState = function (state, title, path, queryParams) {
  405. var url = this.prepareExternalUrl(path + Location.normalizeQueryParams(queryParams));
  406. if (url.length == 0) {
  407. url = this._platformLocation.pathname;
  408. }
  409. this._platformLocation.pushState(state, title, url);
  410. };
  411. HashLocationStrategy.prototype.replaceState = function (state, title, path, queryParams) {
  412. var url = this.prepareExternalUrl(path + Location.normalizeQueryParams(queryParams));
  413. if (url.length == 0) {
  414. url = this._platformLocation.pathname;
  415. }
  416. this._platformLocation.replaceState(state, title, url);
  417. };
  418. HashLocationStrategy.prototype.forward = function () { this._platformLocation.forward(); };
  419. HashLocationStrategy.prototype.back = function () { this._platformLocation.back(); };
  420. HashLocationStrategy = __decorate([
  421. Injectable(),
  422. __param(1, Optional()), __param(1, Inject(APP_BASE_HREF)),
  423. __metadata("design:paramtypes", [PlatformLocation, String])
  424. ], HashLocationStrategy);
  425. return HashLocationStrategy;
  426. }(LocationStrategy));
  427. /**
  428. * @license
  429. * Copyright Google Inc. All Rights Reserved.
  430. *
  431. * Use of this source code is governed by an MIT-style license that can be
  432. * found in the LICENSE file at https://angular.io/license
  433. */
  434. /**
  435. * @description
  436. * A {@link LocationStrategy} used to configure the {@link Location} service to
  437. * represent its state in the
  438. * [path](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax) of the
  439. * browser's URL.
  440. *
  441. * If you're using `PathLocationStrategy`, you must provide a {@link APP_BASE_HREF}
  442. * or add a base element to the document. This URL prefix that will be preserved
  443. * when generating and recognizing URLs.
  444. *
  445. * For instance, if you provide an `APP_BASE_HREF` of `'/my/app'` and call
  446. * `location.go('/foo')`, the browser's URL will become
  447. * `example.com/my/app/foo`.
  448. *
  449. * Similarly, if you add `<base href='/my/app'/>` to the document and call
  450. * `location.go('/foo')`, the browser's URL will become
  451. * `example.com/my/app/foo`.
  452. *
  453. * @usageNotes
  454. *
  455. * ### Example
  456. *
  457. * {@example common/location/ts/path_location_component.ts region='LocationComponent'}
  458. *
  459. * @publicApi
  460. */
  461. var PathLocationStrategy = /** @class */ (function (_super) {
  462. __extends(PathLocationStrategy, _super);
  463. function PathLocationStrategy(_platformLocation, href) {
  464. var _this = _super.call(this) || this;
  465. _this._platformLocation = _platformLocation;
  466. if (href == null) {
  467. href = _this._platformLocation.getBaseHrefFromDOM();
  468. }
  469. if (href == null) {
  470. throw new Error("No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document.");
  471. }
  472. _this._baseHref = href;
  473. return _this;
  474. }
  475. PathLocationStrategy.prototype.onPopState = function (fn) {
  476. this._platformLocation.onPopState(fn);
  477. this._platformLocation.onHashChange(fn);
  478. };
  479. PathLocationStrategy.prototype.getBaseHref = function () { return this._baseHref; };
  480. PathLocationStrategy.prototype.prepareExternalUrl = function (internal) {
  481. return Location.joinWithSlash(this._baseHref, internal);
  482. };
  483. PathLocationStrategy.prototype.path = function (includeHash) {
  484. if (includeHash === void 0) { includeHash = false; }
  485. var pathname = this._platformLocation.pathname +
  486. Location.normalizeQueryParams(this._platformLocation.search);
  487. var hash = this._platformLocation.hash;
  488. return hash && includeHash ? "" + pathname + hash : pathname;
  489. };
  490. PathLocationStrategy.prototype.pushState = function (state, title, url, queryParams) {
  491. var externalUrl = this.prepareExternalUrl(url + Location.normalizeQueryParams(queryParams));
  492. this._platformLocation.pushState(state, title, externalUrl);
  493. };
  494. PathLocationStrategy.prototype.replaceState = function (state, title, url, queryParams) {
  495. var externalUrl = this.prepareExternalUrl(url + Location.normalizeQueryParams(queryParams));
  496. this._platformLocation.replaceState(state, title, externalUrl);
  497. };
  498. PathLocationStrategy.prototype.forward = function () { this._platformLocation.forward(); };
  499. PathLocationStrategy.prototype.back = function () { this._platformLocation.back(); };
  500. PathLocationStrategy = __decorate([
  501. Injectable(),
  502. __param(1, Optional()), __param(1, Inject(APP_BASE_HREF)),
  503. __metadata("design:paramtypes", [PlatformLocation, String])
  504. ], PathLocationStrategy);
  505. return PathLocationStrategy;
  506. }(LocationStrategy));
  507. /**
  508. * @license
  509. * Copyright Google Inc. All Rights Reserved.
  510. *
  511. * Use of this source code is governed by an MIT-style license that can be
  512. * found in the LICENSE file at https://angular.io/license
  513. */
  514. /**
  515. * @license
  516. * Copyright Google Inc. All Rights Reserved.
  517. *
  518. * Use of this source code is governed by an MIT-style license that can be
  519. * found in the LICENSE file at https://angular.io/license
  520. */
  521. /** @internal */
  522. var CURRENCIES_EN = {
  523. 'ADP': [undefined, undefined, 0],
  524. 'AFN': [undefined, undefined, 0],
  525. 'ALL': [undefined, undefined, 0],
  526. 'AMD': [undefined, undefined, 0],
  527. 'AOA': [undefined, 'Kz'],
  528. 'ARS': [undefined, '$'],
  529. 'AUD': ['A$', '$'],
  530. 'BAM': [undefined, 'KM'],
  531. 'BBD': [undefined, '$'],
  532. 'BDT': [undefined, '৳'],
  533. 'BHD': [undefined, undefined, 3],
  534. 'BIF': [undefined, undefined, 0],
  535. 'BMD': [undefined, '$'],
  536. 'BND': [undefined, '$'],
  537. 'BOB': [undefined, 'Bs'],
  538. 'BRL': ['R$'],
  539. 'BSD': [undefined, '$'],
  540. 'BWP': [undefined, 'P'],
  541. 'BYN': [undefined, 'р.', 2],
  542. 'BYR': [undefined, undefined, 0],
  543. 'BZD': [undefined, '$'],
  544. 'CAD': ['CA$', '$', 2],
  545. 'CHF': [undefined, undefined, 2],
  546. 'CLF': [undefined, undefined, 4],
  547. 'CLP': [undefined, '$', 0],
  548. 'CNY': ['CN¥', '¥'],
  549. 'COP': [undefined, '$', 0],
  550. 'CRC': [undefined, '₡', 2],
  551. 'CUC': [undefined, '$'],
  552. 'CUP': [undefined, '$'],
  553. 'CZK': [undefined, 'Kč', 2],
  554. 'DJF': [undefined, undefined, 0],
  555. 'DKK': [undefined, 'kr', 2],
  556. 'DOP': [undefined, '$'],
  557. 'EGP': [undefined, 'E£'],
  558. 'ESP': [undefined, '₧', 0],
  559. 'EUR': ['€'],
  560. 'FJD': [undefined, '$'],
  561. 'FKP': [undefined, '£'],
  562. 'GBP': ['£'],
  563. 'GEL': [undefined, '₾'],
  564. 'GIP': [undefined, '£'],
  565. 'GNF': [undefined, 'FG', 0],
  566. 'GTQ': [undefined, 'Q'],
  567. 'GYD': [undefined, '$', 0],
  568. 'HKD': ['HK$', '$'],
  569. 'HNL': [undefined, 'L'],
  570. 'HRK': [undefined, 'kn'],
  571. 'HUF': [undefined, 'Ft', 2],
  572. 'IDR': [undefined, 'Rp', 0],
  573. 'ILS': ['₪'],
  574. 'INR': ['₹'],
  575. 'IQD': [undefined, undefined, 0],
  576. 'IRR': [undefined, undefined, 0],
  577. 'ISK': [undefined, 'kr', 0],
  578. 'ITL': [undefined, undefined, 0],
  579. 'JMD': [undefined, '$'],
  580. 'JOD': [undefined, undefined, 3],
  581. 'JPY': ['¥', undefined, 0],
  582. 'KHR': [undefined, '៛'],
  583. 'KMF': [undefined, 'CF', 0],
  584. 'KPW': [undefined, '₩', 0],
  585. 'KRW': ['₩', undefined, 0],
  586. 'KWD': [undefined, undefined, 3],
  587. 'KYD': [undefined, '$'],
  588. 'KZT': [undefined, '₸'],
  589. 'LAK': [undefined, '₭', 0],
  590. 'LBP': [undefined, 'L£', 0],
  591. 'LKR': [undefined, 'Rs'],
  592. 'LRD': [undefined, '$'],
  593. 'LTL': [undefined, 'Lt'],
  594. 'LUF': [undefined, undefined, 0],
  595. 'LVL': [undefined, 'Ls'],
  596. 'LYD': [undefined, undefined, 3],
  597. 'MGA': [undefined, 'Ar', 0],
  598. 'MGF': [undefined, undefined, 0],
  599. 'MMK': [undefined, 'K', 0],
  600. 'MNT': [undefined, '₮', 0],
  601. 'MRO': [undefined, undefined, 0],
  602. 'MUR': [undefined, 'Rs', 0],
  603. 'MXN': ['MX$', '$'],
  604. 'MYR': [undefined, 'RM'],
  605. 'NAD': [undefined, '$'],
  606. 'NGN': [undefined, '₦'],
  607. 'NIO': [undefined, 'C$'],
  608. 'NOK': [undefined, 'kr', 2],
  609. 'NPR': [undefined, 'Rs'],
  610. 'NZD': ['NZ$', '$'],
  611. 'OMR': [undefined, undefined, 3],
  612. 'PHP': [undefined, '₱'],
  613. 'PKR': [undefined, 'Rs', 0],
  614. 'PLN': [undefined, 'zł'],
  615. 'PYG': [undefined, '₲', 0],
  616. 'RON': [undefined, 'lei'],
  617. 'RSD': [undefined, undefined, 0],
  618. 'RUB': [undefined, '₽'],
  619. 'RUR': [undefined, 'р.'],
  620. 'RWF': [undefined, 'RF', 0],
  621. 'SBD': [undefined, '$'],
  622. 'SEK': [undefined, 'kr', 2],
  623. 'SGD': [undefined, '$'],
  624. 'SHP': [undefined, '£'],
  625. 'SLL': [undefined, undefined, 0],
  626. 'SOS': [undefined, undefined, 0],
  627. 'SRD': [undefined, '$'],
  628. 'SSP': [undefined, '£'],
  629. 'STD': [undefined, undefined, 0],
  630. 'STN': [undefined, 'Db'],
  631. 'SYP': [undefined, '£', 0],
  632. 'THB': [undefined, '฿'],
  633. 'TMM': [undefined, undefined, 0],
  634. 'TND': [undefined, undefined, 3],
  635. 'TOP': [undefined, 'T$'],
  636. 'TRL': [undefined, undefined, 0],
  637. 'TRY': [undefined, '₺'],
  638. 'TTD': [undefined, '$'],
  639. 'TWD': ['NT$', '$', 2],
  640. 'TZS': [undefined, undefined, 0],
  641. 'UAH': [undefined, '₴'],
  642. 'UGX': [undefined, undefined, 0],
  643. 'USD': ['$'],
  644. 'UYI': [undefined, undefined, 0],
  645. 'UYU': [undefined, '$'],
  646. 'UZS': [undefined, undefined, 0],
  647. 'VEF': [undefined, 'Bs'],
  648. 'VND': ['₫', undefined, 0],
  649. 'VUV': [undefined, undefined, 0],
  650. 'XAF': ['FCFA', undefined, 0],
  651. 'XCD': ['EC$', '$'],
  652. 'XOF': ['CFA', undefined, 0],
  653. 'XPF': ['CFPF', undefined, 0],
  654. 'YER': [undefined, undefined, 0],
  655. 'ZAR': [undefined, 'R'],
  656. 'ZMK': [undefined, undefined, 0],
  657. 'ZMW': [undefined, 'ZK'],
  658. 'ZWD': [undefined, undefined, 0]
  659. };
  660. /**
  661. * @license
  662. * Copyright Google Inc. All Rights Reserved.
  663. *
  664. * Use of this source code is governed by an MIT-style license that can be
  665. * found in the LICENSE file at https://angular.io/license
  666. */
  667. /**
  668. * Format styles that can be used to represent numbers.
  669. * @see `getLocaleNumberFormat()`.
  670. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  671. *
  672. * @publicApi
  673. */
  674. var NumberFormatStyle;
  675. (function (NumberFormatStyle) {
  676. NumberFormatStyle[NumberFormatStyle["Decimal"] = 0] = "Decimal";
  677. NumberFormatStyle[NumberFormatStyle["Percent"] = 1] = "Percent";
  678. NumberFormatStyle[NumberFormatStyle["Currency"] = 2] = "Currency";
  679. NumberFormatStyle[NumberFormatStyle["Scientific"] = 3] = "Scientific";
  680. })(NumberFormatStyle || (NumberFormatStyle = {}));
  681. /**
  682. * Plurality cases used for translating plurals to different languages.
  683. *
  684. * @see `NgPlural`
  685. * @see `NgPluralCase`
  686. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  687. *
  688. * @publicApi
  689. */
  690. var Plural;
  691. (function (Plural) {
  692. Plural[Plural["Zero"] = 0] = "Zero";
  693. Plural[Plural["One"] = 1] = "One";
  694. Plural[Plural["Two"] = 2] = "Two";
  695. Plural[Plural["Few"] = 3] = "Few";
  696. Plural[Plural["Many"] = 4] = "Many";
  697. Plural[Plural["Other"] = 5] = "Other";
  698. })(Plural || (Plural = {}));
  699. /**
  700. * Context-dependant translation forms for strings.
  701. * Typically the standalone version is for the nominative form of the word,
  702. * and the format version is used for the genitive case.
  703. * @see [CLDR website](http://cldr.unicode.org/translation/date-time#TOC-Stand-Alone-vs.-Format-Styles)
  704. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  705. *
  706. * @publicApi
  707. */
  708. var FormStyle;
  709. (function (FormStyle) {
  710. FormStyle[FormStyle["Format"] = 0] = "Format";
  711. FormStyle[FormStyle["Standalone"] = 1] = "Standalone";
  712. })(FormStyle || (FormStyle = {}));
  713. /**
  714. * String widths available for translations.
  715. * The specific character widths are locale-specific.
  716. * Examples are given for the word "Sunday" in English.
  717. *
  718. * @publicApi
  719. */
  720. var TranslationWidth;
  721. (function (TranslationWidth) {
  722. /** 1 character for `en-US`. For example: 'S' */
  723. TranslationWidth[TranslationWidth["Narrow"] = 0] = "Narrow";
  724. /** 3 characters for `en-US`. For example: 'Sun' */
  725. TranslationWidth[TranslationWidth["Abbreviated"] = 1] = "Abbreviated";
  726. /** Full length for `en-US`. For example: "Sunday" */
  727. TranslationWidth[TranslationWidth["Wide"] = 2] = "Wide";
  728. /** 2 characters for `en-US`, For example: "Su" */
  729. TranslationWidth[TranslationWidth["Short"] = 3] = "Short";
  730. })(TranslationWidth || (TranslationWidth = {}));
  731. /**
  732. * String widths available for date-time formats.
  733. * The specific character widths are locale-specific.
  734. * Examples are given for `en-US`.
  735. *
  736. * @see `getLocaleDateFormat()`
  737. * @see `getLocaleTimeFormat()``
  738. * @see `getLocaleDateTimeFormat()`
  739. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  740. * @publicApi
  741. */
  742. var FormatWidth;
  743. (function (FormatWidth) {
  744. /**
  745. * For `en-US`, 'M/d/yy, h:mm a'`
  746. * (Example: `6/15/15, 9:03 AM`)
  747. */
  748. FormatWidth[FormatWidth["Short"] = 0] = "Short";
  749. /**
  750. * For `en-US`, `'MMM d, y, h:mm:ss a'`
  751. * (Example: `Jun 15, 2015, 9:03:01 AM`)
  752. */
  753. FormatWidth[FormatWidth["Medium"] = 1] = "Medium";
  754. /**
  755. * For `en-US`, `'MMMM d, y, h:mm:ss a z'`
  756. * (Example: `June 15, 2015 at 9:03:01 AM GMT+1`)
  757. */
  758. FormatWidth[FormatWidth["Long"] = 2] = "Long";
  759. /**
  760. * For `en-US`, `'EEEE, MMMM d, y, h:mm:ss a zzzz'`
  761. * (Example: `Monday, June 15, 2015 at 9:03:01 AM GMT+01:00`)
  762. */
  763. FormatWidth[FormatWidth["Full"] = 3] = "Full";
  764. })(FormatWidth || (FormatWidth = {}));
  765. /**
  766. * Symbols that can be used to replace placeholders in number patterns.
  767. * Examples are based on `en-US` values.
  768. *
  769. * @see `getLocaleNumberSymbol()`
  770. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  771. *
  772. * @publicApi
  773. */
  774. var NumberSymbol;
  775. (function (NumberSymbol) {
  776. /**
  777. * Decimal separator.
  778. * For `en-US`, the dot character.
  779. * Example : 2,345`.`67
  780. */
  781. NumberSymbol[NumberSymbol["Decimal"] = 0] = "Decimal";
  782. /**
  783. * Grouping separator, typically for thousands.
  784. * For `en-US`, the comma character.
  785. * Example: 2`,`345.67
  786. */
  787. NumberSymbol[NumberSymbol["Group"] = 1] = "Group";
  788. /**
  789. * List-item separator.
  790. * Example: "one, two, and three"
  791. */
  792. NumberSymbol[NumberSymbol["List"] = 2] = "List";
  793. /**
  794. * Sign for percentage (out of 100).
  795. * Example: 23.4%
  796. */
  797. NumberSymbol[NumberSymbol["PercentSign"] = 3] = "PercentSign";
  798. /**
  799. * Sign for positive numbers.
  800. * Example: +23
  801. */
  802. NumberSymbol[NumberSymbol["PlusSign"] = 4] = "PlusSign";
  803. /**
  804. * Sign for negative numbers.
  805. * Example: -23
  806. */
  807. NumberSymbol[NumberSymbol["MinusSign"] = 5] = "MinusSign";
  808. /**
  809. * Computer notation for exponential value (n times a power of 10).
  810. * Example: 1.2E3
  811. */
  812. NumberSymbol[NumberSymbol["Exponential"] = 6] = "Exponential";
  813. /**
  814. * Human-readable format of exponential.
  815. * Example: 1.2x103
  816. */
  817. NumberSymbol[NumberSymbol["SuperscriptingExponent"] = 7] = "SuperscriptingExponent";
  818. /**
  819. * Sign for permille (out of 1000).
  820. * Example: 23.4‰
  821. */
  822. NumberSymbol[NumberSymbol["PerMille"] = 8] = "PerMille";
  823. /**
  824. * Infinity, can be used with plus and minus.
  825. * Example: ∞, +∞, -∞
  826. */
  827. NumberSymbol[NumberSymbol["Infinity"] = 9] = "Infinity";
  828. /**
  829. * Not a number.
  830. * Example: NaN
  831. */
  832. NumberSymbol[NumberSymbol["NaN"] = 10] = "NaN";
  833. /**
  834. * Symbol used between time units.
  835. * Example: 10:52
  836. */
  837. NumberSymbol[NumberSymbol["TimeSeparator"] = 11] = "TimeSeparator";
  838. /**
  839. * Decimal separator for currency values (fallback to `Decimal`).
  840. * Example: $2,345.67
  841. */
  842. NumberSymbol[NumberSymbol["CurrencyDecimal"] = 12] = "CurrencyDecimal";
  843. /**
  844. * Group separator for currency values (fallback to `Group`).
  845. * Example: $2,345.67
  846. */
  847. NumberSymbol[NumberSymbol["CurrencyGroup"] = 13] = "CurrencyGroup";
  848. })(NumberSymbol || (NumberSymbol = {}));
  849. /**
  850. * The value for each day of the week, based on the `en-US` locale
  851. *
  852. * @publicApi
  853. */
  854. var WeekDay;
  855. (function (WeekDay) {
  856. WeekDay[WeekDay["Sunday"] = 0] = "Sunday";
  857. WeekDay[WeekDay["Monday"] = 1] = "Monday";
  858. WeekDay[WeekDay["Tuesday"] = 2] = "Tuesday";
  859. WeekDay[WeekDay["Wednesday"] = 3] = "Wednesday";
  860. WeekDay[WeekDay["Thursday"] = 4] = "Thursday";
  861. WeekDay[WeekDay["Friday"] = 5] = "Friday";
  862. WeekDay[WeekDay["Saturday"] = 6] = "Saturday";
  863. })(WeekDay || (WeekDay = {}));
  864. /**
  865. * Retrieves the locale ID from the currently loaded locale.
  866. * The loaded locale could be, for example, a global one rather than a regional one.
  867. * @param locale A locale code, such as `fr-FR`.
  868. * @returns The locale code. For example, `fr`.
  869. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  870. *
  871. * @publicApi
  872. */
  873. function getLocaleId(locale) {
  874. return ɵfindLocaleData(locale)[ɵLocaleDataIndex.LocaleId];
  875. }
  876. /**
  877. * Retrieves day period strings for the given locale.
  878. *
  879. * @param locale A locale code for the locale format rules to use.
  880. * @param formStyle The required grammatical form.
  881. * @param width The required character width.
  882. * @returns An array of localized period strings. For example, `[AM, PM]` for `en-US`.
  883. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  884. *
  885. * @publicApi
  886. */
  887. function getLocaleDayPeriods(locale, formStyle, width) {
  888. var data = ɵfindLocaleData(locale);
  889. var amPmData = [data[ɵLocaleDataIndex.DayPeriodsFormat], data[ɵLocaleDataIndex.DayPeriodsStandalone]];
  890. var amPm = getLastDefinedValue(amPmData, formStyle);
  891. return getLastDefinedValue(amPm, width);
  892. }
  893. /**
  894. * Retrieves days of the week for the given locale, using the Gregorian calendar.
  895. *
  896. * @param locale A locale code for the locale format rules to use.
  897. * @param formStyle The required grammatical form.
  898. * @param width The required character width.
  899. * @returns An array of localized name strings.
  900. * For example,`[Sunday, Monday, ... Saturday]` for `en-US`.
  901. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  902. *
  903. * @publicApi
  904. */
  905. function getLocaleDayNames(locale, formStyle, width) {
  906. var data = ɵfindLocaleData(locale);
  907. var daysData = [data[ɵLocaleDataIndex.DaysFormat], data[ɵLocaleDataIndex.DaysStandalone]];
  908. var days = getLastDefinedValue(daysData, formStyle);
  909. return getLastDefinedValue(days, width);
  910. }
  911. /**
  912. * Retrieves months of the year for the given locale, using the Gregorian calendar.
  913. *
  914. * @param locale A locale code for the locale format rules to use.
  915. * @param formStyle The required grammatical form.
  916. * @param width The required character width.
  917. * @returns An array of localized name strings.
  918. * For example, `[January, February, ...]` for `en-US`.
  919. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  920. *
  921. * @publicApi
  922. */
  923. function getLocaleMonthNames(locale, formStyle, width) {
  924. var data = ɵfindLocaleData(locale);
  925. var monthsData = [data[ɵLocaleDataIndex.MonthsFormat], data[ɵLocaleDataIndex.MonthsStandalone]];
  926. var months = getLastDefinedValue(monthsData, formStyle);
  927. return getLastDefinedValue(months, width);
  928. }
  929. /**
  930. * Retrieves Gregorian-calendar eras for the given locale.
  931. * @param locale A locale code for the locale format rules to use.
  932. * @param formStyle The required grammatical form.
  933. * @param width The required character width.
  934. * @returns An array of localized era strings.
  935. * For example, `[AD, BC]` for `en-US`.
  936. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  937. *
  938. * @publicApi
  939. */
  940. function getLocaleEraNames(locale, width) {
  941. var data = ɵfindLocaleData(locale);
  942. var erasData = data[ɵLocaleDataIndex.Eras];
  943. return getLastDefinedValue(erasData, width);
  944. }
  945. /**
  946. * Retrieves the first day of the week for the given locale.
  947. *
  948. * @param locale A locale code for the locale format rules to use.
  949. * @returns A day index number, using the 0-based week-day index for `en-US`
  950. * (Sunday = 0, Monday = 1, ...).
  951. * For example, for `fr-FR`, returns 1 to indicate that the first day is Monday.
  952. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  953. *
  954. * @publicApi
  955. */
  956. function getLocaleFirstDayOfWeek(locale) {
  957. var data = ɵfindLocaleData(locale);
  958. return data[ɵLocaleDataIndex.FirstDayOfWeek];
  959. }
  960. /**
  961. * Range of week days that are considered the week-end for the given locale.
  962. *
  963. * @param locale A locale code for the locale format rules to use.
  964. * @returns The range of day values, `[startDay, endDay]`.
  965. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  966. *
  967. * @publicApi
  968. */
  969. function getLocaleWeekEndRange(locale) {
  970. var data = ɵfindLocaleData(locale);
  971. return data[ɵLocaleDataIndex.WeekendRange];
  972. }
  973. /**
  974. * Retrieves a localized date-value formating string.
  975. *
  976. * @param locale A locale code for the locale format rules to use.
  977. * @param width The format type.
  978. * @returns The localized formating string.
  979. * @see `FormatWidth`
  980. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  981. *
  982. * @publicApi
  983. */
  984. function getLocaleDateFormat(locale, width) {
  985. var data = ɵfindLocaleData(locale);
  986. return getLastDefinedValue(data[ɵLocaleDataIndex.DateFormat], width);
  987. }
  988. /**
  989. * Retrieves a localized time-value formatting string.
  990. *
  991. * @param locale A locale code for the locale format rules to use.
  992. * @param width The format type.
  993. * @returns The localized formatting string.
  994. * @see `FormatWidth`
  995. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  996. * @publicApi
  997. */
  998. function getLocaleTimeFormat(locale, width) {
  999. var data = ɵfindLocaleData(locale);
  1000. return getLastDefinedValue(data[ɵLocaleDataIndex.TimeFormat], width);
  1001. }
  1002. /**
  1003. * Retrieves a localized date-time formatting string.
  1004. *
  1005. * @param locale A locale code for the locale format rules to use.
  1006. * @param width The format type.
  1007. * @returns The localized formatting string.
  1008. * @see `FormatWidth`
  1009. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1010. *
  1011. * @publicApi
  1012. */
  1013. function getLocaleDateTimeFormat(locale, width) {
  1014. var data = ɵfindLocaleData(locale);
  1015. var dateTimeFormatData = data[ɵLocaleDataIndex.DateTimeFormat];
  1016. return getLastDefinedValue(dateTimeFormatData, width);
  1017. }
  1018. /**
  1019. * Retrieves a localized number symbol that can be used to replace placeholders in number formats.
  1020. * @param locale The locale code.
  1021. * @param symbol The symbol to localize.
  1022. * @returns The character for the localized symbol.
  1023. * @see `NumberSymbol`
  1024. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1025. *
  1026. * @publicApi
  1027. */
  1028. function getLocaleNumberSymbol(locale, symbol) {
  1029. var data = ɵfindLocaleData(locale);
  1030. var res = data[ɵLocaleDataIndex.NumberSymbols][symbol];
  1031. if (typeof res === 'undefined') {
  1032. if (symbol === NumberSymbol.CurrencyDecimal) {
  1033. return data[ɵLocaleDataIndex.NumberSymbols][NumberSymbol.Decimal];
  1034. }
  1035. else if (symbol === NumberSymbol.CurrencyGroup) {
  1036. return data[ɵLocaleDataIndex.NumberSymbols][NumberSymbol.Group];
  1037. }
  1038. }
  1039. return res;
  1040. }
  1041. /**
  1042. * Retrieves a number format for a given locale.
  1043. *
  1044. * Numbers are formatted using patterns, like `#,###.00`. For example, the pattern `#,###.00`
  1045. * when used to format the number 12345.678 could result in "12'345,678". That would happen if the
  1046. * grouping separator for your language is an apostrophe, and the decimal separator is a comma.
  1047. *
  1048. * <b>Important:</b> The characters `.` `,` `0` `#` (and others below) are special placeholders
  1049. * that stand for the decimal separator, and so on, and are NOT real characters.
  1050. * You must NOT "translate" the placeholders. For example, don't change `.` to `,` even though in
  1051. * your language the decimal point is written with a comma. The symbols should be replaced by the
  1052. * local equivalents, using the appropriate `NumberSymbol` for your language.
  1053. *
  1054. * Here are the special characters used in number patterns:
  1055. *
  1056. * | Symbol | Meaning |
  1057. * |--------|---------|
  1058. * | . | Replaced automatically by the character used for the decimal point. |
  1059. * | , | Replaced by the "grouping" (thousands) separator. |
  1060. * | 0 | Replaced by a digit (or zero if there aren't enough digits). |
  1061. * | # | Replaced by a digit (or nothing if there aren't enough). |
  1062. * | ¤ | Replaced by a currency symbol, such as $ or USD. |
  1063. * | % | Marks a percent format. The % symbol may change position, but must be retained. |
  1064. * | E | Marks a scientific format. The E symbol may change position, but must be retained. |
  1065. * | ' | Special characters used as literal characters are quoted with ASCII single quotes. |
  1066. *
  1067. * @param locale A locale code for the locale format rules to use.
  1068. * @param type The type of numeric value to be formatted (such as `Decimal` or `Currency`.)
  1069. * @returns The localized format string.
  1070. * @see `NumberFormatStyle`
  1071. * @see [CLDR website](http://cldr.unicode.org/translation/number-patterns)
  1072. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1073. *
  1074. * @publicApi
  1075. */
  1076. function getLocaleNumberFormat(locale, type) {
  1077. var data = ɵfindLocaleData(locale);
  1078. return data[ɵLocaleDataIndex.NumberFormats][type];
  1079. }
  1080. /**
  1081. * Retrieves the symbol used to represent the currency for the main country
  1082. * corresponding to a given locale. For example, '$' for `en-US`.
  1083. *
  1084. * @param locale A locale code for the locale format rules to use.
  1085. * @returns The localized symbol character,
  1086. * or `null` if the main country cannot be determined.
  1087. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1088. *
  1089. * @publicApi
  1090. */
  1091. function getLocaleCurrencySymbol(locale) {
  1092. var data = ɵfindLocaleData(locale);
  1093. return data[ɵLocaleDataIndex.CurrencySymbol] || null;
  1094. }
  1095. /**
  1096. * Retrieves the name of the currency for the main country corresponding
  1097. * to a given locale. For example, 'US Dollar' for `en-US`.
  1098. * @param locale A locale code for the locale format rules to use.
  1099. * @returns The currency name,
  1100. * or `null` if the main country cannot be determined.
  1101. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1102. *
  1103. * @publicApi
  1104. */
  1105. function getLocaleCurrencyName(locale) {
  1106. var data = ɵfindLocaleData(locale);
  1107. return data[ɵLocaleDataIndex.CurrencyName] || null;
  1108. }
  1109. /**
  1110. * Retrieves the currency values for a given locale.
  1111. * @param locale A locale code for the locale format rules to use.
  1112. * @returns The currency values.
  1113. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1114. */
  1115. function getLocaleCurrencies(locale) {
  1116. var data = ɵfindLocaleData(locale);
  1117. return data[ɵLocaleDataIndex.Currencies];
  1118. }
  1119. /**
  1120. * @alias core/ɵgetLocalePluralCase
  1121. * @publicApi
  1122. */
  1123. var getLocalePluralCase = ɵgetLocalePluralCase;
  1124. function checkFullData(data) {
  1125. if (!data[ɵLocaleDataIndex.ExtraData]) {
  1126. throw new Error("Missing extra locale data for the locale \"" + data[ɵLocaleDataIndex.LocaleId] + "\". Use \"registerLocaleData\" to load new data. See the \"I18n guide\" on angular.io to know more.");
  1127. }
  1128. }
  1129. /**
  1130. * Retrieves locale-specific rules used to determine which day period to use
  1131. * when more than one period is defined for a locale.
  1132. *
  1133. * There is a rule for each defined day period. The
  1134. * first rule is applied to the first day period and so on.
  1135. * Fall back to AM/PM when no rules are available.
  1136. *
  1137. * A rule can specify a period as time range, or as a single time value.
  1138. *
  1139. * This functionality is only available when you have loaded the full locale data.
  1140. * See the ["I18n guide"](guide/i18n#i18n-pipes).
  1141. *
  1142. * @param locale A locale code for the locale format rules to use.
  1143. * @returns The rules for the locale, a single time value or array of *from-time, to-time*,
  1144. * or null if no periods are available.
  1145. *
  1146. * @see `getLocaleExtraDayPeriods()`
  1147. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1148. *
  1149. * @publicApi
  1150. */
  1151. function getLocaleExtraDayPeriodRules(locale) {
  1152. var data = ɵfindLocaleData(locale);
  1153. checkFullData(data);
  1154. var rules = data[ɵLocaleDataIndex.ExtraData][2 /* ExtraDayPeriodsRules */] || [];
  1155. return rules.map(function (rule) {
  1156. if (typeof rule === 'string') {
  1157. return extractTime(rule);
  1158. }
  1159. return [extractTime(rule[0]), extractTime(rule[1])];
  1160. });
  1161. }
  1162. /**
  1163. * Retrieves locale-specific day periods, which indicate roughly how a day is broken up
  1164. * in different languages.
  1165. * For example, for `en-US`, periods are morning, noon, afternoon, evening, and midnight.
  1166. *
  1167. * This functionality is only available when you have loaded the full locale data.
  1168. * See the ["I18n guide"](guide/i18n#i18n-pipes).
  1169. *
  1170. * @param locale A locale code for the locale format rules to use.
  1171. * @param formStyle The required grammatical form.
  1172. * @param width The required character width.
  1173. * @returns The translated day-period strings.
  1174. * @see `getLocaleExtraDayPeriodRules()`
  1175. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1176. *
  1177. * @publicApi
  1178. */
  1179. function getLocaleExtraDayPeriods(locale, formStyle, width) {
  1180. var data = ɵfindLocaleData(locale);
  1181. checkFullData(data);
  1182. var dayPeriodsData = [
  1183. data[ɵLocaleDataIndex.ExtraData][0 /* ExtraDayPeriodFormats */],
  1184. data[ɵLocaleDataIndex.ExtraData][1 /* ExtraDayPeriodStandalone */]
  1185. ];
  1186. var dayPeriods = getLastDefinedValue(dayPeriodsData, formStyle) || [];
  1187. return getLastDefinedValue(dayPeriods, width) || [];
  1188. }
  1189. /**
  1190. * Retrieves the first value that is defined in an array, going backwards from an index position.
  1191. *
  1192. * To avoid repeating the same data (as when the "format" and "standalone" forms are the same)
  1193. * add the first value to the locale data arrays, and add other values only if they are different.
  1194. *
  1195. * @param data The data array to retrieve from.
  1196. * @param index A 0-based index into the array to start from.
  1197. * @returns The value immediately before the given index position.
  1198. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1199. *
  1200. * @publicApi
  1201. */
  1202. function getLastDefinedValue(data, index) {
  1203. for (var i = index; i > -1; i--) {
  1204. if (typeof data[i] !== 'undefined') {
  1205. return data[i];
  1206. }
  1207. }
  1208. throw new Error('Locale data API: locale data undefined');
  1209. }
  1210. /**
  1211. * Extracts the hours and minutes from a string like "15:45"
  1212. */
  1213. function extractTime(time) {
  1214. var _a = __read(time.split(':'), 2), h = _a[0], m = _a[1];
  1215. return { hours: +h, minutes: +m };
  1216. }
  1217. /**
  1218. * Retrieves the currency symbol for a given currency code.
  1219. *
  1220. * For example, for the default `en-US` locale, the code `USD` can
  1221. * be represented by the narrow symbol `$` or the wide symbol `US$`.
  1222. *
  1223. * @param code The currency code.
  1224. * @param format The format, `wide` or `narrow`.
  1225. * @param locale A locale code for the locale format rules to use.
  1226. *
  1227. * @returns The symbol, or the currency code if no symbol is available.0
  1228. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1229. *
  1230. * @publicApi
  1231. */
  1232. function getCurrencySymbol(code, format, locale) {
  1233. if (locale === void 0) { locale = 'en'; }
  1234. var currency = getLocaleCurrencies(locale)[code] || CURRENCIES_EN[code] || [];
  1235. var symbolNarrow = currency[1 /* SymbolNarrow */];
  1236. if (format === 'narrow' && typeof symbolNarrow === 'string') {
  1237. return symbolNarrow;
  1238. }
  1239. return currency[0 /* Symbol */] || code;
  1240. }
  1241. // Most currencies have cents, that's why the default is 2
  1242. var DEFAULT_NB_OF_CURRENCY_DIGITS = 2;
  1243. /**
  1244. * Reports the number of decimal digits for a given currency.
  1245. * The value depends upon the presence of cents in that particular currency.
  1246. *
  1247. * @param code The currency code.
  1248. * @returns The number of decimal digits, typically 0 or 2.
  1249. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1250. *
  1251. * @publicApi
  1252. */
  1253. function getNumberOfCurrencyDigits(code) {
  1254. var digits;
  1255. var currency = CURRENCIES_EN[code];
  1256. if (currency) {
  1257. digits = currency[2 /* NbOfDigits */];
  1258. }
  1259. return typeof digits === 'number' ? digits : DEFAULT_NB_OF_CURRENCY_DIGITS;
  1260. }
  1261. /**
  1262. * @license
  1263. * Copyright Google Inc. All Rights Reserved.
  1264. *
  1265. * Use of this source code is governed by an MIT-style license that can be
  1266. * found in the LICENSE file at https://angular.io/license
  1267. */
  1268. var ISO8601_DATE_REGEX = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;
  1269. // 1 2 3 4 5 6 7 8 9 10 11
  1270. var NAMED_FORMATS = {};
  1271. var DATE_FORMATS_SPLIT = /((?:[^GyMLwWdEabBhHmsSzZO']+)|(?:'(?:[^']|'')*')|(?:G{1,5}|y{1,4}|M{1,5}|L{1,5}|w{1,2}|W{1}|d{1,2}|E{1,6}|a{1,5}|b{1,5}|B{1,5}|h{1,2}|H{1,2}|m{1,2}|s{1,2}|S{1,3}|z{1,4}|Z{1,5}|O{1,4}))([\s\S]*)/;
  1272. var ZoneWidth;
  1273. (function (ZoneWidth) {
  1274. ZoneWidth[ZoneWidth["Short"] = 0] = "Short";
  1275. ZoneWidth[ZoneWidth["ShortGMT"] = 1] = "ShortGMT";
  1276. ZoneWidth[ZoneWidth["Long"] = 2] = "Long";
  1277. ZoneWidth[ZoneWidth["Extended"] = 3] = "Extended";
  1278. })(ZoneWidth || (ZoneWidth = {}));
  1279. var DateType;
  1280. (function (DateType) {
  1281. DateType[DateType["FullYear"] = 0] = "FullYear";
  1282. DateType[DateType["Month"] = 1] = "Month";
  1283. DateType[DateType["Date"] = 2] = "Date";
  1284. DateType[DateType["Hours"] = 3] = "Hours";
  1285. DateType[DateType["Minutes"] = 4] = "Minutes";
  1286. DateType[DateType["Seconds"] = 5] = "Seconds";
  1287. DateType[DateType["FractionalSeconds"] = 6] = "FractionalSeconds";
  1288. DateType[DateType["Day"] = 7] = "Day";
  1289. })(DateType || (DateType = {}));
  1290. var TranslationType;
  1291. (function (TranslationType) {
  1292. TranslationType[TranslationType["DayPeriods"] = 0] = "DayPeriods";
  1293. TranslationType[TranslationType["Days"] = 1] = "Days";
  1294. TranslationType[TranslationType["Months"] = 2] = "Months";
  1295. TranslationType[TranslationType["Eras"] = 3] = "Eras";
  1296. })(TranslationType || (TranslationType = {}));
  1297. /**
  1298. * @ngModule CommonModule
  1299. * @description
  1300. *
  1301. * Formats a date according to locale rules.
  1302. *
  1303. * @param value The date to format, as a Date, or a number (milliseconds since UTC epoch)
  1304. * or an [ISO date-time string](https://www.w3.org/TR/NOTE-datetime).
  1305. * @param format The date-time components to include. See `DatePipe` for details.
  1306. * @param locale A locale code for the locale format rules to use.
  1307. * @param timezone The time zone. A time zone offset from GMT (such as `'+0430'`),
  1308. * or a standard UTC/GMT or continental US time zone abbreviation.
  1309. * If not specified, uses host system settings.
  1310. *
  1311. * @returns The formatted date string.
  1312. *
  1313. * @see `DatePipe`
  1314. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  1315. *
  1316. * @publicApi
  1317. */
  1318. function formatDate(value, format, locale, timezone) {
  1319. var date = toDate(value);
  1320. var namedFormat = getNamedFormat(locale, format);
  1321. format = namedFormat || format;
  1322. var parts = [];
  1323. var match;
  1324. while (format) {
  1325. match = DATE_FORMATS_SPLIT.exec(format);
  1326. if (match) {
  1327. parts = parts.concat(match.slice(1));
  1328. var part = parts.pop();
  1329. if (!part) {
  1330. break;
  1331. }
  1332. format = part;
  1333. }
  1334. else {
  1335. parts.push(format);
  1336. break;
  1337. }
  1338. }
  1339. var dateTimezoneOffset = date.getTimezoneOffset();
  1340. if (timezone) {
  1341. dateTimezoneOffset = timezoneToOffset(timezone, dateTimezoneOffset);
  1342. date = convertTimezoneToLocal(date, timezone, true);
  1343. }
  1344. var text = '';
  1345. parts.forEach(function (value) {
  1346. var dateFormatter = getDateFormatter(value);
  1347. text += dateFormatter ?
  1348. dateFormatter(date, locale, dateTimezoneOffset) :
  1349. value === '\'\'' ? '\'' : value.replace(/(^'|'$)/g, '').replace(/''/g, '\'');
  1350. });
  1351. return text;
  1352. }
  1353. function getNamedFormat(locale, format) {
  1354. var localeId = getLocaleId(locale);
  1355. NAMED_FORMATS[localeId] = NAMED_FORMATS[localeId] || {};
  1356. if (NAMED_FORMATS[localeId][format]) {
  1357. return NAMED_FORMATS[localeId][format];
  1358. }
  1359. var formatValue = '';
  1360. switch (format) {
  1361. case 'shortDate':
  1362. formatValue = getLocaleDateFormat(locale, FormatWidth.Short);
  1363. break;
  1364. case 'mediumDate':
  1365. formatValue = getLocaleDateFormat(locale, FormatWidth.Medium);
  1366. break;
  1367. case 'longDate':
  1368. formatValue = getLocaleDateFormat(locale, FormatWidth.Long);
  1369. break;
  1370. case 'fullDate':
  1371. formatValue = getLocaleDateFormat(locale, FormatWidth.Full);
  1372. break;
  1373. case 'shortTime':
  1374. formatValue = getLocaleTimeFormat(locale, FormatWidth.Short);
  1375. break;
  1376. case 'mediumTime':
  1377. formatValue = getLocaleTimeFormat(locale, FormatWidth.Medium);
  1378. break;
  1379. case 'longTime':
  1380. formatValue = getLocaleTimeFormat(locale, FormatWidth.Long);
  1381. break;
  1382. case 'fullTime':
  1383. formatValue = getLocaleTimeFormat(locale, FormatWidth.Full);
  1384. break;
  1385. case 'short':
  1386. var shortTime = getNamedFormat(locale, 'shortTime');
  1387. var shortDate = getNamedFormat(locale, 'shortDate');
  1388. formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Short), [shortTime, shortDate]);
  1389. break;
  1390. case 'medium':
  1391. var mediumTime = getNamedFormat(locale, 'mediumTime');
  1392. var mediumDate = getNamedFormat(locale, 'mediumDate');
  1393. formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Medium), [mediumTime, mediumDate]);
  1394. break;
  1395. case 'long':
  1396. var longTime = getNamedFormat(locale, 'longTime');
  1397. var longDate = getNamedFormat(locale, 'longDate');
  1398. formatValue =
  1399. formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Long), [longTime, longDate]);
  1400. break;
  1401. case 'full':
  1402. var fullTime = getNamedFormat(locale, 'fullTime');
  1403. var fullDate = getNamedFormat(locale, 'fullDate');
  1404. formatValue =
  1405. formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Full), [fullTime, fullDate]);
  1406. break;
  1407. }
  1408. if (formatValue) {
  1409. NAMED_FORMATS[localeId][format] = formatValue;
  1410. }
  1411. return formatValue;
  1412. }
  1413. function formatDateTime(str, opt_values) {
  1414. if (opt_values) {
  1415. str = str.replace(/\{([^}]+)}/g, function (match, key) {
  1416. return (opt_values != null && key in opt_values) ? opt_values[key] : match;
  1417. });
  1418. }
  1419. return str;
  1420. }
  1421. function padNumber(num, digits, minusSign, trim, negWrap) {
  1422. if (minusSign === void 0) { minusSign = '-'; }
  1423. var neg = '';
  1424. if (num < 0 || (negWrap && num <= 0)) {
  1425. if (negWrap) {
  1426. num = -num + 1;
  1427. }
  1428. else {
  1429. num = -num;
  1430. neg = minusSign;
  1431. }
  1432. }
  1433. var strNum = String(num);
  1434. while (strNum.length < digits) {
  1435. strNum = '0' + strNum;
  1436. }
  1437. if (trim) {
  1438. strNum = strNum.substr(strNum.length - digits);
  1439. }
  1440. return neg + strNum;
  1441. }
  1442. function formatFractionalSeconds(milliseconds, digits) {
  1443. var strMs = padNumber(milliseconds, 3);
  1444. return strMs.substr(0, digits);
  1445. }
  1446. /**
  1447. * Returns a date formatter that transforms a date into its locale digit representation
  1448. */
  1449. function dateGetter(name, size, offset, trim, negWrap) {
  1450. if (offset === void 0) { offset = 0; }
  1451. if (trim === void 0) { trim = false; }
  1452. if (negWrap === void 0) { negWrap = false; }
  1453. return function (date, locale) {
  1454. var part = getDatePart(name, date);
  1455. if (offset > 0 || part > -offset) {
  1456. part += offset;
  1457. }
  1458. if (name === DateType.Hours) {
  1459. if (part === 0 && offset === -12) {
  1460. part = 12;
  1461. }
  1462. }
  1463. else if (name === DateType.FractionalSeconds) {
  1464. return formatFractionalSeconds(part, size);
  1465. }
  1466. var localeMinus = getLocaleNumberSymbol(locale, NumberSymbol.MinusSign);
  1467. return padNumber(part, size, localeMinus, trim, negWrap);
  1468. };
  1469. }
  1470. function getDatePart(part, date) {
  1471. switch (part) {
  1472. case DateType.FullYear:
  1473. return date.getFullYear();
  1474. case DateType.Month:
  1475. return date.getMonth();
  1476. case DateType.Date:
  1477. return date.getDate();
  1478. case DateType.Hours:
  1479. return date.getHours();
  1480. case DateType.Minutes:
  1481. return date.getMinutes();
  1482. case DateType.Seconds:
  1483. return date.getSeconds();
  1484. case DateType.FractionalSeconds:
  1485. return date.getMilliseconds();
  1486. case DateType.Day:
  1487. return date.getDay();
  1488. default:
  1489. throw new Error("Unknown DateType value \"" + part + "\".");
  1490. }
  1491. }
  1492. /**
  1493. * Returns a date formatter that transforms a date into its locale string representation
  1494. */
  1495. function dateStrGetter(name, width, form, extended) {
  1496. if (form === void 0) { form = FormStyle.Format; }
  1497. if (extended === void 0) { extended = false; }
  1498. return function (date, locale) {
  1499. return getDateTranslation(date, locale, name, width, form, extended);
  1500. };
  1501. }
  1502. /**
  1503. * Returns the locale translation of a date for a given form, type and width
  1504. */
  1505. function getDateTranslation(date, locale, name, width, form, extended) {
  1506. switch (name) {
  1507. case TranslationType.Months:
  1508. return getLocaleMonthNames(locale, form, width)[date.getMonth()];
  1509. case TranslationType.Days:
  1510. return getLocaleDayNames(locale, form, width)[date.getDay()];
  1511. case TranslationType.DayPeriods:
  1512. var currentHours_1 = date.getHours();
  1513. var currentMinutes_1 = date.getMinutes();
  1514. if (extended) {
  1515. var rules = getLocaleExtraDayPeriodRules(locale);
  1516. var dayPeriods_1 = getLocaleExtraDayPeriods(locale, form, width);
  1517. var result_1;
  1518. rules.forEach(function (rule, index) {
  1519. if (Array.isArray(rule)) {
  1520. // morning, afternoon, evening, night
  1521. var _a = rule[0], hoursFrom = _a.hours, minutesFrom = _a.minutes;
  1522. var _b = rule[1], hoursTo = _b.hours, minutesTo = _b.minutes;
  1523. if (currentHours_1 >= hoursFrom && currentMinutes_1 >= minutesFrom &&
  1524. (currentHours_1 < hoursTo ||
  1525. (currentHours_1 === hoursTo && currentMinutes_1 < minutesTo))) {
  1526. result_1 = dayPeriods_1[index];
  1527. }
  1528. }
  1529. else { // noon or midnight
  1530. var hours = rule.hours, minutes = rule.minutes;
  1531. if (hours === currentHours_1 && minutes === currentMinutes_1) {
  1532. result_1 = dayPeriods_1[index];
  1533. }
  1534. }
  1535. });
  1536. if (result_1) {
  1537. return result_1;
  1538. }
  1539. }
  1540. // if no rules for the day periods, we use am/pm by default
  1541. return getLocaleDayPeriods(locale, form, width)[currentHours_1 < 12 ? 0 : 1];
  1542. case TranslationType.Eras:
  1543. return getLocaleEraNames(locale, width)[date.getFullYear() <= 0 ? 0 : 1];
  1544. default:
  1545. // This default case is not needed by TypeScript compiler, as the switch is exhaustive.
  1546. // However Closure Compiler does not understand that and reports an error in typed mode.
  1547. // The `throw new Error` below works around the problem, and the unexpected: never variable
  1548. // makes sure tsc still checks this code is unreachable.
  1549. var unexpected = name;
  1550. throw new Error("unexpected translation type " + unexpected);
  1551. }
  1552. }
  1553. /**
  1554. * Returns a date formatter that transforms a date and an offset into a timezone with ISO8601 or
  1555. * GMT format depending on the width (eg: short = +0430, short:GMT = GMT+4, long = GMT+04:30,
  1556. * extended = +04:30)
  1557. */
  1558. function timeZoneGetter(width) {
  1559. return function (date, locale, offset) {
  1560. var zone = -1 * offset;
  1561. var minusSign = getLocaleNumberSymbol(locale, NumberSymbol.MinusSign);
  1562. var hours = zone > 0 ? Math.floor(zone / 60) : Math.ceil(zone / 60);
  1563. switch (width) {
  1564. case ZoneWidth.Short:
  1565. return ((zone >= 0) ? '+' : '') + padNumber(hours, 2, minusSign) +
  1566. padNumber(Math.abs(zone % 60), 2, minusSign);
  1567. case ZoneWidth.ShortGMT:
  1568. return 'GMT' + ((zone >= 0) ? '+' : '') + padNumber(hours, 1, minusSign);
  1569. case ZoneWidth.Long:
  1570. return 'GMT' + ((zone >= 0) ? '+' : '') + padNumber(hours, 2, minusSign) + ':' +
  1571. padNumber(Math.abs(zone % 60), 2, minusSign);
  1572. case ZoneWidth.Extended:
  1573. if (offset === 0) {
  1574. return 'Z';
  1575. }
  1576. else {
  1577. return ((zone >= 0) ? '+' : '') + padNumber(hours, 2, minusSign) + ':' +
  1578. padNumber(Math.abs(zone % 60), 2, minusSign);
  1579. }
  1580. default:
  1581. throw new Error("Unknown zone width \"" + width + "\"");
  1582. }
  1583. };
  1584. }
  1585. var JANUARY = 0;
  1586. var THURSDAY = 4;
  1587. function getFirstThursdayOfYear(year) {
  1588. var firstDayOfYear = (new Date(year, JANUARY, 1)).getDay();
  1589. return new Date(year, 0, 1 + ((firstDayOfYear <= THURSDAY) ? THURSDAY : THURSDAY + 7) - firstDayOfYear);
  1590. }
  1591. function getThursdayThisWeek(datetime) {
  1592. return new Date(datetime.getFullYear(), datetime.getMonth(), datetime.getDate() + (THURSDAY - datetime.getDay()));
  1593. }
  1594. function weekGetter(size, monthBased) {
  1595. if (monthBased === void 0) { monthBased = false; }
  1596. return function (date, locale) {
  1597. var result;
  1598. if (monthBased) {
  1599. var nbDaysBefore1stDayOfMonth = new Date(date.getFullYear(), date.getMonth(), 1).getDay() - 1;
  1600. var today = date.getDate();
  1601. result = 1 + Math.floor((today + nbDaysBefore1stDayOfMonth) / 7);
  1602. }
  1603. else {
  1604. var firstThurs = getFirstThursdayOfYear(date.getFullYear());
  1605. var thisThurs = getThursdayThisWeek(date);
  1606. var diff = thisThurs.getTime() - firstThurs.getTime();
  1607. result = 1 + Math.round(diff / 6.048e8); // 6.048e8 ms per week
  1608. }
  1609. return padNumber(result, size, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
  1610. };
  1611. }
  1612. var DATE_FORMATS = {};
  1613. // Based on CLDR formats:
  1614. // See complete list: http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
  1615. // See also explanations: http://cldr.unicode.org/translation/date-time
  1616. // TODO(ocombe): support all missing cldr formats: Y, U, Q, D, F, e, c, j, J, C, A, v, V, X, x
  1617. function getDateFormatter(format) {
  1618. if (DATE_FORMATS[format]) {
  1619. return DATE_FORMATS[format];
  1620. }
  1621. var formatter;
  1622. switch (format) {
  1623. // Era name (AD/BC)
  1624. case 'G':
  1625. case 'GG':
  1626. case 'GGG':
  1627. formatter = dateStrGetter(TranslationType.Eras, TranslationWidth.Abbreviated);
  1628. break;
  1629. case 'GGGG':
  1630. formatter = dateStrGetter(TranslationType.Eras, TranslationWidth.Wide);
  1631. break;
  1632. case 'GGGGG':
  1633. formatter = dateStrGetter(TranslationType.Eras, TranslationWidth.Narrow);
  1634. break;
  1635. // 1 digit representation of the year, e.g. (AD 1 => 1, AD 199 => 199)
  1636. case 'y':
  1637. formatter = dateGetter(DateType.FullYear, 1, 0, false, true);
  1638. break;
  1639. // 2 digit representation of the year, padded (00-99). (e.g. AD 2001 => 01, AD 2010 => 10)
  1640. case 'yy':
  1641. formatter = dateGetter(DateType.FullYear, 2, 0, true, true);
  1642. break;
  1643. // 3 digit representation of the year, padded (000-999). (e.g. AD 2001 => 01, AD 2010 => 10)
  1644. case 'yyy':
  1645. formatter = dateGetter(DateType.FullYear, 3, 0, false, true);
  1646. break;
  1647. // 4 digit representation of the year (e.g. AD 1 => 0001, AD 2010 => 2010)
  1648. case 'yyyy':
  1649. formatter = dateGetter(DateType.FullYear, 4, 0, false, true);
  1650. break;
  1651. // Month of the year (1-12), numeric
  1652. case 'M':
  1653. case 'L':
  1654. formatter = dateGetter(DateType.Month, 1, 1);
  1655. break;
  1656. case 'MM':
  1657. case 'LL':
  1658. formatter = dateGetter(DateType.Month, 2, 1);
  1659. break;
  1660. // Month of the year (January, ...), string, format
  1661. case 'MMM':
  1662. formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Abbreviated);
  1663. break;
  1664. case 'MMMM':
  1665. formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Wide);
  1666. break;
  1667. case 'MMMMM':
  1668. formatter = dateStrGetter(TranslationType.Months, TranslationWidth.Narrow);
  1669. break;
  1670. // Month of the year (January, ...), string, standalone
  1671. case 'LLL':
  1672. formatter =
  1673. dateStrGetter(TranslationType.Months, TranslationWidth.Abbreviated, FormStyle.Standalone);
  1674. break;
  1675. case 'LLLL':
  1676. formatter =
  1677. dateStrGetter(TranslationType.Months, TranslationWidth.Wide, FormStyle.Standalone);
  1678. break;
  1679. case 'LLLLL':
  1680. formatter =
  1681. dateStrGetter(TranslationType.Months, TranslationWidth.Narrow, FormStyle.Standalone);
  1682. break;
  1683. // Week of the year (1, ... 52)
  1684. case 'w':
  1685. formatter = weekGetter(1);
  1686. break;
  1687. case 'ww':
  1688. formatter = weekGetter(2);
  1689. break;
  1690. // Week of the month (1, ...)
  1691. case 'W':
  1692. formatter = weekGetter(1, true);
  1693. break;
  1694. // Day of the month (1-31)
  1695. case 'd':
  1696. formatter = dateGetter(DateType.Date, 1);
  1697. break;
  1698. case 'dd':
  1699. formatter = dateGetter(DateType.Date, 2);
  1700. break;
  1701. // Day of the Week
  1702. case 'E':
  1703. case 'EE':
  1704. case 'EEE':
  1705. formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Abbreviated);
  1706. break;
  1707. case 'EEEE':
  1708. formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Wide);
  1709. break;
  1710. case 'EEEEE':
  1711. formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Narrow);
  1712. break;
  1713. case 'EEEEEE':
  1714. formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Short);
  1715. break;
  1716. // Generic period of the day (am-pm)
  1717. case 'a':
  1718. case 'aa':
  1719. case 'aaa':
  1720. formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Abbreviated);
  1721. break;
  1722. case 'aaaa':
  1723. formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Wide);
  1724. break;
  1725. case 'aaaaa':
  1726. formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Narrow);
  1727. break;
  1728. // Extended period of the day (midnight, at night, ...), standalone
  1729. case 'b':
  1730. case 'bb':
  1731. case 'bbb':
  1732. formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Abbreviated, FormStyle.Standalone, true);
  1733. break;
  1734. case 'bbbb':
  1735. formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Wide, FormStyle.Standalone, true);
  1736. break;
  1737. case 'bbbbb':
  1738. formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Narrow, FormStyle.Standalone, true);
  1739. break;
  1740. // Extended period of the day (midnight, night, ...), standalone
  1741. case 'B':
  1742. case 'BB':
  1743. case 'BBB':
  1744. formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Abbreviated, FormStyle.Format, true);
  1745. break;
  1746. case 'BBBB':
  1747. formatter =
  1748. dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Wide, FormStyle.Format, true);
  1749. break;
  1750. case 'BBBBB':
  1751. formatter = dateStrGetter(TranslationType.DayPeriods, TranslationWidth.Narrow, FormStyle.Format, true);
  1752. break;
  1753. // Hour in AM/PM, (1-12)
  1754. case 'h':
  1755. formatter = dateGetter(DateType.Hours, 1, -12);
  1756. break;
  1757. case 'hh':
  1758. formatter = dateGetter(DateType.Hours, 2, -12);
  1759. break;
  1760. // Hour of the day (0-23)
  1761. case 'H':
  1762. formatter = dateGetter(DateType.Hours, 1);
  1763. break;
  1764. // Hour in day, padded (00-23)
  1765. case 'HH':
  1766. formatter = dateGetter(DateType.Hours, 2);
  1767. break;
  1768. // Minute of the hour (0-59)
  1769. case 'm':
  1770. formatter = dateGetter(DateType.Minutes, 1);
  1771. break;
  1772. case 'mm':
  1773. formatter = dateGetter(DateType.Minutes, 2);
  1774. break;
  1775. // Second of the minute (0-59)
  1776. case 's':
  1777. formatter = dateGetter(DateType.Seconds, 1);
  1778. break;
  1779. case 'ss':
  1780. formatter = dateGetter(DateType.Seconds, 2);
  1781. break;
  1782. // Fractional second
  1783. case 'S':
  1784. formatter = dateGetter(DateType.FractionalSeconds, 1);
  1785. break;
  1786. case 'SS':
  1787. formatter = dateGetter(DateType.FractionalSeconds, 2);
  1788. break;
  1789. case 'SSS':
  1790. formatter = dateGetter(DateType.FractionalSeconds, 3);
  1791. break;
  1792. // Timezone ISO8601 short format (-0430)
  1793. case 'Z':
  1794. case 'ZZ':
  1795. case 'ZZZ':
  1796. formatter = timeZoneGetter(ZoneWidth.Short);
  1797. break;
  1798. // Timezone ISO8601 extended format (-04:30)
  1799. case 'ZZZZZ':
  1800. formatter = timeZoneGetter(ZoneWidth.Extended);
  1801. break;
  1802. // Timezone GMT short format (GMT+4)
  1803. case 'O':
  1804. case 'OO':
  1805. case 'OOO':
  1806. // Should be location, but fallback to format O instead because we don't have the data yet
  1807. case 'z':
  1808. case 'zz':
  1809. case 'zzz':
  1810. formatter = timeZoneGetter(ZoneWidth.ShortGMT);
  1811. break;
  1812. // Timezone GMT long format (GMT+0430)
  1813. case 'OOOO':
  1814. case 'ZZZZ':
  1815. // Should be location, but fallback to format O instead because we don't have the data yet
  1816. case 'zzzz':
  1817. formatter = timeZoneGetter(ZoneWidth.Long);
  1818. break;
  1819. default:
  1820. return null;
  1821. }
  1822. DATE_FORMATS[format] = formatter;
  1823. return formatter;
  1824. }
  1825. function timezoneToOffset(timezone, fallback) {
  1826. // Support: IE 9-11 only, Edge 13-15+
  1827. // IE/Edge do not "understand" colon (`:`) in timezone
  1828. timezone = timezone.replace(/:/g, '');
  1829. var requestedTimezoneOffset = Date.parse('Jan 01, 1970 00:00:00 ' + timezone) / 60000;
  1830. return isNaN(requestedTimezoneOffset) ? fallback : requestedTimezoneOffset;
  1831. }
  1832. function addDateMinutes(date, minutes) {
  1833. date = new Date(date.getTime());
  1834. date.setMinutes(date.getMinutes() + minutes);
  1835. return date;
  1836. }
  1837. function convertTimezoneToLocal(date, timezone, reverse) {
  1838. var reverseValue = reverse ? -1 : 1;
  1839. var dateTimezoneOffset = date.getTimezoneOffset();
  1840. var timezoneOffset = timezoneToOffset(timezone, dateTimezoneOffset);
  1841. return addDateMinutes(date, reverseValue * (timezoneOffset - dateTimezoneOffset));
  1842. }
  1843. /**
  1844. * Converts a value to date.
  1845. *
  1846. * Supported input formats:
  1847. * - `Date`
  1848. * - number: timestamp
  1849. * - string: numeric (e.g. "1234"), ISO and date strings in a format supported by
  1850. * [Date.parse()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse).
  1851. * Note: ISO strings without time return a date without timeoffset.
  1852. *
  1853. * Throws if unable to convert to a date.
  1854. */
  1855. function toDate(value) {
  1856. if (isDate(value)) {
  1857. return value;
  1858. }
  1859. if (typeof value === 'number' && !isNaN(value)) {
  1860. return new Date(value);
  1861. }
  1862. if (typeof value === 'string') {
  1863. value = value.trim();
  1864. var parsedNb = parseFloat(value);
  1865. // any string that only contains numbers, like "1234" but not like "1234hello"
  1866. if (!isNaN(value - parsedNb)) {
  1867. return new Date(parsedNb);
  1868. }
  1869. if (/^(\d{4}-\d{1,2}-\d{1,2})$/.test(value)) {
  1870. /* For ISO Strings without time the day, month and year must be extracted from the ISO String
  1871. before Date creation to avoid time offset and errors in the new Date.
  1872. If we only replace '-' with ',' in the ISO String ("2015,01,01"), and try to create a new
  1873. date, some browsers (e.g. IE 9) will throw an invalid Date error.
  1874. If we leave the '-' ("2015-01-01") and try to create a new Date("2015-01-01") the timeoffset
  1875. is applied.
  1876. Note: ISO months are 0 for January, 1 for February, ... */
  1877. var _a = __read(value.split('-').map(function (val) { return +val; }), 3), y = _a[0], m = _a[1], d = _a[2];
  1878. return new Date(y, m - 1, d);
  1879. }
  1880. var match = void 0;
  1881. if (match = value.match(ISO8601_DATE_REGEX)) {
  1882. return isoStringToDate(match);
  1883. }
  1884. }
  1885. var date = new Date(value);
  1886. if (!isDate(date)) {
  1887. throw new Error("Unable to convert \"" + value + "\" into a date");
  1888. }
  1889. return date;
  1890. }
  1891. /**
  1892. * Converts a date in ISO8601 to a Date.
  1893. * Used instead of `Date.parse` because of browser discrepancies.
  1894. */
  1895. function isoStringToDate(match) {
  1896. var date = new Date(0);
  1897. var tzHour = 0;
  1898. var tzMin = 0;
  1899. // match[8] means that the string contains "Z" (UTC) or a timezone like "+01:00" or "+0100"
  1900. var dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear;
  1901. var timeSetter = match[8] ? date.setUTCHours : date.setHours;
  1902. // if there is a timezone defined like "+01:00" or "+0100"
  1903. if (match[9]) {
  1904. tzHour = Number(match[9] + match[10]);
  1905. tzMin = Number(match[9] + match[11]);
  1906. }
  1907. dateSetter.call(date, Number(match[1]), Number(match[2]) - 1, Number(match[3]));
  1908. var h = Number(match[4] || 0) - tzHour;
  1909. var m = Number(match[5] || 0) - tzMin;
  1910. var s = Number(match[6] || 0);
  1911. var ms = Math.round(parseFloat('0.' + (match[7] || 0)) * 1000);
  1912. timeSetter.call(date, h, m, s, ms);
  1913. return date;
  1914. }
  1915. function isDate(value) {
  1916. return value instanceof Date && !isNaN(value.valueOf());
  1917. }
  1918. /**
  1919. * @license
  1920. * Copyright Google Inc. All Rights Reserved.
  1921. *
  1922. * Use of this source code is governed by an MIT-style license that can be
  1923. * found in the LICENSE file at https://angular.io/license
  1924. */
  1925. var NUMBER_FORMAT_REGEXP = /^(\d+)?\.((\d+)(-(\d+))?)?$/;
  1926. var MAX_DIGITS = 22;
  1927. var DECIMAL_SEP = '.';
  1928. var ZERO_CHAR = '0';
  1929. var PATTERN_SEP = ';';
  1930. var GROUP_SEP = ',';
  1931. var DIGIT_CHAR = '#';
  1932. var CURRENCY_CHAR = '¤';
  1933. var PERCENT_CHAR = '%';
  1934. /**
  1935. * Transforms a number to a locale string based on a style and a format.
  1936. */
  1937. function formatNumberToLocaleString(value, pattern, locale, groupSymbol, decimalSymbol, digitsInfo, isPercent) {
  1938. if (isPercent === void 0) { isPercent = false; }
  1939. var formattedText = '';
  1940. var isZero = false;
  1941. if (!isFinite(value)) {
  1942. formattedText = getLocaleNumberSymbol(locale, NumberSymbol.Infinity);
  1943. }
  1944. else {
  1945. var parsedNumber = parseNumber(value);
  1946. if (isPercent) {
  1947. parsedNumber = toPercent(parsedNumber);
  1948. }
  1949. var minInt = pattern.minInt;
  1950. var minFraction = pattern.minFrac;
  1951. var maxFraction = pattern.maxFrac;
  1952. if (digitsInfo) {
  1953. var parts = digitsInfo.match(NUMBER_FORMAT_REGEXP);
  1954. if (parts === null) {
  1955. throw new Error(digitsInfo + " is not a valid digit info");
  1956. }
  1957. var minIntPart = parts[1];
  1958. var minFractionPart = parts[3];
  1959. var maxFractionPart = parts[5];
  1960. if (minIntPart != null) {
  1961. minInt = parseIntAutoRadix(minIntPart);
  1962. }
  1963. if (minFractionPart != null) {
  1964. minFraction = parseIntAutoRadix(minFractionPart);
  1965. }
  1966. if (maxFractionPart != null) {
  1967. maxFraction = parseIntAutoRadix(maxFractionPart);
  1968. }
  1969. else if (minFractionPart != null && minFraction > maxFraction) {
  1970. maxFraction = minFraction;
  1971. }
  1972. }
  1973. roundNumber(parsedNumber, minFraction, maxFraction);
  1974. var digits = parsedNumber.digits;
  1975. var integerLen = parsedNumber.integerLen;
  1976. var exponent = parsedNumber.exponent;
  1977. var decimals = [];
  1978. isZero = digits.every(function (d) { return !d; });
  1979. // pad zeros for small numbers
  1980. for (; integerLen < minInt; integerLen++) {
  1981. digits.unshift(0);
  1982. }
  1983. // pad zeros for small numbers
  1984. for (; integerLen < 0; integerLen++) {
  1985. digits.unshift(0);
  1986. }
  1987. // extract decimals digits
  1988. if (integerLen > 0) {
  1989. decimals = digits.splice(integerLen, digits.length);
  1990. }
  1991. else {
  1992. decimals = digits;
  1993. digits = [0];
  1994. }
  1995. // format the integer digits with grouping separators
  1996. var groups = [];
  1997. if (digits.length >= pattern.lgSize) {
  1998. groups.unshift(digits.splice(-pattern.lgSize, digits.length).join(''));
  1999. }
  2000. while (digits.length > pattern.gSize) {
  2001. groups.unshift(digits.splice(-pattern.gSize, digits.length).join(''));
  2002. }
  2003. if (digits.length) {
  2004. groups.unshift(digits.join(''));
  2005. }
  2006. formattedText = groups.join(getLocaleNumberSymbol(locale, groupSymbol));
  2007. // append the decimal digits
  2008. if (decimals.length) {
  2009. formattedText += getLocaleNumberSymbol(locale, decimalSymbol) + decimals.join('');
  2010. }
  2011. if (exponent) {
  2012. formattedText += getLocaleNumberSymbol(locale, NumberSymbol.Exponential) + '+' + exponent;
  2013. }
  2014. }
  2015. if (value < 0 && !isZero) {
  2016. formattedText = pattern.negPre + formattedText + pattern.negSuf;
  2017. }
  2018. else {
  2019. formattedText = pattern.posPre + formattedText + pattern.posSuf;
  2020. }
  2021. return formattedText;
  2022. }
  2023. /**
  2024. * @ngModule CommonModule
  2025. * @description
  2026. *
  2027. * Formats a number as currency using locale rules.
  2028. *
  2029. * @param value The number to format.
  2030. * @param locale A locale code for the locale format rules to use.
  2031. * @param currency A string containing the currency symbol or its name,
  2032. * such as "$" or "Canadian Dollar". Used in output string, but does not affect the operation
  2033. * of the function.
  2034. * @param currencyCode The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)
  2035. * currency code to use in the result string, such as `USD` for the US dollar and `EUR` for the euro.
  2036. * @param digitInfo Decimal representation options, specified by a string in the following format:
  2037. * `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details.
  2038. *
  2039. * @returns The formatted currency value.
  2040. *
  2041. * @see `formatNumber()`
  2042. * @see `DecimalPipe`
  2043. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  2044. *
  2045. * @publicApi
  2046. */
  2047. function formatCurrency(value, locale, currency, currencyCode, digitsInfo) {
  2048. var format = getLocaleNumberFormat(locale, NumberFormatStyle.Currency);
  2049. var pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
  2050. pattern.minFrac = getNumberOfCurrencyDigits(currencyCode);
  2051. pattern.maxFrac = pattern.minFrac;
  2052. var res = formatNumberToLocaleString(value, pattern, locale, NumberSymbol.CurrencyGroup, NumberSymbol.CurrencyDecimal, digitsInfo);
  2053. return res
  2054. .replace(CURRENCY_CHAR, currency)
  2055. // if we have 2 time the currency character, the second one is ignored
  2056. .replace(CURRENCY_CHAR, '');
  2057. }
  2058. /**
  2059. * @ngModule CommonModule
  2060. * @description
  2061. *
  2062. * Formats a number as a percentage according to locale rules.
  2063. *
  2064. * @param value The number to format.
  2065. * @param locale A locale code for the locale format rules to use.
  2066. * @param digitInfo Decimal representation options, specified by a string in the following format:
  2067. * `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details.
  2068. *
  2069. * @returns The formatted percentage value.
  2070. *
  2071. * @see `formatNumber()`
  2072. * @see `DecimalPipe`
  2073. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  2074. * @publicApi
  2075. *
  2076. */
  2077. function formatPercent(value, locale, digitsInfo) {
  2078. var format = getLocaleNumberFormat(locale, NumberFormatStyle.Percent);
  2079. var pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
  2080. var res = formatNumberToLocaleString(value, pattern, locale, NumberSymbol.Group, NumberSymbol.Decimal, digitsInfo, true);
  2081. return res.replace(new RegExp(PERCENT_CHAR, 'g'), getLocaleNumberSymbol(locale, NumberSymbol.PercentSign));
  2082. }
  2083. /**
  2084. * @ngModule CommonModule
  2085. * @description
  2086. *
  2087. * Formats a number as text, with group sizing, separator, and other
  2088. * parameters based on the locale.
  2089. *
  2090. * @param value The number to format.
  2091. * @param locale A locale code for the locale format rules to use.
  2092. * @param digitInfo Decimal representation options, specified by a string in the following format:
  2093. * `{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}`. See `DecimalPipe` for more details.
  2094. *
  2095. * @returns The formatted text string.
  2096. * @see [Internationalization (i18n) Guide](https://angular.io/guide/i18n)
  2097. *
  2098. * @publicApi
  2099. */
  2100. function formatNumber(value, locale, digitsInfo) {
  2101. var format = getLocaleNumberFormat(locale, NumberFormatStyle.Decimal);
  2102. var pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
  2103. return formatNumberToLocaleString(value, pattern, locale, NumberSymbol.Group, NumberSymbol.Decimal, digitsInfo);
  2104. }
  2105. function parseNumberFormat(format, minusSign) {
  2106. if (minusSign === void 0) { minusSign = '-'; }
  2107. var p = {
  2108. minInt: 1,
  2109. minFrac: 0,
  2110. maxFrac: 0,
  2111. posPre: '',
  2112. posSuf: '',
  2113. negPre: '',
  2114. negSuf: '',
  2115. gSize: 0,
  2116. lgSize: 0
  2117. };
  2118. var patternParts = format.split(PATTERN_SEP);
  2119. var positive = patternParts[0];
  2120. var negative = patternParts[1];
  2121. var positiveParts = positive.indexOf(DECIMAL_SEP) !== -1 ?
  2122. positive.split(DECIMAL_SEP) :
  2123. [
  2124. positive.substring(0, positive.lastIndexOf(ZERO_CHAR) + 1),
  2125. positive.substring(positive.lastIndexOf(ZERO_CHAR) + 1)
  2126. ], integer = positiveParts[0], fraction = positiveParts[1] || '';
  2127. p.posPre = integer.substr(0, integer.indexOf(DIGIT_CHAR));
  2128. for (var i = 0; i < fraction.length; i++) {
  2129. var ch = fraction.charAt(i);
  2130. if (ch === ZERO_CHAR) {
  2131. p.minFrac = p.maxFrac = i + 1;
  2132. }
  2133. else if (ch === DIGIT_CHAR) {
  2134. p.maxFrac = i + 1;
  2135. }
  2136. else {
  2137. p.posSuf += ch;
  2138. }
  2139. }
  2140. var groups = integer.split(GROUP_SEP);
  2141. p.gSize = groups[1] ? groups[1].length : 0;
  2142. p.lgSize = (groups[2] || groups[1]) ? (groups[2] || groups[1]).length : 0;
  2143. if (negative) {
  2144. var trunkLen = positive.length - p.posPre.length - p.posSuf.length, pos = negative.indexOf(DIGIT_CHAR);
  2145. p.negPre = negative.substr(0, pos).replace(/'/g, '');
  2146. p.negSuf = negative.substr(pos + trunkLen).replace(/'/g, '');
  2147. }
  2148. else {
  2149. p.negPre = minusSign + p.posPre;
  2150. p.negSuf = p.posSuf;
  2151. }
  2152. return p;
  2153. }
  2154. // Transforms a parsed number into a percentage by multiplying it by 100
  2155. function toPercent(parsedNumber) {
  2156. // if the number is 0, don't do anything
  2157. if (parsedNumber.digits[0] === 0) {
  2158. return parsedNumber;
  2159. }
  2160. // Getting the current number of decimals
  2161. var fractionLen = parsedNumber.digits.length - parsedNumber.integerLen;
  2162. if (parsedNumber.exponent) {
  2163. parsedNumber.exponent += 2;
  2164. }
  2165. else {
  2166. if (fractionLen === 0) {
  2167. parsedNumber.digits.push(0, 0);
  2168. }
  2169. else if (fractionLen === 1) {
  2170. parsedNumber.digits.push(0);
  2171. }
  2172. parsedNumber.integerLen += 2;
  2173. }
  2174. return parsedNumber;
  2175. }
  2176. /**
  2177. * Parses a number.
  2178. * Significant bits of this parse algorithm came from https://github.com/MikeMcl/big.js/
  2179. */
  2180. function parseNumber(num) {
  2181. var numStr = Math.abs(num) + '';
  2182. var exponent = 0, digits, integerLen;
  2183. var i, j, zeros;
  2184. // Decimal point?
  2185. if ((integerLen = numStr.indexOf(DECIMAL_SEP)) > -1) {
  2186. numStr = numStr.replace(DECIMAL_SEP, '');
  2187. }
  2188. // Exponential form?
  2189. if ((i = numStr.search(/e/i)) > 0) {
  2190. // Work out the exponent.
  2191. if (integerLen < 0)
  2192. integerLen = i;
  2193. integerLen += +numStr.slice(i + 1);
  2194. numStr = numStr.substring(0, i);
  2195. }
  2196. else if (integerLen < 0) {
  2197. // There was no decimal point or exponent so it is an integer.
  2198. integerLen = numStr.length;
  2199. }
  2200. // Count the number of leading zeros.
  2201. for (i = 0; numStr.charAt(i) === ZERO_CHAR; i++) { /* empty */
  2202. }
  2203. if (i === (zeros = numStr.length)) {
  2204. // The digits are all zero.
  2205. digits = [0];
  2206. integerLen = 1;
  2207. }
  2208. else {
  2209. // Count the number of trailing zeros
  2210. zeros--;
  2211. while (numStr.charAt(zeros) === ZERO_CHAR)
  2212. zeros--;
  2213. // Trailing zeros are insignificant so ignore them
  2214. integerLen -= i;
  2215. digits = [];
  2216. // Convert string to array of digits without leading/trailing zeros.
  2217. for (j = 0; i <= zeros; i++, j++) {
  2218. digits[j] = Number(numStr.charAt(i));
  2219. }
  2220. }
  2221. // If the number overflows the maximum allowed digits then use an exponent.
  2222. if (integerLen > MAX_DIGITS) {
  2223. digits = digits.splice(0, MAX_DIGITS - 1);
  2224. exponent = integerLen - 1;
  2225. integerLen = 1;
  2226. }
  2227. return { digits: digits, exponent: exponent, integerLen: integerLen };
  2228. }
  2229. /**
  2230. * Round the parsed number to the specified number of decimal places
  2231. * This function changes the parsedNumber in-place
  2232. */
  2233. function roundNumber(parsedNumber, minFrac, maxFrac) {
  2234. if (minFrac > maxFrac) {
  2235. throw new Error("The minimum number of digits after fraction (" + minFrac + ") is higher than the maximum (" + maxFrac + ").");
  2236. }
  2237. var digits = parsedNumber.digits;
  2238. var fractionLen = digits.length - parsedNumber.integerLen;
  2239. var fractionSize = Math.min(Math.max(minFrac, fractionLen), maxFrac);
  2240. // The index of the digit to where rounding is to occur
  2241. var roundAt = fractionSize + parsedNumber.integerLen;
  2242. var digit = digits[roundAt];
  2243. if (roundAt > 0) {
  2244. // Drop fractional digits beyond `roundAt`
  2245. digits.splice(Math.max(parsedNumber.integerLen, roundAt));
  2246. // Set non-fractional digits beyond `roundAt` to 0
  2247. for (var j = roundAt; j < digits.length; j++) {
  2248. digits[j] = 0;
  2249. }
  2250. }
  2251. else {
  2252. // We rounded to zero so reset the parsedNumber
  2253. fractionLen = Math.max(0, fractionLen);
  2254. parsedNumber.integerLen = 1;
  2255. digits.length = Math.max(1, roundAt = fractionSize + 1);
  2256. digits[0] = 0;
  2257. for (var i = 1; i < roundAt; i++)
  2258. digits[i] = 0;
  2259. }
  2260. if (digit >= 5) {
  2261. if (roundAt - 1 < 0) {
  2262. for (var k = 0; k > roundAt; k--) {
  2263. digits.unshift(0);
  2264. parsedNumber.integerLen++;
  2265. }
  2266. digits.unshift(1);
  2267. parsedNumber.integerLen++;
  2268. }
  2269. else {
  2270. digits[roundAt - 1]++;
  2271. }
  2272. }
  2273. // Pad out with zeros to get the required fraction length
  2274. for (; fractionLen < Math.max(0, fractionSize); fractionLen++)
  2275. digits.push(0);
  2276. var dropTrailingZeros = fractionSize !== 0;
  2277. // Minimal length = nb of decimals required + current nb of integers
  2278. // Any number besides that is optional and can be removed if it's a trailing 0
  2279. var minLen = minFrac + parsedNumber.integerLen;
  2280. // Do any carrying, e.g. a digit was rounded up to 10
  2281. var carry = digits.reduceRight(function (carry, d, i, digits) {
  2282. d = d + carry;
  2283. digits[i] = d < 10 ? d : d - 10; // d % 10
  2284. if (dropTrailingZeros) {
  2285. // Do not keep meaningless fractional trailing zeros (e.g. 15.52000 --> 15.52)
  2286. if (digits[i] === 0 && i >= minLen) {
  2287. digits.pop();
  2288. }
  2289. else {
  2290. dropTrailingZeros = false;
  2291. }
  2292. }
  2293. return d >= 10 ? 1 : 0; // Math.floor(d / 10);
  2294. }, 0);
  2295. if (carry) {
  2296. digits.unshift(carry);
  2297. parsedNumber.integerLen++;
  2298. }
  2299. }
  2300. function parseIntAutoRadix(text) {
  2301. var result = parseInt(text);
  2302. if (isNaN(result)) {
  2303. throw new Error('Invalid integer literal when parsing ' + text);
  2304. }
  2305. return result;
  2306. }
  2307. /**
  2308. * @license
  2309. * Copyright Google Inc. All Rights Reserved.
  2310. *
  2311. * Use of this source code is governed by an MIT-style license that can be
  2312. * found in the LICENSE file at https://angular.io/license
  2313. */
  2314. /**
  2315. * @deprecated from v5
  2316. */
  2317. var DEPRECATED_PLURAL_FN = new InjectionToken('UseV4Plurals');
  2318. /**
  2319. * @publicApi
  2320. */
  2321. var NgLocalization = /** @class */ (function () {
  2322. function NgLocalization() {
  2323. }
  2324. return NgLocalization;
  2325. }());
  2326. /**
  2327. * Returns the plural category for a given value.
  2328. * - "=value" when the case exists,
  2329. * - the plural category otherwise
  2330. */
  2331. function getPluralCategory(value, cases, ngLocalization, locale) {
  2332. var key = "=" + value;
  2333. if (cases.indexOf(key) > -1) {
  2334. return key;
  2335. }
  2336. key = ngLocalization.getPluralCategory(value, locale);
  2337. if (cases.indexOf(key) > -1) {
  2338. return key;
  2339. }
  2340. if (cases.indexOf('other') > -1) {
  2341. return 'other';
  2342. }
  2343. throw new Error("No plural message found for value \"" + value + "\"");
  2344. }
  2345. /**
  2346. * Returns the plural case based on the locale
  2347. *
  2348. * @publicApi
  2349. */
  2350. var NgLocaleLocalization = /** @class */ (function (_super) {
  2351. __extends(NgLocaleLocalization, _super);
  2352. function NgLocaleLocalization(locale,
  2353. /** @deprecated from v5 */
  2354. deprecatedPluralFn) {
  2355. var _this = _super.call(this) || this;
  2356. _this.locale = locale;
  2357. _this.deprecatedPluralFn = deprecatedPluralFn;
  2358. return _this;
  2359. }
  2360. NgLocaleLocalization.prototype.getPluralCategory = function (value, locale) {
  2361. var plural = this.deprecatedPluralFn ? this.deprecatedPluralFn(locale || this.locale, value) :
  2362. getLocalePluralCase(locale || this.locale)(value);
  2363. switch (plural) {
  2364. case Plural.Zero:
  2365. return 'zero';
  2366. case Plural.One:
  2367. return 'one';
  2368. case Plural.Two:
  2369. return 'two';
  2370. case Plural.Few:
  2371. return 'few';
  2372. case Plural.Many:
  2373. return 'many';
  2374. default:
  2375. return 'other';
  2376. }
  2377. };
  2378. NgLocaleLocalization = __decorate([
  2379. Injectable(),
  2380. __param(0, Inject(LOCALE_ID)),
  2381. __param(1, Optional()), __param(1, Inject(DEPRECATED_PLURAL_FN)),
  2382. __metadata("design:paramtypes", [String, Object])
  2383. ], NgLocaleLocalization);
  2384. return NgLocaleLocalization;
  2385. }(NgLocalization));
  2386. /**
  2387. * Returns the plural case based on the locale
  2388. *
  2389. * @deprecated from v5 the plural case function is in locale data files common/locales/*.ts
  2390. * @publicApi
  2391. */
  2392. function getPluralCase(locale, nLike) {
  2393. // TODO(vicb): lazy compute
  2394. if (typeof nLike === 'string') {
  2395. nLike = parseInt(nLike, 10);
  2396. }
  2397. var n = nLike;
  2398. var nDecimal = n.toString().replace(/^[^.]*\.?/, '');
  2399. var i = Math.floor(Math.abs(n));
  2400. var v = nDecimal.length;
  2401. var f = parseInt(nDecimal, 10);
  2402. var t = parseInt(n.toString().replace(/^[^.]*\.?|0+$/g, ''), 10) || 0;
  2403. var lang = locale.split('-')[0].toLowerCase();
  2404. switch (lang) {
  2405. case 'af':
  2406. case 'asa':
  2407. case 'az':
  2408. case 'bem':
  2409. case 'bez':
  2410. case 'bg':
  2411. case 'brx':
  2412. case 'ce':
  2413. case 'cgg':
  2414. case 'chr':
  2415. case 'ckb':
  2416. case 'ee':
  2417. case 'el':
  2418. case 'eo':
  2419. case 'es':
  2420. case 'eu':
  2421. case 'fo':
  2422. case 'fur':
  2423. case 'gsw':
  2424. case 'ha':
  2425. case 'haw':
  2426. case 'hu':
  2427. case 'jgo':
  2428. case 'jmc':
  2429. case 'ka':
  2430. case 'kk':
  2431. case 'kkj':
  2432. case 'kl':
  2433. case 'ks':
  2434. case 'ksb':
  2435. case 'ky':
  2436. case 'lb':
  2437. case 'lg':
  2438. case 'mas':
  2439. case 'mgo':
  2440. case 'ml':
  2441. case 'mn':
  2442. case 'nb':
  2443. case 'nd':
  2444. case 'ne':
  2445. case 'nn':
  2446. case 'nnh':
  2447. case 'nyn':
  2448. case 'om':
  2449. case 'or':
  2450. case 'os':
  2451. case 'ps':
  2452. case 'rm':
  2453. case 'rof':
  2454. case 'rwk':
  2455. case 'saq':
  2456. case 'seh':
  2457. case 'sn':
  2458. case 'so':
  2459. case 'sq':
  2460. case 'ta':
  2461. case 'te':
  2462. case 'teo':
  2463. case 'tk':
  2464. case 'tr':
  2465. case 'ug':
  2466. case 'uz':
  2467. case 'vo':
  2468. case 'vun':
  2469. case 'wae':
  2470. case 'xog':
  2471. if (n === 1)
  2472. return Plural.One;
  2473. return Plural.Other;
  2474. case 'ak':
  2475. case 'ln':
  2476. case 'mg':
  2477. case 'pa':
  2478. case 'ti':
  2479. if (n === Math.floor(n) && n >= 0 && n <= 1)
  2480. return Plural.One;
  2481. return Plural.Other;
  2482. case 'am':
  2483. case 'as':
  2484. case 'bn':
  2485. case 'fa':
  2486. case 'gu':
  2487. case 'hi':
  2488. case 'kn':
  2489. case 'mr':
  2490. case 'zu':
  2491. if (i === 0 || n === 1)
  2492. return Plural.One;
  2493. return Plural.Other;
  2494. case 'ar':
  2495. if (n === 0)
  2496. return Plural.Zero;
  2497. if (n === 1)
  2498. return Plural.One;
  2499. if (n === 2)
  2500. return Plural.Two;
  2501. if (n % 100 === Math.floor(n % 100) && n % 100 >= 3 && n % 100 <= 10)
  2502. return Plural.Few;
  2503. if (n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 99)
  2504. return Plural.Many;
  2505. return Plural.Other;
  2506. case 'ast':
  2507. case 'ca':
  2508. case 'de':
  2509. case 'en':
  2510. case 'et':
  2511. case 'fi':
  2512. case 'fy':
  2513. case 'gl':
  2514. case 'it':
  2515. case 'nl':
  2516. case 'sv':
  2517. case 'sw':
  2518. case 'ur':
  2519. case 'yi':
  2520. if (i === 1 && v === 0)
  2521. return Plural.One;
  2522. return Plural.Other;
  2523. case 'be':
  2524. if (n % 10 === 1 && !(n % 100 === 11))
  2525. return Plural.One;
  2526. if (n % 10 === Math.floor(n % 10) && n % 10 >= 2 && n % 10 <= 4 &&
  2527. !(n % 100 >= 12 && n % 100 <= 14))
  2528. return Plural.Few;
  2529. if (n % 10 === 0 || n % 10 === Math.floor(n % 10) && n % 10 >= 5 && n % 10 <= 9 ||
  2530. n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 14)
  2531. return Plural.Many;
  2532. return Plural.Other;
  2533. case 'br':
  2534. if (n % 10 === 1 && !(n % 100 === 11 || n % 100 === 71 || n % 100 === 91))
  2535. return Plural.One;
  2536. if (n % 10 === 2 && !(n % 100 === 12 || n % 100 === 72 || n % 100 === 92))
  2537. return Plural.Two;
  2538. if (n % 10 === Math.floor(n % 10) && (n % 10 >= 3 && n % 10 <= 4 || n % 10 === 9) &&
  2539. !(n % 100 >= 10 && n % 100 <= 19 || n % 100 >= 70 && n % 100 <= 79 ||
  2540. n % 100 >= 90 && n % 100 <= 99))
  2541. return Plural.Few;
  2542. if (!(n === 0) && n % 1e6 === 0)
  2543. return Plural.Many;
  2544. return Plural.Other;
  2545. case 'bs':
  2546. case 'hr':
  2547. case 'sr':
  2548. if (v === 0 && i % 10 === 1 && !(i % 100 === 11) || f % 10 === 1 && !(f % 100 === 11))
  2549. return Plural.One;
  2550. if (v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 2 && i % 10 <= 4 &&
  2551. !(i % 100 >= 12 && i % 100 <= 14) ||
  2552. f % 10 === Math.floor(f % 10) && f % 10 >= 2 && f % 10 <= 4 &&
  2553. !(f % 100 >= 12 && f % 100 <= 14))
  2554. return Plural.Few;
  2555. return Plural.Other;
  2556. case 'cs':
  2557. case 'sk':
  2558. if (i === 1 && v === 0)
  2559. return Plural.One;
  2560. if (i === Math.floor(i) && i >= 2 && i <= 4 && v === 0)
  2561. return Plural.Few;
  2562. if (!(v === 0))
  2563. return Plural.Many;
  2564. return Plural.Other;
  2565. case 'cy':
  2566. if (n === 0)
  2567. return Plural.Zero;
  2568. if (n === 1)
  2569. return Plural.One;
  2570. if (n === 2)
  2571. return Plural.Two;
  2572. if (n === 3)
  2573. return Plural.Few;
  2574. if (n === 6)
  2575. return Plural.Many;
  2576. return Plural.Other;
  2577. case 'da':
  2578. if (n === 1 || !(t === 0) && (i === 0 || i === 1))
  2579. return Plural.One;
  2580. return Plural.Other;
  2581. case 'dsb':
  2582. case 'hsb':
  2583. if (v === 0 && i % 100 === 1 || f % 100 === 1)
  2584. return Plural.One;
  2585. if (v === 0 && i % 100 === 2 || f % 100 === 2)
  2586. return Plural.Two;
  2587. if (v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 3 && i % 100 <= 4 ||
  2588. f % 100 === Math.floor(f % 100) && f % 100 >= 3 && f % 100 <= 4)
  2589. return Plural.Few;
  2590. return Plural.Other;
  2591. case 'ff':
  2592. case 'fr':
  2593. case 'hy':
  2594. case 'kab':
  2595. if (i === 0 || i === 1)
  2596. return Plural.One;
  2597. return Plural.Other;
  2598. case 'fil':
  2599. if (v === 0 && (i === 1 || i === 2 || i === 3) ||
  2600. v === 0 && !(i % 10 === 4 || i % 10 === 6 || i % 10 === 9) ||
  2601. !(v === 0) && !(f % 10 === 4 || f % 10 === 6 || f % 10 === 9))
  2602. return Plural.One;
  2603. return Plural.Other;
  2604. case 'ga':
  2605. if (n === 1)
  2606. return Plural.One;
  2607. if (n === 2)
  2608. return Plural.Two;
  2609. if (n === Math.floor(n) && n >= 3 && n <= 6)
  2610. return Plural.Few;
  2611. if (n === Math.floor(n) && n >= 7 && n <= 10)
  2612. return Plural.Many;
  2613. return Plural.Other;
  2614. case 'gd':
  2615. if (n === 1 || n === 11)
  2616. return Plural.One;
  2617. if (n === 2 || n === 12)
  2618. return Plural.Two;
  2619. if (n === Math.floor(n) && (n >= 3 && n <= 10 || n >= 13 && n <= 19))
  2620. return Plural.Few;
  2621. return Plural.Other;
  2622. case 'gv':
  2623. if (v === 0 && i % 10 === 1)
  2624. return Plural.One;
  2625. if (v === 0 && i % 10 === 2)
  2626. return Plural.Two;
  2627. if (v === 0 &&
  2628. (i % 100 === 0 || i % 100 === 20 || i % 100 === 40 || i % 100 === 60 || i % 100 === 80))
  2629. return Plural.Few;
  2630. if (!(v === 0))
  2631. return Plural.Many;
  2632. return Plural.Other;
  2633. case 'he':
  2634. if (i === 1 && v === 0)
  2635. return Plural.One;
  2636. if (i === 2 && v === 0)
  2637. return Plural.Two;
  2638. if (v === 0 && !(n >= 0 && n <= 10) && n % 10 === 0)
  2639. return Plural.Many;
  2640. return Plural.Other;
  2641. case 'is':
  2642. if (t === 0 && i % 10 === 1 && !(i % 100 === 11) || !(t === 0))
  2643. return Plural.One;
  2644. return Plural.Other;
  2645. case 'ksh':
  2646. if (n === 0)
  2647. return Plural.Zero;
  2648. if (n === 1)
  2649. return Plural.One;
  2650. return Plural.Other;
  2651. case 'kw':
  2652. case 'naq':
  2653. case 'se':
  2654. case 'smn':
  2655. if (n === 1)
  2656. return Plural.One;
  2657. if (n === 2)
  2658. return Plural.Two;
  2659. return Plural.Other;
  2660. case 'lag':
  2661. if (n === 0)
  2662. return Plural.Zero;
  2663. if ((i === 0 || i === 1) && !(n === 0))
  2664. return Plural.One;
  2665. return Plural.Other;
  2666. case 'lt':
  2667. if (n % 10 === 1 && !(n % 100 >= 11 && n % 100 <= 19))
  2668. return Plural.One;
  2669. if (n % 10 === Math.floor(n % 10) && n % 10 >= 2 && n % 10 <= 9 &&
  2670. !(n % 100 >= 11 && n % 100 <= 19))
  2671. return Plural.Few;
  2672. if (!(f === 0))
  2673. return Plural.Many;
  2674. return Plural.Other;
  2675. case 'lv':
  2676. case 'prg':
  2677. if (n % 10 === 0 || n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 19 ||
  2678. v === 2 && f % 100 === Math.floor(f % 100) && f % 100 >= 11 && f % 100 <= 19)
  2679. return Plural.Zero;
  2680. if (n % 10 === 1 && !(n % 100 === 11) || v === 2 && f % 10 === 1 && !(f % 100 === 11) ||
  2681. !(v === 2) && f % 10 === 1)
  2682. return Plural.One;
  2683. return Plural.Other;
  2684. case 'mk':
  2685. if (v === 0 && i % 10 === 1 || f % 10 === 1)
  2686. return Plural.One;
  2687. return Plural.Other;
  2688. case 'mt':
  2689. if (n === 1)
  2690. return Plural.One;
  2691. if (n === 0 || n % 100 === Math.floor(n % 100) && n % 100 >= 2 && n % 100 <= 10)
  2692. return Plural.Few;
  2693. if (n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 19)
  2694. return Plural.Many;
  2695. return Plural.Other;
  2696. case 'pl':
  2697. if (i === 1 && v === 0)
  2698. return Plural.One;
  2699. if (v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 2 && i % 10 <= 4 &&
  2700. !(i % 100 >= 12 && i % 100 <= 14))
  2701. return Plural.Few;
  2702. if (v === 0 && !(i === 1) && i % 10 === Math.floor(i % 10) && i % 10 >= 0 && i % 10 <= 1 ||
  2703. v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 5 && i % 10 <= 9 ||
  2704. v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 12 && i % 100 <= 14)
  2705. return Plural.Many;
  2706. return Plural.Other;
  2707. case 'pt':
  2708. if (n === Math.floor(n) && n >= 0 && n <= 2 && !(n === 2))
  2709. return Plural.One;
  2710. return Plural.Other;
  2711. case 'ro':
  2712. if (i === 1 && v === 0)
  2713. return Plural.One;
  2714. if (!(v === 0) || n === 0 ||
  2715. !(n === 1) && n % 100 === Math.floor(n % 100) && n % 100 >= 1 && n % 100 <= 19)
  2716. return Plural.Few;
  2717. return Plural.Other;
  2718. case 'ru':
  2719. case 'uk':
  2720. if (v === 0 && i % 10 === 1 && !(i % 100 === 11))
  2721. return Plural.One;
  2722. if (v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 2 && i % 10 <= 4 &&
  2723. !(i % 100 >= 12 && i % 100 <= 14))
  2724. return Plural.Few;
  2725. if (v === 0 && i % 10 === 0 ||
  2726. v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 5 && i % 10 <= 9 ||
  2727. v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 11 && i % 100 <= 14)
  2728. return Plural.Many;
  2729. return Plural.Other;
  2730. case 'shi':
  2731. if (i === 0 || n === 1)
  2732. return Plural.One;
  2733. if (n === Math.floor(n) && n >= 2 && n <= 10)
  2734. return Plural.Few;
  2735. return Plural.Other;
  2736. case 'si':
  2737. if (n === 0 || n === 1 || i === 0 && f === 1)
  2738. return Plural.One;
  2739. return Plural.Other;
  2740. case 'sl':
  2741. if (v === 0 && i % 100 === 1)
  2742. return Plural.One;
  2743. if (v === 0 && i % 100 === 2)
  2744. return Plural.Two;
  2745. if (v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 3 && i % 100 <= 4 || !(v === 0))
  2746. return Plural.Few;
  2747. return Plural.Other;
  2748. case 'tzm':
  2749. if (n === Math.floor(n) && n >= 0 && n <= 1 || n === Math.floor(n) && n >= 11 && n <= 99)
  2750. return Plural.One;
  2751. return Plural.Other;
  2752. // When there is no specification, the default is always "other"
  2753. // Spec: http://cldr.unicode.org/index/cldr-spec/plural-rules
  2754. // > other (required—general plural form — also used if the language only has a single form)
  2755. default:
  2756. return Plural.Other;
  2757. }
  2758. }
  2759. /**
  2760. * @license
  2761. * Copyright Google Inc. All Rights Reserved.
  2762. *
  2763. * Use of this source code is governed by an MIT-style license that can be
  2764. * found in the LICENSE file at https://angular.io/license
  2765. */
  2766. /**
  2767. * Register global data to be used internally by Angular. See the
  2768. * ["I18n guide"](guide/i18n#i18n-pipes) to know how to import additional locale data.
  2769. *
  2770. * @publicApi
  2771. */
  2772. // The signature registerLocaleData(data: any, extraData?: any) is deprecated since v5.1
  2773. function registerLocaleData(data, localeId, extraData) {
  2774. if (typeof localeId !== 'string') {
  2775. extraData = localeId;
  2776. localeId = data[ɵLocaleDataIndex.LocaleId];
  2777. }
  2778. localeId = localeId.toLowerCase().replace(/_/g, '-');
  2779. ɵLOCALE_DATA[localeId] = data;
  2780. if (extraData) {
  2781. ɵLOCALE_DATA[localeId][ɵLocaleDataIndex.ExtraData] = extraData;
  2782. }
  2783. }
  2784. /**
  2785. * @license
  2786. * Copyright Google Inc. All Rights Reserved.
  2787. *
  2788. * Use of this source code is governed by an MIT-style license that can be
  2789. * found in the LICENSE file at https://angular.io/license
  2790. */
  2791. function parseCookieValue(cookieStr, name) {
  2792. var e_1, _a;
  2793. name = encodeURIComponent(name);
  2794. try {
  2795. for (var _b = __values(cookieStr.split(';')), _c = _b.next(); !_c.done; _c = _b.next()) {
  2796. var cookie = _c.value;
  2797. var eqIndex = cookie.indexOf('=');
  2798. var _d = __read(eqIndex == -1 ? [cookie, ''] : [cookie.slice(0, eqIndex), cookie.slice(eqIndex + 1)], 2), cookieName = _d[0], cookieValue = _d[1];
  2799. if (cookieName.trim() === name) {
  2800. return decodeURIComponent(cookieValue);
  2801. }
  2802. }
  2803. }
  2804. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  2805. finally {
  2806. try {
  2807. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  2808. }
  2809. finally { if (e_1) throw e_1.error; }
  2810. }
  2811. return null;
  2812. }
  2813. /**
  2814. * @license
  2815. * Copyright Google Inc. All Rights Reserved.
  2816. *
  2817. * Use of this source code is governed by an MIT-style license that can be
  2818. * found in the LICENSE file at https://angular.io/license
  2819. */
  2820. /**
  2821. * Used to diff and convert ngStyle/ngClass instructions into [style] and [class] bindings.
  2822. *
  2823. * ngStyle and ngClass both accept various forms of input and behave differently than that
  2824. * of how [style] and [class] behave in Angular.
  2825. *
  2826. * The differences are:
  2827. * - ngStyle and ngClass both **watch** their binding values for changes each time CD runs
  2828. * while [style] and [class] bindings do not (they check for identity changes)
  2829. * - ngStyle allows for unit-based keys (e.g. `{'max-width.px':value}`) and [style] does not
  2830. * - ngClass supports arrays of class values and [class] only accepts map and string values
  2831. * - ngClass allows for multiple className keys (space-separated) within an array or map
  2832. * (as the * key) while [class] only accepts a simple key/value map object
  2833. *
  2834. * Having Angular understand and adapt to all the different forms of behavior is complicated
  2835. * and unnecessary. Instead, ngClass and ngStyle should have their input values be converted
  2836. * into something that the core-level [style] and [class] bindings understand.
  2837. *
  2838. * This [StylingDiffer] class handles this conversion by creating a new input value each time
  2839. * the inner representation of the binding value have changed.
  2840. *
  2841. * ## Why do we care about ngStyle/ngClass?
  2842. * The styling algorithm code (documented inside of `render3/interfaces/styling.ts`) needs to
  2843. * respect and understand the styling values emitted through ngStyle and ngClass (when they
  2844. * are present and used in a template).
  2845. *
  2846. * Instead of having these directives manage styling on their own, they should be included
  2847. * into the Angular styling algorithm that exists for [style] and [class] bindings.
  2848. *
  2849. * Here's why:
  2850. *
  2851. * - If ngStyle/ngClass is used in combination with [style]/[class] bindings then the
  2852. * styles and classes would fall out of sync and be applied and updated at
  2853. * inconsistent times
  2854. * - Both ngClass/ngStyle do not respect [class.name] and [style.prop] bindings
  2855. * (they will write over them given the right combination of events)
  2856. *
  2857. * ```
  2858. * <!-- if `w1` is updated then it will always override `w2`
  2859. * if `w2` is updated then it will always override `w1`
  2860. * if both are updated at the same time then `w1` wins -->
  2861. * <div [ngStyle]="{width:w1}" [style.width]="w2">...</div>
  2862. *
  2863. * <!-- if `w1` is updated then it will always lose to `w2`
  2864. * if `w2` is updated then it will always override `w1`
  2865. * if both are updated at the same time then `w2` wins -->
  2866. * <div [style]="{width:w1}" [style.width]="w2">...</div>
  2867. * ```
  2868. * - ngClass/ngStyle were written as a directives and made use of maps, closures and other
  2869. * expensive data structures which were evaluated each time CD runs
  2870. */
  2871. var StylingDiffer = /** @class */ (function () {
  2872. function StylingDiffer(_name, _options) {
  2873. this._name = _name;
  2874. this._options = _options;
  2875. this.value = null;
  2876. this._lastSetValue = null;
  2877. this._lastSetValueType = 0 /* Null */;
  2878. this._lastSetValueIdentityChange = false;
  2879. }
  2880. /**
  2881. * Sets (updates) the styling value within the differ.
  2882. *
  2883. * Only when `hasValueChanged` is called then this new value will be evaluted
  2884. * and checked against the previous value.
  2885. *
  2886. * @param value the new styling value provided from the ngClass/ngStyle binding
  2887. */
  2888. StylingDiffer.prototype.setValue = function (value) {
  2889. if (Array.isArray(value)) {
  2890. this._lastSetValueType = 4 /* Array */;
  2891. }
  2892. else if (value instanceof Set) {
  2893. this._lastSetValueType = 8 /* Set */;
  2894. }
  2895. else if (value && typeof value === 'string') {
  2896. if (!(this._options & 4 /* AllowStringValue */)) {
  2897. throw new Error(this._name + ' string values are not allowed');
  2898. }
  2899. this._lastSetValueType = 1 /* String */;
  2900. }
  2901. else {
  2902. this._lastSetValueType = value ? 2 /* Map */ : 0 /* Null */;
  2903. }
  2904. this._lastSetValueIdentityChange = true;
  2905. this._lastSetValue = value || null;
  2906. };
  2907. /**
  2908. * Determines whether or not the value has changed.
  2909. *
  2910. * This function can be called right after `setValue()` is called, but it can also be
  2911. * called incase the existing value (if it's a collection) changes internally. If the
  2912. * value is indeed a collection it will do the necessary diffing work and produce a
  2913. * new object value as assign that to `value`.
  2914. *
  2915. * @returns whether or not the value has changed in some way.
  2916. */
  2917. StylingDiffer.prototype.hasValueChanged = function () {
  2918. var valueHasChanged = this._lastSetValueIdentityChange;
  2919. if (!valueHasChanged && !(this._lastSetValueType & 14 /* Collection */))
  2920. return false;
  2921. var finalValue = null;
  2922. var trimValues = (this._options & 1 /* TrimProperties */) ? true : false;
  2923. var parseOutUnits = (this._options & 8 /* AllowUnits */) ? true : false;
  2924. var allowSubKeys = (this._options & 2 /* AllowSubKeys */) ? true : false;
  2925. switch (this._lastSetValueType) {
  2926. // case 1: [input]="string"
  2927. case 1 /* String */:
  2928. var tokens = this._lastSetValue.split(/\s+/g);
  2929. if (this._options & 16 /* ForceAsMap */) {
  2930. finalValue = {};
  2931. tokens.forEach(function (token, i) { return finalValue[token] = true; });
  2932. }
  2933. else {
  2934. finalValue = tokens.reduce(function (str, token, i) { return str + (i ? ' ' : '') + token; });
  2935. }
  2936. break;
  2937. // case 2: [input]="{key:value}"
  2938. case 2 /* Map */:
  2939. var map = this._lastSetValue;
  2940. var keys = Object.keys(map);
  2941. if (!valueHasChanged) {
  2942. if (this.value) {
  2943. // we know that the classExp value exists and that it is
  2944. // a map (otherwise an identity change would have occurred)
  2945. valueHasChanged = mapHasChanged(keys, this.value, map);
  2946. }
  2947. else {
  2948. valueHasChanged = true;
  2949. }
  2950. }
  2951. if (valueHasChanged) {
  2952. finalValue =
  2953. bulidMapFromValues(this._name, trimValues, parseOutUnits, allowSubKeys, map, keys);
  2954. }
  2955. break;
  2956. // case 3a: [input]="[str1, str2, ...]"
  2957. // case 3b: [input]="Set"
  2958. case 4 /* Array */:
  2959. case 8 /* Set */:
  2960. var values = Array.from(this._lastSetValue);
  2961. if (!valueHasChanged) {
  2962. var keys_1 = Object.keys(this.value);
  2963. valueHasChanged = !arrayEqualsArray(keys_1, values);
  2964. }
  2965. if (valueHasChanged) {
  2966. finalValue =
  2967. bulidMapFromValues(this._name, trimValues, parseOutUnits, allowSubKeys, values);
  2968. }
  2969. break;
  2970. // case 4: [input]="null|undefined"
  2971. default:
  2972. finalValue = null;
  2973. break;
  2974. }
  2975. if (valueHasChanged) {
  2976. this.value = finalValue;
  2977. }
  2978. return valueHasChanged;
  2979. };
  2980. return StylingDiffer;
  2981. }());
  2982. /**
  2983. * builds and returns a map based on the values input value
  2984. *
  2985. * If the `keys` param is provided then the `values` param is treated as a
  2986. * string map. Otherwise `values` is treated as a string array.
  2987. */
  2988. function bulidMapFromValues(errorPrefix, trim, parseOutUnits, allowSubKeys, values, keys) {
  2989. var map = {};
  2990. if (keys) {
  2991. // case 1: map
  2992. for (var i = 0; i < keys.length; i++) {
  2993. var key = keys[i];
  2994. key = trim ? key.trim() : key;
  2995. var value = values[key];
  2996. setMapValues(map, key, value, parseOutUnits, allowSubKeys);
  2997. }
  2998. }
  2999. else {
  3000. // case 2: array
  3001. for (var i = 0; i < values.length; i++) {
  3002. var value = values[i];
  3003. assertValidValue(errorPrefix, value);
  3004. value = trim ? value.trim() : value;
  3005. setMapValues(map, value, true, false, allowSubKeys);
  3006. }
  3007. }
  3008. return map;
  3009. }
  3010. function assertValidValue(errorPrefix, value) {
  3011. if (typeof value !== 'string') {
  3012. throw new Error(errorPrefix + " can only toggle CSS classes expressed as strings, got " + value);
  3013. }
  3014. }
  3015. function setMapValues(map, key, value, parseOutUnits, allowSubKeys) {
  3016. if (allowSubKeys && key.indexOf(' ') > 0) {
  3017. var innerKeys = key.split(/\s+/g);
  3018. for (var j = 0; j < innerKeys.length; j++) {
  3019. setIndividualMapValue(map, innerKeys[j], value, parseOutUnits);
  3020. }
  3021. }
  3022. else {
  3023. setIndividualMapValue(map, key, value, parseOutUnits);
  3024. }
  3025. }
  3026. function setIndividualMapValue(map, key, value, parseOutUnits) {
  3027. if (parseOutUnits) {
  3028. var values = normalizeStyleKeyAndValue(key, value);
  3029. value = values.value;
  3030. key = values.key;
  3031. }
  3032. map[key] = value;
  3033. }
  3034. function normalizeStyleKeyAndValue(key, value) {
  3035. var index = key.indexOf('.');
  3036. if (index > 0) {
  3037. var unit = key.substr(index + 1); // ignore the . ([width.px]="'40'" => "40px")
  3038. key = key.substring(0, index);
  3039. if (value != null) { // we should not convert null values to string
  3040. value += unit;
  3041. }
  3042. }
  3043. return { key: key, value: value };
  3044. }
  3045. function mapHasChanged(keys, a, b) {
  3046. var oldKeys = Object.keys(a);
  3047. var newKeys = keys;
  3048. // the keys are different which means the map changed
  3049. if (!arrayEqualsArray(oldKeys, newKeys)) {
  3050. return true;
  3051. }
  3052. for (var i = 0; i < newKeys.length; i++) {
  3053. var key = newKeys[i];
  3054. if (a[key] !== b[key]) {
  3055. return true;
  3056. }
  3057. }
  3058. return false;
  3059. }
  3060. function arrayEqualsArray(a, b) {
  3061. if (a && b) {
  3062. if (a.length !== b.length)
  3063. return false;
  3064. for (var i = 0; i < a.length; i++) {
  3065. if (b.indexOf(a[i]) === -1)
  3066. return false;
  3067. }
  3068. return true;
  3069. }
  3070. return false;
  3071. }
  3072. /**
  3073. * Used as a token for an injected service within the NgClass directive.
  3074. *
  3075. * NgClass behaves differenly whether or not VE is being used or not. If
  3076. * present then the legacy ngClass diffing algorithm will be used as an
  3077. * injected service. Otherwise the new diffing algorithm (which delegates
  3078. * to the `[class]` binding) will be used. This toggle behavior is done so
  3079. * via the ivy_switch mechanism.
  3080. */
  3081. var NgClassImpl = /** @class */ (function () {
  3082. function NgClassImpl() {
  3083. }
  3084. return NgClassImpl;
  3085. }());
  3086. var NgClassR2Impl = /** @class */ (function () {
  3087. function NgClassR2Impl(_iterableDiffers, _keyValueDiffers, _ngEl, _renderer) {
  3088. this._iterableDiffers = _iterableDiffers;
  3089. this._keyValueDiffers = _keyValueDiffers;
  3090. this._ngEl = _ngEl;
  3091. this._renderer = _renderer;
  3092. this._initialClasses = [];
  3093. }
  3094. NgClassR2Impl.prototype.getValue = function () { return null; };
  3095. NgClassR2Impl.prototype.setClass = function (value) {
  3096. this._removeClasses(this._initialClasses);
  3097. this._initialClasses = typeof value === 'string' ? value.split(/\s+/) : [];
  3098. this._applyClasses(this._initialClasses);
  3099. this._applyClasses(this._rawClass);
  3100. };
  3101. NgClassR2Impl.prototype.setNgClass = function (value) {
  3102. this._removeClasses(this._rawClass);
  3103. this._applyClasses(this._initialClasses);
  3104. this._iterableDiffer = null;
  3105. this._keyValueDiffer = null;
  3106. this._rawClass = typeof value === 'string' ? value.split(/\s+/) : value;
  3107. if (this._rawClass) {
  3108. if (ɵisListLikeIterable(this._rawClass)) {
  3109. this._iterableDiffer = this._iterableDiffers.find(this._rawClass).create();
  3110. }
  3111. else {
  3112. this._keyValueDiffer = this._keyValueDiffers.find(this._rawClass).create();
  3113. }
  3114. }
  3115. };
  3116. NgClassR2Impl.prototype.applyChanges = function () {
  3117. if (this._iterableDiffer) {
  3118. var iterableChanges = this._iterableDiffer.diff(this._rawClass);
  3119. if (iterableChanges) {
  3120. this._applyIterableChanges(iterableChanges);
  3121. }
  3122. }
  3123. else if (this._keyValueDiffer) {
  3124. var keyValueChanges = this._keyValueDiffer.diff(this._rawClass);
  3125. if (keyValueChanges) {
  3126. this._applyKeyValueChanges(keyValueChanges);
  3127. }
  3128. }
  3129. };
  3130. NgClassR2Impl.prototype._applyKeyValueChanges = function (changes) {
  3131. var _this = this;
  3132. changes.forEachAddedItem(function (record) { return _this._toggleClass(record.key, record.currentValue); });
  3133. changes.forEachChangedItem(function (record) { return _this._toggleClass(record.key, record.currentValue); });
  3134. changes.forEachRemovedItem(function (record) {
  3135. if (record.previousValue) {
  3136. _this._toggleClass(record.key, false);
  3137. }
  3138. });
  3139. };
  3140. NgClassR2Impl.prototype._applyIterableChanges = function (changes) {
  3141. var _this = this;
  3142. changes.forEachAddedItem(function (record) {
  3143. if (typeof record.item === 'string') {
  3144. _this._toggleClass(record.item, true);
  3145. }
  3146. else {
  3147. throw new Error("NgClass can only toggle CSS classes expressed as strings, got " + ɵstringify(record.item));
  3148. }
  3149. });
  3150. changes.forEachRemovedItem(function (record) { return _this._toggleClass(record.item, false); });
  3151. };
  3152. /**
  3153. * Applies a collection of CSS classes to the DOM element.
  3154. *
  3155. * For argument of type Set and Array CSS class names contained in those collections are always
  3156. * added.
  3157. * For argument of type Map CSS class name in the map's key is toggled based on the value (added
  3158. * for truthy and removed for falsy).
  3159. */
  3160. NgClassR2Impl.prototype._applyClasses = function (rawClassVal) {
  3161. var _this = this;
  3162. if (rawClassVal) {
  3163. if (Array.isArray(rawClassVal) || rawClassVal instanceof Set) {
  3164. rawClassVal.forEach(function (klass) { return _this._toggleClass(klass, true); });
  3165. }
  3166. else {
  3167. Object.keys(rawClassVal).forEach(function (klass) { return _this._toggleClass(klass, !!rawClassVal[klass]); });
  3168. }
  3169. }
  3170. };
  3171. /**
  3172. * Removes a collection of CSS classes from the DOM element. This is mostly useful for cleanup
  3173. * purposes.
  3174. */
  3175. NgClassR2Impl.prototype._removeClasses = function (rawClassVal) {
  3176. var _this = this;
  3177. if (rawClassVal) {
  3178. if (Array.isArray(rawClassVal) || rawClassVal instanceof Set) {
  3179. rawClassVal.forEach(function (klass) { return _this._toggleClass(klass, false); });
  3180. }
  3181. else {
  3182. Object.keys(rawClassVal).forEach(function (klass) { return _this._toggleClass(klass, false); });
  3183. }
  3184. }
  3185. };
  3186. NgClassR2Impl.prototype._toggleClass = function (klass, enabled) {
  3187. var _this = this;
  3188. klass = klass.trim();
  3189. if (klass) {
  3190. klass.split(/\s+/g).forEach(function (klass) {
  3191. if (enabled) {
  3192. _this._renderer.addClass(_this._ngEl.nativeElement, klass);
  3193. }
  3194. else {
  3195. _this._renderer.removeClass(_this._ngEl.nativeElement, klass);
  3196. }
  3197. });
  3198. }
  3199. };
  3200. NgClassR2Impl = __decorate([
  3201. Injectable(),
  3202. __metadata("design:paramtypes", [IterableDiffers, KeyValueDiffers,
  3203. ElementRef, Renderer2])
  3204. ], NgClassR2Impl);
  3205. return NgClassR2Impl;
  3206. }());
  3207. var NgClassR3Impl = /** @class */ (function () {
  3208. function NgClassR3Impl() {
  3209. this._value = null;
  3210. this._ngClassDiffer = new StylingDiffer('NgClass', 1 /* TrimProperties */ |
  3211. 2 /* AllowSubKeys */ |
  3212. 4 /* AllowStringValue */ | 16 /* ForceAsMap */);
  3213. this._classStringDiffer = null;
  3214. }
  3215. NgClassR3Impl.prototype.getValue = function () { return this._value; };
  3216. NgClassR3Impl.prototype.setClass = function (value) {
  3217. // early exit incase the binding gets emitted as an empty value which
  3218. // means there is no reason to instantiate and diff the values...
  3219. if (!value && !this._classStringDiffer)
  3220. return;
  3221. this._classStringDiffer = this._classStringDiffer ||
  3222. new StylingDiffer('class', 4 /* AllowStringValue */ | 16 /* ForceAsMap */);
  3223. this._classStringDiffer.setValue(value);
  3224. };
  3225. NgClassR3Impl.prototype.setNgClass = function (value) {
  3226. this._ngClassDiffer.setValue(value);
  3227. };
  3228. NgClassR3Impl.prototype.applyChanges = function () {
  3229. var classChanged = this._classStringDiffer ? this._classStringDiffer.hasValueChanged() : false;
  3230. var ngClassChanged = this._ngClassDiffer.hasValueChanged();
  3231. if (classChanged || ngClassChanged) {
  3232. var value = this._ngClassDiffer.value;
  3233. if (this._classStringDiffer) {
  3234. var classValue = this._classStringDiffer.value;
  3235. if (classValue) {
  3236. value = value ? __assign({}, classValue, value) : classValue;
  3237. }
  3238. }
  3239. this._value = value;
  3240. }
  3241. };
  3242. NgClassR3Impl = __decorate([
  3243. Injectable()
  3244. ], NgClassR3Impl);
  3245. return NgClassR3Impl;
  3246. }());
  3247. // the implementation for both NgStyleR2Impl and NgStyleR3Impl are
  3248. // not ivy_switch'd away, instead they are only hooked up into the
  3249. // DI via NgStyle's directive's provider property.
  3250. var NgClassImplProvider__PRE_R3__ = {
  3251. provide: NgClassImpl,
  3252. useClass: NgClassR2Impl
  3253. };
  3254. var NgClassImplProvider__POST_R3__ = {
  3255. provide: NgClassImpl,
  3256. useClass: NgClassR3Impl
  3257. };
  3258. var NgClassImplProvider = NgClassImplProvider__PRE_R3__;
  3259. /*
  3260. * NgClass (as well as NgStyle) behaves differently when loaded in the VE and when not.
  3261. *
  3262. * If the VE is present (which is for older versions of Angular) then NgClass will inject
  3263. * the legacy diffing algorithm as a service and delegate all styling changes to that.
  3264. *
  3265. * If the VE is not present then NgStyle will normalize (through the injected service) and
  3266. * then write all styling changes to the `[style]` binding directly (through a host binding).
  3267. * Then Angular will notice the host binding change and treat the changes as styling
  3268. * changes and apply them via the core styling instructions that exist within Angular.
  3269. */
  3270. // used when the VE is present
  3271. var ngClassDirectiveDef__PRE_R3__ = undefined;
  3272. var ɵ0 = function () { }, ɵ1 = function () { }, ɵ2 = function (rf, ctx, elIndex) {
  3273. if (rf & 1 /* Create */) {
  3274. ɵɵstyling();
  3275. }
  3276. if (rf & 2 /* Update */) {
  3277. ɵɵclassMap(ctx.getValue());
  3278. ɵɵstylingApply();
  3279. }
  3280. };
  3281. // used when the VE is not present (note the directive will
  3282. // never be instantiated normally because it is apart of a
  3283. // base class)
  3284. var ngClassDirectiveDef__POST_R3__ = ɵɵdefineDirective({
  3285. type: ɵ0,
  3286. selectors: null,
  3287. factory: ɵ1,
  3288. hostBindings: ɵ2
  3289. });
  3290. var ngClassDirectiveDef = ngClassDirectiveDef__PRE_R3__;
  3291. /**
  3292. * Serves as the base non-VE container for NgClass.
  3293. *
  3294. * While this is a base class that NgClass extends from, the
  3295. * class itself acts as a container for non-VE code to setup
  3296. * a link to the `[class]` host binding (via the static
  3297. * `ngDirectiveDef` property on the class).
  3298. *
  3299. * Note that the `ngDirectiveDef` property's code is switched
  3300. * depending if VE is present or not (this allows for the
  3301. * binding code to be set only for newer versions of Angular).
  3302. *
  3303. * @publicApi
  3304. */
  3305. var NgClassBase = /** @class */ (function () {
  3306. function NgClassBase(_delegate) {
  3307. this._delegate = _delegate;
  3308. }
  3309. NgClassBase.prototype.getValue = function () { return this._delegate.getValue(); };
  3310. NgClassBase.ngDirectiveDef = ngClassDirectiveDef;
  3311. return NgClassBase;
  3312. }());
  3313. /**
  3314. * @ngModule CommonModule
  3315. *
  3316. * @usageNotes
  3317. * ```
  3318. * <some-element [ngClass]="'first second'">...</some-element>
  3319. *
  3320. * <some-element [ngClass]="['first', 'second']">...</some-element>
  3321. *
  3322. * <some-element [ngClass]="{'first': true, 'second': true, 'third': false}">...</some-element>
  3323. *
  3324. * <some-element [ngClass]="stringExp|arrayExp|objExp">...</some-element>
  3325. *
  3326. * <some-element [ngClass]="{'class1 class2 class3' : true}">...</some-element>
  3327. * ```
  3328. *
  3329. * @description
  3330. *
  3331. * Adds and removes CSS classes on an HTML element.
  3332. *
  3333. * The CSS classes are updated as follows, depending on the type of the expression evaluation:
  3334. * - `string` - the CSS classes listed in the string (space delimited) are added,
  3335. * - `Array` - the CSS classes declared as Array elements are added,
  3336. * - `Object` - keys are CSS classes that get added when the expression given in the value
  3337. * evaluates to a truthy value, otherwise they are removed.
  3338. *
  3339. * @publicApi
  3340. */
  3341. var NgClass = /** @class */ (function (_super) {
  3342. __extends(NgClass, _super);
  3343. function NgClass(delegate) {
  3344. return _super.call(this, delegate) || this;
  3345. }
  3346. Object.defineProperty(NgClass.prototype, "klass", {
  3347. set: function (value) { this._delegate.setClass(value); },
  3348. enumerable: true,
  3349. configurable: true
  3350. });
  3351. Object.defineProperty(NgClass.prototype, "ngClass", {
  3352. set: function (value) {
  3353. this._delegate.setNgClass(value);
  3354. },
  3355. enumerable: true,
  3356. configurable: true
  3357. });
  3358. NgClass.prototype.ngDoCheck = function () { this._delegate.applyChanges(); };
  3359. __decorate([
  3360. Input('class'),
  3361. __metadata("design:type", String),
  3362. __metadata("design:paramtypes", [String])
  3363. ], NgClass.prototype, "klass", null);
  3364. __decorate([
  3365. Input('ngClass'),
  3366. __metadata("design:type", Object),
  3367. __metadata("design:paramtypes", [Object])
  3368. ], NgClass.prototype, "ngClass", null);
  3369. NgClass = __decorate([
  3370. Directive({ selector: '[ngClass]', providers: [NgClassImplProvider] }),
  3371. __metadata("design:paramtypes", [NgClassImpl])
  3372. ], NgClass);
  3373. return NgClass;
  3374. }(NgClassBase));
  3375. /**
  3376. * @license
  3377. * Copyright Google Inc. All Rights Reserved.
  3378. *
  3379. * Use of this source code is governed by an MIT-style license that can be
  3380. * found in the LICENSE file at https://angular.io/license
  3381. */
  3382. /**
  3383. * Instantiates a single {@link Component} type and inserts its Host View into current View.
  3384. * `NgComponentOutlet` provides a declarative approach for dynamic component creation.
  3385. *
  3386. * `NgComponentOutlet` requires a component type, if a falsy value is set the view will clear and
  3387. * any existing component will get destroyed.
  3388. *
  3389. * @usageNotes
  3390. *
  3391. * ### Fine tune control
  3392. *
  3393. * You can control the component creation process by using the following optional attributes:
  3394. *
  3395. * * `ngComponentOutletInjector`: Optional custom {@link Injector} that will be used as parent for
  3396. * the Component. Defaults to the injector of the current view container.
  3397. *
  3398. * * `ngComponentOutletContent`: Optional list of projectable nodes to insert into the content
  3399. * section of the component, if exists.
  3400. *
  3401. * * `ngComponentOutletNgModuleFactory`: Optional module factory to allow dynamically loading other
  3402. * module, then load a component from that module.
  3403. *
  3404. * ### Syntax
  3405. *
  3406. * Simple
  3407. * ```
  3408. * <ng-container *ngComponentOutlet="componentTypeExpression"></ng-container>
  3409. * ```
  3410. *
  3411. * Customized injector/content
  3412. * ```
  3413. * <ng-container *ngComponentOutlet="componentTypeExpression;
  3414. * injector: injectorExpression;
  3415. * content: contentNodesExpression;">
  3416. * </ng-container>
  3417. * ```
  3418. *
  3419. * Customized ngModuleFactory
  3420. * ```
  3421. * <ng-container *ngComponentOutlet="componentTypeExpression;
  3422. * ngModuleFactory: moduleFactory;">
  3423. * </ng-container>
  3424. * ```
  3425. *
  3426. * ### A simple example
  3427. *
  3428. * {@example common/ngComponentOutlet/ts/module.ts region='SimpleExample'}
  3429. *
  3430. * A more complete example with additional options:
  3431. *
  3432. * {@example common/ngComponentOutlet/ts/module.ts region='CompleteExample'}
  3433. *
  3434. * @publicApi
  3435. * @ngModule CommonModule
  3436. */
  3437. var NgComponentOutlet = /** @class */ (function () {
  3438. function NgComponentOutlet(_viewContainerRef) {
  3439. this._viewContainerRef = _viewContainerRef;
  3440. this._componentRef = null;
  3441. this._moduleRef = null;
  3442. }
  3443. NgComponentOutlet.prototype.ngOnChanges = function (changes) {
  3444. this._viewContainerRef.clear();
  3445. this._componentRef = null;
  3446. if (this.ngComponentOutlet) {
  3447. var elInjector = this.ngComponentOutletInjector || this._viewContainerRef.parentInjector;
  3448. if (changes['ngComponentOutletNgModuleFactory']) {
  3449. if (this._moduleRef)
  3450. this._moduleRef.destroy();
  3451. if (this.ngComponentOutletNgModuleFactory) {
  3452. var parentModule = elInjector.get(NgModuleRef);
  3453. this._moduleRef = this.ngComponentOutletNgModuleFactory.create(parentModule.injector);
  3454. }
  3455. else {
  3456. this._moduleRef = null;
  3457. }
  3458. }
  3459. var componentFactoryResolver = this._moduleRef ? this._moduleRef.componentFactoryResolver :
  3460. elInjector.get(ComponentFactoryResolver);
  3461. var componentFactory = componentFactoryResolver.resolveComponentFactory(this.ngComponentOutlet);
  3462. this._componentRef = this._viewContainerRef.createComponent(componentFactory, this._viewContainerRef.length, elInjector, this.ngComponentOutletContent);
  3463. }
  3464. };
  3465. NgComponentOutlet.prototype.ngOnDestroy = function () {
  3466. if (this._moduleRef)
  3467. this._moduleRef.destroy();
  3468. };
  3469. __decorate([
  3470. Input(),
  3471. __metadata("design:type", Type)
  3472. ], NgComponentOutlet.prototype, "ngComponentOutlet", void 0);
  3473. __decorate([
  3474. Input(),
  3475. __metadata("design:type", Injector)
  3476. ], NgComponentOutlet.prototype, "ngComponentOutletInjector", void 0);
  3477. __decorate([
  3478. Input(),
  3479. __metadata("design:type", Array)
  3480. ], NgComponentOutlet.prototype, "ngComponentOutletContent", void 0);
  3481. __decorate([
  3482. Input(),
  3483. __metadata("design:type", NgModuleFactory)
  3484. ], NgComponentOutlet.prototype, "ngComponentOutletNgModuleFactory", void 0);
  3485. NgComponentOutlet = __decorate([
  3486. Directive({ selector: '[ngComponentOutlet]' }),
  3487. __metadata("design:paramtypes", [ViewContainerRef])
  3488. ], NgComponentOutlet);
  3489. return NgComponentOutlet;
  3490. }());
  3491. /**
  3492. * @license
  3493. * Copyright Google Inc. All Rights Reserved.
  3494. *
  3495. * Use of this source code is governed by an MIT-style license that can be
  3496. * found in the LICENSE file at https://angular.io/license
  3497. */
  3498. /**
  3499. * @publicApi
  3500. */
  3501. var NgForOfContext = /** @class */ (function () {
  3502. function NgForOfContext($implicit, ngForOf, index, count) {
  3503. this.$implicit = $implicit;
  3504. this.ngForOf = ngForOf;
  3505. this.index = index;
  3506. this.count = count;
  3507. }
  3508. Object.defineProperty(NgForOfContext.prototype, "first", {
  3509. get: function () { return this.index === 0; },
  3510. enumerable: true,
  3511. configurable: true
  3512. });
  3513. Object.defineProperty(NgForOfContext.prototype, "last", {
  3514. get: function () { return this.index === this.count - 1; },
  3515. enumerable: true,
  3516. configurable: true
  3517. });
  3518. Object.defineProperty(NgForOfContext.prototype, "even", {
  3519. get: function () { return this.index % 2 === 0; },
  3520. enumerable: true,
  3521. configurable: true
  3522. });
  3523. Object.defineProperty(NgForOfContext.prototype, "odd", {
  3524. get: function () { return !this.even; },
  3525. enumerable: true,
  3526. configurable: true
  3527. });
  3528. return NgForOfContext;
  3529. }());
  3530. /**
  3531. * A [structural directive](guide/structural-directives) that renders
  3532. * a template for each item in a collection.
  3533. * The directive is placed on an element, which becomes the parent
  3534. * of the cloned templates.
  3535. *
  3536. * The `ngForOf` directive is generally used in the
  3537. * [shorthand form](guide/structural-directives#the-asterisk--prefix) `*ngFor`.
  3538. * In this form, the template to be rendered for each iteration is the content
  3539. * of an anchor element containing the directive.
  3540. *
  3541. * The following example shows the shorthand syntax with some options,
  3542. * contained in an `<li>` element.
  3543. *
  3544. * ```
  3545. * <li *ngFor="let item of items; index as i; trackBy: trackByFn">...</li>
  3546. * ```
  3547. *
  3548. * The shorthand form expands into a long form that uses the `ngForOf` selector
  3549. * on an `<ng-template>` element.
  3550. * The content of the `<ng-template>` element is the `<li>` element that held the
  3551. * short-form directive.
  3552. *
  3553. * Here is the expanded version of the short-form example.
  3554. *
  3555. * ```
  3556. * <ng-template ngFor let-item [ngForOf]="items" let-i="index" [ngForTrackBy]="trackByFn">
  3557. * <li>...</li>
  3558. * </ng-template>
  3559. * ```
  3560. *
  3561. * Angular automatically expands the shorthand syntax as it compiles the template.
  3562. * The context for each embedded view is logically merged to the current component
  3563. * context according to its lexical position.
  3564. *
  3565. * When using the shorthand syntax, Angular allows only [one structural directive
  3566. * on an element](guide/structural-directives#one-structural-directive-per-host-element).
  3567. * If you want to iterate conditionally, for example,
  3568. * put the `*ngIf` on a container element that wraps the `*ngFor` element.
  3569. * For futher discussion, see
  3570. * [Structural Directives](guide/structural-directives#one-per-element).
  3571. *
  3572. * @usageNotes
  3573. *
  3574. * ### Local variables
  3575. *
  3576. * `NgForOf` provides exported values that can be aliased to local variables.
  3577. * For example:
  3578. *
  3579. * ```
  3580. * <li *ngFor="let user of userObservable | async as users; index as i; first as isFirst">
  3581. * {{i}}/{{users.length}}. {{user}} <span *ngIf="isFirst">default</span>
  3582. * </li>
  3583. * ```
  3584. *
  3585. * The following exported values can be aliased to local variables:
  3586. *
  3587. * - `$implicit: T`: The value of the individual items in the iterable (`ngForOf`).
  3588. * - `ngForOf: NgIterable<T>`: The value of the iterable expression. Useful when the expression is
  3589. * more complex then a property access, for example when using the async pipe (`userStreams |
  3590. * async`).
  3591. * - `index: number`: The index of the current item in the iterable.
  3592. * - `first: boolean`: True when the item is the first item in the iterable.
  3593. * - `last: boolean`: True when the item is the last item in the iterable.
  3594. * - `even: boolean`: True when the item has an even index in the iterable.
  3595. * - `odd: boolean`: True when the item has an odd index in the iterable.
  3596. *
  3597. * ### Change propagation
  3598. *
  3599. * When the contents of the iterator changes, `NgForOf` makes the corresponding changes to the DOM:
  3600. *
  3601. * * When an item is added, a new instance of the template is added to the DOM.
  3602. * * When an item is removed, its template instance is removed from the DOM.
  3603. * * When items are reordered, their respective templates are reordered in the DOM.
  3604. *
  3605. * Angular uses object identity to track insertions and deletions within the iterator and reproduce
  3606. * those changes in the DOM. This has important implications for animations and any stateful
  3607. * controls that are present, such as `<input>` elements that accept user input. Inserted rows can
  3608. * be animated in, deleted rows can be animated out, and unchanged rows retain any unsaved state
  3609. * such as user input.
  3610. * For more on animations, see [Transitions and Triggers](guide/transition-and-triggers).
  3611. *
  3612. * The identities of elements in the iterator can change while the data does not.
  3613. * This can happen, for example, if the iterator is produced from an RPC to the server, and that
  3614. * RPC is re-run. Even if the data hasn't changed, the second response produces objects with
  3615. * different identities, and Angular must tear down the entire DOM and rebuild it (as if all old
  3616. * elements were deleted and all new elements inserted).
  3617. *
  3618. * To avoid this expensive operation, you can customize the default tracking algorithm.
  3619. * by supplying the `trackBy` option to `NgForOf`.
  3620. * `trackBy` takes a function that has two arguments: `index` and `item`.
  3621. * If `trackBy` is given, Angular tracks changes by the return value of the function.
  3622. *
  3623. * @see [Structural Directives](guide/structural-directives)
  3624. * @ngModule CommonModule
  3625. * @publicApi
  3626. */
  3627. var NgForOf = /** @class */ (function () {
  3628. function NgForOf(_viewContainer, _template, _differs) {
  3629. this._viewContainer = _viewContainer;
  3630. this._template = _template;
  3631. this._differs = _differs;
  3632. this._ngForOfDirty = true;
  3633. this._differ = null;
  3634. }
  3635. Object.defineProperty(NgForOf.prototype, "ngForOf", {
  3636. /**
  3637. * The value of the iterable expression, which can be used as a
  3638. * [template input variable](guide/structural-directives#template-input-variable).
  3639. */
  3640. set: function (ngForOf) {
  3641. this._ngForOf = ngForOf;
  3642. this._ngForOfDirty = true;
  3643. },
  3644. enumerable: true,
  3645. configurable: true
  3646. });
  3647. Object.defineProperty(NgForOf.prototype, "ngForTrackBy", {
  3648. get: function () { return this._trackByFn; },
  3649. /**
  3650. * A function that defines how to track changes for items in the iterable.
  3651. *
  3652. * When items are added, moved, or removed in the iterable,
  3653. * the directive must re-render the appropriate DOM nodes.
  3654. * To minimize churn in the DOM, only nodes that have changed
  3655. * are re-rendered.
  3656. *
  3657. * By default, the change detector assumes that
  3658. * the object instance identifies the node in the iterable.
  3659. * When this function is supplied, the directive uses
  3660. * the result of calling this function to identify the item node,
  3661. * rather than the identity of the object itself.
  3662. *
  3663. * The function receives two inputs,
  3664. * the iteration index and the node object ID.
  3665. */
  3666. set: function (fn) {
  3667. if (isDevMode() && fn != null && typeof fn !== 'function') {
  3668. // TODO(vicb): use a log service once there is a public one available
  3669. if (console && console.warn) {
  3670. console.warn("trackBy must be a function, but received " + JSON.stringify(fn) + ". " +
  3671. "See https://angular.io/docs/ts/latest/api/common/index/NgFor-directive.html#!#change-propagation for more information.");
  3672. }
  3673. }
  3674. this._trackByFn = fn;
  3675. },
  3676. enumerable: true,
  3677. configurable: true
  3678. });
  3679. Object.defineProperty(NgForOf.prototype, "ngForTemplate", {
  3680. /**
  3681. * A reference to the template that is stamped out for each item in the iterable.
  3682. * @see [template reference variable](guide/template-syntax#template-reference-variables--var-)
  3683. */
  3684. set: function (value) {
  3685. // TODO(TS2.1): make TemplateRef<Partial<NgForRowOf<T>>> once we move to TS v2.1
  3686. // The current type is too restrictive; a template that just uses index, for example,
  3687. // should be acceptable.
  3688. if (value) {
  3689. this._template = value;
  3690. }
  3691. },
  3692. enumerable: true,
  3693. configurable: true
  3694. });
  3695. /**
  3696. * Applies the changes when needed.
  3697. */
  3698. NgForOf.prototype.ngDoCheck = function () {
  3699. if (this._ngForOfDirty) {
  3700. this._ngForOfDirty = false;
  3701. // React on ngForOf changes only once all inputs have been initialized
  3702. var value = this._ngForOf;
  3703. if (!this._differ && value) {
  3704. try {
  3705. this._differ = this._differs.find(value).create(this.ngForTrackBy);
  3706. }
  3707. catch (_a) {
  3708. throw new Error("Cannot find a differ supporting object '" + value + "' of type '" + getTypeName(value) + "'. NgFor only supports binding to Iterables such as Arrays.");
  3709. }
  3710. }
  3711. }
  3712. if (this._differ) {
  3713. var changes = this._differ.diff(this._ngForOf);
  3714. if (changes)
  3715. this._applyChanges(changes);
  3716. }
  3717. };
  3718. NgForOf.prototype._applyChanges = function (changes) {
  3719. var _this = this;
  3720. var insertTuples = [];
  3721. changes.forEachOperation(function (item, adjustedPreviousIndex, currentIndex) {
  3722. if (item.previousIndex == null) {
  3723. var view = _this._viewContainer.createEmbeddedView(_this._template, new NgForOfContext(null, _this._ngForOf, -1, -1), currentIndex);
  3724. var tuple = new RecordViewTuple(item, view);
  3725. insertTuples.push(tuple);
  3726. }
  3727. else if (currentIndex == null) {
  3728. _this._viewContainer.remove(adjustedPreviousIndex);
  3729. }
  3730. else {
  3731. var view = _this._viewContainer.get(adjustedPreviousIndex);
  3732. _this._viewContainer.move(view, currentIndex);
  3733. var tuple = new RecordViewTuple(item, view);
  3734. insertTuples.push(tuple);
  3735. }
  3736. });
  3737. for (var i = 0; i < insertTuples.length; i++) {
  3738. this._perViewChange(insertTuples[i].view, insertTuples[i].record);
  3739. }
  3740. for (var i = 0, ilen = this._viewContainer.length; i < ilen; i++) {
  3741. var viewRef = this._viewContainer.get(i);
  3742. viewRef.context.index = i;
  3743. viewRef.context.count = ilen;
  3744. viewRef.context.ngForOf = this._ngForOf;
  3745. }
  3746. changes.forEachIdentityChange(function (record) {
  3747. var viewRef = _this._viewContainer.get(record.currentIndex);
  3748. viewRef.context.$implicit = record.item;
  3749. });
  3750. };
  3751. NgForOf.prototype._perViewChange = function (view, record) {
  3752. view.context.$implicit = record.item;
  3753. };
  3754. /**
  3755. * Asserts the correct type of the context for the template that `NgForOf` will render.
  3756. *
  3757. * The presence of this method is a signal to the Ivy template type-check compiler that the
  3758. * `NgForOf` structural directive renders its template with a specific context type.
  3759. */
  3760. NgForOf.ngTemplateContextGuard = function (dir, ctx) {
  3761. return true;
  3762. };
  3763. __decorate([
  3764. Input(),
  3765. __metadata("design:type", Object),
  3766. __metadata("design:paramtypes", [Object])
  3767. ], NgForOf.prototype, "ngForOf", null);
  3768. __decorate([
  3769. Input(),
  3770. __metadata("design:type", Function),
  3771. __metadata("design:paramtypes", [Function])
  3772. ], NgForOf.prototype, "ngForTrackBy", null);
  3773. __decorate([
  3774. Input(),
  3775. __metadata("design:type", TemplateRef),
  3776. __metadata("design:paramtypes", [TemplateRef])
  3777. ], NgForOf.prototype, "ngForTemplate", null);
  3778. NgForOf = __decorate([
  3779. Directive({ selector: '[ngFor][ngForOf]' }),
  3780. __metadata("design:paramtypes", [ViewContainerRef, TemplateRef,
  3781. IterableDiffers])
  3782. ], NgForOf);
  3783. return NgForOf;
  3784. }());
  3785. var RecordViewTuple = /** @class */ (function () {
  3786. function RecordViewTuple(record, view) {
  3787. this.record = record;
  3788. this.view = view;
  3789. }
  3790. return RecordViewTuple;
  3791. }());
  3792. function getTypeName(type) {
  3793. return type['name'] || typeof type;
  3794. }
  3795. /**
  3796. * @license
  3797. * Copyright Google Inc. All Rights Reserved.
  3798. *
  3799. * Use of this source code is governed by an MIT-style license that can be
  3800. * found in the LICENSE file at https://angular.io/license
  3801. */
  3802. /**
  3803. * A structural directive that conditionally includes a template based on the value of
  3804. * an expression coerced to Boolean.
  3805. * When the expression evaluates to true, Angular renders the template
  3806. * provided in a `then` clause, and when false or null,
  3807. * Angular renders the template provided in an optional `else` clause. The default
  3808. * template for the `else` clause is blank.
  3809. *
  3810. * A [shorthand form](guide/structural-directives#the-asterisk--prefix) of the directive,
  3811. * `*ngIf="condition"`, is generally used, provided
  3812. * as an attribute of the anchor element for the inserted template.
  3813. * Angular expands this into a more explicit version, in which the anchor element
  3814. * is contained in an `<ng-template>` element.
  3815. *
  3816. * Simple form with shorthand syntax:
  3817. *
  3818. * ```
  3819. * <div *ngIf="condition">Content to render when condition is true.</div>
  3820. * ```
  3821. *
  3822. * Simple form with expanded syntax:
  3823. *
  3824. * ```
  3825. * <ng-template [ngIf]="condition"><div>Content to render when condition is
  3826. * true.</div></ng-template>
  3827. * ```
  3828. *
  3829. * Form with an "else" block:
  3830. *
  3831. * ```
  3832. * <div *ngIf="condition; else elseBlock">Content to render when condition is true.</div>
  3833. * <ng-template #elseBlock>Content to render when condition is false.</ng-template>
  3834. * ```
  3835. *
  3836. * Shorthand form with "then" and "else" blocks:
  3837. *
  3838. * ```
  3839. * <div *ngIf="condition; then thenBlock else elseBlock"></div>
  3840. * <ng-template #thenBlock>Content to render when condition is true.</ng-template>
  3841. * <ng-template #elseBlock>Content to render when condition is false.</ng-template>
  3842. * ```
  3843. *
  3844. * Form with storing the value locally:
  3845. *
  3846. * ```
  3847. * <div *ngIf="condition as value; else elseBlock">{{value}}</div>
  3848. * <ng-template #elseBlock>Content to render when value is null.</ng-template>
  3849. * ```
  3850. *
  3851. * @usageNotes
  3852. *
  3853. * The `*ngIf` directive is most commonly used to conditionally show an inline template,
  3854. * as seen in the following example.
  3855. * The default `else` template is blank.
  3856. *
  3857. * {@example common/ngIf/ts/module.ts region='NgIfSimple'}
  3858. *
  3859. * ### Showing an alternative template using `else`
  3860. *
  3861. * To display a template when `expression` evaluates to false, use an `else` template
  3862. * binding as shown in the following example.
  3863. * The `else` binding points to an `<ng-template>` element labeled `#elseBlock`.
  3864. * The template can be defined anywhere in the component view, but is typically placed right after
  3865. * `ngIf` for readability.
  3866. *
  3867. * {@example common/ngIf/ts/module.ts region='NgIfElse'}
  3868. *
  3869. * ### Using an external `then` template
  3870. *
  3871. * In the previous example, the then-clause template is specified inline, as the content of the
  3872. * tag that contains the `ngIf` directive. You can also specify a template that is defined
  3873. * externally, by referencing a labeled `<ng-template>` element. When you do this, you can
  3874. * change which template to use at runtime, as shown in the following example.
  3875. *
  3876. * {@example common/ngIf/ts/module.ts region='NgIfThenElse'}
  3877. *
  3878. * ### Storing a conditional result in a variable
  3879. *
  3880. * You might want to show a set of properties from the same object. If you are waiting
  3881. * for asynchronous data, the object can be undefined.
  3882. * In this case, you can use `ngIf` and store the result of the condition in a local
  3883. * variable as shown in the the following example.
  3884. *
  3885. * {@example common/ngIf/ts/module.ts region='NgIfAs'}
  3886. *
  3887. * This code uses only one `AsyncPipe`, so only one subscription is created.
  3888. * The conditional statement stores the result of `userStream|async` in the local variable `user`.
  3889. * You can then bind the local `user` repeatedly.
  3890. *
  3891. * The conditional displays the data only if `userStream` returns a value,
  3892. * so you don't need to use the
  3893. * [safe-navigation-operator](guide/template-syntax#safe-navigation-operator) (`?.`)
  3894. * to guard against null values when accessing properties.
  3895. * You can display an alternative template while waiting for the data.
  3896. *
  3897. * ### Shorthand syntax
  3898. *
  3899. * The shorthand syntax `*ngIf` expands into two separate template specifications
  3900. * for the "then" and "else" clauses. For example, consider the following shorthand statement,
  3901. * that is meant to show a loading page while waiting for data to be loaded.
  3902. *
  3903. * ```
  3904. * <div class="hero-list" *ngIf="heroes else loading">
  3905. * ...
  3906. * </div>
  3907. *
  3908. * <ng-template #loading>
  3909. * <div>Loading...</div>
  3910. * </ng-template>
  3911. * ```
  3912. *
  3913. * You can see that the "else" clause references the `<ng-template>`
  3914. * with the `#loading` label, and the template for the "then" clause
  3915. * is provided as the content of the anchor element.
  3916. *
  3917. * However, when Angular expands the shorthand syntax, it creates
  3918. * another `<ng-template>` tag, with `ngIf` and `ngIfElse` directives.
  3919. * The anchor element containing the template for the "then" clause becomes
  3920. * the content of this unlabeled `<ng-template>` tag.
  3921. *
  3922. * ```
  3923. * <ng-template [ngIf]="hero-list" [ngIfElse]="loading">
  3924. * <div class="hero-list">
  3925. * ...
  3926. * </div>
  3927. * </ng-template>
  3928. *
  3929. * <ng-template #loading>
  3930. * <div>Loading...</div>
  3931. * </ng-template>
  3932. * ```
  3933. *
  3934. * The presence of the implicit template object has implications for the nesting of
  3935. * structural directives. For more on this subject, see
  3936. * [Structural Directives](https://angular.io/guide/structural-directives#one-per-element).
  3937. *
  3938. * @ngModule CommonModule
  3939. * @publicApi
  3940. */
  3941. var NgIf = /** @class */ (function () {
  3942. function NgIf(_viewContainer, templateRef) {
  3943. this._viewContainer = _viewContainer;
  3944. this._context = new NgIfContext();
  3945. this._thenTemplateRef = null;
  3946. this._elseTemplateRef = null;
  3947. this._thenViewRef = null;
  3948. this._elseViewRef = null;
  3949. this._thenTemplateRef = templateRef;
  3950. }
  3951. Object.defineProperty(NgIf.prototype, "ngIf", {
  3952. /**
  3953. * The Boolean expression to evaluate as the condition for showing a template.
  3954. */
  3955. set: function (condition) {
  3956. this._context.$implicit = this._context.ngIf = condition;
  3957. this._updateView();
  3958. },
  3959. enumerable: true,
  3960. configurable: true
  3961. });
  3962. Object.defineProperty(NgIf.prototype, "ngIfThen", {
  3963. /**
  3964. * A template to show if the condition expression evaluates to true.
  3965. */
  3966. set: function (templateRef) {
  3967. assertTemplate('ngIfThen', templateRef);
  3968. this._thenTemplateRef = templateRef;
  3969. this._thenViewRef = null; // clear previous view if any.
  3970. this._updateView();
  3971. },
  3972. enumerable: true,
  3973. configurable: true
  3974. });
  3975. Object.defineProperty(NgIf.prototype, "ngIfElse", {
  3976. /**
  3977. * A template to show if the condition expression evaluates to false.
  3978. */
  3979. set: function (templateRef) {
  3980. assertTemplate('ngIfElse', templateRef);
  3981. this._elseTemplateRef = templateRef;
  3982. this._elseViewRef = null; // clear previous view if any.
  3983. this._updateView();
  3984. },
  3985. enumerable: true,
  3986. configurable: true
  3987. });
  3988. NgIf.prototype._updateView = function () {
  3989. if (this._context.$implicit) {
  3990. if (!this._thenViewRef) {
  3991. this._viewContainer.clear();
  3992. this._elseViewRef = null;
  3993. if (this._thenTemplateRef) {
  3994. this._thenViewRef =
  3995. this._viewContainer.createEmbeddedView(this._thenTemplateRef, this._context);
  3996. }
  3997. }
  3998. }
  3999. else {
  4000. if (!this._elseViewRef) {
  4001. this._viewContainer.clear();
  4002. this._thenViewRef = null;
  4003. if (this._elseTemplateRef) {
  4004. this._elseViewRef =
  4005. this._viewContainer.createEmbeddedView(this._elseTemplateRef, this._context);
  4006. }
  4007. }
  4008. }
  4009. };
  4010. __decorate([
  4011. Input(),
  4012. __metadata("design:type", Object),
  4013. __metadata("design:paramtypes", [Object])
  4014. ], NgIf.prototype, "ngIf", null);
  4015. __decorate([
  4016. Input(),
  4017. __metadata("design:type", Object),
  4018. __metadata("design:paramtypes", [Object])
  4019. ], NgIf.prototype, "ngIfThen", null);
  4020. __decorate([
  4021. Input(),
  4022. __metadata("design:type", Object),
  4023. __metadata("design:paramtypes", [Object])
  4024. ], NgIf.prototype, "ngIfElse", null);
  4025. NgIf = __decorate([
  4026. Directive({ selector: '[ngIf]' }),
  4027. __metadata("design:paramtypes", [ViewContainerRef, TemplateRef])
  4028. ], NgIf);
  4029. return NgIf;
  4030. }());
  4031. /**
  4032. * @publicApi
  4033. */
  4034. var NgIfContext = /** @class */ (function () {
  4035. function NgIfContext() {
  4036. this.$implicit = null;
  4037. this.ngIf = null;
  4038. }
  4039. return NgIfContext;
  4040. }());
  4041. function assertTemplate(property, templateRef) {
  4042. var isTemplateRefOrNull = !!(!templateRef || templateRef.createEmbeddedView);
  4043. if (!isTemplateRefOrNull) {
  4044. throw new Error(property + " must be a TemplateRef, but received '" + ɵstringify(templateRef) + "'.");
  4045. }
  4046. }
  4047. /**
  4048. * @license
  4049. * Copyright Google Inc. All Rights Reserved.
  4050. *
  4051. * Use of this source code is governed by an MIT-style license that can be
  4052. * found in the LICENSE file at https://angular.io/license
  4053. */
  4054. var SwitchView = /** @class */ (function () {
  4055. function SwitchView(_viewContainerRef, _templateRef) {
  4056. this._viewContainerRef = _viewContainerRef;
  4057. this._templateRef = _templateRef;
  4058. this._created = false;
  4059. }
  4060. SwitchView.prototype.create = function () {
  4061. this._created = true;
  4062. this._viewContainerRef.createEmbeddedView(this._templateRef);
  4063. };
  4064. SwitchView.prototype.destroy = function () {
  4065. this._created = false;
  4066. this._viewContainerRef.clear();
  4067. };
  4068. SwitchView.prototype.enforceState = function (created) {
  4069. if (created && !this._created) {
  4070. this.create();
  4071. }
  4072. else if (!created && this._created) {
  4073. this.destroy();
  4074. }
  4075. };
  4076. return SwitchView;
  4077. }());
  4078. /**
  4079. * @ngModule CommonModule
  4080. *
  4081. * @description A structural directive that adds or removes templates (displaying or hiding views)
  4082. * when the next match expression matches the switch expression.
  4083. *
  4084. * The `[ngSwitch]` directive on a container specifies an expression to match against.
  4085. * The expressions to match are provided by `ngSwitchCase` directives on views within the container.
  4086. * - Every view that matches is rendered.
  4087. * - If there are no matches, a view with the `ngSwitchDefault` directive is rendered.
  4088. * - Elements within the `[NgSwitch]` statement but outside of any `NgSwitchCase`
  4089. * or `ngSwitchDefault` directive are preserved at the location.
  4090. *
  4091. * @usageNotes
  4092. * Define a container element for the directive, and specify the switch expression
  4093. * to match against as an attribute:
  4094. *
  4095. * ```
  4096. * <container-element [ngSwitch]="switch_expression">
  4097. * ```
  4098. *
  4099. * Within the container, `*ngSwitchCase` statements specify the match expressions
  4100. * as attributes. Include `*ngSwitchDefault` as the final case.
  4101. *
  4102. * ```
  4103. * <container-element [ngSwitch]="switch_expression">
  4104. * <some-element *ngSwitchCase="match_expression_1">...</some-element>
  4105. * ...
  4106. * <some-element *ngSwitchDefault>...</some-element>
  4107. * </container-element>
  4108. * ```
  4109. *
  4110. * ### Usage Examples
  4111. *
  4112. * The following example shows how to use more than one case to display the same view:
  4113. *
  4114. * ```
  4115. * <container-element [ngSwitch]="switch_expression">
  4116. * <!-- the same view can be shown in more than one case -->
  4117. * <some-element *ngSwitchCase="match_expression_1">...</some-element>
  4118. * <some-element *ngSwitchCase="match_expression_2">...</some-element>
  4119. * <some-other-element *ngSwitchCase="match_expression_3">...</some-other-element>
  4120. * <!--default case when there are no matches -->
  4121. * <some-element *ngSwitchDefault>...</some-element>
  4122. * </container-element>
  4123. * ```
  4124. *
  4125. * The following example shows how cases can be nested:
  4126. * ```
  4127. * <container-element [ngSwitch]="switch_expression">
  4128. * <some-element *ngSwitchCase="match_expression_1">...</some-element>
  4129. * <some-element *ngSwitchCase="match_expression_2">...</some-element>
  4130. * <some-other-element *ngSwitchCase="match_expression_3">...</some-other-element>
  4131. * <ng-container *ngSwitchCase="match_expression_3">
  4132. * <!-- use a ng-container to group multiple root nodes -->
  4133. * <inner-element></inner-element>
  4134. * <inner-other-element></inner-other-element>
  4135. * </ng-container>
  4136. * <some-element *ngSwitchDefault>...</some-element>
  4137. * </container-element>
  4138. * ```
  4139. *
  4140. * @publicApi
  4141. * @see `NgSwitchCase`
  4142. * @see `NgSwitchDefault`
  4143. * @see [Structural Directives](guide/structural-directives)
  4144. *
  4145. */
  4146. var NgSwitch = /** @class */ (function () {
  4147. function NgSwitch() {
  4148. this._defaultUsed = false;
  4149. this._caseCount = 0;
  4150. this._lastCaseCheckIndex = 0;
  4151. this._lastCasesMatched = false;
  4152. }
  4153. Object.defineProperty(NgSwitch.prototype, "ngSwitch", {
  4154. set: function (newValue) {
  4155. this._ngSwitch = newValue;
  4156. if (this._caseCount === 0) {
  4157. this._updateDefaultCases(true);
  4158. }
  4159. },
  4160. enumerable: true,
  4161. configurable: true
  4162. });
  4163. /** @internal */
  4164. NgSwitch.prototype._addCase = function () { return this._caseCount++; };
  4165. /** @internal */
  4166. NgSwitch.prototype._addDefault = function (view) {
  4167. if (!this._defaultViews) {
  4168. this._defaultViews = [];
  4169. }
  4170. this._defaultViews.push(view);
  4171. };
  4172. /** @internal */
  4173. NgSwitch.prototype._matchCase = function (value) {
  4174. var matched = value == this._ngSwitch;
  4175. this._lastCasesMatched = this._lastCasesMatched || matched;
  4176. this._lastCaseCheckIndex++;
  4177. if (this._lastCaseCheckIndex === this._caseCount) {
  4178. this._updateDefaultCases(!this._lastCasesMatched);
  4179. this._lastCaseCheckIndex = 0;
  4180. this._lastCasesMatched = false;
  4181. }
  4182. return matched;
  4183. };
  4184. NgSwitch.prototype._updateDefaultCases = function (useDefault) {
  4185. if (this._defaultViews && useDefault !== this._defaultUsed) {
  4186. this._defaultUsed = useDefault;
  4187. for (var i = 0; i < this._defaultViews.length; i++) {
  4188. var defaultView = this._defaultViews[i];
  4189. defaultView.enforceState(useDefault);
  4190. }
  4191. }
  4192. };
  4193. __decorate([
  4194. Input(),
  4195. __metadata("design:type", Object),
  4196. __metadata("design:paramtypes", [Object])
  4197. ], NgSwitch.prototype, "ngSwitch", null);
  4198. NgSwitch = __decorate([
  4199. Directive({ selector: '[ngSwitch]' })
  4200. ], NgSwitch);
  4201. return NgSwitch;
  4202. }());
  4203. /**
  4204. * @ngModule CommonModule
  4205. *
  4206. * @description
  4207. * Provides a switch case expression to match against an enclosing `ngSwitch` expression.
  4208. * When the expressions match, the given `NgSwitchCase` template is rendered.
  4209. * If multiple match expressions match the switch expression value, all of them are displayed.
  4210. *
  4211. * @usageNotes
  4212. *
  4213. * Within a switch container, `*ngSwitchCase` statements specify the match expressions
  4214. * as attributes. Include `*ngSwitchDefault` as the final case.
  4215. *
  4216. * ```
  4217. * <container-element [ngSwitch]="switch_expression">
  4218. * <some-element *ngSwitchCase="match_expression_1">...</some-element>
  4219. * ...
  4220. * <some-element *ngSwitchDefault>...</some-element>
  4221. * </container-element>
  4222. * ```
  4223. *
  4224. * Each switch-case statement contains an in-line HTML template or template reference
  4225. * that defines the subtree to be selected if the value of the match expression
  4226. * matches the value of the switch expression.
  4227. *
  4228. * Unlike JavaScript, which uses strict equality, Angular uses loose equality.
  4229. * This means that the empty string, `""` matches 0.
  4230. *
  4231. * @publicApi
  4232. * @see `NgSwitch`
  4233. * @see `NgSwitchDefault`
  4234. *
  4235. */
  4236. var NgSwitchCase = /** @class */ (function () {
  4237. function NgSwitchCase(viewContainer, templateRef, ngSwitch) {
  4238. this.ngSwitch = ngSwitch;
  4239. ngSwitch._addCase();
  4240. this._view = new SwitchView(viewContainer, templateRef);
  4241. }
  4242. /**
  4243. * Performs case matching. For internal use only.
  4244. */
  4245. NgSwitchCase.prototype.ngDoCheck = function () { this._view.enforceState(this.ngSwitch._matchCase(this.ngSwitchCase)); };
  4246. __decorate([
  4247. Input(),
  4248. __metadata("design:type", Object)
  4249. ], NgSwitchCase.prototype, "ngSwitchCase", void 0);
  4250. NgSwitchCase = __decorate([
  4251. Directive({ selector: '[ngSwitchCase]' }),
  4252. __param(2, Host()),
  4253. __metadata("design:paramtypes", [ViewContainerRef, TemplateRef,
  4254. NgSwitch])
  4255. ], NgSwitchCase);
  4256. return NgSwitchCase;
  4257. }());
  4258. /**
  4259. * @ngModule CommonModule
  4260. *
  4261. * @description
  4262. *
  4263. * Creates a view that is rendered when no `NgSwitchCase` expressions
  4264. * match the `NgSwitch` expression.
  4265. * This statement should be the final case in an `NgSwitch`.
  4266. *
  4267. * @publicApi
  4268. * @see `NgSwitch`
  4269. * @see `NgSwitchCase`
  4270. *
  4271. */
  4272. var NgSwitchDefault = /** @class */ (function () {
  4273. function NgSwitchDefault(viewContainer, templateRef, ngSwitch) {
  4274. ngSwitch._addDefault(new SwitchView(viewContainer, templateRef));
  4275. }
  4276. NgSwitchDefault = __decorate([
  4277. Directive({ selector: '[ngSwitchDefault]' }),
  4278. __param(2, Host()),
  4279. __metadata("design:paramtypes", [ViewContainerRef, TemplateRef,
  4280. NgSwitch])
  4281. ], NgSwitchDefault);
  4282. return NgSwitchDefault;
  4283. }());
  4284. /**
  4285. * @license
  4286. * Copyright Google Inc. All Rights Reserved.
  4287. *
  4288. * Use of this source code is governed by an MIT-style license that can be
  4289. * found in the LICENSE file at https://angular.io/license
  4290. */
  4291. /**
  4292. * @ngModule CommonModule
  4293. *
  4294. * @usageNotes
  4295. * ```
  4296. * <some-element [ngPlural]="value">
  4297. * <ng-template ngPluralCase="=0">there is nothing</ng-template>
  4298. * <ng-template ngPluralCase="=1">there is one</ng-template>
  4299. * <ng-template ngPluralCase="few">there are a few</ng-template>
  4300. * </some-element>
  4301. * ```
  4302. *
  4303. * @description
  4304. *
  4305. * Adds / removes DOM sub-trees based on a numeric value. Tailored for pluralization.
  4306. *
  4307. * Displays DOM sub-trees that match the switch expression value, or failing that, DOM sub-trees
  4308. * that match the switch expression's pluralization category.
  4309. *
  4310. * To use this directive you must provide a container element that sets the `[ngPlural]` attribute
  4311. * to a switch expression. Inner elements with a `[ngPluralCase]` will display based on their
  4312. * expression:
  4313. * - if `[ngPluralCase]` is set to a value starting with `=`, it will only display if the value
  4314. * matches the switch expression exactly,
  4315. * - otherwise, the view will be treated as a "category match", and will only display if exact
  4316. * value matches aren't found and the value maps to its category for the defined locale.
  4317. *
  4318. * See http://cldr.unicode.org/index/cldr-spec/plural-rules
  4319. *
  4320. * @publicApi
  4321. */
  4322. var NgPlural = /** @class */ (function () {
  4323. function NgPlural(_localization) {
  4324. this._localization = _localization;
  4325. this._caseViews = {};
  4326. }
  4327. Object.defineProperty(NgPlural.prototype, "ngPlural", {
  4328. set: function (value) {
  4329. this._switchValue = value;
  4330. this._updateView();
  4331. },
  4332. enumerable: true,
  4333. configurable: true
  4334. });
  4335. NgPlural.prototype.addCase = function (value, switchView) { this._caseViews[value] = switchView; };
  4336. NgPlural.prototype._updateView = function () {
  4337. this._clearViews();
  4338. var cases = Object.keys(this._caseViews);
  4339. var key = getPluralCategory(this._switchValue, cases, this._localization);
  4340. this._activateView(this._caseViews[key]);
  4341. };
  4342. NgPlural.prototype._clearViews = function () {
  4343. if (this._activeView)
  4344. this._activeView.destroy();
  4345. };
  4346. NgPlural.prototype._activateView = function (view) {
  4347. if (view) {
  4348. this._activeView = view;
  4349. this._activeView.create();
  4350. }
  4351. };
  4352. __decorate([
  4353. Input(),
  4354. __metadata("design:type", Number),
  4355. __metadata("design:paramtypes", [Number])
  4356. ], NgPlural.prototype, "ngPlural", null);
  4357. NgPlural = __decorate([
  4358. Directive({ selector: '[ngPlural]' }),
  4359. __metadata("design:paramtypes", [NgLocalization])
  4360. ], NgPlural);
  4361. return NgPlural;
  4362. }());
  4363. /**
  4364. * @ngModule CommonModule
  4365. *
  4366. * @description
  4367. *
  4368. * Creates a view that will be added/removed from the parent {@link NgPlural} when the
  4369. * given expression matches the plural expression according to CLDR rules.
  4370. *
  4371. * @usageNotes
  4372. * ```
  4373. * <some-element [ngPlural]="value">
  4374. * <ng-template ngPluralCase="=0">...</ng-template>
  4375. * <ng-template ngPluralCase="other">...</ng-template>
  4376. * </some-element>
  4377. *```
  4378. *
  4379. * See {@link NgPlural} for more details and example.
  4380. *
  4381. * @publicApi
  4382. */
  4383. var NgPluralCase = /** @class */ (function () {
  4384. function NgPluralCase(value, template, viewContainer, ngPlural) {
  4385. this.value = value;
  4386. var isANumber = !isNaN(Number(value));
  4387. ngPlural.addCase(isANumber ? "=" + value : value, new SwitchView(viewContainer, template));
  4388. }
  4389. NgPluralCase = __decorate([
  4390. Directive({ selector: '[ngPluralCase]' }),
  4391. __param(0, Attribute('ngPluralCase')),
  4392. __param(3, Host()),
  4393. __metadata("design:paramtypes", [String, TemplateRef,
  4394. ViewContainerRef, NgPlural])
  4395. ], NgPluralCase);
  4396. return NgPluralCase;
  4397. }());
  4398. /**
  4399. * Used as a token for an injected service within the NgStyle directive.
  4400. *
  4401. * NgStyle behaves differenly whether or not VE is being used or not. If
  4402. * present then the legacy ngClass diffing algorithm will be used as an
  4403. * injected service. Otherwise the new diffing algorithm (which delegates
  4404. * to the `[style]` binding) will be used. This toggle behavior is done so
  4405. * via the ivy_switch mechanism.
  4406. */
  4407. var NgStyleImpl = /** @class */ (function () {
  4408. function NgStyleImpl() {
  4409. }
  4410. return NgStyleImpl;
  4411. }());
  4412. var NgStyleR2Impl = /** @class */ (function () {
  4413. function NgStyleR2Impl(_ngEl, _differs, _renderer) {
  4414. this._ngEl = _ngEl;
  4415. this._differs = _differs;
  4416. this._renderer = _renderer;
  4417. }
  4418. NgStyleR2Impl.prototype.getValue = function () { return null; };
  4419. /**
  4420. * A map of style properties, specified as colon-separated
  4421. * key-value pairs.
  4422. * * The key is a style name, with an optional `.<unit>` suffix
  4423. * (such as 'top.px', 'font-style.em').
  4424. * * The value is an expression to be evaluated.
  4425. */
  4426. NgStyleR2Impl.prototype.setNgStyle = function (values) {
  4427. this._ngStyle = values;
  4428. if (!this._differ && values) {
  4429. this._differ = this._differs.find(values).create();
  4430. }
  4431. };
  4432. /**
  4433. * Applies the new styles if needed.
  4434. */
  4435. NgStyleR2Impl.prototype.applyChanges = function () {
  4436. if (this._differ) {
  4437. var changes = this._differ.diff(this._ngStyle);
  4438. if (changes) {
  4439. this._applyChanges(changes);
  4440. }
  4441. }
  4442. };
  4443. NgStyleR2Impl.prototype._applyChanges = function (changes) {
  4444. var _this = this;
  4445. changes.forEachRemovedItem(function (record) { return _this._setStyle(record.key, null); });
  4446. changes.forEachAddedItem(function (record) { return _this._setStyle(record.key, record.currentValue); });
  4447. changes.forEachChangedItem(function (record) { return _this._setStyle(record.key, record.currentValue); });
  4448. };
  4449. NgStyleR2Impl.prototype._setStyle = function (nameAndUnit, value) {
  4450. var _a = __read(nameAndUnit.split('.'), 2), name = _a[0], unit = _a[1];
  4451. value = value != null && unit ? "" + value + unit : value;
  4452. if (value != null) {
  4453. this._renderer.setStyle(this._ngEl.nativeElement, name, value);
  4454. }
  4455. else {
  4456. this._renderer.removeStyle(this._ngEl.nativeElement, name);
  4457. }
  4458. };
  4459. NgStyleR2Impl = __decorate([
  4460. Injectable(),
  4461. __metadata("design:paramtypes", [ElementRef, KeyValueDiffers, Renderer2])
  4462. ], NgStyleR2Impl);
  4463. return NgStyleR2Impl;
  4464. }());
  4465. var NgStyleR3Impl = /** @class */ (function () {
  4466. function NgStyleR3Impl() {
  4467. this._differ = new StylingDiffer('NgStyle', 8 /* AllowUnits */);
  4468. this._value = null;
  4469. }
  4470. NgStyleR3Impl.prototype.getValue = function () { return this._value; };
  4471. NgStyleR3Impl.prototype.setNgStyle = function (value) { this._differ.setValue(value); };
  4472. NgStyleR3Impl.prototype.applyChanges = function () {
  4473. if (this._differ.hasValueChanged()) {
  4474. this._value = this._differ.value;
  4475. }
  4476. };
  4477. NgStyleR3Impl = __decorate([
  4478. Injectable()
  4479. ], NgStyleR3Impl);
  4480. return NgStyleR3Impl;
  4481. }());
  4482. // the implementation for both NgClassR2Impl and NgClassR3Impl are
  4483. // not ivy_switch'd away, instead they are only hooked up into the
  4484. // DI via NgStyle's directive's provider property.
  4485. var NgStyleImplProvider__PRE_R3__ = {
  4486. provide: NgStyleImpl,
  4487. useClass: NgStyleR2Impl
  4488. };
  4489. var NgStyleImplProvider__POST_R3__ = {
  4490. provide: NgStyleImpl,
  4491. useClass: NgStyleR3Impl
  4492. };
  4493. var NgStyleImplProvider = NgStyleImplProvider__PRE_R3__;
  4494. /*
  4495. * NgStyle (as well as NgClass) behaves differently when loaded in the VE and when not.
  4496. *
  4497. * If the VE is present (which is for older versions of Angular) then NgStyle will inject
  4498. * the legacy diffing algorithm as a service and delegate all styling changes to that.
  4499. *
  4500. * If the VE is not present then NgStyle will normalize (through the injected service) and
  4501. * then write all styling changes to the `[style]` binding directly (through a host binding).
  4502. * Then Angular will notice the host binding change and treat the changes as styling
  4503. * changes and apply them via the core styling instructions that exist within Angular.
  4504. */
  4505. // used when the VE is present
  4506. var ngStyleDirectiveDef__PRE_R3__ = undefined;
  4507. var ɵ0$1 = function () { }, ɵ1$1 = function () { }, ɵ2$1 = function (rf, ctx, elIndex) {
  4508. if (rf & 1 /* Create */) {
  4509. ɵɵstyling();
  4510. }
  4511. if (rf & 2 /* Update */) {
  4512. ɵɵstyleMap(ctx.getValue());
  4513. ɵɵstylingApply();
  4514. }
  4515. };
  4516. // used when the VE is not present (note the directive will
  4517. // never be instantiated normally because it is apart of a
  4518. // base class)
  4519. var ngStyleDirectiveDef__POST_R3__ = ɵɵdefineDirective({
  4520. type: ɵ0$1,
  4521. selectors: null,
  4522. factory: ɵ1$1,
  4523. hostBindings: ɵ2$1
  4524. });
  4525. var ngStyleDirectiveDef = ngStyleDirectiveDef__PRE_R3__;
  4526. /**
  4527. * Serves as the base non-VE container for NgStyle.
  4528. *
  4529. * While this is a base class that NgStyle extends from, the
  4530. * class itself acts as a container for non-VE code to setup
  4531. * a link to the `[style]` host binding (via the static
  4532. * `ngDirectiveDef` property on the class).
  4533. *
  4534. * Note that the `ngDirectiveDef` property's code is switched
  4535. * depending if VE is present or not (this allows for the
  4536. * binding code to be set only for newer versions of Angular).
  4537. *
  4538. * @publicApi
  4539. */
  4540. var NgStyleBase = /** @class */ (function () {
  4541. function NgStyleBase(_delegate) {
  4542. this._delegate = _delegate;
  4543. }
  4544. NgStyleBase.prototype.getValue = function () { return this._delegate.getValue(); };
  4545. NgStyleBase.ngDirectiveDef = ngStyleDirectiveDef;
  4546. return NgStyleBase;
  4547. }());
  4548. /**
  4549. * @ngModule CommonModule
  4550. *
  4551. * @usageNotes
  4552. *
  4553. * Set the font of the containing element to the result of an expression.
  4554. *
  4555. * ```
  4556. * <some-element [ngStyle]="{'font-style': styleExp}">...</some-element>
  4557. * ```
  4558. *
  4559. * Set the width of the containing element to a pixel value returned by an expression.
  4560. *
  4561. * ```
  4562. * <some-element [ngStyle]="{'max-width.px': widthExp}">...</some-element>
  4563. * ```
  4564. *
  4565. * Set a collection of style values using an expression that returns key-value pairs.
  4566. *
  4567. * ```
  4568. * <some-element [ngStyle]="objExp">...</some-element>
  4569. * ```
  4570. *
  4571. * @description
  4572. *
  4573. * An attribute directive that updates styles for the containing HTML element.
  4574. * Sets one or more style properties, specified as colon-separated key-value pairs.
  4575. * The key is a style name, with an optional `.<unit>` suffix
  4576. * (such as 'top.px', 'font-style.em').
  4577. * The value is an expression to be evaluated.
  4578. * The resulting non-null value, expressed in the given unit,
  4579. * is assigned to the given style property.
  4580. * If the result of evaluation is null, the corresponding style is removed.
  4581. *
  4582. * @publicApi
  4583. */
  4584. var NgStyle = /** @class */ (function (_super) {
  4585. __extends(NgStyle, _super);
  4586. function NgStyle(delegate) {
  4587. return _super.call(this, delegate) || this;
  4588. }
  4589. Object.defineProperty(NgStyle.prototype, "ngStyle", {
  4590. set: function (value) { this._delegate.setNgStyle(value); },
  4591. enumerable: true,
  4592. configurable: true
  4593. });
  4594. NgStyle.prototype.ngDoCheck = function () { this._delegate.applyChanges(); };
  4595. __decorate([
  4596. Input('ngStyle'),
  4597. __metadata("design:type", Object),
  4598. __metadata("design:paramtypes", [Object])
  4599. ], NgStyle.prototype, "ngStyle", null);
  4600. NgStyle = __decorate([
  4601. Directive({ selector: '[ngStyle]', providers: [NgStyleImplProvider] }),
  4602. __metadata("design:paramtypes", [NgStyleImpl])
  4603. ], NgStyle);
  4604. return NgStyle;
  4605. }(NgStyleBase));
  4606. /**
  4607. * @license
  4608. * Copyright Google Inc. All Rights Reserved.
  4609. *
  4610. * Use of this source code is governed by an MIT-style license that can be
  4611. * found in the LICENSE file at https://angular.io/license
  4612. */
  4613. /**
  4614. * @ngModule CommonModule
  4615. *
  4616. * @description
  4617. *
  4618. * Inserts an embedded view from a prepared `TemplateRef`.
  4619. *
  4620. * You can attach a context object to the `EmbeddedViewRef` by setting `[ngTemplateOutletContext]`.
  4621. * `[ngTemplateOutletContext]` should be an object, the object's keys will be available for binding
  4622. * by the local template `let` declarations.
  4623. *
  4624. * @usageNotes
  4625. * ```
  4626. * <ng-container *ngTemplateOutlet="templateRefExp; context: contextExp"></ng-container>
  4627. * ```
  4628. *
  4629. * Using the key `$implicit` in the context object will set its value as default.
  4630. *
  4631. * ### Example
  4632. *
  4633. * {@example common/ngTemplateOutlet/ts/module.ts region='NgTemplateOutlet'}
  4634. *
  4635. * @publicApi
  4636. */
  4637. var NgTemplateOutlet = /** @class */ (function () {
  4638. function NgTemplateOutlet(_viewContainerRef) {
  4639. this._viewContainerRef = _viewContainerRef;
  4640. this._viewRef = null;
  4641. /**
  4642. * A context object to attach to the {@link EmbeddedViewRef}. This should be an
  4643. * object, the object's keys will be available for binding by the local template `let`
  4644. * declarations.
  4645. * Using the key `$implicit` in the context object will set its value as default.
  4646. */
  4647. this.ngTemplateOutletContext = null;
  4648. /**
  4649. * A string defining the template reference and optionally the context object for the template.
  4650. */
  4651. this.ngTemplateOutlet = null;
  4652. }
  4653. NgTemplateOutlet.prototype.ngOnChanges = function (changes) {
  4654. var recreateView = this._shouldRecreateView(changes);
  4655. if (recreateView) {
  4656. if (this._viewRef) {
  4657. this._viewContainerRef.remove(this._viewContainerRef.indexOf(this._viewRef));
  4658. }
  4659. if (this.ngTemplateOutlet) {
  4660. this._viewRef = this._viewContainerRef.createEmbeddedView(this.ngTemplateOutlet, this.ngTemplateOutletContext);
  4661. }
  4662. }
  4663. else {
  4664. if (this._viewRef && this.ngTemplateOutletContext) {
  4665. this._updateExistingContext(this.ngTemplateOutletContext);
  4666. }
  4667. }
  4668. };
  4669. /**
  4670. * We need to re-create existing embedded view if:
  4671. * - templateRef has changed
  4672. * - context has changes
  4673. *
  4674. * We mark context object as changed when the corresponding object
  4675. * shape changes (new properties are added or existing properties are removed).
  4676. * In other words we consider context with the same properties as "the same" even
  4677. * if object reference changes (see https://github.com/angular/angular/issues/13407).
  4678. */
  4679. NgTemplateOutlet.prototype._shouldRecreateView = function (changes) {
  4680. var ctxChange = changes['ngTemplateOutletContext'];
  4681. return !!changes['ngTemplateOutlet'] || (ctxChange && this._hasContextShapeChanged(ctxChange));
  4682. };
  4683. NgTemplateOutlet.prototype._hasContextShapeChanged = function (ctxChange) {
  4684. var e_1, _a;
  4685. var prevCtxKeys = Object.keys(ctxChange.previousValue || {});
  4686. var currCtxKeys = Object.keys(ctxChange.currentValue || {});
  4687. if (prevCtxKeys.length === currCtxKeys.length) {
  4688. try {
  4689. for (var currCtxKeys_1 = __values(currCtxKeys), currCtxKeys_1_1 = currCtxKeys_1.next(); !currCtxKeys_1_1.done; currCtxKeys_1_1 = currCtxKeys_1.next()) {
  4690. var propName = currCtxKeys_1_1.value;
  4691. if (prevCtxKeys.indexOf(propName) === -1) {
  4692. return true;
  4693. }
  4694. }
  4695. }
  4696. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  4697. finally {
  4698. try {
  4699. if (currCtxKeys_1_1 && !currCtxKeys_1_1.done && (_a = currCtxKeys_1.return)) _a.call(currCtxKeys_1);
  4700. }
  4701. finally { if (e_1) throw e_1.error; }
  4702. }
  4703. return false;
  4704. }
  4705. else {
  4706. return true;
  4707. }
  4708. };
  4709. NgTemplateOutlet.prototype._updateExistingContext = function (ctx) {
  4710. var e_2, _a;
  4711. try {
  4712. for (var _b = __values(Object.keys(ctx)), _c = _b.next(); !_c.done; _c = _b.next()) {
  4713. var propName = _c.value;
  4714. this._viewRef.context[propName] = this.ngTemplateOutletContext[propName];
  4715. }
  4716. }
  4717. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  4718. finally {
  4719. try {
  4720. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  4721. }
  4722. finally { if (e_2) throw e_2.error; }
  4723. }
  4724. };
  4725. __decorate([
  4726. Input(),
  4727. __metadata("design:type", Object)
  4728. ], NgTemplateOutlet.prototype, "ngTemplateOutletContext", void 0);
  4729. __decorate([
  4730. Input(),
  4731. __metadata("design:type", Object)
  4732. ], NgTemplateOutlet.prototype, "ngTemplateOutlet", void 0);
  4733. NgTemplateOutlet = __decorate([
  4734. Directive({ selector: '[ngTemplateOutlet]' }),
  4735. __metadata("design:paramtypes", [ViewContainerRef])
  4736. ], NgTemplateOutlet);
  4737. return NgTemplateOutlet;
  4738. }());
  4739. /**
  4740. * @license
  4741. * Copyright Google Inc. All Rights Reserved.
  4742. *
  4743. * Use of this source code is governed by an MIT-style license that can be
  4744. * found in the LICENSE file at https://angular.io/license
  4745. */
  4746. /**
  4747. * A collection of Angular directives that are likely to be used in each and every Angular
  4748. * application.
  4749. */
  4750. var COMMON_DIRECTIVES = [
  4751. NgClass,
  4752. NgComponentOutlet,
  4753. NgForOf,
  4754. NgIf,
  4755. NgTemplateOutlet,
  4756. NgStyle,
  4757. NgSwitch,
  4758. NgSwitchCase,
  4759. NgSwitchDefault,
  4760. NgPlural,
  4761. NgPluralCase,
  4762. ];
  4763. /**
  4764. * @license
  4765. * Copyright Google Inc. All Rights Reserved.
  4766. *
  4767. * Use of this source code is governed by an MIT-style license that can be
  4768. * found in the LICENSE file at https://angular.io/license
  4769. */
  4770. function invalidPipeArgumentError(type, value) {
  4771. return Error("InvalidPipeArgument: '" + value + "' for pipe '" + ɵstringify(type) + "'");
  4772. }
  4773. var NumberFormatter = /** @class */ (function () {
  4774. function NumberFormatter() {
  4775. }
  4776. NumberFormatter.format = function (num, locale, style, opts) {
  4777. if (opts === void 0) { opts = {}; }
  4778. var minimumIntegerDigits = opts.minimumIntegerDigits, minimumFractionDigits = opts.minimumFractionDigits, maximumFractionDigits = opts.maximumFractionDigits, currency = opts.currency, _a = opts.currencyAsSymbol, currencyAsSymbol = _a === void 0 ? false : _a;
  4779. var options = {
  4780. minimumIntegerDigits: minimumIntegerDigits,
  4781. minimumFractionDigits: minimumFractionDigits,
  4782. maximumFractionDigits: maximumFractionDigits,
  4783. style: NumberFormatStyle[style].toLowerCase()
  4784. };
  4785. if (style == NumberFormatStyle.Currency) {
  4786. options.currency = typeof currency == 'string' ? currency : undefined;
  4787. options.currencyDisplay = currencyAsSymbol ? 'symbol' : 'code';
  4788. }
  4789. return new Intl.NumberFormat(locale, options).format(num);
  4790. };
  4791. return NumberFormatter;
  4792. }());
  4793. var DATE_FORMATS_SPLIT$1 = /((?:[^yMLdHhmsazZEwGjJ']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|L+|d+|H+|h+|J+|j+|m+|s+|a|z|Z|G+|w+))(.*)/;
  4794. var PATTERN_ALIASES = {
  4795. // Keys are quoted so they do not get renamed during closure compilation.
  4796. 'yMMMdjms': datePartGetterFactory(combine([
  4797. digitCondition('year', 1),
  4798. nameCondition('month', 3),
  4799. digitCondition('day', 1),
  4800. digitCondition('hour', 1),
  4801. digitCondition('minute', 1),
  4802. digitCondition('second', 1),
  4803. ])),
  4804. 'yMdjm': datePartGetterFactory(combine([
  4805. digitCondition('year', 1), digitCondition('month', 1), digitCondition('day', 1),
  4806. digitCondition('hour', 1), digitCondition('minute', 1)
  4807. ])),
  4808. 'yMMMMEEEEd': datePartGetterFactory(combine([
  4809. digitCondition('year', 1), nameCondition('month', 4), nameCondition('weekday', 4),
  4810. digitCondition('day', 1)
  4811. ])),
  4812. 'yMMMMd': datePartGetterFactory(combine([digitCondition('year', 1), nameCondition('month', 4), digitCondition('day', 1)])),
  4813. 'yMMMd': datePartGetterFactory(combine([digitCondition('year', 1), nameCondition('month', 3), digitCondition('day', 1)])),
  4814. 'yMd': datePartGetterFactory(combine([digitCondition('year', 1), digitCondition('month', 1), digitCondition('day', 1)])),
  4815. 'jms': datePartGetterFactory(combine([digitCondition('hour', 1), digitCondition('second', 1), digitCondition('minute', 1)])),
  4816. 'jm': datePartGetterFactory(combine([digitCondition('hour', 1), digitCondition('minute', 1)]))
  4817. };
  4818. var DATE_FORMATS$1 = {
  4819. // Keys are quoted so they do not get renamed.
  4820. 'yyyy': datePartGetterFactory(digitCondition('year', 4)),
  4821. 'yy': datePartGetterFactory(digitCondition('year', 2)),
  4822. 'y': datePartGetterFactory(digitCondition('year', 1)),
  4823. 'MMMM': datePartGetterFactory(nameCondition('month', 4)),
  4824. 'MMM': datePartGetterFactory(nameCondition('month', 3)),
  4825. 'MM': datePartGetterFactory(digitCondition('month', 2)),
  4826. 'M': datePartGetterFactory(digitCondition('month', 1)),
  4827. 'LLLL': datePartGetterFactory(nameCondition('month', 4)),
  4828. 'L': datePartGetterFactory(nameCondition('month', 1)),
  4829. 'dd': datePartGetterFactory(digitCondition('day', 2)),
  4830. 'd': datePartGetterFactory(digitCondition('day', 1)),
  4831. 'HH': digitModifier(hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 2), false)))),
  4832. 'H': hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), false))),
  4833. 'hh': digitModifier(hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 2), true)))),
  4834. 'h': hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), true))),
  4835. 'jj': datePartGetterFactory(digitCondition('hour', 2)),
  4836. 'j': datePartGetterFactory(digitCondition('hour', 1)),
  4837. 'mm': digitModifier(datePartGetterFactory(digitCondition('minute', 2))),
  4838. 'm': datePartGetterFactory(digitCondition('minute', 1)),
  4839. 'ss': digitModifier(datePartGetterFactory(digitCondition('second', 2))),
  4840. 's': datePartGetterFactory(digitCondition('second', 1)),
  4841. // while ISO 8601 requires fractions to be prefixed with `.` or `,`
  4842. // we can be just safely rely on using `sss` since we currently don't support single or two digit
  4843. // fractions
  4844. 'sss': datePartGetterFactory(digitCondition('second', 3)),
  4845. 'EEEE': datePartGetterFactory(nameCondition('weekday', 4)),
  4846. 'EEE': datePartGetterFactory(nameCondition('weekday', 3)),
  4847. 'EE': datePartGetterFactory(nameCondition('weekday', 2)),
  4848. 'E': datePartGetterFactory(nameCondition('weekday', 1)),
  4849. 'a': hourClockExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), true))),
  4850. 'Z': timeZoneGetter$1('short'),
  4851. 'z': timeZoneGetter$1('long'),
  4852. 'ww': datePartGetterFactory({}),
  4853. // first Thursday of the year. not support ?
  4854. 'w': datePartGetterFactory({}),
  4855. // of the year not support ?
  4856. 'G': datePartGetterFactory(nameCondition('era', 1)),
  4857. 'GG': datePartGetterFactory(nameCondition('era', 2)),
  4858. 'GGG': datePartGetterFactory(nameCondition('era', 3)),
  4859. 'GGGG': datePartGetterFactory(nameCondition('era', 4))
  4860. };
  4861. function digitModifier(inner) {
  4862. return function (date, locale) {
  4863. var result = inner(date, locale);
  4864. return result.length == 1 ? '0' + result : result;
  4865. };
  4866. }
  4867. function hourClockExtractor(inner) {
  4868. return function (date, locale) { return inner(date, locale).split(' ')[1]; };
  4869. }
  4870. function hourExtractor(inner) {
  4871. return function (date, locale) { return inner(date, locale).split(' ')[0]; };
  4872. }
  4873. function intlDateFormat(date, locale, options) {
  4874. return new Intl.DateTimeFormat(locale, options).format(date).replace(/[\u200e\u200f]/g, '');
  4875. }
  4876. function timeZoneGetter$1(timezone) {
  4877. // To workaround `Intl` API restriction for single timezone let format with 24 hours
  4878. var options = { hour: '2-digit', hour12: false, timeZoneName: timezone };
  4879. return function (date, locale) {
  4880. var result = intlDateFormat(date, locale, options);
  4881. // Then extract first 3 letters that related to hours
  4882. return result ? result.substring(3) : '';
  4883. };
  4884. }
  4885. function hour12Modify(options, value) {
  4886. options.hour12 = value;
  4887. return options;
  4888. }
  4889. function digitCondition(prop, len) {
  4890. var result = {};
  4891. result[prop] = len === 2 ? '2-digit' : 'numeric';
  4892. return result;
  4893. }
  4894. function nameCondition(prop, len) {
  4895. var result = {};
  4896. if (len < 4) {
  4897. result[prop] = len > 1 ? 'short' : 'narrow';
  4898. }
  4899. else {
  4900. result[prop] = 'long';
  4901. }
  4902. return result;
  4903. }
  4904. function combine(options) {
  4905. return options.reduce(function (merged, opt) { return (__assign({}, merged, opt)); }, {});
  4906. }
  4907. function datePartGetterFactory(ret) {
  4908. return function (date, locale) { return intlDateFormat(date, locale, ret); };
  4909. }
  4910. var DATE_FORMATTER_CACHE = new Map();
  4911. function dateFormatter(format, date, locale) {
  4912. var fn = PATTERN_ALIASES[format];
  4913. if (fn)
  4914. return fn(date, locale);
  4915. var cacheKey = format;
  4916. var parts = DATE_FORMATTER_CACHE.get(cacheKey);
  4917. if (!parts) {
  4918. parts = [];
  4919. var match = void 0;
  4920. DATE_FORMATS_SPLIT$1.exec(format);
  4921. var _format = format;
  4922. while (_format) {
  4923. match = DATE_FORMATS_SPLIT$1.exec(_format);
  4924. if (match) {
  4925. parts = parts.concat(match.slice(1));
  4926. _format = parts.pop();
  4927. }
  4928. else {
  4929. parts.push(_format);
  4930. _format = null;
  4931. }
  4932. }
  4933. DATE_FORMATTER_CACHE.set(cacheKey, parts);
  4934. }
  4935. return parts.reduce(function (text, part) {
  4936. var fn = DATE_FORMATS$1[part];
  4937. return text + (fn ? fn(date, locale) : partToTime(part));
  4938. }, '');
  4939. }
  4940. function partToTime(part) {
  4941. return part === '\'\'' ? '\'' : part.replace(/(^'|'$)/g, '').replace(/''/g, '\'');
  4942. }
  4943. var DateFormatter = /** @class */ (function () {
  4944. function DateFormatter() {
  4945. }
  4946. DateFormatter.format = function (date, locale, pattern) {
  4947. return dateFormatter(pattern, date, locale);
  4948. };
  4949. return DateFormatter;
  4950. }());
  4951. /**
  4952. * @license
  4953. * Copyright Google Inc. All Rights Reserved.
  4954. *
  4955. * Use of this source code is governed by an MIT-style license that can be
  4956. * found in the LICENSE file at https://angular.io/license
  4957. */
  4958. /**
  4959. * @ngModule CommonModule
  4960. * @description
  4961. *
  4962. * Formats a date according to locale rules.
  4963. *
  4964. * Where:
  4965. * - `expression` is a date object or a number (milliseconds since UTC epoch) or an ISO string
  4966. * (https://www.w3.org/TR/NOTE-datetime).
  4967. * - `format` indicates which date/time components to include. The format can be predefined as
  4968. * shown below or custom as shown in the table.
  4969. * - `'medium'`: equivalent to `'yMMMdjms'` (e.g. `Sep 3, 2010, 12:05:08 PM` for `en-US`)
  4970. * - `'short'`: equivalent to `'yMdjm'` (e.g. `9/3/2010, 12:05 PM` for `en-US`)
  4971. * - `'fullDate'`: equivalent to `'yMMMMEEEEd'` (e.g. `Friday, September 3, 2010` for `en-US`)
  4972. * - `'longDate'`: equivalent to `'yMMMMd'` (e.g. `September 3, 2010` for `en-US`)
  4973. * - `'mediumDate'`: equivalent to `'yMMMd'` (e.g. `Sep 3, 2010` for `en-US`)
  4974. * - `'shortDate'`: equivalent to `'yMd'` (e.g. `9/3/2010` for `en-US`)
  4975. * - `'mediumTime'`: equivalent to `'jms'` (e.g. `12:05:08 PM` for `en-US`)
  4976. * - `'shortTime'`: equivalent to `'jm'` (e.g. `12:05 PM` for `en-US`)
  4977. *
  4978. *
  4979. * | Component | Symbol | Narrow | Short Form | Long Form | Numeric | 2-digit |
  4980. * |-----------|:------:|--------|--------------|-------------------|-----------|-----------|
  4981. * | era | G | G (A) | GGG (AD) | GGGG (Anno Domini)| - | - |
  4982. * | year | y | - | - | - | y (2015) | yy (15) |
  4983. * | month | M | L (S) | MMM (Sep) | MMMM (September) | M (9) | MM (09) |
  4984. * | day | d | - | - | - | d (3) | dd (03) |
  4985. * | weekday | E | E (S) | EEE (Sun) | EEEE (Sunday) | - | - |
  4986. * | hour | j | - | - | - | j (13) | jj (13) |
  4987. * | hour12 | h | - | - | - | h (1 PM) | hh (01 PM)|
  4988. * | hour24 | H | - | - | - | H (13) | HH (13) |
  4989. * | minute | m | - | - | - | m (5) | mm (05) |
  4990. * | second | s | - | - | - | s (9) | ss (09) |
  4991. * | timezone | z | - | - | z (Pacific Standard Time)| - | - |
  4992. * | timezone | Z | - | Z (GMT-8:00) | - | - | - |
  4993. * | timezone | a | - | a (PM) | - | - | - |
  4994. *
  4995. * In javascript, only the components specified will be respected (not the ordering,
  4996. * punctuations, ...) and details of the formatting will be dependent on the locale.
  4997. *
  4998. * Timezone of the formatted text will be the local system timezone of the end-user's machine.
  4999. *
  5000. * When the expression is a ISO string without time (e.g. 2016-09-19) the time zone offset is not
  5001. * applied and the formatted text will have the same day, month and year of the expression.
  5002. *
  5003. * WARNINGS:
  5004. * - this pipe is marked as pure hence it will not be re-evaluated when the input is mutated.
  5005. * Instead users should treat the date as an immutable object and change the reference when the
  5006. * pipe needs to re-run (this is to avoid reformatting the date on every change detection run
  5007. * which would be an expensive operation).
  5008. * - this pipe uses the Internationalization API. Therefore it is only reliable in Chrome and Opera
  5009. * browsers.
  5010. *
  5011. * @usageNotes
  5012. *
  5013. * ### Examples
  5014. *
  5015. * Assuming `dateObj` is (year: 2010, month: 9, day: 3, hour: 12 PM, minute: 05, second: 08)
  5016. * in the _local_ time and locale is 'en-US':
  5017. *
  5018. * {@example common/pipes/ts/date_pipe.ts region='DeprecatedDatePipe'}
  5019. *
  5020. * @publicApi
  5021. */
  5022. var DeprecatedDatePipe = /** @class */ (function () {
  5023. function DeprecatedDatePipe(_locale) {
  5024. this._locale = _locale;
  5025. }
  5026. DeprecatedDatePipe_1 = DeprecatedDatePipe;
  5027. DeprecatedDatePipe.prototype.transform = function (value, pattern) {
  5028. if (pattern === void 0) { pattern = 'mediumDate'; }
  5029. if (value == null || value === '' || value !== value)
  5030. return null;
  5031. var date;
  5032. if (typeof value === 'string') {
  5033. value = value.trim();
  5034. }
  5035. if (isDate$1(value)) {
  5036. date = value;
  5037. }
  5038. else if (!isNaN(value - parseFloat(value))) {
  5039. date = new Date(parseFloat(value));
  5040. }
  5041. else if (typeof value === 'string' && /^(\d{4}-\d{1,2}-\d{1,2})$/.test(value)) {
  5042. /**
  5043. * For ISO Strings without time the day, month and year must be extracted from the ISO String
  5044. * before Date creation to avoid time offset and errors in the new Date.
  5045. * If we only replace '-' with ',' in the ISO String ("2015,01,01"), and try to create a new
  5046. * date, some browsers (e.g. IE 9) will throw an invalid Date error
  5047. * If we leave the '-' ("2015-01-01") and try to create a new Date("2015-01-01") the
  5048. * timeoffset
  5049. * is applied
  5050. * Note: ISO months are 0 for January, 1 for February, ...
  5051. */
  5052. var _a = __read(value.split('-').map(function (val) { return parseInt(val, 10); }), 3), y = _a[0], m = _a[1], d = _a[2];
  5053. date = new Date(y, m - 1, d);
  5054. }
  5055. else {
  5056. date = new Date(value);
  5057. }
  5058. if (!isDate$1(date)) {
  5059. var match = void 0;
  5060. if ((typeof value === 'string') && (match = value.match(ISO8601_DATE_REGEX))) {
  5061. date = isoStringToDate(match);
  5062. }
  5063. else {
  5064. throw invalidPipeArgumentError(DeprecatedDatePipe_1, value);
  5065. }
  5066. }
  5067. return DateFormatter.format(date, this._locale, DeprecatedDatePipe_1._ALIASES[pattern] || pattern);
  5068. };
  5069. var DeprecatedDatePipe_1;
  5070. /** @internal */
  5071. DeprecatedDatePipe._ALIASES = {
  5072. 'medium': 'yMMMdjms',
  5073. 'short': 'yMdjm',
  5074. 'fullDate': 'yMMMMEEEEd',
  5075. 'longDate': 'yMMMMd',
  5076. 'mediumDate': 'yMMMd',
  5077. 'shortDate': 'yMd',
  5078. 'mediumTime': 'jms',
  5079. 'shortTime': 'jm'
  5080. };
  5081. DeprecatedDatePipe = DeprecatedDatePipe_1 = __decorate([
  5082. Pipe({ name: 'date', pure: true }),
  5083. __param(0, Inject(LOCALE_ID)),
  5084. __metadata("design:paramtypes", [String])
  5085. ], DeprecatedDatePipe);
  5086. return DeprecatedDatePipe;
  5087. }());
  5088. function isDate$1(value) {
  5089. return value instanceof Date && !isNaN(value.valueOf());
  5090. }
  5091. /**
  5092. * @license
  5093. * Copyright Google Inc. All Rights Reserved.
  5094. *
  5095. * Use of this source code is governed by an MIT-style license that can be
  5096. * found in the LICENSE file at https://angular.io/license
  5097. */
  5098. function formatNumber$1(pipe, locale, value, style, digits, currency, currencyAsSymbol) {
  5099. if (currency === void 0) { currency = null; }
  5100. if (currencyAsSymbol === void 0) { currencyAsSymbol = false; }
  5101. if (value == null)
  5102. return null;
  5103. // Convert strings to numbers
  5104. value = typeof value === 'string' && !isNaN(+value - parseFloat(value)) ? +value : value;
  5105. if (typeof value !== 'number') {
  5106. throw invalidPipeArgumentError(pipe, value);
  5107. }
  5108. var minInt;
  5109. var minFraction;
  5110. var maxFraction;
  5111. if (style !== NumberFormatStyle.Currency) {
  5112. // rely on Intl default for currency
  5113. minInt = 1;
  5114. minFraction = 0;
  5115. maxFraction = 3;
  5116. }
  5117. if (digits) {
  5118. var parts = digits.match(NUMBER_FORMAT_REGEXP);
  5119. if (parts === null) {
  5120. throw new Error(digits + " is not a valid digit info for number pipes");
  5121. }
  5122. if (parts[1] != null) { // min integer digits
  5123. minInt = parseIntAutoRadix(parts[1]);
  5124. }
  5125. if (parts[3] != null) { // min fraction digits
  5126. minFraction = parseIntAutoRadix(parts[3]);
  5127. }
  5128. if (parts[5] != null) { // max fraction digits
  5129. maxFraction = parseIntAutoRadix(parts[5]);
  5130. }
  5131. }
  5132. return NumberFormatter.format(value, locale, style, {
  5133. minimumIntegerDigits: minInt,
  5134. minimumFractionDigits: minFraction,
  5135. maximumFractionDigits: maxFraction,
  5136. currency: currency,
  5137. currencyAsSymbol: currencyAsSymbol,
  5138. });
  5139. }
  5140. /**
  5141. * Formats a number as text. Group sizing and separator and other locale-specific
  5142. * configurations are based on the active locale.
  5143. *
  5144. * where `expression` is a number:
  5145. * - `digitInfo` is a `string` which has a following format: <br>
  5146. * <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>
  5147. * - `minIntegerDigits` is the minimum number of integer digits to use. Defaults to `1`.
  5148. * - `minFractionDigits` is the minimum number of digits after fraction. Defaults to `0`.
  5149. * - `maxFractionDigits` is the maximum number of digits after fraction. Defaults to `3`.
  5150. *
  5151. * For more information on the acceptable range for each of these numbers and other
  5152. * details see your native internationalization library.
  5153. *
  5154. * WARNING: this pipe uses the Internationalization API which is not yet available in all browsers
  5155. * and may require a polyfill. See [Browser Support](guide/browser-support) for details.
  5156. *
  5157. * @usageNotes
  5158. *
  5159. * ### Example
  5160. *
  5161. * {@example common/pipes/ts/number_pipe.ts region='DeprecatedNumberPipe'}
  5162. *
  5163. * @ngModule CommonModule
  5164. * @publicApi
  5165. */
  5166. var DeprecatedDecimalPipe = /** @class */ (function () {
  5167. function DeprecatedDecimalPipe(_locale) {
  5168. this._locale = _locale;
  5169. }
  5170. DeprecatedDecimalPipe_1 = DeprecatedDecimalPipe;
  5171. DeprecatedDecimalPipe.prototype.transform = function (value, digits) {
  5172. return formatNumber$1(DeprecatedDecimalPipe_1, this._locale, value, NumberFormatStyle.Decimal, digits);
  5173. };
  5174. var DeprecatedDecimalPipe_1;
  5175. DeprecatedDecimalPipe = DeprecatedDecimalPipe_1 = __decorate([
  5176. Pipe({ name: 'number' }),
  5177. __param(0, Inject(LOCALE_ID)),
  5178. __metadata("design:paramtypes", [String])
  5179. ], DeprecatedDecimalPipe);
  5180. return DeprecatedDecimalPipe;
  5181. }());
  5182. /**
  5183. * @ngModule CommonModule
  5184. *
  5185. * @description
  5186. *
  5187. * Formats a number as percentage according to locale rules.
  5188. *
  5189. * - `digitInfo` See {@link DecimalPipe} for detailed description.
  5190. *
  5191. * WARNING: this pipe uses the Internationalization API which is not yet available in all browsers
  5192. * and may require a polyfill. See [Browser Support](guide/browser-support) for details.
  5193. *
  5194. * @usageNotes
  5195. *
  5196. * ### Example
  5197. *
  5198. * {@example common/pipes/ts/percent_pipe.ts region='DeprecatedPercentPipe'}
  5199. *
  5200. * @publicApi
  5201. */
  5202. var DeprecatedPercentPipe = /** @class */ (function () {
  5203. function DeprecatedPercentPipe(_locale) {
  5204. this._locale = _locale;
  5205. }
  5206. DeprecatedPercentPipe_1 = DeprecatedPercentPipe;
  5207. DeprecatedPercentPipe.prototype.transform = function (value, digits) {
  5208. return formatNumber$1(DeprecatedPercentPipe_1, this._locale, value, NumberFormatStyle.Percent, digits);
  5209. };
  5210. var DeprecatedPercentPipe_1;
  5211. DeprecatedPercentPipe = DeprecatedPercentPipe_1 = __decorate([
  5212. Pipe({ name: 'percent' }),
  5213. __param(0, Inject(LOCALE_ID)),
  5214. __metadata("design:paramtypes", [String])
  5215. ], DeprecatedPercentPipe);
  5216. return DeprecatedPercentPipe;
  5217. }());
  5218. /**
  5219. * @ngModule CommonModule
  5220. * @description
  5221. *
  5222. * Formats a number as currency using locale rules.
  5223. *
  5224. * Use `currency` to format a number as currency.
  5225. *
  5226. * - `currencyCode` is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, such
  5227. * as `USD` for the US dollar and `EUR` for the euro.
  5228. * - `symbolDisplay` is a boolean indicating whether to use the currency symbol or code.
  5229. * - `true`: use symbol (e.g. `$`).
  5230. * - `false`(default): use code (e.g. `USD`).
  5231. * - `digitInfo` See {@link DecimalPipe} for detailed description.
  5232. *
  5233. * WARNING: this pipe uses the Internationalization API which is not yet available in all browsers
  5234. * and may require a polyfill. See [Browser Support](guide/browser-support) for details.
  5235. *
  5236. * @usageNotes
  5237. *
  5238. * ### Example
  5239. *
  5240. * {@example common/pipes/ts/currency_pipe.ts region='DeprecatedCurrencyPipe'}
  5241. *
  5242. * @publicApi
  5243. */
  5244. var DeprecatedCurrencyPipe = /** @class */ (function () {
  5245. function DeprecatedCurrencyPipe(_locale) {
  5246. this._locale = _locale;
  5247. }
  5248. DeprecatedCurrencyPipe_1 = DeprecatedCurrencyPipe;
  5249. DeprecatedCurrencyPipe.prototype.transform = function (value, currencyCode, symbolDisplay, digits) {
  5250. if (currencyCode === void 0) { currencyCode = 'USD'; }
  5251. if (symbolDisplay === void 0) { symbolDisplay = false; }
  5252. return formatNumber$1(DeprecatedCurrencyPipe_1, this._locale, value, NumberFormatStyle.Currency, digits, currencyCode, symbolDisplay);
  5253. };
  5254. var DeprecatedCurrencyPipe_1;
  5255. DeprecatedCurrencyPipe = DeprecatedCurrencyPipe_1 = __decorate([
  5256. Pipe({ name: 'currency' }),
  5257. __param(0, Inject(LOCALE_ID)),
  5258. __metadata("design:paramtypes", [String])
  5259. ], DeprecatedCurrencyPipe);
  5260. return DeprecatedCurrencyPipe;
  5261. }());
  5262. /**
  5263. * @license
  5264. * Copyright Google Inc. All Rights Reserved.
  5265. *
  5266. * Use of this source code is governed by an MIT-style license that can be
  5267. * found in the LICENSE file at https://angular.io/license
  5268. */
  5269. /**
  5270. * A collection of deprecated i18n pipes that require intl api
  5271. *
  5272. * @deprecated from v5
  5273. */
  5274. var COMMON_DEPRECATED_I18N_PIPES = [DeprecatedDecimalPipe, DeprecatedPercentPipe, DeprecatedCurrencyPipe, DeprecatedDatePipe];
  5275. /**
  5276. * @license
  5277. * Copyright Google Inc. All Rights Reserved.
  5278. *
  5279. * Use of this source code is governed by an MIT-style license that can be
  5280. * found in the LICENSE file at https://angular.io/license
  5281. */
  5282. var ObservableStrategy = /** @class */ (function () {
  5283. function ObservableStrategy() {
  5284. }
  5285. ObservableStrategy.prototype.createSubscription = function (async, updateLatestValue) {
  5286. return async.subscribe({ next: updateLatestValue, error: function (e) { throw e; } });
  5287. };
  5288. ObservableStrategy.prototype.dispose = function (subscription) { subscription.unsubscribe(); };
  5289. ObservableStrategy.prototype.onDestroy = function (subscription) { subscription.unsubscribe(); };
  5290. return ObservableStrategy;
  5291. }());
  5292. var PromiseStrategy = /** @class */ (function () {
  5293. function PromiseStrategy() {
  5294. }
  5295. PromiseStrategy.prototype.createSubscription = function (async, updateLatestValue) {
  5296. return async.then(updateLatestValue, function (e) { throw e; });
  5297. };
  5298. PromiseStrategy.prototype.dispose = function (subscription) { };
  5299. PromiseStrategy.prototype.onDestroy = function (subscription) { };
  5300. return PromiseStrategy;
  5301. }());
  5302. var _promiseStrategy = new PromiseStrategy();
  5303. var _observableStrategy = new ObservableStrategy();
  5304. /**
  5305. * @ngModule CommonModule
  5306. * @description
  5307. *
  5308. * Unwraps a value from an asynchronous primitive.
  5309. *
  5310. * The `async` pipe subscribes to an `Observable` or `Promise` and returns the latest value it has
  5311. * emitted. When a new value is emitted, the `async` pipe marks the component to be checked for
  5312. * changes. When the component gets destroyed, the `async` pipe unsubscribes automatically to avoid
  5313. * potential memory leaks.
  5314. *
  5315. * @usageNotes
  5316. *
  5317. * ### Examples
  5318. *
  5319. * This example binds a `Promise` to the view. Clicking the `Resolve` button resolves the
  5320. * promise.
  5321. *
  5322. * {@example common/pipes/ts/async_pipe.ts region='AsyncPipePromise'}
  5323. *
  5324. * It's also possible to use `async` with Observables. The example below binds the `time` Observable
  5325. * to the view. The Observable continuously updates the view with the current time.
  5326. *
  5327. * {@example common/pipes/ts/async_pipe.ts region='AsyncPipeObservable'}
  5328. *
  5329. * @publicApi
  5330. */
  5331. var AsyncPipe = /** @class */ (function () {
  5332. function AsyncPipe(_ref) {
  5333. this._ref = _ref;
  5334. this._latestValue = null;
  5335. this._latestReturnedValue = null;
  5336. this._subscription = null;
  5337. this._obj = null;
  5338. this._strategy = null;
  5339. }
  5340. AsyncPipe_1 = AsyncPipe;
  5341. AsyncPipe.prototype.ngOnDestroy = function () {
  5342. if (this._subscription) {
  5343. this._dispose();
  5344. }
  5345. };
  5346. AsyncPipe.prototype.transform = function (obj) {
  5347. if (!this._obj) {
  5348. if (obj) {
  5349. this._subscribe(obj);
  5350. }
  5351. this._latestReturnedValue = this._latestValue;
  5352. return this._latestValue;
  5353. }
  5354. if (obj !== this._obj) {
  5355. this._dispose();
  5356. return this.transform(obj);
  5357. }
  5358. if (ɵlooseIdentical(this._latestValue, this._latestReturnedValue)) {
  5359. return this._latestReturnedValue;
  5360. }
  5361. this._latestReturnedValue = this._latestValue;
  5362. return WrappedValue.wrap(this._latestValue);
  5363. };
  5364. AsyncPipe.prototype._subscribe = function (obj) {
  5365. var _this = this;
  5366. this._obj = obj;
  5367. this._strategy = this._selectStrategy(obj);
  5368. this._subscription = this._strategy.createSubscription(obj, function (value) { return _this._updateLatestValue(obj, value); });
  5369. };
  5370. AsyncPipe.prototype._selectStrategy = function (obj) {
  5371. if (ɵisPromise(obj)) {
  5372. return _promiseStrategy;
  5373. }
  5374. if (ɵisObservable(obj)) {
  5375. return _observableStrategy;
  5376. }
  5377. throw invalidPipeArgumentError(AsyncPipe_1, obj);
  5378. };
  5379. AsyncPipe.prototype._dispose = function () {
  5380. this._strategy.dispose(this._subscription);
  5381. this._latestValue = null;
  5382. this._latestReturnedValue = null;
  5383. this._subscription = null;
  5384. this._obj = null;
  5385. };
  5386. AsyncPipe.prototype._updateLatestValue = function (async, value) {
  5387. if (async === this._obj) {
  5388. this._latestValue = value;
  5389. this._ref.markForCheck();
  5390. }
  5391. };
  5392. var AsyncPipe_1;
  5393. AsyncPipe = AsyncPipe_1 = __decorate([
  5394. Injectable(),
  5395. Pipe({ name: 'async', pure: false }),
  5396. __metadata("design:paramtypes", [ChangeDetectorRef])
  5397. ], AsyncPipe);
  5398. return AsyncPipe;
  5399. }());
  5400. /**
  5401. * @license
  5402. * Copyright Google Inc. All Rights Reserved.
  5403. *
  5404. * Use of this source code is governed by an MIT-style license that can be
  5405. * found in the LICENSE file at https://angular.io/license
  5406. */
  5407. /**
  5408. * Transforms text to all lower case.
  5409. *
  5410. * @see `UpperCasePipe`
  5411. * @see `TitleCasePipe`
  5412. * @usageNotes
  5413. *
  5414. * The following example defines a view that allows the user to enter
  5415. * text, and then uses the pipe to convert the input text to all lower case.
  5416. *
  5417. * <code-example path="common/pipes/ts/lowerupper_pipe.ts" region='LowerUpperPipe'></code-example>
  5418. *
  5419. * @ngModule CommonModule
  5420. * @publicApi
  5421. */
  5422. var LowerCasePipe = /** @class */ (function () {
  5423. function LowerCasePipe() {
  5424. }
  5425. LowerCasePipe_1 = LowerCasePipe;
  5426. /**
  5427. * @param value The string to transform to lower case.
  5428. */
  5429. LowerCasePipe.prototype.transform = function (value) {
  5430. if (!value)
  5431. return value;
  5432. if (typeof value !== 'string') {
  5433. throw invalidPipeArgumentError(LowerCasePipe_1, value);
  5434. }
  5435. return value.toLowerCase();
  5436. };
  5437. var LowerCasePipe_1;
  5438. LowerCasePipe = LowerCasePipe_1 = __decorate([
  5439. Injectable(),
  5440. Pipe({ name: 'lowercase' })
  5441. ], LowerCasePipe);
  5442. return LowerCasePipe;
  5443. }());
  5444. //
  5445. // Regex below matches any Unicode word and compatible with ES5. In ES2018 the same result
  5446. // can be achieved by using /\p{L}\S*/gu and also known as Unicode Property Escapes
  5447. // (http://2ality.com/2017/07/regexp-unicode-property-escapes.html). Since there is no
  5448. // transpilation of this functionality down to ES5 without external tool, the only solution is
  5449. // to use already transpiled form. Example can be found here -
  5450. // https://mothereff.in/regexpu#input=var+regex+%3D+/%5Cp%7BL%7D/u%3B&unicodePropertyEscape=1
  5451. //
  5452. var unicodeWordMatch = /(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D])\S*/g;
  5453. /**
  5454. * Transforms text to title case.
  5455. * Capitalizes the first letter of each word, and transforms the
  5456. * rest of the word to lower case.
  5457. * Words are delimited by any whitespace character, such as a space, tab, or line-feed character.
  5458. *
  5459. * @see `LowerCasePipe`
  5460. * @see `UpperCasePipe`
  5461. *
  5462. * @usageNotes
  5463. * The following example shows the result of transforming various strings into title case.
  5464. *
  5465. * <code-example path="common/pipes/ts/titlecase_pipe.ts" region='TitleCasePipe'></code-example>
  5466. *
  5467. * @ngModule CommonModule
  5468. * @publicApi
  5469. */
  5470. var TitleCasePipe = /** @class */ (function () {
  5471. function TitleCasePipe() {
  5472. }
  5473. TitleCasePipe_1 = TitleCasePipe;
  5474. /**
  5475. * @param value The string to transform to title case.
  5476. */
  5477. TitleCasePipe.prototype.transform = function (value) {
  5478. if (!value)
  5479. return value;
  5480. if (typeof value !== 'string') {
  5481. throw invalidPipeArgumentError(TitleCasePipe_1, value);
  5482. }
  5483. return value.replace(unicodeWordMatch, (function (txt) { return txt[0].toUpperCase() + txt.substr(1).toLowerCase(); }));
  5484. };
  5485. var TitleCasePipe_1;
  5486. TitleCasePipe = TitleCasePipe_1 = __decorate([
  5487. Injectable(),
  5488. Pipe({ name: 'titlecase' })
  5489. ], TitleCasePipe);
  5490. return TitleCasePipe;
  5491. }());
  5492. /**
  5493. * Transforms text to all upper case.
  5494. * @see `LowerCasePipe`
  5495. * @see `TitleCasePipe`
  5496. *
  5497. * @ngModule CommonModule
  5498. * @publicApi
  5499. */
  5500. var UpperCasePipe = /** @class */ (function () {
  5501. function UpperCasePipe() {
  5502. }
  5503. UpperCasePipe_1 = UpperCasePipe;
  5504. /**
  5505. * @param value The string to transform to upper case.
  5506. */
  5507. UpperCasePipe.prototype.transform = function (value) {
  5508. if (!value)
  5509. return value;
  5510. if (typeof value !== 'string') {
  5511. throw invalidPipeArgumentError(UpperCasePipe_1, value);
  5512. }
  5513. return value.toUpperCase();
  5514. };
  5515. var UpperCasePipe_1;
  5516. UpperCasePipe = UpperCasePipe_1 = __decorate([
  5517. Injectable(),
  5518. Pipe({ name: 'uppercase' })
  5519. ], UpperCasePipe);
  5520. return UpperCasePipe;
  5521. }());
  5522. /**
  5523. * @license
  5524. * Copyright Google Inc. All Rights Reserved.
  5525. *
  5526. * Use of this source code is governed by an MIT-style license that can be
  5527. * found in the LICENSE file at https://angular.io/license
  5528. */
  5529. // clang-format off
  5530. /**
  5531. * @ngModule CommonModule
  5532. * @description
  5533. *
  5534. * Formats a date value according to locale rules.
  5535. *
  5536. * Only the `en-US` locale data comes with Angular. To localize dates
  5537. * in another language, you must import the corresponding locale data.
  5538. * See the [I18n guide](guide/i18n#i18n-pipes) for more information.
  5539. *
  5540. * @see `formatDate()`
  5541. *
  5542. *
  5543. * @usageNotes
  5544. *
  5545. * The result of this pipe is not reevaluated when the input is mutated. To avoid the need to
  5546. * reformat the date on every change-detection cycle, treat the date as an immutable object
  5547. * and change the reference when the pipe needs to run again.
  5548. *
  5549. * ### Pre-defined format options
  5550. *
  5551. * Examples are given in `en-US` locale.
  5552. *
  5553. * - `'short'`: equivalent to `'M/d/yy, h:mm a'` (`6/15/15, 9:03 AM`).
  5554. * - `'medium'`: equivalent to `'MMM d, y, h:mm:ss a'` (`Jun 15, 2015, 9:03:01 AM`).
  5555. * - `'long'`: equivalent to `'MMMM d, y, h:mm:ss a z'` (`June 15, 2015 at 9:03:01 AM
  5556. * GMT+1`).
  5557. * - `'full'`: equivalent to `'EEEE, MMMM d, y, h:mm:ss a zzzz'` (`Monday, June 15, 2015 at
  5558. * 9:03:01 AM GMT+01:00`).
  5559. * - `'shortDate'`: equivalent to `'M/d/yy'` (`6/15/15`).
  5560. * - `'mediumDate'`: equivalent to `'MMM d, y'` (`Jun 15, 2015`).
  5561. * - `'longDate'`: equivalent to `'MMMM d, y'` (`June 15, 2015`).
  5562. * - `'fullDate'`: equivalent to `'EEEE, MMMM d, y'` (`Monday, June 15, 2015`).
  5563. * - `'shortTime'`: equivalent to `'h:mm a'` (`9:03 AM`).
  5564. * - `'mediumTime'`: equivalent to `'h:mm:ss a'` (`9:03:01 AM`).
  5565. * - `'longTime'`: equivalent to `'h:mm:ss a z'` (`9:03:01 AM GMT+1`).
  5566. * - `'fullTime'`: equivalent to `'h:mm:ss a zzzz'` (`9:03:01 AM GMT+01:00`).
  5567. *
  5568. * ### Custom format options
  5569. *
  5570. * You can construct a format string using symbols to specify the components
  5571. * of a date-time value, as described in the following table.
  5572. * Format details depend on the locale.
  5573. * Fields marked with (*) are only available in the extra data set for the given locale.
  5574. *
  5575. * | Field type | Format | Description | Example Value |
  5576. * |--------------------|-------------|---------------------------------------------------------------|------------------------------------------------------------|
  5577. * | Era | G, GG & GGG | Abbreviated | AD |
  5578. * | | GGGG | Wide | Anno Domini |
  5579. * | | GGGGG | Narrow | A |
  5580. * | Year | y | Numeric: minimum digits | 2, 20, 201, 2017, 20173 |
  5581. * | | yy | Numeric: 2 digits + zero padded | 02, 20, 01, 17, 73 |
  5582. * | | yyy | Numeric: 3 digits + zero padded | 002, 020, 201, 2017, 20173 |
  5583. * | | yyyy | Numeric: 4 digits or more + zero padded | 0002, 0020, 0201, 2017, 20173 |
  5584. * | Month | M | Numeric: 1 digit | 9, 12 |
  5585. * | | MM | Numeric: 2 digits + zero padded | 09, 12 |
  5586. * | | MMM | Abbreviated | Sep |
  5587. * | | MMMM | Wide | September |
  5588. * | | MMMMM | Narrow | S |
  5589. * | Month standalone | L | Numeric: 1 digit | 9, 12 |
  5590. * | | LL | Numeric: 2 digits + zero padded | 09, 12 |
  5591. * | | LLL | Abbreviated | Sep |
  5592. * | | LLLL | Wide | September |
  5593. * | | LLLLL | Narrow | S |
  5594. * | Week of year | w | Numeric: minimum digits | 1... 53 |
  5595. * | | ww | Numeric: 2 digits + zero padded | 01... 53 |
  5596. * | Week of month | W | Numeric: 1 digit | 1... 5 |
  5597. * | Day of month | d | Numeric: minimum digits | 1 |
  5598. * | | dd | Numeric: 2 digits + zero padded | 01 |
  5599. * | Week day | E, EE & EEE | Abbreviated | Tue |
  5600. * | | EEEE | Wide | Tuesday |
  5601. * | | EEEEE | Narrow | T |
  5602. * | | EEEEEE | Short | Tu |
  5603. * | Period | a, aa & aaa | Abbreviated | am/pm or AM/PM |
  5604. * | | aaaa | Wide (fallback to `a` when missing) | ante meridiem/post meridiem |
  5605. * | | aaaaa | Narrow | a/p |
  5606. * | Period* | B, BB & BBB | Abbreviated | mid. |
  5607. * | | BBBB | Wide | am, pm, midnight, noon, morning, afternoon, evening, night |
  5608. * | | BBBBB | Narrow | md |
  5609. * | Period standalone* | b, bb & bbb | Abbreviated | mid. |
  5610. * | | bbbb | Wide | am, pm, midnight, noon, morning, afternoon, evening, night |
  5611. * | | bbbbb | Narrow | md |
  5612. * | Hour 1-12 | h | Numeric: minimum digits | 1, 12 |
  5613. * | | hh | Numeric: 2 digits + zero padded | 01, 12 |
  5614. * | Hour 0-23 | H | Numeric: minimum digits | 0, 23 |
  5615. * | | HH | Numeric: 2 digits + zero padded | 00, 23 |
  5616. * | Minute | m | Numeric: minimum digits | 8, 59 |
  5617. * | | mm | Numeric: 2 digits + zero padded | 08, 59 |
  5618. * | Second | s | Numeric: minimum digits | 0... 59 |
  5619. * | | ss | Numeric: 2 digits + zero padded | 00... 59 |
  5620. * | Fractional seconds | S | Numeric: 1 digit | 0... 9 |
  5621. * | | SS | Numeric: 2 digits + zero padded | 00... 99 |
  5622. * | | SSS | Numeric: 3 digits + zero padded (= milliseconds) | 000... 999 |
  5623. * | Zone | z, zz & zzz | Short specific non location format (fallback to O) | GMT-8 |
  5624. * | | zzzz | Long specific non location format (fallback to OOOO) | GMT-08:00 |
  5625. * | | Z, ZZ & ZZZ | ISO8601 basic format | -0800 |
  5626. * | | ZZZZ | Long localized GMT format | GMT-8:00 |
  5627. * | | ZZZZZ | ISO8601 extended format + Z indicator for offset 0 (= XXXXX) | -08:00 |
  5628. * | | O, OO & OOO | Short localized GMT format | GMT-8 |
  5629. * | | OOOO | Long localized GMT format | GMT-08:00 |
  5630. *
  5631. * Note that timezone correction is not applied to an ISO string that has no time component, such as "2016-09-19"
  5632. *
  5633. * ### Format examples
  5634. *
  5635. * These examples transform a date into various formats,
  5636. * assuming that `dateObj` is a JavaScript `Date` object for
  5637. * year: 2015, month: 6, day: 15, hour: 21, minute: 43, second: 11,
  5638. * given in the local time for the `en-US` locale.
  5639. *
  5640. * ```
  5641. * {{ dateObj | date }} // output is 'Jun 15, 2015'
  5642. * {{ dateObj | date:'medium' }} // output is 'Jun 15, 2015, 9:43:11 PM'
  5643. * {{ dateObj | date:'shortTime' }} // output is '9:43 PM'
  5644. * {{ dateObj | date:'mm:ss' }} // output is '43:11'
  5645. * ```
  5646. *
  5647. * ### Usage example
  5648. *
  5649. * The following component uses a date pipe to display the current date in different formats.
  5650. *
  5651. * ```
  5652. * @Component({
  5653. * selector: 'date-pipe',
  5654. * template: `<div>
  5655. * <p>Today is {{today | date}}</p>
  5656. * <p>Or if you prefer, {{today | date:'fullDate'}}</p>
  5657. * <p>The time is {{today | date:'h:mm a z'}}</p>
  5658. * </div>`
  5659. * })
  5660. * // Get the current date and time as a date-time value.
  5661. * export class DatePipeComponent {
  5662. * today: number = Date.now();
  5663. * }
  5664. * ```
  5665. *
  5666. * @publicApi
  5667. */
  5668. // clang-format on
  5669. var DatePipe = /** @class */ (function () {
  5670. function DatePipe(locale) {
  5671. this.locale = locale;
  5672. }
  5673. DatePipe_1 = DatePipe;
  5674. /**
  5675. * @param value The date expression: a `Date` object, a number
  5676. * (milliseconds since UTC epoch), or an ISO string (https://www.w3.org/TR/NOTE-datetime).
  5677. * @param format The date/time components to include, using predefined options or a
  5678. * custom format string.
  5679. * @param timezone A timezone offset (such as `'+0430'`), or a standard
  5680. * UTC/GMT or continental US timezone abbreviation. Default is
  5681. * the local system timezone of the end-user's machine.
  5682. * @param locale A locale code for the locale format rules to use.
  5683. * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.
  5684. * See [Setting your app locale](guide/i18n#setting-up-the-locale-of-your-app).
  5685. * @returns A date string in the desired format.
  5686. */
  5687. DatePipe.prototype.transform = function (value, format, timezone, locale) {
  5688. if (format === void 0) { format = 'mediumDate'; }
  5689. if (value == null || value === '' || value !== value)
  5690. return null;
  5691. try {
  5692. return formatDate(value, format, locale || this.locale, timezone);
  5693. }
  5694. catch (error) {
  5695. throw invalidPipeArgumentError(DatePipe_1, error.message);
  5696. }
  5697. };
  5698. var DatePipe_1;
  5699. DatePipe = DatePipe_1 = __decorate([
  5700. Injectable(),
  5701. Pipe({ name: 'date', pure: true }),
  5702. __param(0, Inject(LOCALE_ID)),
  5703. __metadata("design:paramtypes", [String])
  5704. ], DatePipe);
  5705. return DatePipe;
  5706. }());
  5707. /**
  5708. * @license
  5709. * Copyright Google Inc. All Rights Reserved.
  5710. *
  5711. * Use of this source code is governed by an MIT-style license that can be
  5712. * found in the LICENSE file at https://angular.io/license
  5713. */
  5714. var _INTERPOLATION_REGEXP = /#/g;
  5715. /**
  5716. * @ngModule CommonModule
  5717. * @description
  5718. *
  5719. * Maps a value to a string that pluralizes the value according to locale rules.
  5720. *
  5721. * @usageNotes
  5722. *
  5723. * ### Example
  5724. *
  5725. * {@example common/pipes/ts/i18n_pipe.ts region='I18nPluralPipeComponent'}
  5726. *
  5727. * @publicApi
  5728. */
  5729. var I18nPluralPipe = /** @class */ (function () {
  5730. function I18nPluralPipe(_localization) {
  5731. this._localization = _localization;
  5732. }
  5733. I18nPluralPipe_1 = I18nPluralPipe;
  5734. /**
  5735. * @param value the number to be formatted
  5736. * @param pluralMap an object that mimics the ICU format, see
  5737. * http://userguide.icu-project.org/formatparse/messages.
  5738. * @param locale a `string` defining the locale to use (uses the current {@link LOCALE_ID} by
  5739. * default).
  5740. */
  5741. I18nPluralPipe.prototype.transform = function (value, pluralMap, locale) {
  5742. if (value == null)
  5743. return '';
  5744. if (typeof pluralMap !== 'object' || pluralMap === null) {
  5745. throw invalidPipeArgumentError(I18nPluralPipe_1, pluralMap);
  5746. }
  5747. var key = getPluralCategory(value, Object.keys(pluralMap), this._localization, locale);
  5748. return pluralMap[key].replace(_INTERPOLATION_REGEXP, value.toString());
  5749. };
  5750. var I18nPluralPipe_1;
  5751. I18nPluralPipe = I18nPluralPipe_1 = __decorate([
  5752. Injectable(),
  5753. Pipe({ name: 'i18nPlural', pure: true }),
  5754. __metadata("design:paramtypes", [NgLocalization])
  5755. ], I18nPluralPipe);
  5756. return I18nPluralPipe;
  5757. }());
  5758. /**
  5759. * @license
  5760. * Copyright Google Inc. All Rights Reserved.
  5761. *
  5762. * Use of this source code is governed by an MIT-style license that can be
  5763. * found in the LICENSE file at https://angular.io/license
  5764. */
  5765. /**
  5766. * @ngModule CommonModule
  5767. * @description
  5768. *
  5769. * Generic selector that displays the string that matches the current value.
  5770. *
  5771. * If none of the keys of the `mapping` match the `value`, then the content
  5772. * of the `other` key is returned when present, otherwise an empty string is returned.
  5773. *
  5774. * @usageNotes
  5775. *
  5776. * ### Example
  5777. *
  5778. * {@example common/pipes/ts/i18n_pipe.ts region='I18nSelectPipeComponent'}
  5779. *
  5780. * @publicApi
  5781. */
  5782. var I18nSelectPipe = /** @class */ (function () {
  5783. function I18nSelectPipe() {
  5784. }
  5785. I18nSelectPipe_1 = I18nSelectPipe;
  5786. /**
  5787. * @param value a string to be internationalized.
  5788. * @param mapping an object that indicates the text that should be displayed
  5789. * for different values of the provided `value`.
  5790. */
  5791. I18nSelectPipe.prototype.transform = function (value, mapping) {
  5792. if (value == null)
  5793. return '';
  5794. if (typeof mapping !== 'object' || typeof value !== 'string') {
  5795. throw invalidPipeArgumentError(I18nSelectPipe_1, mapping);
  5796. }
  5797. if (mapping.hasOwnProperty(value)) {
  5798. return mapping[value];
  5799. }
  5800. if (mapping.hasOwnProperty('other')) {
  5801. return mapping['other'];
  5802. }
  5803. return '';
  5804. };
  5805. var I18nSelectPipe_1;
  5806. I18nSelectPipe = I18nSelectPipe_1 = __decorate([
  5807. Injectable(),
  5808. Pipe({ name: 'i18nSelect', pure: true })
  5809. ], I18nSelectPipe);
  5810. return I18nSelectPipe;
  5811. }());
  5812. /**
  5813. * @license
  5814. * Copyright Google Inc. All Rights Reserved.
  5815. *
  5816. * Use of this source code is governed by an MIT-style license that can be
  5817. * found in the LICENSE file at https://angular.io/license
  5818. */
  5819. /**
  5820. * @ngModule CommonModule
  5821. * @description
  5822. *
  5823. * Converts a value into its JSON-format representation. Useful for debugging.
  5824. *
  5825. * @usageNotes
  5826. *
  5827. * The following component uses a JSON pipe to convert an object
  5828. * to JSON format, and displays the string in both formats for comparison.
  5829. *
  5830. * {@example common/pipes/ts/json_pipe.ts region='JsonPipe'}
  5831. *
  5832. * @publicApi
  5833. */
  5834. var JsonPipe = /** @class */ (function () {
  5835. function JsonPipe() {
  5836. }
  5837. /**
  5838. * @param value A value of any type to convert into a JSON-format string.
  5839. */
  5840. JsonPipe.prototype.transform = function (value) { return JSON.stringify(value, null, 2); };
  5841. JsonPipe = __decorate([
  5842. Injectable(),
  5843. Pipe({ name: 'json', pure: false })
  5844. ], JsonPipe);
  5845. return JsonPipe;
  5846. }());
  5847. /**
  5848. * @license
  5849. * Copyright Google Inc. All Rights Reserved.
  5850. *
  5851. * Use of this source code is governed by an MIT-style license that can be
  5852. * found in the LICENSE file at https://angular.io/license
  5853. */
  5854. function makeKeyValuePair(key, value) {
  5855. return { key: key, value: value };
  5856. }
  5857. /**
  5858. * @ngModule CommonModule
  5859. * @description
  5860. *
  5861. * Transforms Object or Map into an array of key value pairs.
  5862. *
  5863. * The output array will be ordered by keys.
  5864. * By default the comparator will be by Unicode point value.
  5865. * You can optionally pass a compareFn if your keys are complex types.
  5866. *
  5867. * @usageNotes
  5868. * ### Examples
  5869. *
  5870. * This examples show how an Object or a Map can be iterated by ngFor with the use of this keyvalue
  5871. * pipe.
  5872. *
  5873. * {@example common/pipes/ts/keyvalue_pipe.ts region='KeyValuePipe'}
  5874. *
  5875. * @publicApi
  5876. */
  5877. var KeyValuePipe = /** @class */ (function () {
  5878. function KeyValuePipe(differs) {
  5879. this.differs = differs;
  5880. this.keyValues = [];
  5881. }
  5882. KeyValuePipe.prototype.transform = function (input, compareFn) {
  5883. var _this = this;
  5884. if (compareFn === void 0) { compareFn = defaultComparator; }
  5885. if (!input || (!(input instanceof Map) && typeof input !== 'object')) {
  5886. return null;
  5887. }
  5888. if (!this.differ) {
  5889. // make a differ for whatever type we've been passed in
  5890. this.differ = this.differs.find(input).create();
  5891. }
  5892. var differChanges = this.differ.diff(input);
  5893. if (differChanges) {
  5894. this.keyValues = [];
  5895. differChanges.forEachItem(function (r) {
  5896. _this.keyValues.push(makeKeyValuePair(r.key, r.currentValue));
  5897. });
  5898. this.keyValues.sort(compareFn);
  5899. }
  5900. return this.keyValues;
  5901. };
  5902. KeyValuePipe = __decorate([
  5903. Injectable(),
  5904. Pipe({ name: 'keyvalue', pure: false }),
  5905. __metadata("design:paramtypes", [KeyValueDiffers])
  5906. ], KeyValuePipe);
  5907. return KeyValuePipe;
  5908. }());
  5909. function defaultComparator(keyValueA, keyValueB) {
  5910. var a = keyValueA.key;
  5911. var b = keyValueB.key;
  5912. // if same exit with 0;
  5913. if (a === b)
  5914. return 0;
  5915. // make sure that undefined are at the end of the sort.
  5916. if (a === undefined)
  5917. return 1;
  5918. if (b === undefined)
  5919. return -1;
  5920. // make sure that nulls are at the end of the sort.
  5921. if (a === null)
  5922. return 1;
  5923. if (b === null)
  5924. return -1;
  5925. if (typeof a == 'string' && typeof b == 'string') {
  5926. return a < b ? -1 : 1;
  5927. }
  5928. if (typeof a == 'number' && typeof b == 'number') {
  5929. return a - b;
  5930. }
  5931. if (typeof a == 'boolean' && typeof b == 'boolean') {
  5932. return a < b ? -1 : 1;
  5933. }
  5934. // `a` and `b` are of different types. Compare their string values.
  5935. var aString = String(a);
  5936. var bString = String(b);
  5937. return aString == bString ? 0 : aString < bString ? -1 : 1;
  5938. }
  5939. /**
  5940. * @license
  5941. * Copyright Google Inc. All Rights Reserved.
  5942. *
  5943. * Use of this source code is governed by an MIT-style license that can be
  5944. * found in the LICENSE file at https://angular.io/license
  5945. */
  5946. /**
  5947. * @ngModule CommonModule
  5948. * @description
  5949. *
  5950. * Transforms a number into a string,
  5951. * formatted according to locale rules that determine group sizing and
  5952. * separator, decimal-point character, and other locale-specific
  5953. * configurations.
  5954. *
  5955. * If no parameters are specified, the function rounds off to the nearest value using this
  5956. * [rounding method](https://en.wikibooks.org/wiki/Arithmetic/Rounding).
  5957. * The behavior differs from that of the JavaScript ```Math.round()``` function.
  5958. * In the following case for example, the pipe rounds down where
  5959. * ```Math.round()``` rounds up:
  5960. *
  5961. * ```html
  5962. * -2.5 | number:'1.0-0'
  5963. * > -3
  5964. * Math.round(-2.5)
  5965. * > -2
  5966. * ```
  5967. *
  5968. * @see `formatNumber()`
  5969. *
  5970. * @usageNotes
  5971. * The following code shows how the pipe transforms numbers
  5972. * into text strings, according to various format specifications,
  5973. * where the caller's default locale is `en-US`.
  5974. *
  5975. * ### Example
  5976. *
  5977. * <code-example path="common/pipes/ts/number_pipe.ts" region='NumberPipe'></code-example>
  5978. *
  5979. * @publicApi
  5980. */
  5981. var DecimalPipe = /** @class */ (function () {
  5982. function DecimalPipe(_locale) {
  5983. this._locale = _locale;
  5984. }
  5985. DecimalPipe_1 = DecimalPipe;
  5986. /**
  5987. * @param value The number to be formatted.
  5988. * @param digitsInfo Decimal representation options, specified by a string
  5989. * in the following format:<br>
  5990. * <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>.
  5991. * - `minIntegerDigits`: The minimum number of integer digits before the decimal point.
  5992. * Default is `1`.
  5993. * - `minFractionDigits`: The minimum number of digits after the decimal point.
  5994. * Default is `0`.
  5995. * - `maxFractionDigits`: The maximum number of digits after the decimal point.
  5996. * Default is `3`.
  5997. * @param locale A locale code for the locale format rules to use.
  5998. * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.
  5999. * See [Setting your app locale](guide/i18n#setting-up-the-locale-of-your-app).
  6000. */
  6001. DecimalPipe.prototype.transform = function (value, digitsInfo, locale) {
  6002. if (isEmpty(value))
  6003. return null;
  6004. locale = locale || this._locale;
  6005. try {
  6006. var num = strToNumber(value);
  6007. return formatNumber(num, locale, digitsInfo);
  6008. }
  6009. catch (error) {
  6010. throw invalidPipeArgumentError(DecimalPipe_1, error.message);
  6011. }
  6012. };
  6013. var DecimalPipe_1;
  6014. DecimalPipe = DecimalPipe_1 = __decorate([
  6015. Injectable(),
  6016. Pipe({ name: 'number' }),
  6017. __param(0, Inject(LOCALE_ID)),
  6018. __metadata("design:paramtypes", [String])
  6019. ], DecimalPipe);
  6020. return DecimalPipe;
  6021. }());
  6022. /**
  6023. * @ngModule CommonModule
  6024. * @description
  6025. *
  6026. * Transforms a number to a percentage
  6027. * string, formatted according to locale rules that determine group sizing and
  6028. * separator, decimal-point character, and other locale-specific
  6029. * configurations.
  6030. *
  6031. * @see `formatPercent()`
  6032. *
  6033. * @usageNotes
  6034. * The following code shows how the pipe transforms numbers
  6035. * into text strings, according to various format specifications,
  6036. * where the caller's default locale is `en-US`.
  6037. *
  6038. * <code-example path="common/pipes/ts/percent_pipe.ts" region='PercentPipe'></code-example>
  6039. *
  6040. * @publicApi
  6041. */
  6042. var PercentPipe = /** @class */ (function () {
  6043. function PercentPipe(_locale) {
  6044. this._locale = _locale;
  6045. }
  6046. PercentPipe_1 = PercentPipe;
  6047. /**
  6048. *
  6049. * @param value The number to be formatted as a percentage.
  6050. * @param digitsInfo Decimal representation options, specified by a string
  6051. * in the following format:<br>
  6052. * <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>.
  6053. * - `minIntegerDigits`: The minimum number of integer digits before the decimal point.
  6054. * Default is `1`.
  6055. * - `minFractionDigits`: The minimum number of digits after the decimal point.
  6056. * Default is `0`.
  6057. * - `maxFractionDigits`: The maximum number of digits after the decimal point.
  6058. * Default is `0`.
  6059. * @param locale A locale code for the locale format rules to use.
  6060. * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.
  6061. * See [Setting your app locale](guide/i18n#setting-up-the-locale-of-your-app).
  6062. */
  6063. PercentPipe.prototype.transform = function (value, digitsInfo, locale) {
  6064. if (isEmpty(value))
  6065. return null;
  6066. locale = locale || this._locale;
  6067. try {
  6068. var num = strToNumber(value);
  6069. return formatPercent(num, locale, digitsInfo);
  6070. }
  6071. catch (error) {
  6072. throw invalidPipeArgumentError(PercentPipe_1, error.message);
  6073. }
  6074. };
  6075. var PercentPipe_1;
  6076. PercentPipe = PercentPipe_1 = __decorate([
  6077. Injectable(),
  6078. Pipe({ name: 'percent' }),
  6079. __param(0, Inject(LOCALE_ID)),
  6080. __metadata("design:paramtypes", [String])
  6081. ], PercentPipe);
  6082. return PercentPipe;
  6083. }());
  6084. /**
  6085. * @ngModule CommonModule
  6086. * @description
  6087. *
  6088. * Transforms a number to a currency string, formatted according to locale rules
  6089. * that determine group sizing and separator, decimal-point character,
  6090. * and other locale-specific configurations.
  6091. *
  6092. * @see `getCurrencySymbol()`
  6093. * @see `formatCurrency()`
  6094. *
  6095. * @usageNotes
  6096. * The following code shows how the pipe transforms numbers
  6097. * into text strings, according to various format specifications,
  6098. * where the caller's default locale is `en-US`.
  6099. *
  6100. * <code-example path="common/pipes/ts/currency_pipe.ts" region='CurrencyPipe'></code-example>
  6101. *
  6102. * @publicApi
  6103. */
  6104. var CurrencyPipe = /** @class */ (function () {
  6105. function CurrencyPipe(_locale) {
  6106. this._locale = _locale;
  6107. }
  6108. CurrencyPipe_1 = CurrencyPipe;
  6109. /**
  6110. *
  6111. * @param value The number to be formatted as currency.
  6112. * @param currencyCode The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code,
  6113. * such as `USD` for the US dollar and `EUR` for the euro.
  6114. * @param display The format for the currency indicator. One of the following:
  6115. * - `code`: Show the code (such as `USD`).
  6116. * - `symbol`(default): Show the symbol (such as `$`).
  6117. * - `symbol-narrow`: Use the narrow symbol for locales that have two symbols for their
  6118. * currency.
  6119. * For example, the Canadian dollar CAD has the symbol `CA$` and the symbol-narrow `$`. If the
  6120. * locale has no narrow symbol, uses the standard symbol for the locale.
  6121. * - String: Use the given string value instead of a code or a symbol.
  6122. * For example, an empty string will suppress the currency & symbol.
  6123. * - Boolean (marked deprecated in v5): `true` for symbol and false for `code`.
  6124. *
  6125. * @param digitsInfo Decimal representation options, specified by a string
  6126. * in the following format:<br>
  6127. * <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>.
  6128. * - `minIntegerDigits`: The minimum number of integer digits before the decimal point.
  6129. * Default is `1`.
  6130. * - `minFractionDigits`: The minimum number of digits after the decimal point.
  6131. * Default is `2`.
  6132. * - `maxFractionDigits`: The maximum number of digits after the decimal point.
  6133. * Default is `2`.
  6134. * If not provided, the number will be formatted with the proper amount of digits,
  6135. * depending on what the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) specifies.
  6136. * For example, the Canadian dollar has 2 digits, whereas the Chilean peso has none.
  6137. * @param locale A locale code for the locale format rules to use.
  6138. * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.
  6139. * See [Setting your app locale](guide/i18n#setting-up-the-locale-of-your-app).
  6140. */
  6141. CurrencyPipe.prototype.transform = function (value, currencyCode, display, digitsInfo, locale) {
  6142. if (display === void 0) { display = 'symbol'; }
  6143. if (isEmpty(value))
  6144. return null;
  6145. locale = locale || this._locale;
  6146. if (typeof display === 'boolean') {
  6147. if (console && console.warn) {
  6148. console.warn("Warning: the currency pipe has been changed in Angular v5. The symbolDisplay option (third parameter) is now a string instead of a boolean. The accepted values are \"code\", \"symbol\" or \"symbol-narrow\".");
  6149. }
  6150. display = display ? 'symbol' : 'code';
  6151. }
  6152. var currency = currencyCode || 'USD';
  6153. if (display !== 'code') {
  6154. if (display === 'symbol' || display === 'symbol-narrow') {
  6155. currency = getCurrencySymbol(currency, display === 'symbol' ? 'wide' : 'narrow', locale);
  6156. }
  6157. else {
  6158. currency = display;
  6159. }
  6160. }
  6161. try {
  6162. var num = strToNumber(value);
  6163. return formatCurrency(num, locale, currency, currencyCode, digitsInfo);
  6164. }
  6165. catch (error) {
  6166. throw invalidPipeArgumentError(CurrencyPipe_1, error.message);
  6167. }
  6168. };
  6169. var CurrencyPipe_1;
  6170. CurrencyPipe = CurrencyPipe_1 = __decorate([
  6171. Injectable(),
  6172. Pipe({ name: 'currency' }),
  6173. __param(0, Inject(LOCALE_ID)),
  6174. __metadata("design:paramtypes", [String])
  6175. ], CurrencyPipe);
  6176. return CurrencyPipe;
  6177. }());
  6178. function isEmpty(value) {
  6179. return value == null || value === '' || value !== value;
  6180. }
  6181. /**
  6182. * Transforms a string into a number (if needed).
  6183. */
  6184. function strToNumber(value) {
  6185. // Convert strings to numbers
  6186. if (typeof value === 'string' && !isNaN(Number(value) - parseFloat(value))) {
  6187. return Number(value);
  6188. }
  6189. if (typeof value !== 'number') {
  6190. throw new Error(value + " is not a number");
  6191. }
  6192. return value;
  6193. }
  6194. /**
  6195. * @license
  6196. * Copyright Google Inc. All Rights Reserved.
  6197. *
  6198. * Use of this source code is governed by an MIT-style license that can be
  6199. * found in the LICENSE file at https://angular.io/license
  6200. */
  6201. /**
  6202. * @ngModule CommonModule
  6203. * @description
  6204. *
  6205. * Creates a new `Array` or `String` containing a subset (slice) of the elements.
  6206. *
  6207. * @usageNotes
  6208. *
  6209. * All behavior is based on the expected behavior of the JavaScript API `Array.prototype.slice()`
  6210. * and `String.prototype.slice()`.
  6211. *
  6212. * When operating on an `Array`, the returned `Array` is always a copy even when all
  6213. * the elements are being returned.
  6214. *
  6215. * When operating on a blank value, the pipe returns the blank value.
  6216. *
  6217. * ### List Example
  6218. *
  6219. * This `ngFor` example:
  6220. *
  6221. * {@example common/pipes/ts/slice_pipe.ts region='SlicePipe_list'}
  6222. *
  6223. * produces the following:
  6224. *
  6225. * ```html
  6226. * <li>b</li>
  6227. * <li>c</li>
  6228. * ```
  6229. *
  6230. * ### String Examples
  6231. *
  6232. * {@example common/pipes/ts/slice_pipe.ts region='SlicePipe_string'}
  6233. *
  6234. * @publicApi
  6235. */
  6236. var SlicePipe = /** @class */ (function () {
  6237. function SlicePipe() {
  6238. }
  6239. SlicePipe_1 = SlicePipe;
  6240. SlicePipe.prototype.transform = function (value, start, end) {
  6241. if (value == null)
  6242. return value;
  6243. if (!this.supports(value)) {
  6244. throw invalidPipeArgumentError(SlicePipe_1, value);
  6245. }
  6246. return value.slice(start, end);
  6247. };
  6248. SlicePipe.prototype.supports = function (obj) { return typeof obj === 'string' || Array.isArray(obj); };
  6249. var SlicePipe_1;
  6250. SlicePipe = SlicePipe_1 = __decorate([
  6251. Injectable(),
  6252. Pipe({ name: 'slice', pure: false })
  6253. ], SlicePipe);
  6254. return SlicePipe;
  6255. }());
  6256. /**
  6257. * @license
  6258. * Copyright Google Inc. All Rights Reserved.
  6259. *
  6260. * Use of this source code is governed by an MIT-style license that can be
  6261. * found in the LICENSE file at https://angular.io/license
  6262. */
  6263. /**
  6264. * A collection of Angular pipes that are likely to be used in each and every application.
  6265. */
  6266. var COMMON_PIPES = [
  6267. AsyncPipe,
  6268. UpperCasePipe,
  6269. LowerCasePipe,
  6270. JsonPipe,
  6271. SlicePipe,
  6272. DecimalPipe,
  6273. PercentPipe,
  6274. TitleCasePipe,
  6275. CurrencyPipe,
  6276. DatePipe,
  6277. I18nPluralPipe,
  6278. I18nSelectPipe,
  6279. KeyValuePipe,
  6280. ];
  6281. /**
  6282. * @license
  6283. * Copyright Google Inc. All Rights Reserved.
  6284. *
  6285. * Use of this source code is governed by an MIT-style license that can be
  6286. * found in the LICENSE file at https://angular.io/license
  6287. */
  6288. // Note: This does not contain the location providers,
  6289. // as they need some platform specific implementations to work.
  6290. /**
  6291. * Exports all the basic Angular directives and pipes,
  6292. * such as `NgIf`, `NgForOf`, `DecimalPipe`, and so on.
  6293. * Re-exported by `BrowserModule`, which is included automatically in the root
  6294. * `AppModule` when you create a new app with the CLI `new` command.
  6295. *
  6296. * * The `providers` options configure the NgModule's injector to provide
  6297. * localization dependencies to members.
  6298. * * The `exports` options make the declared directives and pipes available for import
  6299. * by other NgModules.
  6300. *
  6301. * @publicApi
  6302. */
  6303. var CommonModule = /** @class */ (function () {
  6304. function CommonModule() {
  6305. }
  6306. CommonModule = __decorate([
  6307. NgModule({
  6308. declarations: [COMMON_DIRECTIVES, COMMON_PIPES],
  6309. exports: [COMMON_DIRECTIVES, COMMON_PIPES],
  6310. providers: [
  6311. { provide: NgLocalization, useClass: NgLocaleLocalization },
  6312. ],
  6313. })
  6314. ], CommonModule);
  6315. return CommonModule;
  6316. }());
  6317. var ɵ0$2 = getPluralCase;
  6318. /**
  6319. * A module that contains the deprecated i18n pipes.
  6320. *
  6321. * @deprecated from v5
  6322. * @publicApi
  6323. */
  6324. var DeprecatedI18NPipesModule = /** @class */ (function () {
  6325. function DeprecatedI18NPipesModule() {
  6326. }
  6327. DeprecatedI18NPipesModule = __decorate([
  6328. NgModule({
  6329. declarations: [COMMON_DEPRECATED_I18N_PIPES],
  6330. exports: [COMMON_DEPRECATED_I18N_PIPES],
  6331. providers: [{ provide: DEPRECATED_PLURAL_FN, useValue: ɵ0$2 }],
  6332. })
  6333. ], DeprecatedI18NPipesModule);
  6334. return DeprecatedI18NPipesModule;
  6335. }());
  6336. /**
  6337. * @license
  6338. * Copyright Google Inc. All Rights Reserved.
  6339. *
  6340. * Use of this source code is governed by an MIT-style license that can be
  6341. * found in the LICENSE file at https://angular.io/license
  6342. */
  6343. /**
  6344. * A DI Token representing the main rendering context. In a browser this is the DOM Document.
  6345. *
  6346. * Note: Document might not be available in the Application Context when Application and Rendering
  6347. * Contexts are not the same (e.g. when running the application into a Web Worker).
  6348. *
  6349. * @publicApi
  6350. */
  6351. var DOCUMENT = new InjectionToken('DocumentToken');
  6352. /**
  6353. * @license
  6354. * Copyright Google Inc. All Rights Reserved.
  6355. *
  6356. * Use of this source code is governed by an MIT-style license that can be
  6357. * found in the LICENSE file at https://angular.io/license
  6358. */
  6359. var PLATFORM_BROWSER_ID = 'browser';
  6360. var PLATFORM_SERVER_ID = 'server';
  6361. var PLATFORM_WORKER_APP_ID = 'browserWorkerApp';
  6362. var PLATFORM_WORKER_UI_ID = 'browserWorkerUi';
  6363. /**
  6364. * Returns whether a platform id represents a browser platform.
  6365. * @publicApi
  6366. */
  6367. function isPlatformBrowser(platformId) {
  6368. return platformId === PLATFORM_BROWSER_ID;
  6369. }
  6370. /**
  6371. * Returns whether a platform id represents a server platform.
  6372. * @publicApi
  6373. */
  6374. function isPlatformServer(platformId) {
  6375. return platformId === PLATFORM_SERVER_ID;
  6376. }
  6377. /**
  6378. * Returns whether a platform id represents a web worker app platform.
  6379. * @publicApi
  6380. */
  6381. function isPlatformWorkerApp(platformId) {
  6382. return platformId === PLATFORM_WORKER_APP_ID;
  6383. }
  6384. /**
  6385. * Returns whether a platform id represents a web worker UI platform.
  6386. * @publicApi
  6387. */
  6388. function isPlatformWorkerUi(platformId) {
  6389. return platformId === PLATFORM_WORKER_UI_ID;
  6390. }
  6391. /**
  6392. * @license
  6393. * Copyright Google Inc. All Rights Reserved.
  6394. *
  6395. * Use of this source code is governed by an MIT-style license that can be
  6396. * found in the LICENSE file at https://angular.io/license
  6397. */
  6398. /**
  6399. * @publicApi
  6400. */
  6401. var VERSION = new Version('8.1.0');
  6402. /**
  6403. * @license
  6404. * Copyright Google Inc. All Rights Reserved.
  6405. *
  6406. * Use of this source code is governed by an MIT-style license that can be
  6407. * found in the LICENSE file at https://angular.io/license
  6408. */
  6409. /**
  6410. * Defines a scroll position manager. Implemented by `BrowserViewportScroller`.
  6411. *
  6412. * @publicApi
  6413. */
  6414. var ViewportScroller = /** @class */ (function () {
  6415. function ViewportScroller() {
  6416. }
  6417. // De-sugared tree-shakable injection
  6418. // See #23917
  6419. /** @nocollapse */
  6420. ViewportScroller.ngInjectableDef = ɵɵdefineInjectable({
  6421. token: ViewportScroller,
  6422. providedIn: 'root',
  6423. factory: function () { return new BrowserViewportScroller(ɵɵinject(DOCUMENT), window, ɵɵinject(ErrorHandler)); }
  6424. });
  6425. return ViewportScroller;
  6426. }());
  6427. /**
  6428. * Manages the scroll position for a browser window.
  6429. */
  6430. var BrowserViewportScroller = /** @class */ (function () {
  6431. function BrowserViewportScroller(document, window, errorHandler) {
  6432. this.document = document;
  6433. this.window = window;
  6434. this.errorHandler = errorHandler;
  6435. this.offset = function () { return [0, 0]; };
  6436. }
  6437. /**
  6438. * Configures the top offset used when scrolling to an anchor.
  6439. * @param offset A position in screen coordinates (a tuple with x and y values)
  6440. * or a function that returns the top offset position.
  6441. *
  6442. */
  6443. BrowserViewportScroller.prototype.setOffset = function (offset) {
  6444. if (Array.isArray(offset)) {
  6445. this.offset = function () { return offset; };
  6446. }
  6447. else {
  6448. this.offset = offset;
  6449. }
  6450. };
  6451. /**
  6452. * Retrieves the current scroll position.
  6453. * @returns The position in screen coordinates.
  6454. */
  6455. BrowserViewportScroller.prototype.getScrollPosition = function () {
  6456. if (this.supportScrollRestoration()) {
  6457. return [this.window.scrollX, this.window.scrollY];
  6458. }
  6459. else {
  6460. return [0, 0];
  6461. }
  6462. };
  6463. /**
  6464. * Sets the scroll position.
  6465. * @param position The new position in screen coordinates.
  6466. */
  6467. BrowserViewportScroller.prototype.scrollToPosition = function (position) {
  6468. if (this.supportScrollRestoration()) {
  6469. this.window.scrollTo(position[0], position[1]);
  6470. }
  6471. };
  6472. /**
  6473. * Scrolls to an anchor element.
  6474. * @param anchor The ID of the anchor element.
  6475. */
  6476. BrowserViewportScroller.prototype.scrollToAnchor = function (anchor) {
  6477. if (this.supportScrollRestoration()) {
  6478. // Escape anything passed to `querySelector` as it can throw errors and stop the application
  6479. // from working if invalid values are passed.
  6480. if (this.window.CSS && this.window.CSS.escape) {
  6481. anchor = this.window.CSS.escape(anchor);
  6482. }
  6483. else {
  6484. anchor = anchor.replace(/(\"|\'\ |:|\.|\[|\]|,|=)/g, '\\$1');
  6485. }
  6486. try {
  6487. var elSelectedById = this.document.querySelector("#" + anchor);
  6488. if (elSelectedById) {
  6489. this.scrollToElement(elSelectedById);
  6490. return;
  6491. }
  6492. var elSelectedByName = this.document.querySelector("[name='" + anchor + "']");
  6493. if (elSelectedByName) {
  6494. this.scrollToElement(elSelectedByName);
  6495. return;
  6496. }
  6497. }
  6498. catch (e) {
  6499. this.errorHandler.handleError(e);
  6500. }
  6501. }
  6502. };
  6503. /**
  6504. * Disables automatic scroll restoration provided by the browser.
  6505. */
  6506. BrowserViewportScroller.prototype.setHistoryScrollRestoration = function (scrollRestoration) {
  6507. if (this.supportScrollRestoration()) {
  6508. var history_1 = this.window.history;
  6509. if (history_1 && history_1.scrollRestoration) {
  6510. history_1.scrollRestoration = scrollRestoration;
  6511. }
  6512. }
  6513. };
  6514. BrowserViewportScroller.prototype.scrollToElement = function (el) {
  6515. var rect = el.getBoundingClientRect();
  6516. var left = rect.left + this.window.pageXOffset;
  6517. var top = rect.top + this.window.pageYOffset;
  6518. var offset = this.offset();
  6519. this.window.scrollTo(left - offset[0], top - offset[1]);
  6520. };
  6521. /**
  6522. * We only support scroll restoration when we can get a hold of window.
  6523. * This means that we do not support this behavior when running in a web worker.
  6524. *
  6525. * Lifting this restriction right now would require more changes in the dom adapter.
  6526. * Since webworkers aren't widely used, we will lift it once RouterScroller is
  6527. * battle-tested.
  6528. */
  6529. BrowserViewportScroller.prototype.supportScrollRestoration = function () {
  6530. try {
  6531. return !!this.window && !!this.window.scrollTo;
  6532. }
  6533. catch (_a) {
  6534. return false;
  6535. }
  6536. };
  6537. return BrowserViewportScroller;
  6538. }());
  6539. /**
  6540. * Provides an empty implementation of the viewport scroller. This will
  6541. * live in @angular/common as it will be used by both platform-server and platform-webworker.
  6542. */
  6543. var NullViewportScroller = /** @class */ (function () {
  6544. function NullViewportScroller() {
  6545. }
  6546. /**
  6547. * Empty implementation
  6548. */
  6549. NullViewportScroller.prototype.setOffset = function (offset) { };
  6550. /**
  6551. * Empty implementation
  6552. */
  6553. NullViewportScroller.prototype.getScrollPosition = function () { return [0, 0]; };
  6554. /**
  6555. * Empty implementation
  6556. */
  6557. NullViewportScroller.prototype.scrollToPosition = function (position) { };
  6558. /**
  6559. * Empty implementation
  6560. */
  6561. NullViewportScroller.prototype.scrollToAnchor = function (anchor) { };
  6562. /**
  6563. * Empty implementation
  6564. */
  6565. NullViewportScroller.prototype.setHistoryScrollRestoration = function (scrollRestoration) { };
  6566. return NullViewportScroller;
  6567. }());
  6568. /**
  6569. * @license
  6570. * Copyright Google Inc. All Rights Reserved.
  6571. *
  6572. * Use of this source code is governed by an MIT-style license that can be
  6573. * found in the LICENSE file at https://angular.io/license
  6574. */
  6575. /**
  6576. * @license
  6577. * Copyright Google Inc. All Rights Reserved.
  6578. *
  6579. * Use of this source code is governed by an MIT-style license that can be
  6580. * found in the LICENSE file at https://angular.io/license
  6581. */
  6582. // This file only reexports content of the `src` folder. Keep it that way.
  6583. /**
  6584. * @license
  6585. * Copyright Google Inc. All Rights Reserved.
  6586. *
  6587. * Use of this source code is governed by an MIT-style license that can be
  6588. * found in the LICENSE file at https://angular.io/license
  6589. */
  6590. /**
  6591. * Generated bundle index. Do not edit.
  6592. */
  6593. export { COMMON_DIRECTIVES as ɵangular_packages_common_common_c, NgClassImplProvider as ɵangular_packages_common_common_h, NgClassImplProvider__PRE_R3__ as ɵangular_packages_common_common_g, NgClassR3Impl as ɵangular_packages_common_common_f, NgStyleImplProvider as ɵangular_packages_common_common_k, NgStyleImplProvider__PRE_R3__ as ɵangular_packages_common_common_j, NgStyleR3Impl as ɵangular_packages_common_common_i, DEPRECATED_PLURAL_FN as ɵangular_packages_common_common_a, getPluralCase as ɵangular_packages_common_common_b, COMMON_DEPRECATED_I18N_PIPES as ɵangular_packages_common_common_e, COMMON_PIPES as ɵangular_packages_common_common_d, registerLocaleData as ɵregisterLocaleData, registerLocaleData, formatDate, formatCurrency, formatNumber, formatPercent, NgLocaleLocalization, NgLocalization, Plural, NumberFormatStyle, FormStyle, TranslationWidth, FormatWidth, NumberSymbol, WeekDay, getNumberOfCurrencyDigits, getCurrencySymbol, getLocaleDayPeriods, getLocaleDayNames, getLocaleMonthNames, getLocaleId, getLocaleEraNames, getLocaleWeekEndRange, getLocaleFirstDayOfWeek, getLocaleDateFormat, getLocaleDateTimeFormat, getLocaleExtraDayPeriodRules, getLocaleExtraDayPeriods, getLocalePluralCase, getLocaleTimeFormat, getLocaleNumberSymbol, getLocaleNumberFormat, getLocaleCurrencyName, getLocaleCurrencySymbol, parseCookieValue as ɵparseCookieValue, CommonModule, DeprecatedI18NPipesModule, NgClass, NgClassBase, NgForOf, NgForOfContext, NgIf, NgIfContext, NgPlural, NgPluralCase, NgStyle, NgStyleBase, NgSwitch, NgSwitchCase, NgSwitchDefault, NgTemplateOutlet, NgComponentOutlet, DOCUMENT, AsyncPipe, DatePipe, I18nPluralPipe, I18nSelectPipe, JsonPipe, LowerCasePipe, CurrencyPipe, DecimalPipe, PercentPipe, SlicePipe, UpperCasePipe, TitleCasePipe, KeyValuePipe, DeprecatedDatePipe, DeprecatedCurrencyPipe, DeprecatedDecimalPipe, DeprecatedPercentPipe, PLATFORM_BROWSER_ID as ɵPLATFORM_BROWSER_ID, PLATFORM_SERVER_ID as ɵPLATFORM_SERVER_ID, PLATFORM_WORKER_APP_ID as ɵPLATFORM_WORKER_APP_ID, PLATFORM_WORKER_UI_ID as ɵPLATFORM_WORKER_UI_ID, isPlatformBrowser, isPlatformServer, isPlatformWorkerApp, isPlatformWorkerUi, VERSION, ViewportScroller, NullViewportScroller as ɵNullViewportScroller, NgClassImplProvider__POST_R3__ as ɵNgClassImplProvider__POST_R3__, NgClassR2Impl as ɵNgClassR2Impl, NgClassImpl as ɵNgClassImpl, NgStyleImplProvider__POST_R3__ as ɵNgStyleImplProvider__POST_R3__, NgStyleR2Impl as ɵNgStyleR2Impl, NgStyleImpl as ɵNgStyleImpl, ngStyleDirectiveDef__POST_R3__ as ɵngStyleDirectiveDef__POST_R3__, ngClassDirectiveDef__POST_R3__ as ɵngClassDirectiveDef__POST_R3__, PlatformLocation, LOCATION_INITIALIZED, LocationStrategy, APP_BASE_HREF, HashLocationStrategy, PathLocationStrategy, Location };
  6594. //# sourceMappingURL=common.js.map