common.umd.js 290 KB

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