a zip code crypto-currency system good for red ONLY

common.js 224KB

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