277.index.js 1.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256
  1. exports.id = 277;
  2. exports.ids = [277];
  3. exports.modules = {
  4. /***/ 42869:
  5. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  6. const json = __webpack_require__(29387);
  7. const strings = __webpack_require__(13043);
  8. const regex = __webpack_require__(13732);
  9. const yaml = __webpack_require__(76050);
  10. module.exports = {
  11. ...json,
  12. ...strings,
  13. ...regex,
  14. ...yaml,
  15. };
  16. /***/ }),
  17. /***/ 29387:
  18. /***/ ((module) => {
  19. function isValidJSON(str) {
  20. if (typeof str !== "string") {
  21. return;
  22. }
  23. try {
  24. JSON.parse(str);
  25. return true;
  26. } catch (err) {
  27. if (err instanceof SyntaxError) {
  28. return false;
  29. }
  30. throw err;
  31. }
  32. }
  33. module.exports = {
  34. "json.is_valid": isValidJSON,
  35. };
  36. /***/ }),
  37. /***/ 13732:
  38. /***/ ((module) => {
  39. const regexSplit = (pattern, s) => s.split(RegExp(pattern));
  40. module.exports = { "regex.split": regexSplit };
  41. /***/ }),
  42. /***/ 13043:
  43. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  44. const vsprintf = __webpack_require__(8975).vsprintf;
  45. const sprintf = (s, values) => vsprintf(s, values);
  46. module.exports = { sprintf };
  47. /***/ }),
  48. /***/ 76050:
  49. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  50. const yaml = __webpack_require__(6792);
  51. // see: https://eemeli.org/yaml/v1/#errors
  52. const errors = new Set([
  53. "YAMLReferenceError",
  54. "YAMLSemanticError",
  55. "YAMLSyntaxError",
  56. "YAMLWarning",
  57. ]);
  58. function parse(str) {
  59. if (typeof str !== "string") {
  60. return { ok: false, result: undefined };
  61. }
  62. const YAML_SILENCE_WARNINGS_CACHED = global.YAML_SILENCE_WARNINGS;
  63. try {
  64. // see: https://eemeli.org/yaml/v1/#silencing-warnings
  65. global.YAML_SILENCE_WARNINGS = true;
  66. return { ok: true, result: yaml.parse(str) };
  67. } catch (err) {
  68. // Ignore parser errors.
  69. if (err && errors.has(err.name)) {
  70. return { ok: false, result: undefined };
  71. }
  72. throw err;
  73. } finally {
  74. global.YAML_SILENCE_WARNINGS = YAML_SILENCE_WARNINGS_CACHED;
  75. }
  76. }
  77. module.exports = {
  78. // is_valid is expected to return nothing if input is invalid otherwise
  79. // true/false for it being valid YAML.
  80. "yaml.is_valid": (str) => typeof str === "string" ? parse(str).ok : undefined,
  81. "yaml.marshal": (data) => yaml.stringify(data),
  82. "yaml.unmarshal": (str) => parse(str).result,
  83. };
  84. /***/ }),
  85. /***/ 39026:
  86. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  87. // Copyright 2018 The OPA Authors. All rights reserved.
  88. // Use of this source code is governed by an Apache2
  89. // license that can be found in the LICENSE file.
  90. const builtIns = __webpack_require__(42869);
  91. const util = __webpack_require__(31669);
  92. // NOTE: The util shim here exists for Node 10.x and can be removed
  93. // when dropping support. Browsers and Node >= 11.x use the global.
  94. const TextEncoder = typeof global.TextEncoder !== "undefined"
  95. ? global.TextEncoder
  96. : util.TextEncoder;
  97. const TextDecoder = typeof global.TextDecoder !== "undefined"
  98. ? global.TextDecoder
  99. : util.TextDecoder;
  100. /**
  101. * @param {WebAssembly.Memory} mem
  102. */
  103. function stringDecoder(mem) {
  104. return function (addr) {
  105. const i8 = new Int8Array(mem.buffer);
  106. let s = "";
  107. while (i8[addr] !== 0) {
  108. s += String.fromCharCode(i8[addr++]);
  109. }
  110. return s;
  111. };
  112. }
  113. /**
  114. * Stringifies and loads an object into OPA's Memory
  115. * @param {WebAssembly.Instance} wasmInstance
  116. * @param {WebAssembly.Memory} memory
  117. * @param {any | ArrayBuffer} value data as `object`, literal primitive or ArrayBuffer (last is assumed to be a well-formed stringified JSON)
  118. * @returns {number}
  119. */
  120. function _loadJSON(wasmInstance, memory, value) {
  121. if (value === undefined) {
  122. return 0;
  123. }
  124. let valueBuf;
  125. if (value instanceof ArrayBuffer) {
  126. valueBuf = new Uint8Array(value);
  127. } else {
  128. const valueAsText = JSON.stringify(value);
  129. valueBuf = new TextEncoder().encode(valueAsText);
  130. }
  131. const valueBufLen = valueBuf.byteLength;
  132. const rawAddr = wasmInstance.exports.opa_malloc(valueBufLen);
  133. const memoryBuffer = new Uint8Array(memory.buffer);
  134. memoryBuffer.set(valueBuf, rawAddr);
  135. const parsedAddr = wasmInstance.exports.opa_json_parse(rawAddr, valueBufLen);
  136. if (parsedAddr === 0) {
  137. throw "failed to parse json value";
  138. }
  139. return parsedAddr;
  140. }
  141. /**
  142. * Dumps and parses a JSON object from OPA's Memory
  143. * @param {WebAssembly.Instance} wasmInstance
  144. * @param {WebAssembly.Memory} memory
  145. * @param {number} addr
  146. * @returns {object}
  147. */
  148. function _dumpJSON(wasmInstance, memory, addr) {
  149. const rawAddr = wasmInstance.exports.opa_json_dump(addr);
  150. return _dumpJSONRaw(memory, rawAddr);
  151. }
  152. /**
  153. * Parses a JSON object from wasm instance's memory
  154. * @param {WebAssembly.Memory} memory
  155. * @param {number} addr
  156. * @returns {object}
  157. */
  158. function _dumpJSONRaw(memory, addr) {
  159. const buf = new Uint8Array(memory.buffer);
  160. let idx = addr;
  161. while (buf[idx] !== 0) {
  162. idx++;
  163. }
  164. const utf8View = new Uint8Array(memory.buffer, addr, idx - addr);
  165. const jsonAsText = new TextDecoder().decode(utf8View);
  166. return JSON.parse(jsonAsText);
  167. }
  168. const builtinFuncs = builtIns;
  169. /**
  170. * _builtinCall dispatches the built-in function. The built-in function
  171. * arguments are loaded from Wasm and back in using JSON serialization.
  172. * @param {WebAssembly.Instance} wasmInstance
  173. * @param {WebAssembly.Memory} memory
  174. * @param {{ [builtinId: number]: string }} builtins
  175. * @param {string} builtin_id
  176. */
  177. function _builtinCall(wasmInstance, memory, builtins, builtinId) {
  178. const builtInName = builtins[builtinId];
  179. const impl = builtinFuncs[builtInName];
  180. if (impl === undefined) {
  181. throw {
  182. message: "not implemented: built-in function " +
  183. builtinId +
  184. ": " +
  185. builtins[builtinId],
  186. };
  187. }
  188. const argArray = Array.prototype.slice.apply(arguments);
  189. const args = [];
  190. for (let i = 4; i < argArray.length; i++) {
  191. const jsArg = _dumpJSON(wasmInstance, memory, argArray[i]);
  192. args.push(jsArg);
  193. }
  194. const result = impl(...args);
  195. return _loadJSON(wasmInstance, memory, result);
  196. }
  197. /**
  198. * _loadPolicy can take in either an ArrayBuffer or WebAssembly.Module
  199. * as its first argument, and a WebAssembly.Memory for the second parameter.
  200. * It will return a Promise, depending on the input type the promise
  201. * resolves to both a compiled WebAssembly.Module and its first WebAssembly.Instance
  202. * or to the WebAssemblyInstance.
  203. * @param {BufferSource | WebAssembly.Module} policyWasm
  204. * @param {WebAssembly.Memory} memory
  205. * @returns {Promise<{ policy: WebAssembly.WebAssemblyInstantiatedSource | WebAssembly.Instance, minorVersion: number }>}
  206. */
  207. async function _loadPolicy(policyWasm, memory) {
  208. const addr2string = stringDecoder(memory);
  209. const env = {};
  210. const wasm = await WebAssembly.instantiate(policyWasm, {
  211. env: {
  212. memory,
  213. opa_abort: function (addr) {
  214. throw addr2string(addr);
  215. },
  216. opa_println: function (addr) {
  217. console.log(addr2string(addr));
  218. },
  219. opa_builtin0: function (builtinId, _ctx) {
  220. return _builtinCall(env.instance, memory, env.builtins, builtinId);
  221. },
  222. opa_builtin1: function (builtinId, _ctx, arg1) {
  223. return _builtinCall(
  224. env.instance,
  225. memory,
  226. env.builtins,
  227. builtinId,
  228. arg1,
  229. );
  230. },
  231. opa_builtin2: function (builtinId, _ctx, arg1, arg2) {
  232. return _builtinCall(
  233. env.instance,
  234. memory,
  235. env.builtins,
  236. builtinId,
  237. arg1,
  238. arg2,
  239. );
  240. },
  241. opa_builtin3: function (builtinId, _ctx, arg1, arg2, arg3) {
  242. return _builtinCall(
  243. env.instance,
  244. memory,
  245. env.builtins,
  246. builtinId,
  247. arg1,
  248. arg2,
  249. arg3,
  250. );
  251. },
  252. opa_builtin4: function (builtinId, _ctx, arg1, arg2, arg3, arg4) {
  253. return _builtinCall(
  254. env.instance,
  255. memory,
  256. env.builtins,
  257. builtinId,
  258. arg1,
  259. arg2,
  260. arg3,
  261. arg4,
  262. );
  263. },
  264. },
  265. });
  266. // Note: On Node 10.x this value is a number on Node 12.x and up it is
  267. // an object with numberic `value` property.
  268. const abiVersionGlobal = wasm.instance.exports.opa_wasm_abi_version;
  269. if (abiVersionGlobal !== undefined) {
  270. const abiVersion = typeof abiVersionGlobal === "number"
  271. ? abiVersionGlobal
  272. : abiVersionGlobal.value;
  273. if (abiVersion !== 1) {
  274. throw `unsupported ABI version ${abiVersion}`;
  275. }
  276. } else {
  277. console.error("opa_wasm_abi_version undefined"); // logs to stderr
  278. }
  279. const abiMinorVersionGlobal =
  280. wasm.instance.exports.opa_wasm_abi_minor_version;
  281. let abiMinorVersion;
  282. if (abiMinorVersionGlobal !== undefined) {
  283. abiMinorVersion = typeof abiMinorVersionGlobal === "number"
  284. ? abiMinorVersionGlobal
  285. : abiMinorVersionGlobal.value;
  286. } else {
  287. console.error("opa_wasm_abi_minor_version undefined");
  288. }
  289. env.instance = wasm.instance ? wasm.instance : wasm;
  290. const builtins = _dumpJSON(
  291. env.instance,
  292. memory,
  293. env.instance.exports.builtins(),
  294. );
  295. /** @type {typeof builtIns} */
  296. env.builtins = {};
  297. for (const key of Object.keys(builtins)) {
  298. env.builtins[builtins[key]] = key;
  299. }
  300. return { policy: wasm, minorVersion: abiMinorVersion };
  301. }
  302. /**
  303. * LoadedPolicy is a wrapper around a WebAssembly.Instance and WebAssembly.Memory
  304. * for a compiled Rego policy. There are helpers to run the wasm instance and
  305. * handle the output from the policy wasm.
  306. */
  307. class LoadedPolicy {
  308. /**
  309. * Loads and initializes a compiled Rego policy.
  310. * @param {WebAssembly.WebAssemblyInstantiatedSource} policy
  311. * @param {WebAssembly.Memory} memory
  312. */
  313. constructor(policy, memory, minorVersion) {
  314. this.minorVersion = minorVersion;
  315. this.mem = memory;
  316. // Depending on how the wasm was instantiated "policy" might be a
  317. // WebAssembly Instance or be a wrapper around the Module and
  318. // Instance. We only care about the Instance.
  319. this.wasmInstance = policy.instance ? policy.instance : policy;
  320. this.dataAddr = _loadJSON(this.wasmInstance, this.mem, {});
  321. this.baseHeapPtr = this.wasmInstance.exports.opa_heap_ptr_get();
  322. this.dataHeapPtr = this.baseHeapPtr;
  323. this.entrypoints = _dumpJSON(
  324. this.wasmInstance,
  325. this.mem,
  326. this.wasmInstance.exports.entrypoints(),
  327. );
  328. }
  329. /**
  330. * Evaluates the loaded policy with the given input and
  331. * return the result set. This should be re-used for multiple evaluations
  332. * of the same policy with different inputs.
  333. *
  334. * To call a non-default entrypoint in your WASM specify it as the second
  335. * param. A list of entrypoints can be accessed with the `this.entrypoints`
  336. * property.
  337. * @param {any | ArrayBuffer} input input to be evaluated in form of `object`, literal primitive or ArrayBuffer (last is assumed to be a well-formed stringified JSON)
  338. * @param {number | string} entrypoint ID or name of the entrypoint to call (optional)
  339. */
  340. evaluate(input, entrypoint = 0) {
  341. // determine entrypoint ID
  342. if (typeof entrypoint === "number") {
  343. // used as-is
  344. } else if (typeof entrypoint === "string") {
  345. if (Object.prototype.hasOwnProperty.call(this.entrypoints, entrypoint)) {
  346. entrypoint = this.entrypoints[entrypoint];
  347. } else {
  348. throw `entrypoint ${entrypoint} is not valid in this instance`;
  349. }
  350. } else {
  351. throw `entrypoint value is an invalid type, must be either string or number`;
  352. }
  353. // ABI 1.2 fastpath
  354. if (this.minorVersion >= 2) {
  355. // write input into memory, adjust heap pointer
  356. let inputBuf = null;
  357. let inputLen = 0;
  358. let inputAddr = 0;
  359. if (input) {
  360. if (input instanceof ArrayBuffer) {
  361. inputBuf = new Uint8Array(input);
  362. } else {
  363. const inputAsText = JSON.stringify(input);
  364. inputBuf = new TextEncoder().encode(inputAsText);
  365. }
  366. inputAddr = this.dataHeapPtr;
  367. inputLen = inputBuf.byteLength;
  368. const delta = inputAddr + inputLen - this.mem.buffer.byteLength;
  369. if (delta > 0) {
  370. const pages = roundup(delta);
  371. this.mem.grow(pages);
  372. }
  373. const buf = new Uint8Array(this.mem.buffer);
  374. buf.set(inputBuf, this.dataHeapPtr);
  375. this.dataHeapPtr = inputAddr + inputLen;
  376. }
  377. const ret = this.wasmInstance.exports.opa_eval(
  378. 0,
  379. entrypoint,
  380. this.dataAddr,
  381. inputAddr,
  382. inputLen,
  383. this.dataHeapPtr,
  384. 0,
  385. );
  386. return _dumpJSONRaw(this.mem, ret);
  387. }
  388. // Reset the heap pointer before each evaluation
  389. this.wasmInstance.exports.opa_heap_ptr_set(this.dataHeapPtr);
  390. // Load the input data
  391. const inputAddr = _loadJSON(this.wasmInstance, this.mem, input);
  392. // Setup the evaluation context
  393. const ctxAddr = this.wasmInstance.exports.opa_eval_ctx_new();
  394. this.wasmInstance.exports.opa_eval_ctx_set_input(ctxAddr, inputAddr);
  395. this.wasmInstance.exports.opa_eval_ctx_set_data(ctxAddr, this.dataAddr);
  396. this.wasmInstance.exports.opa_eval_ctx_set_entrypoint(ctxAddr, entrypoint);
  397. // Actually evaluate the policy
  398. this.wasmInstance.exports.eval(ctxAddr);
  399. // Retrieve the result
  400. const resultAddr = this.wasmInstance.exports.opa_eval_ctx_get_result(
  401. ctxAddr,
  402. );
  403. return _dumpJSON(this.wasmInstance, this.mem, resultAddr);
  404. }
  405. /**
  406. * evalBool will evaluate the policy and return a boolean answer
  407. * depending on the return code from the policy evaluation.
  408. * @deprecated Use `evaluate` instead.
  409. * @param {object} input
  410. */
  411. evalBool(input) {
  412. const rs = this.evaluate(input);
  413. return rs && rs.length === 1 && rs[0] === true;
  414. }
  415. /**
  416. * Loads data for use in subsequent evaluations.
  417. * @param {object | ArrayBuffer} data data in form of `object` or ArrayBuffer (last is assumed to be a well-formed stringified JSON)
  418. */
  419. setData(data) {
  420. this.wasmInstance.exports.opa_heap_ptr_set(this.baseHeapPtr);
  421. this.dataAddr = _loadJSON(this.wasmInstance, this.mem, data);
  422. this.dataHeapPtr = this.wasmInstance.exports.opa_heap_ptr_get();
  423. }
  424. }
  425. function roundup(bytes) {
  426. const pageSize = 64 * 1024;
  427. return Math.ceil(bytes / pageSize);
  428. }
  429. module.exports = {
  430. /**
  431. * Takes in either an ArrayBuffer or WebAssembly.Module
  432. * and will return a LoadedPolicy object which can be used to evaluate
  433. * the policy.
  434. *
  435. * To set custom memory size specify number of memory pages
  436. * as second param.
  437. * Defaults to 5 pages (320KB).
  438. * @param {BufferSource | WebAssembly.Module} regoWasm
  439. * @param {number | WebAssembly.MemoryDescriptor} memoryDescriptor For backwards-compatibility, a 'number' argument is taken to be the initial memory size.
  440. */
  441. async loadPolicy(regoWasm, memoryDescriptor = {}) {
  442. // back-compat, second arg used to be a number: 'memorySize', with default of 5
  443. if (typeof memoryDescriptor === "number") {
  444. memoryDescriptor = { initial: memoryDescriptor };
  445. }
  446. memoryDescriptor.initial = memoryDescriptor.initial || 5;
  447. const memory = new WebAssembly.Memory(memoryDescriptor);
  448. const { policy, minorVersion } = await _loadPolicy(regoWasm, memory);
  449. return new LoadedPolicy(policy, memory, minorVersion);
  450. },
  451. };
  452. /***/ }),
  453. /***/ 98611:
  454. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  455. "use strict";
  456. Object.defineProperty(exports, "__esModule", ({ value: true }));
  457. var types_1 = __webpack_require__(60442);
  458. Object.defineProperty(exports, "CloudConfigFileTypes", ({ enumerable: true, get: function () { return types_1.CloudConfigFileTypes; } }));
  459. var issue_to_line_1 = __webpack_require__(76932);
  460. Object.defineProperty(exports, "issuesToLineNumbers", ({ enumerable: true, get: function () { return issue_to_line_1.issuesToLineNumbers; } }));
  461. Object.defineProperty(exports, "getTrees", ({ enumerable: true, get: function () { return issue_to_line_1.getTrees; } }));
  462. Object.defineProperty(exports, "getLineNumber", ({ enumerable: true, get: function () { return issue_to_line_1.getLineNumber; } }));
  463. var yaml_parser_1 = __webpack_require__(54232);
  464. Object.defineProperty(exports, "parseFileContent", ({ enumerable: true, get: function () { return yaml_parser_1.parseFileContent; } }));
  465. var path_1 = __webpack_require__(89639);
  466. Object.defineProperty(exports, "parsePath", ({ enumerable: true, get: function () { return path_1.parsePath; } }));
  467. //# sourceMappingURL=index.js.map
  468. /***/ }),
  469. /***/ 76932:
  470. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  471. "use strict";
  472. Object.defineProperty(exports, "__esModule", ({ value: true }));
  473. exports.getLineNumber = exports.getTrees = exports.issuesToLineNumbers = void 0;
  474. var types = __webpack_require__(60442);
  475. var utils_1 = __webpack_require__(95680);
  476. function issuesToLineNumbers(fileContent, fileType, path) {
  477. var trees = getTrees(fileType, fileContent);
  478. return getLineNumber(path, fileType, trees);
  479. }
  480. exports.issuesToLineNumbers = issuesToLineNumbers;
  481. function getTrees(fileType, fileContent) {
  482. assertFileType(fileType);
  483. var trees = utils_1.buildTreeForTypeMap[fileType](fileContent);
  484. if (Object.keys(trees).length === 0) {
  485. throw new Error('failed to create trees');
  486. }
  487. return trees;
  488. }
  489. exports.getTrees = getTrees;
  490. function getLineNumber(path, fileType, trees) {
  491. assertFileType(fileType);
  492. var pathDetails = utils_1.getPathDetails(path.slice(), fileType);
  493. var treeNodes = trees[pathDetails.docId].nodes;
  494. return utils_1.findLineNumberOfGivenPath(treeNodes, pathDetails);
  495. }
  496. exports.getLineNumber = getLineNumber;
  497. function assertFileType(fileType) {
  498. if (!Object.values(types.CloudConfigFileTypes).includes(fileType)) {
  499. throw new Error('Unknown format');
  500. }
  501. }
  502. //# sourceMappingURL=index.js.map
  503. /***/ }),
  504. /***/ 83686:
  505. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  506. "use strict";
  507. Object.defineProperty(exports, "__esModule", ({ value: true }));
  508. var esprima_1 = __webpack_require__(31072);
  509. var JsonIterator = /** @class */ (function () {
  510. function JsonIterator(fileContent) {
  511. this.tokens = [];
  512. this.i = -1;
  513. this.currentToken = {
  514. type: '',
  515. value: '',
  516. loc: undefined,
  517. };
  518. this.done = false;
  519. this.previousProps = [];
  520. this.lastProp = undefined;
  521. this.tokens = esprima_1.tokenize(fileContent, {
  522. comment: true,
  523. loc: true,
  524. });
  525. if (!this.tokens.length) {
  526. throw new SyntaxError('unexpected end of JSON input');
  527. }
  528. }
  529. JsonIterator.prototype[Symbol.iterator] = function () {
  530. return this;
  531. };
  532. JsonIterator.prototype.isCurrentType = function (type) {
  533. if (!this.currentToken) {
  534. throw new SyntaxError('unexpected end of JSON input');
  535. }
  536. return ((this.currentToken.type === 'Punctuator'
  537. ? this.currentToken.value
  538. : this.currentToken.type) === type);
  539. };
  540. JsonIterator.prototype.isCurrentValue = function (value) {
  541. if (!this.currentToken) {
  542. throw new SyntaxError('unexpected end of JSON input');
  543. }
  544. return (this.currentToken.type === 'Punctuator' &&
  545. this.currentToken.value === value);
  546. };
  547. JsonIterator.prototype.expectType = function (type) {
  548. if (this.isCurrentType(type)) {
  549. return;
  550. }
  551. var error = new SyntaxError("Unexpected type " + this.currentToken.type);
  552. Object.assign(error, this.currentToken.loc.start);
  553. throw error;
  554. };
  555. JsonIterator.prototype.expectValue = function (value) {
  556. if (this.isCurrentValue(value)) {
  557. return;
  558. }
  559. var error = new SyntaxError("Unexpected value " + this.currentToken.value);
  560. Object.assign(error, this.currentToken.loc.start);
  561. throw error;
  562. };
  563. JsonIterator.prototype.skipComments = function () {
  564. while (this.currentToken &&
  565. (this.isCurrentType('LineComment') || this.isCurrentType('BlockComment'))) {
  566. this.next();
  567. }
  568. };
  569. JsonIterator.prototype.next = function () {
  570. if (this.done) {
  571. throw new SyntaxError('Unexpected EOF');
  572. }
  573. var newToken = this.tokens[++this.i];
  574. this.currentToken = newToken;
  575. if (!this.currentToken) {
  576. this.done = true;
  577. }
  578. };
  579. JsonIterator.prototype.current = function () {
  580. return this.currentToken;
  581. };
  582. JsonIterator.prototype.getCurrentLocation = function () {
  583. return {
  584. line: this.currentToken ? this.currentToken.loc.start.line : 0,
  585. columnStart: this.currentToken ? this.currentToken.loc.start.column : 0,
  586. columnEnd: this.currentToken ? this.currentToken.loc.end.column : 0,
  587. };
  588. };
  589. //--------------- Prop Handling
  590. JsonIterator.prototype.setLastProp = function (prop) {
  591. this.lastProp = prop;
  592. };
  593. JsonIterator.prototype.pushLastProp = function () {
  594. this.previousProps.push(this.lastProp);
  595. this.lastProp = undefined;
  596. };
  597. JsonIterator.prototype.restoreProp = function () {
  598. this.lastProp = this.previousProps.pop();
  599. };
  600. JsonIterator.prototype.getLastProp = function () {
  601. return this.lastProp !== undefined ? this.lastProp.toString() : '';
  602. };
  603. return JsonIterator;
  604. }());
  605. exports.default = JsonIterator;
  606. //# sourceMappingURL=iterator.js.map
  607. /***/ }),
  608. /***/ 25552:
  609. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  610. "use strict";
  611. Object.defineProperty(exports, "__esModule", ({ value: true }));
  612. exports.buildJsonTreeMap = void 0;
  613. var tslib_1 = __webpack_require__(70655);
  614. var iterator_1 = __webpack_require__(83686);
  615. var COLON = ':';
  616. var BRACKET_OPEN = '[';
  617. var BRACKET_CLOSE = ']';
  618. var CURLY_BRACKET_OPEN = '{';
  619. var CURLY_BRACKET_CLOSE = '}';
  620. var COMMA = ',';
  621. var MINUS = '-';
  622. var possibleValueTypes = ['String', 'Boolean', 'Null', 'Numeric'];
  623. function buildJsonTreeMap(jsonContent) {
  624. var iter = new iterator_1.default(jsonContent);
  625. iter.next();
  626. iter.skipComments();
  627. var singleWalk = walk(iter);
  628. var tree = {
  629. nodes: singleWalk[0].values,
  630. };
  631. // JSON are always single doc
  632. return {
  633. 0: tree,
  634. };
  635. }
  636. exports.buildJsonTreeMap = buildJsonTreeMap;
  637. function skipCommentsAndParseObjectOrArray(iter, shouldParseObject) {
  638. iter.pushLastProp();
  639. iter.skipComments();
  640. var nodes = [];
  641. if (shouldParseObject) {
  642. nodes = parseObject(iter);
  643. }
  644. else {
  645. nodes = parseArray(iter);
  646. }
  647. // bypass }
  648. iter.next();
  649. iter.restoreProp();
  650. return nodes;
  651. }
  652. function parseObject(iter) {
  653. var nodes = [];
  654. var firstLoop = true;
  655. var name;
  656. while (!iter.isCurrentValue(CURLY_BRACKET_CLOSE)) {
  657. if (!firstLoop) {
  658. // key-value pair delimiter
  659. iter.expectValue(COMMA);
  660. iter.next();
  661. iter.skipComments();
  662. // If there is a trailing comma, we might reach the end
  663. // ```
  664. // {
  665. // "a": 1,
  666. // }
  667. // ```
  668. if (iter.isCurrentValue(CURLY_BRACKET_CLOSE)) {
  669. break;
  670. }
  671. }
  672. firstLoop = false;
  673. iter.expectType('String');
  674. name = JSON.parse(iter.current().value);
  675. iter.setLastProp(name);
  676. iter.next();
  677. iter.expectValue(COLON);
  678. iter.next();
  679. nodes.push.apply(nodes, walk(iter));
  680. }
  681. return nodes;
  682. }
  683. function parseArray(iter) {
  684. var nodes = [];
  685. var firstLoop = true;
  686. var i = 0;
  687. while (!iter.isCurrentValue(BRACKET_CLOSE)) {
  688. if (!firstLoop) {
  689. iter.expectValue(COMMA);
  690. iter.next();
  691. iter.skipComments();
  692. if (iter.isCurrentValue(BRACKET_CLOSE)) {
  693. break;
  694. }
  695. }
  696. firstLoop = false;
  697. iter.setLastProp(i);
  698. nodes.push.apply(nodes, walk(iter));
  699. iter.skipComments();
  700. i++;
  701. }
  702. return nodes;
  703. }
  704. function handleNativeCase(iter) {
  705. if (!possibleValueTypes.includes(iter.current().type)) {
  706. throw new Error('failed to find type ' + iter.current().type);
  707. }
  708. // turn "apiVersion" -> apiVersion
  709. // turn 'apiVersion' -> apiVersion
  710. var currentValue = iter.current().value;
  711. if ((currentValue.startsWith('"') && currentValue.endsWith('"')) ||
  712. (currentValue.startsWith("'") && currentValue.endsWith("'"))) {
  713. currentValue = currentValue.substring(1, currentValue.length - 1);
  714. }
  715. var nativeNode = {
  716. key: iter.getLastProp(),
  717. lineLocation: iter.getCurrentLocation(),
  718. values: currentValue,
  719. };
  720. iter.next();
  721. return [nativeNode];
  722. }
  723. function walk(iter) {
  724. var currentNode = {
  725. key: iter.getLastProp(),
  726. lineLocation: iter.getCurrentLocation(),
  727. values: [],
  728. };
  729. switch (iter.current().value) {
  730. case CURLY_BRACKET_OPEN:
  731. iter.next();
  732. return [
  733. tslib_1.__assign(tslib_1.__assign({}, currentNode), { values: skipCommentsAndParseObjectOrArray(iter, true) }),
  734. ];
  735. case BRACKET_OPEN:
  736. iter.next();
  737. return skipCommentsAndParseObjectOrArray(iter, false).map(function (value, i) {
  738. return {
  739. key: iter.getLastProp() + "[" + i + "]",
  740. lineLocation: value.lineLocation,
  741. values: value.values,
  742. };
  743. });
  744. case MINUS:
  745. iter.next();
  746. break;
  747. }
  748. return handleNativeCase(iter);
  749. }
  750. //# sourceMappingURL=parser.js.map
  751. /***/ }),
  752. /***/ 89179:
  753. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  754. "use strict";
  755. Object.defineProperty(exports, "__esModule", ({ value: true }));
  756. exports.buildTfTreeMap = void 0;
  757. var types_1 = __webpack_require__(978);
  758. var utils_1 = __webpack_require__(41904);
  759. function buildTfTreeMap(tfContent) {
  760. var multiLineComment = false;
  761. var multiLinePhrase = { phrase: null };
  762. var nodes = [];
  763. var currNode = null;
  764. var stateQueue = [];
  765. var duringTypeParsing = false;
  766. var tfFileLines = tfContent.split('\n');
  767. for (var i = 0; i < tfFileLines.length; i++) {
  768. var line = { content: tfFileLines[i].trim(), number: i };
  769. var lineState = utils_1.getLineState(line, multiLineComment, multiLinePhrase);
  770. multiLineComment = lineState.multiCommentLine;
  771. if (lineState.ignoredLine) {
  772. continue;
  773. }
  774. if (multiLinePhrase.phrase) {
  775. //Multi-line phrase ended - line is not ignored any more
  776. multiLinePhrase.phrase = null;
  777. continue;
  778. }
  779. var topType = void 0;
  780. if (stateQueue.length > 0) {
  781. topType = stateQueue[stateQueue.length - 1].type;
  782. }
  783. var lineType = utils_1.getLineType(line, topType);
  784. // In case of array value where is multiline and not completed yet
  785. // or
  786. // Object inside array
  787. // -> can skip this line
  788. if (topType === types_1.TFLineTypes.ARRAY_START &&
  789. ![
  790. types_1.TFLineTypes.ARRAY_END,
  791. types_1.TFLineTypes.OBJECT_START,
  792. types_1.TFLineTypes.OBJECT_START_AND_END,
  793. ].includes(lineType)) {
  794. continue;
  795. }
  796. switch (lineType) {
  797. case types_1.TFLineTypes.IGNORE:
  798. continue;
  799. case types_1.TFLineTypes.TYPE_START:
  800. currNode = getTypeDetailsFromLine(line, nodes, stateQueue);
  801. duringTypeParsing = true;
  802. continue;
  803. case types_1.TFLineTypes.TYPE_START_AND_END:
  804. currNode = getTypeDetailsFromLine(line, nodes, stateQueue);
  805. stateQueue = [];
  806. duringTypeParsing = false;
  807. continue;
  808. case types_1.TFLineTypes.TYPE_END:
  809. if (topType !== types_1.TFLineTypes.SUB_TYPE) {
  810. throw new SyntaxError('Invalid TF Input - End of type object without sub type');
  811. }
  812. stateQueue = [];
  813. duringTypeParsing = false;
  814. continue;
  815. case types_1.TFLineTypes.OBJECT_START:
  816. currNode = getComplexObjectNode(line, stateQueue, utils_1.Charts.openBracketsObject, lineType);
  817. continue;
  818. case types_1.TFLineTypes.OBJECT_START_AND_END:
  819. getComplexObjectNode(line, stateQueue, utils_1.Charts.openBracketsObject, lineType);
  820. stateQueue.pop();
  821. continue;
  822. case types_1.TFLineTypes.OBJECT_END: {
  823. currNode = handleComplexObjectEnd(currNode, stateQueue, types_1.TFLineTypes.OBJECT_START);
  824. continue;
  825. }
  826. case types_1.TFLineTypes.FUNCTION_START:
  827. currNode = getComplexObjectNode(line, stateQueue, utils_1.Charts.openFunction, lineType);
  828. continue;
  829. case types_1.TFLineTypes.FUNCTION_START_AND_END:
  830. getComplexObjectNode(line, stateQueue, utils_1.Charts.openFunction, lineType);
  831. stateQueue.pop();
  832. continue;
  833. case types_1.TFLineTypes.FUNCTION_END:
  834. currNode = handleComplexObjectEnd(currNode, stateQueue, types_1.TFLineTypes.FUNCTION_START);
  835. continue;
  836. case types_1.TFLineTypes.STRING:
  837. case types_1.TFLineTypes.MULTILINE_STRING:
  838. case types_1.TFLineTypes.ARRAY_START_AND_END: {
  839. if (!currNode) {
  840. throw new SyntaxError('Unexpected TF input - Simple object without parent node');
  841. }
  842. var simpleNode = getSimpleNode(line);
  843. currNode.values.push(simpleNode);
  844. if (lineType === types_1.TFLineTypes.MULTILINE_STRING) {
  845. multiLinePhrase = utils_1.getMultiLinePhrase(line);
  846. }
  847. continue;
  848. }
  849. case types_1.TFLineTypes.ARRAY_START: {
  850. if (!currNode) {
  851. throw new SyntaxError('Unexpected TF input - Simple object without parent node');
  852. }
  853. var simpleNode = getSimpleNode(line);
  854. if (simpleNode.values === utils_1.Charts.openBracketsArray) {
  855. simpleNode.values = [];
  856. }
  857. currNode.values.push(simpleNode);
  858. stateQueue.push({
  859. structure: simpleNode,
  860. type: lineType,
  861. });
  862. continue;
  863. }
  864. case types_1.TFLineTypes.ARRAY_END: {
  865. stateQueue.pop();
  866. continue;
  867. }
  868. default:
  869. throw new SyntaxError("Invalid TF input - Unhandled line type " + types_1.TFLineTypes[lineType]);
  870. }
  871. }
  872. if (duringTypeParsing || stateQueue.length !== 0) {
  873. throw new SyntaxError('Invalid TF input - Broken file');
  874. }
  875. if (nodes.length === 0) {
  876. throw new SyntaxError('Invalid TF input - No nodes were parsed');
  877. }
  878. // TF are always single doc
  879. return {
  880. 0: { nodes: nodes },
  881. };
  882. }
  883. exports.buildTfTreeMap = buildTfTreeMap;
  884. function getTypeDetailsFromLine(currentLine, nodes, stateQueue) {
  885. var lineContent = currentLine.content.split(utils_1.Charts.space);
  886. var resourceType = lineContent[1].replace(/"/g, '');
  887. var objectType = lineContent[0];
  888. if (resourceType === utils_1.Charts.openBracketsObject) {
  889. if (types_1.TerraformValidConfigurationTypes.includes(objectType)) {
  890. //Support Terraform configurations settings object
  891. resourceType = '';
  892. }
  893. else {
  894. throw new SyntaxError('Invalid TF input - Type object without sub type');
  895. }
  896. }
  897. var headNode = getTypeNode(objectType, currentLine, nodes);
  898. if (lineContent[2] &&
  899. lineContent[2] !== null &&
  900. lineContent[2] !== utils_1.Charts.openBracketsObject) {
  901. var resourceName = lineContent[2].replace(/"/g, '');
  902. resourceType = resourceType + "[" + resourceName + "]";
  903. }
  904. var subHeadNode = getSubTypeNode(headNode, resourceType, currentLine);
  905. stateQueue.push({ structure: headNode, type: types_1.TFLineTypes.TYPE_START });
  906. stateQueue.push({ structure: subHeadNode, type: types_1.TFLineTypes.SUB_TYPE });
  907. return subHeadNode;
  908. }
  909. function getTypeNode(objectType, line, nodes) {
  910. var headNode = nodes.find(function (node) { return node.key === objectType; });
  911. if (!headNode) {
  912. headNode = utils_1.getNode(objectType, line, []);
  913. nodes.push(headNode);
  914. }
  915. return headNode;
  916. }
  917. function getSubTypeNode(headNode, resourceType, line) {
  918. var headerSubTypes = headNode.values;
  919. var subHeadNode = headerSubTypes.find(function (node) { return node.key === resourceType; });
  920. if (!subHeadNode) {
  921. subHeadNode = utils_1.getNode(resourceType, line);
  922. headNode.values.push(subHeadNode);
  923. }
  924. return subHeadNode;
  925. }
  926. function getComplexObjectNode(line, stateQueue, splitByChart, lineType) {
  927. var key = line.content
  928. .split(splitByChart)[0]
  929. .split(utils_1.Charts.equal)[0]
  930. .trim();
  931. var objectNode = utils_1.getNode(key, line);
  932. stateQueue.push({ structure: objectNode, type: lineType });
  933. return objectNode;
  934. }
  935. function getSimpleNode(line) {
  936. var _a = line.content.split(utils_1.Charts.equal), key = _a[0], value = _a[1];
  937. return utils_1.getNode(key.trim(), line, value.trim().replace(/"/g, ''));
  938. }
  939. function handleComplexObjectEnd(currNode, stateQueue, startLineType) {
  940. var topState = stateQueue[stateQueue.length - 1];
  941. if (topState.type !== startLineType || stateQueue.length === 0) {
  942. throw new SyntaxError('Invalid TF Input - Object end without start');
  943. }
  944. if (!currNode) {
  945. throw new SyntaxError('Invalid TF input - Object without parent');
  946. }
  947. stateQueue.pop();
  948. topState = stateQueue[stateQueue.length - 1];
  949. var topNode = topState.structure;
  950. topNode.values.push(currNode);
  951. return topNode;
  952. }
  953. //# sourceMappingURL=parser.js.map
  954. /***/ }),
  955. /***/ 978:
  956. /***/ ((__unused_webpack_module, exports) => {
  957. "use strict";
  958. Object.defineProperty(exports, "__esModule", ({ value: true }));
  959. exports.TerraformValidConfigurationTypes = exports.TFLineTypes = void 0;
  960. var TFLineTypes;
  961. (function (TFLineTypes) {
  962. TFLineTypes[TFLineTypes["TYPE_START"] = 1] = "TYPE_START";
  963. TFLineTypes[TFLineTypes["TYPE_END"] = 2] = "TYPE_END";
  964. TFLineTypes[TFLineTypes["TYPE_START_AND_END"] = 3] = "TYPE_START_AND_END";
  965. TFLineTypes[TFLineTypes["SUB_TYPE"] = 4] = "SUB_TYPE";
  966. TFLineTypes[TFLineTypes["STRING"] = 5] = "STRING";
  967. TFLineTypes[TFLineTypes["MULTILINE_STRING"] = 6] = "MULTILINE_STRING";
  968. TFLineTypes[TFLineTypes["ARRAY_START_AND_END"] = 7] = "ARRAY_START_AND_END";
  969. TFLineTypes[TFLineTypes["ARRAY_START"] = 8] = "ARRAY_START";
  970. TFLineTypes[TFLineTypes["ARRAY_END"] = 9] = "ARRAY_END";
  971. TFLineTypes[TFLineTypes["OBJECT_START_AND_END"] = 10] = "OBJECT_START_AND_END";
  972. TFLineTypes[TFLineTypes["OBJECT_START"] = 11] = "OBJECT_START";
  973. TFLineTypes[TFLineTypes["OBJECT_END"] = 12] = "OBJECT_END";
  974. TFLineTypes[TFLineTypes["FUNCTION_START_AND_END"] = 13] = "FUNCTION_START_AND_END";
  975. TFLineTypes[TFLineTypes["FUNCTION_START"] = 14] = "FUNCTION_START";
  976. TFLineTypes[TFLineTypes["FUNCTION_END"] = 15] = "FUNCTION_END";
  977. TFLineTypes[TFLineTypes["IGNORE"] = 99] = "IGNORE";
  978. })(TFLineTypes = exports.TFLineTypes || (exports.TFLineTypes = {}));
  979. exports.TerraformValidConfigurationTypes = ['terraform', 'locals'];
  980. //# sourceMappingURL=types.js.map
  981. /***/ }),
  982. /***/ 41904:
  983. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  984. "use strict";
  985. Object.defineProperty(exports, "__esModule", ({ value: true }));
  986. exports.getNode = exports.getLineType = exports.getMultiLinePhrase = exports.getLineState = exports.Charts = void 0;
  987. var types_1 = __webpack_require__(978);
  988. exports.Charts = {
  989. space: ' ',
  990. equal: '=',
  991. commentHash: '#',
  992. commentDash: '//',
  993. multilineCommentStart: '/*',
  994. multilineCommentEnd: '*/',
  995. multilinePhrase: '<<',
  996. openBracketsObject: '{',
  997. closeBracketsObject: '}',
  998. openBracketsArray: '[',
  999. closeBracketsArray: ']',
  1000. openFunction: '(',
  1001. closeFunction: ')',
  1002. };
  1003. function getLineState(line, isMultiLineComment, multiLinePhrase) {
  1004. var multiCommentLine = isMultiLineComment;
  1005. var ignoredLine = false;
  1006. if (line.content.startsWith(exports.Charts.multilineCommentStart)) {
  1007. ignoredLine = true;
  1008. multiCommentLine = true;
  1009. }
  1010. if (line.content.includes(exports.Charts.multilineCommentEnd)) {
  1011. // Multiline comment ended - this is still a commented line
  1012. ignoredLine = true;
  1013. multiCommentLine = false;
  1014. }
  1015. if (line.content.startsWith(exports.Charts.commentHash) ||
  1016. line.content.startsWith(exports.Charts.commentDash) ||
  1017. line.content.length === 0 //Empty Line
  1018. ) {
  1019. ignoredLine = true;
  1020. }
  1021. // Inside a multiline comment
  1022. if (isMultiLineComment && !ignoredLine) {
  1023. ignoredLine = true;
  1024. }
  1025. // Inside a multiline phrase
  1026. if (multiLinePhrase.phrase &&
  1027. !line.content.includes(multiLinePhrase.phrase)) {
  1028. ignoredLine = true;
  1029. }
  1030. return {
  1031. ignoredLine: ignoredLine,
  1032. multiCommentLine: multiCommentLine,
  1033. };
  1034. }
  1035. exports.getLineState = getLineState;
  1036. function getMultiLinePhrase(line) {
  1037. var phrase = line.content
  1038. .split(exports.Charts.multilinePhrase)[1]
  1039. .trim()
  1040. .split(exports.Charts.space)[0];
  1041. return { phrase: phrase };
  1042. }
  1043. exports.getMultiLinePhrase = getMultiLinePhrase;
  1044. function getLineType(line, currentObjectType) {
  1045. if (!currentObjectType) {
  1046. if (line.content.includes(exports.Charts.openBracketsObject)) {
  1047. if (line.content.includes(exports.Charts.closeBracketsObject)) {
  1048. return types_1.TFLineTypes.TYPE_START_AND_END;
  1049. }
  1050. return types_1.TFLineTypes.TYPE_START;
  1051. }
  1052. throw new SyntaxError('Invalid TF input - TF Object without parent Type');
  1053. }
  1054. if (line.content.includes(exports.Charts.openBracketsArray)) {
  1055. if (line.content.includes(exports.Charts.closeBracketsArray)) {
  1056. return types_1.TFLineTypes.ARRAY_START_AND_END;
  1057. }
  1058. return types_1.TFLineTypes.ARRAY_START;
  1059. }
  1060. if (line.content.includes(exports.Charts.closeBracketsArray)) {
  1061. return types_1.TFLineTypes.ARRAY_END;
  1062. }
  1063. if (line.content.includes(exports.Charts.multilinePhrase)) {
  1064. return types_1.TFLineTypes.MULTILINE_STRING;
  1065. }
  1066. if (line.content.includes(exports.Charts.openFunction)) {
  1067. if (line.content.includes(exports.Charts.closeFunction)) {
  1068. return types_1.TFLineTypes.FUNCTION_START_AND_END;
  1069. }
  1070. return types_1.TFLineTypes.FUNCTION_START;
  1071. }
  1072. if (line.content.includes(exports.Charts.openBracketsObject)) {
  1073. if (line.content.includes(exports.Charts.closeBracketsObject)) {
  1074. if (line.content.includes(exports.Charts.equal)) {
  1075. return types_1.TFLineTypes.STRING;
  1076. }
  1077. return types_1.TFLineTypes.OBJECT_START_AND_END;
  1078. }
  1079. return types_1.TFLineTypes.OBJECT_START;
  1080. }
  1081. if (line.content.includes(exports.Charts.closeFunction)) {
  1082. if (currentObjectType != types_1.TFLineTypes.FUNCTION_START) {
  1083. throw new SyntaxError('Invalid TF input - Close function sign without open function');
  1084. }
  1085. return types_1.TFLineTypes.FUNCTION_END;
  1086. }
  1087. if (currentObjectType === types_1.TFLineTypes.FUNCTION_START) {
  1088. if (line.content.split(exports.Charts.space).length === 1) {
  1089. return types_1.TFLineTypes.IGNORE;
  1090. }
  1091. return types_1.TFLineTypes.STRING;
  1092. }
  1093. if (line.content.includes(exports.Charts.equal)) {
  1094. return types_1.TFLineTypes.STRING;
  1095. }
  1096. if (line.content.includes(exports.Charts.closeBracketsObject)) {
  1097. if (currentObjectType === types_1.TFLineTypes.SUB_TYPE) {
  1098. return types_1.TFLineTypes.TYPE_END;
  1099. }
  1100. return types_1.TFLineTypes.OBJECT_END;
  1101. }
  1102. if (line.content.startsWith(exports.Charts.multilinePhrase)) {
  1103. return types_1.TFLineTypes.MULTILINE_STRING;
  1104. }
  1105. if (currentObjectType === types_1.TFLineTypes.ARRAY_START) {
  1106. // Handling case of multi-line array object where the content is not yet finished.
  1107. // Those lines will be skipped as part of
  1108. // https://github.com/snyk/cloud-config-parser/blob/b5f5bdd8dd60cb3ad9c110bb6c640f08db0e108b/lib/issue-to-line/tf/parser.ts#L44
  1109. return types_1.TFLineTypes.STRING;
  1110. }
  1111. throw new SyntaxError("Invalid TF input - Unknown line type - " + line.content);
  1112. }
  1113. exports.getLineType = getLineType;
  1114. function getNode(key, line, values) {
  1115. var node = {
  1116. key: key,
  1117. lineLocation: {
  1118. line: line.number + 1,
  1119. columnStart: 0,
  1120. columnEnd: line.content.length,
  1121. },
  1122. values: values ? values : [],
  1123. };
  1124. return node;
  1125. }
  1126. exports.getNode = getNode;
  1127. //# sourceMappingURL=utils.js.map
  1128. /***/ }),
  1129. /***/ 95680:
  1130. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1131. "use strict";
  1132. var _a;
  1133. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1134. exports.getLineLocationForYamlElement = exports.findLineNumberOfGivenPath = exports.removeInputPathPrefix = exports.getPathDetails = exports.buildTreeForTypeMap = void 0;
  1135. var types_1 = __webpack_require__(60442);
  1136. var parser_1 = __webpack_require__(59559);
  1137. var parser_2 = __webpack_require__(25552);
  1138. var parser_3 = __webpack_require__(89179);
  1139. exports.buildTreeForTypeMap = (_a = {},
  1140. _a[types_1.CloudConfigFileTypes.YAML] = parser_1.buildYamlTreeMap,
  1141. _a[types_1.CloudConfigFileTypes.JSON] = parser_2.buildJsonTreeMap,
  1142. _a[types_1.CloudConfigFileTypes.TF] = parser_3.buildTfTreeMap,
  1143. _a);
  1144. function getPathDetails(path, fileType) {
  1145. if (fileType === types_1.CloudConfigFileTypes.YAML) {
  1146. return parser_1.getPathDetailsForYamlFile(path);
  1147. }
  1148. return {
  1149. docId: 0,
  1150. path: removeInputPathPrefix(path),
  1151. };
  1152. }
  1153. exports.getPathDetails = getPathDetails;
  1154. function removeInputPathPrefix(path) {
  1155. if (path[0] === 'input') {
  1156. return path.splice(1);
  1157. }
  1158. return path;
  1159. }
  1160. exports.removeInputPathPrefix = removeInputPathPrefix;
  1161. function findLineNumberOfGivenPath(nodes, pathDetails) {
  1162. var filteredNodes = nodes.filter(function (node) { return node.key === pathDetails.path[0]; });
  1163. if (filteredNodes.length === 0) {
  1164. // If the path does not exist, we will return '-1'
  1165. return -1;
  1166. }
  1167. if (pathDetails.path.length === 1) {
  1168. return filteredNodes[0].lineLocation.line;
  1169. }
  1170. return getLineNumberForSingleNode(filteredNodes[0], pathDetails.path.splice(1));
  1171. }
  1172. exports.findLineNumberOfGivenPath = findLineNumberOfGivenPath;
  1173. function getLineNumberForSingleNode(baseNode, remainingPath) {
  1174. var node = baseNode;
  1175. while (remainingPath.length) {
  1176. if (typeof node.values === 'string') {
  1177. return node.lineLocation.line;
  1178. }
  1179. var nodeForPath = getNodeForPath(node.values, remainingPath[0]);
  1180. if (!nodeForPath) {
  1181. //Not exists
  1182. return node.lineLocation.line;
  1183. }
  1184. node = nodeForPath;
  1185. remainingPath = remainingPath.splice(1);
  1186. }
  1187. return node.lineLocation.line;
  1188. }
  1189. function getNodeForPath(nodeValues, path) {
  1190. if (!path.includes('[')) {
  1191. return nodeValues.find(function (currNode) {
  1192. return currNode.key.startsWith(path + "[") || currNode.key === path;
  1193. });
  1194. }
  1195. var _a = path.replace(']', '').split('['), nodeName = _a[0], subNodeName = _a[1];
  1196. var subNodeId = parseInt(subNodeName);
  1197. if (!isNaN(subNodeId) && Number.isInteger(subNodeId)) {
  1198. return nodeValues.find(function (currNode) { return currNode.key === path; });
  1199. }
  1200. return nodeValues.find(function (currNode) {
  1201. var values = currNode.values;
  1202. if (typeof values !== 'string') {
  1203. return (currNode.key === path ||
  1204. (currNode.key.startsWith(nodeName) &&
  1205. values.filter(function (value) {
  1206. return value.key === 'name' && value.values === subNodeName;
  1207. }).length > 0));
  1208. }
  1209. return false;
  1210. });
  1211. }
  1212. function getLineLocationForYamlElement(nodeElement) {
  1213. return {
  1214. line: nodeElement.startMark.line + 1,
  1215. columnStart: nodeElement.startMark.pointer,
  1216. columnEnd: nodeElement.endMark.pointer,
  1217. };
  1218. }
  1219. exports.getLineLocationForYamlElement = getLineLocationForYamlElement;
  1220. //# sourceMappingURL=utils.js.map
  1221. /***/ }),
  1222. /***/ 59559:
  1223. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1224. "use strict";
  1225. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1226. exports.getPathDetailsForYamlFile = exports.buildYamlTreeMap = void 0;
  1227. var yamlJs = __webpack_require__(35740);
  1228. var utils_1 = __webpack_require__(95680);
  1229. var NULL_TAG = 'tag:yaml.org,2002:null';
  1230. var STR_TAG = 'tag:yaml.org,2002:str';
  1231. var INT_TAG = 'tag:yaml.org,2002:int';
  1232. var FLOAT_TAG = 'tag:yaml.org,2002:float';
  1233. var BOOL_TAG = 'tag:yaml.org,2002:bool';
  1234. var MAP_TAG = 'tag:yaml.org,2002:map';
  1235. var SEQ_TAG = 'tag:yaml.org,2002:seq';
  1236. var TIMESTAMP_TAG = 'tag:yaml.org,2002:timestamp';
  1237. var KEY_NODE_INDEX = 0;
  1238. var VAL_NODE_INDEX = 1;
  1239. var COMMENT_CHAR = '#';
  1240. var MULTI_DOC_SEPARATOR = '---';
  1241. function buildYamlTreeMap(yamlContent) {
  1242. var yamlTrees = {};
  1243. var docsArray = [];
  1244. try {
  1245. docsArray = yamlJs.compose_all(yamlContent);
  1246. }
  1247. catch (error) {
  1248. throw new Error('failed to compose_all for given yaml');
  1249. }
  1250. // Edge case that yamlJs does not handle -
  1251. // The first lines, before the first doc separator (---) are comments
  1252. // The yamlJs will ignore this lines and will have 1 less document than expected.
  1253. // This will only happen for the first document which document object will not be added for
  1254. if (yamlContent.startsWith(COMMENT_CHAR) &&
  1255. yamlContent.split(MULTI_DOC_SEPARATOR).length === docsArray.length + 1) {
  1256. /* eslint-disable @typescript-eslint/camelcase */
  1257. // Disable camelcase - object structure from yamlJs
  1258. var commentObject = {
  1259. start_mark: { line: 0, column: 0, pointer: 0, buffer: yamlContent },
  1260. end_mark: { line: 0, column: 0, pointer: 0, buffer: yamlContent },
  1261. style: undefined,
  1262. tag: NULL_TAG,
  1263. unique_id: 'node_0',
  1264. value: '',
  1265. };
  1266. /* eslint-enable @typescript-eslint/camelcase */
  1267. docsArray.unshift(commentObject);
  1268. }
  1269. for (var i = 0; i < docsArray.length; i++) {
  1270. var yamlDoc = convertComposeElementToType(docsArray[i]);
  1271. // Handle case of empty document - the tag will be null
  1272. // No need to build tree for this document
  1273. if (yamlDoc.tag !== NULL_TAG) {
  1274. yamlTrees[i] = buildTree(yamlDoc);
  1275. }
  1276. }
  1277. return yamlTrees;
  1278. }
  1279. exports.buildYamlTreeMap = buildYamlTreeMap;
  1280. function buildTree(yamlDoc) {
  1281. var _a;
  1282. var tree = { nodes: [] };
  1283. if (yamlDoc.tag !== MAP_TAG) {
  1284. throw new Error('Invalid tree - cannot build from map');
  1285. }
  1286. for (var _i = 0, _b = yamlDoc.value; _i < _b.length; _i++) {
  1287. var yamlElementValues = _b[_i];
  1288. var values = [
  1289. convertComposeElementToType(yamlElementValues[KEY_NODE_INDEX]),
  1290. convertComposeElementToType(yamlElementValues[VAL_NODE_INDEX]),
  1291. ];
  1292. (_a = tree.nodes).push.apply(_a, buildTreeBranch(values, []));
  1293. }
  1294. return tree;
  1295. }
  1296. function buildTreeBranch(yamlElements, path) {
  1297. //We are checking on the valNode - which is the second element in the yamlElements array ([1])
  1298. switch (yamlElements[VAL_NODE_INDEX].tag) {
  1299. case NULL_TAG:
  1300. case STR_TAG:
  1301. case INT_TAG:
  1302. case FLOAT_TAG:
  1303. case BOOL_TAG:
  1304. case TIMESTAMP_TAG:
  1305. return buildPrimitiveLeaf(yamlElements);
  1306. case MAP_TAG:
  1307. return buildMapBranch(yamlElements, path);
  1308. case SEQ_TAG:
  1309. return buildSeqBranch(yamlElements, path);
  1310. default:
  1311. return [];
  1312. }
  1313. }
  1314. function buildPrimitiveLeaf(yamlElements) {
  1315. var keyNode = yamlElements[0], valNode = yamlElements[1];
  1316. var key = keyNode.value;
  1317. var values = valNode.value;
  1318. var lineLocation = utils_1.getLineLocationForYamlElement(keyNode);
  1319. return [
  1320. {
  1321. key: key,
  1322. lineLocation: lineLocation,
  1323. values: values,
  1324. },
  1325. ];
  1326. }
  1327. function buildMapBranch(yamlElements, path) {
  1328. var keyNode = yamlElements[KEY_NODE_INDEX];
  1329. var fullPath = path.concat([keyNode.value]);
  1330. return [
  1331. getFileStructureNodesForYamlElement(yamlElements, keyNode.value, fullPath),
  1332. ];
  1333. }
  1334. function buildSeqBranch(yamlElements, path) {
  1335. var keyNode = yamlElements[0], valNode = yamlElements[1];
  1336. var seqNodes = [];
  1337. for (var i = 0; i < valNode.value.length; i++) {
  1338. var nodeElement = convertComposeElementToType(valNode.value[i]);
  1339. var key = keyNode.value + "[" + i + "]";
  1340. var fullPath = path.concat(key);
  1341. if (typeof nodeElement.value === 'string') {
  1342. var lineLocation = utils_1.getLineLocationForYamlElement(nodeElement);
  1343. var node = {
  1344. key: key,
  1345. lineLocation: lineLocation,
  1346. values: nodeElement.value,
  1347. };
  1348. seqNodes.push(node);
  1349. }
  1350. else {
  1351. seqNodes.push(getFileStructureNodesForYamlElement([nodeElement, nodeElement], key, fullPath));
  1352. }
  1353. }
  1354. return seqNodes;
  1355. }
  1356. function convertComposeElementToType(yamlElement) {
  1357. return {
  1358. id: yamlElement.id,
  1359. tag: yamlElement.tag,
  1360. startMark: {
  1361. line: yamlElement.start_mark.line,
  1362. column: yamlElement.start_mark.column,
  1363. Buffer: yamlElement.start_mark.buffer,
  1364. pointer: yamlElement.start_mark.pointer,
  1365. },
  1366. endMark: {
  1367. line: yamlElement.end_mark.line,
  1368. column: yamlElement.end_mark.column,
  1369. Buffer: yamlElement.end_mark.buffer,
  1370. pointer: yamlElement.end_mark.pointer,
  1371. },
  1372. value: yamlElement.value,
  1373. };
  1374. }
  1375. function getFileStructureNodesForYamlElement(yamlElements, key, fullPath) {
  1376. var keyNode = yamlElements[0], valNode = yamlElements[1];
  1377. var nodes = [];
  1378. var lineLocation = utils_1.getLineLocationForYamlElement(keyNode);
  1379. for (var _i = 0, _a = valNode.value; _i < _a.length; _i++) {
  1380. var yamlElementValues = _a[_i];
  1381. var values = [
  1382. convertComposeElementToType(yamlElementValues[KEY_NODE_INDEX]),
  1383. convertComposeElementToType(yamlElementValues[VAL_NODE_INDEX]),
  1384. ];
  1385. nodes.push.apply(nodes, buildTreeBranch(values, fullPath));
  1386. }
  1387. return {
  1388. key: key,
  1389. lineLocation: lineLocation,
  1390. values: nodes,
  1391. };
  1392. }
  1393. function getPathDetailsForYamlFile(path) {
  1394. var firstPath = path[0];
  1395. if (firstPath.includes('[DocId:')) {
  1396. var docId = firstPath.replace('[DocId: ', '').replace(']', '');
  1397. var pathWithoutDocId = path.splice(1);
  1398. return {
  1399. docId: parseInt(docId),
  1400. path: utils_1.removeInputPathPrefix(pathWithoutDocId),
  1401. };
  1402. }
  1403. return {
  1404. docId: 0,
  1405. path: utils_1.removeInputPathPrefix(path),
  1406. };
  1407. }
  1408. exports.getPathDetailsForYamlFile = getPathDetailsForYamlFile;
  1409. //# sourceMappingURL=parser.js.map
  1410. /***/ }),
  1411. /***/ 89639:
  1412. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1413. "use strict";
  1414. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1415. exports.parsePath = void 0;
  1416. var peggy = __webpack_require__(4193);
  1417. var grammar = "\n// Documentation, specifically for parsing delimited lists.\n// https://peggyjs.org/documentation#parsing-lists\n\n// A path is a dot delimeted list of identifiers.\npath = head:segment tail:(\".\" @segment)* { return [head, ...tail]; }\n\n// Segments consist of an identifier and an optional index.\n// e.g. hello or hello[world]\nsegment = $(identifier index?)\n\n// An identifier is a string of consecutive characters not consisting of dots, quotes or brackets. \nidentifier = [^'\"\\[\\]\\.]+\n\n// An index consists of square brackets containing a quoted or unquoted value.\n// e.g. hello['world'] or hello[world]\nindex = \"[\" $( unquoted_index / single_quoted_index / double_quoted_index) \"]\"\n\nunquoted_index = [^'\"\\]\\[]+\nsingle_quoted_index = \"'\" [^']+ \"'\"\ndouble_quoted_index = '\"' [^\"]+ '\"'\n";
  1418. exports.parsePath = createPathParser();
  1419. function createPathParser() {
  1420. var parser = peggy.generate(grammar);
  1421. return function (expr) {
  1422. try {
  1423. return parser.parse(expr);
  1424. }
  1425. catch (e) {
  1426. return expr.split('.');
  1427. }
  1428. };
  1429. }
  1430. //# sourceMappingURL=path.js.map
  1431. /***/ }),
  1432. /***/ 60442:
  1433. /***/ ((__unused_webpack_module, exports) => {
  1434. "use strict";
  1435. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1436. exports.CloudConfigFileTypes = void 0;
  1437. var CloudConfigFileTypes;
  1438. (function (CloudConfigFileTypes) {
  1439. CloudConfigFileTypes[CloudConfigFileTypes["YAML"] = 1] = "YAML";
  1440. CloudConfigFileTypes[CloudConfigFileTypes["JSON"] = 2] = "JSON";
  1441. CloudConfigFileTypes[CloudConfigFileTypes["TF"] = 3] = "TF";
  1442. })(CloudConfigFileTypes = exports.CloudConfigFileTypes || (exports.CloudConfigFileTypes = {}));
  1443. //# sourceMappingURL=types.js.map
  1444. /***/ }),
  1445. /***/ 54232:
  1446. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1447. "use strict";
  1448. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1449. exports.parseFileContent = void 0;
  1450. var YAML = __webpack_require__(6792);
  1451. function parseFileContent(fileContent) {
  1452. // the YAML library can parse both YAML and JSON content, as well as content with singe/multiple YAMLs
  1453. // by using this library we don't have to disambiguate between these different contents ourselves
  1454. return YAML.parseAllDocuments(fileContent).map(function (doc) {
  1455. if (shouldThrowErrorFor(doc)) {
  1456. throw doc.errors[0];
  1457. }
  1458. if (showThrowWarningFor(doc)) {
  1459. throw doc.warnings[0];
  1460. }
  1461. return doc.toJSON();
  1462. });
  1463. }
  1464. exports.parseFileContent = parseFileContent;
  1465. function shouldThrowErrorFor(doc) {
  1466. var errorsToSkip = [
  1467. 'Insufficient indentation in flow collection',
  1468. 'Map keys must be unique',
  1469. ];
  1470. return (doc.errors.length !== 0 &&
  1471. !errorsToSkip.some(function (e) { return doc.errors[0].message.includes(e); }));
  1472. }
  1473. function showThrowWarningFor(doc) {
  1474. var warningsToInclude = [
  1475. 'Keys with collection values will be stringified as YAML due to JS Object restrictions. Use mapAsMap: true to avoid this.',
  1476. ];
  1477. return (doc.warnings.length !== 0 &&
  1478. warningsToInclude.some(function (e) { return doc.warnings[0].message.includes(e); }));
  1479. }
  1480. //# sourceMappingURL=index.js.map
  1481. /***/ }),
  1482. /***/ 76884:
  1483. /***/ ((module) => {
  1484. /**
  1485. * lodash (Custom Build) <https://lodash.com/>
  1486. * Build: `lodash modularize exports="npm" -o ./`
  1487. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  1488. * Released under MIT license <https://lodash.com/license>
  1489. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  1490. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  1491. */
  1492. /** Used as references for various `Number` constants. */
  1493. var INFINITY = 1 / 0;
  1494. /** `Object#toString` result references. */
  1495. var symbolTag = '[object Symbol]';
  1496. /** Used to match words composed of alphanumeric characters. */
  1497. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  1498. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  1499. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  1500. /** Used to compose unicode character classes. */
  1501. var rsAstralRange = '\\ud800-\\udfff',
  1502. rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
  1503. rsComboSymbolsRange = '\\u20d0-\\u20f0',
  1504. rsDingbatRange = '\\u2700-\\u27bf',
  1505. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  1506. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  1507. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  1508. rsPunctuationRange = '\\u2000-\\u206f',
  1509. rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',
  1510. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  1511. rsVarRange = '\\ufe0e\\ufe0f',
  1512. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  1513. /** Used to compose unicode capture groups. */
  1514. var rsApos = "['\u2019]",
  1515. rsAstral = '[' + rsAstralRange + ']',
  1516. rsBreak = '[' + rsBreakRange + ']',
  1517. rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',
  1518. rsDigits = '\\d+',
  1519. rsDingbat = '[' + rsDingbatRange + ']',
  1520. rsLower = '[' + rsLowerRange + ']',
  1521. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  1522. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  1523. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  1524. rsNonAstral = '[^' + rsAstralRange + ']',
  1525. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  1526. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  1527. rsUpper = '[' + rsUpperRange + ']',
  1528. rsZWJ = '\\u200d';
  1529. /** Used to compose unicode regexes. */
  1530. var rsLowerMisc = '(?:' + rsLower + '|' + rsMisc + ')',
  1531. rsUpperMisc = '(?:' + rsUpper + '|' + rsMisc + ')',
  1532. rsOptLowerContr = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  1533. rsOptUpperContr = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  1534. reOptMod = rsModifier + '?',
  1535. rsOptVar = '[' + rsVarRange + ']?',
  1536. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  1537. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  1538. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  1539. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  1540. /** Used to match apostrophes. */
  1541. var reApos = RegExp(rsApos, 'g');
  1542. /**
  1543. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  1544. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  1545. */
  1546. var reComboMark = RegExp(rsCombo, 'g');
  1547. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  1548. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  1549. /** Used to match complex or compound words. */
  1550. var reUnicodeWord = RegExp([
  1551. rsUpper + '?' + rsLower + '+' + rsOptLowerContr + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  1552. rsUpperMisc + '+' + rsOptUpperContr + '(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')',
  1553. rsUpper + '?' + rsLowerMisc + '+' + rsOptLowerContr,
  1554. rsUpper + '+' + rsOptUpperContr,
  1555. rsDigits,
  1556. rsEmoji
  1557. ].join('|'), 'g');
  1558. /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
  1559. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
  1560. /** Used to detect strings that need a more robust regexp to match words. */
  1561. var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
  1562. /** Used to map Latin Unicode letters to basic Latin letters. */
  1563. var deburredLetters = {
  1564. // Latin-1 Supplement block.
  1565. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  1566. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  1567. '\xc7': 'C', '\xe7': 'c',
  1568. '\xd0': 'D', '\xf0': 'd',
  1569. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  1570. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  1571. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  1572. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  1573. '\xd1': 'N', '\xf1': 'n',
  1574. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  1575. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  1576. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  1577. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  1578. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  1579. '\xc6': 'Ae', '\xe6': 'ae',
  1580. '\xde': 'Th', '\xfe': 'th',
  1581. '\xdf': 'ss',
  1582. // Latin Extended-A block.
  1583. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  1584. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  1585. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  1586. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  1587. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  1588. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  1589. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  1590. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  1591. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  1592. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  1593. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  1594. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  1595. '\u0134': 'J', '\u0135': 'j',
  1596. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  1597. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  1598. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  1599. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  1600. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  1601. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  1602. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  1603. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  1604. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  1605. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  1606. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  1607. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  1608. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  1609. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  1610. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  1611. '\u0174': 'W', '\u0175': 'w',
  1612. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  1613. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  1614. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  1615. '\u0132': 'IJ', '\u0133': 'ij',
  1616. '\u0152': 'Oe', '\u0153': 'oe',
  1617. '\u0149': "'n", '\u017f': 'ss'
  1618. };
  1619. /** Detect free variable `global` from Node.js. */
  1620. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  1621. /** Detect free variable `self`. */
  1622. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  1623. /** Used as a reference to the global object. */
  1624. var root = freeGlobal || freeSelf || Function('return this')();
  1625. /**
  1626. * A specialized version of `_.reduce` for arrays without support for
  1627. * iteratee shorthands.
  1628. *
  1629. * @private
  1630. * @param {Array} [array] The array to iterate over.
  1631. * @param {Function} iteratee The function invoked per iteration.
  1632. * @param {*} [accumulator] The initial value.
  1633. * @param {boolean} [initAccum] Specify using the first element of `array` as
  1634. * the initial value.
  1635. * @returns {*} Returns the accumulated value.
  1636. */
  1637. function arrayReduce(array, iteratee, accumulator, initAccum) {
  1638. var index = -1,
  1639. length = array ? array.length : 0;
  1640. if (initAccum && length) {
  1641. accumulator = array[++index];
  1642. }
  1643. while (++index < length) {
  1644. accumulator = iteratee(accumulator, array[index], index, array);
  1645. }
  1646. return accumulator;
  1647. }
  1648. /**
  1649. * Converts an ASCII `string` to an array.
  1650. *
  1651. * @private
  1652. * @param {string} string The string to convert.
  1653. * @returns {Array} Returns the converted array.
  1654. */
  1655. function asciiToArray(string) {
  1656. return string.split('');
  1657. }
  1658. /**
  1659. * Splits an ASCII `string` into an array of its words.
  1660. *
  1661. * @private
  1662. * @param {string} The string to inspect.
  1663. * @returns {Array} Returns the words of `string`.
  1664. */
  1665. function asciiWords(string) {
  1666. return string.match(reAsciiWord) || [];
  1667. }
  1668. /**
  1669. * The base implementation of `_.propertyOf` without support for deep paths.
  1670. *
  1671. * @private
  1672. * @param {Object} object The object to query.
  1673. * @returns {Function} Returns the new accessor function.
  1674. */
  1675. function basePropertyOf(object) {
  1676. return function(key) {
  1677. return object == null ? undefined : object[key];
  1678. };
  1679. }
  1680. /**
  1681. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  1682. * letters to basic Latin letters.
  1683. *
  1684. * @private
  1685. * @param {string} letter The matched letter to deburr.
  1686. * @returns {string} Returns the deburred letter.
  1687. */
  1688. var deburrLetter = basePropertyOf(deburredLetters);
  1689. /**
  1690. * Checks if `string` contains Unicode symbols.
  1691. *
  1692. * @private
  1693. * @param {string} string The string to inspect.
  1694. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  1695. */
  1696. function hasUnicode(string) {
  1697. return reHasUnicode.test(string);
  1698. }
  1699. /**
  1700. * Checks if `string` contains a word composed of Unicode symbols.
  1701. *
  1702. * @private
  1703. * @param {string} string The string to inspect.
  1704. * @returns {boolean} Returns `true` if a word is found, else `false`.
  1705. */
  1706. function hasUnicodeWord(string) {
  1707. return reHasUnicodeWord.test(string);
  1708. }
  1709. /**
  1710. * Converts `string` to an array.
  1711. *
  1712. * @private
  1713. * @param {string} string The string to convert.
  1714. * @returns {Array} Returns the converted array.
  1715. */
  1716. function stringToArray(string) {
  1717. return hasUnicode(string)
  1718. ? unicodeToArray(string)
  1719. : asciiToArray(string);
  1720. }
  1721. /**
  1722. * Converts a Unicode `string` to an array.
  1723. *
  1724. * @private
  1725. * @param {string} string The string to convert.
  1726. * @returns {Array} Returns the converted array.
  1727. */
  1728. function unicodeToArray(string) {
  1729. return string.match(reUnicode) || [];
  1730. }
  1731. /**
  1732. * Splits a Unicode `string` into an array of its words.
  1733. *
  1734. * @private
  1735. * @param {string} The string to inspect.
  1736. * @returns {Array} Returns the words of `string`.
  1737. */
  1738. function unicodeWords(string) {
  1739. return string.match(reUnicodeWord) || [];
  1740. }
  1741. /** Used for built-in method references. */
  1742. var objectProto = Object.prototype;
  1743. /**
  1744. * Used to resolve the
  1745. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  1746. * of values.
  1747. */
  1748. var objectToString = objectProto.toString;
  1749. /** Built-in value references. */
  1750. var Symbol = root.Symbol;
  1751. /** Used to convert symbols to primitives and strings. */
  1752. var symbolProto = Symbol ? Symbol.prototype : undefined,
  1753. symbolToString = symbolProto ? symbolProto.toString : undefined;
  1754. /**
  1755. * The base implementation of `_.slice` without an iteratee call guard.
  1756. *
  1757. * @private
  1758. * @param {Array} array The array to slice.
  1759. * @param {number} [start=0] The start position.
  1760. * @param {number} [end=array.length] The end position.
  1761. * @returns {Array} Returns the slice of `array`.
  1762. */
  1763. function baseSlice(array, start, end) {
  1764. var index = -1,
  1765. length = array.length;
  1766. if (start < 0) {
  1767. start = -start > length ? 0 : (length + start);
  1768. }
  1769. end = end > length ? length : end;
  1770. if (end < 0) {
  1771. end += length;
  1772. }
  1773. length = start > end ? 0 : ((end - start) >>> 0);
  1774. start >>>= 0;
  1775. var result = Array(length);
  1776. while (++index < length) {
  1777. result[index] = array[index + start];
  1778. }
  1779. return result;
  1780. }
  1781. /**
  1782. * The base implementation of `_.toString` which doesn't convert nullish
  1783. * values to empty strings.
  1784. *
  1785. * @private
  1786. * @param {*} value The value to process.
  1787. * @returns {string} Returns the string.
  1788. */
  1789. function baseToString(value) {
  1790. // Exit early for strings to avoid a performance hit in some environments.
  1791. if (typeof value == 'string') {
  1792. return value;
  1793. }
  1794. if (isSymbol(value)) {
  1795. return symbolToString ? symbolToString.call(value) : '';
  1796. }
  1797. var result = (value + '');
  1798. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  1799. }
  1800. /**
  1801. * Casts `array` to a slice if it's needed.
  1802. *
  1803. * @private
  1804. * @param {Array} array The array to inspect.
  1805. * @param {number} start The start position.
  1806. * @param {number} [end=array.length] The end position.
  1807. * @returns {Array} Returns the cast slice.
  1808. */
  1809. function castSlice(array, start, end) {
  1810. var length = array.length;
  1811. end = end === undefined ? length : end;
  1812. return (!start && end >= length) ? array : baseSlice(array, start, end);
  1813. }
  1814. /**
  1815. * Creates a function like `_.lowerFirst`.
  1816. *
  1817. * @private
  1818. * @param {string} methodName The name of the `String` case method to use.
  1819. * @returns {Function} Returns the new case function.
  1820. */
  1821. function createCaseFirst(methodName) {
  1822. return function(string) {
  1823. string = toString(string);
  1824. var strSymbols = hasUnicode(string)
  1825. ? stringToArray(string)
  1826. : undefined;
  1827. var chr = strSymbols
  1828. ? strSymbols[0]
  1829. : string.charAt(0);
  1830. var trailing = strSymbols
  1831. ? castSlice(strSymbols, 1).join('')
  1832. : string.slice(1);
  1833. return chr[methodName]() + trailing;
  1834. };
  1835. }
  1836. /**
  1837. * Creates a function like `_.camelCase`.
  1838. *
  1839. * @private
  1840. * @param {Function} callback The function to combine each word.
  1841. * @returns {Function} Returns the new compounder function.
  1842. */
  1843. function createCompounder(callback) {
  1844. return function(string) {
  1845. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  1846. };
  1847. }
  1848. /**
  1849. * Checks if `value` is object-like. A value is object-like if it's not `null`
  1850. * and has a `typeof` result of "object".
  1851. *
  1852. * @static
  1853. * @memberOf _
  1854. * @since 4.0.0
  1855. * @category Lang
  1856. * @param {*} value The value to check.
  1857. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  1858. * @example
  1859. *
  1860. * _.isObjectLike({});
  1861. * // => true
  1862. *
  1863. * _.isObjectLike([1, 2, 3]);
  1864. * // => true
  1865. *
  1866. * _.isObjectLike(_.noop);
  1867. * // => false
  1868. *
  1869. * _.isObjectLike(null);
  1870. * // => false
  1871. */
  1872. function isObjectLike(value) {
  1873. return !!value && typeof value == 'object';
  1874. }
  1875. /**
  1876. * Checks if `value` is classified as a `Symbol` primitive or object.
  1877. *
  1878. * @static
  1879. * @memberOf _
  1880. * @since 4.0.0
  1881. * @category Lang
  1882. * @param {*} value The value to check.
  1883. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  1884. * @example
  1885. *
  1886. * _.isSymbol(Symbol.iterator);
  1887. * // => true
  1888. *
  1889. * _.isSymbol('abc');
  1890. * // => false
  1891. */
  1892. function isSymbol(value) {
  1893. return typeof value == 'symbol' ||
  1894. (isObjectLike(value) && objectToString.call(value) == symbolTag);
  1895. }
  1896. /**
  1897. * Converts `value` to a string. An empty string is returned for `null`
  1898. * and `undefined` values. The sign of `-0` is preserved.
  1899. *
  1900. * @static
  1901. * @memberOf _
  1902. * @since 4.0.0
  1903. * @category Lang
  1904. * @param {*} value The value to process.
  1905. * @returns {string} Returns the string.
  1906. * @example
  1907. *
  1908. * _.toString(null);
  1909. * // => ''
  1910. *
  1911. * _.toString(-0);
  1912. * // => '-0'
  1913. *
  1914. * _.toString([1, 2, 3]);
  1915. * // => '1,2,3'
  1916. */
  1917. function toString(value) {
  1918. return value == null ? '' : baseToString(value);
  1919. }
  1920. /**
  1921. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  1922. *
  1923. * @static
  1924. * @memberOf _
  1925. * @since 3.0.0
  1926. * @category String
  1927. * @param {string} [string=''] The string to convert.
  1928. * @returns {string} Returns the camel cased string.
  1929. * @example
  1930. *
  1931. * _.camelCase('Foo Bar');
  1932. * // => 'fooBar'
  1933. *
  1934. * _.camelCase('--foo-bar--');
  1935. * // => 'fooBar'
  1936. *
  1937. * _.camelCase('__FOO_BAR__');
  1938. * // => 'fooBar'
  1939. */
  1940. var camelCase = createCompounder(function(result, word, index) {
  1941. word = word.toLowerCase();
  1942. return result + (index ? capitalize(word) : word);
  1943. });
  1944. /**
  1945. * Converts the first character of `string` to upper case and the remaining
  1946. * to lower case.
  1947. *
  1948. * @static
  1949. * @memberOf _
  1950. * @since 3.0.0
  1951. * @category String
  1952. * @param {string} [string=''] The string to capitalize.
  1953. * @returns {string} Returns the capitalized string.
  1954. * @example
  1955. *
  1956. * _.capitalize('FRED');
  1957. * // => 'Fred'
  1958. */
  1959. function capitalize(string) {
  1960. return upperFirst(toString(string).toLowerCase());
  1961. }
  1962. /**
  1963. * Deburrs `string` by converting
  1964. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  1965. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  1966. * letters to basic Latin letters and removing
  1967. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  1968. *
  1969. * @static
  1970. * @memberOf _
  1971. * @since 3.0.0
  1972. * @category String
  1973. * @param {string} [string=''] The string to deburr.
  1974. * @returns {string} Returns the deburred string.
  1975. * @example
  1976. *
  1977. * _.deburr('déjà vu');
  1978. * // => 'deja vu'
  1979. */
  1980. function deburr(string) {
  1981. string = toString(string);
  1982. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  1983. }
  1984. /**
  1985. * Converts the first character of `string` to upper case.
  1986. *
  1987. * @static
  1988. * @memberOf _
  1989. * @since 4.0.0
  1990. * @category String
  1991. * @param {string} [string=''] The string to convert.
  1992. * @returns {string} Returns the converted string.
  1993. * @example
  1994. *
  1995. * _.upperFirst('fred');
  1996. * // => 'Fred'
  1997. *
  1998. * _.upperFirst('FRED');
  1999. * // => 'FRED'
  2000. */
  2001. var upperFirst = createCaseFirst('toUpperCase');
  2002. /**
  2003. * Splits `string` into an array of its words.
  2004. *
  2005. * @static
  2006. * @memberOf _
  2007. * @since 3.0.0
  2008. * @category String
  2009. * @param {string} [string=''] The string to inspect.
  2010. * @param {RegExp|string} [pattern] The pattern to match words.
  2011. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  2012. * @returns {Array} Returns the words of `string`.
  2013. * @example
  2014. *
  2015. * _.words('fred, barney, & pebbles');
  2016. * // => ['fred', 'barney', 'pebbles']
  2017. *
  2018. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  2019. * // => ['fred', 'barney', '&', 'pebbles']
  2020. */
  2021. function words(string, pattern, guard) {
  2022. string = toString(string);
  2023. pattern = guard ? undefined : pattern;
  2024. if (pattern === undefined) {
  2025. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  2026. }
  2027. return string.match(pattern) || [];
  2028. }
  2029. module.exports = camelCase;
  2030. /***/ }),
  2031. /***/ 51633:
  2032. /***/ ((module) => {
  2033. /**
  2034. * lodash (Custom Build) <https://lodash.com/>
  2035. * Build: `lodash modularize exports="npm" -o ./`
  2036. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  2037. * Released under MIT license <https://lodash.com/license>
  2038. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  2039. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  2040. */
  2041. /** Used as references for various `Number` constants. */
  2042. var INFINITY = 1 / 0;
  2043. /** `Object#toString` result references. */
  2044. var symbolTag = '[object Symbol]';
  2045. /** Used to compose unicode character classes. */
  2046. var rsAstralRange = '\\ud800-\\udfff',
  2047. rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
  2048. rsComboSymbolsRange = '\\u20d0-\\u20f0',
  2049. rsVarRange = '\\ufe0e\\ufe0f';
  2050. /** Used to compose unicode capture groups. */
  2051. var rsAstral = '[' + rsAstralRange + ']',
  2052. rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',
  2053. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  2054. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  2055. rsNonAstral = '[^' + rsAstralRange + ']',
  2056. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  2057. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  2058. rsZWJ = '\\u200d';
  2059. /** Used to compose unicode regexes. */
  2060. var reOptMod = rsModifier + '?',
  2061. rsOptVar = '[' + rsVarRange + ']?',
  2062. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  2063. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  2064. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  2065. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  2066. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  2067. /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
  2068. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
  2069. /** Detect free variable `global` from Node.js. */
  2070. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  2071. /** Detect free variable `self`. */
  2072. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  2073. /** Used as a reference to the global object. */
  2074. var root = freeGlobal || freeSelf || Function('return this')();
  2075. /**
  2076. * Converts an ASCII `string` to an array.
  2077. *
  2078. * @private
  2079. * @param {string} string The string to convert.
  2080. * @returns {Array} Returns the converted array.
  2081. */
  2082. function asciiToArray(string) {
  2083. return string.split('');
  2084. }
  2085. /**
  2086. * Checks if `string` contains Unicode symbols.
  2087. *
  2088. * @private
  2089. * @param {string} string The string to inspect.
  2090. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  2091. */
  2092. function hasUnicode(string) {
  2093. return reHasUnicode.test(string);
  2094. }
  2095. /**
  2096. * Converts `string` to an array.
  2097. *
  2098. * @private
  2099. * @param {string} string The string to convert.
  2100. * @returns {Array} Returns the converted array.
  2101. */
  2102. function stringToArray(string) {
  2103. return hasUnicode(string)
  2104. ? unicodeToArray(string)
  2105. : asciiToArray(string);
  2106. }
  2107. /**
  2108. * Converts a Unicode `string` to an array.
  2109. *
  2110. * @private
  2111. * @param {string} string The string to convert.
  2112. * @returns {Array} Returns the converted array.
  2113. */
  2114. function unicodeToArray(string) {
  2115. return string.match(reUnicode) || [];
  2116. }
  2117. /** Used for built-in method references. */
  2118. var objectProto = Object.prototype;
  2119. /**
  2120. * Used to resolve the
  2121. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  2122. * of values.
  2123. */
  2124. var objectToString = objectProto.toString;
  2125. /** Built-in value references. */
  2126. var Symbol = root.Symbol;
  2127. /** Used to convert symbols to primitives and strings. */
  2128. var symbolProto = Symbol ? Symbol.prototype : undefined,
  2129. symbolToString = symbolProto ? symbolProto.toString : undefined;
  2130. /**
  2131. * The base implementation of `_.slice` without an iteratee call guard.
  2132. *
  2133. * @private
  2134. * @param {Array} array The array to slice.
  2135. * @param {number} [start=0] The start position.
  2136. * @param {number} [end=array.length] The end position.
  2137. * @returns {Array} Returns the slice of `array`.
  2138. */
  2139. function baseSlice(array, start, end) {
  2140. var index = -1,
  2141. length = array.length;
  2142. if (start < 0) {
  2143. start = -start > length ? 0 : (length + start);
  2144. }
  2145. end = end > length ? length : end;
  2146. if (end < 0) {
  2147. end += length;
  2148. }
  2149. length = start > end ? 0 : ((end - start) >>> 0);
  2150. start >>>= 0;
  2151. var result = Array(length);
  2152. while (++index < length) {
  2153. result[index] = array[index + start];
  2154. }
  2155. return result;
  2156. }
  2157. /**
  2158. * The base implementation of `_.toString` which doesn't convert nullish
  2159. * values to empty strings.
  2160. *
  2161. * @private
  2162. * @param {*} value The value to process.
  2163. * @returns {string} Returns the string.
  2164. */
  2165. function baseToString(value) {
  2166. // Exit early for strings to avoid a performance hit in some environments.
  2167. if (typeof value == 'string') {
  2168. return value;
  2169. }
  2170. if (isSymbol(value)) {
  2171. return symbolToString ? symbolToString.call(value) : '';
  2172. }
  2173. var result = (value + '');
  2174. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  2175. }
  2176. /**
  2177. * Casts `array` to a slice if it's needed.
  2178. *
  2179. * @private
  2180. * @param {Array} array The array to inspect.
  2181. * @param {number} start The start position.
  2182. * @param {number} [end=array.length] The end position.
  2183. * @returns {Array} Returns the cast slice.
  2184. */
  2185. function castSlice(array, start, end) {
  2186. var length = array.length;
  2187. end = end === undefined ? length : end;
  2188. return (!start && end >= length) ? array : baseSlice(array, start, end);
  2189. }
  2190. /**
  2191. * Creates a function like `_.lowerFirst`.
  2192. *
  2193. * @private
  2194. * @param {string} methodName The name of the `String` case method to use.
  2195. * @returns {Function} Returns the new case function.
  2196. */
  2197. function createCaseFirst(methodName) {
  2198. return function(string) {
  2199. string = toString(string);
  2200. var strSymbols = hasUnicode(string)
  2201. ? stringToArray(string)
  2202. : undefined;
  2203. var chr = strSymbols
  2204. ? strSymbols[0]
  2205. : string.charAt(0);
  2206. var trailing = strSymbols
  2207. ? castSlice(strSymbols, 1).join('')
  2208. : string.slice(1);
  2209. return chr[methodName]() + trailing;
  2210. };
  2211. }
  2212. /**
  2213. * Checks if `value` is object-like. A value is object-like if it's not `null`
  2214. * and has a `typeof` result of "object".
  2215. *
  2216. * @static
  2217. * @memberOf _
  2218. * @since 4.0.0
  2219. * @category Lang
  2220. * @param {*} value The value to check.
  2221. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  2222. * @example
  2223. *
  2224. * _.isObjectLike({});
  2225. * // => true
  2226. *
  2227. * _.isObjectLike([1, 2, 3]);
  2228. * // => true
  2229. *
  2230. * _.isObjectLike(_.noop);
  2231. * // => false
  2232. *
  2233. * _.isObjectLike(null);
  2234. * // => false
  2235. */
  2236. function isObjectLike(value) {
  2237. return !!value && typeof value == 'object';
  2238. }
  2239. /**
  2240. * Checks if `value` is classified as a `Symbol` primitive or object.
  2241. *
  2242. * @static
  2243. * @memberOf _
  2244. * @since 4.0.0
  2245. * @category Lang
  2246. * @param {*} value The value to check.
  2247. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  2248. * @example
  2249. *
  2250. * _.isSymbol(Symbol.iterator);
  2251. * // => true
  2252. *
  2253. * _.isSymbol('abc');
  2254. * // => false
  2255. */
  2256. function isSymbol(value) {
  2257. return typeof value == 'symbol' ||
  2258. (isObjectLike(value) && objectToString.call(value) == symbolTag);
  2259. }
  2260. /**
  2261. * Converts `value` to a string. An empty string is returned for `null`
  2262. * and `undefined` values. The sign of `-0` is preserved.
  2263. *
  2264. * @static
  2265. * @memberOf _
  2266. * @since 4.0.0
  2267. * @category Lang
  2268. * @param {*} value The value to process.
  2269. * @returns {string} Returns the string.
  2270. * @example
  2271. *
  2272. * _.toString(null);
  2273. * // => ''
  2274. *
  2275. * _.toString(-0);
  2276. * // => '-0'
  2277. *
  2278. * _.toString([1, 2, 3]);
  2279. * // => '1,2,3'
  2280. */
  2281. function toString(value) {
  2282. return value == null ? '' : baseToString(value);
  2283. }
  2284. /**
  2285. * Converts the first character of `string` to upper case and the remaining
  2286. * to lower case.
  2287. *
  2288. * @static
  2289. * @memberOf _
  2290. * @since 3.0.0
  2291. * @category String
  2292. * @param {string} [string=''] The string to capitalize.
  2293. * @returns {string} Returns the capitalized string.
  2294. * @example
  2295. *
  2296. * _.capitalize('FRED');
  2297. * // => 'Fred'
  2298. */
  2299. function capitalize(string) {
  2300. return upperFirst(toString(string).toLowerCase());
  2301. }
  2302. /**
  2303. * Converts the first character of `string` to upper case.
  2304. *
  2305. * @static
  2306. * @memberOf _
  2307. * @since 4.0.0
  2308. * @category String
  2309. * @param {string} [string=''] The string to convert.
  2310. * @returns {string} Returns the converted string.
  2311. * @example
  2312. *
  2313. * _.upperFirst('fred');
  2314. * // => 'Fred'
  2315. *
  2316. * _.upperFirst('FRED');
  2317. * // => 'FRED'
  2318. */
  2319. var upperFirst = createCaseFirst('toUpperCase');
  2320. module.exports = capitalize;
  2321. /***/ }),
  2322. /***/ 75316:
  2323. /***/ ((module, exports, __webpack_require__) => {
  2324. /* module decorator */ module = __webpack_require__.nmd(module);
  2325. /**
  2326. * lodash (Custom Build) <https://lodash.com/>
  2327. * Build: `lodash modularize exports="npm" -o ./`
  2328. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  2329. * Released under MIT license <https://lodash.com/license>
  2330. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  2331. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  2332. */
  2333. /** Used as the size to enable large array optimizations. */
  2334. var LARGE_ARRAY_SIZE = 200;
  2335. /** Used as the `TypeError` message for "Functions" methods. */
  2336. var FUNC_ERROR_TEXT = 'Expected a function';
  2337. /** Used to stand-in for `undefined` hash values. */
  2338. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  2339. /** Used to compose bitmasks for comparison styles. */
  2340. var UNORDERED_COMPARE_FLAG = 1,
  2341. PARTIAL_COMPARE_FLAG = 2;
  2342. /** Used as references for various `Number` constants. */
  2343. var INFINITY = 1 / 0,
  2344. MAX_SAFE_INTEGER = 9007199254740991;
  2345. /** `Object#toString` result references. */
  2346. var argsTag = '[object Arguments]',
  2347. arrayTag = '[object Array]',
  2348. boolTag = '[object Boolean]',
  2349. dateTag = '[object Date]',
  2350. errorTag = '[object Error]',
  2351. funcTag = '[object Function]',
  2352. genTag = '[object GeneratorFunction]',
  2353. mapTag = '[object Map]',
  2354. numberTag = '[object Number]',
  2355. objectTag = '[object Object]',
  2356. promiseTag = '[object Promise]',
  2357. regexpTag = '[object RegExp]',
  2358. setTag = '[object Set]',
  2359. stringTag = '[object String]',
  2360. symbolTag = '[object Symbol]',
  2361. weakMapTag = '[object WeakMap]';
  2362. var arrayBufferTag = '[object ArrayBuffer]',
  2363. dataViewTag = '[object DataView]',
  2364. float32Tag = '[object Float32Array]',
  2365. float64Tag = '[object Float64Array]',
  2366. int8Tag = '[object Int8Array]',
  2367. int16Tag = '[object Int16Array]',
  2368. int32Tag = '[object Int32Array]',
  2369. uint8Tag = '[object Uint8Array]',
  2370. uint8ClampedTag = '[object Uint8ClampedArray]',
  2371. uint16Tag = '[object Uint16Array]',
  2372. uint32Tag = '[object Uint32Array]';
  2373. /** Used to match property names within property paths. */
  2374. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  2375. reIsPlainProp = /^\w*$/,
  2376. reLeadingDot = /^\./,
  2377. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  2378. /**
  2379. * Used to match `RegExp`
  2380. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  2381. */
  2382. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  2383. /** Used to match backslashes in property paths. */
  2384. var reEscapeChar = /\\(\\)?/g;
  2385. /** Used to detect host constructors (Safari). */
  2386. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  2387. /** Used to detect unsigned integer values. */
  2388. var reIsUint = /^(?:0|[1-9]\d*)$/;
  2389. /** Used to identify `toStringTag` values of typed arrays. */
  2390. var typedArrayTags = {};
  2391. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  2392. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  2393. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  2394. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  2395. typedArrayTags[uint32Tag] = true;
  2396. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  2397. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  2398. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  2399. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  2400. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  2401. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  2402. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  2403. typedArrayTags[weakMapTag] = false;
  2404. /** Detect free variable `global` from Node.js. */
  2405. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  2406. /** Detect free variable `self`. */
  2407. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  2408. /** Used as a reference to the global object. */
  2409. var root = freeGlobal || freeSelf || Function('return this')();
  2410. /** Detect free variable `exports`. */
  2411. var freeExports = true && exports && !exports.nodeType && exports;
  2412. /** Detect free variable `module`. */
  2413. var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module;
  2414. /** Detect the popular CommonJS extension `module.exports`. */
  2415. var moduleExports = freeModule && freeModule.exports === freeExports;
  2416. /** Detect free variable `process` from Node.js. */
  2417. var freeProcess = moduleExports && freeGlobal.process;
  2418. /** Used to access faster Node.js helpers. */
  2419. var nodeUtil = (function() {
  2420. try {
  2421. return freeProcess && freeProcess.binding('util');
  2422. } catch (e) {}
  2423. }());
  2424. /* Node.js helper references. */
  2425. var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  2426. /**
  2427. * A specialized version of `_.map` for arrays without support for iteratee
  2428. * shorthands.
  2429. *
  2430. * @private
  2431. * @param {Array} [array] The array to iterate over.
  2432. * @param {Function} iteratee The function invoked per iteration.
  2433. * @returns {Array} Returns the new mapped array.
  2434. */
  2435. function arrayMap(array, iteratee) {
  2436. var index = -1,
  2437. length = array ? array.length : 0,
  2438. result = Array(length);
  2439. while (++index < length) {
  2440. result[index] = iteratee(array[index], index, array);
  2441. }
  2442. return result;
  2443. }
  2444. /**
  2445. * A specialized version of `_.some` for arrays without support for iteratee
  2446. * shorthands.
  2447. *
  2448. * @private
  2449. * @param {Array} [array] The array to iterate over.
  2450. * @param {Function} predicate The function invoked per iteration.
  2451. * @returns {boolean} Returns `true` if any element passes the predicate check,
  2452. * else `false`.
  2453. */
  2454. function arraySome(array, predicate) {
  2455. var index = -1,
  2456. length = array ? array.length : 0;
  2457. while (++index < length) {
  2458. if (predicate(array[index], index, array)) {
  2459. return true;
  2460. }
  2461. }
  2462. return false;
  2463. }
  2464. /**
  2465. * The base implementation of `_.property` without support for deep paths.
  2466. *
  2467. * @private
  2468. * @param {string} key The key of the property to get.
  2469. * @returns {Function} Returns the new accessor function.
  2470. */
  2471. function baseProperty(key) {
  2472. return function(object) {
  2473. return object == null ? undefined : object[key];
  2474. };
  2475. }
  2476. /**
  2477. * The base implementation of `_.sortBy` which uses `comparer` to define the
  2478. * sort order of `array` and replaces criteria objects with their corresponding
  2479. * values.
  2480. *
  2481. * @private
  2482. * @param {Array} array The array to sort.
  2483. * @param {Function} comparer The function to define sort order.
  2484. * @returns {Array} Returns `array`.
  2485. */
  2486. function baseSortBy(array, comparer) {
  2487. var length = array.length;
  2488. array.sort(comparer);
  2489. while (length--) {
  2490. array[length] = array[length].value;
  2491. }
  2492. return array;
  2493. }
  2494. /**
  2495. * The base implementation of `_.times` without support for iteratee shorthands
  2496. * or max array length checks.
  2497. *
  2498. * @private
  2499. * @param {number} n The number of times to invoke `iteratee`.
  2500. * @param {Function} iteratee The function invoked per iteration.
  2501. * @returns {Array} Returns the array of results.
  2502. */
  2503. function baseTimes(n, iteratee) {
  2504. var index = -1,
  2505. result = Array(n);
  2506. while (++index < n) {
  2507. result[index] = iteratee(index);
  2508. }
  2509. return result;
  2510. }
  2511. /**
  2512. * The base implementation of `_.unary` without support for storing metadata.
  2513. *
  2514. * @private
  2515. * @param {Function} func The function to cap arguments for.
  2516. * @returns {Function} Returns the new capped function.
  2517. */
  2518. function baseUnary(func) {
  2519. return function(value) {
  2520. return func(value);
  2521. };
  2522. }
  2523. /**
  2524. * Gets the value at `key` of `object`.
  2525. *
  2526. * @private
  2527. * @param {Object} [object] The object to query.
  2528. * @param {string} key The key of the property to get.
  2529. * @returns {*} Returns the property value.
  2530. */
  2531. function getValue(object, key) {
  2532. return object == null ? undefined : object[key];
  2533. }
  2534. /**
  2535. * Checks if `value` is a host object in IE < 9.
  2536. *
  2537. * @private
  2538. * @param {*} value The value to check.
  2539. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  2540. */
  2541. function isHostObject(value) {
  2542. // Many host objects are `Object` objects that can coerce to strings
  2543. // despite having improperly defined `toString` methods.
  2544. var result = false;
  2545. if (value != null && typeof value.toString != 'function') {
  2546. try {
  2547. result = !!(value + '');
  2548. } catch (e) {}
  2549. }
  2550. return result;
  2551. }
  2552. /**
  2553. * Converts `map` to its key-value pairs.
  2554. *
  2555. * @private
  2556. * @param {Object} map The map to convert.
  2557. * @returns {Array} Returns the key-value pairs.
  2558. */
  2559. function mapToArray(map) {
  2560. var index = -1,
  2561. result = Array(map.size);
  2562. map.forEach(function(value, key) {
  2563. result[++index] = [key, value];
  2564. });
  2565. return result;
  2566. }
  2567. /**
  2568. * Creates a unary function that invokes `func` with its argument transformed.
  2569. *
  2570. * @private
  2571. * @param {Function} func The function to wrap.
  2572. * @param {Function} transform The argument transform.
  2573. * @returns {Function} Returns the new function.
  2574. */
  2575. function overArg(func, transform) {
  2576. return function(arg) {
  2577. return func(transform(arg));
  2578. };
  2579. }
  2580. /**
  2581. * Converts `set` to an array of its values.
  2582. *
  2583. * @private
  2584. * @param {Object} set The set to convert.
  2585. * @returns {Array} Returns the values.
  2586. */
  2587. function setToArray(set) {
  2588. var index = -1,
  2589. result = Array(set.size);
  2590. set.forEach(function(value) {
  2591. result[++index] = value;
  2592. });
  2593. return result;
  2594. }
  2595. /** Used for built-in method references. */
  2596. var arrayProto = Array.prototype,
  2597. funcProto = Function.prototype,
  2598. objectProto = Object.prototype;
  2599. /** Used to detect overreaching core-js shims. */
  2600. var coreJsData = root['__core-js_shared__'];
  2601. /** Used to detect methods masquerading as native. */
  2602. var maskSrcKey = (function() {
  2603. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  2604. return uid ? ('Symbol(src)_1.' + uid) : '';
  2605. }());
  2606. /** Used to resolve the decompiled source of functions. */
  2607. var funcToString = funcProto.toString;
  2608. /** Used to check objects for own properties. */
  2609. var hasOwnProperty = objectProto.hasOwnProperty;
  2610. /**
  2611. * Used to resolve the
  2612. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  2613. * of values.
  2614. */
  2615. var objectToString = objectProto.toString;
  2616. /** Used to detect if a method is native. */
  2617. var reIsNative = RegExp('^' +
  2618. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  2619. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  2620. );
  2621. /** Built-in value references. */
  2622. var Symbol = root.Symbol,
  2623. Uint8Array = root.Uint8Array,
  2624. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  2625. splice = arrayProto.splice;
  2626. /* Built-in method references for those with the same name as other `lodash` methods. */
  2627. var nativeKeys = overArg(Object.keys, Object);
  2628. /* Built-in method references that are verified to be native. */
  2629. var DataView = getNative(root, 'DataView'),
  2630. Map = getNative(root, 'Map'),
  2631. Promise = getNative(root, 'Promise'),
  2632. Set = getNative(root, 'Set'),
  2633. WeakMap = getNative(root, 'WeakMap'),
  2634. nativeCreate = getNative(Object, 'create');
  2635. /** Used to detect maps, sets, and weakmaps. */
  2636. var dataViewCtorString = toSource(DataView),
  2637. mapCtorString = toSource(Map),
  2638. promiseCtorString = toSource(Promise),
  2639. setCtorString = toSource(Set),
  2640. weakMapCtorString = toSource(WeakMap);
  2641. /** Used to convert symbols to primitives and strings. */
  2642. var symbolProto = Symbol ? Symbol.prototype : undefined,
  2643. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  2644. symbolToString = symbolProto ? symbolProto.toString : undefined;
  2645. /**
  2646. * Creates a hash object.
  2647. *
  2648. * @private
  2649. * @constructor
  2650. * @param {Array} [entries] The key-value pairs to cache.
  2651. */
  2652. function Hash(entries) {
  2653. var index = -1,
  2654. length = entries ? entries.length : 0;
  2655. this.clear();
  2656. while (++index < length) {
  2657. var entry = entries[index];
  2658. this.set(entry[0], entry[1]);
  2659. }
  2660. }
  2661. /**
  2662. * Removes all key-value entries from the hash.
  2663. *
  2664. * @private
  2665. * @name clear
  2666. * @memberOf Hash
  2667. */
  2668. function hashClear() {
  2669. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  2670. }
  2671. /**
  2672. * Removes `key` and its value from the hash.
  2673. *
  2674. * @private
  2675. * @name delete
  2676. * @memberOf Hash
  2677. * @param {Object} hash The hash to modify.
  2678. * @param {string} key The key of the value to remove.
  2679. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2680. */
  2681. function hashDelete(key) {
  2682. return this.has(key) && delete this.__data__[key];
  2683. }
  2684. /**
  2685. * Gets the hash value for `key`.
  2686. *
  2687. * @private
  2688. * @name get
  2689. * @memberOf Hash
  2690. * @param {string} key The key of the value to get.
  2691. * @returns {*} Returns the entry value.
  2692. */
  2693. function hashGet(key) {
  2694. var data = this.__data__;
  2695. if (nativeCreate) {
  2696. var result = data[key];
  2697. return result === HASH_UNDEFINED ? undefined : result;
  2698. }
  2699. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  2700. }
  2701. /**
  2702. * Checks if a hash value for `key` exists.
  2703. *
  2704. * @private
  2705. * @name has
  2706. * @memberOf Hash
  2707. * @param {string} key The key of the entry to check.
  2708. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2709. */
  2710. function hashHas(key) {
  2711. var data = this.__data__;
  2712. return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
  2713. }
  2714. /**
  2715. * Sets the hash `key` to `value`.
  2716. *
  2717. * @private
  2718. * @name set
  2719. * @memberOf Hash
  2720. * @param {string} key The key of the value to set.
  2721. * @param {*} value The value to set.
  2722. * @returns {Object} Returns the hash instance.
  2723. */
  2724. function hashSet(key, value) {
  2725. var data = this.__data__;
  2726. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  2727. return this;
  2728. }
  2729. // Add methods to `Hash`.
  2730. Hash.prototype.clear = hashClear;
  2731. Hash.prototype['delete'] = hashDelete;
  2732. Hash.prototype.get = hashGet;
  2733. Hash.prototype.has = hashHas;
  2734. Hash.prototype.set = hashSet;
  2735. /**
  2736. * Creates an list cache object.
  2737. *
  2738. * @private
  2739. * @constructor
  2740. * @param {Array} [entries] The key-value pairs to cache.
  2741. */
  2742. function ListCache(entries) {
  2743. var index = -1,
  2744. length = entries ? entries.length : 0;
  2745. this.clear();
  2746. while (++index < length) {
  2747. var entry = entries[index];
  2748. this.set(entry[0], entry[1]);
  2749. }
  2750. }
  2751. /**
  2752. * Removes all key-value entries from the list cache.
  2753. *
  2754. * @private
  2755. * @name clear
  2756. * @memberOf ListCache
  2757. */
  2758. function listCacheClear() {
  2759. this.__data__ = [];
  2760. }
  2761. /**
  2762. * Removes `key` and its value from the list cache.
  2763. *
  2764. * @private
  2765. * @name delete
  2766. * @memberOf ListCache
  2767. * @param {string} key The key of the value to remove.
  2768. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2769. */
  2770. function listCacheDelete(key) {
  2771. var data = this.__data__,
  2772. index = assocIndexOf(data, key);
  2773. if (index < 0) {
  2774. return false;
  2775. }
  2776. var lastIndex = data.length - 1;
  2777. if (index == lastIndex) {
  2778. data.pop();
  2779. } else {
  2780. splice.call(data, index, 1);
  2781. }
  2782. return true;
  2783. }
  2784. /**
  2785. * Gets the list cache value for `key`.
  2786. *
  2787. * @private
  2788. * @name get
  2789. * @memberOf ListCache
  2790. * @param {string} key The key of the value to get.
  2791. * @returns {*} Returns the entry value.
  2792. */
  2793. function listCacheGet(key) {
  2794. var data = this.__data__,
  2795. index = assocIndexOf(data, key);
  2796. return index < 0 ? undefined : data[index][1];
  2797. }
  2798. /**
  2799. * Checks if a list cache value for `key` exists.
  2800. *
  2801. * @private
  2802. * @name has
  2803. * @memberOf ListCache
  2804. * @param {string} key The key of the entry to check.
  2805. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2806. */
  2807. function listCacheHas(key) {
  2808. return assocIndexOf(this.__data__, key) > -1;
  2809. }
  2810. /**
  2811. * Sets the list cache `key` to `value`.
  2812. *
  2813. * @private
  2814. * @name set
  2815. * @memberOf ListCache
  2816. * @param {string} key The key of the value to set.
  2817. * @param {*} value The value to set.
  2818. * @returns {Object} Returns the list cache instance.
  2819. */
  2820. function listCacheSet(key, value) {
  2821. var data = this.__data__,
  2822. index = assocIndexOf(data, key);
  2823. if (index < 0) {
  2824. data.push([key, value]);
  2825. } else {
  2826. data[index][1] = value;
  2827. }
  2828. return this;
  2829. }
  2830. // Add methods to `ListCache`.
  2831. ListCache.prototype.clear = listCacheClear;
  2832. ListCache.prototype['delete'] = listCacheDelete;
  2833. ListCache.prototype.get = listCacheGet;
  2834. ListCache.prototype.has = listCacheHas;
  2835. ListCache.prototype.set = listCacheSet;
  2836. /**
  2837. * Creates a map cache object to store key-value pairs.
  2838. *
  2839. * @private
  2840. * @constructor
  2841. * @param {Array} [entries] The key-value pairs to cache.
  2842. */
  2843. function MapCache(entries) {
  2844. var index = -1,
  2845. length = entries ? entries.length : 0;
  2846. this.clear();
  2847. while (++index < length) {
  2848. var entry = entries[index];
  2849. this.set(entry[0], entry[1]);
  2850. }
  2851. }
  2852. /**
  2853. * Removes all key-value entries from the map.
  2854. *
  2855. * @private
  2856. * @name clear
  2857. * @memberOf MapCache
  2858. */
  2859. function mapCacheClear() {
  2860. this.__data__ = {
  2861. 'hash': new Hash,
  2862. 'map': new (Map || ListCache),
  2863. 'string': new Hash
  2864. };
  2865. }
  2866. /**
  2867. * Removes `key` and its value from the map.
  2868. *
  2869. * @private
  2870. * @name delete
  2871. * @memberOf MapCache
  2872. * @param {string} key The key of the value to remove.
  2873. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2874. */
  2875. function mapCacheDelete(key) {
  2876. return getMapData(this, key)['delete'](key);
  2877. }
  2878. /**
  2879. * Gets the map value for `key`.
  2880. *
  2881. * @private
  2882. * @name get
  2883. * @memberOf MapCache
  2884. * @param {string} key The key of the value to get.
  2885. * @returns {*} Returns the entry value.
  2886. */
  2887. function mapCacheGet(key) {
  2888. return getMapData(this, key).get(key);
  2889. }
  2890. /**
  2891. * Checks if a map value for `key` exists.
  2892. *
  2893. * @private
  2894. * @name has
  2895. * @memberOf MapCache
  2896. * @param {string} key The key of the entry to check.
  2897. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2898. */
  2899. function mapCacheHas(key) {
  2900. return getMapData(this, key).has(key);
  2901. }
  2902. /**
  2903. * Sets the map `key` to `value`.
  2904. *
  2905. * @private
  2906. * @name set
  2907. * @memberOf MapCache
  2908. * @param {string} key The key of the value to set.
  2909. * @param {*} value The value to set.
  2910. * @returns {Object} Returns the map cache instance.
  2911. */
  2912. function mapCacheSet(key, value) {
  2913. getMapData(this, key).set(key, value);
  2914. return this;
  2915. }
  2916. // Add methods to `MapCache`.
  2917. MapCache.prototype.clear = mapCacheClear;
  2918. MapCache.prototype['delete'] = mapCacheDelete;
  2919. MapCache.prototype.get = mapCacheGet;
  2920. MapCache.prototype.has = mapCacheHas;
  2921. MapCache.prototype.set = mapCacheSet;
  2922. /**
  2923. *
  2924. * Creates an array cache object to store unique values.
  2925. *
  2926. * @private
  2927. * @constructor
  2928. * @param {Array} [values] The values to cache.
  2929. */
  2930. function SetCache(values) {
  2931. var index = -1,
  2932. length = values ? values.length : 0;
  2933. this.__data__ = new MapCache;
  2934. while (++index < length) {
  2935. this.add(values[index]);
  2936. }
  2937. }
  2938. /**
  2939. * Adds `value` to the array cache.
  2940. *
  2941. * @private
  2942. * @name add
  2943. * @memberOf SetCache
  2944. * @alias push
  2945. * @param {*} value The value to cache.
  2946. * @returns {Object} Returns the cache instance.
  2947. */
  2948. function setCacheAdd(value) {
  2949. this.__data__.set(value, HASH_UNDEFINED);
  2950. return this;
  2951. }
  2952. /**
  2953. * Checks if `value` is in the array cache.
  2954. *
  2955. * @private
  2956. * @name has
  2957. * @memberOf SetCache
  2958. * @param {*} value The value to search for.
  2959. * @returns {number} Returns `true` if `value` is found, else `false`.
  2960. */
  2961. function setCacheHas(value) {
  2962. return this.__data__.has(value);
  2963. }
  2964. // Add methods to `SetCache`.
  2965. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  2966. SetCache.prototype.has = setCacheHas;
  2967. /**
  2968. * Creates a stack cache object to store key-value pairs.
  2969. *
  2970. * @private
  2971. * @constructor
  2972. * @param {Array} [entries] The key-value pairs to cache.
  2973. */
  2974. function Stack(entries) {
  2975. this.__data__ = new ListCache(entries);
  2976. }
  2977. /**
  2978. * Removes all key-value entries from the stack.
  2979. *
  2980. * @private
  2981. * @name clear
  2982. * @memberOf Stack
  2983. */
  2984. function stackClear() {
  2985. this.__data__ = new ListCache;
  2986. }
  2987. /**
  2988. * Removes `key` and its value from the stack.
  2989. *
  2990. * @private
  2991. * @name delete
  2992. * @memberOf Stack
  2993. * @param {string} key The key of the value to remove.
  2994. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2995. */
  2996. function stackDelete(key) {
  2997. return this.__data__['delete'](key);
  2998. }
  2999. /**
  3000. * Gets the stack value for `key`.
  3001. *
  3002. * @private
  3003. * @name get
  3004. * @memberOf Stack
  3005. * @param {string} key The key of the value to get.
  3006. * @returns {*} Returns the entry value.
  3007. */
  3008. function stackGet(key) {
  3009. return this.__data__.get(key);
  3010. }
  3011. /**
  3012. * Checks if a stack value for `key` exists.
  3013. *
  3014. * @private
  3015. * @name has
  3016. * @memberOf Stack
  3017. * @param {string} key The key of the entry to check.
  3018. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  3019. */
  3020. function stackHas(key) {
  3021. return this.__data__.has(key);
  3022. }
  3023. /**
  3024. * Sets the stack `key` to `value`.
  3025. *
  3026. * @private
  3027. * @name set
  3028. * @memberOf Stack
  3029. * @param {string} key The key of the value to set.
  3030. * @param {*} value The value to set.
  3031. * @returns {Object} Returns the stack cache instance.
  3032. */
  3033. function stackSet(key, value) {
  3034. var cache = this.__data__;
  3035. if (cache instanceof ListCache) {
  3036. var pairs = cache.__data__;
  3037. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  3038. pairs.push([key, value]);
  3039. return this;
  3040. }
  3041. cache = this.__data__ = new MapCache(pairs);
  3042. }
  3043. cache.set(key, value);
  3044. return this;
  3045. }
  3046. // Add methods to `Stack`.
  3047. Stack.prototype.clear = stackClear;
  3048. Stack.prototype['delete'] = stackDelete;
  3049. Stack.prototype.get = stackGet;
  3050. Stack.prototype.has = stackHas;
  3051. Stack.prototype.set = stackSet;
  3052. /**
  3053. * Creates an array of the enumerable property names of the array-like `value`.
  3054. *
  3055. * @private
  3056. * @param {*} value The value to query.
  3057. * @param {boolean} inherited Specify returning inherited property names.
  3058. * @returns {Array} Returns the array of property names.
  3059. */
  3060. function arrayLikeKeys(value, inherited) {
  3061. // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
  3062. // Safari 9 makes `arguments.length` enumerable in strict mode.
  3063. var result = (isArray(value) || isArguments(value))
  3064. ? baseTimes(value.length, String)
  3065. : [];
  3066. var length = result.length,
  3067. skipIndexes = !!length;
  3068. for (var key in value) {
  3069. if ((inherited || hasOwnProperty.call(value, key)) &&
  3070. !(skipIndexes && (key == 'length' || isIndex(key, length)))) {
  3071. result.push(key);
  3072. }
  3073. }
  3074. return result;
  3075. }
  3076. /**
  3077. * Gets the index at which the `key` is found in `array` of key-value pairs.
  3078. *
  3079. * @private
  3080. * @param {Array} array The array to inspect.
  3081. * @param {*} key The key to search for.
  3082. * @returns {number} Returns the index of the matched value, else `-1`.
  3083. */
  3084. function assocIndexOf(array, key) {
  3085. var length = array.length;
  3086. while (length--) {
  3087. if (eq(array[length][0], key)) {
  3088. return length;
  3089. }
  3090. }
  3091. return -1;
  3092. }
  3093. /**
  3094. * The base implementation of `_.forEach` without support for iteratee shorthands.
  3095. *
  3096. * @private
  3097. * @param {Array|Object} collection The collection to iterate over.
  3098. * @param {Function} iteratee The function invoked per iteration.
  3099. * @returns {Array|Object} Returns `collection`.
  3100. */
  3101. var baseEach = createBaseEach(baseForOwn);
  3102. /**
  3103. * The base implementation of `baseForOwn` which iterates over `object`
  3104. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  3105. * Iteratee functions may exit iteration early by explicitly returning `false`.
  3106. *
  3107. * @private
  3108. * @param {Object} object The object to iterate over.
  3109. * @param {Function} iteratee The function invoked per iteration.
  3110. * @param {Function} keysFunc The function to get the keys of `object`.
  3111. * @returns {Object} Returns `object`.
  3112. */
  3113. var baseFor = createBaseFor();
  3114. /**
  3115. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  3116. *
  3117. * @private
  3118. * @param {Object} object The object to iterate over.
  3119. * @param {Function} iteratee The function invoked per iteration.
  3120. * @returns {Object} Returns `object`.
  3121. */
  3122. function baseForOwn(object, iteratee) {
  3123. return object && baseFor(object, iteratee, keys);
  3124. }
  3125. /**
  3126. * The base implementation of `_.get` without support for default values.
  3127. *
  3128. * @private
  3129. * @param {Object} object The object to query.
  3130. * @param {Array|string} path The path of the property to get.
  3131. * @returns {*} Returns the resolved value.
  3132. */
  3133. function baseGet(object, path) {
  3134. path = isKey(path, object) ? [path] : castPath(path);
  3135. var index = 0,
  3136. length = path.length;
  3137. while (object != null && index < length) {
  3138. object = object[toKey(path[index++])];
  3139. }
  3140. return (index && index == length) ? object : undefined;
  3141. }
  3142. /**
  3143. * The base implementation of `getTag`.
  3144. *
  3145. * @private
  3146. * @param {*} value The value to query.
  3147. * @returns {string} Returns the `toStringTag`.
  3148. */
  3149. function baseGetTag(value) {
  3150. return objectToString.call(value);
  3151. }
  3152. /**
  3153. * The base implementation of `_.hasIn` without support for deep paths.
  3154. *
  3155. * @private
  3156. * @param {Object} [object] The object to query.
  3157. * @param {Array|string} key The key to check.
  3158. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  3159. */
  3160. function baseHasIn(object, key) {
  3161. return object != null && key in Object(object);
  3162. }
  3163. /**
  3164. * The base implementation of `_.isEqual` which supports partial comparisons
  3165. * and tracks traversed objects.
  3166. *
  3167. * @private
  3168. * @param {*} value The value to compare.
  3169. * @param {*} other The other value to compare.
  3170. * @param {Function} [customizer] The function to customize comparisons.
  3171. * @param {boolean} [bitmask] The bitmask of comparison flags.
  3172. * The bitmask may be composed of the following flags:
  3173. * 1 - Unordered comparison
  3174. * 2 - Partial comparison
  3175. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  3176. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  3177. */
  3178. function baseIsEqual(value, other, customizer, bitmask, stack) {
  3179. if (value === other) {
  3180. return true;
  3181. }
  3182. if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
  3183. return value !== value && other !== other;
  3184. }
  3185. return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);
  3186. }
  3187. /**
  3188. * A specialized version of `baseIsEqual` for arrays and objects which performs
  3189. * deep comparisons and tracks traversed objects enabling objects with circular
  3190. * references to be compared.
  3191. *
  3192. * @private
  3193. * @param {Object} object The object to compare.
  3194. * @param {Object} other The other object to compare.
  3195. * @param {Function} equalFunc The function to determine equivalents of values.
  3196. * @param {Function} [customizer] The function to customize comparisons.
  3197. * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`
  3198. * for more details.
  3199. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  3200. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  3201. */
  3202. function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
  3203. var objIsArr = isArray(object),
  3204. othIsArr = isArray(other),
  3205. objTag = arrayTag,
  3206. othTag = arrayTag;
  3207. if (!objIsArr) {
  3208. objTag = getTag(object);
  3209. objTag = objTag == argsTag ? objectTag : objTag;
  3210. }
  3211. if (!othIsArr) {
  3212. othTag = getTag(other);
  3213. othTag = othTag == argsTag ? objectTag : othTag;
  3214. }
  3215. var objIsObj = objTag == objectTag && !isHostObject(object),
  3216. othIsObj = othTag == objectTag && !isHostObject(other),
  3217. isSameTag = objTag == othTag;
  3218. if (isSameTag && !objIsObj) {
  3219. stack || (stack = new Stack);
  3220. return (objIsArr || isTypedArray(object))
  3221. ? equalArrays(object, other, equalFunc, customizer, bitmask, stack)
  3222. : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
  3223. }
  3224. if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
  3225. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  3226. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  3227. if (objIsWrapped || othIsWrapped) {
  3228. var objUnwrapped = objIsWrapped ? object.value() : object,
  3229. othUnwrapped = othIsWrapped ? other.value() : other;
  3230. stack || (stack = new Stack);
  3231. return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
  3232. }
  3233. }
  3234. if (!isSameTag) {
  3235. return false;
  3236. }
  3237. stack || (stack = new Stack);
  3238. return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
  3239. }
  3240. /**
  3241. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  3242. *
  3243. * @private
  3244. * @param {Object} object The object to inspect.
  3245. * @param {Object} source The object of property values to match.
  3246. * @param {Array} matchData The property names, values, and compare flags to match.
  3247. * @param {Function} [customizer] The function to customize comparisons.
  3248. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  3249. */
  3250. function baseIsMatch(object, source, matchData, customizer) {
  3251. var index = matchData.length,
  3252. length = index,
  3253. noCustomizer = !customizer;
  3254. if (object == null) {
  3255. return !length;
  3256. }
  3257. object = Object(object);
  3258. while (index--) {
  3259. var data = matchData[index];
  3260. if ((noCustomizer && data[2])
  3261. ? data[1] !== object[data[0]]
  3262. : !(data[0] in object)
  3263. ) {
  3264. return false;
  3265. }
  3266. }
  3267. while (++index < length) {
  3268. data = matchData[index];
  3269. var key = data[0],
  3270. objValue = object[key],
  3271. srcValue = data[1];
  3272. if (noCustomizer && data[2]) {
  3273. if (objValue === undefined && !(key in object)) {
  3274. return false;
  3275. }
  3276. } else {
  3277. var stack = new Stack;
  3278. if (customizer) {
  3279. var result = customizer(objValue, srcValue, key, object, source, stack);
  3280. }
  3281. if (!(result === undefined
  3282. ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)
  3283. : result
  3284. )) {
  3285. return false;
  3286. }
  3287. }
  3288. }
  3289. return true;
  3290. }
  3291. /**
  3292. * The base implementation of `_.isNative` without bad shim checks.
  3293. *
  3294. * @private
  3295. * @param {*} value The value to check.
  3296. * @returns {boolean} Returns `true` if `value` is a native function,
  3297. * else `false`.
  3298. */
  3299. function baseIsNative(value) {
  3300. if (!isObject(value) || isMasked(value)) {
  3301. return false;
  3302. }
  3303. var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
  3304. return pattern.test(toSource(value));
  3305. }
  3306. /**
  3307. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  3308. *
  3309. * @private
  3310. * @param {*} value The value to check.
  3311. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  3312. */
  3313. function baseIsTypedArray(value) {
  3314. return isObjectLike(value) &&
  3315. isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
  3316. }
  3317. /**
  3318. * The base implementation of `_.iteratee`.
  3319. *
  3320. * @private
  3321. * @param {*} [value=_.identity] The value to convert to an iteratee.
  3322. * @returns {Function} Returns the iteratee.
  3323. */
  3324. function baseIteratee(value) {
  3325. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  3326. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  3327. if (typeof value == 'function') {
  3328. return value;
  3329. }
  3330. if (value == null) {
  3331. return identity;
  3332. }
  3333. if (typeof value == 'object') {
  3334. return isArray(value)
  3335. ? baseMatchesProperty(value[0], value[1])
  3336. : baseMatches(value);
  3337. }
  3338. return property(value);
  3339. }
  3340. /**
  3341. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  3342. *
  3343. * @private
  3344. * @param {Object} object The object to query.
  3345. * @returns {Array} Returns the array of property names.
  3346. */
  3347. function baseKeys(object) {
  3348. if (!isPrototype(object)) {
  3349. return nativeKeys(object);
  3350. }
  3351. var result = [];
  3352. for (var key in Object(object)) {
  3353. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  3354. result.push(key);
  3355. }
  3356. }
  3357. return result;
  3358. }
  3359. /**
  3360. * The base implementation of `_.map` without support for iteratee shorthands.
  3361. *
  3362. * @private
  3363. * @param {Array|Object} collection The collection to iterate over.
  3364. * @param {Function} iteratee The function invoked per iteration.
  3365. * @returns {Array} Returns the new mapped array.
  3366. */
  3367. function baseMap(collection, iteratee) {
  3368. var index = -1,
  3369. result = isArrayLike(collection) ? Array(collection.length) : [];
  3370. baseEach(collection, function(value, key, collection) {
  3371. result[++index] = iteratee(value, key, collection);
  3372. });
  3373. return result;
  3374. }
  3375. /**
  3376. * The base implementation of `_.matches` which doesn't clone `source`.
  3377. *
  3378. * @private
  3379. * @param {Object} source The object of property values to match.
  3380. * @returns {Function} Returns the new spec function.
  3381. */
  3382. function baseMatches(source) {
  3383. var matchData = getMatchData(source);
  3384. if (matchData.length == 1 && matchData[0][2]) {
  3385. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  3386. }
  3387. return function(object) {
  3388. return object === source || baseIsMatch(object, source, matchData);
  3389. };
  3390. }
  3391. /**
  3392. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  3393. *
  3394. * @private
  3395. * @param {string} path The path of the property to get.
  3396. * @param {*} srcValue The value to match.
  3397. * @returns {Function} Returns the new spec function.
  3398. */
  3399. function baseMatchesProperty(path, srcValue) {
  3400. if (isKey(path) && isStrictComparable(srcValue)) {
  3401. return matchesStrictComparable(toKey(path), srcValue);
  3402. }
  3403. return function(object) {
  3404. var objValue = get(object, path);
  3405. return (objValue === undefined && objValue === srcValue)
  3406. ? hasIn(object, path)
  3407. : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG);
  3408. };
  3409. }
  3410. /**
  3411. * The base implementation of `_.orderBy` without param guards.
  3412. *
  3413. * @private
  3414. * @param {Array|Object} collection The collection to iterate over.
  3415. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  3416. * @param {string[]} orders The sort orders of `iteratees`.
  3417. * @returns {Array} Returns the new sorted array.
  3418. */
  3419. function baseOrderBy(collection, iteratees, orders) {
  3420. var index = -1;
  3421. iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(baseIteratee));
  3422. var result = baseMap(collection, function(value, key, collection) {
  3423. var criteria = arrayMap(iteratees, function(iteratee) {
  3424. return iteratee(value);
  3425. });
  3426. return { 'criteria': criteria, 'index': ++index, 'value': value };
  3427. });
  3428. return baseSortBy(result, function(object, other) {
  3429. return compareMultiple(object, other, orders);
  3430. });
  3431. }
  3432. /**
  3433. * A specialized version of `baseProperty` which supports deep paths.
  3434. *
  3435. * @private
  3436. * @param {Array|string} path The path of the property to get.
  3437. * @returns {Function} Returns the new accessor function.
  3438. */
  3439. function basePropertyDeep(path) {
  3440. return function(object) {
  3441. return baseGet(object, path);
  3442. };
  3443. }
  3444. /**
  3445. * The base implementation of `_.toString` which doesn't convert nullish
  3446. * values to empty strings.
  3447. *
  3448. * @private
  3449. * @param {*} value The value to process.
  3450. * @returns {string} Returns the string.
  3451. */
  3452. function baseToString(value) {
  3453. // Exit early for strings to avoid a performance hit in some environments.
  3454. if (typeof value == 'string') {
  3455. return value;
  3456. }
  3457. if (isSymbol(value)) {
  3458. return symbolToString ? symbolToString.call(value) : '';
  3459. }
  3460. var result = (value + '');
  3461. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  3462. }
  3463. /**
  3464. * Casts `value` to a path array if it's not one.
  3465. *
  3466. * @private
  3467. * @param {*} value The value to inspect.
  3468. * @returns {Array} Returns the cast property path array.
  3469. */
  3470. function castPath(value) {
  3471. return isArray(value) ? value : stringToPath(value);
  3472. }
  3473. /**
  3474. * Compares values to sort them in ascending order.
  3475. *
  3476. * @private
  3477. * @param {*} value The value to compare.
  3478. * @param {*} other The other value to compare.
  3479. * @returns {number} Returns the sort order indicator for `value`.
  3480. */
  3481. function compareAscending(value, other) {
  3482. if (value !== other) {
  3483. var valIsDefined = value !== undefined,
  3484. valIsNull = value === null,
  3485. valIsReflexive = value === value,
  3486. valIsSymbol = isSymbol(value);
  3487. var othIsDefined = other !== undefined,
  3488. othIsNull = other === null,
  3489. othIsReflexive = other === other,
  3490. othIsSymbol = isSymbol(other);
  3491. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  3492. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  3493. (valIsNull && othIsDefined && othIsReflexive) ||
  3494. (!valIsDefined && othIsReflexive) ||
  3495. !valIsReflexive) {
  3496. return 1;
  3497. }
  3498. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  3499. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  3500. (othIsNull && valIsDefined && valIsReflexive) ||
  3501. (!othIsDefined && valIsReflexive) ||
  3502. !othIsReflexive) {
  3503. return -1;
  3504. }
  3505. }
  3506. return 0;
  3507. }
  3508. /**
  3509. * Used by `_.orderBy` to compare multiple properties of a value to another
  3510. * and stable sort them.
  3511. *
  3512. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  3513. * specify an order of "desc" for descending or "asc" for ascending sort order
  3514. * of corresponding values.
  3515. *
  3516. * @private
  3517. * @param {Object} object The object to compare.
  3518. * @param {Object} other The other object to compare.
  3519. * @param {boolean[]|string[]} orders The order to sort by for each property.
  3520. * @returns {number} Returns the sort order indicator for `object`.
  3521. */
  3522. function compareMultiple(object, other, orders) {
  3523. var index = -1,
  3524. objCriteria = object.criteria,
  3525. othCriteria = other.criteria,
  3526. length = objCriteria.length,
  3527. ordersLength = orders.length;
  3528. while (++index < length) {
  3529. var result = compareAscending(objCriteria[index], othCriteria[index]);
  3530. if (result) {
  3531. if (index >= ordersLength) {
  3532. return result;
  3533. }
  3534. var order = orders[index];
  3535. return result * (order == 'desc' ? -1 : 1);
  3536. }
  3537. }
  3538. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  3539. // that causes it, under certain circumstances, to provide the same value for
  3540. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  3541. // for more details.
  3542. //
  3543. // This also ensures a stable sort in V8 and other engines.
  3544. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  3545. return object.index - other.index;
  3546. }
  3547. /**
  3548. * Creates a `baseEach` or `baseEachRight` function.
  3549. *
  3550. * @private
  3551. * @param {Function} eachFunc The function to iterate over a collection.
  3552. * @param {boolean} [fromRight] Specify iterating from right to left.
  3553. * @returns {Function} Returns the new base function.
  3554. */
  3555. function createBaseEach(eachFunc, fromRight) {
  3556. return function(collection, iteratee) {
  3557. if (collection == null) {
  3558. return collection;
  3559. }
  3560. if (!isArrayLike(collection)) {
  3561. return eachFunc(collection, iteratee);
  3562. }
  3563. var length = collection.length,
  3564. index = fromRight ? length : -1,
  3565. iterable = Object(collection);
  3566. while ((fromRight ? index-- : ++index < length)) {
  3567. if (iteratee(iterable[index], index, iterable) === false) {
  3568. break;
  3569. }
  3570. }
  3571. return collection;
  3572. };
  3573. }
  3574. /**
  3575. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  3576. *
  3577. * @private
  3578. * @param {boolean} [fromRight] Specify iterating from right to left.
  3579. * @returns {Function} Returns the new base function.
  3580. */
  3581. function createBaseFor(fromRight) {
  3582. return function(object, iteratee, keysFunc) {
  3583. var index = -1,
  3584. iterable = Object(object),
  3585. props = keysFunc(object),
  3586. length = props.length;
  3587. while (length--) {
  3588. var key = props[fromRight ? length : ++index];
  3589. if (iteratee(iterable[key], key, iterable) === false) {
  3590. break;
  3591. }
  3592. }
  3593. return object;
  3594. };
  3595. }
  3596. /**
  3597. * A specialized version of `baseIsEqualDeep` for arrays with support for
  3598. * partial deep comparisons.
  3599. *
  3600. * @private
  3601. * @param {Array} array The array to compare.
  3602. * @param {Array} other The other array to compare.
  3603. * @param {Function} equalFunc The function to determine equivalents of values.
  3604. * @param {Function} customizer The function to customize comparisons.
  3605. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  3606. * for more details.
  3607. * @param {Object} stack Tracks traversed `array` and `other` objects.
  3608. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  3609. */
  3610. function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
  3611. var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
  3612. arrLength = array.length,
  3613. othLength = other.length;
  3614. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  3615. return false;
  3616. }
  3617. // Assume cyclic values are equal.
  3618. var stacked = stack.get(array);
  3619. if (stacked && stack.get(other)) {
  3620. return stacked == other;
  3621. }
  3622. var index = -1,
  3623. result = true,
  3624. seen = (bitmask & UNORDERED_COMPARE_FLAG) ? new SetCache : undefined;
  3625. stack.set(array, other);
  3626. stack.set(other, array);
  3627. // Ignore non-index properties.
  3628. while (++index < arrLength) {
  3629. var arrValue = array[index],
  3630. othValue = other[index];
  3631. if (customizer) {
  3632. var compared = isPartial
  3633. ? customizer(othValue, arrValue, index, other, array, stack)
  3634. : customizer(arrValue, othValue, index, array, other, stack);
  3635. }
  3636. if (compared !== undefined) {
  3637. if (compared) {
  3638. continue;
  3639. }
  3640. result = false;
  3641. break;
  3642. }
  3643. // Recursively compare arrays (susceptible to call stack limits).
  3644. if (seen) {
  3645. if (!arraySome(other, function(othValue, othIndex) {
  3646. if (!seen.has(othIndex) &&
  3647. (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
  3648. return seen.add(othIndex);
  3649. }
  3650. })) {
  3651. result = false;
  3652. break;
  3653. }
  3654. } else if (!(
  3655. arrValue === othValue ||
  3656. equalFunc(arrValue, othValue, customizer, bitmask, stack)
  3657. )) {
  3658. result = false;
  3659. break;
  3660. }
  3661. }
  3662. stack['delete'](array);
  3663. stack['delete'](other);
  3664. return result;
  3665. }
  3666. /**
  3667. * A specialized version of `baseIsEqualDeep` for comparing objects of
  3668. * the same `toStringTag`.
  3669. *
  3670. * **Note:** This function only supports comparing values with tags of
  3671. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  3672. *
  3673. * @private
  3674. * @param {Object} object The object to compare.
  3675. * @param {Object} other The other object to compare.
  3676. * @param {string} tag The `toStringTag` of the objects to compare.
  3677. * @param {Function} equalFunc The function to determine equivalents of values.
  3678. * @param {Function} customizer The function to customize comparisons.
  3679. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  3680. * for more details.
  3681. * @param {Object} stack Tracks traversed `object` and `other` objects.
  3682. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  3683. */
  3684. function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
  3685. switch (tag) {
  3686. case dataViewTag:
  3687. if ((object.byteLength != other.byteLength) ||
  3688. (object.byteOffset != other.byteOffset)) {
  3689. return false;
  3690. }
  3691. object = object.buffer;
  3692. other = other.buffer;
  3693. case arrayBufferTag:
  3694. if ((object.byteLength != other.byteLength) ||
  3695. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  3696. return false;
  3697. }
  3698. return true;
  3699. case boolTag:
  3700. case dateTag:
  3701. case numberTag:
  3702. // Coerce booleans to `1` or `0` and dates to milliseconds.
  3703. // Invalid dates are coerced to `NaN`.
  3704. return eq(+object, +other);
  3705. case errorTag:
  3706. return object.name == other.name && object.message == other.message;
  3707. case regexpTag:
  3708. case stringTag:
  3709. // Coerce regexes to strings and treat strings, primitives and objects,
  3710. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  3711. // for more details.
  3712. return object == (other + '');
  3713. case mapTag:
  3714. var convert = mapToArray;
  3715. case setTag:
  3716. var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
  3717. convert || (convert = setToArray);
  3718. if (object.size != other.size && !isPartial) {
  3719. return false;
  3720. }
  3721. // Assume cyclic values are equal.
  3722. var stacked = stack.get(object);
  3723. if (stacked) {
  3724. return stacked == other;
  3725. }
  3726. bitmask |= UNORDERED_COMPARE_FLAG;
  3727. // Recursively compare objects (susceptible to call stack limits).
  3728. stack.set(object, other);
  3729. var result = equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);
  3730. stack['delete'](object);
  3731. return result;
  3732. case symbolTag:
  3733. if (symbolValueOf) {
  3734. return symbolValueOf.call(object) == symbolValueOf.call(other);
  3735. }
  3736. }
  3737. return false;
  3738. }
  3739. /**
  3740. * A specialized version of `baseIsEqualDeep` for objects with support for
  3741. * partial deep comparisons.
  3742. *
  3743. * @private
  3744. * @param {Object} object The object to compare.
  3745. * @param {Object} other The other object to compare.
  3746. * @param {Function} equalFunc The function to determine equivalents of values.
  3747. * @param {Function} customizer The function to customize comparisons.
  3748. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
  3749. * for more details.
  3750. * @param {Object} stack Tracks traversed `object` and `other` objects.
  3751. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  3752. */
  3753. function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
  3754. var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
  3755. objProps = keys(object),
  3756. objLength = objProps.length,
  3757. othProps = keys(other),
  3758. othLength = othProps.length;
  3759. if (objLength != othLength && !isPartial) {
  3760. return false;
  3761. }
  3762. var index = objLength;
  3763. while (index--) {
  3764. var key = objProps[index];
  3765. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  3766. return false;
  3767. }
  3768. }
  3769. // Assume cyclic values are equal.
  3770. var stacked = stack.get(object);
  3771. if (stacked && stack.get(other)) {
  3772. return stacked == other;
  3773. }
  3774. var result = true;
  3775. stack.set(object, other);
  3776. stack.set(other, object);
  3777. var skipCtor = isPartial;
  3778. while (++index < objLength) {
  3779. key = objProps[index];
  3780. var objValue = object[key],
  3781. othValue = other[key];
  3782. if (customizer) {
  3783. var compared = isPartial
  3784. ? customizer(othValue, objValue, key, other, object, stack)
  3785. : customizer(objValue, othValue, key, object, other, stack);
  3786. }
  3787. // Recursively compare objects (susceptible to call stack limits).
  3788. if (!(compared === undefined
  3789. ? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack))
  3790. : compared
  3791. )) {
  3792. result = false;
  3793. break;
  3794. }
  3795. skipCtor || (skipCtor = key == 'constructor');
  3796. }
  3797. if (result && !skipCtor) {
  3798. var objCtor = object.constructor,
  3799. othCtor = other.constructor;
  3800. // Non `Object` object instances with different constructors are not equal.
  3801. if (objCtor != othCtor &&
  3802. ('constructor' in object && 'constructor' in other) &&
  3803. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  3804. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  3805. result = false;
  3806. }
  3807. }
  3808. stack['delete'](object);
  3809. stack['delete'](other);
  3810. return result;
  3811. }
  3812. /**
  3813. * Gets the data for `map`.
  3814. *
  3815. * @private
  3816. * @param {Object} map The map to query.
  3817. * @param {string} key The reference key.
  3818. * @returns {*} Returns the map data.
  3819. */
  3820. function getMapData(map, key) {
  3821. var data = map.__data__;
  3822. return isKeyable(key)
  3823. ? data[typeof key == 'string' ? 'string' : 'hash']
  3824. : data.map;
  3825. }
  3826. /**
  3827. * Gets the property names, values, and compare flags of `object`.
  3828. *
  3829. * @private
  3830. * @param {Object} object The object to query.
  3831. * @returns {Array} Returns the match data of `object`.
  3832. */
  3833. function getMatchData(object) {
  3834. var result = keys(object),
  3835. length = result.length;
  3836. while (length--) {
  3837. var key = result[length],
  3838. value = object[key];
  3839. result[length] = [key, value, isStrictComparable(value)];
  3840. }
  3841. return result;
  3842. }
  3843. /**
  3844. * Gets the native function at `key` of `object`.
  3845. *
  3846. * @private
  3847. * @param {Object} object The object to query.
  3848. * @param {string} key The key of the method to get.
  3849. * @returns {*} Returns the function if it's native, else `undefined`.
  3850. */
  3851. function getNative(object, key) {
  3852. var value = getValue(object, key);
  3853. return baseIsNative(value) ? value : undefined;
  3854. }
  3855. /**
  3856. * Gets the `toStringTag` of `value`.
  3857. *
  3858. * @private
  3859. * @param {*} value The value to query.
  3860. * @returns {string} Returns the `toStringTag`.
  3861. */
  3862. var getTag = baseGetTag;
  3863. // Fallback for data views, maps, sets, and weak maps in IE 11,
  3864. // for data views in Edge < 14, and promises in Node.js.
  3865. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  3866. (Map && getTag(new Map) != mapTag) ||
  3867. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  3868. (Set && getTag(new Set) != setTag) ||
  3869. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  3870. getTag = function(value) {
  3871. var result = objectToString.call(value),
  3872. Ctor = result == objectTag ? value.constructor : undefined,
  3873. ctorString = Ctor ? toSource(Ctor) : undefined;
  3874. if (ctorString) {
  3875. switch (ctorString) {
  3876. case dataViewCtorString: return dataViewTag;
  3877. case mapCtorString: return mapTag;
  3878. case promiseCtorString: return promiseTag;
  3879. case setCtorString: return setTag;
  3880. case weakMapCtorString: return weakMapTag;
  3881. }
  3882. }
  3883. return result;
  3884. };
  3885. }
  3886. /**
  3887. * Checks if `path` exists on `object`.
  3888. *
  3889. * @private
  3890. * @param {Object} object The object to query.
  3891. * @param {Array|string} path The path to check.
  3892. * @param {Function} hasFunc The function to check properties.
  3893. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  3894. */
  3895. function hasPath(object, path, hasFunc) {
  3896. path = isKey(path, object) ? [path] : castPath(path);
  3897. var result,
  3898. index = -1,
  3899. length = path.length;
  3900. while (++index < length) {
  3901. var key = toKey(path[index]);
  3902. if (!(result = object != null && hasFunc(object, key))) {
  3903. break;
  3904. }
  3905. object = object[key];
  3906. }
  3907. if (result) {
  3908. return result;
  3909. }
  3910. var length = object ? object.length : 0;
  3911. return !!length && isLength(length) && isIndex(key, length) &&
  3912. (isArray(object) || isArguments(object));
  3913. }
  3914. /**
  3915. * Checks if `value` is a valid array-like index.
  3916. *
  3917. * @private
  3918. * @param {*} value The value to check.
  3919. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  3920. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  3921. */
  3922. function isIndex(value, length) {
  3923. length = length == null ? MAX_SAFE_INTEGER : length;
  3924. return !!length &&
  3925. (typeof value == 'number' || reIsUint.test(value)) &&
  3926. (value > -1 && value % 1 == 0 && value < length);
  3927. }
  3928. /**
  3929. * Checks if `value` is a property name and not a property path.
  3930. *
  3931. * @private
  3932. * @param {*} value The value to check.
  3933. * @param {Object} [object] The object to query keys on.
  3934. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  3935. */
  3936. function isKey(value, object) {
  3937. if (isArray(value)) {
  3938. return false;
  3939. }
  3940. var type = typeof value;
  3941. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  3942. value == null || isSymbol(value)) {
  3943. return true;
  3944. }
  3945. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  3946. (object != null && value in Object(object));
  3947. }
  3948. /**
  3949. * Checks if `value` is suitable for use as unique object key.
  3950. *
  3951. * @private
  3952. * @param {*} value The value to check.
  3953. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  3954. */
  3955. function isKeyable(value) {
  3956. var type = typeof value;
  3957. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  3958. ? (value !== '__proto__')
  3959. : (value === null);
  3960. }
  3961. /**
  3962. * Checks if `func` has its source masked.
  3963. *
  3964. * @private
  3965. * @param {Function} func The function to check.
  3966. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  3967. */
  3968. function isMasked(func) {
  3969. return !!maskSrcKey && (maskSrcKey in func);
  3970. }
  3971. /**
  3972. * Checks if `value` is likely a prototype object.
  3973. *
  3974. * @private
  3975. * @param {*} value The value to check.
  3976. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  3977. */
  3978. function isPrototype(value) {
  3979. var Ctor = value && value.constructor,
  3980. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  3981. return value === proto;
  3982. }
  3983. /**
  3984. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  3985. *
  3986. * @private
  3987. * @param {*} value The value to check.
  3988. * @returns {boolean} Returns `true` if `value` if suitable for strict
  3989. * equality comparisons, else `false`.
  3990. */
  3991. function isStrictComparable(value) {
  3992. return value === value && !isObject(value);
  3993. }
  3994. /**
  3995. * A specialized version of `matchesProperty` for source values suitable
  3996. * for strict equality comparisons, i.e. `===`.
  3997. *
  3998. * @private
  3999. * @param {string} key The key of the property to get.
  4000. * @param {*} srcValue The value to match.
  4001. * @returns {Function} Returns the new spec function.
  4002. */
  4003. function matchesStrictComparable(key, srcValue) {
  4004. return function(object) {
  4005. if (object == null) {
  4006. return false;
  4007. }
  4008. return object[key] === srcValue &&
  4009. (srcValue !== undefined || (key in Object(object)));
  4010. };
  4011. }
  4012. /**
  4013. * Converts `string` to a property path array.
  4014. *
  4015. * @private
  4016. * @param {string} string The string to convert.
  4017. * @returns {Array} Returns the property path array.
  4018. */
  4019. var stringToPath = memoize(function(string) {
  4020. string = toString(string);
  4021. var result = [];
  4022. if (reLeadingDot.test(string)) {
  4023. result.push('');
  4024. }
  4025. string.replace(rePropName, function(match, number, quote, string) {
  4026. result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
  4027. });
  4028. return result;
  4029. });
  4030. /**
  4031. * Converts `value` to a string key if it's not a string or symbol.
  4032. *
  4033. * @private
  4034. * @param {*} value The value to inspect.
  4035. * @returns {string|symbol} Returns the key.
  4036. */
  4037. function toKey(value) {
  4038. if (typeof value == 'string' || isSymbol(value)) {
  4039. return value;
  4040. }
  4041. var result = (value + '');
  4042. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  4043. }
  4044. /**
  4045. * Converts `func` to its source code.
  4046. *
  4047. * @private
  4048. * @param {Function} func The function to process.
  4049. * @returns {string} Returns the source code.
  4050. */
  4051. function toSource(func) {
  4052. if (func != null) {
  4053. try {
  4054. return funcToString.call(func);
  4055. } catch (e) {}
  4056. try {
  4057. return (func + '');
  4058. } catch (e) {}
  4059. }
  4060. return '';
  4061. }
  4062. /**
  4063. * This method is like `_.sortBy` except that it allows specifying the sort
  4064. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  4065. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  4066. * descending or "asc" for ascending sort order of corresponding values.
  4067. *
  4068. * @static
  4069. * @memberOf _
  4070. * @since 4.0.0
  4071. * @category Collection
  4072. * @param {Array|Object} collection The collection to iterate over.
  4073. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  4074. * The iteratees to sort by.
  4075. * @param {string[]} [orders] The sort orders of `iteratees`.
  4076. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  4077. * @returns {Array} Returns the new sorted array.
  4078. * @example
  4079. *
  4080. * var users = [
  4081. * { 'user': 'fred', 'age': 48 },
  4082. * { 'user': 'barney', 'age': 34 },
  4083. * { 'user': 'fred', 'age': 40 },
  4084. * { 'user': 'barney', 'age': 36 }
  4085. * ];
  4086. *
  4087. * // Sort by `user` in ascending order and by `age` in descending order.
  4088. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  4089. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  4090. */
  4091. function orderBy(collection, iteratees, orders, guard) {
  4092. if (collection == null) {
  4093. return [];
  4094. }
  4095. if (!isArray(iteratees)) {
  4096. iteratees = iteratees == null ? [] : [iteratees];
  4097. }
  4098. orders = guard ? undefined : orders;
  4099. if (!isArray(orders)) {
  4100. orders = orders == null ? [] : [orders];
  4101. }
  4102. return baseOrderBy(collection, iteratees, orders);
  4103. }
  4104. /**
  4105. * Creates a function that memoizes the result of `func`. If `resolver` is
  4106. * provided, it determines the cache key for storing the result based on the
  4107. * arguments provided to the memoized function. By default, the first argument
  4108. * provided to the memoized function is used as the map cache key. The `func`
  4109. * is invoked with the `this` binding of the memoized function.
  4110. *
  4111. * **Note:** The cache is exposed as the `cache` property on the memoized
  4112. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  4113. * constructor with one whose instances implement the
  4114. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  4115. * method interface of `delete`, `get`, `has`, and `set`.
  4116. *
  4117. * @static
  4118. * @memberOf _
  4119. * @since 0.1.0
  4120. * @category Function
  4121. * @param {Function} func The function to have its output memoized.
  4122. * @param {Function} [resolver] The function to resolve the cache key.
  4123. * @returns {Function} Returns the new memoized function.
  4124. * @example
  4125. *
  4126. * var object = { 'a': 1, 'b': 2 };
  4127. * var other = { 'c': 3, 'd': 4 };
  4128. *
  4129. * var values = _.memoize(_.values);
  4130. * values(object);
  4131. * // => [1, 2]
  4132. *
  4133. * values(other);
  4134. * // => [3, 4]
  4135. *
  4136. * object.a = 2;
  4137. * values(object);
  4138. * // => [1, 2]
  4139. *
  4140. * // Modify the result cache.
  4141. * values.cache.set(object, ['a', 'b']);
  4142. * values(object);
  4143. * // => ['a', 'b']
  4144. *
  4145. * // Replace `_.memoize.Cache`.
  4146. * _.memoize.Cache = WeakMap;
  4147. */
  4148. function memoize(func, resolver) {
  4149. if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
  4150. throw new TypeError(FUNC_ERROR_TEXT);
  4151. }
  4152. var memoized = function() {
  4153. var args = arguments,
  4154. key = resolver ? resolver.apply(this, args) : args[0],
  4155. cache = memoized.cache;
  4156. if (cache.has(key)) {
  4157. return cache.get(key);
  4158. }
  4159. var result = func.apply(this, args);
  4160. memoized.cache = cache.set(key, result);
  4161. return result;
  4162. };
  4163. memoized.cache = new (memoize.Cache || MapCache);
  4164. return memoized;
  4165. }
  4166. // Assign cache to `_.memoize`.
  4167. memoize.Cache = MapCache;
  4168. /**
  4169. * Performs a
  4170. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  4171. * comparison between two values to determine if they are equivalent.
  4172. *
  4173. * @static
  4174. * @memberOf _
  4175. * @since 4.0.0
  4176. * @category Lang
  4177. * @param {*} value The value to compare.
  4178. * @param {*} other The other value to compare.
  4179. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  4180. * @example
  4181. *
  4182. * var object = { 'a': 1 };
  4183. * var other = { 'a': 1 };
  4184. *
  4185. * _.eq(object, object);
  4186. * // => true
  4187. *
  4188. * _.eq(object, other);
  4189. * // => false
  4190. *
  4191. * _.eq('a', 'a');
  4192. * // => true
  4193. *
  4194. * _.eq('a', Object('a'));
  4195. * // => false
  4196. *
  4197. * _.eq(NaN, NaN);
  4198. * // => true
  4199. */
  4200. function eq(value, other) {
  4201. return value === other || (value !== value && other !== other);
  4202. }
  4203. /**
  4204. * Checks if `value` is likely an `arguments` object.
  4205. *
  4206. * @static
  4207. * @memberOf _
  4208. * @since 0.1.0
  4209. * @category Lang
  4210. * @param {*} value The value to check.
  4211. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  4212. * else `false`.
  4213. * @example
  4214. *
  4215. * _.isArguments(function() { return arguments; }());
  4216. * // => true
  4217. *
  4218. * _.isArguments([1, 2, 3]);
  4219. * // => false
  4220. */
  4221. function isArguments(value) {
  4222. // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
  4223. return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
  4224. (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
  4225. }
  4226. /**
  4227. * Checks if `value` is classified as an `Array` object.
  4228. *
  4229. * @static
  4230. * @memberOf _
  4231. * @since 0.1.0
  4232. * @category Lang
  4233. * @param {*} value The value to check.
  4234. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  4235. * @example
  4236. *
  4237. * _.isArray([1, 2, 3]);
  4238. * // => true
  4239. *
  4240. * _.isArray(document.body.children);
  4241. * // => false
  4242. *
  4243. * _.isArray('abc');
  4244. * // => false
  4245. *
  4246. * _.isArray(_.noop);
  4247. * // => false
  4248. */
  4249. var isArray = Array.isArray;
  4250. /**
  4251. * Checks if `value` is array-like. A value is considered array-like if it's
  4252. * not a function and has a `value.length` that's an integer greater than or
  4253. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  4254. *
  4255. * @static
  4256. * @memberOf _
  4257. * @since 4.0.0
  4258. * @category Lang
  4259. * @param {*} value The value to check.
  4260. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  4261. * @example
  4262. *
  4263. * _.isArrayLike([1, 2, 3]);
  4264. * // => true
  4265. *
  4266. * _.isArrayLike(document.body.children);
  4267. * // => true
  4268. *
  4269. * _.isArrayLike('abc');
  4270. * // => true
  4271. *
  4272. * _.isArrayLike(_.noop);
  4273. * // => false
  4274. */
  4275. function isArrayLike(value) {
  4276. return value != null && isLength(value.length) && !isFunction(value);
  4277. }
  4278. /**
  4279. * This method is like `_.isArrayLike` except that it also checks if `value`
  4280. * is an object.
  4281. *
  4282. * @static
  4283. * @memberOf _
  4284. * @since 4.0.0
  4285. * @category Lang
  4286. * @param {*} value The value to check.
  4287. * @returns {boolean} Returns `true` if `value` is an array-like object,
  4288. * else `false`.
  4289. * @example
  4290. *
  4291. * _.isArrayLikeObject([1, 2, 3]);
  4292. * // => true
  4293. *
  4294. * _.isArrayLikeObject(document.body.children);
  4295. * // => true
  4296. *
  4297. * _.isArrayLikeObject('abc');
  4298. * // => false
  4299. *
  4300. * _.isArrayLikeObject(_.noop);
  4301. * // => false
  4302. */
  4303. function isArrayLikeObject(value) {
  4304. return isObjectLike(value) && isArrayLike(value);
  4305. }
  4306. /**
  4307. * Checks if `value` is classified as a `Function` object.
  4308. *
  4309. * @static
  4310. * @memberOf _
  4311. * @since 0.1.0
  4312. * @category Lang
  4313. * @param {*} value The value to check.
  4314. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  4315. * @example
  4316. *
  4317. * _.isFunction(_);
  4318. * // => true
  4319. *
  4320. * _.isFunction(/abc/);
  4321. * // => false
  4322. */
  4323. function isFunction(value) {
  4324. // The use of `Object#toString` avoids issues with the `typeof` operator
  4325. // in Safari 8-9 which returns 'object' for typed array and other constructors.
  4326. var tag = isObject(value) ? objectToString.call(value) : '';
  4327. return tag == funcTag || tag == genTag;
  4328. }
  4329. /**
  4330. * Checks if `value` is a valid array-like length.
  4331. *
  4332. * **Note:** This method is loosely based on
  4333. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  4334. *
  4335. * @static
  4336. * @memberOf _
  4337. * @since 4.0.0
  4338. * @category Lang
  4339. * @param {*} value The value to check.
  4340. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  4341. * @example
  4342. *
  4343. * _.isLength(3);
  4344. * // => true
  4345. *
  4346. * _.isLength(Number.MIN_VALUE);
  4347. * // => false
  4348. *
  4349. * _.isLength(Infinity);
  4350. * // => false
  4351. *
  4352. * _.isLength('3');
  4353. * // => false
  4354. */
  4355. function isLength(value) {
  4356. return typeof value == 'number' &&
  4357. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  4358. }
  4359. /**
  4360. * Checks if `value` is the
  4361. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  4362. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  4363. *
  4364. * @static
  4365. * @memberOf _
  4366. * @since 0.1.0
  4367. * @category Lang
  4368. * @param {*} value The value to check.
  4369. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  4370. * @example
  4371. *
  4372. * _.isObject({});
  4373. * // => true
  4374. *
  4375. * _.isObject([1, 2, 3]);
  4376. * // => true
  4377. *
  4378. * _.isObject(_.noop);
  4379. * // => true
  4380. *
  4381. * _.isObject(null);
  4382. * // => false
  4383. */
  4384. function isObject(value) {
  4385. var type = typeof value;
  4386. return !!value && (type == 'object' || type == 'function');
  4387. }
  4388. /**
  4389. * Checks if `value` is object-like. A value is object-like if it's not `null`
  4390. * and has a `typeof` result of "object".
  4391. *
  4392. * @static
  4393. * @memberOf _
  4394. * @since 4.0.0
  4395. * @category Lang
  4396. * @param {*} value The value to check.
  4397. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  4398. * @example
  4399. *
  4400. * _.isObjectLike({});
  4401. * // => true
  4402. *
  4403. * _.isObjectLike([1, 2, 3]);
  4404. * // => true
  4405. *
  4406. * _.isObjectLike(_.noop);
  4407. * // => false
  4408. *
  4409. * _.isObjectLike(null);
  4410. * // => false
  4411. */
  4412. function isObjectLike(value) {
  4413. return !!value && typeof value == 'object';
  4414. }
  4415. /**
  4416. * Checks if `value` is classified as a `Symbol` primitive or object.
  4417. *
  4418. * @static
  4419. * @memberOf _
  4420. * @since 4.0.0
  4421. * @category Lang
  4422. * @param {*} value The value to check.
  4423. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  4424. * @example
  4425. *
  4426. * _.isSymbol(Symbol.iterator);
  4427. * // => true
  4428. *
  4429. * _.isSymbol('abc');
  4430. * // => false
  4431. */
  4432. function isSymbol(value) {
  4433. return typeof value == 'symbol' ||
  4434. (isObjectLike(value) && objectToString.call(value) == symbolTag);
  4435. }
  4436. /**
  4437. * Checks if `value` is classified as a typed array.
  4438. *
  4439. * @static
  4440. * @memberOf _
  4441. * @since 3.0.0
  4442. * @category Lang
  4443. * @param {*} value The value to check.
  4444. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  4445. * @example
  4446. *
  4447. * _.isTypedArray(new Uint8Array);
  4448. * // => true
  4449. *
  4450. * _.isTypedArray([]);
  4451. * // => false
  4452. */
  4453. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  4454. /**
  4455. * Converts `value` to a string. An empty string is returned for `null`
  4456. * and `undefined` values. The sign of `-0` is preserved.
  4457. *
  4458. * @static
  4459. * @memberOf _
  4460. * @since 4.0.0
  4461. * @category Lang
  4462. * @param {*} value The value to process.
  4463. * @returns {string} Returns the string.
  4464. * @example
  4465. *
  4466. * _.toString(null);
  4467. * // => ''
  4468. *
  4469. * _.toString(-0);
  4470. * // => '-0'
  4471. *
  4472. * _.toString([1, 2, 3]);
  4473. * // => '1,2,3'
  4474. */
  4475. function toString(value) {
  4476. return value == null ? '' : baseToString(value);
  4477. }
  4478. /**
  4479. * Gets the value at `path` of `object`. If the resolved value is
  4480. * `undefined`, the `defaultValue` is returned in its place.
  4481. *
  4482. * @static
  4483. * @memberOf _
  4484. * @since 3.7.0
  4485. * @category Object
  4486. * @param {Object} object The object to query.
  4487. * @param {Array|string} path The path of the property to get.
  4488. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  4489. * @returns {*} Returns the resolved value.
  4490. * @example
  4491. *
  4492. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  4493. *
  4494. * _.get(object, 'a[0].b.c');
  4495. * // => 3
  4496. *
  4497. * _.get(object, ['a', '0', 'b', 'c']);
  4498. * // => 3
  4499. *
  4500. * _.get(object, 'a.b.c', 'default');
  4501. * // => 'default'
  4502. */
  4503. function get(object, path, defaultValue) {
  4504. var result = object == null ? undefined : baseGet(object, path);
  4505. return result === undefined ? defaultValue : result;
  4506. }
  4507. /**
  4508. * Checks if `path` is a direct or inherited property of `object`.
  4509. *
  4510. * @static
  4511. * @memberOf _
  4512. * @since 4.0.0
  4513. * @category Object
  4514. * @param {Object} object The object to query.
  4515. * @param {Array|string} path The path to check.
  4516. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  4517. * @example
  4518. *
  4519. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  4520. *
  4521. * _.hasIn(object, 'a');
  4522. * // => true
  4523. *
  4524. * _.hasIn(object, 'a.b');
  4525. * // => true
  4526. *
  4527. * _.hasIn(object, ['a', 'b']);
  4528. * // => true
  4529. *
  4530. * _.hasIn(object, 'b');
  4531. * // => false
  4532. */
  4533. function hasIn(object, path) {
  4534. return object != null && hasPath(object, path, baseHasIn);
  4535. }
  4536. /**
  4537. * Creates an array of the own enumerable property names of `object`.
  4538. *
  4539. * **Note:** Non-object values are coerced to objects. See the
  4540. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  4541. * for more details.
  4542. *
  4543. * @static
  4544. * @since 0.1.0
  4545. * @memberOf _
  4546. * @category Object
  4547. * @param {Object} object The object to query.
  4548. * @returns {Array} Returns the array of property names.
  4549. * @example
  4550. *
  4551. * function Foo() {
  4552. * this.a = 1;
  4553. * this.b = 2;
  4554. * }
  4555. *
  4556. * Foo.prototype.c = 3;
  4557. *
  4558. * _.keys(new Foo);
  4559. * // => ['a', 'b'] (iteration order is not guaranteed)
  4560. *
  4561. * _.keys('hi');
  4562. * // => ['0', '1']
  4563. */
  4564. function keys(object) {
  4565. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  4566. }
  4567. /**
  4568. * This method returns the first argument it receives.
  4569. *
  4570. * @static
  4571. * @since 0.1.0
  4572. * @memberOf _
  4573. * @category Util
  4574. * @param {*} value Any value.
  4575. * @returns {*} Returns `value`.
  4576. * @example
  4577. *
  4578. * var object = { 'a': 1 };
  4579. *
  4580. * console.log(_.identity(object) === object);
  4581. * // => true
  4582. */
  4583. function identity(value) {
  4584. return value;
  4585. }
  4586. /**
  4587. * Creates a function that returns the value at `path` of a given object.
  4588. *
  4589. * @static
  4590. * @memberOf _
  4591. * @since 2.4.0
  4592. * @category Util
  4593. * @param {Array|string} path The path of the property to get.
  4594. * @returns {Function} Returns the new accessor function.
  4595. * @example
  4596. *
  4597. * var objects = [
  4598. * { 'a': { 'b': 2 } },
  4599. * { 'a': { 'b': 1 } }
  4600. * ];
  4601. *
  4602. * _.map(objects, _.property('a.b'));
  4603. * // => [2, 1]
  4604. *
  4605. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  4606. * // => [1, 2]
  4607. */
  4608. function property(path) {
  4609. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  4610. }
  4611. module.exports = orderBy;
  4612. /***/ }),
  4613. /***/ 90039:
  4614. /***/ ((module) => {
  4615. /**
  4616. * lodash (Custom Build) <https://lodash.com/>
  4617. * Build: `lodash modularize exports="npm" -o ./`
  4618. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  4619. * Released under MIT license <https://lodash.com/license>
  4620. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  4621. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  4622. */
  4623. /** Used as references for various `Number` constants. */
  4624. var INFINITY = 1 / 0;
  4625. /** `Object#toString` result references. */
  4626. var symbolTag = '[object Symbol]';
  4627. /** Used to compose unicode character classes. */
  4628. var rsAstralRange = '\\ud800-\\udfff',
  4629. rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
  4630. rsComboSymbolsRange = '\\u20d0-\\u20f0',
  4631. rsVarRange = '\\ufe0e\\ufe0f';
  4632. /** Used to compose unicode capture groups. */
  4633. var rsAstral = '[' + rsAstralRange + ']',
  4634. rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',
  4635. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  4636. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  4637. rsNonAstral = '[^' + rsAstralRange + ']',
  4638. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  4639. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  4640. rsZWJ = '\\u200d';
  4641. /** Used to compose unicode regexes. */
  4642. var reOptMod = rsModifier + '?',
  4643. rsOptVar = '[' + rsVarRange + ']?',
  4644. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  4645. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  4646. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  4647. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  4648. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  4649. /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
  4650. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
  4651. /** Detect free variable `global` from Node.js. */
  4652. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  4653. /** Detect free variable `self`. */
  4654. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  4655. /** Used as a reference to the global object. */
  4656. var root = freeGlobal || freeSelf || Function('return this')();
  4657. /**
  4658. * Converts an ASCII `string` to an array.
  4659. *
  4660. * @private
  4661. * @param {string} string The string to convert.
  4662. * @returns {Array} Returns the converted array.
  4663. */
  4664. function asciiToArray(string) {
  4665. return string.split('');
  4666. }
  4667. /**
  4668. * Checks if `string` contains Unicode symbols.
  4669. *
  4670. * @private
  4671. * @param {string} string The string to inspect.
  4672. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  4673. */
  4674. function hasUnicode(string) {
  4675. return reHasUnicode.test(string);
  4676. }
  4677. /**
  4678. * Converts `string` to an array.
  4679. *
  4680. * @private
  4681. * @param {string} string The string to convert.
  4682. * @returns {Array} Returns the converted array.
  4683. */
  4684. function stringToArray(string) {
  4685. return hasUnicode(string)
  4686. ? unicodeToArray(string)
  4687. : asciiToArray(string);
  4688. }
  4689. /**
  4690. * Converts a Unicode `string` to an array.
  4691. *
  4692. * @private
  4693. * @param {string} string The string to convert.
  4694. * @returns {Array} Returns the converted array.
  4695. */
  4696. function unicodeToArray(string) {
  4697. return string.match(reUnicode) || [];
  4698. }
  4699. /** Used for built-in method references. */
  4700. var objectProto = Object.prototype;
  4701. /**
  4702. * Used to resolve the
  4703. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  4704. * of values.
  4705. */
  4706. var objectToString = objectProto.toString;
  4707. /** Built-in value references. */
  4708. var Symbol = root.Symbol;
  4709. /** Used to convert symbols to primitives and strings. */
  4710. var symbolProto = Symbol ? Symbol.prototype : undefined,
  4711. symbolToString = symbolProto ? symbolProto.toString : undefined;
  4712. /**
  4713. * The base implementation of `_.slice` without an iteratee call guard.
  4714. *
  4715. * @private
  4716. * @param {Array} array The array to slice.
  4717. * @param {number} [start=0] The start position.
  4718. * @param {number} [end=array.length] The end position.
  4719. * @returns {Array} Returns the slice of `array`.
  4720. */
  4721. function baseSlice(array, start, end) {
  4722. var index = -1,
  4723. length = array.length;
  4724. if (start < 0) {
  4725. start = -start > length ? 0 : (length + start);
  4726. }
  4727. end = end > length ? length : end;
  4728. if (end < 0) {
  4729. end += length;
  4730. }
  4731. length = start > end ? 0 : ((end - start) >>> 0);
  4732. start >>>= 0;
  4733. var result = Array(length);
  4734. while (++index < length) {
  4735. result[index] = array[index + start];
  4736. }
  4737. return result;
  4738. }
  4739. /**
  4740. * The base implementation of `_.toString` which doesn't convert nullish
  4741. * values to empty strings.
  4742. *
  4743. * @private
  4744. * @param {*} value The value to process.
  4745. * @returns {string} Returns the string.
  4746. */
  4747. function baseToString(value) {
  4748. // Exit early for strings to avoid a performance hit in some environments.
  4749. if (typeof value == 'string') {
  4750. return value;
  4751. }
  4752. if (isSymbol(value)) {
  4753. return symbolToString ? symbolToString.call(value) : '';
  4754. }
  4755. var result = (value + '');
  4756. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  4757. }
  4758. /**
  4759. * Casts `array` to a slice if it's needed.
  4760. *
  4761. * @private
  4762. * @param {Array} array The array to inspect.
  4763. * @param {number} start The start position.
  4764. * @param {number} [end=array.length] The end position.
  4765. * @returns {Array} Returns the cast slice.
  4766. */
  4767. function castSlice(array, start, end) {
  4768. var length = array.length;
  4769. end = end === undefined ? length : end;
  4770. return (!start && end >= length) ? array : baseSlice(array, start, end);
  4771. }
  4772. /**
  4773. * Creates a function like `_.lowerFirst`.
  4774. *
  4775. * @private
  4776. * @param {string} methodName The name of the `String` case method to use.
  4777. * @returns {Function} Returns the new case function.
  4778. */
  4779. function createCaseFirst(methodName) {
  4780. return function(string) {
  4781. string = toString(string);
  4782. var strSymbols = hasUnicode(string)
  4783. ? stringToArray(string)
  4784. : undefined;
  4785. var chr = strSymbols
  4786. ? strSymbols[0]
  4787. : string.charAt(0);
  4788. var trailing = strSymbols
  4789. ? castSlice(strSymbols, 1).join('')
  4790. : string.slice(1);
  4791. return chr[methodName]() + trailing;
  4792. };
  4793. }
  4794. /**
  4795. * Checks if `value` is object-like. A value is object-like if it's not `null`
  4796. * and has a `typeof` result of "object".
  4797. *
  4798. * @static
  4799. * @memberOf _
  4800. * @since 4.0.0
  4801. * @category Lang
  4802. * @param {*} value The value to check.
  4803. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  4804. * @example
  4805. *
  4806. * _.isObjectLike({});
  4807. * // => true
  4808. *
  4809. * _.isObjectLike([1, 2, 3]);
  4810. * // => true
  4811. *
  4812. * _.isObjectLike(_.noop);
  4813. * // => false
  4814. *
  4815. * _.isObjectLike(null);
  4816. * // => false
  4817. */
  4818. function isObjectLike(value) {
  4819. return !!value && typeof value == 'object';
  4820. }
  4821. /**
  4822. * Checks if `value` is classified as a `Symbol` primitive or object.
  4823. *
  4824. * @static
  4825. * @memberOf _
  4826. * @since 4.0.0
  4827. * @category Lang
  4828. * @param {*} value The value to check.
  4829. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  4830. * @example
  4831. *
  4832. * _.isSymbol(Symbol.iterator);
  4833. * // => true
  4834. *
  4835. * _.isSymbol('abc');
  4836. * // => false
  4837. */
  4838. function isSymbol(value) {
  4839. return typeof value == 'symbol' ||
  4840. (isObjectLike(value) && objectToString.call(value) == symbolTag);
  4841. }
  4842. /**
  4843. * Converts `value` to a string. An empty string is returned for `null`
  4844. * and `undefined` values. The sign of `-0` is preserved.
  4845. *
  4846. * @static
  4847. * @memberOf _
  4848. * @since 4.0.0
  4849. * @category Lang
  4850. * @param {*} value The value to process.
  4851. * @returns {string} Returns the string.
  4852. * @example
  4853. *
  4854. * _.toString(null);
  4855. * // => ''
  4856. *
  4857. * _.toString(-0);
  4858. * // => '-0'
  4859. *
  4860. * _.toString([1, 2, 3]);
  4861. * // => '1,2,3'
  4862. */
  4863. function toString(value) {
  4864. return value == null ? '' : baseToString(value);
  4865. }
  4866. /**
  4867. * Converts the first character of `string` to upper case.
  4868. *
  4869. * @static
  4870. * @memberOf _
  4871. * @since 4.0.0
  4872. * @category String
  4873. * @param {string} [string=''] The string to convert.
  4874. * @returns {string} Returns the converted string.
  4875. * @example
  4876. *
  4877. * _.upperFirst('fred');
  4878. * // => 'Fred'
  4879. *
  4880. * _.upperFirst('FRED');
  4881. * // => 'FRED'
  4882. */
  4883. var upperFirst = createCaseFirst('toUpperCase');
  4884. module.exports = upperFirst;
  4885. /***/ }),
  4886. /***/ 96486:
  4887. /***/ (function(module, exports, __webpack_require__) {
  4888. /* module decorator */ module = __webpack_require__.nmd(module);
  4889. var __WEBPACK_AMD_DEFINE_RESULT__;/**
  4890. * @license
  4891. * Lodash <https://lodash.com/>
  4892. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  4893. * Released under MIT license <https://lodash.com/license>
  4894. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  4895. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  4896. */
  4897. ;(function() {
  4898. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  4899. var undefined;
  4900. /** Used as the semantic version number. */
  4901. var VERSION = '4.17.21';
  4902. /** Used as the size to enable large array optimizations. */
  4903. var LARGE_ARRAY_SIZE = 200;
  4904. /** Error message constants. */
  4905. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  4906. FUNC_ERROR_TEXT = 'Expected a function',
  4907. INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`';
  4908. /** Used to stand-in for `undefined` hash values. */
  4909. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  4910. /** Used as the maximum memoize cache size. */
  4911. var MAX_MEMOIZE_SIZE = 500;
  4912. /** Used as the internal argument placeholder. */
  4913. var PLACEHOLDER = '__lodash_placeholder__';
  4914. /** Used to compose bitmasks for cloning. */
  4915. var CLONE_DEEP_FLAG = 1,
  4916. CLONE_FLAT_FLAG = 2,
  4917. CLONE_SYMBOLS_FLAG = 4;
  4918. /** Used to compose bitmasks for value comparisons. */
  4919. var COMPARE_PARTIAL_FLAG = 1,
  4920. COMPARE_UNORDERED_FLAG = 2;
  4921. /** Used to compose bitmasks for function metadata. */
  4922. var WRAP_BIND_FLAG = 1,
  4923. WRAP_BIND_KEY_FLAG = 2,
  4924. WRAP_CURRY_BOUND_FLAG = 4,
  4925. WRAP_CURRY_FLAG = 8,
  4926. WRAP_CURRY_RIGHT_FLAG = 16,
  4927. WRAP_PARTIAL_FLAG = 32,
  4928. WRAP_PARTIAL_RIGHT_FLAG = 64,
  4929. WRAP_ARY_FLAG = 128,
  4930. WRAP_REARG_FLAG = 256,
  4931. WRAP_FLIP_FLAG = 512;
  4932. /** Used as default options for `_.truncate`. */
  4933. var DEFAULT_TRUNC_LENGTH = 30,
  4934. DEFAULT_TRUNC_OMISSION = '...';
  4935. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  4936. var HOT_COUNT = 800,
  4937. HOT_SPAN = 16;
  4938. /** Used to indicate the type of lazy iteratees. */
  4939. var LAZY_FILTER_FLAG = 1,
  4940. LAZY_MAP_FLAG = 2,
  4941. LAZY_WHILE_FLAG = 3;
  4942. /** Used as references for various `Number` constants. */
  4943. var INFINITY = 1 / 0,
  4944. MAX_SAFE_INTEGER = 9007199254740991,
  4945. MAX_INTEGER = 1.7976931348623157e+308,
  4946. NAN = 0 / 0;
  4947. /** Used as references for the maximum length and index of an array. */
  4948. var MAX_ARRAY_LENGTH = 4294967295,
  4949. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  4950. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  4951. /** Used to associate wrap methods with their bit flags. */
  4952. var wrapFlags = [
  4953. ['ary', WRAP_ARY_FLAG],
  4954. ['bind', WRAP_BIND_FLAG],
  4955. ['bindKey', WRAP_BIND_KEY_FLAG],
  4956. ['curry', WRAP_CURRY_FLAG],
  4957. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  4958. ['flip', WRAP_FLIP_FLAG],
  4959. ['partial', WRAP_PARTIAL_FLAG],
  4960. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  4961. ['rearg', WRAP_REARG_FLAG]
  4962. ];
  4963. /** `Object#toString` result references. */
  4964. var argsTag = '[object Arguments]',
  4965. arrayTag = '[object Array]',
  4966. asyncTag = '[object AsyncFunction]',
  4967. boolTag = '[object Boolean]',
  4968. dateTag = '[object Date]',
  4969. domExcTag = '[object DOMException]',
  4970. errorTag = '[object Error]',
  4971. funcTag = '[object Function]',
  4972. genTag = '[object GeneratorFunction]',
  4973. mapTag = '[object Map]',
  4974. numberTag = '[object Number]',
  4975. nullTag = '[object Null]',
  4976. objectTag = '[object Object]',
  4977. promiseTag = '[object Promise]',
  4978. proxyTag = '[object Proxy]',
  4979. regexpTag = '[object RegExp]',
  4980. setTag = '[object Set]',
  4981. stringTag = '[object String]',
  4982. symbolTag = '[object Symbol]',
  4983. undefinedTag = '[object Undefined]',
  4984. weakMapTag = '[object WeakMap]',
  4985. weakSetTag = '[object WeakSet]';
  4986. var arrayBufferTag = '[object ArrayBuffer]',
  4987. dataViewTag = '[object DataView]',
  4988. float32Tag = '[object Float32Array]',
  4989. float64Tag = '[object Float64Array]',
  4990. int8Tag = '[object Int8Array]',
  4991. int16Tag = '[object Int16Array]',
  4992. int32Tag = '[object Int32Array]',
  4993. uint8Tag = '[object Uint8Array]',
  4994. uint8ClampedTag = '[object Uint8ClampedArray]',
  4995. uint16Tag = '[object Uint16Array]',
  4996. uint32Tag = '[object Uint32Array]';
  4997. /** Used to match empty string literals in compiled template source. */
  4998. var reEmptyStringLeading = /\b__p \+= '';/g,
  4999. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  5000. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  5001. /** Used to match HTML entities and HTML characters. */
  5002. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  5003. reUnescapedHtml = /[&<>"']/g,
  5004. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  5005. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  5006. /** Used to match template delimiters. */
  5007. var reEscape = /<%-([\s\S]+?)%>/g,
  5008. reEvaluate = /<%([\s\S]+?)%>/g,
  5009. reInterpolate = /<%=([\s\S]+?)%>/g;
  5010. /** Used to match property names within property paths. */
  5011. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  5012. reIsPlainProp = /^\w*$/,
  5013. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  5014. /**
  5015. * Used to match `RegExp`
  5016. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  5017. */
  5018. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  5019. reHasRegExpChar = RegExp(reRegExpChar.source);
  5020. /** Used to match leading whitespace. */
  5021. var reTrimStart = /^\s+/;
  5022. /** Used to match a single whitespace character. */
  5023. var reWhitespace = /\s/;
  5024. /** Used to match wrap detail comments. */
  5025. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  5026. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  5027. reSplitDetails = /,? & /;
  5028. /** Used to match words composed of alphanumeric characters. */
  5029. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  5030. /**
  5031. * Used to validate the `validate` option in `_.template` variable.
  5032. *
  5033. * Forbids characters which could potentially change the meaning of the function argument definition:
  5034. * - "()," (modification of function parameters)
  5035. * - "=" (default value)
  5036. * - "[]{}" (destructuring of function parameters)
  5037. * - "/" (beginning of a comment)
  5038. * - whitespace
  5039. */
  5040. var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/;
  5041. /** Used to match backslashes in property paths. */
  5042. var reEscapeChar = /\\(\\)?/g;
  5043. /**
  5044. * Used to match
  5045. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  5046. */
  5047. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  5048. /** Used to match `RegExp` flags from their coerced string values. */
  5049. var reFlags = /\w*$/;
  5050. /** Used to detect bad signed hexadecimal string values. */
  5051. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  5052. /** Used to detect binary string values. */
  5053. var reIsBinary = /^0b[01]+$/i;
  5054. /** Used to detect host constructors (Safari). */
  5055. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  5056. /** Used to detect octal string values. */
  5057. var reIsOctal = /^0o[0-7]+$/i;
  5058. /** Used to detect unsigned integer values. */
  5059. var reIsUint = /^(?:0|[1-9]\d*)$/;
  5060. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  5061. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  5062. /** Used to ensure capturing order of template delimiters. */
  5063. var reNoMatch = /($^)/;
  5064. /** Used to match unescaped characters in compiled string literals. */
  5065. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  5066. /** Used to compose unicode character classes. */
  5067. var rsAstralRange = '\\ud800-\\udfff',
  5068. rsComboMarksRange = '\\u0300-\\u036f',
  5069. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  5070. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  5071. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  5072. rsDingbatRange = '\\u2700-\\u27bf',
  5073. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  5074. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  5075. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  5076. rsPunctuationRange = '\\u2000-\\u206f',
  5077. rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',
  5078. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  5079. rsVarRange = '\\ufe0e\\ufe0f',
  5080. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  5081. /** Used to compose unicode capture groups. */
  5082. var rsApos = "['\u2019]",
  5083. rsAstral = '[' + rsAstralRange + ']',
  5084. rsBreak = '[' + rsBreakRange + ']',
  5085. rsCombo = '[' + rsComboRange + ']',
  5086. rsDigits = '\\d+',
  5087. rsDingbat = '[' + rsDingbatRange + ']',
  5088. rsLower = '[' + rsLowerRange + ']',
  5089. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  5090. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  5091. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  5092. rsNonAstral = '[^' + rsAstralRange + ']',
  5093. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  5094. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  5095. rsUpper = '[' + rsUpperRange + ']',
  5096. rsZWJ = '\\u200d';
  5097. /** Used to compose unicode regexes. */
  5098. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  5099. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  5100. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  5101. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  5102. reOptMod = rsModifier + '?',
  5103. rsOptVar = '[' + rsVarRange + ']?',
  5104. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  5105. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  5106. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  5107. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  5108. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  5109. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  5110. /** Used to match apostrophes. */
  5111. var reApos = RegExp(rsApos, 'g');
  5112. /**
  5113. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  5114. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  5115. */
  5116. var reComboMark = RegExp(rsCombo, 'g');
  5117. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  5118. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  5119. /** Used to match complex or compound words. */
  5120. var reUnicodeWord = RegExp([
  5121. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  5122. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  5123. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  5124. rsUpper + '+' + rsOptContrUpper,
  5125. rsOrdUpper,
  5126. rsOrdLower,
  5127. rsDigits,
  5128. rsEmoji
  5129. ].join('|'), 'g');
  5130. /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
  5131. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  5132. /** Used to detect strings that need a more robust regexp to match words. */
  5133. var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
  5134. /** Used to assign default `context` object properties. */
  5135. var contextProps = [
  5136. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  5137. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  5138. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  5139. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  5140. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  5141. ];
  5142. /** Used to make template sourceURLs easier to identify. */
  5143. var templateCounter = -1;
  5144. /** Used to identify `toStringTag` values of typed arrays. */
  5145. var typedArrayTags = {};
  5146. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  5147. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  5148. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  5149. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  5150. typedArrayTags[uint32Tag] = true;
  5151. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  5152. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  5153. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  5154. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  5155. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  5156. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  5157. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  5158. typedArrayTags[weakMapTag] = false;
  5159. /** Used to identify `toStringTag` values supported by `_.clone`. */
  5160. var cloneableTags = {};
  5161. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  5162. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  5163. cloneableTags[boolTag] = cloneableTags[dateTag] =
  5164. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  5165. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  5166. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  5167. cloneableTags[numberTag] = cloneableTags[objectTag] =
  5168. cloneableTags[regexpTag] = cloneableTags[setTag] =
  5169. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  5170. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  5171. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  5172. cloneableTags[errorTag] = cloneableTags[funcTag] =
  5173. cloneableTags[weakMapTag] = false;
  5174. /** Used to map Latin Unicode letters to basic Latin letters. */
  5175. var deburredLetters = {
  5176. // Latin-1 Supplement block.
  5177. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  5178. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  5179. '\xc7': 'C', '\xe7': 'c',
  5180. '\xd0': 'D', '\xf0': 'd',
  5181. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  5182. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  5183. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  5184. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  5185. '\xd1': 'N', '\xf1': 'n',
  5186. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  5187. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  5188. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  5189. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  5190. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  5191. '\xc6': 'Ae', '\xe6': 'ae',
  5192. '\xde': 'Th', '\xfe': 'th',
  5193. '\xdf': 'ss',
  5194. // Latin Extended-A block.
  5195. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  5196. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  5197. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  5198. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  5199. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  5200. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  5201. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  5202. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  5203. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  5204. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  5205. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  5206. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  5207. '\u0134': 'J', '\u0135': 'j',
  5208. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  5209. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  5210. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  5211. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  5212. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  5213. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  5214. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  5215. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  5216. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  5217. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  5218. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  5219. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  5220. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  5221. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  5222. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  5223. '\u0174': 'W', '\u0175': 'w',
  5224. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  5225. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  5226. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  5227. '\u0132': 'IJ', '\u0133': 'ij',
  5228. '\u0152': 'Oe', '\u0153': 'oe',
  5229. '\u0149': "'n", '\u017f': 's'
  5230. };
  5231. /** Used to map characters to HTML entities. */
  5232. var htmlEscapes = {
  5233. '&': '&amp;',
  5234. '<': '&lt;',
  5235. '>': '&gt;',
  5236. '"': '&quot;',
  5237. "'": '&#39;'
  5238. };
  5239. /** Used to map HTML entities to characters. */
  5240. var htmlUnescapes = {
  5241. '&amp;': '&',
  5242. '&lt;': '<',
  5243. '&gt;': '>',
  5244. '&quot;': '"',
  5245. '&#39;': "'"
  5246. };
  5247. /** Used to escape characters for inclusion in compiled string literals. */
  5248. var stringEscapes = {
  5249. '\\': '\\',
  5250. "'": "'",
  5251. '\n': 'n',
  5252. '\r': 'r',
  5253. '\u2028': 'u2028',
  5254. '\u2029': 'u2029'
  5255. };
  5256. /** Built-in method references without a dependency on `root`. */
  5257. var freeParseFloat = parseFloat,
  5258. freeParseInt = parseInt;
  5259. /** Detect free variable `global` from Node.js. */
  5260. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  5261. /** Detect free variable `self`. */
  5262. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  5263. /** Used as a reference to the global object. */
  5264. var root = freeGlobal || freeSelf || Function('return this')();
  5265. /** Detect free variable `exports`. */
  5266. var freeExports = true && exports && !exports.nodeType && exports;
  5267. /** Detect free variable `module`. */
  5268. var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module;
  5269. /** Detect the popular CommonJS extension `module.exports`. */
  5270. var moduleExports = freeModule && freeModule.exports === freeExports;
  5271. /** Detect free variable `process` from Node.js. */
  5272. var freeProcess = moduleExports && freeGlobal.process;
  5273. /** Used to access faster Node.js helpers. */
  5274. var nodeUtil = (function() {
  5275. try {
  5276. // Use `util.types` for Node.js 10+.
  5277. var types = freeModule && freeModule.require && freeModule.require('util').types;
  5278. if (types) {
  5279. return types;
  5280. }
  5281. // Legacy `process.binding('util')` for Node.js < 10.
  5282. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  5283. } catch (e) {}
  5284. }());
  5285. /* Node.js helper references. */
  5286. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  5287. nodeIsDate = nodeUtil && nodeUtil.isDate,
  5288. nodeIsMap = nodeUtil && nodeUtil.isMap,
  5289. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  5290. nodeIsSet = nodeUtil && nodeUtil.isSet,
  5291. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  5292. /*--------------------------------------------------------------------------*/
  5293. /**
  5294. * A faster alternative to `Function#apply`, this function invokes `func`
  5295. * with the `this` binding of `thisArg` and the arguments of `args`.
  5296. *
  5297. * @private
  5298. * @param {Function} func The function to invoke.
  5299. * @param {*} thisArg The `this` binding of `func`.
  5300. * @param {Array} args The arguments to invoke `func` with.
  5301. * @returns {*} Returns the result of `func`.
  5302. */
  5303. function apply(func, thisArg, args) {
  5304. switch (args.length) {
  5305. case 0: return func.call(thisArg);
  5306. case 1: return func.call(thisArg, args[0]);
  5307. case 2: return func.call(thisArg, args[0], args[1]);
  5308. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  5309. }
  5310. return func.apply(thisArg, args);
  5311. }
  5312. /**
  5313. * A specialized version of `baseAggregator` for arrays.
  5314. *
  5315. * @private
  5316. * @param {Array} [array] The array to iterate over.
  5317. * @param {Function} setter The function to set `accumulator` values.
  5318. * @param {Function} iteratee The iteratee to transform keys.
  5319. * @param {Object} accumulator The initial aggregated object.
  5320. * @returns {Function} Returns `accumulator`.
  5321. */
  5322. function arrayAggregator(array, setter, iteratee, accumulator) {
  5323. var index = -1,
  5324. length = array == null ? 0 : array.length;
  5325. while (++index < length) {
  5326. var value = array[index];
  5327. setter(accumulator, value, iteratee(value), array);
  5328. }
  5329. return accumulator;
  5330. }
  5331. /**
  5332. * A specialized version of `_.forEach` for arrays without support for
  5333. * iteratee shorthands.
  5334. *
  5335. * @private
  5336. * @param {Array} [array] The array to iterate over.
  5337. * @param {Function} iteratee The function invoked per iteration.
  5338. * @returns {Array} Returns `array`.
  5339. */
  5340. function arrayEach(array, iteratee) {
  5341. var index = -1,
  5342. length = array == null ? 0 : array.length;
  5343. while (++index < length) {
  5344. if (iteratee(array[index], index, array) === false) {
  5345. break;
  5346. }
  5347. }
  5348. return array;
  5349. }
  5350. /**
  5351. * A specialized version of `_.forEachRight` for arrays without support for
  5352. * iteratee shorthands.
  5353. *
  5354. * @private
  5355. * @param {Array} [array] The array to iterate over.
  5356. * @param {Function} iteratee The function invoked per iteration.
  5357. * @returns {Array} Returns `array`.
  5358. */
  5359. function arrayEachRight(array, iteratee) {
  5360. var length = array == null ? 0 : array.length;
  5361. while (length--) {
  5362. if (iteratee(array[length], length, array) === false) {
  5363. break;
  5364. }
  5365. }
  5366. return array;
  5367. }
  5368. /**
  5369. * A specialized version of `_.every` for arrays without support for
  5370. * iteratee shorthands.
  5371. *
  5372. * @private
  5373. * @param {Array} [array] The array to iterate over.
  5374. * @param {Function} predicate The function invoked per iteration.
  5375. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  5376. * else `false`.
  5377. */
  5378. function arrayEvery(array, predicate) {
  5379. var index = -1,
  5380. length = array == null ? 0 : array.length;
  5381. while (++index < length) {
  5382. if (!predicate(array[index], index, array)) {
  5383. return false;
  5384. }
  5385. }
  5386. return true;
  5387. }
  5388. /**
  5389. * A specialized version of `_.filter` for arrays without support for
  5390. * iteratee shorthands.
  5391. *
  5392. * @private
  5393. * @param {Array} [array] The array to iterate over.
  5394. * @param {Function} predicate The function invoked per iteration.
  5395. * @returns {Array} Returns the new filtered array.
  5396. */
  5397. function arrayFilter(array, predicate) {
  5398. var index = -1,
  5399. length = array == null ? 0 : array.length,
  5400. resIndex = 0,
  5401. result = [];
  5402. while (++index < length) {
  5403. var value = array[index];
  5404. if (predicate(value, index, array)) {
  5405. result[resIndex++] = value;
  5406. }
  5407. }
  5408. return result;
  5409. }
  5410. /**
  5411. * A specialized version of `_.includes` for arrays without support for
  5412. * specifying an index to search from.
  5413. *
  5414. * @private
  5415. * @param {Array} [array] The array to inspect.
  5416. * @param {*} target The value to search for.
  5417. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  5418. */
  5419. function arrayIncludes(array, value) {
  5420. var length = array == null ? 0 : array.length;
  5421. return !!length && baseIndexOf(array, value, 0) > -1;
  5422. }
  5423. /**
  5424. * This function is like `arrayIncludes` except that it accepts a comparator.
  5425. *
  5426. * @private
  5427. * @param {Array} [array] The array to inspect.
  5428. * @param {*} target The value to search for.
  5429. * @param {Function} comparator The comparator invoked per element.
  5430. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  5431. */
  5432. function arrayIncludesWith(array, value, comparator) {
  5433. var index = -1,
  5434. length = array == null ? 0 : array.length;
  5435. while (++index < length) {
  5436. if (comparator(value, array[index])) {
  5437. return true;
  5438. }
  5439. }
  5440. return false;
  5441. }
  5442. /**
  5443. * A specialized version of `_.map` for arrays without support for iteratee
  5444. * shorthands.
  5445. *
  5446. * @private
  5447. * @param {Array} [array] The array to iterate over.
  5448. * @param {Function} iteratee The function invoked per iteration.
  5449. * @returns {Array} Returns the new mapped array.
  5450. */
  5451. function arrayMap(array, iteratee) {
  5452. var index = -1,
  5453. length = array == null ? 0 : array.length,
  5454. result = Array(length);
  5455. while (++index < length) {
  5456. result[index] = iteratee(array[index], index, array);
  5457. }
  5458. return result;
  5459. }
  5460. /**
  5461. * Appends the elements of `values` to `array`.
  5462. *
  5463. * @private
  5464. * @param {Array} array The array to modify.
  5465. * @param {Array} values The values to append.
  5466. * @returns {Array} Returns `array`.
  5467. */
  5468. function arrayPush(array, values) {
  5469. var index = -1,
  5470. length = values.length,
  5471. offset = array.length;
  5472. while (++index < length) {
  5473. array[offset + index] = values[index];
  5474. }
  5475. return array;
  5476. }
  5477. /**
  5478. * A specialized version of `_.reduce` for arrays without support for
  5479. * iteratee shorthands.
  5480. *
  5481. * @private
  5482. * @param {Array} [array] The array to iterate over.
  5483. * @param {Function} iteratee The function invoked per iteration.
  5484. * @param {*} [accumulator] The initial value.
  5485. * @param {boolean} [initAccum] Specify using the first element of `array` as
  5486. * the initial value.
  5487. * @returns {*} Returns the accumulated value.
  5488. */
  5489. function arrayReduce(array, iteratee, accumulator, initAccum) {
  5490. var index = -1,
  5491. length = array == null ? 0 : array.length;
  5492. if (initAccum && length) {
  5493. accumulator = array[++index];
  5494. }
  5495. while (++index < length) {
  5496. accumulator = iteratee(accumulator, array[index], index, array);
  5497. }
  5498. return accumulator;
  5499. }
  5500. /**
  5501. * A specialized version of `_.reduceRight` for arrays without support for
  5502. * iteratee shorthands.
  5503. *
  5504. * @private
  5505. * @param {Array} [array] The array to iterate over.
  5506. * @param {Function} iteratee The function invoked per iteration.
  5507. * @param {*} [accumulator] The initial value.
  5508. * @param {boolean} [initAccum] Specify using the last element of `array` as
  5509. * the initial value.
  5510. * @returns {*} Returns the accumulated value.
  5511. */
  5512. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  5513. var length = array == null ? 0 : array.length;
  5514. if (initAccum && length) {
  5515. accumulator = array[--length];
  5516. }
  5517. while (length--) {
  5518. accumulator = iteratee(accumulator, array[length], length, array);
  5519. }
  5520. return accumulator;
  5521. }
  5522. /**
  5523. * A specialized version of `_.some` for arrays without support for iteratee
  5524. * shorthands.
  5525. *
  5526. * @private
  5527. * @param {Array} [array] The array to iterate over.
  5528. * @param {Function} predicate The function invoked per iteration.
  5529. * @returns {boolean} Returns `true` if any element passes the predicate check,
  5530. * else `false`.
  5531. */
  5532. function arraySome(array, predicate) {
  5533. var index = -1,
  5534. length = array == null ? 0 : array.length;
  5535. while (++index < length) {
  5536. if (predicate(array[index], index, array)) {
  5537. return true;
  5538. }
  5539. }
  5540. return false;
  5541. }
  5542. /**
  5543. * Gets the size of an ASCII `string`.
  5544. *
  5545. * @private
  5546. * @param {string} string The string inspect.
  5547. * @returns {number} Returns the string size.
  5548. */
  5549. var asciiSize = baseProperty('length');
  5550. /**
  5551. * Converts an ASCII `string` to an array.
  5552. *
  5553. * @private
  5554. * @param {string} string The string to convert.
  5555. * @returns {Array} Returns the converted array.
  5556. */
  5557. function asciiToArray(string) {
  5558. return string.split('');
  5559. }
  5560. /**
  5561. * Splits an ASCII `string` into an array of its words.
  5562. *
  5563. * @private
  5564. * @param {string} The string to inspect.
  5565. * @returns {Array} Returns the words of `string`.
  5566. */
  5567. function asciiWords(string) {
  5568. return string.match(reAsciiWord) || [];
  5569. }
  5570. /**
  5571. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  5572. * without support for iteratee shorthands, which iterates over `collection`
  5573. * using `eachFunc`.
  5574. *
  5575. * @private
  5576. * @param {Array|Object} collection The collection to inspect.
  5577. * @param {Function} predicate The function invoked per iteration.
  5578. * @param {Function} eachFunc The function to iterate over `collection`.
  5579. * @returns {*} Returns the found element or its key, else `undefined`.
  5580. */
  5581. function baseFindKey(collection, predicate, eachFunc) {
  5582. var result;
  5583. eachFunc(collection, function(value, key, collection) {
  5584. if (predicate(value, key, collection)) {
  5585. result = key;
  5586. return false;
  5587. }
  5588. });
  5589. return result;
  5590. }
  5591. /**
  5592. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  5593. * support for iteratee shorthands.
  5594. *
  5595. * @private
  5596. * @param {Array} array The array to inspect.
  5597. * @param {Function} predicate The function invoked per iteration.
  5598. * @param {number} fromIndex The index to search from.
  5599. * @param {boolean} [fromRight] Specify iterating from right to left.
  5600. * @returns {number} Returns the index of the matched value, else `-1`.
  5601. */
  5602. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  5603. var length = array.length,
  5604. index = fromIndex + (fromRight ? 1 : -1);
  5605. while ((fromRight ? index-- : ++index < length)) {
  5606. if (predicate(array[index], index, array)) {
  5607. return index;
  5608. }
  5609. }
  5610. return -1;
  5611. }
  5612. /**
  5613. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  5614. *
  5615. * @private
  5616. * @param {Array} array The array to inspect.
  5617. * @param {*} value The value to search for.
  5618. * @param {number} fromIndex The index to search from.
  5619. * @returns {number} Returns the index of the matched value, else `-1`.
  5620. */
  5621. function baseIndexOf(array, value, fromIndex) {
  5622. return value === value
  5623. ? strictIndexOf(array, value, fromIndex)
  5624. : baseFindIndex(array, baseIsNaN, fromIndex);
  5625. }
  5626. /**
  5627. * This function is like `baseIndexOf` except that it accepts a comparator.
  5628. *
  5629. * @private
  5630. * @param {Array} array The array to inspect.
  5631. * @param {*} value The value to search for.
  5632. * @param {number} fromIndex The index to search from.
  5633. * @param {Function} comparator The comparator invoked per element.
  5634. * @returns {number} Returns the index of the matched value, else `-1`.
  5635. */
  5636. function baseIndexOfWith(array, value, fromIndex, comparator) {
  5637. var index = fromIndex - 1,
  5638. length = array.length;
  5639. while (++index < length) {
  5640. if (comparator(array[index], value)) {
  5641. return index;
  5642. }
  5643. }
  5644. return -1;
  5645. }
  5646. /**
  5647. * The base implementation of `_.isNaN` without support for number objects.
  5648. *
  5649. * @private
  5650. * @param {*} value The value to check.
  5651. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  5652. */
  5653. function baseIsNaN(value) {
  5654. return value !== value;
  5655. }
  5656. /**
  5657. * The base implementation of `_.mean` and `_.meanBy` without support for
  5658. * iteratee shorthands.
  5659. *
  5660. * @private
  5661. * @param {Array} array The array to iterate over.
  5662. * @param {Function} iteratee The function invoked per iteration.
  5663. * @returns {number} Returns the mean.
  5664. */
  5665. function baseMean(array, iteratee) {
  5666. var length = array == null ? 0 : array.length;
  5667. return length ? (baseSum(array, iteratee) / length) : NAN;
  5668. }
  5669. /**
  5670. * The base implementation of `_.property` without support for deep paths.
  5671. *
  5672. * @private
  5673. * @param {string} key The key of the property to get.
  5674. * @returns {Function} Returns the new accessor function.
  5675. */
  5676. function baseProperty(key) {
  5677. return function(object) {
  5678. return object == null ? undefined : object[key];
  5679. };
  5680. }
  5681. /**
  5682. * The base implementation of `_.propertyOf` without support for deep paths.
  5683. *
  5684. * @private
  5685. * @param {Object} object The object to query.
  5686. * @returns {Function} Returns the new accessor function.
  5687. */
  5688. function basePropertyOf(object) {
  5689. return function(key) {
  5690. return object == null ? undefined : object[key];
  5691. };
  5692. }
  5693. /**
  5694. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  5695. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  5696. *
  5697. * @private
  5698. * @param {Array|Object} collection The collection to iterate over.
  5699. * @param {Function} iteratee The function invoked per iteration.
  5700. * @param {*} accumulator The initial value.
  5701. * @param {boolean} initAccum Specify using the first or last element of
  5702. * `collection` as the initial value.
  5703. * @param {Function} eachFunc The function to iterate over `collection`.
  5704. * @returns {*} Returns the accumulated value.
  5705. */
  5706. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  5707. eachFunc(collection, function(value, index, collection) {
  5708. accumulator = initAccum
  5709. ? (initAccum = false, value)
  5710. : iteratee(accumulator, value, index, collection);
  5711. });
  5712. return accumulator;
  5713. }
  5714. /**
  5715. * The base implementation of `_.sortBy` which uses `comparer` to define the
  5716. * sort order of `array` and replaces criteria objects with their corresponding
  5717. * values.
  5718. *
  5719. * @private
  5720. * @param {Array} array The array to sort.
  5721. * @param {Function} comparer The function to define sort order.
  5722. * @returns {Array} Returns `array`.
  5723. */
  5724. function baseSortBy(array, comparer) {
  5725. var length = array.length;
  5726. array.sort(comparer);
  5727. while (length--) {
  5728. array[length] = array[length].value;
  5729. }
  5730. return array;
  5731. }
  5732. /**
  5733. * The base implementation of `_.sum` and `_.sumBy` without support for
  5734. * iteratee shorthands.
  5735. *
  5736. * @private
  5737. * @param {Array} array The array to iterate over.
  5738. * @param {Function} iteratee The function invoked per iteration.
  5739. * @returns {number} Returns the sum.
  5740. */
  5741. function baseSum(array, iteratee) {
  5742. var result,
  5743. index = -1,
  5744. length = array.length;
  5745. while (++index < length) {
  5746. var current = iteratee(array[index]);
  5747. if (current !== undefined) {
  5748. result = result === undefined ? current : (result + current);
  5749. }
  5750. }
  5751. return result;
  5752. }
  5753. /**
  5754. * The base implementation of `_.times` without support for iteratee shorthands
  5755. * or max array length checks.
  5756. *
  5757. * @private
  5758. * @param {number} n The number of times to invoke `iteratee`.
  5759. * @param {Function} iteratee The function invoked per iteration.
  5760. * @returns {Array} Returns the array of results.
  5761. */
  5762. function baseTimes(n, iteratee) {
  5763. var index = -1,
  5764. result = Array(n);
  5765. while (++index < n) {
  5766. result[index] = iteratee(index);
  5767. }
  5768. return result;
  5769. }
  5770. /**
  5771. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  5772. * of key-value pairs for `object` corresponding to the property names of `props`.
  5773. *
  5774. * @private
  5775. * @param {Object} object The object to query.
  5776. * @param {Array} props The property names to get values for.
  5777. * @returns {Object} Returns the key-value pairs.
  5778. */
  5779. function baseToPairs(object, props) {
  5780. return arrayMap(props, function(key) {
  5781. return [key, object[key]];
  5782. });
  5783. }
  5784. /**
  5785. * The base implementation of `_.trim`.
  5786. *
  5787. * @private
  5788. * @param {string} string The string to trim.
  5789. * @returns {string} Returns the trimmed string.
  5790. */
  5791. function baseTrim(string) {
  5792. return string
  5793. ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
  5794. : string;
  5795. }
  5796. /**
  5797. * The base implementation of `_.unary` without support for storing metadata.
  5798. *
  5799. * @private
  5800. * @param {Function} func The function to cap arguments for.
  5801. * @returns {Function} Returns the new capped function.
  5802. */
  5803. function baseUnary(func) {
  5804. return function(value) {
  5805. return func(value);
  5806. };
  5807. }
  5808. /**
  5809. * The base implementation of `_.values` and `_.valuesIn` which creates an
  5810. * array of `object` property values corresponding to the property names
  5811. * of `props`.
  5812. *
  5813. * @private
  5814. * @param {Object} object The object to query.
  5815. * @param {Array} props The property names to get values for.
  5816. * @returns {Object} Returns the array of property values.
  5817. */
  5818. function baseValues(object, props) {
  5819. return arrayMap(props, function(key) {
  5820. return object[key];
  5821. });
  5822. }
  5823. /**
  5824. * Checks if a `cache` value for `key` exists.
  5825. *
  5826. * @private
  5827. * @param {Object} cache The cache to query.
  5828. * @param {string} key The key of the entry to check.
  5829. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  5830. */
  5831. function cacheHas(cache, key) {
  5832. return cache.has(key);
  5833. }
  5834. /**
  5835. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  5836. * that is not found in the character symbols.
  5837. *
  5838. * @private
  5839. * @param {Array} strSymbols The string symbols to inspect.
  5840. * @param {Array} chrSymbols The character symbols to find.
  5841. * @returns {number} Returns the index of the first unmatched string symbol.
  5842. */
  5843. function charsStartIndex(strSymbols, chrSymbols) {
  5844. var index = -1,
  5845. length = strSymbols.length;
  5846. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  5847. return index;
  5848. }
  5849. /**
  5850. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  5851. * that is not found in the character symbols.
  5852. *
  5853. * @private
  5854. * @param {Array} strSymbols The string symbols to inspect.
  5855. * @param {Array} chrSymbols The character symbols to find.
  5856. * @returns {number} Returns the index of the last unmatched string symbol.
  5857. */
  5858. function charsEndIndex(strSymbols, chrSymbols) {
  5859. var index = strSymbols.length;
  5860. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  5861. return index;
  5862. }
  5863. /**
  5864. * Gets the number of `placeholder` occurrences in `array`.
  5865. *
  5866. * @private
  5867. * @param {Array} array The array to inspect.
  5868. * @param {*} placeholder The placeholder to search for.
  5869. * @returns {number} Returns the placeholder count.
  5870. */
  5871. function countHolders(array, placeholder) {
  5872. var length = array.length,
  5873. result = 0;
  5874. while (length--) {
  5875. if (array[length] === placeholder) {
  5876. ++result;
  5877. }
  5878. }
  5879. return result;
  5880. }
  5881. /**
  5882. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  5883. * letters to basic Latin letters.
  5884. *
  5885. * @private
  5886. * @param {string} letter The matched letter to deburr.
  5887. * @returns {string} Returns the deburred letter.
  5888. */
  5889. var deburrLetter = basePropertyOf(deburredLetters);
  5890. /**
  5891. * Used by `_.escape` to convert characters to HTML entities.
  5892. *
  5893. * @private
  5894. * @param {string} chr The matched character to escape.
  5895. * @returns {string} Returns the escaped character.
  5896. */
  5897. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  5898. /**
  5899. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  5900. *
  5901. * @private
  5902. * @param {string} chr The matched character to escape.
  5903. * @returns {string} Returns the escaped character.
  5904. */
  5905. function escapeStringChar(chr) {
  5906. return '\\' + stringEscapes[chr];
  5907. }
  5908. /**
  5909. * Gets the value at `key` of `object`.
  5910. *
  5911. * @private
  5912. * @param {Object} [object] The object to query.
  5913. * @param {string} key The key of the property to get.
  5914. * @returns {*} Returns the property value.
  5915. */
  5916. function getValue(object, key) {
  5917. return object == null ? undefined : object[key];
  5918. }
  5919. /**
  5920. * Checks if `string` contains Unicode symbols.
  5921. *
  5922. * @private
  5923. * @param {string} string The string to inspect.
  5924. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  5925. */
  5926. function hasUnicode(string) {
  5927. return reHasUnicode.test(string);
  5928. }
  5929. /**
  5930. * Checks if `string` contains a word composed of Unicode symbols.
  5931. *
  5932. * @private
  5933. * @param {string} string The string to inspect.
  5934. * @returns {boolean} Returns `true` if a word is found, else `false`.
  5935. */
  5936. function hasUnicodeWord(string) {
  5937. return reHasUnicodeWord.test(string);
  5938. }
  5939. /**
  5940. * Converts `iterator` to an array.
  5941. *
  5942. * @private
  5943. * @param {Object} iterator The iterator to convert.
  5944. * @returns {Array} Returns the converted array.
  5945. */
  5946. function iteratorToArray(iterator) {
  5947. var data,
  5948. result = [];
  5949. while (!(data = iterator.next()).done) {
  5950. result.push(data.value);
  5951. }
  5952. return result;
  5953. }
  5954. /**
  5955. * Converts `map` to its key-value pairs.
  5956. *
  5957. * @private
  5958. * @param {Object} map The map to convert.
  5959. * @returns {Array} Returns the key-value pairs.
  5960. */
  5961. function mapToArray(map) {
  5962. var index = -1,
  5963. result = Array(map.size);
  5964. map.forEach(function(value, key) {
  5965. result[++index] = [key, value];
  5966. });
  5967. return result;
  5968. }
  5969. /**
  5970. * Creates a unary function that invokes `func` with its argument transformed.
  5971. *
  5972. * @private
  5973. * @param {Function} func The function to wrap.
  5974. * @param {Function} transform The argument transform.
  5975. * @returns {Function} Returns the new function.
  5976. */
  5977. function overArg(func, transform) {
  5978. return function(arg) {
  5979. return func(transform(arg));
  5980. };
  5981. }
  5982. /**
  5983. * Replaces all `placeholder` elements in `array` with an internal placeholder
  5984. * and returns an array of their indexes.
  5985. *
  5986. * @private
  5987. * @param {Array} array The array to modify.
  5988. * @param {*} placeholder The placeholder to replace.
  5989. * @returns {Array} Returns the new array of placeholder indexes.
  5990. */
  5991. function replaceHolders(array, placeholder) {
  5992. var index = -1,
  5993. length = array.length,
  5994. resIndex = 0,
  5995. result = [];
  5996. while (++index < length) {
  5997. var value = array[index];
  5998. if (value === placeholder || value === PLACEHOLDER) {
  5999. array[index] = PLACEHOLDER;
  6000. result[resIndex++] = index;
  6001. }
  6002. }
  6003. return result;
  6004. }
  6005. /**
  6006. * Converts `set` to an array of its values.
  6007. *
  6008. * @private
  6009. * @param {Object} set The set to convert.
  6010. * @returns {Array} Returns the values.
  6011. */
  6012. function setToArray(set) {
  6013. var index = -1,
  6014. result = Array(set.size);
  6015. set.forEach(function(value) {
  6016. result[++index] = value;
  6017. });
  6018. return result;
  6019. }
  6020. /**
  6021. * Converts `set` to its value-value pairs.
  6022. *
  6023. * @private
  6024. * @param {Object} set The set to convert.
  6025. * @returns {Array} Returns the value-value pairs.
  6026. */
  6027. function setToPairs(set) {
  6028. var index = -1,
  6029. result = Array(set.size);
  6030. set.forEach(function(value) {
  6031. result[++index] = [value, value];
  6032. });
  6033. return result;
  6034. }
  6035. /**
  6036. * A specialized version of `_.indexOf` which performs strict equality
  6037. * comparisons of values, i.e. `===`.
  6038. *
  6039. * @private
  6040. * @param {Array} array The array to inspect.
  6041. * @param {*} value The value to search for.
  6042. * @param {number} fromIndex The index to search from.
  6043. * @returns {number} Returns the index of the matched value, else `-1`.
  6044. */
  6045. function strictIndexOf(array, value, fromIndex) {
  6046. var index = fromIndex - 1,
  6047. length = array.length;
  6048. while (++index < length) {
  6049. if (array[index] === value) {
  6050. return index;
  6051. }
  6052. }
  6053. return -1;
  6054. }
  6055. /**
  6056. * A specialized version of `_.lastIndexOf` which performs strict equality
  6057. * comparisons of values, i.e. `===`.
  6058. *
  6059. * @private
  6060. * @param {Array} array The array to inspect.
  6061. * @param {*} value The value to search for.
  6062. * @param {number} fromIndex The index to search from.
  6063. * @returns {number} Returns the index of the matched value, else `-1`.
  6064. */
  6065. function strictLastIndexOf(array, value, fromIndex) {
  6066. var index = fromIndex + 1;
  6067. while (index--) {
  6068. if (array[index] === value) {
  6069. return index;
  6070. }
  6071. }
  6072. return index;
  6073. }
  6074. /**
  6075. * Gets the number of symbols in `string`.
  6076. *
  6077. * @private
  6078. * @param {string} string The string to inspect.
  6079. * @returns {number} Returns the string size.
  6080. */
  6081. function stringSize(string) {
  6082. return hasUnicode(string)
  6083. ? unicodeSize(string)
  6084. : asciiSize(string);
  6085. }
  6086. /**
  6087. * Converts `string` to an array.
  6088. *
  6089. * @private
  6090. * @param {string} string The string to convert.
  6091. * @returns {Array} Returns the converted array.
  6092. */
  6093. function stringToArray(string) {
  6094. return hasUnicode(string)
  6095. ? unicodeToArray(string)
  6096. : asciiToArray(string);
  6097. }
  6098. /**
  6099. * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
  6100. * character of `string`.
  6101. *
  6102. * @private
  6103. * @param {string} string The string to inspect.
  6104. * @returns {number} Returns the index of the last non-whitespace character.
  6105. */
  6106. function trimmedEndIndex(string) {
  6107. var index = string.length;
  6108. while (index-- && reWhitespace.test(string.charAt(index))) {}
  6109. return index;
  6110. }
  6111. /**
  6112. * Used by `_.unescape` to convert HTML entities to characters.
  6113. *
  6114. * @private
  6115. * @param {string} chr The matched character to unescape.
  6116. * @returns {string} Returns the unescaped character.
  6117. */
  6118. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  6119. /**
  6120. * Gets the size of a Unicode `string`.
  6121. *
  6122. * @private
  6123. * @param {string} string The string inspect.
  6124. * @returns {number} Returns the string size.
  6125. */
  6126. function unicodeSize(string) {
  6127. var result = reUnicode.lastIndex = 0;
  6128. while (reUnicode.test(string)) {
  6129. ++result;
  6130. }
  6131. return result;
  6132. }
  6133. /**
  6134. * Converts a Unicode `string` to an array.
  6135. *
  6136. * @private
  6137. * @param {string} string The string to convert.
  6138. * @returns {Array} Returns the converted array.
  6139. */
  6140. function unicodeToArray(string) {
  6141. return string.match(reUnicode) || [];
  6142. }
  6143. /**
  6144. * Splits a Unicode `string` into an array of its words.
  6145. *
  6146. * @private
  6147. * @param {string} The string to inspect.
  6148. * @returns {Array} Returns the words of `string`.
  6149. */
  6150. function unicodeWords(string) {
  6151. return string.match(reUnicodeWord) || [];
  6152. }
  6153. /*--------------------------------------------------------------------------*/
  6154. /**
  6155. * Create a new pristine `lodash` function using the `context` object.
  6156. *
  6157. * @static
  6158. * @memberOf _
  6159. * @since 1.1.0
  6160. * @category Util
  6161. * @param {Object} [context=root] The context object.
  6162. * @returns {Function} Returns a new `lodash` function.
  6163. * @example
  6164. *
  6165. * _.mixin({ 'foo': _.constant('foo') });
  6166. *
  6167. * var lodash = _.runInContext();
  6168. * lodash.mixin({ 'bar': lodash.constant('bar') });
  6169. *
  6170. * _.isFunction(_.foo);
  6171. * // => true
  6172. * _.isFunction(_.bar);
  6173. * // => false
  6174. *
  6175. * lodash.isFunction(lodash.foo);
  6176. * // => false
  6177. * lodash.isFunction(lodash.bar);
  6178. * // => true
  6179. *
  6180. * // Create a suped-up `defer` in Node.js.
  6181. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  6182. */
  6183. var runInContext = (function runInContext(context) {
  6184. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  6185. /** Built-in constructor references. */
  6186. var Array = context.Array,
  6187. Date = context.Date,
  6188. Error = context.Error,
  6189. Function = context.Function,
  6190. Math = context.Math,
  6191. Object = context.Object,
  6192. RegExp = context.RegExp,
  6193. String = context.String,
  6194. TypeError = context.TypeError;
  6195. /** Used for built-in method references. */
  6196. var arrayProto = Array.prototype,
  6197. funcProto = Function.prototype,
  6198. objectProto = Object.prototype;
  6199. /** Used to detect overreaching core-js shims. */
  6200. var coreJsData = context['__core-js_shared__'];
  6201. /** Used to resolve the decompiled source of functions. */
  6202. var funcToString = funcProto.toString;
  6203. /** Used to check objects for own properties. */
  6204. var hasOwnProperty = objectProto.hasOwnProperty;
  6205. /** Used to generate unique IDs. */
  6206. var idCounter = 0;
  6207. /** Used to detect methods masquerading as native. */
  6208. var maskSrcKey = (function() {
  6209. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  6210. return uid ? ('Symbol(src)_1.' + uid) : '';
  6211. }());
  6212. /**
  6213. * Used to resolve the
  6214. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  6215. * of values.
  6216. */
  6217. var nativeObjectToString = objectProto.toString;
  6218. /** Used to infer the `Object` constructor. */
  6219. var objectCtorString = funcToString.call(Object);
  6220. /** Used to restore the original `_` reference in `_.noConflict`. */
  6221. var oldDash = root._;
  6222. /** Used to detect if a method is native. */
  6223. var reIsNative = RegExp('^' +
  6224. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  6225. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  6226. );
  6227. /** Built-in value references. */
  6228. var Buffer = moduleExports ? context.Buffer : undefined,
  6229. Symbol = context.Symbol,
  6230. Uint8Array = context.Uint8Array,
  6231. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  6232. getPrototype = overArg(Object.getPrototypeOf, Object),
  6233. objectCreate = Object.create,
  6234. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  6235. splice = arrayProto.splice,
  6236. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  6237. symIterator = Symbol ? Symbol.iterator : undefined,
  6238. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  6239. var defineProperty = (function() {
  6240. try {
  6241. var func = getNative(Object, 'defineProperty');
  6242. func({}, '', {});
  6243. return func;
  6244. } catch (e) {}
  6245. }());
  6246. /** Mocked built-ins. */
  6247. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  6248. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  6249. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  6250. /* Built-in method references for those with the same name as other `lodash` methods. */
  6251. var nativeCeil = Math.ceil,
  6252. nativeFloor = Math.floor,
  6253. nativeGetSymbols = Object.getOwnPropertySymbols,
  6254. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  6255. nativeIsFinite = context.isFinite,
  6256. nativeJoin = arrayProto.join,
  6257. nativeKeys = overArg(Object.keys, Object),
  6258. nativeMax = Math.max,
  6259. nativeMin = Math.min,
  6260. nativeNow = Date.now,
  6261. nativeParseInt = context.parseInt,
  6262. nativeRandom = Math.random,
  6263. nativeReverse = arrayProto.reverse;
  6264. /* Built-in method references that are verified to be native. */
  6265. var DataView = getNative(context, 'DataView'),
  6266. Map = getNative(context, 'Map'),
  6267. Promise = getNative(context, 'Promise'),
  6268. Set = getNative(context, 'Set'),
  6269. WeakMap = getNative(context, 'WeakMap'),
  6270. nativeCreate = getNative(Object, 'create');
  6271. /** Used to store function metadata. */
  6272. var metaMap = WeakMap && new WeakMap;
  6273. /** Used to lookup unminified function names. */
  6274. var realNames = {};
  6275. /** Used to detect maps, sets, and weakmaps. */
  6276. var dataViewCtorString = toSource(DataView),
  6277. mapCtorString = toSource(Map),
  6278. promiseCtorString = toSource(Promise),
  6279. setCtorString = toSource(Set),
  6280. weakMapCtorString = toSource(WeakMap);
  6281. /** Used to convert symbols to primitives and strings. */
  6282. var symbolProto = Symbol ? Symbol.prototype : undefined,
  6283. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  6284. symbolToString = symbolProto ? symbolProto.toString : undefined;
  6285. /*------------------------------------------------------------------------*/
  6286. /**
  6287. * Creates a `lodash` object which wraps `value` to enable implicit method
  6288. * chain sequences. Methods that operate on and return arrays, collections,
  6289. * and functions can be chained together. Methods that retrieve a single value
  6290. * or may return a primitive value will automatically end the chain sequence
  6291. * and return the unwrapped value. Otherwise, the value must be unwrapped
  6292. * with `_#value`.
  6293. *
  6294. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  6295. * enabled using `_.chain`.
  6296. *
  6297. * The execution of chained methods is lazy, that is, it's deferred until
  6298. * `_#value` is implicitly or explicitly called.
  6299. *
  6300. * Lazy evaluation allows several methods to support shortcut fusion.
  6301. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  6302. * the creation of intermediate arrays and can greatly reduce the number of
  6303. * iteratee executions. Sections of a chain sequence qualify for shortcut
  6304. * fusion if the section is applied to an array and iteratees accept only
  6305. * one argument. The heuristic for whether a section qualifies for shortcut
  6306. * fusion is subject to change.
  6307. *
  6308. * Chaining is supported in custom builds as long as the `_#value` method is
  6309. * directly or indirectly included in the build.
  6310. *
  6311. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  6312. *
  6313. * The wrapper `Array` methods are:
  6314. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  6315. *
  6316. * The wrapper `String` methods are:
  6317. * `replace` and `split`
  6318. *
  6319. * The wrapper methods that support shortcut fusion are:
  6320. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  6321. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  6322. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  6323. *
  6324. * The chainable wrapper methods are:
  6325. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  6326. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  6327. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  6328. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  6329. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  6330. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  6331. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  6332. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  6333. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  6334. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  6335. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  6336. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  6337. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  6338. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  6339. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  6340. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  6341. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  6342. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  6343. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  6344. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  6345. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  6346. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  6347. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  6348. * `zipObject`, `zipObjectDeep`, and `zipWith`
  6349. *
  6350. * The wrapper methods that are **not** chainable by default are:
  6351. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  6352. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  6353. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  6354. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  6355. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  6356. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  6357. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  6358. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  6359. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  6360. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  6361. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  6362. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  6363. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  6364. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  6365. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  6366. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  6367. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  6368. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  6369. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  6370. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  6371. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  6372. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  6373. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  6374. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  6375. * `upperFirst`, `value`, and `words`
  6376. *
  6377. * @name _
  6378. * @constructor
  6379. * @category Seq
  6380. * @param {*} value The value to wrap in a `lodash` instance.
  6381. * @returns {Object} Returns the new `lodash` wrapper instance.
  6382. * @example
  6383. *
  6384. * function square(n) {
  6385. * return n * n;
  6386. * }
  6387. *
  6388. * var wrapped = _([1, 2, 3]);
  6389. *
  6390. * // Returns an unwrapped value.
  6391. * wrapped.reduce(_.add);
  6392. * // => 6
  6393. *
  6394. * // Returns a wrapped value.
  6395. * var squares = wrapped.map(square);
  6396. *
  6397. * _.isArray(squares);
  6398. * // => false
  6399. *
  6400. * _.isArray(squares.value());
  6401. * // => true
  6402. */
  6403. function lodash(value) {
  6404. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  6405. if (value instanceof LodashWrapper) {
  6406. return value;
  6407. }
  6408. if (hasOwnProperty.call(value, '__wrapped__')) {
  6409. return wrapperClone(value);
  6410. }
  6411. }
  6412. return new LodashWrapper(value);
  6413. }
  6414. /**
  6415. * The base implementation of `_.create` without support for assigning
  6416. * properties to the created object.
  6417. *
  6418. * @private
  6419. * @param {Object} proto The object to inherit from.
  6420. * @returns {Object} Returns the new object.
  6421. */
  6422. var baseCreate = (function() {
  6423. function object() {}
  6424. return function(proto) {
  6425. if (!isObject(proto)) {
  6426. return {};
  6427. }
  6428. if (objectCreate) {
  6429. return objectCreate(proto);
  6430. }
  6431. object.prototype = proto;
  6432. var result = new object;
  6433. object.prototype = undefined;
  6434. return result;
  6435. };
  6436. }());
  6437. /**
  6438. * The function whose prototype chain sequence wrappers inherit from.
  6439. *
  6440. * @private
  6441. */
  6442. function baseLodash() {
  6443. // No operation performed.
  6444. }
  6445. /**
  6446. * The base constructor for creating `lodash` wrapper objects.
  6447. *
  6448. * @private
  6449. * @param {*} value The value to wrap.
  6450. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  6451. */
  6452. function LodashWrapper(value, chainAll) {
  6453. this.__wrapped__ = value;
  6454. this.__actions__ = [];
  6455. this.__chain__ = !!chainAll;
  6456. this.__index__ = 0;
  6457. this.__values__ = undefined;
  6458. }
  6459. /**
  6460. * By default, the template delimiters used by lodash are like those in
  6461. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  6462. * following template settings to use alternative delimiters.
  6463. *
  6464. * @static
  6465. * @memberOf _
  6466. * @type {Object}
  6467. */
  6468. lodash.templateSettings = {
  6469. /**
  6470. * Used to detect `data` property values to be HTML-escaped.
  6471. *
  6472. * @memberOf _.templateSettings
  6473. * @type {RegExp}
  6474. */
  6475. 'escape': reEscape,
  6476. /**
  6477. * Used to detect code to be evaluated.
  6478. *
  6479. * @memberOf _.templateSettings
  6480. * @type {RegExp}
  6481. */
  6482. 'evaluate': reEvaluate,
  6483. /**
  6484. * Used to detect `data` property values to inject.
  6485. *
  6486. * @memberOf _.templateSettings
  6487. * @type {RegExp}
  6488. */
  6489. 'interpolate': reInterpolate,
  6490. /**
  6491. * Used to reference the data object in the template text.
  6492. *
  6493. * @memberOf _.templateSettings
  6494. * @type {string}
  6495. */
  6496. 'variable': '',
  6497. /**
  6498. * Used to import variables into the compiled template.
  6499. *
  6500. * @memberOf _.templateSettings
  6501. * @type {Object}
  6502. */
  6503. 'imports': {
  6504. /**
  6505. * A reference to the `lodash` function.
  6506. *
  6507. * @memberOf _.templateSettings.imports
  6508. * @type {Function}
  6509. */
  6510. '_': lodash
  6511. }
  6512. };
  6513. // Ensure wrappers are instances of `baseLodash`.
  6514. lodash.prototype = baseLodash.prototype;
  6515. lodash.prototype.constructor = lodash;
  6516. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  6517. LodashWrapper.prototype.constructor = LodashWrapper;
  6518. /*------------------------------------------------------------------------*/
  6519. /**
  6520. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  6521. *
  6522. * @private
  6523. * @constructor
  6524. * @param {*} value The value to wrap.
  6525. */
  6526. function LazyWrapper(value) {
  6527. this.__wrapped__ = value;
  6528. this.__actions__ = [];
  6529. this.__dir__ = 1;
  6530. this.__filtered__ = false;
  6531. this.__iteratees__ = [];
  6532. this.__takeCount__ = MAX_ARRAY_LENGTH;
  6533. this.__views__ = [];
  6534. }
  6535. /**
  6536. * Creates a clone of the lazy wrapper object.
  6537. *
  6538. * @private
  6539. * @name clone
  6540. * @memberOf LazyWrapper
  6541. * @returns {Object} Returns the cloned `LazyWrapper` object.
  6542. */
  6543. function lazyClone() {
  6544. var result = new LazyWrapper(this.__wrapped__);
  6545. result.__actions__ = copyArray(this.__actions__);
  6546. result.__dir__ = this.__dir__;
  6547. result.__filtered__ = this.__filtered__;
  6548. result.__iteratees__ = copyArray(this.__iteratees__);
  6549. result.__takeCount__ = this.__takeCount__;
  6550. result.__views__ = copyArray(this.__views__);
  6551. return result;
  6552. }
  6553. /**
  6554. * Reverses the direction of lazy iteration.
  6555. *
  6556. * @private
  6557. * @name reverse
  6558. * @memberOf LazyWrapper
  6559. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  6560. */
  6561. function lazyReverse() {
  6562. if (this.__filtered__) {
  6563. var result = new LazyWrapper(this);
  6564. result.__dir__ = -1;
  6565. result.__filtered__ = true;
  6566. } else {
  6567. result = this.clone();
  6568. result.__dir__ *= -1;
  6569. }
  6570. return result;
  6571. }
  6572. /**
  6573. * Extracts the unwrapped value from its lazy wrapper.
  6574. *
  6575. * @private
  6576. * @name value
  6577. * @memberOf LazyWrapper
  6578. * @returns {*} Returns the unwrapped value.
  6579. */
  6580. function lazyValue() {
  6581. var array = this.__wrapped__.value(),
  6582. dir = this.__dir__,
  6583. isArr = isArray(array),
  6584. isRight = dir < 0,
  6585. arrLength = isArr ? array.length : 0,
  6586. view = getView(0, arrLength, this.__views__),
  6587. start = view.start,
  6588. end = view.end,
  6589. length = end - start,
  6590. index = isRight ? end : (start - 1),
  6591. iteratees = this.__iteratees__,
  6592. iterLength = iteratees.length,
  6593. resIndex = 0,
  6594. takeCount = nativeMin(length, this.__takeCount__);
  6595. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  6596. return baseWrapperValue(array, this.__actions__);
  6597. }
  6598. var result = [];
  6599. outer:
  6600. while (length-- && resIndex < takeCount) {
  6601. index += dir;
  6602. var iterIndex = -1,
  6603. value = array[index];
  6604. while (++iterIndex < iterLength) {
  6605. var data = iteratees[iterIndex],
  6606. iteratee = data.iteratee,
  6607. type = data.type,
  6608. computed = iteratee(value);
  6609. if (type == LAZY_MAP_FLAG) {
  6610. value = computed;
  6611. } else if (!computed) {
  6612. if (type == LAZY_FILTER_FLAG) {
  6613. continue outer;
  6614. } else {
  6615. break outer;
  6616. }
  6617. }
  6618. }
  6619. result[resIndex++] = value;
  6620. }
  6621. return result;
  6622. }
  6623. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  6624. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  6625. LazyWrapper.prototype.constructor = LazyWrapper;
  6626. /*------------------------------------------------------------------------*/
  6627. /**
  6628. * Creates a hash object.
  6629. *
  6630. * @private
  6631. * @constructor
  6632. * @param {Array} [entries] The key-value pairs to cache.
  6633. */
  6634. function Hash(entries) {
  6635. var index = -1,
  6636. length = entries == null ? 0 : entries.length;
  6637. this.clear();
  6638. while (++index < length) {
  6639. var entry = entries[index];
  6640. this.set(entry[0], entry[1]);
  6641. }
  6642. }
  6643. /**
  6644. * Removes all key-value entries from the hash.
  6645. *
  6646. * @private
  6647. * @name clear
  6648. * @memberOf Hash
  6649. */
  6650. function hashClear() {
  6651. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  6652. this.size = 0;
  6653. }
  6654. /**
  6655. * Removes `key` and its value from the hash.
  6656. *
  6657. * @private
  6658. * @name delete
  6659. * @memberOf Hash
  6660. * @param {Object} hash The hash to modify.
  6661. * @param {string} key The key of the value to remove.
  6662. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  6663. */
  6664. function hashDelete(key) {
  6665. var result = this.has(key) && delete this.__data__[key];
  6666. this.size -= result ? 1 : 0;
  6667. return result;
  6668. }
  6669. /**
  6670. * Gets the hash value for `key`.
  6671. *
  6672. * @private
  6673. * @name get
  6674. * @memberOf Hash
  6675. * @param {string} key The key of the value to get.
  6676. * @returns {*} Returns the entry value.
  6677. */
  6678. function hashGet(key) {
  6679. var data = this.__data__;
  6680. if (nativeCreate) {
  6681. var result = data[key];
  6682. return result === HASH_UNDEFINED ? undefined : result;
  6683. }
  6684. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  6685. }
  6686. /**
  6687. * Checks if a hash value for `key` exists.
  6688. *
  6689. * @private
  6690. * @name has
  6691. * @memberOf Hash
  6692. * @param {string} key The key of the entry to check.
  6693. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  6694. */
  6695. function hashHas(key) {
  6696. var data = this.__data__;
  6697. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  6698. }
  6699. /**
  6700. * Sets the hash `key` to `value`.
  6701. *
  6702. * @private
  6703. * @name set
  6704. * @memberOf Hash
  6705. * @param {string} key The key of the value to set.
  6706. * @param {*} value The value to set.
  6707. * @returns {Object} Returns the hash instance.
  6708. */
  6709. function hashSet(key, value) {
  6710. var data = this.__data__;
  6711. this.size += this.has(key) ? 0 : 1;
  6712. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  6713. return this;
  6714. }
  6715. // Add methods to `Hash`.
  6716. Hash.prototype.clear = hashClear;
  6717. Hash.prototype['delete'] = hashDelete;
  6718. Hash.prototype.get = hashGet;
  6719. Hash.prototype.has = hashHas;
  6720. Hash.prototype.set = hashSet;
  6721. /*------------------------------------------------------------------------*/
  6722. /**
  6723. * Creates an list cache object.
  6724. *
  6725. * @private
  6726. * @constructor
  6727. * @param {Array} [entries] The key-value pairs to cache.
  6728. */
  6729. function ListCache(entries) {
  6730. var index = -1,
  6731. length = entries == null ? 0 : entries.length;
  6732. this.clear();
  6733. while (++index < length) {
  6734. var entry = entries[index];
  6735. this.set(entry[0], entry[1]);
  6736. }
  6737. }
  6738. /**
  6739. * Removes all key-value entries from the list cache.
  6740. *
  6741. * @private
  6742. * @name clear
  6743. * @memberOf ListCache
  6744. */
  6745. function listCacheClear() {
  6746. this.__data__ = [];
  6747. this.size = 0;
  6748. }
  6749. /**
  6750. * Removes `key` and its value from the list cache.
  6751. *
  6752. * @private
  6753. * @name delete
  6754. * @memberOf ListCache
  6755. * @param {string} key The key of the value to remove.
  6756. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  6757. */
  6758. function listCacheDelete(key) {
  6759. var data = this.__data__,
  6760. index = assocIndexOf(data, key);
  6761. if (index < 0) {
  6762. return false;
  6763. }
  6764. var lastIndex = data.length - 1;
  6765. if (index == lastIndex) {
  6766. data.pop();
  6767. } else {
  6768. splice.call(data, index, 1);
  6769. }
  6770. --this.size;
  6771. return true;
  6772. }
  6773. /**
  6774. * Gets the list cache value for `key`.
  6775. *
  6776. * @private
  6777. * @name get
  6778. * @memberOf ListCache
  6779. * @param {string} key The key of the value to get.
  6780. * @returns {*} Returns the entry value.
  6781. */
  6782. function listCacheGet(key) {
  6783. var data = this.__data__,
  6784. index = assocIndexOf(data, key);
  6785. return index < 0 ? undefined : data[index][1];
  6786. }
  6787. /**
  6788. * Checks if a list cache value for `key` exists.
  6789. *
  6790. * @private
  6791. * @name has
  6792. * @memberOf ListCache
  6793. * @param {string} key The key of the entry to check.
  6794. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  6795. */
  6796. function listCacheHas(key) {
  6797. return assocIndexOf(this.__data__, key) > -1;
  6798. }
  6799. /**
  6800. * Sets the list cache `key` to `value`.
  6801. *
  6802. * @private
  6803. * @name set
  6804. * @memberOf ListCache
  6805. * @param {string} key The key of the value to set.
  6806. * @param {*} value The value to set.
  6807. * @returns {Object} Returns the list cache instance.
  6808. */
  6809. function listCacheSet(key, value) {
  6810. var data = this.__data__,
  6811. index = assocIndexOf(data, key);
  6812. if (index < 0) {
  6813. ++this.size;
  6814. data.push([key, value]);
  6815. } else {
  6816. data[index][1] = value;
  6817. }
  6818. return this;
  6819. }
  6820. // Add methods to `ListCache`.
  6821. ListCache.prototype.clear = listCacheClear;
  6822. ListCache.prototype['delete'] = listCacheDelete;
  6823. ListCache.prototype.get = listCacheGet;
  6824. ListCache.prototype.has = listCacheHas;
  6825. ListCache.prototype.set = listCacheSet;
  6826. /*------------------------------------------------------------------------*/
  6827. /**
  6828. * Creates a map cache object to store key-value pairs.
  6829. *
  6830. * @private
  6831. * @constructor
  6832. * @param {Array} [entries] The key-value pairs to cache.
  6833. */
  6834. function MapCache(entries) {
  6835. var index = -1,
  6836. length = entries == null ? 0 : entries.length;
  6837. this.clear();
  6838. while (++index < length) {
  6839. var entry = entries[index];
  6840. this.set(entry[0], entry[1]);
  6841. }
  6842. }
  6843. /**
  6844. * Removes all key-value entries from the map.
  6845. *
  6846. * @private
  6847. * @name clear
  6848. * @memberOf MapCache
  6849. */
  6850. function mapCacheClear() {
  6851. this.size = 0;
  6852. this.__data__ = {
  6853. 'hash': new Hash,
  6854. 'map': new (Map || ListCache),
  6855. 'string': new Hash
  6856. };
  6857. }
  6858. /**
  6859. * Removes `key` and its value from the map.
  6860. *
  6861. * @private
  6862. * @name delete
  6863. * @memberOf MapCache
  6864. * @param {string} key The key of the value to remove.
  6865. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  6866. */
  6867. function mapCacheDelete(key) {
  6868. var result = getMapData(this, key)['delete'](key);
  6869. this.size -= result ? 1 : 0;
  6870. return result;
  6871. }
  6872. /**
  6873. * Gets the map value for `key`.
  6874. *
  6875. * @private
  6876. * @name get
  6877. * @memberOf MapCache
  6878. * @param {string} key The key of the value to get.
  6879. * @returns {*} Returns the entry value.
  6880. */
  6881. function mapCacheGet(key) {
  6882. return getMapData(this, key).get(key);
  6883. }
  6884. /**
  6885. * Checks if a map value for `key` exists.
  6886. *
  6887. * @private
  6888. * @name has
  6889. * @memberOf MapCache
  6890. * @param {string} key The key of the entry to check.
  6891. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  6892. */
  6893. function mapCacheHas(key) {
  6894. return getMapData(this, key).has(key);
  6895. }
  6896. /**
  6897. * Sets the map `key` to `value`.
  6898. *
  6899. * @private
  6900. * @name set
  6901. * @memberOf MapCache
  6902. * @param {string} key The key of the value to set.
  6903. * @param {*} value The value to set.
  6904. * @returns {Object} Returns the map cache instance.
  6905. */
  6906. function mapCacheSet(key, value) {
  6907. var data = getMapData(this, key),
  6908. size = data.size;
  6909. data.set(key, value);
  6910. this.size += data.size == size ? 0 : 1;
  6911. return this;
  6912. }
  6913. // Add methods to `MapCache`.
  6914. MapCache.prototype.clear = mapCacheClear;
  6915. MapCache.prototype['delete'] = mapCacheDelete;
  6916. MapCache.prototype.get = mapCacheGet;
  6917. MapCache.prototype.has = mapCacheHas;
  6918. MapCache.prototype.set = mapCacheSet;
  6919. /*------------------------------------------------------------------------*/
  6920. /**
  6921. *
  6922. * Creates an array cache object to store unique values.
  6923. *
  6924. * @private
  6925. * @constructor
  6926. * @param {Array} [values] The values to cache.
  6927. */
  6928. function SetCache(values) {
  6929. var index = -1,
  6930. length = values == null ? 0 : values.length;
  6931. this.__data__ = new MapCache;
  6932. while (++index < length) {
  6933. this.add(values[index]);
  6934. }
  6935. }
  6936. /**
  6937. * Adds `value` to the array cache.
  6938. *
  6939. * @private
  6940. * @name add
  6941. * @memberOf SetCache
  6942. * @alias push
  6943. * @param {*} value The value to cache.
  6944. * @returns {Object} Returns the cache instance.
  6945. */
  6946. function setCacheAdd(value) {
  6947. this.__data__.set(value, HASH_UNDEFINED);
  6948. return this;
  6949. }
  6950. /**
  6951. * Checks if `value` is in the array cache.
  6952. *
  6953. * @private
  6954. * @name has
  6955. * @memberOf SetCache
  6956. * @param {*} value The value to search for.
  6957. * @returns {number} Returns `true` if `value` is found, else `false`.
  6958. */
  6959. function setCacheHas(value) {
  6960. return this.__data__.has(value);
  6961. }
  6962. // Add methods to `SetCache`.
  6963. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  6964. SetCache.prototype.has = setCacheHas;
  6965. /*------------------------------------------------------------------------*/
  6966. /**
  6967. * Creates a stack cache object to store key-value pairs.
  6968. *
  6969. * @private
  6970. * @constructor
  6971. * @param {Array} [entries] The key-value pairs to cache.
  6972. */
  6973. function Stack(entries) {
  6974. var data = this.__data__ = new ListCache(entries);
  6975. this.size = data.size;
  6976. }
  6977. /**
  6978. * Removes all key-value entries from the stack.
  6979. *
  6980. * @private
  6981. * @name clear
  6982. * @memberOf Stack
  6983. */
  6984. function stackClear() {
  6985. this.__data__ = new ListCache;
  6986. this.size = 0;
  6987. }
  6988. /**
  6989. * Removes `key` and its value from the stack.
  6990. *
  6991. * @private
  6992. * @name delete
  6993. * @memberOf Stack
  6994. * @param {string} key The key of the value to remove.
  6995. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  6996. */
  6997. function stackDelete(key) {
  6998. var data = this.__data__,
  6999. result = data['delete'](key);
  7000. this.size = data.size;
  7001. return result;
  7002. }
  7003. /**
  7004. * Gets the stack value for `key`.
  7005. *
  7006. * @private
  7007. * @name get
  7008. * @memberOf Stack
  7009. * @param {string} key The key of the value to get.
  7010. * @returns {*} Returns the entry value.
  7011. */
  7012. function stackGet(key) {
  7013. return this.__data__.get(key);
  7014. }
  7015. /**
  7016. * Checks if a stack value for `key` exists.
  7017. *
  7018. * @private
  7019. * @name has
  7020. * @memberOf Stack
  7021. * @param {string} key The key of the entry to check.
  7022. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  7023. */
  7024. function stackHas(key) {
  7025. return this.__data__.has(key);
  7026. }
  7027. /**
  7028. * Sets the stack `key` to `value`.
  7029. *
  7030. * @private
  7031. * @name set
  7032. * @memberOf Stack
  7033. * @param {string} key The key of the value to set.
  7034. * @param {*} value The value to set.
  7035. * @returns {Object} Returns the stack cache instance.
  7036. */
  7037. function stackSet(key, value) {
  7038. var data = this.__data__;
  7039. if (data instanceof ListCache) {
  7040. var pairs = data.__data__;
  7041. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  7042. pairs.push([key, value]);
  7043. this.size = ++data.size;
  7044. return this;
  7045. }
  7046. data = this.__data__ = new MapCache(pairs);
  7047. }
  7048. data.set(key, value);
  7049. this.size = data.size;
  7050. return this;
  7051. }
  7052. // Add methods to `Stack`.
  7053. Stack.prototype.clear = stackClear;
  7054. Stack.prototype['delete'] = stackDelete;
  7055. Stack.prototype.get = stackGet;
  7056. Stack.prototype.has = stackHas;
  7057. Stack.prototype.set = stackSet;
  7058. /*------------------------------------------------------------------------*/
  7059. /**
  7060. * Creates an array of the enumerable property names of the array-like `value`.
  7061. *
  7062. * @private
  7063. * @param {*} value The value to query.
  7064. * @param {boolean} inherited Specify returning inherited property names.
  7065. * @returns {Array} Returns the array of property names.
  7066. */
  7067. function arrayLikeKeys(value, inherited) {
  7068. var isArr = isArray(value),
  7069. isArg = !isArr && isArguments(value),
  7070. isBuff = !isArr && !isArg && isBuffer(value),
  7071. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  7072. skipIndexes = isArr || isArg || isBuff || isType,
  7073. result = skipIndexes ? baseTimes(value.length, String) : [],
  7074. length = result.length;
  7075. for (var key in value) {
  7076. if ((inherited || hasOwnProperty.call(value, key)) &&
  7077. !(skipIndexes && (
  7078. // Safari 9 has enumerable `arguments.length` in strict mode.
  7079. key == 'length' ||
  7080. // Node.js 0.10 has enumerable non-index properties on buffers.
  7081. (isBuff && (key == 'offset' || key == 'parent')) ||
  7082. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  7083. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  7084. // Skip index properties.
  7085. isIndex(key, length)
  7086. ))) {
  7087. result.push(key);
  7088. }
  7089. }
  7090. return result;
  7091. }
  7092. /**
  7093. * A specialized version of `_.sample` for arrays.
  7094. *
  7095. * @private
  7096. * @param {Array} array The array to sample.
  7097. * @returns {*} Returns the random element.
  7098. */
  7099. function arraySample(array) {
  7100. var length = array.length;
  7101. return length ? array[baseRandom(0, length - 1)] : undefined;
  7102. }
  7103. /**
  7104. * A specialized version of `_.sampleSize` for arrays.
  7105. *
  7106. * @private
  7107. * @param {Array} array The array to sample.
  7108. * @param {number} n The number of elements to sample.
  7109. * @returns {Array} Returns the random elements.
  7110. */
  7111. function arraySampleSize(array, n) {
  7112. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  7113. }
  7114. /**
  7115. * A specialized version of `_.shuffle` for arrays.
  7116. *
  7117. * @private
  7118. * @param {Array} array The array to shuffle.
  7119. * @returns {Array} Returns the new shuffled array.
  7120. */
  7121. function arrayShuffle(array) {
  7122. return shuffleSelf(copyArray(array));
  7123. }
  7124. /**
  7125. * This function is like `assignValue` except that it doesn't assign
  7126. * `undefined` values.
  7127. *
  7128. * @private
  7129. * @param {Object} object The object to modify.
  7130. * @param {string} key The key of the property to assign.
  7131. * @param {*} value The value to assign.
  7132. */
  7133. function assignMergeValue(object, key, value) {
  7134. if ((value !== undefined && !eq(object[key], value)) ||
  7135. (value === undefined && !(key in object))) {
  7136. baseAssignValue(object, key, value);
  7137. }
  7138. }
  7139. /**
  7140. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  7141. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  7142. * for equality comparisons.
  7143. *
  7144. * @private
  7145. * @param {Object} object The object to modify.
  7146. * @param {string} key The key of the property to assign.
  7147. * @param {*} value The value to assign.
  7148. */
  7149. function assignValue(object, key, value) {
  7150. var objValue = object[key];
  7151. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  7152. (value === undefined && !(key in object))) {
  7153. baseAssignValue(object, key, value);
  7154. }
  7155. }
  7156. /**
  7157. * Gets the index at which the `key` is found in `array` of key-value pairs.
  7158. *
  7159. * @private
  7160. * @param {Array} array The array to inspect.
  7161. * @param {*} key The key to search for.
  7162. * @returns {number} Returns the index of the matched value, else `-1`.
  7163. */
  7164. function assocIndexOf(array, key) {
  7165. var length = array.length;
  7166. while (length--) {
  7167. if (eq(array[length][0], key)) {
  7168. return length;
  7169. }
  7170. }
  7171. return -1;
  7172. }
  7173. /**
  7174. * Aggregates elements of `collection` on `accumulator` with keys transformed
  7175. * by `iteratee` and values set by `setter`.
  7176. *
  7177. * @private
  7178. * @param {Array|Object} collection The collection to iterate over.
  7179. * @param {Function} setter The function to set `accumulator` values.
  7180. * @param {Function} iteratee The iteratee to transform keys.
  7181. * @param {Object} accumulator The initial aggregated object.
  7182. * @returns {Function} Returns `accumulator`.
  7183. */
  7184. function baseAggregator(collection, setter, iteratee, accumulator) {
  7185. baseEach(collection, function(value, key, collection) {
  7186. setter(accumulator, value, iteratee(value), collection);
  7187. });
  7188. return accumulator;
  7189. }
  7190. /**
  7191. * The base implementation of `_.assign` without support for multiple sources
  7192. * or `customizer` functions.
  7193. *
  7194. * @private
  7195. * @param {Object} object The destination object.
  7196. * @param {Object} source The source object.
  7197. * @returns {Object} Returns `object`.
  7198. */
  7199. function baseAssign(object, source) {
  7200. return object && copyObject(source, keys(source), object);
  7201. }
  7202. /**
  7203. * The base implementation of `_.assignIn` without support for multiple sources
  7204. * or `customizer` functions.
  7205. *
  7206. * @private
  7207. * @param {Object} object The destination object.
  7208. * @param {Object} source The source object.
  7209. * @returns {Object} Returns `object`.
  7210. */
  7211. function baseAssignIn(object, source) {
  7212. return object && copyObject(source, keysIn(source), object);
  7213. }
  7214. /**
  7215. * The base implementation of `assignValue` and `assignMergeValue` without
  7216. * value checks.
  7217. *
  7218. * @private
  7219. * @param {Object} object The object to modify.
  7220. * @param {string} key The key of the property to assign.
  7221. * @param {*} value The value to assign.
  7222. */
  7223. function baseAssignValue(object, key, value) {
  7224. if (key == '__proto__' && defineProperty) {
  7225. defineProperty(object, key, {
  7226. 'configurable': true,
  7227. 'enumerable': true,
  7228. 'value': value,
  7229. 'writable': true
  7230. });
  7231. } else {
  7232. object[key] = value;
  7233. }
  7234. }
  7235. /**
  7236. * The base implementation of `_.at` without support for individual paths.
  7237. *
  7238. * @private
  7239. * @param {Object} object The object to iterate over.
  7240. * @param {string[]} paths The property paths to pick.
  7241. * @returns {Array} Returns the picked elements.
  7242. */
  7243. function baseAt(object, paths) {
  7244. var index = -1,
  7245. length = paths.length,
  7246. result = Array(length),
  7247. skip = object == null;
  7248. while (++index < length) {
  7249. result[index] = skip ? undefined : get(object, paths[index]);
  7250. }
  7251. return result;
  7252. }
  7253. /**
  7254. * The base implementation of `_.clamp` which doesn't coerce arguments.
  7255. *
  7256. * @private
  7257. * @param {number} number The number to clamp.
  7258. * @param {number} [lower] The lower bound.
  7259. * @param {number} upper The upper bound.
  7260. * @returns {number} Returns the clamped number.
  7261. */
  7262. function baseClamp(number, lower, upper) {
  7263. if (number === number) {
  7264. if (upper !== undefined) {
  7265. number = number <= upper ? number : upper;
  7266. }
  7267. if (lower !== undefined) {
  7268. number = number >= lower ? number : lower;
  7269. }
  7270. }
  7271. return number;
  7272. }
  7273. /**
  7274. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  7275. * traversed objects.
  7276. *
  7277. * @private
  7278. * @param {*} value The value to clone.
  7279. * @param {boolean} bitmask The bitmask flags.
  7280. * 1 - Deep clone
  7281. * 2 - Flatten inherited properties
  7282. * 4 - Clone symbols
  7283. * @param {Function} [customizer] The function to customize cloning.
  7284. * @param {string} [key] The key of `value`.
  7285. * @param {Object} [object] The parent object of `value`.
  7286. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  7287. * @returns {*} Returns the cloned value.
  7288. */
  7289. function baseClone(value, bitmask, customizer, key, object, stack) {
  7290. var result,
  7291. isDeep = bitmask & CLONE_DEEP_FLAG,
  7292. isFlat = bitmask & CLONE_FLAT_FLAG,
  7293. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  7294. if (customizer) {
  7295. result = object ? customizer(value, key, object, stack) : customizer(value);
  7296. }
  7297. if (result !== undefined) {
  7298. return result;
  7299. }
  7300. if (!isObject(value)) {
  7301. return value;
  7302. }
  7303. var isArr = isArray(value);
  7304. if (isArr) {
  7305. result = initCloneArray(value);
  7306. if (!isDeep) {
  7307. return copyArray(value, result);
  7308. }
  7309. } else {
  7310. var tag = getTag(value),
  7311. isFunc = tag == funcTag || tag == genTag;
  7312. if (isBuffer(value)) {
  7313. return cloneBuffer(value, isDeep);
  7314. }
  7315. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  7316. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  7317. if (!isDeep) {
  7318. return isFlat
  7319. ? copySymbolsIn(value, baseAssignIn(result, value))
  7320. : copySymbols(value, baseAssign(result, value));
  7321. }
  7322. } else {
  7323. if (!cloneableTags[tag]) {
  7324. return object ? value : {};
  7325. }
  7326. result = initCloneByTag(value, tag, isDeep);
  7327. }
  7328. }
  7329. // Check for circular references and return its corresponding clone.
  7330. stack || (stack = new Stack);
  7331. var stacked = stack.get(value);
  7332. if (stacked) {
  7333. return stacked;
  7334. }
  7335. stack.set(value, result);
  7336. if (isSet(value)) {
  7337. value.forEach(function(subValue) {
  7338. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  7339. });
  7340. } else if (isMap(value)) {
  7341. value.forEach(function(subValue, key) {
  7342. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  7343. });
  7344. }
  7345. var keysFunc = isFull
  7346. ? (isFlat ? getAllKeysIn : getAllKeys)
  7347. : (isFlat ? keysIn : keys);
  7348. var props = isArr ? undefined : keysFunc(value);
  7349. arrayEach(props || value, function(subValue, key) {
  7350. if (props) {
  7351. key = subValue;
  7352. subValue = value[key];
  7353. }
  7354. // Recursively populate clone (susceptible to call stack limits).
  7355. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  7356. });
  7357. return result;
  7358. }
  7359. /**
  7360. * The base implementation of `_.conforms` which doesn't clone `source`.
  7361. *
  7362. * @private
  7363. * @param {Object} source The object of property predicates to conform to.
  7364. * @returns {Function} Returns the new spec function.
  7365. */
  7366. function baseConforms(source) {
  7367. var props = keys(source);
  7368. return function(object) {
  7369. return baseConformsTo(object, source, props);
  7370. };
  7371. }
  7372. /**
  7373. * The base implementation of `_.conformsTo` which accepts `props` to check.
  7374. *
  7375. * @private
  7376. * @param {Object} object The object to inspect.
  7377. * @param {Object} source The object of property predicates to conform to.
  7378. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  7379. */
  7380. function baseConformsTo(object, source, props) {
  7381. var length = props.length;
  7382. if (object == null) {
  7383. return !length;
  7384. }
  7385. object = Object(object);
  7386. while (length--) {
  7387. var key = props[length],
  7388. predicate = source[key],
  7389. value = object[key];
  7390. if ((value === undefined && !(key in object)) || !predicate(value)) {
  7391. return false;
  7392. }
  7393. }
  7394. return true;
  7395. }
  7396. /**
  7397. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  7398. * to provide to `func`.
  7399. *
  7400. * @private
  7401. * @param {Function} func The function to delay.
  7402. * @param {number} wait The number of milliseconds to delay invocation.
  7403. * @param {Array} args The arguments to provide to `func`.
  7404. * @returns {number|Object} Returns the timer id or timeout object.
  7405. */
  7406. function baseDelay(func, wait, args) {
  7407. if (typeof func != 'function') {
  7408. throw new TypeError(FUNC_ERROR_TEXT);
  7409. }
  7410. return setTimeout(function() { func.apply(undefined, args); }, wait);
  7411. }
  7412. /**
  7413. * The base implementation of methods like `_.difference` without support
  7414. * for excluding multiple arrays or iteratee shorthands.
  7415. *
  7416. * @private
  7417. * @param {Array} array The array to inspect.
  7418. * @param {Array} values The values to exclude.
  7419. * @param {Function} [iteratee] The iteratee invoked per element.
  7420. * @param {Function} [comparator] The comparator invoked per element.
  7421. * @returns {Array} Returns the new array of filtered values.
  7422. */
  7423. function baseDifference(array, values, iteratee, comparator) {
  7424. var index = -1,
  7425. includes = arrayIncludes,
  7426. isCommon = true,
  7427. length = array.length,
  7428. result = [],
  7429. valuesLength = values.length;
  7430. if (!length) {
  7431. return result;
  7432. }
  7433. if (iteratee) {
  7434. values = arrayMap(values, baseUnary(iteratee));
  7435. }
  7436. if (comparator) {
  7437. includes = arrayIncludesWith;
  7438. isCommon = false;
  7439. }
  7440. else if (values.length >= LARGE_ARRAY_SIZE) {
  7441. includes = cacheHas;
  7442. isCommon = false;
  7443. values = new SetCache(values);
  7444. }
  7445. outer:
  7446. while (++index < length) {
  7447. var value = array[index],
  7448. computed = iteratee == null ? value : iteratee(value);
  7449. value = (comparator || value !== 0) ? value : 0;
  7450. if (isCommon && computed === computed) {
  7451. var valuesIndex = valuesLength;
  7452. while (valuesIndex--) {
  7453. if (values[valuesIndex] === computed) {
  7454. continue outer;
  7455. }
  7456. }
  7457. result.push(value);
  7458. }
  7459. else if (!includes(values, computed, comparator)) {
  7460. result.push(value);
  7461. }
  7462. }
  7463. return result;
  7464. }
  7465. /**
  7466. * The base implementation of `_.forEach` without support for iteratee shorthands.
  7467. *
  7468. * @private
  7469. * @param {Array|Object} collection The collection to iterate over.
  7470. * @param {Function} iteratee The function invoked per iteration.
  7471. * @returns {Array|Object} Returns `collection`.
  7472. */
  7473. var baseEach = createBaseEach(baseForOwn);
  7474. /**
  7475. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  7476. *
  7477. * @private
  7478. * @param {Array|Object} collection The collection to iterate over.
  7479. * @param {Function} iteratee The function invoked per iteration.
  7480. * @returns {Array|Object} Returns `collection`.
  7481. */
  7482. var baseEachRight = createBaseEach(baseForOwnRight, true);
  7483. /**
  7484. * The base implementation of `_.every` without support for iteratee shorthands.
  7485. *
  7486. * @private
  7487. * @param {Array|Object} collection The collection to iterate over.
  7488. * @param {Function} predicate The function invoked per iteration.
  7489. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  7490. * else `false`
  7491. */
  7492. function baseEvery(collection, predicate) {
  7493. var result = true;
  7494. baseEach(collection, function(value, index, collection) {
  7495. result = !!predicate(value, index, collection);
  7496. return result;
  7497. });
  7498. return result;
  7499. }
  7500. /**
  7501. * The base implementation of methods like `_.max` and `_.min` which accepts a
  7502. * `comparator` to determine the extremum value.
  7503. *
  7504. * @private
  7505. * @param {Array} array The array to iterate over.
  7506. * @param {Function} iteratee The iteratee invoked per iteration.
  7507. * @param {Function} comparator The comparator used to compare values.
  7508. * @returns {*} Returns the extremum value.
  7509. */
  7510. function baseExtremum(array, iteratee, comparator) {
  7511. var index = -1,
  7512. length = array.length;
  7513. while (++index < length) {
  7514. var value = array[index],
  7515. current = iteratee(value);
  7516. if (current != null && (computed === undefined
  7517. ? (current === current && !isSymbol(current))
  7518. : comparator(current, computed)
  7519. )) {
  7520. var computed = current,
  7521. result = value;
  7522. }
  7523. }
  7524. return result;
  7525. }
  7526. /**
  7527. * The base implementation of `_.fill` without an iteratee call guard.
  7528. *
  7529. * @private
  7530. * @param {Array} array The array to fill.
  7531. * @param {*} value The value to fill `array` with.
  7532. * @param {number} [start=0] The start position.
  7533. * @param {number} [end=array.length] The end position.
  7534. * @returns {Array} Returns `array`.
  7535. */
  7536. function baseFill(array, value, start, end) {
  7537. var length = array.length;
  7538. start = toInteger(start);
  7539. if (start < 0) {
  7540. start = -start > length ? 0 : (length + start);
  7541. }
  7542. end = (end === undefined || end > length) ? length : toInteger(end);
  7543. if (end < 0) {
  7544. end += length;
  7545. }
  7546. end = start > end ? 0 : toLength(end);
  7547. while (start < end) {
  7548. array[start++] = value;
  7549. }
  7550. return array;
  7551. }
  7552. /**
  7553. * The base implementation of `_.filter` without support for iteratee shorthands.
  7554. *
  7555. * @private
  7556. * @param {Array|Object} collection The collection to iterate over.
  7557. * @param {Function} predicate The function invoked per iteration.
  7558. * @returns {Array} Returns the new filtered array.
  7559. */
  7560. function baseFilter(collection, predicate) {
  7561. var result = [];
  7562. baseEach(collection, function(value, index, collection) {
  7563. if (predicate(value, index, collection)) {
  7564. result.push(value);
  7565. }
  7566. });
  7567. return result;
  7568. }
  7569. /**
  7570. * The base implementation of `_.flatten` with support for restricting flattening.
  7571. *
  7572. * @private
  7573. * @param {Array} array The array to flatten.
  7574. * @param {number} depth The maximum recursion depth.
  7575. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  7576. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  7577. * @param {Array} [result=[]] The initial result value.
  7578. * @returns {Array} Returns the new flattened array.
  7579. */
  7580. function baseFlatten(array, depth, predicate, isStrict, result) {
  7581. var index = -1,
  7582. length = array.length;
  7583. predicate || (predicate = isFlattenable);
  7584. result || (result = []);
  7585. while (++index < length) {
  7586. var value = array[index];
  7587. if (depth > 0 && predicate(value)) {
  7588. if (depth > 1) {
  7589. // Recursively flatten arrays (susceptible to call stack limits).
  7590. baseFlatten(value, depth - 1, predicate, isStrict, result);
  7591. } else {
  7592. arrayPush(result, value);
  7593. }
  7594. } else if (!isStrict) {
  7595. result[result.length] = value;
  7596. }
  7597. }
  7598. return result;
  7599. }
  7600. /**
  7601. * The base implementation of `baseForOwn` which iterates over `object`
  7602. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  7603. * Iteratee functions may exit iteration early by explicitly returning `false`.
  7604. *
  7605. * @private
  7606. * @param {Object} object The object to iterate over.
  7607. * @param {Function} iteratee The function invoked per iteration.
  7608. * @param {Function} keysFunc The function to get the keys of `object`.
  7609. * @returns {Object} Returns `object`.
  7610. */
  7611. var baseFor = createBaseFor();
  7612. /**
  7613. * This function is like `baseFor` except that it iterates over properties
  7614. * in the opposite order.
  7615. *
  7616. * @private
  7617. * @param {Object} object The object to iterate over.
  7618. * @param {Function} iteratee The function invoked per iteration.
  7619. * @param {Function} keysFunc The function to get the keys of `object`.
  7620. * @returns {Object} Returns `object`.
  7621. */
  7622. var baseForRight = createBaseFor(true);
  7623. /**
  7624. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  7625. *
  7626. * @private
  7627. * @param {Object} object The object to iterate over.
  7628. * @param {Function} iteratee The function invoked per iteration.
  7629. * @returns {Object} Returns `object`.
  7630. */
  7631. function baseForOwn(object, iteratee) {
  7632. return object && baseFor(object, iteratee, keys);
  7633. }
  7634. /**
  7635. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  7636. *
  7637. * @private
  7638. * @param {Object} object The object to iterate over.
  7639. * @param {Function} iteratee The function invoked per iteration.
  7640. * @returns {Object} Returns `object`.
  7641. */
  7642. function baseForOwnRight(object, iteratee) {
  7643. return object && baseForRight(object, iteratee, keys);
  7644. }
  7645. /**
  7646. * The base implementation of `_.functions` which creates an array of
  7647. * `object` function property names filtered from `props`.
  7648. *
  7649. * @private
  7650. * @param {Object} object The object to inspect.
  7651. * @param {Array} props The property names to filter.
  7652. * @returns {Array} Returns the function names.
  7653. */
  7654. function baseFunctions(object, props) {
  7655. return arrayFilter(props, function(key) {
  7656. return isFunction(object[key]);
  7657. });
  7658. }
  7659. /**
  7660. * The base implementation of `_.get` without support for default values.
  7661. *
  7662. * @private
  7663. * @param {Object} object The object to query.
  7664. * @param {Array|string} path The path of the property to get.
  7665. * @returns {*} Returns the resolved value.
  7666. */
  7667. function baseGet(object, path) {
  7668. path = castPath(path, object);
  7669. var index = 0,
  7670. length = path.length;
  7671. while (object != null && index < length) {
  7672. object = object[toKey(path[index++])];
  7673. }
  7674. return (index && index == length) ? object : undefined;
  7675. }
  7676. /**
  7677. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  7678. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  7679. * symbols of `object`.
  7680. *
  7681. * @private
  7682. * @param {Object} object The object to query.
  7683. * @param {Function} keysFunc The function to get the keys of `object`.
  7684. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  7685. * @returns {Array} Returns the array of property names and symbols.
  7686. */
  7687. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  7688. var result = keysFunc(object);
  7689. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  7690. }
  7691. /**
  7692. * The base implementation of `getTag` without fallbacks for buggy environments.
  7693. *
  7694. * @private
  7695. * @param {*} value The value to query.
  7696. * @returns {string} Returns the `toStringTag`.
  7697. */
  7698. function baseGetTag(value) {
  7699. if (value == null) {
  7700. return value === undefined ? undefinedTag : nullTag;
  7701. }
  7702. return (symToStringTag && symToStringTag in Object(value))
  7703. ? getRawTag(value)
  7704. : objectToString(value);
  7705. }
  7706. /**
  7707. * The base implementation of `_.gt` which doesn't coerce arguments.
  7708. *
  7709. * @private
  7710. * @param {*} value The value to compare.
  7711. * @param {*} other The other value to compare.
  7712. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  7713. * else `false`.
  7714. */
  7715. function baseGt(value, other) {
  7716. return value > other;
  7717. }
  7718. /**
  7719. * The base implementation of `_.has` without support for deep paths.
  7720. *
  7721. * @private
  7722. * @param {Object} [object] The object to query.
  7723. * @param {Array|string} key The key to check.
  7724. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  7725. */
  7726. function baseHas(object, key) {
  7727. return object != null && hasOwnProperty.call(object, key);
  7728. }
  7729. /**
  7730. * The base implementation of `_.hasIn` without support for deep paths.
  7731. *
  7732. * @private
  7733. * @param {Object} [object] The object to query.
  7734. * @param {Array|string} key The key to check.
  7735. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  7736. */
  7737. function baseHasIn(object, key) {
  7738. return object != null && key in Object(object);
  7739. }
  7740. /**
  7741. * The base implementation of `_.inRange` which doesn't coerce arguments.
  7742. *
  7743. * @private
  7744. * @param {number} number The number to check.
  7745. * @param {number} start The start of the range.
  7746. * @param {number} end The end of the range.
  7747. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  7748. */
  7749. function baseInRange(number, start, end) {
  7750. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  7751. }
  7752. /**
  7753. * The base implementation of methods like `_.intersection`, without support
  7754. * for iteratee shorthands, that accepts an array of arrays to inspect.
  7755. *
  7756. * @private
  7757. * @param {Array} arrays The arrays to inspect.
  7758. * @param {Function} [iteratee] The iteratee invoked per element.
  7759. * @param {Function} [comparator] The comparator invoked per element.
  7760. * @returns {Array} Returns the new array of shared values.
  7761. */
  7762. function baseIntersection(arrays, iteratee, comparator) {
  7763. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  7764. length = arrays[0].length,
  7765. othLength = arrays.length,
  7766. othIndex = othLength,
  7767. caches = Array(othLength),
  7768. maxLength = Infinity,
  7769. result = [];
  7770. while (othIndex--) {
  7771. var array = arrays[othIndex];
  7772. if (othIndex && iteratee) {
  7773. array = arrayMap(array, baseUnary(iteratee));
  7774. }
  7775. maxLength = nativeMin(array.length, maxLength);
  7776. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  7777. ? new SetCache(othIndex && array)
  7778. : undefined;
  7779. }
  7780. array = arrays[0];
  7781. var index = -1,
  7782. seen = caches[0];
  7783. outer:
  7784. while (++index < length && result.length < maxLength) {
  7785. var value = array[index],
  7786. computed = iteratee ? iteratee(value) : value;
  7787. value = (comparator || value !== 0) ? value : 0;
  7788. if (!(seen
  7789. ? cacheHas(seen, computed)
  7790. : includes(result, computed, comparator)
  7791. )) {
  7792. othIndex = othLength;
  7793. while (--othIndex) {
  7794. var cache = caches[othIndex];
  7795. if (!(cache
  7796. ? cacheHas(cache, computed)
  7797. : includes(arrays[othIndex], computed, comparator))
  7798. ) {
  7799. continue outer;
  7800. }
  7801. }
  7802. if (seen) {
  7803. seen.push(computed);
  7804. }
  7805. result.push(value);
  7806. }
  7807. }
  7808. return result;
  7809. }
  7810. /**
  7811. * The base implementation of `_.invert` and `_.invertBy` which inverts
  7812. * `object` with values transformed by `iteratee` and set by `setter`.
  7813. *
  7814. * @private
  7815. * @param {Object} object The object to iterate over.
  7816. * @param {Function} setter The function to set `accumulator` values.
  7817. * @param {Function} iteratee The iteratee to transform values.
  7818. * @param {Object} accumulator The initial inverted object.
  7819. * @returns {Function} Returns `accumulator`.
  7820. */
  7821. function baseInverter(object, setter, iteratee, accumulator) {
  7822. baseForOwn(object, function(value, key, object) {
  7823. setter(accumulator, iteratee(value), key, object);
  7824. });
  7825. return accumulator;
  7826. }
  7827. /**
  7828. * The base implementation of `_.invoke` without support for individual
  7829. * method arguments.
  7830. *
  7831. * @private
  7832. * @param {Object} object The object to query.
  7833. * @param {Array|string} path The path of the method to invoke.
  7834. * @param {Array} args The arguments to invoke the method with.
  7835. * @returns {*} Returns the result of the invoked method.
  7836. */
  7837. function baseInvoke(object, path, args) {
  7838. path = castPath(path, object);
  7839. object = parent(object, path);
  7840. var func = object == null ? object : object[toKey(last(path))];
  7841. return func == null ? undefined : apply(func, object, args);
  7842. }
  7843. /**
  7844. * The base implementation of `_.isArguments`.
  7845. *
  7846. * @private
  7847. * @param {*} value The value to check.
  7848. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  7849. */
  7850. function baseIsArguments(value) {
  7851. return isObjectLike(value) && baseGetTag(value) == argsTag;
  7852. }
  7853. /**
  7854. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  7855. *
  7856. * @private
  7857. * @param {*} value The value to check.
  7858. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  7859. */
  7860. function baseIsArrayBuffer(value) {
  7861. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  7862. }
  7863. /**
  7864. * The base implementation of `_.isDate` without Node.js optimizations.
  7865. *
  7866. * @private
  7867. * @param {*} value The value to check.
  7868. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  7869. */
  7870. function baseIsDate(value) {
  7871. return isObjectLike(value) && baseGetTag(value) == dateTag;
  7872. }
  7873. /**
  7874. * The base implementation of `_.isEqual` which supports partial comparisons
  7875. * and tracks traversed objects.
  7876. *
  7877. * @private
  7878. * @param {*} value The value to compare.
  7879. * @param {*} other The other value to compare.
  7880. * @param {boolean} bitmask The bitmask flags.
  7881. * 1 - Unordered comparison
  7882. * 2 - Partial comparison
  7883. * @param {Function} [customizer] The function to customize comparisons.
  7884. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  7885. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  7886. */
  7887. function baseIsEqual(value, other, bitmask, customizer, stack) {
  7888. if (value === other) {
  7889. return true;
  7890. }
  7891. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  7892. return value !== value && other !== other;
  7893. }
  7894. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  7895. }
  7896. /**
  7897. * A specialized version of `baseIsEqual` for arrays and objects which performs
  7898. * deep comparisons and tracks traversed objects enabling objects with circular
  7899. * references to be compared.
  7900. *
  7901. * @private
  7902. * @param {Object} object The object to compare.
  7903. * @param {Object} other The other object to compare.
  7904. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  7905. * @param {Function} customizer The function to customize comparisons.
  7906. * @param {Function} equalFunc The function to determine equivalents of values.
  7907. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  7908. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  7909. */
  7910. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  7911. var objIsArr = isArray(object),
  7912. othIsArr = isArray(other),
  7913. objTag = objIsArr ? arrayTag : getTag(object),
  7914. othTag = othIsArr ? arrayTag : getTag(other);
  7915. objTag = objTag == argsTag ? objectTag : objTag;
  7916. othTag = othTag == argsTag ? objectTag : othTag;
  7917. var objIsObj = objTag == objectTag,
  7918. othIsObj = othTag == objectTag,
  7919. isSameTag = objTag == othTag;
  7920. if (isSameTag && isBuffer(object)) {
  7921. if (!isBuffer(other)) {
  7922. return false;
  7923. }
  7924. objIsArr = true;
  7925. objIsObj = false;
  7926. }
  7927. if (isSameTag && !objIsObj) {
  7928. stack || (stack = new Stack);
  7929. return (objIsArr || isTypedArray(object))
  7930. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  7931. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  7932. }
  7933. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  7934. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  7935. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  7936. if (objIsWrapped || othIsWrapped) {
  7937. var objUnwrapped = objIsWrapped ? object.value() : object,
  7938. othUnwrapped = othIsWrapped ? other.value() : other;
  7939. stack || (stack = new Stack);
  7940. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  7941. }
  7942. }
  7943. if (!isSameTag) {
  7944. return false;
  7945. }
  7946. stack || (stack = new Stack);
  7947. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  7948. }
  7949. /**
  7950. * The base implementation of `_.isMap` without Node.js optimizations.
  7951. *
  7952. * @private
  7953. * @param {*} value The value to check.
  7954. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  7955. */
  7956. function baseIsMap(value) {
  7957. return isObjectLike(value) && getTag(value) == mapTag;
  7958. }
  7959. /**
  7960. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  7961. *
  7962. * @private
  7963. * @param {Object} object The object to inspect.
  7964. * @param {Object} source The object of property values to match.
  7965. * @param {Array} matchData The property names, values, and compare flags to match.
  7966. * @param {Function} [customizer] The function to customize comparisons.
  7967. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  7968. */
  7969. function baseIsMatch(object, source, matchData, customizer) {
  7970. var index = matchData.length,
  7971. length = index,
  7972. noCustomizer = !customizer;
  7973. if (object == null) {
  7974. return !length;
  7975. }
  7976. object = Object(object);
  7977. while (index--) {
  7978. var data = matchData[index];
  7979. if ((noCustomizer && data[2])
  7980. ? data[1] !== object[data[0]]
  7981. : !(data[0] in object)
  7982. ) {
  7983. return false;
  7984. }
  7985. }
  7986. while (++index < length) {
  7987. data = matchData[index];
  7988. var key = data[0],
  7989. objValue = object[key],
  7990. srcValue = data[1];
  7991. if (noCustomizer && data[2]) {
  7992. if (objValue === undefined && !(key in object)) {
  7993. return false;
  7994. }
  7995. } else {
  7996. var stack = new Stack;
  7997. if (customizer) {
  7998. var result = customizer(objValue, srcValue, key, object, source, stack);
  7999. }
  8000. if (!(result === undefined
  8001. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  8002. : result
  8003. )) {
  8004. return false;
  8005. }
  8006. }
  8007. }
  8008. return true;
  8009. }
  8010. /**
  8011. * The base implementation of `_.isNative` without bad shim checks.
  8012. *
  8013. * @private
  8014. * @param {*} value The value to check.
  8015. * @returns {boolean} Returns `true` if `value` is a native function,
  8016. * else `false`.
  8017. */
  8018. function baseIsNative(value) {
  8019. if (!isObject(value) || isMasked(value)) {
  8020. return false;
  8021. }
  8022. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  8023. return pattern.test(toSource(value));
  8024. }
  8025. /**
  8026. * The base implementation of `_.isRegExp` without Node.js optimizations.
  8027. *
  8028. * @private
  8029. * @param {*} value The value to check.
  8030. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  8031. */
  8032. function baseIsRegExp(value) {
  8033. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  8034. }
  8035. /**
  8036. * The base implementation of `_.isSet` without Node.js optimizations.
  8037. *
  8038. * @private
  8039. * @param {*} value The value to check.
  8040. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  8041. */
  8042. function baseIsSet(value) {
  8043. return isObjectLike(value) && getTag(value) == setTag;
  8044. }
  8045. /**
  8046. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  8047. *
  8048. * @private
  8049. * @param {*} value The value to check.
  8050. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  8051. */
  8052. function baseIsTypedArray(value) {
  8053. return isObjectLike(value) &&
  8054. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  8055. }
  8056. /**
  8057. * The base implementation of `_.iteratee`.
  8058. *
  8059. * @private
  8060. * @param {*} [value=_.identity] The value to convert to an iteratee.
  8061. * @returns {Function} Returns the iteratee.
  8062. */
  8063. function baseIteratee(value) {
  8064. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  8065. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  8066. if (typeof value == 'function') {
  8067. return value;
  8068. }
  8069. if (value == null) {
  8070. return identity;
  8071. }
  8072. if (typeof value == 'object') {
  8073. return isArray(value)
  8074. ? baseMatchesProperty(value[0], value[1])
  8075. : baseMatches(value);
  8076. }
  8077. return property(value);
  8078. }
  8079. /**
  8080. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  8081. *
  8082. * @private
  8083. * @param {Object} object The object to query.
  8084. * @returns {Array} Returns the array of property names.
  8085. */
  8086. function baseKeys(object) {
  8087. if (!isPrototype(object)) {
  8088. return nativeKeys(object);
  8089. }
  8090. var result = [];
  8091. for (var key in Object(object)) {
  8092. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  8093. result.push(key);
  8094. }
  8095. }
  8096. return result;
  8097. }
  8098. /**
  8099. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  8100. *
  8101. * @private
  8102. * @param {Object} object The object to query.
  8103. * @returns {Array} Returns the array of property names.
  8104. */
  8105. function baseKeysIn(object) {
  8106. if (!isObject(object)) {
  8107. return nativeKeysIn(object);
  8108. }
  8109. var isProto = isPrototype(object),
  8110. result = [];
  8111. for (var key in object) {
  8112. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  8113. result.push(key);
  8114. }
  8115. }
  8116. return result;
  8117. }
  8118. /**
  8119. * The base implementation of `_.lt` which doesn't coerce arguments.
  8120. *
  8121. * @private
  8122. * @param {*} value The value to compare.
  8123. * @param {*} other The other value to compare.
  8124. * @returns {boolean} Returns `true` if `value` is less than `other`,
  8125. * else `false`.
  8126. */
  8127. function baseLt(value, other) {
  8128. return value < other;
  8129. }
  8130. /**
  8131. * The base implementation of `_.map` without support for iteratee shorthands.
  8132. *
  8133. * @private
  8134. * @param {Array|Object} collection The collection to iterate over.
  8135. * @param {Function} iteratee The function invoked per iteration.
  8136. * @returns {Array} Returns the new mapped array.
  8137. */
  8138. function baseMap(collection, iteratee) {
  8139. var index = -1,
  8140. result = isArrayLike(collection) ? Array(collection.length) : [];
  8141. baseEach(collection, function(value, key, collection) {
  8142. result[++index] = iteratee(value, key, collection);
  8143. });
  8144. return result;
  8145. }
  8146. /**
  8147. * The base implementation of `_.matches` which doesn't clone `source`.
  8148. *
  8149. * @private
  8150. * @param {Object} source The object of property values to match.
  8151. * @returns {Function} Returns the new spec function.
  8152. */
  8153. function baseMatches(source) {
  8154. var matchData = getMatchData(source);
  8155. if (matchData.length == 1 && matchData[0][2]) {
  8156. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  8157. }
  8158. return function(object) {
  8159. return object === source || baseIsMatch(object, source, matchData);
  8160. };
  8161. }
  8162. /**
  8163. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  8164. *
  8165. * @private
  8166. * @param {string} path The path of the property to get.
  8167. * @param {*} srcValue The value to match.
  8168. * @returns {Function} Returns the new spec function.
  8169. */
  8170. function baseMatchesProperty(path, srcValue) {
  8171. if (isKey(path) && isStrictComparable(srcValue)) {
  8172. return matchesStrictComparable(toKey(path), srcValue);
  8173. }
  8174. return function(object) {
  8175. var objValue = get(object, path);
  8176. return (objValue === undefined && objValue === srcValue)
  8177. ? hasIn(object, path)
  8178. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  8179. };
  8180. }
  8181. /**
  8182. * The base implementation of `_.merge` without support for multiple sources.
  8183. *
  8184. * @private
  8185. * @param {Object} object The destination object.
  8186. * @param {Object} source The source object.
  8187. * @param {number} srcIndex The index of `source`.
  8188. * @param {Function} [customizer] The function to customize merged values.
  8189. * @param {Object} [stack] Tracks traversed source values and their merged
  8190. * counterparts.
  8191. */
  8192. function baseMerge(object, source, srcIndex, customizer, stack) {
  8193. if (object === source) {
  8194. return;
  8195. }
  8196. baseFor(source, function(srcValue, key) {
  8197. stack || (stack = new Stack);
  8198. if (isObject(srcValue)) {
  8199. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  8200. }
  8201. else {
  8202. var newValue = customizer
  8203. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  8204. : undefined;
  8205. if (newValue === undefined) {
  8206. newValue = srcValue;
  8207. }
  8208. assignMergeValue(object, key, newValue);
  8209. }
  8210. }, keysIn);
  8211. }
  8212. /**
  8213. * A specialized version of `baseMerge` for arrays and objects which performs
  8214. * deep merges and tracks traversed objects enabling objects with circular
  8215. * references to be merged.
  8216. *
  8217. * @private
  8218. * @param {Object} object The destination object.
  8219. * @param {Object} source The source object.
  8220. * @param {string} key The key of the value to merge.
  8221. * @param {number} srcIndex The index of `source`.
  8222. * @param {Function} mergeFunc The function to merge values.
  8223. * @param {Function} [customizer] The function to customize assigned values.
  8224. * @param {Object} [stack] Tracks traversed source values and their merged
  8225. * counterparts.
  8226. */
  8227. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  8228. var objValue = safeGet(object, key),
  8229. srcValue = safeGet(source, key),
  8230. stacked = stack.get(srcValue);
  8231. if (stacked) {
  8232. assignMergeValue(object, key, stacked);
  8233. return;
  8234. }
  8235. var newValue = customizer
  8236. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  8237. : undefined;
  8238. var isCommon = newValue === undefined;
  8239. if (isCommon) {
  8240. var isArr = isArray(srcValue),
  8241. isBuff = !isArr && isBuffer(srcValue),
  8242. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  8243. newValue = srcValue;
  8244. if (isArr || isBuff || isTyped) {
  8245. if (isArray(objValue)) {
  8246. newValue = objValue;
  8247. }
  8248. else if (isArrayLikeObject(objValue)) {
  8249. newValue = copyArray(objValue);
  8250. }
  8251. else if (isBuff) {
  8252. isCommon = false;
  8253. newValue = cloneBuffer(srcValue, true);
  8254. }
  8255. else if (isTyped) {
  8256. isCommon = false;
  8257. newValue = cloneTypedArray(srcValue, true);
  8258. }
  8259. else {
  8260. newValue = [];
  8261. }
  8262. }
  8263. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  8264. newValue = objValue;
  8265. if (isArguments(objValue)) {
  8266. newValue = toPlainObject(objValue);
  8267. }
  8268. else if (!isObject(objValue) || isFunction(objValue)) {
  8269. newValue = initCloneObject(srcValue);
  8270. }
  8271. }
  8272. else {
  8273. isCommon = false;
  8274. }
  8275. }
  8276. if (isCommon) {
  8277. // Recursively merge objects and arrays (susceptible to call stack limits).
  8278. stack.set(srcValue, newValue);
  8279. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  8280. stack['delete'](srcValue);
  8281. }
  8282. assignMergeValue(object, key, newValue);
  8283. }
  8284. /**
  8285. * The base implementation of `_.nth` which doesn't coerce arguments.
  8286. *
  8287. * @private
  8288. * @param {Array} array The array to query.
  8289. * @param {number} n The index of the element to return.
  8290. * @returns {*} Returns the nth element of `array`.
  8291. */
  8292. function baseNth(array, n) {
  8293. var length = array.length;
  8294. if (!length) {
  8295. return;
  8296. }
  8297. n += n < 0 ? length : 0;
  8298. return isIndex(n, length) ? array[n] : undefined;
  8299. }
  8300. /**
  8301. * The base implementation of `_.orderBy` without param guards.
  8302. *
  8303. * @private
  8304. * @param {Array|Object} collection The collection to iterate over.
  8305. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  8306. * @param {string[]} orders The sort orders of `iteratees`.
  8307. * @returns {Array} Returns the new sorted array.
  8308. */
  8309. function baseOrderBy(collection, iteratees, orders) {
  8310. if (iteratees.length) {
  8311. iteratees = arrayMap(iteratees, function(iteratee) {
  8312. if (isArray(iteratee)) {
  8313. return function(value) {
  8314. return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee);
  8315. }
  8316. }
  8317. return iteratee;
  8318. });
  8319. } else {
  8320. iteratees = [identity];
  8321. }
  8322. var index = -1;
  8323. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  8324. var result = baseMap(collection, function(value, key, collection) {
  8325. var criteria = arrayMap(iteratees, function(iteratee) {
  8326. return iteratee(value);
  8327. });
  8328. return { 'criteria': criteria, 'index': ++index, 'value': value };
  8329. });
  8330. return baseSortBy(result, function(object, other) {
  8331. return compareMultiple(object, other, orders);
  8332. });
  8333. }
  8334. /**
  8335. * The base implementation of `_.pick` without support for individual
  8336. * property identifiers.
  8337. *
  8338. * @private
  8339. * @param {Object} object The source object.
  8340. * @param {string[]} paths The property paths to pick.
  8341. * @returns {Object} Returns the new object.
  8342. */
  8343. function basePick(object, paths) {
  8344. return basePickBy(object, paths, function(value, path) {
  8345. return hasIn(object, path);
  8346. });
  8347. }
  8348. /**
  8349. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  8350. *
  8351. * @private
  8352. * @param {Object} object The source object.
  8353. * @param {string[]} paths The property paths to pick.
  8354. * @param {Function} predicate The function invoked per property.
  8355. * @returns {Object} Returns the new object.
  8356. */
  8357. function basePickBy(object, paths, predicate) {
  8358. var index = -1,
  8359. length = paths.length,
  8360. result = {};
  8361. while (++index < length) {
  8362. var path = paths[index],
  8363. value = baseGet(object, path);
  8364. if (predicate(value, path)) {
  8365. baseSet(result, castPath(path, object), value);
  8366. }
  8367. }
  8368. return result;
  8369. }
  8370. /**
  8371. * A specialized version of `baseProperty` which supports deep paths.
  8372. *
  8373. * @private
  8374. * @param {Array|string} path The path of the property to get.
  8375. * @returns {Function} Returns the new accessor function.
  8376. */
  8377. function basePropertyDeep(path) {
  8378. return function(object) {
  8379. return baseGet(object, path);
  8380. };
  8381. }
  8382. /**
  8383. * The base implementation of `_.pullAllBy` without support for iteratee
  8384. * shorthands.
  8385. *
  8386. * @private
  8387. * @param {Array} array The array to modify.
  8388. * @param {Array} values The values to remove.
  8389. * @param {Function} [iteratee] The iteratee invoked per element.
  8390. * @param {Function} [comparator] The comparator invoked per element.
  8391. * @returns {Array} Returns `array`.
  8392. */
  8393. function basePullAll(array, values, iteratee, comparator) {
  8394. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  8395. index = -1,
  8396. length = values.length,
  8397. seen = array;
  8398. if (array === values) {
  8399. values = copyArray(values);
  8400. }
  8401. if (iteratee) {
  8402. seen = arrayMap(array, baseUnary(iteratee));
  8403. }
  8404. while (++index < length) {
  8405. var fromIndex = 0,
  8406. value = values[index],
  8407. computed = iteratee ? iteratee(value) : value;
  8408. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  8409. if (seen !== array) {
  8410. splice.call(seen, fromIndex, 1);
  8411. }
  8412. splice.call(array, fromIndex, 1);
  8413. }
  8414. }
  8415. return array;
  8416. }
  8417. /**
  8418. * The base implementation of `_.pullAt` without support for individual
  8419. * indexes or capturing the removed elements.
  8420. *
  8421. * @private
  8422. * @param {Array} array The array to modify.
  8423. * @param {number[]} indexes The indexes of elements to remove.
  8424. * @returns {Array} Returns `array`.
  8425. */
  8426. function basePullAt(array, indexes) {
  8427. var length = array ? indexes.length : 0,
  8428. lastIndex = length - 1;
  8429. while (length--) {
  8430. var index = indexes[length];
  8431. if (length == lastIndex || index !== previous) {
  8432. var previous = index;
  8433. if (isIndex(index)) {
  8434. splice.call(array, index, 1);
  8435. } else {
  8436. baseUnset(array, index);
  8437. }
  8438. }
  8439. }
  8440. return array;
  8441. }
  8442. /**
  8443. * The base implementation of `_.random` without support for returning
  8444. * floating-point numbers.
  8445. *
  8446. * @private
  8447. * @param {number} lower The lower bound.
  8448. * @param {number} upper The upper bound.
  8449. * @returns {number} Returns the random number.
  8450. */
  8451. function baseRandom(lower, upper) {
  8452. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  8453. }
  8454. /**
  8455. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  8456. * coerce arguments.
  8457. *
  8458. * @private
  8459. * @param {number} start The start of the range.
  8460. * @param {number} end The end of the range.
  8461. * @param {number} step The value to increment or decrement by.
  8462. * @param {boolean} [fromRight] Specify iterating from right to left.
  8463. * @returns {Array} Returns the range of numbers.
  8464. */
  8465. function baseRange(start, end, step, fromRight) {
  8466. var index = -1,
  8467. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  8468. result = Array(length);
  8469. while (length--) {
  8470. result[fromRight ? length : ++index] = start;
  8471. start += step;
  8472. }
  8473. return result;
  8474. }
  8475. /**
  8476. * The base implementation of `_.repeat` which doesn't coerce arguments.
  8477. *
  8478. * @private
  8479. * @param {string} string The string to repeat.
  8480. * @param {number} n The number of times to repeat the string.
  8481. * @returns {string} Returns the repeated string.
  8482. */
  8483. function baseRepeat(string, n) {
  8484. var result = '';
  8485. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  8486. return result;
  8487. }
  8488. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  8489. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  8490. do {
  8491. if (n % 2) {
  8492. result += string;
  8493. }
  8494. n = nativeFloor(n / 2);
  8495. if (n) {
  8496. string += string;
  8497. }
  8498. } while (n);
  8499. return result;
  8500. }
  8501. /**
  8502. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  8503. *
  8504. * @private
  8505. * @param {Function} func The function to apply a rest parameter to.
  8506. * @param {number} [start=func.length-1] The start position of the rest parameter.
  8507. * @returns {Function} Returns the new function.
  8508. */
  8509. function baseRest(func, start) {
  8510. return setToString(overRest(func, start, identity), func + '');
  8511. }
  8512. /**
  8513. * The base implementation of `_.sample`.
  8514. *
  8515. * @private
  8516. * @param {Array|Object} collection The collection to sample.
  8517. * @returns {*} Returns the random element.
  8518. */
  8519. function baseSample(collection) {
  8520. return arraySample(values(collection));
  8521. }
  8522. /**
  8523. * The base implementation of `_.sampleSize` without param guards.
  8524. *
  8525. * @private
  8526. * @param {Array|Object} collection The collection to sample.
  8527. * @param {number} n The number of elements to sample.
  8528. * @returns {Array} Returns the random elements.
  8529. */
  8530. function baseSampleSize(collection, n) {
  8531. var array = values(collection);
  8532. return shuffleSelf(array, baseClamp(n, 0, array.length));
  8533. }
  8534. /**
  8535. * The base implementation of `_.set`.
  8536. *
  8537. * @private
  8538. * @param {Object} object The object to modify.
  8539. * @param {Array|string} path The path of the property to set.
  8540. * @param {*} value The value to set.
  8541. * @param {Function} [customizer] The function to customize path creation.
  8542. * @returns {Object} Returns `object`.
  8543. */
  8544. function baseSet(object, path, value, customizer) {
  8545. if (!isObject(object)) {
  8546. return object;
  8547. }
  8548. path = castPath(path, object);
  8549. var index = -1,
  8550. length = path.length,
  8551. lastIndex = length - 1,
  8552. nested = object;
  8553. while (nested != null && ++index < length) {
  8554. var key = toKey(path[index]),
  8555. newValue = value;
  8556. if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
  8557. return object;
  8558. }
  8559. if (index != lastIndex) {
  8560. var objValue = nested[key];
  8561. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  8562. if (newValue === undefined) {
  8563. newValue = isObject(objValue)
  8564. ? objValue
  8565. : (isIndex(path[index + 1]) ? [] : {});
  8566. }
  8567. }
  8568. assignValue(nested, key, newValue);
  8569. nested = nested[key];
  8570. }
  8571. return object;
  8572. }
  8573. /**
  8574. * The base implementation of `setData` without support for hot loop shorting.
  8575. *
  8576. * @private
  8577. * @param {Function} func The function to associate metadata with.
  8578. * @param {*} data The metadata.
  8579. * @returns {Function} Returns `func`.
  8580. */
  8581. var baseSetData = !metaMap ? identity : function(func, data) {
  8582. metaMap.set(func, data);
  8583. return func;
  8584. };
  8585. /**
  8586. * The base implementation of `setToString` without support for hot loop shorting.
  8587. *
  8588. * @private
  8589. * @param {Function} func The function to modify.
  8590. * @param {Function} string The `toString` result.
  8591. * @returns {Function} Returns `func`.
  8592. */
  8593. var baseSetToString = !defineProperty ? identity : function(func, string) {
  8594. return defineProperty(func, 'toString', {
  8595. 'configurable': true,
  8596. 'enumerable': false,
  8597. 'value': constant(string),
  8598. 'writable': true
  8599. });
  8600. };
  8601. /**
  8602. * The base implementation of `_.shuffle`.
  8603. *
  8604. * @private
  8605. * @param {Array|Object} collection The collection to shuffle.
  8606. * @returns {Array} Returns the new shuffled array.
  8607. */
  8608. function baseShuffle(collection) {
  8609. return shuffleSelf(values(collection));
  8610. }
  8611. /**
  8612. * The base implementation of `_.slice` without an iteratee call guard.
  8613. *
  8614. * @private
  8615. * @param {Array} array The array to slice.
  8616. * @param {number} [start=0] The start position.
  8617. * @param {number} [end=array.length] The end position.
  8618. * @returns {Array} Returns the slice of `array`.
  8619. */
  8620. function baseSlice(array, start, end) {
  8621. var index = -1,
  8622. length = array.length;
  8623. if (start < 0) {
  8624. start = -start > length ? 0 : (length + start);
  8625. }
  8626. end = end > length ? length : end;
  8627. if (end < 0) {
  8628. end += length;
  8629. }
  8630. length = start > end ? 0 : ((end - start) >>> 0);
  8631. start >>>= 0;
  8632. var result = Array(length);
  8633. while (++index < length) {
  8634. result[index] = array[index + start];
  8635. }
  8636. return result;
  8637. }
  8638. /**
  8639. * The base implementation of `_.some` without support for iteratee shorthands.
  8640. *
  8641. * @private
  8642. * @param {Array|Object} collection The collection to iterate over.
  8643. * @param {Function} predicate The function invoked per iteration.
  8644. * @returns {boolean} Returns `true` if any element passes the predicate check,
  8645. * else `false`.
  8646. */
  8647. function baseSome(collection, predicate) {
  8648. var result;
  8649. baseEach(collection, function(value, index, collection) {
  8650. result = predicate(value, index, collection);
  8651. return !result;
  8652. });
  8653. return !!result;
  8654. }
  8655. /**
  8656. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  8657. * performs a binary search of `array` to determine the index at which `value`
  8658. * should be inserted into `array` in order to maintain its sort order.
  8659. *
  8660. * @private
  8661. * @param {Array} array The sorted array to inspect.
  8662. * @param {*} value The value to evaluate.
  8663. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  8664. * @returns {number} Returns the index at which `value` should be inserted
  8665. * into `array`.
  8666. */
  8667. function baseSortedIndex(array, value, retHighest) {
  8668. var low = 0,
  8669. high = array == null ? low : array.length;
  8670. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  8671. while (low < high) {
  8672. var mid = (low + high) >>> 1,
  8673. computed = array[mid];
  8674. if (computed !== null && !isSymbol(computed) &&
  8675. (retHighest ? (computed <= value) : (computed < value))) {
  8676. low = mid + 1;
  8677. } else {
  8678. high = mid;
  8679. }
  8680. }
  8681. return high;
  8682. }
  8683. return baseSortedIndexBy(array, value, identity, retHighest);
  8684. }
  8685. /**
  8686. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  8687. * which invokes `iteratee` for `value` and each element of `array` to compute
  8688. * their sort ranking. The iteratee is invoked with one argument; (value).
  8689. *
  8690. * @private
  8691. * @param {Array} array The sorted array to inspect.
  8692. * @param {*} value The value to evaluate.
  8693. * @param {Function} iteratee The iteratee invoked per element.
  8694. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  8695. * @returns {number} Returns the index at which `value` should be inserted
  8696. * into `array`.
  8697. */
  8698. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  8699. var low = 0,
  8700. high = array == null ? 0 : array.length;
  8701. if (high === 0) {
  8702. return 0;
  8703. }
  8704. value = iteratee(value);
  8705. var valIsNaN = value !== value,
  8706. valIsNull = value === null,
  8707. valIsSymbol = isSymbol(value),
  8708. valIsUndefined = value === undefined;
  8709. while (low < high) {
  8710. var mid = nativeFloor((low + high) / 2),
  8711. computed = iteratee(array[mid]),
  8712. othIsDefined = computed !== undefined,
  8713. othIsNull = computed === null,
  8714. othIsReflexive = computed === computed,
  8715. othIsSymbol = isSymbol(computed);
  8716. if (valIsNaN) {
  8717. var setLow = retHighest || othIsReflexive;
  8718. } else if (valIsUndefined) {
  8719. setLow = othIsReflexive && (retHighest || othIsDefined);
  8720. } else if (valIsNull) {
  8721. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  8722. } else if (valIsSymbol) {
  8723. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  8724. } else if (othIsNull || othIsSymbol) {
  8725. setLow = false;
  8726. } else {
  8727. setLow = retHighest ? (computed <= value) : (computed < value);
  8728. }
  8729. if (setLow) {
  8730. low = mid + 1;
  8731. } else {
  8732. high = mid;
  8733. }
  8734. }
  8735. return nativeMin(high, MAX_ARRAY_INDEX);
  8736. }
  8737. /**
  8738. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  8739. * support for iteratee shorthands.
  8740. *
  8741. * @private
  8742. * @param {Array} array The array to inspect.
  8743. * @param {Function} [iteratee] The iteratee invoked per element.
  8744. * @returns {Array} Returns the new duplicate free array.
  8745. */
  8746. function baseSortedUniq(array, iteratee) {
  8747. var index = -1,
  8748. length = array.length,
  8749. resIndex = 0,
  8750. result = [];
  8751. while (++index < length) {
  8752. var value = array[index],
  8753. computed = iteratee ? iteratee(value) : value;
  8754. if (!index || !eq(computed, seen)) {
  8755. var seen = computed;
  8756. result[resIndex++] = value === 0 ? 0 : value;
  8757. }
  8758. }
  8759. return result;
  8760. }
  8761. /**
  8762. * The base implementation of `_.toNumber` which doesn't ensure correct
  8763. * conversions of binary, hexadecimal, or octal string values.
  8764. *
  8765. * @private
  8766. * @param {*} value The value to process.
  8767. * @returns {number} Returns the number.
  8768. */
  8769. function baseToNumber(value) {
  8770. if (typeof value == 'number') {
  8771. return value;
  8772. }
  8773. if (isSymbol(value)) {
  8774. return NAN;
  8775. }
  8776. return +value;
  8777. }
  8778. /**
  8779. * The base implementation of `_.toString` which doesn't convert nullish
  8780. * values to empty strings.
  8781. *
  8782. * @private
  8783. * @param {*} value The value to process.
  8784. * @returns {string} Returns the string.
  8785. */
  8786. function baseToString(value) {
  8787. // Exit early for strings to avoid a performance hit in some environments.
  8788. if (typeof value == 'string') {
  8789. return value;
  8790. }
  8791. if (isArray(value)) {
  8792. // Recursively convert values (susceptible to call stack limits).
  8793. return arrayMap(value, baseToString) + '';
  8794. }
  8795. if (isSymbol(value)) {
  8796. return symbolToString ? symbolToString.call(value) : '';
  8797. }
  8798. var result = (value + '');
  8799. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  8800. }
  8801. /**
  8802. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  8803. *
  8804. * @private
  8805. * @param {Array} array The array to inspect.
  8806. * @param {Function} [iteratee] The iteratee invoked per element.
  8807. * @param {Function} [comparator] The comparator invoked per element.
  8808. * @returns {Array} Returns the new duplicate free array.
  8809. */
  8810. function baseUniq(array, iteratee, comparator) {
  8811. var index = -1,
  8812. includes = arrayIncludes,
  8813. length = array.length,
  8814. isCommon = true,
  8815. result = [],
  8816. seen = result;
  8817. if (comparator) {
  8818. isCommon = false;
  8819. includes = arrayIncludesWith;
  8820. }
  8821. else if (length >= LARGE_ARRAY_SIZE) {
  8822. var set = iteratee ? null : createSet(array);
  8823. if (set) {
  8824. return setToArray(set);
  8825. }
  8826. isCommon = false;
  8827. includes = cacheHas;
  8828. seen = new SetCache;
  8829. }
  8830. else {
  8831. seen = iteratee ? [] : result;
  8832. }
  8833. outer:
  8834. while (++index < length) {
  8835. var value = array[index],
  8836. computed = iteratee ? iteratee(value) : value;
  8837. value = (comparator || value !== 0) ? value : 0;
  8838. if (isCommon && computed === computed) {
  8839. var seenIndex = seen.length;
  8840. while (seenIndex--) {
  8841. if (seen[seenIndex] === computed) {
  8842. continue outer;
  8843. }
  8844. }
  8845. if (iteratee) {
  8846. seen.push(computed);
  8847. }
  8848. result.push(value);
  8849. }
  8850. else if (!includes(seen, computed, comparator)) {
  8851. if (seen !== result) {
  8852. seen.push(computed);
  8853. }
  8854. result.push(value);
  8855. }
  8856. }
  8857. return result;
  8858. }
  8859. /**
  8860. * The base implementation of `_.unset`.
  8861. *
  8862. * @private
  8863. * @param {Object} object The object to modify.
  8864. * @param {Array|string} path The property path to unset.
  8865. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  8866. */
  8867. function baseUnset(object, path) {
  8868. path = castPath(path, object);
  8869. object = parent(object, path);
  8870. return object == null || delete object[toKey(last(path))];
  8871. }
  8872. /**
  8873. * The base implementation of `_.update`.
  8874. *
  8875. * @private
  8876. * @param {Object} object The object to modify.
  8877. * @param {Array|string} path The path of the property to update.
  8878. * @param {Function} updater The function to produce the updated value.
  8879. * @param {Function} [customizer] The function to customize path creation.
  8880. * @returns {Object} Returns `object`.
  8881. */
  8882. function baseUpdate(object, path, updater, customizer) {
  8883. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  8884. }
  8885. /**
  8886. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  8887. * without support for iteratee shorthands.
  8888. *
  8889. * @private
  8890. * @param {Array} array The array to query.
  8891. * @param {Function} predicate The function invoked per iteration.
  8892. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  8893. * @param {boolean} [fromRight] Specify iterating from right to left.
  8894. * @returns {Array} Returns the slice of `array`.
  8895. */
  8896. function baseWhile(array, predicate, isDrop, fromRight) {
  8897. var length = array.length,
  8898. index = fromRight ? length : -1;
  8899. while ((fromRight ? index-- : ++index < length) &&
  8900. predicate(array[index], index, array)) {}
  8901. return isDrop
  8902. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  8903. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  8904. }
  8905. /**
  8906. * The base implementation of `wrapperValue` which returns the result of
  8907. * performing a sequence of actions on the unwrapped `value`, where each
  8908. * successive action is supplied the return value of the previous.
  8909. *
  8910. * @private
  8911. * @param {*} value The unwrapped value.
  8912. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  8913. * @returns {*} Returns the resolved value.
  8914. */
  8915. function baseWrapperValue(value, actions) {
  8916. var result = value;
  8917. if (result instanceof LazyWrapper) {
  8918. result = result.value();
  8919. }
  8920. return arrayReduce(actions, function(result, action) {
  8921. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  8922. }, result);
  8923. }
  8924. /**
  8925. * The base implementation of methods like `_.xor`, without support for
  8926. * iteratee shorthands, that accepts an array of arrays to inspect.
  8927. *
  8928. * @private
  8929. * @param {Array} arrays The arrays to inspect.
  8930. * @param {Function} [iteratee] The iteratee invoked per element.
  8931. * @param {Function} [comparator] The comparator invoked per element.
  8932. * @returns {Array} Returns the new array of values.
  8933. */
  8934. function baseXor(arrays, iteratee, comparator) {
  8935. var length = arrays.length;
  8936. if (length < 2) {
  8937. return length ? baseUniq(arrays[0]) : [];
  8938. }
  8939. var index = -1,
  8940. result = Array(length);
  8941. while (++index < length) {
  8942. var array = arrays[index],
  8943. othIndex = -1;
  8944. while (++othIndex < length) {
  8945. if (othIndex != index) {
  8946. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  8947. }
  8948. }
  8949. }
  8950. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  8951. }
  8952. /**
  8953. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  8954. *
  8955. * @private
  8956. * @param {Array} props The property identifiers.
  8957. * @param {Array} values The property values.
  8958. * @param {Function} assignFunc The function to assign values.
  8959. * @returns {Object} Returns the new object.
  8960. */
  8961. function baseZipObject(props, values, assignFunc) {
  8962. var index = -1,
  8963. length = props.length,
  8964. valsLength = values.length,
  8965. result = {};
  8966. while (++index < length) {
  8967. var value = index < valsLength ? values[index] : undefined;
  8968. assignFunc(result, props[index], value);
  8969. }
  8970. return result;
  8971. }
  8972. /**
  8973. * Casts `value` to an empty array if it's not an array like object.
  8974. *
  8975. * @private
  8976. * @param {*} value The value to inspect.
  8977. * @returns {Array|Object} Returns the cast array-like object.
  8978. */
  8979. function castArrayLikeObject(value) {
  8980. return isArrayLikeObject(value) ? value : [];
  8981. }
  8982. /**
  8983. * Casts `value` to `identity` if it's not a function.
  8984. *
  8985. * @private
  8986. * @param {*} value The value to inspect.
  8987. * @returns {Function} Returns cast function.
  8988. */
  8989. function castFunction(value) {
  8990. return typeof value == 'function' ? value : identity;
  8991. }
  8992. /**
  8993. * Casts `value` to a path array if it's not one.
  8994. *
  8995. * @private
  8996. * @param {*} value The value to inspect.
  8997. * @param {Object} [object] The object to query keys on.
  8998. * @returns {Array} Returns the cast property path array.
  8999. */
  9000. function castPath(value, object) {
  9001. if (isArray(value)) {
  9002. return value;
  9003. }
  9004. return isKey(value, object) ? [value] : stringToPath(toString(value));
  9005. }
  9006. /**
  9007. * A `baseRest` alias which can be replaced with `identity` by module
  9008. * replacement plugins.
  9009. *
  9010. * @private
  9011. * @type {Function}
  9012. * @param {Function} func The function to apply a rest parameter to.
  9013. * @returns {Function} Returns the new function.
  9014. */
  9015. var castRest = baseRest;
  9016. /**
  9017. * Casts `array` to a slice if it's needed.
  9018. *
  9019. * @private
  9020. * @param {Array} array The array to inspect.
  9021. * @param {number} start The start position.
  9022. * @param {number} [end=array.length] The end position.
  9023. * @returns {Array} Returns the cast slice.
  9024. */
  9025. function castSlice(array, start, end) {
  9026. var length = array.length;
  9027. end = end === undefined ? length : end;
  9028. return (!start && end >= length) ? array : baseSlice(array, start, end);
  9029. }
  9030. /**
  9031. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  9032. *
  9033. * @private
  9034. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  9035. */
  9036. var clearTimeout = ctxClearTimeout || function(id) {
  9037. return root.clearTimeout(id);
  9038. };
  9039. /**
  9040. * Creates a clone of `buffer`.
  9041. *
  9042. * @private
  9043. * @param {Buffer} buffer The buffer to clone.
  9044. * @param {boolean} [isDeep] Specify a deep clone.
  9045. * @returns {Buffer} Returns the cloned buffer.
  9046. */
  9047. function cloneBuffer(buffer, isDeep) {
  9048. if (isDeep) {
  9049. return buffer.slice();
  9050. }
  9051. var length = buffer.length,
  9052. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  9053. buffer.copy(result);
  9054. return result;
  9055. }
  9056. /**
  9057. * Creates a clone of `arrayBuffer`.
  9058. *
  9059. * @private
  9060. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  9061. * @returns {ArrayBuffer} Returns the cloned array buffer.
  9062. */
  9063. function cloneArrayBuffer(arrayBuffer) {
  9064. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  9065. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  9066. return result;
  9067. }
  9068. /**
  9069. * Creates a clone of `dataView`.
  9070. *
  9071. * @private
  9072. * @param {Object} dataView The data view to clone.
  9073. * @param {boolean} [isDeep] Specify a deep clone.
  9074. * @returns {Object} Returns the cloned data view.
  9075. */
  9076. function cloneDataView(dataView, isDeep) {
  9077. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  9078. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  9079. }
  9080. /**
  9081. * Creates a clone of `regexp`.
  9082. *
  9083. * @private
  9084. * @param {Object} regexp The regexp to clone.
  9085. * @returns {Object} Returns the cloned regexp.
  9086. */
  9087. function cloneRegExp(regexp) {
  9088. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  9089. result.lastIndex = regexp.lastIndex;
  9090. return result;
  9091. }
  9092. /**
  9093. * Creates a clone of the `symbol` object.
  9094. *
  9095. * @private
  9096. * @param {Object} symbol The symbol object to clone.
  9097. * @returns {Object} Returns the cloned symbol object.
  9098. */
  9099. function cloneSymbol(symbol) {
  9100. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  9101. }
  9102. /**
  9103. * Creates a clone of `typedArray`.
  9104. *
  9105. * @private
  9106. * @param {Object} typedArray The typed array to clone.
  9107. * @param {boolean} [isDeep] Specify a deep clone.
  9108. * @returns {Object} Returns the cloned typed array.
  9109. */
  9110. function cloneTypedArray(typedArray, isDeep) {
  9111. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  9112. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  9113. }
  9114. /**
  9115. * Compares values to sort them in ascending order.
  9116. *
  9117. * @private
  9118. * @param {*} value The value to compare.
  9119. * @param {*} other The other value to compare.
  9120. * @returns {number} Returns the sort order indicator for `value`.
  9121. */
  9122. function compareAscending(value, other) {
  9123. if (value !== other) {
  9124. var valIsDefined = value !== undefined,
  9125. valIsNull = value === null,
  9126. valIsReflexive = value === value,
  9127. valIsSymbol = isSymbol(value);
  9128. var othIsDefined = other !== undefined,
  9129. othIsNull = other === null,
  9130. othIsReflexive = other === other,
  9131. othIsSymbol = isSymbol(other);
  9132. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  9133. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  9134. (valIsNull && othIsDefined && othIsReflexive) ||
  9135. (!valIsDefined && othIsReflexive) ||
  9136. !valIsReflexive) {
  9137. return 1;
  9138. }
  9139. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  9140. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  9141. (othIsNull && valIsDefined && valIsReflexive) ||
  9142. (!othIsDefined && valIsReflexive) ||
  9143. !othIsReflexive) {
  9144. return -1;
  9145. }
  9146. }
  9147. return 0;
  9148. }
  9149. /**
  9150. * Used by `_.orderBy` to compare multiple properties of a value to another
  9151. * and stable sort them.
  9152. *
  9153. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  9154. * specify an order of "desc" for descending or "asc" for ascending sort order
  9155. * of corresponding values.
  9156. *
  9157. * @private
  9158. * @param {Object} object The object to compare.
  9159. * @param {Object} other The other object to compare.
  9160. * @param {boolean[]|string[]} orders The order to sort by for each property.
  9161. * @returns {number} Returns the sort order indicator for `object`.
  9162. */
  9163. function compareMultiple(object, other, orders) {
  9164. var index = -1,
  9165. objCriteria = object.criteria,
  9166. othCriteria = other.criteria,
  9167. length = objCriteria.length,
  9168. ordersLength = orders.length;
  9169. while (++index < length) {
  9170. var result = compareAscending(objCriteria[index], othCriteria[index]);
  9171. if (result) {
  9172. if (index >= ordersLength) {
  9173. return result;
  9174. }
  9175. var order = orders[index];
  9176. return result * (order == 'desc' ? -1 : 1);
  9177. }
  9178. }
  9179. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  9180. // that causes it, under certain circumstances, to provide the same value for
  9181. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  9182. // for more details.
  9183. //
  9184. // This also ensures a stable sort in V8 and other engines.
  9185. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  9186. return object.index - other.index;
  9187. }
  9188. /**
  9189. * Creates an array that is the composition of partially applied arguments,
  9190. * placeholders, and provided arguments into a single array of arguments.
  9191. *
  9192. * @private
  9193. * @param {Array} args The provided arguments.
  9194. * @param {Array} partials The arguments to prepend to those provided.
  9195. * @param {Array} holders The `partials` placeholder indexes.
  9196. * @params {boolean} [isCurried] Specify composing for a curried function.
  9197. * @returns {Array} Returns the new array of composed arguments.
  9198. */
  9199. function composeArgs(args, partials, holders, isCurried) {
  9200. var argsIndex = -1,
  9201. argsLength = args.length,
  9202. holdersLength = holders.length,
  9203. leftIndex = -1,
  9204. leftLength = partials.length,
  9205. rangeLength = nativeMax(argsLength - holdersLength, 0),
  9206. result = Array(leftLength + rangeLength),
  9207. isUncurried = !isCurried;
  9208. while (++leftIndex < leftLength) {
  9209. result[leftIndex] = partials[leftIndex];
  9210. }
  9211. while (++argsIndex < holdersLength) {
  9212. if (isUncurried || argsIndex < argsLength) {
  9213. result[holders[argsIndex]] = args[argsIndex];
  9214. }
  9215. }
  9216. while (rangeLength--) {
  9217. result[leftIndex++] = args[argsIndex++];
  9218. }
  9219. return result;
  9220. }
  9221. /**
  9222. * This function is like `composeArgs` except that the arguments composition
  9223. * is tailored for `_.partialRight`.
  9224. *
  9225. * @private
  9226. * @param {Array} args The provided arguments.
  9227. * @param {Array} partials The arguments to append to those provided.
  9228. * @param {Array} holders The `partials` placeholder indexes.
  9229. * @params {boolean} [isCurried] Specify composing for a curried function.
  9230. * @returns {Array} Returns the new array of composed arguments.
  9231. */
  9232. function composeArgsRight(args, partials, holders, isCurried) {
  9233. var argsIndex = -1,
  9234. argsLength = args.length,
  9235. holdersIndex = -1,
  9236. holdersLength = holders.length,
  9237. rightIndex = -1,
  9238. rightLength = partials.length,
  9239. rangeLength = nativeMax(argsLength - holdersLength, 0),
  9240. result = Array(rangeLength + rightLength),
  9241. isUncurried = !isCurried;
  9242. while (++argsIndex < rangeLength) {
  9243. result[argsIndex] = args[argsIndex];
  9244. }
  9245. var offset = argsIndex;
  9246. while (++rightIndex < rightLength) {
  9247. result[offset + rightIndex] = partials[rightIndex];
  9248. }
  9249. while (++holdersIndex < holdersLength) {
  9250. if (isUncurried || argsIndex < argsLength) {
  9251. result[offset + holders[holdersIndex]] = args[argsIndex++];
  9252. }
  9253. }
  9254. return result;
  9255. }
  9256. /**
  9257. * Copies the values of `source` to `array`.
  9258. *
  9259. * @private
  9260. * @param {Array} source The array to copy values from.
  9261. * @param {Array} [array=[]] The array to copy values to.
  9262. * @returns {Array} Returns `array`.
  9263. */
  9264. function copyArray(source, array) {
  9265. var index = -1,
  9266. length = source.length;
  9267. array || (array = Array(length));
  9268. while (++index < length) {
  9269. array[index] = source[index];
  9270. }
  9271. return array;
  9272. }
  9273. /**
  9274. * Copies properties of `source` to `object`.
  9275. *
  9276. * @private
  9277. * @param {Object} source The object to copy properties from.
  9278. * @param {Array} props The property identifiers to copy.
  9279. * @param {Object} [object={}] The object to copy properties to.
  9280. * @param {Function} [customizer] The function to customize copied values.
  9281. * @returns {Object} Returns `object`.
  9282. */
  9283. function copyObject(source, props, object, customizer) {
  9284. var isNew = !object;
  9285. object || (object = {});
  9286. var index = -1,
  9287. length = props.length;
  9288. while (++index < length) {
  9289. var key = props[index];
  9290. var newValue = customizer
  9291. ? customizer(object[key], source[key], key, object, source)
  9292. : undefined;
  9293. if (newValue === undefined) {
  9294. newValue = source[key];
  9295. }
  9296. if (isNew) {
  9297. baseAssignValue(object, key, newValue);
  9298. } else {
  9299. assignValue(object, key, newValue);
  9300. }
  9301. }
  9302. return object;
  9303. }
  9304. /**
  9305. * Copies own symbols of `source` to `object`.
  9306. *
  9307. * @private
  9308. * @param {Object} source The object to copy symbols from.
  9309. * @param {Object} [object={}] The object to copy symbols to.
  9310. * @returns {Object} Returns `object`.
  9311. */
  9312. function copySymbols(source, object) {
  9313. return copyObject(source, getSymbols(source), object);
  9314. }
  9315. /**
  9316. * Copies own and inherited symbols of `source` to `object`.
  9317. *
  9318. * @private
  9319. * @param {Object} source The object to copy symbols from.
  9320. * @param {Object} [object={}] The object to copy symbols to.
  9321. * @returns {Object} Returns `object`.
  9322. */
  9323. function copySymbolsIn(source, object) {
  9324. return copyObject(source, getSymbolsIn(source), object);
  9325. }
  9326. /**
  9327. * Creates a function like `_.groupBy`.
  9328. *
  9329. * @private
  9330. * @param {Function} setter The function to set accumulator values.
  9331. * @param {Function} [initializer] The accumulator object initializer.
  9332. * @returns {Function} Returns the new aggregator function.
  9333. */
  9334. function createAggregator(setter, initializer) {
  9335. return function(collection, iteratee) {
  9336. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  9337. accumulator = initializer ? initializer() : {};
  9338. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  9339. };
  9340. }
  9341. /**
  9342. * Creates a function like `_.assign`.
  9343. *
  9344. * @private
  9345. * @param {Function} assigner The function to assign values.
  9346. * @returns {Function} Returns the new assigner function.
  9347. */
  9348. function createAssigner(assigner) {
  9349. return baseRest(function(object, sources) {
  9350. var index = -1,
  9351. length = sources.length,
  9352. customizer = length > 1 ? sources[length - 1] : undefined,
  9353. guard = length > 2 ? sources[2] : undefined;
  9354. customizer = (assigner.length > 3 && typeof customizer == 'function')
  9355. ? (length--, customizer)
  9356. : undefined;
  9357. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  9358. customizer = length < 3 ? undefined : customizer;
  9359. length = 1;
  9360. }
  9361. object = Object(object);
  9362. while (++index < length) {
  9363. var source = sources[index];
  9364. if (source) {
  9365. assigner(object, source, index, customizer);
  9366. }
  9367. }
  9368. return object;
  9369. });
  9370. }
  9371. /**
  9372. * Creates a `baseEach` or `baseEachRight` function.
  9373. *
  9374. * @private
  9375. * @param {Function} eachFunc The function to iterate over a collection.
  9376. * @param {boolean} [fromRight] Specify iterating from right to left.
  9377. * @returns {Function} Returns the new base function.
  9378. */
  9379. function createBaseEach(eachFunc, fromRight) {
  9380. return function(collection, iteratee) {
  9381. if (collection == null) {
  9382. return collection;
  9383. }
  9384. if (!isArrayLike(collection)) {
  9385. return eachFunc(collection, iteratee);
  9386. }
  9387. var length = collection.length,
  9388. index = fromRight ? length : -1,
  9389. iterable = Object(collection);
  9390. while ((fromRight ? index-- : ++index < length)) {
  9391. if (iteratee(iterable[index], index, iterable) === false) {
  9392. break;
  9393. }
  9394. }
  9395. return collection;
  9396. };
  9397. }
  9398. /**
  9399. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  9400. *
  9401. * @private
  9402. * @param {boolean} [fromRight] Specify iterating from right to left.
  9403. * @returns {Function} Returns the new base function.
  9404. */
  9405. function createBaseFor(fromRight) {
  9406. return function(object, iteratee, keysFunc) {
  9407. var index = -1,
  9408. iterable = Object(object),
  9409. props = keysFunc(object),
  9410. length = props.length;
  9411. while (length--) {
  9412. var key = props[fromRight ? length : ++index];
  9413. if (iteratee(iterable[key], key, iterable) === false) {
  9414. break;
  9415. }
  9416. }
  9417. return object;
  9418. };
  9419. }
  9420. /**
  9421. * Creates a function that wraps `func` to invoke it with the optional `this`
  9422. * binding of `thisArg`.
  9423. *
  9424. * @private
  9425. * @param {Function} func The function to wrap.
  9426. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  9427. * @param {*} [thisArg] The `this` binding of `func`.
  9428. * @returns {Function} Returns the new wrapped function.
  9429. */
  9430. function createBind(func, bitmask, thisArg) {
  9431. var isBind = bitmask & WRAP_BIND_FLAG,
  9432. Ctor = createCtor(func);
  9433. function wrapper() {
  9434. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  9435. return fn.apply(isBind ? thisArg : this, arguments);
  9436. }
  9437. return wrapper;
  9438. }
  9439. /**
  9440. * Creates a function like `_.lowerFirst`.
  9441. *
  9442. * @private
  9443. * @param {string} methodName The name of the `String` case method to use.
  9444. * @returns {Function} Returns the new case function.
  9445. */
  9446. function createCaseFirst(methodName) {
  9447. return function(string) {
  9448. string = toString(string);
  9449. var strSymbols = hasUnicode(string)
  9450. ? stringToArray(string)
  9451. : undefined;
  9452. var chr = strSymbols
  9453. ? strSymbols[0]
  9454. : string.charAt(0);
  9455. var trailing = strSymbols
  9456. ? castSlice(strSymbols, 1).join('')
  9457. : string.slice(1);
  9458. return chr[methodName]() + trailing;
  9459. };
  9460. }
  9461. /**
  9462. * Creates a function like `_.camelCase`.
  9463. *
  9464. * @private
  9465. * @param {Function} callback The function to combine each word.
  9466. * @returns {Function} Returns the new compounder function.
  9467. */
  9468. function createCompounder(callback) {
  9469. return function(string) {
  9470. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  9471. };
  9472. }
  9473. /**
  9474. * Creates a function that produces an instance of `Ctor` regardless of
  9475. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  9476. *
  9477. * @private
  9478. * @param {Function} Ctor The constructor to wrap.
  9479. * @returns {Function} Returns the new wrapped function.
  9480. */
  9481. function createCtor(Ctor) {
  9482. return function() {
  9483. // Use a `switch` statement to work with class constructors. See
  9484. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  9485. // for more details.
  9486. var args = arguments;
  9487. switch (args.length) {
  9488. case 0: return new Ctor;
  9489. case 1: return new Ctor(args[0]);
  9490. case 2: return new Ctor(args[0], args[1]);
  9491. case 3: return new Ctor(args[0], args[1], args[2]);
  9492. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  9493. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  9494. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  9495. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  9496. }
  9497. var thisBinding = baseCreate(Ctor.prototype),
  9498. result = Ctor.apply(thisBinding, args);
  9499. // Mimic the constructor's `return` behavior.
  9500. // See https://es5.github.io/#x13.2.2 for more details.
  9501. return isObject(result) ? result : thisBinding;
  9502. };
  9503. }
  9504. /**
  9505. * Creates a function that wraps `func` to enable currying.
  9506. *
  9507. * @private
  9508. * @param {Function} func The function to wrap.
  9509. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  9510. * @param {number} arity The arity of `func`.
  9511. * @returns {Function} Returns the new wrapped function.
  9512. */
  9513. function createCurry(func, bitmask, arity) {
  9514. var Ctor = createCtor(func);
  9515. function wrapper() {
  9516. var length = arguments.length,
  9517. args = Array(length),
  9518. index = length,
  9519. placeholder = getHolder(wrapper);
  9520. while (index--) {
  9521. args[index] = arguments[index];
  9522. }
  9523. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  9524. ? []
  9525. : replaceHolders(args, placeholder);
  9526. length -= holders.length;
  9527. if (length < arity) {
  9528. return createRecurry(
  9529. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  9530. args, holders, undefined, undefined, arity - length);
  9531. }
  9532. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  9533. return apply(fn, this, args);
  9534. }
  9535. return wrapper;
  9536. }
  9537. /**
  9538. * Creates a `_.find` or `_.findLast` function.
  9539. *
  9540. * @private
  9541. * @param {Function} findIndexFunc The function to find the collection index.
  9542. * @returns {Function} Returns the new find function.
  9543. */
  9544. function createFind(findIndexFunc) {
  9545. return function(collection, predicate, fromIndex) {
  9546. var iterable = Object(collection);
  9547. if (!isArrayLike(collection)) {
  9548. var iteratee = getIteratee(predicate, 3);
  9549. collection = keys(collection);
  9550. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  9551. }
  9552. var index = findIndexFunc(collection, predicate, fromIndex);
  9553. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  9554. };
  9555. }
  9556. /**
  9557. * Creates a `_.flow` or `_.flowRight` function.
  9558. *
  9559. * @private
  9560. * @param {boolean} [fromRight] Specify iterating from right to left.
  9561. * @returns {Function} Returns the new flow function.
  9562. */
  9563. function createFlow(fromRight) {
  9564. return flatRest(function(funcs) {
  9565. var length = funcs.length,
  9566. index = length,
  9567. prereq = LodashWrapper.prototype.thru;
  9568. if (fromRight) {
  9569. funcs.reverse();
  9570. }
  9571. while (index--) {
  9572. var func = funcs[index];
  9573. if (typeof func != 'function') {
  9574. throw new TypeError(FUNC_ERROR_TEXT);
  9575. }
  9576. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  9577. var wrapper = new LodashWrapper([], true);
  9578. }
  9579. }
  9580. index = wrapper ? index : length;
  9581. while (++index < length) {
  9582. func = funcs[index];
  9583. var funcName = getFuncName(func),
  9584. data = funcName == 'wrapper' ? getData(func) : undefined;
  9585. if (data && isLaziable(data[0]) &&
  9586. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  9587. !data[4].length && data[9] == 1
  9588. ) {
  9589. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  9590. } else {
  9591. wrapper = (func.length == 1 && isLaziable(func))
  9592. ? wrapper[funcName]()
  9593. : wrapper.thru(func);
  9594. }
  9595. }
  9596. return function() {
  9597. var args = arguments,
  9598. value = args[0];
  9599. if (wrapper && args.length == 1 && isArray(value)) {
  9600. return wrapper.plant(value).value();
  9601. }
  9602. var index = 0,
  9603. result = length ? funcs[index].apply(this, args) : value;
  9604. while (++index < length) {
  9605. result = funcs[index].call(this, result);
  9606. }
  9607. return result;
  9608. };
  9609. });
  9610. }
  9611. /**
  9612. * Creates a function that wraps `func` to invoke it with optional `this`
  9613. * binding of `thisArg`, partial application, and currying.
  9614. *
  9615. * @private
  9616. * @param {Function|string} func The function or method name to wrap.
  9617. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  9618. * @param {*} [thisArg] The `this` binding of `func`.
  9619. * @param {Array} [partials] The arguments to prepend to those provided to
  9620. * the new function.
  9621. * @param {Array} [holders] The `partials` placeholder indexes.
  9622. * @param {Array} [partialsRight] The arguments to append to those provided
  9623. * to the new function.
  9624. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  9625. * @param {Array} [argPos] The argument positions of the new function.
  9626. * @param {number} [ary] The arity cap of `func`.
  9627. * @param {number} [arity] The arity of `func`.
  9628. * @returns {Function} Returns the new wrapped function.
  9629. */
  9630. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  9631. var isAry = bitmask & WRAP_ARY_FLAG,
  9632. isBind = bitmask & WRAP_BIND_FLAG,
  9633. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  9634. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  9635. isFlip = bitmask & WRAP_FLIP_FLAG,
  9636. Ctor = isBindKey ? undefined : createCtor(func);
  9637. function wrapper() {
  9638. var length = arguments.length,
  9639. args = Array(length),
  9640. index = length;
  9641. while (index--) {
  9642. args[index] = arguments[index];
  9643. }
  9644. if (isCurried) {
  9645. var placeholder = getHolder(wrapper),
  9646. holdersCount = countHolders(args, placeholder);
  9647. }
  9648. if (partials) {
  9649. args = composeArgs(args, partials, holders, isCurried);
  9650. }
  9651. if (partialsRight) {
  9652. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  9653. }
  9654. length -= holdersCount;
  9655. if (isCurried && length < arity) {
  9656. var newHolders = replaceHolders(args, placeholder);
  9657. return createRecurry(
  9658. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  9659. args, newHolders, argPos, ary, arity - length
  9660. );
  9661. }
  9662. var thisBinding = isBind ? thisArg : this,
  9663. fn = isBindKey ? thisBinding[func] : func;
  9664. length = args.length;
  9665. if (argPos) {
  9666. args = reorder(args, argPos);
  9667. } else if (isFlip && length > 1) {
  9668. args.reverse();
  9669. }
  9670. if (isAry && ary < length) {
  9671. args.length = ary;
  9672. }
  9673. if (this && this !== root && this instanceof wrapper) {
  9674. fn = Ctor || createCtor(fn);
  9675. }
  9676. return fn.apply(thisBinding, args);
  9677. }
  9678. return wrapper;
  9679. }
  9680. /**
  9681. * Creates a function like `_.invertBy`.
  9682. *
  9683. * @private
  9684. * @param {Function} setter The function to set accumulator values.
  9685. * @param {Function} toIteratee The function to resolve iteratees.
  9686. * @returns {Function} Returns the new inverter function.
  9687. */
  9688. function createInverter(setter, toIteratee) {
  9689. return function(object, iteratee) {
  9690. return baseInverter(object, setter, toIteratee(iteratee), {});
  9691. };
  9692. }
  9693. /**
  9694. * Creates a function that performs a mathematical operation on two values.
  9695. *
  9696. * @private
  9697. * @param {Function} operator The function to perform the operation.
  9698. * @param {number} [defaultValue] The value used for `undefined` arguments.
  9699. * @returns {Function} Returns the new mathematical operation function.
  9700. */
  9701. function createMathOperation(operator, defaultValue) {
  9702. return function(value, other) {
  9703. var result;
  9704. if (value === undefined && other === undefined) {
  9705. return defaultValue;
  9706. }
  9707. if (value !== undefined) {
  9708. result = value;
  9709. }
  9710. if (other !== undefined) {
  9711. if (result === undefined) {
  9712. return other;
  9713. }
  9714. if (typeof value == 'string' || typeof other == 'string') {
  9715. value = baseToString(value);
  9716. other = baseToString(other);
  9717. } else {
  9718. value = baseToNumber(value);
  9719. other = baseToNumber(other);
  9720. }
  9721. result = operator(value, other);
  9722. }
  9723. return result;
  9724. };
  9725. }
  9726. /**
  9727. * Creates a function like `_.over`.
  9728. *
  9729. * @private
  9730. * @param {Function} arrayFunc The function to iterate over iteratees.
  9731. * @returns {Function} Returns the new over function.
  9732. */
  9733. function createOver(arrayFunc) {
  9734. return flatRest(function(iteratees) {
  9735. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  9736. return baseRest(function(args) {
  9737. var thisArg = this;
  9738. return arrayFunc(iteratees, function(iteratee) {
  9739. return apply(iteratee, thisArg, args);
  9740. });
  9741. });
  9742. });
  9743. }
  9744. /**
  9745. * Creates the padding for `string` based on `length`. The `chars` string
  9746. * is truncated if the number of characters exceeds `length`.
  9747. *
  9748. * @private
  9749. * @param {number} length The padding length.
  9750. * @param {string} [chars=' '] The string used as padding.
  9751. * @returns {string} Returns the padding for `string`.
  9752. */
  9753. function createPadding(length, chars) {
  9754. chars = chars === undefined ? ' ' : baseToString(chars);
  9755. var charsLength = chars.length;
  9756. if (charsLength < 2) {
  9757. return charsLength ? baseRepeat(chars, length) : chars;
  9758. }
  9759. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  9760. return hasUnicode(chars)
  9761. ? castSlice(stringToArray(result), 0, length).join('')
  9762. : result.slice(0, length);
  9763. }
  9764. /**
  9765. * Creates a function that wraps `func` to invoke it with the `this` binding
  9766. * of `thisArg` and `partials` prepended to the arguments it receives.
  9767. *
  9768. * @private
  9769. * @param {Function} func The function to wrap.
  9770. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  9771. * @param {*} thisArg The `this` binding of `func`.
  9772. * @param {Array} partials The arguments to prepend to those provided to
  9773. * the new function.
  9774. * @returns {Function} Returns the new wrapped function.
  9775. */
  9776. function createPartial(func, bitmask, thisArg, partials) {
  9777. var isBind = bitmask & WRAP_BIND_FLAG,
  9778. Ctor = createCtor(func);
  9779. function wrapper() {
  9780. var argsIndex = -1,
  9781. argsLength = arguments.length,
  9782. leftIndex = -1,
  9783. leftLength = partials.length,
  9784. args = Array(leftLength + argsLength),
  9785. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  9786. while (++leftIndex < leftLength) {
  9787. args[leftIndex] = partials[leftIndex];
  9788. }
  9789. while (argsLength--) {
  9790. args[leftIndex++] = arguments[++argsIndex];
  9791. }
  9792. return apply(fn, isBind ? thisArg : this, args);
  9793. }
  9794. return wrapper;
  9795. }
  9796. /**
  9797. * Creates a `_.range` or `_.rangeRight` function.
  9798. *
  9799. * @private
  9800. * @param {boolean} [fromRight] Specify iterating from right to left.
  9801. * @returns {Function} Returns the new range function.
  9802. */
  9803. function createRange(fromRight) {
  9804. return function(start, end, step) {
  9805. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  9806. end = step = undefined;
  9807. }
  9808. // Ensure the sign of `-0` is preserved.
  9809. start = toFinite(start);
  9810. if (end === undefined) {
  9811. end = start;
  9812. start = 0;
  9813. } else {
  9814. end = toFinite(end);
  9815. }
  9816. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  9817. return baseRange(start, end, step, fromRight);
  9818. };
  9819. }
  9820. /**
  9821. * Creates a function that performs a relational operation on two values.
  9822. *
  9823. * @private
  9824. * @param {Function} operator The function to perform the operation.
  9825. * @returns {Function} Returns the new relational operation function.
  9826. */
  9827. function createRelationalOperation(operator) {
  9828. return function(value, other) {
  9829. if (!(typeof value == 'string' && typeof other == 'string')) {
  9830. value = toNumber(value);
  9831. other = toNumber(other);
  9832. }
  9833. return operator(value, other);
  9834. };
  9835. }
  9836. /**
  9837. * Creates a function that wraps `func` to continue currying.
  9838. *
  9839. * @private
  9840. * @param {Function} func The function to wrap.
  9841. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  9842. * @param {Function} wrapFunc The function to create the `func` wrapper.
  9843. * @param {*} placeholder The placeholder value.
  9844. * @param {*} [thisArg] The `this` binding of `func`.
  9845. * @param {Array} [partials] The arguments to prepend to those provided to
  9846. * the new function.
  9847. * @param {Array} [holders] The `partials` placeholder indexes.
  9848. * @param {Array} [argPos] The argument positions of the new function.
  9849. * @param {number} [ary] The arity cap of `func`.
  9850. * @param {number} [arity] The arity of `func`.
  9851. * @returns {Function} Returns the new wrapped function.
  9852. */
  9853. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  9854. var isCurry = bitmask & WRAP_CURRY_FLAG,
  9855. newHolders = isCurry ? holders : undefined,
  9856. newHoldersRight = isCurry ? undefined : holders,
  9857. newPartials = isCurry ? partials : undefined,
  9858. newPartialsRight = isCurry ? undefined : partials;
  9859. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  9860. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  9861. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  9862. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  9863. }
  9864. var newData = [
  9865. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  9866. newHoldersRight, argPos, ary, arity
  9867. ];
  9868. var result = wrapFunc.apply(undefined, newData);
  9869. if (isLaziable(func)) {
  9870. setData(result, newData);
  9871. }
  9872. result.placeholder = placeholder;
  9873. return setWrapToString(result, func, bitmask);
  9874. }
  9875. /**
  9876. * Creates a function like `_.round`.
  9877. *
  9878. * @private
  9879. * @param {string} methodName The name of the `Math` method to use when rounding.
  9880. * @returns {Function} Returns the new round function.
  9881. */
  9882. function createRound(methodName) {
  9883. var func = Math[methodName];
  9884. return function(number, precision) {
  9885. number = toNumber(number);
  9886. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  9887. if (precision && nativeIsFinite(number)) {
  9888. // Shift with exponential notation to avoid floating-point issues.
  9889. // See [MDN](https://mdn.io/round#Examples) for more details.
  9890. var pair = (toString(number) + 'e').split('e'),
  9891. value = func(pair[0] + 'e' + (+pair[1] + precision));
  9892. pair = (toString(value) + 'e').split('e');
  9893. return +(pair[0] + 'e' + (+pair[1] - precision));
  9894. }
  9895. return func(number);
  9896. };
  9897. }
  9898. /**
  9899. * Creates a set object of `values`.
  9900. *
  9901. * @private
  9902. * @param {Array} values The values to add to the set.
  9903. * @returns {Object} Returns the new set.
  9904. */
  9905. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  9906. return new Set(values);
  9907. };
  9908. /**
  9909. * Creates a `_.toPairs` or `_.toPairsIn` function.
  9910. *
  9911. * @private
  9912. * @param {Function} keysFunc The function to get the keys of a given object.
  9913. * @returns {Function} Returns the new pairs function.
  9914. */
  9915. function createToPairs(keysFunc) {
  9916. return function(object) {
  9917. var tag = getTag(object);
  9918. if (tag == mapTag) {
  9919. return mapToArray(object);
  9920. }
  9921. if (tag == setTag) {
  9922. return setToPairs(object);
  9923. }
  9924. return baseToPairs(object, keysFunc(object));
  9925. };
  9926. }
  9927. /**
  9928. * Creates a function that either curries or invokes `func` with optional
  9929. * `this` binding and partially applied arguments.
  9930. *
  9931. * @private
  9932. * @param {Function|string} func The function or method name to wrap.
  9933. * @param {number} bitmask The bitmask flags.
  9934. * 1 - `_.bind`
  9935. * 2 - `_.bindKey`
  9936. * 4 - `_.curry` or `_.curryRight` of a bound function
  9937. * 8 - `_.curry`
  9938. * 16 - `_.curryRight`
  9939. * 32 - `_.partial`
  9940. * 64 - `_.partialRight`
  9941. * 128 - `_.rearg`
  9942. * 256 - `_.ary`
  9943. * 512 - `_.flip`
  9944. * @param {*} [thisArg] The `this` binding of `func`.
  9945. * @param {Array} [partials] The arguments to be partially applied.
  9946. * @param {Array} [holders] The `partials` placeholder indexes.
  9947. * @param {Array} [argPos] The argument positions of the new function.
  9948. * @param {number} [ary] The arity cap of `func`.
  9949. * @param {number} [arity] The arity of `func`.
  9950. * @returns {Function} Returns the new wrapped function.
  9951. */
  9952. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  9953. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  9954. if (!isBindKey && typeof func != 'function') {
  9955. throw new TypeError(FUNC_ERROR_TEXT);
  9956. }
  9957. var length = partials ? partials.length : 0;
  9958. if (!length) {
  9959. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  9960. partials = holders = undefined;
  9961. }
  9962. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  9963. arity = arity === undefined ? arity : toInteger(arity);
  9964. length -= holders ? holders.length : 0;
  9965. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  9966. var partialsRight = partials,
  9967. holdersRight = holders;
  9968. partials = holders = undefined;
  9969. }
  9970. var data = isBindKey ? undefined : getData(func);
  9971. var newData = [
  9972. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  9973. argPos, ary, arity
  9974. ];
  9975. if (data) {
  9976. mergeData(newData, data);
  9977. }
  9978. func = newData[0];
  9979. bitmask = newData[1];
  9980. thisArg = newData[2];
  9981. partials = newData[3];
  9982. holders = newData[4];
  9983. arity = newData[9] = newData[9] === undefined
  9984. ? (isBindKey ? 0 : func.length)
  9985. : nativeMax(newData[9] - length, 0);
  9986. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  9987. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  9988. }
  9989. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  9990. var result = createBind(func, bitmask, thisArg);
  9991. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  9992. result = createCurry(func, bitmask, arity);
  9993. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  9994. result = createPartial(func, bitmask, thisArg, partials);
  9995. } else {
  9996. result = createHybrid.apply(undefined, newData);
  9997. }
  9998. var setter = data ? baseSetData : setData;
  9999. return setWrapToString(setter(result, newData), func, bitmask);
  10000. }
  10001. /**
  10002. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  10003. * of source objects to the destination object for all destination properties
  10004. * that resolve to `undefined`.
  10005. *
  10006. * @private
  10007. * @param {*} objValue The destination value.
  10008. * @param {*} srcValue The source value.
  10009. * @param {string} key The key of the property to assign.
  10010. * @param {Object} object The parent object of `objValue`.
  10011. * @returns {*} Returns the value to assign.
  10012. */
  10013. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  10014. if (objValue === undefined ||
  10015. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  10016. return srcValue;
  10017. }
  10018. return objValue;
  10019. }
  10020. /**
  10021. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  10022. * objects into destination objects that are passed thru.
  10023. *
  10024. * @private
  10025. * @param {*} objValue The destination value.
  10026. * @param {*} srcValue The source value.
  10027. * @param {string} key The key of the property to merge.
  10028. * @param {Object} object The parent object of `objValue`.
  10029. * @param {Object} source The parent object of `srcValue`.
  10030. * @param {Object} [stack] Tracks traversed source values and their merged
  10031. * counterparts.
  10032. * @returns {*} Returns the value to assign.
  10033. */
  10034. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  10035. if (isObject(objValue) && isObject(srcValue)) {
  10036. // Recursively merge objects and arrays (susceptible to call stack limits).
  10037. stack.set(srcValue, objValue);
  10038. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  10039. stack['delete'](srcValue);
  10040. }
  10041. return objValue;
  10042. }
  10043. /**
  10044. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  10045. * objects.
  10046. *
  10047. * @private
  10048. * @param {*} value The value to inspect.
  10049. * @param {string} key The key of the property to inspect.
  10050. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  10051. */
  10052. function customOmitClone(value) {
  10053. return isPlainObject(value) ? undefined : value;
  10054. }
  10055. /**
  10056. * A specialized version of `baseIsEqualDeep` for arrays with support for
  10057. * partial deep comparisons.
  10058. *
  10059. * @private
  10060. * @param {Array} array The array to compare.
  10061. * @param {Array} other The other array to compare.
  10062. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  10063. * @param {Function} customizer The function to customize comparisons.
  10064. * @param {Function} equalFunc The function to determine equivalents of values.
  10065. * @param {Object} stack Tracks traversed `array` and `other` objects.
  10066. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  10067. */
  10068. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  10069. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  10070. arrLength = array.length,
  10071. othLength = other.length;
  10072. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  10073. return false;
  10074. }
  10075. // Check that cyclic values are equal.
  10076. var arrStacked = stack.get(array);
  10077. var othStacked = stack.get(other);
  10078. if (arrStacked && othStacked) {
  10079. return arrStacked == other && othStacked == array;
  10080. }
  10081. var index = -1,
  10082. result = true,
  10083. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  10084. stack.set(array, other);
  10085. stack.set(other, array);
  10086. // Ignore non-index properties.
  10087. while (++index < arrLength) {
  10088. var arrValue = array[index],
  10089. othValue = other[index];
  10090. if (customizer) {
  10091. var compared = isPartial
  10092. ? customizer(othValue, arrValue, index, other, array, stack)
  10093. : customizer(arrValue, othValue, index, array, other, stack);
  10094. }
  10095. if (compared !== undefined) {
  10096. if (compared) {
  10097. continue;
  10098. }
  10099. result = false;
  10100. break;
  10101. }
  10102. // Recursively compare arrays (susceptible to call stack limits).
  10103. if (seen) {
  10104. if (!arraySome(other, function(othValue, othIndex) {
  10105. if (!cacheHas(seen, othIndex) &&
  10106. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  10107. return seen.push(othIndex);
  10108. }
  10109. })) {
  10110. result = false;
  10111. break;
  10112. }
  10113. } else if (!(
  10114. arrValue === othValue ||
  10115. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  10116. )) {
  10117. result = false;
  10118. break;
  10119. }
  10120. }
  10121. stack['delete'](array);
  10122. stack['delete'](other);
  10123. return result;
  10124. }
  10125. /**
  10126. * A specialized version of `baseIsEqualDeep` for comparing objects of
  10127. * the same `toStringTag`.
  10128. *
  10129. * **Note:** This function only supports comparing values with tags of
  10130. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  10131. *
  10132. * @private
  10133. * @param {Object} object The object to compare.
  10134. * @param {Object} other The other object to compare.
  10135. * @param {string} tag The `toStringTag` of the objects to compare.
  10136. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  10137. * @param {Function} customizer The function to customize comparisons.
  10138. * @param {Function} equalFunc The function to determine equivalents of values.
  10139. * @param {Object} stack Tracks traversed `object` and `other` objects.
  10140. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  10141. */
  10142. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  10143. switch (tag) {
  10144. case dataViewTag:
  10145. if ((object.byteLength != other.byteLength) ||
  10146. (object.byteOffset != other.byteOffset)) {
  10147. return false;
  10148. }
  10149. object = object.buffer;
  10150. other = other.buffer;
  10151. case arrayBufferTag:
  10152. if ((object.byteLength != other.byteLength) ||
  10153. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  10154. return false;
  10155. }
  10156. return true;
  10157. case boolTag:
  10158. case dateTag:
  10159. case numberTag:
  10160. // Coerce booleans to `1` or `0` and dates to milliseconds.
  10161. // Invalid dates are coerced to `NaN`.
  10162. return eq(+object, +other);
  10163. case errorTag:
  10164. return object.name == other.name && object.message == other.message;
  10165. case regexpTag:
  10166. case stringTag:
  10167. // Coerce regexes to strings and treat strings, primitives and objects,
  10168. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  10169. // for more details.
  10170. return object == (other + '');
  10171. case mapTag:
  10172. var convert = mapToArray;
  10173. case setTag:
  10174. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  10175. convert || (convert = setToArray);
  10176. if (object.size != other.size && !isPartial) {
  10177. return false;
  10178. }
  10179. // Assume cyclic values are equal.
  10180. var stacked = stack.get(object);
  10181. if (stacked) {
  10182. return stacked == other;
  10183. }
  10184. bitmask |= COMPARE_UNORDERED_FLAG;
  10185. // Recursively compare objects (susceptible to call stack limits).
  10186. stack.set(object, other);
  10187. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  10188. stack['delete'](object);
  10189. return result;
  10190. case symbolTag:
  10191. if (symbolValueOf) {
  10192. return symbolValueOf.call(object) == symbolValueOf.call(other);
  10193. }
  10194. }
  10195. return false;
  10196. }
  10197. /**
  10198. * A specialized version of `baseIsEqualDeep` for objects with support for
  10199. * partial deep comparisons.
  10200. *
  10201. * @private
  10202. * @param {Object} object The object to compare.
  10203. * @param {Object} other The other object to compare.
  10204. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  10205. * @param {Function} customizer The function to customize comparisons.
  10206. * @param {Function} equalFunc The function to determine equivalents of values.
  10207. * @param {Object} stack Tracks traversed `object` and `other` objects.
  10208. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  10209. */
  10210. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  10211. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  10212. objProps = getAllKeys(object),
  10213. objLength = objProps.length,
  10214. othProps = getAllKeys(other),
  10215. othLength = othProps.length;
  10216. if (objLength != othLength && !isPartial) {
  10217. return false;
  10218. }
  10219. var index = objLength;
  10220. while (index--) {
  10221. var key = objProps[index];
  10222. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  10223. return false;
  10224. }
  10225. }
  10226. // Check that cyclic values are equal.
  10227. var objStacked = stack.get(object);
  10228. var othStacked = stack.get(other);
  10229. if (objStacked && othStacked) {
  10230. return objStacked == other && othStacked == object;
  10231. }
  10232. var result = true;
  10233. stack.set(object, other);
  10234. stack.set(other, object);
  10235. var skipCtor = isPartial;
  10236. while (++index < objLength) {
  10237. key = objProps[index];
  10238. var objValue = object[key],
  10239. othValue = other[key];
  10240. if (customizer) {
  10241. var compared = isPartial
  10242. ? customizer(othValue, objValue, key, other, object, stack)
  10243. : customizer(objValue, othValue, key, object, other, stack);
  10244. }
  10245. // Recursively compare objects (susceptible to call stack limits).
  10246. if (!(compared === undefined
  10247. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  10248. : compared
  10249. )) {
  10250. result = false;
  10251. break;
  10252. }
  10253. skipCtor || (skipCtor = key == 'constructor');
  10254. }
  10255. if (result && !skipCtor) {
  10256. var objCtor = object.constructor,
  10257. othCtor = other.constructor;
  10258. // Non `Object` object instances with different constructors are not equal.
  10259. if (objCtor != othCtor &&
  10260. ('constructor' in object && 'constructor' in other) &&
  10261. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  10262. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  10263. result = false;
  10264. }
  10265. }
  10266. stack['delete'](object);
  10267. stack['delete'](other);
  10268. return result;
  10269. }
  10270. /**
  10271. * A specialized version of `baseRest` which flattens the rest array.
  10272. *
  10273. * @private
  10274. * @param {Function} func The function to apply a rest parameter to.
  10275. * @returns {Function} Returns the new function.
  10276. */
  10277. function flatRest(func) {
  10278. return setToString(overRest(func, undefined, flatten), func + '');
  10279. }
  10280. /**
  10281. * Creates an array of own enumerable property names and symbols of `object`.
  10282. *
  10283. * @private
  10284. * @param {Object} object The object to query.
  10285. * @returns {Array} Returns the array of property names and symbols.
  10286. */
  10287. function getAllKeys(object) {
  10288. return baseGetAllKeys(object, keys, getSymbols);
  10289. }
  10290. /**
  10291. * Creates an array of own and inherited enumerable property names and
  10292. * symbols of `object`.
  10293. *
  10294. * @private
  10295. * @param {Object} object The object to query.
  10296. * @returns {Array} Returns the array of property names and symbols.
  10297. */
  10298. function getAllKeysIn(object) {
  10299. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  10300. }
  10301. /**
  10302. * Gets metadata for `func`.
  10303. *
  10304. * @private
  10305. * @param {Function} func The function to query.
  10306. * @returns {*} Returns the metadata for `func`.
  10307. */
  10308. var getData = !metaMap ? noop : function(func) {
  10309. return metaMap.get(func);
  10310. };
  10311. /**
  10312. * Gets the name of `func`.
  10313. *
  10314. * @private
  10315. * @param {Function} func The function to query.
  10316. * @returns {string} Returns the function name.
  10317. */
  10318. function getFuncName(func) {
  10319. var result = (func.name + ''),
  10320. array = realNames[result],
  10321. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  10322. while (length--) {
  10323. var data = array[length],
  10324. otherFunc = data.func;
  10325. if (otherFunc == null || otherFunc == func) {
  10326. return data.name;
  10327. }
  10328. }
  10329. return result;
  10330. }
  10331. /**
  10332. * Gets the argument placeholder value for `func`.
  10333. *
  10334. * @private
  10335. * @param {Function} func The function to inspect.
  10336. * @returns {*} Returns the placeholder value.
  10337. */
  10338. function getHolder(func) {
  10339. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  10340. return object.placeholder;
  10341. }
  10342. /**
  10343. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  10344. * this function returns the custom method, otherwise it returns `baseIteratee`.
  10345. * If arguments are provided, the chosen function is invoked with them and
  10346. * its result is returned.
  10347. *
  10348. * @private
  10349. * @param {*} [value] The value to convert to an iteratee.
  10350. * @param {number} [arity] The arity of the created iteratee.
  10351. * @returns {Function} Returns the chosen function or its result.
  10352. */
  10353. function getIteratee() {
  10354. var result = lodash.iteratee || iteratee;
  10355. result = result === iteratee ? baseIteratee : result;
  10356. return arguments.length ? result(arguments[0], arguments[1]) : result;
  10357. }
  10358. /**
  10359. * Gets the data for `map`.
  10360. *
  10361. * @private
  10362. * @param {Object} map The map to query.
  10363. * @param {string} key The reference key.
  10364. * @returns {*} Returns the map data.
  10365. */
  10366. function getMapData(map, key) {
  10367. var data = map.__data__;
  10368. return isKeyable(key)
  10369. ? data[typeof key == 'string' ? 'string' : 'hash']
  10370. : data.map;
  10371. }
  10372. /**
  10373. * Gets the property names, values, and compare flags of `object`.
  10374. *
  10375. * @private
  10376. * @param {Object} object The object to query.
  10377. * @returns {Array} Returns the match data of `object`.
  10378. */
  10379. function getMatchData(object) {
  10380. var result = keys(object),
  10381. length = result.length;
  10382. while (length--) {
  10383. var key = result[length],
  10384. value = object[key];
  10385. result[length] = [key, value, isStrictComparable(value)];
  10386. }
  10387. return result;
  10388. }
  10389. /**
  10390. * Gets the native function at `key` of `object`.
  10391. *
  10392. * @private
  10393. * @param {Object} object The object to query.
  10394. * @param {string} key The key of the method to get.
  10395. * @returns {*} Returns the function if it's native, else `undefined`.
  10396. */
  10397. function getNative(object, key) {
  10398. var value = getValue(object, key);
  10399. return baseIsNative(value) ? value : undefined;
  10400. }
  10401. /**
  10402. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  10403. *
  10404. * @private
  10405. * @param {*} value The value to query.
  10406. * @returns {string} Returns the raw `toStringTag`.
  10407. */
  10408. function getRawTag(value) {
  10409. var isOwn = hasOwnProperty.call(value, symToStringTag),
  10410. tag = value[symToStringTag];
  10411. try {
  10412. value[symToStringTag] = undefined;
  10413. var unmasked = true;
  10414. } catch (e) {}
  10415. var result = nativeObjectToString.call(value);
  10416. if (unmasked) {
  10417. if (isOwn) {
  10418. value[symToStringTag] = tag;
  10419. } else {
  10420. delete value[symToStringTag];
  10421. }
  10422. }
  10423. return result;
  10424. }
  10425. /**
  10426. * Creates an array of the own enumerable symbols of `object`.
  10427. *
  10428. * @private
  10429. * @param {Object} object The object to query.
  10430. * @returns {Array} Returns the array of symbols.
  10431. */
  10432. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  10433. if (object == null) {
  10434. return [];
  10435. }
  10436. object = Object(object);
  10437. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  10438. return propertyIsEnumerable.call(object, symbol);
  10439. });
  10440. };
  10441. /**
  10442. * Creates an array of the own and inherited enumerable symbols of `object`.
  10443. *
  10444. * @private
  10445. * @param {Object} object The object to query.
  10446. * @returns {Array} Returns the array of symbols.
  10447. */
  10448. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  10449. var result = [];
  10450. while (object) {
  10451. arrayPush(result, getSymbols(object));
  10452. object = getPrototype(object);
  10453. }
  10454. return result;
  10455. };
  10456. /**
  10457. * Gets the `toStringTag` of `value`.
  10458. *
  10459. * @private
  10460. * @param {*} value The value to query.
  10461. * @returns {string} Returns the `toStringTag`.
  10462. */
  10463. var getTag = baseGetTag;
  10464. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  10465. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  10466. (Map && getTag(new Map) != mapTag) ||
  10467. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  10468. (Set && getTag(new Set) != setTag) ||
  10469. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  10470. getTag = function(value) {
  10471. var result = baseGetTag(value),
  10472. Ctor = result == objectTag ? value.constructor : undefined,
  10473. ctorString = Ctor ? toSource(Ctor) : '';
  10474. if (ctorString) {
  10475. switch (ctorString) {
  10476. case dataViewCtorString: return dataViewTag;
  10477. case mapCtorString: return mapTag;
  10478. case promiseCtorString: return promiseTag;
  10479. case setCtorString: return setTag;
  10480. case weakMapCtorString: return weakMapTag;
  10481. }
  10482. }
  10483. return result;
  10484. };
  10485. }
  10486. /**
  10487. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  10488. *
  10489. * @private
  10490. * @param {number} start The start of the view.
  10491. * @param {number} end The end of the view.
  10492. * @param {Array} transforms The transformations to apply to the view.
  10493. * @returns {Object} Returns an object containing the `start` and `end`
  10494. * positions of the view.
  10495. */
  10496. function getView(start, end, transforms) {
  10497. var index = -1,
  10498. length = transforms.length;
  10499. while (++index < length) {
  10500. var data = transforms[index],
  10501. size = data.size;
  10502. switch (data.type) {
  10503. case 'drop': start += size; break;
  10504. case 'dropRight': end -= size; break;
  10505. case 'take': end = nativeMin(end, start + size); break;
  10506. case 'takeRight': start = nativeMax(start, end - size); break;
  10507. }
  10508. }
  10509. return { 'start': start, 'end': end };
  10510. }
  10511. /**
  10512. * Extracts wrapper details from the `source` body comment.
  10513. *
  10514. * @private
  10515. * @param {string} source The source to inspect.
  10516. * @returns {Array} Returns the wrapper details.
  10517. */
  10518. function getWrapDetails(source) {
  10519. var match = source.match(reWrapDetails);
  10520. return match ? match[1].split(reSplitDetails) : [];
  10521. }
  10522. /**
  10523. * Checks if `path` exists on `object`.
  10524. *
  10525. * @private
  10526. * @param {Object} object The object to query.
  10527. * @param {Array|string} path The path to check.
  10528. * @param {Function} hasFunc The function to check properties.
  10529. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  10530. */
  10531. function hasPath(object, path, hasFunc) {
  10532. path = castPath(path, object);
  10533. var index = -1,
  10534. length = path.length,
  10535. result = false;
  10536. while (++index < length) {
  10537. var key = toKey(path[index]);
  10538. if (!(result = object != null && hasFunc(object, key))) {
  10539. break;
  10540. }
  10541. object = object[key];
  10542. }
  10543. if (result || ++index != length) {
  10544. return result;
  10545. }
  10546. length = object == null ? 0 : object.length;
  10547. return !!length && isLength(length) && isIndex(key, length) &&
  10548. (isArray(object) || isArguments(object));
  10549. }
  10550. /**
  10551. * Initializes an array clone.
  10552. *
  10553. * @private
  10554. * @param {Array} array The array to clone.
  10555. * @returns {Array} Returns the initialized clone.
  10556. */
  10557. function initCloneArray(array) {
  10558. var length = array.length,
  10559. result = new array.constructor(length);
  10560. // Add properties assigned by `RegExp#exec`.
  10561. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  10562. result.index = array.index;
  10563. result.input = array.input;
  10564. }
  10565. return result;
  10566. }
  10567. /**
  10568. * Initializes an object clone.
  10569. *
  10570. * @private
  10571. * @param {Object} object The object to clone.
  10572. * @returns {Object} Returns the initialized clone.
  10573. */
  10574. function initCloneObject(object) {
  10575. return (typeof object.constructor == 'function' && !isPrototype(object))
  10576. ? baseCreate(getPrototype(object))
  10577. : {};
  10578. }
  10579. /**
  10580. * Initializes an object clone based on its `toStringTag`.
  10581. *
  10582. * **Note:** This function only supports cloning values with tags of
  10583. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  10584. *
  10585. * @private
  10586. * @param {Object} object The object to clone.
  10587. * @param {string} tag The `toStringTag` of the object to clone.
  10588. * @param {boolean} [isDeep] Specify a deep clone.
  10589. * @returns {Object} Returns the initialized clone.
  10590. */
  10591. function initCloneByTag(object, tag, isDeep) {
  10592. var Ctor = object.constructor;
  10593. switch (tag) {
  10594. case arrayBufferTag:
  10595. return cloneArrayBuffer(object);
  10596. case boolTag:
  10597. case dateTag:
  10598. return new Ctor(+object);
  10599. case dataViewTag:
  10600. return cloneDataView(object, isDeep);
  10601. case float32Tag: case float64Tag:
  10602. case int8Tag: case int16Tag: case int32Tag:
  10603. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  10604. return cloneTypedArray(object, isDeep);
  10605. case mapTag:
  10606. return new Ctor;
  10607. case numberTag:
  10608. case stringTag:
  10609. return new Ctor(object);
  10610. case regexpTag:
  10611. return cloneRegExp(object);
  10612. case setTag:
  10613. return new Ctor;
  10614. case symbolTag:
  10615. return cloneSymbol(object);
  10616. }
  10617. }
  10618. /**
  10619. * Inserts wrapper `details` in a comment at the top of the `source` body.
  10620. *
  10621. * @private
  10622. * @param {string} source The source to modify.
  10623. * @returns {Array} details The details to insert.
  10624. * @returns {string} Returns the modified source.
  10625. */
  10626. function insertWrapDetails(source, details) {
  10627. var length = details.length;
  10628. if (!length) {
  10629. return source;
  10630. }
  10631. var lastIndex = length - 1;
  10632. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  10633. details = details.join(length > 2 ? ', ' : ' ');
  10634. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  10635. }
  10636. /**
  10637. * Checks if `value` is a flattenable `arguments` object or array.
  10638. *
  10639. * @private
  10640. * @param {*} value The value to check.
  10641. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  10642. */
  10643. function isFlattenable(value) {
  10644. return isArray(value) || isArguments(value) ||
  10645. !!(spreadableSymbol && value && value[spreadableSymbol]);
  10646. }
  10647. /**
  10648. * Checks if `value` is a valid array-like index.
  10649. *
  10650. * @private
  10651. * @param {*} value The value to check.
  10652. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  10653. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  10654. */
  10655. function isIndex(value, length) {
  10656. var type = typeof value;
  10657. length = length == null ? MAX_SAFE_INTEGER : length;
  10658. return !!length &&
  10659. (type == 'number' ||
  10660. (type != 'symbol' && reIsUint.test(value))) &&
  10661. (value > -1 && value % 1 == 0 && value < length);
  10662. }
  10663. /**
  10664. * Checks if the given arguments are from an iteratee call.
  10665. *
  10666. * @private
  10667. * @param {*} value The potential iteratee value argument.
  10668. * @param {*} index The potential iteratee index or key argument.
  10669. * @param {*} object The potential iteratee object argument.
  10670. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  10671. * else `false`.
  10672. */
  10673. function isIterateeCall(value, index, object) {
  10674. if (!isObject(object)) {
  10675. return false;
  10676. }
  10677. var type = typeof index;
  10678. if (type == 'number'
  10679. ? (isArrayLike(object) && isIndex(index, object.length))
  10680. : (type == 'string' && index in object)
  10681. ) {
  10682. return eq(object[index], value);
  10683. }
  10684. return false;
  10685. }
  10686. /**
  10687. * Checks if `value` is a property name and not a property path.
  10688. *
  10689. * @private
  10690. * @param {*} value The value to check.
  10691. * @param {Object} [object] The object to query keys on.
  10692. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  10693. */
  10694. function isKey(value, object) {
  10695. if (isArray(value)) {
  10696. return false;
  10697. }
  10698. var type = typeof value;
  10699. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  10700. value == null || isSymbol(value)) {
  10701. return true;
  10702. }
  10703. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  10704. (object != null && value in Object(object));
  10705. }
  10706. /**
  10707. * Checks if `value` is suitable for use as unique object key.
  10708. *
  10709. * @private
  10710. * @param {*} value The value to check.
  10711. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  10712. */
  10713. function isKeyable(value) {
  10714. var type = typeof value;
  10715. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  10716. ? (value !== '__proto__')
  10717. : (value === null);
  10718. }
  10719. /**
  10720. * Checks if `func` has a lazy counterpart.
  10721. *
  10722. * @private
  10723. * @param {Function} func The function to check.
  10724. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  10725. * else `false`.
  10726. */
  10727. function isLaziable(func) {
  10728. var funcName = getFuncName(func),
  10729. other = lodash[funcName];
  10730. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  10731. return false;
  10732. }
  10733. if (func === other) {
  10734. return true;
  10735. }
  10736. var data = getData(other);
  10737. return !!data && func === data[0];
  10738. }
  10739. /**
  10740. * Checks if `func` has its source masked.
  10741. *
  10742. * @private
  10743. * @param {Function} func The function to check.
  10744. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  10745. */
  10746. function isMasked(func) {
  10747. return !!maskSrcKey && (maskSrcKey in func);
  10748. }
  10749. /**
  10750. * Checks if `func` is capable of being masked.
  10751. *
  10752. * @private
  10753. * @param {*} value The value to check.
  10754. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  10755. */
  10756. var isMaskable = coreJsData ? isFunction : stubFalse;
  10757. /**
  10758. * Checks if `value` is likely a prototype object.
  10759. *
  10760. * @private
  10761. * @param {*} value The value to check.
  10762. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  10763. */
  10764. function isPrototype(value) {
  10765. var Ctor = value && value.constructor,
  10766. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  10767. return value === proto;
  10768. }
  10769. /**
  10770. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  10771. *
  10772. * @private
  10773. * @param {*} value The value to check.
  10774. * @returns {boolean} Returns `true` if `value` if suitable for strict
  10775. * equality comparisons, else `false`.
  10776. */
  10777. function isStrictComparable(value) {
  10778. return value === value && !isObject(value);
  10779. }
  10780. /**
  10781. * A specialized version of `matchesProperty` for source values suitable
  10782. * for strict equality comparisons, i.e. `===`.
  10783. *
  10784. * @private
  10785. * @param {string} key The key of the property to get.
  10786. * @param {*} srcValue The value to match.
  10787. * @returns {Function} Returns the new spec function.
  10788. */
  10789. function matchesStrictComparable(key, srcValue) {
  10790. return function(object) {
  10791. if (object == null) {
  10792. return false;
  10793. }
  10794. return object[key] === srcValue &&
  10795. (srcValue !== undefined || (key in Object(object)));
  10796. };
  10797. }
  10798. /**
  10799. * A specialized version of `_.memoize` which clears the memoized function's
  10800. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  10801. *
  10802. * @private
  10803. * @param {Function} func The function to have its output memoized.
  10804. * @returns {Function} Returns the new memoized function.
  10805. */
  10806. function memoizeCapped(func) {
  10807. var result = memoize(func, function(key) {
  10808. if (cache.size === MAX_MEMOIZE_SIZE) {
  10809. cache.clear();
  10810. }
  10811. return key;
  10812. });
  10813. var cache = result.cache;
  10814. return result;
  10815. }
  10816. /**
  10817. * Merges the function metadata of `source` into `data`.
  10818. *
  10819. * Merging metadata reduces the number of wrappers used to invoke a function.
  10820. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  10821. * may be applied regardless of execution order. Methods like `_.ary` and
  10822. * `_.rearg` modify function arguments, making the order in which they are
  10823. * executed important, preventing the merging of metadata. However, we make
  10824. * an exception for a safe combined case where curried functions have `_.ary`
  10825. * and or `_.rearg` applied.
  10826. *
  10827. * @private
  10828. * @param {Array} data The destination metadata.
  10829. * @param {Array} source The source metadata.
  10830. * @returns {Array} Returns `data`.
  10831. */
  10832. function mergeData(data, source) {
  10833. var bitmask = data[1],
  10834. srcBitmask = source[1],
  10835. newBitmask = bitmask | srcBitmask,
  10836. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  10837. var isCombo =
  10838. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  10839. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  10840. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  10841. // Exit early if metadata can't be merged.
  10842. if (!(isCommon || isCombo)) {
  10843. return data;
  10844. }
  10845. // Use source `thisArg` if available.
  10846. if (srcBitmask & WRAP_BIND_FLAG) {
  10847. data[2] = source[2];
  10848. // Set when currying a bound function.
  10849. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  10850. }
  10851. // Compose partial arguments.
  10852. var value = source[3];
  10853. if (value) {
  10854. var partials = data[3];
  10855. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  10856. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  10857. }
  10858. // Compose partial right arguments.
  10859. value = source[5];
  10860. if (value) {
  10861. partials = data[5];
  10862. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  10863. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  10864. }
  10865. // Use source `argPos` if available.
  10866. value = source[7];
  10867. if (value) {
  10868. data[7] = value;
  10869. }
  10870. // Use source `ary` if it's smaller.
  10871. if (srcBitmask & WRAP_ARY_FLAG) {
  10872. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  10873. }
  10874. // Use source `arity` if one is not provided.
  10875. if (data[9] == null) {
  10876. data[9] = source[9];
  10877. }
  10878. // Use source `func` and merge bitmasks.
  10879. data[0] = source[0];
  10880. data[1] = newBitmask;
  10881. return data;
  10882. }
  10883. /**
  10884. * This function is like
  10885. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  10886. * except that it includes inherited enumerable properties.
  10887. *
  10888. * @private
  10889. * @param {Object} object The object to query.
  10890. * @returns {Array} Returns the array of property names.
  10891. */
  10892. function nativeKeysIn(object) {
  10893. var result = [];
  10894. if (object != null) {
  10895. for (var key in Object(object)) {
  10896. result.push(key);
  10897. }
  10898. }
  10899. return result;
  10900. }
  10901. /**
  10902. * Converts `value` to a string using `Object.prototype.toString`.
  10903. *
  10904. * @private
  10905. * @param {*} value The value to convert.
  10906. * @returns {string} Returns the converted string.
  10907. */
  10908. function objectToString(value) {
  10909. return nativeObjectToString.call(value);
  10910. }
  10911. /**
  10912. * A specialized version of `baseRest` which transforms the rest array.
  10913. *
  10914. * @private
  10915. * @param {Function} func The function to apply a rest parameter to.
  10916. * @param {number} [start=func.length-1] The start position of the rest parameter.
  10917. * @param {Function} transform The rest array transform.
  10918. * @returns {Function} Returns the new function.
  10919. */
  10920. function overRest(func, start, transform) {
  10921. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  10922. return function() {
  10923. var args = arguments,
  10924. index = -1,
  10925. length = nativeMax(args.length - start, 0),
  10926. array = Array(length);
  10927. while (++index < length) {
  10928. array[index] = args[start + index];
  10929. }
  10930. index = -1;
  10931. var otherArgs = Array(start + 1);
  10932. while (++index < start) {
  10933. otherArgs[index] = args[index];
  10934. }
  10935. otherArgs[start] = transform(array);
  10936. return apply(func, this, otherArgs);
  10937. };
  10938. }
  10939. /**
  10940. * Gets the parent value at `path` of `object`.
  10941. *
  10942. * @private
  10943. * @param {Object} object The object to query.
  10944. * @param {Array} path The path to get the parent value of.
  10945. * @returns {*} Returns the parent value.
  10946. */
  10947. function parent(object, path) {
  10948. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  10949. }
  10950. /**
  10951. * Reorder `array` according to the specified indexes where the element at
  10952. * the first index is assigned as the first element, the element at
  10953. * the second index is assigned as the second element, and so on.
  10954. *
  10955. * @private
  10956. * @param {Array} array The array to reorder.
  10957. * @param {Array} indexes The arranged array indexes.
  10958. * @returns {Array} Returns `array`.
  10959. */
  10960. function reorder(array, indexes) {
  10961. var arrLength = array.length,
  10962. length = nativeMin(indexes.length, arrLength),
  10963. oldArray = copyArray(array);
  10964. while (length--) {
  10965. var index = indexes[length];
  10966. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  10967. }
  10968. return array;
  10969. }
  10970. /**
  10971. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  10972. *
  10973. * @private
  10974. * @param {Object} object The object to query.
  10975. * @param {string} key The key of the property to get.
  10976. * @returns {*} Returns the property value.
  10977. */
  10978. function safeGet(object, key) {
  10979. if (key === 'constructor' && typeof object[key] === 'function') {
  10980. return;
  10981. }
  10982. if (key == '__proto__') {
  10983. return;
  10984. }
  10985. return object[key];
  10986. }
  10987. /**
  10988. * Sets metadata for `func`.
  10989. *
  10990. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  10991. * period of time, it will trip its breaker and transition to an identity
  10992. * function to avoid garbage collection pauses in V8. See
  10993. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  10994. * for more details.
  10995. *
  10996. * @private
  10997. * @param {Function} func The function to associate metadata with.
  10998. * @param {*} data The metadata.
  10999. * @returns {Function} Returns `func`.
  11000. */
  11001. var setData = shortOut(baseSetData);
  11002. /**
  11003. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  11004. *
  11005. * @private
  11006. * @param {Function} func The function to delay.
  11007. * @param {number} wait The number of milliseconds to delay invocation.
  11008. * @returns {number|Object} Returns the timer id or timeout object.
  11009. */
  11010. var setTimeout = ctxSetTimeout || function(func, wait) {
  11011. return root.setTimeout(func, wait);
  11012. };
  11013. /**
  11014. * Sets the `toString` method of `func` to return `string`.
  11015. *
  11016. * @private
  11017. * @param {Function} func The function to modify.
  11018. * @param {Function} string The `toString` result.
  11019. * @returns {Function} Returns `func`.
  11020. */
  11021. var setToString = shortOut(baseSetToString);
  11022. /**
  11023. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  11024. * with wrapper details in a comment at the top of the source body.
  11025. *
  11026. * @private
  11027. * @param {Function} wrapper The function to modify.
  11028. * @param {Function} reference The reference function.
  11029. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  11030. * @returns {Function} Returns `wrapper`.
  11031. */
  11032. function setWrapToString(wrapper, reference, bitmask) {
  11033. var source = (reference + '');
  11034. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  11035. }
  11036. /**
  11037. * Creates a function that'll short out and invoke `identity` instead
  11038. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  11039. * milliseconds.
  11040. *
  11041. * @private
  11042. * @param {Function} func The function to restrict.
  11043. * @returns {Function} Returns the new shortable function.
  11044. */
  11045. function shortOut(func) {
  11046. var count = 0,
  11047. lastCalled = 0;
  11048. return function() {
  11049. var stamp = nativeNow(),
  11050. remaining = HOT_SPAN - (stamp - lastCalled);
  11051. lastCalled = stamp;
  11052. if (remaining > 0) {
  11053. if (++count >= HOT_COUNT) {
  11054. return arguments[0];
  11055. }
  11056. } else {
  11057. count = 0;
  11058. }
  11059. return func.apply(undefined, arguments);
  11060. };
  11061. }
  11062. /**
  11063. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  11064. *
  11065. * @private
  11066. * @param {Array} array The array to shuffle.
  11067. * @param {number} [size=array.length] The size of `array`.
  11068. * @returns {Array} Returns `array`.
  11069. */
  11070. function shuffleSelf(array, size) {
  11071. var index = -1,
  11072. length = array.length,
  11073. lastIndex = length - 1;
  11074. size = size === undefined ? length : size;
  11075. while (++index < size) {
  11076. var rand = baseRandom(index, lastIndex),
  11077. value = array[rand];
  11078. array[rand] = array[index];
  11079. array[index] = value;
  11080. }
  11081. array.length = size;
  11082. return array;
  11083. }
  11084. /**
  11085. * Converts `string` to a property path array.
  11086. *
  11087. * @private
  11088. * @param {string} string The string to convert.
  11089. * @returns {Array} Returns the property path array.
  11090. */
  11091. var stringToPath = memoizeCapped(function(string) {
  11092. var result = [];
  11093. if (string.charCodeAt(0) === 46 /* . */) {
  11094. result.push('');
  11095. }
  11096. string.replace(rePropName, function(match, number, quote, subString) {
  11097. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  11098. });
  11099. return result;
  11100. });
  11101. /**
  11102. * Converts `value` to a string key if it's not a string or symbol.
  11103. *
  11104. * @private
  11105. * @param {*} value The value to inspect.
  11106. * @returns {string|symbol} Returns the key.
  11107. */
  11108. function toKey(value) {
  11109. if (typeof value == 'string' || isSymbol(value)) {
  11110. return value;
  11111. }
  11112. var result = (value + '');
  11113. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  11114. }
  11115. /**
  11116. * Converts `func` to its source code.
  11117. *
  11118. * @private
  11119. * @param {Function} func The function to convert.
  11120. * @returns {string} Returns the source code.
  11121. */
  11122. function toSource(func) {
  11123. if (func != null) {
  11124. try {
  11125. return funcToString.call(func);
  11126. } catch (e) {}
  11127. try {
  11128. return (func + '');
  11129. } catch (e) {}
  11130. }
  11131. return '';
  11132. }
  11133. /**
  11134. * Updates wrapper `details` based on `bitmask` flags.
  11135. *
  11136. * @private
  11137. * @returns {Array} details The details to modify.
  11138. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  11139. * @returns {Array} Returns `details`.
  11140. */
  11141. function updateWrapDetails(details, bitmask) {
  11142. arrayEach(wrapFlags, function(pair) {
  11143. var value = '_.' + pair[0];
  11144. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  11145. details.push(value);
  11146. }
  11147. });
  11148. return details.sort();
  11149. }
  11150. /**
  11151. * Creates a clone of `wrapper`.
  11152. *
  11153. * @private
  11154. * @param {Object} wrapper The wrapper to clone.
  11155. * @returns {Object} Returns the cloned wrapper.
  11156. */
  11157. function wrapperClone(wrapper) {
  11158. if (wrapper instanceof LazyWrapper) {
  11159. return wrapper.clone();
  11160. }
  11161. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  11162. result.__actions__ = copyArray(wrapper.__actions__);
  11163. result.__index__ = wrapper.__index__;
  11164. result.__values__ = wrapper.__values__;
  11165. return result;
  11166. }
  11167. /*------------------------------------------------------------------------*/
  11168. /**
  11169. * Creates an array of elements split into groups the length of `size`.
  11170. * If `array` can't be split evenly, the final chunk will be the remaining
  11171. * elements.
  11172. *
  11173. * @static
  11174. * @memberOf _
  11175. * @since 3.0.0
  11176. * @category Array
  11177. * @param {Array} array The array to process.
  11178. * @param {number} [size=1] The length of each chunk
  11179. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  11180. * @returns {Array} Returns the new array of chunks.
  11181. * @example
  11182. *
  11183. * _.chunk(['a', 'b', 'c', 'd'], 2);
  11184. * // => [['a', 'b'], ['c', 'd']]
  11185. *
  11186. * _.chunk(['a', 'b', 'c', 'd'], 3);
  11187. * // => [['a', 'b', 'c'], ['d']]
  11188. */
  11189. function chunk(array, size, guard) {
  11190. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  11191. size = 1;
  11192. } else {
  11193. size = nativeMax(toInteger(size), 0);
  11194. }
  11195. var length = array == null ? 0 : array.length;
  11196. if (!length || size < 1) {
  11197. return [];
  11198. }
  11199. var index = 0,
  11200. resIndex = 0,
  11201. result = Array(nativeCeil(length / size));
  11202. while (index < length) {
  11203. result[resIndex++] = baseSlice(array, index, (index += size));
  11204. }
  11205. return result;
  11206. }
  11207. /**
  11208. * Creates an array with all falsey values removed. The values `false`, `null`,
  11209. * `0`, `""`, `undefined`, and `NaN` are falsey.
  11210. *
  11211. * @static
  11212. * @memberOf _
  11213. * @since 0.1.0
  11214. * @category Array
  11215. * @param {Array} array The array to compact.
  11216. * @returns {Array} Returns the new array of filtered values.
  11217. * @example
  11218. *
  11219. * _.compact([0, 1, false, 2, '', 3]);
  11220. * // => [1, 2, 3]
  11221. */
  11222. function compact(array) {
  11223. var index = -1,
  11224. length = array == null ? 0 : array.length,
  11225. resIndex = 0,
  11226. result = [];
  11227. while (++index < length) {
  11228. var value = array[index];
  11229. if (value) {
  11230. result[resIndex++] = value;
  11231. }
  11232. }
  11233. return result;
  11234. }
  11235. /**
  11236. * Creates a new array concatenating `array` with any additional arrays
  11237. * and/or values.
  11238. *
  11239. * @static
  11240. * @memberOf _
  11241. * @since 4.0.0
  11242. * @category Array
  11243. * @param {Array} array The array to concatenate.
  11244. * @param {...*} [values] The values to concatenate.
  11245. * @returns {Array} Returns the new concatenated array.
  11246. * @example
  11247. *
  11248. * var array = [1];
  11249. * var other = _.concat(array, 2, [3], [[4]]);
  11250. *
  11251. * console.log(other);
  11252. * // => [1, 2, 3, [4]]
  11253. *
  11254. * console.log(array);
  11255. * // => [1]
  11256. */
  11257. function concat() {
  11258. var length = arguments.length;
  11259. if (!length) {
  11260. return [];
  11261. }
  11262. var args = Array(length - 1),
  11263. array = arguments[0],
  11264. index = length;
  11265. while (index--) {
  11266. args[index - 1] = arguments[index];
  11267. }
  11268. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  11269. }
  11270. /**
  11271. * Creates an array of `array` values not included in the other given arrays
  11272. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  11273. * for equality comparisons. The order and references of result values are
  11274. * determined by the first array.
  11275. *
  11276. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  11277. *
  11278. * @static
  11279. * @memberOf _
  11280. * @since 0.1.0
  11281. * @category Array
  11282. * @param {Array} array The array to inspect.
  11283. * @param {...Array} [values] The values to exclude.
  11284. * @returns {Array} Returns the new array of filtered values.
  11285. * @see _.without, _.xor
  11286. * @example
  11287. *
  11288. * _.difference([2, 1], [2, 3]);
  11289. * // => [1]
  11290. */
  11291. var difference = baseRest(function(array, values) {
  11292. return isArrayLikeObject(array)
  11293. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  11294. : [];
  11295. });
  11296. /**
  11297. * This method is like `_.difference` except that it accepts `iteratee` which
  11298. * is invoked for each element of `array` and `values` to generate the criterion
  11299. * by which they're compared. The order and references of result values are
  11300. * determined by the first array. The iteratee is invoked with one argument:
  11301. * (value).
  11302. *
  11303. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  11304. *
  11305. * @static
  11306. * @memberOf _
  11307. * @since 4.0.0
  11308. * @category Array
  11309. * @param {Array} array The array to inspect.
  11310. * @param {...Array} [values] The values to exclude.
  11311. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  11312. * @returns {Array} Returns the new array of filtered values.
  11313. * @example
  11314. *
  11315. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  11316. * // => [1.2]
  11317. *
  11318. * // The `_.property` iteratee shorthand.
  11319. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  11320. * // => [{ 'x': 2 }]
  11321. */
  11322. var differenceBy = baseRest(function(array, values) {
  11323. var iteratee = last(values);
  11324. if (isArrayLikeObject(iteratee)) {
  11325. iteratee = undefined;
  11326. }
  11327. return isArrayLikeObject(array)
  11328. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  11329. : [];
  11330. });
  11331. /**
  11332. * This method is like `_.difference` except that it accepts `comparator`
  11333. * which is invoked to compare elements of `array` to `values`. The order and
  11334. * references of result values are determined by the first array. The comparator
  11335. * is invoked with two arguments: (arrVal, othVal).
  11336. *
  11337. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  11338. *
  11339. * @static
  11340. * @memberOf _
  11341. * @since 4.0.0
  11342. * @category Array
  11343. * @param {Array} array The array to inspect.
  11344. * @param {...Array} [values] The values to exclude.
  11345. * @param {Function} [comparator] The comparator invoked per element.
  11346. * @returns {Array} Returns the new array of filtered values.
  11347. * @example
  11348. *
  11349. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  11350. *
  11351. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  11352. * // => [{ 'x': 2, 'y': 1 }]
  11353. */
  11354. var differenceWith = baseRest(function(array, values) {
  11355. var comparator = last(values);
  11356. if (isArrayLikeObject(comparator)) {
  11357. comparator = undefined;
  11358. }
  11359. return isArrayLikeObject(array)
  11360. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  11361. : [];
  11362. });
  11363. /**
  11364. * Creates a slice of `array` with `n` elements dropped from the beginning.
  11365. *
  11366. * @static
  11367. * @memberOf _
  11368. * @since 0.5.0
  11369. * @category Array
  11370. * @param {Array} array The array to query.
  11371. * @param {number} [n=1] The number of elements to drop.
  11372. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  11373. * @returns {Array} Returns the slice of `array`.
  11374. * @example
  11375. *
  11376. * _.drop([1, 2, 3]);
  11377. * // => [2, 3]
  11378. *
  11379. * _.drop([1, 2, 3], 2);
  11380. * // => [3]
  11381. *
  11382. * _.drop([1, 2, 3], 5);
  11383. * // => []
  11384. *
  11385. * _.drop([1, 2, 3], 0);
  11386. * // => [1, 2, 3]
  11387. */
  11388. function drop(array, n, guard) {
  11389. var length = array == null ? 0 : array.length;
  11390. if (!length) {
  11391. return [];
  11392. }
  11393. n = (guard || n === undefined) ? 1 : toInteger(n);
  11394. return baseSlice(array, n < 0 ? 0 : n, length);
  11395. }
  11396. /**
  11397. * Creates a slice of `array` with `n` elements dropped from the end.
  11398. *
  11399. * @static
  11400. * @memberOf _
  11401. * @since 3.0.0
  11402. * @category Array
  11403. * @param {Array} array The array to query.
  11404. * @param {number} [n=1] The number of elements to drop.
  11405. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  11406. * @returns {Array} Returns the slice of `array`.
  11407. * @example
  11408. *
  11409. * _.dropRight([1, 2, 3]);
  11410. * // => [1, 2]
  11411. *
  11412. * _.dropRight([1, 2, 3], 2);
  11413. * // => [1]
  11414. *
  11415. * _.dropRight([1, 2, 3], 5);
  11416. * // => []
  11417. *
  11418. * _.dropRight([1, 2, 3], 0);
  11419. * // => [1, 2, 3]
  11420. */
  11421. function dropRight(array, n, guard) {
  11422. var length = array == null ? 0 : array.length;
  11423. if (!length) {
  11424. return [];
  11425. }
  11426. n = (guard || n === undefined) ? 1 : toInteger(n);
  11427. n = length - n;
  11428. return baseSlice(array, 0, n < 0 ? 0 : n);
  11429. }
  11430. /**
  11431. * Creates a slice of `array` excluding elements dropped from the end.
  11432. * Elements are dropped until `predicate` returns falsey. The predicate is
  11433. * invoked with three arguments: (value, index, array).
  11434. *
  11435. * @static
  11436. * @memberOf _
  11437. * @since 3.0.0
  11438. * @category Array
  11439. * @param {Array} array The array to query.
  11440. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  11441. * @returns {Array} Returns the slice of `array`.
  11442. * @example
  11443. *
  11444. * var users = [
  11445. * { 'user': 'barney', 'active': true },
  11446. * { 'user': 'fred', 'active': false },
  11447. * { 'user': 'pebbles', 'active': false }
  11448. * ];
  11449. *
  11450. * _.dropRightWhile(users, function(o) { return !o.active; });
  11451. * // => objects for ['barney']
  11452. *
  11453. * // The `_.matches` iteratee shorthand.
  11454. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  11455. * // => objects for ['barney', 'fred']
  11456. *
  11457. * // The `_.matchesProperty` iteratee shorthand.
  11458. * _.dropRightWhile(users, ['active', false]);
  11459. * // => objects for ['barney']
  11460. *
  11461. * // The `_.property` iteratee shorthand.
  11462. * _.dropRightWhile(users, 'active');
  11463. * // => objects for ['barney', 'fred', 'pebbles']
  11464. */
  11465. function dropRightWhile(array, predicate) {
  11466. return (array && array.length)
  11467. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  11468. : [];
  11469. }
  11470. /**
  11471. * Creates a slice of `array` excluding elements dropped from the beginning.
  11472. * Elements are dropped until `predicate` returns falsey. The predicate is
  11473. * invoked with three arguments: (value, index, array).
  11474. *
  11475. * @static
  11476. * @memberOf _
  11477. * @since 3.0.0
  11478. * @category Array
  11479. * @param {Array} array The array to query.
  11480. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  11481. * @returns {Array} Returns the slice of `array`.
  11482. * @example
  11483. *
  11484. * var users = [
  11485. * { 'user': 'barney', 'active': false },
  11486. * { 'user': 'fred', 'active': false },
  11487. * { 'user': 'pebbles', 'active': true }
  11488. * ];
  11489. *
  11490. * _.dropWhile(users, function(o) { return !o.active; });
  11491. * // => objects for ['pebbles']
  11492. *
  11493. * // The `_.matches` iteratee shorthand.
  11494. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  11495. * // => objects for ['fred', 'pebbles']
  11496. *
  11497. * // The `_.matchesProperty` iteratee shorthand.
  11498. * _.dropWhile(users, ['active', false]);
  11499. * // => objects for ['pebbles']
  11500. *
  11501. * // The `_.property` iteratee shorthand.
  11502. * _.dropWhile(users, 'active');
  11503. * // => objects for ['barney', 'fred', 'pebbles']
  11504. */
  11505. function dropWhile(array, predicate) {
  11506. return (array && array.length)
  11507. ? baseWhile(array, getIteratee(predicate, 3), true)
  11508. : [];
  11509. }
  11510. /**
  11511. * Fills elements of `array` with `value` from `start` up to, but not
  11512. * including, `end`.
  11513. *
  11514. * **Note:** This method mutates `array`.
  11515. *
  11516. * @static
  11517. * @memberOf _
  11518. * @since 3.2.0
  11519. * @category Array
  11520. * @param {Array} array The array to fill.
  11521. * @param {*} value The value to fill `array` with.
  11522. * @param {number} [start=0] The start position.
  11523. * @param {number} [end=array.length] The end position.
  11524. * @returns {Array} Returns `array`.
  11525. * @example
  11526. *
  11527. * var array = [1, 2, 3];
  11528. *
  11529. * _.fill(array, 'a');
  11530. * console.log(array);
  11531. * // => ['a', 'a', 'a']
  11532. *
  11533. * _.fill(Array(3), 2);
  11534. * // => [2, 2, 2]
  11535. *
  11536. * _.fill([4, 6, 8, 10], '*', 1, 3);
  11537. * // => [4, '*', '*', 10]
  11538. */
  11539. function fill(array, value, start, end) {
  11540. var length = array == null ? 0 : array.length;
  11541. if (!length) {
  11542. return [];
  11543. }
  11544. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  11545. start = 0;
  11546. end = length;
  11547. }
  11548. return baseFill(array, value, start, end);
  11549. }
  11550. /**
  11551. * This method is like `_.find` except that it returns the index of the first
  11552. * element `predicate` returns truthy for instead of the element itself.
  11553. *
  11554. * @static
  11555. * @memberOf _
  11556. * @since 1.1.0
  11557. * @category Array
  11558. * @param {Array} array The array to inspect.
  11559. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  11560. * @param {number} [fromIndex=0] The index to search from.
  11561. * @returns {number} Returns the index of the found element, else `-1`.
  11562. * @example
  11563. *
  11564. * var users = [
  11565. * { 'user': 'barney', 'active': false },
  11566. * { 'user': 'fred', 'active': false },
  11567. * { 'user': 'pebbles', 'active': true }
  11568. * ];
  11569. *
  11570. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  11571. * // => 0
  11572. *
  11573. * // The `_.matches` iteratee shorthand.
  11574. * _.findIndex(users, { 'user': 'fred', 'active': false });
  11575. * // => 1
  11576. *
  11577. * // The `_.matchesProperty` iteratee shorthand.
  11578. * _.findIndex(users, ['active', false]);
  11579. * // => 0
  11580. *
  11581. * // The `_.property` iteratee shorthand.
  11582. * _.findIndex(users, 'active');
  11583. * // => 2
  11584. */
  11585. function findIndex(array, predicate, fromIndex) {
  11586. var length = array == null ? 0 : array.length;
  11587. if (!length) {
  11588. return -1;
  11589. }
  11590. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  11591. if (index < 0) {
  11592. index = nativeMax(length + index, 0);
  11593. }
  11594. return baseFindIndex(array, getIteratee(predicate, 3), index);
  11595. }
  11596. /**
  11597. * This method is like `_.findIndex` except that it iterates over elements
  11598. * of `collection` from right to left.
  11599. *
  11600. * @static
  11601. * @memberOf _
  11602. * @since 2.0.0
  11603. * @category Array
  11604. * @param {Array} array The array to inspect.
  11605. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  11606. * @param {number} [fromIndex=array.length-1] The index to search from.
  11607. * @returns {number} Returns the index of the found element, else `-1`.
  11608. * @example
  11609. *
  11610. * var users = [
  11611. * { 'user': 'barney', 'active': true },
  11612. * { 'user': 'fred', 'active': false },
  11613. * { 'user': 'pebbles', 'active': false }
  11614. * ];
  11615. *
  11616. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  11617. * // => 2
  11618. *
  11619. * // The `_.matches` iteratee shorthand.
  11620. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  11621. * // => 0
  11622. *
  11623. * // The `_.matchesProperty` iteratee shorthand.
  11624. * _.findLastIndex(users, ['active', false]);
  11625. * // => 2
  11626. *
  11627. * // The `_.property` iteratee shorthand.
  11628. * _.findLastIndex(users, 'active');
  11629. * // => 0
  11630. */
  11631. function findLastIndex(array, predicate, fromIndex) {
  11632. var length = array == null ? 0 : array.length;
  11633. if (!length) {
  11634. return -1;
  11635. }
  11636. var index = length - 1;
  11637. if (fromIndex !== undefined) {
  11638. index = toInteger(fromIndex);
  11639. index = fromIndex < 0
  11640. ? nativeMax(length + index, 0)
  11641. : nativeMin(index, length - 1);
  11642. }
  11643. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  11644. }
  11645. /**
  11646. * Flattens `array` a single level deep.
  11647. *
  11648. * @static
  11649. * @memberOf _
  11650. * @since 0.1.0
  11651. * @category Array
  11652. * @param {Array} array The array to flatten.
  11653. * @returns {Array} Returns the new flattened array.
  11654. * @example
  11655. *
  11656. * _.flatten([1, [2, [3, [4]], 5]]);
  11657. * // => [1, 2, [3, [4]], 5]
  11658. */
  11659. function flatten(array) {
  11660. var length = array == null ? 0 : array.length;
  11661. return length ? baseFlatten(array, 1) : [];
  11662. }
  11663. /**
  11664. * Recursively flattens `array`.
  11665. *
  11666. * @static
  11667. * @memberOf _
  11668. * @since 3.0.0
  11669. * @category Array
  11670. * @param {Array} array The array to flatten.
  11671. * @returns {Array} Returns the new flattened array.
  11672. * @example
  11673. *
  11674. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  11675. * // => [1, 2, 3, 4, 5]
  11676. */
  11677. function flattenDeep(array) {
  11678. var length = array == null ? 0 : array.length;
  11679. return length ? baseFlatten(array, INFINITY) : [];
  11680. }
  11681. /**
  11682. * Recursively flatten `array` up to `depth` times.
  11683. *
  11684. * @static
  11685. * @memberOf _
  11686. * @since 4.4.0
  11687. * @category Array
  11688. * @param {Array} array The array to flatten.
  11689. * @param {number} [depth=1] The maximum recursion depth.
  11690. * @returns {Array} Returns the new flattened array.
  11691. * @example
  11692. *
  11693. * var array = [1, [2, [3, [4]], 5]];
  11694. *
  11695. * _.flattenDepth(array, 1);
  11696. * // => [1, 2, [3, [4]], 5]
  11697. *
  11698. * _.flattenDepth(array, 2);
  11699. * // => [1, 2, 3, [4], 5]
  11700. */
  11701. function flattenDepth(array, depth) {
  11702. var length = array == null ? 0 : array.length;
  11703. if (!length) {
  11704. return [];
  11705. }
  11706. depth = depth === undefined ? 1 : toInteger(depth);
  11707. return baseFlatten(array, depth);
  11708. }
  11709. /**
  11710. * The inverse of `_.toPairs`; this method returns an object composed
  11711. * from key-value `pairs`.
  11712. *
  11713. * @static
  11714. * @memberOf _
  11715. * @since 4.0.0
  11716. * @category Array
  11717. * @param {Array} pairs The key-value pairs.
  11718. * @returns {Object} Returns the new object.
  11719. * @example
  11720. *
  11721. * _.fromPairs([['a', 1], ['b', 2]]);
  11722. * // => { 'a': 1, 'b': 2 }
  11723. */
  11724. function fromPairs(pairs) {
  11725. var index = -1,
  11726. length = pairs == null ? 0 : pairs.length,
  11727. result = {};
  11728. while (++index < length) {
  11729. var pair = pairs[index];
  11730. result[pair[0]] = pair[1];
  11731. }
  11732. return result;
  11733. }
  11734. /**
  11735. * Gets the first element of `array`.
  11736. *
  11737. * @static
  11738. * @memberOf _
  11739. * @since 0.1.0
  11740. * @alias first
  11741. * @category Array
  11742. * @param {Array} array The array to query.
  11743. * @returns {*} Returns the first element of `array`.
  11744. * @example
  11745. *
  11746. * _.head([1, 2, 3]);
  11747. * // => 1
  11748. *
  11749. * _.head([]);
  11750. * // => undefined
  11751. */
  11752. function head(array) {
  11753. return (array && array.length) ? array[0] : undefined;
  11754. }
  11755. /**
  11756. * Gets the index at which the first occurrence of `value` is found in `array`
  11757. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  11758. * for equality comparisons. If `fromIndex` is negative, it's used as the
  11759. * offset from the end of `array`.
  11760. *
  11761. * @static
  11762. * @memberOf _
  11763. * @since 0.1.0
  11764. * @category Array
  11765. * @param {Array} array The array to inspect.
  11766. * @param {*} value The value to search for.
  11767. * @param {number} [fromIndex=0] The index to search from.
  11768. * @returns {number} Returns the index of the matched value, else `-1`.
  11769. * @example
  11770. *
  11771. * _.indexOf([1, 2, 1, 2], 2);
  11772. * // => 1
  11773. *
  11774. * // Search from the `fromIndex`.
  11775. * _.indexOf([1, 2, 1, 2], 2, 2);
  11776. * // => 3
  11777. */
  11778. function indexOf(array, value, fromIndex) {
  11779. var length = array == null ? 0 : array.length;
  11780. if (!length) {
  11781. return -1;
  11782. }
  11783. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  11784. if (index < 0) {
  11785. index = nativeMax(length + index, 0);
  11786. }
  11787. return baseIndexOf(array, value, index);
  11788. }
  11789. /**
  11790. * Gets all but the last element of `array`.
  11791. *
  11792. * @static
  11793. * @memberOf _
  11794. * @since 0.1.0
  11795. * @category Array
  11796. * @param {Array} array The array to query.
  11797. * @returns {Array} Returns the slice of `array`.
  11798. * @example
  11799. *
  11800. * _.initial([1, 2, 3]);
  11801. * // => [1, 2]
  11802. */
  11803. function initial(array) {
  11804. var length = array == null ? 0 : array.length;
  11805. return length ? baseSlice(array, 0, -1) : [];
  11806. }
  11807. /**
  11808. * Creates an array of unique values that are included in all given arrays
  11809. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  11810. * for equality comparisons. The order and references of result values are
  11811. * determined by the first array.
  11812. *
  11813. * @static
  11814. * @memberOf _
  11815. * @since 0.1.0
  11816. * @category Array
  11817. * @param {...Array} [arrays] The arrays to inspect.
  11818. * @returns {Array} Returns the new array of intersecting values.
  11819. * @example
  11820. *
  11821. * _.intersection([2, 1], [2, 3]);
  11822. * // => [2]
  11823. */
  11824. var intersection = baseRest(function(arrays) {
  11825. var mapped = arrayMap(arrays, castArrayLikeObject);
  11826. return (mapped.length && mapped[0] === arrays[0])
  11827. ? baseIntersection(mapped)
  11828. : [];
  11829. });
  11830. /**
  11831. * This method is like `_.intersection` except that it accepts `iteratee`
  11832. * which is invoked for each element of each `arrays` to generate the criterion
  11833. * by which they're compared. The order and references of result values are
  11834. * determined by the first array. The iteratee is invoked with one argument:
  11835. * (value).
  11836. *
  11837. * @static
  11838. * @memberOf _
  11839. * @since 4.0.0
  11840. * @category Array
  11841. * @param {...Array} [arrays] The arrays to inspect.
  11842. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  11843. * @returns {Array} Returns the new array of intersecting values.
  11844. * @example
  11845. *
  11846. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  11847. * // => [2.1]
  11848. *
  11849. * // The `_.property` iteratee shorthand.
  11850. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  11851. * // => [{ 'x': 1 }]
  11852. */
  11853. var intersectionBy = baseRest(function(arrays) {
  11854. var iteratee = last(arrays),
  11855. mapped = arrayMap(arrays, castArrayLikeObject);
  11856. if (iteratee === last(mapped)) {
  11857. iteratee = undefined;
  11858. } else {
  11859. mapped.pop();
  11860. }
  11861. return (mapped.length && mapped[0] === arrays[0])
  11862. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  11863. : [];
  11864. });
  11865. /**
  11866. * This method is like `_.intersection` except that it accepts `comparator`
  11867. * which is invoked to compare elements of `arrays`. The order and references
  11868. * of result values are determined by the first array. The comparator is
  11869. * invoked with two arguments: (arrVal, othVal).
  11870. *
  11871. * @static
  11872. * @memberOf _
  11873. * @since 4.0.0
  11874. * @category Array
  11875. * @param {...Array} [arrays] The arrays to inspect.
  11876. * @param {Function} [comparator] The comparator invoked per element.
  11877. * @returns {Array} Returns the new array of intersecting values.
  11878. * @example
  11879. *
  11880. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  11881. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  11882. *
  11883. * _.intersectionWith(objects, others, _.isEqual);
  11884. * // => [{ 'x': 1, 'y': 2 }]
  11885. */
  11886. var intersectionWith = baseRest(function(arrays) {
  11887. var comparator = last(arrays),
  11888. mapped = arrayMap(arrays, castArrayLikeObject);
  11889. comparator = typeof comparator == 'function' ? comparator : undefined;
  11890. if (comparator) {
  11891. mapped.pop();
  11892. }
  11893. return (mapped.length && mapped[0] === arrays[0])
  11894. ? baseIntersection(mapped, undefined, comparator)
  11895. : [];
  11896. });
  11897. /**
  11898. * Converts all elements in `array` into a string separated by `separator`.
  11899. *
  11900. * @static
  11901. * @memberOf _
  11902. * @since 4.0.0
  11903. * @category Array
  11904. * @param {Array} array The array to convert.
  11905. * @param {string} [separator=','] The element separator.
  11906. * @returns {string} Returns the joined string.
  11907. * @example
  11908. *
  11909. * _.join(['a', 'b', 'c'], '~');
  11910. * // => 'a~b~c'
  11911. */
  11912. function join(array, separator) {
  11913. return array == null ? '' : nativeJoin.call(array, separator);
  11914. }
  11915. /**
  11916. * Gets the last element of `array`.
  11917. *
  11918. * @static
  11919. * @memberOf _
  11920. * @since 0.1.0
  11921. * @category Array
  11922. * @param {Array} array The array to query.
  11923. * @returns {*} Returns the last element of `array`.
  11924. * @example
  11925. *
  11926. * _.last([1, 2, 3]);
  11927. * // => 3
  11928. */
  11929. function last(array) {
  11930. var length = array == null ? 0 : array.length;
  11931. return length ? array[length - 1] : undefined;
  11932. }
  11933. /**
  11934. * This method is like `_.indexOf` except that it iterates over elements of
  11935. * `array` from right to left.
  11936. *
  11937. * @static
  11938. * @memberOf _
  11939. * @since 0.1.0
  11940. * @category Array
  11941. * @param {Array} array The array to inspect.
  11942. * @param {*} value The value to search for.
  11943. * @param {number} [fromIndex=array.length-1] The index to search from.
  11944. * @returns {number} Returns the index of the matched value, else `-1`.
  11945. * @example
  11946. *
  11947. * _.lastIndexOf([1, 2, 1, 2], 2);
  11948. * // => 3
  11949. *
  11950. * // Search from the `fromIndex`.
  11951. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  11952. * // => 1
  11953. */
  11954. function lastIndexOf(array, value, fromIndex) {
  11955. var length = array == null ? 0 : array.length;
  11956. if (!length) {
  11957. return -1;
  11958. }
  11959. var index = length;
  11960. if (fromIndex !== undefined) {
  11961. index = toInteger(fromIndex);
  11962. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  11963. }
  11964. return value === value
  11965. ? strictLastIndexOf(array, value, index)
  11966. : baseFindIndex(array, baseIsNaN, index, true);
  11967. }
  11968. /**
  11969. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  11970. * element from the end is returned.
  11971. *
  11972. * @static
  11973. * @memberOf _
  11974. * @since 4.11.0
  11975. * @category Array
  11976. * @param {Array} array The array to query.
  11977. * @param {number} [n=0] The index of the element to return.
  11978. * @returns {*} Returns the nth element of `array`.
  11979. * @example
  11980. *
  11981. * var array = ['a', 'b', 'c', 'd'];
  11982. *
  11983. * _.nth(array, 1);
  11984. * // => 'b'
  11985. *
  11986. * _.nth(array, -2);
  11987. * // => 'c';
  11988. */
  11989. function nth(array, n) {
  11990. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  11991. }
  11992. /**
  11993. * Removes all given values from `array` using
  11994. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  11995. * for equality comparisons.
  11996. *
  11997. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  11998. * to remove elements from an array by predicate.
  11999. *
  12000. * @static
  12001. * @memberOf _
  12002. * @since 2.0.0
  12003. * @category Array
  12004. * @param {Array} array The array to modify.
  12005. * @param {...*} [values] The values to remove.
  12006. * @returns {Array} Returns `array`.
  12007. * @example
  12008. *
  12009. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  12010. *
  12011. * _.pull(array, 'a', 'c');
  12012. * console.log(array);
  12013. * // => ['b', 'b']
  12014. */
  12015. var pull = baseRest(pullAll);
  12016. /**
  12017. * This method is like `_.pull` except that it accepts an array of values to remove.
  12018. *
  12019. * **Note:** Unlike `_.difference`, this method mutates `array`.
  12020. *
  12021. * @static
  12022. * @memberOf _
  12023. * @since 4.0.0
  12024. * @category Array
  12025. * @param {Array} array The array to modify.
  12026. * @param {Array} values The values to remove.
  12027. * @returns {Array} Returns `array`.
  12028. * @example
  12029. *
  12030. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  12031. *
  12032. * _.pullAll(array, ['a', 'c']);
  12033. * console.log(array);
  12034. * // => ['b', 'b']
  12035. */
  12036. function pullAll(array, values) {
  12037. return (array && array.length && values && values.length)
  12038. ? basePullAll(array, values)
  12039. : array;
  12040. }
  12041. /**
  12042. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  12043. * invoked for each element of `array` and `values` to generate the criterion
  12044. * by which they're compared. The iteratee is invoked with one argument: (value).
  12045. *
  12046. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  12047. *
  12048. * @static
  12049. * @memberOf _
  12050. * @since 4.0.0
  12051. * @category Array
  12052. * @param {Array} array The array to modify.
  12053. * @param {Array} values The values to remove.
  12054. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  12055. * @returns {Array} Returns `array`.
  12056. * @example
  12057. *
  12058. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  12059. *
  12060. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  12061. * console.log(array);
  12062. * // => [{ 'x': 2 }]
  12063. */
  12064. function pullAllBy(array, values, iteratee) {
  12065. return (array && array.length && values && values.length)
  12066. ? basePullAll(array, values, getIteratee(iteratee, 2))
  12067. : array;
  12068. }
  12069. /**
  12070. * This method is like `_.pullAll` except that it accepts `comparator` which
  12071. * is invoked to compare elements of `array` to `values`. The comparator is
  12072. * invoked with two arguments: (arrVal, othVal).
  12073. *
  12074. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  12075. *
  12076. * @static
  12077. * @memberOf _
  12078. * @since 4.6.0
  12079. * @category Array
  12080. * @param {Array} array The array to modify.
  12081. * @param {Array} values The values to remove.
  12082. * @param {Function} [comparator] The comparator invoked per element.
  12083. * @returns {Array} Returns `array`.
  12084. * @example
  12085. *
  12086. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  12087. *
  12088. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  12089. * console.log(array);
  12090. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  12091. */
  12092. function pullAllWith(array, values, comparator) {
  12093. return (array && array.length && values && values.length)
  12094. ? basePullAll(array, values, undefined, comparator)
  12095. : array;
  12096. }
  12097. /**
  12098. * Removes elements from `array` corresponding to `indexes` and returns an
  12099. * array of removed elements.
  12100. *
  12101. * **Note:** Unlike `_.at`, this method mutates `array`.
  12102. *
  12103. * @static
  12104. * @memberOf _
  12105. * @since 3.0.0
  12106. * @category Array
  12107. * @param {Array} array The array to modify.
  12108. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  12109. * @returns {Array} Returns the new array of removed elements.
  12110. * @example
  12111. *
  12112. * var array = ['a', 'b', 'c', 'd'];
  12113. * var pulled = _.pullAt(array, [1, 3]);
  12114. *
  12115. * console.log(array);
  12116. * // => ['a', 'c']
  12117. *
  12118. * console.log(pulled);
  12119. * // => ['b', 'd']
  12120. */
  12121. var pullAt = flatRest(function(array, indexes) {
  12122. var length = array == null ? 0 : array.length,
  12123. result = baseAt(array, indexes);
  12124. basePullAt(array, arrayMap(indexes, function(index) {
  12125. return isIndex(index, length) ? +index : index;
  12126. }).sort(compareAscending));
  12127. return result;
  12128. });
  12129. /**
  12130. * Removes all elements from `array` that `predicate` returns truthy for
  12131. * and returns an array of the removed elements. The predicate is invoked
  12132. * with three arguments: (value, index, array).
  12133. *
  12134. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  12135. * to pull elements from an array by value.
  12136. *
  12137. * @static
  12138. * @memberOf _
  12139. * @since 2.0.0
  12140. * @category Array
  12141. * @param {Array} array The array to modify.
  12142. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  12143. * @returns {Array} Returns the new array of removed elements.
  12144. * @example
  12145. *
  12146. * var array = [1, 2, 3, 4];
  12147. * var evens = _.remove(array, function(n) {
  12148. * return n % 2 == 0;
  12149. * });
  12150. *
  12151. * console.log(array);
  12152. * // => [1, 3]
  12153. *
  12154. * console.log(evens);
  12155. * // => [2, 4]
  12156. */
  12157. function remove(array, predicate) {
  12158. var result = [];
  12159. if (!(array && array.length)) {
  12160. return result;
  12161. }
  12162. var index = -1,
  12163. indexes = [],
  12164. length = array.length;
  12165. predicate = getIteratee(predicate, 3);
  12166. while (++index < length) {
  12167. var value = array[index];
  12168. if (predicate(value, index, array)) {
  12169. result.push(value);
  12170. indexes.push(index);
  12171. }
  12172. }
  12173. basePullAt(array, indexes);
  12174. return result;
  12175. }
  12176. /**
  12177. * Reverses `array` so that the first element becomes the last, the second
  12178. * element becomes the second to last, and so on.
  12179. *
  12180. * **Note:** This method mutates `array` and is based on
  12181. * [`Array#reverse`](https://mdn.io/Array/reverse).
  12182. *
  12183. * @static
  12184. * @memberOf _
  12185. * @since 4.0.0
  12186. * @category Array
  12187. * @param {Array} array The array to modify.
  12188. * @returns {Array} Returns `array`.
  12189. * @example
  12190. *
  12191. * var array = [1, 2, 3];
  12192. *
  12193. * _.reverse(array);
  12194. * // => [3, 2, 1]
  12195. *
  12196. * console.log(array);
  12197. * // => [3, 2, 1]
  12198. */
  12199. function reverse(array) {
  12200. return array == null ? array : nativeReverse.call(array);
  12201. }
  12202. /**
  12203. * Creates a slice of `array` from `start` up to, but not including, `end`.
  12204. *
  12205. * **Note:** This method is used instead of
  12206. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  12207. * returned.
  12208. *
  12209. * @static
  12210. * @memberOf _
  12211. * @since 3.0.0
  12212. * @category Array
  12213. * @param {Array} array The array to slice.
  12214. * @param {number} [start=0] The start position.
  12215. * @param {number} [end=array.length] The end position.
  12216. * @returns {Array} Returns the slice of `array`.
  12217. */
  12218. function slice(array, start, end) {
  12219. var length = array == null ? 0 : array.length;
  12220. if (!length) {
  12221. return [];
  12222. }
  12223. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  12224. start = 0;
  12225. end = length;
  12226. }
  12227. else {
  12228. start = start == null ? 0 : toInteger(start);
  12229. end = end === undefined ? length : toInteger(end);
  12230. }
  12231. return baseSlice(array, start, end);
  12232. }
  12233. /**
  12234. * Uses a binary search to determine the lowest index at which `value`
  12235. * should be inserted into `array` in order to maintain its sort order.
  12236. *
  12237. * @static
  12238. * @memberOf _
  12239. * @since 0.1.0
  12240. * @category Array
  12241. * @param {Array} array The sorted array to inspect.
  12242. * @param {*} value The value to evaluate.
  12243. * @returns {number} Returns the index at which `value` should be inserted
  12244. * into `array`.
  12245. * @example
  12246. *
  12247. * _.sortedIndex([30, 50], 40);
  12248. * // => 1
  12249. */
  12250. function sortedIndex(array, value) {
  12251. return baseSortedIndex(array, value);
  12252. }
  12253. /**
  12254. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  12255. * which is invoked for `value` and each element of `array` to compute their
  12256. * sort ranking. The iteratee is invoked with one argument: (value).
  12257. *
  12258. * @static
  12259. * @memberOf _
  12260. * @since 4.0.0
  12261. * @category Array
  12262. * @param {Array} array The sorted array to inspect.
  12263. * @param {*} value The value to evaluate.
  12264. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  12265. * @returns {number} Returns the index at which `value` should be inserted
  12266. * into `array`.
  12267. * @example
  12268. *
  12269. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  12270. *
  12271. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  12272. * // => 0
  12273. *
  12274. * // The `_.property` iteratee shorthand.
  12275. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  12276. * // => 0
  12277. */
  12278. function sortedIndexBy(array, value, iteratee) {
  12279. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  12280. }
  12281. /**
  12282. * This method is like `_.indexOf` except that it performs a binary
  12283. * search on a sorted `array`.
  12284. *
  12285. * @static
  12286. * @memberOf _
  12287. * @since 4.0.0
  12288. * @category Array
  12289. * @param {Array} array The array to inspect.
  12290. * @param {*} value The value to search for.
  12291. * @returns {number} Returns the index of the matched value, else `-1`.
  12292. * @example
  12293. *
  12294. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  12295. * // => 1
  12296. */
  12297. function sortedIndexOf(array, value) {
  12298. var length = array == null ? 0 : array.length;
  12299. if (length) {
  12300. var index = baseSortedIndex(array, value);
  12301. if (index < length && eq(array[index], value)) {
  12302. return index;
  12303. }
  12304. }
  12305. return -1;
  12306. }
  12307. /**
  12308. * This method is like `_.sortedIndex` except that it returns the highest
  12309. * index at which `value` should be inserted into `array` in order to
  12310. * maintain its sort order.
  12311. *
  12312. * @static
  12313. * @memberOf _
  12314. * @since 3.0.0
  12315. * @category Array
  12316. * @param {Array} array The sorted array to inspect.
  12317. * @param {*} value The value to evaluate.
  12318. * @returns {number} Returns the index at which `value` should be inserted
  12319. * into `array`.
  12320. * @example
  12321. *
  12322. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  12323. * // => 4
  12324. */
  12325. function sortedLastIndex(array, value) {
  12326. return baseSortedIndex(array, value, true);
  12327. }
  12328. /**
  12329. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  12330. * which is invoked for `value` and each element of `array` to compute their
  12331. * sort ranking. The iteratee is invoked with one argument: (value).
  12332. *
  12333. * @static
  12334. * @memberOf _
  12335. * @since 4.0.0
  12336. * @category Array
  12337. * @param {Array} array The sorted array to inspect.
  12338. * @param {*} value The value to evaluate.
  12339. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  12340. * @returns {number} Returns the index at which `value` should be inserted
  12341. * into `array`.
  12342. * @example
  12343. *
  12344. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  12345. *
  12346. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  12347. * // => 1
  12348. *
  12349. * // The `_.property` iteratee shorthand.
  12350. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  12351. * // => 1
  12352. */
  12353. function sortedLastIndexBy(array, value, iteratee) {
  12354. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  12355. }
  12356. /**
  12357. * This method is like `_.lastIndexOf` except that it performs a binary
  12358. * search on a sorted `array`.
  12359. *
  12360. * @static
  12361. * @memberOf _
  12362. * @since 4.0.0
  12363. * @category Array
  12364. * @param {Array} array The array to inspect.
  12365. * @param {*} value The value to search for.
  12366. * @returns {number} Returns the index of the matched value, else `-1`.
  12367. * @example
  12368. *
  12369. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  12370. * // => 3
  12371. */
  12372. function sortedLastIndexOf(array, value) {
  12373. var length = array == null ? 0 : array.length;
  12374. if (length) {
  12375. var index = baseSortedIndex(array, value, true) - 1;
  12376. if (eq(array[index], value)) {
  12377. return index;
  12378. }
  12379. }
  12380. return -1;
  12381. }
  12382. /**
  12383. * This method is like `_.uniq` except that it's designed and optimized
  12384. * for sorted arrays.
  12385. *
  12386. * @static
  12387. * @memberOf _
  12388. * @since 4.0.0
  12389. * @category Array
  12390. * @param {Array} array The array to inspect.
  12391. * @returns {Array} Returns the new duplicate free array.
  12392. * @example
  12393. *
  12394. * _.sortedUniq([1, 1, 2]);
  12395. * // => [1, 2]
  12396. */
  12397. function sortedUniq(array) {
  12398. return (array && array.length)
  12399. ? baseSortedUniq(array)
  12400. : [];
  12401. }
  12402. /**
  12403. * This method is like `_.uniqBy` except that it's designed and optimized
  12404. * for sorted arrays.
  12405. *
  12406. * @static
  12407. * @memberOf _
  12408. * @since 4.0.0
  12409. * @category Array
  12410. * @param {Array} array The array to inspect.
  12411. * @param {Function} [iteratee] The iteratee invoked per element.
  12412. * @returns {Array} Returns the new duplicate free array.
  12413. * @example
  12414. *
  12415. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  12416. * // => [1.1, 2.3]
  12417. */
  12418. function sortedUniqBy(array, iteratee) {
  12419. return (array && array.length)
  12420. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  12421. : [];
  12422. }
  12423. /**
  12424. * Gets all but the first element of `array`.
  12425. *
  12426. * @static
  12427. * @memberOf _
  12428. * @since 4.0.0
  12429. * @category Array
  12430. * @param {Array} array The array to query.
  12431. * @returns {Array} Returns the slice of `array`.
  12432. * @example
  12433. *
  12434. * _.tail([1, 2, 3]);
  12435. * // => [2, 3]
  12436. */
  12437. function tail(array) {
  12438. var length = array == null ? 0 : array.length;
  12439. return length ? baseSlice(array, 1, length) : [];
  12440. }
  12441. /**
  12442. * Creates a slice of `array` with `n` elements taken from the beginning.
  12443. *
  12444. * @static
  12445. * @memberOf _
  12446. * @since 0.1.0
  12447. * @category Array
  12448. * @param {Array} array The array to query.
  12449. * @param {number} [n=1] The number of elements to take.
  12450. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  12451. * @returns {Array} Returns the slice of `array`.
  12452. * @example
  12453. *
  12454. * _.take([1, 2, 3]);
  12455. * // => [1]
  12456. *
  12457. * _.take([1, 2, 3], 2);
  12458. * // => [1, 2]
  12459. *
  12460. * _.take([1, 2, 3], 5);
  12461. * // => [1, 2, 3]
  12462. *
  12463. * _.take([1, 2, 3], 0);
  12464. * // => []
  12465. */
  12466. function take(array, n, guard) {
  12467. if (!(array && array.length)) {
  12468. return [];
  12469. }
  12470. n = (guard || n === undefined) ? 1 : toInteger(n);
  12471. return baseSlice(array, 0, n < 0 ? 0 : n);
  12472. }
  12473. /**
  12474. * Creates a slice of `array` with `n` elements taken from the end.
  12475. *
  12476. * @static
  12477. * @memberOf _
  12478. * @since 3.0.0
  12479. * @category Array
  12480. * @param {Array} array The array to query.
  12481. * @param {number} [n=1] The number of elements to take.
  12482. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  12483. * @returns {Array} Returns the slice of `array`.
  12484. * @example
  12485. *
  12486. * _.takeRight([1, 2, 3]);
  12487. * // => [3]
  12488. *
  12489. * _.takeRight([1, 2, 3], 2);
  12490. * // => [2, 3]
  12491. *
  12492. * _.takeRight([1, 2, 3], 5);
  12493. * // => [1, 2, 3]
  12494. *
  12495. * _.takeRight([1, 2, 3], 0);
  12496. * // => []
  12497. */
  12498. function takeRight(array, n, guard) {
  12499. var length = array == null ? 0 : array.length;
  12500. if (!length) {
  12501. return [];
  12502. }
  12503. n = (guard || n === undefined) ? 1 : toInteger(n);
  12504. n = length - n;
  12505. return baseSlice(array, n < 0 ? 0 : n, length);
  12506. }
  12507. /**
  12508. * Creates a slice of `array` with elements taken from the end. Elements are
  12509. * taken until `predicate` returns falsey. The predicate is invoked with
  12510. * three arguments: (value, index, array).
  12511. *
  12512. * @static
  12513. * @memberOf _
  12514. * @since 3.0.0
  12515. * @category Array
  12516. * @param {Array} array The array to query.
  12517. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  12518. * @returns {Array} Returns the slice of `array`.
  12519. * @example
  12520. *
  12521. * var users = [
  12522. * { 'user': 'barney', 'active': true },
  12523. * { 'user': 'fred', 'active': false },
  12524. * { 'user': 'pebbles', 'active': false }
  12525. * ];
  12526. *
  12527. * _.takeRightWhile(users, function(o) { return !o.active; });
  12528. * // => objects for ['fred', 'pebbles']
  12529. *
  12530. * // The `_.matches` iteratee shorthand.
  12531. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  12532. * // => objects for ['pebbles']
  12533. *
  12534. * // The `_.matchesProperty` iteratee shorthand.
  12535. * _.takeRightWhile(users, ['active', false]);
  12536. * // => objects for ['fred', 'pebbles']
  12537. *
  12538. * // The `_.property` iteratee shorthand.
  12539. * _.takeRightWhile(users, 'active');
  12540. * // => []
  12541. */
  12542. function takeRightWhile(array, predicate) {
  12543. return (array && array.length)
  12544. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  12545. : [];
  12546. }
  12547. /**
  12548. * Creates a slice of `array` with elements taken from the beginning. Elements
  12549. * are taken until `predicate` returns falsey. The predicate is invoked with
  12550. * three arguments: (value, index, array).
  12551. *
  12552. * @static
  12553. * @memberOf _
  12554. * @since 3.0.0
  12555. * @category Array
  12556. * @param {Array} array The array to query.
  12557. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  12558. * @returns {Array} Returns the slice of `array`.
  12559. * @example
  12560. *
  12561. * var users = [
  12562. * { 'user': 'barney', 'active': false },
  12563. * { 'user': 'fred', 'active': false },
  12564. * { 'user': 'pebbles', 'active': true }
  12565. * ];
  12566. *
  12567. * _.takeWhile(users, function(o) { return !o.active; });
  12568. * // => objects for ['barney', 'fred']
  12569. *
  12570. * // The `_.matches` iteratee shorthand.
  12571. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  12572. * // => objects for ['barney']
  12573. *
  12574. * // The `_.matchesProperty` iteratee shorthand.
  12575. * _.takeWhile(users, ['active', false]);
  12576. * // => objects for ['barney', 'fred']
  12577. *
  12578. * // The `_.property` iteratee shorthand.
  12579. * _.takeWhile(users, 'active');
  12580. * // => []
  12581. */
  12582. function takeWhile(array, predicate) {
  12583. return (array && array.length)
  12584. ? baseWhile(array, getIteratee(predicate, 3))
  12585. : [];
  12586. }
  12587. /**
  12588. * Creates an array of unique values, in order, from all given arrays using
  12589. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  12590. * for equality comparisons.
  12591. *
  12592. * @static
  12593. * @memberOf _
  12594. * @since 0.1.0
  12595. * @category Array
  12596. * @param {...Array} [arrays] The arrays to inspect.
  12597. * @returns {Array} Returns the new array of combined values.
  12598. * @example
  12599. *
  12600. * _.union([2], [1, 2]);
  12601. * // => [2, 1]
  12602. */
  12603. var union = baseRest(function(arrays) {
  12604. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  12605. });
  12606. /**
  12607. * This method is like `_.union` except that it accepts `iteratee` which is
  12608. * invoked for each element of each `arrays` to generate the criterion by
  12609. * which uniqueness is computed. Result values are chosen from the first
  12610. * array in which the value occurs. The iteratee is invoked with one argument:
  12611. * (value).
  12612. *
  12613. * @static
  12614. * @memberOf _
  12615. * @since 4.0.0
  12616. * @category Array
  12617. * @param {...Array} [arrays] The arrays to inspect.
  12618. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  12619. * @returns {Array} Returns the new array of combined values.
  12620. * @example
  12621. *
  12622. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  12623. * // => [2.1, 1.2]
  12624. *
  12625. * // The `_.property` iteratee shorthand.
  12626. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  12627. * // => [{ 'x': 1 }, { 'x': 2 }]
  12628. */
  12629. var unionBy = baseRest(function(arrays) {
  12630. var iteratee = last(arrays);
  12631. if (isArrayLikeObject(iteratee)) {
  12632. iteratee = undefined;
  12633. }
  12634. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  12635. });
  12636. /**
  12637. * This method is like `_.union` except that it accepts `comparator` which
  12638. * is invoked to compare elements of `arrays`. Result values are chosen from
  12639. * the first array in which the value occurs. The comparator is invoked
  12640. * with two arguments: (arrVal, othVal).
  12641. *
  12642. * @static
  12643. * @memberOf _
  12644. * @since 4.0.0
  12645. * @category Array
  12646. * @param {...Array} [arrays] The arrays to inspect.
  12647. * @param {Function} [comparator] The comparator invoked per element.
  12648. * @returns {Array} Returns the new array of combined values.
  12649. * @example
  12650. *
  12651. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  12652. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  12653. *
  12654. * _.unionWith(objects, others, _.isEqual);
  12655. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  12656. */
  12657. var unionWith = baseRest(function(arrays) {
  12658. var comparator = last(arrays);
  12659. comparator = typeof comparator == 'function' ? comparator : undefined;
  12660. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  12661. });
  12662. /**
  12663. * Creates a duplicate-free version of an array, using
  12664. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  12665. * for equality comparisons, in which only the first occurrence of each element
  12666. * is kept. The order of result values is determined by the order they occur
  12667. * in the array.
  12668. *
  12669. * @static
  12670. * @memberOf _
  12671. * @since 0.1.0
  12672. * @category Array
  12673. * @param {Array} array The array to inspect.
  12674. * @returns {Array} Returns the new duplicate free array.
  12675. * @example
  12676. *
  12677. * _.uniq([2, 1, 2]);
  12678. * // => [2, 1]
  12679. */
  12680. function uniq(array) {
  12681. return (array && array.length) ? baseUniq(array) : [];
  12682. }
  12683. /**
  12684. * This method is like `_.uniq` except that it accepts `iteratee` which is
  12685. * invoked for each element in `array` to generate the criterion by which
  12686. * uniqueness is computed. The order of result values is determined by the
  12687. * order they occur in the array. The iteratee is invoked with one argument:
  12688. * (value).
  12689. *
  12690. * @static
  12691. * @memberOf _
  12692. * @since 4.0.0
  12693. * @category Array
  12694. * @param {Array} array The array to inspect.
  12695. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  12696. * @returns {Array} Returns the new duplicate free array.
  12697. * @example
  12698. *
  12699. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  12700. * // => [2.1, 1.2]
  12701. *
  12702. * // The `_.property` iteratee shorthand.
  12703. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  12704. * // => [{ 'x': 1 }, { 'x': 2 }]
  12705. */
  12706. function uniqBy(array, iteratee) {
  12707. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  12708. }
  12709. /**
  12710. * This method is like `_.uniq` except that it accepts `comparator` which
  12711. * is invoked to compare elements of `array`. The order of result values is
  12712. * determined by the order they occur in the array.The comparator is invoked
  12713. * with two arguments: (arrVal, othVal).
  12714. *
  12715. * @static
  12716. * @memberOf _
  12717. * @since 4.0.0
  12718. * @category Array
  12719. * @param {Array} array The array to inspect.
  12720. * @param {Function} [comparator] The comparator invoked per element.
  12721. * @returns {Array} Returns the new duplicate free array.
  12722. * @example
  12723. *
  12724. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  12725. *
  12726. * _.uniqWith(objects, _.isEqual);
  12727. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  12728. */
  12729. function uniqWith(array, comparator) {
  12730. comparator = typeof comparator == 'function' ? comparator : undefined;
  12731. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  12732. }
  12733. /**
  12734. * This method is like `_.zip` except that it accepts an array of grouped
  12735. * elements and creates an array regrouping the elements to their pre-zip
  12736. * configuration.
  12737. *
  12738. * @static
  12739. * @memberOf _
  12740. * @since 1.2.0
  12741. * @category Array
  12742. * @param {Array} array The array of grouped elements to process.
  12743. * @returns {Array} Returns the new array of regrouped elements.
  12744. * @example
  12745. *
  12746. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  12747. * // => [['a', 1, true], ['b', 2, false]]
  12748. *
  12749. * _.unzip(zipped);
  12750. * // => [['a', 'b'], [1, 2], [true, false]]
  12751. */
  12752. function unzip(array) {
  12753. if (!(array && array.length)) {
  12754. return [];
  12755. }
  12756. var length = 0;
  12757. array = arrayFilter(array, function(group) {
  12758. if (isArrayLikeObject(group)) {
  12759. length = nativeMax(group.length, length);
  12760. return true;
  12761. }
  12762. });
  12763. return baseTimes(length, function(index) {
  12764. return arrayMap(array, baseProperty(index));
  12765. });
  12766. }
  12767. /**
  12768. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  12769. * how regrouped values should be combined. The iteratee is invoked with the
  12770. * elements of each group: (...group).
  12771. *
  12772. * @static
  12773. * @memberOf _
  12774. * @since 3.8.0
  12775. * @category Array
  12776. * @param {Array} array The array of grouped elements to process.
  12777. * @param {Function} [iteratee=_.identity] The function to combine
  12778. * regrouped values.
  12779. * @returns {Array} Returns the new array of regrouped elements.
  12780. * @example
  12781. *
  12782. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  12783. * // => [[1, 10, 100], [2, 20, 200]]
  12784. *
  12785. * _.unzipWith(zipped, _.add);
  12786. * // => [3, 30, 300]
  12787. */
  12788. function unzipWith(array, iteratee) {
  12789. if (!(array && array.length)) {
  12790. return [];
  12791. }
  12792. var result = unzip(array);
  12793. if (iteratee == null) {
  12794. return result;
  12795. }
  12796. return arrayMap(result, function(group) {
  12797. return apply(iteratee, undefined, group);
  12798. });
  12799. }
  12800. /**
  12801. * Creates an array excluding all given values using
  12802. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  12803. * for equality comparisons.
  12804. *
  12805. * **Note:** Unlike `_.pull`, this method returns a new array.
  12806. *
  12807. * @static
  12808. * @memberOf _
  12809. * @since 0.1.0
  12810. * @category Array
  12811. * @param {Array} array The array to inspect.
  12812. * @param {...*} [values] The values to exclude.
  12813. * @returns {Array} Returns the new array of filtered values.
  12814. * @see _.difference, _.xor
  12815. * @example
  12816. *
  12817. * _.without([2, 1, 2, 3], 1, 2);
  12818. * // => [3]
  12819. */
  12820. var without = baseRest(function(array, values) {
  12821. return isArrayLikeObject(array)
  12822. ? baseDifference(array, values)
  12823. : [];
  12824. });
  12825. /**
  12826. * Creates an array of unique values that is the
  12827. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  12828. * of the given arrays. The order of result values is determined by the order
  12829. * they occur in the arrays.
  12830. *
  12831. * @static
  12832. * @memberOf _
  12833. * @since 2.4.0
  12834. * @category Array
  12835. * @param {...Array} [arrays] The arrays to inspect.
  12836. * @returns {Array} Returns the new array of filtered values.
  12837. * @see _.difference, _.without
  12838. * @example
  12839. *
  12840. * _.xor([2, 1], [2, 3]);
  12841. * // => [1, 3]
  12842. */
  12843. var xor = baseRest(function(arrays) {
  12844. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  12845. });
  12846. /**
  12847. * This method is like `_.xor` except that it accepts `iteratee` which is
  12848. * invoked for each element of each `arrays` to generate the criterion by
  12849. * which by which they're compared. The order of result values is determined
  12850. * by the order they occur in the arrays. The iteratee is invoked with one
  12851. * argument: (value).
  12852. *
  12853. * @static
  12854. * @memberOf _
  12855. * @since 4.0.0
  12856. * @category Array
  12857. * @param {...Array} [arrays] The arrays to inspect.
  12858. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  12859. * @returns {Array} Returns the new array of filtered values.
  12860. * @example
  12861. *
  12862. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  12863. * // => [1.2, 3.4]
  12864. *
  12865. * // The `_.property` iteratee shorthand.
  12866. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  12867. * // => [{ 'x': 2 }]
  12868. */
  12869. var xorBy = baseRest(function(arrays) {
  12870. var iteratee = last(arrays);
  12871. if (isArrayLikeObject(iteratee)) {
  12872. iteratee = undefined;
  12873. }
  12874. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  12875. });
  12876. /**
  12877. * This method is like `_.xor` except that it accepts `comparator` which is
  12878. * invoked to compare elements of `arrays`. The order of result values is
  12879. * determined by the order they occur in the arrays. The comparator is invoked
  12880. * with two arguments: (arrVal, othVal).
  12881. *
  12882. * @static
  12883. * @memberOf _
  12884. * @since 4.0.0
  12885. * @category Array
  12886. * @param {...Array} [arrays] The arrays to inspect.
  12887. * @param {Function} [comparator] The comparator invoked per element.
  12888. * @returns {Array} Returns the new array of filtered values.
  12889. * @example
  12890. *
  12891. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  12892. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  12893. *
  12894. * _.xorWith(objects, others, _.isEqual);
  12895. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  12896. */
  12897. var xorWith = baseRest(function(arrays) {
  12898. var comparator = last(arrays);
  12899. comparator = typeof comparator == 'function' ? comparator : undefined;
  12900. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  12901. });
  12902. /**
  12903. * Creates an array of grouped elements, the first of which contains the
  12904. * first elements of the given arrays, the second of which contains the
  12905. * second elements of the given arrays, and so on.
  12906. *
  12907. * @static
  12908. * @memberOf _
  12909. * @since 0.1.0
  12910. * @category Array
  12911. * @param {...Array} [arrays] The arrays to process.
  12912. * @returns {Array} Returns the new array of grouped elements.
  12913. * @example
  12914. *
  12915. * _.zip(['a', 'b'], [1, 2], [true, false]);
  12916. * // => [['a', 1, true], ['b', 2, false]]
  12917. */
  12918. var zip = baseRest(unzip);
  12919. /**
  12920. * This method is like `_.fromPairs` except that it accepts two arrays,
  12921. * one of property identifiers and one of corresponding values.
  12922. *
  12923. * @static
  12924. * @memberOf _
  12925. * @since 0.4.0
  12926. * @category Array
  12927. * @param {Array} [props=[]] The property identifiers.
  12928. * @param {Array} [values=[]] The property values.
  12929. * @returns {Object} Returns the new object.
  12930. * @example
  12931. *
  12932. * _.zipObject(['a', 'b'], [1, 2]);
  12933. * // => { 'a': 1, 'b': 2 }
  12934. */
  12935. function zipObject(props, values) {
  12936. return baseZipObject(props || [], values || [], assignValue);
  12937. }
  12938. /**
  12939. * This method is like `_.zipObject` except that it supports property paths.
  12940. *
  12941. * @static
  12942. * @memberOf _
  12943. * @since 4.1.0
  12944. * @category Array
  12945. * @param {Array} [props=[]] The property identifiers.
  12946. * @param {Array} [values=[]] The property values.
  12947. * @returns {Object} Returns the new object.
  12948. * @example
  12949. *
  12950. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  12951. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  12952. */
  12953. function zipObjectDeep(props, values) {
  12954. return baseZipObject(props || [], values || [], baseSet);
  12955. }
  12956. /**
  12957. * This method is like `_.zip` except that it accepts `iteratee` to specify
  12958. * how grouped values should be combined. The iteratee is invoked with the
  12959. * elements of each group: (...group).
  12960. *
  12961. * @static
  12962. * @memberOf _
  12963. * @since 3.8.0
  12964. * @category Array
  12965. * @param {...Array} [arrays] The arrays to process.
  12966. * @param {Function} [iteratee=_.identity] The function to combine
  12967. * grouped values.
  12968. * @returns {Array} Returns the new array of grouped elements.
  12969. * @example
  12970. *
  12971. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  12972. * return a + b + c;
  12973. * });
  12974. * // => [111, 222]
  12975. */
  12976. var zipWith = baseRest(function(arrays) {
  12977. var length = arrays.length,
  12978. iteratee = length > 1 ? arrays[length - 1] : undefined;
  12979. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  12980. return unzipWith(arrays, iteratee);
  12981. });
  12982. /*------------------------------------------------------------------------*/
  12983. /**
  12984. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  12985. * chain sequences enabled. The result of such sequences must be unwrapped
  12986. * with `_#value`.
  12987. *
  12988. * @static
  12989. * @memberOf _
  12990. * @since 1.3.0
  12991. * @category Seq
  12992. * @param {*} value The value to wrap.
  12993. * @returns {Object} Returns the new `lodash` wrapper instance.
  12994. * @example
  12995. *
  12996. * var users = [
  12997. * { 'user': 'barney', 'age': 36 },
  12998. * { 'user': 'fred', 'age': 40 },
  12999. * { 'user': 'pebbles', 'age': 1 }
  13000. * ];
  13001. *
  13002. * var youngest = _
  13003. * .chain(users)
  13004. * .sortBy('age')
  13005. * .map(function(o) {
  13006. * return o.user + ' is ' + o.age;
  13007. * })
  13008. * .head()
  13009. * .value();
  13010. * // => 'pebbles is 1'
  13011. */
  13012. function chain(value) {
  13013. var result = lodash(value);
  13014. result.__chain__ = true;
  13015. return result;
  13016. }
  13017. /**
  13018. * This method invokes `interceptor` and returns `value`. The interceptor
  13019. * is invoked with one argument; (value). The purpose of this method is to
  13020. * "tap into" a method chain sequence in order to modify intermediate results.
  13021. *
  13022. * @static
  13023. * @memberOf _
  13024. * @since 0.1.0
  13025. * @category Seq
  13026. * @param {*} value The value to provide to `interceptor`.
  13027. * @param {Function} interceptor The function to invoke.
  13028. * @returns {*} Returns `value`.
  13029. * @example
  13030. *
  13031. * _([1, 2, 3])
  13032. * .tap(function(array) {
  13033. * // Mutate input array.
  13034. * array.pop();
  13035. * })
  13036. * .reverse()
  13037. * .value();
  13038. * // => [2, 1]
  13039. */
  13040. function tap(value, interceptor) {
  13041. interceptor(value);
  13042. return value;
  13043. }
  13044. /**
  13045. * This method is like `_.tap` except that it returns the result of `interceptor`.
  13046. * The purpose of this method is to "pass thru" values replacing intermediate
  13047. * results in a method chain sequence.
  13048. *
  13049. * @static
  13050. * @memberOf _
  13051. * @since 3.0.0
  13052. * @category Seq
  13053. * @param {*} value The value to provide to `interceptor`.
  13054. * @param {Function} interceptor The function to invoke.
  13055. * @returns {*} Returns the result of `interceptor`.
  13056. * @example
  13057. *
  13058. * _(' abc ')
  13059. * .chain()
  13060. * .trim()
  13061. * .thru(function(value) {
  13062. * return [value];
  13063. * })
  13064. * .value();
  13065. * // => ['abc']
  13066. */
  13067. function thru(value, interceptor) {
  13068. return interceptor(value);
  13069. }
  13070. /**
  13071. * This method is the wrapper version of `_.at`.
  13072. *
  13073. * @name at
  13074. * @memberOf _
  13075. * @since 1.0.0
  13076. * @category Seq
  13077. * @param {...(string|string[])} [paths] The property paths to pick.
  13078. * @returns {Object} Returns the new `lodash` wrapper instance.
  13079. * @example
  13080. *
  13081. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  13082. *
  13083. * _(object).at(['a[0].b.c', 'a[1]']).value();
  13084. * // => [3, 4]
  13085. */
  13086. var wrapperAt = flatRest(function(paths) {
  13087. var length = paths.length,
  13088. start = length ? paths[0] : 0,
  13089. value = this.__wrapped__,
  13090. interceptor = function(object) { return baseAt(object, paths); };
  13091. if (length > 1 || this.__actions__.length ||
  13092. !(value instanceof LazyWrapper) || !isIndex(start)) {
  13093. return this.thru(interceptor);
  13094. }
  13095. value = value.slice(start, +start + (length ? 1 : 0));
  13096. value.__actions__.push({
  13097. 'func': thru,
  13098. 'args': [interceptor],
  13099. 'thisArg': undefined
  13100. });
  13101. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  13102. if (length && !array.length) {
  13103. array.push(undefined);
  13104. }
  13105. return array;
  13106. });
  13107. });
  13108. /**
  13109. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  13110. *
  13111. * @name chain
  13112. * @memberOf _
  13113. * @since 0.1.0
  13114. * @category Seq
  13115. * @returns {Object} Returns the new `lodash` wrapper instance.
  13116. * @example
  13117. *
  13118. * var users = [
  13119. * { 'user': 'barney', 'age': 36 },
  13120. * { 'user': 'fred', 'age': 40 }
  13121. * ];
  13122. *
  13123. * // A sequence without explicit chaining.
  13124. * _(users).head();
  13125. * // => { 'user': 'barney', 'age': 36 }
  13126. *
  13127. * // A sequence with explicit chaining.
  13128. * _(users)
  13129. * .chain()
  13130. * .head()
  13131. * .pick('user')
  13132. * .value();
  13133. * // => { 'user': 'barney' }
  13134. */
  13135. function wrapperChain() {
  13136. return chain(this);
  13137. }
  13138. /**
  13139. * Executes the chain sequence and returns the wrapped result.
  13140. *
  13141. * @name commit
  13142. * @memberOf _
  13143. * @since 3.2.0
  13144. * @category Seq
  13145. * @returns {Object} Returns the new `lodash` wrapper instance.
  13146. * @example
  13147. *
  13148. * var array = [1, 2];
  13149. * var wrapped = _(array).push(3);
  13150. *
  13151. * console.log(array);
  13152. * // => [1, 2]
  13153. *
  13154. * wrapped = wrapped.commit();
  13155. * console.log(array);
  13156. * // => [1, 2, 3]
  13157. *
  13158. * wrapped.last();
  13159. * // => 3
  13160. *
  13161. * console.log(array);
  13162. * // => [1, 2, 3]
  13163. */
  13164. function wrapperCommit() {
  13165. return new LodashWrapper(this.value(), this.__chain__);
  13166. }
  13167. /**
  13168. * Gets the next value on a wrapped object following the
  13169. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  13170. *
  13171. * @name next
  13172. * @memberOf _
  13173. * @since 4.0.0
  13174. * @category Seq
  13175. * @returns {Object} Returns the next iterator value.
  13176. * @example
  13177. *
  13178. * var wrapped = _([1, 2]);
  13179. *
  13180. * wrapped.next();
  13181. * // => { 'done': false, 'value': 1 }
  13182. *
  13183. * wrapped.next();
  13184. * // => { 'done': false, 'value': 2 }
  13185. *
  13186. * wrapped.next();
  13187. * // => { 'done': true, 'value': undefined }
  13188. */
  13189. function wrapperNext() {
  13190. if (this.__values__ === undefined) {
  13191. this.__values__ = toArray(this.value());
  13192. }
  13193. var done = this.__index__ >= this.__values__.length,
  13194. value = done ? undefined : this.__values__[this.__index__++];
  13195. return { 'done': done, 'value': value };
  13196. }
  13197. /**
  13198. * Enables the wrapper to be iterable.
  13199. *
  13200. * @name Symbol.iterator
  13201. * @memberOf _
  13202. * @since 4.0.0
  13203. * @category Seq
  13204. * @returns {Object} Returns the wrapper object.
  13205. * @example
  13206. *
  13207. * var wrapped = _([1, 2]);
  13208. *
  13209. * wrapped[Symbol.iterator]() === wrapped;
  13210. * // => true
  13211. *
  13212. * Array.from(wrapped);
  13213. * // => [1, 2]
  13214. */
  13215. function wrapperToIterator() {
  13216. return this;
  13217. }
  13218. /**
  13219. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  13220. *
  13221. * @name plant
  13222. * @memberOf _
  13223. * @since 3.2.0
  13224. * @category Seq
  13225. * @param {*} value The value to plant.
  13226. * @returns {Object} Returns the new `lodash` wrapper instance.
  13227. * @example
  13228. *
  13229. * function square(n) {
  13230. * return n * n;
  13231. * }
  13232. *
  13233. * var wrapped = _([1, 2]).map(square);
  13234. * var other = wrapped.plant([3, 4]);
  13235. *
  13236. * other.value();
  13237. * // => [9, 16]
  13238. *
  13239. * wrapped.value();
  13240. * // => [1, 4]
  13241. */
  13242. function wrapperPlant(value) {
  13243. var result,
  13244. parent = this;
  13245. while (parent instanceof baseLodash) {
  13246. var clone = wrapperClone(parent);
  13247. clone.__index__ = 0;
  13248. clone.__values__ = undefined;
  13249. if (result) {
  13250. previous.__wrapped__ = clone;
  13251. } else {
  13252. result = clone;
  13253. }
  13254. var previous = clone;
  13255. parent = parent.__wrapped__;
  13256. }
  13257. previous.__wrapped__ = value;
  13258. return result;
  13259. }
  13260. /**
  13261. * This method is the wrapper version of `_.reverse`.
  13262. *
  13263. * **Note:** This method mutates the wrapped array.
  13264. *
  13265. * @name reverse
  13266. * @memberOf _
  13267. * @since 0.1.0
  13268. * @category Seq
  13269. * @returns {Object} Returns the new `lodash` wrapper instance.
  13270. * @example
  13271. *
  13272. * var array = [1, 2, 3];
  13273. *
  13274. * _(array).reverse().value()
  13275. * // => [3, 2, 1]
  13276. *
  13277. * console.log(array);
  13278. * // => [3, 2, 1]
  13279. */
  13280. function wrapperReverse() {
  13281. var value = this.__wrapped__;
  13282. if (value instanceof LazyWrapper) {
  13283. var wrapped = value;
  13284. if (this.__actions__.length) {
  13285. wrapped = new LazyWrapper(this);
  13286. }
  13287. wrapped = wrapped.reverse();
  13288. wrapped.__actions__.push({
  13289. 'func': thru,
  13290. 'args': [reverse],
  13291. 'thisArg': undefined
  13292. });
  13293. return new LodashWrapper(wrapped, this.__chain__);
  13294. }
  13295. return this.thru(reverse);
  13296. }
  13297. /**
  13298. * Executes the chain sequence to resolve the unwrapped value.
  13299. *
  13300. * @name value
  13301. * @memberOf _
  13302. * @since 0.1.0
  13303. * @alias toJSON, valueOf
  13304. * @category Seq
  13305. * @returns {*} Returns the resolved unwrapped value.
  13306. * @example
  13307. *
  13308. * _([1, 2, 3]).value();
  13309. * // => [1, 2, 3]
  13310. */
  13311. function wrapperValue() {
  13312. return baseWrapperValue(this.__wrapped__, this.__actions__);
  13313. }
  13314. /*------------------------------------------------------------------------*/
  13315. /**
  13316. * Creates an object composed of keys generated from the results of running
  13317. * each element of `collection` thru `iteratee`. The corresponding value of
  13318. * each key is the number of times the key was returned by `iteratee`. The
  13319. * iteratee is invoked with one argument: (value).
  13320. *
  13321. * @static
  13322. * @memberOf _
  13323. * @since 0.5.0
  13324. * @category Collection
  13325. * @param {Array|Object} collection The collection to iterate over.
  13326. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  13327. * @returns {Object} Returns the composed aggregate object.
  13328. * @example
  13329. *
  13330. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  13331. * // => { '4': 1, '6': 2 }
  13332. *
  13333. * // The `_.property` iteratee shorthand.
  13334. * _.countBy(['one', 'two', 'three'], 'length');
  13335. * // => { '3': 2, '5': 1 }
  13336. */
  13337. var countBy = createAggregator(function(result, value, key) {
  13338. if (hasOwnProperty.call(result, key)) {
  13339. ++result[key];
  13340. } else {
  13341. baseAssignValue(result, key, 1);
  13342. }
  13343. });
  13344. /**
  13345. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  13346. * Iteration is stopped once `predicate` returns falsey. The predicate is
  13347. * invoked with three arguments: (value, index|key, collection).
  13348. *
  13349. * **Note:** This method returns `true` for
  13350. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  13351. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  13352. * elements of empty collections.
  13353. *
  13354. * @static
  13355. * @memberOf _
  13356. * @since 0.1.0
  13357. * @category Collection
  13358. * @param {Array|Object} collection The collection to iterate over.
  13359. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  13360. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  13361. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  13362. * else `false`.
  13363. * @example
  13364. *
  13365. * _.every([true, 1, null, 'yes'], Boolean);
  13366. * // => false
  13367. *
  13368. * var users = [
  13369. * { 'user': 'barney', 'age': 36, 'active': false },
  13370. * { 'user': 'fred', 'age': 40, 'active': false }
  13371. * ];
  13372. *
  13373. * // The `_.matches` iteratee shorthand.
  13374. * _.every(users, { 'user': 'barney', 'active': false });
  13375. * // => false
  13376. *
  13377. * // The `_.matchesProperty` iteratee shorthand.
  13378. * _.every(users, ['active', false]);
  13379. * // => true
  13380. *
  13381. * // The `_.property` iteratee shorthand.
  13382. * _.every(users, 'active');
  13383. * // => false
  13384. */
  13385. function every(collection, predicate, guard) {
  13386. var func = isArray(collection) ? arrayEvery : baseEvery;
  13387. if (guard && isIterateeCall(collection, predicate, guard)) {
  13388. predicate = undefined;
  13389. }
  13390. return func(collection, getIteratee(predicate, 3));
  13391. }
  13392. /**
  13393. * Iterates over elements of `collection`, returning an array of all elements
  13394. * `predicate` returns truthy for. The predicate is invoked with three
  13395. * arguments: (value, index|key, collection).
  13396. *
  13397. * **Note:** Unlike `_.remove`, this method returns a new array.
  13398. *
  13399. * @static
  13400. * @memberOf _
  13401. * @since 0.1.0
  13402. * @category Collection
  13403. * @param {Array|Object} collection The collection to iterate over.
  13404. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  13405. * @returns {Array} Returns the new filtered array.
  13406. * @see _.reject
  13407. * @example
  13408. *
  13409. * var users = [
  13410. * { 'user': 'barney', 'age': 36, 'active': true },
  13411. * { 'user': 'fred', 'age': 40, 'active': false }
  13412. * ];
  13413. *
  13414. * _.filter(users, function(o) { return !o.active; });
  13415. * // => objects for ['fred']
  13416. *
  13417. * // The `_.matches` iteratee shorthand.
  13418. * _.filter(users, { 'age': 36, 'active': true });
  13419. * // => objects for ['barney']
  13420. *
  13421. * // The `_.matchesProperty` iteratee shorthand.
  13422. * _.filter(users, ['active', false]);
  13423. * // => objects for ['fred']
  13424. *
  13425. * // The `_.property` iteratee shorthand.
  13426. * _.filter(users, 'active');
  13427. * // => objects for ['barney']
  13428. *
  13429. * // Combining several predicates using `_.overEvery` or `_.overSome`.
  13430. * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]]));
  13431. * // => objects for ['fred', 'barney']
  13432. */
  13433. function filter(collection, predicate) {
  13434. var func = isArray(collection) ? arrayFilter : baseFilter;
  13435. return func(collection, getIteratee(predicate, 3));
  13436. }
  13437. /**
  13438. * Iterates over elements of `collection`, returning the first element
  13439. * `predicate` returns truthy for. The predicate is invoked with three
  13440. * arguments: (value, index|key, collection).
  13441. *
  13442. * @static
  13443. * @memberOf _
  13444. * @since 0.1.0
  13445. * @category Collection
  13446. * @param {Array|Object} collection The collection to inspect.
  13447. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  13448. * @param {number} [fromIndex=0] The index to search from.
  13449. * @returns {*} Returns the matched element, else `undefined`.
  13450. * @example
  13451. *
  13452. * var users = [
  13453. * { 'user': 'barney', 'age': 36, 'active': true },
  13454. * { 'user': 'fred', 'age': 40, 'active': false },
  13455. * { 'user': 'pebbles', 'age': 1, 'active': true }
  13456. * ];
  13457. *
  13458. * _.find(users, function(o) { return o.age < 40; });
  13459. * // => object for 'barney'
  13460. *
  13461. * // The `_.matches` iteratee shorthand.
  13462. * _.find(users, { 'age': 1, 'active': true });
  13463. * // => object for 'pebbles'
  13464. *
  13465. * // The `_.matchesProperty` iteratee shorthand.
  13466. * _.find(users, ['active', false]);
  13467. * // => object for 'fred'
  13468. *
  13469. * // The `_.property` iteratee shorthand.
  13470. * _.find(users, 'active');
  13471. * // => object for 'barney'
  13472. */
  13473. var find = createFind(findIndex);
  13474. /**
  13475. * This method is like `_.find` except that it iterates over elements of
  13476. * `collection` from right to left.
  13477. *
  13478. * @static
  13479. * @memberOf _
  13480. * @since 2.0.0
  13481. * @category Collection
  13482. * @param {Array|Object} collection The collection to inspect.
  13483. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  13484. * @param {number} [fromIndex=collection.length-1] The index to search from.
  13485. * @returns {*} Returns the matched element, else `undefined`.
  13486. * @example
  13487. *
  13488. * _.findLast([1, 2, 3, 4], function(n) {
  13489. * return n % 2 == 1;
  13490. * });
  13491. * // => 3
  13492. */
  13493. var findLast = createFind(findLastIndex);
  13494. /**
  13495. * Creates a flattened array of values by running each element in `collection`
  13496. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  13497. * with three arguments: (value, index|key, collection).
  13498. *
  13499. * @static
  13500. * @memberOf _
  13501. * @since 4.0.0
  13502. * @category Collection
  13503. * @param {Array|Object} collection The collection to iterate over.
  13504. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13505. * @returns {Array} Returns the new flattened array.
  13506. * @example
  13507. *
  13508. * function duplicate(n) {
  13509. * return [n, n];
  13510. * }
  13511. *
  13512. * _.flatMap([1, 2], duplicate);
  13513. * // => [1, 1, 2, 2]
  13514. */
  13515. function flatMap(collection, iteratee) {
  13516. return baseFlatten(map(collection, iteratee), 1);
  13517. }
  13518. /**
  13519. * This method is like `_.flatMap` except that it recursively flattens the
  13520. * mapped results.
  13521. *
  13522. * @static
  13523. * @memberOf _
  13524. * @since 4.7.0
  13525. * @category Collection
  13526. * @param {Array|Object} collection The collection to iterate over.
  13527. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13528. * @returns {Array} Returns the new flattened array.
  13529. * @example
  13530. *
  13531. * function duplicate(n) {
  13532. * return [[[n, n]]];
  13533. * }
  13534. *
  13535. * _.flatMapDeep([1, 2], duplicate);
  13536. * // => [1, 1, 2, 2]
  13537. */
  13538. function flatMapDeep(collection, iteratee) {
  13539. return baseFlatten(map(collection, iteratee), INFINITY);
  13540. }
  13541. /**
  13542. * This method is like `_.flatMap` except that it recursively flattens the
  13543. * mapped results up to `depth` times.
  13544. *
  13545. * @static
  13546. * @memberOf _
  13547. * @since 4.7.0
  13548. * @category Collection
  13549. * @param {Array|Object} collection The collection to iterate over.
  13550. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13551. * @param {number} [depth=1] The maximum recursion depth.
  13552. * @returns {Array} Returns the new flattened array.
  13553. * @example
  13554. *
  13555. * function duplicate(n) {
  13556. * return [[[n, n]]];
  13557. * }
  13558. *
  13559. * _.flatMapDepth([1, 2], duplicate, 2);
  13560. * // => [[1, 1], [2, 2]]
  13561. */
  13562. function flatMapDepth(collection, iteratee, depth) {
  13563. depth = depth === undefined ? 1 : toInteger(depth);
  13564. return baseFlatten(map(collection, iteratee), depth);
  13565. }
  13566. /**
  13567. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  13568. * The iteratee is invoked with three arguments: (value, index|key, collection).
  13569. * Iteratee functions may exit iteration early by explicitly returning `false`.
  13570. *
  13571. * **Note:** As with other "Collections" methods, objects with a "length"
  13572. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  13573. * or `_.forOwn` for object iteration.
  13574. *
  13575. * @static
  13576. * @memberOf _
  13577. * @since 0.1.0
  13578. * @alias each
  13579. * @category Collection
  13580. * @param {Array|Object} collection The collection to iterate over.
  13581. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13582. * @returns {Array|Object} Returns `collection`.
  13583. * @see _.forEachRight
  13584. * @example
  13585. *
  13586. * _.forEach([1, 2], function(value) {
  13587. * console.log(value);
  13588. * });
  13589. * // => Logs `1` then `2`.
  13590. *
  13591. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  13592. * console.log(key);
  13593. * });
  13594. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  13595. */
  13596. function forEach(collection, iteratee) {
  13597. var func = isArray(collection) ? arrayEach : baseEach;
  13598. return func(collection, getIteratee(iteratee, 3));
  13599. }
  13600. /**
  13601. * This method is like `_.forEach` except that it iterates over elements of
  13602. * `collection` from right to left.
  13603. *
  13604. * @static
  13605. * @memberOf _
  13606. * @since 2.0.0
  13607. * @alias eachRight
  13608. * @category Collection
  13609. * @param {Array|Object} collection The collection to iterate over.
  13610. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13611. * @returns {Array|Object} Returns `collection`.
  13612. * @see _.forEach
  13613. * @example
  13614. *
  13615. * _.forEachRight([1, 2], function(value) {
  13616. * console.log(value);
  13617. * });
  13618. * // => Logs `2` then `1`.
  13619. */
  13620. function forEachRight(collection, iteratee) {
  13621. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  13622. return func(collection, getIteratee(iteratee, 3));
  13623. }
  13624. /**
  13625. * Creates an object composed of keys generated from the results of running
  13626. * each element of `collection` thru `iteratee`. The order of grouped values
  13627. * is determined by the order they occur in `collection`. The corresponding
  13628. * value of each key is an array of elements responsible for generating the
  13629. * key. The iteratee is invoked with one argument: (value).
  13630. *
  13631. * @static
  13632. * @memberOf _
  13633. * @since 0.1.0
  13634. * @category Collection
  13635. * @param {Array|Object} collection The collection to iterate over.
  13636. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  13637. * @returns {Object} Returns the composed aggregate object.
  13638. * @example
  13639. *
  13640. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  13641. * // => { '4': [4.2], '6': [6.1, 6.3] }
  13642. *
  13643. * // The `_.property` iteratee shorthand.
  13644. * _.groupBy(['one', 'two', 'three'], 'length');
  13645. * // => { '3': ['one', 'two'], '5': ['three'] }
  13646. */
  13647. var groupBy = createAggregator(function(result, value, key) {
  13648. if (hasOwnProperty.call(result, key)) {
  13649. result[key].push(value);
  13650. } else {
  13651. baseAssignValue(result, key, [value]);
  13652. }
  13653. });
  13654. /**
  13655. * Checks if `value` is in `collection`. If `collection` is a string, it's
  13656. * checked for a substring of `value`, otherwise
  13657. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  13658. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  13659. * the offset from the end of `collection`.
  13660. *
  13661. * @static
  13662. * @memberOf _
  13663. * @since 0.1.0
  13664. * @category Collection
  13665. * @param {Array|Object|string} collection The collection to inspect.
  13666. * @param {*} value The value to search for.
  13667. * @param {number} [fromIndex=0] The index to search from.
  13668. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  13669. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  13670. * @example
  13671. *
  13672. * _.includes([1, 2, 3], 1);
  13673. * // => true
  13674. *
  13675. * _.includes([1, 2, 3], 1, 2);
  13676. * // => false
  13677. *
  13678. * _.includes({ 'a': 1, 'b': 2 }, 1);
  13679. * // => true
  13680. *
  13681. * _.includes('abcd', 'bc');
  13682. * // => true
  13683. */
  13684. function includes(collection, value, fromIndex, guard) {
  13685. collection = isArrayLike(collection) ? collection : values(collection);
  13686. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  13687. var length = collection.length;
  13688. if (fromIndex < 0) {
  13689. fromIndex = nativeMax(length + fromIndex, 0);
  13690. }
  13691. return isString(collection)
  13692. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  13693. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  13694. }
  13695. /**
  13696. * Invokes the method at `path` of each element in `collection`, returning
  13697. * an array of the results of each invoked method. Any additional arguments
  13698. * are provided to each invoked method. If `path` is a function, it's invoked
  13699. * for, and `this` bound to, each element in `collection`.
  13700. *
  13701. * @static
  13702. * @memberOf _
  13703. * @since 4.0.0
  13704. * @category Collection
  13705. * @param {Array|Object} collection The collection to iterate over.
  13706. * @param {Array|Function|string} path The path of the method to invoke or
  13707. * the function invoked per iteration.
  13708. * @param {...*} [args] The arguments to invoke each method with.
  13709. * @returns {Array} Returns the array of results.
  13710. * @example
  13711. *
  13712. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  13713. * // => [[1, 5, 7], [1, 2, 3]]
  13714. *
  13715. * _.invokeMap([123, 456], String.prototype.split, '');
  13716. * // => [['1', '2', '3'], ['4', '5', '6']]
  13717. */
  13718. var invokeMap = baseRest(function(collection, path, args) {
  13719. var index = -1,
  13720. isFunc = typeof path == 'function',
  13721. result = isArrayLike(collection) ? Array(collection.length) : [];
  13722. baseEach(collection, function(value) {
  13723. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  13724. });
  13725. return result;
  13726. });
  13727. /**
  13728. * Creates an object composed of keys generated from the results of running
  13729. * each element of `collection` thru `iteratee`. The corresponding value of
  13730. * each key is the last element responsible for generating the key. The
  13731. * iteratee is invoked with one argument: (value).
  13732. *
  13733. * @static
  13734. * @memberOf _
  13735. * @since 4.0.0
  13736. * @category Collection
  13737. * @param {Array|Object} collection The collection to iterate over.
  13738. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  13739. * @returns {Object} Returns the composed aggregate object.
  13740. * @example
  13741. *
  13742. * var array = [
  13743. * { 'dir': 'left', 'code': 97 },
  13744. * { 'dir': 'right', 'code': 100 }
  13745. * ];
  13746. *
  13747. * _.keyBy(array, function(o) {
  13748. * return String.fromCharCode(o.code);
  13749. * });
  13750. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  13751. *
  13752. * _.keyBy(array, 'dir');
  13753. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  13754. */
  13755. var keyBy = createAggregator(function(result, value, key) {
  13756. baseAssignValue(result, key, value);
  13757. });
  13758. /**
  13759. * Creates an array of values by running each element in `collection` thru
  13760. * `iteratee`. The iteratee is invoked with three arguments:
  13761. * (value, index|key, collection).
  13762. *
  13763. * Many lodash methods are guarded to work as iteratees for methods like
  13764. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  13765. *
  13766. * The guarded methods are:
  13767. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  13768. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  13769. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  13770. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  13771. *
  13772. * @static
  13773. * @memberOf _
  13774. * @since 0.1.0
  13775. * @category Collection
  13776. * @param {Array|Object} collection The collection to iterate over.
  13777. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13778. * @returns {Array} Returns the new mapped array.
  13779. * @example
  13780. *
  13781. * function square(n) {
  13782. * return n * n;
  13783. * }
  13784. *
  13785. * _.map([4, 8], square);
  13786. * // => [16, 64]
  13787. *
  13788. * _.map({ 'a': 4, 'b': 8 }, square);
  13789. * // => [16, 64] (iteration order is not guaranteed)
  13790. *
  13791. * var users = [
  13792. * { 'user': 'barney' },
  13793. * { 'user': 'fred' }
  13794. * ];
  13795. *
  13796. * // The `_.property` iteratee shorthand.
  13797. * _.map(users, 'user');
  13798. * // => ['barney', 'fred']
  13799. */
  13800. function map(collection, iteratee) {
  13801. var func = isArray(collection) ? arrayMap : baseMap;
  13802. return func(collection, getIteratee(iteratee, 3));
  13803. }
  13804. /**
  13805. * This method is like `_.sortBy` except that it allows specifying the sort
  13806. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  13807. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  13808. * descending or "asc" for ascending sort order of corresponding values.
  13809. *
  13810. * @static
  13811. * @memberOf _
  13812. * @since 4.0.0
  13813. * @category Collection
  13814. * @param {Array|Object} collection The collection to iterate over.
  13815. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  13816. * The iteratees to sort by.
  13817. * @param {string[]} [orders] The sort orders of `iteratees`.
  13818. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  13819. * @returns {Array} Returns the new sorted array.
  13820. * @example
  13821. *
  13822. * var users = [
  13823. * { 'user': 'fred', 'age': 48 },
  13824. * { 'user': 'barney', 'age': 34 },
  13825. * { 'user': 'fred', 'age': 40 },
  13826. * { 'user': 'barney', 'age': 36 }
  13827. * ];
  13828. *
  13829. * // Sort by `user` in ascending order and by `age` in descending order.
  13830. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  13831. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  13832. */
  13833. function orderBy(collection, iteratees, orders, guard) {
  13834. if (collection == null) {
  13835. return [];
  13836. }
  13837. if (!isArray(iteratees)) {
  13838. iteratees = iteratees == null ? [] : [iteratees];
  13839. }
  13840. orders = guard ? undefined : orders;
  13841. if (!isArray(orders)) {
  13842. orders = orders == null ? [] : [orders];
  13843. }
  13844. return baseOrderBy(collection, iteratees, orders);
  13845. }
  13846. /**
  13847. * Creates an array of elements split into two groups, the first of which
  13848. * contains elements `predicate` returns truthy for, the second of which
  13849. * contains elements `predicate` returns falsey for. The predicate is
  13850. * invoked with one argument: (value).
  13851. *
  13852. * @static
  13853. * @memberOf _
  13854. * @since 3.0.0
  13855. * @category Collection
  13856. * @param {Array|Object} collection The collection to iterate over.
  13857. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  13858. * @returns {Array} Returns the array of grouped elements.
  13859. * @example
  13860. *
  13861. * var users = [
  13862. * { 'user': 'barney', 'age': 36, 'active': false },
  13863. * { 'user': 'fred', 'age': 40, 'active': true },
  13864. * { 'user': 'pebbles', 'age': 1, 'active': false }
  13865. * ];
  13866. *
  13867. * _.partition(users, function(o) { return o.active; });
  13868. * // => objects for [['fred'], ['barney', 'pebbles']]
  13869. *
  13870. * // The `_.matches` iteratee shorthand.
  13871. * _.partition(users, { 'age': 1, 'active': false });
  13872. * // => objects for [['pebbles'], ['barney', 'fred']]
  13873. *
  13874. * // The `_.matchesProperty` iteratee shorthand.
  13875. * _.partition(users, ['active', false]);
  13876. * // => objects for [['barney', 'pebbles'], ['fred']]
  13877. *
  13878. * // The `_.property` iteratee shorthand.
  13879. * _.partition(users, 'active');
  13880. * // => objects for [['fred'], ['barney', 'pebbles']]
  13881. */
  13882. var partition = createAggregator(function(result, value, key) {
  13883. result[key ? 0 : 1].push(value);
  13884. }, function() { return [[], []]; });
  13885. /**
  13886. * Reduces `collection` to a value which is the accumulated result of running
  13887. * each element in `collection` thru `iteratee`, where each successive
  13888. * invocation is supplied the return value of the previous. If `accumulator`
  13889. * is not given, the first element of `collection` is used as the initial
  13890. * value. The iteratee is invoked with four arguments:
  13891. * (accumulator, value, index|key, collection).
  13892. *
  13893. * Many lodash methods are guarded to work as iteratees for methods like
  13894. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  13895. *
  13896. * The guarded methods are:
  13897. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  13898. * and `sortBy`
  13899. *
  13900. * @static
  13901. * @memberOf _
  13902. * @since 0.1.0
  13903. * @category Collection
  13904. * @param {Array|Object} collection The collection to iterate over.
  13905. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13906. * @param {*} [accumulator] The initial value.
  13907. * @returns {*} Returns the accumulated value.
  13908. * @see _.reduceRight
  13909. * @example
  13910. *
  13911. * _.reduce([1, 2], function(sum, n) {
  13912. * return sum + n;
  13913. * }, 0);
  13914. * // => 3
  13915. *
  13916. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  13917. * (result[value] || (result[value] = [])).push(key);
  13918. * return result;
  13919. * }, {});
  13920. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  13921. */
  13922. function reduce(collection, iteratee, accumulator) {
  13923. var func = isArray(collection) ? arrayReduce : baseReduce,
  13924. initAccum = arguments.length < 3;
  13925. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  13926. }
  13927. /**
  13928. * This method is like `_.reduce` except that it iterates over elements of
  13929. * `collection` from right to left.
  13930. *
  13931. * @static
  13932. * @memberOf _
  13933. * @since 0.1.0
  13934. * @category Collection
  13935. * @param {Array|Object} collection The collection to iterate over.
  13936. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13937. * @param {*} [accumulator] The initial value.
  13938. * @returns {*} Returns the accumulated value.
  13939. * @see _.reduce
  13940. * @example
  13941. *
  13942. * var array = [[0, 1], [2, 3], [4, 5]];
  13943. *
  13944. * _.reduceRight(array, function(flattened, other) {
  13945. * return flattened.concat(other);
  13946. * }, []);
  13947. * // => [4, 5, 2, 3, 0, 1]
  13948. */
  13949. function reduceRight(collection, iteratee, accumulator) {
  13950. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  13951. initAccum = arguments.length < 3;
  13952. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  13953. }
  13954. /**
  13955. * The opposite of `_.filter`; this method returns the elements of `collection`
  13956. * that `predicate` does **not** return truthy for.
  13957. *
  13958. * @static
  13959. * @memberOf _
  13960. * @since 0.1.0
  13961. * @category Collection
  13962. * @param {Array|Object} collection The collection to iterate over.
  13963. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  13964. * @returns {Array} Returns the new filtered array.
  13965. * @see _.filter
  13966. * @example
  13967. *
  13968. * var users = [
  13969. * { 'user': 'barney', 'age': 36, 'active': false },
  13970. * { 'user': 'fred', 'age': 40, 'active': true }
  13971. * ];
  13972. *
  13973. * _.reject(users, function(o) { return !o.active; });
  13974. * // => objects for ['fred']
  13975. *
  13976. * // The `_.matches` iteratee shorthand.
  13977. * _.reject(users, { 'age': 40, 'active': true });
  13978. * // => objects for ['barney']
  13979. *
  13980. * // The `_.matchesProperty` iteratee shorthand.
  13981. * _.reject(users, ['active', false]);
  13982. * // => objects for ['fred']
  13983. *
  13984. * // The `_.property` iteratee shorthand.
  13985. * _.reject(users, 'active');
  13986. * // => objects for ['barney']
  13987. */
  13988. function reject(collection, predicate) {
  13989. var func = isArray(collection) ? arrayFilter : baseFilter;
  13990. return func(collection, negate(getIteratee(predicate, 3)));
  13991. }
  13992. /**
  13993. * Gets a random element from `collection`.
  13994. *
  13995. * @static
  13996. * @memberOf _
  13997. * @since 2.0.0
  13998. * @category Collection
  13999. * @param {Array|Object} collection The collection to sample.
  14000. * @returns {*} Returns the random element.
  14001. * @example
  14002. *
  14003. * _.sample([1, 2, 3, 4]);
  14004. * // => 2
  14005. */
  14006. function sample(collection) {
  14007. var func = isArray(collection) ? arraySample : baseSample;
  14008. return func(collection);
  14009. }
  14010. /**
  14011. * Gets `n` random elements at unique keys from `collection` up to the
  14012. * size of `collection`.
  14013. *
  14014. * @static
  14015. * @memberOf _
  14016. * @since 4.0.0
  14017. * @category Collection
  14018. * @param {Array|Object} collection The collection to sample.
  14019. * @param {number} [n=1] The number of elements to sample.
  14020. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14021. * @returns {Array} Returns the random elements.
  14022. * @example
  14023. *
  14024. * _.sampleSize([1, 2, 3], 2);
  14025. * // => [3, 1]
  14026. *
  14027. * _.sampleSize([1, 2, 3], 4);
  14028. * // => [2, 3, 1]
  14029. */
  14030. function sampleSize(collection, n, guard) {
  14031. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  14032. n = 1;
  14033. } else {
  14034. n = toInteger(n);
  14035. }
  14036. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  14037. return func(collection, n);
  14038. }
  14039. /**
  14040. * Creates an array of shuffled values, using a version of the
  14041. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  14042. *
  14043. * @static
  14044. * @memberOf _
  14045. * @since 0.1.0
  14046. * @category Collection
  14047. * @param {Array|Object} collection The collection to shuffle.
  14048. * @returns {Array} Returns the new shuffled array.
  14049. * @example
  14050. *
  14051. * _.shuffle([1, 2, 3, 4]);
  14052. * // => [4, 1, 3, 2]
  14053. */
  14054. function shuffle(collection) {
  14055. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  14056. return func(collection);
  14057. }
  14058. /**
  14059. * Gets the size of `collection` by returning its length for array-like
  14060. * values or the number of own enumerable string keyed properties for objects.
  14061. *
  14062. * @static
  14063. * @memberOf _
  14064. * @since 0.1.0
  14065. * @category Collection
  14066. * @param {Array|Object|string} collection The collection to inspect.
  14067. * @returns {number} Returns the collection size.
  14068. * @example
  14069. *
  14070. * _.size([1, 2, 3]);
  14071. * // => 3
  14072. *
  14073. * _.size({ 'a': 1, 'b': 2 });
  14074. * // => 2
  14075. *
  14076. * _.size('pebbles');
  14077. * // => 7
  14078. */
  14079. function size(collection) {
  14080. if (collection == null) {
  14081. return 0;
  14082. }
  14083. if (isArrayLike(collection)) {
  14084. return isString(collection) ? stringSize(collection) : collection.length;
  14085. }
  14086. var tag = getTag(collection);
  14087. if (tag == mapTag || tag == setTag) {
  14088. return collection.size;
  14089. }
  14090. return baseKeys(collection).length;
  14091. }
  14092. /**
  14093. * Checks if `predicate` returns truthy for **any** element of `collection`.
  14094. * Iteration is stopped once `predicate` returns truthy. The predicate is
  14095. * invoked with three arguments: (value, index|key, collection).
  14096. *
  14097. * @static
  14098. * @memberOf _
  14099. * @since 0.1.0
  14100. * @category Collection
  14101. * @param {Array|Object} collection The collection to iterate over.
  14102. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  14103. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14104. * @returns {boolean} Returns `true` if any element passes the predicate check,
  14105. * else `false`.
  14106. * @example
  14107. *
  14108. * _.some([null, 0, 'yes', false], Boolean);
  14109. * // => true
  14110. *
  14111. * var users = [
  14112. * { 'user': 'barney', 'active': true },
  14113. * { 'user': 'fred', 'active': false }
  14114. * ];
  14115. *
  14116. * // The `_.matches` iteratee shorthand.
  14117. * _.some(users, { 'user': 'barney', 'active': false });
  14118. * // => false
  14119. *
  14120. * // The `_.matchesProperty` iteratee shorthand.
  14121. * _.some(users, ['active', false]);
  14122. * // => true
  14123. *
  14124. * // The `_.property` iteratee shorthand.
  14125. * _.some(users, 'active');
  14126. * // => true
  14127. */
  14128. function some(collection, predicate, guard) {
  14129. var func = isArray(collection) ? arraySome : baseSome;
  14130. if (guard && isIterateeCall(collection, predicate, guard)) {
  14131. predicate = undefined;
  14132. }
  14133. return func(collection, getIteratee(predicate, 3));
  14134. }
  14135. /**
  14136. * Creates an array of elements, sorted in ascending order by the results of
  14137. * running each element in a collection thru each iteratee. This method
  14138. * performs a stable sort, that is, it preserves the original sort order of
  14139. * equal elements. The iteratees are invoked with one argument: (value).
  14140. *
  14141. * @static
  14142. * @memberOf _
  14143. * @since 0.1.0
  14144. * @category Collection
  14145. * @param {Array|Object} collection The collection to iterate over.
  14146. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  14147. * The iteratees to sort by.
  14148. * @returns {Array} Returns the new sorted array.
  14149. * @example
  14150. *
  14151. * var users = [
  14152. * { 'user': 'fred', 'age': 48 },
  14153. * { 'user': 'barney', 'age': 36 },
  14154. * { 'user': 'fred', 'age': 30 },
  14155. * { 'user': 'barney', 'age': 34 }
  14156. * ];
  14157. *
  14158. * _.sortBy(users, [function(o) { return o.user; }]);
  14159. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]]
  14160. *
  14161. * _.sortBy(users, ['user', 'age']);
  14162. * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]]
  14163. */
  14164. var sortBy = baseRest(function(collection, iteratees) {
  14165. if (collection == null) {
  14166. return [];
  14167. }
  14168. var length = iteratees.length;
  14169. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  14170. iteratees = [];
  14171. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  14172. iteratees = [iteratees[0]];
  14173. }
  14174. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  14175. });
  14176. /*------------------------------------------------------------------------*/
  14177. /**
  14178. * Gets the timestamp of the number of milliseconds that have elapsed since
  14179. * the Unix epoch (1 January 1970 00:00:00 UTC).
  14180. *
  14181. * @static
  14182. * @memberOf _
  14183. * @since 2.4.0
  14184. * @category Date
  14185. * @returns {number} Returns the timestamp.
  14186. * @example
  14187. *
  14188. * _.defer(function(stamp) {
  14189. * console.log(_.now() - stamp);
  14190. * }, _.now());
  14191. * // => Logs the number of milliseconds it took for the deferred invocation.
  14192. */
  14193. var now = ctxNow || function() {
  14194. return root.Date.now();
  14195. };
  14196. /*------------------------------------------------------------------------*/
  14197. /**
  14198. * The opposite of `_.before`; this method creates a function that invokes
  14199. * `func` once it's called `n` or more times.
  14200. *
  14201. * @static
  14202. * @memberOf _
  14203. * @since 0.1.0
  14204. * @category Function
  14205. * @param {number} n The number of calls before `func` is invoked.
  14206. * @param {Function} func The function to restrict.
  14207. * @returns {Function} Returns the new restricted function.
  14208. * @example
  14209. *
  14210. * var saves = ['profile', 'settings'];
  14211. *
  14212. * var done = _.after(saves.length, function() {
  14213. * console.log('done saving!');
  14214. * });
  14215. *
  14216. * _.forEach(saves, function(type) {
  14217. * asyncSave({ 'type': type, 'complete': done });
  14218. * });
  14219. * // => Logs 'done saving!' after the two async saves have completed.
  14220. */
  14221. function after(n, func) {
  14222. if (typeof func != 'function') {
  14223. throw new TypeError(FUNC_ERROR_TEXT);
  14224. }
  14225. n = toInteger(n);
  14226. return function() {
  14227. if (--n < 1) {
  14228. return func.apply(this, arguments);
  14229. }
  14230. };
  14231. }
  14232. /**
  14233. * Creates a function that invokes `func`, with up to `n` arguments,
  14234. * ignoring any additional arguments.
  14235. *
  14236. * @static
  14237. * @memberOf _
  14238. * @since 3.0.0
  14239. * @category Function
  14240. * @param {Function} func The function to cap arguments for.
  14241. * @param {number} [n=func.length] The arity cap.
  14242. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14243. * @returns {Function} Returns the new capped function.
  14244. * @example
  14245. *
  14246. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  14247. * // => [6, 8, 10]
  14248. */
  14249. function ary(func, n, guard) {
  14250. n = guard ? undefined : n;
  14251. n = (func && n == null) ? func.length : n;
  14252. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  14253. }
  14254. /**
  14255. * Creates a function that invokes `func`, with the `this` binding and arguments
  14256. * of the created function, while it's called less than `n` times. Subsequent
  14257. * calls to the created function return the result of the last `func` invocation.
  14258. *
  14259. * @static
  14260. * @memberOf _
  14261. * @since 3.0.0
  14262. * @category Function
  14263. * @param {number} n The number of calls at which `func` is no longer invoked.
  14264. * @param {Function} func The function to restrict.
  14265. * @returns {Function} Returns the new restricted function.
  14266. * @example
  14267. *
  14268. * jQuery(element).on('click', _.before(5, addContactToList));
  14269. * // => Allows adding up to 4 contacts to the list.
  14270. */
  14271. function before(n, func) {
  14272. var result;
  14273. if (typeof func != 'function') {
  14274. throw new TypeError(FUNC_ERROR_TEXT);
  14275. }
  14276. n = toInteger(n);
  14277. return function() {
  14278. if (--n > 0) {
  14279. result = func.apply(this, arguments);
  14280. }
  14281. if (n <= 1) {
  14282. func = undefined;
  14283. }
  14284. return result;
  14285. };
  14286. }
  14287. /**
  14288. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  14289. * and `partials` prepended to the arguments it receives.
  14290. *
  14291. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  14292. * may be used as a placeholder for partially applied arguments.
  14293. *
  14294. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  14295. * property of bound functions.
  14296. *
  14297. * @static
  14298. * @memberOf _
  14299. * @since 0.1.0
  14300. * @category Function
  14301. * @param {Function} func The function to bind.
  14302. * @param {*} thisArg The `this` binding of `func`.
  14303. * @param {...*} [partials] The arguments to be partially applied.
  14304. * @returns {Function} Returns the new bound function.
  14305. * @example
  14306. *
  14307. * function greet(greeting, punctuation) {
  14308. * return greeting + ' ' + this.user + punctuation;
  14309. * }
  14310. *
  14311. * var object = { 'user': 'fred' };
  14312. *
  14313. * var bound = _.bind(greet, object, 'hi');
  14314. * bound('!');
  14315. * // => 'hi fred!'
  14316. *
  14317. * // Bound with placeholders.
  14318. * var bound = _.bind(greet, object, _, '!');
  14319. * bound('hi');
  14320. * // => 'hi fred!'
  14321. */
  14322. var bind = baseRest(function(func, thisArg, partials) {
  14323. var bitmask = WRAP_BIND_FLAG;
  14324. if (partials.length) {
  14325. var holders = replaceHolders(partials, getHolder(bind));
  14326. bitmask |= WRAP_PARTIAL_FLAG;
  14327. }
  14328. return createWrap(func, bitmask, thisArg, partials, holders);
  14329. });
  14330. /**
  14331. * Creates a function that invokes the method at `object[key]` with `partials`
  14332. * prepended to the arguments it receives.
  14333. *
  14334. * This method differs from `_.bind` by allowing bound functions to reference
  14335. * methods that may be redefined or don't yet exist. See
  14336. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  14337. * for more details.
  14338. *
  14339. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  14340. * builds, may be used as a placeholder for partially applied arguments.
  14341. *
  14342. * @static
  14343. * @memberOf _
  14344. * @since 0.10.0
  14345. * @category Function
  14346. * @param {Object} object The object to invoke the method on.
  14347. * @param {string} key The key of the method.
  14348. * @param {...*} [partials] The arguments to be partially applied.
  14349. * @returns {Function} Returns the new bound function.
  14350. * @example
  14351. *
  14352. * var object = {
  14353. * 'user': 'fred',
  14354. * 'greet': function(greeting, punctuation) {
  14355. * return greeting + ' ' + this.user + punctuation;
  14356. * }
  14357. * };
  14358. *
  14359. * var bound = _.bindKey(object, 'greet', 'hi');
  14360. * bound('!');
  14361. * // => 'hi fred!'
  14362. *
  14363. * object.greet = function(greeting, punctuation) {
  14364. * return greeting + 'ya ' + this.user + punctuation;
  14365. * };
  14366. *
  14367. * bound('!');
  14368. * // => 'hiya fred!'
  14369. *
  14370. * // Bound with placeholders.
  14371. * var bound = _.bindKey(object, 'greet', _, '!');
  14372. * bound('hi');
  14373. * // => 'hiya fred!'
  14374. */
  14375. var bindKey = baseRest(function(object, key, partials) {
  14376. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  14377. if (partials.length) {
  14378. var holders = replaceHolders(partials, getHolder(bindKey));
  14379. bitmask |= WRAP_PARTIAL_FLAG;
  14380. }
  14381. return createWrap(key, bitmask, object, partials, holders);
  14382. });
  14383. /**
  14384. * Creates a function that accepts arguments of `func` and either invokes
  14385. * `func` returning its result, if at least `arity` number of arguments have
  14386. * been provided, or returns a function that accepts the remaining `func`
  14387. * arguments, and so on. The arity of `func` may be specified if `func.length`
  14388. * is not sufficient.
  14389. *
  14390. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  14391. * may be used as a placeholder for provided arguments.
  14392. *
  14393. * **Note:** This method doesn't set the "length" property of curried functions.
  14394. *
  14395. * @static
  14396. * @memberOf _
  14397. * @since 2.0.0
  14398. * @category Function
  14399. * @param {Function} func The function to curry.
  14400. * @param {number} [arity=func.length] The arity of `func`.
  14401. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14402. * @returns {Function} Returns the new curried function.
  14403. * @example
  14404. *
  14405. * var abc = function(a, b, c) {
  14406. * return [a, b, c];
  14407. * };
  14408. *
  14409. * var curried = _.curry(abc);
  14410. *
  14411. * curried(1)(2)(3);
  14412. * // => [1, 2, 3]
  14413. *
  14414. * curried(1, 2)(3);
  14415. * // => [1, 2, 3]
  14416. *
  14417. * curried(1, 2, 3);
  14418. * // => [1, 2, 3]
  14419. *
  14420. * // Curried with placeholders.
  14421. * curried(1)(_, 3)(2);
  14422. * // => [1, 2, 3]
  14423. */
  14424. function curry(func, arity, guard) {
  14425. arity = guard ? undefined : arity;
  14426. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  14427. result.placeholder = curry.placeholder;
  14428. return result;
  14429. }
  14430. /**
  14431. * This method is like `_.curry` except that arguments are applied to `func`
  14432. * in the manner of `_.partialRight` instead of `_.partial`.
  14433. *
  14434. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  14435. * builds, may be used as a placeholder for provided arguments.
  14436. *
  14437. * **Note:** This method doesn't set the "length" property of curried functions.
  14438. *
  14439. * @static
  14440. * @memberOf _
  14441. * @since 3.0.0
  14442. * @category Function
  14443. * @param {Function} func The function to curry.
  14444. * @param {number} [arity=func.length] The arity of `func`.
  14445. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  14446. * @returns {Function} Returns the new curried function.
  14447. * @example
  14448. *
  14449. * var abc = function(a, b, c) {
  14450. * return [a, b, c];
  14451. * };
  14452. *
  14453. * var curried = _.curryRight(abc);
  14454. *
  14455. * curried(3)(2)(1);
  14456. * // => [1, 2, 3]
  14457. *
  14458. * curried(2, 3)(1);
  14459. * // => [1, 2, 3]
  14460. *
  14461. * curried(1, 2, 3);
  14462. * // => [1, 2, 3]
  14463. *
  14464. * // Curried with placeholders.
  14465. * curried(3)(1, _)(2);
  14466. * // => [1, 2, 3]
  14467. */
  14468. function curryRight(func, arity, guard) {
  14469. arity = guard ? undefined : arity;
  14470. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  14471. result.placeholder = curryRight.placeholder;
  14472. return result;
  14473. }
  14474. /**
  14475. * Creates a debounced function that delays invoking `func` until after `wait`
  14476. * milliseconds have elapsed since the last time the debounced function was
  14477. * invoked. The debounced function comes with a `cancel` method to cancel
  14478. * delayed `func` invocations and a `flush` method to immediately invoke them.
  14479. * Provide `options` to indicate whether `func` should be invoked on the
  14480. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  14481. * with the last arguments provided to the debounced function. Subsequent
  14482. * calls to the debounced function return the result of the last `func`
  14483. * invocation.
  14484. *
  14485. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  14486. * invoked on the trailing edge of the timeout only if the debounced function
  14487. * is invoked more than once during the `wait` timeout.
  14488. *
  14489. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  14490. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  14491. *
  14492. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  14493. * for details over the differences between `_.debounce` and `_.throttle`.
  14494. *
  14495. * @static
  14496. * @memberOf _
  14497. * @since 0.1.0
  14498. * @category Function
  14499. * @param {Function} func The function to debounce.
  14500. * @param {number} [wait=0] The number of milliseconds to delay.
  14501. * @param {Object} [options={}] The options object.
  14502. * @param {boolean} [options.leading=false]
  14503. * Specify invoking on the leading edge of the timeout.
  14504. * @param {number} [options.maxWait]
  14505. * The maximum time `func` is allowed to be delayed before it's invoked.
  14506. * @param {boolean} [options.trailing=true]
  14507. * Specify invoking on the trailing edge of the timeout.
  14508. * @returns {Function} Returns the new debounced function.
  14509. * @example
  14510. *
  14511. * // Avoid costly calculations while the window size is in flux.
  14512. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  14513. *
  14514. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  14515. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  14516. * 'leading': true,
  14517. * 'trailing': false
  14518. * }));
  14519. *
  14520. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  14521. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  14522. * var source = new EventSource('/stream');
  14523. * jQuery(source).on('message', debounced);
  14524. *
  14525. * // Cancel the trailing debounced invocation.
  14526. * jQuery(window).on('popstate', debounced.cancel);
  14527. */
  14528. function debounce(func, wait, options) {
  14529. var lastArgs,
  14530. lastThis,
  14531. maxWait,
  14532. result,
  14533. timerId,
  14534. lastCallTime,
  14535. lastInvokeTime = 0,
  14536. leading = false,
  14537. maxing = false,
  14538. trailing = true;
  14539. if (typeof func != 'function') {
  14540. throw new TypeError(FUNC_ERROR_TEXT);
  14541. }
  14542. wait = toNumber(wait) || 0;
  14543. if (isObject(options)) {
  14544. leading = !!options.leading;
  14545. maxing = 'maxWait' in options;
  14546. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  14547. trailing = 'trailing' in options ? !!options.trailing : trailing;
  14548. }
  14549. function invokeFunc(time) {
  14550. var args = lastArgs,
  14551. thisArg = lastThis;
  14552. lastArgs = lastThis = undefined;
  14553. lastInvokeTime = time;
  14554. result = func.apply(thisArg, args);
  14555. return result;
  14556. }
  14557. function leadingEdge(time) {
  14558. // Reset any `maxWait` timer.
  14559. lastInvokeTime = time;
  14560. // Start the timer for the trailing edge.
  14561. timerId = setTimeout(timerExpired, wait);
  14562. // Invoke the leading edge.
  14563. return leading ? invokeFunc(time) : result;
  14564. }
  14565. function remainingWait(time) {
  14566. var timeSinceLastCall = time - lastCallTime,
  14567. timeSinceLastInvoke = time - lastInvokeTime,
  14568. timeWaiting = wait - timeSinceLastCall;
  14569. return maxing
  14570. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  14571. : timeWaiting;
  14572. }
  14573. function shouldInvoke(time) {
  14574. var timeSinceLastCall = time - lastCallTime,
  14575. timeSinceLastInvoke = time - lastInvokeTime;
  14576. // Either this is the first call, activity has stopped and we're at the
  14577. // trailing edge, the system time has gone backwards and we're treating
  14578. // it as the trailing edge, or we've hit the `maxWait` limit.
  14579. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  14580. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  14581. }
  14582. function timerExpired() {
  14583. var time = now();
  14584. if (shouldInvoke(time)) {
  14585. return trailingEdge(time);
  14586. }
  14587. // Restart the timer.
  14588. timerId = setTimeout(timerExpired, remainingWait(time));
  14589. }
  14590. function trailingEdge(time) {
  14591. timerId = undefined;
  14592. // Only invoke if we have `lastArgs` which means `func` has been
  14593. // debounced at least once.
  14594. if (trailing && lastArgs) {
  14595. return invokeFunc(time);
  14596. }
  14597. lastArgs = lastThis = undefined;
  14598. return result;
  14599. }
  14600. function cancel() {
  14601. if (timerId !== undefined) {
  14602. clearTimeout(timerId);
  14603. }
  14604. lastInvokeTime = 0;
  14605. lastArgs = lastCallTime = lastThis = timerId = undefined;
  14606. }
  14607. function flush() {
  14608. return timerId === undefined ? result : trailingEdge(now());
  14609. }
  14610. function debounced() {
  14611. var time = now(),
  14612. isInvoking = shouldInvoke(time);
  14613. lastArgs = arguments;
  14614. lastThis = this;
  14615. lastCallTime = time;
  14616. if (isInvoking) {
  14617. if (timerId === undefined) {
  14618. return leadingEdge(lastCallTime);
  14619. }
  14620. if (maxing) {
  14621. // Handle invocations in a tight loop.
  14622. clearTimeout(timerId);
  14623. timerId = setTimeout(timerExpired, wait);
  14624. return invokeFunc(lastCallTime);
  14625. }
  14626. }
  14627. if (timerId === undefined) {
  14628. timerId = setTimeout(timerExpired, wait);
  14629. }
  14630. return result;
  14631. }
  14632. debounced.cancel = cancel;
  14633. debounced.flush = flush;
  14634. return debounced;
  14635. }
  14636. /**
  14637. * Defers invoking the `func` until the current call stack has cleared. Any
  14638. * additional arguments are provided to `func` when it's invoked.
  14639. *
  14640. * @static
  14641. * @memberOf _
  14642. * @since 0.1.0
  14643. * @category Function
  14644. * @param {Function} func The function to defer.
  14645. * @param {...*} [args] The arguments to invoke `func` with.
  14646. * @returns {number} Returns the timer id.
  14647. * @example
  14648. *
  14649. * _.defer(function(text) {
  14650. * console.log(text);
  14651. * }, 'deferred');
  14652. * // => Logs 'deferred' after one millisecond.
  14653. */
  14654. var defer = baseRest(function(func, args) {
  14655. return baseDelay(func, 1, args);
  14656. });
  14657. /**
  14658. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  14659. * provided to `func` when it's invoked.
  14660. *
  14661. * @static
  14662. * @memberOf _
  14663. * @since 0.1.0
  14664. * @category Function
  14665. * @param {Function} func The function to delay.
  14666. * @param {number} wait The number of milliseconds to delay invocation.
  14667. * @param {...*} [args] The arguments to invoke `func` with.
  14668. * @returns {number} Returns the timer id.
  14669. * @example
  14670. *
  14671. * _.delay(function(text) {
  14672. * console.log(text);
  14673. * }, 1000, 'later');
  14674. * // => Logs 'later' after one second.
  14675. */
  14676. var delay = baseRest(function(func, wait, args) {
  14677. return baseDelay(func, toNumber(wait) || 0, args);
  14678. });
  14679. /**
  14680. * Creates a function that invokes `func` with arguments reversed.
  14681. *
  14682. * @static
  14683. * @memberOf _
  14684. * @since 4.0.0
  14685. * @category Function
  14686. * @param {Function} func The function to flip arguments for.
  14687. * @returns {Function} Returns the new flipped function.
  14688. * @example
  14689. *
  14690. * var flipped = _.flip(function() {
  14691. * return _.toArray(arguments);
  14692. * });
  14693. *
  14694. * flipped('a', 'b', 'c', 'd');
  14695. * // => ['d', 'c', 'b', 'a']
  14696. */
  14697. function flip(func) {
  14698. return createWrap(func, WRAP_FLIP_FLAG);
  14699. }
  14700. /**
  14701. * Creates a function that memoizes the result of `func`. If `resolver` is
  14702. * provided, it determines the cache key for storing the result based on the
  14703. * arguments provided to the memoized function. By default, the first argument
  14704. * provided to the memoized function is used as the map cache key. The `func`
  14705. * is invoked with the `this` binding of the memoized function.
  14706. *
  14707. * **Note:** The cache is exposed as the `cache` property on the memoized
  14708. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  14709. * constructor with one whose instances implement the
  14710. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  14711. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  14712. *
  14713. * @static
  14714. * @memberOf _
  14715. * @since 0.1.0
  14716. * @category Function
  14717. * @param {Function} func The function to have its output memoized.
  14718. * @param {Function} [resolver] The function to resolve the cache key.
  14719. * @returns {Function} Returns the new memoized function.
  14720. * @example
  14721. *
  14722. * var object = { 'a': 1, 'b': 2 };
  14723. * var other = { 'c': 3, 'd': 4 };
  14724. *
  14725. * var values = _.memoize(_.values);
  14726. * values(object);
  14727. * // => [1, 2]
  14728. *
  14729. * values(other);
  14730. * // => [3, 4]
  14731. *
  14732. * object.a = 2;
  14733. * values(object);
  14734. * // => [1, 2]
  14735. *
  14736. * // Modify the result cache.
  14737. * values.cache.set(object, ['a', 'b']);
  14738. * values(object);
  14739. * // => ['a', 'b']
  14740. *
  14741. * // Replace `_.memoize.Cache`.
  14742. * _.memoize.Cache = WeakMap;
  14743. */
  14744. function memoize(func, resolver) {
  14745. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  14746. throw new TypeError(FUNC_ERROR_TEXT);
  14747. }
  14748. var memoized = function() {
  14749. var args = arguments,
  14750. key = resolver ? resolver.apply(this, args) : args[0],
  14751. cache = memoized.cache;
  14752. if (cache.has(key)) {
  14753. return cache.get(key);
  14754. }
  14755. var result = func.apply(this, args);
  14756. memoized.cache = cache.set(key, result) || cache;
  14757. return result;
  14758. };
  14759. memoized.cache = new (memoize.Cache || MapCache);
  14760. return memoized;
  14761. }
  14762. // Expose `MapCache`.
  14763. memoize.Cache = MapCache;
  14764. /**
  14765. * Creates a function that negates the result of the predicate `func`. The
  14766. * `func` predicate is invoked with the `this` binding and arguments of the
  14767. * created function.
  14768. *
  14769. * @static
  14770. * @memberOf _
  14771. * @since 3.0.0
  14772. * @category Function
  14773. * @param {Function} predicate The predicate to negate.
  14774. * @returns {Function} Returns the new negated function.
  14775. * @example
  14776. *
  14777. * function isEven(n) {
  14778. * return n % 2 == 0;
  14779. * }
  14780. *
  14781. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  14782. * // => [1, 3, 5]
  14783. */
  14784. function negate(predicate) {
  14785. if (typeof predicate != 'function') {
  14786. throw new TypeError(FUNC_ERROR_TEXT);
  14787. }
  14788. return function() {
  14789. var args = arguments;
  14790. switch (args.length) {
  14791. case 0: return !predicate.call(this);
  14792. case 1: return !predicate.call(this, args[0]);
  14793. case 2: return !predicate.call(this, args[0], args[1]);
  14794. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  14795. }
  14796. return !predicate.apply(this, args);
  14797. };
  14798. }
  14799. /**
  14800. * Creates a function that is restricted to invoking `func` once. Repeat calls
  14801. * to the function return the value of the first invocation. The `func` is
  14802. * invoked with the `this` binding and arguments of the created function.
  14803. *
  14804. * @static
  14805. * @memberOf _
  14806. * @since 0.1.0
  14807. * @category Function
  14808. * @param {Function} func The function to restrict.
  14809. * @returns {Function} Returns the new restricted function.
  14810. * @example
  14811. *
  14812. * var initialize = _.once(createApplication);
  14813. * initialize();
  14814. * initialize();
  14815. * // => `createApplication` is invoked once
  14816. */
  14817. function once(func) {
  14818. return before(2, func);
  14819. }
  14820. /**
  14821. * Creates a function that invokes `func` with its arguments transformed.
  14822. *
  14823. * @static
  14824. * @since 4.0.0
  14825. * @memberOf _
  14826. * @category Function
  14827. * @param {Function} func The function to wrap.
  14828. * @param {...(Function|Function[])} [transforms=[_.identity]]
  14829. * The argument transforms.
  14830. * @returns {Function} Returns the new function.
  14831. * @example
  14832. *
  14833. * function doubled(n) {
  14834. * return n * 2;
  14835. * }
  14836. *
  14837. * function square(n) {
  14838. * return n * n;
  14839. * }
  14840. *
  14841. * var func = _.overArgs(function(x, y) {
  14842. * return [x, y];
  14843. * }, [square, doubled]);
  14844. *
  14845. * func(9, 3);
  14846. * // => [81, 6]
  14847. *
  14848. * func(10, 5);
  14849. * // => [100, 10]
  14850. */
  14851. var overArgs = castRest(function(func, transforms) {
  14852. transforms = (transforms.length == 1 && isArray(transforms[0]))
  14853. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  14854. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  14855. var funcsLength = transforms.length;
  14856. return baseRest(function(args) {
  14857. var index = -1,
  14858. length = nativeMin(args.length, funcsLength);
  14859. while (++index < length) {
  14860. args[index] = transforms[index].call(this, args[index]);
  14861. }
  14862. return apply(func, this, args);
  14863. });
  14864. });
  14865. /**
  14866. * Creates a function that invokes `func` with `partials` prepended to the
  14867. * arguments it receives. This method is like `_.bind` except it does **not**
  14868. * alter the `this` binding.
  14869. *
  14870. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  14871. * builds, may be used as a placeholder for partially applied arguments.
  14872. *
  14873. * **Note:** This method doesn't set the "length" property of partially
  14874. * applied functions.
  14875. *
  14876. * @static
  14877. * @memberOf _
  14878. * @since 0.2.0
  14879. * @category Function
  14880. * @param {Function} func The function to partially apply arguments to.
  14881. * @param {...*} [partials] The arguments to be partially applied.
  14882. * @returns {Function} Returns the new partially applied function.
  14883. * @example
  14884. *
  14885. * function greet(greeting, name) {
  14886. * return greeting + ' ' + name;
  14887. * }
  14888. *
  14889. * var sayHelloTo = _.partial(greet, 'hello');
  14890. * sayHelloTo('fred');
  14891. * // => 'hello fred'
  14892. *
  14893. * // Partially applied with placeholders.
  14894. * var greetFred = _.partial(greet, _, 'fred');
  14895. * greetFred('hi');
  14896. * // => 'hi fred'
  14897. */
  14898. var partial = baseRest(function(func, partials) {
  14899. var holders = replaceHolders(partials, getHolder(partial));
  14900. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  14901. });
  14902. /**
  14903. * This method is like `_.partial` except that partially applied arguments
  14904. * are appended to the arguments it receives.
  14905. *
  14906. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  14907. * builds, may be used as a placeholder for partially applied arguments.
  14908. *
  14909. * **Note:** This method doesn't set the "length" property of partially
  14910. * applied functions.
  14911. *
  14912. * @static
  14913. * @memberOf _
  14914. * @since 1.0.0
  14915. * @category Function
  14916. * @param {Function} func The function to partially apply arguments to.
  14917. * @param {...*} [partials] The arguments to be partially applied.
  14918. * @returns {Function} Returns the new partially applied function.
  14919. * @example
  14920. *
  14921. * function greet(greeting, name) {
  14922. * return greeting + ' ' + name;
  14923. * }
  14924. *
  14925. * var greetFred = _.partialRight(greet, 'fred');
  14926. * greetFred('hi');
  14927. * // => 'hi fred'
  14928. *
  14929. * // Partially applied with placeholders.
  14930. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  14931. * sayHelloTo('fred');
  14932. * // => 'hello fred'
  14933. */
  14934. var partialRight = baseRest(function(func, partials) {
  14935. var holders = replaceHolders(partials, getHolder(partialRight));
  14936. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  14937. });
  14938. /**
  14939. * Creates a function that invokes `func` with arguments arranged according
  14940. * to the specified `indexes` where the argument value at the first index is
  14941. * provided as the first argument, the argument value at the second index is
  14942. * provided as the second argument, and so on.
  14943. *
  14944. * @static
  14945. * @memberOf _
  14946. * @since 3.0.0
  14947. * @category Function
  14948. * @param {Function} func The function to rearrange arguments for.
  14949. * @param {...(number|number[])} indexes The arranged argument indexes.
  14950. * @returns {Function} Returns the new function.
  14951. * @example
  14952. *
  14953. * var rearged = _.rearg(function(a, b, c) {
  14954. * return [a, b, c];
  14955. * }, [2, 0, 1]);
  14956. *
  14957. * rearged('b', 'c', 'a')
  14958. * // => ['a', 'b', 'c']
  14959. */
  14960. var rearg = flatRest(function(func, indexes) {
  14961. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  14962. });
  14963. /**
  14964. * Creates a function that invokes `func` with the `this` binding of the
  14965. * created function and arguments from `start` and beyond provided as
  14966. * an array.
  14967. *
  14968. * **Note:** This method is based on the
  14969. * [rest parameter](https://mdn.io/rest_parameters).
  14970. *
  14971. * @static
  14972. * @memberOf _
  14973. * @since 4.0.0
  14974. * @category Function
  14975. * @param {Function} func The function to apply a rest parameter to.
  14976. * @param {number} [start=func.length-1] The start position of the rest parameter.
  14977. * @returns {Function} Returns the new function.
  14978. * @example
  14979. *
  14980. * var say = _.rest(function(what, names) {
  14981. * return what + ' ' + _.initial(names).join(', ') +
  14982. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  14983. * });
  14984. *
  14985. * say('hello', 'fred', 'barney', 'pebbles');
  14986. * // => 'hello fred, barney, & pebbles'
  14987. */
  14988. function rest(func, start) {
  14989. if (typeof func != 'function') {
  14990. throw new TypeError(FUNC_ERROR_TEXT);
  14991. }
  14992. start = start === undefined ? start : toInteger(start);
  14993. return baseRest(func, start);
  14994. }
  14995. /**
  14996. * Creates a function that invokes `func` with the `this` binding of the
  14997. * create function and an array of arguments much like
  14998. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  14999. *
  15000. * **Note:** This method is based on the
  15001. * [spread operator](https://mdn.io/spread_operator).
  15002. *
  15003. * @static
  15004. * @memberOf _
  15005. * @since 3.2.0
  15006. * @category Function
  15007. * @param {Function} func The function to spread arguments over.
  15008. * @param {number} [start=0] The start position of the spread.
  15009. * @returns {Function} Returns the new function.
  15010. * @example
  15011. *
  15012. * var say = _.spread(function(who, what) {
  15013. * return who + ' says ' + what;
  15014. * });
  15015. *
  15016. * say(['fred', 'hello']);
  15017. * // => 'fred says hello'
  15018. *
  15019. * var numbers = Promise.all([
  15020. * Promise.resolve(40),
  15021. * Promise.resolve(36)
  15022. * ]);
  15023. *
  15024. * numbers.then(_.spread(function(x, y) {
  15025. * return x + y;
  15026. * }));
  15027. * // => a Promise of 76
  15028. */
  15029. function spread(func, start) {
  15030. if (typeof func != 'function') {
  15031. throw new TypeError(FUNC_ERROR_TEXT);
  15032. }
  15033. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  15034. return baseRest(function(args) {
  15035. var array = args[start],
  15036. otherArgs = castSlice(args, 0, start);
  15037. if (array) {
  15038. arrayPush(otherArgs, array);
  15039. }
  15040. return apply(func, this, otherArgs);
  15041. });
  15042. }
  15043. /**
  15044. * Creates a throttled function that only invokes `func` at most once per
  15045. * every `wait` milliseconds. The throttled function comes with a `cancel`
  15046. * method to cancel delayed `func` invocations and a `flush` method to
  15047. * immediately invoke them. Provide `options` to indicate whether `func`
  15048. * should be invoked on the leading and/or trailing edge of the `wait`
  15049. * timeout. The `func` is invoked with the last arguments provided to the
  15050. * throttled function. Subsequent calls to the throttled function return the
  15051. * result of the last `func` invocation.
  15052. *
  15053. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  15054. * invoked on the trailing edge of the timeout only if the throttled function
  15055. * is invoked more than once during the `wait` timeout.
  15056. *
  15057. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  15058. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  15059. *
  15060. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  15061. * for details over the differences between `_.throttle` and `_.debounce`.
  15062. *
  15063. * @static
  15064. * @memberOf _
  15065. * @since 0.1.0
  15066. * @category Function
  15067. * @param {Function} func The function to throttle.
  15068. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  15069. * @param {Object} [options={}] The options object.
  15070. * @param {boolean} [options.leading=true]
  15071. * Specify invoking on the leading edge of the timeout.
  15072. * @param {boolean} [options.trailing=true]
  15073. * Specify invoking on the trailing edge of the timeout.
  15074. * @returns {Function} Returns the new throttled function.
  15075. * @example
  15076. *
  15077. * // Avoid excessively updating the position while scrolling.
  15078. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  15079. *
  15080. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  15081. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  15082. * jQuery(element).on('click', throttled);
  15083. *
  15084. * // Cancel the trailing throttled invocation.
  15085. * jQuery(window).on('popstate', throttled.cancel);
  15086. */
  15087. function throttle(func, wait, options) {
  15088. var leading = true,
  15089. trailing = true;
  15090. if (typeof func != 'function') {
  15091. throw new TypeError(FUNC_ERROR_TEXT);
  15092. }
  15093. if (isObject(options)) {
  15094. leading = 'leading' in options ? !!options.leading : leading;
  15095. trailing = 'trailing' in options ? !!options.trailing : trailing;
  15096. }
  15097. return debounce(func, wait, {
  15098. 'leading': leading,
  15099. 'maxWait': wait,
  15100. 'trailing': trailing
  15101. });
  15102. }
  15103. /**
  15104. * Creates a function that accepts up to one argument, ignoring any
  15105. * additional arguments.
  15106. *
  15107. * @static
  15108. * @memberOf _
  15109. * @since 4.0.0
  15110. * @category Function
  15111. * @param {Function} func The function to cap arguments for.
  15112. * @returns {Function} Returns the new capped function.
  15113. * @example
  15114. *
  15115. * _.map(['6', '8', '10'], _.unary(parseInt));
  15116. * // => [6, 8, 10]
  15117. */
  15118. function unary(func) {
  15119. return ary(func, 1);
  15120. }
  15121. /**
  15122. * Creates a function that provides `value` to `wrapper` as its first
  15123. * argument. Any additional arguments provided to the function are appended
  15124. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  15125. * binding of the created function.
  15126. *
  15127. * @static
  15128. * @memberOf _
  15129. * @since 0.1.0
  15130. * @category Function
  15131. * @param {*} value The value to wrap.
  15132. * @param {Function} [wrapper=identity] The wrapper function.
  15133. * @returns {Function} Returns the new function.
  15134. * @example
  15135. *
  15136. * var p = _.wrap(_.escape, function(func, text) {
  15137. * return '<p>' + func(text) + '</p>';
  15138. * });
  15139. *
  15140. * p('fred, barney, & pebbles');
  15141. * // => '<p>fred, barney, &amp; pebbles</p>'
  15142. */
  15143. function wrap(value, wrapper) {
  15144. return partial(castFunction(wrapper), value);
  15145. }
  15146. /*------------------------------------------------------------------------*/
  15147. /**
  15148. * Casts `value` as an array if it's not one.
  15149. *
  15150. * @static
  15151. * @memberOf _
  15152. * @since 4.4.0
  15153. * @category Lang
  15154. * @param {*} value The value to inspect.
  15155. * @returns {Array} Returns the cast array.
  15156. * @example
  15157. *
  15158. * _.castArray(1);
  15159. * // => [1]
  15160. *
  15161. * _.castArray({ 'a': 1 });
  15162. * // => [{ 'a': 1 }]
  15163. *
  15164. * _.castArray('abc');
  15165. * // => ['abc']
  15166. *
  15167. * _.castArray(null);
  15168. * // => [null]
  15169. *
  15170. * _.castArray(undefined);
  15171. * // => [undefined]
  15172. *
  15173. * _.castArray();
  15174. * // => []
  15175. *
  15176. * var array = [1, 2, 3];
  15177. * console.log(_.castArray(array) === array);
  15178. * // => true
  15179. */
  15180. function castArray() {
  15181. if (!arguments.length) {
  15182. return [];
  15183. }
  15184. var value = arguments[0];
  15185. return isArray(value) ? value : [value];
  15186. }
  15187. /**
  15188. * Creates a shallow clone of `value`.
  15189. *
  15190. * **Note:** This method is loosely based on the
  15191. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  15192. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  15193. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  15194. * arrays. The own enumerable properties of `arguments` objects are cloned
  15195. * as plain objects. An empty object is returned for uncloneable values such
  15196. * as error objects, functions, DOM nodes, and WeakMaps.
  15197. *
  15198. * @static
  15199. * @memberOf _
  15200. * @since 0.1.0
  15201. * @category Lang
  15202. * @param {*} value The value to clone.
  15203. * @returns {*} Returns the cloned value.
  15204. * @see _.cloneDeep
  15205. * @example
  15206. *
  15207. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  15208. *
  15209. * var shallow = _.clone(objects);
  15210. * console.log(shallow[0] === objects[0]);
  15211. * // => true
  15212. */
  15213. function clone(value) {
  15214. return baseClone(value, CLONE_SYMBOLS_FLAG);
  15215. }
  15216. /**
  15217. * This method is like `_.clone` except that it accepts `customizer` which
  15218. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  15219. * cloning is handled by the method instead. The `customizer` is invoked with
  15220. * up to four arguments; (value [, index|key, object, stack]).
  15221. *
  15222. * @static
  15223. * @memberOf _
  15224. * @since 4.0.0
  15225. * @category Lang
  15226. * @param {*} value The value to clone.
  15227. * @param {Function} [customizer] The function to customize cloning.
  15228. * @returns {*} Returns the cloned value.
  15229. * @see _.cloneDeepWith
  15230. * @example
  15231. *
  15232. * function customizer(value) {
  15233. * if (_.isElement(value)) {
  15234. * return value.cloneNode(false);
  15235. * }
  15236. * }
  15237. *
  15238. * var el = _.cloneWith(document.body, customizer);
  15239. *
  15240. * console.log(el === document.body);
  15241. * // => false
  15242. * console.log(el.nodeName);
  15243. * // => 'BODY'
  15244. * console.log(el.childNodes.length);
  15245. * // => 0
  15246. */
  15247. function cloneWith(value, customizer) {
  15248. customizer = typeof customizer == 'function' ? customizer : undefined;
  15249. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  15250. }
  15251. /**
  15252. * This method is like `_.clone` except that it recursively clones `value`.
  15253. *
  15254. * @static
  15255. * @memberOf _
  15256. * @since 1.0.0
  15257. * @category Lang
  15258. * @param {*} value The value to recursively clone.
  15259. * @returns {*} Returns the deep cloned value.
  15260. * @see _.clone
  15261. * @example
  15262. *
  15263. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  15264. *
  15265. * var deep = _.cloneDeep(objects);
  15266. * console.log(deep[0] === objects[0]);
  15267. * // => false
  15268. */
  15269. function cloneDeep(value) {
  15270. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  15271. }
  15272. /**
  15273. * This method is like `_.cloneWith` except that it recursively clones `value`.
  15274. *
  15275. * @static
  15276. * @memberOf _
  15277. * @since 4.0.0
  15278. * @category Lang
  15279. * @param {*} value The value to recursively clone.
  15280. * @param {Function} [customizer] The function to customize cloning.
  15281. * @returns {*} Returns the deep cloned value.
  15282. * @see _.cloneWith
  15283. * @example
  15284. *
  15285. * function customizer(value) {
  15286. * if (_.isElement(value)) {
  15287. * return value.cloneNode(true);
  15288. * }
  15289. * }
  15290. *
  15291. * var el = _.cloneDeepWith(document.body, customizer);
  15292. *
  15293. * console.log(el === document.body);
  15294. * // => false
  15295. * console.log(el.nodeName);
  15296. * // => 'BODY'
  15297. * console.log(el.childNodes.length);
  15298. * // => 20
  15299. */
  15300. function cloneDeepWith(value, customizer) {
  15301. customizer = typeof customizer == 'function' ? customizer : undefined;
  15302. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  15303. }
  15304. /**
  15305. * Checks if `object` conforms to `source` by invoking the predicate
  15306. * properties of `source` with the corresponding property values of `object`.
  15307. *
  15308. * **Note:** This method is equivalent to `_.conforms` when `source` is
  15309. * partially applied.
  15310. *
  15311. * @static
  15312. * @memberOf _
  15313. * @since 4.14.0
  15314. * @category Lang
  15315. * @param {Object} object The object to inspect.
  15316. * @param {Object} source The object of property predicates to conform to.
  15317. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  15318. * @example
  15319. *
  15320. * var object = { 'a': 1, 'b': 2 };
  15321. *
  15322. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  15323. * // => true
  15324. *
  15325. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  15326. * // => false
  15327. */
  15328. function conformsTo(object, source) {
  15329. return source == null || baseConformsTo(object, source, keys(source));
  15330. }
  15331. /**
  15332. * Performs a
  15333. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  15334. * comparison between two values to determine if they are equivalent.
  15335. *
  15336. * @static
  15337. * @memberOf _
  15338. * @since 4.0.0
  15339. * @category Lang
  15340. * @param {*} value The value to compare.
  15341. * @param {*} other The other value to compare.
  15342. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  15343. * @example
  15344. *
  15345. * var object = { 'a': 1 };
  15346. * var other = { 'a': 1 };
  15347. *
  15348. * _.eq(object, object);
  15349. * // => true
  15350. *
  15351. * _.eq(object, other);
  15352. * // => false
  15353. *
  15354. * _.eq('a', 'a');
  15355. * // => true
  15356. *
  15357. * _.eq('a', Object('a'));
  15358. * // => false
  15359. *
  15360. * _.eq(NaN, NaN);
  15361. * // => true
  15362. */
  15363. function eq(value, other) {
  15364. return value === other || (value !== value && other !== other);
  15365. }
  15366. /**
  15367. * Checks if `value` is greater than `other`.
  15368. *
  15369. * @static
  15370. * @memberOf _
  15371. * @since 3.9.0
  15372. * @category Lang
  15373. * @param {*} value The value to compare.
  15374. * @param {*} other The other value to compare.
  15375. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  15376. * else `false`.
  15377. * @see _.lt
  15378. * @example
  15379. *
  15380. * _.gt(3, 1);
  15381. * // => true
  15382. *
  15383. * _.gt(3, 3);
  15384. * // => false
  15385. *
  15386. * _.gt(1, 3);
  15387. * // => false
  15388. */
  15389. var gt = createRelationalOperation(baseGt);
  15390. /**
  15391. * Checks if `value` is greater than or equal to `other`.
  15392. *
  15393. * @static
  15394. * @memberOf _
  15395. * @since 3.9.0
  15396. * @category Lang
  15397. * @param {*} value The value to compare.
  15398. * @param {*} other The other value to compare.
  15399. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  15400. * `other`, else `false`.
  15401. * @see _.lte
  15402. * @example
  15403. *
  15404. * _.gte(3, 1);
  15405. * // => true
  15406. *
  15407. * _.gte(3, 3);
  15408. * // => true
  15409. *
  15410. * _.gte(1, 3);
  15411. * // => false
  15412. */
  15413. var gte = createRelationalOperation(function(value, other) {
  15414. return value >= other;
  15415. });
  15416. /**
  15417. * Checks if `value` is likely an `arguments` object.
  15418. *
  15419. * @static
  15420. * @memberOf _
  15421. * @since 0.1.0
  15422. * @category Lang
  15423. * @param {*} value The value to check.
  15424. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  15425. * else `false`.
  15426. * @example
  15427. *
  15428. * _.isArguments(function() { return arguments; }());
  15429. * // => true
  15430. *
  15431. * _.isArguments([1, 2, 3]);
  15432. * // => false
  15433. */
  15434. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  15435. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  15436. !propertyIsEnumerable.call(value, 'callee');
  15437. };
  15438. /**
  15439. * Checks if `value` is classified as an `Array` object.
  15440. *
  15441. * @static
  15442. * @memberOf _
  15443. * @since 0.1.0
  15444. * @category Lang
  15445. * @param {*} value The value to check.
  15446. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  15447. * @example
  15448. *
  15449. * _.isArray([1, 2, 3]);
  15450. * // => true
  15451. *
  15452. * _.isArray(document.body.children);
  15453. * // => false
  15454. *
  15455. * _.isArray('abc');
  15456. * // => false
  15457. *
  15458. * _.isArray(_.noop);
  15459. * // => false
  15460. */
  15461. var isArray = Array.isArray;
  15462. /**
  15463. * Checks if `value` is classified as an `ArrayBuffer` object.
  15464. *
  15465. * @static
  15466. * @memberOf _
  15467. * @since 4.3.0
  15468. * @category Lang
  15469. * @param {*} value The value to check.
  15470. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  15471. * @example
  15472. *
  15473. * _.isArrayBuffer(new ArrayBuffer(2));
  15474. * // => true
  15475. *
  15476. * _.isArrayBuffer(new Array(2));
  15477. * // => false
  15478. */
  15479. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  15480. /**
  15481. * Checks if `value` is array-like. A value is considered array-like if it's
  15482. * not a function and has a `value.length` that's an integer greater than or
  15483. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  15484. *
  15485. * @static
  15486. * @memberOf _
  15487. * @since 4.0.0
  15488. * @category Lang
  15489. * @param {*} value The value to check.
  15490. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  15491. * @example
  15492. *
  15493. * _.isArrayLike([1, 2, 3]);
  15494. * // => true
  15495. *
  15496. * _.isArrayLike(document.body.children);
  15497. * // => true
  15498. *
  15499. * _.isArrayLike('abc');
  15500. * // => true
  15501. *
  15502. * _.isArrayLike(_.noop);
  15503. * // => false
  15504. */
  15505. function isArrayLike(value) {
  15506. return value != null && isLength(value.length) && !isFunction(value);
  15507. }
  15508. /**
  15509. * This method is like `_.isArrayLike` except that it also checks if `value`
  15510. * is an object.
  15511. *
  15512. * @static
  15513. * @memberOf _
  15514. * @since 4.0.0
  15515. * @category Lang
  15516. * @param {*} value The value to check.
  15517. * @returns {boolean} Returns `true` if `value` is an array-like object,
  15518. * else `false`.
  15519. * @example
  15520. *
  15521. * _.isArrayLikeObject([1, 2, 3]);
  15522. * // => true
  15523. *
  15524. * _.isArrayLikeObject(document.body.children);
  15525. * // => true
  15526. *
  15527. * _.isArrayLikeObject('abc');
  15528. * // => false
  15529. *
  15530. * _.isArrayLikeObject(_.noop);
  15531. * // => false
  15532. */
  15533. function isArrayLikeObject(value) {
  15534. return isObjectLike(value) && isArrayLike(value);
  15535. }
  15536. /**
  15537. * Checks if `value` is classified as a boolean primitive or object.
  15538. *
  15539. * @static
  15540. * @memberOf _
  15541. * @since 0.1.0
  15542. * @category Lang
  15543. * @param {*} value The value to check.
  15544. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  15545. * @example
  15546. *
  15547. * _.isBoolean(false);
  15548. * // => true
  15549. *
  15550. * _.isBoolean(null);
  15551. * // => false
  15552. */
  15553. function isBoolean(value) {
  15554. return value === true || value === false ||
  15555. (isObjectLike(value) && baseGetTag(value) == boolTag);
  15556. }
  15557. /**
  15558. * Checks if `value` is a buffer.
  15559. *
  15560. * @static
  15561. * @memberOf _
  15562. * @since 4.3.0
  15563. * @category Lang
  15564. * @param {*} value The value to check.
  15565. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  15566. * @example
  15567. *
  15568. * _.isBuffer(new Buffer(2));
  15569. * // => true
  15570. *
  15571. * _.isBuffer(new Uint8Array(2));
  15572. * // => false
  15573. */
  15574. var isBuffer = nativeIsBuffer || stubFalse;
  15575. /**
  15576. * Checks if `value` is classified as a `Date` object.
  15577. *
  15578. * @static
  15579. * @memberOf _
  15580. * @since 0.1.0
  15581. * @category Lang
  15582. * @param {*} value The value to check.
  15583. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  15584. * @example
  15585. *
  15586. * _.isDate(new Date);
  15587. * // => true
  15588. *
  15589. * _.isDate('Mon April 23 2012');
  15590. * // => false
  15591. */
  15592. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  15593. /**
  15594. * Checks if `value` is likely a DOM element.
  15595. *
  15596. * @static
  15597. * @memberOf _
  15598. * @since 0.1.0
  15599. * @category Lang
  15600. * @param {*} value The value to check.
  15601. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  15602. * @example
  15603. *
  15604. * _.isElement(document.body);
  15605. * // => true
  15606. *
  15607. * _.isElement('<body>');
  15608. * // => false
  15609. */
  15610. function isElement(value) {
  15611. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  15612. }
  15613. /**
  15614. * Checks if `value` is an empty object, collection, map, or set.
  15615. *
  15616. * Objects are considered empty if they have no own enumerable string keyed
  15617. * properties.
  15618. *
  15619. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  15620. * jQuery-like collections are considered empty if they have a `length` of `0`.
  15621. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  15622. *
  15623. * @static
  15624. * @memberOf _
  15625. * @since 0.1.0
  15626. * @category Lang
  15627. * @param {*} value The value to check.
  15628. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  15629. * @example
  15630. *
  15631. * _.isEmpty(null);
  15632. * // => true
  15633. *
  15634. * _.isEmpty(true);
  15635. * // => true
  15636. *
  15637. * _.isEmpty(1);
  15638. * // => true
  15639. *
  15640. * _.isEmpty([1, 2, 3]);
  15641. * // => false
  15642. *
  15643. * _.isEmpty({ 'a': 1 });
  15644. * // => false
  15645. */
  15646. function isEmpty(value) {
  15647. if (value == null) {
  15648. return true;
  15649. }
  15650. if (isArrayLike(value) &&
  15651. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  15652. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  15653. return !value.length;
  15654. }
  15655. var tag = getTag(value);
  15656. if (tag == mapTag || tag == setTag) {
  15657. return !value.size;
  15658. }
  15659. if (isPrototype(value)) {
  15660. return !baseKeys(value).length;
  15661. }
  15662. for (var key in value) {
  15663. if (hasOwnProperty.call(value, key)) {
  15664. return false;
  15665. }
  15666. }
  15667. return true;
  15668. }
  15669. /**
  15670. * Performs a deep comparison between two values to determine if they are
  15671. * equivalent.
  15672. *
  15673. * **Note:** This method supports comparing arrays, array buffers, booleans,
  15674. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  15675. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  15676. * by their own, not inherited, enumerable properties. Functions and DOM
  15677. * nodes are compared by strict equality, i.e. `===`.
  15678. *
  15679. * @static
  15680. * @memberOf _
  15681. * @since 0.1.0
  15682. * @category Lang
  15683. * @param {*} value The value to compare.
  15684. * @param {*} other The other value to compare.
  15685. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  15686. * @example
  15687. *
  15688. * var object = { 'a': 1 };
  15689. * var other = { 'a': 1 };
  15690. *
  15691. * _.isEqual(object, other);
  15692. * // => true
  15693. *
  15694. * object === other;
  15695. * // => false
  15696. */
  15697. function isEqual(value, other) {
  15698. return baseIsEqual(value, other);
  15699. }
  15700. /**
  15701. * This method is like `_.isEqual` except that it accepts `customizer` which
  15702. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  15703. * are handled by the method instead. The `customizer` is invoked with up to
  15704. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  15705. *
  15706. * @static
  15707. * @memberOf _
  15708. * @since 4.0.0
  15709. * @category Lang
  15710. * @param {*} value The value to compare.
  15711. * @param {*} other The other value to compare.
  15712. * @param {Function} [customizer] The function to customize comparisons.
  15713. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  15714. * @example
  15715. *
  15716. * function isGreeting(value) {
  15717. * return /^h(?:i|ello)$/.test(value);
  15718. * }
  15719. *
  15720. * function customizer(objValue, othValue) {
  15721. * if (isGreeting(objValue) && isGreeting(othValue)) {
  15722. * return true;
  15723. * }
  15724. * }
  15725. *
  15726. * var array = ['hello', 'goodbye'];
  15727. * var other = ['hi', 'goodbye'];
  15728. *
  15729. * _.isEqualWith(array, other, customizer);
  15730. * // => true
  15731. */
  15732. function isEqualWith(value, other, customizer) {
  15733. customizer = typeof customizer == 'function' ? customizer : undefined;
  15734. var result = customizer ? customizer(value, other) : undefined;
  15735. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  15736. }
  15737. /**
  15738. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  15739. * `SyntaxError`, `TypeError`, or `URIError` object.
  15740. *
  15741. * @static
  15742. * @memberOf _
  15743. * @since 3.0.0
  15744. * @category Lang
  15745. * @param {*} value The value to check.
  15746. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  15747. * @example
  15748. *
  15749. * _.isError(new Error);
  15750. * // => true
  15751. *
  15752. * _.isError(Error);
  15753. * // => false
  15754. */
  15755. function isError(value) {
  15756. if (!isObjectLike(value)) {
  15757. return false;
  15758. }
  15759. var tag = baseGetTag(value);
  15760. return tag == errorTag || tag == domExcTag ||
  15761. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  15762. }
  15763. /**
  15764. * Checks if `value` is a finite primitive number.
  15765. *
  15766. * **Note:** This method is based on
  15767. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  15768. *
  15769. * @static
  15770. * @memberOf _
  15771. * @since 0.1.0
  15772. * @category Lang
  15773. * @param {*} value The value to check.
  15774. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  15775. * @example
  15776. *
  15777. * _.isFinite(3);
  15778. * // => true
  15779. *
  15780. * _.isFinite(Number.MIN_VALUE);
  15781. * // => true
  15782. *
  15783. * _.isFinite(Infinity);
  15784. * // => false
  15785. *
  15786. * _.isFinite('3');
  15787. * // => false
  15788. */
  15789. function isFinite(value) {
  15790. return typeof value == 'number' && nativeIsFinite(value);
  15791. }
  15792. /**
  15793. * Checks if `value` is classified as a `Function` object.
  15794. *
  15795. * @static
  15796. * @memberOf _
  15797. * @since 0.1.0
  15798. * @category Lang
  15799. * @param {*} value The value to check.
  15800. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  15801. * @example
  15802. *
  15803. * _.isFunction(_);
  15804. * // => true
  15805. *
  15806. * _.isFunction(/abc/);
  15807. * // => false
  15808. */
  15809. function isFunction(value) {
  15810. if (!isObject(value)) {
  15811. return false;
  15812. }
  15813. // The use of `Object#toString` avoids issues with the `typeof` operator
  15814. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  15815. var tag = baseGetTag(value);
  15816. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  15817. }
  15818. /**
  15819. * Checks if `value` is an integer.
  15820. *
  15821. * **Note:** This method is based on
  15822. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  15823. *
  15824. * @static
  15825. * @memberOf _
  15826. * @since 4.0.0
  15827. * @category Lang
  15828. * @param {*} value The value to check.
  15829. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  15830. * @example
  15831. *
  15832. * _.isInteger(3);
  15833. * // => true
  15834. *
  15835. * _.isInteger(Number.MIN_VALUE);
  15836. * // => false
  15837. *
  15838. * _.isInteger(Infinity);
  15839. * // => false
  15840. *
  15841. * _.isInteger('3');
  15842. * // => false
  15843. */
  15844. function isInteger(value) {
  15845. return typeof value == 'number' && value == toInteger(value);
  15846. }
  15847. /**
  15848. * Checks if `value` is a valid array-like length.
  15849. *
  15850. * **Note:** This method is loosely based on
  15851. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  15852. *
  15853. * @static
  15854. * @memberOf _
  15855. * @since 4.0.0
  15856. * @category Lang
  15857. * @param {*} value The value to check.
  15858. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  15859. * @example
  15860. *
  15861. * _.isLength(3);
  15862. * // => true
  15863. *
  15864. * _.isLength(Number.MIN_VALUE);
  15865. * // => false
  15866. *
  15867. * _.isLength(Infinity);
  15868. * // => false
  15869. *
  15870. * _.isLength('3');
  15871. * // => false
  15872. */
  15873. function isLength(value) {
  15874. return typeof value == 'number' &&
  15875. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  15876. }
  15877. /**
  15878. * Checks if `value` is the
  15879. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  15880. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  15881. *
  15882. * @static
  15883. * @memberOf _
  15884. * @since 0.1.0
  15885. * @category Lang
  15886. * @param {*} value The value to check.
  15887. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  15888. * @example
  15889. *
  15890. * _.isObject({});
  15891. * // => true
  15892. *
  15893. * _.isObject([1, 2, 3]);
  15894. * // => true
  15895. *
  15896. * _.isObject(_.noop);
  15897. * // => true
  15898. *
  15899. * _.isObject(null);
  15900. * // => false
  15901. */
  15902. function isObject(value) {
  15903. var type = typeof value;
  15904. return value != null && (type == 'object' || type == 'function');
  15905. }
  15906. /**
  15907. * Checks if `value` is object-like. A value is object-like if it's not `null`
  15908. * and has a `typeof` result of "object".
  15909. *
  15910. * @static
  15911. * @memberOf _
  15912. * @since 4.0.0
  15913. * @category Lang
  15914. * @param {*} value The value to check.
  15915. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  15916. * @example
  15917. *
  15918. * _.isObjectLike({});
  15919. * // => true
  15920. *
  15921. * _.isObjectLike([1, 2, 3]);
  15922. * // => true
  15923. *
  15924. * _.isObjectLike(_.noop);
  15925. * // => false
  15926. *
  15927. * _.isObjectLike(null);
  15928. * // => false
  15929. */
  15930. function isObjectLike(value) {
  15931. return value != null && typeof value == 'object';
  15932. }
  15933. /**
  15934. * Checks if `value` is classified as a `Map` object.
  15935. *
  15936. * @static
  15937. * @memberOf _
  15938. * @since 4.3.0
  15939. * @category Lang
  15940. * @param {*} value The value to check.
  15941. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  15942. * @example
  15943. *
  15944. * _.isMap(new Map);
  15945. * // => true
  15946. *
  15947. * _.isMap(new WeakMap);
  15948. * // => false
  15949. */
  15950. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  15951. /**
  15952. * Performs a partial deep comparison between `object` and `source` to
  15953. * determine if `object` contains equivalent property values.
  15954. *
  15955. * **Note:** This method is equivalent to `_.matches` when `source` is
  15956. * partially applied.
  15957. *
  15958. * Partial comparisons will match empty array and empty object `source`
  15959. * values against any array or object value, respectively. See `_.isEqual`
  15960. * for a list of supported value comparisons.
  15961. *
  15962. * @static
  15963. * @memberOf _
  15964. * @since 3.0.0
  15965. * @category Lang
  15966. * @param {Object} object The object to inspect.
  15967. * @param {Object} source The object of property values to match.
  15968. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  15969. * @example
  15970. *
  15971. * var object = { 'a': 1, 'b': 2 };
  15972. *
  15973. * _.isMatch(object, { 'b': 2 });
  15974. * // => true
  15975. *
  15976. * _.isMatch(object, { 'b': 1 });
  15977. * // => false
  15978. */
  15979. function isMatch(object, source) {
  15980. return object === source || baseIsMatch(object, source, getMatchData(source));
  15981. }
  15982. /**
  15983. * This method is like `_.isMatch` except that it accepts `customizer` which
  15984. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  15985. * are handled by the method instead. The `customizer` is invoked with five
  15986. * arguments: (objValue, srcValue, index|key, object, source).
  15987. *
  15988. * @static
  15989. * @memberOf _
  15990. * @since 4.0.0
  15991. * @category Lang
  15992. * @param {Object} object The object to inspect.
  15993. * @param {Object} source The object of property values to match.
  15994. * @param {Function} [customizer] The function to customize comparisons.
  15995. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  15996. * @example
  15997. *
  15998. * function isGreeting(value) {
  15999. * return /^h(?:i|ello)$/.test(value);
  16000. * }
  16001. *
  16002. * function customizer(objValue, srcValue) {
  16003. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  16004. * return true;
  16005. * }
  16006. * }
  16007. *
  16008. * var object = { 'greeting': 'hello' };
  16009. * var source = { 'greeting': 'hi' };
  16010. *
  16011. * _.isMatchWith(object, source, customizer);
  16012. * // => true
  16013. */
  16014. function isMatchWith(object, source, customizer) {
  16015. customizer = typeof customizer == 'function' ? customizer : undefined;
  16016. return baseIsMatch(object, source, getMatchData(source), customizer);
  16017. }
  16018. /**
  16019. * Checks if `value` is `NaN`.
  16020. *
  16021. * **Note:** This method is based on
  16022. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  16023. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  16024. * `undefined` and other non-number values.
  16025. *
  16026. * @static
  16027. * @memberOf _
  16028. * @since 0.1.0
  16029. * @category Lang
  16030. * @param {*} value The value to check.
  16031. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  16032. * @example
  16033. *
  16034. * _.isNaN(NaN);
  16035. * // => true
  16036. *
  16037. * _.isNaN(new Number(NaN));
  16038. * // => true
  16039. *
  16040. * isNaN(undefined);
  16041. * // => true
  16042. *
  16043. * _.isNaN(undefined);
  16044. * // => false
  16045. */
  16046. function isNaN(value) {
  16047. // An `NaN` primitive is the only value that is not equal to itself.
  16048. // Perform the `toStringTag` check first to avoid errors with some
  16049. // ActiveX objects in IE.
  16050. return isNumber(value) && value != +value;
  16051. }
  16052. /**
  16053. * Checks if `value` is a pristine native function.
  16054. *
  16055. * **Note:** This method can't reliably detect native functions in the presence
  16056. * of the core-js package because core-js circumvents this kind of detection.
  16057. * Despite multiple requests, the core-js maintainer has made it clear: any
  16058. * attempt to fix the detection will be obstructed. As a result, we're left
  16059. * with little choice but to throw an error. Unfortunately, this also affects
  16060. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  16061. * which rely on core-js.
  16062. *
  16063. * @static
  16064. * @memberOf _
  16065. * @since 3.0.0
  16066. * @category Lang
  16067. * @param {*} value The value to check.
  16068. * @returns {boolean} Returns `true` if `value` is a native function,
  16069. * else `false`.
  16070. * @example
  16071. *
  16072. * _.isNative(Array.prototype.push);
  16073. * // => true
  16074. *
  16075. * _.isNative(_);
  16076. * // => false
  16077. */
  16078. function isNative(value) {
  16079. if (isMaskable(value)) {
  16080. throw new Error(CORE_ERROR_TEXT);
  16081. }
  16082. return baseIsNative(value);
  16083. }
  16084. /**
  16085. * Checks if `value` is `null`.
  16086. *
  16087. * @static
  16088. * @memberOf _
  16089. * @since 0.1.0
  16090. * @category Lang
  16091. * @param {*} value The value to check.
  16092. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  16093. * @example
  16094. *
  16095. * _.isNull(null);
  16096. * // => true
  16097. *
  16098. * _.isNull(void 0);
  16099. * // => false
  16100. */
  16101. function isNull(value) {
  16102. return value === null;
  16103. }
  16104. /**
  16105. * Checks if `value` is `null` or `undefined`.
  16106. *
  16107. * @static
  16108. * @memberOf _
  16109. * @since 4.0.0
  16110. * @category Lang
  16111. * @param {*} value The value to check.
  16112. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  16113. * @example
  16114. *
  16115. * _.isNil(null);
  16116. * // => true
  16117. *
  16118. * _.isNil(void 0);
  16119. * // => true
  16120. *
  16121. * _.isNil(NaN);
  16122. * // => false
  16123. */
  16124. function isNil(value) {
  16125. return value == null;
  16126. }
  16127. /**
  16128. * Checks if `value` is classified as a `Number` primitive or object.
  16129. *
  16130. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  16131. * classified as numbers, use the `_.isFinite` method.
  16132. *
  16133. * @static
  16134. * @memberOf _
  16135. * @since 0.1.0
  16136. * @category Lang
  16137. * @param {*} value The value to check.
  16138. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  16139. * @example
  16140. *
  16141. * _.isNumber(3);
  16142. * // => true
  16143. *
  16144. * _.isNumber(Number.MIN_VALUE);
  16145. * // => true
  16146. *
  16147. * _.isNumber(Infinity);
  16148. * // => true
  16149. *
  16150. * _.isNumber('3');
  16151. * // => false
  16152. */
  16153. function isNumber(value) {
  16154. return typeof value == 'number' ||
  16155. (isObjectLike(value) && baseGetTag(value) == numberTag);
  16156. }
  16157. /**
  16158. * Checks if `value` is a plain object, that is, an object created by the
  16159. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  16160. *
  16161. * @static
  16162. * @memberOf _
  16163. * @since 0.8.0
  16164. * @category Lang
  16165. * @param {*} value The value to check.
  16166. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  16167. * @example
  16168. *
  16169. * function Foo() {
  16170. * this.a = 1;
  16171. * }
  16172. *
  16173. * _.isPlainObject(new Foo);
  16174. * // => false
  16175. *
  16176. * _.isPlainObject([1, 2, 3]);
  16177. * // => false
  16178. *
  16179. * _.isPlainObject({ 'x': 0, 'y': 0 });
  16180. * // => true
  16181. *
  16182. * _.isPlainObject(Object.create(null));
  16183. * // => true
  16184. */
  16185. function isPlainObject(value) {
  16186. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  16187. return false;
  16188. }
  16189. var proto = getPrototype(value);
  16190. if (proto === null) {
  16191. return true;
  16192. }
  16193. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  16194. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  16195. funcToString.call(Ctor) == objectCtorString;
  16196. }
  16197. /**
  16198. * Checks if `value` is classified as a `RegExp` object.
  16199. *
  16200. * @static
  16201. * @memberOf _
  16202. * @since 0.1.0
  16203. * @category Lang
  16204. * @param {*} value The value to check.
  16205. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  16206. * @example
  16207. *
  16208. * _.isRegExp(/abc/);
  16209. * // => true
  16210. *
  16211. * _.isRegExp('/abc/');
  16212. * // => false
  16213. */
  16214. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  16215. /**
  16216. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  16217. * double precision number which isn't the result of a rounded unsafe integer.
  16218. *
  16219. * **Note:** This method is based on
  16220. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  16221. *
  16222. * @static
  16223. * @memberOf _
  16224. * @since 4.0.0
  16225. * @category Lang
  16226. * @param {*} value The value to check.
  16227. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  16228. * @example
  16229. *
  16230. * _.isSafeInteger(3);
  16231. * // => true
  16232. *
  16233. * _.isSafeInteger(Number.MIN_VALUE);
  16234. * // => false
  16235. *
  16236. * _.isSafeInteger(Infinity);
  16237. * // => false
  16238. *
  16239. * _.isSafeInteger('3');
  16240. * // => false
  16241. */
  16242. function isSafeInteger(value) {
  16243. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  16244. }
  16245. /**
  16246. * Checks if `value` is classified as a `Set` object.
  16247. *
  16248. * @static
  16249. * @memberOf _
  16250. * @since 4.3.0
  16251. * @category Lang
  16252. * @param {*} value The value to check.
  16253. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  16254. * @example
  16255. *
  16256. * _.isSet(new Set);
  16257. * // => true
  16258. *
  16259. * _.isSet(new WeakSet);
  16260. * // => false
  16261. */
  16262. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  16263. /**
  16264. * Checks if `value` is classified as a `String` primitive or object.
  16265. *
  16266. * @static
  16267. * @since 0.1.0
  16268. * @memberOf _
  16269. * @category Lang
  16270. * @param {*} value The value to check.
  16271. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  16272. * @example
  16273. *
  16274. * _.isString('abc');
  16275. * // => true
  16276. *
  16277. * _.isString(1);
  16278. * // => false
  16279. */
  16280. function isString(value) {
  16281. return typeof value == 'string' ||
  16282. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  16283. }
  16284. /**
  16285. * Checks if `value` is classified as a `Symbol` primitive or object.
  16286. *
  16287. * @static
  16288. * @memberOf _
  16289. * @since 4.0.0
  16290. * @category Lang
  16291. * @param {*} value The value to check.
  16292. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  16293. * @example
  16294. *
  16295. * _.isSymbol(Symbol.iterator);
  16296. * // => true
  16297. *
  16298. * _.isSymbol('abc');
  16299. * // => false
  16300. */
  16301. function isSymbol(value) {
  16302. return typeof value == 'symbol' ||
  16303. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  16304. }
  16305. /**
  16306. * Checks if `value` is classified as a typed array.
  16307. *
  16308. * @static
  16309. * @memberOf _
  16310. * @since 3.0.0
  16311. * @category Lang
  16312. * @param {*} value The value to check.
  16313. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  16314. * @example
  16315. *
  16316. * _.isTypedArray(new Uint8Array);
  16317. * // => true
  16318. *
  16319. * _.isTypedArray([]);
  16320. * // => false
  16321. */
  16322. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  16323. /**
  16324. * Checks if `value` is `undefined`.
  16325. *
  16326. * @static
  16327. * @since 0.1.0
  16328. * @memberOf _
  16329. * @category Lang
  16330. * @param {*} value The value to check.
  16331. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  16332. * @example
  16333. *
  16334. * _.isUndefined(void 0);
  16335. * // => true
  16336. *
  16337. * _.isUndefined(null);
  16338. * // => false
  16339. */
  16340. function isUndefined(value) {
  16341. return value === undefined;
  16342. }
  16343. /**
  16344. * Checks if `value` is classified as a `WeakMap` object.
  16345. *
  16346. * @static
  16347. * @memberOf _
  16348. * @since 4.3.0
  16349. * @category Lang
  16350. * @param {*} value The value to check.
  16351. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  16352. * @example
  16353. *
  16354. * _.isWeakMap(new WeakMap);
  16355. * // => true
  16356. *
  16357. * _.isWeakMap(new Map);
  16358. * // => false
  16359. */
  16360. function isWeakMap(value) {
  16361. return isObjectLike(value) && getTag(value) == weakMapTag;
  16362. }
  16363. /**
  16364. * Checks if `value` is classified as a `WeakSet` object.
  16365. *
  16366. * @static
  16367. * @memberOf _
  16368. * @since 4.3.0
  16369. * @category Lang
  16370. * @param {*} value The value to check.
  16371. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  16372. * @example
  16373. *
  16374. * _.isWeakSet(new WeakSet);
  16375. * // => true
  16376. *
  16377. * _.isWeakSet(new Set);
  16378. * // => false
  16379. */
  16380. function isWeakSet(value) {
  16381. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  16382. }
  16383. /**
  16384. * Checks if `value` is less than `other`.
  16385. *
  16386. * @static
  16387. * @memberOf _
  16388. * @since 3.9.0
  16389. * @category Lang
  16390. * @param {*} value The value to compare.
  16391. * @param {*} other The other value to compare.
  16392. * @returns {boolean} Returns `true` if `value` is less than `other`,
  16393. * else `false`.
  16394. * @see _.gt
  16395. * @example
  16396. *
  16397. * _.lt(1, 3);
  16398. * // => true
  16399. *
  16400. * _.lt(3, 3);
  16401. * // => false
  16402. *
  16403. * _.lt(3, 1);
  16404. * // => false
  16405. */
  16406. var lt = createRelationalOperation(baseLt);
  16407. /**
  16408. * Checks if `value` is less than or equal to `other`.
  16409. *
  16410. * @static
  16411. * @memberOf _
  16412. * @since 3.9.0
  16413. * @category Lang
  16414. * @param {*} value The value to compare.
  16415. * @param {*} other The other value to compare.
  16416. * @returns {boolean} Returns `true` if `value` is less than or equal to
  16417. * `other`, else `false`.
  16418. * @see _.gte
  16419. * @example
  16420. *
  16421. * _.lte(1, 3);
  16422. * // => true
  16423. *
  16424. * _.lte(3, 3);
  16425. * // => true
  16426. *
  16427. * _.lte(3, 1);
  16428. * // => false
  16429. */
  16430. var lte = createRelationalOperation(function(value, other) {
  16431. return value <= other;
  16432. });
  16433. /**
  16434. * Converts `value` to an array.
  16435. *
  16436. * @static
  16437. * @since 0.1.0
  16438. * @memberOf _
  16439. * @category Lang
  16440. * @param {*} value The value to convert.
  16441. * @returns {Array} Returns the converted array.
  16442. * @example
  16443. *
  16444. * _.toArray({ 'a': 1, 'b': 2 });
  16445. * // => [1, 2]
  16446. *
  16447. * _.toArray('abc');
  16448. * // => ['a', 'b', 'c']
  16449. *
  16450. * _.toArray(1);
  16451. * // => []
  16452. *
  16453. * _.toArray(null);
  16454. * // => []
  16455. */
  16456. function toArray(value) {
  16457. if (!value) {
  16458. return [];
  16459. }
  16460. if (isArrayLike(value)) {
  16461. return isString(value) ? stringToArray(value) : copyArray(value);
  16462. }
  16463. if (symIterator && value[symIterator]) {
  16464. return iteratorToArray(value[symIterator]());
  16465. }
  16466. var tag = getTag(value),
  16467. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  16468. return func(value);
  16469. }
  16470. /**
  16471. * Converts `value` to a finite number.
  16472. *
  16473. * @static
  16474. * @memberOf _
  16475. * @since 4.12.0
  16476. * @category Lang
  16477. * @param {*} value The value to convert.
  16478. * @returns {number} Returns the converted number.
  16479. * @example
  16480. *
  16481. * _.toFinite(3.2);
  16482. * // => 3.2
  16483. *
  16484. * _.toFinite(Number.MIN_VALUE);
  16485. * // => 5e-324
  16486. *
  16487. * _.toFinite(Infinity);
  16488. * // => 1.7976931348623157e+308
  16489. *
  16490. * _.toFinite('3.2');
  16491. * // => 3.2
  16492. */
  16493. function toFinite(value) {
  16494. if (!value) {
  16495. return value === 0 ? value : 0;
  16496. }
  16497. value = toNumber(value);
  16498. if (value === INFINITY || value === -INFINITY) {
  16499. var sign = (value < 0 ? -1 : 1);
  16500. return sign * MAX_INTEGER;
  16501. }
  16502. return value === value ? value : 0;
  16503. }
  16504. /**
  16505. * Converts `value` to an integer.
  16506. *
  16507. * **Note:** This method is loosely based on
  16508. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  16509. *
  16510. * @static
  16511. * @memberOf _
  16512. * @since 4.0.0
  16513. * @category Lang
  16514. * @param {*} value The value to convert.
  16515. * @returns {number} Returns the converted integer.
  16516. * @example
  16517. *
  16518. * _.toInteger(3.2);
  16519. * // => 3
  16520. *
  16521. * _.toInteger(Number.MIN_VALUE);
  16522. * // => 0
  16523. *
  16524. * _.toInteger(Infinity);
  16525. * // => 1.7976931348623157e+308
  16526. *
  16527. * _.toInteger('3.2');
  16528. * // => 3
  16529. */
  16530. function toInteger(value) {
  16531. var result = toFinite(value),
  16532. remainder = result % 1;
  16533. return result === result ? (remainder ? result - remainder : result) : 0;
  16534. }
  16535. /**
  16536. * Converts `value` to an integer suitable for use as the length of an
  16537. * array-like object.
  16538. *
  16539. * **Note:** This method is based on
  16540. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  16541. *
  16542. * @static
  16543. * @memberOf _
  16544. * @since 4.0.0
  16545. * @category Lang
  16546. * @param {*} value The value to convert.
  16547. * @returns {number} Returns the converted integer.
  16548. * @example
  16549. *
  16550. * _.toLength(3.2);
  16551. * // => 3
  16552. *
  16553. * _.toLength(Number.MIN_VALUE);
  16554. * // => 0
  16555. *
  16556. * _.toLength(Infinity);
  16557. * // => 4294967295
  16558. *
  16559. * _.toLength('3.2');
  16560. * // => 3
  16561. */
  16562. function toLength(value) {
  16563. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  16564. }
  16565. /**
  16566. * Converts `value` to a number.
  16567. *
  16568. * @static
  16569. * @memberOf _
  16570. * @since 4.0.0
  16571. * @category Lang
  16572. * @param {*} value The value to process.
  16573. * @returns {number} Returns the number.
  16574. * @example
  16575. *
  16576. * _.toNumber(3.2);
  16577. * // => 3.2
  16578. *
  16579. * _.toNumber(Number.MIN_VALUE);
  16580. * // => 5e-324
  16581. *
  16582. * _.toNumber(Infinity);
  16583. * // => Infinity
  16584. *
  16585. * _.toNumber('3.2');
  16586. * // => 3.2
  16587. */
  16588. function toNumber(value) {
  16589. if (typeof value == 'number') {
  16590. return value;
  16591. }
  16592. if (isSymbol(value)) {
  16593. return NAN;
  16594. }
  16595. if (isObject(value)) {
  16596. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  16597. value = isObject(other) ? (other + '') : other;
  16598. }
  16599. if (typeof value != 'string') {
  16600. return value === 0 ? value : +value;
  16601. }
  16602. value = baseTrim(value);
  16603. var isBinary = reIsBinary.test(value);
  16604. return (isBinary || reIsOctal.test(value))
  16605. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  16606. : (reIsBadHex.test(value) ? NAN : +value);
  16607. }
  16608. /**
  16609. * Converts `value` to a plain object flattening inherited enumerable string
  16610. * keyed properties of `value` to own properties of the plain object.
  16611. *
  16612. * @static
  16613. * @memberOf _
  16614. * @since 3.0.0
  16615. * @category Lang
  16616. * @param {*} value The value to convert.
  16617. * @returns {Object} Returns the converted plain object.
  16618. * @example
  16619. *
  16620. * function Foo() {
  16621. * this.b = 2;
  16622. * }
  16623. *
  16624. * Foo.prototype.c = 3;
  16625. *
  16626. * _.assign({ 'a': 1 }, new Foo);
  16627. * // => { 'a': 1, 'b': 2 }
  16628. *
  16629. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  16630. * // => { 'a': 1, 'b': 2, 'c': 3 }
  16631. */
  16632. function toPlainObject(value) {
  16633. return copyObject(value, keysIn(value));
  16634. }
  16635. /**
  16636. * Converts `value` to a safe integer. A safe integer can be compared and
  16637. * represented correctly.
  16638. *
  16639. * @static
  16640. * @memberOf _
  16641. * @since 4.0.0
  16642. * @category Lang
  16643. * @param {*} value The value to convert.
  16644. * @returns {number} Returns the converted integer.
  16645. * @example
  16646. *
  16647. * _.toSafeInteger(3.2);
  16648. * // => 3
  16649. *
  16650. * _.toSafeInteger(Number.MIN_VALUE);
  16651. * // => 0
  16652. *
  16653. * _.toSafeInteger(Infinity);
  16654. * // => 9007199254740991
  16655. *
  16656. * _.toSafeInteger('3.2');
  16657. * // => 3
  16658. */
  16659. function toSafeInteger(value) {
  16660. return value
  16661. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  16662. : (value === 0 ? value : 0);
  16663. }
  16664. /**
  16665. * Converts `value` to a string. An empty string is returned for `null`
  16666. * and `undefined` values. The sign of `-0` is preserved.
  16667. *
  16668. * @static
  16669. * @memberOf _
  16670. * @since 4.0.0
  16671. * @category Lang
  16672. * @param {*} value The value to convert.
  16673. * @returns {string} Returns the converted string.
  16674. * @example
  16675. *
  16676. * _.toString(null);
  16677. * // => ''
  16678. *
  16679. * _.toString(-0);
  16680. * // => '-0'
  16681. *
  16682. * _.toString([1, 2, 3]);
  16683. * // => '1,2,3'
  16684. */
  16685. function toString(value) {
  16686. return value == null ? '' : baseToString(value);
  16687. }
  16688. /*------------------------------------------------------------------------*/
  16689. /**
  16690. * Assigns own enumerable string keyed properties of source objects to the
  16691. * destination object. Source objects are applied from left to right.
  16692. * Subsequent sources overwrite property assignments of previous sources.
  16693. *
  16694. * **Note:** This method mutates `object` and is loosely based on
  16695. * [`Object.assign`](https://mdn.io/Object/assign).
  16696. *
  16697. * @static
  16698. * @memberOf _
  16699. * @since 0.10.0
  16700. * @category Object
  16701. * @param {Object} object The destination object.
  16702. * @param {...Object} [sources] The source objects.
  16703. * @returns {Object} Returns `object`.
  16704. * @see _.assignIn
  16705. * @example
  16706. *
  16707. * function Foo() {
  16708. * this.a = 1;
  16709. * }
  16710. *
  16711. * function Bar() {
  16712. * this.c = 3;
  16713. * }
  16714. *
  16715. * Foo.prototype.b = 2;
  16716. * Bar.prototype.d = 4;
  16717. *
  16718. * _.assign({ 'a': 0 }, new Foo, new Bar);
  16719. * // => { 'a': 1, 'c': 3 }
  16720. */
  16721. var assign = createAssigner(function(object, source) {
  16722. if (isPrototype(source) || isArrayLike(source)) {
  16723. copyObject(source, keys(source), object);
  16724. return;
  16725. }
  16726. for (var key in source) {
  16727. if (hasOwnProperty.call(source, key)) {
  16728. assignValue(object, key, source[key]);
  16729. }
  16730. }
  16731. });
  16732. /**
  16733. * This method is like `_.assign` except that it iterates over own and
  16734. * inherited source properties.
  16735. *
  16736. * **Note:** This method mutates `object`.
  16737. *
  16738. * @static
  16739. * @memberOf _
  16740. * @since 4.0.0
  16741. * @alias extend
  16742. * @category Object
  16743. * @param {Object} object The destination object.
  16744. * @param {...Object} [sources] The source objects.
  16745. * @returns {Object} Returns `object`.
  16746. * @see _.assign
  16747. * @example
  16748. *
  16749. * function Foo() {
  16750. * this.a = 1;
  16751. * }
  16752. *
  16753. * function Bar() {
  16754. * this.c = 3;
  16755. * }
  16756. *
  16757. * Foo.prototype.b = 2;
  16758. * Bar.prototype.d = 4;
  16759. *
  16760. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  16761. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  16762. */
  16763. var assignIn = createAssigner(function(object, source) {
  16764. copyObject(source, keysIn(source), object);
  16765. });
  16766. /**
  16767. * This method is like `_.assignIn` except that it accepts `customizer`
  16768. * which is invoked to produce the assigned values. If `customizer` returns
  16769. * `undefined`, assignment is handled by the method instead. The `customizer`
  16770. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  16771. *
  16772. * **Note:** This method mutates `object`.
  16773. *
  16774. * @static
  16775. * @memberOf _
  16776. * @since 4.0.0
  16777. * @alias extendWith
  16778. * @category Object
  16779. * @param {Object} object The destination object.
  16780. * @param {...Object} sources The source objects.
  16781. * @param {Function} [customizer] The function to customize assigned values.
  16782. * @returns {Object} Returns `object`.
  16783. * @see _.assignWith
  16784. * @example
  16785. *
  16786. * function customizer(objValue, srcValue) {
  16787. * return _.isUndefined(objValue) ? srcValue : objValue;
  16788. * }
  16789. *
  16790. * var defaults = _.partialRight(_.assignInWith, customizer);
  16791. *
  16792. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  16793. * // => { 'a': 1, 'b': 2 }
  16794. */
  16795. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  16796. copyObject(source, keysIn(source), object, customizer);
  16797. });
  16798. /**
  16799. * This method is like `_.assign` except that it accepts `customizer`
  16800. * which is invoked to produce the assigned values. If `customizer` returns
  16801. * `undefined`, assignment is handled by the method instead. The `customizer`
  16802. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  16803. *
  16804. * **Note:** This method mutates `object`.
  16805. *
  16806. * @static
  16807. * @memberOf _
  16808. * @since 4.0.0
  16809. * @category Object
  16810. * @param {Object} object The destination object.
  16811. * @param {...Object} sources The source objects.
  16812. * @param {Function} [customizer] The function to customize assigned values.
  16813. * @returns {Object} Returns `object`.
  16814. * @see _.assignInWith
  16815. * @example
  16816. *
  16817. * function customizer(objValue, srcValue) {
  16818. * return _.isUndefined(objValue) ? srcValue : objValue;
  16819. * }
  16820. *
  16821. * var defaults = _.partialRight(_.assignWith, customizer);
  16822. *
  16823. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  16824. * // => { 'a': 1, 'b': 2 }
  16825. */
  16826. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  16827. copyObject(source, keys(source), object, customizer);
  16828. });
  16829. /**
  16830. * Creates an array of values corresponding to `paths` of `object`.
  16831. *
  16832. * @static
  16833. * @memberOf _
  16834. * @since 1.0.0
  16835. * @category Object
  16836. * @param {Object} object The object to iterate over.
  16837. * @param {...(string|string[])} [paths] The property paths to pick.
  16838. * @returns {Array} Returns the picked values.
  16839. * @example
  16840. *
  16841. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  16842. *
  16843. * _.at(object, ['a[0].b.c', 'a[1]']);
  16844. * // => [3, 4]
  16845. */
  16846. var at = flatRest(baseAt);
  16847. /**
  16848. * Creates an object that inherits from the `prototype` object. If a
  16849. * `properties` object is given, its own enumerable string keyed properties
  16850. * are assigned to the created object.
  16851. *
  16852. * @static
  16853. * @memberOf _
  16854. * @since 2.3.0
  16855. * @category Object
  16856. * @param {Object} prototype The object to inherit from.
  16857. * @param {Object} [properties] The properties to assign to the object.
  16858. * @returns {Object} Returns the new object.
  16859. * @example
  16860. *
  16861. * function Shape() {
  16862. * this.x = 0;
  16863. * this.y = 0;
  16864. * }
  16865. *
  16866. * function Circle() {
  16867. * Shape.call(this);
  16868. * }
  16869. *
  16870. * Circle.prototype = _.create(Shape.prototype, {
  16871. * 'constructor': Circle
  16872. * });
  16873. *
  16874. * var circle = new Circle;
  16875. * circle instanceof Circle;
  16876. * // => true
  16877. *
  16878. * circle instanceof Shape;
  16879. * // => true
  16880. */
  16881. function create(prototype, properties) {
  16882. var result = baseCreate(prototype);
  16883. return properties == null ? result : baseAssign(result, properties);
  16884. }
  16885. /**
  16886. * Assigns own and inherited enumerable string keyed properties of source
  16887. * objects to the destination object for all destination properties that
  16888. * resolve to `undefined`. Source objects are applied from left to right.
  16889. * Once a property is set, additional values of the same property are ignored.
  16890. *
  16891. * **Note:** This method mutates `object`.
  16892. *
  16893. * @static
  16894. * @since 0.1.0
  16895. * @memberOf _
  16896. * @category Object
  16897. * @param {Object} object The destination object.
  16898. * @param {...Object} [sources] The source objects.
  16899. * @returns {Object} Returns `object`.
  16900. * @see _.defaultsDeep
  16901. * @example
  16902. *
  16903. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  16904. * // => { 'a': 1, 'b': 2 }
  16905. */
  16906. var defaults = baseRest(function(object, sources) {
  16907. object = Object(object);
  16908. var index = -1;
  16909. var length = sources.length;
  16910. var guard = length > 2 ? sources[2] : undefined;
  16911. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  16912. length = 1;
  16913. }
  16914. while (++index < length) {
  16915. var source = sources[index];
  16916. var props = keysIn(source);
  16917. var propsIndex = -1;
  16918. var propsLength = props.length;
  16919. while (++propsIndex < propsLength) {
  16920. var key = props[propsIndex];
  16921. var value = object[key];
  16922. if (value === undefined ||
  16923. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  16924. object[key] = source[key];
  16925. }
  16926. }
  16927. }
  16928. return object;
  16929. });
  16930. /**
  16931. * This method is like `_.defaults` except that it recursively assigns
  16932. * default properties.
  16933. *
  16934. * **Note:** This method mutates `object`.
  16935. *
  16936. * @static
  16937. * @memberOf _
  16938. * @since 3.10.0
  16939. * @category Object
  16940. * @param {Object} object The destination object.
  16941. * @param {...Object} [sources] The source objects.
  16942. * @returns {Object} Returns `object`.
  16943. * @see _.defaults
  16944. * @example
  16945. *
  16946. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  16947. * // => { 'a': { 'b': 2, 'c': 3 } }
  16948. */
  16949. var defaultsDeep = baseRest(function(args) {
  16950. args.push(undefined, customDefaultsMerge);
  16951. return apply(mergeWith, undefined, args);
  16952. });
  16953. /**
  16954. * This method is like `_.find` except that it returns the key of the first
  16955. * element `predicate` returns truthy for instead of the element itself.
  16956. *
  16957. * @static
  16958. * @memberOf _
  16959. * @since 1.1.0
  16960. * @category Object
  16961. * @param {Object} object The object to inspect.
  16962. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  16963. * @returns {string|undefined} Returns the key of the matched element,
  16964. * else `undefined`.
  16965. * @example
  16966. *
  16967. * var users = {
  16968. * 'barney': { 'age': 36, 'active': true },
  16969. * 'fred': { 'age': 40, 'active': false },
  16970. * 'pebbles': { 'age': 1, 'active': true }
  16971. * };
  16972. *
  16973. * _.findKey(users, function(o) { return o.age < 40; });
  16974. * // => 'barney' (iteration order is not guaranteed)
  16975. *
  16976. * // The `_.matches` iteratee shorthand.
  16977. * _.findKey(users, { 'age': 1, 'active': true });
  16978. * // => 'pebbles'
  16979. *
  16980. * // The `_.matchesProperty` iteratee shorthand.
  16981. * _.findKey(users, ['active', false]);
  16982. * // => 'fred'
  16983. *
  16984. * // The `_.property` iteratee shorthand.
  16985. * _.findKey(users, 'active');
  16986. * // => 'barney'
  16987. */
  16988. function findKey(object, predicate) {
  16989. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  16990. }
  16991. /**
  16992. * This method is like `_.findKey` except that it iterates over elements of
  16993. * a collection in the opposite order.
  16994. *
  16995. * @static
  16996. * @memberOf _
  16997. * @since 2.0.0
  16998. * @category Object
  16999. * @param {Object} object The object to inspect.
  17000. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  17001. * @returns {string|undefined} Returns the key of the matched element,
  17002. * else `undefined`.
  17003. * @example
  17004. *
  17005. * var users = {
  17006. * 'barney': { 'age': 36, 'active': true },
  17007. * 'fred': { 'age': 40, 'active': false },
  17008. * 'pebbles': { 'age': 1, 'active': true }
  17009. * };
  17010. *
  17011. * _.findLastKey(users, function(o) { return o.age < 40; });
  17012. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  17013. *
  17014. * // The `_.matches` iteratee shorthand.
  17015. * _.findLastKey(users, { 'age': 36, 'active': true });
  17016. * // => 'barney'
  17017. *
  17018. * // The `_.matchesProperty` iteratee shorthand.
  17019. * _.findLastKey(users, ['active', false]);
  17020. * // => 'fred'
  17021. *
  17022. * // The `_.property` iteratee shorthand.
  17023. * _.findLastKey(users, 'active');
  17024. * // => 'pebbles'
  17025. */
  17026. function findLastKey(object, predicate) {
  17027. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  17028. }
  17029. /**
  17030. * Iterates over own and inherited enumerable string keyed properties of an
  17031. * object and invokes `iteratee` for each property. The iteratee is invoked
  17032. * with three arguments: (value, key, object). Iteratee functions may exit
  17033. * iteration early by explicitly returning `false`.
  17034. *
  17035. * @static
  17036. * @memberOf _
  17037. * @since 0.3.0
  17038. * @category Object
  17039. * @param {Object} object The object to iterate over.
  17040. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  17041. * @returns {Object} Returns `object`.
  17042. * @see _.forInRight
  17043. * @example
  17044. *
  17045. * function Foo() {
  17046. * this.a = 1;
  17047. * this.b = 2;
  17048. * }
  17049. *
  17050. * Foo.prototype.c = 3;
  17051. *
  17052. * _.forIn(new Foo, function(value, key) {
  17053. * console.log(key);
  17054. * });
  17055. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  17056. */
  17057. function forIn(object, iteratee) {
  17058. return object == null
  17059. ? object
  17060. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  17061. }
  17062. /**
  17063. * This method is like `_.forIn` except that it iterates over properties of
  17064. * `object` in the opposite order.
  17065. *
  17066. * @static
  17067. * @memberOf _
  17068. * @since 2.0.0
  17069. * @category Object
  17070. * @param {Object} object The object to iterate over.
  17071. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  17072. * @returns {Object} Returns `object`.
  17073. * @see _.forIn
  17074. * @example
  17075. *
  17076. * function Foo() {
  17077. * this.a = 1;
  17078. * this.b = 2;
  17079. * }
  17080. *
  17081. * Foo.prototype.c = 3;
  17082. *
  17083. * _.forInRight(new Foo, function(value, key) {
  17084. * console.log(key);
  17085. * });
  17086. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  17087. */
  17088. function forInRight(object, iteratee) {
  17089. return object == null
  17090. ? object
  17091. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  17092. }
  17093. /**
  17094. * Iterates over own enumerable string keyed properties of an object and
  17095. * invokes `iteratee` for each property. The iteratee is invoked with three
  17096. * arguments: (value, key, object). Iteratee functions may exit iteration
  17097. * early by explicitly returning `false`.
  17098. *
  17099. * @static
  17100. * @memberOf _
  17101. * @since 0.3.0
  17102. * @category Object
  17103. * @param {Object} object The object to iterate over.
  17104. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  17105. * @returns {Object} Returns `object`.
  17106. * @see _.forOwnRight
  17107. * @example
  17108. *
  17109. * function Foo() {
  17110. * this.a = 1;
  17111. * this.b = 2;
  17112. * }
  17113. *
  17114. * Foo.prototype.c = 3;
  17115. *
  17116. * _.forOwn(new Foo, function(value, key) {
  17117. * console.log(key);
  17118. * });
  17119. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  17120. */
  17121. function forOwn(object, iteratee) {
  17122. return object && baseForOwn(object, getIteratee(iteratee, 3));
  17123. }
  17124. /**
  17125. * This method is like `_.forOwn` except that it iterates over properties of
  17126. * `object` in the opposite order.
  17127. *
  17128. * @static
  17129. * @memberOf _
  17130. * @since 2.0.0
  17131. * @category Object
  17132. * @param {Object} object The object to iterate over.
  17133. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  17134. * @returns {Object} Returns `object`.
  17135. * @see _.forOwn
  17136. * @example
  17137. *
  17138. * function Foo() {
  17139. * this.a = 1;
  17140. * this.b = 2;
  17141. * }
  17142. *
  17143. * Foo.prototype.c = 3;
  17144. *
  17145. * _.forOwnRight(new Foo, function(value, key) {
  17146. * console.log(key);
  17147. * });
  17148. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  17149. */
  17150. function forOwnRight(object, iteratee) {
  17151. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  17152. }
  17153. /**
  17154. * Creates an array of function property names from own enumerable properties
  17155. * of `object`.
  17156. *
  17157. * @static
  17158. * @since 0.1.0
  17159. * @memberOf _
  17160. * @category Object
  17161. * @param {Object} object The object to inspect.
  17162. * @returns {Array} Returns the function names.
  17163. * @see _.functionsIn
  17164. * @example
  17165. *
  17166. * function Foo() {
  17167. * this.a = _.constant('a');
  17168. * this.b = _.constant('b');
  17169. * }
  17170. *
  17171. * Foo.prototype.c = _.constant('c');
  17172. *
  17173. * _.functions(new Foo);
  17174. * // => ['a', 'b']
  17175. */
  17176. function functions(object) {
  17177. return object == null ? [] : baseFunctions(object, keys(object));
  17178. }
  17179. /**
  17180. * Creates an array of function property names from own and inherited
  17181. * enumerable properties of `object`.
  17182. *
  17183. * @static
  17184. * @memberOf _
  17185. * @since 4.0.0
  17186. * @category Object
  17187. * @param {Object} object The object to inspect.
  17188. * @returns {Array} Returns the function names.
  17189. * @see _.functions
  17190. * @example
  17191. *
  17192. * function Foo() {
  17193. * this.a = _.constant('a');
  17194. * this.b = _.constant('b');
  17195. * }
  17196. *
  17197. * Foo.prototype.c = _.constant('c');
  17198. *
  17199. * _.functionsIn(new Foo);
  17200. * // => ['a', 'b', 'c']
  17201. */
  17202. function functionsIn(object) {
  17203. return object == null ? [] : baseFunctions(object, keysIn(object));
  17204. }
  17205. /**
  17206. * Gets the value at `path` of `object`. If the resolved value is
  17207. * `undefined`, the `defaultValue` is returned in its place.
  17208. *
  17209. * @static
  17210. * @memberOf _
  17211. * @since 3.7.0
  17212. * @category Object
  17213. * @param {Object} object The object to query.
  17214. * @param {Array|string} path The path of the property to get.
  17215. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  17216. * @returns {*} Returns the resolved value.
  17217. * @example
  17218. *
  17219. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  17220. *
  17221. * _.get(object, 'a[0].b.c');
  17222. * // => 3
  17223. *
  17224. * _.get(object, ['a', '0', 'b', 'c']);
  17225. * // => 3
  17226. *
  17227. * _.get(object, 'a.b.c', 'default');
  17228. * // => 'default'
  17229. */
  17230. function get(object, path, defaultValue) {
  17231. var result = object == null ? undefined : baseGet(object, path);
  17232. return result === undefined ? defaultValue : result;
  17233. }
  17234. /**
  17235. * Checks if `path` is a direct property of `object`.
  17236. *
  17237. * @static
  17238. * @since 0.1.0
  17239. * @memberOf _
  17240. * @category Object
  17241. * @param {Object} object The object to query.
  17242. * @param {Array|string} path The path to check.
  17243. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  17244. * @example
  17245. *
  17246. * var object = { 'a': { 'b': 2 } };
  17247. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  17248. *
  17249. * _.has(object, 'a');
  17250. * // => true
  17251. *
  17252. * _.has(object, 'a.b');
  17253. * // => true
  17254. *
  17255. * _.has(object, ['a', 'b']);
  17256. * // => true
  17257. *
  17258. * _.has(other, 'a');
  17259. * // => false
  17260. */
  17261. function has(object, path) {
  17262. return object != null && hasPath(object, path, baseHas);
  17263. }
  17264. /**
  17265. * Checks if `path` is a direct or inherited property of `object`.
  17266. *
  17267. * @static
  17268. * @memberOf _
  17269. * @since 4.0.0
  17270. * @category Object
  17271. * @param {Object} object The object to query.
  17272. * @param {Array|string} path The path to check.
  17273. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  17274. * @example
  17275. *
  17276. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  17277. *
  17278. * _.hasIn(object, 'a');
  17279. * // => true
  17280. *
  17281. * _.hasIn(object, 'a.b');
  17282. * // => true
  17283. *
  17284. * _.hasIn(object, ['a', 'b']);
  17285. * // => true
  17286. *
  17287. * _.hasIn(object, 'b');
  17288. * // => false
  17289. */
  17290. function hasIn(object, path) {
  17291. return object != null && hasPath(object, path, baseHasIn);
  17292. }
  17293. /**
  17294. * Creates an object composed of the inverted keys and values of `object`.
  17295. * If `object` contains duplicate values, subsequent values overwrite
  17296. * property assignments of previous values.
  17297. *
  17298. * @static
  17299. * @memberOf _
  17300. * @since 0.7.0
  17301. * @category Object
  17302. * @param {Object} object The object to invert.
  17303. * @returns {Object} Returns the new inverted object.
  17304. * @example
  17305. *
  17306. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  17307. *
  17308. * _.invert(object);
  17309. * // => { '1': 'c', '2': 'b' }
  17310. */
  17311. var invert = createInverter(function(result, value, key) {
  17312. if (value != null &&
  17313. typeof value.toString != 'function') {
  17314. value = nativeObjectToString.call(value);
  17315. }
  17316. result[value] = key;
  17317. }, constant(identity));
  17318. /**
  17319. * This method is like `_.invert` except that the inverted object is generated
  17320. * from the results of running each element of `object` thru `iteratee`. The
  17321. * corresponding inverted value of each inverted key is an array of keys
  17322. * responsible for generating the inverted value. The iteratee is invoked
  17323. * with one argument: (value).
  17324. *
  17325. * @static
  17326. * @memberOf _
  17327. * @since 4.1.0
  17328. * @category Object
  17329. * @param {Object} object The object to invert.
  17330. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  17331. * @returns {Object} Returns the new inverted object.
  17332. * @example
  17333. *
  17334. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  17335. *
  17336. * _.invertBy(object);
  17337. * // => { '1': ['a', 'c'], '2': ['b'] }
  17338. *
  17339. * _.invertBy(object, function(value) {
  17340. * return 'group' + value;
  17341. * });
  17342. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  17343. */
  17344. var invertBy = createInverter(function(result, value, key) {
  17345. if (value != null &&
  17346. typeof value.toString != 'function') {
  17347. value = nativeObjectToString.call(value);
  17348. }
  17349. if (hasOwnProperty.call(result, value)) {
  17350. result[value].push(key);
  17351. } else {
  17352. result[value] = [key];
  17353. }
  17354. }, getIteratee);
  17355. /**
  17356. * Invokes the method at `path` of `object`.
  17357. *
  17358. * @static
  17359. * @memberOf _
  17360. * @since 4.0.0
  17361. * @category Object
  17362. * @param {Object} object The object to query.
  17363. * @param {Array|string} path The path of the method to invoke.
  17364. * @param {...*} [args] The arguments to invoke the method with.
  17365. * @returns {*} Returns the result of the invoked method.
  17366. * @example
  17367. *
  17368. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  17369. *
  17370. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  17371. * // => [2, 3]
  17372. */
  17373. var invoke = baseRest(baseInvoke);
  17374. /**
  17375. * Creates an array of the own enumerable property names of `object`.
  17376. *
  17377. * **Note:** Non-object values are coerced to objects. See the
  17378. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  17379. * for more details.
  17380. *
  17381. * @static
  17382. * @since 0.1.0
  17383. * @memberOf _
  17384. * @category Object
  17385. * @param {Object} object The object to query.
  17386. * @returns {Array} Returns the array of property names.
  17387. * @example
  17388. *
  17389. * function Foo() {
  17390. * this.a = 1;
  17391. * this.b = 2;
  17392. * }
  17393. *
  17394. * Foo.prototype.c = 3;
  17395. *
  17396. * _.keys(new Foo);
  17397. * // => ['a', 'b'] (iteration order is not guaranteed)
  17398. *
  17399. * _.keys('hi');
  17400. * // => ['0', '1']
  17401. */
  17402. function keys(object) {
  17403. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  17404. }
  17405. /**
  17406. * Creates an array of the own and inherited enumerable property names of `object`.
  17407. *
  17408. * **Note:** Non-object values are coerced to objects.
  17409. *
  17410. * @static
  17411. * @memberOf _
  17412. * @since 3.0.0
  17413. * @category Object
  17414. * @param {Object} object The object to query.
  17415. * @returns {Array} Returns the array of property names.
  17416. * @example
  17417. *
  17418. * function Foo() {
  17419. * this.a = 1;
  17420. * this.b = 2;
  17421. * }
  17422. *
  17423. * Foo.prototype.c = 3;
  17424. *
  17425. * _.keysIn(new Foo);
  17426. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  17427. */
  17428. function keysIn(object) {
  17429. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  17430. }
  17431. /**
  17432. * The opposite of `_.mapValues`; this method creates an object with the
  17433. * same values as `object` and keys generated by running each own enumerable
  17434. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  17435. * with three arguments: (value, key, object).
  17436. *
  17437. * @static
  17438. * @memberOf _
  17439. * @since 3.8.0
  17440. * @category Object
  17441. * @param {Object} object The object to iterate over.
  17442. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  17443. * @returns {Object} Returns the new mapped object.
  17444. * @see _.mapValues
  17445. * @example
  17446. *
  17447. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  17448. * return key + value;
  17449. * });
  17450. * // => { 'a1': 1, 'b2': 2 }
  17451. */
  17452. function mapKeys(object, iteratee) {
  17453. var result = {};
  17454. iteratee = getIteratee(iteratee, 3);
  17455. baseForOwn(object, function(value, key, object) {
  17456. baseAssignValue(result, iteratee(value, key, object), value);
  17457. });
  17458. return result;
  17459. }
  17460. /**
  17461. * Creates an object with the same keys as `object` and values generated
  17462. * by running each own enumerable string keyed property of `object` thru
  17463. * `iteratee`. The iteratee is invoked with three arguments:
  17464. * (value, key, object).
  17465. *
  17466. * @static
  17467. * @memberOf _
  17468. * @since 2.4.0
  17469. * @category Object
  17470. * @param {Object} object The object to iterate over.
  17471. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  17472. * @returns {Object} Returns the new mapped object.
  17473. * @see _.mapKeys
  17474. * @example
  17475. *
  17476. * var users = {
  17477. * 'fred': { 'user': 'fred', 'age': 40 },
  17478. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  17479. * };
  17480. *
  17481. * _.mapValues(users, function(o) { return o.age; });
  17482. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  17483. *
  17484. * // The `_.property` iteratee shorthand.
  17485. * _.mapValues(users, 'age');
  17486. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  17487. */
  17488. function mapValues(object, iteratee) {
  17489. var result = {};
  17490. iteratee = getIteratee(iteratee, 3);
  17491. baseForOwn(object, function(value, key, object) {
  17492. baseAssignValue(result, key, iteratee(value, key, object));
  17493. });
  17494. return result;
  17495. }
  17496. /**
  17497. * This method is like `_.assign` except that it recursively merges own and
  17498. * inherited enumerable string keyed properties of source objects into the
  17499. * destination object. Source properties that resolve to `undefined` are
  17500. * skipped if a destination value exists. Array and plain object properties
  17501. * are merged recursively. Other objects and value types are overridden by
  17502. * assignment. Source objects are applied from left to right. Subsequent
  17503. * sources overwrite property assignments of previous sources.
  17504. *
  17505. * **Note:** This method mutates `object`.
  17506. *
  17507. * @static
  17508. * @memberOf _
  17509. * @since 0.5.0
  17510. * @category Object
  17511. * @param {Object} object The destination object.
  17512. * @param {...Object} [sources] The source objects.
  17513. * @returns {Object} Returns `object`.
  17514. * @example
  17515. *
  17516. * var object = {
  17517. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  17518. * };
  17519. *
  17520. * var other = {
  17521. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  17522. * };
  17523. *
  17524. * _.merge(object, other);
  17525. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  17526. */
  17527. var merge = createAssigner(function(object, source, srcIndex) {
  17528. baseMerge(object, source, srcIndex);
  17529. });
  17530. /**
  17531. * This method is like `_.merge` except that it accepts `customizer` which
  17532. * is invoked to produce the merged values of the destination and source
  17533. * properties. If `customizer` returns `undefined`, merging is handled by the
  17534. * method instead. The `customizer` is invoked with six arguments:
  17535. * (objValue, srcValue, key, object, source, stack).
  17536. *
  17537. * **Note:** This method mutates `object`.
  17538. *
  17539. * @static
  17540. * @memberOf _
  17541. * @since 4.0.0
  17542. * @category Object
  17543. * @param {Object} object The destination object.
  17544. * @param {...Object} sources The source objects.
  17545. * @param {Function} customizer The function to customize assigned values.
  17546. * @returns {Object} Returns `object`.
  17547. * @example
  17548. *
  17549. * function customizer(objValue, srcValue) {
  17550. * if (_.isArray(objValue)) {
  17551. * return objValue.concat(srcValue);
  17552. * }
  17553. * }
  17554. *
  17555. * var object = { 'a': [1], 'b': [2] };
  17556. * var other = { 'a': [3], 'b': [4] };
  17557. *
  17558. * _.mergeWith(object, other, customizer);
  17559. * // => { 'a': [1, 3], 'b': [2, 4] }
  17560. */
  17561. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  17562. baseMerge(object, source, srcIndex, customizer);
  17563. });
  17564. /**
  17565. * The opposite of `_.pick`; this method creates an object composed of the
  17566. * own and inherited enumerable property paths of `object` that are not omitted.
  17567. *
  17568. * **Note:** This method is considerably slower than `_.pick`.
  17569. *
  17570. * @static
  17571. * @since 0.1.0
  17572. * @memberOf _
  17573. * @category Object
  17574. * @param {Object} object The source object.
  17575. * @param {...(string|string[])} [paths] The property paths to omit.
  17576. * @returns {Object} Returns the new object.
  17577. * @example
  17578. *
  17579. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  17580. *
  17581. * _.omit(object, ['a', 'c']);
  17582. * // => { 'b': '2' }
  17583. */
  17584. var omit = flatRest(function(object, paths) {
  17585. var result = {};
  17586. if (object == null) {
  17587. return result;
  17588. }
  17589. var isDeep = false;
  17590. paths = arrayMap(paths, function(path) {
  17591. path = castPath(path, object);
  17592. isDeep || (isDeep = path.length > 1);
  17593. return path;
  17594. });
  17595. copyObject(object, getAllKeysIn(object), result);
  17596. if (isDeep) {
  17597. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  17598. }
  17599. var length = paths.length;
  17600. while (length--) {
  17601. baseUnset(result, paths[length]);
  17602. }
  17603. return result;
  17604. });
  17605. /**
  17606. * The opposite of `_.pickBy`; this method creates an object composed of
  17607. * the own and inherited enumerable string keyed properties of `object` that
  17608. * `predicate` doesn't return truthy for. The predicate is invoked with two
  17609. * arguments: (value, key).
  17610. *
  17611. * @static
  17612. * @memberOf _
  17613. * @since 4.0.0
  17614. * @category Object
  17615. * @param {Object} object The source object.
  17616. * @param {Function} [predicate=_.identity] The function invoked per property.
  17617. * @returns {Object} Returns the new object.
  17618. * @example
  17619. *
  17620. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  17621. *
  17622. * _.omitBy(object, _.isNumber);
  17623. * // => { 'b': '2' }
  17624. */
  17625. function omitBy(object, predicate) {
  17626. return pickBy(object, negate(getIteratee(predicate)));
  17627. }
  17628. /**
  17629. * Creates an object composed of the picked `object` properties.
  17630. *
  17631. * @static
  17632. * @since 0.1.0
  17633. * @memberOf _
  17634. * @category Object
  17635. * @param {Object} object The source object.
  17636. * @param {...(string|string[])} [paths] The property paths to pick.
  17637. * @returns {Object} Returns the new object.
  17638. * @example
  17639. *
  17640. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  17641. *
  17642. * _.pick(object, ['a', 'c']);
  17643. * // => { 'a': 1, 'c': 3 }
  17644. */
  17645. var pick = flatRest(function(object, paths) {
  17646. return object == null ? {} : basePick(object, paths);
  17647. });
  17648. /**
  17649. * Creates an object composed of the `object` properties `predicate` returns
  17650. * truthy for. The predicate is invoked with two arguments: (value, key).
  17651. *
  17652. * @static
  17653. * @memberOf _
  17654. * @since 4.0.0
  17655. * @category Object
  17656. * @param {Object} object The source object.
  17657. * @param {Function} [predicate=_.identity] The function invoked per property.
  17658. * @returns {Object} Returns the new object.
  17659. * @example
  17660. *
  17661. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  17662. *
  17663. * _.pickBy(object, _.isNumber);
  17664. * // => { 'a': 1, 'c': 3 }
  17665. */
  17666. function pickBy(object, predicate) {
  17667. if (object == null) {
  17668. return {};
  17669. }
  17670. var props = arrayMap(getAllKeysIn(object), function(prop) {
  17671. return [prop];
  17672. });
  17673. predicate = getIteratee(predicate);
  17674. return basePickBy(object, props, function(value, path) {
  17675. return predicate(value, path[0]);
  17676. });
  17677. }
  17678. /**
  17679. * This method is like `_.get` except that if the resolved value is a
  17680. * function it's invoked with the `this` binding of its parent object and
  17681. * its result is returned.
  17682. *
  17683. * @static
  17684. * @since 0.1.0
  17685. * @memberOf _
  17686. * @category Object
  17687. * @param {Object} object The object to query.
  17688. * @param {Array|string} path The path of the property to resolve.
  17689. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  17690. * @returns {*} Returns the resolved value.
  17691. * @example
  17692. *
  17693. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  17694. *
  17695. * _.result(object, 'a[0].b.c1');
  17696. * // => 3
  17697. *
  17698. * _.result(object, 'a[0].b.c2');
  17699. * // => 4
  17700. *
  17701. * _.result(object, 'a[0].b.c3', 'default');
  17702. * // => 'default'
  17703. *
  17704. * _.result(object, 'a[0].b.c3', _.constant('default'));
  17705. * // => 'default'
  17706. */
  17707. function result(object, path, defaultValue) {
  17708. path = castPath(path, object);
  17709. var index = -1,
  17710. length = path.length;
  17711. // Ensure the loop is entered when path is empty.
  17712. if (!length) {
  17713. length = 1;
  17714. object = undefined;
  17715. }
  17716. while (++index < length) {
  17717. var value = object == null ? undefined : object[toKey(path[index])];
  17718. if (value === undefined) {
  17719. index = length;
  17720. value = defaultValue;
  17721. }
  17722. object = isFunction(value) ? value.call(object) : value;
  17723. }
  17724. return object;
  17725. }
  17726. /**
  17727. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  17728. * it's created. Arrays are created for missing index properties while objects
  17729. * are created for all other missing properties. Use `_.setWith` to customize
  17730. * `path` creation.
  17731. *
  17732. * **Note:** This method mutates `object`.
  17733. *
  17734. * @static
  17735. * @memberOf _
  17736. * @since 3.7.0
  17737. * @category Object
  17738. * @param {Object} object The object to modify.
  17739. * @param {Array|string} path The path of the property to set.
  17740. * @param {*} value The value to set.
  17741. * @returns {Object} Returns `object`.
  17742. * @example
  17743. *
  17744. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  17745. *
  17746. * _.set(object, 'a[0].b.c', 4);
  17747. * console.log(object.a[0].b.c);
  17748. * // => 4
  17749. *
  17750. * _.set(object, ['x', '0', 'y', 'z'], 5);
  17751. * console.log(object.x[0].y.z);
  17752. * // => 5
  17753. */
  17754. function set(object, path, value) {
  17755. return object == null ? object : baseSet(object, path, value);
  17756. }
  17757. /**
  17758. * This method is like `_.set` except that it accepts `customizer` which is
  17759. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  17760. * path creation is handled by the method instead. The `customizer` is invoked
  17761. * with three arguments: (nsValue, key, nsObject).
  17762. *
  17763. * **Note:** This method mutates `object`.
  17764. *
  17765. * @static
  17766. * @memberOf _
  17767. * @since 4.0.0
  17768. * @category Object
  17769. * @param {Object} object The object to modify.
  17770. * @param {Array|string} path The path of the property to set.
  17771. * @param {*} value The value to set.
  17772. * @param {Function} [customizer] The function to customize assigned values.
  17773. * @returns {Object} Returns `object`.
  17774. * @example
  17775. *
  17776. * var object = {};
  17777. *
  17778. * _.setWith(object, '[0][1]', 'a', Object);
  17779. * // => { '0': { '1': 'a' } }
  17780. */
  17781. function setWith(object, path, value, customizer) {
  17782. customizer = typeof customizer == 'function' ? customizer : undefined;
  17783. return object == null ? object : baseSet(object, path, value, customizer);
  17784. }
  17785. /**
  17786. * Creates an array of own enumerable string keyed-value pairs for `object`
  17787. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  17788. * entries are returned.
  17789. *
  17790. * @static
  17791. * @memberOf _
  17792. * @since 4.0.0
  17793. * @alias entries
  17794. * @category Object
  17795. * @param {Object} object The object to query.
  17796. * @returns {Array} Returns the key-value pairs.
  17797. * @example
  17798. *
  17799. * function Foo() {
  17800. * this.a = 1;
  17801. * this.b = 2;
  17802. * }
  17803. *
  17804. * Foo.prototype.c = 3;
  17805. *
  17806. * _.toPairs(new Foo);
  17807. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  17808. */
  17809. var toPairs = createToPairs(keys);
  17810. /**
  17811. * Creates an array of own and inherited enumerable string keyed-value pairs
  17812. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  17813. * or set, its entries are returned.
  17814. *
  17815. * @static
  17816. * @memberOf _
  17817. * @since 4.0.0
  17818. * @alias entriesIn
  17819. * @category Object
  17820. * @param {Object} object The object to query.
  17821. * @returns {Array} Returns the key-value pairs.
  17822. * @example
  17823. *
  17824. * function Foo() {
  17825. * this.a = 1;
  17826. * this.b = 2;
  17827. * }
  17828. *
  17829. * Foo.prototype.c = 3;
  17830. *
  17831. * _.toPairsIn(new Foo);
  17832. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  17833. */
  17834. var toPairsIn = createToPairs(keysIn);
  17835. /**
  17836. * An alternative to `_.reduce`; this method transforms `object` to a new
  17837. * `accumulator` object which is the result of running each of its own
  17838. * enumerable string keyed properties thru `iteratee`, with each invocation
  17839. * potentially mutating the `accumulator` object. If `accumulator` is not
  17840. * provided, a new object with the same `[[Prototype]]` will be used. The
  17841. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  17842. * Iteratee functions may exit iteration early by explicitly returning `false`.
  17843. *
  17844. * @static
  17845. * @memberOf _
  17846. * @since 1.3.0
  17847. * @category Object
  17848. * @param {Object} object The object to iterate over.
  17849. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  17850. * @param {*} [accumulator] The custom accumulator value.
  17851. * @returns {*} Returns the accumulated value.
  17852. * @example
  17853. *
  17854. * _.transform([2, 3, 4], function(result, n) {
  17855. * result.push(n *= n);
  17856. * return n % 2 == 0;
  17857. * }, []);
  17858. * // => [4, 9]
  17859. *
  17860. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  17861. * (result[value] || (result[value] = [])).push(key);
  17862. * }, {});
  17863. * // => { '1': ['a', 'c'], '2': ['b'] }
  17864. */
  17865. function transform(object, iteratee, accumulator) {
  17866. var isArr = isArray(object),
  17867. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  17868. iteratee = getIteratee(iteratee, 4);
  17869. if (accumulator == null) {
  17870. var Ctor = object && object.constructor;
  17871. if (isArrLike) {
  17872. accumulator = isArr ? new Ctor : [];
  17873. }
  17874. else if (isObject(object)) {
  17875. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  17876. }
  17877. else {
  17878. accumulator = {};
  17879. }
  17880. }
  17881. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  17882. return iteratee(accumulator, value, index, object);
  17883. });
  17884. return accumulator;
  17885. }
  17886. /**
  17887. * Removes the property at `path` of `object`.
  17888. *
  17889. * **Note:** This method mutates `object`.
  17890. *
  17891. * @static
  17892. * @memberOf _
  17893. * @since 4.0.0
  17894. * @category Object
  17895. * @param {Object} object The object to modify.
  17896. * @param {Array|string} path The path of the property to unset.
  17897. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  17898. * @example
  17899. *
  17900. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  17901. * _.unset(object, 'a[0].b.c');
  17902. * // => true
  17903. *
  17904. * console.log(object);
  17905. * // => { 'a': [{ 'b': {} }] };
  17906. *
  17907. * _.unset(object, ['a', '0', 'b', 'c']);
  17908. * // => true
  17909. *
  17910. * console.log(object);
  17911. * // => { 'a': [{ 'b': {} }] };
  17912. */
  17913. function unset(object, path) {
  17914. return object == null ? true : baseUnset(object, path);
  17915. }
  17916. /**
  17917. * This method is like `_.set` except that accepts `updater` to produce the
  17918. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  17919. * is invoked with one argument: (value).
  17920. *
  17921. * **Note:** This method mutates `object`.
  17922. *
  17923. * @static
  17924. * @memberOf _
  17925. * @since 4.6.0
  17926. * @category Object
  17927. * @param {Object} object The object to modify.
  17928. * @param {Array|string} path The path of the property to set.
  17929. * @param {Function} updater The function to produce the updated value.
  17930. * @returns {Object} Returns `object`.
  17931. * @example
  17932. *
  17933. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  17934. *
  17935. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  17936. * console.log(object.a[0].b.c);
  17937. * // => 9
  17938. *
  17939. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  17940. * console.log(object.x[0].y.z);
  17941. * // => 0
  17942. */
  17943. function update(object, path, updater) {
  17944. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  17945. }
  17946. /**
  17947. * This method is like `_.update` except that it accepts `customizer` which is
  17948. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  17949. * path creation is handled by the method instead. The `customizer` is invoked
  17950. * with three arguments: (nsValue, key, nsObject).
  17951. *
  17952. * **Note:** This method mutates `object`.
  17953. *
  17954. * @static
  17955. * @memberOf _
  17956. * @since 4.6.0
  17957. * @category Object
  17958. * @param {Object} object The object to modify.
  17959. * @param {Array|string} path The path of the property to set.
  17960. * @param {Function} updater The function to produce the updated value.
  17961. * @param {Function} [customizer] The function to customize assigned values.
  17962. * @returns {Object} Returns `object`.
  17963. * @example
  17964. *
  17965. * var object = {};
  17966. *
  17967. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  17968. * // => { '0': { '1': 'a' } }
  17969. */
  17970. function updateWith(object, path, updater, customizer) {
  17971. customizer = typeof customizer == 'function' ? customizer : undefined;
  17972. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  17973. }
  17974. /**
  17975. * Creates an array of the own enumerable string keyed property values of `object`.
  17976. *
  17977. * **Note:** Non-object values are coerced to objects.
  17978. *
  17979. * @static
  17980. * @since 0.1.0
  17981. * @memberOf _
  17982. * @category Object
  17983. * @param {Object} object The object to query.
  17984. * @returns {Array} Returns the array of property values.
  17985. * @example
  17986. *
  17987. * function Foo() {
  17988. * this.a = 1;
  17989. * this.b = 2;
  17990. * }
  17991. *
  17992. * Foo.prototype.c = 3;
  17993. *
  17994. * _.values(new Foo);
  17995. * // => [1, 2] (iteration order is not guaranteed)
  17996. *
  17997. * _.values('hi');
  17998. * // => ['h', 'i']
  17999. */
  18000. function values(object) {
  18001. return object == null ? [] : baseValues(object, keys(object));
  18002. }
  18003. /**
  18004. * Creates an array of the own and inherited enumerable string keyed property
  18005. * values of `object`.
  18006. *
  18007. * **Note:** Non-object values are coerced to objects.
  18008. *
  18009. * @static
  18010. * @memberOf _
  18011. * @since 3.0.0
  18012. * @category Object
  18013. * @param {Object} object The object to query.
  18014. * @returns {Array} Returns the array of property values.
  18015. * @example
  18016. *
  18017. * function Foo() {
  18018. * this.a = 1;
  18019. * this.b = 2;
  18020. * }
  18021. *
  18022. * Foo.prototype.c = 3;
  18023. *
  18024. * _.valuesIn(new Foo);
  18025. * // => [1, 2, 3] (iteration order is not guaranteed)
  18026. */
  18027. function valuesIn(object) {
  18028. return object == null ? [] : baseValues(object, keysIn(object));
  18029. }
  18030. /*------------------------------------------------------------------------*/
  18031. /**
  18032. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  18033. *
  18034. * @static
  18035. * @memberOf _
  18036. * @since 4.0.0
  18037. * @category Number
  18038. * @param {number} number The number to clamp.
  18039. * @param {number} [lower] The lower bound.
  18040. * @param {number} upper The upper bound.
  18041. * @returns {number} Returns the clamped number.
  18042. * @example
  18043. *
  18044. * _.clamp(-10, -5, 5);
  18045. * // => -5
  18046. *
  18047. * _.clamp(10, -5, 5);
  18048. * // => 5
  18049. */
  18050. function clamp(number, lower, upper) {
  18051. if (upper === undefined) {
  18052. upper = lower;
  18053. lower = undefined;
  18054. }
  18055. if (upper !== undefined) {
  18056. upper = toNumber(upper);
  18057. upper = upper === upper ? upper : 0;
  18058. }
  18059. if (lower !== undefined) {
  18060. lower = toNumber(lower);
  18061. lower = lower === lower ? lower : 0;
  18062. }
  18063. return baseClamp(toNumber(number), lower, upper);
  18064. }
  18065. /**
  18066. * Checks if `n` is between `start` and up to, but not including, `end`. If
  18067. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  18068. * If `start` is greater than `end` the params are swapped to support
  18069. * negative ranges.
  18070. *
  18071. * @static
  18072. * @memberOf _
  18073. * @since 3.3.0
  18074. * @category Number
  18075. * @param {number} number The number to check.
  18076. * @param {number} [start=0] The start of the range.
  18077. * @param {number} end The end of the range.
  18078. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  18079. * @see _.range, _.rangeRight
  18080. * @example
  18081. *
  18082. * _.inRange(3, 2, 4);
  18083. * // => true
  18084. *
  18085. * _.inRange(4, 8);
  18086. * // => true
  18087. *
  18088. * _.inRange(4, 2);
  18089. * // => false
  18090. *
  18091. * _.inRange(2, 2);
  18092. * // => false
  18093. *
  18094. * _.inRange(1.2, 2);
  18095. * // => true
  18096. *
  18097. * _.inRange(5.2, 4);
  18098. * // => false
  18099. *
  18100. * _.inRange(-3, -2, -6);
  18101. * // => true
  18102. */
  18103. function inRange(number, start, end) {
  18104. start = toFinite(start);
  18105. if (end === undefined) {
  18106. end = start;
  18107. start = 0;
  18108. } else {
  18109. end = toFinite(end);
  18110. }
  18111. number = toNumber(number);
  18112. return baseInRange(number, start, end);
  18113. }
  18114. /**
  18115. * Produces a random number between the inclusive `lower` and `upper` bounds.
  18116. * If only one argument is provided a number between `0` and the given number
  18117. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  18118. * floats, a floating-point number is returned instead of an integer.
  18119. *
  18120. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  18121. * floating-point values which can produce unexpected results.
  18122. *
  18123. * @static
  18124. * @memberOf _
  18125. * @since 0.7.0
  18126. * @category Number
  18127. * @param {number} [lower=0] The lower bound.
  18128. * @param {number} [upper=1] The upper bound.
  18129. * @param {boolean} [floating] Specify returning a floating-point number.
  18130. * @returns {number} Returns the random number.
  18131. * @example
  18132. *
  18133. * _.random(0, 5);
  18134. * // => an integer between 0 and 5
  18135. *
  18136. * _.random(5);
  18137. * // => also an integer between 0 and 5
  18138. *
  18139. * _.random(5, true);
  18140. * // => a floating-point number between 0 and 5
  18141. *
  18142. * _.random(1.2, 5.2);
  18143. * // => a floating-point number between 1.2 and 5.2
  18144. */
  18145. function random(lower, upper, floating) {
  18146. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  18147. upper = floating = undefined;
  18148. }
  18149. if (floating === undefined) {
  18150. if (typeof upper == 'boolean') {
  18151. floating = upper;
  18152. upper = undefined;
  18153. }
  18154. else if (typeof lower == 'boolean') {
  18155. floating = lower;
  18156. lower = undefined;
  18157. }
  18158. }
  18159. if (lower === undefined && upper === undefined) {
  18160. lower = 0;
  18161. upper = 1;
  18162. }
  18163. else {
  18164. lower = toFinite(lower);
  18165. if (upper === undefined) {
  18166. upper = lower;
  18167. lower = 0;
  18168. } else {
  18169. upper = toFinite(upper);
  18170. }
  18171. }
  18172. if (lower > upper) {
  18173. var temp = lower;
  18174. lower = upper;
  18175. upper = temp;
  18176. }
  18177. if (floating || lower % 1 || upper % 1) {
  18178. var rand = nativeRandom();
  18179. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  18180. }
  18181. return baseRandom(lower, upper);
  18182. }
  18183. /*------------------------------------------------------------------------*/
  18184. /**
  18185. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  18186. *
  18187. * @static
  18188. * @memberOf _
  18189. * @since 3.0.0
  18190. * @category String
  18191. * @param {string} [string=''] The string to convert.
  18192. * @returns {string} Returns the camel cased string.
  18193. * @example
  18194. *
  18195. * _.camelCase('Foo Bar');
  18196. * // => 'fooBar'
  18197. *
  18198. * _.camelCase('--foo-bar--');
  18199. * // => 'fooBar'
  18200. *
  18201. * _.camelCase('__FOO_BAR__');
  18202. * // => 'fooBar'
  18203. */
  18204. var camelCase = createCompounder(function(result, word, index) {
  18205. word = word.toLowerCase();
  18206. return result + (index ? capitalize(word) : word);
  18207. });
  18208. /**
  18209. * Converts the first character of `string` to upper case and the remaining
  18210. * to lower case.
  18211. *
  18212. * @static
  18213. * @memberOf _
  18214. * @since 3.0.0
  18215. * @category String
  18216. * @param {string} [string=''] The string to capitalize.
  18217. * @returns {string} Returns the capitalized string.
  18218. * @example
  18219. *
  18220. * _.capitalize('FRED');
  18221. * // => 'Fred'
  18222. */
  18223. function capitalize(string) {
  18224. return upperFirst(toString(string).toLowerCase());
  18225. }
  18226. /**
  18227. * Deburrs `string` by converting
  18228. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  18229. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  18230. * letters to basic Latin letters and removing
  18231. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  18232. *
  18233. * @static
  18234. * @memberOf _
  18235. * @since 3.0.0
  18236. * @category String
  18237. * @param {string} [string=''] The string to deburr.
  18238. * @returns {string} Returns the deburred string.
  18239. * @example
  18240. *
  18241. * _.deburr('déjà vu');
  18242. * // => 'deja vu'
  18243. */
  18244. function deburr(string) {
  18245. string = toString(string);
  18246. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  18247. }
  18248. /**
  18249. * Checks if `string` ends with the given target string.
  18250. *
  18251. * @static
  18252. * @memberOf _
  18253. * @since 3.0.0
  18254. * @category String
  18255. * @param {string} [string=''] The string to inspect.
  18256. * @param {string} [target] The string to search for.
  18257. * @param {number} [position=string.length] The position to search up to.
  18258. * @returns {boolean} Returns `true` if `string` ends with `target`,
  18259. * else `false`.
  18260. * @example
  18261. *
  18262. * _.endsWith('abc', 'c');
  18263. * // => true
  18264. *
  18265. * _.endsWith('abc', 'b');
  18266. * // => false
  18267. *
  18268. * _.endsWith('abc', 'b', 2);
  18269. * // => true
  18270. */
  18271. function endsWith(string, target, position) {
  18272. string = toString(string);
  18273. target = baseToString(target);
  18274. var length = string.length;
  18275. position = position === undefined
  18276. ? length
  18277. : baseClamp(toInteger(position), 0, length);
  18278. var end = position;
  18279. position -= target.length;
  18280. return position >= 0 && string.slice(position, end) == target;
  18281. }
  18282. /**
  18283. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  18284. * corresponding HTML entities.
  18285. *
  18286. * **Note:** No other characters are escaped. To escape additional
  18287. * characters use a third-party library like [_he_](https://mths.be/he).
  18288. *
  18289. * Though the ">" character is escaped for symmetry, characters like
  18290. * ">" and "/" don't need escaping in HTML and have no special meaning
  18291. * unless they're part of a tag or unquoted attribute value. See
  18292. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  18293. * (under "semi-related fun fact") for more details.
  18294. *
  18295. * When working with HTML you should always
  18296. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  18297. * XSS vectors.
  18298. *
  18299. * @static
  18300. * @since 0.1.0
  18301. * @memberOf _
  18302. * @category String
  18303. * @param {string} [string=''] The string to escape.
  18304. * @returns {string} Returns the escaped string.
  18305. * @example
  18306. *
  18307. * _.escape('fred, barney, & pebbles');
  18308. * // => 'fred, barney, &amp; pebbles'
  18309. */
  18310. function escape(string) {
  18311. string = toString(string);
  18312. return (string && reHasUnescapedHtml.test(string))
  18313. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  18314. : string;
  18315. }
  18316. /**
  18317. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  18318. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  18319. *
  18320. * @static
  18321. * @memberOf _
  18322. * @since 3.0.0
  18323. * @category String
  18324. * @param {string} [string=''] The string to escape.
  18325. * @returns {string} Returns the escaped string.
  18326. * @example
  18327. *
  18328. * _.escapeRegExp('[lodash](https://lodash.com/)');
  18329. * // => '\[lodash\]\(https://lodash\.com/\)'
  18330. */
  18331. function escapeRegExp(string) {
  18332. string = toString(string);
  18333. return (string && reHasRegExpChar.test(string))
  18334. ? string.replace(reRegExpChar, '\\$&')
  18335. : string;
  18336. }
  18337. /**
  18338. * Converts `string` to
  18339. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  18340. *
  18341. * @static
  18342. * @memberOf _
  18343. * @since 3.0.0
  18344. * @category String
  18345. * @param {string} [string=''] The string to convert.
  18346. * @returns {string} Returns the kebab cased string.
  18347. * @example
  18348. *
  18349. * _.kebabCase('Foo Bar');
  18350. * // => 'foo-bar'
  18351. *
  18352. * _.kebabCase('fooBar');
  18353. * // => 'foo-bar'
  18354. *
  18355. * _.kebabCase('__FOO_BAR__');
  18356. * // => 'foo-bar'
  18357. */
  18358. var kebabCase = createCompounder(function(result, word, index) {
  18359. return result + (index ? '-' : '') + word.toLowerCase();
  18360. });
  18361. /**
  18362. * Converts `string`, as space separated words, to lower case.
  18363. *
  18364. * @static
  18365. * @memberOf _
  18366. * @since 4.0.0
  18367. * @category String
  18368. * @param {string} [string=''] The string to convert.
  18369. * @returns {string} Returns the lower cased string.
  18370. * @example
  18371. *
  18372. * _.lowerCase('--Foo-Bar--');
  18373. * // => 'foo bar'
  18374. *
  18375. * _.lowerCase('fooBar');
  18376. * // => 'foo bar'
  18377. *
  18378. * _.lowerCase('__FOO_BAR__');
  18379. * // => 'foo bar'
  18380. */
  18381. var lowerCase = createCompounder(function(result, word, index) {
  18382. return result + (index ? ' ' : '') + word.toLowerCase();
  18383. });
  18384. /**
  18385. * Converts the first character of `string` to lower case.
  18386. *
  18387. * @static
  18388. * @memberOf _
  18389. * @since 4.0.0
  18390. * @category String
  18391. * @param {string} [string=''] The string to convert.
  18392. * @returns {string} Returns the converted string.
  18393. * @example
  18394. *
  18395. * _.lowerFirst('Fred');
  18396. * // => 'fred'
  18397. *
  18398. * _.lowerFirst('FRED');
  18399. * // => 'fRED'
  18400. */
  18401. var lowerFirst = createCaseFirst('toLowerCase');
  18402. /**
  18403. * Pads `string` on the left and right sides if it's shorter than `length`.
  18404. * Padding characters are truncated if they can't be evenly divided by `length`.
  18405. *
  18406. * @static
  18407. * @memberOf _
  18408. * @since 3.0.0
  18409. * @category String
  18410. * @param {string} [string=''] The string to pad.
  18411. * @param {number} [length=0] The padding length.
  18412. * @param {string} [chars=' '] The string used as padding.
  18413. * @returns {string} Returns the padded string.
  18414. * @example
  18415. *
  18416. * _.pad('abc', 8);
  18417. * // => ' abc '
  18418. *
  18419. * _.pad('abc', 8, '_-');
  18420. * // => '_-abc_-_'
  18421. *
  18422. * _.pad('abc', 3);
  18423. * // => 'abc'
  18424. */
  18425. function pad(string, length, chars) {
  18426. string = toString(string);
  18427. length = toInteger(length);
  18428. var strLength = length ? stringSize(string) : 0;
  18429. if (!length || strLength >= length) {
  18430. return string;
  18431. }
  18432. var mid = (length - strLength) / 2;
  18433. return (
  18434. createPadding(nativeFloor(mid), chars) +
  18435. string +
  18436. createPadding(nativeCeil(mid), chars)
  18437. );
  18438. }
  18439. /**
  18440. * Pads `string` on the right side if it's shorter than `length`. Padding
  18441. * characters are truncated if they exceed `length`.
  18442. *
  18443. * @static
  18444. * @memberOf _
  18445. * @since 4.0.0
  18446. * @category String
  18447. * @param {string} [string=''] The string to pad.
  18448. * @param {number} [length=0] The padding length.
  18449. * @param {string} [chars=' '] The string used as padding.
  18450. * @returns {string} Returns the padded string.
  18451. * @example
  18452. *
  18453. * _.padEnd('abc', 6);
  18454. * // => 'abc '
  18455. *
  18456. * _.padEnd('abc', 6, '_-');
  18457. * // => 'abc_-_'
  18458. *
  18459. * _.padEnd('abc', 3);
  18460. * // => 'abc'
  18461. */
  18462. function padEnd(string, length, chars) {
  18463. string = toString(string);
  18464. length = toInteger(length);
  18465. var strLength = length ? stringSize(string) : 0;
  18466. return (length && strLength < length)
  18467. ? (string + createPadding(length - strLength, chars))
  18468. : string;
  18469. }
  18470. /**
  18471. * Pads `string` on the left side if it's shorter than `length`. Padding
  18472. * characters are truncated if they exceed `length`.
  18473. *
  18474. * @static
  18475. * @memberOf _
  18476. * @since 4.0.0
  18477. * @category String
  18478. * @param {string} [string=''] The string to pad.
  18479. * @param {number} [length=0] The padding length.
  18480. * @param {string} [chars=' '] The string used as padding.
  18481. * @returns {string} Returns the padded string.
  18482. * @example
  18483. *
  18484. * _.padStart('abc', 6);
  18485. * // => ' abc'
  18486. *
  18487. * _.padStart('abc', 6, '_-');
  18488. * // => '_-_abc'
  18489. *
  18490. * _.padStart('abc', 3);
  18491. * // => 'abc'
  18492. */
  18493. function padStart(string, length, chars) {
  18494. string = toString(string);
  18495. length = toInteger(length);
  18496. var strLength = length ? stringSize(string) : 0;
  18497. return (length && strLength < length)
  18498. ? (createPadding(length - strLength, chars) + string)
  18499. : string;
  18500. }
  18501. /**
  18502. * Converts `string` to an integer of the specified radix. If `radix` is
  18503. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  18504. * hexadecimal, in which case a `radix` of `16` is used.
  18505. *
  18506. * **Note:** This method aligns with the
  18507. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  18508. *
  18509. * @static
  18510. * @memberOf _
  18511. * @since 1.1.0
  18512. * @category String
  18513. * @param {string} string The string to convert.
  18514. * @param {number} [radix=10] The radix to interpret `value` by.
  18515. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  18516. * @returns {number} Returns the converted integer.
  18517. * @example
  18518. *
  18519. * _.parseInt('08');
  18520. * // => 8
  18521. *
  18522. * _.map(['6', '08', '10'], _.parseInt);
  18523. * // => [6, 8, 10]
  18524. */
  18525. function parseInt(string, radix, guard) {
  18526. if (guard || radix == null) {
  18527. radix = 0;
  18528. } else if (radix) {
  18529. radix = +radix;
  18530. }
  18531. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  18532. }
  18533. /**
  18534. * Repeats the given string `n` times.
  18535. *
  18536. * @static
  18537. * @memberOf _
  18538. * @since 3.0.0
  18539. * @category String
  18540. * @param {string} [string=''] The string to repeat.
  18541. * @param {number} [n=1] The number of times to repeat the string.
  18542. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  18543. * @returns {string} Returns the repeated string.
  18544. * @example
  18545. *
  18546. * _.repeat('*', 3);
  18547. * // => '***'
  18548. *
  18549. * _.repeat('abc', 2);
  18550. * // => 'abcabc'
  18551. *
  18552. * _.repeat('abc', 0);
  18553. * // => ''
  18554. */
  18555. function repeat(string, n, guard) {
  18556. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  18557. n = 1;
  18558. } else {
  18559. n = toInteger(n);
  18560. }
  18561. return baseRepeat(toString(string), n);
  18562. }
  18563. /**
  18564. * Replaces matches for `pattern` in `string` with `replacement`.
  18565. *
  18566. * **Note:** This method is based on
  18567. * [`String#replace`](https://mdn.io/String/replace).
  18568. *
  18569. * @static
  18570. * @memberOf _
  18571. * @since 4.0.0
  18572. * @category String
  18573. * @param {string} [string=''] The string to modify.
  18574. * @param {RegExp|string} pattern The pattern to replace.
  18575. * @param {Function|string} replacement The match replacement.
  18576. * @returns {string} Returns the modified string.
  18577. * @example
  18578. *
  18579. * _.replace('Hi Fred', 'Fred', 'Barney');
  18580. * // => 'Hi Barney'
  18581. */
  18582. function replace() {
  18583. var args = arguments,
  18584. string = toString(args[0]);
  18585. return args.length < 3 ? string : string.replace(args[1], args[2]);
  18586. }
  18587. /**
  18588. * Converts `string` to
  18589. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  18590. *
  18591. * @static
  18592. * @memberOf _
  18593. * @since 3.0.0
  18594. * @category String
  18595. * @param {string} [string=''] The string to convert.
  18596. * @returns {string} Returns the snake cased string.
  18597. * @example
  18598. *
  18599. * _.snakeCase('Foo Bar');
  18600. * // => 'foo_bar'
  18601. *
  18602. * _.snakeCase('fooBar');
  18603. * // => 'foo_bar'
  18604. *
  18605. * _.snakeCase('--FOO-BAR--');
  18606. * // => 'foo_bar'
  18607. */
  18608. var snakeCase = createCompounder(function(result, word, index) {
  18609. return result + (index ? '_' : '') + word.toLowerCase();
  18610. });
  18611. /**
  18612. * Splits `string` by `separator`.
  18613. *
  18614. * **Note:** This method is based on
  18615. * [`String#split`](https://mdn.io/String/split).
  18616. *
  18617. * @static
  18618. * @memberOf _
  18619. * @since 4.0.0
  18620. * @category String
  18621. * @param {string} [string=''] The string to split.
  18622. * @param {RegExp|string} separator The separator pattern to split by.
  18623. * @param {number} [limit] The length to truncate results to.
  18624. * @returns {Array} Returns the string segments.
  18625. * @example
  18626. *
  18627. * _.split('a-b-c', '-', 2);
  18628. * // => ['a', 'b']
  18629. */
  18630. function split(string, separator, limit) {
  18631. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  18632. separator = limit = undefined;
  18633. }
  18634. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  18635. if (!limit) {
  18636. return [];
  18637. }
  18638. string = toString(string);
  18639. if (string && (
  18640. typeof separator == 'string' ||
  18641. (separator != null && !isRegExp(separator))
  18642. )) {
  18643. separator = baseToString(separator);
  18644. if (!separator && hasUnicode(string)) {
  18645. return castSlice(stringToArray(string), 0, limit);
  18646. }
  18647. }
  18648. return string.split(separator, limit);
  18649. }
  18650. /**
  18651. * Converts `string` to
  18652. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  18653. *
  18654. * @static
  18655. * @memberOf _
  18656. * @since 3.1.0
  18657. * @category String
  18658. * @param {string} [string=''] The string to convert.
  18659. * @returns {string} Returns the start cased string.
  18660. * @example
  18661. *
  18662. * _.startCase('--foo-bar--');
  18663. * // => 'Foo Bar'
  18664. *
  18665. * _.startCase('fooBar');
  18666. * // => 'Foo Bar'
  18667. *
  18668. * _.startCase('__FOO_BAR__');
  18669. * // => 'FOO BAR'
  18670. */
  18671. var startCase = createCompounder(function(result, word, index) {
  18672. return result + (index ? ' ' : '') + upperFirst(word);
  18673. });
  18674. /**
  18675. * Checks if `string` starts with the given target string.
  18676. *
  18677. * @static
  18678. * @memberOf _
  18679. * @since 3.0.0
  18680. * @category String
  18681. * @param {string} [string=''] The string to inspect.
  18682. * @param {string} [target] The string to search for.
  18683. * @param {number} [position=0] The position to search from.
  18684. * @returns {boolean} Returns `true` if `string` starts with `target`,
  18685. * else `false`.
  18686. * @example
  18687. *
  18688. * _.startsWith('abc', 'a');
  18689. * // => true
  18690. *
  18691. * _.startsWith('abc', 'b');
  18692. * // => false
  18693. *
  18694. * _.startsWith('abc', 'b', 1);
  18695. * // => true
  18696. */
  18697. function startsWith(string, target, position) {
  18698. string = toString(string);
  18699. position = position == null
  18700. ? 0
  18701. : baseClamp(toInteger(position), 0, string.length);
  18702. target = baseToString(target);
  18703. return string.slice(position, position + target.length) == target;
  18704. }
  18705. /**
  18706. * Creates a compiled template function that can interpolate data properties
  18707. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  18708. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  18709. * properties may be accessed as free variables in the template. If a setting
  18710. * object is given, it takes precedence over `_.templateSettings` values.
  18711. *
  18712. * **Note:** In the development build `_.template` utilizes
  18713. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  18714. * for easier debugging.
  18715. *
  18716. * For more information on precompiling templates see
  18717. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  18718. *
  18719. * For more information on Chrome extension sandboxes see
  18720. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  18721. *
  18722. * @static
  18723. * @since 0.1.0
  18724. * @memberOf _
  18725. * @category String
  18726. * @param {string} [string=''] The template string.
  18727. * @param {Object} [options={}] The options object.
  18728. * @param {RegExp} [options.escape=_.templateSettings.escape]
  18729. * The HTML "escape" delimiter.
  18730. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  18731. * The "evaluate" delimiter.
  18732. * @param {Object} [options.imports=_.templateSettings.imports]
  18733. * An object to import into the template as free variables.
  18734. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  18735. * The "interpolate" delimiter.
  18736. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  18737. * The sourceURL of the compiled template.
  18738. * @param {string} [options.variable='obj']
  18739. * The data object variable name.
  18740. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  18741. * @returns {Function} Returns the compiled template function.
  18742. * @example
  18743. *
  18744. * // Use the "interpolate" delimiter to create a compiled template.
  18745. * var compiled = _.template('hello <%= user %>!');
  18746. * compiled({ 'user': 'fred' });
  18747. * // => 'hello fred!'
  18748. *
  18749. * // Use the HTML "escape" delimiter to escape data property values.
  18750. * var compiled = _.template('<b><%- value %></b>');
  18751. * compiled({ 'value': '<script>' });
  18752. * // => '<b>&lt;script&gt;</b>'
  18753. *
  18754. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  18755. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  18756. * compiled({ 'users': ['fred', 'barney'] });
  18757. * // => '<li>fred</li><li>barney</li>'
  18758. *
  18759. * // Use the internal `print` function in "evaluate" delimiters.
  18760. * var compiled = _.template('<% print("hello " + user); %>!');
  18761. * compiled({ 'user': 'barney' });
  18762. * // => 'hello barney!'
  18763. *
  18764. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  18765. * // Disable support by replacing the "interpolate" delimiter.
  18766. * var compiled = _.template('hello ${ user }!');
  18767. * compiled({ 'user': 'pebbles' });
  18768. * // => 'hello pebbles!'
  18769. *
  18770. * // Use backslashes to treat delimiters as plain text.
  18771. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  18772. * compiled({ 'value': 'ignored' });
  18773. * // => '<%- value %>'
  18774. *
  18775. * // Use the `imports` option to import `jQuery` as `jq`.
  18776. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  18777. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  18778. * compiled({ 'users': ['fred', 'barney'] });
  18779. * // => '<li>fred</li><li>barney</li>'
  18780. *
  18781. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  18782. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  18783. * compiled(data);
  18784. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  18785. *
  18786. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  18787. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  18788. * compiled.source;
  18789. * // => function(data) {
  18790. * // var __t, __p = '';
  18791. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  18792. * // return __p;
  18793. * // }
  18794. *
  18795. * // Use custom template delimiters.
  18796. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  18797. * var compiled = _.template('hello {{ user }}!');
  18798. * compiled({ 'user': 'mustache' });
  18799. * // => 'hello mustache!'
  18800. *
  18801. * // Use the `source` property to inline compiled templates for meaningful
  18802. * // line numbers in error messages and stack traces.
  18803. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  18804. * var JST = {\
  18805. * "main": ' + _.template(mainText).source + '\
  18806. * };\
  18807. * ');
  18808. */
  18809. function template(string, options, guard) {
  18810. // Based on John Resig's `tmpl` implementation
  18811. // (http://ejohn.org/blog/javascript-micro-templating/)
  18812. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  18813. var settings = lodash.templateSettings;
  18814. if (guard && isIterateeCall(string, options, guard)) {
  18815. options = undefined;
  18816. }
  18817. string = toString(string);
  18818. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  18819. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  18820. importsKeys = keys(imports),
  18821. importsValues = baseValues(imports, importsKeys);
  18822. var isEscaping,
  18823. isEvaluating,
  18824. index = 0,
  18825. interpolate = options.interpolate || reNoMatch,
  18826. source = "__p += '";
  18827. // Compile the regexp to match each delimiter.
  18828. var reDelimiters = RegExp(
  18829. (options.escape || reNoMatch).source + '|' +
  18830. interpolate.source + '|' +
  18831. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  18832. (options.evaluate || reNoMatch).source + '|$'
  18833. , 'g');
  18834. // Use a sourceURL for easier debugging.
  18835. // The sourceURL gets injected into the source that's eval-ed, so be careful
  18836. // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in
  18837. // and escape the comment, thus injecting code that gets evaled.
  18838. var sourceURL = '//# sourceURL=' +
  18839. (hasOwnProperty.call(options, 'sourceURL')
  18840. ? (options.sourceURL + '').replace(/\s/g, ' ')
  18841. : ('lodash.templateSources[' + (++templateCounter) + ']')
  18842. ) + '\n';
  18843. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  18844. interpolateValue || (interpolateValue = esTemplateValue);
  18845. // Escape characters that can't be included in string literals.
  18846. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  18847. // Replace delimiters with snippets.
  18848. if (escapeValue) {
  18849. isEscaping = true;
  18850. source += "' +\n__e(" + escapeValue + ") +\n'";
  18851. }
  18852. if (evaluateValue) {
  18853. isEvaluating = true;
  18854. source += "';\n" + evaluateValue + ";\n__p += '";
  18855. }
  18856. if (interpolateValue) {
  18857. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  18858. }
  18859. index = offset + match.length;
  18860. // The JS engine embedded in Adobe products needs `match` returned in
  18861. // order to produce the correct `offset` value.
  18862. return match;
  18863. });
  18864. source += "';\n";
  18865. // If `variable` is not specified wrap a with-statement around the generated
  18866. // code to add the data object to the top of the scope chain.
  18867. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  18868. if (!variable) {
  18869. source = 'with (obj) {\n' + source + '\n}\n';
  18870. }
  18871. // Throw an error if a forbidden character was found in `variable`, to prevent
  18872. // potential command injection attacks.
  18873. else if (reForbiddenIdentifierChars.test(variable)) {
  18874. throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT);
  18875. }
  18876. // Cleanup code by stripping empty strings.
  18877. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  18878. .replace(reEmptyStringMiddle, '$1')
  18879. .replace(reEmptyStringTrailing, '$1;');
  18880. // Frame code as the function body.
  18881. source = 'function(' + (variable || 'obj') + ') {\n' +
  18882. (variable
  18883. ? ''
  18884. : 'obj || (obj = {});\n'
  18885. ) +
  18886. "var __t, __p = ''" +
  18887. (isEscaping
  18888. ? ', __e = _.escape'
  18889. : ''
  18890. ) +
  18891. (isEvaluating
  18892. ? ', __j = Array.prototype.join;\n' +
  18893. "function print() { __p += __j.call(arguments, '') }\n"
  18894. : ';\n'
  18895. ) +
  18896. source +
  18897. 'return __p\n}';
  18898. var result = attempt(function() {
  18899. return Function(importsKeys, sourceURL + 'return ' + source)
  18900. .apply(undefined, importsValues);
  18901. });
  18902. // Provide the compiled function's source by its `toString` method or
  18903. // the `source` property as a convenience for inlining compiled templates.
  18904. result.source = source;
  18905. if (isError(result)) {
  18906. throw result;
  18907. }
  18908. return result;
  18909. }
  18910. /**
  18911. * Converts `string`, as a whole, to lower case just like
  18912. * [String#toLowerCase](https://mdn.io/toLowerCase).
  18913. *
  18914. * @static
  18915. * @memberOf _
  18916. * @since 4.0.0
  18917. * @category String
  18918. * @param {string} [string=''] The string to convert.
  18919. * @returns {string} Returns the lower cased string.
  18920. * @example
  18921. *
  18922. * _.toLower('--Foo-Bar--');
  18923. * // => '--foo-bar--'
  18924. *
  18925. * _.toLower('fooBar');
  18926. * // => 'foobar'
  18927. *
  18928. * _.toLower('__FOO_BAR__');
  18929. * // => '__foo_bar__'
  18930. */
  18931. function toLower(value) {
  18932. return toString(value).toLowerCase();
  18933. }
  18934. /**
  18935. * Converts `string`, as a whole, to upper case just like
  18936. * [String#toUpperCase](https://mdn.io/toUpperCase).
  18937. *
  18938. * @static
  18939. * @memberOf _
  18940. * @since 4.0.0
  18941. * @category String
  18942. * @param {string} [string=''] The string to convert.
  18943. * @returns {string} Returns the upper cased string.
  18944. * @example
  18945. *
  18946. * _.toUpper('--foo-bar--');
  18947. * // => '--FOO-BAR--'
  18948. *
  18949. * _.toUpper('fooBar');
  18950. * // => 'FOOBAR'
  18951. *
  18952. * _.toUpper('__foo_bar__');
  18953. * // => '__FOO_BAR__'
  18954. */
  18955. function toUpper(value) {
  18956. return toString(value).toUpperCase();
  18957. }
  18958. /**
  18959. * Removes leading and trailing whitespace or specified characters from `string`.
  18960. *
  18961. * @static
  18962. * @memberOf _
  18963. * @since 3.0.0
  18964. * @category String
  18965. * @param {string} [string=''] The string to trim.
  18966. * @param {string} [chars=whitespace] The characters to trim.
  18967. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  18968. * @returns {string} Returns the trimmed string.
  18969. * @example
  18970. *
  18971. * _.trim(' abc ');
  18972. * // => 'abc'
  18973. *
  18974. * _.trim('-_-abc-_-', '_-');
  18975. * // => 'abc'
  18976. *
  18977. * _.map([' foo ', ' bar '], _.trim);
  18978. * // => ['foo', 'bar']
  18979. */
  18980. function trim(string, chars, guard) {
  18981. string = toString(string);
  18982. if (string && (guard || chars === undefined)) {
  18983. return baseTrim(string);
  18984. }
  18985. if (!string || !(chars = baseToString(chars))) {
  18986. return string;
  18987. }
  18988. var strSymbols = stringToArray(string),
  18989. chrSymbols = stringToArray(chars),
  18990. start = charsStartIndex(strSymbols, chrSymbols),
  18991. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  18992. return castSlice(strSymbols, start, end).join('');
  18993. }
  18994. /**
  18995. * Removes trailing whitespace or specified characters from `string`.
  18996. *
  18997. * @static
  18998. * @memberOf _
  18999. * @since 4.0.0
  19000. * @category String
  19001. * @param {string} [string=''] The string to trim.
  19002. * @param {string} [chars=whitespace] The characters to trim.
  19003. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  19004. * @returns {string} Returns the trimmed string.
  19005. * @example
  19006. *
  19007. * _.trimEnd(' abc ');
  19008. * // => ' abc'
  19009. *
  19010. * _.trimEnd('-_-abc-_-', '_-');
  19011. * // => '-_-abc'
  19012. */
  19013. function trimEnd(string, chars, guard) {
  19014. string = toString(string);
  19015. if (string && (guard || chars === undefined)) {
  19016. return string.slice(0, trimmedEndIndex(string) + 1);
  19017. }
  19018. if (!string || !(chars = baseToString(chars))) {
  19019. return string;
  19020. }
  19021. var strSymbols = stringToArray(string),
  19022. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  19023. return castSlice(strSymbols, 0, end).join('');
  19024. }
  19025. /**
  19026. * Removes leading whitespace or specified characters from `string`.
  19027. *
  19028. * @static
  19029. * @memberOf _
  19030. * @since 4.0.0
  19031. * @category String
  19032. * @param {string} [string=''] The string to trim.
  19033. * @param {string} [chars=whitespace] The characters to trim.
  19034. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  19035. * @returns {string} Returns the trimmed string.
  19036. * @example
  19037. *
  19038. * _.trimStart(' abc ');
  19039. * // => 'abc '
  19040. *
  19041. * _.trimStart('-_-abc-_-', '_-');
  19042. * // => 'abc-_-'
  19043. */
  19044. function trimStart(string, chars, guard) {
  19045. string = toString(string);
  19046. if (string && (guard || chars === undefined)) {
  19047. return string.replace(reTrimStart, '');
  19048. }
  19049. if (!string || !(chars = baseToString(chars))) {
  19050. return string;
  19051. }
  19052. var strSymbols = stringToArray(string),
  19053. start = charsStartIndex(strSymbols, stringToArray(chars));
  19054. return castSlice(strSymbols, start).join('');
  19055. }
  19056. /**
  19057. * Truncates `string` if it's longer than the given maximum string length.
  19058. * The last characters of the truncated string are replaced with the omission
  19059. * string which defaults to "...".
  19060. *
  19061. * @static
  19062. * @memberOf _
  19063. * @since 4.0.0
  19064. * @category String
  19065. * @param {string} [string=''] The string to truncate.
  19066. * @param {Object} [options={}] The options object.
  19067. * @param {number} [options.length=30] The maximum string length.
  19068. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  19069. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  19070. * @returns {string} Returns the truncated string.
  19071. * @example
  19072. *
  19073. * _.truncate('hi-diddly-ho there, neighborino');
  19074. * // => 'hi-diddly-ho there, neighbo...'
  19075. *
  19076. * _.truncate('hi-diddly-ho there, neighborino', {
  19077. * 'length': 24,
  19078. * 'separator': ' '
  19079. * });
  19080. * // => 'hi-diddly-ho there,...'
  19081. *
  19082. * _.truncate('hi-diddly-ho there, neighborino', {
  19083. * 'length': 24,
  19084. * 'separator': /,? +/
  19085. * });
  19086. * // => 'hi-diddly-ho there...'
  19087. *
  19088. * _.truncate('hi-diddly-ho there, neighborino', {
  19089. * 'omission': ' [...]'
  19090. * });
  19091. * // => 'hi-diddly-ho there, neig [...]'
  19092. */
  19093. function truncate(string, options) {
  19094. var length = DEFAULT_TRUNC_LENGTH,
  19095. omission = DEFAULT_TRUNC_OMISSION;
  19096. if (isObject(options)) {
  19097. var separator = 'separator' in options ? options.separator : separator;
  19098. length = 'length' in options ? toInteger(options.length) : length;
  19099. omission = 'omission' in options ? baseToString(options.omission) : omission;
  19100. }
  19101. string = toString(string);
  19102. var strLength = string.length;
  19103. if (hasUnicode(string)) {
  19104. var strSymbols = stringToArray(string);
  19105. strLength = strSymbols.length;
  19106. }
  19107. if (length >= strLength) {
  19108. return string;
  19109. }
  19110. var end = length - stringSize(omission);
  19111. if (end < 1) {
  19112. return omission;
  19113. }
  19114. var result = strSymbols
  19115. ? castSlice(strSymbols, 0, end).join('')
  19116. : string.slice(0, end);
  19117. if (separator === undefined) {
  19118. return result + omission;
  19119. }
  19120. if (strSymbols) {
  19121. end += (result.length - end);
  19122. }
  19123. if (isRegExp(separator)) {
  19124. if (string.slice(end).search(separator)) {
  19125. var match,
  19126. substring = result;
  19127. if (!separator.global) {
  19128. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  19129. }
  19130. separator.lastIndex = 0;
  19131. while ((match = separator.exec(substring))) {
  19132. var newEnd = match.index;
  19133. }
  19134. result = result.slice(0, newEnd === undefined ? end : newEnd);
  19135. }
  19136. } else if (string.indexOf(baseToString(separator), end) != end) {
  19137. var index = result.lastIndexOf(separator);
  19138. if (index > -1) {
  19139. result = result.slice(0, index);
  19140. }
  19141. }
  19142. return result + omission;
  19143. }
  19144. /**
  19145. * The inverse of `_.escape`; this method converts the HTML entities
  19146. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  19147. * their corresponding characters.
  19148. *
  19149. * **Note:** No other HTML entities are unescaped. To unescape additional
  19150. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  19151. *
  19152. * @static
  19153. * @memberOf _
  19154. * @since 0.6.0
  19155. * @category String
  19156. * @param {string} [string=''] The string to unescape.
  19157. * @returns {string} Returns the unescaped string.
  19158. * @example
  19159. *
  19160. * _.unescape('fred, barney, &amp; pebbles');
  19161. * // => 'fred, barney, & pebbles'
  19162. */
  19163. function unescape(string) {
  19164. string = toString(string);
  19165. return (string && reHasEscapedHtml.test(string))
  19166. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  19167. : string;
  19168. }
  19169. /**
  19170. * Converts `string`, as space separated words, to upper case.
  19171. *
  19172. * @static
  19173. * @memberOf _
  19174. * @since 4.0.0
  19175. * @category String
  19176. * @param {string} [string=''] The string to convert.
  19177. * @returns {string} Returns the upper cased string.
  19178. * @example
  19179. *
  19180. * _.upperCase('--foo-bar');
  19181. * // => 'FOO BAR'
  19182. *
  19183. * _.upperCase('fooBar');
  19184. * // => 'FOO BAR'
  19185. *
  19186. * _.upperCase('__foo_bar__');
  19187. * // => 'FOO BAR'
  19188. */
  19189. var upperCase = createCompounder(function(result, word, index) {
  19190. return result + (index ? ' ' : '') + word.toUpperCase();
  19191. });
  19192. /**
  19193. * Converts the first character of `string` to upper case.
  19194. *
  19195. * @static
  19196. * @memberOf _
  19197. * @since 4.0.0
  19198. * @category String
  19199. * @param {string} [string=''] The string to convert.
  19200. * @returns {string} Returns the converted string.
  19201. * @example
  19202. *
  19203. * _.upperFirst('fred');
  19204. * // => 'Fred'
  19205. *
  19206. * _.upperFirst('FRED');
  19207. * // => 'FRED'
  19208. */
  19209. var upperFirst = createCaseFirst('toUpperCase');
  19210. /**
  19211. * Splits `string` into an array of its words.
  19212. *
  19213. * @static
  19214. * @memberOf _
  19215. * @since 3.0.0
  19216. * @category String
  19217. * @param {string} [string=''] The string to inspect.
  19218. * @param {RegExp|string} [pattern] The pattern to match words.
  19219. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  19220. * @returns {Array} Returns the words of `string`.
  19221. * @example
  19222. *
  19223. * _.words('fred, barney, & pebbles');
  19224. * // => ['fred', 'barney', 'pebbles']
  19225. *
  19226. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  19227. * // => ['fred', 'barney', '&', 'pebbles']
  19228. */
  19229. function words(string, pattern, guard) {
  19230. string = toString(string);
  19231. pattern = guard ? undefined : pattern;
  19232. if (pattern === undefined) {
  19233. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  19234. }
  19235. return string.match(pattern) || [];
  19236. }
  19237. /*------------------------------------------------------------------------*/
  19238. /**
  19239. * Attempts to invoke `func`, returning either the result or the caught error
  19240. * object. Any additional arguments are provided to `func` when it's invoked.
  19241. *
  19242. * @static
  19243. * @memberOf _
  19244. * @since 3.0.0
  19245. * @category Util
  19246. * @param {Function} func The function to attempt.
  19247. * @param {...*} [args] The arguments to invoke `func` with.
  19248. * @returns {*} Returns the `func` result or error object.
  19249. * @example
  19250. *
  19251. * // Avoid throwing errors for invalid selectors.
  19252. * var elements = _.attempt(function(selector) {
  19253. * return document.querySelectorAll(selector);
  19254. * }, '>_>');
  19255. *
  19256. * if (_.isError(elements)) {
  19257. * elements = [];
  19258. * }
  19259. */
  19260. var attempt = baseRest(function(func, args) {
  19261. try {
  19262. return apply(func, undefined, args);
  19263. } catch (e) {
  19264. return isError(e) ? e : new Error(e);
  19265. }
  19266. });
  19267. /**
  19268. * Binds methods of an object to the object itself, overwriting the existing
  19269. * method.
  19270. *
  19271. * **Note:** This method doesn't set the "length" property of bound functions.
  19272. *
  19273. * @static
  19274. * @since 0.1.0
  19275. * @memberOf _
  19276. * @category Util
  19277. * @param {Object} object The object to bind and assign the bound methods to.
  19278. * @param {...(string|string[])} methodNames The object method names to bind.
  19279. * @returns {Object} Returns `object`.
  19280. * @example
  19281. *
  19282. * var view = {
  19283. * 'label': 'docs',
  19284. * 'click': function() {
  19285. * console.log('clicked ' + this.label);
  19286. * }
  19287. * };
  19288. *
  19289. * _.bindAll(view, ['click']);
  19290. * jQuery(element).on('click', view.click);
  19291. * // => Logs 'clicked docs' when clicked.
  19292. */
  19293. var bindAll = flatRest(function(object, methodNames) {
  19294. arrayEach(methodNames, function(key) {
  19295. key = toKey(key);
  19296. baseAssignValue(object, key, bind(object[key], object));
  19297. });
  19298. return object;
  19299. });
  19300. /**
  19301. * Creates a function that iterates over `pairs` and invokes the corresponding
  19302. * function of the first predicate to return truthy. The predicate-function
  19303. * pairs are invoked with the `this` binding and arguments of the created
  19304. * function.
  19305. *
  19306. * @static
  19307. * @memberOf _
  19308. * @since 4.0.0
  19309. * @category Util
  19310. * @param {Array} pairs The predicate-function pairs.
  19311. * @returns {Function} Returns the new composite function.
  19312. * @example
  19313. *
  19314. * var func = _.cond([
  19315. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  19316. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  19317. * [_.stubTrue, _.constant('no match')]
  19318. * ]);
  19319. *
  19320. * func({ 'a': 1, 'b': 2 });
  19321. * // => 'matches A'
  19322. *
  19323. * func({ 'a': 0, 'b': 1 });
  19324. * // => 'matches B'
  19325. *
  19326. * func({ 'a': '1', 'b': '2' });
  19327. * // => 'no match'
  19328. */
  19329. function cond(pairs) {
  19330. var length = pairs == null ? 0 : pairs.length,
  19331. toIteratee = getIteratee();
  19332. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  19333. if (typeof pair[1] != 'function') {
  19334. throw new TypeError(FUNC_ERROR_TEXT);
  19335. }
  19336. return [toIteratee(pair[0]), pair[1]];
  19337. });
  19338. return baseRest(function(args) {
  19339. var index = -1;
  19340. while (++index < length) {
  19341. var pair = pairs[index];
  19342. if (apply(pair[0], this, args)) {
  19343. return apply(pair[1], this, args);
  19344. }
  19345. }
  19346. });
  19347. }
  19348. /**
  19349. * Creates a function that invokes the predicate properties of `source` with
  19350. * the corresponding property values of a given object, returning `true` if
  19351. * all predicates return truthy, else `false`.
  19352. *
  19353. * **Note:** The created function is equivalent to `_.conformsTo` with
  19354. * `source` partially applied.
  19355. *
  19356. * @static
  19357. * @memberOf _
  19358. * @since 4.0.0
  19359. * @category Util
  19360. * @param {Object} source The object of property predicates to conform to.
  19361. * @returns {Function} Returns the new spec function.
  19362. * @example
  19363. *
  19364. * var objects = [
  19365. * { 'a': 2, 'b': 1 },
  19366. * { 'a': 1, 'b': 2 }
  19367. * ];
  19368. *
  19369. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  19370. * // => [{ 'a': 1, 'b': 2 }]
  19371. */
  19372. function conforms(source) {
  19373. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  19374. }
  19375. /**
  19376. * Creates a function that returns `value`.
  19377. *
  19378. * @static
  19379. * @memberOf _
  19380. * @since 2.4.0
  19381. * @category Util
  19382. * @param {*} value The value to return from the new function.
  19383. * @returns {Function} Returns the new constant function.
  19384. * @example
  19385. *
  19386. * var objects = _.times(2, _.constant({ 'a': 1 }));
  19387. *
  19388. * console.log(objects);
  19389. * // => [{ 'a': 1 }, { 'a': 1 }]
  19390. *
  19391. * console.log(objects[0] === objects[1]);
  19392. * // => true
  19393. */
  19394. function constant(value) {
  19395. return function() {
  19396. return value;
  19397. };
  19398. }
  19399. /**
  19400. * Checks `value` to determine whether a default value should be returned in
  19401. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  19402. * or `undefined`.
  19403. *
  19404. * @static
  19405. * @memberOf _
  19406. * @since 4.14.0
  19407. * @category Util
  19408. * @param {*} value The value to check.
  19409. * @param {*} defaultValue The default value.
  19410. * @returns {*} Returns the resolved value.
  19411. * @example
  19412. *
  19413. * _.defaultTo(1, 10);
  19414. * // => 1
  19415. *
  19416. * _.defaultTo(undefined, 10);
  19417. * // => 10
  19418. */
  19419. function defaultTo(value, defaultValue) {
  19420. return (value == null || value !== value) ? defaultValue : value;
  19421. }
  19422. /**
  19423. * Creates a function that returns the result of invoking the given functions
  19424. * with the `this` binding of the created function, where each successive
  19425. * invocation is supplied the return value of the previous.
  19426. *
  19427. * @static
  19428. * @memberOf _
  19429. * @since 3.0.0
  19430. * @category Util
  19431. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  19432. * @returns {Function} Returns the new composite function.
  19433. * @see _.flowRight
  19434. * @example
  19435. *
  19436. * function square(n) {
  19437. * return n * n;
  19438. * }
  19439. *
  19440. * var addSquare = _.flow([_.add, square]);
  19441. * addSquare(1, 2);
  19442. * // => 9
  19443. */
  19444. var flow = createFlow();
  19445. /**
  19446. * This method is like `_.flow` except that it creates a function that
  19447. * invokes the given functions from right to left.
  19448. *
  19449. * @static
  19450. * @since 3.0.0
  19451. * @memberOf _
  19452. * @category Util
  19453. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  19454. * @returns {Function} Returns the new composite function.
  19455. * @see _.flow
  19456. * @example
  19457. *
  19458. * function square(n) {
  19459. * return n * n;
  19460. * }
  19461. *
  19462. * var addSquare = _.flowRight([square, _.add]);
  19463. * addSquare(1, 2);
  19464. * // => 9
  19465. */
  19466. var flowRight = createFlow(true);
  19467. /**
  19468. * This method returns the first argument it receives.
  19469. *
  19470. * @static
  19471. * @since 0.1.0
  19472. * @memberOf _
  19473. * @category Util
  19474. * @param {*} value Any value.
  19475. * @returns {*} Returns `value`.
  19476. * @example
  19477. *
  19478. * var object = { 'a': 1 };
  19479. *
  19480. * console.log(_.identity(object) === object);
  19481. * // => true
  19482. */
  19483. function identity(value) {
  19484. return value;
  19485. }
  19486. /**
  19487. * Creates a function that invokes `func` with the arguments of the created
  19488. * function. If `func` is a property name, the created function returns the
  19489. * property value for a given element. If `func` is an array or object, the
  19490. * created function returns `true` for elements that contain the equivalent
  19491. * source properties, otherwise it returns `false`.
  19492. *
  19493. * @static
  19494. * @since 4.0.0
  19495. * @memberOf _
  19496. * @category Util
  19497. * @param {*} [func=_.identity] The value to convert to a callback.
  19498. * @returns {Function} Returns the callback.
  19499. * @example
  19500. *
  19501. * var users = [
  19502. * { 'user': 'barney', 'age': 36, 'active': true },
  19503. * { 'user': 'fred', 'age': 40, 'active': false }
  19504. * ];
  19505. *
  19506. * // The `_.matches` iteratee shorthand.
  19507. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  19508. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  19509. *
  19510. * // The `_.matchesProperty` iteratee shorthand.
  19511. * _.filter(users, _.iteratee(['user', 'fred']));
  19512. * // => [{ 'user': 'fred', 'age': 40 }]
  19513. *
  19514. * // The `_.property` iteratee shorthand.
  19515. * _.map(users, _.iteratee('user'));
  19516. * // => ['barney', 'fred']
  19517. *
  19518. * // Create custom iteratee shorthands.
  19519. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  19520. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  19521. * return func.test(string);
  19522. * };
  19523. * });
  19524. *
  19525. * _.filter(['abc', 'def'], /ef/);
  19526. * // => ['def']
  19527. */
  19528. function iteratee(func) {
  19529. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  19530. }
  19531. /**
  19532. * Creates a function that performs a partial deep comparison between a given
  19533. * object and `source`, returning `true` if the given object has equivalent
  19534. * property values, else `false`.
  19535. *
  19536. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  19537. * partially applied.
  19538. *
  19539. * Partial comparisons will match empty array and empty object `source`
  19540. * values against any array or object value, respectively. See `_.isEqual`
  19541. * for a list of supported value comparisons.
  19542. *
  19543. * **Note:** Multiple values can be checked by combining several matchers
  19544. * using `_.overSome`
  19545. *
  19546. * @static
  19547. * @memberOf _
  19548. * @since 3.0.0
  19549. * @category Util
  19550. * @param {Object} source The object of property values to match.
  19551. * @returns {Function} Returns the new spec function.
  19552. * @example
  19553. *
  19554. * var objects = [
  19555. * { 'a': 1, 'b': 2, 'c': 3 },
  19556. * { 'a': 4, 'b': 5, 'c': 6 }
  19557. * ];
  19558. *
  19559. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  19560. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  19561. *
  19562. * // Checking for several possible values
  19563. * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })]));
  19564. * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
  19565. */
  19566. function matches(source) {
  19567. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  19568. }
  19569. /**
  19570. * Creates a function that performs a partial deep comparison between the
  19571. * value at `path` of a given object to `srcValue`, returning `true` if the
  19572. * object value is equivalent, else `false`.
  19573. *
  19574. * **Note:** Partial comparisons will match empty array and empty object
  19575. * `srcValue` values against any array or object value, respectively. See
  19576. * `_.isEqual` for a list of supported value comparisons.
  19577. *
  19578. * **Note:** Multiple values can be checked by combining several matchers
  19579. * using `_.overSome`
  19580. *
  19581. * @static
  19582. * @memberOf _
  19583. * @since 3.2.0
  19584. * @category Util
  19585. * @param {Array|string} path The path of the property to get.
  19586. * @param {*} srcValue The value to match.
  19587. * @returns {Function} Returns the new spec function.
  19588. * @example
  19589. *
  19590. * var objects = [
  19591. * { 'a': 1, 'b': 2, 'c': 3 },
  19592. * { 'a': 4, 'b': 5, 'c': 6 }
  19593. * ];
  19594. *
  19595. * _.find(objects, _.matchesProperty('a', 4));
  19596. * // => { 'a': 4, 'b': 5, 'c': 6 }
  19597. *
  19598. * // Checking for several possible values
  19599. * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)]));
  19600. * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
  19601. */
  19602. function matchesProperty(path, srcValue) {
  19603. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  19604. }
  19605. /**
  19606. * Creates a function that invokes the method at `path` of a given object.
  19607. * Any additional arguments are provided to the invoked method.
  19608. *
  19609. * @static
  19610. * @memberOf _
  19611. * @since 3.7.0
  19612. * @category Util
  19613. * @param {Array|string} path The path of the method to invoke.
  19614. * @param {...*} [args] The arguments to invoke the method with.
  19615. * @returns {Function} Returns the new invoker function.
  19616. * @example
  19617. *
  19618. * var objects = [
  19619. * { 'a': { 'b': _.constant(2) } },
  19620. * { 'a': { 'b': _.constant(1) } }
  19621. * ];
  19622. *
  19623. * _.map(objects, _.method('a.b'));
  19624. * // => [2, 1]
  19625. *
  19626. * _.map(objects, _.method(['a', 'b']));
  19627. * // => [2, 1]
  19628. */
  19629. var method = baseRest(function(path, args) {
  19630. return function(object) {
  19631. return baseInvoke(object, path, args);
  19632. };
  19633. });
  19634. /**
  19635. * The opposite of `_.method`; this method creates a function that invokes
  19636. * the method at a given path of `object`. Any additional arguments are
  19637. * provided to the invoked method.
  19638. *
  19639. * @static
  19640. * @memberOf _
  19641. * @since 3.7.0
  19642. * @category Util
  19643. * @param {Object} object The object to query.
  19644. * @param {...*} [args] The arguments to invoke the method with.
  19645. * @returns {Function} Returns the new invoker function.
  19646. * @example
  19647. *
  19648. * var array = _.times(3, _.constant),
  19649. * object = { 'a': array, 'b': array, 'c': array };
  19650. *
  19651. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  19652. * // => [2, 0]
  19653. *
  19654. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  19655. * // => [2, 0]
  19656. */
  19657. var methodOf = baseRest(function(object, args) {
  19658. return function(path) {
  19659. return baseInvoke(object, path, args);
  19660. };
  19661. });
  19662. /**
  19663. * Adds all own enumerable string keyed function properties of a source
  19664. * object to the destination object. If `object` is a function, then methods
  19665. * are added to its prototype as well.
  19666. *
  19667. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  19668. * avoid conflicts caused by modifying the original.
  19669. *
  19670. * @static
  19671. * @since 0.1.0
  19672. * @memberOf _
  19673. * @category Util
  19674. * @param {Function|Object} [object=lodash] The destination object.
  19675. * @param {Object} source The object of functions to add.
  19676. * @param {Object} [options={}] The options object.
  19677. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  19678. * @returns {Function|Object} Returns `object`.
  19679. * @example
  19680. *
  19681. * function vowels(string) {
  19682. * return _.filter(string, function(v) {
  19683. * return /[aeiou]/i.test(v);
  19684. * });
  19685. * }
  19686. *
  19687. * _.mixin({ 'vowels': vowels });
  19688. * _.vowels('fred');
  19689. * // => ['e']
  19690. *
  19691. * _('fred').vowels().value();
  19692. * // => ['e']
  19693. *
  19694. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  19695. * _('fred').vowels();
  19696. * // => ['e']
  19697. */
  19698. function mixin(object, source, options) {
  19699. var props = keys(source),
  19700. methodNames = baseFunctions(source, props);
  19701. if (options == null &&
  19702. !(isObject(source) && (methodNames.length || !props.length))) {
  19703. options = source;
  19704. source = object;
  19705. object = this;
  19706. methodNames = baseFunctions(source, keys(source));
  19707. }
  19708. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  19709. isFunc = isFunction(object);
  19710. arrayEach(methodNames, function(methodName) {
  19711. var func = source[methodName];
  19712. object[methodName] = func;
  19713. if (isFunc) {
  19714. object.prototype[methodName] = function() {
  19715. var chainAll = this.__chain__;
  19716. if (chain || chainAll) {
  19717. var result = object(this.__wrapped__),
  19718. actions = result.__actions__ = copyArray(this.__actions__);
  19719. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  19720. result.__chain__ = chainAll;
  19721. return result;
  19722. }
  19723. return func.apply(object, arrayPush([this.value()], arguments));
  19724. };
  19725. }
  19726. });
  19727. return object;
  19728. }
  19729. /**
  19730. * Reverts the `_` variable to its previous value and returns a reference to
  19731. * the `lodash` function.
  19732. *
  19733. * @static
  19734. * @since 0.1.0
  19735. * @memberOf _
  19736. * @category Util
  19737. * @returns {Function} Returns the `lodash` function.
  19738. * @example
  19739. *
  19740. * var lodash = _.noConflict();
  19741. */
  19742. function noConflict() {
  19743. if (root._ === this) {
  19744. root._ = oldDash;
  19745. }
  19746. return this;
  19747. }
  19748. /**
  19749. * This method returns `undefined`.
  19750. *
  19751. * @static
  19752. * @memberOf _
  19753. * @since 2.3.0
  19754. * @category Util
  19755. * @example
  19756. *
  19757. * _.times(2, _.noop);
  19758. * // => [undefined, undefined]
  19759. */
  19760. function noop() {
  19761. // No operation performed.
  19762. }
  19763. /**
  19764. * Creates a function that gets the argument at index `n`. If `n` is negative,
  19765. * the nth argument from the end is returned.
  19766. *
  19767. * @static
  19768. * @memberOf _
  19769. * @since 4.0.0
  19770. * @category Util
  19771. * @param {number} [n=0] The index of the argument to return.
  19772. * @returns {Function} Returns the new pass-thru function.
  19773. * @example
  19774. *
  19775. * var func = _.nthArg(1);
  19776. * func('a', 'b', 'c', 'd');
  19777. * // => 'b'
  19778. *
  19779. * var func = _.nthArg(-2);
  19780. * func('a', 'b', 'c', 'd');
  19781. * // => 'c'
  19782. */
  19783. function nthArg(n) {
  19784. n = toInteger(n);
  19785. return baseRest(function(args) {
  19786. return baseNth(args, n);
  19787. });
  19788. }
  19789. /**
  19790. * Creates a function that invokes `iteratees` with the arguments it receives
  19791. * and returns their results.
  19792. *
  19793. * @static
  19794. * @memberOf _
  19795. * @since 4.0.0
  19796. * @category Util
  19797. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  19798. * The iteratees to invoke.
  19799. * @returns {Function} Returns the new function.
  19800. * @example
  19801. *
  19802. * var func = _.over([Math.max, Math.min]);
  19803. *
  19804. * func(1, 2, 3, 4);
  19805. * // => [4, 1]
  19806. */
  19807. var over = createOver(arrayMap);
  19808. /**
  19809. * Creates a function that checks if **all** of the `predicates` return
  19810. * truthy when invoked with the arguments it receives.
  19811. *
  19812. * Following shorthands are possible for providing predicates.
  19813. * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
  19814. * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
  19815. *
  19816. * @static
  19817. * @memberOf _
  19818. * @since 4.0.0
  19819. * @category Util
  19820. * @param {...(Function|Function[])} [predicates=[_.identity]]
  19821. * The predicates to check.
  19822. * @returns {Function} Returns the new function.
  19823. * @example
  19824. *
  19825. * var func = _.overEvery([Boolean, isFinite]);
  19826. *
  19827. * func('1');
  19828. * // => true
  19829. *
  19830. * func(null);
  19831. * // => false
  19832. *
  19833. * func(NaN);
  19834. * // => false
  19835. */
  19836. var overEvery = createOver(arrayEvery);
  19837. /**
  19838. * Creates a function that checks if **any** of the `predicates` return
  19839. * truthy when invoked with the arguments it receives.
  19840. *
  19841. * Following shorthands are possible for providing predicates.
  19842. * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
  19843. * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
  19844. *
  19845. * @static
  19846. * @memberOf _
  19847. * @since 4.0.0
  19848. * @category Util
  19849. * @param {...(Function|Function[])} [predicates=[_.identity]]
  19850. * The predicates to check.
  19851. * @returns {Function} Returns the new function.
  19852. * @example
  19853. *
  19854. * var func = _.overSome([Boolean, isFinite]);
  19855. *
  19856. * func('1');
  19857. * // => true
  19858. *
  19859. * func(null);
  19860. * // => true
  19861. *
  19862. * func(NaN);
  19863. * // => false
  19864. *
  19865. * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }])
  19866. * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]])
  19867. */
  19868. var overSome = createOver(arraySome);
  19869. /**
  19870. * Creates a function that returns the value at `path` of a given object.
  19871. *
  19872. * @static
  19873. * @memberOf _
  19874. * @since 2.4.0
  19875. * @category Util
  19876. * @param {Array|string} path The path of the property to get.
  19877. * @returns {Function} Returns the new accessor function.
  19878. * @example
  19879. *
  19880. * var objects = [
  19881. * { 'a': { 'b': 2 } },
  19882. * { 'a': { 'b': 1 } }
  19883. * ];
  19884. *
  19885. * _.map(objects, _.property('a.b'));
  19886. * // => [2, 1]
  19887. *
  19888. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  19889. * // => [1, 2]
  19890. */
  19891. function property(path) {
  19892. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  19893. }
  19894. /**
  19895. * The opposite of `_.property`; this method creates a function that returns
  19896. * the value at a given path of `object`.
  19897. *
  19898. * @static
  19899. * @memberOf _
  19900. * @since 3.0.0
  19901. * @category Util
  19902. * @param {Object} object The object to query.
  19903. * @returns {Function} Returns the new accessor function.
  19904. * @example
  19905. *
  19906. * var array = [0, 1, 2],
  19907. * object = { 'a': array, 'b': array, 'c': array };
  19908. *
  19909. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  19910. * // => [2, 0]
  19911. *
  19912. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  19913. * // => [2, 0]
  19914. */
  19915. function propertyOf(object) {
  19916. return function(path) {
  19917. return object == null ? undefined : baseGet(object, path);
  19918. };
  19919. }
  19920. /**
  19921. * Creates an array of numbers (positive and/or negative) progressing from
  19922. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  19923. * `start` is specified without an `end` or `step`. If `end` is not specified,
  19924. * it's set to `start` with `start` then set to `0`.
  19925. *
  19926. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  19927. * floating-point values which can produce unexpected results.
  19928. *
  19929. * @static
  19930. * @since 0.1.0
  19931. * @memberOf _
  19932. * @category Util
  19933. * @param {number} [start=0] The start of the range.
  19934. * @param {number} end The end of the range.
  19935. * @param {number} [step=1] The value to increment or decrement by.
  19936. * @returns {Array} Returns the range of numbers.
  19937. * @see _.inRange, _.rangeRight
  19938. * @example
  19939. *
  19940. * _.range(4);
  19941. * // => [0, 1, 2, 3]
  19942. *
  19943. * _.range(-4);
  19944. * // => [0, -1, -2, -3]
  19945. *
  19946. * _.range(1, 5);
  19947. * // => [1, 2, 3, 4]
  19948. *
  19949. * _.range(0, 20, 5);
  19950. * // => [0, 5, 10, 15]
  19951. *
  19952. * _.range(0, -4, -1);
  19953. * // => [0, -1, -2, -3]
  19954. *
  19955. * _.range(1, 4, 0);
  19956. * // => [1, 1, 1]
  19957. *
  19958. * _.range(0);
  19959. * // => []
  19960. */
  19961. var range = createRange();
  19962. /**
  19963. * This method is like `_.range` except that it populates values in
  19964. * descending order.
  19965. *
  19966. * @static
  19967. * @memberOf _
  19968. * @since 4.0.0
  19969. * @category Util
  19970. * @param {number} [start=0] The start of the range.
  19971. * @param {number} end The end of the range.
  19972. * @param {number} [step=1] The value to increment or decrement by.
  19973. * @returns {Array} Returns the range of numbers.
  19974. * @see _.inRange, _.range
  19975. * @example
  19976. *
  19977. * _.rangeRight(4);
  19978. * // => [3, 2, 1, 0]
  19979. *
  19980. * _.rangeRight(-4);
  19981. * // => [-3, -2, -1, 0]
  19982. *
  19983. * _.rangeRight(1, 5);
  19984. * // => [4, 3, 2, 1]
  19985. *
  19986. * _.rangeRight(0, 20, 5);
  19987. * // => [15, 10, 5, 0]
  19988. *
  19989. * _.rangeRight(0, -4, -1);
  19990. * // => [-3, -2, -1, 0]
  19991. *
  19992. * _.rangeRight(1, 4, 0);
  19993. * // => [1, 1, 1]
  19994. *
  19995. * _.rangeRight(0);
  19996. * // => []
  19997. */
  19998. var rangeRight = createRange(true);
  19999. /**
  20000. * This method returns a new empty array.
  20001. *
  20002. * @static
  20003. * @memberOf _
  20004. * @since 4.13.0
  20005. * @category Util
  20006. * @returns {Array} Returns the new empty array.
  20007. * @example
  20008. *
  20009. * var arrays = _.times(2, _.stubArray);
  20010. *
  20011. * console.log(arrays);
  20012. * // => [[], []]
  20013. *
  20014. * console.log(arrays[0] === arrays[1]);
  20015. * // => false
  20016. */
  20017. function stubArray() {
  20018. return [];
  20019. }
  20020. /**
  20021. * This method returns `false`.
  20022. *
  20023. * @static
  20024. * @memberOf _
  20025. * @since 4.13.0
  20026. * @category Util
  20027. * @returns {boolean} Returns `false`.
  20028. * @example
  20029. *
  20030. * _.times(2, _.stubFalse);
  20031. * // => [false, false]
  20032. */
  20033. function stubFalse() {
  20034. return false;
  20035. }
  20036. /**
  20037. * This method returns a new empty object.
  20038. *
  20039. * @static
  20040. * @memberOf _
  20041. * @since 4.13.0
  20042. * @category Util
  20043. * @returns {Object} Returns the new empty object.
  20044. * @example
  20045. *
  20046. * var objects = _.times(2, _.stubObject);
  20047. *
  20048. * console.log(objects);
  20049. * // => [{}, {}]
  20050. *
  20051. * console.log(objects[0] === objects[1]);
  20052. * // => false
  20053. */
  20054. function stubObject() {
  20055. return {};
  20056. }
  20057. /**
  20058. * This method returns an empty string.
  20059. *
  20060. * @static
  20061. * @memberOf _
  20062. * @since 4.13.0
  20063. * @category Util
  20064. * @returns {string} Returns the empty string.
  20065. * @example
  20066. *
  20067. * _.times(2, _.stubString);
  20068. * // => ['', '']
  20069. */
  20070. function stubString() {
  20071. return '';
  20072. }
  20073. /**
  20074. * This method returns `true`.
  20075. *
  20076. * @static
  20077. * @memberOf _
  20078. * @since 4.13.0
  20079. * @category Util
  20080. * @returns {boolean} Returns `true`.
  20081. * @example
  20082. *
  20083. * _.times(2, _.stubTrue);
  20084. * // => [true, true]
  20085. */
  20086. function stubTrue() {
  20087. return true;
  20088. }
  20089. /**
  20090. * Invokes the iteratee `n` times, returning an array of the results of
  20091. * each invocation. The iteratee is invoked with one argument; (index).
  20092. *
  20093. * @static
  20094. * @since 0.1.0
  20095. * @memberOf _
  20096. * @category Util
  20097. * @param {number} n The number of times to invoke `iteratee`.
  20098. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  20099. * @returns {Array} Returns the array of results.
  20100. * @example
  20101. *
  20102. * _.times(3, String);
  20103. * // => ['0', '1', '2']
  20104. *
  20105. * _.times(4, _.constant(0));
  20106. * // => [0, 0, 0, 0]
  20107. */
  20108. function times(n, iteratee) {
  20109. n = toInteger(n);
  20110. if (n < 1 || n > MAX_SAFE_INTEGER) {
  20111. return [];
  20112. }
  20113. var index = MAX_ARRAY_LENGTH,
  20114. length = nativeMin(n, MAX_ARRAY_LENGTH);
  20115. iteratee = getIteratee(iteratee);
  20116. n -= MAX_ARRAY_LENGTH;
  20117. var result = baseTimes(length, iteratee);
  20118. while (++index < n) {
  20119. iteratee(index);
  20120. }
  20121. return result;
  20122. }
  20123. /**
  20124. * Converts `value` to a property path array.
  20125. *
  20126. * @static
  20127. * @memberOf _
  20128. * @since 4.0.0
  20129. * @category Util
  20130. * @param {*} value The value to convert.
  20131. * @returns {Array} Returns the new property path array.
  20132. * @example
  20133. *
  20134. * _.toPath('a.b.c');
  20135. * // => ['a', 'b', 'c']
  20136. *
  20137. * _.toPath('a[0].b.c');
  20138. * // => ['a', '0', 'b', 'c']
  20139. */
  20140. function toPath(value) {
  20141. if (isArray(value)) {
  20142. return arrayMap(value, toKey);
  20143. }
  20144. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  20145. }
  20146. /**
  20147. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  20148. *
  20149. * @static
  20150. * @since 0.1.0
  20151. * @memberOf _
  20152. * @category Util
  20153. * @param {string} [prefix=''] The value to prefix the ID with.
  20154. * @returns {string} Returns the unique ID.
  20155. * @example
  20156. *
  20157. * _.uniqueId('contact_');
  20158. * // => 'contact_104'
  20159. *
  20160. * _.uniqueId();
  20161. * // => '105'
  20162. */
  20163. function uniqueId(prefix) {
  20164. var id = ++idCounter;
  20165. return toString(prefix) + id;
  20166. }
  20167. /*------------------------------------------------------------------------*/
  20168. /**
  20169. * Adds two numbers.
  20170. *
  20171. * @static
  20172. * @memberOf _
  20173. * @since 3.4.0
  20174. * @category Math
  20175. * @param {number} augend The first number in an addition.
  20176. * @param {number} addend The second number in an addition.
  20177. * @returns {number} Returns the total.
  20178. * @example
  20179. *
  20180. * _.add(6, 4);
  20181. * // => 10
  20182. */
  20183. var add = createMathOperation(function(augend, addend) {
  20184. return augend + addend;
  20185. }, 0);
  20186. /**
  20187. * Computes `number` rounded up to `precision`.
  20188. *
  20189. * @static
  20190. * @memberOf _
  20191. * @since 3.10.0
  20192. * @category Math
  20193. * @param {number} number The number to round up.
  20194. * @param {number} [precision=0] The precision to round up to.
  20195. * @returns {number} Returns the rounded up number.
  20196. * @example
  20197. *
  20198. * _.ceil(4.006);
  20199. * // => 5
  20200. *
  20201. * _.ceil(6.004, 2);
  20202. * // => 6.01
  20203. *
  20204. * _.ceil(6040, -2);
  20205. * // => 6100
  20206. */
  20207. var ceil = createRound('ceil');
  20208. /**
  20209. * Divide two numbers.
  20210. *
  20211. * @static
  20212. * @memberOf _
  20213. * @since 4.7.0
  20214. * @category Math
  20215. * @param {number} dividend The first number in a division.
  20216. * @param {number} divisor The second number in a division.
  20217. * @returns {number} Returns the quotient.
  20218. * @example
  20219. *
  20220. * _.divide(6, 4);
  20221. * // => 1.5
  20222. */
  20223. var divide = createMathOperation(function(dividend, divisor) {
  20224. return dividend / divisor;
  20225. }, 1);
  20226. /**
  20227. * Computes `number` rounded down to `precision`.
  20228. *
  20229. * @static
  20230. * @memberOf _
  20231. * @since 3.10.0
  20232. * @category Math
  20233. * @param {number} number The number to round down.
  20234. * @param {number} [precision=0] The precision to round down to.
  20235. * @returns {number} Returns the rounded down number.
  20236. * @example
  20237. *
  20238. * _.floor(4.006);
  20239. * // => 4
  20240. *
  20241. * _.floor(0.046, 2);
  20242. * // => 0.04
  20243. *
  20244. * _.floor(4060, -2);
  20245. * // => 4000
  20246. */
  20247. var floor = createRound('floor');
  20248. /**
  20249. * Computes the maximum value of `array`. If `array` is empty or falsey,
  20250. * `undefined` is returned.
  20251. *
  20252. * @static
  20253. * @since 0.1.0
  20254. * @memberOf _
  20255. * @category Math
  20256. * @param {Array} array The array to iterate over.
  20257. * @returns {*} Returns the maximum value.
  20258. * @example
  20259. *
  20260. * _.max([4, 2, 8, 6]);
  20261. * // => 8
  20262. *
  20263. * _.max([]);
  20264. * // => undefined
  20265. */
  20266. function max(array) {
  20267. return (array && array.length)
  20268. ? baseExtremum(array, identity, baseGt)
  20269. : undefined;
  20270. }
  20271. /**
  20272. * This method is like `_.max` except that it accepts `iteratee` which is
  20273. * invoked for each element in `array` to generate the criterion by which
  20274. * the value is ranked. The iteratee is invoked with one argument: (value).
  20275. *
  20276. * @static
  20277. * @memberOf _
  20278. * @since 4.0.0
  20279. * @category Math
  20280. * @param {Array} array The array to iterate over.
  20281. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  20282. * @returns {*} Returns the maximum value.
  20283. * @example
  20284. *
  20285. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  20286. *
  20287. * _.maxBy(objects, function(o) { return o.n; });
  20288. * // => { 'n': 2 }
  20289. *
  20290. * // The `_.property` iteratee shorthand.
  20291. * _.maxBy(objects, 'n');
  20292. * // => { 'n': 2 }
  20293. */
  20294. function maxBy(array, iteratee) {
  20295. return (array && array.length)
  20296. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  20297. : undefined;
  20298. }
  20299. /**
  20300. * Computes the mean of the values in `array`.
  20301. *
  20302. * @static
  20303. * @memberOf _
  20304. * @since 4.0.0
  20305. * @category Math
  20306. * @param {Array} array The array to iterate over.
  20307. * @returns {number} Returns the mean.
  20308. * @example
  20309. *
  20310. * _.mean([4, 2, 8, 6]);
  20311. * // => 5
  20312. */
  20313. function mean(array) {
  20314. return baseMean(array, identity);
  20315. }
  20316. /**
  20317. * This method is like `_.mean` except that it accepts `iteratee` which is
  20318. * invoked for each element in `array` to generate the value to be averaged.
  20319. * The iteratee is invoked with one argument: (value).
  20320. *
  20321. * @static
  20322. * @memberOf _
  20323. * @since 4.7.0
  20324. * @category Math
  20325. * @param {Array} array The array to iterate over.
  20326. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  20327. * @returns {number} Returns the mean.
  20328. * @example
  20329. *
  20330. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  20331. *
  20332. * _.meanBy(objects, function(o) { return o.n; });
  20333. * // => 5
  20334. *
  20335. * // The `_.property` iteratee shorthand.
  20336. * _.meanBy(objects, 'n');
  20337. * // => 5
  20338. */
  20339. function meanBy(array, iteratee) {
  20340. return baseMean(array, getIteratee(iteratee, 2));
  20341. }
  20342. /**
  20343. * Computes the minimum value of `array`. If `array` is empty or falsey,
  20344. * `undefined` is returned.
  20345. *
  20346. * @static
  20347. * @since 0.1.0
  20348. * @memberOf _
  20349. * @category Math
  20350. * @param {Array} array The array to iterate over.
  20351. * @returns {*} Returns the minimum value.
  20352. * @example
  20353. *
  20354. * _.min([4, 2, 8, 6]);
  20355. * // => 2
  20356. *
  20357. * _.min([]);
  20358. * // => undefined
  20359. */
  20360. function min(array) {
  20361. return (array && array.length)
  20362. ? baseExtremum(array, identity, baseLt)
  20363. : undefined;
  20364. }
  20365. /**
  20366. * This method is like `_.min` except that it accepts `iteratee` which is
  20367. * invoked for each element in `array` to generate the criterion by which
  20368. * the value is ranked. The iteratee is invoked with one argument: (value).
  20369. *
  20370. * @static
  20371. * @memberOf _
  20372. * @since 4.0.0
  20373. * @category Math
  20374. * @param {Array} array The array to iterate over.
  20375. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  20376. * @returns {*} Returns the minimum value.
  20377. * @example
  20378. *
  20379. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  20380. *
  20381. * _.minBy(objects, function(o) { return o.n; });
  20382. * // => { 'n': 1 }
  20383. *
  20384. * // The `_.property` iteratee shorthand.
  20385. * _.minBy(objects, 'n');
  20386. * // => { 'n': 1 }
  20387. */
  20388. function minBy(array, iteratee) {
  20389. return (array && array.length)
  20390. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  20391. : undefined;
  20392. }
  20393. /**
  20394. * Multiply two numbers.
  20395. *
  20396. * @static
  20397. * @memberOf _
  20398. * @since 4.7.0
  20399. * @category Math
  20400. * @param {number} multiplier The first number in a multiplication.
  20401. * @param {number} multiplicand The second number in a multiplication.
  20402. * @returns {number} Returns the product.
  20403. * @example
  20404. *
  20405. * _.multiply(6, 4);
  20406. * // => 24
  20407. */
  20408. var multiply = createMathOperation(function(multiplier, multiplicand) {
  20409. return multiplier * multiplicand;
  20410. }, 1);
  20411. /**
  20412. * Computes `number` rounded to `precision`.
  20413. *
  20414. * @static
  20415. * @memberOf _
  20416. * @since 3.10.0
  20417. * @category Math
  20418. * @param {number} number The number to round.
  20419. * @param {number} [precision=0] The precision to round to.
  20420. * @returns {number} Returns the rounded number.
  20421. * @example
  20422. *
  20423. * _.round(4.006);
  20424. * // => 4
  20425. *
  20426. * _.round(4.006, 2);
  20427. * // => 4.01
  20428. *
  20429. * _.round(4060, -2);
  20430. * // => 4100
  20431. */
  20432. var round = createRound('round');
  20433. /**
  20434. * Subtract two numbers.
  20435. *
  20436. * @static
  20437. * @memberOf _
  20438. * @since 4.0.0
  20439. * @category Math
  20440. * @param {number} minuend The first number in a subtraction.
  20441. * @param {number} subtrahend The second number in a subtraction.
  20442. * @returns {number} Returns the difference.
  20443. * @example
  20444. *
  20445. * _.subtract(6, 4);
  20446. * // => 2
  20447. */
  20448. var subtract = createMathOperation(function(minuend, subtrahend) {
  20449. return minuend - subtrahend;
  20450. }, 0);
  20451. /**
  20452. * Computes the sum of the values in `array`.
  20453. *
  20454. * @static
  20455. * @memberOf _
  20456. * @since 3.4.0
  20457. * @category Math
  20458. * @param {Array} array The array to iterate over.
  20459. * @returns {number} Returns the sum.
  20460. * @example
  20461. *
  20462. * _.sum([4, 2, 8, 6]);
  20463. * // => 20
  20464. */
  20465. function sum(array) {
  20466. return (array && array.length)
  20467. ? baseSum(array, identity)
  20468. : 0;
  20469. }
  20470. /**
  20471. * This method is like `_.sum` except that it accepts `iteratee` which is
  20472. * invoked for each element in `array` to generate the value to be summed.
  20473. * The iteratee is invoked with one argument: (value).
  20474. *
  20475. * @static
  20476. * @memberOf _
  20477. * @since 4.0.0
  20478. * @category Math
  20479. * @param {Array} array The array to iterate over.
  20480. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  20481. * @returns {number} Returns the sum.
  20482. * @example
  20483. *
  20484. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  20485. *
  20486. * _.sumBy(objects, function(o) { return o.n; });
  20487. * // => 20
  20488. *
  20489. * // The `_.property` iteratee shorthand.
  20490. * _.sumBy(objects, 'n');
  20491. * // => 20
  20492. */
  20493. function sumBy(array, iteratee) {
  20494. return (array && array.length)
  20495. ? baseSum(array, getIteratee(iteratee, 2))
  20496. : 0;
  20497. }
  20498. /*------------------------------------------------------------------------*/
  20499. // Add methods that return wrapped values in chain sequences.
  20500. lodash.after = after;
  20501. lodash.ary = ary;
  20502. lodash.assign = assign;
  20503. lodash.assignIn = assignIn;
  20504. lodash.assignInWith = assignInWith;
  20505. lodash.assignWith = assignWith;
  20506. lodash.at = at;
  20507. lodash.before = before;
  20508. lodash.bind = bind;
  20509. lodash.bindAll = bindAll;
  20510. lodash.bindKey = bindKey;
  20511. lodash.castArray = castArray;
  20512. lodash.chain = chain;
  20513. lodash.chunk = chunk;
  20514. lodash.compact = compact;
  20515. lodash.concat = concat;
  20516. lodash.cond = cond;
  20517. lodash.conforms = conforms;
  20518. lodash.constant = constant;
  20519. lodash.countBy = countBy;
  20520. lodash.create = create;
  20521. lodash.curry = curry;
  20522. lodash.curryRight = curryRight;
  20523. lodash.debounce = debounce;
  20524. lodash.defaults = defaults;
  20525. lodash.defaultsDeep = defaultsDeep;
  20526. lodash.defer = defer;
  20527. lodash.delay = delay;
  20528. lodash.difference = difference;
  20529. lodash.differenceBy = differenceBy;
  20530. lodash.differenceWith = differenceWith;
  20531. lodash.drop = drop;
  20532. lodash.dropRight = dropRight;
  20533. lodash.dropRightWhile = dropRightWhile;
  20534. lodash.dropWhile = dropWhile;
  20535. lodash.fill = fill;
  20536. lodash.filter = filter;
  20537. lodash.flatMap = flatMap;
  20538. lodash.flatMapDeep = flatMapDeep;
  20539. lodash.flatMapDepth = flatMapDepth;
  20540. lodash.flatten = flatten;
  20541. lodash.flattenDeep = flattenDeep;
  20542. lodash.flattenDepth = flattenDepth;
  20543. lodash.flip = flip;
  20544. lodash.flow = flow;
  20545. lodash.flowRight = flowRight;
  20546. lodash.fromPairs = fromPairs;
  20547. lodash.functions = functions;
  20548. lodash.functionsIn = functionsIn;
  20549. lodash.groupBy = groupBy;
  20550. lodash.initial = initial;
  20551. lodash.intersection = intersection;
  20552. lodash.intersectionBy = intersectionBy;
  20553. lodash.intersectionWith = intersectionWith;
  20554. lodash.invert = invert;
  20555. lodash.invertBy = invertBy;
  20556. lodash.invokeMap = invokeMap;
  20557. lodash.iteratee = iteratee;
  20558. lodash.keyBy = keyBy;
  20559. lodash.keys = keys;
  20560. lodash.keysIn = keysIn;
  20561. lodash.map = map;
  20562. lodash.mapKeys = mapKeys;
  20563. lodash.mapValues = mapValues;
  20564. lodash.matches = matches;
  20565. lodash.matchesProperty = matchesProperty;
  20566. lodash.memoize = memoize;
  20567. lodash.merge = merge;
  20568. lodash.mergeWith = mergeWith;
  20569. lodash.method = method;
  20570. lodash.methodOf = methodOf;
  20571. lodash.mixin = mixin;
  20572. lodash.negate = negate;
  20573. lodash.nthArg = nthArg;
  20574. lodash.omit = omit;
  20575. lodash.omitBy = omitBy;
  20576. lodash.once = once;
  20577. lodash.orderBy = orderBy;
  20578. lodash.over = over;
  20579. lodash.overArgs = overArgs;
  20580. lodash.overEvery = overEvery;
  20581. lodash.overSome = overSome;
  20582. lodash.partial = partial;
  20583. lodash.partialRight = partialRight;
  20584. lodash.partition = partition;
  20585. lodash.pick = pick;
  20586. lodash.pickBy = pickBy;
  20587. lodash.property = property;
  20588. lodash.propertyOf = propertyOf;
  20589. lodash.pull = pull;
  20590. lodash.pullAll = pullAll;
  20591. lodash.pullAllBy = pullAllBy;
  20592. lodash.pullAllWith = pullAllWith;
  20593. lodash.pullAt = pullAt;
  20594. lodash.range = range;
  20595. lodash.rangeRight = rangeRight;
  20596. lodash.rearg = rearg;
  20597. lodash.reject = reject;
  20598. lodash.remove = remove;
  20599. lodash.rest = rest;
  20600. lodash.reverse = reverse;
  20601. lodash.sampleSize = sampleSize;
  20602. lodash.set = set;
  20603. lodash.setWith = setWith;
  20604. lodash.shuffle = shuffle;
  20605. lodash.slice = slice;
  20606. lodash.sortBy = sortBy;
  20607. lodash.sortedUniq = sortedUniq;
  20608. lodash.sortedUniqBy = sortedUniqBy;
  20609. lodash.split = split;
  20610. lodash.spread = spread;
  20611. lodash.tail = tail;
  20612. lodash.take = take;
  20613. lodash.takeRight = takeRight;
  20614. lodash.takeRightWhile = takeRightWhile;
  20615. lodash.takeWhile = takeWhile;
  20616. lodash.tap = tap;
  20617. lodash.throttle = throttle;
  20618. lodash.thru = thru;
  20619. lodash.toArray = toArray;
  20620. lodash.toPairs = toPairs;
  20621. lodash.toPairsIn = toPairsIn;
  20622. lodash.toPath = toPath;
  20623. lodash.toPlainObject = toPlainObject;
  20624. lodash.transform = transform;
  20625. lodash.unary = unary;
  20626. lodash.union = union;
  20627. lodash.unionBy = unionBy;
  20628. lodash.unionWith = unionWith;
  20629. lodash.uniq = uniq;
  20630. lodash.uniqBy = uniqBy;
  20631. lodash.uniqWith = uniqWith;
  20632. lodash.unset = unset;
  20633. lodash.unzip = unzip;
  20634. lodash.unzipWith = unzipWith;
  20635. lodash.update = update;
  20636. lodash.updateWith = updateWith;
  20637. lodash.values = values;
  20638. lodash.valuesIn = valuesIn;
  20639. lodash.without = without;
  20640. lodash.words = words;
  20641. lodash.wrap = wrap;
  20642. lodash.xor = xor;
  20643. lodash.xorBy = xorBy;
  20644. lodash.xorWith = xorWith;
  20645. lodash.zip = zip;
  20646. lodash.zipObject = zipObject;
  20647. lodash.zipObjectDeep = zipObjectDeep;
  20648. lodash.zipWith = zipWith;
  20649. // Add aliases.
  20650. lodash.entries = toPairs;
  20651. lodash.entriesIn = toPairsIn;
  20652. lodash.extend = assignIn;
  20653. lodash.extendWith = assignInWith;
  20654. // Add methods to `lodash.prototype`.
  20655. mixin(lodash, lodash);
  20656. /*------------------------------------------------------------------------*/
  20657. // Add methods that return unwrapped values in chain sequences.
  20658. lodash.add = add;
  20659. lodash.attempt = attempt;
  20660. lodash.camelCase = camelCase;
  20661. lodash.capitalize = capitalize;
  20662. lodash.ceil = ceil;
  20663. lodash.clamp = clamp;
  20664. lodash.clone = clone;
  20665. lodash.cloneDeep = cloneDeep;
  20666. lodash.cloneDeepWith = cloneDeepWith;
  20667. lodash.cloneWith = cloneWith;
  20668. lodash.conformsTo = conformsTo;
  20669. lodash.deburr = deburr;
  20670. lodash.defaultTo = defaultTo;
  20671. lodash.divide = divide;
  20672. lodash.endsWith = endsWith;
  20673. lodash.eq = eq;
  20674. lodash.escape = escape;
  20675. lodash.escapeRegExp = escapeRegExp;
  20676. lodash.every = every;
  20677. lodash.find = find;
  20678. lodash.findIndex = findIndex;
  20679. lodash.findKey = findKey;
  20680. lodash.findLast = findLast;
  20681. lodash.findLastIndex = findLastIndex;
  20682. lodash.findLastKey = findLastKey;
  20683. lodash.floor = floor;
  20684. lodash.forEach = forEach;
  20685. lodash.forEachRight = forEachRight;
  20686. lodash.forIn = forIn;
  20687. lodash.forInRight = forInRight;
  20688. lodash.forOwn = forOwn;
  20689. lodash.forOwnRight = forOwnRight;
  20690. lodash.get = get;
  20691. lodash.gt = gt;
  20692. lodash.gte = gte;
  20693. lodash.has = has;
  20694. lodash.hasIn = hasIn;
  20695. lodash.head = head;
  20696. lodash.identity = identity;
  20697. lodash.includes = includes;
  20698. lodash.indexOf = indexOf;
  20699. lodash.inRange = inRange;
  20700. lodash.invoke = invoke;
  20701. lodash.isArguments = isArguments;
  20702. lodash.isArray = isArray;
  20703. lodash.isArrayBuffer = isArrayBuffer;
  20704. lodash.isArrayLike = isArrayLike;
  20705. lodash.isArrayLikeObject = isArrayLikeObject;
  20706. lodash.isBoolean = isBoolean;
  20707. lodash.isBuffer = isBuffer;
  20708. lodash.isDate = isDate;
  20709. lodash.isElement = isElement;
  20710. lodash.isEmpty = isEmpty;
  20711. lodash.isEqual = isEqual;
  20712. lodash.isEqualWith = isEqualWith;
  20713. lodash.isError = isError;
  20714. lodash.isFinite = isFinite;
  20715. lodash.isFunction = isFunction;
  20716. lodash.isInteger = isInteger;
  20717. lodash.isLength = isLength;
  20718. lodash.isMap = isMap;
  20719. lodash.isMatch = isMatch;
  20720. lodash.isMatchWith = isMatchWith;
  20721. lodash.isNaN = isNaN;
  20722. lodash.isNative = isNative;
  20723. lodash.isNil = isNil;
  20724. lodash.isNull = isNull;
  20725. lodash.isNumber = isNumber;
  20726. lodash.isObject = isObject;
  20727. lodash.isObjectLike = isObjectLike;
  20728. lodash.isPlainObject = isPlainObject;
  20729. lodash.isRegExp = isRegExp;
  20730. lodash.isSafeInteger = isSafeInteger;
  20731. lodash.isSet = isSet;
  20732. lodash.isString = isString;
  20733. lodash.isSymbol = isSymbol;
  20734. lodash.isTypedArray = isTypedArray;
  20735. lodash.isUndefined = isUndefined;
  20736. lodash.isWeakMap = isWeakMap;
  20737. lodash.isWeakSet = isWeakSet;
  20738. lodash.join = join;
  20739. lodash.kebabCase = kebabCase;
  20740. lodash.last = last;
  20741. lodash.lastIndexOf = lastIndexOf;
  20742. lodash.lowerCase = lowerCase;
  20743. lodash.lowerFirst = lowerFirst;
  20744. lodash.lt = lt;
  20745. lodash.lte = lte;
  20746. lodash.max = max;
  20747. lodash.maxBy = maxBy;
  20748. lodash.mean = mean;
  20749. lodash.meanBy = meanBy;
  20750. lodash.min = min;
  20751. lodash.minBy = minBy;
  20752. lodash.stubArray = stubArray;
  20753. lodash.stubFalse = stubFalse;
  20754. lodash.stubObject = stubObject;
  20755. lodash.stubString = stubString;
  20756. lodash.stubTrue = stubTrue;
  20757. lodash.multiply = multiply;
  20758. lodash.nth = nth;
  20759. lodash.noConflict = noConflict;
  20760. lodash.noop = noop;
  20761. lodash.now = now;
  20762. lodash.pad = pad;
  20763. lodash.padEnd = padEnd;
  20764. lodash.padStart = padStart;
  20765. lodash.parseInt = parseInt;
  20766. lodash.random = random;
  20767. lodash.reduce = reduce;
  20768. lodash.reduceRight = reduceRight;
  20769. lodash.repeat = repeat;
  20770. lodash.replace = replace;
  20771. lodash.result = result;
  20772. lodash.round = round;
  20773. lodash.runInContext = runInContext;
  20774. lodash.sample = sample;
  20775. lodash.size = size;
  20776. lodash.snakeCase = snakeCase;
  20777. lodash.some = some;
  20778. lodash.sortedIndex = sortedIndex;
  20779. lodash.sortedIndexBy = sortedIndexBy;
  20780. lodash.sortedIndexOf = sortedIndexOf;
  20781. lodash.sortedLastIndex = sortedLastIndex;
  20782. lodash.sortedLastIndexBy = sortedLastIndexBy;
  20783. lodash.sortedLastIndexOf = sortedLastIndexOf;
  20784. lodash.startCase = startCase;
  20785. lodash.startsWith = startsWith;
  20786. lodash.subtract = subtract;
  20787. lodash.sum = sum;
  20788. lodash.sumBy = sumBy;
  20789. lodash.template = template;
  20790. lodash.times = times;
  20791. lodash.toFinite = toFinite;
  20792. lodash.toInteger = toInteger;
  20793. lodash.toLength = toLength;
  20794. lodash.toLower = toLower;
  20795. lodash.toNumber = toNumber;
  20796. lodash.toSafeInteger = toSafeInteger;
  20797. lodash.toString = toString;
  20798. lodash.toUpper = toUpper;
  20799. lodash.trim = trim;
  20800. lodash.trimEnd = trimEnd;
  20801. lodash.trimStart = trimStart;
  20802. lodash.truncate = truncate;
  20803. lodash.unescape = unescape;
  20804. lodash.uniqueId = uniqueId;
  20805. lodash.upperCase = upperCase;
  20806. lodash.upperFirst = upperFirst;
  20807. // Add aliases.
  20808. lodash.each = forEach;
  20809. lodash.eachRight = forEachRight;
  20810. lodash.first = head;
  20811. mixin(lodash, (function() {
  20812. var source = {};
  20813. baseForOwn(lodash, function(func, methodName) {
  20814. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  20815. source[methodName] = func;
  20816. }
  20817. });
  20818. return source;
  20819. }()), { 'chain': false });
  20820. /*------------------------------------------------------------------------*/
  20821. /**
  20822. * The semantic version number.
  20823. *
  20824. * @static
  20825. * @memberOf _
  20826. * @type {string}
  20827. */
  20828. lodash.VERSION = VERSION;
  20829. // Assign default placeholders.
  20830. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  20831. lodash[methodName].placeholder = lodash;
  20832. });
  20833. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  20834. arrayEach(['drop', 'take'], function(methodName, index) {
  20835. LazyWrapper.prototype[methodName] = function(n) {
  20836. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  20837. var result = (this.__filtered__ && !index)
  20838. ? new LazyWrapper(this)
  20839. : this.clone();
  20840. if (result.__filtered__) {
  20841. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  20842. } else {
  20843. result.__views__.push({
  20844. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  20845. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  20846. });
  20847. }
  20848. return result;
  20849. };
  20850. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  20851. return this.reverse()[methodName](n).reverse();
  20852. };
  20853. });
  20854. // Add `LazyWrapper` methods that accept an `iteratee` value.
  20855. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  20856. var type = index + 1,
  20857. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  20858. LazyWrapper.prototype[methodName] = function(iteratee) {
  20859. var result = this.clone();
  20860. result.__iteratees__.push({
  20861. 'iteratee': getIteratee(iteratee, 3),
  20862. 'type': type
  20863. });
  20864. result.__filtered__ = result.__filtered__ || isFilter;
  20865. return result;
  20866. };
  20867. });
  20868. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  20869. arrayEach(['head', 'last'], function(methodName, index) {
  20870. var takeName = 'take' + (index ? 'Right' : '');
  20871. LazyWrapper.prototype[methodName] = function() {
  20872. return this[takeName](1).value()[0];
  20873. };
  20874. });
  20875. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  20876. arrayEach(['initial', 'tail'], function(methodName, index) {
  20877. var dropName = 'drop' + (index ? '' : 'Right');
  20878. LazyWrapper.prototype[methodName] = function() {
  20879. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  20880. };
  20881. });
  20882. LazyWrapper.prototype.compact = function() {
  20883. return this.filter(identity);
  20884. };
  20885. LazyWrapper.prototype.find = function(predicate) {
  20886. return this.filter(predicate).head();
  20887. };
  20888. LazyWrapper.prototype.findLast = function(predicate) {
  20889. return this.reverse().find(predicate);
  20890. };
  20891. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  20892. if (typeof path == 'function') {
  20893. return new LazyWrapper(this);
  20894. }
  20895. return this.map(function(value) {
  20896. return baseInvoke(value, path, args);
  20897. });
  20898. });
  20899. LazyWrapper.prototype.reject = function(predicate) {
  20900. return this.filter(negate(getIteratee(predicate)));
  20901. };
  20902. LazyWrapper.prototype.slice = function(start, end) {
  20903. start = toInteger(start);
  20904. var result = this;
  20905. if (result.__filtered__ && (start > 0 || end < 0)) {
  20906. return new LazyWrapper(result);
  20907. }
  20908. if (start < 0) {
  20909. result = result.takeRight(-start);
  20910. } else if (start) {
  20911. result = result.drop(start);
  20912. }
  20913. if (end !== undefined) {
  20914. end = toInteger(end);
  20915. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  20916. }
  20917. return result;
  20918. };
  20919. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  20920. return this.reverse().takeWhile(predicate).reverse();
  20921. };
  20922. LazyWrapper.prototype.toArray = function() {
  20923. return this.take(MAX_ARRAY_LENGTH);
  20924. };
  20925. // Add `LazyWrapper` methods to `lodash.prototype`.
  20926. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  20927. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  20928. isTaker = /^(?:head|last)$/.test(methodName),
  20929. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  20930. retUnwrapped = isTaker || /^find/.test(methodName);
  20931. if (!lodashFunc) {
  20932. return;
  20933. }
  20934. lodash.prototype[methodName] = function() {
  20935. var value = this.__wrapped__,
  20936. args = isTaker ? [1] : arguments,
  20937. isLazy = value instanceof LazyWrapper,
  20938. iteratee = args[0],
  20939. useLazy = isLazy || isArray(value);
  20940. var interceptor = function(value) {
  20941. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  20942. return (isTaker && chainAll) ? result[0] : result;
  20943. };
  20944. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  20945. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  20946. isLazy = useLazy = false;
  20947. }
  20948. var chainAll = this.__chain__,
  20949. isHybrid = !!this.__actions__.length,
  20950. isUnwrapped = retUnwrapped && !chainAll,
  20951. onlyLazy = isLazy && !isHybrid;
  20952. if (!retUnwrapped && useLazy) {
  20953. value = onlyLazy ? value : new LazyWrapper(this);
  20954. var result = func.apply(value, args);
  20955. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  20956. return new LodashWrapper(result, chainAll);
  20957. }
  20958. if (isUnwrapped && onlyLazy) {
  20959. return func.apply(this, args);
  20960. }
  20961. result = this.thru(interceptor);
  20962. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  20963. };
  20964. });
  20965. // Add `Array` methods to `lodash.prototype`.
  20966. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  20967. var func = arrayProto[methodName],
  20968. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  20969. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  20970. lodash.prototype[methodName] = function() {
  20971. var args = arguments;
  20972. if (retUnwrapped && !this.__chain__) {
  20973. var value = this.value();
  20974. return func.apply(isArray(value) ? value : [], args);
  20975. }
  20976. return this[chainName](function(value) {
  20977. return func.apply(isArray(value) ? value : [], args);
  20978. });
  20979. };
  20980. });
  20981. // Map minified method names to their real names.
  20982. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  20983. var lodashFunc = lodash[methodName];
  20984. if (lodashFunc) {
  20985. var key = lodashFunc.name + '';
  20986. if (!hasOwnProperty.call(realNames, key)) {
  20987. realNames[key] = [];
  20988. }
  20989. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  20990. }
  20991. });
  20992. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  20993. 'name': 'wrapper',
  20994. 'func': undefined
  20995. }];
  20996. // Add methods to `LazyWrapper`.
  20997. LazyWrapper.prototype.clone = lazyClone;
  20998. LazyWrapper.prototype.reverse = lazyReverse;
  20999. LazyWrapper.prototype.value = lazyValue;
  21000. // Add chain sequence methods to the `lodash` wrapper.
  21001. lodash.prototype.at = wrapperAt;
  21002. lodash.prototype.chain = wrapperChain;
  21003. lodash.prototype.commit = wrapperCommit;
  21004. lodash.prototype.next = wrapperNext;
  21005. lodash.prototype.plant = wrapperPlant;
  21006. lodash.prototype.reverse = wrapperReverse;
  21007. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  21008. // Add lazy aliases.
  21009. lodash.prototype.first = lodash.prototype.head;
  21010. if (symIterator) {
  21011. lodash.prototype[symIterator] = wrapperToIterator;
  21012. }
  21013. return lodash;
  21014. });
  21015. /*--------------------------------------------------------------------------*/
  21016. // Export lodash.
  21017. var _ = runInContext();
  21018. // Some AMD build optimizers, like r.js, check for condition patterns like:
  21019. if (true) {
  21020. // Expose Lodash on the global object to prevent errors when Lodash is
  21021. // loaded by a script tag in the presence of an AMD loader.
  21022. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  21023. // Use `_.noConflict` to remove Lodash from the global object.
  21024. root._ = _;
  21025. // Define as an anonymous module so, through path mapping, it can be
  21026. // referenced as the "underscore" module.
  21027. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  21028. return _;
  21029. }).call(exports, __webpack_require__, exports, module),
  21030. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  21031. }
  21032. // Check for `exports` after `define` in case a build optimizer adds it.
  21033. else {}
  21034. }.call(this));
  21035. /***/ }),
  21036. /***/ 19861:
  21037. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  21038. "use strict";
  21039. const visitor = __webpack_require__(68202);
  21040. // AST utilities.
  21041. const asts = {
  21042. findRule(ast, name) {
  21043. for (let i = 0; i < ast.rules.length; i++) {
  21044. if (ast.rules[i].name === name) {
  21045. return ast.rules[i];
  21046. }
  21047. }
  21048. return undefined;
  21049. },
  21050. indexOfRule(ast, name) {
  21051. for (let i = 0; i < ast.rules.length; i++) {
  21052. if (ast.rules[i].name === name) {
  21053. return i;
  21054. }
  21055. }
  21056. return -1;
  21057. },
  21058. alwaysConsumesOnSuccess(ast, node) {
  21059. function consumesTrue() { return true; }
  21060. function consumesFalse() { return false; }
  21061. const consumes = visitor.build({
  21062. choice(node) {
  21063. return node.alternatives.every(consumes);
  21064. },
  21065. sequence(node) {
  21066. return node.elements.some(consumes);
  21067. },
  21068. simple_and: consumesFalse,
  21069. simple_not: consumesFalse,
  21070. optional: consumesFalse,
  21071. zero_or_more: consumesFalse,
  21072. semantic_and: consumesFalse,
  21073. semantic_not: consumesFalse,
  21074. rule_ref(node) {
  21075. return consumes(asts.findRule(ast, node.name));
  21076. },
  21077. literal(node) {
  21078. return node.value !== "";
  21079. },
  21080. class: consumesTrue,
  21081. any: consumesTrue
  21082. });
  21083. return consumes(node);
  21084. }
  21085. };
  21086. module.exports = asts;
  21087. /***/ }),
  21088. /***/ 79203:
  21089. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  21090. "use strict";
  21091. const generateBytecode = __webpack_require__(12886);
  21092. const generateJS = __webpack_require__(15843);
  21093. const inferenceMatchResult = __webpack_require__(35412);
  21094. const removeProxyRules = __webpack_require__(32929);
  21095. const reportDuplicateLabels = __webpack_require__(96734);
  21096. const reportDuplicateRules = __webpack_require__(1117);
  21097. const reportInfiniteRecursion = __webpack_require__(10730);
  21098. const reportInfiniteRepetition = __webpack_require__(79505);
  21099. const reportUndefinedRules = __webpack_require__(41442);
  21100. const reportIncorrectPlucking = __webpack_require__(66237);
  21101. const visitor = __webpack_require__(68202);
  21102. function processOptions(options, defaults) {
  21103. const processedOptions = {};
  21104. Object.keys(options).forEach(name => {
  21105. processedOptions[name] = options[name];
  21106. });
  21107. Object.keys(defaults).forEach(name => {
  21108. if (!Object.prototype.hasOwnProperty.call(processedOptions, name)) {
  21109. processedOptions[name] = defaults[name];
  21110. }
  21111. });
  21112. return processedOptions;
  21113. }
  21114. const compiler = {
  21115. // AST node visitor builder. Useful mainly for plugins which manipulate the
  21116. // AST.
  21117. visitor,
  21118. // Compiler passes.
  21119. //
  21120. // Each pass is a function that is passed the AST. It can perform checks on it
  21121. // or modify it as needed. If the pass encounters a semantic error, it throws
  21122. // |peg.GrammarError|.
  21123. passes: {
  21124. check: [
  21125. reportUndefinedRules,
  21126. reportDuplicateRules,
  21127. reportDuplicateLabels,
  21128. reportInfiniteRecursion,
  21129. reportInfiniteRepetition,
  21130. reportIncorrectPlucking
  21131. ],
  21132. transform: [
  21133. removeProxyRules,
  21134. inferenceMatchResult,
  21135. ],
  21136. generate: [
  21137. generateBytecode,
  21138. generateJS
  21139. ]
  21140. },
  21141. // Generates a parser from a specified grammar AST. Throws |peg.GrammarError|
  21142. // if the AST contains a semantic error. Note that not all errors are detected
  21143. // during the generation and some may protrude to the generated parser and
  21144. // cause its malfunction.
  21145. compile(ast, passes, options) {
  21146. options = options !== undefined ? options : {};
  21147. options = processOptions(options, {
  21148. allowedStartRules: [ast.rules[0].name],
  21149. cache: false,
  21150. dependencies: {},
  21151. exportVar: null,
  21152. format: "bare",
  21153. output: "parser",
  21154. trace: false
  21155. });
  21156. Object.keys(passes).forEach(stage => {
  21157. passes[stage].forEach(p => { p(ast, options); });
  21158. });
  21159. switch (options.output) {
  21160. case "parser":
  21161. return eval(ast.code);
  21162. case "source":
  21163. return ast.code;
  21164. default:
  21165. throw new Error("Invalid output format: " + options.output + ".");
  21166. }
  21167. }
  21168. };
  21169. module.exports = compiler;
  21170. /***/ }),
  21171. /***/ 86164:
  21172. /***/ ((module) => {
  21173. "use strict";
  21174. // Bytecode instruction opcodes.
  21175. const opcodes = {
  21176. // Stack Manipulation
  21177. /** @deprecated Unused */
  21178. PUSH: 0, // PUSH c
  21179. PUSH_EMPTY_STRING: 35, // PUSH_EMPTY_STRING
  21180. PUSH_UNDEFINED: 1, // PUSH_UNDEFINED
  21181. PUSH_NULL: 2, // PUSH_NULL
  21182. PUSH_FAILED: 3, // PUSH_FAILED
  21183. PUSH_EMPTY_ARRAY: 4, // PUSH_EMPTY_ARRAY
  21184. PUSH_CURR_POS: 5, // PUSH_CURR_POS
  21185. POP: 6, // POP
  21186. POP_CURR_POS: 7, // POP_CURR_POS
  21187. POP_N: 8, // POP_N n
  21188. NIP: 9, // NIP
  21189. APPEND: 10, // APPEND
  21190. WRAP: 11, // WRAP n
  21191. TEXT: 12, // TEXT
  21192. PLUCK: 36, // PLUCK n, k, p1, ..., pK
  21193. // Conditions and Loops
  21194. IF: 13, // IF t, f
  21195. IF_ERROR: 14, // IF_ERROR t, f
  21196. IF_NOT_ERROR: 15, // IF_NOT_ERROR t, f
  21197. WHILE_NOT_ERROR: 16, // WHILE_NOT_ERROR b
  21198. // Matching
  21199. MATCH_ANY: 17, // MATCH_ANY a, f, ...
  21200. MATCH_STRING: 18, // MATCH_STRING s, a, f, ...
  21201. MATCH_STRING_IC: 19, // MATCH_STRING_IC s, a, f, ...
  21202. MATCH_CHAR_CLASS: 20, // MATCH_CHAR_CLASS c, a, f, ...
  21203. /** @deprecated Replaced with `MATCH_CHAR_CLASS` */
  21204. MATCH_REGEXP: 20, // MATCH_REGEXP r, a, f, ...
  21205. ACCEPT_N: 21, // ACCEPT_N n
  21206. ACCEPT_STRING: 22, // ACCEPT_STRING s
  21207. FAIL: 23, // FAIL e
  21208. // Calls
  21209. LOAD_SAVED_POS: 24, // LOAD_SAVED_POS p
  21210. UPDATE_SAVED_POS: 25, // UPDATE_SAVED_POS
  21211. CALL: 26, // CALL f, n, pc, p1, p2, ..., pN
  21212. // Rules
  21213. RULE: 27, // RULE r
  21214. // Failure Reporting
  21215. SILENT_FAILS_ON: 28, // SILENT_FAILS_ON
  21216. SILENT_FAILS_OFF: 29 // SILENT_FAILS_OFF
  21217. // Because the tests have hard-coded opcode numbers, don't renumber
  21218. // existing opcodes. New opcodes that have been put in the correct
  21219. // sections above are repeated here in order to ensure we don't
  21220. // reuse them.
  21221. //
  21222. // 30-34 reserved for @mingun
  21223. // PUSH_EMPTY_STRING: 35
  21224. // PLUCK: 36
  21225. };
  21226. module.exports = opcodes;
  21227. /***/ }),
  21228. /***/ 12886:
  21229. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  21230. "use strict";
  21231. const asts = __webpack_require__(19861);
  21232. const op = __webpack_require__(86164);
  21233. const visitor = __webpack_require__(68202);
  21234. const { ALWAYS_MATCH, SOMETIMES_MATCH, NEVER_MATCH } = __webpack_require__(35412);
  21235. // Generates bytecode.
  21236. //
  21237. // Instructions
  21238. // ============
  21239. //
  21240. // Stack Manipulation
  21241. // ------------------
  21242. //
  21243. // [35] PUSH_EMPTY_STRING
  21244. //
  21245. // stack.push("");
  21246. //
  21247. // [1] PUSH_UNDEFINED
  21248. //
  21249. // stack.push(undefined);
  21250. //
  21251. // [2] PUSH_NULL
  21252. //
  21253. // stack.push(null);
  21254. //
  21255. // [3] PUSH_FAILED
  21256. //
  21257. // stack.push(FAILED);
  21258. //
  21259. // [4] PUSH_EMPTY_ARRAY
  21260. //
  21261. // stack.push([]);
  21262. //
  21263. // [5] PUSH_CURR_POS
  21264. //
  21265. // stack.push(currPos);
  21266. //
  21267. // [6] POP
  21268. //
  21269. // stack.pop();
  21270. //
  21271. // [7] POP_CURR_POS
  21272. //
  21273. // currPos = stack.pop();
  21274. //
  21275. // [8] POP_N n
  21276. //
  21277. // stack.pop(n);
  21278. //
  21279. // [9] NIP
  21280. //
  21281. // value = stack.pop();
  21282. // stack.pop();
  21283. // stack.push(value);
  21284. //
  21285. // [10] APPEND
  21286. //
  21287. // value = stack.pop();
  21288. // array = stack.pop();
  21289. // array.push(value);
  21290. // stack.push(array);
  21291. //
  21292. // [11] WRAP n
  21293. //
  21294. // stack.push(stack.pop(n));
  21295. //
  21296. // [12] TEXT
  21297. //
  21298. // stack.push(input.substring(stack.pop(), currPos));
  21299. //
  21300. // [36] PLUCK n, k, p1, ..., pK
  21301. //
  21302. // value = [stack[p1], ..., stack[pK]]; // when k != 1
  21303. // -or-
  21304. // value = stack[p1]; // when k == 1
  21305. //
  21306. // stack.pop(n);
  21307. // stack.push(value);
  21308. //
  21309. // Conditions and Loops
  21310. // --------------------
  21311. //
  21312. // [13] IF t, f
  21313. //
  21314. // if (stack.top()) {
  21315. // interpret(ip + 3, ip + 3 + t);
  21316. // } else {
  21317. // interpret(ip + 3 + t, ip + 3 + t + f);
  21318. // }
  21319. //
  21320. // [14] IF_ERROR t, f
  21321. //
  21322. // if (stack.top() === FAILED) {
  21323. // interpret(ip + 3, ip + 3 + t);
  21324. // } else {
  21325. // interpret(ip + 3 + t, ip + 3 + t + f);
  21326. // }
  21327. //
  21328. // [15] IF_NOT_ERROR t, f
  21329. //
  21330. // if (stack.top() !== FAILED) {
  21331. // interpret(ip + 3, ip + 3 + t);
  21332. // } else {
  21333. // interpret(ip + 3 + t, ip + 3 + t + f);
  21334. // }
  21335. //
  21336. // [16] WHILE_NOT_ERROR b
  21337. //
  21338. // while(stack.top() !== FAILED) {
  21339. // interpret(ip + 2, ip + 2 + b);
  21340. // }
  21341. //
  21342. // Matching
  21343. // --------
  21344. //
  21345. // [17] MATCH_ANY a, f, ...
  21346. //
  21347. // if (input.length > currPos) {
  21348. // interpret(ip + 3, ip + 3 + a);
  21349. // } else {
  21350. // interpret(ip + 3 + a, ip + 3 + a + f);
  21351. // }
  21352. //
  21353. // [18] MATCH_STRING s, a, f, ...
  21354. //
  21355. // if (input.substr(currPos, literals[s].length) === literals[s]) {
  21356. // interpret(ip + 4, ip + 4 + a);
  21357. // } else {
  21358. // interpret(ip + 4 + a, ip + 4 + a + f);
  21359. // }
  21360. //
  21361. // [19] MATCH_STRING_IC s, a, f, ...
  21362. //
  21363. // if (input.substr(currPos, literals[s].length).toLowerCase() === literals[s]) {
  21364. // interpret(ip + 4, ip + 4 + a);
  21365. // } else {
  21366. // interpret(ip + 4 + a, ip + 4 + a + f);
  21367. // }
  21368. //
  21369. // [20] MATCH_CHAR_CLASS c, a, f, ...
  21370. //
  21371. // if (classes[c].test(input.charAt(currPos))) {
  21372. // interpret(ip + 4, ip + 4 + a);
  21373. // } else {
  21374. // interpret(ip + 4 + a, ip + 4 + a + f);
  21375. // }
  21376. //
  21377. // [21] ACCEPT_N n
  21378. //
  21379. // stack.push(input.substring(currPos, n));
  21380. // currPos += n;
  21381. //
  21382. // [22] ACCEPT_STRING s
  21383. //
  21384. // stack.push(literals[s]);
  21385. // currPos += literals[s].length;
  21386. //
  21387. // [23] FAIL e
  21388. //
  21389. // stack.push(FAILED);
  21390. // fail(expectations[e]);
  21391. //
  21392. // Calls
  21393. // -----
  21394. //
  21395. // [24] LOAD_SAVED_POS p
  21396. //
  21397. // savedPos = stack[p];
  21398. //
  21399. // [25] UPDATE_SAVED_POS
  21400. //
  21401. // savedPos = currPos;
  21402. //
  21403. // [26] CALL f, n, pc, p1, p2, ..., pN
  21404. //
  21405. // value = functions[f](stack[p1], ..., stack[pN]);
  21406. // stack.pop(n);
  21407. // stack.push(value);
  21408. //
  21409. // Rules
  21410. // -----
  21411. //
  21412. // [27] RULE r
  21413. //
  21414. // stack.push(parseRule(r));
  21415. //
  21416. // Failure Reporting
  21417. // -----------------
  21418. //
  21419. // [28] SILENT_FAILS_ON
  21420. //
  21421. // silentFails++;
  21422. //
  21423. // [29] SILENT_FAILS_OFF
  21424. //
  21425. // silentFails--;
  21426. //
  21427. // This pass can use the results of other previous passes, each of which can
  21428. // change the AST (and, as consequence, the bytecode).
  21429. //
  21430. // In particular, if the pass |inferenceMatchResult| has been run before this pass,
  21431. // then each AST node will contain a |match| property, which represents a possible
  21432. // match result of the node:
  21433. // - `<0` - node is never matched, for example, `!('a'*)` (negation of the always
  21434. // matched node). Generator can put |FAILED| to the stack immediately
  21435. // - `=0` - sometimes node matched, sometimes not. This is the same behavior
  21436. // when |match| is missed
  21437. // - `>0` - node is always matched, for example, `'a'*` (because result is an
  21438. // empty array, or an array with some elements). The generator does not
  21439. // need to add a check for |FAILED|, because it is impossible
  21440. //
  21441. // To handle the situation, when the |inferenceMatchResult| has not run (that
  21442. // happens, for example, in tests), the |match| value extracted using the
  21443. // `|0` trick, which performing cast of any value to an integer with value `0`
  21444. // that is equivalent of an unknown match result and signals the generator that
  21445. // runtime check for the |FAILED| is required. Trick is explained on the
  21446. // Wikipedia page (https://en.wikipedia.org/wiki/Asm.js#Code_generation)
  21447. function generateBytecode(ast) {
  21448. const literals = [];
  21449. const classes = [];
  21450. const expectations = [];
  21451. const functions = [];
  21452. function addLiteralConst(value) {
  21453. const index = literals.indexOf(value);
  21454. return index === -1 ? literals.push(value) - 1 : index;
  21455. }
  21456. function addClassConst(node) {
  21457. const cls = {
  21458. value: node.parts,
  21459. inverted: node.inverted,
  21460. ignoreCase: node.ignoreCase
  21461. };
  21462. const pattern = JSON.stringify(cls);
  21463. const index = classes.findIndex(c => JSON.stringify(c) === pattern);
  21464. return index === -1 ? classes.push(cls) - 1 : index;
  21465. }
  21466. function addExpectedConst(expected) {
  21467. const pattern = JSON.stringify(expected);
  21468. const index = expectations.findIndex(e => JSON.stringify(e) === pattern);
  21469. return index === -1 ? expectations.push(expected) - 1 : index;
  21470. }
  21471. function addFunctionConst(predicate, params, code) {
  21472. const func = { predicate, params, body: code };
  21473. const pattern = JSON.stringify(func);
  21474. const index = functions.findIndex(f => JSON.stringify(f) === pattern);
  21475. return index === -1 ? functions.push(func) - 1 : index;
  21476. }
  21477. function cloneEnv(env) {
  21478. const clone = {};
  21479. Object.keys(env).forEach(name => {
  21480. clone[name] = env[name];
  21481. });
  21482. return clone;
  21483. }
  21484. function buildSequence(first, ...args) {
  21485. return first.concat(...args);
  21486. }
  21487. function buildCondition(match, condCode, thenCode, elseCode) {
  21488. if (match === ALWAYS_MATCH) { return thenCode; }
  21489. if (match === NEVER_MATCH) { return elseCode; }
  21490. return condCode.concat(
  21491. [thenCode.length, elseCode.length],
  21492. thenCode,
  21493. elseCode
  21494. );
  21495. }
  21496. function buildLoop(condCode, bodyCode) {
  21497. return condCode.concat([bodyCode.length], bodyCode);
  21498. }
  21499. function buildCall(functionIndex, delta, env, sp) {
  21500. const params = Object.keys(env).map(name => sp - env[name]);
  21501. return [op.CALL, functionIndex, delta, params.length].concat(params);
  21502. }
  21503. function buildSimplePredicate(expression, negative, context) {
  21504. const match = expression.match | 0;
  21505. return buildSequence(
  21506. [op.PUSH_CURR_POS],
  21507. [op.SILENT_FAILS_ON],
  21508. generate(expression, {
  21509. sp: context.sp + 1,
  21510. env: cloneEnv(context.env),
  21511. action: null
  21512. }),
  21513. [op.SILENT_FAILS_OFF],
  21514. buildCondition(
  21515. negative ? -match : match,
  21516. [negative ? op.IF_ERROR : op.IF_NOT_ERROR],
  21517. buildSequence(
  21518. [op.POP],
  21519. [negative ? op.POP : op.POP_CURR_POS],
  21520. [op.PUSH_UNDEFINED]
  21521. ),
  21522. buildSequence(
  21523. [op.POP],
  21524. [negative ? op.POP_CURR_POS : op.POP],
  21525. [op.PUSH_FAILED]
  21526. )
  21527. )
  21528. );
  21529. }
  21530. function buildSemanticPredicate(node, negative, context) {
  21531. const functionIndex = addFunctionConst(
  21532. true, Object.keys(context.env), node.code
  21533. );
  21534. return buildSequence(
  21535. [op.UPDATE_SAVED_POS],
  21536. buildCall(functionIndex, 0, context.env, context.sp),
  21537. buildCondition(
  21538. node.match | 0,
  21539. [op.IF],
  21540. buildSequence(
  21541. [op.POP],
  21542. negative ? [op.PUSH_FAILED] : [op.PUSH_UNDEFINED]
  21543. ),
  21544. buildSequence(
  21545. [op.POP],
  21546. negative ? [op.PUSH_UNDEFINED] : [op.PUSH_FAILED]
  21547. )
  21548. )
  21549. );
  21550. }
  21551. function buildAppendLoop(expressionCode) {
  21552. return buildLoop(
  21553. [op.WHILE_NOT_ERROR],
  21554. buildSequence([op.APPEND], expressionCode)
  21555. );
  21556. }
  21557. const generate = visitor.build({
  21558. grammar(node) {
  21559. node.rules.forEach(generate);
  21560. node.literals = literals;
  21561. node.classes = classes;
  21562. node.expectations = expectations;
  21563. node.functions = functions;
  21564. },
  21565. rule(node) {
  21566. node.bytecode = generate(node.expression, {
  21567. sp: -1, // stack pointer
  21568. env: { }, // mapping of label names to stack positions
  21569. pluck: [], // fields that have been picked
  21570. action: null // action nodes pass themselves to children here
  21571. });
  21572. },
  21573. named(node, context) {
  21574. const match = node.match | 0;
  21575. // Expectation not required if node always fail
  21576. const nameIndex = match === NEVER_MATCH ? null : addExpectedConst(
  21577. { type: "rule", value: node.name }
  21578. );
  21579. // The code generated below is slightly suboptimal because |FAIL| pushes
  21580. // to the stack, so we need to stick a |POP| in front of it. We lack a
  21581. // dedicated instruction that would just report the failure and not touch
  21582. // the stack.
  21583. return buildSequence(
  21584. [op.SILENT_FAILS_ON],
  21585. generate(node.expression, context),
  21586. [op.SILENT_FAILS_OFF],
  21587. buildCondition(match, [op.IF_ERROR], [op.FAIL, nameIndex], [])
  21588. );
  21589. },
  21590. choice(node, context) {
  21591. function buildAlternativesCode(alternatives, context) {
  21592. const match = alternatives[0].match | 0;
  21593. const first = generate(alternatives[0], {
  21594. sp: context.sp,
  21595. env: cloneEnv(context.env),
  21596. action: null
  21597. });
  21598. // If an alternative always match, no need to generate code for the next
  21599. // alternatives. Because their will never tried to match, any side-effects
  21600. // from next alternatives is impossible so we can skip their generation
  21601. if (match === ALWAYS_MATCH) {
  21602. return first;
  21603. }
  21604. // Even if an alternative never match it can have side-effects from
  21605. // a semantic predicates or an actions, so we can not skip generation
  21606. // of the first alternative.
  21607. // We can do that when analysis for possible side-effects will be introduced
  21608. return buildSequence(
  21609. first,
  21610. alternatives.length > 1
  21611. ? buildCondition(
  21612. SOMETIMES_MATCH,
  21613. [op.IF_ERROR],
  21614. buildSequence(
  21615. [op.POP],
  21616. buildAlternativesCode(alternatives.slice(1), context)
  21617. ),
  21618. []
  21619. )
  21620. : []
  21621. );
  21622. }
  21623. return buildAlternativesCode(node.alternatives, context);
  21624. },
  21625. action(node, context) {
  21626. const env = cloneEnv(context.env);
  21627. const emitCall = node.expression.type !== "sequence"
  21628. || node.expression.elements.length === 0;
  21629. const expressionCode = generate(node.expression, {
  21630. sp: context.sp + (emitCall ? 1 : 0),
  21631. env,
  21632. action: node
  21633. });
  21634. const match = node.expression.match | 0;
  21635. // Function only required if expression can match
  21636. const functionIndex = emitCall && match !== NEVER_MATCH
  21637. ? addFunctionConst(false, Object.keys(env), node.code)
  21638. : null;
  21639. return emitCall
  21640. ? buildSequence(
  21641. [op.PUSH_CURR_POS],
  21642. expressionCode,
  21643. buildCondition(
  21644. match,
  21645. [op.IF_NOT_ERROR],
  21646. buildSequence(
  21647. [op.LOAD_SAVED_POS, 1],
  21648. buildCall(functionIndex, 1, env, context.sp + 2)
  21649. ),
  21650. []
  21651. ),
  21652. [op.NIP]
  21653. )
  21654. : expressionCode;
  21655. },
  21656. sequence(node, context) {
  21657. function buildElementsCode(elements, context) {
  21658. if (elements.length > 0) {
  21659. const processedCount = node.elements.length - elements.length + 1;
  21660. return buildSequence(
  21661. generate(elements[0], {
  21662. sp: context.sp,
  21663. env: context.env,
  21664. pluck: context.pluck,
  21665. action: null
  21666. }),
  21667. buildCondition(
  21668. elements[0].match | 0,
  21669. [op.IF_NOT_ERROR],
  21670. buildElementsCode(elements.slice(1), {
  21671. sp: context.sp + 1,
  21672. env: context.env,
  21673. pluck: context.pluck,
  21674. action: context.action
  21675. }),
  21676. buildSequence(
  21677. processedCount > 1 ? [op.POP_N, processedCount] : [op.POP],
  21678. [op.POP_CURR_POS],
  21679. [op.PUSH_FAILED]
  21680. )
  21681. )
  21682. );
  21683. } else {
  21684. if (context.pluck.length > 0) {
  21685. return buildSequence(
  21686. [ op.PLUCK, node.elements.length + 1, context.pluck.length ],
  21687. context.pluck.map(eSP => context.sp - eSP)
  21688. );
  21689. }
  21690. if (context.action) {
  21691. const functionIndex = addFunctionConst(
  21692. false,
  21693. Object.keys(context.env),
  21694. context.action.code
  21695. );
  21696. return buildSequence(
  21697. [op.LOAD_SAVED_POS, node.elements.length],
  21698. buildCall(
  21699. functionIndex,
  21700. node.elements.length + 1,
  21701. context.env,
  21702. context.sp
  21703. )
  21704. );
  21705. } else {
  21706. return buildSequence([op.WRAP, node.elements.length], [op.NIP]);
  21707. }
  21708. }
  21709. }
  21710. return buildSequence(
  21711. [op.PUSH_CURR_POS],
  21712. buildElementsCode(node.elements, {
  21713. sp: context.sp + 1,
  21714. env: context.env,
  21715. pluck: [],
  21716. action: context.action
  21717. })
  21718. );
  21719. },
  21720. labeled(node, context) {
  21721. let env = context.env;
  21722. const label = node.label;
  21723. const sp = context.sp + 1;
  21724. if (label) {
  21725. env = cloneEnv(context.env);
  21726. context.env[node.label] = sp;
  21727. }
  21728. if (node.pick) {
  21729. context.pluck.push(sp);
  21730. }
  21731. return generate(node.expression, {
  21732. sp: context.sp,
  21733. env,
  21734. action: null
  21735. });
  21736. },
  21737. text(node, context) {
  21738. return buildSequence(
  21739. [op.PUSH_CURR_POS],
  21740. generate(node.expression, {
  21741. sp: context.sp + 1,
  21742. env: cloneEnv(context.env),
  21743. action: null
  21744. }),
  21745. buildCondition(
  21746. node.match | 0,
  21747. [op.IF_NOT_ERROR],
  21748. buildSequence([op.POP], [op.TEXT]),
  21749. [op.NIP]
  21750. )
  21751. );
  21752. },
  21753. simple_and(node, context) {
  21754. return buildSimplePredicate(node.expression, false, context);
  21755. },
  21756. simple_not(node, context) {
  21757. return buildSimplePredicate(node.expression, true, context);
  21758. },
  21759. optional(node, context) {
  21760. return buildSequence(
  21761. generate(node.expression, {
  21762. sp: context.sp,
  21763. env: cloneEnv(context.env),
  21764. action: null
  21765. }),
  21766. buildCondition(
  21767. // Check expression match, not the node match
  21768. // If expression always match, no need to replace FAILED to NULL,
  21769. // because FAILED will never appeared
  21770. -(node.expression.match | 0),
  21771. [op.IF_ERROR],
  21772. buildSequence([op.POP], [op.PUSH_NULL]),
  21773. []
  21774. )
  21775. );
  21776. },
  21777. zero_or_more(node, context) {
  21778. const expressionCode = generate(node.expression, {
  21779. sp: context.sp + 1,
  21780. env: cloneEnv(context.env),
  21781. action: null
  21782. });
  21783. return buildSequence(
  21784. [op.PUSH_EMPTY_ARRAY],
  21785. expressionCode,
  21786. buildAppendLoop(expressionCode),
  21787. [op.POP]
  21788. );
  21789. },
  21790. one_or_more(node, context) {
  21791. const expressionCode = generate(node.expression, {
  21792. sp: context.sp + 1,
  21793. env: cloneEnv(context.env),
  21794. action: null
  21795. });
  21796. return buildSequence(
  21797. [op.PUSH_EMPTY_ARRAY],
  21798. expressionCode,
  21799. buildCondition(
  21800. // Condition depends on the expression match, not the node match
  21801. node.expression.match | 0,
  21802. [op.IF_NOT_ERROR],
  21803. buildSequence(buildAppendLoop(expressionCode), [op.POP]),
  21804. buildSequence([op.POP], [op.POP], [op.PUSH_FAILED])
  21805. )
  21806. );
  21807. },
  21808. group(node, context) {
  21809. return generate(node.expression, {
  21810. sp: context.sp,
  21811. env: cloneEnv(context.env),
  21812. action: null
  21813. });
  21814. },
  21815. semantic_and(node, context) {
  21816. return buildSemanticPredicate(node, false, context);
  21817. },
  21818. semantic_not(node, context) {
  21819. return buildSemanticPredicate(node, true, context);
  21820. },
  21821. rule_ref(node) {
  21822. return [op.RULE, asts.indexOfRule(ast, node.name)];
  21823. },
  21824. literal(node) {
  21825. if (node.value.length > 0) {
  21826. const match = node.match | 0;
  21827. // String only required if condition is generated or string is
  21828. // case-sensitive and node always match
  21829. const needConst = match === SOMETIMES_MATCH
  21830. || (match === ALWAYS_MATCH && !node.ignoreCase);
  21831. const stringIndex = needConst ? addLiteralConst(
  21832. node.ignoreCase ? node.value.toLowerCase() : node.value
  21833. ) : null;
  21834. // Expectation not required if node always match
  21835. const expectedIndex = match !== ALWAYS_MATCH ? addExpectedConst({
  21836. type: "literal",
  21837. value: node.value,
  21838. ignoreCase: node.ignoreCase
  21839. }) : null;
  21840. // For case-sensitive strings the value must match the beginning of the
  21841. // remaining input exactly. As a result, we can use |ACCEPT_STRING| and
  21842. // save one |substr| call that would be needed if we used |ACCEPT_N|.
  21843. return buildCondition(
  21844. match,
  21845. node.ignoreCase
  21846. ? [op.MATCH_STRING_IC, stringIndex]
  21847. : [op.MATCH_STRING, stringIndex],
  21848. node.ignoreCase
  21849. ? [op.ACCEPT_N, node.value.length]
  21850. : [op.ACCEPT_STRING, stringIndex],
  21851. [op.FAIL, expectedIndex]
  21852. );
  21853. }
  21854. return [op.PUSH_EMPTY_STRING];
  21855. },
  21856. class(node) {
  21857. const match = node.match | 0;
  21858. // Character class constant only required if condition is generated
  21859. const classIndex = match === SOMETIMES_MATCH ? addClassConst(node) : null;
  21860. // Expectation not required if node always match
  21861. const expectedIndex = match !== ALWAYS_MATCH ? addExpectedConst({
  21862. type: "class",
  21863. value: node.parts,
  21864. inverted: node.inverted,
  21865. ignoreCase: node.ignoreCase
  21866. }) : null;
  21867. return buildCondition(
  21868. match,
  21869. [op.MATCH_CHAR_CLASS, classIndex],
  21870. [op.ACCEPT_N, 1],
  21871. [op.FAIL, expectedIndex]
  21872. );
  21873. },
  21874. any(node) {
  21875. const match = node.match | 0;
  21876. // Expectation not required if node always match
  21877. const expectedIndex = match !== ALWAYS_MATCH ? addExpectedConst({
  21878. type: "any"
  21879. }) : null;
  21880. return buildCondition(
  21881. match,
  21882. [op.MATCH_ANY],
  21883. [op.ACCEPT_N, 1],
  21884. [op.FAIL, expectedIndex]
  21885. );
  21886. }
  21887. });
  21888. generate(ast);
  21889. }
  21890. module.exports = generateBytecode;
  21891. /***/ }),
  21892. /***/ 15843:
  21893. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  21894. "use strict";
  21895. const asts = __webpack_require__(19861);
  21896. const op = __webpack_require__(86164);
  21897. const Stack = __webpack_require__(78013);
  21898. const VERSION = __webpack_require__(80244);
  21899. function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); }
  21900. function stringEscape(s) {
  21901. // ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a string
  21902. // literal except for the closing quote character, backslash, carriage
  21903. // return, line separator, paragraph separator, and line feed. Any character
  21904. // may appear in the form of an escape sequence.
  21905. //
  21906. // For portability, we also escape all control and non-ASCII characters.
  21907. return s
  21908. .replace(/\\/g, "\\\\") // backslash
  21909. .replace(/"/g, "\\\"") // closing double quote
  21910. .replace(/\0/g, "\\0") // null
  21911. .replace(/\x08/g, "\\b") // backspace
  21912. .replace(/\t/g, "\\t") // horizontal tab
  21913. .replace(/\n/g, "\\n") // line feed
  21914. .replace(/\v/g, "\\v") // vertical tab
  21915. .replace(/\f/g, "\\f") // form feed
  21916. .replace(/\r/g, "\\r") // carriage return
  21917. .replace(/[\x00-\x0F]/g, ch => "\\x0" + hex(ch))
  21918. .replace(/[\x10-\x1F\x7F-\xFF]/g, ch => "\\x" + hex(ch))
  21919. .replace(/[\u0100-\u0FFF]/g, ch => "\\u0" + hex(ch))
  21920. .replace(/[\u1000-\uFFFF]/g, ch => "\\u" + hex(ch));
  21921. }
  21922. function regexpClassEscape(s) {
  21923. // Based on ECMA-262, 5th ed., 7.8.5 & 15.10.1.
  21924. //
  21925. // For portability, we also escape all control and non-ASCII characters.
  21926. return s
  21927. .replace(/\\/g, "\\\\") // backslash
  21928. .replace(/\//g, "\\/") // closing slash
  21929. .replace(/]/g, "\\]") // closing bracket
  21930. .replace(/\^/g, "\\^") // caret
  21931. .replace(/-/g, "\\-") // dash
  21932. .replace(/\0/g, "\\0") // null
  21933. .replace(/\x08/g, "\\b") // backspace
  21934. .replace(/\t/g, "\\t") // horizontal tab
  21935. .replace(/\n/g, "\\n") // line feed
  21936. .replace(/\v/g, "\\v") // vertical tab
  21937. .replace(/\f/g, "\\f") // form feed
  21938. .replace(/\r/g, "\\r") // carriage return
  21939. .replace(/[\x00-\x0F]/g, ch => "\\x0" + hex(ch))
  21940. .replace(/[\x10-\x1F\x7F-\xFF]/g, ch => "\\x" + hex(ch))
  21941. .replace(/[\u0100-\u0FFF]/g, ch => "\\u0" + hex(ch))
  21942. .replace(/[\u1000-\uFFFF]/g, ch => "\\u" + hex(ch));
  21943. }
  21944. // Generates parser JavaScript code.
  21945. function generateJS(ast, options) {
  21946. // These only indent non-empty lines to avoid trailing whitespace.
  21947. function indent2(code) { return code.replace(/^(.+)$/gm, " $1"); }
  21948. function l(i) { return "peg$c" + i; } // |literals[i]| of the abstract machine
  21949. function r(i) { return "peg$r" + i; } // |classes[i]| of the abstract machine
  21950. function e(i) { return "peg$e" + i; } // |expectations[i]| of the abstract machine
  21951. function f(i) { return "peg$f" + i; } // |actions[i]| of the abstract machine
  21952. function generateTables() {
  21953. function buildLiteral(literal) {
  21954. return "\"" + stringEscape(literal) + "\"";
  21955. }
  21956. function buildRegexp(cls) {
  21957. return "/^["
  21958. + (cls.inverted ? "^" : "")
  21959. + cls.value.map(part =>
  21960. Array.isArray(part)
  21961. ? regexpClassEscape(part[0])
  21962. + "-"
  21963. + regexpClassEscape(part[1])
  21964. : regexpClassEscape(part)
  21965. ).join("")
  21966. + "]/" + (cls.ignoreCase ? "i" : "");
  21967. }
  21968. function buildExpectation(e) {
  21969. switch (e.type) {
  21970. case "rule": {
  21971. return "peg$otherExpectation(\"" + stringEscape(e.value) + "\")";
  21972. }
  21973. case "literal": {
  21974. return "peg$literalExpectation(\""
  21975. + stringEscape(e.value)
  21976. + "\", "
  21977. + e.ignoreCase
  21978. + ")";
  21979. }
  21980. case "class": {
  21981. const parts = e.value.map(part =>
  21982. Array.isArray(part)
  21983. ? "[\"" + stringEscape(part[0]) + "\", \"" + stringEscape(part[1]) + "\"]"
  21984. : "\"" + stringEscape(part) + "\""
  21985. ).join(", ");
  21986. return "peg$classExpectation(["
  21987. + parts + "], "
  21988. + e.inverted + ", "
  21989. + e.ignoreCase
  21990. + ")";
  21991. }
  21992. case "any": return "peg$anyExpectation()";
  21993. default: throw new Error("Unknown expectation type (" + JSON.stringify(e) + ")");
  21994. }
  21995. }
  21996. function buildFunc(a) {
  21997. return "function(" + a.params.join(", ") + ") {"
  21998. + a.body
  21999. + "}";
  22000. }
  22001. return ast.literals.map(
  22002. (c, i) => "var " + l(i) + " = " + buildLiteral(c) + ";"
  22003. ).concat("", ast.classes.map(
  22004. (c, i) => "var " + r(i) + " = " + buildRegexp(c) + ";"
  22005. )).concat("", ast.expectations.map(
  22006. (c, i) => "var " + e(i) + " = " + buildExpectation(c) + ";"
  22007. )).concat("", ast.functions.map(
  22008. (c, i) => "var " + f(i) + " = " + buildFunc(c) + ";"
  22009. )).join("\n");
  22010. }
  22011. function generateRuleHeader(ruleNameCode, ruleIndexCode) {
  22012. const parts = [];
  22013. parts.push("");
  22014. if (options.trace) {
  22015. parts.push([
  22016. "peg$tracer.trace({",
  22017. " type: \"rule.enter\",",
  22018. " rule: " + ruleNameCode + ",",
  22019. " location: peg$computeLocation(startPos, startPos)",
  22020. "});",
  22021. ""
  22022. ].join("\n"));
  22023. }
  22024. if (options.cache) {
  22025. parts.push([
  22026. "var key = peg$currPos * " + ast.rules.length + " + " + ruleIndexCode + ";",
  22027. "var cached = peg$resultsCache[key];",
  22028. "",
  22029. "if (cached) {",
  22030. " peg$currPos = cached.nextPos;",
  22031. ""
  22032. ].join("\n"));
  22033. if (options.trace) {
  22034. parts.push([
  22035. "if (cached.result !== peg$FAILED) {",
  22036. " peg$tracer.trace({",
  22037. " type: \"rule.match\",",
  22038. " rule: " + ruleNameCode + ",",
  22039. " result: cached.result,",
  22040. " location: peg$computeLocation(startPos, peg$currPos)",
  22041. " });",
  22042. "} else {",
  22043. " peg$tracer.trace({",
  22044. " type: \"rule.fail\",",
  22045. " rule: " + ruleNameCode + ",",
  22046. " location: peg$computeLocation(startPos, startPos)",
  22047. " });",
  22048. "}",
  22049. ""
  22050. ].join("\n"));
  22051. }
  22052. parts.push([
  22053. " return cached.result;",
  22054. "}",
  22055. ""
  22056. ].join("\n"));
  22057. }
  22058. return parts.join("\n");
  22059. }
  22060. function generateRuleFooter(ruleNameCode, resultCode) {
  22061. const parts = [];
  22062. if (options.cache) {
  22063. parts.push([
  22064. "",
  22065. "peg$resultsCache[key] = { nextPos: peg$currPos, result: " + resultCode + " };"
  22066. ].join("\n"));
  22067. }
  22068. if (options.trace) {
  22069. parts.push([
  22070. "",
  22071. "if (" + resultCode + " !== peg$FAILED) {",
  22072. " peg$tracer.trace({",
  22073. " type: \"rule.match\",",
  22074. " rule: " + ruleNameCode + ",",
  22075. " result: " + resultCode + ",",
  22076. " location: peg$computeLocation(startPos, peg$currPos)",
  22077. " });",
  22078. "} else {",
  22079. " peg$tracer.trace({",
  22080. " type: \"rule.fail\",",
  22081. " rule: " + ruleNameCode + ",",
  22082. " location: peg$computeLocation(startPos, startPos)",
  22083. " });",
  22084. "}"
  22085. ].join("\n"));
  22086. }
  22087. parts.push([
  22088. "",
  22089. "return " + resultCode + ";"
  22090. ].join("\n"));
  22091. return parts.join("\n");
  22092. }
  22093. function generateRuleFunction(rule) {
  22094. const parts = [];
  22095. const stack = new Stack(rule.name, "s", "var");
  22096. function compile(bc) {
  22097. let ip = 0;
  22098. const end = bc.length;
  22099. const parts = [];
  22100. let value;
  22101. function compileCondition(cond, argCount) {
  22102. const baseLength = argCount + 3;
  22103. const thenLength = bc[ip + baseLength - 2];
  22104. const elseLength = bc[ip + baseLength - 1];
  22105. let thenCode, elseCode;
  22106. stack.checkedIf(ip,
  22107. () => {
  22108. ip += baseLength;
  22109. thenCode = compile(bc.slice(ip, ip + thenLength));
  22110. ip += thenLength;
  22111. },
  22112. elseLength > 0 ? () => {
  22113. elseCode = compile(bc.slice(ip, ip + elseLength));
  22114. ip += elseLength;
  22115. } : null
  22116. );
  22117. parts.push("if (" + cond + ") {");
  22118. parts.push(indent2(thenCode));
  22119. if (elseLength > 0) {
  22120. parts.push("} else {");
  22121. parts.push(indent2(elseCode));
  22122. }
  22123. parts.push("}");
  22124. }
  22125. function compileLoop(cond) {
  22126. const baseLength = 2;
  22127. const bodyLength = bc[ip + baseLength - 1];
  22128. let bodyCode;
  22129. stack.checkedLoop(ip, () => {
  22130. ip += baseLength;
  22131. bodyCode = compile(bc.slice(ip, ip + bodyLength));
  22132. ip += bodyLength;
  22133. });
  22134. parts.push("while (" + cond + ") {");
  22135. parts.push(indent2(bodyCode));
  22136. parts.push("}");
  22137. }
  22138. function compileCall() {
  22139. const baseLength = 4;
  22140. const paramsLength = bc[ip + baseLength - 1];
  22141. const value = f(bc[ip + 1]) + "("
  22142. + bc.slice(ip + baseLength, ip + baseLength + paramsLength).map(
  22143. p => stack.index(p)
  22144. ).join(", ")
  22145. + ")";
  22146. stack.pop(bc[ip + 2]);
  22147. parts.push(stack.push(value));
  22148. ip += baseLength + paramsLength;
  22149. }
  22150. while (ip < end) {
  22151. switch (bc[ip]) {
  22152. case op.PUSH_EMPTY_STRING: // PUSH_EMPTY_STRING
  22153. parts.push(stack.push("''"));
  22154. ip++;
  22155. break;
  22156. case op.PUSH_CURR_POS: // PUSH_CURR_POS
  22157. parts.push(stack.push("peg$currPos"));
  22158. ip++;
  22159. break;
  22160. case op.PUSH_UNDEFINED: // PUSH_UNDEFINED
  22161. parts.push(stack.push("undefined"));
  22162. ip++;
  22163. break;
  22164. case op.PUSH_NULL: // PUSH_NULL
  22165. parts.push(stack.push("null"));
  22166. ip++;
  22167. break;
  22168. case op.PUSH_FAILED: // PUSH_FAILED
  22169. parts.push(stack.push("peg$FAILED"));
  22170. ip++;
  22171. break;
  22172. case op.PUSH_EMPTY_ARRAY: // PUSH_EMPTY_ARRAY
  22173. parts.push(stack.push("[]"));
  22174. ip++;
  22175. break;
  22176. case op.POP: // POP
  22177. stack.pop();
  22178. ip++;
  22179. break;
  22180. case op.POP_CURR_POS: // POP_CURR_POS
  22181. parts.push("peg$currPos = " + stack.pop() + ";");
  22182. ip++;
  22183. break;
  22184. case op.POP_N: // POP_N n
  22185. stack.pop(bc[ip + 1]);
  22186. ip += 2;
  22187. break;
  22188. case op.NIP: // NIP
  22189. value = stack.pop();
  22190. stack.pop();
  22191. parts.push(stack.push(value));
  22192. ip++;
  22193. break;
  22194. case op.APPEND: // APPEND
  22195. value = stack.pop();
  22196. parts.push(stack.top() + ".push(" + value + ");");
  22197. ip++;
  22198. break;
  22199. case op.WRAP: // WRAP n
  22200. parts.push(
  22201. // @ts-expect-error pop() returns array if argument is specified
  22202. stack.push("[" + stack.pop(bc[ip + 1]).join(", ") + "]")
  22203. );
  22204. ip += 2;
  22205. break;
  22206. case op.TEXT: // TEXT
  22207. parts.push(
  22208. stack.push("input.substring(" + stack.pop() + ", peg$currPos)")
  22209. );
  22210. ip++;
  22211. break;
  22212. case op.PLUCK: { // PLUCK n, k, p1, ..., pK
  22213. const baseLength = 3;
  22214. const paramsLength = bc[ip + baseLength - 1];
  22215. const n = baseLength + paramsLength;
  22216. value = bc.slice(ip + baseLength, ip + n);
  22217. value = paramsLength === 1
  22218. ? stack.index(value[0])
  22219. : `[ ${
  22220. value.map(p => stack.index(p)).join(", ")
  22221. } ]`;
  22222. stack.pop(bc[ip + 1]);
  22223. parts.push(stack.push(value));
  22224. ip += n;
  22225. break;
  22226. }
  22227. case op.IF: // IF t, f
  22228. compileCondition(stack.top(), 0);
  22229. break;
  22230. case op.IF_ERROR: // IF_ERROR t, f
  22231. compileCondition(stack.top() + " === peg$FAILED", 0);
  22232. break;
  22233. case op.IF_NOT_ERROR: // IF_NOT_ERROR t, f
  22234. compileCondition(stack.top() + " !== peg$FAILED", 0);
  22235. break;
  22236. case op.WHILE_NOT_ERROR: // WHILE_NOT_ERROR b
  22237. compileLoop(stack.top() + " !== peg$FAILED");
  22238. break;
  22239. case op.MATCH_ANY: // MATCH_ANY a, f, ...
  22240. compileCondition("input.length > peg$currPos", 0);
  22241. break;
  22242. case op.MATCH_STRING: // MATCH_STRING s, a, f, ...
  22243. compileCondition(
  22244. ast.literals[bc[ip + 1]].length > 1
  22245. ? "input.substr(peg$currPos, "
  22246. + ast.literals[bc[ip + 1]].length
  22247. + ") === "
  22248. + l(bc[ip + 1])
  22249. : "input.charCodeAt(peg$currPos) === "
  22250. + ast.literals[bc[ip + 1]].charCodeAt(0),
  22251. 1
  22252. );
  22253. break;
  22254. case op.MATCH_STRING_IC: // MATCH_STRING_IC s, a, f, ...
  22255. compileCondition(
  22256. "input.substr(peg$currPos, "
  22257. + ast.literals[bc[ip + 1]].length
  22258. + ").toLowerCase() === "
  22259. + l(bc[ip + 1]),
  22260. 1
  22261. );
  22262. break;
  22263. case op.MATCH_CHAR_CLASS: // MATCH_CHAR_CLASS c, a, f, ...
  22264. compileCondition(
  22265. r(bc[ip + 1]) + ".test(input.charAt(peg$currPos))",
  22266. 1
  22267. );
  22268. break;
  22269. case op.ACCEPT_N: // ACCEPT_N n
  22270. parts.push(stack.push(
  22271. bc[ip + 1] > 1
  22272. ? "input.substr(peg$currPos, " + bc[ip + 1] + ")"
  22273. : "input.charAt(peg$currPos)"
  22274. ));
  22275. parts.push(
  22276. bc[ip + 1] > 1
  22277. ? "peg$currPos += " + bc[ip + 1] + ";"
  22278. : "peg$currPos++;"
  22279. );
  22280. ip += 2;
  22281. break;
  22282. case op.ACCEPT_STRING: // ACCEPT_STRING s
  22283. parts.push(stack.push(l(bc[ip + 1])));
  22284. parts.push(
  22285. ast.literals[bc[ip + 1]].length > 1
  22286. ? "peg$currPos += " + ast.literals[bc[ip + 1]].length + ";"
  22287. : "peg$currPos++;"
  22288. );
  22289. ip += 2;
  22290. break;
  22291. case op.FAIL: // FAIL e
  22292. parts.push(stack.push("peg$FAILED"));
  22293. parts.push("if (peg$silentFails === 0) { peg$fail(" + e(bc[ip + 1]) + "); }");
  22294. ip += 2;
  22295. break;
  22296. case op.LOAD_SAVED_POS: // LOAD_SAVED_POS p
  22297. parts.push("peg$savedPos = " + stack.index(bc[ip + 1]) + ";");
  22298. ip += 2;
  22299. break;
  22300. case op.UPDATE_SAVED_POS: // UPDATE_SAVED_POS
  22301. parts.push("peg$savedPos = peg$currPos;");
  22302. ip++;
  22303. break;
  22304. case op.CALL: // CALL f, n, pc, p1, p2, ..., pN
  22305. compileCall();
  22306. break;
  22307. case op.RULE: // RULE r
  22308. parts.push(stack.push("peg$parse" + ast.rules[bc[ip + 1]].name + "()"));
  22309. ip += 2;
  22310. break;
  22311. case op.SILENT_FAILS_ON: // SILENT_FAILS_ON
  22312. parts.push("peg$silentFails++;");
  22313. ip++;
  22314. break;
  22315. case op.SILENT_FAILS_OFF: // SILENT_FAILS_OFF
  22316. parts.push("peg$silentFails--;");
  22317. ip++;
  22318. break;
  22319. default:
  22320. throw new Error("Invalid opcode: " + bc[ip] + ".");
  22321. }
  22322. }
  22323. return parts.join("\n");
  22324. }
  22325. const code = compile(rule.bytecode);
  22326. parts.push("function peg$parse" + rule.name + "() {");
  22327. if (options.trace) {
  22328. parts.push(" var startPos = peg$currPos;");
  22329. }
  22330. parts.push(indent2(stack.defines()));
  22331. parts.push(indent2(generateRuleHeader(
  22332. "\"" + stringEscape(rule.name) + "\"",
  22333. asts.indexOfRule(ast, rule.name)
  22334. )));
  22335. parts.push(indent2(code));
  22336. parts.push(indent2(generateRuleFooter(
  22337. "\"" + stringEscape(rule.name) + "\"",
  22338. stack.result()
  22339. )));
  22340. parts.push("}");
  22341. return parts.join("\n");
  22342. }
  22343. function generateToplevel() {
  22344. const parts = [];
  22345. if (ast.topLevelInitializer) {
  22346. parts.push(ast.topLevelInitializer.code);
  22347. parts.push("");
  22348. }
  22349. parts.push([
  22350. "function peg$subclass(child, parent) {",
  22351. " function C() { this.constructor = child; }",
  22352. " C.prototype = parent.prototype;",
  22353. " child.prototype = new C();",
  22354. "}",
  22355. "",
  22356. "function peg$SyntaxError(message, expected, found, location) {",
  22357. " var self = Error.call(this, message);",
  22358. " if (Object.setPrototypeOf) {",
  22359. " Object.setPrototypeOf(self, peg$SyntaxError.prototype);",
  22360. " }",
  22361. " self.expected = expected;",
  22362. " self.found = found;",
  22363. " self.location = location;",
  22364. " self.name = \"SyntaxError\";",
  22365. " return self;",
  22366. "}",
  22367. "",
  22368. "peg$subclass(peg$SyntaxError, Error);",
  22369. "",
  22370. "function peg$padEnd(str, targetLength, padString) {",
  22371. " padString = padString || \" \";",
  22372. " if (str.length > targetLength) { return str; }",
  22373. " targetLength -= str.length;",
  22374. " padString += padString.repeat(targetLength);",
  22375. " return str + padString.slice(0, targetLength);",
  22376. "}",
  22377. "",
  22378. "peg$SyntaxError.prototype.format = function(sources) {",
  22379. " var str = \"Error: \" + this.message;",
  22380. " if (this.location) {",
  22381. " var src = null;",
  22382. " var k;",
  22383. " for (k = 0; k < sources.length; k++) {",
  22384. " if (sources[k].source === this.location.source) {",
  22385. " src = sources[k].text.split(/\\r\\n|\\n|\\r/g);",
  22386. " break;",
  22387. " }",
  22388. " }",
  22389. " var s = this.location.start;",
  22390. " var loc = this.location.source + \":\" + s.line + \":\" + s.column;",
  22391. " if (src) {",
  22392. " var e = this.location.end;",
  22393. " var filler = peg$padEnd(\"\", s.line.toString().length);",
  22394. " var line = src[s.line - 1];",
  22395. " var last = s.line === e.line ? e.column : line.length + 1;",
  22396. " str += \"\\n --> \" + loc + \"\\n\"",
  22397. " + filler + \" |\\n\"",
  22398. " + s.line + \" | \" + line + \"\\n\"",
  22399. " + filler + \" | \" + peg$padEnd(\"\", s.column - 1)",
  22400. " + peg$padEnd(\"\", last - s.column, \"^\");",
  22401. " } else {",
  22402. " str += \"\\n at \" + loc;",
  22403. " }",
  22404. " }",
  22405. " return str;",
  22406. "};",
  22407. "",
  22408. "peg$SyntaxError.buildMessage = function(expected, found) {",
  22409. " var DESCRIBE_EXPECTATION_FNS = {",
  22410. " literal: function(expectation) {",
  22411. " return \"\\\"\" + literalEscape(expectation.text) + \"\\\"\";",
  22412. " },",
  22413. "",
  22414. " class: function(expectation) {",
  22415. " var escapedParts = expectation.parts.map(function(part) {",
  22416. " return Array.isArray(part)",
  22417. " ? classEscape(part[0]) + \"-\" + classEscape(part[1])",
  22418. " : classEscape(part);",
  22419. " });",
  22420. "",
  22421. " return \"[\" + (expectation.inverted ? \"^\" : \"\") + escapedParts + \"]\";",
  22422. " },",
  22423. "",
  22424. " any: function() {",
  22425. " return \"any character\";",
  22426. " },",
  22427. "",
  22428. " end: function() {",
  22429. " return \"end of input\";",
  22430. " },",
  22431. "",
  22432. " other: function(expectation) {",
  22433. " return expectation.description;",
  22434. " }",
  22435. " };",
  22436. "",
  22437. " function hex(ch) {",
  22438. " return ch.charCodeAt(0).toString(16).toUpperCase();",
  22439. " }",
  22440. "",
  22441. " function literalEscape(s) {",
  22442. " return s",
  22443. " .replace(/\\\\/g, \"\\\\\\\\\")", // backslash
  22444. " .replace(/\"/g, \"\\\\\\\"\")", // closing double quote
  22445. " .replace(/\\0/g, \"\\\\0\")", // null
  22446. " .replace(/\\t/g, \"\\\\t\")", // horizontal tab
  22447. " .replace(/\\n/g, \"\\\\n\")", // line feed
  22448. " .replace(/\\r/g, \"\\\\r\")", // carriage return
  22449. " .replace(/[\\x00-\\x0F]/g, function(ch) { return \"\\\\x0\" + hex(ch); })",
  22450. " .replace(/[\\x10-\\x1F\\x7F-\\x9F]/g, function(ch) { return \"\\\\x\" + hex(ch); });",
  22451. " }",
  22452. "",
  22453. " function classEscape(s) {",
  22454. " return s",
  22455. " .replace(/\\\\/g, \"\\\\\\\\\")", // backslash
  22456. " .replace(/\\]/g, \"\\\\]\")", // closing bracket
  22457. " .replace(/\\^/g, \"\\\\^\")", // caret
  22458. " .replace(/-/g, \"\\\\-\")", // dash
  22459. " .replace(/\\0/g, \"\\\\0\")", // null
  22460. " .replace(/\\t/g, \"\\\\t\")", // horizontal tab
  22461. " .replace(/\\n/g, \"\\\\n\")", // line feed
  22462. " .replace(/\\r/g, \"\\\\r\")", // carriage return
  22463. " .replace(/[\\x00-\\x0F]/g, function(ch) { return \"\\\\x0\" + hex(ch); })",
  22464. " .replace(/[\\x10-\\x1F\\x7F-\\x9F]/g, function(ch) { return \"\\\\x\" + hex(ch); });",
  22465. " }",
  22466. "",
  22467. " function describeExpectation(expectation) {",
  22468. " return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);",
  22469. " }",
  22470. "",
  22471. " function describeExpected(expected) {",
  22472. " var descriptions = expected.map(describeExpectation);",
  22473. " var i, j;",
  22474. "",
  22475. " descriptions.sort();",
  22476. "",
  22477. " if (descriptions.length > 0) {",
  22478. " for (i = 1, j = 1; i < descriptions.length; i++) {",
  22479. " if (descriptions[i - 1] !== descriptions[i]) {",
  22480. " descriptions[j] = descriptions[i];",
  22481. " j++;",
  22482. " }",
  22483. " }",
  22484. " descriptions.length = j;",
  22485. " }",
  22486. "",
  22487. " switch (descriptions.length) {",
  22488. " case 1:",
  22489. " return descriptions[0];",
  22490. "",
  22491. " case 2:",
  22492. " return descriptions[0] + \" or \" + descriptions[1];",
  22493. "",
  22494. " default:",
  22495. " return descriptions.slice(0, -1).join(\", \")",
  22496. " + \", or \"",
  22497. " + descriptions[descriptions.length - 1];",
  22498. " }",
  22499. " }",
  22500. "",
  22501. " function describeFound(found) {",
  22502. " return found ? \"\\\"\" + literalEscape(found) + \"\\\"\" : \"end of input\";",
  22503. " }",
  22504. "",
  22505. " return \"Expected \" + describeExpected(expected) + \" but \" + describeFound(found) + \" found.\";",
  22506. "};",
  22507. ""
  22508. ].join("\n"));
  22509. if (options.trace) {
  22510. parts.push([
  22511. "function peg$DefaultTracer() {",
  22512. " this.indentLevel = 0;",
  22513. "}",
  22514. "",
  22515. "peg$DefaultTracer.prototype.trace = function(event) {",
  22516. " var that = this;",
  22517. "",
  22518. " function log(event) {",
  22519. " function repeat(string, n) {",
  22520. " var result = \"\", i;",
  22521. "",
  22522. " for (i = 0; i < n; i++) {",
  22523. " result += string;",
  22524. " }",
  22525. "",
  22526. " return result;",
  22527. " }",
  22528. "",
  22529. " function pad(string, length) {",
  22530. " return string + repeat(\" \", length - string.length);",
  22531. " }",
  22532. "",
  22533. " if (typeof console === \"object\") {", // IE 8-10
  22534. " console.log(",
  22535. " event.location.start.line + \":\" + event.location.start.column + \"-\"",
  22536. " + event.location.end.line + \":\" + event.location.end.column + \" \"",
  22537. " + pad(event.type, 10) + \" \"",
  22538. " + repeat(\" \", that.indentLevel) + event.rule",
  22539. " );",
  22540. " }",
  22541. " }",
  22542. "",
  22543. " switch (event.type) {",
  22544. " case \"rule.enter\":",
  22545. " log(event);",
  22546. " this.indentLevel++;",
  22547. " break;",
  22548. "",
  22549. " case \"rule.match\":",
  22550. " this.indentLevel--;",
  22551. " log(event);",
  22552. " break;",
  22553. "",
  22554. " case \"rule.fail\":",
  22555. " this.indentLevel--;",
  22556. " log(event);",
  22557. " break;",
  22558. "",
  22559. " default:",
  22560. " throw new Error(\"Invalid event type: \" + event.type + \".\");",
  22561. " }",
  22562. "};",
  22563. ""
  22564. ].join("\n"));
  22565. }
  22566. const startRuleFunctions = "{ "
  22567. + options.allowedStartRules.map(
  22568. r => r + ": peg$parse" + r
  22569. ).join(", ")
  22570. + " }";
  22571. const startRuleFunction = "peg$parse" + options.allowedStartRules[0];
  22572. parts.push([
  22573. "function peg$parse(input, options) {",
  22574. " options = options !== undefined ? options : {};",
  22575. "",
  22576. " var peg$FAILED = {};",
  22577. " var peg$source = options.grammarSource;",
  22578. "",
  22579. " var peg$startRuleFunctions = " + startRuleFunctions + ";",
  22580. " var peg$startRuleFunction = " + startRuleFunction + ";",
  22581. "",
  22582. indent2(generateTables()),
  22583. "",
  22584. " var peg$currPos = 0;",
  22585. " var peg$savedPos = 0;",
  22586. " var peg$posDetailsCache = [{ line: 1, column: 1 }];",
  22587. " var peg$maxFailPos = 0;",
  22588. " var peg$maxFailExpected = [];",
  22589. " var peg$silentFails = 0;", // 0 = report failures, > 0 = silence failures
  22590. ""
  22591. ].join("\n"));
  22592. if (options.cache) {
  22593. parts.push([
  22594. " var peg$resultsCache = {};",
  22595. ""
  22596. ].join("\n"));
  22597. }
  22598. if (options.trace) {
  22599. parts.push([
  22600. " var peg$tracer = \"tracer\" in options ? options.tracer : new peg$DefaultTracer();",
  22601. ""
  22602. ].join("\n"));
  22603. }
  22604. parts.push([
  22605. " var peg$result;",
  22606. "",
  22607. " if (\"startRule\" in options) {",
  22608. " if (!(options.startRule in peg$startRuleFunctions)) {",
  22609. " throw new Error(\"Can't start parsing from rule \\\"\" + options.startRule + \"\\\".\");",
  22610. " }",
  22611. "",
  22612. " peg$startRuleFunction = peg$startRuleFunctions[options.startRule];",
  22613. " }",
  22614. "",
  22615. " function text() {",
  22616. " return input.substring(peg$savedPos, peg$currPos);",
  22617. " }",
  22618. "",
  22619. " function offset() {",
  22620. " return peg$savedPos;",
  22621. " }",
  22622. "",
  22623. " function range() {",
  22624. " return {",
  22625. " source: peg$source,",
  22626. " start: peg$savedPos,",
  22627. " end: peg$currPos",
  22628. " };",
  22629. " }",
  22630. "",
  22631. " function location() {",
  22632. " return peg$computeLocation(peg$savedPos, peg$currPos);",
  22633. " }",
  22634. "",
  22635. " function expected(description, location) {",
  22636. " location = location !== undefined",
  22637. " ? location",
  22638. " : peg$computeLocation(peg$savedPos, peg$currPos);",
  22639. "",
  22640. " throw peg$buildStructuredError(",
  22641. " [peg$otherExpectation(description)],",
  22642. " input.substring(peg$savedPos, peg$currPos),",
  22643. " location",
  22644. " );",
  22645. " }",
  22646. "",
  22647. " function error(message, location) {",
  22648. " location = location !== undefined",
  22649. " ? location",
  22650. " : peg$computeLocation(peg$savedPos, peg$currPos);",
  22651. "",
  22652. " throw peg$buildSimpleError(message, location);",
  22653. " }",
  22654. "",
  22655. " function peg$literalExpectation(text, ignoreCase) {",
  22656. " return { type: \"literal\", text: text, ignoreCase: ignoreCase };",
  22657. " }",
  22658. "",
  22659. " function peg$classExpectation(parts, inverted, ignoreCase) {",
  22660. " return { type: \"class\", parts: parts, inverted: inverted, ignoreCase: ignoreCase };",
  22661. " }",
  22662. "",
  22663. " function peg$anyExpectation() {",
  22664. " return { type: \"any\" };",
  22665. " }",
  22666. "",
  22667. " function peg$endExpectation() {",
  22668. " return { type: \"end\" };",
  22669. " }",
  22670. "",
  22671. " function peg$otherExpectation(description) {",
  22672. " return { type: \"other\", description: description };",
  22673. " }",
  22674. "",
  22675. " function peg$computePosDetails(pos) {",
  22676. " var details = peg$posDetailsCache[pos];",
  22677. " var p;",
  22678. "",
  22679. " if (details) {",
  22680. " return details;",
  22681. " } else {",
  22682. " p = pos - 1;",
  22683. " while (!peg$posDetailsCache[p]) {",
  22684. " p--;",
  22685. " }",
  22686. "",
  22687. " details = peg$posDetailsCache[p];",
  22688. " details = {",
  22689. " line: details.line,",
  22690. " column: details.column",
  22691. " };",
  22692. "",
  22693. " while (p < pos) {",
  22694. " if (input.charCodeAt(p) === 10) {",
  22695. " details.line++;",
  22696. " details.column = 1;",
  22697. " } else {",
  22698. " details.column++;",
  22699. " }",
  22700. "",
  22701. " p++;",
  22702. " }",
  22703. "",
  22704. " peg$posDetailsCache[pos] = details;",
  22705. "",
  22706. " return details;",
  22707. " }",
  22708. " }",
  22709. "",
  22710. " function peg$computeLocation(startPos, endPos) {",
  22711. " var startPosDetails = peg$computePosDetails(startPos);",
  22712. " var endPosDetails = peg$computePosDetails(endPos);",
  22713. "",
  22714. " return {",
  22715. " source: peg$source,",
  22716. " start: {",
  22717. " offset: startPos,",
  22718. " line: startPosDetails.line,",
  22719. " column: startPosDetails.column",
  22720. " },",
  22721. " end: {",
  22722. " offset: endPos,",
  22723. " line: endPosDetails.line,",
  22724. " column: endPosDetails.column",
  22725. " }",
  22726. " };",
  22727. " }",
  22728. "",
  22729. " function peg$fail(expected) {",
  22730. " if (peg$currPos < peg$maxFailPos) { return; }",
  22731. "",
  22732. " if (peg$currPos > peg$maxFailPos) {",
  22733. " peg$maxFailPos = peg$currPos;",
  22734. " peg$maxFailExpected = [];",
  22735. " }",
  22736. "",
  22737. " peg$maxFailExpected.push(expected);",
  22738. " }",
  22739. "",
  22740. " function peg$buildSimpleError(message, location) {",
  22741. " return new peg$SyntaxError(message, null, null, location);",
  22742. " }",
  22743. "",
  22744. " function peg$buildStructuredError(expected, found, location) {",
  22745. " return new peg$SyntaxError(",
  22746. " peg$SyntaxError.buildMessage(expected, found),",
  22747. " expected,",
  22748. " found,",
  22749. " location",
  22750. " );",
  22751. " }",
  22752. ""
  22753. ].join("\n"));
  22754. ast.rules.forEach(rule => {
  22755. parts.push(indent2(generateRuleFunction(rule)));
  22756. parts.push("");
  22757. });
  22758. if (ast.initializer) {
  22759. parts.push(indent2(ast.initializer.code));
  22760. parts.push("");
  22761. }
  22762. parts.push([
  22763. " peg$result = peg$startRuleFunction();",
  22764. "",
  22765. " if (peg$result !== peg$FAILED && peg$currPos === input.length) {",
  22766. " return peg$result;",
  22767. " } else {",
  22768. " if (peg$result !== peg$FAILED && peg$currPos < input.length) {",
  22769. " peg$fail(peg$endExpectation());",
  22770. " }",
  22771. "",
  22772. " throw peg$buildStructuredError(",
  22773. " peg$maxFailExpected,",
  22774. " peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,",
  22775. " peg$maxFailPos < input.length",
  22776. " ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)",
  22777. " : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)",
  22778. " );",
  22779. " }",
  22780. "}"
  22781. ].join("\n"));
  22782. return parts.join("\n");
  22783. }
  22784. function generateWrapper(toplevelCode) {
  22785. function generateGeneratedByComment() {
  22786. return [
  22787. `// Generated by Peggy ${VERSION}.`,
  22788. "//",
  22789. "// https://peggyjs.org/"
  22790. ].join("\n");
  22791. }
  22792. function generateParserObject() {
  22793. return options.trace
  22794. ? [
  22795. "{",
  22796. " SyntaxError: peg$SyntaxError,",
  22797. " DefaultTracer: peg$DefaultTracer,",
  22798. " parse: peg$parse",
  22799. "}"
  22800. ].join("\n")
  22801. : [
  22802. "{",
  22803. " SyntaxError: peg$SyntaxError,",
  22804. " parse: peg$parse",
  22805. "}"
  22806. ].join("\n");
  22807. }
  22808. function generateParserExports() {
  22809. return options.trace
  22810. ? [
  22811. "{",
  22812. " peg$SyntaxError as SyntaxError,",
  22813. " peg$DefaultTracer as DefaultTracer,",
  22814. " peg$parse as parse",
  22815. "}"
  22816. ].join("\n")
  22817. : [
  22818. "{",
  22819. " peg$SyntaxError as SyntaxError,",
  22820. " peg$parse as parse",
  22821. "}"
  22822. ].join("\n");
  22823. }
  22824. const generators = {
  22825. bare() {
  22826. return [
  22827. generateGeneratedByComment(),
  22828. "(function() {",
  22829. " \"use strict\";",
  22830. "",
  22831. indent2(toplevelCode),
  22832. "",
  22833. indent2("return " + generateParserObject() + ";"),
  22834. "})()"
  22835. ].join("\n");
  22836. },
  22837. commonjs() {
  22838. const parts = [];
  22839. const dependencyVars = Object.keys(options.dependencies);
  22840. parts.push([
  22841. generateGeneratedByComment(),
  22842. "",
  22843. "\"use strict\";",
  22844. ""
  22845. ].join("\n"));
  22846. if (dependencyVars.length > 0) {
  22847. dependencyVars.forEach(variable => {
  22848. parts.push("var " + variable
  22849. + " = require(\""
  22850. + stringEscape(options.dependencies[variable])
  22851. + "\");"
  22852. );
  22853. });
  22854. parts.push("");
  22855. }
  22856. parts.push([
  22857. toplevelCode,
  22858. "",
  22859. "module.exports = " + generateParserObject() + ";",
  22860. ""
  22861. ].join("\n"));
  22862. return parts.join("\n");
  22863. },
  22864. es() {
  22865. const parts = [];
  22866. const dependencyVars = Object.keys(options.dependencies);
  22867. parts.push(
  22868. generateGeneratedByComment(),
  22869. ""
  22870. );
  22871. if (dependencyVars.length > 0) {
  22872. dependencyVars.forEach(variable => {
  22873. parts.push("import " + variable
  22874. + " from \""
  22875. + stringEscape(options.dependencies[variable])
  22876. + "\";"
  22877. );
  22878. });
  22879. parts.push("");
  22880. }
  22881. parts.push(
  22882. toplevelCode,
  22883. "",
  22884. "export " + generateParserExports() + ";",
  22885. ""
  22886. );
  22887. return parts.join("\n");
  22888. },
  22889. amd() {
  22890. const dependencyVars = Object.keys(options.dependencies);
  22891. const dependencyIds = dependencyVars.map(v => options.dependencies[v]);
  22892. const dependencies = "["
  22893. + dependencyIds.map(
  22894. id => "\"" + stringEscape(id) + "\""
  22895. ).join(", ")
  22896. + "]";
  22897. const params = dependencyVars.join(", ");
  22898. return [
  22899. generateGeneratedByComment(),
  22900. "define(" + dependencies + ", function(" + params + ") {",
  22901. " \"use strict\";",
  22902. "",
  22903. indent2(toplevelCode),
  22904. "",
  22905. indent2("return " + generateParserObject() + ";"),
  22906. "});",
  22907. ""
  22908. ].join("\n");
  22909. },
  22910. globals() {
  22911. return [
  22912. generateGeneratedByComment(),
  22913. "(function(root) {",
  22914. " \"use strict\";",
  22915. "",
  22916. indent2(toplevelCode),
  22917. "",
  22918. indent2("root." + options.exportVar + " = " + generateParserObject() + ";"),
  22919. "})(this);",
  22920. ""
  22921. ].join("\n");
  22922. },
  22923. umd() {
  22924. const parts = [];
  22925. const dependencyVars = Object.keys(options.dependencies);
  22926. const dependencyIds = dependencyVars.map(v => options.dependencies[v]);
  22927. const dependencies = "["
  22928. + dependencyIds.map(
  22929. id => "\"" + stringEscape(id) + "\""
  22930. ).join(", ")
  22931. + "]";
  22932. const requires = dependencyIds.map(
  22933. id => "require(\"" + stringEscape(id) + "\")"
  22934. ).join(", ");
  22935. const params = dependencyVars.join(", ");
  22936. parts.push([
  22937. generateGeneratedByComment(),
  22938. "(function(root, factory) {",
  22939. " if (typeof define === \"function\" && define.amd) {",
  22940. " define(" + dependencies + ", factory);",
  22941. " } else if (typeof module === \"object\" && module.exports) {",
  22942. " module.exports = factory(" + requires + ");"
  22943. ].join("\n"));
  22944. if (options.exportVar !== null) {
  22945. parts.push([
  22946. " } else {",
  22947. " root." + options.exportVar + " = factory();"
  22948. ].join("\n"));
  22949. }
  22950. parts.push([
  22951. " }",
  22952. "})(this, function(" + params + ") {",
  22953. " \"use strict\";",
  22954. "",
  22955. indent2(toplevelCode),
  22956. "",
  22957. indent2("return " + generateParserObject() + ";"),
  22958. "});",
  22959. ""
  22960. ].join("\n"));
  22961. return parts.join("\n");
  22962. }
  22963. };
  22964. return generators[options.format]();
  22965. }
  22966. ast.code = generateWrapper(generateToplevel());
  22967. }
  22968. module.exports = generateJS;
  22969. /***/ }),
  22970. /***/ 35412:
  22971. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  22972. "use strict";
  22973. const visitor = __webpack_require__(68202);
  22974. const asts = __webpack_require__(19861);
  22975. const GrammarError = __webpack_require__(94297);
  22976. const ALWAYS_MATCH = 1;
  22977. const SOMETIMES_MATCH = 0;
  22978. const NEVER_MATCH = -1;
  22979. // Inference match result of the each node. Can be:
  22980. // -1: negative result, matching of that node always fails
  22981. // 0: neutral result, may be fail, may be match
  22982. // 1: positive result, always match
  22983. function inferenceMatchResult(ast) {
  22984. function sometimesMatch(node) { return (node.match = SOMETIMES_MATCH); }
  22985. function alwaysMatch(node) {
  22986. inference(node.expression);
  22987. return (node.match = ALWAYS_MATCH);
  22988. }
  22989. function inferenceExpression(node) {
  22990. return (node.match = inference(node.expression));
  22991. }
  22992. function inferenceElements(elements, forChoice) {
  22993. const length = elements.length;
  22994. let always = 0;
  22995. let never = 0;
  22996. for (let i = 0; i < length; ++i) {
  22997. const result = inference(elements[i]);
  22998. if (result === ALWAYS_MATCH) { ++always; }
  22999. if (result === NEVER_MATCH) { ++never; }
  23000. }
  23001. if (always === length) {
  23002. return ALWAYS_MATCH;
  23003. }
  23004. if (forChoice) {
  23005. return never === length ? NEVER_MATCH : SOMETIMES_MATCH;
  23006. }
  23007. return never > 0 ? NEVER_MATCH : SOMETIMES_MATCH;
  23008. }
  23009. const inference = visitor.build({
  23010. rule(node) {
  23011. let oldResult;
  23012. let count = 0;
  23013. // If property not yet calculated, do that
  23014. if (typeof node.match === "undefined") {
  23015. node.match = SOMETIMES_MATCH;
  23016. do {
  23017. oldResult = node.match;
  23018. node.match = inference(node.expression);
  23019. // 6 == 3! -- permutations count for all transitions from one match
  23020. // state to another.
  23021. // After 6 iterations the cycle with guarantee begins
  23022. // For example, an input of `start = [] start` will generate the
  23023. // sequence: 0 -> -1 -> -1 (then stop)
  23024. //
  23025. // A more complex grammar theoretically would generate the
  23026. // sequence: 0 -> 1 -> 0 -> -1 -> 0 -> 1 -> ... (then cycle)
  23027. // but there are no examples of such grammars yet (possible, they
  23028. // do not exist at all)
  23029. // istanbul ignore next This is canary test, shouldn't trigger in real life
  23030. if (++count > 6) {
  23031. throw new GrammarError(
  23032. "Infinity cycle detected when trying to evaluate node match result",
  23033. node.location
  23034. );
  23035. }
  23036. } while (oldResult !== node.match);
  23037. }
  23038. return node.match;
  23039. },
  23040. named: inferenceExpression,
  23041. choice(node) {
  23042. return (node.match = inferenceElements(node.alternatives, true));
  23043. },
  23044. action: inferenceExpression,
  23045. sequence(node) {
  23046. return (node.match = inferenceElements(node.elements, false));
  23047. },
  23048. labeled: inferenceExpression,
  23049. text: inferenceExpression,
  23050. simple_and: inferenceExpression,
  23051. simple_not(node) {
  23052. return (node.match = -inference(node.expression));
  23053. },
  23054. optional: alwaysMatch,
  23055. zero_or_more: alwaysMatch,
  23056. one_or_more: inferenceExpression,
  23057. group: inferenceExpression,
  23058. semantic_and: sometimesMatch,
  23059. semantic_not: sometimesMatch,
  23060. rule_ref(node) {
  23061. const rule = asts.findRule(ast, node.name);
  23062. return (node.match = inference(rule));
  23063. },
  23064. literal(node) {
  23065. // Empty literal always match on any input
  23066. const match = node.value.length === 0 ? ALWAYS_MATCH : SOMETIMES_MATCH;
  23067. return (node.match = match);
  23068. },
  23069. class(node) {
  23070. // Empty character class never match on any input
  23071. const match = node.parts.length === 0 ? NEVER_MATCH : SOMETIMES_MATCH;
  23072. return (node.match = match);
  23073. },
  23074. // |any| not match on empty input
  23075. any: sometimesMatch
  23076. });
  23077. inference(ast);
  23078. }
  23079. inferenceMatchResult.ALWAYS_MATCH = ALWAYS_MATCH;
  23080. inferenceMatchResult.SOMETIMES_MATCH = SOMETIMES_MATCH;
  23081. inferenceMatchResult.NEVER_MATCH = NEVER_MATCH;
  23082. module.exports = inferenceMatchResult;
  23083. /***/ }),
  23084. /***/ 32929:
  23085. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  23086. "use strict";
  23087. const visitor = __webpack_require__(68202);
  23088. // Removes proxy rules -- that is, rules that only delegate to other rule.
  23089. function removeProxyRules(ast, options) {
  23090. function isProxyRule(node) {
  23091. return node.type === "rule" && node.expression.type === "rule_ref";
  23092. }
  23093. function replaceRuleRefs(ast, from, to) {
  23094. const replace = visitor.build({
  23095. rule_ref(node) {
  23096. if (node.name === from) {
  23097. node.name = to;
  23098. }
  23099. }
  23100. });
  23101. replace(ast);
  23102. }
  23103. const indices = [];
  23104. ast.rules.forEach((rule, i) => {
  23105. if (isProxyRule(rule)) {
  23106. replaceRuleRefs(ast, rule.name, rule.expression.name);
  23107. if (options.allowedStartRules.indexOf(rule.name) === -1) {
  23108. indices.push(i);
  23109. }
  23110. }
  23111. });
  23112. indices.reverse();
  23113. indices.forEach(i => { ast.rules.splice(i, 1); });
  23114. }
  23115. module.exports = removeProxyRules;
  23116. /***/ }),
  23117. /***/ 96734:
  23118. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  23119. "use strict";
  23120. const GrammarError = __webpack_require__(94297);
  23121. const visitor = __webpack_require__(68202);
  23122. // Checks that each label is defined only once within each scope.
  23123. function reportDuplicateLabels(ast) {
  23124. function cloneEnv(env) {
  23125. const clone = {};
  23126. Object.keys(env).forEach(name => {
  23127. clone[name] = env[name];
  23128. });
  23129. return clone;
  23130. }
  23131. function checkExpressionWithClonedEnv(node, env) {
  23132. check(node.expression, cloneEnv(env));
  23133. }
  23134. const check = visitor.build({
  23135. rule(node) {
  23136. check(node.expression, { });
  23137. },
  23138. choice(node, env) {
  23139. node.alternatives.forEach(alternative => {
  23140. check(alternative, cloneEnv(env));
  23141. });
  23142. },
  23143. action: checkExpressionWithClonedEnv,
  23144. labeled(node, env) {
  23145. const label = node.label;
  23146. if (label && Object.prototype.hasOwnProperty.call(env, label)) {
  23147. throw new GrammarError(
  23148. `Label "${node.label}" is already defined`,
  23149. node.labelLocation,
  23150. [{
  23151. message: "Original label location",
  23152. location: env[label]
  23153. }]
  23154. );
  23155. }
  23156. check(node.expression, env);
  23157. env[node.label] = node.labelLocation;
  23158. },
  23159. text: checkExpressionWithClonedEnv,
  23160. simple_and: checkExpressionWithClonedEnv,
  23161. simple_not: checkExpressionWithClonedEnv,
  23162. optional: checkExpressionWithClonedEnv,
  23163. zero_or_more: checkExpressionWithClonedEnv,
  23164. one_or_more: checkExpressionWithClonedEnv,
  23165. group: checkExpressionWithClonedEnv
  23166. });
  23167. check(ast);
  23168. }
  23169. module.exports = reportDuplicateLabels;
  23170. /***/ }),
  23171. /***/ 1117:
  23172. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  23173. "use strict";
  23174. const GrammarError = __webpack_require__(94297);
  23175. const visitor = __webpack_require__(68202);
  23176. // Checks that each rule is defined only once.
  23177. function reportDuplicateRules(ast) {
  23178. const rules = {};
  23179. const check = visitor.build({
  23180. rule(node) {
  23181. if (Object.prototype.hasOwnProperty.call(rules, node.name)) {
  23182. throw new GrammarError(
  23183. `Rule "${node.name}" is already defined`,
  23184. node.nameLocation,
  23185. [{
  23186. message: "Original rule location",
  23187. location: rules[node.name]
  23188. }]
  23189. );
  23190. }
  23191. rules[node.name] = node.nameLocation;
  23192. }
  23193. });
  23194. check(ast);
  23195. }
  23196. module.exports = reportDuplicateRules;
  23197. /***/ }),
  23198. /***/ 66237:
  23199. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  23200. "use strict";
  23201. const GrammarError = __webpack_require__(94297);
  23202. const visitor = __webpack_require__(68202);
  23203. //
  23204. // Compiler pass to ensure the following are enforced:
  23205. //
  23206. // - plucking can not be done with an action block
  23207. //
  23208. function reportIncorrectPlucking(ast) {
  23209. const check = visitor.build({
  23210. action(node) {
  23211. check(node.expression, node);
  23212. },
  23213. labeled(node, action) {
  23214. if (node.pick) {
  23215. if (action) {
  23216. throw new GrammarError(
  23217. "\"@\" cannot be used with an action block",
  23218. node.labelLocation,
  23219. [{
  23220. message: "Action block location",
  23221. location: action.codeLocation
  23222. }]
  23223. );
  23224. }
  23225. }
  23226. check(node.expression);
  23227. }
  23228. });
  23229. check(ast);
  23230. }
  23231. module.exports = reportIncorrectPlucking;
  23232. /***/ }),
  23233. /***/ 10730:
  23234. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  23235. "use strict";
  23236. const GrammarError = __webpack_require__(94297);
  23237. const asts = __webpack_require__(19861);
  23238. const visitor = __webpack_require__(68202);
  23239. // Reports left recursion in the grammar, which prevents infinite recursion in
  23240. // the generated parser.
  23241. //
  23242. // Both direct and indirect recursion is detected. The pass also correctly
  23243. // reports cases like this:
  23244. //
  23245. // start = "a"? start
  23246. //
  23247. // In general, if a rule reference can be reached without consuming any input,
  23248. // it can lead to left recursion.
  23249. function reportInfiniteRecursion(ast) {
  23250. // Array with rule names for error message
  23251. const visitedRules = [];
  23252. // Array with rule_refs for diagnostic
  23253. const backtraceRefs = [];
  23254. const check = visitor.build({
  23255. rule(node) {
  23256. visitedRules.push(node.name);
  23257. check(node.expression);
  23258. visitedRules.pop();
  23259. },
  23260. sequence(node) {
  23261. node.elements.every(element => {
  23262. check(element);
  23263. return !asts.alwaysConsumesOnSuccess(ast, element);
  23264. });
  23265. },
  23266. rule_ref(node) {
  23267. backtraceRefs.push(node);
  23268. const rule = asts.findRule(ast, node.name);
  23269. if (visitedRules.indexOf(node.name) !== -1) {
  23270. visitedRules.push(node.name);
  23271. throw new GrammarError(
  23272. "Possible infinite loop when parsing (left recursion: "
  23273. + visitedRules.join(" -> ")
  23274. + ")",
  23275. rule.nameLocation,
  23276. backtraceRefs.map((ref, i, a) => {
  23277. return {
  23278. message: i + 1 !== a.length
  23279. ? `Step ${i + 1}: call of the rule "${ref.name}" without input consumption`
  23280. : `Step ${i + 1}: call itself without input consumption - left recursion`,
  23281. location: ref.location
  23282. };
  23283. })
  23284. );
  23285. }
  23286. check(rule);
  23287. backtraceRefs.pop();
  23288. }
  23289. });
  23290. check(ast);
  23291. }
  23292. module.exports = reportInfiniteRecursion;
  23293. /***/ }),
  23294. /***/ 79505:
  23295. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  23296. "use strict";
  23297. const GrammarError = __webpack_require__(94297);
  23298. const asts = __webpack_require__(19861);
  23299. const visitor = __webpack_require__(68202);
  23300. // Reports expressions that don't consume any input inside |*| or |+| in the
  23301. // grammar, which prevents infinite loops in the generated parser.
  23302. function reportInfiniteRepetition(ast) {
  23303. const check = visitor.build({
  23304. zero_or_more(node) {
  23305. if (!asts.alwaysConsumesOnSuccess(ast, node.expression)) {
  23306. throw new GrammarError(
  23307. "Possible infinite loop when parsing (repetition used with an expression that may not consume any input)",
  23308. node.location
  23309. );
  23310. }
  23311. },
  23312. one_or_more(node) {
  23313. if (!asts.alwaysConsumesOnSuccess(ast, node.expression)) {
  23314. throw new GrammarError(
  23315. "Possible infinite loop when parsing (repetition used with an expression that may not consume any input)",
  23316. node.location
  23317. );
  23318. }
  23319. }
  23320. });
  23321. check(ast);
  23322. }
  23323. module.exports = reportInfiniteRepetition;
  23324. /***/ }),
  23325. /***/ 41442:
  23326. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  23327. "use strict";
  23328. const GrammarError = __webpack_require__(94297);
  23329. const asts = __webpack_require__(19861);
  23330. const visitor = __webpack_require__(68202);
  23331. // Checks that all referenced rules exist.
  23332. function reportUndefinedRules(ast) {
  23333. const check = visitor.build({
  23334. rule_ref(node) {
  23335. if (!asts.findRule(ast, node.name)) {
  23336. throw new GrammarError(
  23337. `Rule "${node.name}" is not defined`,
  23338. node.location
  23339. );
  23340. }
  23341. }
  23342. });
  23343. check(ast);
  23344. }
  23345. module.exports = reportUndefinedRules;
  23346. /***/ }),
  23347. /***/ 78013:
  23348. /***/ ((module) => {
  23349. "use strict";
  23350. /** Utility class that helps generating code for C-like languages. */
  23351. class Stack {
  23352. /**
  23353. * Constructs the helper for tracking variable slots of the stack virtual machine
  23354. *
  23355. * @param {string} ruleName The name of rule that will be used in error messages
  23356. * @param {string} varName The prefix for generated names of variables
  23357. * @param {string} type The type of the variables. For JavaScript there are `var` or `let`
  23358. */
  23359. constructor(ruleName, varName, type) {
  23360. /** Last used variable in the stack. */
  23361. this.sp = -1;
  23362. /** Maximum stack size. */
  23363. this.maxSp = -1;
  23364. this.varName = varName;
  23365. this.ruleName = ruleName;
  23366. this.type = type;
  23367. }
  23368. /**
  23369. * Returns name of the variable at the index `i`.
  23370. *
  23371. * @param {number} i Index for which name must be generated
  23372. * @return {string} Generated name
  23373. *
  23374. * @throws {RangeError} If `i < 0`, which means a stack underflow (there are more `pop`s than `push`es)
  23375. */
  23376. name(i) {
  23377. if (i < 0) {
  23378. throw new RangeError(
  23379. `Rule '${this.ruleName}': The variable stack underflow: attempt to use a variable '${this.varName}<x>' at an index ${i}`
  23380. );
  23381. }
  23382. return this.varName + i;
  23383. }
  23384. /**
  23385. * Assigns `exprCode` to the new variable in the stack, returns generated code.
  23386. * As the result, the size of a stack increases on 1.
  23387. *
  23388. * @param {string} exprCode Any expression code that must be assigned to the new variable in the stack
  23389. * @return {string} Assignment code
  23390. */
  23391. push(exprCode) {
  23392. const code = this.name(++this.sp) + " = " + exprCode + ";";
  23393. if (this.sp > this.maxSp) { this.maxSp = this.sp; }
  23394. return code;
  23395. }
  23396. /**
  23397. * Returns name or `n` names of the variable(s) from the top of the stack.
  23398. *
  23399. * @param {number} [n=1] Quantity of variables, which need to be removed from the stack
  23400. * @return {string|string[]} Generated name(s). If `n > 1` than array has length of `n`
  23401. *
  23402. * @throws {RangeError} If the stack underflow (there are more `pop`s than `push`es)
  23403. */
  23404. pop(n) {
  23405. if (n !== undefined) {
  23406. this.sp -= n;
  23407. return Array.from({ length: n }, (v, i) => this.name(this.sp + 1 + i));
  23408. }
  23409. return this.name(this.sp--);
  23410. }
  23411. /**
  23412. * Returns name of the first free variable. The same as `index(0)`.
  23413. *
  23414. * @return {string} Generated name
  23415. *
  23416. * @throws {RangeError} If the stack is empty (there was no `push`'s yet)
  23417. */
  23418. top() { return this.name(this.sp); }
  23419. /**
  23420. * Returns name of the variable at index `i`.
  23421. *
  23422. * @param {number} [i] Index of the variable from top of the stack
  23423. * @return {string} Generated name
  23424. *
  23425. * @throws {RangeError} If `i < 0` or more than the stack size
  23426. */
  23427. index(i) {
  23428. if (i < 0) {
  23429. throw new RangeError(
  23430. `Rule '${this.ruleName}': The variable stack overflow: attempt to get a variable at a negative index ${i}`
  23431. );
  23432. }
  23433. return this.name(this.sp - i);
  23434. }
  23435. /**
  23436. * Returns variable name that contains result (bottom of the stack).
  23437. *
  23438. * @return {string} Generated name
  23439. *
  23440. * @throws {RangeError} If the stack is empty (there was no `push`es yet)
  23441. */
  23442. result() {
  23443. if (this.maxSp < 0) {
  23444. throw new RangeError(
  23445. `Rule '${this.ruleName}': The variable stack is empty, can't get the result'`
  23446. );
  23447. }
  23448. return this.name(0);
  23449. }
  23450. /**
  23451. * Returns defines of all used variables.
  23452. *
  23453. * @return {string} Generated define variable expression with the type `this.type`.
  23454. * If the stack is empty, returns empty string
  23455. */
  23456. defines() {
  23457. if (this.maxSp < 0) {
  23458. return "";
  23459. }
  23460. return this.type + " " + Array.from({ length: this.maxSp + 1 }, (v, i) => this.name(i)).join(", ") + ";";
  23461. }
  23462. /**
  23463. * Checks that code in the `generateIf` and `generateElse` move the stack pointer in the same way.
  23464. *
  23465. * @param {number} pos Opcode number for error messages
  23466. * @param {function()} generateIf First function that works with this stack
  23467. * @param {function()} [generateElse] Second function that works with this stack
  23468. * @return {undefined}
  23469. *
  23470. * @throws {Error} If `generateElse` is defined and the stack pointer moved differently in the
  23471. * `generateIf` and `generateElse`
  23472. */
  23473. checkedIf(pos, generateIf, generateElse) {
  23474. const baseSp = this.sp;
  23475. generateIf();
  23476. if (generateElse) {
  23477. const thenSp = this.sp;
  23478. this.sp = baseSp;
  23479. generateElse();
  23480. if (thenSp !== this.sp) {
  23481. throw new Error(
  23482. "Rule '" + this.ruleName + "', position " + pos + ": "
  23483. + "Branches of a condition can't move the stack pointer differently "
  23484. + "(before: " + baseSp + ", after then: " + thenSp + ", after else: " + this.sp + ")."
  23485. );
  23486. }
  23487. }
  23488. }
  23489. /**
  23490. * Checks that code in the `generateBody` do not move stack pointer.
  23491. *
  23492. * @param {number} pos Opcode number for error messages
  23493. * @param {function()} generateBody Function that works with this stack
  23494. * @return {undefined}
  23495. *
  23496. * @throws {Error} If `generateBody` move the stack pointer (if it contains unbalanced `push`es and `pop`s)
  23497. */
  23498. checkedLoop(pos, generateBody) {
  23499. const baseSp = this.sp;
  23500. generateBody();
  23501. if (baseSp !== this.sp) {
  23502. throw new Error(
  23503. "Rule '" + this.ruleName + "', position " + pos + ": "
  23504. + "Body of a loop can't move the stack pointer "
  23505. + "(before: " + baseSp + ", after: " + this.sp + ")."
  23506. );
  23507. }
  23508. }
  23509. }
  23510. module.exports = Stack;
  23511. /***/ }),
  23512. /***/ 68202:
  23513. /***/ ((module) => {
  23514. "use strict";
  23515. // Simple AST node visitor builder.
  23516. const visitor = {
  23517. build(functions) {
  23518. function visit(node, ...args) {
  23519. return functions[node.type](node, ...args);
  23520. }
  23521. function visitNop() {
  23522. // Do nothing.
  23523. }
  23524. function visitExpression(node, ...args) {
  23525. return visit(node.expression, ...args);
  23526. }
  23527. function visitChildren(property) {
  23528. return function(node, ...args) {
  23529. // We do not use .map() here, because if you need the result
  23530. // of applying visitor to children you probable also need to
  23531. // process it in some way, therefore you anyway have to override
  23532. // this method. If you do not needed that, we do not waste time
  23533. // and memory for creating the output array
  23534. node[property].forEach(child => visit(child, ...args));
  23535. };
  23536. }
  23537. const DEFAULT_FUNCTIONS = {
  23538. grammar(node, ...args) {
  23539. if (node.topLevelInitializer) {
  23540. visit(node.topLevelInitializer, ...args);
  23541. }
  23542. if (node.initializer) {
  23543. visit(node.initializer, ...args);
  23544. }
  23545. node.rules.forEach(rule => visit(rule, ...args));
  23546. },
  23547. top_level_initializer: visitNop,
  23548. initializer: visitNop,
  23549. rule: visitExpression,
  23550. named: visitExpression,
  23551. choice: visitChildren("alternatives"),
  23552. action: visitExpression,
  23553. sequence: visitChildren("elements"),
  23554. labeled: visitExpression,
  23555. text: visitExpression,
  23556. simple_and: visitExpression,
  23557. simple_not: visitExpression,
  23558. optional: visitExpression,
  23559. zero_or_more: visitExpression,
  23560. one_or_more: visitExpression,
  23561. group: visitExpression,
  23562. semantic_and: visitNop,
  23563. semantic_not: visitNop,
  23564. rule_ref: visitNop,
  23565. literal: visitNop,
  23566. class: visitNop,
  23567. any: visitNop
  23568. };
  23569. Object.keys(DEFAULT_FUNCTIONS).forEach(type => {
  23570. if (!Object.prototype.hasOwnProperty.call(functions, type)) {
  23571. functions[type] = DEFAULT_FUNCTIONS[type];
  23572. }
  23573. });
  23574. return visit;
  23575. }
  23576. };
  23577. module.exports = visitor;
  23578. /***/ }),
  23579. /***/ 94297:
  23580. /***/ ((module) => {
  23581. "use strict";
  23582. // See: https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
  23583. // This is roughly what typescript generates, it's not called after super(), where it's needed.
  23584. const setProtoOf = Object.setPrototypeOf
  23585. || ({ __proto__: [] } instanceof Array
  23586. && function(d, b) {
  23587. // eslint-disable-next-line no-proto
  23588. d.__proto__ = b;
  23589. })
  23590. || function(d, b) {
  23591. for (const p in b) {
  23592. if (Object.prototype.hasOwnProperty.call(b, p)) {
  23593. d[p] = b[p];
  23594. }
  23595. }
  23596. };
  23597. // Thrown when the grammar contains an error.
  23598. class GrammarError extends Error {
  23599. constructor(message, location, diagnostics) {
  23600. super(message);
  23601. setProtoOf(this, GrammarError.prototype);
  23602. this.name = "GrammarError";
  23603. this.location = location;
  23604. if (diagnostics === undefined) {
  23605. diagnostics = [];
  23606. }
  23607. this.diagnostics = diagnostics;
  23608. }
  23609. toString() {
  23610. let str = super.toString();
  23611. if (this.location) {
  23612. str += "\n at ";
  23613. if ((this.location.source !== undefined)
  23614. && (this.location.source !== null)) {
  23615. str += `${this.location.source}:`;
  23616. }
  23617. str += `${this.location.start.line}:${this.location.start.column}`;
  23618. }
  23619. for (const diag of this.diagnostics) {
  23620. str += "\n from ";
  23621. if ((diag.location.source !== undefined)
  23622. && (diag.location.source !== null)) {
  23623. str += `${diag.location.source}:`;
  23624. }
  23625. str += `${diag.location.start.line}:${diag.location.start.column}: ${diag.message}`;
  23626. }
  23627. return str;
  23628. }
  23629. /**
  23630. * @typedef SourceText {source: any, text: string}
  23631. */
  23632. /**
  23633. * Format the error with associated sources. The `location.source` should have
  23634. * a `toString()` representation in order the result to look nice. If source
  23635. * is `null` or `undefined`, it is skipped from the output
  23636. *
  23637. * Sample output:
  23638. * ```
  23639. * Error: Label "head" is already defined
  23640. * --> examples/arithmetics.pegjs:15:17
  23641. * |
  23642. * 15 | = head:Factor head:(_ ("*" / "/") _ Factor)* {
  23643. * | ^^^^
  23644. * note: Original label location
  23645. * --> examples/arithmetics.pegjs:15:5
  23646. * |
  23647. * 15 | = head:Factor head:(_ ("*" / "/") _ Factor)* {
  23648. * | ^^^^
  23649. * ```
  23650. *
  23651. * @param {SourceText[]} sources mapping from location source to source text
  23652. *
  23653. * @returns {string} the formatted error
  23654. */
  23655. format(sources) {
  23656. const srcLines = sources.map(({ source, text }) => ({
  23657. source,
  23658. text: text.split(/\r\n|\n|\r/g)
  23659. }));
  23660. function entry(location, indent, message = "") {
  23661. let str = "";
  23662. const src = srcLines.find(({ source }) => source === location.source);
  23663. const s = location.start;
  23664. if (src) {
  23665. const e = location.end;
  23666. const line = src.text[s.line - 1];
  23667. const last = s.line === e.line ? e.column : line.length + 1;
  23668. if (message) {
  23669. str += `\nnote: ${message}`;
  23670. }
  23671. str += `
  23672. --> ${location.source}:${s.line}:${s.column}
  23673. ${"".padEnd(indent)} |
  23674. ${s.line.toString().padStart(indent)} | ${line}
  23675. ${"".padEnd(indent)} | ${"".padEnd(s.column - 1)}${"".padEnd(last - s.column, "^")}`;
  23676. } else {
  23677. str += `\n at ${location.source}:${s.line}:${s.column}`;
  23678. if (message) {
  23679. str += `: ${message}`;
  23680. }
  23681. }
  23682. return str;
  23683. }
  23684. // Calculate maximum width of all lines
  23685. let maxLine;
  23686. if (this.location) {
  23687. maxLine = this.diagnostics.reduce(
  23688. (t, { location }) => Math.max(t, location.start.line),
  23689. this.location.start.line
  23690. );
  23691. } else {
  23692. maxLine = Math.max.apply(
  23693. null,
  23694. this.diagnostics.map(d => d.location.start.line)
  23695. );
  23696. }
  23697. maxLine = maxLine.toString().length;
  23698. let str = `Error: ${this.message}`;
  23699. if (this.location) {
  23700. str += entry(this.location, maxLine);
  23701. }
  23702. for (const diag of this.diagnostics) {
  23703. str += entry(diag.location, maxLine, diag.message);
  23704. }
  23705. return str;
  23706. }
  23707. }
  23708. module.exports = GrammarError;
  23709. /***/ }),
  23710. /***/ 80170:
  23711. /***/ ((module) => {
  23712. "use strict";
  23713. // Generated by Peggy 1.2.0.
  23714. //
  23715. // https://peggyjs.org/
  23716. const OPS_TO_PREFIXED_TYPES = {
  23717. "$": "text",
  23718. "&": "simple_and",
  23719. "!": "simple_not"
  23720. };
  23721. const OPS_TO_SUFFIXED_TYPES = {
  23722. "?": "optional",
  23723. "*": "zero_or_more",
  23724. "+": "one_or_more"
  23725. };
  23726. const OPS_TO_SEMANTIC_PREDICATE_TYPES = {
  23727. "&": "semantic_and",
  23728. "!": "semantic_not"
  23729. };
  23730. function peg$subclass(child, parent) {
  23731. function C() { this.constructor = child; }
  23732. C.prototype = parent.prototype;
  23733. child.prototype = new C();
  23734. }
  23735. function peg$SyntaxError(message, expected, found, location) {
  23736. var self = Error.call(this, message);
  23737. if (Object.setPrototypeOf) {
  23738. Object.setPrototypeOf(self, peg$SyntaxError.prototype);
  23739. }
  23740. self.expected = expected;
  23741. self.found = found;
  23742. self.location = location;
  23743. self.name = "SyntaxError";
  23744. return self;
  23745. }
  23746. peg$subclass(peg$SyntaxError, Error);
  23747. function peg$padEnd(str, targetLength, padString) {
  23748. padString = padString || " ";
  23749. if (str.length > targetLength) { return str; }
  23750. targetLength -= str.length;
  23751. padString += padString.repeat(targetLength);
  23752. return str + padString.slice(0, targetLength);
  23753. }
  23754. peg$SyntaxError.prototype.format = function(sources) {
  23755. var str = "Error: " + this.message;
  23756. if (this.location) {
  23757. var src = null;
  23758. var k;
  23759. for (k = 0; k < sources.length; k++) {
  23760. if (sources[k].source === this.location.source) {
  23761. src = sources[k].text.split(/\r\n|\n|\r/g);
  23762. break;
  23763. }
  23764. }
  23765. var s = this.location.start;
  23766. var loc = this.location.source + ":" + s.line + ":" + s.column;
  23767. if (src) {
  23768. var e = this.location.end;
  23769. var filler = peg$padEnd("", s.line.toString().length);
  23770. var line = src[s.line - 1];
  23771. var last = s.line === e.line ? e.column : line.length + 1;
  23772. str += "\n --> " + loc + "\n"
  23773. + filler + " |\n"
  23774. + s.line + " | " + line + "\n"
  23775. + filler + " | " + peg$padEnd("", s.column - 1)
  23776. + peg$padEnd("", last - s.column, "^");
  23777. } else {
  23778. str += "\n at " + loc;
  23779. }
  23780. }
  23781. return str;
  23782. };
  23783. peg$SyntaxError.buildMessage = function(expected, found) {
  23784. var DESCRIBE_EXPECTATION_FNS = {
  23785. literal: function(expectation) {
  23786. return "\"" + literalEscape(expectation.text) + "\"";
  23787. },
  23788. class: function(expectation) {
  23789. var escapedParts = expectation.parts.map(function(part) {
  23790. return Array.isArray(part)
  23791. ? classEscape(part[0]) + "-" + classEscape(part[1])
  23792. : classEscape(part);
  23793. });
  23794. return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
  23795. },
  23796. any: function() {
  23797. return "any character";
  23798. },
  23799. end: function() {
  23800. return "end of input";
  23801. },
  23802. other: function(expectation) {
  23803. return expectation.description;
  23804. }
  23805. };
  23806. function hex(ch) {
  23807. return ch.charCodeAt(0).toString(16).toUpperCase();
  23808. }
  23809. function literalEscape(s) {
  23810. return s
  23811. .replace(/\\/g, "\\\\")
  23812. .replace(/"/g, "\\\"")
  23813. .replace(/\0/g, "\\0")
  23814. .replace(/\t/g, "\\t")
  23815. .replace(/\n/g, "\\n")
  23816. .replace(/\r/g, "\\r")
  23817. .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); })
  23818. .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); });
  23819. }
  23820. function classEscape(s) {
  23821. return s
  23822. .replace(/\\/g, "\\\\")
  23823. .replace(/\]/g, "\\]")
  23824. .replace(/\^/g, "\\^")
  23825. .replace(/-/g, "\\-")
  23826. .replace(/\0/g, "\\0")
  23827. .replace(/\t/g, "\\t")
  23828. .replace(/\n/g, "\\n")
  23829. .replace(/\r/g, "\\r")
  23830. .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); })
  23831. .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); });
  23832. }
  23833. function describeExpectation(expectation) {
  23834. return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
  23835. }
  23836. function describeExpected(expected) {
  23837. var descriptions = expected.map(describeExpectation);
  23838. var i, j;
  23839. descriptions.sort();
  23840. if (descriptions.length > 0) {
  23841. for (i = 1, j = 1; i < descriptions.length; i++) {
  23842. if (descriptions[i - 1] !== descriptions[i]) {
  23843. descriptions[j] = descriptions[i];
  23844. j++;
  23845. }
  23846. }
  23847. descriptions.length = j;
  23848. }
  23849. switch (descriptions.length) {
  23850. case 1:
  23851. return descriptions[0];
  23852. case 2:
  23853. return descriptions[0] + " or " + descriptions[1];
  23854. default:
  23855. return descriptions.slice(0, -1).join(", ")
  23856. + ", or "
  23857. + descriptions[descriptions.length - 1];
  23858. }
  23859. }
  23860. function describeFound(found) {
  23861. return found ? "\"" + literalEscape(found) + "\"" : "end of input";
  23862. }
  23863. return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
  23864. };
  23865. function peg$parse(input, options) {
  23866. options = options !== undefined ? options : {};
  23867. var peg$FAILED = {};
  23868. var peg$source = options.grammarSource;
  23869. var peg$startRuleFunctions = { Grammar: peg$parseGrammar };
  23870. var peg$startRuleFunction = peg$parseGrammar;
  23871. var peg$c0 = "{";
  23872. var peg$c1 = "}";
  23873. var peg$c2 = "=";
  23874. var peg$c3 = "/";
  23875. var peg$c4 = "@";
  23876. var peg$c5 = ":";
  23877. var peg$c6 = "$";
  23878. var peg$c7 = "&";
  23879. var peg$c8 = "!";
  23880. var peg$c9 = "?";
  23881. var peg$c10 = "*";
  23882. var peg$c11 = "+";
  23883. var peg$c12 = "(";
  23884. var peg$c13 = ")";
  23885. var peg$c14 = "\t";
  23886. var peg$c15 = "\v";
  23887. var peg$c16 = "\f";
  23888. var peg$c17 = " ";
  23889. var peg$c18 = "\xA0";
  23890. var peg$c19 = "\uFEFF";
  23891. var peg$c20 = "\n";
  23892. var peg$c21 = "\r\n";
  23893. var peg$c22 = "\r";
  23894. var peg$c23 = "\u2028";
  23895. var peg$c24 = "\u2029";
  23896. var peg$c25 = "/*";
  23897. var peg$c26 = "*/";
  23898. var peg$c27 = "//";
  23899. var peg$c28 = "_";
  23900. var peg$c29 = "\\";
  23901. var peg$c30 = "\u200C";
  23902. var peg$c31 = "\u200D";
  23903. var peg$c32 = "i";
  23904. var peg$c33 = "\"";
  23905. var peg$c34 = "'";
  23906. var peg$c35 = "[";
  23907. var peg$c36 = "^";
  23908. var peg$c37 = "]";
  23909. var peg$c38 = "-";
  23910. var peg$c39 = "0";
  23911. var peg$c40 = "b";
  23912. var peg$c41 = "f";
  23913. var peg$c42 = "n";
  23914. var peg$c43 = "r";
  23915. var peg$c44 = "t";
  23916. var peg$c45 = "v";
  23917. var peg$c46 = "x";
  23918. var peg$c47 = "u";
  23919. var peg$c48 = ".";
  23920. var peg$c49 = ";";
  23921. var peg$r0 = /^[\n\r\u2028\u2029]/;
  23922. var peg$r1 = /^[0-9]/;
  23923. var peg$r2 = /^[0-9a-f]/i;
  23924. var peg$r3 = /^[{}]/;
  23925. var peg$r4 = /^[a-z\xB5\xDF-\xF6\xF8-\xFF\u0101\u0103\u0105\u0107\u0109\u010B\u010D\u010F\u0111\u0113\u0115\u0117\u0119\u011B\u011D\u011F\u0121\u0123\u0125\u0127\u0129\u012B\u012D\u012F\u0131\u0133\u0135\u0137-\u0138\u013A\u013C\u013E\u0140\u0142\u0144\u0146\u0148-\u0149\u014B\u014D\u014F\u0151\u0153\u0155\u0157\u0159\u015B\u015D\u015F\u0161\u0163\u0165\u0167\u0169\u016B\u016D\u016F\u0171\u0173\u0175\u0177\u017A\u017C\u017E-\u0180\u0183\u0185\u0188\u018C-\u018D\u0192\u0195\u0199-\u019B\u019E\u01A1\u01A3\u01A5\u01A8\u01AA-\u01AB\u01AD\u01B0\u01B4\u01B6\u01B9-\u01BA\u01BD-\u01BF\u01C6\u01C9\u01CC\u01CE\u01D0\u01D2\u01D4\u01D6\u01D8\u01DA\u01DC-\u01DD\u01DF\u01E1\u01E3\u01E5\u01E7\u01E9\u01EB\u01ED\u01EF-\u01F0\u01F3\u01F5\u01F9\u01FB\u01FD\u01FF\u0201\u0203\u0205\u0207\u0209\u020B\u020D\u020F\u0211\u0213\u0215\u0217\u0219\u021B\u021D\u021F\u0221\u0223\u0225\u0227\u0229\u022B\u022D\u022F\u0231\u0233-\u0239\u023C\u023F-\u0240\u0242\u0247\u0249\u024B\u024D\u024F-\u0293\u0295-\u02AF\u0371\u0373\u0377\u037B-\u037D\u0390\u03AC-\u03CE\u03D0-\u03D1\u03D5-\u03D7\u03D9\u03DB\u03DD\u03DF\u03E1\u03E3\u03E5\u03E7\u03E9\u03EB\u03ED\u03EF-\u03F3\u03F5\u03F8\u03FB-\u03FC\u0430-\u045F\u0461\u0463\u0465\u0467\u0469\u046B\u046D\u046F\u0471\u0473\u0475\u0477\u0479\u047B\u047D\u047F\u0481\u048B\u048D\u048F\u0491\u0493\u0495\u0497\u0499\u049B\u049D\u049F\u04A1\u04A3\u04A5\u04A7\u04A9\u04AB\u04AD\u04AF\u04B1\u04B3\u04B5\u04B7\u04B9\u04BB\u04BD\u04BF\u04C2\u04C4\u04C6\u04C8\u04CA\u04CC\u04CE-\u04CF\u04D1\u04D3\u04D5\u04D7\u04D9\u04DB\u04DD\u04DF\u04E1\u04E3\u04E5\u04E7\u04E9\u04EB\u04ED\u04EF\u04F1\u04F3\u04F5\u04F7\u04F9\u04FB\u04FD\u04FF\u0501\u0503\u0505\u0507\u0509\u050B\u050D\u050F\u0511\u0513\u0515\u0517\u0519\u051B\u051D\u051F\u0521\u0523\u0525\u0527\u0529\u052B\u052D\u052F\u0561-\u0587\u13F8-\u13FD\u1D00-\u1D2B\u1D6B-\u1D77\u1D79-\u1D9A\u1E01\u1E03\u1E05\u1E07\u1E09\u1E0B\u1E0D\u1E0F\u1E11\u1E13\u1E15\u1E17\u1E19\u1E1B\u1E1D\u1E1F\u1E21\u1E23\u1E25\u1E27\u1E29\u1E2B\u1E2D\u1E2F\u1E31\u1E33\u1E35\u1E37\u1E39\u1E3B\u1E3D\u1E3F\u1E41\u1E43\u1E45\u1E47\u1E49\u1E4B\u1E4D\u1E4F\u1E51\u1E53\u1E55\u1E57\u1E59\u1E5B\u1E5D\u1E5F\u1E61\u1E63\u1E65\u1E67\u1E69\u1E6B\u1E6D\u1E6F\u1E71\u1E73\u1E75\u1E77\u1E79\u1E7B\u1E7D\u1E7F\u1E81\u1E83\u1E85\u1E87\u1E89\u1E8B\u1E8D\u1E8F\u1E91\u1E93\u1E95-\u1E9D\u1E9F\u1EA1\u1EA3\u1EA5\u1EA7\u1EA9\u1EAB\u1EAD\u1EAF\u1EB1\u1EB3\u1EB5\u1EB7\u1EB9\u1EBB\u1EBD\u1EBF\u1EC1\u1EC3\u1EC5\u1EC7\u1EC9\u1ECB\u1ECD\u1ECF\u1ED1\u1ED3\u1ED5\u1ED7\u1ED9\u1EDB\u1EDD\u1EDF\u1EE1\u1EE3\u1EE5\u1EE7\u1EE9\u1EEB\u1EED\u1EEF\u1EF1\u1EF3\u1EF5\u1EF7\u1EF9\u1EFB\u1EFD\u1EFF-\u1F07\u1F10-\u1F15\u1F20-\u1F27\u1F30-\u1F37\u1F40-\u1F45\u1F50-\u1F57\u1F60-\u1F67\u1F70-\u1F7D\u1F80-\u1F87\u1F90-\u1F97\u1FA0-\u1FA7\u1FB0-\u1FB4\u1FB6-\u1FB7\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FC7\u1FD0-\u1FD3\u1FD6-\u1FD7\u1FE0-\u1FE7\u1FF2-\u1FF4\u1FF6-\u1FF7\u210A\u210E-\u210F\u2113\u212F\u2134\u2139\u213C-\u213D\u2146-\u2149\u214E\u2184\u2C30-\u2C5E\u2C61\u2C65-\u2C66\u2C68\u2C6A\u2C6C\u2C71\u2C73-\u2C74\u2C76-\u2C7B\u2C81\u2C83\u2C85\u2C87\u2C89\u2C8B\u2C8D\u2C8F\u2C91\u2C93\u2C95\u2C97\u2C99\u2C9B\u2C9D\u2C9F\u2CA1\u2CA3\u2CA5\u2CA7\u2CA9\u2CAB\u2CAD\u2CAF\u2CB1\u2CB3\u2CB5\u2CB7\u2CB9\u2CBB\u2CBD\u2CBF\u2CC1\u2CC3\u2CC5\u2CC7\u2CC9\u2CCB\u2CCD\u2CCF\u2CD1\u2CD3\u2CD5\u2CD7\u2CD9\u2CDB\u2CDD\u2CDF\u2CE1\u2CE3-\u2CE4\u2CEC\u2CEE\u2CF3\u2D00-\u2D25\u2D27\u2D2D\uA641\uA643\uA645\uA647\uA649\uA64B\uA64D\uA64F\uA651\uA653\uA655\uA657\uA659\uA65B\uA65D\uA65F\uA661\uA663\uA665\uA667\uA669\uA66B\uA66D\uA681\uA683\uA685\uA687\uA689\uA68B\uA68D\uA68F\uA691\uA693\uA695\uA697\uA699\uA69B\uA723\uA725\uA727\uA729\uA72B\uA72D\uA72F-\uA731\uA733\uA735\uA737\uA739\uA73B\uA73D\uA73F\uA741\uA743\uA745\uA747\uA749\uA74B\uA74D\uA74F\uA751\uA753\uA755\uA757\uA759\uA75B\uA75D\uA75F\uA761\uA763\uA765\uA767\uA769\uA76B\uA76D\uA76F\uA771-\uA778\uA77A\uA77C\uA77F\uA781\uA783\uA785\uA787\uA78C\uA78E\uA791\uA793-\uA795\uA797\uA799\uA79B\uA79D\uA79F\uA7A1\uA7A3\uA7A5\uA7A7\uA7A9\uA7B5\uA7B7\uA7FA\uAB30-\uAB5A\uAB60-\uAB65\uAB70-\uABBF\uFB00-\uFB06\uFB13-\uFB17\uFF41-\uFF5A]/;
  23926. var peg$r5 = /^[\u02B0-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0374\u037A\u0559\u0640\u06E5-\u06E6\u07F4-\u07F5\u07FA\u081A\u0824\u0828\u0971\u0E46\u0EC6\u10FC\u17D7\u1843\u1AA7\u1C78-\u1C7D\u1D2C-\u1D6A\u1D78\u1D9B-\u1DBF\u2071\u207F\u2090-\u209C\u2C7C-\u2C7D\u2D6F\u2E2F\u3005\u3031-\u3035\u303B\u309D-\u309E\u30FC-\u30FE\uA015\uA4F8-\uA4FD\uA60C\uA67F\uA69C-\uA69D\uA717-\uA71F\uA770\uA788\uA7F8-\uA7F9\uA9CF\uA9E6\uAA70\uAADD\uAAF3-\uAAF4\uAB5C-\uAB5F\uFF70\uFF9E-\uFF9F]/;
  23927. var peg$r6 = /^[\xAA\xBA\u01BB\u01C0-\u01C3\u0294\u05D0-\u05EA\u05F0-\u05F2\u0620-\u063F\u0641-\u064A\u066E-\u066F\u0671-\u06D3\u06D5\u06EE-\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u0800-\u0815\u0840-\u0858\u08A0-\u08B4\u0904-\u0939\u093D\u0950\u0958-\u0961\u0972-\u0980\u0985-\u098C\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC-\u09DD\u09DF-\u09E1\u09F0-\u09F1\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\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0-\u0CE1\u0CF1-\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32-\u0E33\u0E40-\u0E45\u0E81-\u0E82\u0E84\u0E87-\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA-\u0EAB\u0EAD-\u0EB0\u0EB2-\u0EB3\u0EBD\u0EC0-\u0EC4\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065-\u1066\u106E-\u1070\u1075-\u1081\u108E\u10D0-\u10FA\u10FD-\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\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17DC\u1820-\u1842\u1844-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE-\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C77\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5-\u1CF6\u2135-\u2138\u2D30-\u2D67\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3006\u303C\u3041-\u3096\u309F\u30A1-\u30FA\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA014\uA016-\uA48C\uA4D0-\uA4F7\uA500-\uA60B\uA610-\uA61F\uA62A-\uA62B\uA66E\uA6A0-\uA6E5\uA78F\uA7F7\uA7FB-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9E0-\uA9E4\uA9E7-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA6F\uAA71-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5-\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADC\uAAE0-\uAAEA\uAAF2\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\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\uFF66-\uFF6F\uFF71-\uFF9D\uFFA0-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/;
  23928. var peg$r7 = /^[\u01C5\u01C8\u01CB\u01F2\u1F88-\u1F8F\u1F98-\u1F9F\u1FA8-\u1FAF\u1FBC\u1FCC\u1FFC]/;
  23929. var peg$r8 = /^[A-Z\xC0-\xD6\xD8-\xDE\u0100\u0102\u0104\u0106\u0108\u010A\u010C\u010E\u0110\u0112\u0114\u0116\u0118\u011A\u011C\u011E\u0120\u0122\u0124\u0126\u0128\u012A\u012C\u012E\u0130\u0132\u0134\u0136\u0139\u013B\u013D\u013F\u0141\u0143\u0145\u0147\u014A\u014C\u014E\u0150\u0152\u0154\u0156\u0158\u015A\u015C\u015E\u0160\u0162\u0164\u0166\u0168\u016A\u016C\u016E\u0170\u0172\u0174\u0176\u0178-\u0179\u017B\u017D\u0181-\u0182\u0184\u0186-\u0187\u0189-\u018B\u018E-\u0191\u0193-\u0194\u0196-\u0198\u019C-\u019D\u019F-\u01A0\u01A2\u01A4\u01A6-\u01A7\u01A9\u01AC\u01AE-\u01AF\u01B1-\u01B3\u01B5\u01B7-\u01B8\u01BC\u01C4\u01C7\u01CA\u01CD\u01CF\u01D1\u01D3\u01D5\u01D7\u01D9\u01DB\u01DE\u01E0\u01E2\u01E4\u01E6\u01E8\u01EA\u01EC\u01EE\u01F1\u01F4\u01F6-\u01F8\u01FA\u01FC\u01FE\u0200\u0202\u0204\u0206\u0208\u020A\u020C\u020E\u0210\u0212\u0214\u0216\u0218\u021A\u021C\u021E\u0220\u0222\u0224\u0226\u0228\u022A\u022C\u022E\u0230\u0232\u023A-\u023B\u023D-\u023E\u0241\u0243-\u0246\u0248\u024A\u024C\u024E\u0370\u0372\u0376\u037F\u0386\u0388-\u038A\u038C\u038E-\u038F\u0391-\u03A1\u03A3-\u03AB\u03CF\u03D2-\u03D4\u03D8\u03DA\u03DC\u03DE\u03E0\u03E2\u03E4\u03E6\u03E8\u03EA\u03EC\u03EE\u03F4\u03F7\u03F9-\u03FA\u03FD-\u042F\u0460\u0462\u0464\u0466\u0468\u046A\u046C\u046E\u0470\u0472\u0474\u0476\u0478\u047A\u047C\u047E\u0480\u048A\u048C\u048E\u0490\u0492\u0494\u0496\u0498\u049A\u049C\u049E\u04A0\u04A2\u04A4\u04A6\u04A8\u04AA\u04AC\u04AE\u04B0\u04B2\u04B4\u04B6\u04B8\u04BA\u04BC\u04BE\u04C0-\u04C1\u04C3\u04C5\u04C7\u04C9\u04CB\u04CD\u04D0\u04D2\u04D4\u04D6\u04D8\u04DA\u04DC\u04DE\u04E0\u04E2\u04E4\u04E6\u04E8\u04EA\u04EC\u04EE\u04F0\u04F2\u04F4\u04F6\u04F8\u04FA\u04FC\u04FE\u0500\u0502\u0504\u0506\u0508\u050A\u050C\u050E\u0510\u0512\u0514\u0516\u0518\u051A\u051C\u051E\u0520\u0522\u0524\u0526\u0528\u052A\u052C\u052E\u0531-\u0556\u10A0-\u10C5\u10C7\u10CD\u13A0-\u13F5\u1E00\u1E02\u1E04\u1E06\u1E08\u1E0A\u1E0C\u1E0E\u1E10\u1E12\u1E14\u1E16\u1E18\u1E1A\u1E1C\u1E1E\u1E20\u1E22\u1E24\u1E26\u1E28\u1E2A\u1E2C\u1E2E\u1E30\u1E32\u1E34\u1E36\u1E38\u1E3A\u1E3C\u1E3E\u1E40\u1E42\u1E44\u1E46\u1E48\u1E4A\u1E4C\u1E4E\u1E50\u1E52\u1E54\u1E56\u1E58\u1E5A\u1E5C\u1E5E\u1E60\u1E62\u1E64\u1E66\u1E68\u1E6A\u1E6C\u1E6E\u1E70\u1E72\u1E74\u1E76\u1E78\u1E7A\u1E7C\u1E7E\u1E80\u1E82\u1E84\u1E86\u1E88\u1E8A\u1E8C\u1E8E\u1E90\u1E92\u1E94\u1E9E\u1EA0\u1EA2\u1EA4\u1EA6\u1EA8\u1EAA\u1EAC\u1EAE\u1EB0\u1EB2\u1EB4\u1EB6\u1EB8\u1EBA\u1EBC\u1EBE\u1EC0\u1EC2\u1EC4\u1EC6\u1EC8\u1ECA\u1ECC\u1ECE\u1ED0\u1ED2\u1ED4\u1ED6\u1ED8\u1EDA\u1EDC\u1EDE\u1EE0\u1EE2\u1EE4\u1EE6\u1EE8\u1EEA\u1EEC\u1EEE\u1EF0\u1EF2\u1EF4\u1EF6\u1EF8\u1EFA\u1EFC\u1EFE\u1F08-\u1F0F\u1F18-\u1F1D\u1F28-\u1F2F\u1F38-\u1F3F\u1F48-\u1F4D\u1F59\u1F5B\u1F5D\u1F5F\u1F68-\u1F6F\u1FB8-\u1FBB\u1FC8-\u1FCB\u1FD8-\u1FDB\u1FE8-\u1FEC\u1FF8-\u1FFB\u2102\u2107\u210B-\u210D\u2110-\u2112\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u2130-\u2133\u213E-\u213F\u2145\u2183\u2C00-\u2C2E\u2C60\u2C62-\u2C64\u2C67\u2C69\u2C6B\u2C6D-\u2C70\u2C72\u2C75\u2C7E-\u2C80\u2C82\u2C84\u2C86\u2C88\u2C8A\u2C8C\u2C8E\u2C90\u2C92\u2C94\u2C96\u2C98\u2C9A\u2C9C\u2C9E\u2CA0\u2CA2\u2CA4\u2CA6\u2CA8\u2CAA\u2CAC\u2CAE\u2CB0\u2CB2\u2CB4\u2CB6\u2CB8\u2CBA\u2CBC\u2CBE\u2CC0\u2CC2\u2CC4\u2CC6\u2CC8\u2CCA\u2CCC\u2CCE\u2CD0\u2CD2\u2CD4\u2CD6\u2CD8\u2CDA\u2CDC\u2CDE\u2CE0\u2CE2\u2CEB\u2CED\u2CF2\uA640\uA642\uA644\uA646\uA648\uA64A\uA64C\uA64E\uA650\uA652\uA654\uA656\uA658\uA65A\uA65C\uA65E\uA660\uA662\uA664\uA666\uA668\uA66A\uA66C\uA680\uA682\uA684\uA686\uA688\uA68A\uA68C\uA68E\uA690\uA692\uA694\uA696\uA698\uA69A\uA722\uA724\uA726\uA728\uA72A\uA72C\uA72E\uA732\uA734\uA736\uA738\uA73A\uA73C\uA73E\uA740\uA742\uA744\uA746\uA748\uA74A\uA74C\uA74E\uA750\uA752\uA754\uA756\uA758\uA75A\uA75C\uA75E\uA760\uA762\uA764\uA766\uA768\uA76A\uA76C\uA76E\uA779\uA77B\uA77D-\uA77E\uA780\uA782\uA784\uA786\uA78B\uA78D\uA790\uA792\uA796\uA798\uA79A\uA79C\uA79E\uA7A0\uA7A2\uA7A4\uA7A6\uA7A8\uA7AA-\uA7AD\uA7B0-\uA7B4\uA7B6\uFF21-\uFF3A]/;
  23930. var peg$r9 = /^[\u0903\u093B\u093E-\u0940\u0949-\u094C\u094E-\u094F\u0982-\u0983\u09BE-\u09C0\u09C7-\u09C8\u09CB-\u09CC\u09D7\u0A03\u0A3E-\u0A40\u0A83\u0ABE-\u0AC0\u0AC9\u0ACB-\u0ACC\u0B02-\u0B03\u0B3E\u0B40\u0B47-\u0B48\u0B4B-\u0B4C\u0B57\u0BBE-\u0BBF\u0BC1-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCC\u0BD7\u0C01-\u0C03\u0C41-\u0C44\u0C82-\u0C83\u0CBE\u0CC0-\u0CC4\u0CC7-\u0CC8\u0CCA-\u0CCB\u0CD5-\u0CD6\u0D02-\u0D03\u0D3E-\u0D40\u0D46-\u0D48\u0D4A-\u0D4C\u0D57\u0D82-\u0D83\u0DCF-\u0DD1\u0DD8-\u0DDF\u0DF2-\u0DF3\u0F3E-\u0F3F\u0F7F\u102B-\u102C\u1031\u1038\u103B-\u103C\u1056-\u1057\u1062-\u1064\u1067-\u106D\u1083-\u1084\u1087-\u108C\u108F\u109A-\u109C\u17B6\u17BE-\u17C5\u17C7-\u17C8\u1923-\u1926\u1929-\u192B\u1930-\u1931\u1933-\u1938\u1A19-\u1A1A\u1A55\u1A57\u1A61\u1A63-\u1A64\u1A6D-\u1A72\u1B04\u1B35\u1B3B\u1B3D-\u1B41\u1B43-\u1B44\u1B82\u1BA1\u1BA6-\u1BA7\u1BAA\u1BE7\u1BEA-\u1BEC\u1BEE\u1BF2-\u1BF3\u1C24-\u1C2B\u1C34-\u1C35\u1CE1\u1CF2-\u1CF3\u302E-\u302F\uA823-\uA824\uA827\uA880-\uA881\uA8B4-\uA8C3\uA952-\uA953\uA983\uA9B4-\uA9B5\uA9BA-\uA9BB\uA9BD-\uA9C0\uAA2F-\uAA30\uAA33-\uAA34\uAA4D\uAA7B\uAA7D\uAAEB\uAAEE-\uAAEF\uAAF5\uABE3-\uABE4\uABE6-\uABE7\uABE9-\uABEA\uABEC]/;
  23931. var peg$r10 = /^[\u0300-\u036F\u0483-\u0487\u0591-\u05BD\u05BF\u05C1-\u05C2\u05C4-\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7-\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08E3-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962-\u0963\u0981\u09BC\u09C1-\u09C4\u09CD\u09E2-\u09E3\u0A01-\u0A02\u0A3C\u0A41-\u0A42\u0A47-\u0A48\u0A4B-\u0A4D\u0A51\u0A70-\u0A71\u0A75\u0A81-\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7-\u0AC8\u0ACD\u0AE2-\u0AE3\u0B01\u0B3C\u0B3F\u0B41-\u0B44\u0B4D\u0B56\u0B62-\u0B63\u0B82\u0BC0\u0BCD\u0C00\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55-\u0C56\u0C62-\u0C63\u0C81\u0CBC\u0CBF\u0CC6\u0CCC-\u0CCD\u0CE2-\u0CE3\u0D01\u0D41-\u0D44\u0D4D\u0D62-\u0D63\u0DCA\u0DD2-\u0DD4\u0DD6\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB-\u0EBC\u0EC8-\u0ECD\u0F18-\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86-\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039-\u103A\u103D-\u103E\u1058-\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085-\u1086\u108D\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752-\u1753\u1772-\u1773\u17B4-\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DD\u180B-\u180D\u18A9\u1920-\u1922\u1927-\u1928\u1932\u1939-\u193B\u1A17-\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1AB0-\u1ABD\u1B00-\u1B03\u1B34\u1B36-\u1B3A\u1B3C\u1B42\u1B6B-\u1B73\u1B80-\u1B81\u1BA2-\u1BA5\u1BA8-\u1BA9\u1BAB-\u1BAD\u1BE6\u1BE8-\u1BE9\u1BED\u1BEF-\u1BF1\u1C2C-\u1C33\u1C36-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8-\u1CF9\u1DC0-\u1DF5\u1DFC-\u1DFF\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302D\u3099-\u309A\uA66F\uA674-\uA67D\uA69E-\uA69F\uA6F0-\uA6F1\uA802\uA806\uA80B\uA825-\uA826\uA8C4\uA8E0-\uA8F1\uA926-\uA92D\uA947-\uA951\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uA9E5\uAA29-\uAA2E\uAA31-\uAA32\uAA35-\uAA36\uAA43\uAA4C\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7-\uAAB8\uAABE-\uAABF\uAAC1\uAAEC-\uAAED\uAAF6\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/;
  23932. var peg$r11 = /^[0-9\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0BE6-\u0BEF\u0C66-\u0C6F\u0CE6-\u0CEF\u0D66-\u0D6F\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F29\u1040-\u1049\u1090-\u1099\u17E0-\u17E9\u1810-\u1819\u1946-\u194F\u19D0-\u19D9\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\uA620-\uA629\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]/;
  23933. var peg$r12 = /^[\u16EE-\u16F0\u2160-\u2182\u2185-\u2188\u3007\u3021-\u3029\u3038-\u303A\uA6E6-\uA6EF]/;
  23934. var peg$r13 = /^[_\u203F-\u2040\u2054\uFE33-\uFE34\uFE4D-\uFE4F\uFF3F]/;
  23935. var peg$r14 = /^[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/;
  23936. var peg$e0 = peg$literalExpectation("{", false);
  23937. var peg$e1 = peg$literalExpectation("}", false);
  23938. var peg$e2 = peg$literalExpectation("=", false);
  23939. var peg$e3 = peg$literalExpectation("/", false);
  23940. var peg$e4 = peg$literalExpectation("@", false);
  23941. var peg$e5 = peg$literalExpectation(":", false);
  23942. var peg$e6 = peg$literalExpectation("$", false);
  23943. var peg$e7 = peg$literalExpectation("&", false);
  23944. var peg$e8 = peg$literalExpectation("!", false);
  23945. var peg$e9 = peg$literalExpectation("?", false);
  23946. var peg$e10 = peg$literalExpectation("*", false);
  23947. var peg$e11 = peg$literalExpectation("+", false);
  23948. var peg$e12 = peg$literalExpectation("(", false);
  23949. var peg$e13 = peg$literalExpectation(")", false);
  23950. var peg$e14 = peg$anyExpectation();
  23951. var peg$e15 = peg$otherExpectation("whitespace");
  23952. var peg$e16 = peg$literalExpectation("\t", false);
  23953. var peg$e17 = peg$literalExpectation("\v", false);
  23954. var peg$e18 = peg$literalExpectation("\f", false);
  23955. var peg$e19 = peg$literalExpectation(" ", false);
  23956. var peg$e20 = peg$literalExpectation("\xA0", false);
  23957. var peg$e21 = peg$literalExpectation("\uFEFF", false);
  23958. var peg$e22 = peg$classExpectation(["\n", "\r", "\u2028", "\u2029"], false, false);
  23959. var peg$e23 = peg$otherExpectation("end of line");
  23960. var peg$e24 = peg$literalExpectation("\n", false);
  23961. var peg$e25 = peg$literalExpectation("\r\n", false);
  23962. var peg$e26 = peg$literalExpectation("\r", false);
  23963. var peg$e27 = peg$literalExpectation("\u2028", false);
  23964. var peg$e28 = peg$literalExpectation("\u2029", false);
  23965. var peg$e29 = peg$otherExpectation("comment");
  23966. var peg$e30 = peg$literalExpectation("/*", false);
  23967. var peg$e31 = peg$literalExpectation("*/", false);
  23968. var peg$e32 = peg$literalExpectation("//", false);
  23969. var peg$e33 = peg$otherExpectation("identifier");
  23970. var peg$e34 = peg$literalExpectation("_", false);
  23971. var peg$e35 = peg$literalExpectation("\\", false);
  23972. var peg$e36 = peg$literalExpectation("\u200C", false);
  23973. var peg$e37 = peg$literalExpectation("\u200D", false);
  23974. var peg$e38 = peg$otherExpectation("literal");
  23975. var peg$e39 = peg$literalExpectation("i", false);
  23976. var peg$e40 = peg$otherExpectation("string");
  23977. var peg$e41 = peg$literalExpectation("\"", false);
  23978. var peg$e42 = peg$literalExpectation("'", false);
  23979. var peg$e43 = peg$otherExpectation("character class");
  23980. var peg$e44 = peg$literalExpectation("[", false);
  23981. var peg$e45 = peg$literalExpectation("^", false);
  23982. var peg$e46 = peg$literalExpectation("]", false);
  23983. var peg$e47 = peg$literalExpectation("-", false);
  23984. var peg$e48 = peg$literalExpectation("0", false);
  23985. var peg$e49 = peg$literalExpectation("b", false);
  23986. var peg$e50 = peg$literalExpectation("f", false);
  23987. var peg$e51 = peg$literalExpectation("n", false);
  23988. var peg$e52 = peg$literalExpectation("r", false);
  23989. var peg$e53 = peg$literalExpectation("t", false);
  23990. var peg$e54 = peg$literalExpectation("v", false);
  23991. var peg$e55 = peg$literalExpectation("x", false);
  23992. var peg$e56 = peg$literalExpectation("u", false);
  23993. var peg$e57 = peg$classExpectation([["0", "9"]], false, false);
  23994. var peg$e58 = peg$classExpectation([["0", "9"], ["a", "f"]], false, true);
  23995. var peg$e59 = peg$literalExpectation(".", false);
  23996. var peg$e60 = peg$otherExpectation("code block");
  23997. var peg$e61 = peg$classExpectation(["{", "}"], false, false);
  23998. var peg$e62 = peg$classExpectation([["a", "z"], "\xB5", ["\xDF", "\xF6"], ["\xF8", "\xFF"], "\u0101", "\u0103", "\u0105", "\u0107", "\u0109", "\u010B", "\u010D", "\u010F", "\u0111", "\u0113", "\u0115", "\u0117", "\u0119", "\u011B", "\u011D", "\u011F", "\u0121", "\u0123", "\u0125", "\u0127", "\u0129", "\u012B", "\u012D", "\u012F", "\u0131", "\u0133", "\u0135", ["\u0137", "\u0138"], "\u013A", "\u013C", "\u013E", "\u0140", "\u0142", "\u0144", "\u0146", ["\u0148", "\u0149"], "\u014B", "\u014D", "\u014F", "\u0151", "\u0153", "\u0155", "\u0157", "\u0159", "\u015B", "\u015D", "\u015F", "\u0161", "\u0163", "\u0165", "\u0167", "\u0169", "\u016B", "\u016D", "\u016F", "\u0171", "\u0173", "\u0175", "\u0177", "\u017A", "\u017C", ["\u017E", "\u0180"], "\u0183", "\u0185", "\u0188", ["\u018C", "\u018D"], "\u0192", "\u0195", ["\u0199", "\u019B"], "\u019E", "\u01A1", "\u01A3", "\u01A5", "\u01A8", ["\u01AA", "\u01AB"], "\u01AD", "\u01B0", "\u01B4", "\u01B6", ["\u01B9", "\u01BA"], ["\u01BD", "\u01BF"], "\u01C6", "\u01C9", "\u01CC", "\u01CE", "\u01D0", "\u01D2", "\u01D4", "\u01D6", "\u01D8", "\u01DA", ["\u01DC", "\u01DD"], "\u01DF", "\u01E1", "\u01E3", "\u01E5", "\u01E7", "\u01E9", "\u01EB", "\u01ED", ["\u01EF", "\u01F0"], "\u01F3", "\u01F5", "\u01F9", "\u01FB", "\u01FD", "\u01FF", "\u0201", "\u0203", "\u0205", "\u0207", "\u0209", "\u020B", "\u020D", "\u020F", "\u0211", "\u0213", "\u0215", "\u0217", "\u0219", "\u021B", "\u021D", "\u021F", "\u0221", "\u0223", "\u0225", "\u0227", "\u0229", "\u022B", "\u022D", "\u022F", "\u0231", ["\u0233", "\u0239"], "\u023C", ["\u023F", "\u0240"], "\u0242", "\u0247", "\u0249", "\u024B", "\u024D", ["\u024F", "\u0293"], ["\u0295", "\u02AF"], "\u0371", "\u0373", "\u0377", ["\u037B", "\u037D"], "\u0390", ["\u03AC", "\u03CE"], ["\u03D0", "\u03D1"], ["\u03D5", "\u03D7"], "\u03D9", "\u03DB", "\u03DD", "\u03DF", "\u03E1", "\u03E3", "\u03E5", "\u03E7", "\u03E9", "\u03EB", "\u03ED", ["\u03EF", "\u03F3"], "\u03F5", "\u03F8", ["\u03FB", "\u03FC"], ["\u0430", "\u045F"], "\u0461", "\u0463", "\u0465", "\u0467", "\u0469", "\u046B", "\u046D", "\u046F", "\u0471", "\u0473", "\u0475", "\u0477", "\u0479", "\u047B", "\u047D", "\u047F", "\u0481", "\u048B", "\u048D", "\u048F", "\u0491", "\u0493", "\u0495", "\u0497", "\u0499", "\u049B", "\u049D", "\u049F", "\u04A1", "\u04A3", "\u04A5", "\u04A7", "\u04A9", "\u04AB", "\u04AD", "\u04AF", "\u04B1", "\u04B3", "\u04B5", "\u04B7", "\u04B9", "\u04BB", "\u04BD", "\u04BF", "\u04C2", "\u04C4", "\u04C6", "\u04C8", "\u04CA", "\u04CC", ["\u04CE", "\u04CF"], "\u04D1", "\u04D3", "\u04D5", "\u04D7", "\u04D9", "\u04DB", "\u04DD", "\u04DF", "\u04E1", "\u04E3", "\u04E5", "\u04E7", "\u04E9", "\u04EB", "\u04ED", "\u04EF", "\u04F1", "\u04F3", "\u04F5", "\u04F7", "\u04F9", "\u04FB", "\u04FD", "\u04FF", "\u0501", "\u0503", "\u0505", "\u0507", "\u0509", "\u050B", "\u050D", "\u050F", "\u0511", "\u0513", "\u0515", "\u0517", "\u0519", "\u051B", "\u051D", "\u051F", "\u0521", "\u0523", "\u0525", "\u0527", "\u0529", "\u052B", "\u052D", "\u052F", ["\u0561", "\u0587"], ["\u13F8", "\u13FD"], ["\u1D00", "\u1D2B"], ["\u1D6B", "\u1D77"], ["\u1D79", "\u1D9A"], "\u1E01", "\u1E03", "\u1E05", "\u1E07", "\u1E09", "\u1E0B", "\u1E0D", "\u1E0F", "\u1E11", "\u1E13", "\u1E15", "\u1E17", "\u1E19", "\u1E1B", "\u1E1D", "\u1E1F", "\u1E21", "\u1E23", "\u1E25", "\u1E27", "\u1E29", "\u1E2B", "\u1E2D", "\u1E2F", "\u1E31", "\u1E33", "\u1E35", "\u1E37", "\u1E39", "\u1E3B", "\u1E3D", "\u1E3F", "\u1E41", "\u1E43", "\u1E45", "\u1E47", "\u1E49", "\u1E4B", "\u1E4D", "\u1E4F", "\u1E51", "\u1E53", "\u1E55", "\u1E57", "\u1E59", "\u1E5B", "\u1E5D", "\u1E5F", "\u1E61", "\u1E63", "\u1E65", "\u1E67", "\u1E69", "\u1E6B", "\u1E6D", "\u1E6F", "\u1E71", "\u1E73", "\u1E75", "\u1E77", "\u1E79", "\u1E7B", "\u1E7D", "\u1E7F", "\u1E81", "\u1E83", "\u1E85", "\u1E87", "\u1E89", "\u1E8B", "\u1E8D", "\u1E8F", "\u1E91", "\u1E93", ["\u1E95", "\u1E9D"], "\u1E9F", "\u1EA1", "\u1EA3", "\u1EA5", "\u1EA7", "\u1EA9", "\u1EAB", "\u1EAD", "\u1EAF", "\u1EB1", "\u1EB3", "\u1EB5", "\u1EB7", "\u1EB9", "\u1EBB", "\u1EBD", "\u1EBF", "\u1EC1", "\u1EC3", "\u1EC5", "\u1EC7", "\u1EC9", "\u1ECB", "\u1ECD", "\u1ECF", "\u1ED1", "\u1ED3", "\u1ED5", "\u1ED7", "\u1ED9", "\u1EDB", "\u1EDD", "\u1EDF", "\u1EE1", "\u1EE3", "\u1EE5", "\u1EE7", "\u1EE9", "\u1EEB", "\u1EED", "\u1EEF", "\u1EF1", "\u1EF3", "\u1EF5", "\u1EF7", "\u1EF9", "\u1EFB", "\u1EFD", ["\u1EFF", "\u1F07"], ["\u1F10", "\u1F15"], ["\u1F20", "\u1F27"], ["\u1F30", "\u1F37"], ["\u1F40", "\u1F45"], ["\u1F50", "\u1F57"], ["\u1F60", "\u1F67"], ["\u1F70", "\u1F7D"], ["\u1F80", "\u1F87"], ["\u1F90", "\u1F97"], ["\u1FA0", "\u1FA7"], ["\u1FB0", "\u1FB4"], ["\u1FB6", "\u1FB7"], "\u1FBE", ["\u1FC2", "\u1FC4"], ["\u1FC6", "\u1FC7"], ["\u1FD0", "\u1FD3"], ["\u1FD6", "\u1FD7"], ["\u1FE0", "\u1FE7"], ["\u1FF2", "\u1FF4"], ["\u1FF6", "\u1FF7"], "\u210A", ["\u210E", "\u210F"], "\u2113", "\u212F", "\u2134", "\u2139", ["\u213C", "\u213D"], ["\u2146", "\u2149"], "\u214E", "\u2184", ["\u2C30", "\u2C5E"], "\u2C61", ["\u2C65", "\u2C66"], "\u2C68", "\u2C6A", "\u2C6C", "\u2C71", ["\u2C73", "\u2C74"], ["\u2C76", "\u2C7B"], "\u2C81", "\u2C83", "\u2C85", "\u2C87", "\u2C89", "\u2C8B", "\u2C8D", "\u2C8F", "\u2C91", "\u2C93", "\u2C95", "\u2C97", "\u2C99", "\u2C9B", "\u2C9D", "\u2C9F", "\u2CA1", "\u2CA3", "\u2CA5", "\u2CA7", "\u2CA9", "\u2CAB", "\u2CAD", "\u2CAF", "\u2CB1", "\u2CB3", "\u2CB5", "\u2CB7", "\u2CB9", "\u2CBB", "\u2CBD", "\u2CBF", "\u2CC1", "\u2CC3", "\u2CC5", "\u2CC7", "\u2CC9", "\u2CCB", "\u2CCD", "\u2CCF", "\u2CD1", "\u2CD3", "\u2CD5", "\u2CD7", "\u2CD9", "\u2CDB", "\u2CDD", "\u2CDF", "\u2CE1", ["\u2CE3", "\u2CE4"], "\u2CEC", "\u2CEE", "\u2CF3", ["\u2D00", "\u2D25"], "\u2D27", "\u2D2D", "\uA641", "\uA643", "\uA645", "\uA647", "\uA649", "\uA64B", "\uA64D", "\uA64F", "\uA651", "\uA653", "\uA655", "\uA657", "\uA659", "\uA65B", "\uA65D", "\uA65F", "\uA661", "\uA663", "\uA665", "\uA667", "\uA669", "\uA66B", "\uA66D", "\uA681", "\uA683", "\uA685", "\uA687", "\uA689", "\uA68B", "\uA68D", "\uA68F", "\uA691", "\uA693", "\uA695", "\uA697", "\uA699", "\uA69B", "\uA723", "\uA725", "\uA727", "\uA729", "\uA72B", "\uA72D", ["\uA72F", "\uA731"], "\uA733", "\uA735", "\uA737", "\uA739", "\uA73B", "\uA73D", "\uA73F", "\uA741", "\uA743", "\uA745", "\uA747", "\uA749", "\uA74B", "\uA74D", "\uA74F", "\uA751", "\uA753", "\uA755", "\uA757", "\uA759", "\uA75B", "\uA75D", "\uA75F", "\uA761", "\uA763", "\uA765", "\uA767", "\uA769", "\uA76B", "\uA76D", "\uA76F", ["\uA771", "\uA778"], "\uA77A", "\uA77C", "\uA77F", "\uA781", "\uA783", "\uA785", "\uA787", "\uA78C", "\uA78E", "\uA791", ["\uA793", "\uA795"], "\uA797", "\uA799", "\uA79B", "\uA79D", "\uA79F", "\uA7A1", "\uA7A3", "\uA7A5", "\uA7A7", "\uA7A9", "\uA7B5", "\uA7B7", "\uA7FA", ["\uAB30", "\uAB5A"], ["\uAB60", "\uAB65"], ["\uAB70", "\uABBF"], ["\uFB00", "\uFB06"], ["\uFB13", "\uFB17"], ["\uFF41", "\uFF5A"]], false, false);
  23999. var peg$e63 = peg$classExpectation([["\u02B0", "\u02C1"], ["\u02C6", "\u02D1"], ["\u02E0", "\u02E4"], "\u02EC", "\u02EE", "\u0374", "\u037A", "\u0559", "\u0640", ["\u06E5", "\u06E6"], ["\u07F4", "\u07F5"], "\u07FA", "\u081A", "\u0824", "\u0828", "\u0971", "\u0E46", "\u0EC6", "\u10FC", "\u17D7", "\u1843", "\u1AA7", ["\u1C78", "\u1C7D"], ["\u1D2C", "\u1D6A"], "\u1D78", ["\u1D9B", "\u1DBF"], "\u2071", "\u207F", ["\u2090", "\u209C"], ["\u2C7C", "\u2C7D"], "\u2D6F", "\u2E2F", "\u3005", ["\u3031", "\u3035"], "\u303B", ["\u309D", "\u309E"], ["\u30FC", "\u30FE"], "\uA015", ["\uA4F8", "\uA4FD"], "\uA60C", "\uA67F", ["\uA69C", "\uA69D"], ["\uA717", "\uA71F"], "\uA770", "\uA788", ["\uA7F8", "\uA7F9"], "\uA9CF", "\uA9E6", "\uAA70", "\uAADD", ["\uAAF3", "\uAAF4"], ["\uAB5C", "\uAB5F"], "\uFF70", ["\uFF9E", "\uFF9F"]], false, false);
  24000. var peg$e64 = peg$classExpectation(["\xAA", "\xBA", "\u01BB", ["\u01C0", "\u01C3"], "\u0294", ["\u05D0", "\u05EA"], ["\u05F0", "\u05F2"], ["\u0620", "\u063F"], ["\u0641", "\u064A"], ["\u066E", "\u066F"], ["\u0671", "\u06D3"], "\u06D5", ["\u06EE", "\u06EF"], ["\u06FA", "\u06FC"], "\u06FF", "\u0710", ["\u0712", "\u072F"], ["\u074D", "\u07A5"], "\u07B1", ["\u07CA", "\u07EA"], ["\u0800", "\u0815"], ["\u0840", "\u0858"], ["\u08A0", "\u08B4"], ["\u0904", "\u0939"], "\u093D", "\u0950", ["\u0958", "\u0961"], ["\u0972", "\u0980"], ["\u0985", "\u098C"], ["\u098F", "\u0990"], ["\u0993", "\u09A8"], ["\u09AA", "\u09B0"], "\u09B2", ["\u09B6", "\u09B9"], "\u09BD", "\u09CE", ["\u09DC", "\u09DD"], ["\u09DF", "\u09E1"], ["\u09F0", "\u09F1"], ["\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"], ["\u0C85", "\u0C8C"], ["\u0C8E", "\u0C90"], ["\u0C92", "\u0CA8"], ["\u0CAA", "\u0CB3"], ["\u0CB5", "\u0CB9"], "\u0CBD", "\u0CDE", ["\u0CE0", "\u0CE1"], ["\u0CF1", "\u0CF2"], ["\u0D05", "\u0D0C"], ["\u0D0E", "\u0D10"], ["\u0D12", "\u0D3A"], "\u0D3D", "\u0D4E", ["\u0D5F", "\u0D61"], ["\u0D7A", "\u0D7F"], ["\u0D85", "\u0D96"], ["\u0D9A", "\u0DB1"], ["\u0DB3", "\u0DBB"], "\u0DBD", ["\u0DC0", "\u0DC6"], ["\u0E01", "\u0E30"], ["\u0E32", "\u0E33"], ["\u0E40", "\u0E45"], ["\u0E81", "\u0E82"], "\u0E84", ["\u0E87", "\u0E88"], "\u0E8A", "\u0E8D", ["\u0E94", "\u0E97"], ["\u0E99", "\u0E9F"], ["\u0EA1", "\u0EA3"], "\u0EA5", "\u0EA7", ["\u0EAA", "\u0EAB"], ["\u0EAD", "\u0EB0"], ["\u0EB2", "\u0EB3"], "\u0EBD", ["\u0EC0", "\u0EC4"], ["\u0EDC", "\u0EDF"], "\u0F00", ["\u0F40", "\u0F47"], ["\u0F49", "\u0F6C"], ["\u0F88", "\u0F8C"], ["\u1000", "\u102A"], "\u103F", ["\u1050", "\u1055"], ["\u105A", "\u105D"], "\u1061", ["\u1065", "\u1066"], ["\u106E", "\u1070"], ["\u1075", "\u1081"], "\u108E", ["\u10D0", "\u10FA"], ["\u10FD", "\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"], ["\u1401", "\u166C"], ["\u166F", "\u167F"], ["\u1681", "\u169A"], ["\u16A0", "\u16EA"], ["\u16F1", "\u16F8"], ["\u1700", "\u170C"], ["\u170E", "\u1711"], ["\u1720", "\u1731"], ["\u1740", "\u1751"], ["\u1760", "\u176C"], ["\u176E", "\u1770"], ["\u1780", "\u17B3"], "\u17DC", ["\u1820", "\u1842"], ["\u1844", "\u1877"], ["\u1880", "\u18A8"], "\u18AA", ["\u18B0", "\u18F5"], ["\u1900", "\u191E"], ["\u1950", "\u196D"], ["\u1970", "\u1974"], ["\u1980", "\u19AB"], ["\u19B0", "\u19C9"], ["\u1A00", "\u1A16"], ["\u1A20", "\u1A54"], ["\u1B05", "\u1B33"], ["\u1B45", "\u1B4B"], ["\u1B83", "\u1BA0"], ["\u1BAE", "\u1BAF"], ["\u1BBA", "\u1BE5"], ["\u1C00", "\u1C23"], ["\u1C4D", "\u1C4F"], ["\u1C5A", "\u1C77"], ["\u1CE9", "\u1CEC"], ["\u1CEE", "\u1CF1"], ["\u1CF5", "\u1CF6"], ["\u2135", "\u2138"], ["\u2D30", "\u2D67"], ["\u2D80", "\u2D96"], ["\u2DA0", "\u2DA6"], ["\u2DA8", "\u2DAE"], ["\u2DB0", "\u2DB6"], ["\u2DB8", "\u2DBE"], ["\u2DC0", "\u2DC6"], ["\u2DC8", "\u2DCE"], ["\u2DD0", "\u2DD6"], ["\u2DD8", "\u2DDE"], "\u3006", "\u303C", ["\u3041", "\u3096"], "\u309F", ["\u30A1", "\u30FA"], "\u30FF", ["\u3105", "\u312D"], ["\u3131", "\u318E"], ["\u31A0", "\u31BA"], ["\u31F0", "\u31FF"], ["\u3400", "\u4DB5"], ["\u4E00", "\u9FD5"], ["\uA000", "\uA014"], ["\uA016", "\uA48C"], ["\uA4D0", "\uA4F7"], ["\uA500", "\uA60B"], ["\uA610", "\uA61F"], ["\uA62A", "\uA62B"], "\uA66E", ["\uA6A0", "\uA6E5"], "\uA78F", "\uA7F7", ["\uA7FB", "\uA801"], ["\uA803", "\uA805"], ["\uA807", "\uA80A"], ["\uA80C", "\uA822"], ["\uA840", "\uA873"], ["\uA882", "\uA8B3"], ["\uA8F2", "\uA8F7"], "\uA8FB", "\uA8FD", ["\uA90A", "\uA925"], ["\uA930", "\uA946"], ["\uA960", "\uA97C"], ["\uA984", "\uA9B2"], ["\uA9E0", "\uA9E4"], ["\uA9E7", "\uA9EF"], ["\uA9FA", "\uA9FE"], ["\uAA00", "\uAA28"], ["\uAA40", "\uAA42"], ["\uAA44", "\uAA4B"], ["\uAA60", "\uAA6F"], ["\uAA71", "\uAA76"], "\uAA7A", ["\uAA7E", "\uAAAF"], "\uAAB1", ["\uAAB5", "\uAAB6"], ["\uAAB9", "\uAABD"], "\uAAC0", "\uAAC2", ["\uAADB", "\uAADC"], ["\uAAE0", "\uAAEA"], "\uAAF2", ["\uAB01", "\uAB06"], ["\uAB09", "\uAB0E"], ["\uAB11", "\uAB16"], ["\uAB20", "\uAB26"], ["\uAB28", "\uAB2E"], ["\uABC0", "\uABE2"], ["\uAC00", "\uD7A3"], ["\uD7B0", "\uD7C6"], ["\uD7CB", "\uD7FB"], ["\uF900", "\uFA6D"], ["\uFA70", "\uFAD9"], "\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"], ["\uFF66", "\uFF6F"], ["\uFF71", "\uFF9D"], ["\uFFA0", "\uFFBE"], ["\uFFC2", "\uFFC7"], ["\uFFCA", "\uFFCF"], ["\uFFD2", "\uFFD7"], ["\uFFDA", "\uFFDC"]], false, false);
  24001. var peg$e65 = peg$classExpectation(["\u01C5", "\u01C8", "\u01CB", "\u01F2", ["\u1F88", "\u1F8F"], ["\u1F98", "\u1F9F"], ["\u1FA8", "\u1FAF"], "\u1FBC", "\u1FCC", "\u1FFC"], false, false);
  24002. var peg$e66 = peg$classExpectation([["A", "Z"], ["\xC0", "\xD6"], ["\xD8", "\xDE"], "\u0100", "\u0102", "\u0104", "\u0106", "\u0108", "\u010A", "\u010C", "\u010E", "\u0110", "\u0112", "\u0114", "\u0116", "\u0118", "\u011A", "\u011C", "\u011E", "\u0120", "\u0122", "\u0124", "\u0126", "\u0128", "\u012A", "\u012C", "\u012E", "\u0130", "\u0132", "\u0134", "\u0136", "\u0139", "\u013B", "\u013D", "\u013F", "\u0141", "\u0143", "\u0145", "\u0147", "\u014A", "\u014C", "\u014E", "\u0150", "\u0152", "\u0154", "\u0156", "\u0158", "\u015A", "\u015C", "\u015E", "\u0160", "\u0162", "\u0164", "\u0166", "\u0168", "\u016A", "\u016C", "\u016E", "\u0170", "\u0172", "\u0174", "\u0176", ["\u0178", "\u0179"], "\u017B", "\u017D", ["\u0181", "\u0182"], "\u0184", ["\u0186", "\u0187"], ["\u0189", "\u018B"], ["\u018E", "\u0191"], ["\u0193", "\u0194"], ["\u0196", "\u0198"], ["\u019C", "\u019D"], ["\u019F", "\u01A0"], "\u01A2", "\u01A4", ["\u01A6", "\u01A7"], "\u01A9", "\u01AC", ["\u01AE", "\u01AF"], ["\u01B1", "\u01B3"], "\u01B5", ["\u01B7", "\u01B8"], "\u01BC", "\u01C4", "\u01C7", "\u01CA", "\u01CD", "\u01CF", "\u01D1", "\u01D3", "\u01D5", "\u01D7", "\u01D9", "\u01DB", "\u01DE", "\u01E0", "\u01E2", "\u01E4", "\u01E6", "\u01E8", "\u01EA", "\u01EC", "\u01EE", "\u01F1", "\u01F4", ["\u01F6", "\u01F8"], "\u01FA", "\u01FC", "\u01FE", "\u0200", "\u0202", "\u0204", "\u0206", "\u0208", "\u020A", "\u020C", "\u020E", "\u0210", "\u0212", "\u0214", "\u0216", "\u0218", "\u021A", "\u021C", "\u021E", "\u0220", "\u0222", "\u0224", "\u0226", "\u0228", "\u022A", "\u022C", "\u022E", "\u0230", "\u0232", ["\u023A", "\u023B"], ["\u023D", "\u023E"], "\u0241", ["\u0243", "\u0246"], "\u0248", "\u024A", "\u024C", "\u024E", "\u0370", "\u0372", "\u0376", "\u037F", "\u0386", ["\u0388", "\u038A"], "\u038C", ["\u038E", "\u038F"], ["\u0391", "\u03A1"], ["\u03A3", "\u03AB"], "\u03CF", ["\u03D2", "\u03D4"], "\u03D8", "\u03DA", "\u03DC", "\u03DE", "\u03E0", "\u03E2", "\u03E4", "\u03E6", "\u03E8", "\u03EA", "\u03EC", "\u03EE", "\u03F4", "\u03F7", ["\u03F9", "\u03FA"], ["\u03FD", "\u042F"], "\u0460", "\u0462", "\u0464", "\u0466", "\u0468", "\u046A", "\u046C", "\u046E", "\u0470", "\u0472", "\u0474", "\u0476", "\u0478", "\u047A", "\u047C", "\u047E", "\u0480", "\u048A", "\u048C", "\u048E", "\u0490", "\u0492", "\u0494", "\u0496", "\u0498", "\u049A", "\u049C", "\u049E", "\u04A0", "\u04A2", "\u04A4", "\u04A6", "\u04A8", "\u04AA", "\u04AC", "\u04AE", "\u04B0", "\u04B2", "\u04B4", "\u04B6", "\u04B8", "\u04BA", "\u04BC", "\u04BE", ["\u04C0", "\u04C1"], "\u04C3", "\u04C5", "\u04C7", "\u04C9", "\u04CB", "\u04CD", "\u04D0", "\u04D2", "\u04D4", "\u04D6", "\u04D8", "\u04DA", "\u04DC", "\u04DE", "\u04E0", "\u04E2", "\u04E4", "\u04E6", "\u04E8", "\u04EA", "\u04EC", "\u04EE", "\u04F0", "\u04F2", "\u04F4", "\u04F6", "\u04F8", "\u04FA", "\u04FC", "\u04FE", "\u0500", "\u0502", "\u0504", "\u0506", "\u0508", "\u050A", "\u050C", "\u050E", "\u0510", "\u0512", "\u0514", "\u0516", "\u0518", "\u051A", "\u051C", "\u051E", "\u0520", "\u0522", "\u0524", "\u0526", "\u0528", "\u052A", "\u052C", "\u052E", ["\u0531", "\u0556"], ["\u10A0", "\u10C5"], "\u10C7", "\u10CD", ["\u13A0", "\u13F5"], "\u1E00", "\u1E02", "\u1E04", "\u1E06", "\u1E08", "\u1E0A", "\u1E0C", "\u1E0E", "\u1E10", "\u1E12", "\u1E14", "\u1E16", "\u1E18", "\u1E1A", "\u1E1C", "\u1E1E", "\u1E20", "\u1E22", "\u1E24", "\u1E26", "\u1E28", "\u1E2A", "\u1E2C", "\u1E2E", "\u1E30", "\u1E32", "\u1E34", "\u1E36", "\u1E38", "\u1E3A", "\u1E3C", "\u1E3E", "\u1E40", "\u1E42", "\u1E44", "\u1E46", "\u1E48", "\u1E4A", "\u1E4C", "\u1E4E", "\u1E50", "\u1E52", "\u1E54", "\u1E56", "\u1E58", "\u1E5A", "\u1E5C", "\u1E5E", "\u1E60", "\u1E62", "\u1E64", "\u1E66", "\u1E68", "\u1E6A", "\u1E6C", "\u1E6E", "\u1E70", "\u1E72", "\u1E74", "\u1E76", "\u1E78", "\u1E7A", "\u1E7C", "\u1E7E", "\u1E80", "\u1E82", "\u1E84", "\u1E86", "\u1E88", "\u1E8A", "\u1E8C", "\u1E8E", "\u1E90", "\u1E92", "\u1E94", "\u1E9E", "\u1EA0", "\u1EA2", "\u1EA4", "\u1EA6", "\u1EA8", "\u1EAA", "\u1EAC", "\u1EAE", "\u1EB0", "\u1EB2", "\u1EB4", "\u1EB6", "\u1EB8", "\u1EBA", "\u1EBC", "\u1EBE", "\u1EC0", "\u1EC2", "\u1EC4", "\u1EC6", "\u1EC8", "\u1ECA", "\u1ECC", "\u1ECE", "\u1ED0", "\u1ED2", "\u1ED4", "\u1ED6", "\u1ED8", "\u1EDA", "\u1EDC", "\u1EDE", "\u1EE0", "\u1EE2", "\u1EE4", "\u1EE6", "\u1EE8", "\u1EEA", "\u1EEC", "\u1EEE", "\u1EF0", "\u1EF2", "\u1EF4", "\u1EF6", "\u1EF8", "\u1EFA", "\u1EFC", "\u1EFE", ["\u1F08", "\u1F0F"], ["\u1F18", "\u1F1D"], ["\u1F28", "\u1F2F"], ["\u1F38", "\u1F3F"], ["\u1F48", "\u1F4D"], "\u1F59", "\u1F5B", "\u1F5D", "\u1F5F", ["\u1F68", "\u1F6F"], ["\u1FB8", "\u1FBB"], ["\u1FC8", "\u1FCB"], ["\u1FD8", "\u1FDB"], ["\u1FE8", "\u1FEC"], ["\u1FF8", "\u1FFB"], "\u2102", "\u2107", ["\u210B", "\u210D"], ["\u2110", "\u2112"], "\u2115", ["\u2119", "\u211D"], "\u2124", "\u2126", "\u2128", ["\u212A", "\u212D"], ["\u2130", "\u2133"], ["\u213E", "\u213F"], "\u2145", "\u2183", ["\u2C00", "\u2C2E"], "\u2C60", ["\u2C62", "\u2C64"], "\u2C67", "\u2C69", "\u2C6B", ["\u2C6D", "\u2C70"], "\u2C72", "\u2C75", ["\u2C7E", "\u2C80"], "\u2C82", "\u2C84", "\u2C86", "\u2C88", "\u2C8A", "\u2C8C", "\u2C8E", "\u2C90", "\u2C92", "\u2C94", "\u2C96", "\u2C98", "\u2C9A", "\u2C9C", "\u2C9E", "\u2CA0", "\u2CA2", "\u2CA4", "\u2CA6", "\u2CA8", "\u2CAA", "\u2CAC", "\u2CAE", "\u2CB0", "\u2CB2", "\u2CB4", "\u2CB6", "\u2CB8", "\u2CBA", "\u2CBC", "\u2CBE", "\u2CC0", "\u2CC2", "\u2CC4", "\u2CC6", "\u2CC8", "\u2CCA", "\u2CCC", "\u2CCE", "\u2CD0", "\u2CD2", "\u2CD4", "\u2CD6", "\u2CD8", "\u2CDA", "\u2CDC", "\u2CDE", "\u2CE0", "\u2CE2", "\u2CEB", "\u2CED", "\u2CF2", "\uA640", "\uA642", "\uA644", "\uA646", "\uA648", "\uA64A", "\uA64C", "\uA64E", "\uA650", "\uA652", "\uA654", "\uA656", "\uA658", "\uA65A", "\uA65C", "\uA65E", "\uA660", "\uA662", "\uA664", "\uA666", "\uA668", "\uA66A", "\uA66C", "\uA680", "\uA682", "\uA684", "\uA686", "\uA688", "\uA68A", "\uA68C", "\uA68E", "\uA690", "\uA692", "\uA694", "\uA696", "\uA698", "\uA69A", "\uA722", "\uA724", "\uA726", "\uA728", "\uA72A", "\uA72C", "\uA72E", "\uA732", "\uA734", "\uA736", "\uA738", "\uA73A", "\uA73C", "\uA73E", "\uA740", "\uA742", "\uA744", "\uA746", "\uA748", "\uA74A", "\uA74C", "\uA74E", "\uA750", "\uA752", "\uA754", "\uA756", "\uA758", "\uA75A", "\uA75C", "\uA75E", "\uA760", "\uA762", "\uA764", "\uA766", "\uA768", "\uA76A", "\uA76C", "\uA76E", "\uA779", "\uA77B", ["\uA77D", "\uA77E"], "\uA780", "\uA782", "\uA784", "\uA786", "\uA78B", "\uA78D", "\uA790", "\uA792", "\uA796", "\uA798", "\uA79A", "\uA79C", "\uA79E", "\uA7A0", "\uA7A2", "\uA7A4", "\uA7A6", "\uA7A8", ["\uA7AA", "\uA7AD"], ["\uA7B0", "\uA7B4"], "\uA7B6", ["\uFF21", "\uFF3A"]], false, false);
  24003. var peg$e67 = peg$classExpectation(["\u0903", "\u093B", ["\u093E", "\u0940"], ["\u0949", "\u094C"], ["\u094E", "\u094F"], ["\u0982", "\u0983"], ["\u09BE", "\u09C0"], ["\u09C7", "\u09C8"], ["\u09CB", "\u09CC"], "\u09D7", "\u0A03", ["\u0A3E", "\u0A40"], "\u0A83", ["\u0ABE", "\u0AC0"], "\u0AC9", ["\u0ACB", "\u0ACC"], ["\u0B02", "\u0B03"], "\u0B3E", "\u0B40", ["\u0B47", "\u0B48"], ["\u0B4B", "\u0B4C"], "\u0B57", ["\u0BBE", "\u0BBF"], ["\u0BC1", "\u0BC2"], ["\u0BC6", "\u0BC8"], ["\u0BCA", "\u0BCC"], "\u0BD7", ["\u0C01", "\u0C03"], ["\u0C41", "\u0C44"], ["\u0C82", "\u0C83"], "\u0CBE", ["\u0CC0", "\u0CC4"], ["\u0CC7", "\u0CC8"], ["\u0CCA", "\u0CCB"], ["\u0CD5", "\u0CD6"], ["\u0D02", "\u0D03"], ["\u0D3E", "\u0D40"], ["\u0D46", "\u0D48"], ["\u0D4A", "\u0D4C"], "\u0D57", ["\u0D82", "\u0D83"], ["\u0DCF", "\u0DD1"], ["\u0DD8", "\u0DDF"], ["\u0DF2", "\u0DF3"], ["\u0F3E", "\u0F3F"], "\u0F7F", ["\u102B", "\u102C"], "\u1031", "\u1038", ["\u103B", "\u103C"], ["\u1056", "\u1057"], ["\u1062", "\u1064"], ["\u1067", "\u106D"], ["\u1083", "\u1084"], ["\u1087", "\u108C"], "\u108F", ["\u109A", "\u109C"], "\u17B6", ["\u17BE", "\u17C5"], ["\u17C7", "\u17C8"], ["\u1923", "\u1926"], ["\u1929", "\u192B"], ["\u1930", "\u1931"], ["\u1933", "\u1938"], ["\u1A19", "\u1A1A"], "\u1A55", "\u1A57", "\u1A61", ["\u1A63", "\u1A64"], ["\u1A6D", "\u1A72"], "\u1B04", "\u1B35", "\u1B3B", ["\u1B3D", "\u1B41"], ["\u1B43", "\u1B44"], "\u1B82", "\u1BA1", ["\u1BA6", "\u1BA7"], "\u1BAA", "\u1BE7", ["\u1BEA", "\u1BEC"], "\u1BEE", ["\u1BF2", "\u1BF3"], ["\u1C24", "\u1C2B"], ["\u1C34", "\u1C35"], "\u1CE1", ["\u1CF2", "\u1CF3"], ["\u302E", "\u302F"], ["\uA823", "\uA824"], "\uA827", ["\uA880", "\uA881"], ["\uA8B4", "\uA8C3"], ["\uA952", "\uA953"], "\uA983", ["\uA9B4", "\uA9B5"], ["\uA9BA", "\uA9BB"], ["\uA9BD", "\uA9C0"], ["\uAA2F", "\uAA30"], ["\uAA33", "\uAA34"], "\uAA4D", "\uAA7B", "\uAA7D", "\uAAEB", ["\uAAEE", "\uAAEF"], "\uAAF5", ["\uABE3", "\uABE4"], ["\uABE6", "\uABE7"], ["\uABE9", "\uABEA"], "\uABEC"], false, false);
  24004. var peg$e68 = peg$classExpectation([["\u0300", "\u036F"], ["\u0483", "\u0487"], ["\u0591", "\u05BD"], "\u05BF", ["\u05C1", "\u05C2"], ["\u05C4", "\u05C5"], "\u05C7", ["\u0610", "\u061A"], ["\u064B", "\u065F"], "\u0670", ["\u06D6", "\u06DC"], ["\u06DF", "\u06E4"], ["\u06E7", "\u06E8"], ["\u06EA", "\u06ED"], "\u0711", ["\u0730", "\u074A"], ["\u07A6", "\u07B0"], ["\u07EB", "\u07F3"], ["\u0816", "\u0819"], ["\u081B", "\u0823"], ["\u0825", "\u0827"], ["\u0829", "\u082D"], ["\u0859", "\u085B"], ["\u08E3", "\u0902"], "\u093A", "\u093C", ["\u0941", "\u0948"], "\u094D", ["\u0951", "\u0957"], ["\u0962", "\u0963"], "\u0981", "\u09BC", ["\u09C1", "\u09C4"], "\u09CD", ["\u09E2", "\u09E3"], ["\u0A01", "\u0A02"], "\u0A3C", ["\u0A41", "\u0A42"], ["\u0A47", "\u0A48"], ["\u0A4B", "\u0A4D"], "\u0A51", ["\u0A70", "\u0A71"], "\u0A75", ["\u0A81", "\u0A82"], "\u0ABC", ["\u0AC1", "\u0AC5"], ["\u0AC7", "\u0AC8"], "\u0ACD", ["\u0AE2", "\u0AE3"], "\u0B01", "\u0B3C", "\u0B3F", ["\u0B41", "\u0B44"], "\u0B4D", "\u0B56", ["\u0B62", "\u0B63"], "\u0B82", "\u0BC0", "\u0BCD", "\u0C00", ["\u0C3E", "\u0C40"], ["\u0C46", "\u0C48"], ["\u0C4A", "\u0C4D"], ["\u0C55", "\u0C56"], ["\u0C62", "\u0C63"], "\u0C81", "\u0CBC", "\u0CBF", "\u0CC6", ["\u0CCC", "\u0CCD"], ["\u0CE2", "\u0CE3"], "\u0D01", ["\u0D41", "\u0D44"], "\u0D4D", ["\u0D62", "\u0D63"], "\u0DCA", ["\u0DD2", "\u0DD4"], "\u0DD6", "\u0E31", ["\u0E34", "\u0E3A"], ["\u0E47", "\u0E4E"], "\u0EB1", ["\u0EB4", "\u0EB9"], ["\u0EBB", "\u0EBC"], ["\u0EC8", "\u0ECD"], ["\u0F18", "\u0F19"], "\u0F35", "\u0F37", "\u0F39", ["\u0F71", "\u0F7E"], ["\u0F80", "\u0F84"], ["\u0F86", "\u0F87"], ["\u0F8D", "\u0F97"], ["\u0F99", "\u0FBC"], "\u0FC6", ["\u102D", "\u1030"], ["\u1032", "\u1037"], ["\u1039", "\u103A"], ["\u103D", "\u103E"], ["\u1058", "\u1059"], ["\u105E", "\u1060"], ["\u1071", "\u1074"], "\u1082", ["\u1085", "\u1086"], "\u108D", "\u109D", ["\u135D", "\u135F"], ["\u1712", "\u1714"], ["\u1732", "\u1734"], ["\u1752", "\u1753"], ["\u1772", "\u1773"], ["\u17B4", "\u17B5"], ["\u17B7", "\u17BD"], "\u17C6", ["\u17C9", "\u17D3"], "\u17DD", ["\u180B", "\u180D"], "\u18A9", ["\u1920", "\u1922"], ["\u1927", "\u1928"], "\u1932", ["\u1939", "\u193B"], ["\u1A17", "\u1A18"], "\u1A1B", "\u1A56", ["\u1A58", "\u1A5E"], "\u1A60", "\u1A62", ["\u1A65", "\u1A6C"], ["\u1A73", "\u1A7C"], "\u1A7F", ["\u1AB0", "\u1ABD"], ["\u1B00", "\u1B03"], "\u1B34", ["\u1B36", "\u1B3A"], "\u1B3C", "\u1B42", ["\u1B6B", "\u1B73"], ["\u1B80", "\u1B81"], ["\u1BA2", "\u1BA5"], ["\u1BA8", "\u1BA9"], ["\u1BAB", "\u1BAD"], "\u1BE6", ["\u1BE8", "\u1BE9"], "\u1BED", ["\u1BEF", "\u1BF1"], ["\u1C2C", "\u1C33"], ["\u1C36", "\u1C37"], ["\u1CD0", "\u1CD2"], ["\u1CD4", "\u1CE0"], ["\u1CE2", "\u1CE8"], "\u1CED", "\u1CF4", ["\u1CF8", "\u1CF9"], ["\u1DC0", "\u1DF5"], ["\u1DFC", "\u1DFF"], ["\u20D0", "\u20DC"], "\u20E1", ["\u20E5", "\u20F0"], ["\u2CEF", "\u2CF1"], "\u2D7F", ["\u2DE0", "\u2DFF"], ["\u302A", "\u302D"], ["\u3099", "\u309A"], "\uA66F", ["\uA674", "\uA67D"], ["\uA69E", "\uA69F"], ["\uA6F0", "\uA6F1"], "\uA802", "\uA806", "\uA80B", ["\uA825", "\uA826"], "\uA8C4", ["\uA8E0", "\uA8F1"], ["\uA926", "\uA92D"], ["\uA947", "\uA951"], ["\uA980", "\uA982"], "\uA9B3", ["\uA9B6", "\uA9B9"], "\uA9BC", "\uA9E5", ["\uAA29", "\uAA2E"], ["\uAA31", "\uAA32"], ["\uAA35", "\uAA36"], "\uAA43", "\uAA4C", "\uAA7C", "\uAAB0", ["\uAAB2", "\uAAB4"], ["\uAAB7", "\uAAB8"], ["\uAABE", "\uAABF"], "\uAAC1", ["\uAAEC", "\uAAED"], "\uAAF6", "\uABE5", "\uABE8", "\uABED", "\uFB1E", ["\uFE00", "\uFE0F"], ["\uFE20", "\uFE2F"]], false, false);
  24005. var peg$e69 = peg$classExpectation([["0", "9"], ["\u0660", "\u0669"], ["\u06F0", "\u06F9"], ["\u07C0", "\u07C9"], ["\u0966", "\u096F"], ["\u09E6", "\u09EF"], ["\u0A66", "\u0A6F"], ["\u0AE6", "\u0AEF"], ["\u0B66", "\u0B6F"], ["\u0BE6", "\u0BEF"], ["\u0C66", "\u0C6F"], ["\u0CE6", "\u0CEF"], ["\u0D66", "\u0D6F"], ["\u0DE6", "\u0DEF"], ["\u0E50", "\u0E59"], ["\u0ED0", "\u0ED9"], ["\u0F20", "\u0F29"], ["\u1040", "\u1049"], ["\u1090", "\u1099"], ["\u17E0", "\u17E9"], ["\u1810", "\u1819"], ["\u1946", "\u194F"], ["\u19D0", "\u19D9"], ["\u1A80", "\u1A89"], ["\u1A90", "\u1A99"], ["\u1B50", "\u1B59"], ["\u1BB0", "\u1BB9"], ["\u1C40", "\u1C49"], ["\u1C50", "\u1C59"], ["\uA620", "\uA629"], ["\uA8D0", "\uA8D9"], ["\uA900", "\uA909"], ["\uA9D0", "\uA9D9"], ["\uA9F0", "\uA9F9"], ["\uAA50", "\uAA59"], ["\uABF0", "\uABF9"], ["\uFF10", "\uFF19"]], false, false);
  24006. var peg$e70 = peg$classExpectation([["\u16EE", "\u16F0"], ["\u2160", "\u2182"], ["\u2185", "\u2188"], "\u3007", ["\u3021", "\u3029"], ["\u3038", "\u303A"], ["\uA6E6", "\uA6EF"]], false, false);
  24007. var peg$e71 = peg$classExpectation(["_", ["\u203F", "\u2040"], "\u2054", ["\uFE33", "\uFE34"], ["\uFE4D", "\uFE4F"], "\uFF3F"], false, false);
  24008. var peg$e72 = peg$classExpectation([" ", "\xA0", "\u1680", ["\u2000", "\u200A"], "\u202F", "\u205F", "\u3000"], false, false);
  24009. var peg$e73 = peg$literalExpectation(";", false);
  24010. var peg$f0 = function(topLevelInitializer, initializer, rules) {
  24011. return {
  24012. type: "grammar",
  24013. topLevelInitializer,
  24014. initializer,
  24015. rules,
  24016. location: location()
  24017. };
  24018. };
  24019. var peg$f1 = function(code) {
  24020. return {
  24021. type: "top_level_initializer",
  24022. code: code[0],
  24023. codeLocation: code[1],
  24024. location: location()
  24025. };
  24026. };
  24027. var peg$f2 = function(code) {
  24028. return {
  24029. type: "initializer",
  24030. code: code[0],
  24031. codeLocation: code[1],
  24032. location: location()
  24033. };
  24034. };
  24035. var peg$f3 = function(name, displayName, expression) {
  24036. return {
  24037. type: "rule",
  24038. name: name[0],
  24039. nameLocation: name[1],
  24040. expression: displayName !== null
  24041. ? {
  24042. type: "named",
  24043. name: displayName,
  24044. expression,
  24045. location: location()
  24046. }
  24047. : expression,
  24048. location: location()
  24049. };
  24050. };
  24051. var peg$f4 = function(head, tail) {
  24052. return tail.length > 0
  24053. ? {
  24054. type: "choice",
  24055. alternatives: [head].concat(tail),
  24056. location: location()
  24057. }
  24058. : head;
  24059. };
  24060. var peg$f5 = function(expression, code) {
  24061. return code !== null
  24062. ? {
  24063. type: "action",
  24064. expression,
  24065. code: code[0],
  24066. codeLocation: code[1],
  24067. location: location()
  24068. }
  24069. : expression;
  24070. };
  24071. var peg$f6 = function(head, tail) {
  24072. return ((tail.length > 0) || (head.type === "labeled" && head.pick))
  24073. ? {
  24074. type: "sequence",
  24075. elements: [head].concat(tail),
  24076. location: location()
  24077. }
  24078. : head;
  24079. };
  24080. var peg$f7 = function(pluck, label, expression) {
  24081. if (expression.type.startsWith("semantic_")) {
  24082. error("\"@\" cannot be used on a semantic predicate", pluck);
  24083. }
  24084. return {
  24085. type: "labeled",
  24086. label: label !== null ? label[0] : null,
  24087. // Use location of "@" if label is unavailable
  24088. labelLocation: label !== null ? label[1] : pluck,
  24089. pick: true,
  24090. expression,
  24091. location: location()
  24092. };
  24093. };
  24094. var peg$f8 = function(label, expression) {
  24095. return {
  24096. type: "labeled",
  24097. label: label[0],
  24098. labelLocation: label[1],
  24099. expression,
  24100. location: location()
  24101. };
  24102. };
  24103. var peg$f9 = function() { return location(); };
  24104. var peg$f10 = function(label) {
  24105. if (reservedWords.indexOf(label[0]) >= 0) {
  24106. error(`Label can't be a reserved word "${label[0]}"`, label[1]);
  24107. }
  24108. return label;
  24109. };
  24110. var peg$f11 = function(operator, expression) {
  24111. return {
  24112. type: OPS_TO_PREFIXED_TYPES[operator],
  24113. expression,
  24114. location: location()
  24115. };
  24116. };
  24117. var peg$f12 = function(expression, operator) {
  24118. return {
  24119. type: OPS_TO_SUFFIXED_TYPES[operator],
  24120. expression,
  24121. location: location()
  24122. };
  24123. };
  24124. var peg$f13 = function(expression) {
  24125. // The purpose of the "group" AST node is just to isolate label scope. We
  24126. // don't need to put it around nodes that can't contain any labels or
  24127. // nodes that already isolate label scope themselves. This leaves us with
  24128. // "labeled" and "sequence".
  24129. return expression.type === "labeled" || expression.type === "sequence"
  24130. ? { type: "group", expression, location: location() }
  24131. : expression;
  24132. };
  24133. var peg$f14 = function(name) {
  24134. return { type: "rule_ref", name: name[0], location: location() };
  24135. };
  24136. var peg$f15 = function(operator, code) {
  24137. return {
  24138. type: OPS_TO_SEMANTIC_PREDICATE_TYPES[operator],
  24139. code: code[0],
  24140. codeLocation: code[1],
  24141. location: location()
  24142. };
  24143. };
  24144. var peg$f16 = function(head, tail) {
  24145. return [head + tail.join(""), location()];
  24146. };
  24147. var peg$f17 = function(value, ignoreCase) {
  24148. return {
  24149. type: "literal",
  24150. value,
  24151. ignoreCase: ignoreCase !== null,
  24152. location: location()
  24153. };
  24154. };
  24155. var peg$f18 = function(chars) { return chars.join(""); };
  24156. var peg$f19 = function(inverted, parts, ignoreCase) {
  24157. return {
  24158. type: "class",
  24159. parts: parts.filter(part => part !== ""),
  24160. inverted: inverted !== null,
  24161. ignoreCase: ignoreCase !== null,
  24162. location: location()
  24163. };
  24164. };
  24165. var peg$f20 = function(begin, end) {
  24166. if (begin.charCodeAt(0) > end.charCodeAt(0)) {
  24167. error(
  24168. "Invalid character range: " + text() + "."
  24169. );
  24170. }
  24171. return [begin, end];
  24172. };
  24173. var peg$f21 = function() { return ""; };
  24174. var peg$f22 = function() { return "\0"; };
  24175. var peg$f23 = function() { return "\b"; };
  24176. var peg$f24 = function() { return "\f"; };
  24177. var peg$f25 = function() { return "\n"; };
  24178. var peg$f26 = function() { return "\r"; };
  24179. var peg$f27 = function() { return "\t"; };
  24180. var peg$f28 = function() { return "\v"; };
  24181. var peg$f29 = function(digits) {
  24182. return String.fromCharCode(parseInt(digits, 16));
  24183. };
  24184. var peg$f30 = function() { return { type: "any", location: location() }; };
  24185. var peg$f31 = function(code) { return [code, location()]; };
  24186. var peg$currPos = 0;
  24187. var peg$savedPos = 0;
  24188. var peg$posDetailsCache = [{ line: 1, column: 1 }];
  24189. var peg$maxFailPos = 0;
  24190. var peg$maxFailExpected = [];
  24191. var peg$silentFails = 0;
  24192. var peg$result;
  24193. if ("startRule" in options) {
  24194. if (!(options.startRule in peg$startRuleFunctions)) {
  24195. throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
  24196. }
  24197. peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
  24198. }
  24199. function text() {
  24200. return input.substring(peg$savedPos, peg$currPos);
  24201. }
  24202. function offset() {
  24203. return peg$savedPos;
  24204. }
  24205. function range() {
  24206. return {
  24207. source: peg$source,
  24208. start: peg$savedPos,
  24209. end: peg$currPos
  24210. };
  24211. }
  24212. function location() {
  24213. return peg$computeLocation(peg$savedPos, peg$currPos);
  24214. }
  24215. function expected(description, location) {
  24216. location = location !== undefined
  24217. ? location
  24218. : peg$computeLocation(peg$savedPos, peg$currPos);
  24219. throw peg$buildStructuredError(
  24220. [peg$otherExpectation(description)],
  24221. input.substring(peg$savedPos, peg$currPos),
  24222. location
  24223. );
  24224. }
  24225. function error(message, location) {
  24226. location = location !== undefined
  24227. ? location
  24228. : peg$computeLocation(peg$savedPos, peg$currPos);
  24229. throw peg$buildSimpleError(message, location);
  24230. }
  24231. function peg$literalExpectation(text, ignoreCase) {
  24232. return { type: "literal", text: text, ignoreCase: ignoreCase };
  24233. }
  24234. function peg$classExpectation(parts, inverted, ignoreCase) {
  24235. return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
  24236. }
  24237. function peg$anyExpectation() {
  24238. return { type: "any" };
  24239. }
  24240. function peg$endExpectation() {
  24241. return { type: "end" };
  24242. }
  24243. function peg$otherExpectation(description) {
  24244. return { type: "other", description: description };
  24245. }
  24246. function peg$computePosDetails(pos) {
  24247. var details = peg$posDetailsCache[pos];
  24248. var p;
  24249. if (details) {
  24250. return details;
  24251. } else {
  24252. p = pos - 1;
  24253. while (!peg$posDetailsCache[p]) {
  24254. p--;
  24255. }
  24256. details = peg$posDetailsCache[p];
  24257. details = {
  24258. line: details.line,
  24259. column: details.column
  24260. };
  24261. while (p < pos) {
  24262. if (input.charCodeAt(p) === 10) {
  24263. details.line++;
  24264. details.column = 1;
  24265. } else {
  24266. details.column++;
  24267. }
  24268. p++;
  24269. }
  24270. peg$posDetailsCache[pos] = details;
  24271. return details;
  24272. }
  24273. }
  24274. function peg$computeLocation(startPos, endPos) {
  24275. var startPosDetails = peg$computePosDetails(startPos);
  24276. var endPosDetails = peg$computePosDetails(endPos);
  24277. return {
  24278. source: peg$source,
  24279. start: {
  24280. offset: startPos,
  24281. line: startPosDetails.line,
  24282. column: startPosDetails.column
  24283. },
  24284. end: {
  24285. offset: endPos,
  24286. line: endPosDetails.line,
  24287. column: endPosDetails.column
  24288. }
  24289. };
  24290. }
  24291. function peg$fail(expected) {
  24292. if (peg$currPos < peg$maxFailPos) { return; }
  24293. if (peg$currPos > peg$maxFailPos) {
  24294. peg$maxFailPos = peg$currPos;
  24295. peg$maxFailExpected = [];
  24296. }
  24297. peg$maxFailExpected.push(expected);
  24298. }
  24299. function peg$buildSimpleError(message, location) {
  24300. return new peg$SyntaxError(message, null, null, location);
  24301. }
  24302. function peg$buildStructuredError(expected, found, location) {
  24303. return new peg$SyntaxError(
  24304. peg$SyntaxError.buildMessage(expected, found),
  24305. expected,
  24306. found,
  24307. location
  24308. );
  24309. }
  24310. function peg$parseGrammar() {
  24311. var s0, s1, s2, s3, s4, s5, s6, s7;
  24312. s0 = peg$currPos;
  24313. s1 = peg$parse__();
  24314. s2 = peg$currPos;
  24315. s3 = peg$parseTopLevelInitializer();
  24316. if (s3 !== peg$FAILED) {
  24317. s4 = peg$parse__();
  24318. s2 = s3;
  24319. } else {
  24320. peg$currPos = s2;
  24321. s2 = peg$FAILED;
  24322. }
  24323. if (s2 === peg$FAILED) {
  24324. s2 = null;
  24325. }
  24326. s3 = peg$currPos;
  24327. s4 = peg$parseInitializer();
  24328. if (s4 !== peg$FAILED) {
  24329. s5 = peg$parse__();
  24330. s3 = s4;
  24331. } else {
  24332. peg$currPos = s3;
  24333. s3 = peg$FAILED;
  24334. }
  24335. if (s3 === peg$FAILED) {
  24336. s3 = null;
  24337. }
  24338. s4 = [];
  24339. s5 = peg$currPos;
  24340. s6 = peg$parseRule();
  24341. if (s6 !== peg$FAILED) {
  24342. s7 = peg$parse__();
  24343. s5 = s6;
  24344. } else {
  24345. peg$currPos = s5;
  24346. s5 = peg$FAILED;
  24347. }
  24348. if (s5 !== peg$FAILED) {
  24349. while (s5 !== peg$FAILED) {
  24350. s4.push(s5);
  24351. s5 = peg$currPos;
  24352. s6 = peg$parseRule();
  24353. if (s6 !== peg$FAILED) {
  24354. s7 = peg$parse__();
  24355. s5 = s6;
  24356. } else {
  24357. peg$currPos = s5;
  24358. s5 = peg$FAILED;
  24359. }
  24360. }
  24361. } else {
  24362. s4 = peg$FAILED;
  24363. }
  24364. if (s4 !== peg$FAILED) {
  24365. peg$savedPos = s0;
  24366. s0 = peg$f0(s2, s3, s4);
  24367. } else {
  24368. peg$currPos = s0;
  24369. s0 = peg$FAILED;
  24370. }
  24371. return s0;
  24372. }
  24373. function peg$parseTopLevelInitializer() {
  24374. var s0, s1, s2, s3, s4;
  24375. s0 = peg$currPos;
  24376. if (input.charCodeAt(peg$currPos) === 123) {
  24377. s1 = peg$c0;
  24378. peg$currPos++;
  24379. } else {
  24380. s1 = peg$FAILED;
  24381. if (peg$silentFails === 0) { peg$fail(peg$e0); }
  24382. }
  24383. if (s1 !== peg$FAILED) {
  24384. s2 = peg$parseCodeBlock();
  24385. if (s2 !== peg$FAILED) {
  24386. if (input.charCodeAt(peg$currPos) === 125) {
  24387. s3 = peg$c1;
  24388. peg$currPos++;
  24389. } else {
  24390. s3 = peg$FAILED;
  24391. if (peg$silentFails === 0) { peg$fail(peg$e1); }
  24392. }
  24393. if (s3 !== peg$FAILED) {
  24394. s4 = peg$parseEOS();
  24395. if (s4 !== peg$FAILED) {
  24396. peg$savedPos = s0;
  24397. s0 = peg$f1(s2);
  24398. } else {
  24399. peg$currPos = s0;
  24400. s0 = peg$FAILED;
  24401. }
  24402. } else {
  24403. peg$currPos = s0;
  24404. s0 = peg$FAILED;
  24405. }
  24406. } else {
  24407. peg$currPos = s0;
  24408. s0 = peg$FAILED;
  24409. }
  24410. } else {
  24411. peg$currPos = s0;
  24412. s0 = peg$FAILED;
  24413. }
  24414. return s0;
  24415. }
  24416. function peg$parseInitializer() {
  24417. var s0, s1, s2;
  24418. s0 = peg$currPos;
  24419. s1 = peg$parseCodeBlock();
  24420. if (s1 !== peg$FAILED) {
  24421. s2 = peg$parseEOS();
  24422. if (s2 !== peg$FAILED) {
  24423. peg$savedPos = s0;
  24424. s0 = peg$f2(s1);
  24425. } else {
  24426. peg$currPos = s0;
  24427. s0 = peg$FAILED;
  24428. }
  24429. } else {
  24430. peg$currPos = s0;
  24431. s0 = peg$FAILED;
  24432. }
  24433. return s0;
  24434. }
  24435. function peg$parseRule() {
  24436. var s0, s1, s2, s3, s4, s5, s6, s7;
  24437. s0 = peg$currPos;
  24438. s1 = peg$parseIdentifierName();
  24439. if (s1 !== peg$FAILED) {
  24440. s2 = peg$parse__();
  24441. s3 = peg$currPos;
  24442. s4 = peg$parseStringLiteral();
  24443. if (s4 !== peg$FAILED) {
  24444. s5 = peg$parse__();
  24445. s3 = s4;
  24446. } else {
  24447. peg$currPos = s3;
  24448. s3 = peg$FAILED;
  24449. }
  24450. if (s3 === peg$FAILED) {
  24451. s3 = null;
  24452. }
  24453. if (input.charCodeAt(peg$currPos) === 61) {
  24454. s4 = peg$c2;
  24455. peg$currPos++;
  24456. } else {
  24457. s4 = peg$FAILED;
  24458. if (peg$silentFails === 0) { peg$fail(peg$e2); }
  24459. }
  24460. if (s4 !== peg$FAILED) {
  24461. s5 = peg$parse__();
  24462. s6 = peg$parseChoiceExpression();
  24463. if (s6 !== peg$FAILED) {
  24464. s7 = peg$parseEOS();
  24465. if (s7 !== peg$FAILED) {
  24466. peg$savedPos = s0;
  24467. s0 = peg$f3(s1, s3, s6);
  24468. } else {
  24469. peg$currPos = s0;
  24470. s0 = peg$FAILED;
  24471. }
  24472. } else {
  24473. peg$currPos = s0;
  24474. s0 = peg$FAILED;
  24475. }
  24476. } else {
  24477. peg$currPos = s0;
  24478. s0 = peg$FAILED;
  24479. }
  24480. } else {
  24481. peg$currPos = s0;
  24482. s0 = peg$FAILED;
  24483. }
  24484. return s0;
  24485. }
  24486. function peg$parseChoiceExpression() {
  24487. var s0, s1, s2, s3, s4, s5, s6, s7;
  24488. s0 = peg$currPos;
  24489. s1 = peg$parseActionExpression();
  24490. if (s1 !== peg$FAILED) {
  24491. s2 = [];
  24492. s3 = peg$currPos;
  24493. s4 = peg$parse__();
  24494. if (input.charCodeAt(peg$currPos) === 47) {
  24495. s5 = peg$c3;
  24496. peg$currPos++;
  24497. } else {
  24498. s5 = peg$FAILED;
  24499. if (peg$silentFails === 0) { peg$fail(peg$e3); }
  24500. }
  24501. if (s5 !== peg$FAILED) {
  24502. s6 = peg$parse__();
  24503. s7 = peg$parseActionExpression();
  24504. if (s7 !== peg$FAILED) {
  24505. s3 = s7;
  24506. } else {
  24507. peg$currPos = s3;
  24508. s3 = peg$FAILED;
  24509. }
  24510. } else {
  24511. peg$currPos = s3;
  24512. s3 = peg$FAILED;
  24513. }
  24514. while (s3 !== peg$FAILED) {
  24515. s2.push(s3);
  24516. s3 = peg$currPos;
  24517. s4 = peg$parse__();
  24518. if (input.charCodeAt(peg$currPos) === 47) {
  24519. s5 = peg$c3;
  24520. peg$currPos++;
  24521. } else {
  24522. s5 = peg$FAILED;
  24523. if (peg$silentFails === 0) { peg$fail(peg$e3); }
  24524. }
  24525. if (s5 !== peg$FAILED) {
  24526. s6 = peg$parse__();
  24527. s7 = peg$parseActionExpression();
  24528. if (s7 !== peg$FAILED) {
  24529. s3 = s7;
  24530. } else {
  24531. peg$currPos = s3;
  24532. s3 = peg$FAILED;
  24533. }
  24534. } else {
  24535. peg$currPos = s3;
  24536. s3 = peg$FAILED;
  24537. }
  24538. }
  24539. peg$savedPos = s0;
  24540. s0 = peg$f4(s1, s2);
  24541. } else {
  24542. peg$currPos = s0;
  24543. s0 = peg$FAILED;
  24544. }
  24545. return s0;
  24546. }
  24547. function peg$parseActionExpression() {
  24548. var s0, s1, s2, s3, s4;
  24549. s0 = peg$currPos;
  24550. s1 = peg$parseSequenceExpression();
  24551. if (s1 !== peg$FAILED) {
  24552. s2 = peg$currPos;
  24553. s3 = peg$parse__();
  24554. s4 = peg$parseCodeBlock();
  24555. if (s4 !== peg$FAILED) {
  24556. s2 = s4;
  24557. } else {
  24558. peg$currPos = s2;
  24559. s2 = peg$FAILED;
  24560. }
  24561. if (s2 === peg$FAILED) {
  24562. s2 = null;
  24563. }
  24564. peg$savedPos = s0;
  24565. s0 = peg$f5(s1, s2);
  24566. } else {
  24567. peg$currPos = s0;
  24568. s0 = peg$FAILED;
  24569. }
  24570. return s0;
  24571. }
  24572. function peg$parseSequenceExpression() {
  24573. var s0, s1, s2, s3, s4, s5;
  24574. s0 = peg$currPos;
  24575. s1 = peg$parseLabeledExpression();
  24576. if (s1 !== peg$FAILED) {
  24577. s2 = [];
  24578. s3 = peg$currPos;
  24579. s4 = peg$parse__();
  24580. s5 = peg$parseLabeledExpression();
  24581. if (s5 !== peg$FAILED) {
  24582. s3 = s5;
  24583. } else {
  24584. peg$currPos = s3;
  24585. s3 = peg$FAILED;
  24586. }
  24587. while (s3 !== peg$FAILED) {
  24588. s2.push(s3);
  24589. s3 = peg$currPos;
  24590. s4 = peg$parse__();
  24591. s5 = peg$parseLabeledExpression();
  24592. if (s5 !== peg$FAILED) {
  24593. s3 = s5;
  24594. } else {
  24595. peg$currPos = s3;
  24596. s3 = peg$FAILED;
  24597. }
  24598. }
  24599. peg$savedPos = s0;
  24600. s0 = peg$f6(s1, s2);
  24601. } else {
  24602. peg$currPos = s0;
  24603. s0 = peg$FAILED;
  24604. }
  24605. return s0;
  24606. }
  24607. function peg$parseLabeledExpression() {
  24608. var s0, s1, s2, s3;
  24609. s0 = peg$currPos;
  24610. s1 = peg$parsePluck();
  24611. if (s1 !== peg$FAILED) {
  24612. s2 = peg$parseLabelColon();
  24613. if (s2 === peg$FAILED) {
  24614. s2 = null;
  24615. }
  24616. s3 = peg$parsePrefixedExpression();
  24617. if (s3 !== peg$FAILED) {
  24618. peg$savedPos = s0;
  24619. s0 = peg$f7(s1, s2, s3);
  24620. } else {
  24621. peg$currPos = s0;
  24622. s0 = peg$FAILED;
  24623. }
  24624. } else {
  24625. peg$currPos = s0;
  24626. s0 = peg$FAILED;
  24627. }
  24628. if (s0 === peg$FAILED) {
  24629. s0 = peg$currPos;
  24630. s1 = peg$parseLabelColon();
  24631. if (s1 !== peg$FAILED) {
  24632. s2 = peg$parse__();
  24633. s3 = peg$parsePrefixedExpression();
  24634. if (s3 !== peg$FAILED) {
  24635. peg$savedPos = s0;
  24636. s0 = peg$f8(s1, s3);
  24637. } else {
  24638. peg$currPos = s0;
  24639. s0 = peg$FAILED;
  24640. }
  24641. } else {
  24642. peg$currPos = s0;
  24643. s0 = peg$FAILED;
  24644. }
  24645. if (s0 === peg$FAILED) {
  24646. s0 = peg$parsePrefixedExpression();
  24647. }
  24648. }
  24649. return s0;
  24650. }
  24651. function peg$parsePluck() {
  24652. var s0, s1;
  24653. s0 = peg$currPos;
  24654. if (input.charCodeAt(peg$currPos) === 64) {
  24655. s1 = peg$c4;
  24656. peg$currPos++;
  24657. } else {
  24658. s1 = peg$FAILED;
  24659. if (peg$silentFails === 0) { peg$fail(peg$e4); }
  24660. }
  24661. if (s1 !== peg$FAILED) {
  24662. peg$savedPos = s0;
  24663. s1 = peg$f9();
  24664. }
  24665. s0 = s1;
  24666. return s0;
  24667. }
  24668. function peg$parseLabelColon() {
  24669. var s0, s1, s2, s3;
  24670. s0 = peg$currPos;
  24671. s1 = peg$parseIdentifierName();
  24672. if (s1 !== peg$FAILED) {
  24673. s2 = peg$parse__();
  24674. if (input.charCodeAt(peg$currPos) === 58) {
  24675. s3 = peg$c5;
  24676. peg$currPos++;
  24677. } else {
  24678. s3 = peg$FAILED;
  24679. if (peg$silentFails === 0) { peg$fail(peg$e5); }
  24680. }
  24681. if (s3 !== peg$FAILED) {
  24682. peg$savedPos = s0;
  24683. s0 = peg$f10(s1);
  24684. } else {
  24685. peg$currPos = s0;
  24686. s0 = peg$FAILED;
  24687. }
  24688. } else {
  24689. peg$currPos = s0;
  24690. s0 = peg$FAILED;
  24691. }
  24692. return s0;
  24693. }
  24694. function peg$parsePrefixedExpression() {
  24695. var s0, s1, s2, s3;
  24696. s0 = peg$currPos;
  24697. s1 = peg$parsePrefixedOperator();
  24698. if (s1 !== peg$FAILED) {
  24699. s2 = peg$parse__();
  24700. s3 = peg$parseSuffixedExpression();
  24701. if (s3 !== peg$FAILED) {
  24702. peg$savedPos = s0;
  24703. s0 = peg$f11(s1, s3);
  24704. } else {
  24705. peg$currPos = s0;
  24706. s0 = peg$FAILED;
  24707. }
  24708. } else {
  24709. peg$currPos = s0;
  24710. s0 = peg$FAILED;
  24711. }
  24712. if (s0 === peg$FAILED) {
  24713. s0 = peg$parseSuffixedExpression();
  24714. }
  24715. return s0;
  24716. }
  24717. function peg$parsePrefixedOperator() {
  24718. var s0;
  24719. if (input.charCodeAt(peg$currPos) === 36) {
  24720. s0 = peg$c6;
  24721. peg$currPos++;
  24722. } else {
  24723. s0 = peg$FAILED;
  24724. if (peg$silentFails === 0) { peg$fail(peg$e6); }
  24725. }
  24726. if (s0 === peg$FAILED) {
  24727. if (input.charCodeAt(peg$currPos) === 38) {
  24728. s0 = peg$c7;
  24729. peg$currPos++;
  24730. } else {
  24731. s0 = peg$FAILED;
  24732. if (peg$silentFails === 0) { peg$fail(peg$e7); }
  24733. }
  24734. if (s0 === peg$FAILED) {
  24735. if (input.charCodeAt(peg$currPos) === 33) {
  24736. s0 = peg$c8;
  24737. peg$currPos++;
  24738. } else {
  24739. s0 = peg$FAILED;
  24740. if (peg$silentFails === 0) { peg$fail(peg$e8); }
  24741. }
  24742. }
  24743. }
  24744. return s0;
  24745. }
  24746. function peg$parseSuffixedExpression() {
  24747. var s0, s1, s2, s3;
  24748. s0 = peg$currPos;
  24749. s1 = peg$parsePrimaryExpression();
  24750. if (s1 !== peg$FAILED) {
  24751. s2 = peg$parse__();
  24752. s3 = peg$parseSuffixedOperator();
  24753. if (s3 !== peg$FAILED) {
  24754. peg$savedPos = s0;
  24755. s0 = peg$f12(s1, s3);
  24756. } else {
  24757. peg$currPos = s0;
  24758. s0 = peg$FAILED;
  24759. }
  24760. } else {
  24761. peg$currPos = s0;
  24762. s0 = peg$FAILED;
  24763. }
  24764. if (s0 === peg$FAILED) {
  24765. s0 = peg$parsePrimaryExpression();
  24766. }
  24767. return s0;
  24768. }
  24769. function peg$parseSuffixedOperator() {
  24770. var s0;
  24771. if (input.charCodeAt(peg$currPos) === 63) {
  24772. s0 = peg$c9;
  24773. peg$currPos++;
  24774. } else {
  24775. s0 = peg$FAILED;
  24776. if (peg$silentFails === 0) { peg$fail(peg$e9); }
  24777. }
  24778. if (s0 === peg$FAILED) {
  24779. if (input.charCodeAt(peg$currPos) === 42) {
  24780. s0 = peg$c10;
  24781. peg$currPos++;
  24782. } else {
  24783. s0 = peg$FAILED;
  24784. if (peg$silentFails === 0) { peg$fail(peg$e10); }
  24785. }
  24786. if (s0 === peg$FAILED) {
  24787. if (input.charCodeAt(peg$currPos) === 43) {
  24788. s0 = peg$c11;
  24789. peg$currPos++;
  24790. } else {
  24791. s0 = peg$FAILED;
  24792. if (peg$silentFails === 0) { peg$fail(peg$e11); }
  24793. }
  24794. }
  24795. }
  24796. return s0;
  24797. }
  24798. function peg$parsePrimaryExpression() {
  24799. var s0, s1, s2, s3, s4, s5;
  24800. s0 = peg$parseLiteralMatcher();
  24801. if (s0 === peg$FAILED) {
  24802. s0 = peg$parseCharacterClassMatcher();
  24803. if (s0 === peg$FAILED) {
  24804. s0 = peg$parseAnyMatcher();
  24805. if (s0 === peg$FAILED) {
  24806. s0 = peg$parseRuleReferenceExpression();
  24807. if (s0 === peg$FAILED) {
  24808. s0 = peg$parseSemanticPredicateExpression();
  24809. if (s0 === peg$FAILED) {
  24810. s0 = peg$currPos;
  24811. if (input.charCodeAt(peg$currPos) === 40) {
  24812. s1 = peg$c12;
  24813. peg$currPos++;
  24814. } else {
  24815. s1 = peg$FAILED;
  24816. if (peg$silentFails === 0) { peg$fail(peg$e12); }
  24817. }
  24818. if (s1 !== peg$FAILED) {
  24819. s2 = peg$parse__();
  24820. s3 = peg$parseChoiceExpression();
  24821. if (s3 !== peg$FAILED) {
  24822. s4 = peg$parse__();
  24823. if (input.charCodeAt(peg$currPos) === 41) {
  24824. s5 = peg$c13;
  24825. peg$currPos++;
  24826. } else {
  24827. s5 = peg$FAILED;
  24828. if (peg$silentFails === 0) { peg$fail(peg$e13); }
  24829. }
  24830. if (s5 !== peg$FAILED) {
  24831. peg$savedPos = s0;
  24832. s0 = peg$f13(s3);
  24833. } else {
  24834. peg$currPos = s0;
  24835. s0 = peg$FAILED;
  24836. }
  24837. } else {
  24838. peg$currPos = s0;
  24839. s0 = peg$FAILED;
  24840. }
  24841. } else {
  24842. peg$currPos = s0;
  24843. s0 = peg$FAILED;
  24844. }
  24845. }
  24846. }
  24847. }
  24848. }
  24849. }
  24850. return s0;
  24851. }
  24852. function peg$parseRuleReferenceExpression() {
  24853. var s0, s1, s2, s3, s4, s5, s6, s7;
  24854. s0 = peg$currPos;
  24855. s1 = peg$parseIdentifierName();
  24856. if (s1 !== peg$FAILED) {
  24857. s2 = peg$currPos;
  24858. peg$silentFails++;
  24859. s3 = peg$currPos;
  24860. s4 = peg$parse__();
  24861. s5 = peg$currPos;
  24862. s6 = peg$parseStringLiteral();
  24863. if (s6 !== peg$FAILED) {
  24864. s7 = peg$parse__();
  24865. s6 = [s6, s7];
  24866. s5 = s6;
  24867. } else {
  24868. peg$currPos = s5;
  24869. s5 = peg$FAILED;
  24870. }
  24871. if (s5 === peg$FAILED) {
  24872. s5 = null;
  24873. }
  24874. if (input.charCodeAt(peg$currPos) === 61) {
  24875. s6 = peg$c2;
  24876. peg$currPos++;
  24877. } else {
  24878. s6 = peg$FAILED;
  24879. if (peg$silentFails === 0) { peg$fail(peg$e2); }
  24880. }
  24881. if (s6 !== peg$FAILED) {
  24882. s4 = [s4, s5, s6];
  24883. s3 = s4;
  24884. } else {
  24885. peg$currPos = s3;
  24886. s3 = peg$FAILED;
  24887. }
  24888. peg$silentFails--;
  24889. if (s3 === peg$FAILED) {
  24890. s2 = undefined;
  24891. } else {
  24892. peg$currPos = s2;
  24893. s2 = peg$FAILED;
  24894. }
  24895. if (s2 !== peg$FAILED) {
  24896. peg$savedPos = s0;
  24897. s0 = peg$f14(s1);
  24898. } else {
  24899. peg$currPos = s0;
  24900. s0 = peg$FAILED;
  24901. }
  24902. } else {
  24903. peg$currPos = s0;
  24904. s0 = peg$FAILED;
  24905. }
  24906. return s0;
  24907. }
  24908. function peg$parseSemanticPredicateExpression() {
  24909. var s0, s1, s2, s3;
  24910. s0 = peg$currPos;
  24911. s1 = peg$parseSemanticPredicateOperator();
  24912. if (s1 !== peg$FAILED) {
  24913. s2 = peg$parse__();
  24914. s3 = peg$parseCodeBlock();
  24915. if (s3 !== peg$FAILED) {
  24916. peg$savedPos = s0;
  24917. s0 = peg$f15(s1, s3);
  24918. } else {
  24919. peg$currPos = s0;
  24920. s0 = peg$FAILED;
  24921. }
  24922. } else {
  24923. peg$currPos = s0;
  24924. s0 = peg$FAILED;
  24925. }
  24926. return s0;
  24927. }
  24928. function peg$parseSemanticPredicateOperator() {
  24929. var s0;
  24930. if (input.charCodeAt(peg$currPos) === 38) {
  24931. s0 = peg$c7;
  24932. peg$currPos++;
  24933. } else {
  24934. s0 = peg$FAILED;
  24935. if (peg$silentFails === 0) { peg$fail(peg$e7); }
  24936. }
  24937. if (s0 === peg$FAILED) {
  24938. if (input.charCodeAt(peg$currPos) === 33) {
  24939. s0 = peg$c8;
  24940. peg$currPos++;
  24941. } else {
  24942. s0 = peg$FAILED;
  24943. if (peg$silentFails === 0) { peg$fail(peg$e8); }
  24944. }
  24945. }
  24946. return s0;
  24947. }
  24948. function peg$parseSourceCharacter() {
  24949. var s0;
  24950. if (input.length > peg$currPos) {
  24951. s0 = input.charAt(peg$currPos);
  24952. peg$currPos++;
  24953. } else {
  24954. s0 = peg$FAILED;
  24955. if (peg$silentFails === 0) { peg$fail(peg$e14); }
  24956. }
  24957. return s0;
  24958. }
  24959. function peg$parseWhiteSpace() {
  24960. var s0, s1;
  24961. peg$silentFails++;
  24962. if (input.charCodeAt(peg$currPos) === 9) {
  24963. s0 = peg$c14;
  24964. peg$currPos++;
  24965. } else {
  24966. s0 = peg$FAILED;
  24967. if (peg$silentFails === 0) { peg$fail(peg$e16); }
  24968. }
  24969. if (s0 === peg$FAILED) {
  24970. if (input.charCodeAt(peg$currPos) === 11) {
  24971. s0 = peg$c15;
  24972. peg$currPos++;
  24973. } else {
  24974. s0 = peg$FAILED;
  24975. if (peg$silentFails === 0) { peg$fail(peg$e17); }
  24976. }
  24977. if (s0 === peg$FAILED) {
  24978. if (input.charCodeAt(peg$currPos) === 12) {
  24979. s0 = peg$c16;
  24980. peg$currPos++;
  24981. } else {
  24982. s0 = peg$FAILED;
  24983. if (peg$silentFails === 0) { peg$fail(peg$e18); }
  24984. }
  24985. if (s0 === peg$FAILED) {
  24986. if (input.charCodeAt(peg$currPos) === 32) {
  24987. s0 = peg$c17;
  24988. peg$currPos++;
  24989. } else {
  24990. s0 = peg$FAILED;
  24991. if (peg$silentFails === 0) { peg$fail(peg$e19); }
  24992. }
  24993. if (s0 === peg$FAILED) {
  24994. if (input.charCodeAt(peg$currPos) === 160) {
  24995. s0 = peg$c18;
  24996. peg$currPos++;
  24997. } else {
  24998. s0 = peg$FAILED;
  24999. if (peg$silentFails === 0) { peg$fail(peg$e20); }
  25000. }
  25001. if (s0 === peg$FAILED) {
  25002. if (input.charCodeAt(peg$currPos) === 65279) {
  25003. s0 = peg$c19;
  25004. peg$currPos++;
  25005. } else {
  25006. s0 = peg$FAILED;
  25007. if (peg$silentFails === 0) { peg$fail(peg$e21); }
  25008. }
  25009. if (s0 === peg$FAILED) {
  25010. s0 = peg$parseZs();
  25011. }
  25012. }
  25013. }
  25014. }
  25015. }
  25016. }
  25017. peg$silentFails--;
  25018. if (s0 === peg$FAILED) {
  25019. s1 = peg$FAILED;
  25020. if (peg$silentFails === 0) { peg$fail(peg$e15); }
  25021. }
  25022. return s0;
  25023. }
  25024. function peg$parseLineTerminator() {
  25025. var s0;
  25026. if (peg$r0.test(input.charAt(peg$currPos))) {
  25027. s0 = input.charAt(peg$currPos);
  25028. peg$currPos++;
  25029. } else {
  25030. s0 = peg$FAILED;
  25031. if (peg$silentFails === 0) { peg$fail(peg$e22); }
  25032. }
  25033. return s0;
  25034. }
  25035. function peg$parseLineTerminatorSequence() {
  25036. var s0, s1;
  25037. peg$silentFails++;
  25038. if (input.charCodeAt(peg$currPos) === 10) {
  25039. s0 = peg$c20;
  25040. peg$currPos++;
  25041. } else {
  25042. s0 = peg$FAILED;
  25043. if (peg$silentFails === 0) { peg$fail(peg$e24); }
  25044. }
  25045. if (s0 === peg$FAILED) {
  25046. if (input.substr(peg$currPos, 2) === peg$c21) {
  25047. s0 = peg$c21;
  25048. peg$currPos += 2;
  25049. } else {
  25050. s0 = peg$FAILED;
  25051. if (peg$silentFails === 0) { peg$fail(peg$e25); }
  25052. }
  25053. if (s0 === peg$FAILED) {
  25054. if (input.charCodeAt(peg$currPos) === 13) {
  25055. s0 = peg$c22;
  25056. peg$currPos++;
  25057. } else {
  25058. s0 = peg$FAILED;
  25059. if (peg$silentFails === 0) { peg$fail(peg$e26); }
  25060. }
  25061. if (s0 === peg$FAILED) {
  25062. if (input.charCodeAt(peg$currPos) === 8232) {
  25063. s0 = peg$c23;
  25064. peg$currPos++;
  25065. } else {
  25066. s0 = peg$FAILED;
  25067. if (peg$silentFails === 0) { peg$fail(peg$e27); }
  25068. }
  25069. if (s0 === peg$FAILED) {
  25070. if (input.charCodeAt(peg$currPos) === 8233) {
  25071. s0 = peg$c24;
  25072. peg$currPos++;
  25073. } else {
  25074. s0 = peg$FAILED;
  25075. if (peg$silentFails === 0) { peg$fail(peg$e28); }
  25076. }
  25077. }
  25078. }
  25079. }
  25080. }
  25081. peg$silentFails--;
  25082. if (s0 === peg$FAILED) {
  25083. s1 = peg$FAILED;
  25084. if (peg$silentFails === 0) { peg$fail(peg$e23); }
  25085. }
  25086. return s0;
  25087. }
  25088. function peg$parseComment() {
  25089. var s0, s1;
  25090. peg$silentFails++;
  25091. s0 = peg$parseMultiLineComment();
  25092. if (s0 === peg$FAILED) {
  25093. s0 = peg$parseSingleLineComment();
  25094. }
  25095. peg$silentFails--;
  25096. if (s0 === peg$FAILED) {
  25097. s1 = peg$FAILED;
  25098. if (peg$silentFails === 0) { peg$fail(peg$e29); }
  25099. }
  25100. return s0;
  25101. }
  25102. function peg$parseMultiLineComment() {
  25103. var s0, s1, s2, s3, s4, s5;
  25104. s0 = peg$currPos;
  25105. if (input.substr(peg$currPos, 2) === peg$c25) {
  25106. s1 = peg$c25;
  25107. peg$currPos += 2;
  25108. } else {
  25109. s1 = peg$FAILED;
  25110. if (peg$silentFails === 0) { peg$fail(peg$e30); }
  25111. }
  25112. if (s1 !== peg$FAILED) {
  25113. s2 = [];
  25114. s3 = peg$currPos;
  25115. s4 = peg$currPos;
  25116. peg$silentFails++;
  25117. if (input.substr(peg$currPos, 2) === peg$c26) {
  25118. s5 = peg$c26;
  25119. peg$currPos += 2;
  25120. } else {
  25121. s5 = peg$FAILED;
  25122. if (peg$silentFails === 0) { peg$fail(peg$e31); }
  25123. }
  25124. peg$silentFails--;
  25125. if (s5 === peg$FAILED) {
  25126. s4 = undefined;
  25127. } else {
  25128. peg$currPos = s4;
  25129. s4 = peg$FAILED;
  25130. }
  25131. if (s4 !== peg$FAILED) {
  25132. s5 = peg$parseSourceCharacter();
  25133. if (s5 !== peg$FAILED) {
  25134. s4 = [s4, s5];
  25135. s3 = s4;
  25136. } else {
  25137. peg$currPos = s3;
  25138. s3 = peg$FAILED;
  25139. }
  25140. } else {
  25141. peg$currPos = s3;
  25142. s3 = peg$FAILED;
  25143. }
  25144. while (s3 !== peg$FAILED) {
  25145. s2.push(s3);
  25146. s3 = peg$currPos;
  25147. s4 = peg$currPos;
  25148. peg$silentFails++;
  25149. if (input.substr(peg$currPos, 2) === peg$c26) {
  25150. s5 = peg$c26;
  25151. peg$currPos += 2;
  25152. } else {
  25153. s5 = peg$FAILED;
  25154. if (peg$silentFails === 0) { peg$fail(peg$e31); }
  25155. }
  25156. peg$silentFails--;
  25157. if (s5 === peg$FAILED) {
  25158. s4 = undefined;
  25159. } else {
  25160. peg$currPos = s4;
  25161. s4 = peg$FAILED;
  25162. }
  25163. if (s4 !== peg$FAILED) {
  25164. s5 = peg$parseSourceCharacter();
  25165. if (s5 !== peg$FAILED) {
  25166. s4 = [s4, s5];
  25167. s3 = s4;
  25168. } else {
  25169. peg$currPos = s3;
  25170. s3 = peg$FAILED;
  25171. }
  25172. } else {
  25173. peg$currPos = s3;
  25174. s3 = peg$FAILED;
  25175. }
  25176. }
  25177. if (input.substr(peg$currPos, 2) === peg$c26) {
  25178. s3 = peg$c26;
  25179. peg$currPos += 2;
  25180. } else {
  25181. s3 = peg$FAILED;
  25182. if (peg$silentFails === 0) { peg$fail(peg$e31); }
  25183. }
  25184. if (s3 !== peg$FAILED) {
  25185. s1 = [s1, s2, s3];
  25186. s0 = s1;
  25187. } else {
  25188. peg$currPos = s0;
  25189. s0 = peg$FAILED;
  25190. }
  25191. } else {
  25192. peg$currPos = s0;
  25193. s0 = peg$FAILED;
  25194. }
  25195. return s0;
  25196. }
  25197. function peg$parseMultiLineCommentNoLineTerminator() {
  25198. var s0, s1, s2, s3, s4, s5;
  25199. s0 = peg$currPos;
  25200. if (input.substr(peg$currPos, 2) === peg$c25) {
  25201. s1 = peg$c25;
  25202. peg$currPos += 2;
  25203. } else {
  25204. s1 = peg$FAILED;
  25205. if (peg$silentFails === 0) { peg$fail(peg$e30); }
  25206. }
  25207. if (s1 !== peg$FAILED) {
  25208. s2 = [];
  25209. s3 = peg$currPos;
  25210. s4 = peg$currPos;
  25211. peg$silentFails++;
  25212. if (input.substr(peg$currPos, 2) === peg$c26) {
  25213. s5 = peg$c26;
  25214. peg$currPos += 2;
  25215. } else {
  25216. s5 = peg$FAILED;
  25217. if (peg$silentFails === 0) { peg$fail(peg$e31); }
  25218. }
  25219. if (s5 === peg$FAILED) {
  25220. s5 = peg$parseLineTerminator();
  25221. }
  25222. peg$silentFails--;
  25223. if (s5 === peg$FAILED) {
  25224. s4 = undefined;
  25225. } else {
  25226. peg$currPos = s4;
  25227. s4 = peg$FAILED;
  25228. }
  25229. if (s4 !== peg$FAILED) {
  25230. s5 = peg$parseSourceCharacter();
  25231. if (s5 !== peg$FAILED) {
  25232. s4 = [s4, s5];
  25233. s3 = s4;
  25234. } else {
  25235. peg$currPos = s3;
  25236. s3 = peg$FAILED;
  25237. }
  25238. } else {
  25239. peg$currPos = s3;
  25240. s3 = peg$FAILED;
  25241. }
  25242. while (s3 !== peg$FAILED) {
  25243. s2.push(s3);
  25244. s3 = peg$currPos;
  25245. s4 = peg$currPos;
  25246. peg$silentFails++;
  25247. if (input.substr(peg$currPos, 2) === peg$c26) {
  25248. s5 = peg$c26;
  25249. peg$currPos += 2;
  25250. } else {
  25251. s5 = peg$FAILED;
  25252. if (peg$silentFails === 0) { peg$fail(peg$e31); }
  25253. }
  25254. if (s5 === peg$FAILED) {
  25255. s5 = peg$parseLineTerminator();
  25256. }
  25257. peg$silentFails--;
  25258. if (s5 === peg$FAILED) {
  25259. s4 = undefined;
  25260. } else {
  25261. peg$currPos = s4;
  25262. s4 = peg$FAILED;
  25263. }
  25264. if (s4 !== peg$FAILED) {
  25265. s5 = peg$parseSourceCharacter();
  25266. if (s5 !== peg$FAILED) {
  25267. s4 = [s4, s5];
  25268. s3 = s4;
  25269. } else {
  25270. peg$currPos = s3;
  25271. s3 = peg$FAILED;
  25272. }
  25273. } else {
  25274. peg$currPos = s3;
  25275. s3 = peg$FAILED;
  25276. }
  25277. }
  25278. if (input.substr(peg$currPos, 2) === peg$c26) {
  25279. s3 = peg$c26;
  25280. peg$currPos += 2;
  25281. } else {
  25282. s3 = peg$FAILED;
  25283. if (peg$silentFails === 0) { peg$fail(peg$e31); }
  25284. }
  25285. if (s3 !== peg$FAILED) {
  25286. s1 = [s1, s2, s3];
  25287. s0 = s1;
  25288. } else {
  25289. peg$currPos = s0;
  25290. s0 = peg$FAILED;
  25291. }
  25292. } else {
  25293. peg$currPos = s0;
  25294. s0 = peg$FAILED;
  25295. }
  25296. return s0;
  25297. }
  25298. function peg$parseSingleLineComment() {
  25299. var s0, s1, s2, s3, s4, s5;
  25300. s0 = peg$currPos;
  25301. if (input.substr(peg$currPos, 2) === peg$c27) {
  25302. s1 = peg$c27;
  25303. peg$currPos += 2;
  25304. } else {
  25305. s1 = peg$FAILED;
  25306. if (peg$silentFails === 0) { peg$fail(peg$e32); }
  25307. }
  25308. if (s1 !== peg$FAILED) {
  25309. s2 = [];
  25310. s3 = peg$currPos;
  25311. s4 = peg$currPos;
  25312. peg$silentFails++;
  25313. s5 = peg$parseLineTerminator();
  25314. peg$silentFails--;
  25315. if (s5 === peg$FAILED) {
  25316. s4 = undefined;
  25317. } else {
  25318. peg$currPos = s4;
  25319. s4 = peg$FAILED;
  25320. }
  25321. if (s4 !== peg$FAILED) {
  25322. s5 = peg$parseSourceCharacter();
  25323. if (s5 !== peg$FAILED) {
  25324. s4 = [s4, s5];
  25325. s3 = s4;
  25326. } else {
  25327. peg$currPos = s3;
  25328. s3 = peg$FAILED;
  25329. }
  25330. } else {
  25331. peg$currPos = s3;
  25332. s3 = peg$FAILED;
  25333. }
  25334. while (s3 !== peg$FAILED) {
  25335. s2.push(s3);
  25336. s3 = peg$currPos;
  25337. s4 = peg$currPos;
  25338. peg$silentFails++;
  25339. s5 = peg$parseLineTerminator();
  25340. peg$silentFails--;
  25341. if (s5 === peg$FAILED) {
  25342. s4 = undefined;
  25343. } else {
  25344. peg$currPos = s4;
  25345. s4 = peg$FAILED;
  25346. }
  25347. if (s4 !== peg$FAILED) {
  25348. s5 = peg$parseSourceCharacter();
  25349. if (s5 !== peg$FAILED) {
  25350. s4 = [s4, s5];
  25351. s3 = s4;
  25352. } else {
  25353. peg$currPos = s3;
  25354. s3 = peg$FAILED;
  25355. }
  25356. } else {
  25357. peg$currPos = s3;
  25358. s3 = peg$FAILED;
  25359. }
  25360. }
  25361. s1 = [s1, s2];
  25362. s0 = s1;
  25363. } else {
  25364. peg$currPos = s0;
  25365. s0 = peg$FAILED;
  25366. }
  25367. return s0;
  25368. }
  25369. function peg$parseIdentifierName() {
  25370. var s0, s1, s2, s3;
  25371. peg$silentFails++;
  25372. s0 = peg$currPos;
  25373. s1 = peg$parseIdentifierStart();
  25374. if (s1 !== peg$FAILED) {
  25375. s2 = [];
  25376. s3 = peg$parseIdentifierPart();
  25377. while (s3 !== peg$FAILED) {
  25378. s2.push(s3);
  25379. s3 = peg$parseIdentifierPart();
  25380. }
  25381. peg$savedPos = s0;
  25382. s0 = peg$f16(s1, s2);
  25383. } else {
  25384. peg$currPos = s0;
  25385. s0 = peg$FAILED;
  25386. }
  25387. peg$silentFails--;
  25388. if (s0 === peg$FAILED) {
  25389. s1 = peg$FAILED;
  25390. if (peg$silentFails === 0) { peg$fail(peg$e33); }
  25391. }
  25392. return s0;
  25393. }
  25394. function peg$parseIdentifierStart() {
  25395. var s0, s1, s2;
  25396. s0 = peg$parseUnicodeLetter();
  25397. if (s0 === peg$FAILED) {
  25398. if (input.charCodeAt(peg$currPos) === 36) {
  25399. s0 = peg$c6;
  25400. peg$currPos++;
  25401. } else {
  25402. s0 = peg$FAILED;
  25403. if (peg$silentFails === 0) { peg$fail(peg$e6); }
  25404. }
  25405. if (s0 === peg$FAILED) {
  25406. if (input.charCodeAt(peg$currPos) === 95) {
  25407. s0 = peg$c28;
  25408. peg$currPos++;
  25409. } else {
  25410. s0 = peg$FAILED;
  25411. if (peg$silentFails === 0) { peg$fail(peg$e34); }
  25412. }
  25413. if (s0 === peg$FAILED) {
  25414. s0 = peg$currPos;
  25415. if (input.charCodeAt(peg$currPos) === 92) {
  25416. s1 = peg$c29;
  25417. peg$currPos++;
  25418. } else {
  25419. s1 = peg$FAILED;
  25420. if (peg$silentFails === 0) { peg$fail(peg$e35); }
  25421. }
  25422. if (s1 !== peg$FAILED) {
  25423. s2 = peg$parseUnicodeEscapeSequence();
  25424. if (s2 !== peg$FAILED) {
  25425. s0 = s2;
  25426. } else {
  25427. peg$currPos = s0;
  25428. s0 = peg$FAILED;
  25429. }
  25430. } else {
  25431. peg$currPos = s0;
  25432. s0 = peg$FAILED;
  25433. }
  25434. }
  25435. }
  25436. }
  25437. return s0;
  25438. }
  25439. function peg$parseIdentifierPart() {
  25440. var s0;
  25441. s0 = peg$parseIdentifierStart();
  25442. if (s0 === peg$FAILED) {
  25443. s0 = peg$parseUnicodeCombiningMark();
  25444. if (s0 === peg$FAILED) {
  25445. s0 = peg$parseNd();
  25446. if (s0 === peg$FAILED) {
  25447. s0 = peg$parsePc();
  25448. if (s0 === peg$FAILED) {
  25449. if (input.charCodeAt(peg$currPos) === 8204) {
  25450. s0 = peg$c30;
  25451. peg$currPos++;
  25452. } else {
  25453. s0 = peg$FAILED;
  25454. if (peg$silentFails === 0) { peg$fail(peg$e36); }
  25455. }
  25456. if (s0 === peg$FAILED) {
  25457. if (input.charCodeAt(peg$currPos) === 8205) {
  25458. s0 = peg$c31;
  25459. peg$currPos++;
  25460. } else {
  25461. s0 = peg$FAILED;
  25462. if (peg$silentFails === 0) { peg$fail(peg$e37); }
  25463. }
  25464. }
  25465. }
  25466. }
  25467. }
  25468. }
  25469. return s0;
  25470. }
  25471. function peg$parseUnicodeLetter() {
  25472. var s0;
  25473. s0 = peg$parseLu();
  25474. if (s0 === peg$FAILED) {
  25475. s0 = peg$parseLl();
  25476. if (s0 === peg$FAILED) {
  25477. s0 = peg$parseLt();
  25478. if (s0 === peg$FAILED) {
  25479. s0 = peg$parseLm();
  25480. if (s0 === peg$FAILED) {
  25481. s0 = peg$parseLo();
  25482. if (s0 === peg$FAILED) {
  25483. s0 = peg$parseNl();
  25484. }
  25485. }
  25486. }
  25487. }
  25488. }
  25489. return s0;
  25490. }
  25491. function peg$parseUnicodeCombiningMark() {
  25492. var s0;
  25493. s0 = peg$parseMn();
  25494. if (s0 === peg$FAILED) {
  25495. s0 = peg$parseMc();
  25496. }
  25497. return s0;
  25498. }
  25499. function peg$parseLiteralMatcher() {
  25500. var s0, s1, s2;
  25501. peg$silentFails++;
  25502. s0 = peg$currPos;
  25503. s1 = peg$parseStringLiteral();
  25504. if (s1 !== peg$FAILED) {
  25505. if (input.charCodeAt(peg$currPos) === 105) {
  25506. s2 = peg$c32;
  25507. peg$currPos++;
  25508. } else {
  25509. s2 = peg$FAILED;
  25510. if (peg$silentFails === 0) { peg$fail(peg$e39); }
  25511. }
  25512. if (s2 === peg$FAILED) {
  25513. s2 = null;
  25514. }
  25515. peg$savedPos = s0;
  25516. s0 = peg$f17(s1, s2);
  25517. } else {
  25518. peg$currPos = s0;
  25519. s0 = peg$FAILED;
  25520. }
  25521. peg$silentFails--;
  25522. if (s0 === peg$FAILED) {
  25523. s1 = peg$FAILED;
  25524. if (peg$silentFails === 0) { peg$fail(peg$e38); }
  25525. }
  25526. return s0;
  25527. }
  25528. function peg$parseStringLiteral() {
  25529. var s0, s1, s2, s3;
  25530. peg$silentFails++;
  25531. s0 = peg$currPos;
  25532. if (input.charCodeAt(peg$currPos) === 34) {
  25533. s1 = peg$c33;
  25534. peg$currPos++;
  25535. } else {
  25536. s1 = peg$FAILED;
  25537. if (peg$silentFails === 0) { peg$fail(peg$e41); }
  25538. }
  25539. if (s1 !== peg$FAILED) {
  25540. s2 = [];
  25541. s3 = peg$parseDoubleStringCharacter();
  25542. while (s3 !== peg$FAILED) {
  25543. s2.push(s3);
  25544. s3 = peg$parseDoubleStringCharacter();
  25545. }
  25546. if (input.charCodeAt(peg$currPos) === 34) {
  25547. s3 = peg$c33;
  25548. peg$currPos++;
  25549. } else {
  25550. s3 = peg$FAILED;
  25551. if (peg$silentFails === 0) { peg$fail(peg$e41); }
  25552. }
  25553. if (s3 !== peg$FAILED) {
  25554. peg$savedPos = s0;
  25555. s0 = peg$f18(s2);
  25556. } else {
  25557. peg$currPos = s0;
  25558. s0 = peg$FAILED;
  25559. }
  25560. } else {
  25561. peg$currPos = s0;
  25562. s0 = peg$FAILED;
  25563. }
  25564. if (s0 === peg$FAILED) {
  25565. s0 = peg$currPos;
  25566. if (input.charCodeAt(peg$currPos) === 39) {
  25567. s1 = peg$c34;
  25568. peg$currPos++;
  25569. } else {
  25570. s1 = peg$FAILED;
  25571. if (peg$silentFails === 0) { peg$fail(peg$e42); }
  25572. }
  25573. if (s1 !== peg$FAILED) {
  25574. s2 = [];
  25575. s3 = peg$parseSingleStringCharacter();
  25576. while (s3 !== peg$FAILED) {
  25577. s2.push(s3);
  25578. s3 = peg$parseSingleStringCharacter();
  25579. }
  25580. if (input.charCodeAt(peg$currPos) === 39) {
  25581. s3 = peg$c34;
  25582. peg$currPos++;
  25583. } else {
  25584. s3 = peg$FAILED;
  25585. if (peg$silentFails === 0) { peg$fail(peg$e42); }
  25586. }
  25587. if (s3 !== peg$FAILED) {
  25588. peg$savedPos = s0;
  25589. s0 = peg$f18(s2);
  25590. } else {
  25591. peg$currPos = s0;
  25592. s0 = peg$FAILED;
  25593. }
  25594. } else {
  25595. peg$currPos = s0;
  25596. s0 = peg$FAILED;
  25597. }
  25598. }
  25599. peg$silentFails--;
  25600. if (s0 === peg$FAILED) {
  25601. s1 = peg$FAILED;
  25602. if (peg$silentFails === 0) { peg$fail(peg$e40); }
  25603. }
  25604. return s0;
  25605. }
  25606. function peg$parseDoubleStringCharacter() {
  25607. var s0, s1, s2, s3;
  25608. s0 = peg$currPos;
  25609. s1 = peg$currPos;
  25610. s2 = peg$currPos;
  25611. peg$silentFails++;
  25612. if (input.charCodeAt(peg$currPos) === 34) {
  25613. s3 = peg$c33;
  25614. peg$currPos++;
  25615. } else {
  25616. s3 = peg$FAILED;
  25617. if (peg$silentFails === 0) { peg$fail(peg$e41); }
  25618. }
  25619. if (s3 === peg$FAILED) {
  25620. if (input.charCodeAt(peg$currPos) === 92) {
  25621. s3 = peg$c29;
  25622. peg$currPos++;
  25623. } else {
  25624. s3 = peg$FAILED;
  25625. if (peg$silentFails === 0) { peg$fail(peg$e35); }
  25626. }
  25627. if (s3 === peg$FAILED) {
  25628. s3 = peg$parseLineTerminator();
  25629. }
  25630. }
  25631. peg$silentFails--;
  25632. if (s3 === peg$FAILED) {
  25633. s2 = undefined;
  25634. } else {
  25635. peg$currPos = s2;
  25636. s2 = peg$FAILED;
  25637. }
  25638. if (s2 !== peg$FAILED) {
  25639. s3 = peg$parseSourceCharacter();
  25640. if (s3 !== peg$FAILED) {
  25641. s2 = [s2, s3];
  25642. s1 = s2;
  25643. } else {
  25644. peg$currPos = s1;
  25645. s1 = peg$FAILED;
  25646. }
  25647. } else {
  25648. peg$currPos = s1;
  25649. s1 = peg$FAILED;
  25650. }
  25651. if (s1 !== peg$FAILED) {
  25652. s0 = input.substring(s0, peg$currPos);
  25653. } else {
  25654. s0 = s1;
  25655. }
  25656. if (s0 === peg$FAILED) {
  25657. s0 = peg$currPos;
  25658. if (input.charCodeAt(peg$currPos) === 92) {
  25659. s1 = peg$c29;
  25660. peg$currPos++;
  25661. } else {
  25662. s1 = peg$FAILED;
  25663. if (peg$silentFails === 0) { peg$fail(peg$e35); }
  25664. }
  25665. if (s1 !== peg$FAILED) {
  25666. s2 = peg$parseEscapeSequence();
  25667. if (s2 !== peg$FAILED) {
  25668. s0 = s2;
  25669. } else {
  25670. peg$currPos = s0;
  25671. s0 = peg$FAILED;
  25672. }
  25673. } else {
  25674. peg$currPos = s0;
  25675. s0 = peg$FAILED;
  25676. }
  25677. if (s0 === peg$FAILED) {
  25678. s0 = peg$parseLineContinuation();
  25679. }
  25680. }
  25681. return s0;
  25682. }
  25683. function peg$parseSingleStringCharacter() {
  25684. var s0, s1, s2, s3;
  25685. s0 = peg$currPos;
  25686. s1 = peg$currPos;
  25687. s2 = peg$currPos;
  25688. peg$silentFails++;
  25689. if (input.charCodeAt(peg$currPos) === 39) {
  25690. s3 = peg$c34;
  25691. peg$currPos++;
  25692. } else {
  25693. s3 = peg$FAILED;
  25694. if (peg$silentFails === 0) { peg$fail(peg$e42); }
  25695. }
  25696. if (s3 === peg$FAILED) {
  25697. if (input.charCodeAt(peg$currPos) === 92) {
  25698. s3 = peg$c29;
  25699. peg$currPos++;
  25700. } else {
  25701. s3 = peg$FAILED;
  25702. if (peg$silentFails === 0) { peg$fail(peg$e35); }
  25703. }
  25704. if (s3 === peg$FAILED) {
  25705. s3 = peg$parseLineTerminator();
  25706. }
  25707. }
  25708. peg$silentFails--;
  25709. if (s3 === peg$FAILED) {
  25710. s2 = undefined;
  25711. } else {
  25712. peg$currPos = s2;
  25713. s2 = peg$FAILED;
  25714. }
  25715. if (s2 !== peg$FAILED) {
  25716. s3 = peg$parseSourceCharacter();
  25717. if (s3 !== peg$FAILED) {
  25718. s2 = [s2, s3];
  25719. s1 = s2;
  25720. } else {
  25721. peg$currPos = s1;
  25722. s1 = peg$FAILED;
  25723. }
  25724. } else {
  25725. peg$currPos = s1;
  25726. s1 = peg$FAILED;
  25727. }
  25728. if (s1 !== peg$FAILED) {
  25729. s0 = input.substring(s0, peg$currPos);
  25730. } else {
  25731. s0 = s1;
  25732. }
  25733. if (s0 === peg$FAILED) {
  25734. s0 = peg$currPos;
  25735. if (input.charCodeAt(peg$currPos) === 92) {
  25736. s1 = peg$c29;
  25737. peg$currPos++;
  25738. } else {
  25739. s1 = peg$FAILED;
  25740. if (peg$silentFails === 0) { peg$fail(peg$e35); }
  25741. }
  25742. if (s1 !== peg$FAILED) {
  25743. s2 = peg$parseEscapeSequence();
  25744. if (s2 !== peg$FAILED) {
  25745. s0 = s2;
  25746. } else {
  25747. peg$currPos = s0;
  25748. s0 = peg$FAILED;
  25749. }
  25750. } else {
  25751. peg$currPos = s0;
  25752. s0 = peg$FAILED;
  25753. }
  25754. if (s0 === peg$FAILED) {
  25755. s0 = peg$parseLineContinuation();
  25756. }
  25757. }
  25758. return s0;
  25759. }
  25760. function peg$parseCharacterClassMatcher() {
  25761. var s0, s1, s2, s3, s4, s5;
  25762. peg$silentFails++;
  25763. s0 = peg$currPos;
  25764. if (input.charCodeAt(peg$currPos) === 91) {
  25765. s1 = peg$c35;
  25766. peg$currPos++;
  25767. } else {
  25768. s1 = peg$FAILED;
  25769. if (peg$silentFails === 0) { peg$fail(peg$e44); }
  25770. }
  25771. if (s1 !== peg$FAILED) {
  25772. if (input.charCodeAt(peg$currPos) === 94) {
  25773. s2 = peg$c36;
  25774. peg$currPos++;
  25775. } else {
  25776. s2 = peg$FAILED;
  25777. if (peg$silentFails === 0) { peg$fail(peg$e45); }
  25778. }
  25779. if (s2 === peg$FAILED) {
  25780. s2 = null;
  25781. }
  25782. s3 = [];
  25783. s4 = peg$parseClassCharacterRange();
  25784. if (s4 === peg$FAILED) {
  25785. s4 = peg$parseClassCharacter();
  25786. }
  25787. while (s4 !== peg$FAILED) {
  25788. s3.push(s4);
  25789. s4 = peg$parseClassCharacterRange();
  25790. if (s4 === peg$FAILED) {
  25791. s4 = peg$parseClassCharacter();
  25792. }
  25793. }
  25794. if (input.charCodeAt(peg$currPos) === 93) {
  25795. s4 = peg$c37;
  25796. peg$currPos++;
  25797. } else {
  25798. s4 = peg$FAILED;
  25799. if (peg$silentFails === 0) { peg$fail(peg$e46); }
  25800. }
  25801. if (s4 !== peg$FAILED) {
  25802. if (input.charCodeAt(peg$currPos) === 105) {
  25803. s5 = peg$c32;
  25804. peg$currPos++;
  25805. } else {
  25806. s5 = peg$FAILED;
  25807. if (peg$silentFails === 0) { peg$fail(peg$e39); }
  25808. }
  25809. if (s5 === peg$FAILED) {
  25810. s5 = null;
  25811. }
  25812. peg$savedPos = s0;
  25813. s0 = peg$f19(s2, s3, s5);
  25814. } else {
  25815. peg$currPos = s0;
  25816. s0 = peg$FAILED;
  25817. }
  25818. } else {
  25819. peg$currPos = s0;
  25820. s0 = peg$FAILED;
  25821. }
  25822. peg$silentFails--;
  25823. if (s0 === peg$FAILED) {
  25824. s1 = peg$FAILED;
  25825. if (peg$silentFails === 0) { peg$fail(peg$e43); }
  25826. }
  25827. return s0;
  25828. }
  25829. function peg$parseClassCharacterRange() {
  25830. var s0, s1, s2, s3;
  25831. s0 = peg$currPos;
  25832. s1 = peg$parseClassCharacter();
  25833. if (s1 !== peg$FAILED) {
  25834. if (input.charCodeAt(peg$currPos) === 45) {
  25835. s2 = peg$c38;
  25836. peg$currPos++;
  25837. } else {
  25838. s2 = peg$FAILED;
  25839. if (peg$silentFails === 0) { peg$fail(peg$e47); }
  25840. }
  25841. if (s2 !== peg$FAILED) {
  25842. s3 = peg$parseClassCharacter();
  25843. if (s3 !== peg$FAILED) {
  25844. peg$savedPos = s0;
  25845. s0 = peg$f20(s1, s3);
  25846. } else {
  25847. peg$currPos = s0;
  25848. s0 = peg$FAILED;
  25849. }
  25850. } else {
  25851. peg$currPos = s0;
  25852. s0 = peg$FAILED;
  25853. }
  25854. } else {
  25855. peg$currPos = s0;
  25856. s0 = peg$FAILED;
  25857. }
  25858. return s0;
  25859. }
  25860. function peg$parseClassCharacter() {
  25861. var s0, s1, s2, s3;
  25862. s0 = peg$currPos;
  25863. s1 = peg$currPos;
  25864. s2 = peg$currPos;
  25865. peg$silentFails++;
  25866. if (input.charCodeAt(peg$currPos) === 93) {
  25867. s3 = peg$c37;
  25868. peg$currPos++;
  25869. } else {
  25870. s3 = peg$FAILED;
  25871. if (peg$silentFails === 0) { peg$fail(peg$e46); }
  25872. }
  25873. if (s3 === peg$FAILED) {
  25874. if (input.charCodeAt(peg$currPos) === 92) {
  25875. s3 = peg$c29;
  25876. peg$currPos++;
  25877. } else {
  25878. s3 = peg$FAILED;
  25879. if (peg$silentFails === 0) { peg$fail(peg$e35); }
  25880. }
  25881. if (s3 === peg$FAILED) {
  25882. s3 = peg$parseLineTerminator();
  25883. }
  25884. }
  25885. peg$silentFails--;
  25886. if (s3 === peg$FAILED) {
  25887. s2 = undefined;
  25888. } else {
  25889. peg$currPos = s2;
  25890. s2 = peg$FAILED;
  25891. }
  25892. if (s2 !== peg$FAILED) {
  25893. s3 = peg$parseSourceCharacter();
  25894. if (s3 !== peg$FAILED) {
  25895. s2 = [s2, s3];
  25896. s1 = s2;
  25897. } else {
  25898. peg$currPos = s1;
  25899. s1 = peg$FAILED;
  25900. }
  25901. } else {
  25902. peg$currPos = s1;
  25903. s1 = peg$FAILED;
  25904. }
  25905. if (s1 !== peg$FAILED) {
  25906. s0 = input.substring(s0, peg$currPos);
  25907. } else {
  25908. s0 = s1;
  25909. }
  25910. if (s0 === peg$FAILED) {
  25911. s0 = peg$currPos;
  25912. if (input.charCodeAt(peg$currPos) === 92) {
  25913. s1 = peg$c29;
  25914. peg$currPos++;
  25915. } else {
  25916. s1 = peg$FAILED;
  25917. if (peg$silentFails === 0) { peg$fail(peg$e35); }
  25918. }
  25919. if (s1 !== peg$FAILED) {
  25920. s2 = peg$parseEscapeSequence();
  25921. if (s2 !== peg$FAILED) {
  25922. s0 = s2;
  25923. } else {
  25924. peg$currPos = s0;
  25925. s0 = peg$FAILED;
  25926. }
  25927. } else {
  25928. peg$currPos = s0;
  25929. s0 = peg$FAILED;
  25930. }
  25931. if (s0 === peg$FAILED) {
  25932. s0 = peg$parseLineContinuation();
  25933. }
  25934. }
  25935. return s0;
  25936. }
  25937. function peg$parseLineContinuation() {
  25938. var s0, s1, s2;
  25939. s0 = peg$currPos;
  25940. if (input.charCodeAt(peg$currPos) === 92) {
  25941. s1 = peg$c29;
  25942. peg$currPos++;
  25943. } else {
  25944. s1 = peg$FAILED;
  25945. if (peg$silentFails === 0) { peg$fail(peg$e35); }
  25946. }
  25947. if (s1 !== peg$FAILED) {
  25948. s2 = peg$parseLineTerminatorSequence();
  25949. if (s2 !== peg$FAILED) {
  25950. peg$savedPos = s0;
  25951. s0 = peg$f21();
  25952. } else {
  25953. peg$currPos = s0;
  25954. s0 = peg$FAILED;
  25955. }
  25956. } else {
  25957. peg$currPos = s0;
  25958. s0 = peg$FAILED;
  25959. }
  25960. return s0;
  25961. }
  25962. function peg$parseEscapeSequence() {
  25963. var s0, s1, s2, s3;
  25964. s0 = peg$parseCharacterEscapeSequence();
  25965. if (s0 === peg$FAILED) {
  25966. s0 = peg$currPos;
  25967. if (input.charCodeAt(peg$currPos) === 48) {
  25968. s1 = peg$c39;
  25969. peg$currPos++;
  25970. } else {
  25971. s1 = peg$FAILED;
  25972. if (peg$silentFails === 0) { peg$fail(peg$e48); }
  25973. }
  25974. if (s1 !== peg$FAILED) {
  25975. s2 = peg$currPos;
  25976. peg$silentFails++;
  25977. s3 = peg$parseDecimalDigit();
  25978. peg$silentFails--;
  25979. if (s3 === peg$FAILED) {
  25980. s2 = undefined;
  25981. } else {
  25982. peg$currPos = s2;
  25983. s2 = peg$FAILED;
  25984. }
  25985. if (s2 !== peg$FAILED) {
  25986. peg$savedPos = s0;
  25987. s0 = peg$f22();
  25988. } else {
  25989. peg$currPos = s0;
  25990. s0 = peg$FAILED;
  25991. }
  25992. } else {
  25993. peg$currPos = s0;
  25994. s0 = peg$FAILED;
  25995. }
  25996. if (s0 === peg$FAILED) {
  25997. s0 = peg$parseHexEscapeSequence();
  25998. if (s0 === peg$FAILED) {
  25999. s0 = peg$parseUnicodeEscapeSequence();
  26000. }
  26001. }
  26002. }
  26003. return s0;
  26004. }
  26005. function peg$parseCharacterEscapeSequence() {
  26006. var s0;
  26007. s0 = peg$parseSingleEscapeCharacter();
  26008. if (s0 === peg$FAILED) {
  26009. s0 = peg$parseNonEscapeCharacter();
  26010. }
  26011. return s0;
  26012. }
  26013. function peg$parseSingleEscapeCharacter() {
  26014. var s0, s1;
  26015. if (input.charCodeAt(peg$currPos) === 39) {
  26016. s0 = peg$c34;
  26017. peg$currPos++;
  26018. } else {
  26019. s0 = peg$FAILED;
  26020. if (peg$silentFails === 0) { peg$fail(peg$e42); }
  26021. }
  26022. if (s0 === peg$FAILED) {
  26023. if (input.charCodeAt(peg$currPos) === 34) {
  26024. s0 = peg$c33;
  26025. peg$currPos++;
  26026. } else {
  26027. s0 = peg$FAILED;
  26028. if (peg$silentFails === 0) { peg$fail(peg$e41); }
  26029. }
  26030. if (s0 === peg$FAILED) {
  26031. if (input.charCodeAt(peg$currPos) === 92) {
  26032. s0 = peg$c29;
  26033. peg$currPos++;
  26034. } else {
  26035. s0 = peg$FAILED;
  26036. if (peg$silentFails === 0) { peg$fail(peg$e35); }
  26037. }
  26038. if (s0 === peg$FAILED) {
  26039. s0 = peg$currPos;
  26040. if (input.charCodeAt(peg$currPos) === 98) {
  26041. s1 = peg$c40;
  26042. peg$currPos++;
  26043. } else {
  26044. s1 = peg$FAILED;
  26045. if (peg$silentFails === 0) { peg$fail(peg$e49); }
  26046. }
  26047. if (s1 !== peg$FAILED) {
  26048. peg$savedPos = s0;
  26049. s1 = peg$f23();
  26050. }
  26051. s0 = s1;
  26052. if (s0 === peg$FAILED) {
  26053. s0 = peg$currPos;
  26054. if (input.charCodeAt(peg$currPos) === 102) {
  26055. s1 = peg$c41;
  26056. peg$currPos++;
  26057. } else {
  26058. s1 = peg$FAILED;
  26059. if (peg$silentFails === 0) { peg$fail(peg$e50); }
  26060. }
  26061. if (s1 !== peg$FAILED) {
  26062. peg$savedPos = s0;
  26063. s1 = peg$f24();
  26064. }
  26065. s0 = s1;
  26066. if (s0 === peg$FAILED) {
  26067. s0 = peg$currPos;
  26068. if (input.charCodeAt(peg$currPos) === 110) {
  26069. s1 = peg$c42;
  26070. peg$currPos++;
  26071. } else {
  26072. s1 = peg$FAILED;
  26073. if (peg$silentFails === 0) { peg$fail(peg$e51); }
  26074. }
  26075. if (s1 !== peg$FAILED) {
  26076. peg$savedPos = s0;
  26077. s1 = peg$f25();
  26078. }
  26079. s0 = s1;
  26080. if (s0 === peg$FAILED) {
  26081. s0 = peg$currPos;
  26082. if (input.charCodeAt(peg$currPos) === 114) {
  26083. s1 = peg$c43;
  26084. peg$currPos++;
  26085. } else {
  26086. s1 = peg$FAILED;
  26087. if (peg$silentFails === 0) { peg$fail(peg$e52); }
  26088. }
  26089. if (s1 !== peg$FAILED) {
  26090. peg$savedPos = s0;
  26091. s1 = peg$f26();
  26092. }
  26093. s0 = s1;
  26094. if (s0 === peg$FAILED) {
  26095. s0 = peg$currPos;
  26096. if (input.charCodeAt(peg$currPos) === 116) {
  26097. s1 = peg$c44;
  26098. peg$currPos++;
  26099. } else {
  26100. s1 = peg$FAILED;
  26101. if (peg$silentFails === 0) { peg$fail(peg$e53); }
  26102. }
  26103. if (s1 !== peg$FAILED) {
  26104. peg$savedPos = s0;
  26105. s1 = peg$f27();
  26106. }
  26107. s0 = s1;
  26108. if (s0 === peg$FAILED) {
  26109. s0 = peg$currPos;
  26110. if (input.charCodeAt(peg$currPos) === 118) {
  26111. s1 = peg$c45;
  26112. peg$currPos++;
  26113. } else {
  26114. s1 = peg$FAILED;
  26115. if (peg$silentFails === 0) { peg$fail(peg$e54); }
  26116. }
  26117. if (s1 !== peg$FAILED) {
  26118. peg$savedPos = s0;
  26119. s1 = peg$f28();
  26120. }
  26121. s0 = s1;
  26122. }
  26123. }
  26124. }
  26125. }
  26126. }
  26127. }
  26128. }
  26129. }
  26130. return s0;
  26131. }
  26132. function peg$parseNonEscapeCharacter() {
  26133. var s0, s1, s2, s3;
  26134. s0 = peg$currPos;
  26135. s1 = peg$currPos;
  26136. s2 = peg$currPos;
  26137. peg$silentFails++;
  26138. s3 = peg$parseEscapeCharacter();
  26139. if (s3 === peg$FAILED) {
  26140. s3 = peg$parseLineTerminator();
  26141. }
  26142. peg$silentFails--;
  26143. if (s3 === peg$FAILED) {
  26144. s2 = undefined;
  26145. } else {
  26146. peg$currPos = s2;
  26147. s2 = peg$FAILED;
  26148. }
  26149. if (s2 !== peg$FAILED) {
  26150. s3 = peg$parseSourceCharacter();
  26151. if (s3 !== peg$FAILED) {
  26152. s2 = [s2, s3];
  26153. s1 = s2;
  26154. } else {
  26155. peg$currPos = s1;
  26156. s1 = peg$FAILED;
  26157. }
  26158. } else {
  26159. peg$currPos = s1;
  26160. s1 = peg$FAILED;
  26161. }
  26162. if (s1 !== peg$FAILED) {
  26163. s0 = input.substring(s0, peg$currPos);
  26164. } else {
  26165. s0 = s1;
  26166. }
  26167. return s0;
  26168. }
  26169. function peg$parseEscapeCharacter() {
  26170. var s0;
  26171. s0 = peg$parseSingleEscapeCharacter();
  26172. if (s0 === peg$FAILED) {
  26173. s0 = peg$parseDecimalDigit();
  26174. if (s0 === peg$FAILED) {
  26175. if (input.charCodeAt(peg$currPos) === 120) {
  26176. s0 = peg$c46;
  26177. peg$currPos++;
  26178. } else {
  26179. s0 = peg$FAILED;
  26180. if (peg$silentFails === 0) { peg$fail(peg$e55); }
  26181. }
  26182. if (s0 === peg$FAILED) {
  26183. if (input.charCodeAt(peg$currPos) === 117) {
  26184. s0 = peg$c47;
  26185. peg$currPos++;
  26186. } else {
  26187. s0 = peg$FAILED;
  26188. if (peg$silentFails === 0) { peg$fail(peg$e56); }
  26189. }
  26190. }
  26191. }
  26192. }
  26193. return s0;
  26194. }
  26195. function peg$parseHexEscapeSequence() {
  26196. var s0, s1, s2, s3, s4, s5;
  26197. s0 = peg$currPos;
  26198. if (input.charCodeAt(peg$currPos) === 120) {
  26199. s1 = peg$c46;
  26200. peg$currPos++;
  26201. } else {
  26202. s1 = peg$FAILED;
  26203. if (peg$silentFails === 0) { peg$fail(peg$e55); }
  26204. }
  26205. if (s1 !== peg$FAILED) {
  26206. s2 = peg$currPos;
  26207. s3 = peg$currPos;
  26208. s4 = peg$parseHexDigit();
  26209. if (s4 !== peg$FAILED) {
  26210. s5 = peg$parseHexDigit();
  26211. if (s5 !== peg$FAILED) {
  26212. s4 = [s4, s5];
  26213. s3 = s4;
  26214. } else {
  26215. peg$currPos = s3;
  26216. s3 = peg$FAILED;
  26217. }
  26218. } else {
  26219. peg$currPos = s3;
  26220. s3 = peg$FAILED;
  26221. }
  26222. if (s3 !== peg$FAILED) {
  26223. s2 = input.substring(s2, peg$currPos);
  26224. } else {
  26225. s2 = s3;
  26226. }
  26227. if (s2 !== peg$FAILED) {
  26228. peg$savedPos = s0;
  26229. s0 = peg$f29(s2);
  26230. } else {
  26231. peg$currPos = s0;
  26232. s0 = peg$FAILED;
  26233. }
  26234. } else {
  26235. peg$currPos = s0;
  26236. s0 = peg$FAILED;
  26237. }
  26238. return s0;
  26239. }
  26240. function peg$parseUnicodeEscapeSequence() {
  26241. var s0, s1, s2, s3, s4, s5, s6, s7;
  26242. s0 = peg$currPos;
  26243. if (input.charCodeAt(peg$currPos) === 117) {
  26244. s1 = peg$c47;
  26245. peg$currPos++;
  26246. } else {
  26247. s1 = peg$FAILED;
  26248. if (peg$silentFails === 0) { peg$fail(peg$e56); }
  26249. }
  26250. if (s1 !== peg$FAILED) {
  26251. s2 = peg$currPos;
  26252. s3 = peg$currPos;
  26253. s4 = peg$parseHexDigit();
  26254. if (s4 !== peg$FAILED) {
  26255. s5 = peg$parseHexDigit();
  26256. if (s5 !== peg$FAILED) {
  26257. s6 = peg$parseHexDigit();
  26258. if (s6 !== peg$FAILED) {
  26259. s7 = peg$parseHexDigit();
  26260. if (s7 !== peg$FAILED) {
  26261. s4 = [s4, s5, s6, s7];
  26262. s3 = s4;
  26263. } else {
  26264. peg$currPos = s3;
  26265. s3 = peg$FAILED;
  26266. }
  26267. } else {
  26268. peg$currPos = s3;
  26269. s3 = peg$FAILED;
  26270. }
  26271. } else {
  26272. peg$currPos = s3;
  26273. s3 = peg$FAILED;
  26274. }
  26275. } else {
  26276. peg$currPos = s3;
  26277. s3 = peg$FAILED;
  26278. }
  26279. if (s3 !== peg$FAILED) {
  26280. s2 = input.substring(s2, peg$currPos);
  26281. } else {
  26282. s2 = s3;
  26283. }
  26284. if (s2 !== peg$FAILED) {
  26285. peg$savedPos = s0;
  26286. s0 = peg$f29(s2);
  26287. } else {
  26288. peg$currPos = s0;
  26289. s0 = peg$FAILED;
  26290. }
  26291. } else {
  26292. peg$currPos = s0;
  26293. s0 = peg$FAILED;
  26294. }
  26295. return s0;
  26296. }
  26297. function peg$parseDecimalDigit() {
  26298. var s0;
  26299. if (peg$r1.test(input.charAt(peg$currPos))) {
  26300. s0 = input.charAt(peg$currPos);
  26301. peg$currPos++;
  26302. } else {
  26303. s0 = peg$FAILED;
  26304. if (peg$silentFails === 0) { peg$fail(peg$e57); }
  26305. }
  26306. return s0;
  26307. }
  26308. function peg$parseHexDigit() {
  26309. var s0;
  26310. if (peg$r2.test(input.charAt(peg$currPos))) {
  26311. s0 = input.charAt(peg$currPos);
  26312. peg$currPos++;
  26313. } else {
  26314. s0 = peg$FAILED;
  26315. if (peg$silentFails === 0) { peg$fail(peg$e58); }
  26316. }
  26317. return s0;
  26318. }
  26319. function peg$parseAnyMatcher() {
  26320. var s0, s1;
  26321. s0 = peg$currPos;
  26322. if (input.charCodeAt(peg$currPos) === 46) {
  26323. s1 = peg$c48;
  26324. peg$currPos++;
  26325. } else {
  26326. s1 = peg$FAILED;
  26327. if (peg$silentFails === 0) { peg$fail(peg$e59); }
  26328. }
  26329. if (s1 !== peg$FAILED) {
  26330. peg$savedPos = s0;
  26331. s1 = peg$f30();
  26332. }
  26333. s0 = s1;
  26334. return s0;
  26335. }
  26336. function peg$parseCodeBlock() {
  26337. var s0, s1, s2, s3;
  26338. peg$silentFails++;
  26339. s0 = peg$currPos;
  26340. if (input.charCodeAt(peg$currPos) === 123) {
  26341. s1 = peg$c0;
  26342. peg$currPos++;
  26343. } else {
  26344. s1 = peg$FAILED;
  26345. if (peg$silentFails === 0) { peg$fail(peg$e0); }
  26346. }
  26347. if (s1 !== peg$FAILED) {
  26348. s2 = peg$parseBareCodeBlock();
  26349. if (input.charCodeAt(peg$currPos) === 125) {
  26350. s3 = peg$c1;
  26351. peg$currPos++;
  26352. } else {
  26353. s3 = peg$FAILED;
  26354. if (peg$silentFails === 0) { peg$fail(peg$e1); }
  26355. }
  26356. if (s3 !== peg$FAILED) {
  26357. s0 = s2;
  26358. } else {
  26359. peg$currPos = s0;
  26360. s0 = peg$FAILED;
  26361. }
  26362. } else {
  26363. peg$currPos = s0;
  26364. s0 = peg$FAILED;
  26365. }
  26366. peg$silentFails--;
  26367. if (s0 === peg$FAILED) {
  26368. s1 = peg$FAILED;
  26369. if (peg$silentFails === 0) { peg$fail(peg$e60); }
  26370. }
  26371. return s0;
  26372. }
  26373. function peg$parseBareCodeBlock() {
  26374. var s0, s1;
  26375. s0 = peg$currPos;
  26376. s1 = peg$parseCode();
  26377. peg$savedPos = s0;
  26378. s1 = peg$f31(s1);
  26379. s0 = s1;
  26380. return s0;
  26381. }
  26382. function peg$parseCode() {
  26383. var s0, s1, s2, s3, s4, s5;
  26384. s0 = peg$currPos;
  26385. s1 = [];
  26386. s2 = [];
  26387. s3 = peg$currPos;
  26388. s4 = peg$currPos;
  26389. peg$silentFails++;
  26390. if (peg$r3.test(input.charAt(peg$currPos))) {
  26391. s5 = input.charAt(peg$currPos);
  26392. peg$currPos++;
  26393. } else {
  26394. s5 = peg$FAILED;
  26395. if (peg$silentFails === 0) { peg$fail(peg$e61); }
  26396. }
  26397. peg$silentFails--;
  26398. if (s5 === peg$FAILED) {
  26399. s4 = undefined;
  26400. } else {
  26401. peg$currPos = s4;
  26402. s4 = peg$FAILED;
  26403. }
  26404. if (s4 !== peg$FAILED) {
  26405. s5 = peg$parseSourceCharacter();
  26406. if (s5 !== peg$FAILED) {
  26407. s4 = [s4, s5];
  26408. s3 = s4;
  26409. } else {
  26410. peg$currPos = s3;
  26411. s3 = peg$FAILED;
  26412. }
  26413. } else {
  26414. peg$currPos = s3;
  26415. s3 = peg$FAILED;
  26416. }
  26417. if (s3 !== peg$FAILED) {
  26418. while (s3 !== peg$FAILED) {
  26419. s2.push(s3);
  26420. s3 = peg$currPos;
  26421. s4 = peg$currPos;
  26422. peg$silentFails++;
  26423. if (peg$r3.test(input.charAt(peg$currPos))) {
  26424. s5 = input.charAt(peg$currPos);
  26425. peg$currPos++;
  26426. } else {
  26427. s5 = peg$FAILED;
  26428. if (peg$silentFails === 0) { peg$fail(peg$e61); }
  26429. }
  26430. peg$silentFails--;
  26431. if (s5 === peg$FAILED) {
  26432. s4 = undefined;
  26433. } else {
  26434. peg$currPos = s4;
  26435. s4 = peg$FAILED;
  26436. }
  26437. if (s4 !== peg$FAILED) {
  26438. s5 = peg$parseSourceCharacter();
  26439. if (s5 !== peg$FAILED) {
  26440. s4 = [s4, s5];
  26441. s3 = s4;
  26442. } else {
  26443. peg$currPos = s3;
  26444. s3 = peg$FAILED;
  26445. }
  26446. } else {
  26447. peg$currPos = s3;
  26448. s3 = peg$FAILED;
  26449. }
  26450. }
  26451. } else {
  26452. s2 = peg$FAILED;
  26453. }
  26454. if (s2 === peg$FAILED) {
  26455. s2 = peg$currPos;
  26456. if (input.charCodeAt(peg$currPos) === 123) {
  26457. s3 = peg$c0;
  26458. peg$currPos++;
  26459. } else {
  26460. s3 = peg$FAILED;
  26461. if (peg$silentFails === 0) { peg$fail(peg$e0); }
  26462. }
  26463. if (s3 !== peg$FAILED) {
  26464. s4 = peg$parseCode();
  26465. if (input.charCodeAt(peg$currPos) === 125) {
  26466. s5 = peg$c1;
  26467. peg$currPos++;
  26468. } else {
  26469. s5 = peg$FAILED;
  26470. if (peg$silentFails === 0) { peg$fail(peg$e1); }
  26471. }
  26472. if (s5 !== peg$FAILED) {
  26473. s3 = [s3, s4, s5];
  26474. s2 = s3;
  26475. } else {
  26476. peg$currPos = s2;
  26477. s2 = peg$FAILED;
  26478. }
  26479. } else {
  26480. peg$currPos = s2;
  26481. s2 = peg$FAILED;
  26482. }
  26483. }
  26484. while (s2 !== peg$FAILED) {
  26485. s1.push(s2);
  26486. s2 = [];
  26487. s3 = peg$currPos;
  26488. s4 = peg$currPos;
  26489. peg$silentFails++;
  26490. if (peg$r3.test(input.charAt(peg$currPos))) {
  26491. s5 = input.charAt(peg$currPos);
  26492. peg$currPos++;
  26493. } else {
  26494. s5 = peg$FAILED;
  26495. if (peg$silentFails === 0) { peg$fail(peg$e61); }
  26496. }
  26497. peg$silentFails--;
  26498. if (s5 === peg$FAILED) {
  26499. s4 = undefined;
  26500. } else {
  26501. peg$currPos = s4;
  26502. s4 = peg$FAILED;
  26503. }
  26504. if (s4 !== peg$FAILED) {
  26505. s5 = peg$parseSourceCharacter();
  26506. if (s5 !== peg$FAILED) {
  26507. s4 = [s4, s5];
  26508. s3 = s4;
  26509. } else {
  26510. peg$currPos = s3;
  26511. s3 = peg$FAILED;
  26512. }
  26513. } else {
  26514. peg$currPos = s3;
  26515. s3 = peg$FAILED;
  26516. }
  26517. if (s3 !== peg$FAILED) {
  26518. while (s3 !== peg$FAILED) {
  26519. s2.push(s3);
  26520. s3 = peg$currPos;
  26521. s4 = peg$currPos;
  26522. peg$silentFails++;
  26523. if (peg$r3.test(input.charAt(peg$currPos))) {
  26524. s5 = input.charAt(peg$currPos);
  26525. peg$currPos++;
  26526. } else {
  26527. s5 = peg$FAILED;
  26528. if (peg$silentFails === 0) { peg$fail(peg$e61); }
  26529. }
  26530. peg$silentFails--;
  26531. if (s5 === peg$FAILED) {
  26532. s4 = undefined;
  26533. } else {
  26534. peg$currPos = s4;
  26535. s4 = peg$FAILED;
  26536. }
  26537. if (s4 !== peg$FAILED) {
  26538. s5 = peg$parseSourceCharacter();
  26539. if (s5 !== peg$FAILED) {
  26540. s4 = [s4, s5];
  26541. s3 = s4;
  26542. } else {
  26543. peg$currPos = s3;
  26544. s3 = peg$FAILED;
  26545. }
  26546. } else {
  26547. peg$currPos = s3;
  26548. s3 = peg$FAILED;
  26549. }
  26550. }
  26551. } else {
  26552. s2 = peg$FAILED;
  26553. }
  26554. if (s2 === peg$FAILED) {
  26555. s2 = peg$currPos;
  26556. if (input.charCodeAt(peg$currPos) === 123) {
  26557. s3 = peg$c0;
  26558. peg$currPos++;
  26559. } else {
  26560. s3 = peg$FAILED;
  26561. if (peg$silentFails === 0) { peg$fail(peg$e0); }
  26562. }
  26563. if (s3 !== peg$FAILED) {
  26564. s4 = peg$parseCode();
  26565. if (input.charCodeAt(peg$currPos) === 125) {
  26566. s5 = peg$c1;
  26567. peg$currPos++;
  26568. } else {
  26569. s5 = peg$FAILED;
  26570. if (peg$silentFails === 0) { peg$fail(peg$e1); }
  26571. }
  26572. if (s5 !== peg$FAILED) {
  26573. s3 = [s3, s4, s5];
  26574. s2 = s3;
  26575. } else {
  26576. peg$currPos = s2;
  26577. s2 = peg$FAILED;
  26578. }
  26579. } else {
  26580. peg$currPos = s2;
  26581. s2 = peg$FAILED;
  26582. }
  26583. }
  26584. }
  26585. s0 = input.substring(s0, peg$currPos);
  26586. return s0;
  26587. }
  26588. function peg$parseLl() {
  26589. var s0;
  26590. if (peg$r4.test(input.charAt(peg$currPos))) {
  26591. s0 = input.charAt(peg$currPos);
  26592. peg$currPos++;
  26593. } else {
  26594. s0 = peg$FAILED;
  26595. if (peg$silentFails === 0) { peg$fail(peg$e62); }
  26596. }
  26597. return s0;
  26598. }
  26599. function peg$parseLm() {
  26600. var s0;
  26601. if (peg$r5.test(input.charAt(peg$currPos))) {
  26602. s0 = input.charAt(peg$currPos);
  26603. peg$currPos++;
  26604. } else {
  26605. s0 = peg$FAILED;
  26606. if (peg$silentFails === 0) { peg$fail(peg$e63); }
  26607. }
  26608. return s0;
  26609. }
  26610. function peg$parseLo() {
  26611. var s0;
  26612. if (peg$r6.test(input.charAt(peg$currPos))) {
  26613. s0 = input.charAt(peg$currPos);
  26614. peg$currPos++;
  26615. } else {
  26616. s0 = peg$FAILED;
  26617. if (peg$silentFails === 0) { peg$fail(peg$e64); }
  26618. }
  26619. return s0;
  26620. }
  26621. function peg$parseLt() {
  26622. var s0;
  26623. if (peg$r7.test(input.charAt(peg$currPos))) {
  26624. s0 = input.charAt(peg$currPos);
  26625. peg$currPos++;
  26626. } else {
  26627. s0 = peg$FAILED;
  26628. if (peg$silentFails === 0) { peg$fail(peg$e65); }
  26629. }
  26630. return s0;
  26631. }
  26632. function peg$parseLu() {
  26633. var s0;
  26634. if (peg$r8.test(input.charAt(peg$currPos))) {
  26635. s0 = input.charAt(peg$currPos);
  26636. peg$currPos++;
  26637. } else {
  26638. s0 = peg$FAILED;
  26639. if (peg$silentFails === 0) { peg$fail(peg$e66); }
  26640. }
  26641. return s0;
  26642. }
  26643. function peg$parseMc() {
  26644. var s0;
  26645. if (peg$r9.test(input.charAt(peg$currPos))) {
  26646. s0 = input.charAt(peg$currPos);
  26647. peg$currPos++;
  26648. } else {
  26649. s0 = peg$FAILED;
  26650. if (peg$silentFails === 0) { peg$fail(peg$e67); }
  26651. }
  26652. return s0;
  26653. }
  26654. function peg$parseMn() {
  26655. var s0;
  26656. if (peg$r10.test(input.charAt(peg$currPos))) {
  26657. s0 = input.charAt(peg$currPos);
  26658. peg$currPos++;
  26659. } else {
  26660. s0 = peg$FAILED;
  26661. if (peg$silentFails === 0) { peg$fail(peg$e68); }
  26662. }
  26663. return s0;
  26664. }
  26665. function peg$parseNd() {
  26666. var s0;
  26667. if (peg$r11.test(input.charAt(peg$currPos))) {
  26668. s0 = input.charAt(peg$currPos);
  26669. peg$currPos++;
  26670. } else {
  26671. s0 = peg$FAILED;
  26672. if (peg$silentFails === 0) { peg$fail(peg$e69); }
  26673. }
  26674. return s0;
  26675. }
  26676. function peg$parseNl() {
  26677. var s0;
  26678. if (peg$r12.test(input.charAt(peg$currPos))) {
  26679. s0 = input.charAt(peg$currPos);
  26680. peg$currPos++;
  26681. } else {
  26682. s0 = peg$FAILED;
  26683. if (peg$silentFails === 0) { peg$fail(peg$e70); }
  26684. }
  26685. return s0;
  26686. }
  26687. function peg$parsePc() {
  26688. var s0;
  26689. if (peg$r13.test(input.charAt(peg$currPos))) {
  26690. s0 = input.charAt(peg$currPos);
  26691. peg$currPos++;
  26692. } else {
  26693. s0 = peg$FAILED;
  26694. if (peg$silentFails === 0) { peg$fail(peg$e71); }
  26695. }
  26696. return s0;
  26697. }
  26698. function peg$parseZs() {
  26699. var s0;
  26700. if (peg$r14.test(input.charAt(peg$currPos))) {
  26701. s0 = input.charAt(peg$currPos);
  26702. peg$currPos++;
  26703. } else {
  26704. s0 = peg$FAILED;
  26705. if (peg$silentFails === 0) { peg$fail(peg$e72); }
  26706. }
  26707. return s0;
  26708. }
  26709. function peg$parse__() {
  26710. var s0, s1;
  26711. s0 = [];
  26712. s1 = peg$parseWhiteSpace();
  26713. if (s1 === peg$FAILED) {
  26714. s1 = peg$parseLineTerminatorSequence();
  26715. if (s1 === peg$FAILED) {
  26716. s1 = peg$parseComment();
  26717. }
  26718. }
  26719. while (s1 !== peg$FAILED) {
  26720. s0.push(s1);
  26721. s1 = peg$parseWhiteSpace();
  26722. if (s1 === peg$FAILED) {
  26723. s1 = peg$parseLineTerminatorSequence();
  26724. if (s1 === peg$FAILED) {
  26725. s1 = peg$parseComment();
  26726. }
  26727. }
  26728. }
  26729. return s0;
  26730. }
  26731. function peg$parse_() {
  26732. var s0, s1;
  26733. s0 = [];
  26734. s1 = peg$parseWhiteSpace();
  26735. if (s1 === peg$FAILED) {
  26736. s1 = peg$parseMultiLineCommentNoLineTerminator();
  26737. }
  26738. while (s1 !== peg$FAILED) {
  26739. s0.push(s1);
  26740. s1 = peg$parseWhiteSpace();
  26741. if (s1 === peg$FAILED) {
  26742. s1 = peg$parseMultiLineCommentNoLineTerminator();
  26743. }
  26744. }
  26745. return s0;
  26746. }
  26747. function peg$parseEOS() {
  26748. var s0, s1, s2, s3;
  26749. s0 = peg$currPos;
  26750. s1 = peg$parse__();
  26751. if (input.charCodeAt(peg$currPos) === 59) {
  26752. s2 = peg$c49;
  26753. peg$currPos++;
  26754. } else {
  26755. s2 = peg$FAILED;
  26756. if (peg$silentFails === 0) { peg$fail(peg$e73); }
  26757. }
  26758. if (s2 !== peg$FAILED) {
  26759. s1 = [s1, s2];
  26760. s0 = s1;
  26761. } else {
  26762. peg$currPos = s0;
  26763. s0 = peg$FAILED;
  26764. }
  26765. if (s0 === peg$FAILED) {
  26766. s0 = peg$currPos;
  26767. s1 = peg$parse_();
  26768. s2 = peg$parseSingleLineComment();
  26769. if (s2 === peg$FAILED) {
  26770. s2 = null;
  26771. }
  26772. s3 = peg$parseLineTerminatorSequence();
  26773. if (s3 !== peg$FAILED) {
  26774. s1 = [s1, s2, s3];
  26775. s0 = s1;
  26776. } else {
  26777. peg$currPos = s0;
  26778. s0 = peg$FAILED;
  26779. }
  26780. if (s0 === peg$FAILED) {
  26781. s0 = peg$currPos;
  26782. s1 = peg$parse__();
  26783. s2 = peg$parseEOF();
  26784. if (s2 !== peg$FAILED) {
  26785. s1 = [s1, s2];
  26786. s0 = s1;
  26787. } else {
  26788. peg$currPos = s0;
  26789. s0 = peg$FAILED;
  26790. }
  26791. }
  26792. }
  26793. return s0;
  26794. }
  26795. function peg$parseEOF() {
  26796. var s0, s1;
  26797. s0 = peg$currPos;
  26798. peg$silentFails++;
  26799. if (input.length > peg$currPos) {
  26800. s1 = input.charAt(peg$currPos);
  26801. peg$currPos++;
  26802. } else {
  26803. s1 = peg$FAILED;
  26804. if (peg$silentFails === 0) { peg$fail(peg$e14); }
  26805. }
  26806. peg$silentFails--;
  26807. if (s1 === peg$FAILED) {
  26808. s0 = undefined;
  26809. } else {
  26810. peg$currPos = s0;
  26811. s0 = peg$FAILED;
  26812. }
  26813. return s0;
  26814. }
  26815. // Cannot use Set here because of native IE support.
  26816. const reservedWords = options.reservedWords || [];
  26817. peg$result = peg$startRuleFunction();
  26818. if (peg$result !== peg$FAILED && peg$currPos === input.length) {
  26819. return peg$result;
  26820. } else {
  26821. if (peg$result !== peg$FAILED && peg$currPos < input.length) {
  26822. peg$fail(peg$endExpectation());
  26823. }
  26824. throw peg$buildStructuredError(
  26825. peg$maxFailExpected,
  26826. peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
  26827. peg$maxFailPos < input.length
  26828. ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
  26829. : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
  26830. );
  26831. }
  26832. }
  26833. module.exports = {
  26834. SyntaxError: peg$SyntaxError,
  26835. parse: peg$parse
  26836. };
  26837. /***/ }),
  26838. /***/ 4193:
  26839. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  26840. "use strict";
  26841. const GrammarError = __webpack_require__(94297);
  26842. const compiler = __webpack_require__(79203);
  26843. const parser = __webpack_require__(80170);
  26844. const VERSION = __webpack_require__(80244);
  26845. const RESERVED_WORDS = [
  26846. // Reserved keywords as of ECMAScript 2015
  26847. "break",
  26848. "case",
  26849. "catch",
  26850. "class",
  26851. "const",
  26852. "continue",
  26853. "debugger",
  26854. "default",
  26855. "delete",
  26856. "do",
  26857. "else",
  26858. "export",
  26859. "extends",
  26860. "finally",
  26861. "for",
  26862. "function",
  26863. "if",
  26864. "import",
  26865. "in",
  26866. "instanceof",
  26867. "new",
  26868. "return",
  26869. "super",
  26870. "switch",
  26871. "this",
  26872. "throw",
  26873. "try",
  26874. "typeof",
  26875. "var",
  26876. "void",
  26877. "while",
  26878. "with",
  26879. // "yield", // encountered twice on the web page
  26880. // Special constants
  26881. "null",
  26882. "true",
  26883. "false",
  26884. // These are always reserved:
  26885. "enum",
  26886. // The following are only reserved when they are found in strict mode code
  26887. // Peggy generates code in strictly mode, so it applicable to it
  26888. "implements",
  26889. "interface",
  26890. "let",
  26891. "package",
  26892. "private",
  26893. "protected",
  26894. "public",
  26895. "static",
  26896. "yield",
  26897. // The following are only reserved when they are found in module code:
  26898. "await"
  26899. ];
  26900. const peg = {
  26901. // Peggy version (filled in by /tools/release).
  26902. VERSION,
  26903. /**
  26904. * Default list of reserved words. Contains list of currently and future
  26905. * JavaScript (ECMAScript 2015) reserved words.
  26906. *
  26907. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#reserved_keywords_as_of_ecmascript_2015
  26908. */
  26909. RESERVED_WORDS,
  26910. GrammarError,
  26911. parser,
  26912. compiler,
  26913. // Generates a parser from a specified grammar and returns it.
  26914. //
  26915. // The grammar must be a string in the format described by the meta-grammar in
  26916. // the parser.pegjs file.
  26917. //
  26918. // Throws |peg.parser.SyntaxError| if the grammar contains a syntax error or
  26919. // |peg.GrammarError| if it contains a semantic error. Note that not all
  26920. // errors are detected during the generation and some may protrude to the
  26921. // generated parser and cause its malfunction.
  26922. generate(grammar, options) {
  26923. options = options !== undefined ? options : {};
  26924. function copyPasses(passes) {
  26925. const converted = {};
  26926. Object.keys(passes).forEach(stage => {
  26927. converted[stage] = passes[stage].slice();
  26928. });
  26929. return converted;
  26930. }
  26931. const plugins = "plugins" in options ? options.plugins : [];
  26932. const config = {
  26933. parser: peg.parser,
  26934. passes: copyPasses(peg.compiler.passes),
  26935. reservedWords: peg.RESERVED_WORDS.slice(),
  26936. };
  26937. plugins.forEach(p => { p.use(config, options); });
  26938. return peg.compiler.compile(
  26939. config.parser.parse(grammar, {
  26940. grammarSource: options.grammarSource,
  26941. reservedWords: config.reservedWords,
  26942. }),
  26943. config.passes,
  26944. options
  26945. );
  26946. }
  26947. };
  26948. module.exports = peg;
  26949. /***/ }),
  26950. /***/ 80244:
  26951. /***/ ((module) => {
  26952. "use strict";
  26953. // This file is generated.
  26954. // Do not edit it! Your work will be overwritten.
  26955. //
  26956. // Instead, please look at ./tools/set_version.js
  26957. module.exports = "1.2.0";
  26958. /***/ }),
  26959. /***/ 6391:
  26960. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  26961. (function() {
  26962. var MarkedYAMLError, events, nodes;
  26963. events = __webpack_require__(35063);
  26964. ({MarkedYAMLError} = __webpack_require__(45372));
  26965. nodes = __webpack_require__(96914);
  26966. /*
  26967. Thrown for errors encountered during composing.
  26968. */
  26969. this.ComposerError = class ComposerError extends MarkedYAMLError {};
  26970. /*
  26971. The composer class handles the construction of representation trees from events.
  26972. This uses the methods from {Parser} to process the event stream, and provides a similar stream-like
  26973. interface to representation trees via {Composer#check_node}, {Composer#get_node}, and
  26974. {Composer#get_single_node}.
  26975. */
  26976. this.Composer = (function() {
  26977. var ctor;
  26978. class Composer {
  26979. constructor() {
  26980. return ctor.apply(this, arguments);
  26981. }
  26982. /*
  26983. Initialise a `Composer` instance.
  26984. */
  26985. initialise() {
  26986. // @property {Object} A mapping from anchor names to nodes.
  26987. return this.anchors = {};
  26988. }
  26989. /*
  26990. Checks if a document can be composed from the event stream.
  26991. So long as the event stream hasn't ended (no [StreamEndEvent]), another document can be composed.
  26992. @return {Boolean} True if a document can be composed, false otherwise.
  26993. */
  26994. check_node() {
  26995. if (this.check_event(events.StreamStartEvent)) {
  26996. // Drop the STREAM-START event.
  26997. this.get_event();
  26998. }
  26999. // Are there more documents available?
  27000. return !this.check_event(events.StreamEndEvent);
  27001. }
  27002. /*
  27003. Compose a document from the remaining event stream.
  27004. {Composer#check_node} must be called before calling this method.
  27005. @return {Node} The next document in the stream. Returns `undefined` if the event stream has ended.
  27006. */
  27007. get_node() {
  27008. if (!this.check_event(events.StreamEndEvent)) {
  27009. return this.compose_document();
  27010. }
  27011. }
  27012. /*
  27013. Compose a single document from the entire event stream.
  27014. @throw {ComposerError} if there's more than one document is in the stream.
  27015. @return {Node} The single document in the stream.
  27016. */
  27017. get_single_node() {
  27018. var document, event;
  27019. // Drop the STREAM-START event.
  27020. this.get_event();
  27021. // Compose a document if the stream is not empty.
  27022. document = null;
  27023. if (!this.check_event(events.StreamEndEvent)) {
  27024. document = this.compose_document();
  27025. }
  27026. // Ensure that the stream contains no more documents.
  27027. if (!this.check_event(events.StreamEndEvent)) {
  27028. event = this.get_event();
  27029. throw new exports.ComposerError('expected a single document in the stream', document.start_mark, 'but found another document', event.start_mark);
  27030. }
  27031. // Drop the STREAM-END event.
  27032. this.get_event();
  27033. return document;
  27034. }
  27035. /*
  27036. Compose a document node from the event stream.
  27037. A 'document' node is any single {Node} subclass. {DocumentStart} and {DocumentEnd} events delimit
  27038. the events used for composition.
  27039. @private
  27040. @return {Node} The document node.
  27041. */
  27042. compose_document() {
  27043. var node;
  27044. // Drop the DOCUMENT-START event.
  27045. this.get_event();
  27046. // Compose the root node.
  27047. node = this.compose_node();
  27048. // Drop the DOCUMENT-END node.
  27049. this.get_event();
  27050. // Reset the anchors
  27051. this.anchors = {};
  27052. return node;
  27053. }
  27054. /*
  27055. Compose a node from the event stream.
  27056. Composes a {ScalarNode}, {SequenceNode}, or {MappingNode} from the event stream, depending on the
  27057. first event encountered ({ScalarEvent}, {SequenceStartEvent}, or {MappingStartEvent}
  27058. respectively).
  27059. @private
  27060. @param parent {Node} The parent of the new node.
  27061. @param index {Number} The index of the new node within the parent's children.
  27062. @throw {ComposerError} if an alias is encountered for an undefined anchor.
  27063. @throw {ComposerError} if a duplicate anchor is envountered.
  27064. @return {Node} The composed node.
  27065. */
  27066. compose_node(parent, index) {
  27067. var anchor, event, node;
  27068. if (this.check_event(events.AliasEvent)) {
  27069. event = this.get_event();
  27070. anchor = event.anchor;
  27071. if (!(anchor in this.anchors)) {
  27072. throw new exports.ComposerError(null, null, `found undefined alias ${anchor}`, event.start_mark);
  27073. }
  27074. return this.anchors[anchor];
  27075. }
  27076. event = this.peek_event();
  27077. anchor = event.anchor;
  27078. if (anchor !== null && anchor in this.anchors) {
  27079. throw new exports.ComposerError(`found duplicate anchor ${anchor}; first occurence`, this.anchors[anchor].start_mark, 'second occurrence', event.start_mark);
  27080. }
  27081. this.descend_resolver(parent, index);
  27082. if (this.check_event(events.ScalarEvent)) {
  27083. node = this.compose_scalar_node(anchor);
  27084. } else if (this.check_event(events.SequenceStartEvent)) {
  27085. node = this.compose_sequence_node(anchor);
  27086. } else if (this.check_event(events.MappingStartEvent)) {
  27087. node = this.compose_mapping_node(anchor);
  27088. }
  27089. this.ascend_resolver();
  27090. return node;
  27091. }
  27092. /*
  27093. Compose a {ScalarNode} from the event stream.
  27094. @private
  27095. @param anchor {String} The anchor name for the node (if any).
  27096. @return {ScalarNode} The node composed from a {ScalarEvent}.
  27097. */
  27098. compose_scalar_node(anchor) {
  27099. var event, node, tag;
  27100. event = this.get_event();
  27101. tag = event.tag;
  27102. if (tag === null || tag === '!') {
  27103. tag = this.resolve(nodes.ScalarNode, event.value, event.implicit);
  27104. }
  27105. node = new nodes.ScalarNode(tag, event.value, event.start_mark, event.end_mark, event.style);
  27106. if (anchor !== null) {
  27107. this.anchors[anchor] = node;
  27108. }
  27109. return node;
  27110. }
  27111. /*
  27112. Compose a {SequenceNode} from the event stream.
  27113. The contents of the node are composed from events between a {SequenceStartEvent} and a
  27114. {SequenceEndEvent}.
  27115. @private
  27116. @param anchor {String} The anchor name for the node (if any).
  27117. @return {SequenceNode} The composed node.
  27118. */
  27119. compose_sequence_node(anchor) {
  27120. var end_event, index, node, start_event, tag;
  27121. start_event = this.get_event();
  27122. tag = start_event.tag;
  27123. if (tag === null || tag === '!') {
  27124. tag = this.resolve(nodes.SequenceNode, null, start_event.implicit);
  27125. }
  27126. node = new nodes.SequenceNode(tag, [], start_event.start_mark, null, start_event.flow_style);
  27127. if (anchor !== null) {
  27128. this.anchors[anchor] = node;
  27129. }
  27130. index = 0;
  27131. while (!this.check_event(events.SequenceEndEvent)) {
  27132. node.value.push(this.compose_node(node, index));
  27133. index++;
  27134. }
  27135. end_event = this.get_event();
  27136. node.end_mark = end_event.end_mark;
  27137. return node;
  27138. }
  27139. /*
  27140. Compose a {MappingNode} from the event stream.
  27141. The contents of the node are composed from events between a {MappingStartEvent} and a
  27142. {MappingEndEvent}.
  27143. @private
  27144. @param anchor {String} The anchor name for the node (if any).
  27145. @return {MappingNode} The composed node.
  27146. */
  27147. compose_mapping_node(anchor) {
  27148. var end_event, item_key, item_value, node, start_event, tag;
  27149. start_event = this.get_event();
  27150. tag = start_event.tag;
  27151. if (tag === null || tag === '!') {
  27152. tag = this.resolve(nodes.MappingNode, null, start_event.implicit);
  27153. }
  27154. node = new nodes.MappingNode(tag, [], start_event.start_mark, null, start_event.flow_style);
  27155. if (anchor !== null) {
  27156. this.anchors[anchor] = node;
  27157. }
  27158. while (!this.check_event(events.MappingEndEvent)) {
  27159. item_key = this.compose_node(node);
  27160. item_value = this.compose_node(node, item_key);
  27161. node.value.push([item_key, item_value]);
  27162. }
  27163. end_event = this.get_event();
  27164. node.end_mark = end_event.end_mark;
  27165. return node;
  27166. }
  27167. };
  27168. ctor = Composer.prototype.initialise;
  27169. return Composer;
  27170. }).call(this);
  27171. }).call(this);
  27172. /***/ }),
  27173. /***/ 51574:
  27174. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  27175. (function() {
  27176. var MarkedYAMLError, nodes, util,
  27177. indexOf = [].indexOf;
  27178. ({MarkedYAMLError} = __webpack_require__(45372));
  27179. nodes = __webpack_require__(96914);
  27180. util = __webpack_require__(23823);
  27181. /*
  27182. Thrown for errors encountered during construction.
  27183. */
  27184. this.ConstructorError = class ConstructorError extends MarkedYAMLError {};
  27185. /*
  27186. The constructor class handles the construction of Javascript objects from representation trees
  27187. ({Node}s).
  27188. This uses the methods from {Composer} to process the representation stream, and provides a similar
  27189. stream-like interface to Javascript objects via {BaseConstructor#check_node},
  27190. {BaseConstructor#get_node}, and {BaseConstructor#get_single_node}.
  27191. */
  27192. this.BaseConstructor = (function() {
  27193. var ctor;
  27194. class BaseConstructor {
  27195. constructor() {
  27196. return ctor.apply(this, arguments);
  27197. }
  27198. /*
  27199. Add a constructor function for a specific tag.
  27200. The constructor will be used to turn {Node Nodes} with the given tag into a Javascript object.
  27201. @param tag {String} The tag for which the constructor should apply.
  27202. @param constructor {Function<Node,any>} A function that turns a {Node} with the given tag into a
  27203. Javascript object.
  27204. @return {Function<Node,Any>} Returns the supplied `constructor`.
  27205. */
  27206. static add_constructor(tag, constructor) {
  27207. if (!this.prototype.hasOwnProperty('yaml_constructors')) {
  27208. this.prototype.yaml_constructors = util.extend({}, this.prototype.yaml_constructors);
  27209. }
  27210. return this.prototype.yaml_constructors[tag] = constructor;
  27211. }
  27212. /*
  27213. Add a constructor function for a tag prefix.
  27214. The constructor will be used to turn {Node Nodes} with the given tag prefix into a Javascript
  27215. object.
  27216. @param tag_prefix {String} The tag prefix for which the constructor should apply.
  27217. @param multi_constructor {Function<Node,any>} A function that turns a {Node} with the given tag
  27218. prefix into a Javascript object.
  27219. @return {Function<Node,Any>} Returns the supplied `multi_constructor`.
  27220. */
  27221. static add_multi_constructor(tag_prefix, multi_constructor) {
  27222. if (!this.prototype.hasOwnProperty('yaml_multi_constructors')) {
  27223. this.prototype.yaml_multi_constructors = util.extend({}, this.prototype.yaml_multi_constructors);
  27224. }
  27225. return this.prototype.yaml_multi_constructors[tag_prefix] = multi_constructor;
  27226. }
  27227. /*
  27228. Initialise a new instance.
  27229. */
  27230. initialise() {
  27231. // @param {Object} A map from {Node#unique_id} to the constructed Javascript object for the node.
  27232. this.constructed_objects = {};
  27233. // @param {Array<String>} An array of {Node#unique_id}s that are being constructed.
  27234. this.constructing_nodes = [];
  27235. // @param {Function<any>} An array of functions to be exectied after docmuent construction.
  27236. return this.deferred_constructors = [];
  27237. }
  27238. /*
  27239. Checks if a document can be constructed from the representation stream.
  27240. So long as the representation stream hasn't ended, another document can be constructed.
  27241. @return {Boolean} True if a document can be constructed, false otherwise.
  27242. */
  27243. check_data() {
  27244. return this.check_node();
  27245. }
  27246. /*
  27247. Construct a document from the remaining representation stream.
  27248. {Constructor#check_data} must be called before calling this method.
  27249. @return {any} The next document in the stream. Returns `undefined` if the stream has ended.
  27250. */
  27251. get_data() {
  27252. if (this.check_node()) {
  27253. return this.construct_document(this.get_node());
  27254. }
  27255. }
  27256. /*
  27257. Construct a single document from the entire representation stream.
  27258. @throw {ComposerError} if there's more than one document is in the stream.
  27259. @return {Node} The single document in the stream.
  27260. */
  27261. get_single_data() {
  27262. var node;
  27263. node = this.get_single_node();
  27264. if (node != null) {
  27265. return this.construct_document(node);
  27266. }
  27267. return null;
  27268. }
  27269. /*
  27270. Construct a document node
  27271. @private
  27272. */
  27273. construct_document(node) {
  27274. var data;
  27275. data = this.construct_object(node);
  27276. while (!util.is_empty(this.deferred_constructors)) {
  27277. this.deferred_constructors.pop()();
  27278. }
  27279. return data;
  27280. }
  27281. defer(f) {
  27282. return this.deferred_constructors.push(f);
  27283. }
  27284. construct_object(node) {
  27285. var constructor, object, ref, tag_prefix, tag_suffix;
  27286. if (node.unique_id in this.constructed_objects) {
  27287. return this.constructed_objects[node.unique_id];
  27288. }
  27289. if (ref = node.unique_id, indexOf.call(this.constructing_nodes, ref) >= 0) {
  27290. throw new exports.ConstructorError(null, null, 'found unconstructable recursive node', node.start_mark);
  27291. }
  27292. this.constructing_nodes.push(node.unique_id);
  27293. constructor = null;
  27294. tag_suffix = null;
  27295. if (node.tag in this.yaml_constructors) {
  27296. constructor = this.yaml_constructors[node.tag];
  27297. } else {
  27298. for (tag_prefix in this.yaml_multi_constructors) {
  27299. if (node.tag.indexOf(tag_prefix === 0)) {
  27300. tag_suffix = node.tag.slice(tag_prefix.length);
  27301. constructor = this.yaml_multi_constructors[tag_prefix];
  27302. break;
  27303. }
  27304. }
  27305. if (constructor == null) {
  27306. if (null in this.yaml_multi_constructors) {
  27307. tag_suffix = node.tag;
  27308. constructor = this.yaml_multi_constructors[null];
  27309. } else if (null in this.yaml_constructors) {
  27310. constructor = this.yaml_constructors[null];
  27311. } else if (node instanceof nodes.ScalarNode) {
  27312. constructor = this.construct_scalar;
  27313. } else if (node instanceof nodes.SequenceNode) {
  27314. constructor = this.construct_sequence;
  27315. } else if (node instanceof nodes.MappingNode) {
  27316. constructor = this.construct_mapping;
  27317. }
  27318. }
  27319. }
  27320. object = constructor.call(this, tag_suffix != null ? tag_suffix : node, node);
  27321. this.constructed_objects[node.unique_id] = object;
  27322. this.constructing_nodes.pop();
  27323. return object;
  27324. }
  27325. construct_scalar(node) {
  27326. if (!(node instanceof nodes.ScalarNode)) {
  27327. throw new exports.ConstructorError(null, null, `expected a scalar node but found ${node.id}`, node.start_mark);
  27328. }
  27329. return node.value;
  27330. }
  27331. construct_sequence(node) {
  27332. var child, i, len, ref, results;
  27333. if (!(node instanceof nodes.SequenceNode)) {
  27334. throw new exports.ConstructorError(null, null, `expected a sequence node but found ${node.id}`, node.start_mark);
  27335. }
  27336. ref = node.value;
  27337. results = [];
  27338. for (i = 0, len = ref.length; i < len; i++) {
  27339. child = ref[i];
  27340. results.push(this.construct_object(child));
  27341. }
  27342. return results;
  27343. }
  27344. construct_mapping(node) {
  27345. var i, key, key_node, len, mapping, ref, value, value_node;
  27346. if (!(node instanceof nodes.MappingNode)) {
  27347. throw new ConstructorError(null, null, `expected a mapping node but found ${node.id}`, node.start_mark);
  27348. }
  27349. mapping = {};
  27350. ref = node.value;
  27351. for (i = 0, len = ref.length; i < len; i++) {
  27352. [key_node, value_node] = ref[i];
  27353. key = this.construct_object(key_node);
  27354. if (typeof key === 'object') {
  27355. throw new exports.ConstructorError('while constructing a mapping', node.start_mark, 'found unhashable key', key_node.start_mark);
  27356. }
  27357. value = this.construct_object(value_node);
  27358. mapping[key] = value;
  27359. }
  27360. return mapping;
  27361. }
  27362. construct_pairs(node) {
  27363. var i, key, key_node, len, pairs, ref, value, value_node;
  27364. if (!(node instanceof nodes.MappingNode)) {
  27365. throw new exports.ConstructorError(null, null, `expected a mapping node but found ${node.id}`, node.start_mark);
  27366. }
  27367. pairs = [];
  27368. ref = node.value;
  27369. for (i = 0, len = ref.length; i < len; i++) {
  27370. [key_node, value_node] = ref[i];
  27371. key = this.construct_object(key_node);
  27372. value = this.construct_object(value_node);
  27373. pairs.push([key, value]);
  27374. }
  27375. return pairs;
  27376. }
  27377. };
  27378. /*
  27379. @property {Object} A map from a YAML tag to a constructor function for data with that tag.
  27380. @private
  27381. */
  27382. BaseConstructor.prototype.yaml_constructors = {};
  27383. /*
  27384. @property {Object} A map from a YAML tag prefix to a constructor function for data with that tag
  27385. prefix.
  27386. @private
  27387. */
  27388. BaseConstructor.prototype.yaml_multi_constructors = {};
  27389. ctor = BaseConstructor.prototype.initialise;
  27390. return BaseConstructor;
  27391. }).call(this);
  27392. this.Constructor = (function() {
  27393. var BOOL_VALUES, TIMESTAMP_PARTS, TIMESTAMP_REGEX;
  27394. class Constructor extends this.BaseConstructor {
  27395. construct_scalar(node) {
  27396. var i, key_node, len, ref, value_node;
  27397. if (node instanceof nodes.MappingNode) {
  27398. ref = node.value;
  27399. for (i = 0, len = ref.length; i < len; i++) {
  27400. [key_node, value_node] = ref[i];
  27401. if (key_node.tag === 'tag:yaml.org,2002:value') {
  27402. return this.construct_scalar(value_node);
  27403. }
  27404. }
  27405. }
  27406. return super.construct_scalar(node);
  27407. }
  27408. flatten_mapping(node) {
  27409. var i, index, j, key_node, len, len1, merge, ref, submerge, subnode, value, value_node;
  27410. merge = [];
  27411. index = 0;
  27412. while (index < node.value.length) {
  27413. [key_node, value_node] = node.value[index];
  27414. if (key_node.tag === 'tag:yaml.org,2002:merge') {
  27415. node.value.splice(index, 1);
  27416. //delete node.value[index]
  27417. if (value_node instanceof nodes.MappingNode) {
  27418. this.flatten_mapping(value_node);
  27419. merge = merge.concat(value_node.value);
  27420. } else if (value_node instanceof nodes.SequenceNode) {
  27421. submerge = [];
  27422. ref = value_node.value;
  27423. for (i = 0, len = ref.length; i < len; i++) {
  27424. subnode = ref[i];
  27425. if (!(subnode instanceof nodes.MappingNode)) {
  27426. throw new exports.ConstructorError('while constructing a mapping', node.start_mark, `expected a mapping for merging, but found ${subnode.id}`, subnode.start_mark);
  27427. }
  27428. this.flatten_mapping(subnode);
  27429. submerge.push(subnode.value);
  27430. }
  27431. submerge.reverse();
  27432. for (j = 0, len1 = submerge.length; j < len1; j++) {
  27433. value = submerge[j];
  27434. merge = merge.concat(value);
  27435. }
  27436. } else {
  27437. throw new exports.ConstructorError('while constructing a mapping', node.start_mark, `expected a mapping or list of mappings for merging but found ${value_node.id}`, value_node.start_mark);
  27438. }
  27439. } else if (key_node.tag === 'tag:yaml.org,2002:value') {
  27440. key_node.tag = 'tag:yaml.org,2002:str';
  27441. index++;
  27442. } else {
  27443. index++;
  27444. }
  27445. }
  27446. if (merge.length) {
  27447. return node.value = merge.concat(node.value);
  27448. }
  27449. }
  27450. construct_mapping(node) {
  27451. if (node instanceof nodes.MappingNode) {
  27452. this.flatten_mapping(node);
  27453. }
  27454. return super.construct_mapping(node);
  27455. }
  27456. construct_yaml_null(node) {
  27457. this.construct_scalar(node);
  27458. return null;
  27459. }
  27460. construct_yaml_bool(node) {
  27461. var value;
  27462. value = this.construct_scalar(node);
  27463. return BOOL_VALUES[value.toLowerCase()];
  27464. }
  27465. construct_yaml_int(node) {
  27466. var base, digit, digits, i, len, part, ref, sign, value;
  27467. value = this.construct_scalar(node);
  27468. value = value.replace(/_/g, '');
  27469. sign = value[0] === '-' ? -1 : 1;
  27470. if (ref = value[0], indexOf.call('+-', ref) >= 0) {
  27471. value = value.slice(1);
  27472. }
  27473. if (value === '0') {
  27474. return 0;
  27475. } else if (value.indexOf('0b') === 0) {
  27476. return sign * parseInt(value.slice(2), 2);
  27477. } else if (value.indexOf('0x') === 0) {
  27478. return sign * parseInt(value.slice(2), 16);
  27479. } else if (value.indexOf('0o') === 0) {
  27480. return sign * parseInt(value.slice(2), 8);
  27481. } else if (value[0] === '0') {
  27482. return sign * parseInt(value, 8);
  27483. } else if (indexOf.call(value, ':') >= 0) {
  27484. digits = (function() {
  27485. var i, len, ref1, results;
  27486. ref1 = value.split(/:/g);
  27487. results = [];
  27488. for (i = 0, len = ref1.length; i < len; i++) {
  27489. part = ref1[i];
  27490. results.push(parseInt(part));
  27491. }
  27492. return results;
  27493. })();
  27494. digits.reverse();
  27495. base = 1;
  27496. value = 0;
  27497. for (i = 0, len = digits.length; i < len; i++) {
  27498. digit = digits[i];
  27499. value += digit * base;
  27500. base *= 60;
  27501. }
  27502. return sign * value;
  27503. } else {
  27504. return sign * parseInt(value);
  27505. }
  27506. }
  27507. construct_yaml_float(node) {
  27508. var base, digit, digits, i, len, part, ref, sign, value;
  27509. value = this.construct_scalar(node);
  27510. value = value.replace(/_/g, '').toLowerCase();
  27511. sign = value[0] === '-' ? -1 : 1;
  27512. if (ref = value[0], indexOf.call('+-', ref) >= 0) {
  27513. value = value.slice(1);
  27514. }
  27515. if (value === '.inf') {
  27516. return sign * 2e308;
  27517. } else if (value === '.nan') {
  27518. return 0/0;
  27519. } else if (indexOf.call(value, ':') >= 0) {
  27520. digits = (function() {
  27521. var i, len, ref1, results;
  27522. ref1 = value.split(/:/g);
  27523. results = [];
  27524. for (i = 0, len = ref1.length; i < len; i++) {
  27525. part = ref1[i];
  27526. results.push(parseFloat(part));
  27527. }
  27528. return results;
  27529. })();
  27530. digits.reverse();
  27531. base = 1;
  27532. value = 0.0;
  27533. for (i = 0, len = digits.length; i < len; i++) {
  27534. digit = digits[i];
  27535. value += digit * base;
  27536. base *= 60;
  27537. }
  27538. return sign * value;
  27539. } else {
  27540. return sign * parseFloat(value);
  27541. }
  27542. }
  27543. construct_yaml_binary(node) {
  27544. var error, value;
  27545. value = this.construct_scalar(node);
  27546. try {
  27547. if (typeof window !== "undefined" && window !== null) {
  27548. return atob(value);
  27549. }
  27550. return new Buffer(value, 'base64').toString('ascii');
  27551. } catch (error1) {
  27552. error = error1;
  27553. throw new exports.ConstructorError(null, null, `failed to decode base64 data: ${error}`, node.start_mark);
  27554. }
  27555. }
  27556. construct_yaml_timestamp(node) {
  27557. var date, day, fraction, hour, index, key, match, millisecond, minute, month, second, tz_hour, tz_minute, tz_sign, value, values, year;
  27558. value = this.construct_scalar(node);
  27559. match = node.value.match(TIMESTAMP_REGEX);
  27560. values = {};
  27561. for (key in TIMESTAMP_PARTS) {
  27562. index = TIMESTAMP_PARTS[key];
  27563. values[key] = match[index];
  27564. }
  27565. year = parseInt(values.year);
  27566. month = parseInt(values.month) - 1;
  27567. day = parseInt(values.day);
  27568. if (!values.hour) {
  27569. return new Date(Date.UTC(year, month, day));
  27570. }
  27571. hour = parseInt(values.hour);
  27572. minute = parseInt(values.minute);
  27573. second = parseInt(values.second);
  27574. millisecond = 0;
  27575. if (values.fraction) {
  27576. fraction = values.fraction.slice(0, 6);
  27577. while (fraction.length < 6) {
  27578. fraction += '0';
  27579. }
  27580. fraction = parseInt(fraction);
  27581. millisecond = Math.round(fraction / 1000);
  27582. }
  27583. if (values.tz_sign) {
  27584. tz_sign = values.tz_sign === '-' ? 1 : -1;
  27585. if (tz_hour = parseInt(values.tz_hour)) {
  27586. hour += tz_sign * tz_hour;
  27587. }
  27588. if (tz_minute = parseInt(values.tz_minute)) {
  27589. minute += tz_sign * tz_minute;
  27590. }
  27591. }
  27592. date = new Date(Date.UTC(year, month, day, hour, minute, second, millisecond));
  27593. return date;
  27594. }
  27595. construct_yaml_pair_list(type, node) {
  27596. var list;
  27597. list = [];
  27598. if (!(node instanceof nodes.SequenceNode)) {
  27599. throw new exports.ConstructorError(`while constructing ${type}`, node.start_mark, `expected a sequence but found ${node.id}`, node.start_mark);
  27600. }
  27601. this.defer(() => {
  27602. var i, key, key_node, len, ref, results, subnode, value, value_node;
  27603. ref = node.value;
  27604. results = [];
  27605. for (i = 0, len = ref.length; i < len; i++) {
  27606. subnode = ref[i];
  27607. if (!(subnode instanceof nodes.MappingNode)) {
  27608. throw new exports.ConstructorError(`while constructing ${type}`, node.start_mark, `expected a mapping of length 1 but found ${subnode.id}`, subnode.start_mark);
  27609. }
  27610. if (subnode.value.length !== 1) {
  27611. throw new exports.ConstructorError(`while constructing ${type}`, node.start_mark, `expected a mapping of length 1 but found ${subnode.id}`, subnode.start_mark);
  27612. }
  27613. [key_node, value_node] = subnode.value[0];
  27614. key = this.construct_object(key_node);
  27615. value = this.construct_object(value_node);
  27616. results.push(list.push([key, value]));
  27617. }
  27618. return results;
  27619. });
  27620. return list;
  27621. }
  27622. construct_yaml_omap(node) {
  27623. return this.construct_yaml_pair_list('an ordered map', node);
  27624. }
  27625. construct_yaml_pairs(node) {
  27626. return this.construct_yaml_pair_list('pairs', node);
  27627. }
  27628. construct_yaml_set(node) {
  27629. var data;
  27630. data = [];
  27631. this.defer(() => {
  27632. var item, results;
  27633. results = [];
  27634. for (item in this.construct_mapping(node)) {
  27635. results.push(data.push(item));
  27636. }
  27637. return results;
  27638. });
  27639. return data;
  27640. }
  27641. construct_yaml_str(node) {
  27642. return this.construct_scalar(node);
  27643. }
  27644. construct_yaml_seq(node) {
  27645. var data;
  27646. data = [];
  27647. this.defer(() => {
  27648. var i, item, len, ref, results;
  27649. ref = this.construct_sequence(node);
  27650. results = [];
  27651. for (i = 0, len = ref.length; i < len; i++) {
  27652. item = ref[i];
  27653. results.push(data.push(item));
  27654. }
  27655. return results;
  27656. });
  27657. return data;
  27658. }
  27659. construct_yaml_map(node) {
  27660. var data;
  27661. data = {};
  27662. this.defer(() => {
  27663. var key, ref, results, value;
  27664. ref = this.construct_mapping(node);
  27665. results = [];
  27666. for (key in ref) {
  27667. value = ref[key];
  27668. results.push(data[key] = value);
  27669. }
  27670. return results;
  27671. });
  27672. return data;
  27673. }
  27674. construct_yaml_object(node, klass) {
  27675. var data;
  27676. data = new klass;
  27677. this.defer(() => {
  27678. var key, ref, results, value;
  27679. ref = this.construct_mapping(node, true);
  27680. results = [];
  27681. for (key in ref) {
  27682. value = ref[key];
  27683. results.push(data[key] = value);
  27684. }
  27685. return results;
  27686. });
  27687. return data;
  27688. }
  27689. construct_undefined(node) {
  27690. throw new exports.ConstructorError(null, null, `could not determine a constructor for the tag ${node.tag}`, node.start_mark);
  27691. }
  27692. };
  27693. BOOL_VALUES = {
  27694. on: true,
  27695. off: false,
  27696. true: true,
  27697. false: false,
  27698. yes: true,
  27699. no: false
  27700. };
  27701. TIMESTAMP_REGEX = /^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:(?:[Tt]|[\x20\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\.([0-9]*))?(?:[\x20\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?)?$/; // 1: year
  27702. // 2: month
  27703. // 3: day
  27704. // 4: hour
  27705. // 5: minute
  27706. // 6: second
  27707. // 7: fraction
  27708. // 9: tz_sign
  27709. // 10: tz_hour
  27710. // 11: tz_minute
  27711. // 8: tz
  27712. TIMESTAMP_PARTS = {
  27713. year: 1,
  27714. month: 2,
  27715. day: 3,
  27716. hour: 4,
  27717. minute: 5,
  27718. second: 6,
  27719. fraction: 7,
  27720. tz: 8,
  27721. tz_sign: 9,
  27722. tz_hour: 10,
  27723. tz_minute: 11
  27724. };
  27725. return Constructor;
  27726. }).call(this);
  27727. this.Constructor.add_constructor('tag:yaml.org,2002:null', this.Constructor.prototype.construct_yaml_null);
  27728. this.Constructor.add_constructor('tag:yaml.org,2002:bool', this.Constructor.prototype.construct_yaml_bool);
  27729. this.Constructor.add_constructor('tag:yaml.org,2002:int', this.Constructor.prototype.construct_yaml_int);
  27730. this.Constructor.add_constructor('tag:yaml.org,2002:float', this.Constructor.prototype.construct_yaml_float);
  27731. this.Constructor.add_constructor('tag:yaml.org,2002:binary', this.Constructor.prototype.construct_yaml_binary);
  27732. this.Constructor.add_constructor('tag:yaml.org,2002:timestamp', this.Constructor.prototype.construct_yaml_timestamp);
  27733. this.Constructor.add_constructor('tag:yaml.org,2002:omap', this.Constructor.prototype.construct_yaml_omap);
  27734. this.Constructor.add_constructor('tag:yaml.org,2002:pairs', this.Constructor.prototype.construct_yaml_pairs);
  27735. this.Constructor.add_constructor('tag:yaml.org,2002:set', this.Constructor.prototype.construct_yaml_set);
  27736. this.Constructor.add_constructor('tag:yaml.org,2002:str', this.Constructor.prototype.construct_yaml_str);
  27737. this.Constructor.add_constructor('tag:yaml.org,2002:seq', this.Constructor.prototype.construct_yaml_seq);
  27738. this.Constructor.add_constructor('tag:yaml.org,2002:map', this.Constructor.prototype.construct_yaml_map);
  27739. this.Constructor.add_constructor(null, this.Constructor.prototype.construct_undefined);
  27740. }).call(this);
  27741. /***/ }),
  27742. /***/ 28190:
  27743. /***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
  27744. (function() {
  27745. var emitter, representer, resolver, serializer, util;
  27746. util = __webpack_require__(23823);
  27747. emitter = __webpack_require__(63320);
  27748. serializer = __webpack_require__(56472);
  27749. representer = __webpack_require__(13832);
  27750. resolver = __webpack_require__(3579);
  27751. this.make_dumper = function(Emitter = emitter.Emitter, Serializer = serializer.Serializer, Representer = representer.Representer, Resolver = resolver.Resolver) {
  27752. var Dumper, components;
  27753. components = [Emitter, Serializer, Representer, Resolver];
  27754. return Dumper = (function() {
  27755. var component;
  27756. class Dumper {
  27757. constructor(stream, options = {}) {
  27758. var i, len, ref;
  27759. components[0].prototype.initialise.call(this, stream, options);
  27760. ref = components.slice(1);
  27761. for (i = 0, len = ref.length; i < len; i++) {
  27762. component = ref[i];
  27763. component.prototype.initialise.call(this, options);
  27764. }
  27765. }
  27766. };
  27767. util.extend(Dumper.prototype, ...((function() {
  27768. var i, len, results;
  27769. results = [];
  27770. for (i = 0, len = components.length; i < len; i++) {
  27771. component = components[i];
  27772. results.push(component.prototype);
  27773. }
  27774. return results;
  27775. })()));
  27776. return Dumper;
  27777. }).call(this);
  27778. };
  27779. this.Dumper = this.make_dumper();
  27780. }).call(this);
  27781. /***/ }),
  27782. /***/ 63320:
  27783. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  27784. (function() {
  27785. var ScalarAnalysis, YAMLError, events, util,
  27786. hasProp = {}.hasOwnProperty,
  27787. indexOf = [].indexOf;
  27788. events = __webpack_require__(35063);
  27789. util = __webpack_require__(23823);
  27790. ({YAMLError} = __webpack_require__(45372));
  27791. this.EmitterError = class EmitterError extends YAMLError {};
  27792. /*
  27793. Emitter expects events obeying the following grammar:
  27794. stream ::= STREAM-START document* STREAM-END
  27795. document ::= DOCUMENT-START node DOCUMENT-END
  27796. node ::= SCALA | sequence | mapping
  27797. sequence ::= SEQUENCE-START node* SEQUENCE-END
  27798. mapping ::= MAPPING-START (node node)* MAPPING-END
  27799. */
  27800. this.Emitter = (function() {
  27801. var C_WHITESPACE, DEFAULT_TAG_PREFIXES, ESCAPE_REPLACEMENTS, ctor;
  27802. class Emitter {
  27803. constructor() {
  27804. return ctor.apply(this, arguments);
  27805. }
  27806. initialise(stream, options) {
  27807. var ref;
  27808. this.stream = stream;
  27809. // Encoding can be overriden by STREAM-START
  27810. this.encoding = null;
  27811. // Emitter is a state machine with a stack of states to handle nested structures.
  27812. this.states = [];
  27813. this.state = this.expect_stream_start;
  27814. // Current event and the event queue
  27815. this.events = [];
  27816. this.event = null;
  27817. // The current indentation level and the stack of previous indents.
  27818. this.indents = [];
  27819. this.indent = null;
  27820. // Flow level.
  27821. this.flow_level = 0;
  27822. // Contexts.
  27823. this.root_context = false;
  27824. this.sequence_context = false;
  27825. this.mapping_context = false;
  27826. this.simple_key_context = false;
  27827. // Characteristics of the last emitted character:
  27828. // - current position.
  27829. // - is it a whitespace?
  27830. // - is it an indentation character (indentation space, '-', '?', or ':')?
  27831. this.line = 0;
  27832. this.column = 0;
  27833. this.whitespace = true;
  27834. this.indentation = true;
  27835. // Whether the document requires an explicit document indicator.
  27836. this.open_ended = false;
  27837. // Formatting details
  27838. ({canonical: this.canonical, allow_unicode: this.allow_unicode} = options);
  27839. if (this.canonical == null) {
  27840. this.canonical = false;
  27841. }
  27842. if (this.allow_unicode == null) {
  27843. this.allow_unicode = true;
  27844. }
  27845. this.best_indent = 1 < options.indent && options.indent < 10 ? options.indent : 2;
  27846. this.best_width = options.width > this.indent * 2 ? options.width : 80;
  27847. this.best_line_break = (ref = options.line_break) === '\r' || ref === '\n' || ref === '\r\n' ? options.line_break : '\n';
  27848. // Tag prefixes.
  27849. this.tag_prefixes = null;
  27850. // Prepared anchor and tag
  27851. this.prepared_anchor = null;
  27852. this.prepared_tag = null;
  27853. // Scalar analysis and style.
  27854. this.analysis = null;
  27855. return this.style = null;
  27856. }
  27857. /*
  27858. Reset the state attributes (to clear self-references)
  27859. */
  27860. dispose() {
  27861. this.states = [];
  27862. return this.state = null;
  27863. }
  27864. emit(event) {
  27865. var results;
  27866. this.events.push(event);
  27867. results = [];
  27868. while (!this.need_more_events()) {
  27869. this.event = this.events.shift();
  27870. this.state();
  27871. results.push(this.event = null);
  27872. }
  27873. return results;
  27874. }
  27875. /*
  27876. In some cases, we wait for a few next events before emitting.
  27877. */
  27878. need_more_events() {
  27879. var event;
  27880. if (this.events.length === 0) {
  27881. return true;
  27882. }
  27883. event = this.events[0];
  27884. if (event instanceof events.DocumentStartEvent) {
  27885. return this.need_events(1);
  27886. } else if (event instanceof events.SequenceStartEvent) {
  27887. return this.need_events(2);
  27888. } else if (event instanceof events.MappingStartEvent) {
  27889. return this.need_events(3);
  27890. } else {
  27891. return false;
  27892. }
  27893. }
  27894. need_events(count) {
  27895. var event, i, len, level, ref;
  27896. level = 0;
  27897. ref = this.events.slice(1);
  27898. for (i = 0, len = ref.length; i < len; i++) {
  27899. event = ref[i];
  27900. if (event instanceof events.DocumentStartEvent || event instanceof events.CollectionStartEvent) {
  27901. level++;
  27902. } else if (event instanceof events.DocumentEndEvent || event instanceof events.CollectionEndEvent) {
  27903. level--;
  27904. } else if (event instanceof events.StreamEndEvent) {
  27905. level = -1;
  27906. }
  27907. if (level < 0) {
  27908. return false;
  27909. }
  27910. }
  27911. return this.events.length < count + 1;
  27912. }
  27913. increase_indent(options = {}) {
  27914. this.indents.push(this.indent);
  27915. if (this.indent == null) {
  27916. return this.indent = options.flow ? this.best_indent : 0;
  27917. } else if (!options.indentless) {
  27918. return this.indent += this.best_indent;
  27919. }
  27920. }
  27921. // Stream states
  27922. expect_stream_start() {
  27923. if (this.event instanceof events.StreamStartEvent) {
  27924. if (this.event.encoding && !('encoding' in this.stream)) {
  27925. this.encoding = this.event.encoding;
  27926. }
  27927. this.write_stream_start();
  27928. return this.state = this.expect_first_document_start;
  27929. } else {
  27930. return this.error('expected StreamStartEvent, but got', this.event);
  27931. }
  27932. }
  27933. expect_nothing() {
  27934. return this.error('expected nothing, but got', this.event);
  27935. }
  27936. // Document states
  27937. expect_first_document_start() {
  27938. return this.expect_document_start(true);
  27939. }
  27940. expect_document_start(first = false) {
  27941. var explicit, handle, i, k, len, prefix, ref;
  27942. if (this.event instanceof events.DocumentStartEvent) {
  27943. if ((this.event.version || this.event.tags) && this.open_ended) {
  27944. this.write_indicator('...', true);
  27945. this.write_indent();
  27946. }
  27947. if (this.event.version) {
  27948. this.write_version_directive(this.prepare_version(this.event.version));
  27949. }
  27950. this.tag_prefixes = util.clone(DEFAULT_TAG_PREFIXES);
  27951. if (this.event.tags) {
  27952. ref = ((function() {
  27953. var ref, results;
  27954. ref = this.event.tags;
  27955. results = [];
  27956. for (k in ref) {
  27957. if (!hasProp.call(ref, k)) continue;
  27958. results.push(k);
  27959. }
  27960. return results;
  27961. }).call(this)).sort();
  27962. for (i = 0, len = ref.length; i < len; i++) {
  27963. handle = ref[i];
  27964. prefix = this.event.tags[handle];
  27965. this.tag_prefixes[prefix] = handle;
  27966. this.write_tag_directive(this.prepare_tag_handle(handle), this.prepare_tag_prefix(prefix));
  27967. }
  27968. }
  27969. explicit = !first || this.event.explicit || this.canonical || this.event.version || this.event.tags || this.check_empty_document();
  27970. if (explicit) {
  27971. this.write_indent();
  27972. this.write_indicator('---', true);
  27973. if (this.canonical) {
  27974. this.write_indent();
  27975. }
  27976. }
  27977. return this.state = this.expect_document_root;
  27978. } else if (this.event instanceof events.StreamEndEvent) {
  27979. if (this.open_ended) {
  27980. this.write_indicator('...', true);
  27981. this.write_indent();
  27982. }
  27983. this.write_stream_end();
  27984. return this.state = this.expect_nothing;
  27985. } else {
  27986. return this.error('expected DocumentStartEvent, but got', this.event);
  27987. }
  27988. }
  27989. expect_document_end() {
  27990. if (this.event instanceof events.DocumentEndEvent) {
  27991. this.write_indent();
  27992. if (this.event.explicit) {
  27993. this.write_indicator('...', true);
  27994. this.write_indent();
  27995. }
  27996. this.flush_stream();
  27997. return this.state = this.expect_document_start;
  27998. } else {
  27999. return this.error('expected DocumentEndEvent, but got', this.event);
  28000. }
  28001. }
  28002. expect_document_root() {
  28003. this.states.push(this.expect_document_end);
  28004. return this.expect_node({
  28005. root: true
  28006. });
  28007. }
  28008. // Node states
  28009. expect_node(expect = {}) {
  28010. this.root_context = !!expect.root;
  28011. this.sequence_context = !!expect.sequence;
  28012. this.mapping_context = !!expect.mapping;
  28013. this.simple_key_context = !!expect.simple_key;
  28014. if (this.event instanceof events.AliasEvent) {
  28015. return this.expect_alias();
  28016. } else if (this.event instanceof events.ScalarEvent || this.event instanceof events.CollectionStartEvent) {
  28017. this.process_anchor('&');
  28018. this.process_tag();
  28019. if (this.event instanceof events.ScalarEvent) {
  28020. return this.expect_scalar();
  28021. } else if (this.event instanceof events.SequenceStartEvent) {
  28022. if (this.flow_level || this.canonical || this.event.flow_style || this.check_empty_sequence()) {
  28023. return this.expect_flow_sequence();
  28024. } else {
  28025. return this.expect_block_sequence();
  28026. }
  28027. } else if (this.event instanceof events.MappingStartEvent) {
  28028. if (this.flow_level || this.canonical || this.event.flow_style || this.check_empty_mapping()) {
  28029. return this.expect_flow_mapping();
  28030. } else {
  28031. return this.expect_block_mapping();
  28032. }
  28033. }
  28034. } else {
  28035. return this.error('expected NodeEvent, but got', this.event);
  28036. }
  28037. }
  28038. expect_alias() {
  28039. if (!this.event.anchor) {
  28040. this.error('anchor is not specified for alias');
  28041. }
  28042. this.process_anchor('*');
  28043. return this.state = this.states.pop();
  28044. }
  28045. expect_scalar() {
  28046. this.increase_indent({
  28047. flow: true
  28048. });
  28049. this.process_scalar();
  28050. this.indent = this.indents.pop();
  28051. return this.state = this.states.pop();
  28052. }
  28053. // Flow sequence states
  28054. expect_flow_sequence() {
  28055. this.write_indicator('[', true, {
  28056. whitespace: true
  28057. });
  28058. this.flow_level++;
  28059. this.increase_indent({
  28060. flow: true
  28061. });
  28062. return this.state = this.expect_first_flow_sequence_item;
  28063. }
  28064. expect_first_flow_sequence_item() {
  28065. if (this.event instanceof events.SequenceEndEvent) {
  28066. this.indent = this.indents.pop();
  28067. this.flow_level--;
  28068. this.write_indicator(']', false);
  28069. return this.state = this.states.pop();
  28070. } else {
  28071. if (this.canonical || this.column > this.best_width) {
  28072. this.write_indent();
  28073. }
  28074. this.states.push(this.expect_flow_sequence_item);
  28075. return this.expect_node({
  28076. sequence: true
  28077. });
  28078. }
  28079. }
  28080. expect_flow_sequence_item() {
  28081. if (this.event instanceof events.SequenceEndEvent) {
  28082. this.indent = this.indents.pop();
  28083. this.flow_level--;
  28084. if (this.canonical) {
  28085. this.write_indicator(',', false);
  28086. this.write_indent();
  28087. }
  28088. this.write_indicator(']', false);
  28089. return this.state = this.states.pop();
  28090. } else {
  28091. this.write_indicator(',', false);
  28092. if (this.canonical || this.column > this.best_width) {
  28093. this.write_indent();
  28094. }
  28095. this.states.push(this.expect_flow_sequence_item);
  28096. return this.expect_node({
  28097. sequence: true
  28098. });
  28099. }
  28100. }
  28101. // Flow mapping states
  28102. expect_flow_mapping() {
  28103. this.write_indicator('{', true, {
  28104. whitespace: true
  28105. });
  28106. this.flow_level++;
  28107. this.increase_indent({
  28108. flow: true
  28109. });
  28110. return this.state = this.expect_first_flow_mapping_key;
  28111. }
  28112. expect_first_flow_mapping_key() {
  28113. if (this.event instanceof events.MappingEndEvent) {
  28114. this.indent = this.indents.pop();
  28115. this.flow_level--;
  28116. this.write_indicator('}', false);
  28117. return this.state = this.states.pop();
  28118. } else {
  28119. if (this.canonical || this.column > this.best_width) {
  28120. this.write_indent();
  28121. }
  28122. if (!this.canonical && this.check_simple_key()) {
  28123. this.states.push(this.expect_flow_mapping_simple_value);
  28124. return this.expect_node({
  28125. mapping: true,
  28126. simple_key: true
  28127. });
  28128. } else {
  28129. this.write_indicator('?', true);
  28130. this.states.push(this.expect_flow_mapping_value);
  28131. return this.expect_node({
  28132. mapping: true
  28133. });
  28134. }
  28135. }
  28136. }
  28137. expect_flow_mapping_key() {
  28138. if (this.event instanceof events.MappingEndEvent) {
  28139. this.indent = this.indents.pop();
  28140. this.flow_level--;
  28141. if (this.canonical) {
  28142. this.write_indicator(',', false);
  28143. this.write_indent();
  28144. }
  28145. this.write_indicator('}', false);
  28146. return this.state = this.states.pop();
  28147. } else {
  28148. this.write_indicator(',', false);
  28149. if (this.canonical || this.column > this.best_width) {
  28150. this.write_indent();
  28151. }
  28152. if (!this.canonical && this.check_simple_key()) {
  28153. this.states.push(this.expect_flow_mapping_simple_value);
  28154. return this.expect_node({
  28155. mapping: true,
  28156. simple_key: true
  28157. });
  28158. } else {
  28159. this.write_indicator('?', true);
  28160. this.states.push(this.expect_flow_mapping_value);
  28161. return this.expect_node({
  28162. mapping: true
  28163. });
  28164. }
  28165. }
  28166. }
  28167. expect_flow_mapping_simple_value() {
  28168. this.write_indicator(':', false);
  28169. this.states.push(this.expect_flow_mapping_key);
  28170. return this.expect_node({
  28171. mapping: true
  28172. });
  28173. }
  28174. expect_flow_mapping_value() {
  28175. if (this.canonical || this.column > this.best_width) {
  28176. this.write_indent();
  28177. }
  28178. this.write_indicator(':', true);
  28179. this.states.push(this.expect_flow_mapping_key);
  28180. return this.expect_node({
  28181. mapping: true
  28182. });
  28183. }
  28184. // Block sequence states
  28185. expect_block_sequence() {
  28186. var indentless;
  28187. indentless = this.mapping_context && !this.indentation;
  28188. this.increase_indent({indentless});
  28189. return this.state = this.expect_first_block_sequence_item;
  28190. }
  28191. expect_first_block_sequence_item() {
  28192. return this.expect_block_sequence_item(true);
  28193. }
  28194. expect_block_sequence_item(first = false) {
  28195. if (!first && this.event instanceof events.SequenceEndEvent) {
  28196. this.indent = this.indents.pop();
  28197. return this.state = this.states.pop();
  28198. } else {
  28199. this.write_indent();
  28200. this.write_indicator('-', true, {
  28201. indentation: true
  28202. });
  28203. this.states.push(this.expect_block_sequence_item);
  28204. return this.expect_node({
  28205. sequence: true
  28206. });
  28207. }
  28208. }
  28209. // Block mapping states
  28210. expect_block_mapping() {
  28211. this.increase_indent();
  28212. return this.state = this.expect_first_block_mapping_key;
  28213. }
  28214. expect_first_block_mapping_key() {
  28215. return this.expect_block_mapping_key(true);
  28216. }
  28217. expect_block_mapping_key(first = false) {
  28218. if (!first && this.event instanceof events.MappingEndEvent) {
  28219. this.indent = this.indents.pop();
  28220. return this.state = this.states.pop();
  28221. } else {
  28222. this.write_indent();
  28223. if (this.check_simple_key()) {
  28224. this.states.push(this.expect_block_mapping_simple_value);
  28225. return this.expect_node({
  28226. mapping: true,
  28227. simple_key: true
  28228. });
  28229. } else {
  28230. this.write_indicator('?', true, {
  28231. indentation: true
  28232. });
  28233. this.states.push(this.expect_block_mapping_value);
  28234. return this.expect_node({
  28235. mapping: true
  28236. });
  28237. }
  28238. }
  28239. }
  28240. expect_block_mapping_simple_value() {
  28241. this.write_indicator(':', false);
  28242. this.states.push(this.expect_block_mapping_key);
  28243. return this.expect_node({
  28244. mapping: true
  28245. });
  28246. }
  28247. expect_block_mapping_value() {
  28248. this.write_indent();
  28249. this.write_indicator(':', true, {
  28250. indentation: true
  28251. });
  28252. this.states.push(this.expect_block_mapping_key);
  28253. return this.expect_node({
  28254. mapping: true
  28255. });
  28256. }
  28257. // Checkers
  28258. check_empty_document() {
  28259. var event;
  28260. if (!(this.event instanceof events.DocumentStartEvent) || this.events.length === 0) {
  28261. return false;
  28262. }
  28263. event = this.events[0];
  28264. return event instanceof events.ScalarEvent && (event.anchor == null) && (event.tag == null) && event.implicit && event.value === '';
  28265. }
  28266. check_empty_sequence() {
  28267. return this.event instanceof events.SequenceStartEvent && this.events[0] instanceof events.SequenceEndEvent;
  28268. }
  28269. check_empty_mapping() {
  28270. return this.event instanceof events.MappingStartEvent && this.events[0] instanceof events.MappingEndEvent;
  28271. }
  28272. check_simple_key() {
  28273. var length;
  28274. length = 0;
  28275. if (this.event instanceof events.NodeEvent && (this.event.anchor != null)) {
  28276. if (this.prepared_anchor == null) {
  28277. this.prepared_anchor = this.prepare_anchor(this.event.anchor);
  28278. }
  28279. length += this.prepared_anchor.length;
  28280. }
  28281. if ((this.event.tag != null) && (this.event instanceof events.ScalarEvent || this.event instanceof events.CollectionStartEvent)) {
  28282. if (this.prepared_tag == null) {
  28283. this.prepared_tag = this.prepare_tag(this.event.tag);
  28284. }
  28285. length += this.prepared_tag.length;
  28286. }
  28287. if (this.event instanceof events.ScalarEvent) {
  28288. if (this.analysis == null) {
  28289. this.analysis = this.analyze_scalar(this.event.value);
  28290. }
  28291. length += this.analysis.scalar.length;
  28292. }
  28293. return length < 128 && (this.event instanceof events.AliasEvent || (this.event instanceof events.ScalarEvent && !this.analysis.empty && !this.analysis.multiline) || this.check_empty_sequence() || this.check_empty_mapping());
  28294. }
  28295. // Anchor, Tag and Scalar processors
  28296. process_anchor(indicator) {
  28297. if (this.event.anchor == null) {
  28298. this.prepared_anchor = null;
  28299. return;
  28300. }
  28301. if (this.prepared_anchor == null) {
  28302. this.prepared_anchor = this.prepare_anchor(this.event.anchor);
  28303. }
  28304. if (this.prepared_anchor) {
  28305. this.write_indicator(`${indicator}${this.prepared_anchor}`, true);
  28306. }
  28307. return this.prepared_anchor = null;
  28308. }
  28309. process_tag() {
  28310. var tag;
  28311. tag = this.event.tag;
  28312. if (this.event instanceof events.ScalarEvent) {
  28313. if (this.style == null) {
  28314. this.style = this.choose_scalar_style();
  28315. }
  28316. if ((!this.canonical || (tag == null)) && ((this.style === '' && this.event.implicit[0]) || (this.style !== '' && this.event.implicit[1]))) {
  28317. this.prepared_tag = null;
  28318. return;
  28319. }
  28320. if (this.event.implicit[0] && (tag == null)) {
  28321. tag = '!';
  28322. this.prepared_tag = null;
  28323. }
  28324. } else if ((!this.canonical || (tag == null)) && this.event.implicit) {
  28325. this.prepared_tag = null;
  28326. return;
  28327. }
  28328. if (tag == null) {
  28329. this.error('tag is not specified');
  28330. }
  28331. if (this.prepared_tag == null) {
  28332. this.prepared_tag = this.prepare_tag(tag);
  28333. }
  28334. this.write_indicator(this.prepared_tag, true);
  28335. return this.prepared_tag = null;
  28336. }
  28337. process_scalar() {
  28338. var split;
  28339. if (this.analysis == null) {
  28340. this.analysis = this.analyze_scalar(this.event.value);
  28341. }
  28342. if (this.style == null) {
  28343. this.style = this.choose_scalar_style();
  28344. }
  28345. split = !this.simple_key_context;
  28346. switch (this.style) {
  28347. case '"':
  28348. this.write_double_quoted(this.analysis.scalar, split);
  28349. break;
  28350. case "'":
  28351. this.write_single_quoted(this.analysis.scalar, split);
  28352. break;
  28353. case '>':
  28354. this.write_folded(this.analysis.scalar);
  28355. break;
  28356. case '|':
  28357. this.write_literal(this.analysis.scalar);
  28358. break;
  28359. default:
  28360. this.write_plain(this.analysis.scalar, split);
  28361. }
  28362. this.analysis = null;
  28363. return this.style = null;
  28364. }
  28365. choose_scalar_style() {
  28366. var ref;
  28367. if (this.analysis == null) {
  28368. this.analysis = this.analyze_scalar(this.event.value);
  28369. }
  28370. if (this.event.style === '"' || this.canonical) {
  28371. return '"';
  28372. }
  28373. if (!this.event.style && this.event.implicit[0] && !(this.simple_key_context && (this.analysis.empty || this.analysis.multiline)) && ((this.flow_level && this.analysis.allow_flow_plain) || (!this.flow_level && this.analysis.allow_block_plain))) {
  28374. return '';
  28375. }
  28376. if (this.event.style && (ref = this.event.style, indexOf.call('|>', ref) >= 0) && !this.flow_level && !this.simple_key_context && this.analysis.allow_block) {
  28377. return this.event.style;
  28378. }
  28379. if ((!this.event.style || this.event.style === "'") && this.analysis.allow_single_quoted && !(this.simple_key_context && this.analysis.multiline)) {
  28380. return "'";
  28381. }
  28382. return '"';
  28383. }
  28384. // Analyzers
  28385. prepare_version([major, minor]) {
  28386. var version;
  28387. version = `${major}.${minor}`;
  28388. if (major === 1) {
  28389. return version;
  28390. } else {
  28391. return this.error('unsupported YAML version', version);
  28392. }
  28393. }
  28394. prepare_tag_handle(handle) {
  28395. var char, i, len, ref;
  28396. if (!handle) {
  28397. this.error('tag handle must not be empty');
  28398. }
  28399. if (handle[0] !== '!' || handle.slice(-1) !== '!') {
  28400. this.error("tag handle must start and end with '!':", handle);
  28401. }
  28402. ref = handle.slice(1, -1);
  28403. for (i = 0, len = ref.length; i < len; i++) {
  28404. char = ref[i];
  28405. if (!(('0' <= char && char <= '9') || ('A' <= char && char <= 'Z') || ('a' <= char && char <= 'z') || indexOf.call('-_', char) >= 0)) {
  28406. this.error(`invalid character '${char}' in the tag handle:`, handle);
  28407. }
  28408. }
  28409. return handle;
  28410. }
  28411. prepare_tag_prefix(prefix) {
  28412. var char, chunks, end, start;
  28413. if (!prefix) {
  28414. this.error('tag prefix must not be empty');
  28415. }
  28416. chunks = [];
  28417. start = 0;
  28418. end = +(prefix[0] === '!');
  28419. while (end < prefix.length) {
  28420. char = prefix[end];
  28421. if (('0' <= char && char <= '9') || ('A' <= char && char <= 'Z') || ('a' <= char && char <= 'z') || indexOf.call('-;/?!:@&=+$,_.~*\'()[]', char) >= 0) {
  28422. end++;
  28423. } else {
  28424. if (start < end) {
  28425. chunks.push(prefix.slice(start, end));
  28426. }
  28427. start = end = end + 1;
  28428. chunks.push(char);
  28429. }
  28430. }
  28431. if (start < end) {
  28432. chunks.push(prefix.slice(start, end));
  28433. }
  28434. return chunks.join('');
  28435. }
  28436. prepare_tag(tag) {
  28437. var char, chunks, end, handle, i, k, len, prefix, ref, start, suffix, suffix_text;
  28438. if (!tag) {
  28439. this.error('tag must not be empty');
  28440. }
  28441. if (tag === '!') {
  28442. return tag;
  28443. }
  28444. handle = null;
  28445. suffix = tag;
  28446. ref = ((function() {
  28447. var ref, results;
  28448. ref = this.tag_prefixes;
  28449. results = [];
  28450. for (k in ref) {
  28451. if (!hasProp.call(ref, k)) continue;
  28452. results.push(k);
  28453. }
  28454. return results;
  28455. }).call(this)).sort();
  28456. for (i = 0, len = ref.length; i < len; i++) {
  28457. prefix = ref[i];
  28458. if (tag.indexOf(prefix) === 0 && (prefix === '!' || prefix.length < tag.length)) {
  28459. handle = this.tag_prefixes[prefix];
  28460. suffix = tag.slice(prefix.length);
  28461. }
  28462. }
  28463. chunks = [];
  28464. start = end = 0;
  28465. while (end < suffix.length) {
  28466. char = suffix[end];
  28467. if (('0' <= char && char <= '9') || ('A' <= char && char <= 'Z') || ('a' <= char && char <= 'z') || indexOf.call('-;/?!:@&=+$,_.~*\'()[]', char) >= 0 || (char === '!' && handle !== '!')) {
  28468. end++;
  28469. } else {
  28470. if (start < end) {
  28471. chunks.push(suffix.slice(start, end));
  28472. }
  28473. start = end = end + 1;
  28474. chunks.push(char);
  28475. }
  28476. }
  28477. if (start < end) {
  28478. chunks.push(suffix.slice(start, end));
  28479. }
  28480. suffix_text = chunks.join('');
  28481. if (handle) {
  28482. return `${handle}${suffix_text}`;
  28483. } else {
  28484. return `!<${suffix_text}>`;
  28485. }
  28486. }
  28487. prepare_anchor(anchor) {
  28488. var char, i, len;
  28489. if (!anchor) {
  28490. this.error('anchor must not be empty');
  28491. }
  28492. for (i = 0, len = anchor.length; i < len; i++) {
  28493. char = anchor[i];
  28494. if (!(('0' <= char && char <= '9') || ('A' <= char && char <= 'Z') || ('a' <= char && char <= 'z') || indexOf.call('-_', char) >= 0)) {
  28495. this.error(`invalid character '${char}' in the anchor:`, anchor);
  28496. }
  28497. }
  28498. return anchor;
  28499. }
  28500. analyze_scalar(scalar) {
  28501. var allow_block, allow_block_plain, allow_double_quoted, allow_flow_plain, allow_single_quoted, block_indicators, break_space, char, flow_indicators, followed_by_whitespace, i, index, leading_break, leading_space, len, line_breaks, preceded_by_whitespace, previous_break, previous_space, ref, ref1, space_break, special_characters, trailing_break, trailing_space, unicode_characters;
  28502. // Empty scalar is a special case.
  28503. if (!scalar) {
  28504. new ScalarAnalysis(scalar, true, false, false, true, true, true, false);
  28505. }
  28506. // Indicators and special characters.
  28507. block_indicators = false;
  28508. flow_indicators = false;
  28509. line_breaks = false;
  28510. special_characters = false;
  28511. unicode_characters = false;
  28512. // Important whitespace combinations
  28513. leading_space = false;
  28514. leading_break = false;
  28515. trailing_space = false;
  28516. trailing_break = false;
  28517. break_space = false;
  28518. space_break = false;
  28519. // Check document indicators.
  28520. if (scalar.indexOf('---') === 0 || scalar.indexOf('...') === 0) {
  28521. block_indicators = true;
  28522. flow_indicators = true;
  28523. }
  28524. // First character or preceded by a whitespace.
  28525. preceded_by_whitespace = true;
  28526. // Last character or followed by a whitespace.
  28527. followed_by_whitespace = scalar.length === 1 || (ref = scalar[1], indexOf.call('\0 \t\r\n\x85\u2028\u2029', ref) >= 0);
  28528. // The previous character is a space.
  28529. previous_space = false;
  28530. // The previous character is a break
  28531. previous_break = false;
  28532. index = 0;
  28533. for (index = i = 0, len = scalar.length; i < len; index = ++i) {
  28534. char = scalar[index];
  28535. // Check for indicators.
  28536. if (index === 0) {
  28537. // Leading indicators are special characters.
  28538. if (indexOf.call('#,[]{}&*!|>\'"%@`', char) >= 0 || (char === '-' && followed_by_whitespace)) {
  28539. flow_indicators = true;
  28540. block_indicators = true;
  28541. } else if (indexOf.call('?:', char) >= 0) {
  28542. flow_indicators = true;
  28543. if (followed_by_whitespace) {
  28544. block_indicators = true;
  28545. }
  28546. }
  28547. } else {
  28548. // Some indicators cannot appear within a scalar as well.
  28549. if (indexOf.call(',?[]{}', char) >= 0) {
  28550. flow_indicators = true;
  28551. } else if (char === ':') {
  28552. flow_indicators = true;
  28553. if (followed_by_whitespace) {
  28554. block_indicators = true;
  28555. }
  28556. } else if (char === '#' && preceded_by_whitespace) {
  28557. flow_indicators = true;
  28558. block_indicators = true;
  28559. }
  28560. }
  28561. // Check for line breaks, special, and unicode characters.
  28562. if (indexOf.call('\n\x85\u2028\u2029', char) >= 0) {
  28563. line_breaks = true;
  28564. }
  28565. if (!(char === '\n' || ('\x20' <= char && char <= '\x7e'))) {
  28566. if (char !== '\uFEFF' && (char === '\x85' || ('\xA0' <= char && char <= '\uD7FF') || ('\uE000' <= char && char <= '\uFFFD'))) {
  28567. unicode_characters = true;
  28568. if (!this.allow_unicode) {
  28569. special_characters = true;
  28570. }
  28571. } else {
  28572. special_characters = true;
  28573. }
  28574. }
  28575. // Detect important whitespace combinations.
  28576. if (char === ' ') {
  28577. if (index === 0) {
  28578. leading_space = true;
  28579. }
  28580. if (index === scalar.length - 1) {
  28581. trailing_space = true;
  28582. }
  28583. if (previous_break) {
  28584. break_space = true;
  28585. }
  28586. previous_break = false;
  28587. previous_space = true;
  28588. } else if (indexOf.call('\n\x85\u2028\u2029', char) >= 0) {
  28589. if (index === 0) {
  28590. leading_break = true;
  28591. }
  28592. if (index === scalar.length - 1) {
  28593. trailing_break = true;
  28594. }
  28595. if (previous_space) {
  28596. space_break = true;
  28597. }
  28598. previous_break = true;
  28599. previous_space = false;
  28600. } else {
  28601. previous_break = false;
  28602. previous_space = false;
  28603. }
  28604. // Prepare for the next character.
  28605. preceded_by_whitespace = indexOf.call(C_WHITESPACE, char) >= 0;
  28606. followed_by_whitespace = index + 2 >= scalar.length || (ref1 = scalar[index + 2], indexOf.call(C_WHITESPACE, ref1) >= 0);
  28607. }
  28608. // Let's decide what styles are allowed.
  28609. allow_flow_plain = true;
  28610. allow_block_plain = true;
  28611. allow_single_quoted = true;
  28612. allow_double_quoted = true;
  28613. allow_block = true;
  28614. // Leading and trailing whitespaces are bad for plain scalars.
  28615. if (leading_space || leading_break || trailing_space || trailing_break) {
  28616. allow_flow_plain = allow_block_plain = false;
  28617. }
  28618. // We do not permit trailing spaces for block scalars.
  28619. if (trailing_space) {
  28620. allow_block = false;
  28621. }
  28622. // Spaces at the beginning of a new line are only acceptable for block scalars.
  28623. if (break_space) {
  28624. allow_flow_plain = allow_block_plain = allow_single_quoted = false;
  28625. }
  28626. // Spaces followed by breaks, as well as special character are only allowed for double quoted
  28627. // scalars.
  28628. if (space_break || special_characters) {
  28629. allow_flow_plain = allow_block_plain = allow_single_quoted = allow_block = false;
  28630. }
  28631. // Although the plain scalar writer supports breaks, we never emit multiline plain scalars.
  28632. if (line_breaks) {
  28633. allow_flow_plain = allow_block_plain = false;
  28634. }
  28635. // Flow indicators are forbidden for flow plain scalars.
  28636. if (flow_indicators) {
  28637. allow_flow_plain = false;
  28638. }
  28639. // Block indicators are forbidden for block plain scalars.
  28640. if (block_indicators) {
  28641. allow_block_plain = false;
  28642. }
  28643. return new ScalarAnalysis(scalar, false, line_breaks, allow_flow_plain, allow_block_plain, allow_single_quoted, allow_double_quoted, allow_block);
  28644. }
  28645. // Writers
  28646. /*
  28647. Write BOM if needed.
  28648. */
  28649. write_stream_start() {
  28650. if (this.encoding && this.encoding.indexOf('utf-16') === 0) {
  28651. return this.stream.write('\uFEFF', this.encoding);
  28652. }
  28653. }
  28654. write_stream_end() {
  28655. return this.flush_stream();
  28656. }
  28657. write_indicator(indicator, need_whitespace, options = {}) {
  28658. var data;
  28659. data = this.whitespace || !need_whitespace ? indicator : ' ' + indicator;
  28660. this.whitespace = !!options.whitespace;
  28661. this.indentation && (this.indentation = !!options.indentation);
  28662. this.column += data.length;
  28663. this.open_ended = false;
  28664. return this.stream.write(data, this.encoding);
  28665. }
  28666. write_indent() {
  28667. var data, indent, ref;
  28668. indent = (ref = this.indent) != null ? ref : 0;
  28669. if (!this.indentation || this.column > indent || (this.column === indent && !this.whitespace)) {
  28670. this.write_line_break();
  28671. }
  28672. if (this.column < indent) {
  28673. this.whitespace = true;
  28674. data = new Array(indent - this.column + 1).join(' ');
  28675. this.column = indent;
  28676. return this.stream.write(data, this.encoding);
  28677. }
  28678. }
  28679. write_line_break(data) {
  28680. this.whitespace = true;
  28681. this.indentation = true;
  28682. this.line += 1;
  28683. this.column = 0;
  28684. return this.stream.write(data != null ? data : this.best_line_break, this.encoding);
  28685. }
  28686. write_version_directive(version_text) {
  28687. this.stream.write(`%YAML ${version_text}`, this.encoding);
  28688. return this.write_line_break();
  28689. }
  28690. write_tag_directive(handle_text, prefix_text) {
  28691. this.stream.write(`%TAG ${handle_text} ${prefix_text}`, this.encoding);
  28692. return this.write_line_break();
  28693. }
  28694. write_single_quoted(text, split = true) {
  28695. var br, breaks, char, data, end, i, len, ref, spaces, start;
  28696. this.write_indicator("'", true);
  28697. spaces = false;
  28698. breaks = false;
  28699. start = end = 0;
  28700. while (end <= text.length) {
  28701. char = text[end];
  28702. if (spaces) {
  28703. if ((char == null) || char !== ' ') {
  28704. if (start + 1 === end && this.column > this.best_width && split && start !== 0 && end !== text.length) {
  28705. this.write_indent();
  28706. } else {
  28707. data = text.slice(start, end);
  28708. this.column += data.length;
  28709. this.stream.write(data, this.encoding);
  28710. }
  28711. start = end;
  28712. }
  28713. } else if (breaks) {
  28714. if ((char == null) || indexOf.call('\n\x85\u2028\u2029', char) < 0) {
  28715. if (text[start] === '\n') {
  28716. this.write_line_break();
  28717. }
  28718. ref = text.slice(start, end);
  28719. for (i = 0, len = ref.length; i < len; i++) {
  28720. br = ref[i];
  28721. if (br === '\n') {
  28722. this.write_line_break();
  28723. } else {
  28724. this.write_line_break(br);
  28725. }
  28726. }
  28727. this.write_indent();
  28728. start = end;
  28729. }
  28730. } else if (((char == null) || indexOf.call(' \n\x85\u2028\u2029', char) >= 0 || char === "'") && start < end) {
  28731. data = text.slice(start, end);
  28732. this.column += data.length;
  28733. this.stream.write(data, this.encoding);
  28734. start = end;
  28735. }
  28736. if (char === "'") {
  28737. this.column += 2;
  28738. this.stream.write("''", this.encoding);
  28739. start = end + 1;
  28740. }
  28741. if (char != null) {
  28742. spaces = char === ' ';
  28743. breaks = indexOf.call('\n\x85\u2028\u2029', char) >= 0;
  28744. }
  28745. end++;
  28746. }
  28747. return this.write_indicator("'", false);
  28748. }
  28749. write_double_quoted(text, split = true) {
  28750. var char, data, end, start;
  28751. this.write_indicator('"', true);
  28752. start = end = 0;
  28753. while (end <= text.length) {
  28754. char = text[end];
  28755. if ((char == null) || indexOf.call('"\\\x85\u2028\u2029\uFEFF', char) >= 0 || !(('\x20' <= char && char <= '\x7E') || (this.allow_unicode && (('\xA0' <= char && char <= '\uD7FF') || ('\uE000' <= char && char <= '\uFFFD'))))) {
  28756. if (start < end) {
  28757. data = text.slice(start, end);
  28758. this.column += data.length;
  28759. this.stream.write(data, this.encoding);
  28760. start = end;
  28761. }
  28762. if (char != null) {
  28763. data = char in ESCAPE_REPLACEMENTS ? '\\' + ESCAPE_REPLACEMENTS[char] : char <= '\xFF' ? `\\x${util.pad_left(util.to_hex(char), '0', 2)}` : char <= '\uFFFF' ? `\\u${util.pad_left(util.to_hex(char), '0', 4)}` : `\\U${util.pad_left(util.to_hex(char), '0', 16)}`;
  28764. this.column += data.length;
  28765. this.stream.write(data, this.encoding);
  28766. start = end + 1;
  28767. }
  28768. }
  28769. if (split && (0 < end && end < text.length - 1) && (char === ' ' || start >= end) && this.column + (end - start) > this.best_width) {
  28770. data = `${text.slice(start, end)}\\`;
  28771. if (start < end) {
  28772. start = end;
  28773. }
  28774. this.column += data.length;
  28775. this.stream.write(data, this.encoding);
  28776. this.write_indent();
  28777. this.whitespace = false;
  28778. this.indentation = false;
  28779. if (text[start] === ' ') {
  28780. data = '\\';
  28781. this.column += data.length;
  28782. this.stream.write(data, this.encoding);
  28783. }
  28784. }
  28785. end++;
  28786. }
  28787. return this.write_indicator('"', false);
  28788. }
  28789. write_folded(text) {
  28790. var br, breaks, char, data, end, hints, i, leading_space, len, ref, results, spaces, start;
  28791. hints = this.determine_block_hints(text);
  28792. this.write_indicator(`>${hints}`, true);
  28793. if (hints.slice(-1) === '+') {
  28794. this.open_ended = true;
  28795. }
  28796. this.write_line_break();
  28797. leading_space = true;
  28798. breaks = true;
  28799. spaces = false;
  28800. start = end = 0;
  28801. results = [];
  28802. while (end <= text.length) {
  28803. char = text[end];
  28804. if (breaks) {
  28805. if ((char == null) || indexOf.call('\n\x85\u2028\u2029', char) < 0) {
  28806. if (!leading_space && (char != null) && char !== ' ' && text[start] === '\n') {
  28807. this.write_line_break();
  28808. }
  28809. leading_space = char === ' ';
  28810. ref = text.slice(start, end);
  28811. for (i = 0, len = ref.length; i < len; i++) {
  28812. br = ref[i];
  28813. if (br === '\n') {
  28814. this.write_line_break();
  28815. } else {
  28816. this.write_line_break(br);
  28817. }
  28818. }
  28819. if (char != null) {
  28820. this.write_indent();
  28821. }
  28822. start = end;
  28823. }
  28824. } else if (spaces) {
  28825. if (char !== ' ') {
  28826. if (start + 1 === end && this.column > this.best_width) {
  28827. this.write_indent();
  28828. } else {
  28829. data = text.slice(start, end);
  28830. this.column += data.length;
  28831. this.stream.write(data, this.encoding);
  28832. }
  28833. start = end;
  28834. }
  28835. } else if ((char == null) || indexOf.call(' \n\x85\u2028\u2029', char) >= 0) {
  28836. data = text.slice(start, end);
  28837. this.column += data.length;
  28838. this.stream.write(data, this.encoding);
  28839. if (char == null) {
  28840. this.write_line_break();
  28841. }
  28842. start = end;
  28843. }
  28844. if (char != null) {
  28845. breaks = indexOf.call('\n\x85\u2028\u2029', char) >= 0;
  28846. spaces = char === ' ';
  28847. }
  28848. results.push(end++);
  28849. }
  28850. return results;
  28851. }
  28852. write_literal(text) {
  28853. var br, breaks, char, data, end, hints, i, len, ref, results, start;
  28854. hints = this.determine_block_hints(text);
  28855. this.write_indicator(`|${hints}`, true);
  28856. if (hints.slice(-1) === '+') {
  28857. this.open_ended = true;
  28858. }
  28859. this.write_line_break();
  28860. breaks = true;
  28861. start = end = 0;
  28862. results = [];
  28863. while (end <= text.length) {
  28864. char = text[end];
  28865. if (breaks) {
  28866. if ((char == null) || indexOf.call('\n\x85\u2028\u2029', char) < 0) {
  28867. ref = text.slice(start, end);
  28868. for (i = 0, len = ref.length; i < len; i++) {
  28869. br = ref[i];
  28870. if (br === '\n') {
  28871. this.write_line_break();
  28872. } else {
  28873. this.write_line_break(br);
  28874. }
  28875. }
  28876. if (char != null) {
  28877. this.write_indent();
  28878. }
  28879. start = end;
  28880. }
  28881. } else {
  28882. if ((char == null) || indexOf.call('\n\x85\u2028\u2029', char) >= 0) {
  28883. data = text.slice(start, end);
  28884. this.stream.write(data, this.encoding);
  28885. if (char == null) {
  28886. this.write_line_break();
  28887. }
  28888. start = end;
  28889. }
  28890. }
  28891. if (char != null) {
  28892. breaks = indexOf.call('\n\x85\u2028\u2029', char) >= 0;
  28893. }
  28894. results.push(end++);
  28895. }
  28896. return results;
  28897. }
  28898. write_plain(text, split = true) {
  28899. var br, breaks, char, data, end, i, len, ref, results, spaces, start;
  28900. if (!text) {
  28901. return;
  28902. }
  28903. if (this.root_context) {
  28904. this.open_ended = true;
  28905. }
  28906. if (!this.whitespace) {
  28907. data = ' ';
  28908. this.column += data.length;
  28909. this.stream.write(data, this.encoding);
  28910. }
  28911. this.whitespace = false;
  28912. this.indentation = false;
  28913. spaces = false;
  28914. breaks = false;
  28915. start = end = 0;
  28916. results = [];
  28917. while (end <= text.length) {
  28918. char = text[end];
  28919. if (spaces) {
  28920. if (char !== ' ') {
  28921. if (start + 1 === end && this.column > this.best_width && split) {
  28922. this.write_indent();
  28923. this.whitespace = false;
  28924. this.indentation = false;
  28925. } else {
  28926. data = text.slice(start, end);
  28927. this.column += data.length;
  28928. this.stream.write(data, this.encoding);
  28929. }
  28930. start = end;
  28931. }
  28932. } else if (breaks) {
  28933. if (indexOf.call('\n\x85\u2028\u2029', char) < 0) {
  28934. if (text[start] === '\n') {
  28935. this.write_line_break();
  28936. }
  28937. ref = text.slice(start, end);
  28938. for (i = 0, len = ref.length; i < len; i++) {
  28939. br = ref[i];
  28940. if (br === '\n') {
  28941. this.write_line_break();
  28942. } else {
  28943. this.write_line_break(br);
  28944. }
  28945. }
  28946. this.write_indent();
  28947. this.whitespace = false;
  28948. this.indentation = false;
  28949. start = end;
  28950. }
  28951. } else {
  28952. if ((char == null) || indexOf.call(' \n\x85\u2028\u2029', char) >= 0) {
  28953. data = text.slice(start, end);
  28954. this.column += data.length;
  28955. this.stream.write(data, this.encoding);
  28956. start = end;
  28957. }
  28958. }
  28959. if (char != null) {
  28960. spaces = char === ' ';
  28961. breaks = indexOf.call('\n\x85\u2028\u2029', char) >= 0;
  28962. }
  28963. results.push(end++);
  28964. }
  28965. return results;
  28966. }
  28967. determine_block_hints(text) {
  28968. var first, hints, i, last, penultimate;
  28969. hints = '';
  28970. first = text[0], i = text.length - 2, penultimate = text[i++], last = text[i++];
  28971. if (indexOf.call(' \n\x85\u2028\u2029', first) >= 0) {
  28972. hints += this.best_indent;
  28973. }
  28974. if (indexOf.call('\n\x85\u2028\u2029', last) < 0) {
  28975. hints += '-';
  28976. } else if (text.length === 1 || indexOf.call('\n\x85\u2028\u2029', penultimate) >= 0) {
  28977. hints += '+';
  28978. }
  28979. return hints;
  28980. }
  28981. flush_stream() {
  28982. var base;
  28983. return typeof (base = this.stream).flush === "function" ? base.flush() : void 0;
  28984. }
  28985. /*
  28986. Helper for common error pattern.
  28987. */
  28988. error(message, context) {
  28989. var ref, ref1;
  28990. if (context) {
  28991. context = (ref = context != null ? (ref1 = context.constructor) != null ? ref1.name : void 0 : void 0) != null ? ref : util.inspect(context);
  28992. }
  28993. throw new exports.EmitterError(`${message}${(context ? ` ${context}` : '')}`);
  28994. }
  28995. };
  28996. C_WHITESPACE = '\0 \t\r\n\x85\u2028\u2029';
  28997. DEFAULT_TAG_PREFIXES = {
  28998. '!': '!',
  28999. 'tag:yaml.org,2002:': '!!'
  29000. };
  29001. ESCAPE_REPLACEMENTS = {
  29002. '\0': '0',
  29003. '\x07': 'a',
  29004. '\x08': 'b',
  29005. '\x09': 't',
  29006. '\x0A': 'n',
  29007. '\x0B': 'v',
  29008. '\x0C': 'f',
  29009. '\x0D': 'r',
  29010. '\x1B': 'e',
  29011. '"': '"',
  29012. '\\': '\\',
  29013. '\x85': 'N',
  29014. '\xA0': '_',
  29015. '\u2028': 'L',
  29016. '\u2029': 'P'
  29017. };
  29018. ctor = Emitter.prototype.initialise;
  29019. return Emitter;
  29020. }).call(this);
  29021. ScalarAnalysis = class ScalarAnalysis {
  29022. constructor(scalar1, empty, multiline, allow_flow_plain1, allow_block_plain1, allow_single_quoted1, allow_double_quoted1, allow_block1) {
  29023. this.scalar = scalar1;
  29024. this.empty = empty;
  29025. this.multiline = multiline;
  29026. this.allow_flow_plain = allow_flow_plain1;
  29027. this.allow_block_plain = allow_block_plain1;
  29028. this.allow_single_quoted = allow_single_quoted1;
  29029. this.allow_double_quoted = allow_double_quoted1;
  29030. this.allow_block = allow_block1;
  29031. }
  29032. };
  29033. }).call(this);
  29034. /***/ }),
  29035. /***/ 45372:
  29036. /***/ (function() {
  29037. (function() {
  29038. var indexOf = [].indexOf;
  29039. this.Mark = class Mark {
  29040. constructor(line, column, buffer, pointer) {
  29041. this.line = line;
  29042. this.column = column;
  29043. this.buffer = buffer;
  29044. this.pointer = pointer;
  29045. }
  29046. get_snippet(indent = 4, max_length = 75) {
  29047. var break_chars, end, head, ref, ref1, start, tail;
  29048. if (this.buffer == null) {
  29049. return null;
  29050. }
  29051. break_chars = '\x00\r\n\x85\u2028\u2029';
  29052. head = '';
  29053. start = this.pointer;
  29054. while (start > 0 && (ref = this.buffer[start - 1], indexOf.call(break_chars, ref) < 0)) {
  29055. start--;
  29056. if (this.pointer - start > max_length / 2 - 1) {
  29057. head = ' ... ';
  29058. start += 5;
  29059. break;
  29060. }
  29061. }
  29062. tail = '';
  29063. end = this.pointer;
  29064. while (end < this.buffer.length && (ref1 = this.buffer[end], indexOf.call(break_chars, ref1) < 0)) {
  29065. end++;
  29066. if (end - this.pointer > max_length / 2 - 1) {
  29067. tail = ' ... ';
  29068. end -= 5;
  29069. break;
  29070. }
  29071. }
  29072. return `${(new Array(indent)).join(' ')}${head}${this.buffer.slice(start, end)}${tail}\n${(new Array(indent + this.pointer - start + head.length)).join(' ')}^`;
  29073. }
  29074. toString() {
  29075. var snippet, where;
  29076. snippet = this.get_snippet();
  29077. where = ` on line ${this.line + 1}, column ${this.column + 1}`;
  29078. if (snippet) {
  29079. return where;
  29080. } else {
  29081. return `${where}:\n${snippet}`;
  29082. }
  29083. }
  29084. };
  29085. this.YAMLError = class YAMLError extends Error {
  29086. constructor(message) {
  29087. super(message);
  29088. // Hack to get the stack on the error somehow
  29089. Object.defineProperty(this, 'stack', {
  29090. get: function() {
  29091. return this.toString() + '\n' + (new Error).stack.split('\n').slice(1).join('\n');
  29092. }
  29093. });
  29094. }
  29095. toString() {
  29096. return this.message;
  29097. }
  29098. };
  29099. this.MarkedYAMLError = class MarkedYAMLError extends this.YAMLError {
  29100. constructor(context, context_mark, problem, problem_mark, note) {
  29101. super();
  29102. this.context = context;
  29103. this.context_mark = context_mark;
  29104. this.problem = problem;
  29105. this.problem_mark = problem_mark;
  29106. this.note = note;
  29107. }
  29108. toString() {
  29109. var lines;
  29110. lines = [];
  29111. if (this.context != null) {
  29112. lines.push(this.context);
  29113. }
  29114. if ((this.context_mark != null) && ((this.problem == null) || (this.problem_mark == null) || this.context_mark.line !== this.problem_mark.line || this.context_mark.column !== this.problem_mark.column)) {
  29115. lines.push(this.context_mark.toString());
  29116. }
  29117. if (this.problem != null) {
  29118. lines.push(this.problem);
  29119. }
  29120. if (this.problem_mark != null) {
  29121. lines.push(this.problem_mark.toString());
  29122. }
  29123. if (this.note != null) {
  29124. lines.push(this.note);
  29125. }
  29126. return lines.join('\n');
  29127. }
  29128. };
  29129. }).call(this);
  29130. /***/ }),
  29131. /***/ 35063:
  29132. /***/ (function() {
  29133. (function() {
  29134. this.Event = class Event {
  29135. constructor(start_mark1, end_mark1) {
  29136. this.start_mark = start_mark1;
  29137. this.end_mark = end_mark1;
  29138. }
  29139. };
  29140. this.NodeEvent = class NodeEvent extends this.Event {
  29141. constructor(anchor1, start_mark, end_mark) {
  29142. super(start_mark, end_mark);
  29143. this.anchor = anchor1;
  29144. }
  29145. };
  29146. this.CollectionStartEvent = class CollectionStartEvent extends this.NodeEvent {
  29147. constructor(anchor, tag, implicit, start_mark, end_mark, flow_style) {
  29148. super(anchor, start_mark, end_mark);
  29149. this.tag = tag;
  29150. this.implicit = implicit;
  29151. this.flow_style = flow_style;
  29152. }
  29153. };
  29154. this.CollectionEndEvent = class CollectionEndEvent extends this.Event {};
  29155. this.StreamStartEvent = class StreamStartEvent extends this.Event {
  29156. constructor(start_mark, end_mark, encoding) {
  29157. super(start_mark, end_mark);
  29158. this.encoding = encoding;
  29159. }
  29160. };
  29161. this.StreamEndEvent = class StreamEndEvent extends this.Event {};
  29162. this.DocumentStartEvent = class DocumentStartEvent extends this.Event {
  29163. constructor(start_mark, end_mark, explicit, version, tags) {
  29164. super(start_mark, end_mark);
  29165. this.explicit = explicit;
  29166. this.version = version;
  29167. this.tags = tags;
  29168. }
  29169. };
  29170. this.DocumentEndEvent = class DocumentEndEvent extends this.Event {
  29171. constructor(start_mark, end_mark, explicit) {
  29172. super(start_mark, end_mark);
  29173. this.explicit = explicit;
  29174. }
  29175. };
  29176. this.AliasEvent = class AliasEvent extends this.NodeEvent {};
  29177. this.ScalarEvent = class ScalarEvent extends this.NodeEvent {
  29178. constructor(anchor, tag, implicit, value, start_mark, end_mark, style) {
  29179. super(anchor, start_mark, end_mark);
  29180. this.tag = tag;
  29181. this.implicit = implicit;
  29182. this.value = value;
  29183. this.style = style;
  29184. }
  29185. };
  29186. this.SequenceStartEvent = class SequenceStartEvent extends this.CollectionStartEvent {};
  29187. this.SequenceEndEvent = class SequenceEndEvent extends this.CollectionEndEvent {};
  29188. this.MappingStartEvent = class MappingStartEvent extends this.CollectionStartEvent {};
  29189. this.MappingEndEvent = class MappingEndEvent extends this.CollectionEndEvent {};
  29190. }).call(this);
  29191. /***/ }),
  29192. /***/ 82696:
  29193. /***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
  29194. (function() {
  29195. var composer, constructor, parser, reader, resolver, scanner, util;
  29196. util = __webpack_require__(23823);
  29197. reader = __webpack_require__(27026);
  29198. scanner = __webpack_require__(72265);
  29199. parser = __webpack_require__(72806);
  29200. composer = __webpack_require__(6391);
  29201. resolver = __webpack_require__(3579);
  29202. constructor = __webpack_require__(51574);
  29203. this.make_loader = function(Reader = reader.Reader, Scanner = scanner.Scanner, Parser = parser.Parser, Composer = composer.Composer, Resolver = resolver.Resolver, Constructor = constructor.Constructor) {
  29204. var Loader, components;
  29205. components = [Reader, Scanner, Parser, Composer, Resolver, Constructor];
  29206. return Loader = (function() {
  29207. var component;
  29208. class Loader {
  29209. constructor(stream) {
  29210. var i, len, ref;
  29211. components[0].prototype.initialise.call(this, stream);
  29212. ref = components.slice(1);
  29213. for (i = 0, len = ref.length; i < len; i++) {
  29214. component = ref[i];
  29215. component.prototype.initialise.call(this);
  29216. }
  29217. }
  29218. };
  29219. util.extend(Loader.prototype, ...((function() {
  29220. var i, len, results;
  29221. results = [];
  29222. for (i = 0, len = components.length; i < len; i++) {
  29223. component = components[i];
  29224. results.push(component.prototype);
  29225. }
  29226. return results;
  29227. })()));
  29228. return Loader;
  29229. }).call(this);
  29230. };
  29231. this.Loader = this.make_loader();
  29232. }).call(this);
  29233. /***/ }),
  29234. /***/ 96914:
  29235. /***/ (function() {
  29236. (function() {
  29237. var unique_id;
  29238. unique_id = 0;
  29239. this.Node = class Node {
  29240. constructor(tag1, value1, start_mark1, end_mark1) {
  29241. this.tag = tag1;
  29242. this.value = value1;
  29243. this.start_mark = start_mark1;
  29244. this.end_mark = end_mark1;
  29245. this.unique_id = `node_${unique_id++}`;
  29246. }
  29247. };
  29248. this.ScalarNode = (function() {
  29249. class ScalarNode extends this.Node {
  29250. constructor(tag, value, start_mark, end_mark, style) {
  29251. super(tag, value, start_mark, end_mark);
  29252. this.style = style;
  29253. }
  29254. };
  29255. ScalarNode.prototype.id = 'scalar';
  29256. return ScalarNode;
  29257. }).call(this);
  29258. this.CollectionNode = class CollectionNode extends this.Node {
  29259. constructor(tag, value, start_mark, end_mark, flow_style) {
  29260. super(tag, value, start_mark, end_mark);
  29261. this.flow_style = flow_style;
  29262. }
  29263. };
  29264. this.SequenceNode = (function() {
  29265. class SequenceNode extends this.CollectionNode {};
  29266. SequenceNode.prototype.id = 'sequence';
  29267. return SequenceNode;
  29268. }).call(this);
  29269. this.MappingNode = (function() {
  29270. class MappingNode extends this.CollectionNode {};
  29271. MappingNode.prototype.id = 'mapping';
  29272. return MappingNode;
  29273. }).call(this);
  29274. }).call(this);
  29275. /***/ }),
  29276. /***/ 72806:
  29277. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  29278. (function() {
  29279. var MarkedYAMLError, events, tokens,
  29280. hasProp = {}.hasOwnProperty;
  29281. events = __webpack_require__(35063);
  29282. ({MarkedYAMLError} = __webpack_require__(45372));
  29283. tokens = __webpack_require__(59902);
  29284. this.ParserError = class ParserError extends MarkedYAMLError {};
  29285. this.Parser = (function() {
  29286. var DEFAULT_TAGS, ctor;
  29287. class Parser {
  29288. constructor() {
  29289. return ctor.apply(this, arguments);
  29290. }
  29291. initialise() {
  29292. this.current_event = null;
  29293. this.yaml_version = null;
  29294. this.tag_handles = {};
  29295. this.states = [];
  29296. this.marks = [];
  29297. return this.state = 'parse_stream_start';
  29298. }
  29299. /*
  29300. Reset the state attributes.
  29301. */
  29302. dispose() {
  29303. this.states = [];
  29304. return this.state = null;
  29305. }
  29306. /*
  29307. Check the type of the next event.
  29308. */
  29309. check_event(...choices) {
  29310. var choice, i, len;
  29311. if (this.current_event === null) {
  29312. if (this.state != null) {
  29313. this.current_event = this[this.state]();
  29314. }
  29315. }
  29316. if (this.current_event !== null) {
  29317. if (choices.length === 0) {
  29318. return true;
  29319. }
  29320. for (i = 0, len = choices.length; i < len; i++) {
  29321. choice = choices[i];
  29322. if (this.current_event instanceof choice) {
  29323. return true;
  29324. }
  29325. }
  29326. }
  29327. return false;
  29328. }
  29329. /*
  29330. Get the next event.
  29331. */
  29332. peek_event() {
  29333. if (this.current_event === null && (this.state != null)) {
  29334. this.current_event = this[this.state]();
  29335. }
  29336. return this.current_event;
  29337. }
  29338. /*
  29339. Get the event and proceed further.
  29340. */
  29341. get_event() {
  29342. var event;
  29343. if (this.current_event === null && (this.state != null)) {
  29344. this.current_event = this[this.state]();
  29345. }
  29346. event = this.current_event;
  29347. this.current_event = null;
  29348. return event;
  29349. }
  29350. // stream ::= STREAM-START implicit_document? explicit_document* STREAM-END
  29351. // implicit_document ::= block_node DOCUMENT-END*
  29352. // explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*
  29353. /*
  29354. Parse the stream start.
  29355. */
  29356. parse_stream_start() {
  29357. var event, token;
  29358. token = this.get_token();
  29359. event = new events.StreamStartEvent(token.start_mark, token.end_mark);
  29360. // Prepare the next state,
  29361. this.state = 'parse_implicit_document_start';
  29362. return event;
  29363. }
  29364. /*
  29365. Parse an implicit document.
  29366. */
  29367. parse_implicit_document_start() {
  29368. var end_mark, event, start_mark, token;
  29369. if (!this.check_token(tokens.DirectiveToken, tokens.DocumentStartToken, tokens.StreamEndToken)) {
  29370. this.tag_handles = DEFAULT_TAGS;
  29371. token = this.peek_token();
  29372. start_mark = end_mark = token.start_mark;
  29373. event = new events.DocumentStartEvent(start_mark, end_mark, false);
  29374. // Prepare the next state
  29375. this.states.push('parse_document_end');
  29376. this.state = 'parse_block_node';
  29377. return event;
  29378. } else {
  29379. return this.parse_document_start();
  29380. }
  29381. }
  29382. /*
  29383. Parse an explicit document.
  29384. */
  29385. parse_document_start() {
  29386. var end_mark, event, start_mark, tags, token, version;
  29387. while (this.check_token(tokens.DocumentEndToken)) {
  29388. // Parse any extra document end indicators
  29389. this.get_token();
  29390. }
  29391. if (!this.check_token(tokens.StreamEndToken)) {
  29392. start_mark = this.peek_token().start_mark;
  29393. [version, tags] = this.process_directives();
  29394. if (!this.check_token(tokens.DocumentStartToken)) {
  29395. throw new exports.ParserError(`expected '<document start>', but found ${(this.peek_token().id)}`, this.peek_token().start_mark);
  29396. }
  29397. token = this.get_token();
  29398. end_mark = token.end_mark;
  29399. event = new events.DocumentStartEvent(start_mark, end_mark, true, version, tags);
  29400. this.states.push('parse_document_end');
  29401. this.state = 'parse_document_content';
  29402. } else {
  29403. // Parse the end of the stream.
  29404. token = this.get_token();
  29405. event = new events.StreamEndEvent(token.start_mark, token.end_mark);
  29406. if (this.states.length !== 0) {
  29407. throw new Error('assertion error, states should be empty');
  29408. }
  29409. if (this.marks.length !== 0) {
  29410. throw new Error('assertion error, marks should be empty');
  29411. }
  29412. this.state = null;
  29413. }
  29414. return event;
  29415. }
  29416. /*
  29417. Parse the document end.
  29418. */
  29419. parse_document_end() {
  29420. var end_mark, event, explicit, start_mark, token;
  29421. token = this.peek_token();
  29422. start_mark = end_mark = token.start_mark;
  29423. explicit = false;
  29424. if (this.check_token(tokens.DocumentEndToken)) {
  29425. token = this.get_token();
  29426. end_mark = token.end_mark;
  29427. explicit = true;
  29428. }
  29429. event = new events.DocumentEndEvent(start_mark, end_mark, explicit);
  29430. // Prepare next state.
  29431. this.state = 'parse_document_start';
  29432. return event;
  29433. }
  29434. parse_document_content() {
  29435. var event;
  29436. if (this.check_token(tokens.DirectiveToken, tokens.DocumentStartToken, tokens.DocumentEndToken, tokens.StreamEndToken)) {
  29437. event = this.process_empty_scalar(this.peek_token().start_mark);
  29438. this.state = this.states.pop();
  29439. return event;
  29440. } else {
  29441. return this.parse_block_node();
  29442. }
  29443. }
  29444. process_directives() {
  29445. var handle, major, minor, prefix, ref, tag_handles_copy, token, value;
  29446. this.yaml_version = null;
  29447. this.tag_handles = {};
  29448. while (this.check_token(tokens.DirectiveToken)) {
  29449. token = this.get_token();
  29450. if (token.name === 'YAML') {
  29451. if (this.yaml_version !== null) {
  29452. throw new exports.ParserError(null, null, 'found duplicate YAML directive', token.start_mark);
  29453. }
  29454. [major, minor] = token.value;
  29455. if (major !== 1) {
  29456. throw new exports.ParserError(null, null, 'found incompatible YAML document (version 1.* is required)', token.start_mark);
  29457. }
  29458. this.yaml_version = token.value;
  29459. } else if (token.name === 'TAG') {
  29460. [handle, prefix] = token.value;
  29461. if (handle in this.tag_handles) {
  29462. throw new exports.ParserError(null, null, `duplicate tag handle ${handle}`, token.start_mark);
  29463. }
  29464. this.tag_handles[handle] = prefix;
  29465. }
  29466. }
  29467. tag_handles_copy = null;
  29468. ref = this.tag_handles;
  29469. for (handle in ref) {
  29470. if (!hasProp.call(ref, handle)) continue;
  29471. prefix = ref[handle];
  29472. if (tag_handles_copy == null) {
  29473. tag_handles_copy = {};
  29474. }
  29475. tag_handles_copy[handle] = prefix;
  29476. }
  29477. value = [this.yaml_version, tag_handles_copy];
  29478. for (handle in DEFAULT_TAGS) {
  29479. if (!hasProp.call(DEFAULT_TAGS, handle)) continue;
  29480. prefix = DEFAULT_TAGS[handle];
  29481. if (!(prefix in this.tag_handles)) {
  29482. this.tag_handles[handle] = prefix;
  29483. }
  29484. }
  29485. return value;
  29486. }
  29487. // block_node_or_indentless_sequence ::= ALIAS
  29488. // | properties (block_content | indentless_sequence)?
  29489. // | block_content
  29490. // | indentless_block_sequence
  29491. // block_node ::= ALIAS
  29492. // | properties block_content?
  29493. // | block_content
  29494. // flow_node ::= ALIAS
  29495. // | properties flow_content?
  29496. // | flow_content
  29497. // properties ::= TAG ANCHOR? | ANCHOR TAG?
  29498. // block_content ::= block_collection | flow_collection | SCALAR
  29499. // flow_content ::= flow_collection | SCALAR
  29500. // block_collection ::= block_sequence | block_mapping
  29501. // flow_collection ::= flow_sequence | flow_mapping
  29502. parse_block_node() {
  29503. return this.parse_node(true);
  29504. }
  29505. parse_flow_node() {
  29506. return this.parse_node();
  29507. }
  29508. parse_block_node_or_indentless_sequence() {
  29509. return this.parse_node(true, true);
  29510. }
  29511. parse_node(block = false, indentless_sequence = false) {
  29512. var anchor, end_mark, event, handle, implicit, node, start_mark, suffix, tag, tag_mark, token;
  29513. if (this.check_token(tokens.AliasToken)) {
  29514. token = this.get_token();
  29515. event = new events.AliasEvent(token.value, token.start_mark, token.end_mark);
  29516. this.state = this.states.pop();
  29517. } else {
  29518. anchor = null;
  29519. tag = null;
  29520. start_mark = end_mark = tag_mark = null;
  29521. if (this.check_token(tokens.AnchorToken)) {
  29522. token = this.get_token();
  29523. start_mark = token.start_mark;
  29524. end_mark = token.end_mark;
  29525. anchor = token.value;
  29526. if (this.check_token(tokens.TagToken)) {
  29527. token = this.get_token();
  29528. tag_mark = token.start_mark;
  29529. end_mark = token.end_mark;
  29530. tag = token.value;
  29531. }
  29532. } else if (this.check_token(tokens.TagToken)) {
  29533. token = this.get_token();
  29534. start_mark = tag_mark = token.start_mark;
  29535. end_mark = token.end_mark;
  29536. tag = token.value;
  29537. if (this.check_token(tokens.AnchorToken)) {
  29538. token = this.get_token();
  29539. end_mark = token.end_mark;
  29540. anchor = token.value;
  29541. }
  29542. }
  29543. if (tag !== null) {
  29544. [handle, suffix] = tag;
  29545. if (handle !== null) {
  29546. if (!(handle in this.tag_handles)) {
  29547. throw new exports.ParserError('while parsing a node', start_mark, `found undefined tag handle ${handle}`, tag_mark);
  29548. }
  29549. tag = this.tag_handles[handle] + suffix;
  29550. } else {
  29551. tag = suffix;
  29552. }
  29553. }
  29554. if (start_mark === null) {
  29555. start_mark = end_mark = this.peek_token().start_mark;
  29556. }
  29557. event = null;
  29558. implicit = tag === null || tag === '!';
  29559. if (indentless_sequence && this.check_token(tokens.BlockEntryToken)) {
  29560. end_mark = this.peek_token().end_mark;
  29561. event = new events.SequenceStartEvent(anchor, tag, implicit, start_mark, end_mark);
  29562. this.state = 'parse_indentless_sequence_entry';
  29563. } else {
  29564. if (this.check_token(tokens.ScalarToken)) {
  29565. token = this.get_token();
  29566. end_mark = token.end_mark;
  29567. if ((token.plain && tag === null) || tag === '!') {
  29568. implicit = [true, false];
  29569. } else if (tag === null) {
  29570. implicit = [false, true];
  29571. } else {
  29572. implicit = [false, false];
  29573. }
  29574. event = new events.ScalarEvent(anchor, tag, implicit, token.value, start_mark, end_mark, token.style);
  29575. this.state = this.states.pop();
  29576. } else if (this.check_token(tokens.FlowSequenceStartToken)) {
  29577. end_mark = this.peek_token().end_mark;
  29578. event = new events.SequenceStartEvent(anchor, tag, implicit, start_mark, end_mark, true);
  29579. this.state = 'parse_flow_sequence_first_entry';
  29580. } else if (this.check_token(tokens.FlowMappingStartToken)) {
  29581. end_mark = this.peek_token().end_mark;
  29582. event = new events.MappingStartEvent(anchor, tag, implicit, start_mark, end_mark, true);
  29583. this.state = 'parse_flow_mapping_first_key';
  29584. } else if (block && this.check_token(tokens.BlockSequenceStartToken)) {
  29585. end_mark = this.peek_token().end_mark;
  29586. event = new events.SequenceStartEvent(anchor, tag, implicit, start_mark, end_mark, false);
  29587. this.state = 'parse_block_sequence_first_entry';
  29588. } else if (block && this.check_token(tokens.BlockMappingStartToken)) {
  29589. end_mark = this.peek_token().end_mark;
  29590. event = new events.MappingStartEvent(anchor, tag, implicit, start_mark, end_mark, false);
  29591. this.state = 'parse_block_mapping_first_key';
  29592. } else if (anchor !== null || tag !== null) {
  29593. // Empty scalars are allowed even if a tag or an anchor is specified.
  29594. event = new events.ScalarEvent(anchor, tag, [implicit, false], '', start_mark, end_mark);
  29595. this.state = this.states.pop();
  29596. } else {
  29597. if (block) {
  29598. node = 'block';
  29599. } else {
  29600. node = 'flow';
  29601. }
  29602. token = this.peek_token();
  29603. throw new exports.ParserError(`while parsing a ${node} node`, start_mark, `expected the node content, but found ${token.id}`, token.start_mark);
  29604. }
  29605. }
  29606. }
  29607. return event;
  29608. }
  29609. // block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)*
  29610. // BLOCK-END
  29611. parse_block_sequence_first_entry() {
  29612. var token;
  29613. token = this.get_token();
  29614. this.marks.push(token.start_mark);
  29615. return this.parse_block_sequence_entry();
  29616. }
  29617. parse_block_sequence_entry() {
  29618. var event, token;
  29619. if (this.check_token(tokens.BlockEntryToken)) {
  29620. token = this.get_token();
  29621. if (!this.check_token(tokens.BlockEntryToken, tokens.BlockEndToken)) {
  29622. this.states.push('parse_block_sequence_entry');
  29623. return this.parse_block_node();
  29624. } else {
  29625. this.state = 'parse_block_sequence_entry';
  29626. return this.process_empty_scalar(token.end_mark);
  29627. }
  29628. }
  29629. if (!this.check_token(tokens.BlockEndToken)) {
  29630. token = this.peek_token();
  29631. throw new exports.ParserError('while parsing a block collection', this.marks.slice(-1)[0], `expected <block end>, but found ${token.id}`, token.start_mark);
  29632. }
  29633. token = this.get_token();
  29634. event = new events.SequenceEndEvent(token.start_mark, token.end_mark);
  29635. this.state = this.states.pop();
  29636. this.marks.pop();
  29637. return event;
  29638. }
  29639. // indentless_sequence ::= (BLOCK-ENTRY block_node?)+
  29640. parse_indentless_sequence_entry() {
  29641. var event, token;
  29642. if (this.check_token(tokens.BlockEntryToken)) {
  29643. token = this.get_token();
  29644. if (!this.check_token(tokens.BlockEntryToken, tokens.KeyToken, tokens.ValueToken, tokens.BlockEndToken)) {
  29645. this.states.push('parse_indentless_sequence_entry');
  29646. return this.parse_block_node();
  29647. } else {
  29648. this.state = 'parse_indentless_sequence_entry';
  29649. return this.process_empty_scalar(token.end_mark);
  29650. }
  29651. }
  29652. token = this.peek_token();
  29653. event = new events.SequenceEndEvent(token.start_mark, token.start_mark);
  29654. this.state = this.states.pop();
  29655. return event;
  29656. }
  29657. // block_mapping ::= BLOCK-MAPPING-START
  29658. // ((KEY block_node_or_indentless_sequence?)?
  29659. // (VALUE block_node_or_indentless_sequence?)?)* BLOCK-END
  29660. parse_block_mapping_first_key() {
  29661. var token;
  29662. token = this.get_token();
  29663. this.marks.push(token.start_mark);
  29664. return this.parse_block_mapping_key();
  29665. }
  29666. parse_block_mapping_key() {
  29667. var event, token;
  29668. if (this.check_token(tokens.KeyToken)) {
  29669. token = this.get_token();
  29670. if (!this.check_token(tokens.KeyToken, tokens.ValueToken, tokens.BlockEndToken)) {
  29671. this.states.push('parse_block_mapping_value');
  29672. return this.parse_block_node_or_indentless_sequence();
  29673. } else {
  29674. this.state = 'parse_block_mapping_value';
  29675. return this.process_empty_scalar(token.end_mark);
  29676. }
  29677. }
  29678. if (!this.check_token(tokens.BlockEndToken)) {
  29679. token = this.peek_token();
  29680. throw new exports.ParserError('while parsing a block mapping', this.marks.slice(-1)[0], `expected <block end>, but found ${token.id}`, token.start_mark);
  29681. }
  29682. token = this.get_token();
  29683. event = new events.MappingEndEvent(token.start_mark, token.end_mark);
  29684. this.state = this.states.pop();
  29685. this.marks.pop();
  29686. return event;
  29687. }
  29688. parse_block_mapping_value() {
  29689. var token;
  29690. if (this.check_token(tokens.ValueToken)) {
  29691. token = this.get_token();
  29692. if (!this.check_token(tokens.KeyToken, tokens.ValueToken, tokens.BlockEndToken)) {
  29693. this.states.push('parse_block_mapping_key');
  29694. return this.parse_block_node_or_indentless_sequence();
  29695. } else {
  29696. this.state = 'parse_block_mapping_key';
  29697. return this.process_empty_scalar(token.end_mark);
  29698. }
  29699. } else {
  29700. this.state = 'parse_block_mapping_key';
  29701. token = this.peek_token();
  29702. return this.process_empty_scalar(token.start_mark);
  29703. }
  29704. }
  29705. // flow_sequence ::= FLOW-SEQUENCE-START
  29706. // (flow_sequence_entry FLOW-ENTRY)* flow_sequence_entry? FLOW-SEQUENCE-END
  29707. // flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
  29708. // Note that while production rules for both flow_sequence_entry and
  29709. // flow_mapping_entry are equal, their interpretations are different. For
  29710. // `flow_sequence_entry`, the part `KEY flow_node? (VALUE flow_node?)?`
  29711. // generate an inline mapping (set syntax).
  29712. parse_flow_sequence_first_entry() {
  29713. var token;
  29714. token = this.get_token();
  29715. this.marks.push(token.start_mark);
  29716. return this.parse_flow_sequence_entry(true);
  29717. }
  29718. parse_flow_sequence_entry(first = false) {
  29719. var event, token;
  29720. if (!this.check_token(tokens.FlowSequenceEndToken)) {
  29721. if (!first) {
  29722. if (this.check_token(tokens.FlowEntryToken)) {
  29723. this.get_token();
  29724. } else {
  29725. token = this.peek_token();
  29726. throw new exports.ParserError('while parsing a flow sequence', this.marks.slice(-1)[0], `expected ',' or ']', but got ${token.id}`, token.start_mark);
  29727. }
  29728. }
  29729. if (this.check_token(tokens.KeyToken)) {
  29730. token = this.peek_token();
  29731. event = new events.MappingStartEvent(null, null, true, token.start_mark, token.end_mark, true);
  29732. this.state = 'parse_flow_sequence_entry_mapping_key';
  29733. return event;
  29734. } else if (!this.check_token(tokens.FlowSequenceEndToken)) {
  29735. this.states.push('parse_flow_sequence_entry');
  29736. return this.parse_flow_node();
  29737. }
  29738. }
  29739. token = this.get_token();
  29740. event = new events.SequenceEndEvent(token.start_mark, token.end_mark);
  29741. this.state = this.states.pop();
  29742. this.marks.pop();
  29743. return event;
  29744. }
  29745. parse_flow_sequence_entry_mapping_key() {
  29746. var token;
  29747. token = this.get_token();
  29748. if (!this.check_token(tokens.ValueToken, tokens.FlowEntryToken, tokens.FlowSequenceEndToken)) {
  29749. this.states.push('parse_flow_sequence_entry_mapping_value');
  29750. return this.parse_flow_node();
  29751. } else {
  29752. this.state = 'parse_flow_sequence_entry_mapping_value';
  29753. return this.process_empty_scalar(token.end_mark);
  29754. }
  29755. }
  29756. parse_flow_sequence_entry_mapping_value() {
  29757. var token;
  29758. if (this.check_token(tokens.ValueToken)) {
  29759. token = this.get_token();
  29760. if (!this.check_token(tokens.FlowEntryToken, tokens.FlowSequenceEndToken)) {
  29761. this.states.push('parse_flow_sequence_entry_mapping_end');
  29762. return this.parse_flow_node();
  29763. } else {
  29764. this.state = 'parse_flow_sequence_entry_mapping_end';
  29765. return this.process_empty_scalar(token.end_mark);
  29766. }
  29767. } else {
  29768. this.state = 'parse_flow_sequence_entry_mapping_end';
  29769. token = this.peek_token();
  29770. return this.process_empty_scalar(token.start_mark);
  29771. }
  29772. }
  29773. parse_flow_sequence_entry_mapping_end() {
  29774. var token;
  29775. this.state = 'parse_flow_sequence_entry';
  29776. token = this.peek_token();
  29777. return new events.MappingEndEvent(token.start_mark, token.start_mark);
  29778. }
  29779. // flow_mapping ::= FLOW-MAPPING-START (flow_mapping_entry FLOW-ENTRY)*
  29780. // flow_mapping_entry? FLOW-MAPPING-END
  29781. // flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
  29782. parse_flow_mapping_first_key() {
  29783. var token;
  29784. token = this.get_token();
  29785. this.marks.push(token.start_mark);
  29786. return this.parse_flow_mapping_key(true);
  29787. }
  29788. parse_flow_mapping_key(first = false) {
  29789. var event, token;
  29790. if (!this.check_token(tokens.FlowMappingEndToken)) {
  29791. if (!first) {
  29792. if (this.check_token(tokens.FlowEntryToken)) {
  29793. this.get_token();
  29794. } else {
  29795. token = this.peek_token();
  29796. throw new exports.ParserError('while parsing a flow mapping', this.marks.slice(-1)[0], `expected ',' or '}', but got ${token.id}`, token.start_mark);
  29797. }
  29798. }
  29799. if (this.check_token(tokens.KeyToken)) {
  29800. token = this.get_token();
  29801. if (!this.check_token(tokens.ValueToken, tokens.FlowEntryToken, tokens.FlowMappingEndToken)) {
  29802. this.states.push('parse_flow_mapping_value');
  29803. return this.parse_flow_node();
  29804. } else {
  29805. this.state = 'parse_flow_mapping_value';
  29806. return this.process_empty_scalar(token.end_mark);
  29807. }
  29808. } else if (!this.check_token(tokens.FlowMappingEndToken)) {
  29809. this.states.push('parse_flow_mapping_empty_value');
  29810. return this.parse_flow_node();
  29811. }
  29812. }
  29813. token = this.get_token();
  29814. event = new events.MappingEndEvent(token.start_mark, token.end_mark);
  29815. this.state = this.states.pop();
  29816. this.marks.pop();
  29817. return event;
  29818. }
  29819. parse_flow_mapping_value() {
  29820. var token;
  29821. if (this.check_token(tokens.ValueToken)) {
  29822. token = this.get_token();
  29823. if (!this.check_token(tokens.FlowEntryToken, tokens.FlowMappingEndToken)) {
  29824. this.states.push('parse_flow_mapping_key');
  29825. return this.parse_flow_node();
  29826. } else {
  29827. this.state = 'parse_flow_mapping_key';
  29828. return this.process_empty_scalar(token.end_mark);
  29829. }
  29830. } else {
  29831. this.state = 'parse_flow_mapping_key';
  29832. token = this.peek_token();
  29833. return this.process_empty_scalar(token.start_mark);
  29834. }
  29835. }
  29836. parse_flow_mapping_empty_value() {
  29837. this.state = 'parse_flow_mapping_key';
  29838. return this.process_empty_scalar(this.peek_token().start_mark);
  29839. }
  29840. process_empty_scalar(mark) {
  29841. return new events.ScalarEvent(null, null, [true, false], '', mark, mark);
  29842. }
  29843. };
  29844. DEFAULT_TAGS = {
  29845. '!': '!',
  29846. '!!': 'tag:yaml.org,2002:'
  29847. };
  29848. ctor = Parser.prototype.initialise;
  29849. return Parser;
  29850. }).call(this);
  29851. }).call(this);
  29852. /***/ }),
  29853. /***/ 27026:
  29854. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  29855. (function() {
  29856. var Mark, YAMLError,
  29857. indexOf = [].indexOf;
  29858. ({Mark, YAMLError} = __webpack_require__(45372));
  29859. this.ReaderError = class ReaderError extends YAMLError {
  29860. constructor(position1, character1, reason) {
  29861. super();
  29862. this.position = position1;
  29863. this.character = character1;
  29864. this.reason = reason;
  29865. }
  29866. toString() {
  29867. return `unacceptable character #${this.character.charCodeAt(0).toString(16)}: ${this.reason}\n position ${this.position}`;
  29868. }
  29869. };
  29870. /*
  29871. Reader:
  29872. checks if characters are within the allowed range
  29873. add '\x00' to the end
  29874. */
  29875. this.Reader = (function() {
  29876. var NON_PRINTABLE, ctor;
  29877. class Reader {
  29878. constructor() {
  29879. return ctor.apply(this, arguments);
  29880. }
  29881. initialise(string) {
  29882. this.string = string;
  29883. this.line = 0;
  29884. this.column = 0;
  29885. this.index = 0;
  29886. this.check_printable();
  29887. return this.string += '\x00';
  29888. }
  29889. peek(index = 0) {
  29890. return this.string[this.index + index];
  29891. }
  29892. prefix(length = 1) {
  29893. return this.string.slice(this.index, this.index + length);
  29894. }
  29895. forward(length = 1) {
  29896. var char, results;
  29897. results = [];
  29898. while (length) {
  29899. char = this.string[this.index];
  29900. this.index++;
  29901. if (indexOf.call('\n\x85\u2082\u2029', char) >= 0 || (char === '\r' && this.string[this.index] !== '\n')) {
  29902. this.line++;
  29903. this.column = 0;
  29904. } else {
  29905. this.column++;
  29906. }
  29907. results.push(length--);
  29908. }
  29909. return results;
  29910. }
  29911. get_mark() {
  29912. return new Mark(this.line, this.column, this.string, this.index);
  29913. }
  29914. check_printable() {
  29915. var character, match, position;
  29916. match = NON_PRINTABLE.exec(this.string);
  29917. if (match) {
  29918. character = match[0];
  29919. position = (this.string.length - this.index) + match.index;
  29920. throw new exports.ReaderError(position, character, 'special characters are not allowed');
  29921. }
  29922. }
  29923. };
  29924. NON_PRINTABLE = /[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uFFFD]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; // Invalid single characters
  29925. // Missing or invalid low surrogate
  29926. // Missing or invalid high surrogate
  29927. ctor = Reader.prototype.initialise;
  29928. return Reader;
  29929. }).call(this);
  29930. }).call(this);
  29931. /***/ }),
  29932. /***/ 13832:
  29933. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  29934. (function() {
  29935. var YAMLError, nodes,
  29936. hasProp = {}.hasOwnProperty;
  29937. nodes = __webpack_require__(96914);
  29938. ({YAMLError} = __webpack_require__(45372));
  29939. this.RepresenterError = class RepresenterError extends YAMLError {};
  29940. this.BaseRepresenter = (function() {
  29941. var ctor;
  29942. class BaseRepresenter {
  29943. constructor() {
  29944. return ctor.apply(this, arguments);
  29945. }
  29946. static add_representer(data_type, handler) {
  29947. if (!this.prototype.hasOwnProperty('yaml_representers_types')) {
  29948. this.prototype.yaml_representers_types = [].concat(this.prototype.yaml_representers_types);
  29949. }
  29950. if (!this.prototype.hasOwnProperty('yaml_representers_handlers')) {
  29951. this.prototype.yaml_representers_handlers = [].concat(this.prototype.yaml_representers_handlers);
  29952. }
  29953. this.prototype.yaml_representers_types.push(data_type);
  29954. return this.prototype.yaml_representers_handlers.push(handler);
  29955. }
  29956. static add_multi_representer(data_type, handler) {
  29957. if (!this.prototype.hasOwnProperty('yaml_multi_representers_types')) {
  29958. this.prototype.yaml_multi_representers_types = [].concat(this.prototype.yaml_multi_representers_types);
  29959. }
  29960. if (!this.prototype.hasOwnProperty('yaml_multi_representers_handlers')) {
  29961. this.prototype.yaml_multi_representers_handlers = [].concat(this.prototype.yaml_multi_representers_handlers);
  29962. }
  29963. this.prototype.yaml_multi_representers_types.push(data_type);
  29964. return this.prototype.yaml_multi_representers_handlers.push(handler);
  29965. }
  29966. initialise({
  29967. default_style: default_style,
  29968. default_flow_style: default_flow_style
  29969. } = {}) {
  29970. this.default_style = default_style;
  29971. this.default_flow_style = default_flow_style;
  29972. this.represented_objects = {};
  29973. this.object_keeper = [];
  29974. return this.alias_key = null;
  29975. }
  29976. represent(data) {
  29977. var node;
  29978. node = this.represent_data(data);
  29979. this.serialize(node);
  29980. this.represented_objects = {};
  29981. this.object_keeper = [];
  29982. return this.alias_key = null;
  29983. }
  29984. represent_data(data) {
  29985. var data_type, i, j, len, ref, representer, type;
  29986. if (this.ignore_aliases(data)) {
  29987. this.alias_key = null;
  29988. } else if ((i = this.object_keeper.indexOf(data)) !== -1) {
  29989. this.alias_key = i;
  29990. if (this.alias_key in this.represented_objects) {
  29991. return this.represented_objects[this.alias_key];
  29992. }
  29993. } else {
  29994. this.alias_key = this.object_keeper.length;
  29995. this.object_keeper.push(data);
  29996. }
  29997. // Bit fiddly: we look into our non-multi representers using the JS type if `data` is not an
  29998. // object, otherwise we use the object's constructor. For multi-representers we just use
  29999. // instanceof. A representer for `undefined` can be called for any type.
  30000. representer = null;
  30001. data_type = data === null ? 'null' : typeof data;
  30002. if (data_type === 'object') {
  30003. data_type = data.constructor;
  30004. }
  30005. if ((i = this.yaml_representers_types.lastIndexOf(data_type)) !== -1) {
  30006. representer = this.yaml_representers_handlers[i];
  30007. }
  30008. if (representer == null) {
  30009. ref = this.yaml_multi_representers_types;
  30010. for (i = j = 0, len = ref.length; j < len; i = ++j) {
  30011. type = ref[i];
  30012. if (!(data instanceof type)) {
  30013. continue;
  30014. }
  30015. representer = this.yaml_multi_representers_handlers[i];
  30016. break;
  30017. }
  30018. }
  30019. if (representer == null) {
  30020. if ((i = this.yaml_multi_representers_types.lastIndexOf(void 0)) !== -1) {
  30021. representer = this.yaml_multi_representers_handlers[i];
  30022. } else if ((i = this.yaml_representers_types.lastIndexOf(void 0)) !== -1) {
  30023. representer = this.yaml_representers_handlers[i];
  30024. }
  30025. }
  30026. if (representer != null) {
  30027. return representer.call(this, data);
  30028. } else {
  30029. return new nodes.ScalarNode(null, `${data}`);
  30030. }
  30031. }
  30032. represent_scalar(tag, value, style = this.default_style) {
  30033. var node;
  30034. node = new nodes.ScalarNode(tag, value, null, null, style);
  30035. if (this.alias_key != null) {
  30036. this.represented_objects[this.alias_key] = node;
  30037. }
  30038. return node;
  30039. }
  30040. represent_sequence(tag, sequence, flow_style) {
  30041. var best_style, item, j, len, node, node_item, ref, value;
  30042. value = [];
  30043. node = new nodes.SequenceNode(tag, value, null, null, flow_style);
  30044. if (this.alias_key != null) {
  30045. this.represented_objects[this.alias_key] = node;
  30046. }
  30047. best_style = true;
  30048. for (j = 0, len = sequence.length; j < len; j++) {
  30049. item = sequence[j];
  30050. node_item = this.represent_data(item);
  30051. if (!(node_item instanceof nodes.ScalarNode || node_item.style)) {
  30052. best_style = false;
  30053. }
  30054. value.push(node_item);
  30055. }
  30056. if (flow_style == null) {
  30057. node.flow_style = (ref = this.default_flow_style) != null ? ref : best_style;
  30058. }
  30059. return node;
  30060. }
  30061. represent_mapping(tag, mapping, flow_style) {
  30062. var best_style, item_key, item_value, node, node_key, node_value, ref, value;
  30063. value = [];
  30064. node = new nodes.MappingNode(tag, value, flow_style);
  30065. if (this.alias_key) {
  30066. this.represented_objects[this.alias_key] = node;
  30067. }
  30068. best_style = true;
  30069. for (item_key in mapping) {
  30070. if (!hasProp.call(mapping, item_key)) continue;
  30071. item_value = mapping[item_key];
  30072. node_key = this.represent_data(item_key);
  30073. node_value = this.represent_data(item_value);
  30074. if (!(node_key instanceof nodes.ScalarNode || node_key.style)) {
  30075. best_style = false;
  30076. }
  30077. if (!(node_value instanceof nodes.ScalarNode || node_value.style)) {
  30078. best_style = false;
  30079. }
  30080. value.push([node_key, node_value]);
  30081. }
  30082. if (!flow_style) {
  30083. node.flow_style = (ref = this.default_flow_style) != null ? ref : best_style;
  30084. }
  30085. return node;
  30086. }
  30087. ignore_aliases(data) {
  30088. return false;
  30089. }
  30090. };
  30091. BaseRepresenter.prototype.yaml_representers_types = [];
  30092. BaseRepresenter.prototype.yaml_representers_handlers = [];
  30093. BaseRepresenter.prototype.yaml_multi_representers_types = [];
  30094. BaseRepresenter.prototype.yaml_multi_representers_handlers = [];
  30095. ctor = BaseRepresenter.prototype.initialise;
  30096. return BaseRepresenter;
  30097. }).call(this);
  30098. this.Representer = class Representer extends this.BaseRepresenter {
  30099. represent_boolean(data) {
  30100. return this.represent_scalar('tag:yaml.org,2002:bool', (data ? 'true' : 'false'));
  30101. }
  30102. represent_null(data) {
  30103. return this.represent_scalar('tag:yaml.org,2002:null', 'null');
  30104. }
  30105. represent_number(data) {
  30106. var tag, value;
  30107. tag = `tag:yaml.org,2002:${(data % 1 === 0 ? 'int' : 'float')}`;
  30108. value = data !== data ? '.nan' : data === 2e308 ? '.inf' : data === -2e308 ? '-.inf' : data.toString();
  30109. return this.represent_scalar(tag, value);
  30110. }
  30111. represent_string(data) {
  30112. return this.represent_scalar('tag:yaml.org,2002:str', data);
  30113. }
  30114. represent_array(data) {
  30115. return this.represent_sequence('tag:yaml.org,2002:seq', data);
  30116. }
  30117. represent_date(data) {
  30118. return this.represent_scalar('tag:yaml.org,2002:timestamp', data.toISOString());
  30119. }
  30120. represent_object(data) {
  30121. return this.represent_mapping('tag:yaml.org,2002:map', data);
  30122. }
  30123. represent_undefined(data) {
  30124. throw new exports.RepresenterError(`cannot represent an onbject: ${data}`);
  30125. }
  30126. ignore_aliases(data) {
  30127. var ref;
  30128. if (data == null) {
  30129. return true;
  30130. }
  30131. if ((ref = typeof data) === 'boolean' || ref === 'number' || ref === 'string') {
  30132. return true;
  30133. }
  30134. return false;
  30135. }
  30136. };
  30137. this.Representer.add_representer('boolean', this.Representer.prototype.represent_boolean);
  30138. this.Representer.add_representer('null', this.Representer.prototype.represent_null);
  30139. this.Representer.add_representer('number', this.Representer.prototype.represent_number);
  30140. this.Representer.add_representer('string', this.Representer.prototype.represent_string);
  30141. this.Representer.add_representer(Array, this.Representer.prototype.represent_array);
  30142. this.Representer.add_representer(Date, this.Representer.prototype.represent_date);
  30143. this.Representer.add_representer(Object, this.Representer.prototype.represent_object);
  30144. this.Representer.add_representer(null, this.Representer.prototype.represent_undefined);
  30145. }).call(this);
  30146. /***/ }),
  30147. /***/ 3579:
  30148. /***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
  30149. (function() {
  30150. var YAMLError, nodes, util,
  30151. indexOf = [].indexOf;
  30152. nodes = __webpack_require__(96914);
  30153. util = __webpack_require__(23823);
  30154. ({YAMLError} = __webpack_require__(45372));
  30155. this.ResolverError = class ResolverError extends YAMLError {};
  30156. this.BaseResolver = (function() {
  30157. var DEFAULT_MAPPING_TAG, DEFAULT_SCALAR_TAG, DEFAULT_SEQUENCE_TAG, ctor;
  30158. class BaseResolver {
  30159. constructor() {
  30160. return ctor.apply(this, arguments);
  30161. }
  30162. static add_implicit_resolver(tag, regexp, first = [null]) {
  30163. var base, char, i, len, results;
  30164. if (!this.prototype.hasOwnProperty('yaml_implicit_resolvers')) {
  30165. this.prototype.yaml_implicit_resolvers = util.extend({}, this.prototype.yaml_implicit_resolvers);
  30166. }
  30167. results = [];
  30168. for (i = 0, len = first.length; i < len; i++) {
  30169. char = first[i];
  30170. results.push(((base = this.prototype.yaml_implicit_resolvers)[char] != null ? base[char] : base[char] = []).push([tag, regexp]));
  30171. }
  30172. return results;
  30173. }
  30174. initialise() {
  30175. this.resolver_exact_paths = [];
  30176. return this.resolver_prefix_paths = [];
  30177. }
  30178. descend_resolver(current_node, current_index) {
  30179. var depth, exact_paths, i, j, kind, len, len1, path, prefix_paths, ref, ref1;
  30180. if (util.is_empty(this.yaml_path_resolvers)) {
  30181. return;
  30182. }
  30183. exact_paths = {};
  30184. prefix_paths = [];
  30185. if (current_node) {
  30186. depth = this.resolver_prefix_paths.length;
  30187. ref = this.resolver_prefix_paths.slice(-1)[0];
  30188. for (i = 0, len = ref.length; i < len; i++) {
  30189. [path, kind] = ref[i];
  30190. if (this.check_resolver_prefix(depth, path, kind, current_node, current_index)) {
  30191. if (path.length > depth) {
  30192. prefix_paths.push([path, kind]);
  30193. } else {
  30194. exact_paths[kind] = this.yaml_path_resolvers[path][kind];
  30195. }
  30196. }
  30197. }
  30198. } else {
  30199. ref1 = this.yaml_path_resolvers;
  30200. for (j = 0, len1 = ref1.length; j < len1; j++) {
  30201. [path, kind] = ref1[j];
  30202. if (!path) {
  30203. exact_paths[kind] = this.yaml_path_resolvers[path][kind];
  30204. } else {
  30205. prefix_paths.push([path, kind]);
  30206. }
  30207. }
  30208. }
  30209. this.resolver_exact_paths.push(exact_paths);
  30210. return this.resolver_prefix_paths.push(prefix_paths);
  30211. }
  30212. ascend_resolver() {
  30213. if (util.is_empty(this.yaml_path_resolvers)) {
  30214. return;
  30215. }
  30216. this.resolver_exact_paths.pop();
  30217. return this.resolver_prefix_paths.pop();
  30218. }
  30219. check_resolver_prefix(depth, path, kind, current_node, current_index) {
  30220. var index_check, node_check;
  30221. [node_check, index_check] = path[depth - 1];
  30222. if (typeof node_check === 'string') {
  30223. if (current_node.tag !== node_check) {
  30224. return;
  30225. }
  30226. } else if (node_check !== null) {
  30227. if (!(current_node instanceof node_check)) {
  30228. return;
  30229. }
  30230. }
  30231. if (index_check === true && current_index !== null) {
  30232. return;
  30233. }
  30234. if ((index_check === false || index_check === null) && current_index === null) {
  30235. return;
  30236. }
  30237. if (typeof index_check === 'string') {
  30238. if (!(current_index instanceof nodes.ScalarNode) && index_check === current_index.value) {
  30239. return;
  30240. }
  30241. } else if (typeof index_check === 'number') {
  30242. if (index_check !== current_index) {
  30243. return;
  30244. }
  30245. }
  30246. return true;
  30247. }
  30248. resolve(kind, value, implicit) {
  30249. var empty, exact_paths, i, k, len, ref, ref1, ref2, regexp, resolvers, tag;
  30250. if (kind === nodes.ScalarNode && implicit[0]) {
  30251. if (value === '') {
  30252. resolvers = (ref = this.yaml_implicit_resolvers['']) != null ? ref : [];
  30253. } else {
  30254. resolvers = (ref1 = this.yaml_implicit_resolvers[value[0]]) != null ? ref1 : [];
  30255. }
  30256. resolvers = resolvers.concat((ref2 = this.yaml_implicit_resolvers[null]) != null ? ref2 : []);
  30257. for (i = 0, len = resolvers.length; i < len; i++) {
  30258. [tag, regexp] = resolvers[i];
  30259. if (value.match(regexp)) {
  30260. return tag;
  30261. }
  30262. }
  30263. implicit = implicit[1];
  30264. }
  30265. empty = true;
  30266. for (k in this.yaml_path_resolvers) {
  30267. if ({}[k] == null) {
  30268. empty = false;
  30269. }
  30270. }
  30271. if (!empty) {
  30272. exact_paths = this.resolver_exact_paths.slice(-1)[0];
  30273. if (indexOf.call(exact_paths, kind) >= 0) {
  30274. return exact_paths[kind];
  30275. }
  30276. if (indexOf.call(exact_paths, null) >= 0) {
  30277. return exact_paths[null];
  30278. }
  30279. }
  30280. if (kind === nodes.ScalarNode) {
  30281. return DEFAULT_SCALAR_TAG;
  30282. }
  30283. if (kind === nodes.SequenceNode) {
  30284. return DEFAULT_SEQUENCE_TAG;
  30285. }
  30286. if (kind === nodes.MappingNode) {
  30287. return DEFAULT_MAPPING_TAG;
  30288. }
  30289. }
  30290. };
  30291. DEFAULT_SCALAR_TAG = 'tag:yaml.org,2002:str';
  30292. DEFAULT_SEQUENCE_TAG = 'tag:yaml.org,2002:seq';
  30293. DEFAULT_MAPPING_TAG = 'tag:yaml.org,2002:map';
  30294. BaseResolver.prototype.yaml_implicit_resolvers = {};
  30295. BaseResolver.prototype.yaml_path_resolvers = {};
  30296. ctor = BaseResolver.prototype.initialise;
  30297. return BaseResolver;
  30298. }).call(this);
  30299. this.Resolver = class Resolver extends this.BaseResolver {};
  30300. this.Resolver.add_implicit_resolver('tag:yaml.org,2002:bool', /^(?:yes|Yes|YES|true|True|TRUE|on|On|ON|no|No|NO|false|False|FALSE|off|Off|OFF)$/, 'yYnNtTfFoO');
  30301. this.Resolver.add_implicit_resolver('tag:yaml.org,2002:float', /^(?:[-+]?(?:[0-9][0-9_]*)\.[0-9_]*(?:[eE][-+][0-9]+)?|\.[0-9_]+(?:[eE][-+][0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*|[-+]?\.(?:inf|Inf|INF)|\.(?:nan|NaN|NAN))$/, '-+0123456789.');
  30302. this.Resolver.add_implicit_resolver('tag:yaml.org,2002:int', /^(?:[-+]?0b[01_]+|[-+]?0[0-7_]+|[-+]?(?:0|[1-9][0-9_]*)|[-+]?0x[0-9a-fA-F_]+|[-+]?0o[0-7_]+|[-+]?[1-9][0-9_]*(?::[0-5]?[0-9])+)$/, '-+0123456789');
  30303. this.Resolver.add_implicit_resolver('tag:yaml.org,2002:merge', /^(?:<<)$/, '<');
  30304. this.Resolver.add_implicit_resolver('tag:yaml.org,2002:null', /^(?:~|null|Null|NULL|)$/, ['~', 'n', 'N', '']);
  30305. this.Resolver.add_implicit_resolver('tag:yaml.org,2002:timestamp', /^(?:[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]|[0-9][0-9][0-9][0-9]-[0-9][0-9]?-[0-9][0-9]?(?:[Tt]|[\x20\t]+)[0-9][0-9]?:[0-9][0-9]:[0-9][0-9](?:\.[0-9]*)?(?:[\x20\t]*(?:Z|[-+][0-9][0-9]?(?::[0-9][0-9])?))?)$/, '0123456789');
  30306. this.Resolver.add_implicit_resolver('tag:yaml.org,2002:value', /^(?:=)$/, '=');
  30307. // The following resolver is only for documentation purposes. It cannot work
  30308. // because plain scalars cannot start with '!', '&' or '*'.
  30309. this.Resolver.add_implicit_resolver('tag:yaml.org,2002:yaml', /^(?:!|&|\*)$/, '!&*');
  30310. }).call(this);
  30311. /***/ }),
  30312. /***/ 72265:
  30313. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  30314. (function() {
  30315. var MarkedYAMLError, SimpleKey, tokens, util,
  30316. hasProp = {}.hasOwnProperty,
  30317. indexOf = [].indexOf;
  30318. ({MarkedYAMLError} = __webpack_require__(45372));
  30319. tokens = __webpack_require__(59902);
  30320. util = __webpack_require__(23823);
  30321. /*
  30322. The Scanner throws these.
  30323. */
  30324. this.ScannerError = class ScannerError extends MarkedYAMLError {};
  30325. /*
  30326. Represents a possible simple key.
  30327. */
  30328. SimpleKey = class SimpleKey {
  30329. constructor(token_number1, required1, index, line, column1, mark1) {
  30330. this.token_number = token_number1;
  30331. this.required = required1;
  30332. this.index = index;
  30333. this.line = line;
  30334. this.column = column1;
  30335. this.mark = mark1;
  30336. }
  30337. };
  30338. /*
  30339. The Scanner class deals with converting a YAML stream into a token stream.
  30340. */
  30341. this.Scanner = (function() {
  30342. var C_LB, C_NUMBERS, C_WS, ESCAPE_CODES, ESCAPE_REPLACEMENTS, ctor;
  30343. class Scanner {
  30344. constructor() {
  30345. return ctor.apply(this, arguments);
  30346. }
  30347. /*
  30348. Initialise the Scanner
  30349. */
  30350. initialise() {
  30351. // Have we reached the end of the stream?
  30352. this.done = false;
  30353. // How many unclosed '{' or '[' have been seen. '0' implies block context.
  30354. this.flow_level = 0;
  30355. // List of processed tokens not yet emitted.
  30356. this.tokens = [];
  30357. // Add the STREAM-START token.
  30358. this.fetch_stream_start();
  30359. // Number of tokens emitted through the `get_token` method.
  30360. this.tokens_taken = 0;
  30361. // Current indentation level. '-1' means no indentation has been seen.
  30362. this.indent = -1;
  30363. // Previous indentation levels.
  30364. this.indents = [];
  30365. // Simple Key Treatment
  30366. // A simple key is a key that is not denoted by the '?' indicator, e.g.
  30367. // block simple key: value
  30368. // ? not a simple key
  30369. // : { flow simple key: value }
  30370. // We emit the KEY token before all keys, so when we find a potential
  30371. // simple key, we try to locate the corresponding ':' indicator. Simple
  30372. // keys should be limited to a single line and 1024 characters.
  30373. // Can a simple key start at the current position? A simple key may
  30374. // start
  30375. // at the beginning of the line, not counting indentation spaces
  30376. // (block context)
  30377. // after '{', '[', ',' (flow context)
  30378. // after '?', ':', '-' (block context)
  30379. // In the block context, this flag also signifies if a block collection
  30380. // may start at the current position.
  30381. this.allow_simple_key = true;
  30382. // Keep track of possible simple keys. This is an object. The key is
  30383. // `flow_level`; there can be no more than one possible simple key for
  30384. // each level. The value is a SimpleKey object. A simple key may start
  30385. // with ALIAS, ANCHOR, TAG, SCALAR (flow), '[' or '{' tokens.
  30386. return this.possible_simple_keys = {};
  30387. }
  30388. // API methods.
  30389. /*
  30390. Check if the next token is one of the given types.
  30391. */
  30392. check_token(...choices) {
  30393. var choice, i, len;
  30394. while (this.need_more_tokens()) {
  30395. this.fetch_more_tokens();
  30396. }
  30397. if (this.tokens.length !== 0) {
  30398. if (choices.length === 0) {
  30399. return true;
  30400. }
  30401. for (i = 0, len = choices.length; i < len; i++) {
  30402. choice = choices[i];
  30403. if (this.tokens[0] instanceof choice) {
  30404. return true;
  30405. }
  30406. }
  30407. }
  30408. return false;
  30409. }
  30410. /*
  30411. Return the next token, but do not delete it from the queue.
  30412. */
  30413. peek_token() {
  30414. while (this.need_more_tokens()) {
  30415. this.fetch_more_tokens();
  30416. }
  30417. if (this.tokens.length !== 0) {
  30418. return this.tokens[0];
  30419. }
  30420. }
  30421. /*
  30422. Return the next token, and remove it from the queue.
  30423. */
  30424. get_token() {
  30425. while (this.need_more_tokens()) {
  30426. this.fetch_more_tokens();
  30427. }
  30428. if (this.tokens.length !== 0) {
  30429. this.tokens_taken++;
  30430. return this.tokens.shift();
  30431. }
  30432. }
  30433. // Non-API methods.
  30434. need_more_tokens() {
  30435. if (this.done) {
  30436. return false;
  30437. }
  30438. if (this.tokens.length === 0) {
  30439. return true;
  30440. }
  30441. // The current token may be a potential simple key, so we need to look
  30442. // further.
  30443. this.stale_possible_simple_keys();
  30444. if (this.next_possible_simple_key() === this.tokens_taken) {
  30445. return true;
  30446. }
  30447. return false;
  30448. }
  30449. fetch_more_tokens() {
  30450. var char;
  30451. // Eat whitespace and comments until we reach the next token.
  30452. this.scan_to_next_token();
  30453. // Remove obsolete possible simple keys
  30454. this.stale_possible_simple_keys();
  30455. // Compare the current indentation and column. It may add some tokens and
  30456. // decrease the current indentation level.
  30457. this.unwind_indent(this.column);
  30458. // Peek the next character.
  30459. char = this.peek();
  30460. if (char === '\x00') {
  30461. // Is it the end of stream?
  30462. return this.fetch_stream_end();
  30463. }
  30464. if (char === '%' && this.check_directive()) {
  30465. // Is it a directive?
  30466. return this.fetch_directive();
  30467. }
  30468. if (char === '-' && this.check_document_start()) {
  30469. // Is it the document start?
  30470. return this.fetch_document_start();
  30471. }
  30472. if (char === '.' && this.check_document_end()) {
  30473. // Is it the document end?
  30474. return this.fetch_document_end();
  30475. }
  30476. if (char === '[') {
  30477. // TODO: support for BOM within a stream.
  30478. // Is it the flow sequence start indicator?
  30479. return this.fetch_flow_sequence_start();
  30480. }
  30481. if (char === '{') {
  30482. // Is it the flow mapping start indicator?
  30483. return this.fetch_flow_mapping_start();
  30484. }
  30485. if (char === ']') {
  30486. // Is it the flow sequence end indicator?
  30487. return this.fetch_flow_sequence_end();
  30488. }
  30489. if (char === '}') {
  30490. // Is it the flow mapping end indicator?
  30491. return this.fetch_flow_mapping_end();
  30492. }
  30493. if (char === ',') {
  30494. // Is it the flow entry indicator?
  30495. return this.fetch_flow_entry();
  30496. }
  30497. if (char === '-' && this.check_block_entry()) {
  30498. // Is it the block entry indicator?
  30499. return this.fetch_block_entry();
  30500. }
  30501. if (char === '?' && this.check_key()) {
  30502. // Is it the key indicator?
  30503. return this.fetch_key();
  30504. }
  30505. if (char === ':' && this.check_value()) {
  30506. // Is it the value indicator?
  30507. return this.fetch_value();
  30508. }
  30509. if (char === '*') {
  30510. // Is it an alias?
  30511. return this.fetch_alias();
  30512. }
  30513. if (char === '&') {
  30514. // Is it an anchor?
  30515. return this.fetch_anchor();
  30516. }
  30517. if (char === '!') {
  30518. // Is it a tag?
  30519. return this.fetch_tag();
  30520. }
  30521. if (char === '|' && this.flow_level === 0) {
  30522. // Is it a literal scalar?
  30523. return this.fetch_literal();
  30524. }
  30525. if (char === '>' && this.flow_level === 0) {
  30526. // Is it a folded scalar?
  30527. return this.fetch_folded();
  30528. }
  30529. if (char === '\'') {
  30530. // Is it a single quoted scalar?
  30531. return this.fetch_single();
  30532. }
  30533. if (char === '"') {
  30534. // Is it a double quoted scalar?
  30535. return this.fetch_double();
  30536. }
  30537. if (this.check_plain()) {
  30538. // It must be a plain scalar then.
  30539. return this.fetch_plain();
  30540. }
  30541. // No? It's an error.
  30542. throw new exports.ScannerError('while scanning for the next token', null, `found character ${char} that cannot start any token`, this.get_mark());
  30543. }
  30544. // Simple keys treatment.
  30545. /*
  30546. Return the number of the nearest possible simple key.
  30547. */
  30548. next_possible_simple_key() {
  30549. var key, level, min_token_number, ref;
  30550. min_token_number = null;
  30551. ref = this.possible_simple_keys;
  30552. for (level in ref) {
  30553. if (!hasProp.call(ref, level)) continue;
  30554. key = ref[level];
  30555. if (min_token_number === null || key.token_number < min_token_number) {
  30556. min_token_number = key.token_number;
  30557. }
  30558. }
  30559. return min_token_number;
  30560. }
  30561. /*
  30562. Remove entries that are no longer possible simple keys. According to the
  30563. YAML spec, simple keys:
  30564. should be limited to a single line
  30565. should be no longer than 1024 characters
  30566. Disabling this procedure will allow simple keys of any length and height
  30567. (may cause problems if indentation is broken though).
  30568. */
  30569. stale_possible_simple_keys() {
  30570. var key, level, ref, results;
  30571. ref = this.possible_simple_keys;
  30572. results = [];
  30573. for (level in ref) {
  30574. if (!hasProp.call(ref, level)) continue;
  30575. key = ref[level];
  30576. if (key.line === this.line && this.index - key.index <= 1024) {
  30577. continue;
  30578. }
  30579. if (!key.required) {
  30580. results.push(delete this.possible_simple_keys[level]);
  30581. } else {
  30582. throw new exports.ScannerError('while scanning a simple key', key.mark, 'could not find expected \':\'', this.get_mark());
  30583. }
  30584. }
  30585. return results;
  30586. }
  30587. /*
  30588. The next token may start a simple key. We check if it's possible and save
  30589. its position. This function is called for ALIAS, ANCHOR, TAG,
  30590. SCALAR (flow),'[' and '{'.
  30591. */
  30592. save_possible_simple_key() {
  30593. var required, token_number;
  30594. // Check if a simple key is required at the current position.
  30595. required = this.flow_level === 0 && this.indent === this.column;
  30596. if (required && !this.allow_simple_key) {
  30597. // A simple key is required only if it is the first token in the current
  30598. // line. Therefore it is always allowed.
  30599. throw new Error('logic failure');
  30600. }
  30601. // If simple keys aren't allowed here we're done.
  30602. if (!this.allow_simple_key) {
  30603. return;
  30604. }
  30605. // The next token might be a simple key. Let's save its number and
  30606. // position.
  30607. this.remove_possible_simple_key();
  30608. token_number = this.tokens_taken + this.tokens.length;
  30609. return this.possible_simple_keys[this.flow_level] = new SimpleKey(token_number, required, this.index, this.line, this.column, this.get_mark());
  30610. }
  30611. /*
  30612. Remove the saved possible simple key at the current flow level.
  30613. */
  30614. remove_possible_simple_key() {
  30615. var key;
  30616. if (!(key = this.possible_simple_keys[this.flow_level])) {
  30617. return;
  30618. }
  30619. if (!key.required) {
  30620. return delete this.possible_simple_keys[this.flow_level];
  30621. } else {
  30622. throw new exports.ScannerError('while scanning a simple key', key.mark, 'could not find expected \':\'', this.get_mark());
  30623. }
  30624. }
  30625. // Indentation functions
  30626. /*
  30627. In flow context, tokens should respect indentation.
  30628. Actually the condition should be `self.indent >= column` according to
  30629. the spec. But this condition will prohibit intuitively correct
  30630. constructions such as
  30631. key : {
  30632. }
  30633. */
  30634. unwind_indent(column) {
  30635. var mark, results;
  30636. // In the flow context, indentation is ignored. We make the scanner less
  30637. // restrictive than the specification requires.
  30638. if (this.flow_level !== 0) {
  30639. return;
  30640. }
  30641. results = [];
  30642. // In block context we may need to issue the BLOCK-END tokens.
  30643. while (this.indent > column) {
  30644. mark = this.get_mark();
  30645. this.indent = this.indents.pop();
  30646. results.push(this.tokens.push(new tokens.BlockEndToken(mark, mark)));
  30647. }
  30648. return results;
  30649. }
  30650. /*
  30651. Check if we need to increase indentation.
  30652. */
  30653. add_indent(column) {
  30654. if (!(column > this.indent)) {
  30655. return false;
  30656. }
  30657. this.indents.push(this.indent);
  30658. this.indent = column;
  30659. return true;
  30660. }
  30661. // Fetchers.
  30662. fetch_stream_start() {
  30663. var mark;
  30664. mark = this.get_mark();
  30665. return this.tokens.push(new tokens.StreamStartToken(mark, mark, this.encoding));
  30666. }
  30667. fetch_stream_end() {
  30668. var mark;
  30669. // Set the current indentation to -1.
  30670. this.unwind_indent(-1);
  30671. // Reset simple keys.
  30672. this.remove_possible_simple_key();
  30673. this.allow_possible_simple_key = false;
  30674. this.possible_simple_keys = {};
  30675. mark = this.get_mark();
  30676. this.tokens.push(new tokens.StreamEndToken(mark, mark));
  30677. // The stream is finished.
  30678. return this.done = true;
  30679. }
  30680. fetch_directive() {
  30681. // Set the current indentation to -1.
  30682. this.unwind_indent(-1);
  30683. // Reset simple keys.
  30684. this.remove_possible_simple_key();
  30685. this.allow_simple_key = false;
  30686. // Scan and add DIRECTIVE
  30687. return this.tokens.push(this.scan_directive());
  30688. }
  30689. fetch_document_start() {
  30690. return this.fetch_document_indicator(tokens.DocumentStartToken);
  30691. }
  30692. fetch_document_end() {
  30693. return this.fetch_document_indicator(tokens.DocumentEndToken);
  30694. }
  30695. fetch_document_indicator(TokenClass) {
  30696. var start_mark;
  30697. // Set the current indentation to -1.
  30698. this.unwind_indent(-1);
  30699. // Reset simple keys. Note that there would not be a block collection
  30700. // after '---'.
  30701. this.remove_possible_simple_key();
  30702. this.allow_simple_key = false;
  30703. // Add DOCUMENT-START or DOCUMENT-END.
  30704. start_mark = this.get_mark();
  30705. this.forward(3);
  30706. return this.tokens.push(new TokenClass(start_mark, this.get_mark()));
  30707. }
  30708. fetch_flow_sequence_start() {
  30709. return this.fetch_flow_collection_start(tokens.FlowSequenceStartToken);
  30710. }
  30711. fetch_flow_mapping_start() {
  30712. return this.fetch_flow_collection_start(tokens.FlowMappingStartToken);
  30713. }
  30714. fetch_flow_collection_start(TokenClass) {
  30715. var start_mark;
  30716. // '[' and '{' may start a simple key.
  30717. this.save_possible_simple_key();
  30718. // Increase flow level.
  30719. this.flow_level++;
  30720. // Simple keys are allowed after '[' and '{'
  30721. this.allow_simple_key = true;
  30722. // Add FLOW-SEQUENCE-START or FLOW-MAPPING-START.
  30723. start_mark = this.get_mark();
  30724. this.forward();
  30725. return this.tokens.push(new TokenClass(start_mark, this.get_mark()));
  30726. }
  30727. fetch_flow_sequence_end() {
  30728. return this.fetch_flow_collection_end(tokens.FlowSequenceEndToken);
  30729. }
  30730. fetch_flow_mapping_end() {
  30731. return this.fetch_flow_collection_end(tokens.FlowMappingEndToken);
  30732. }
  30733. fetch_flow_collection_end(TokenClass) {
  30734. var start_mark;
  30735. // Reset possible simple key on the current level.
  30736. this.remove_possible_simple_key();
  30737. // Decrease the flow level
  30738. this.flow_level--;
  30739. // No simple keys after ']' or '}'
  30740. this.allow_simple_key = false;
  30741. // Add FLOW-SEQUENCE-END or FLOW-MAPPING-END.
  30742. start_mark = this.get_mark();
  30743. this.forward();
  30744. return this.tokens.push(new TokenClass(start_mark, this.get_mark()));
  30745. }
  30746. fetch_flow_entry() {
  30747. var start_mark;
  30748. // Simple keys are allowed after ','.
  30749. this.allow_simple_key = true;
  30750. // Reset possible simple key on the current level.
  30751. this.remove_possible_simple_key();
  30752. // Add FLOW-ENTRY
  30753. start_mark = this.get_mark();
  30754. this.forward();
  30755. return this.tokens.push(new tokens.FlowEntryToken(start_mark, this.get_mark()));
  30756. }
  30757. fetch_block_entry() {
  30758. var mark, start_mark;
  30759. // Block context needs additional checks
  30760. if (this.flow_level === 0) {
  30761. // Are we allowed to start a new entry?
  30762. if (!this.allow_simple_key) {
  30763. throw new exports.ScannerError(null, null, 'sequence entries are not allowed here', this.get_mark());
  30764. }
  30765. // We may need to add BLOCK-SEQUENCE-START
  30766. if (this.add_indent(this.column)) {
  30767. mark = this.get_mark();
  30768. this.tokens.push(new tokens.BlockSequenceStartToken(mark, mark));
  30769. }
  30770. }
  30771. // It's an error for the block entry to occur in the flow context but we
  30772. // let the parser detect this.
  30773. // Simple keys are allowed after '-'
  30774. this.allow_simple_key = true;
  30775. // Reset possible simple key on the current level.
  30776. this.remove_possible_simple_key();
  30777. // Add BLOCK-ENTRY
  30778. start_mark = this.get_mark();
  30779. this.forward();
  30780. return this.tokens.push(new tokens.BlockEntryToken(start_mark, this.get_mark()));
  30781. }
  30782. fetch_key() {
  30783. var mark, start_mark;
  30784. // Block context needs additional checks.
  30785. if (this.flow_level === 0) {
  30786. // Are we allowed to start a key?
  30787. if (!this.allow_simple_key) {
  30788. throw new exports.ScannerError(null, null, 'mapping keys are not allowed here', this.get_mark());
  30789. }
  30790. // We may need to add BLOCK-MAPPING-START.
  30791. if (this.add_indent(this.column)) {
  30792. mark = this.get_mark();
  30793. this.tokens.push(new tokens.BlockMappingStartToken(mark, mark));
  30794. }
  30795. }
  30796. // Simple keys are allowed after '?' in the flow context.
  30797. this.allow_simple_key = !this.flow_level;
  30798. // Reset possible simple key on the current level.
  30799. this.remove_possible_simple_key();
  30800. // Add KEY.
  30801. start_mark = this.get_mark();
  30802. this.forward();
  30803. return this.tokens.push(new tokens.KeyToken(start_mark, this.get_mark()));
  30804. }
  30805. fetch_value() {
  30806. var key, mark, start_mark;
  30807. // Do we determine a simple key?
  30808. if (key = this.possible_simple_keys[this.flow_level]) {
  30809. // Add KEY.
  30810. delete this.possible_simple_keys[this.flow_level];
  30811. this.tokens.splice(key.token_number - this.tokens_taken, 0, new tokens.KeyToken(key.mark, key.mark));
  30812. // If this key starts a new block mapping we need to add
  30813. // BLOCK-MAPPING-START.
  30814. if (this.flow_level === 0) {
  30815. if (this.add_indent(key.column)) {
  30816. this.tokens.splice(key.token_number - this.tokens_taken, 0, new tokens.BlockMappingStartToken(key.mark, key.mark));
  30817. }
  30818. }
  30819. // There cannot be two simple keys one after the other.
  30820. this.allow_simple_key = false;
  30821. } else {
  30822. // Block context needs additional checks.
  30823. // TODO: do we really need them? Parser will catch them anyway.
  30824. // It must be part of a complex key.
  30825. if (this.flow_level === 0) {
  30826. // We are allowed to start a complex value if and only if we can start
  30827. // a simple key.
  30828. if (!this.allow_simple_key) {
  30829. throw new exports.ScannerError(null, null, 'mapping values are not allowed here', this.get_mark());
  30830. }
  30831. // If this value starts a new block mapping we need to add
  30832. // BLOCK-MAPPING-START. It will be detected as an error later by the
  30833. // parser.
  30834. if (this.add_indent(this.column)) {
  30835. mark = this.get_mark();
  30836. this.tokens.push(new tokens.BlockMappingStartToken(mark, mark));
  30837. }
  30838. }
  30839. // Simple keys are allowed after ':' in the block context.
  30840. this.allow_simple_key = !this.flow_level;
  30841. // Reset possible simple key on the current level.
  30842. this.remove_possible_simple_key();
  30843. }
  30844. // Add VALUE.
  30845. start_mark = this.get_mark();
  30846. this.forward();
  30847. return this.tokens.push(new tokens.ValueToken(start_mark, this.get_mark()));
  30848. }
  30849. fetch_alias() {
  30850. // ALIAS could be a simple key.
  30851. this.save_possible_simple_key();
  30852. // No simple keys after ALIAS.
  30853. this.allow_simple_key = false;
  30854. // Scan and add ALIAS.
  30855. return this.tokens.push(this.scan_anchor(tokens.AliasToken));
  30856. }
  30857. fetch_anchor() {
  30858. // ANCHOR could start a simple key.
  30859. this.save_possible_simple_key();
  30860. // No simple keys allowed after ANCHOR.
  30861. this.allow_simple_key = false;
  30862. // Scan and add ANCHOR.
  30863. return this.tokens.push(this.scan_anchor(tokens.AnchorToken));
  30864. }
  30865. fetch_tag() {
  30866. // TAG could start a simple key
  30867. this.save_possible_simple_key();
  30868. // No simple keys after TAG.
  30869. this.allow_simple_key = false;
  30870. // Scan and add TAG.
  30871. return this.tokens.push(this.scan_tag());
  30872. }
  30873. fetch_literal() {
  30874. return this.fetch_block_scalar('|');
  30875. }
  30876. fetch_folded() {
  30877. return this.fetch_block_scalar('>');
  30878. }
  30879. fetch_block_scalar(style) {
  30880. // A simple key may follow a block sclar.
  30881. this.allow_simple_key = true;
  30882. // Reset possible simple key on the current level.
  30883. this.remove_possible_simple_key();
  30884. // Scan and add SCALAR.
  30885. return this.tokens.push(this.scan_block_scalar(style));
  30886. }
  30887. fetch_single() {
  30888. return this.fetch_flow_scalar('\'');
  30889. }
  30890. fetch_double() {
  30891. return this.fetch_flow_scalar('"');
  30892. }
  30893. fetch_flow_scalar(style) {
  30894. // A flow scalar could be a simple key.
  30895. this.save_possible_simple_key();
  30896. // No simple keys after flow scalars.
  30897. this.allow_simple_key = false;
  30898. // Scan and add SCALAR.
  30899. return this.tokens.push(this.scan_flow_scalar(style));
  30900. }
  30901. fetch_plain() {
  30902. // A plain scalar could be a simple key.
  30903. this.save_possible_simple_key();
  30904. // No simple keys after plain scalars. But note that `scan_plain` will
  30905. // change this flag if the scan is finished at the beginning of the line.
  30906. this.allow_simple_key = false;
  30907. // Scan and add SCALAR. May change `allow_simple_key`.
  30908. return this.tokens.push(this.scan_plain());
  30909. }
  30910. // Checkers.
  30911. /*
  30912. DIRECTIVE: ^ '%'
  30913. */
  30914. check_directive() {
  30915. if (this.column === 0) {
  30916. // The % indicator has already been checked.
  30917. return true;
  30918. }
  30919. return false;
  30920. }
  30921. /*
  30922. DOCUMENT-START: ^ '---' (' '|'\n')
  30923. */
  30924. check_document_start() {
  30925. var ref;
  30926. if (this.column === 0 && this.prefix(3) === '---' && (ref = this.peek(3), indexOf.call(C_LB + C_WS + '\x00', ref) >= 0)) {
  30927. return true;
  30928. }
  30929. return false;
  30930. }
  30931. /*
  30932. DOCUMENT-END: ^ '...' (' '|'\n')
  30933. */
  30934. check_document_end() {
  30935. var ref;
  30936. if (this.column === 0 && this.prefix(3) === '...' && (ref = this.peek(3), indexOf.call(C_LB + C_WS + '\x00', ref) >= 0)) {
  30937. return true;
  30938. }
  30939. return false;
  30940. }
  30941. /*
  30942. BLOCK-ENTRY: '-' (' '|'\n')
  30943. */
  30944. check_block_entry() {
  30945. var ref;
  30946. return ref = this.peek(1), indexOf.call(C_LB + C_WS + '\x00', ref) >= 0;
  30947. }
  30948. /*
  30949. KEY (flow context): '?'
  30950. KEY (block context): '?' (' '|'\n')
  30951. */
  30952. check_key() {
  30953. var ref;
  30954. if (this.flow_level !== 0) {
  30955. // KEY (flow context)
  30956. return true;
  30957. }
  30958. // KEY (block context)
  30959. return ref = this.peek(1), indexOf.call(C_LB + C_WS + '\x00', ref) >= 0;
  30960. }
  30961. /*
  30962. VALUE (flow context): ':'
  30963. VALUE (block context): ':' (' '|'\n')
  30964. */
  30965. check_value() {
  30966. var ref;
  30967. if (this.flow_level !== 0) {
  30968. // VALUE (flow context)
  30969. return true;
  30970. }
  30971. // VALUE (block context)
  30972. return ref = this.peek(1), indexOf.call(C_LB + C_WS + '\x00', ref) >= 0;
  30973. }
  30974. /*
  30975. A plain scalar may start with any non-space character except:
  30976. '-', '?', ':', ',', '[', ']', '{', '}',
  30977. '#', '&', '*', '!', '|', '>', '\'', '"',
  30978. '%', '@', '`'.
  30979. It may also start with
  30980. '-', '?', ':'
  30981. if it is followed by a non-space character.
  30982. Note that we limit the last rule to the block context (except the '-'
  30983. character) because we want the flow context to be space independent.
  30984. */
  30985. check_plain() {
  30986. var char, ref;
  30987. char = this.peek();
  30988. return indexOf.call(C_LB + C_WS + '\x00-?:,[]{}#&*!|>\'"%@`', char) < 0 || ((ref = this.peek(1), indexOf.call(C_LB + C_WS + '\x00', ref) < 0) && (char === '-' || (this.flow_level === 0 && indexOf.call('?:', char) >= 0)));
  30989. }
  30990. // Scanners.
  30991. /*
  30992. We ignore spaces, line breaks and comments.
  30993. If we find a line break in the block context, we set the flag
  30994. `allow_simple_key` on.
  30995. The byte order mark is stripped if it's the first character in the stream.
  30996. We do not yet support BOM inside the stream as the specification requires.
  30997. Any such mark will be considered as a part of the document.
  30998. TODO: We need to make tab handling rules more sane. A good rule is
  30999. Tabs cannot precede tokens BLOCK-SEQUENCE-START, BLOCK-MAPPING-START,
  31000. BLOCK-END, KEY (block context), VALUE (block context), BLOCK-ENTRY
  31001. So the tab checking code is
  31002. @allow_simple_key = off if <TAB>
  31003. We also need to add the check for `allow_simple_key is on` to
  31004. `unwind_indent` before issuing BLOCK-END. Scanners for block, flow and
  31005. plain scalars need to be modified.
  31006. */
  31007. scan_to_next_token() {
  31008. var found, ref, results;
  31009. if (this.index === 0 && this.peek() === '\uFEFF') {
  31010. this.forward();
  31011. }
  31012. found = false;
  31013. results = [];
  31014. while (!found) {
  31015. while (this.peek() === ' ') {
  31016. this.forward();
  31017. }
  31018. if (this.peek() === '#') {
  31019. while (ref = this.peek(), indexOf.call(C_LB + '\x00', ref) < 0) {
  31020. this.forward();
  31021. }
  31022. }
  31023. if (this.scan_line_break()) {
  31024. if (this.flow_level === 0) {
  31025. results.push(this.allow_simple_key = true);
  31026. } else {
  31027. results.push(void 0);
  31028. }
  31029. } else {
  31030. results.push(found = true);
  31031. }
  31032. }
  31033. return results;
  31034. }
  31035. /*
  31036. See the specification for details.
  31037. */
  31038. scan_directive() {
  31039. var end_mark, name, ref, start_mark, value;
  31040. start_mark = this.get_mark();
  31041. this.forward();
  31042. name = this.scan_directive_name(start_mark);
  31043. value = null;
  31044. if (name === 'YAML') {
  31045. value = this.scan_yaml_directive_value(start_mark);
  31046. end_mark = this.get_mark();
  31047. } else if (name === 'TAG') {
  31048. value = this.scan_tag_directive_value(start_mark);
  31049. end_mark = this.get_mark();
  31050. } else {
  31051. end_mark = this.get_mark();
  31052. while (ref = this.peek(), indexOf.call(C_LB + '\x00', ref) < 0) {
  31053. this.forward();
  31054. }
  31055. }
  31056. this.scan_directive_ignored_line(start_mark);
  31057. return new tokens.DirectiveToken(name, value, start_mark, end_mark);
  31058. }
  31059. /*
  31060. See the specification for details.
  31061. */
  31062. scan_directive_name(start_mark) {
  31063. var char, length, value;
  31064. length = 0;
  31065. char = this.peek(length);
  31066. while (('0' <= char && char <= '9') || ('A' <= char && char <= 'Z') || ('a' <= char && char <= 'z') || indexOf.call('-_', char) >= 0) {
  31067. length++;
  31068. char = this.peek(length);
  31069. }
  31070. if (length === 0) {
  31071. throw new exports.ScannerError('while scanning a directive', start_mark, `expected alphanumeric or numeric character but found ${char}`, this.get_mark());
  31072. }
  31073. value = this.prefix(length);
  31074. this.forward(length);
  31075. char = this.peek();
  31076. if (indexOf.call(C_LB + '\x00 ', char) < 0) {
  31077. throw new exports.ScannerError('while scanning a directive', start_mark, `expected alphanumeric or numeric character but found ${char}`, this.get_mark());
  31078. }
  31079. return value;
  31080. }
  31081. /*
  31082. See the specification for details.
  31083. */
  31084. scan_yaml_directive_value(start_mark) {
  31085. var major, minor, ref;
  31086. while (this.peek() === ' ') {
  31087. this.forward();
  31088. }
  31089. major = this.scan_yaml_directive_number(start_mark);
  31090. if (this.peek() !== '.') {
  31091. throw new exports.ScannerError('while scanning a directive', start_mark, `expected a digit or '.' but found ${this.peek()}`, this.get_mark());
  31092. }
  31093. this.forward();
  31094. minor = this.scan_yaml_directive_number(start_mark);
  31095. if (ref = this.peek(), indexOf.call(C_LB + '\x00 ', ref) < 0) {
  31096. throw new exports.ScannerError('while scanning a directive', start_mark, `expected a digit or ' ' but found ${this.peek()}`, this.get_mark());
  31097. }
  31098. return [major, minor];
  31099. }
  31100. /*
  31101. See the specification for details.
  31102. */
  31103. scan_yaml_directive_number(start_mark) {
  31104. var char, length, ref, value;
  31105. char = this.peek();
  31106. if (!(('0' <= char && char <= '9'))) {
  31107. throw new exports.ScannerError('while scanning a directive', start_mark, `expected a digit but found ${char}`, this.get_mark());
  31108. }
  31109. length = 0;
  31110. while (('0' <= (ref = this.peek(length)) && ref <= '9')) {
  31111. length++;
  31112. }
  31113. value = parseInt(this.prefix(length));
  31114. this.forward(length);
  31115. return value;
  31116. }
  31117. /*
  31118. See the specification for details.
  31119. */
  31120. scan_tag_directive_value(start_mark) {
  31121. var handle, prefix;
  31122. while (this.peek() === ' ') {
  31123. this.forward();
  31124. }
  31125. handle = this.scan_tag_directive_handle(start_mark);
  31126. while (this.peek() === ' ') {
  31127. this.forward();
  31128. }
  31129. prefix = this.scan_tag_directive_prefix(start_mark);
  31130. return [handle, prefix];
  31131. }
  31132. /*
  31133. See the specification for details.
  31134. */
  31135. scan_tag_directive_handle(start_mark) {
  31136. var char, value;
  31137. value = this.scan_tag_handle('directive', start_mark);
  31138. char = this.peek();
  31139. if (char !== ' ') {
  31140. throw new exports.ScannerError('while scanning a directive', start_mark, `expected ' ' but found ${char}`, this.get_mark());
  31141. }
  31142. return value;
  31143. }
  31144. /*
  31145. See the specification for details.
  31146. */
  31147. scan_tag_directive_prefix(start_mark) {
  31148. var char, value;
  31149. value = this.scan_tag_uri('directive', start_mark);
  31150. char = this.peek();
  31151. if (indexOf.call(C_LB + '\x00 ', char) < 0) {
  31152. throw new exports.ScannerError('while scanning a directive', start_mark, `expected ' ' but found ${char}`, this.get_mark());
  31153. }
  31154. return value;
  31155. }
  31156. /*
  31157. See the specification for details.
  31158. */
  31159. scan_directive_ignored_line(start_mark) {
  31160. var char, ref;
  31161. while (this.peek() === ' ') {
  31162. this.forward();
  31163. }
  31164. if (this.peek() === '#') {
  31165. while (ref = this.peek(), indexOf.call(C_LB + '\x00', ref) < 0) {
  31166. this.forward();
  31167. }
  31168. }
  31169. char = this.peek();
  31170. if (indexOf.call(C_LB + '\x00', char) < 0) {
  31171. throw new exports.ScannerError('while scanning a directive', start_mark, `expected a comment or a line break but found ${char}`, this.get_mark());
  31172. }
  31173. return this.scan_line_break();
  31174. }
  31175. /*
  31176. The specification does not restrict characters for anchors and aliases.
  31177. This may lead to problems, for instance, the document:
  31178. [ *alias, value ]
  31179. can be interpteted in two ways, as
  31180. [ "value" ]
  31181. and
  31182. [ *alias , "value" ]
  31183. Therefore we restrict aliases to numbers and ASCII letters.
  31184. */
  31185. scan_anchor(TokenClass) {
  31186. var char, indicator, length, name, start_mark, value;
  31187. start_mark = this.get_mark();
  31188. indicator = this.peek();
  31189. if (indicator === '*') {
  31190. name = 'alias';
  31191. } else {
  31192. name = 'anchor';
  31193. }
  31194. this.forward();
  31195. length = 0;
  31196. char = this.peek(length);
  31197. while (('0' <= char && char <= '9') || ('A' <= char && char <= 'Z') || ('a' <= char && char <= 'z') || indexOf.call('-_', char) >= 0) {
  31198. length++;
  31199. char = this.peek(length);
  31200. }
  31201. if (length === 0) {
  31202. throw new exports.ScannerError(`while scanning an ${name}`, start_mark, `expected alphabetic or numeric character but found '${char}'`, this.get_mark());
  31203. }
  31204. value = this.prefix(length);
  31205. this.forward(length);
  31206. char = this.peek();
  31207. if (indexOf.call(C_LB + C_WS + '\x00' + '?:,]}%@`', char) < 0) {
  31208. throw new exports.ScannerError(`while scanning an ${name}`, start_mark, `expected alphabetic or numeric character but found '${char}'`, this.get_mark());
  31209. }
  31210. return new TokenClass(value, start_mark, this.get_mark());
  31211. }
  31212. /*
  31213. See the specification for details.
  31214. */
  31215. scan_tag() {
  31216. var char, handle, length, start_mark, suffix, use_handle;
  31217. start_mark = this.get_mark();
  31218. char = this.peek(1);
  31219. if (char === '<') {
  31220. handle = null;
  31221. this.forward(2);
  31222. suffix = this.scan_tag_uri('tag', start_mark);
  31223. if (this.peek() !== '>') {
  31224. throw new exports.ScannerError('while parsing a tag', start_mark, `expected '>' but found ${this.peek()}`, this.get_mark());
  31225. }
  31226. this.forward();
  31227. } else if (indexOf.call(C_LB + C_WS + '\x00', char) >= 0) {
  31228. handle = null;
  31229. suffix = '!';
  31230. this.forward();
  31231. } else {
  31232. length = 1;
  31233. use_handle = false;
  31234. while (indexOf.call(C_LB + '\x00 ', char) < 0) {
  31235. if (char === '!') {
  31236. use_handle = true;
  31237. break;
  31238. }
  31239. length++;
  31240. char = this.peek(length);
  31241. }
  31242. if (use_handle) {
  31243. handle = this.scan_tag_handle('tag', start_mark);
  31244. } else {
  31245. handle = '!';
  31246. this.forward();
  31247. }
  31248. suffix = this.scan_tag_uri('tag', start_mark);
  31249. }
  31250. char = this.peek();
  31251. if (indexOf.call(C_LB + '\x00 ', char) < 0) {
  31252. throw new exports.ScannerError('while scanning a tag', start_mark, `expected ' ' but found ${char}`, this.get_mark());
  31253. }
  31254. return new tokens.TagToken([handle, suffix], start_mark, this.get_mark());
  31255. }
  31256. /*
  31257. See the specification for details.
  31258. */
  31259. scan_block_scalar(style) {
  31260. var breaks, chomping, chunks, end_mark, folded, increment, indent, leading_non_space, length, line_break, max_indent, min_indent, ref, ref1, ref2, start_mark;
  31261. folded = style === '>';
  31262. chunks = [];
  31263. start_mark = this.get_mark();
  31264. // Scan the header.
  31265. this.forward();
  31266. [chomping, increment] = this.scan_block_scalar_indicators(start_mark);
  31267. this.scan_block_scalar_ignored_line(start_mark);
  31268. // Determine the indentation level and go to the first non-empty line.
  31269. min_indent = this.indent + 1;
  31270. if (min_indent < 1) {
  31271. min_indent = 1;
  31272. }
  31273. if (increment == null) {
  31274. [breaks, max_indent, end_mark] = this.scan_block_scalar_indentation();
  31275. indent = Math.max(min_indent, max_indent);
  31276. } else {
  31277. indent = min_indent + increment - 1;
  31278. [breaks, end_mark] = this.scan_block_scalar_breaks(indent);
  31279. }
  31280. line_break = '';
  31281. // Scan the inner part of the block scalar.
  31282. while (this.column === indent && this.peek() !== '\x00') {
  31283. chunks = chunks.concat(breaks);
  31284. leading_non_space = (ref = this.peek(), indexOf.call(' \t', ref) < 0);
  31285. length = 0;
  31286. while (ref1 = this.peek(length), indexOf.call(C_LB + '\x00', ref1) < 0) {
  31287. length++;
  31288. }
  31289. chunks.push(this.prefix(length));
  31290. this.forward(length);
  31291. line_break = this.scan_line_break();
  31292. [breaks, end_mark] = this.scan_block_scalar_breaks(indent);
  31293. if (this.column === indent && this.peek() !== '\x00') {
  31294. // Unfortunately, folding rules are ambiguous. This is the folding
  31295. // according to the specification:
  31296. if (folded && line_break === '\n' && leading_non_space && (ref2 = this.peek(), indexOf.call(' \t', ref2) < 0)) {
  31297. if (util.is_empty(breaks)) {
  31298. chunks.push(' ');
  31299. }
  31300. } else {
  31301. chunks.push(line_break);
  31302. }
  31303. } else {
  31304. // This is Clark Evan's interpretation (also in the spec examples):
  31305. // if folded and line_break is '\n'
  31306. // if not breaks
  31307. // if @peek() not in ' \t'
  31308. // chunks.push ' '
  31309. // else
  31310. // chunks.push line_break
  31311. // else
  31312. // chunks.push line_break
  31313. break;
  31314. }
  31315. }
  31316. if (chomping !== false) {
  31317. // Chomp the tail
  31318. chunks.push(line_break);
  31319. }
  31320. if (chomping === true) {
  31321. chunks = chunks.concat(breaks);
  31322. }
  31323. // And we're done.
  31324. return new tokens.ScalarToken(chunks.join(''), false, start_mark, end_mark, style);
  31325. }
  31326. /*
  31327. See the specification for details.
  31328. */
  31329. scan_block_scalar_indicators(start_mark) {
  31330. var char, chomping, increment;
  31331. chomping = null;
  31332. increment = null;
  31333. char = this.peek();
  31334. if (indexOf.call('+-', char) >= 0) {
  31335. chomping = char === '+';
  31336. this.forward();
  31337. char = this.peek();
  31338. if (indexOf.call(C_NUMBERS, char) >= 0) {
  31339. increment = parseInt(char);
  31340. if (increment === 0) {
  31341. throw new exports.ScannerError('while scanning a block scalar', start_mark, 'expected indentation indicator in the range 1-9 but found 0', this.get_mark());
  31342. }
  31343. this.forward();
  31344. }
  31345. } else if (indexOf.call(C_NUMBERS, char) >= 0) {
  31346. increment = parseInt(char);
  31347. if (increment === 0) {
  31348. throw new exports.ScannerError('while scanning a block scalar', start_mark, 'expected indentation indicator in the range 1-9 but found 0', this.get_mark());
  31349. }
  31350. this.forward();
  31351. char = this.peek();
  31352. if (indexOf.call('+-', char) >= 0) {
  31353. chomping = char === '+';
  31354. this.forward();
  31355. }
  31356. }
  31357. char = this.peek();
  31358. if (indexOf.call(C_LB + '\x00 ', char) < 0) {
  31359. throw new exports.ScannerError('while scanning a block scalar', start_mark, `expected chomping or indentation indicators, but found ${char}`, this.get_mark());
  31360. }
  31361. return [chomping, increment];
  31362. }
  31363. /*
  31364. See the specification for details.
  31365. */
  31366. scan_block_scalar_ignored_line(start_mark) {
  31367. var char, ref;
  31368. while (this.peek() === ' ') {
  31369. this.forward();
  31370. }
  31371. if (this.peek() === '#') {
  31372. while (ref = this.peek(), indexOf.call(C_LB + '\x00', ref) < 0) {
  31373. this.forward();
  31374. }
  31375. }
  31376. char = this.peek();
  31377. if (indexOf.call(C_LB + '\x00', char) < 0) {
  31378. throw new exports.ScannerError('while scanning a block scalar', start_mark, `expected a comment or a line break but found ${char}`, this.get_mark());
  31379. }
  31380. return this.scan_line_break();
  31381. }
  31382. /*
  31383. See the specification for details.
  31384. */
  31385. scan_block_scalar_indentation() {
  31386. var chunks, end_mark, max_indent, ref;
  31387. chunks = [];
  31388. max_indent = 0;
  31389. end_mark = this.get_mark();
  31390. while (ref = this.peek(), indexOf.call(C_LB + ' ', ref) >= 0) {
  31391. if (this.peek() !== ' ') {
  31392. chunks.push(this.scan_line_break());
  31393. end_mark = this.get_mark();
  31394. } else {
  31395. this.forward();
  31396. if (this.column > max_indent) {
  31397. max_indent = this.column;
  31398. }
  31399. }
  31400. }
  31401. return [chunks, max_indent, end_mark];
  31402. }
  31403. /*
  31404. See the specification for details.
  31405. */
  31406. scan_block_scalar_breaks(indent) {
  31407. var chunks, end_mark, ref;
  31408. chunks = [];
  31409. end_mark = this.get_mark();
  31410. while (this.column < indent && this.peek() === ' ') {
  31411. this.forward();
  31412. }
  31413. while (ref = this.peek(), indexOf.call(C_LB, ref) >= 0) {
  31414. chunks.push(this.scan_line_break());
  31415. end_mark = this.get_mark();
  31416. while (this.column < indent && this.peek() === ' ') {
  31417. this.forward();
  31418. }
  31419. }
  31420. return [chunks, end_mark];
  31421. }
  31422. /*
  31423. See the specification for details.
  31424. Note that we loose indentation rules for quoted scalars. Quoted scalars
  31425. don't need to adhere indentation because " and ' clearly mark the beginning
  31426. and the end of them. Therefore we are less restrictive than the
  31427. specification requires. We only need to check that document separators are
  31428. not included in scalars.
  31429. */
  31430. scan_flow_scalar(style) {
  31431. var chunks, double, quote, start_mark;
  31432. double = style === '"';
  31433. chunks = [];
  31434. start_mark = this.get_mark();
  31435. quote = this.peek();
  31436. this.forward();
  31437. chunks = chunks.concat(this.scan_flow_scalar_non_spaces(double, start_mark));
  31438. while (this.peek() !== quote) {
  31439. chunks = chunks.concat(this.scan_flow_scalar_spaces(double, start_mark));
  31440. chunks = chunks.concat(this.scan_flow_scalar_non_spaces(double, start_mark));
  31441. }
  31442. this.forward();
  31443. return new tokens.ScalarToken(chunks.join(''), false, start_mark, this.get_mark(), style);
  31444. }
  31445. /*
  31446. See the specification for details.
  31447. */
  31448. scan_flow_scalar_non_spaces(double, start_mark) {
  31449. var char, chunks, code, i, k, length, ref, ref1, ref2;
  31450. chunks = [];
  31451. while (true) {
  31452. length = 0;
  31453. while (ref = this.peek(length), indexOf.call(C_LB + C_WS + '\'"\\\x00', ref) < 0) {
  31454. length++;
  31455. }
  31456. if (length !== 0) {
  31457. chunks.push(this.prefix(length));
  31458. this.forward(length);
  31459. }
  31460. char = this.peek();
  31461. if (!double && char === '\'' && this.peek(1) === '\'') {
  31462. chunks.push('\'');
  31463. this.forward(2);
  31464. } else if ((double && char === '\'') || (!double && indexOf.call('"\\', char) >= 0)) {
  31465. chunks.push(char);
  31466. this.forward();
  31467. } else if (double && char === '\\') {
  31468. this.forward();
  31469. char = this.peek();
  31470. if (char in ESCAPE_REPLACEMENTS) {
  31471. chunks.push(ESCAPE_REPLACEMENTS[char]);
  31472. this.forward();
  31473. } else if (char in ESCAPE_CODES) {
  31474. length = ESCAPE_CODES[char];
  31475. this.forward();
  31476. for (k = i = 0, ref1 = length; 0 <= ref1 ? i < ref1 : i > ref1; k = 0 <= ref1 ? ++i : --i) {
  31477. if (ref2 = this.peek(k), indexOf.call(`${C_NUMBERS}ABCDEFabcdef`, ref2) < 0) {
  31478. throw new exports.ScannerError('while scanning a double-quoted scalar', start_mark, `expected escape sequence of ${length} hexadecimal numbers, but found ${this.peek(k)}`, this.get_mark());
  31479. }
  31480. }
  31481. code = parseInt(this.prefix(length), 16);
  31482. chunks.push(String.fromCharCode(code));
  31483. this.forward(length);
  31484. } else if (indexOf.call(C_LB, char) >= 0) {
  31485. this.scan_line_break();
  31486. chunks = chunks.concat(this.scan_flow_scalar_breaks(double, start_mark));
  31487. } else {
  31488. throw new exports.ScannerError('while scanning a double-quoted scalar', start_mark, `found unknown escape character ${char}`, this.get_mark());
  31489. }
  31490. } else {
  31491. return chunks;
  31492. }
  31493. }
  31494. }
  31495. /*
  31496. See the specification for details.
  31497. */
  31498. scan_flow_scalar_spaces(double, start_mark) {
  31499. var breaks, char, chunks, length, line_break, ref, whitespaces;
  31500. chunks = [];
  31501. length = 0;
  31502. while (ref = this.peek(length), indexOf.call(C_WS, ref) >= 0) {
  31503. length++;
  31504. }
  31505. whitespaces = this.prefix(length);
  31506. this.forward(length);
  31507. char = this.peek();
  31508. if (char === '\x00') {
  31509. throw new exports.ScannerError('while scanning a quoted scalar', start_mark, 'found unexpected end of stream', this.get_mark());
  31510. }
  31511. if (indexOf.call(C_LB, char) >= 0) {
  31512. line_break = this.scan_line_break();
  31513. breaks = this.scan_flow_scalar_breaks(double, start_mark);
  31514. if (line_break !== '\n') {
  31515. chunks.push(line_break);
  31516. } else if (breaks.length === 0) {
  31517. chunks.push(' ');
  31518. }
  31519. chunks = chunks.concat(breaks);
  31520. } else {
  31521. chunks.push(whitespaces);
  31522. }
  31523. return chunks;
  31524. }
  31525. /*
  31526. See the specification for details.
  31527. */
  31528. scan_flow_scalar_breaks(double, start_mark) {
  31529. var chunks, prefix, ref, ref1, ref2;
  31530. chunks = [];
  31531. while (true) {
  31532. // Instead of checking for indentation, we check for document separators.
  31533. prefix = this.prefix(3);
  31534. if (prefix === '---' || prefix === '...' && (ref = this.peek(3), indexOf.call(C_LB + C_WS + '\x00', ref) >= 0)) {
  31535. throw new exports.ScannerError('while scanning a quoted scalar', start_mark, 'found unexpected document separator', this.get_mark());
  31536. }
  31537. while (ref1 = this.peek(), indexOf.call(C_WS, ref1) >= 0) {
  31538. this.forward();
  31539. }
  31540. if (ref2 = this.peek(), indexOf.call(C_LB, ref2) >= 0) {
  31541. chunks.push(this.scan_line_break());
  31542. } else {
  31543. return chunks;
  31544. }
  31545. }
  31546. }
  31547. /*
  31548. See the specification for details.
  31549. We add an additional restriction for the flow context:
  31550. plain scalars in the flow context cannot contain ',', ':' and '?'.
  31551. We also keep track of the `allow_simple_key` flag here.
  31552. Indentation rules are loosed for the flow context.
  31553. */
  31554. scan_plain() {
  31555. var char, chunks, end_mark, indent, length, ref, ref1, spaces, start_mark;
  31556. chunks = [];
  31557. start_mark = end_mark = this.get_mark();
  31558. indent = this.indent + 1;
  31559. // We allow zero indentation for scalars, but then we need to check for
  31560. // document separators at the beginning of the line.
  31561. // indent = 1 if indent is 0
  31562. spaces = [];
  31563. while (true) {
  31564. length = 0;
  31565. if (this.peek() === '#') {
  31566. break;
  31567. }
  31568. while (true) {
  31569. char = this.peek(length);
  31570. if (indexOf.call(C_LB + C_WS + '\x00', char) >= 0 || (this.flow_level === 0 && char === ':' && (ref = this.peek(length + 1), indexOf.call(C_LB + C_WS + '\x00', ref) >= 0)) || (this.flow_level !== 0 && indexOf.call(',:?[]{}', char) >= 0)) {
  31571. break;
  31572. }
  31573. length++;
  31574. }
  31575. // It's not clear what we should do with ':' in the flow context.
  31576. if (this.flow_level !== 0 && char === ':' && (ref1 = this.peek(length + 1), indexOf.call(C_LB + C_WS + '\x00,[]{}', ref1) < 0)) {
  31577. this.forward(length);
  31578. throw new exports.ScannerError('while scanning a plain scalar', start_mark, 'found unexpected \':\'', this.get_mark(), 'Please check http://pyyaml.org/wiki/YAMLColonInFlowContext');
  31579. }
  31580. if (length === 0) {
  31581. break;
  31582. }
  31583. this.allow_simple_key = false;
  31584. chunks = chunks.concat(spaces);
  31585. chunks.push(this.prefix(length));
  31586. this.forward(length);
  31587. end_mark = this.get_mark();
  31588. spaces = this.scan_plain_spaces(indent, start_mark);
  31589. if ((spaces == null) || spaces.length === 0 || this.peek() === '#' || (this.flow_level === 0 && this.column < indent)) {
  31590. break;
  31591. }
  31592. }
  31593. return new tokens.ScalarToken(chunks.join(''), true, start_mark, end_mark);
  31594. }
  31595. /*
  31596. See the specification for details.
  31597. The specification is really confusing about tabs in plain scalars.
  31598. We just forbid them completely. Do not use tabs in YAML!
  31599. */
  31600. scan_plain_spaces(indent, start_mark) {
  31601. var breaks, char, chunks, length, line_break, prefix, ref, ref1, ref2, ref3, whitespaces;
  31602. chunks = [];
  31603. length = 0;
  31604. while (ref = this.peek(length), indexOf.call(' ', ref) >= 0) {
  31605. length++;
  31606. }
  31607. whitespaces = this.prefix(length);
  31608. this.forward(length);
  31609. char = this.peek();
  31610. if (indexOf.call(C_LB, char) >= 0) {
  31611. line_break = this.scan_line_break();
  31612. this.allow_simple_key = true;
  31613. prefix = this.prefix(3);
  31614. if (prefix === '---' || prefix === '...' && (ref1 = this.peek(3), indexOf.call(C_LB + C_WS + '\x00', ref1) >= 0)) {
  31615. return;
  31616. }
  31617. breaks = [];
  31618. while (ref3 = this.peek(), indexOf.call(C_LB + ' ', ref3) >= 0) {
  31619. if (this.peek() === ' ') {
  31620. this.forward();
  31621. } else {
  31622. breaks.push(this.scan_line_break());
  31623. prefix = this.prefix(3);
  31624. if (prefix === '---' || prefix === '...' && (ref2 = this.peek(3), indexOf.call(C_LB + C_WS + '\x00', ref2) >= 0)) {
  31625. return;
  31626. }
  31627. }
  31628. }
  31629. if (line_break !== '\n') {
  31630. chunks.push(line_break);
  31631. } else if (breaks.length === 0) {
  31632. chunks.push(' ');
  31633. }
  31634. chunks = chunks.concat(breaks);
  31635. } else if (whitespaces) {
  31636. chunks.push(whitespaces);
  31637. }
  31638. return chunks;
  31639. }
  31640. /*
  31641. See the specification for details.
  31642. For some strange reasons, the specification does not allow '_' in tag
  31643. handles. I have allowed it anyway.
  31644. */
  31645. scan_tag_handle(name, start_mark) {
  31646. var char, length, value;
  31647. char = this.peek();
  31648. if (char !== '!') {
  31649. throw new exports.ScannerError(`while scanning a ${name}`, start_mark, `expected '!' but found ${char}`, this.get_mark());
  31650. }
  31651. length = 1;
  31652. char = this.peek(length);
  31653. if (char !== ' ') {
  31654. while (('0' <= char && char <= '9') || ('A' <= char && char <= 'Z') || ('a' <= char && char <= 'z') || indexOf.call('-_', char) >= 0) {
  31655. length++;
  31656. char = this.peek(length);
  31657. }
  31658. if (char !== '!') {
  31659. this.forward(length);
  31660. throw new exports.ScannerError(`while scanning a ${name}`, start_mark, `expected '!' but found ${char}`, this.get_mark());
  31661. }
  31662. length++;
  31663. }
  31664. value = this.prefix(length);
  31665. this.forward(length);
  31666. return value;
  31667. }
  31668. /*
  31669. See the specification for details.
  31670. Note: we do not check if URI is well-formed.
  31671. */
  31672. scan_tag_uri(name, start_mark) {
  31673. var char, chunks, length;
  31674. chunks = [];
  31675. length = 0;
  31676. char = this.peek(length);
  31677. while (('0' <= char && char <= '9') || ('A' <= char && char <= 'Z') || ('a' <= char && char <= 'z') || indexOf.call('-;/?:@&=+$,_.!~*\'()[]%', char) >= 0) {
  31678. if (char === '%') {
  31679. chunks.push(this.prefix(length));
  31680. this.forward(length);
  31681. length = 0;
  31682. chunks.push(this.scan_uri_escapes(name, start_mark));
  31683. } else {
  31684. length++;
  31685. }
  31686. char = this.peek(length);
  31687. }
  31688. if (length !== 0) {
  31689. chunks.push(this.prefix(length));
  31690. this.forward(length);
  31691. length = 0;
  31692. }
  31693. if (chunks.length === 0) {
  31694. throw new exports.ScannerError(`while parsing a ${name}`, start_mark, `expected URI but found ${char}`, this.get_mark());
  31695. }
  31696. return chunks.join('');
  31697. }
  31698. /*
  31699. See the specification for details.
  31700. */
  31701. scan_uri_escapes(name, start_mark) {
  31702. var bytes, i, k, mark;
  31703. bytes = [];
  31704. mark = this.get_mark();
  31705. while (this.peek() === '%') {
  31706. this.forward();
  31707. for (k = i = 0; i <= 2; k = ++i) {
  31708. throw new exports.ScannerError(`while scanning a ${name}`, start_mark, `expected URI escape sequence of 2 hexadecimal numbers but found ${this.peek(k)}`, this.get_mark());
  31709. }
  31710. bytes.push(String.fromCharCode(parseInt(this.prefix(2), 16)));
  31711. this.forward(2);
  31712. }
  31713. return bytes.join('');
  31714. }
  31715. /*
  31716. Transforms:
  31717. '\r\n' : '\n'
  31718. '\r' : '\n'
  31719. '\n' : '\n'
  31720. '\x85' : '\n'
  31721. '\u2028' : '\u2028'
  31722. '\u2029 : '\u2029'
  31723. default : ''
  31724. */
  31725. scan_line_break() {
  31726. var char;
  31727. char = this.peek();
  31728. if (indexOf.call('\r\n\x85', char) >= 0) {
  31729. if (this.prefix(2) === '\r\n') {
  31730. this.forward(2);
  31731. } else {
  31732. this.forward();
  31733. }
  31734. return '\n';
  31735. } else if (indexOf.call('\u2028\u2029', char) >= 0) {
  31736. this.forward();
  31737. return char;
  31738. }
  31739. return '';
  31740. }
  31741. };
  31742. C_LB = '\r\n\x85\u2028\u2029';
  31743. C_WS = '\t ';
  31744. C_NUMBERS = '0123456789';
  31745. ESCAPE_REPLACEMENTS = {
  31746. '0': '\x00',
  31747. 'a': '\x07',
  31748. 'b': '\x08',
  31749. 't': '\x09',
  31750. '\t': '\x09',
  31751. 'n': '\x0A',
  31752. 'v': '\x0B',
  31753. 'f': '\x0C',
  31754. 'r': '\x0D',
  31755. 'e': '\x1B',
  31756. ' ': '\x20',
  31757. '"': '"',
  31758. '\\': '\\',
  31759. 'N': '\x85',
  31760. '_': '\xA0',
  31761. 'L': '\u2028',
  31762. 'P': '\u2029'
  31763. };
  31764. ESCAPE_CODES = {
  31765. 'x': 2,
  31766. 'u': 4,
  31767. 'U': 8
  31768. };
  31769. ctor = Scanner.prototype.initialise;
  31770. return Scanner;
  31771. }).call(this);
  31772. }).call(this);
  31773. /***/ }),
  31774. /***/ 56472:
  31775. /***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
  31776. (function() {
  31777. var YAMLError, events, nodes, util;
  31778. events = __webpack_require__(35063);
  31779. nodes = __webpack_require__(96914);
  31780. util = __webpack_require__(23823);
  31781. ({YAMLError} = __webpack_require__(45372));
  31782. this.SerializerError = class SerializerError extends YAMLError {};
  31783. this.Serializer = (function() {
  31784. var ctor;
  31785. class Serializer {
  31786. constructor() {
  31787. return ctor.apply(this, arguments);
  31788. }
  31789. initialise({
  31790. encoding: encoding,
  31791. explicit_start: explicit_start,
  31792. explicit_end: explicit_end,
  31793. version: version,
  31794. tags: tags
  31795. } = {}) {
  31796. this.encoding = encoding;
  31797. this.explicit_start = explicit_start;
  31798. this.explicit_end = explicit_end;
  31799. this.version = version;
  31800. this.tags = tags;
  31801. this.serialized_nodes = {};
  31802. this.anchors = {};
  31803. this.last_anchor_id = 0;
  31804. return this.closed = null;
  31805. }
  31806. open() {
  31807. if (this.closed === null) {
  31808. this.emit(new events.StreamStartEvent(this.encoding));
  31809. return this.closed = false;
  31810. } else if (this.closed) {
  31811. throw new SerializerError('serializer is closed');
  31812. } else {
  31813. throw new SerializerError('serializer is already open');
  31814. }
  31815. }
  31816. close() {
  31817. if (this.closed === null) {
  31818. throw new SerializerError('serializer is not opened');
  31819. } else if (!this.closed) {
  31820. this.emit(new events.StreamEndEvent);
  31821. return this.closed = true;
  31822. }
  31823. }
  31824. serialize(node) {
  31825. if (this.closed === null) {
  31826. throw new SerializerError('serializer is not opened');
  31827. } else if (this.closed) {
  31828. throw new SerializerError('serializer is closed');
  31829. }
  31830. if (node != null) {
  31831. this.emit(new events.DocumentStartEvent(void 0, void 0, this.explicit_start, this.version, this.tags));
  31832. this.anchor_node(node);
  31833. this.serialize_node(node);
  31834. this.emit(new events.DocumentEndEvent(void 0, void 0, this.explicit_end));
  31835. }
  31836. this.serialized_nodes = {};
  31837. this.anchors = {};
  31838. return this.last_anchor_id = 0;
  31839. }
  31840. anchor_node(node) {
  31841. var base, i, item, j, key, len, len1, name, ref, ref1, results, results1, value;
  31842. if (node.unique_id in this.anchors) {
  31843. return (base = this.anchors)[name = node.unique_id] != null ? base[name] : base[name] = this.generate_anchor(node);
  31844. } else {
  31845. this.anchors[node.unique_id] = null;
  31846. if (node instanceof nodes.SequenceNode) {
  31847. ref = node.value;
  31848. results = [];
  31849. for (i = 0, len = ref.length; i < len; i++) {
  31850. item = ref[i];
  31851. results.push(this.anchor_node(item));
  31852. }
  31853. return results;
  31854. } else if (node instanceof nodes.MappingNode) {
  31855. ref1 = node.value;
  31856. results1 = [];
  31857. for (j = 0, len1 = ref1.length; j < len1; j++) {
  31858. [key, value] = ref1[j];
  31859. this.anchor_node(key);
  31860. results1.push(this.anchor_node(value));
  31861. }
  31862. return results1;
  31863. }
  31864. }
  31865. }
  31866. generate_anchor(node) {
  31867. return `id${util.pad_left(++this.last_anchor_id, '0', 4)}`;
  31868. }
  31869. serialize_node(node, parent, index) {
  31870. var alias, default_tag, detected_tag, i, implicit, item, j, key, len, len1, ref, ref1, value;
  31871. alias = this.anchors[node.unique_id];
  31872. if (node.unique_id in this.serialized_nodes) {
  31873. return this.emit(new events.AliasEvent(alias));
  31874. } else {
  31875. this.serialized_nodes[node.unique_id] = true;
  31876. this.descend_resolver(parent, index);
  31877. if (node instanceof nodes.ScalarNode) {
  31878. detected_tag = this.resolve(nodes.ScalarNode, node.value, [true, false]);
  31879. default_tag = this.resolve(nodes.ScalarNode, node.value, [false, true]);
  31880. implicit = [node.tag === detected_tag, node.tag === default_tag];
  31881. this.emit(new events.ScalarEvent(alias, node.tag, implicit, node.value, void 0, void 0, node.style));
  31882. } else if (node instanceof nodes.SequenceNode) {
  31883. implicit = node.tag === this.resolve(nodes.SequenceNode, node.value, true);
  31884. this.emit(new events.SequenceStartEvent(alias, node.tag, implicit, void 0, void 0, node.flow_style));
  31885. ref = node.value;
  31886. for (index = i = 0, len = ref.length; i < len; index = ++i) {
  31887. item = ref[index];
  31888. this.serialize_node(item, node, index);
  31889. }
  31890. this.emit(new events.SequenceEndEvent);
  31891. } else if (node instanceof nodes.MappingNode) {
  31892. implicit = node.tag === this.resolve(nodes.MappingNode, node.value, true);
  31893. this.emit(new events.MappingStartEvent(alias, node.tag, implicit, void 0, void 0, node.flow_style));
  31894. ref1 = node.value;
  31895. for (j = 0, len1 = ref1.length; j < len1; j++) {
  31896. [key, value] = ref1[j];
  31897. this.serialize_node(key, node, null);
  31898. this.serialize_node(value, node, key);
  31899. }
  31900. this.emit(new events.MappingEndEvent);
  31901. }
  31902. return this.ascend_resolver();
  31903. }
  31904. }
  31905. };
  31906. ctor = Serializer.prototype.initialise;
  31907. return Serializer;
  31908. }).call(this);
  31909. }).call(this);
  31910. /***/ }),
  31911. /***/ 59902:
  31912. /***/ (function() {
  31913. (function() {
  31914. this.Token = class Token {
  31915. constructor(start_mark1, end_mark1) {
  31916. this.start_mark = start_mark1;
  31917. this.end_mark = end_mark1;
  31918. }
  31919. };
  31920. this.DirectiveToken = (function() {
  31921. class DirectiveToken extends this.Token {
  31922. constructor(name, value, start_mark, end_mark) {
  31923. super(start_mark, end_mark);
  31924. this.name = name;
  31925. this.value = value;
  31926. }
  31927. };
  31928. DirectiveToken.prototype.id = '<directive>';
  31929. return DirectiveToken;
  31930. }).call(this);
  31931. this.DocumentStartToken = (function() {
  31932. class DocumentStartToken extends this.Token {};
  31933. DocumentStartToken.prototype.id = '<document start>';
  31934. return DocumentStartToken;
  31935. }).call(this);
  31936. this.DocumentEndToken = (function() {
  31937. class DocumentEndToken extends this.Token {};
  31938. DocumentEndToken.prototype.id = '<document end>';
  31939. return DocumentEndToken;
  31940. }).call(this);
  31941. this.StreamStartToken = (function() {
  31942. class StreamStartToken extends this.Token {
  31943. constructor(start_mark, end_mark, encoding) {
  31944. super(start_mark, end_mark);
  31945. this.encoding = encoding;
  31946. }
  31947. };
  31948. StreamStartToken.prototype.id = '<stream start>';
  31949. return StreamStartToken;
  31950. }).call(this);
  31951. this.StreamEndToken = (function() {
  31952. class StreamEndToken extends this.Token {};
  31953. StreamEndToken.prototype.id = '<stream end>';
  31954. return StreamEndToken;
  31955. }).call(this);
  31956. this.BlockSequenceStartToken = (function() {
  31957. class BlockSequenceStartToken extends this.Token {};
  31958. BlockSequenceStartToken.prototype.id = '<block sequence start>';
  31959. return BlockSequenceStartToken;
  31960. }).call(this);
  31961. this.BlockMappingStartToken = (function() {
  31962. class BlockMappingStartToken extends this.Token {};
  31963. BlockMappingStartToken.prototype.id = '<block mapping end>';
  31964. return BlockMappingStartToken;
  31965. }).call(this);
  31966. this.BlockEndToken = (function() {
  31967. class BlockEndToken extends this.Token {};
  31968. BlockEndToken.prototype.id = '<block end>';
  31969. return BlockEndToken;
  31970. }).call(this);
  31971. this.FlowSequenceStartToken = (function() {
  31972. class FlowSequenceStartToken extends this.Token {};
  31973. FlowSequenceStartToken.prototype.id = '[';
  31974. return FlowSequenceStartToken;
  31975. }).call(this);
  31976. this.FlowMappingStartToken = (function() {
  31977. class FlowMappingStartToken extends this.Token {};
  31978. FlowMappingStartToken.prototype.id = '{';
  31979. return FlowMappingStartToken;
  31980. }).call(this);
  31981. this.FlowSequenceEndToken = (function() {
  31982. class FlowSequenceEndToken extends this.Token {};
  31983. FlowSequenceEndToken.prototype.id = ']';
  31984. return FlowSequenceEndToken;
  31985. }).call(this);
  31986. this.FlowMappingEndToken = (function() {
  31987. class FlowMappingEndToken extends this.Token {};
  31988. FlowMappingEndToken.prototype.id = '}';
  31989. return FlowMappingEndToken;
  31990. }).call(this);
  31991. this.KeyToken = (function() {
  31992. class KeyToken extends this.Token {};
  31993. KeyToken.prototype.id = '?';
  31994. return KeyToken;
  31995. }).call(this);
  31996. this.ValueToken = (function() {
  31997. class ValueToken extends this.Token {};
  31998. ValueToken.prototype.id = ':';
  31999. return ValueToken;
  32000. }).call(this);
  32001. this.BlockEntryToken = (function() {
  32002. class BlockEntryToken extends this.Token {};
  32003. BlockEntryToken.prototype.id = '-';
  32004. return BlockEntryToken;
  32005. }).call(this);
  32006. this.FlowEntryToken = (function() {
  32007. class FlowEntryToken extends this.Token {};
  32008. FlowEntryToken.prototype.id = ',';
  32009. return FlowEntryToken;
  32010. }).call(this);
  32011. this.AliasToken = (function() {
  32012. class AliasToken extends this.Token {
  32013. constructor(value, start_mark, end_mark) {
  32014. super(start_mark, end_mark);
  32015. this.value = value;
  32016. }
  32017. };
  32018. AliasToken.prototype.id = '<alias>';
  32019. return AliasToken;
  32020. }).call(this);
  32021. this.AnchorToken = (function() {
  32022. class AnchorToken extends this.Token {
  32023. constructor(value, start_mark, end_mark) {
  32024. super(start_mark, end_mark);
  32025. this.value = value;
  32026. }
  32027. };
  32028. AnchorToken.prototype.id = '<anchor>';
  32029. return AnchorToken;
  32030. }).call(this);
  32031. this.TagToken = (function() {
  32032. class TagToken extends this.Token {
  32033. constructor(value, start_mark, end_mark) {
  32034. super(start_mark, end_mark);
  32035. this.value = value;
  32036. }
  32037. };
  32038. TagToken.prototype.id = '<tag>';
  32039. return TagToken;
  32040. }).call(this);
  32041. this.ScalarToken = (function() {
  32042. class ScalarToken extends this.Token {
  32043. constructor(value, plain, start_mark, end_mark, style) {
  32044. super(start_mark, end_mark);
  32045. this.value = value;
  32046. this.plain = plain;
  32047. this.style = style;
  32048. }
  32049. };
  32050. ScalarToken.prototype.id = '<scalar>';
  32051. return ScalarToken;
  32052. }).call(this);
  32053. }).call(this);
  32054. /***/ }),
  32055. /***/ 23823:
  32056. /***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
  32057. (function() {
  32058. /*
  32059. A small class to stand-in for a stream when you simply want to write to a string.
  32060. */
  32061. var ref, ref1, ref2,
  32062. hasProp = {}.hasOwnProperty;
  32063. this.StringStream = class StringStream {
  32064. constructor() {
  32065. this.string = '';
  32066. }
  32067. write(chunk) {
  32068. return this.string += chunk;
  32069. }
  32070. };
  32071. this.clone = (obj) => {
  32072. return Object.assign({}, obj);
  32073. };
  32074. this.extend = function(destination, ...sources) {
  32075. var i, j, len, len1, name, ref, source;
  32076. for (i = 0, len = sources.length; i < len; i++) {
  32077. source = sources[i];
  32078. while (source !== Object.prototype) {
  32079. ref = Object.getOwnPropertyNames(source);
  32080. for (j = 0, len1 = ref.length; j < len1; j++) {
  32081. name = ref[j];
  32082. if (destination[name] == null) {
  32083. destination[name] = source[name];
  32084. }
  32085. }
  32086. source = Object.getPrototypeOf(source);
  32087. }
  32088. }
  32089. return destination;
  32090. };
  32091. this.is_empty = function(obj) {
  32092. var key;
  32093. if (Array.isArray(obj) || typeof obj === 'string') {
  32094. return obj.length === 0;
  32095. }
  32096. for (key in obj) {
  32097. if (!hasProp.call(obj, key)) continue;
  32098. return false;
  32099. }
  32100. return true;
  32101. };
  32102. this.inspect = (ref = (ref1 = (ref2 = __webpack_require__(31669)) != null ? ref2.inspect : void 0) != null ? ref1 : global.inspect) != null ? ref : function(a) {
  32103. return `${a}`;
  32104. };
  32105. this.pad_left = function(str, char, length) {
  32106. str = String(str);
  32107. if (str.length >= length) {
  32108. return str;
  32109. } else if (str.length + 1 === length) {
  32110. return `${char}${str}`;
  32111. } else {
  32112. return `${new Array(length - str.length + 1).join(char)}${str}`;
  32113. }
  32114. };
  32115. this.to_hex = function(num) {
  32116. if (typeof num === 'string') {
  32117. num = num.charCodeAt(0);
  32118. }
  32119. return num.toString(16);
  32120. };
  32121. }).call(this);
  32122. /***/ }),
  32123. /***/ 35740:
  32124. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  32125. (function() {
  32126. var composer, constructor, dumper, errors, events, loader, nodes, parser, reader, resolver, scanner, tokens, util;
  32127. composer = this.composer = __webpack_require__(6391);
  32128. constructor = this.constructor = __webpack_require__(51574);
  32129. dumper = this.dumper = __webpack_require__(28190);
  32130. errors = this.errors = __webpack_require__(45372);
  32131. events = this.events = __webpack_require__(35063);
  32132. loader = this.loader = __webpack_require__(82696);
  32133. nodes = this.nodes = __webpack_require__(96914);
  32134. parser = this.parser = __webpack_require__(72806);
  32135. reader = this.reader = __webpack_require__(27026);
  32136. resolver = this.resolver = __webpack_require__(3579);
  32137. scanner = this.scanner = __webpack_require__(72265);
  32138. tokens = this.tokens = __webpack_require__(59902);
  32139. util = __webpack_require__(23823);
  32140. /*
  32141. Scan a YAML stream and produce scanning tokens.
  32142. */
  32143. this.scan = function(stream, Loader = loader.Loader) {
  32144. var _loader, results;
  32145. _loader = new Loader(stream);
  32146. results = [];
  32147. while (_loader.check_token()) {
  32148. results.push(_loader.get_token());
  32149. }
  32150. return results;
  32151. };
  32152. /*
  32153. Parse a YAML stream and produce parsing events.
  32154. */
  32155. this.parse = function(stream, Loader = loader.Loader) {
  32156. var _loader, results;
  32157. _loader = new Loader(stream);
  32158. results = [];
  32159. while (_loader.check_event()) {
  32160. results.push(_loader.get_event());
  32161. }
  32162. return results;
  32163. };
  32164. /*
  32165. Parse the first YAML document in a stream and produce the corresponding
  32166. representation tree.
  32167. */
  32168. this.compose = function(stream, Loader = loader.Loader) {
  32169. var _loader;
  32170. _loader = new Loader(stream);
  32171. return _loader.get_single_node();
  32172. };
  32173. /*
  32174. Parse all YAML documents in a stream and produce corresponding representation
  32175. trees.
  32176. */
  32177. this.compose_all = function(stream, Loader = loader.Loader) {
  32178. var _loader, results;
  32179. _loader = new Loader(stream);
  32180. results = [];
  32181. while (_loader.check_node()) {
  32182. results.push(_loader.get_node());
  32183. }
  32184. return results;
  32185. };
  32186. /*
  32187. Parse the first YAML document in a stream and produce the corresponding
  32188. Javascript object.
  32189. */
  32190. this.load = function(stream, Loader = loader.Loader) {
  32191. var _loader;
  32192. _loader = new Loader(stream);
  32193. return _loader.get_single_data();
  32194. };
  32195. /*
  32196. Parse all YAML documents in a stream and produce the corresponing Javascript
  32197. object.
  32198. */
  32199. this.load_all = function(stream, Loader = loader.Loader) {
  32200. var _loader, results;
  32201. _loader = new Loader(stream);
  32202. results = [];
  32203. while (_loader.check_data()) {
  32204. results.push(_loader.get_data());
  32205. }
  32206. return results;
  32207. };
  32208. /*
  32209. Emit YAML parsing events into a stream.
  32210. If stream is falsey, return the produced string instead.
  32211. */
  32212. this.emit = function(events, stream, Dumper = dumper.Dumper, options = {}) {
  32213. var _dumper, dest, event, i, len;
  32214. dest = stream || new util.StringStream;
  32215. _dumper = new Dumper(dest, options);
  32216. try {
  32217. for (i = 0, len = events.length; i < len; i++) {
  32218. event = events[i];
  32219. _dumper.emit(event);
  32220. }
  32221. } finally {
  32222. _dumper.dispose();
  32223. }
  32224. return stream || dest.string;
  32225. };
  32226. /*
  32227. Serialize a representation tree into a YAML stream.
  32228. If stream is falsey, return the produced string instead.
  32229. */
  32230. this.serialize = function(node, stream, Dumper = dumper.Dumper, options = {}) {
  32231. return exports.serialize_all([node], stream, Dumper, options);
  32232. };
  32233. /*
  32234. Serialize a sequence of representation tress into a YAML stream.
  32235. If stream is falsey, return the produced string instead.
  32236. */
  32237. this.serialize_all = function(nodes, stream, Dumper = dumper.Dumper, options = {}) {
  32238. var _dumper, dest, i, len, node;
  32239. dest = stream || new util.StringStream;
  32240. _dumper = new Dumper(dest, options);
  32241. try {
  32242. _dumper.open();
  32243. for (i = 0, len = nodes.length; i < len; i++) {
  32244. node = nodes[i];
  32245. _dumper.serialize(node);
  32246. }
  32247. _dumper.close();
  32248. } finally {
  32249. _dumper.dispose();
  32250. }
  32251. return stream || dest.string;
  32252. };
  32253. /*
  32254. Serialize a Javascript object into a YAML stream.
  32255. If stream is falsey, return the produced string instead.
  32256. */
  32257. this.dump = function(data, stream, Dumper = dumper.Dumper, options = {}) {
  32258. return exports.dump_all([data], stream, Dumper, options);
  32259. };
  32260. /*
  32261. Serialize a sequence of Javascript objects into a YAML stream.
  32262. If stream is falsey, return the produced string instead.
  32263. */
  32264. this.dump_all = function(documents, stream, Dumper = dumper.Dumper, options = {}) {
  32265. var _dumper, dest, document, i, len;
  32266. dest = stream || new util.StringStream;
  32267. _dumper = new Dumper(dest, options);
  32268. try {
  32269. _dumper.open();
  32270. for (i = 0, len = documents.length; i < len; i++) {
  32271. document = documents[i];
  32272. _dumper.represent(document);
  32273. }
  32274. _dumper.close();
  32275. } finally {
  32276. _dumper.dispose();
  32277. }
  32278. return stream || dest.string;
  32279. };
  32280. }).call(this);
  32281. /***/ }),
  32282. /***/ 79264:
  32283. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  32284. module.exports = __webpack_require__(39026);
  32285. /***/ })
  32286. };
  32287. ;
  32288. //# sourceMappingURL=277.index.js.map