bootstrap.js 952 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537
  1. /******/ (function(modules) { // webpackBootstrap
  2. /******/ // The module cache
  3. /******/ var installedModules = {};
  4. /******/
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/
  8. /******/ // Check if module is in cache
  9. /******/ if(installedModules[moduleId]) {
  10. /******/ return installedModules[moduleId].exports;
  11. /******/ }
  12. /******/ // Create a new module (and put it into the cache)
  13. /******/ var module = installedModules[moduleId] = {
  14. /******/ i: moduleId,
  15. /******/ l: false,
  16. /******/ exports: {}
  17. /******/ };
  18. /******/
  19. /******/ // Execute the module function
  20. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  21. /******/
  22. /******/ // Flag the module as loaded
  23. /******/ module.l = true;
  24. /******/
  25. /******/ // Return the exports of the module
  26. /******/ return module.exports;
  27. /******/ }
  28. /******/
  29. /******/
  30. /******/ // expose the modules object (__webpack_modules__)
  31. /******/ __webpack_require__.m = modules;
  32. /******/
  33. /******/ // expose the module cache
  34. /******/ __webpack_require__.c = installedModules;
  35. /******/
  36. /******/ // define getter function for harmony exports
  37. /******/ __webpack_require__.d = function(exports, name, getter) {
  38. /******/ if(!__webpack_require__.o(exports, name)) {
  39. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  40. /******/ }
  41. /******/ };
  42. /******/
  43. /******/ // define __esModule on exports
  44. /******/ __webpack_require__.r = function(exports) {
  45. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  46. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  47. /******/ }
  48. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  49. /******/ };
  50. /******/
  51. /******/ // create a fake namespace object
  52. /******/ // mode & 1: value is a module id, require it
  53. /******/ // mode & 2: merge all properties of value into the ns
  54. /******/ // mode & 4: return value when already ns object
  55. /******/ // mode & 8|1: behave like require
  56. /******/ __webpack_require__.t = function(value, mode) {
  57. /******/ if(mode & 1) value = __webpack_require__(value);
  58. /******/ if(mode & 8) return value;
  59. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  60. /******/ var ns = Object.create(null);
  61. /******/ __webpack_require__.r(ns);
  62. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  63. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  64. /******/ return ns;
  65. /******/ };
  66. /******/
  67. /******/ // getDefaultExport function for compatibility with non-harmony modules
  68. /******/ __webpack_require__.n = function(module) {
  69. /******/ var getter = module && module.__esModule ?
  70. /******/ function getDefault() { return module['default']; } :
  71. /******/ function getModuleExports() { return module; };
  72. /******/ __webpack_require__.d(getter, 'a', getter);
  73. /******/ return getter;
  74. /******/ };
  75. /******/
  76. /******/ // Object.prototype.hasOwnProperty.call
  77. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  78. /******/
  79. /******/ // __webpack_public_path__
  80. /******/ __webpack_require__.p = "/";
  81. /******/
  82. /******/
  83. /******/ // Load entry module and return exports
  84. /******/ return __webpack_require__(__webpack_require__.s = 1);
  85. /******/ })
  86. /************************************************************************/
  87. /******/ ({
  88. /***/ "./node_modules/axios/index.js":
  89. /*!*************************************!*\
  90. !*** ./node_modules/axios/index.js ***!
  91. \*************************************/
  92. /*! no static exports found */
  93. /***/ (function(module, exports, __webpack_require__) {
  94. module.exports = __webpack_require__(/*! ./lib/axios */ "./node_modules/axios/lib/axios.js");
  95. /***/ }),
  96. /***/ "./node_modules/axios/lib/adapters/xhr.js":
  97. /*!************************************************!*\
  98. !*** ./node_modules/axios/lib/adapters/xhr.js ***!
  99. \************************************************/
  100. /*! no static exports found */
  101. /***/ (function(module, exports, __webpack_require__) {
  102. "use strict";
  103. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  104. var settle = __webpack_require__(/*! ./../core/settle */ "./node_modules/axios/lib/core/settle.js");
  105. var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  106. var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js");
  107. var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js");
  108. var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js");
  109. module.exports = function xhrAdapter(config) {
  110. return new Promise(function dispatchXhrRequest(resolve, reject) {
  111. var requestData = config.data;
  112. var requestHeaders = config.headers;
  113. if (utils.isFormData(requestData)) {
  114. delete requestHeaders['Content-Type']; // Let the browser set it
  115. }
  116. var request = new XMLHttpRequest();
  117. // HTTP basic authentication
  118. if (config.auth) {
  119. var username = config.auth.username || '';
  120. var password = config.auth.password || '';
  121. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  122. }
  123. request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);
  124. // Set the request timeout in MS
  125. request.timeout = config.timeout;
  126. // Listen for ready state
  127. request.onreadystatechange = function handleLoad() {
  128. if (!request || request.readyState !== 4) {
  129. return;
  130. }
  131. // The request errored out and we didn't get a response, this will be
  132. // handled by onerror instead
  133. // With one exception: request that using file: protocol, most browsers
  134. // will return status as 0 even though it's a successful request
  135. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  136. return;
  137. }
  138. // Prepare the response
  139. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  140. var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
  141. var response = {
  142. data: responseData,
  143. status: request.status,
  144. statusText: request.statusText,
  145. headers: responseHeaders,
  146. config: config,
  147. request: request
  148. };
  149. settle(resolve, reject, response);
  150. // Clean up request
  151. request = null;
  152. };
  153. // Handle browser request cancellation (as opposed to a manual cancellation)
  154. request.onabort = function handleAbort() {
  155. if (!request) {
  156. return;
  157. }
  158. reject(createError('Request aborted', config, 'ECONNABORTED', request));
  159. // Clean up request
  160. request = null;
  161. };
  162. // Handle low level network errors
  163. request.onerror = function handleError() {
  164. // Real errors are hidden from us by the browser
  165. // onerror should only fire if it's a network error
  166. reject(createError('Network Error', config, null, request));
  167. // Clean up request
  168. request = null;
  169. };
  170. // Handle timeout
  171. request.ontimeout = function handleTimeout() {
  172. reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED',
  173. request));
  174. // Clean up request
  175. request = null;
  176. };
  177. // Add xsrf header
  178. // This is only done if running in a standard browser environment.
  179. // Specifically not if we're in a web worker, or react-native.
  180. if (utils.isStandardBrowserEnv()) {
  181. var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./node_modules/axios/lib/helpers/cookies.js");
  182. // Add xsrf header
  183. var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?
  184. cookies.read(config.xsrfCookieName) :
  185. undefined;
  186. if (xsrfValue) {
  187. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  188. }
  189. }
  190. // Add headers to the request
  191. if ('setRequestHeader' in request) {
  192. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  193. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  194. // Remove Content-Type if data is undefined
  195. delete requestHeaders[key];
  196. } else {
  197. // Otherwise add header to the request
  198. request.setRequestHeader(key, val);
  199. }
  200. });
  201. }
  202. // Add withCredentials to request if needed
  203. if (config.withCredentials) {
  204. request.withCredentials = true;
  205. }
  206. // Add responseType to request if needed
  207. if (config.responseType) {
  208. try {
  209. request.responseType = config.responseType;
  210. } catch (e) {
  211. // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
  212. // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
  213. if (config.responseType !== 'json') {
  214. throw e;
  215. }
  216. }
  217. }
  218. // Handle progress if needed
  219. if (typeof config.onDownloadProgress === 'function') {
  220. request.addEventListener('progress', config.onDownloadProgress);
  221. }
  222. // Not all browsers support upload events
  223. if (typeof config.onUploadProgress === 'function' && request.upload) {
  224. request.upload.addEventListener('progress', config.onUploadProgress);
  225. }
  226. if (config.cancelToken) {
  227. // Handle cancellation
  228. config.cancelToken.promise.then(function onCanceled(cancel) {
  229. if (!request) {
  230. return;
  231. }
  232. request.abort();
  233. reject(cancel);
  234. // Clean up request
  235. request = null;
  236. });
  237. }
  238. if (requestData === undefined) {
  239. requestData = null;
  240. }
  241. // Send the request
  242. request.send(requestData);
  243. });
  244. };
  245. /***/ }),
  246. /***/ "./node_modules/axios/lib/axios.js":
  247. /*!*****************************************!*\
  248. !*** ./node_modules/axios/lib/axios.js ***!
  249. \*****************************************/
  250. /*! no static exports found */
  251. /***/ (function(module, exports, __webpack_require__) {
  252. "use strict";
  253. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  254. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  255. var Axios = __webpack_require__(/*! ./core/Axios */ "./node_modules/axios/lib/core/Axios.js");
  256. var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  257. var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/axios/lib/defaults.js");
  258. /**
  259. * Create an instance of Axios
  260. *
  261. * @param {Object} defaultConfig The default config for the instance
  262. * @return {Axios} A new instance of Axios
  263. */
  264. function createInstance(defaultConfig) {
  265. var context = new Axios(defaultConfig);
  266. var instance = bind(Axios.prototype.request, context);
  267. // Copy axios.prototype to instance
  268. utils.extend(instance, Axios.prototype, context);
  269. // Copy context to instance
  270. utils.extend(instance, context);
  271. return instance;
  272. }
  273. // Create the default instance to be exported
  274. var axios = createInstance(defaults);
  275. // Expose Axios class to allow class inheritance
  276. axios.Axios = Axios;
  277. // Factory for creating new instances
  278. axios.create = function create(instanceConfig) {
  279. return createInstance(mergeConfig(axios.defaults, instanceConfig));
  280. };
  281. // Expose Cancel & CancelToken
  282. axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  283. axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js");
  284. axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  285. // Expose all/spread
  286. axios.all = function all(promises) {
  287. return Promise.all(promises);
  288. };
  289. axios.spread = __webpack_require__(/*! ./helpers/spread */ "./node_modules/axios/lib/helpers/spread.js");
  290. module.exports = axios;
  291. // Allow use of default import syntax in TypeScript
  292. module.exports.default = axios;
  293. /***/ }),
  294. /***/ "./node_modules/axios/lib/cancel/Cancel.js":
  295. /*!*************************************************!*\
  296. !*** ./node_modules/axios/lib/cancel/Cancel.js ***!
  297. \*************************************************/
  298. /*! no static exports found */
  299. /***/ (function(module, exports, __webpack_require__) {
  300. "use strict";
  301. /**
  302. * A `Cancel` is an object that is thrown when an operation is canceled.
  303. *
  304. * @class
  305. * @param {string=} message The message.
  306. */
  307. function Cancel(message) {
  308. this.message = message;
  309. }
  310. Cancel.prototype.toString = function toString() {
  311. return 'Cancel' + (this.message ? ': ' + this.message : '');
  312. };
  313. Cancel.prototype.__CANCEL__ = true;
  314. module.exports = Cancel;
  315. /***/ }),
  316. /***/ "./node_modules/axios/lib/cancel/CancelToken.js":
  317. /*!******************************************************!*\
  318. !*** ./node_modules/axios/lib/cancel/CancelToken.js ***!
  319. \******************************************************/
  320. /*! no static exports found */
  321. /***/ (function(module, exports, __webpack_require__) {
  322. "use strict";
  323. var Cancel = __webpack_require__(/*! ./Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  324. /**
  325. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  326. *
  327. * @class
  328. * @param {Function} executor The executor function.
  329. */
  330. function CancelToken(executor) {
  331. if (typeof executor !== 'function') {
  332. throw new TypeError('executor must be a function.');
  333. }
  334. var resolvePromise;
  335. this.promise = new Promise(function promiseExecutor(resolve) {
  336. resolvePromise = resolve;
  337. });
  338. var token = this;
  339. executor(function cancel(message) {
  340. if (token.reason) {
  341. // Cancellation has already been requested
  342. return;
  343. }
  344. token.reason = new Cancel(message);
  345. resolvePromise(token.reason);
  346. });
  347. }
  348. /**
  349. * Throws a `Cancel` if cancellation has been requested.
  350. */
  351. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  352. if (this.reason) {
  353. throw this.reason;
  354. }
  355. };
  356. /**
  357. * Returns an object that contains a new `CancelToken` and a function that, when called,
  358. * cancels the `CancelToken`.
  359. */
  360. CancelToken.source = function source() {
  361. var cancel;
  362. var token = new CancelToken(function executor(c) {
  363. cancel = c;
  364. });
  365. return {
  366. token: token,
  367. cancel: cancel
  368. };
  369. };
  370. module.exports = CancelToken;
  371. /***/ }),
  372. /***/ "./node_modules/axios/lib/cancel/isCancel.js":
  373. /*!***************************************************!*\
  374. !*** ./node_modules/axios/lib/cancel/isCancel.js ***!
  375. \***************************************************/
  376. /*! no static exports found */
  377. /***/ (function(module, exports, __webpack_require__) {
  378. "use strict";
  379. module.exports = function isCancel(value) {
  380. return !!(value && value.__CANCEL__);
  381. };
  382. /***/ }),
  383. /***/ "./node_modules/axios/lib/core/Axios.js":
  384. /*!**********************************************!*\
  385. !*** ./node_modules/axios/lib/core/Axios.js ***!
  386. \**********************************************/
  387. /*! no static exports found */
  388. /***/ (function(module, exports, __webpack_require__) {
  389. "use strict";
  390. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  391. var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  392. var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./node_modules/axios/lib/core/InterceptorManager.js");
  393. var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./node_modules/axios/lib/core/dispatchRequest.js");
  394. var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  395. /**
  396. * Create a new instance of Axios
  397. *
  398. * @param {Object} instanceConfig The default config for the instance
  399. */
  400. function Axios(instanceConfig) {
  401. this.defaults = instanceConfig;
  402. this.interceptors = {
  403. request: new InterceptorManager(),
  404. response: new InterceptorManager()
  405. };
  406. }
  407. /**
  408. * Dispatch a request
  409. *
  410. * @param {Object} config The config specific for this request (merged with this.defaults)
  411. */
  412. Axios.prototype.request = function request(config) {
  413. /*eslint no-param-reassign:0*/
  414. // Allow for axios('example/url'[, config]) a la fetch API
  415. if (typeof config === 'string') {
  416. config = arguments[1] || {};
  417. config.url = arguments[0];
  418. } else {
  419. config = config || {};
  420. }
  421. config = mergeConfig(this.defaults, config);
  422. config.method = config.method ? config.method.toLowerCase() : 'get';
  423. // Hook up interceptors middleware
  424. var chain = [dispatchRequest, undefined];
  425. var promise = Promise.resolve(config);
  426. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  427. chain.unshift(interceptor.fulfilled, interceptor.rejected);
  428. });
  429. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  430. chain.push(interceptor.fulfilled, interceptor.rejected);
  431. });
  432. while (chain.length) {
  433. promise = promise.then(chain.shift(), chain.shift());
  434. }
  435. return promise;
  436. };
  437. Axios.prototype.getUri = function getUri(config) {
  438. config = mergeConfig(this.defaults, config);
  439. return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
  440. };
  441. // Provide aliases for supported request methods
  442. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  443. /*eslint func-names:0*/
  444. Axios.prototype[method] = function(url, config) {
  445. return this.request(utils.merge(config || {}, {
  446. method: method,
  447. url: url
  448. }));
  449. };
  450. });
  451. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  452. /*eslint func-names:0*/
  453. Axios.prototype[method] = function(url, data, config) {
  454. return this.request(utils.merge(config || {}, {
  455. method: method,
  456. url: url,
  457. data: data
  458. }));
  459. };
  460. });
  461. module.exports = Axios;
  462. /***/ }),
  463. /***/ "./node_modules/axios/lib/core/InterceptorManager.js":
  464. /*!***********************************************************!*\
  465. !*** ./node_modules/axios/lib/core/InterceptorManager.js ***!
  466. \***********************************************************/
  467. /*! no static exports found */
  468. /***/ (function(module, exports, __webpack_require__) {
  469. "use strict";
  470. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  471. function InterceptorManager() {
  472. this.handlers = [];
  473. }
  474. /**
  475. * Add a new interceptor to the stack
  476. *
  477. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  478. * @param {Function} rejected The function to handle `reject` for a `Promise`
  479. *
  480. * @return {Number} An ID used to remove interceptor later
  481. */
  482. InterceptorManager.prototype.use = function use(fulfilled, rejected) {
  483. this.handlers.push({
  484. fulfilled: fulfilled,
  485. rejected: rejected
  486. });
  487. return this.handlers.length - 1;
  488. };
  489. /**
  490. * Remove an interceptor from the stack
  491. *
  492. * @param {Number} id The ID that was returned by `use`
  493. */
  494. InterceptorManager.prototype.eject = function eject(id) {
  495. if (this.handlers[id]) {
  496. this.handlers[id] = null;
  497. }
  498. };
  499. /**
  500. * Iterate over all the registered interceptors
  501. *
  502. * This method is particularly useful for skipping over any
  503. * interceptors that may have become `null` calling `eject`.
  504. *
  505. * @param {Function} fn The function to call for each interceptor
  506. */
  507. InterceptorManager.prototype.forEach = function forEach(fn) {
  508. utils.forEach(this.handlers, function forEachHandler(h) {
  509. if (h !== null) {
  510. fn(h);
  511. }
  512. });
  513. };
  514. module.exports = InterceptorManager;
  515. /***/ }),
  516. /***/ "./node_modules/axios/lib/core/createError.js":
  517. /*!****************************************************!*\
  518. !*** ./node_modules/axios/lib/core/createError.js ***!
  519. \****************************************************/
  520. /*! no static exports found */
  521. /***/ (function(module, exports, __webpack_require__) {
  522. "use strict";
  523. var enhanceError = __webpack_require__(/*! ./enhanceError */ "./node_modules/axios/lib/core/enhanceError.js");
  524. /**
  525. * Create an Error with the specified message, config, error code, request and response.
  526. *
  527. * @param {string} message The error message.
  528. * @param {Object} config The config.
  529. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  530. * @param {Object} [request] The request.
  531. * @param {Object} [response] The response.
  532. * @returns {Error} The created error.
  533. */
  534. module.exports = function createError(message, config, code, request, response) {
  535. var error = new Error(message);
  536. return enhanceError(error, config, code, request, response);
  537. };
  538. /***/ }),
  539. /***/ "./node_modules/axios/lib/core/dispatchRequest.js":
  540. /*!********************************************************!*\
  541. !*** ./node_modules/axios/lib/core/dispatchRequest.js ***!
  542. \********************************************************/
  543. /*! no static exports found */
  544. /***/ (function(module, exports, __webpack_require__) {
  545. "use strict";
  546. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  547. var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js");
  548. var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  549. var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js");
  550. var isAbsoluteURL = __webpack_require__(/*! ./../helpers/isAbsoluteURL */ "./node_modules/axios/lib/helpers/isAbsoluteURL.js");
  551. var combineURLs = __webpack_require__(/*! ./../helpers/combineURLs */ "./node_modules/axios/lib/helpers/combineURLs.js");
  552. /**
  553. * Throws a `Cancel` if cancellation has been requested.
  554. */
  555. function throwIfCancellationRequested(config) {
  556. if (config.cancelToken) {
  557. config.cancelToken.throwIfRequested();
  558. }
  559. }
  560. /**
  561. * Dispatch a request to the server using the configured adapter.
  562. *
  563. * @param {object} config The config that is to be used for the request
  564. * @returns {Promise} The Promise to be fulfilled
  565. */
  566. module.exports = function dispatchRequest(config) {
  567. throwIfCancellationRequested(config);
  568. // Support baseURL config
  569. if (config.baseURL && !isAbsoluteURL(config.url)) {
  570. config.url = combineURLs(config.baseURL, config.url);
  571. }
  572. // Ensure headers exist
  573. config.headers = config.headers || {};
  574. // Transform request data
  575. config.data = transformData(
  576. config.data,
  577. config.headers,
  578. config.transformRequest
  579. );
  580. // Flatten headers
  581. config.headers = utils.merge(
  582. config.headers.common || {},
  583. config.headers[config.method] || {},
  584. config.headers || {}
  585. );
  586. utils.forEach(
  587. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  588. function cleanHeaderConfig(method) {
  589. delete config.headers[method];
  590. }
  591. );
  592. var adapter = config.adapter || defaults.adapter;
  593. return adapter(config).then(function onAdapterResolution(response) {
  594. throwIfCancellationRequested(config);
  595. // Transform response data
  596. response.data = transformData(
  597. response.data,
  598. response.headers,
  599. config.transformResponse
  600. );
  601. return response;
  602. }, function onAdapterRejection(reason) {
  603. if (!isCancel(reason)) {
  604. throwIfCancellationRequested(config);
  605. // Transform response data
  606. if (reason && reason.response) {
  607. reason.response.data = transformData(
  608. reason.response.data,
  609. reason.response.headers,
  610. config.transformResponse
  611. );
  612. }
  613. }
  614. return Promise.reject(reason);
  615. });
  616. };
  617. /***/ }),
  618. /***/ "./node_modules/axios/lib/core/enhanceError.js":
  619. /*!*****************************************************!*\
  620. !*** ./node_modules/axios/lib/core/enhanceError.js ***!
  621. \*****************************************************/
  622. /*! no static exports found */
  623. /***/ (function(module, exports, __webpack_require__) {
  624. "use strict";
  625. /**
  626. * Update an Error with the specified config, error code, and response.
  627. *
  628. * @param {Error} error The error to update.
  629. * @param {Object} config The config.
  630. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  631. * @param {Object} [request] The request.
  632. * @param {Object} [response] The response.
  633. * @returns {Error} The error.
  634. */
  635. module.exports = function enhanceError(error, config, code, request, response) {
  636. error.config = config;
  637. if (code) {
  638. error.code = code;
  639. }
  640. error.request = request;
  641. error.response = response;
  642. error.isAxiosError = true;
  643. error.toJSON = function() {
  644. return {
  645. // Standard
  646. message: this.message,
  647. name: this.name,
  648. // Microsoft
  649. description: this.description,
  650. number: this.number,
  651. // Mozilla
  652. fileName: this.fileName,
  653. lineNumber: this.lineNumber,
  654. columnNumber: this.columnNumber,
  655. stack: this.stack,
  656. // Axios
  657. config: this.config,
  658. code: this.code
  659. };
  660. };
  661. return error;
  662. };
  663. /***/ }),
  664. /***/ "./node_modules/axios/lib/core/mergeConfig.js":
  665. /*!****************************************************!*\
  666. !*** ./node_modules/axios/lib/core/mergeConfig.js ***!
  667. \****************************************************/
  668. /*! no static exports found */
  669. /***/ (function(module, exports, __webpack_require__) {
  670. "use strict";
  671. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  672. /**
  673. * Config-specific merge-function which creates a new config-object
  674. * by merging two configuration objects together.
  675. *
  676. * @param {Object} config1
  677. * @param {Object} config2
  678. * @returns {Object} New object resulting from merging config2 to config1
  679. */
  680. module.exports = function mergeConfig(config1, config2) {
  681. // eslint-disable-next-line no-param-reassign
  682. config2 = config2 || {};
  683. var config = {};
  684. utils.forEach(['url', 'method', 'params', 'data'], function valueFromConfig2(prop) {
  685. if (typeof config2[prop] !== 'undefined') {
  686. config[prop] = config2[prop];
  687. }
  688. });
  689. utils.forEach(['headers', 'auth', 'proxy'], function mergeDeepProperties(prop) {
  690. if (utils.isObject(config2[prop])) {
  691. config[prop] = utils.deepMerge(config1[prop], config2[prop]);
  692. } else if (typeof config2[prop] !== 'undefined') {
  693. config[prop] = config2[prop];
  694. } else if (utils.isObject(config1[prop])) {
  695. config[prop] = utils.deepMerge(config1[prop]);
  696. } else if (typeof config1[prop] !== 'undefined') {
  697. config[prop] = config1[prop];
  698. }
  699. });
  700. utils.forEach([
  701. 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
  702. 'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
  703. 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'maxContentLength',
  704. 'validateStatus', 'maxRedirects', 'httpAgent', 'httpsAgent', 'cancelToken',
  705. 'socketPath'
  706. ], function defaultToConfig2(prop) {
  707. if (typeof config2[prop] !== 'undefined') {
  708. config[prop] = config2[prop];
  709. } else if (typeof config1[prop] !== 'undefined') {
  710. config[prop] = config1[prop];
  711. }
  712. });
  713. return config;
  714. };
  715. /***/ }),
  716. /***/ "./node_modules/axios/lib/core/settle.js":
  717. /*!***********************************************!*\
  718. !*** ./node_modules/axios/lib/core/settle.js ***!
  719. \***********************************************/
  720. /*! no static exports found */
  721. /***/ (function(module, exports, __webpack_require__) {
  722. "use strict";
  723. var createError = __webpack_require__(/*! ./createError */ "./node_modules/axios/lib/core/createError.js");
  724. /**
  725. * Resolve or reject a Promise based on response status.
  726. *
  727. * @param {Function} resolve A function that resolves the promise.
  728. * @param {Function} reject A function that rejects the promise.
  729. * @param {object} response The response.
  730. */
  731. module.exports = function settle(resolve, reject, response) {
  732. var validateStatus = response.config.validateStatus;
  733. if (!validateStatus || validateStatus(response.status)) {
  734. resolve(response);
  735. } else {
  736. reject(createError(
  737. 'Request failed with status code ' + response.status,
  738. response.config,
  739. null,
  740. response.request,
  741. response
  742. ));
  743. }
  744. };
  745. /***/ }),
  746. /***/ "./node_modules/axios/lib/core/transformData.js":
  747. /*!******************************************************!*\
  748. !*** ./node_modules/axios/lib/core/transformData.js ***!
  749. \******************************************************/
  750. /*! no static exports found */
  751. /***/ (function(module, exports, __webpack_require__) {
  752. "use strict";
  753. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  754. /**
  755. * Transform the data for a request or a response
  756. *
  757. * @param {Object|String} data The data to be transformed
  758. * @param {Array} headers The headers for the request or response
  759. * @param {Array|Function} fns A single function or Array of functions
  760. * @returns {*} The resulting transformed data
  761. */
  762. module.exports = function transformData(data, headers, fns) {
  763. /*eslint no-param-reassign:0*/
  764. utils.forEach(fns, function transform(fn) {
  765. data = fn(data, headers);
  766. });
  767. return data;
  768. };
  769. /***/ }),
  770. /***/ "./node_modules/axios/lib/defaults.js":
  771. /*!********************************************!*\
  772. !*** ./node_modules/axios/lib/defaults.js ***!
  773. \********************************************/
  774. /*! no static exports found */
  775. /***/ (function(module, exports, __webpack_require__) {
  776. "use strict";
  777. /* WEBPACK VAR INJECTION */(function(process) {
  778. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  779. var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./node_modules/axios/lib/helpers/normalizeHeaderName.js");
  780. var DEFAULT_CONTENT_TYPE = {
  781. 'Content-Type': 'application/x-www-form-urlencoded'
  782. };
  783. function setContentTypeIfUnset(headers, value) {
  784. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  785. headers['Content-Type'] = value;
  786. }
  787. }
  788. function getDefaultAdapter() {
  789. var adapter;
  790. // Only Node.JS has a process variable that is of [[Class]] process
  791. if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  792. // For node use HTTP adapter
  793. adapter = __webpack_require__(/*! ./adapters/http */ "./node_modules/axios/lib/adapters/xhr.js");
  794. } else if (typeof XMLHttpRequest !== 'undefined') {
  795. // For browsers use XHR adapter
  796. adapter = __webpack_require__(/*! ./adapters/xhr */ "./node_modules/axios/lib/adapters/xhr.js");
  797. }
  798. return adapter;
  799. }
  800. var defaults = {
  801. adapter: getDefaultAdapter(),
  802. transformRequest: [function transformRequest(data, headers) {
  803. normalizeHeaderName(headers, 'Accept');
  804. normalizeHeaderName(headers, 'Content-Type');
  805. if (utils.isFormData(data) ||
  806. utils.isArrayBuffer(data) ||
  807. utils.isBuffer(data) ||
  808. utils.isStream(data) ||
  809. utils.isFile(data) ||
  810. utils.isBlob(data)
  811. ) {
  812. return data;
  813. }
  814. if (utils.isArrayBufferView(data)) {
  815. return data.buffer;
  816. }
  817. if (utils.isURLSearchParams(data)) {
  818. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  819. return data.toString();
  820. }
  821. if (utils.isObject(data)) {
  822. setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
  823. return JSON.stringify(data);
  824. }
  825. return data;
  826. }],
  827. transformResponse: [function transformResponse(data) {
  828. /*eslint no-param-reassign:0*/
  829. if (typeof data === 'string') {
  830. try {
  831. data = JSON.parse(data);
  832. } catch (e) { /* Ignore */ }
  833. }
  834. return data;
  835. }],
  836. /**
  837. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  838. * timeout is not created.
  839. */
  840. timeout: 0,
  841. xsrfCookieName: 'XSRF-TOKEN',
  842. xsrfHeaderName: 'X-XSRF-TOKEN',
  843. maxContentLength: -1,
  844. validateStatus: function validateStatus(status) {
  845. return status >= 200 && status < 300;
  846. }
  847. };
  848. defaults.headers = {
  849. common: {
  850. 'Accept': 'application/json, text/plain, */*'
  851. }
  852. };
  853. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  854. defaults.headers[method] = {};
  855. });
  856. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  857. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  858. });
  859. module.exports = defaults;
  860. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "./node_modules/process/browser.js")))
  861. /***/ }),
  862. /***/ "./node_modules/axios/lib/helpers/bind.js":
  863. /*!************************************************!*\
  864. !*** ./node_modules/axios/lib/helpers/bind.js ***!
  865. \************************************************/
  866. /*! no static exports found */
  867. /***/ (function(module, exports, __webpack_require__) {
  868. "use strict";
  869. module.exports = function bind(fn, thisArg) {
  870. return function wrap() {
  871. var args = new Array(arguments.length);
  872. for (var i = 0; i < args.length; i++) {
  873. args[i] = arguments[i];
  874. }
  875. return fn.apply(thisArg, args);
  876. };
  877. };
  878. /***/ }),
  879. /***/ "./node_modules/axios/lib/helpers/buildURL.js":
  880. /*!****************************************************!*\
  881. !*** ./node_modules/axios/lib/helpers/buildURL.js ***!
  882. \****************************************************/
  883. /*! no static exports found */
  884. /***/ (function(module, exports, __webpack_require__) {
  885. "use strict";
  886. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  887. function encode(val) {
  888. return encodeURIComponent(val).
  889. replace(/%40/gi, '@').
  890. replace(/%3A/gi, ':').
  891. replace(/%24/g, '$').
  892. replace(/%2C/gi, ',').
  893. replace(/%20/g, '+').
  894. replace(/%5B/gi, '[').
  895. replace(/%5D/gi, ']');
  896. }
  897. /**
  898. * Build a URL by appending params to the end
  899. *
  900. * @param {string} url The base of the url (e.g., http://www.google.com)
  901. * @param {object} [params] The params to be appended
  902. * @returns {string} The formatted url
  903. */
  904. module.exports = function buildURL(url, params, paramsSerializer) {
  905. /*eslint no-param-reassign:0*/
  906. if (!params) {
  907. return url;
  908. }
  909. var serializedParams;
  910. if (paramsSerializer) {
  911. serializedParams = paramsSerializer(params);
  912. } else if (utils.isURLSearchParams(params)) {
  913. serializedParams = params.toString();
  914. } else {
  915. var parts = [];
  916. utils.forEach(params, function serialize(val, key) {
  917. if (val === null || typeof val === 'undefined') {
  918. return;
  919. }
  920. if (utils.isArray(val)) {
  921. key = key + '[]';
  922. } else {
  923. val = [val];
  924. }
  925. utils.forEach(val, function parseValue(v) {
  926. if (utils.isDate(v)) {
  927. v = v.toISOString();
  928. } else if (utils.isObject(v)) {
  929. v = JSON.stringify(v);
  930. }
  931. parts.push(encode(key) + '=' + encode(v));
  932. });
  933. });
  934. serializedParams = parts.join('&');
  935. }
  936. if (serializedParams) {
  937. var hashmarkIndex = url.indexOf('#');
  938. if (hashmarkIndex !== -1) {
  939. url = url.slice(0, hashmarkIndex);
  940. }
  941. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  942. }
  943. return url;
  944. };
  945. /***/ }),
  946. /***/ "./node_modules/axios/lib/helpers/combineURLs.js":
  947. /*!*******************************************************!*\
  948. !*** ./node_modules/axios/lib/helpers/combineURLs.js ***!
  949. \*******************************************************/
  950. /*! no static exports found */
  951. /***/ (function(module, exports, __webpack_require__) {
  952. "use strict";
  953. /**
  954. * Creates a new URL by combining the specified URLs
  955. *
  956. * @param {string} baseURL The base URL
  957. * @param {string} relativeURL The relative URL
  958. * @returns {string} The combined URL
  959. */
  960. module.exports = function combineURLs(baseURL, relativeURL) {
  961. return relativeURL
  962. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  963. : baseURL;
  964. };
  965. /***/ }),
  966. /***/ "./node_modules/axios/lib/helpers/cookies.js":
  967. /*!***************************************************!*\
  968. !*** ./node_modules/axios/lib/helpers/cookies.js ***!
  969. \***************************************************/
  970. /*! no static exports found */
  971. /***/ (function(module, exports, __webpack_require__) {
  972. "use strict";
  973. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  974. module.exports = (
  975. utils.isStandardBrowserEnv() ?
  976. // Standard browser envs support document.cookie
  977. (function standardBrowserEnv() {
  978. return {
  979. write: function write(name, value, expires, path, domain, secure) {
  980. var cookie = [];
  981. cookie.push(name + '=' + encodeURIComponent(value));
  982. if (utils.isNumber(expires)) {
  983. cookie.push('expires=' + new Date(expires).toGMTString());
  984. }
  985. if (utils.isString(path)) {
  986. cookie.push('path=' + path);
  987. }
  988. if (utils.isString(domain)) {
  989. cookie.push('domain=' + domain);
  990. }
  991. if (secure === true) {
  992. cookie.push('secure');
  993. }
  994. document.cookie = cookie.join('; ');
  995. },
  996. read: function read(name) {
  997. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  998. return (match ? decodeURIComponent(match[3]) : null);
  999. },
  1000. remove: function remove(name) {
  1001. this.write(name, '', Date.now() - 86400000);
  1002. }
  1003. };
  1004. })() :
  1005. // Non standard browser env (web workers, react-native) lack needed support.
  1006. (function nonStandardBrowserEnv() {
  1007. return {
  1008. write: function write() {},
  1009. read: function read() { return null; },
  1010. remove: function remove() {}
  1011. };
  1012. })()
  1013. );
  1014. /***/ }),
  1015. /***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js":
  1016. /*!*********************************************************!*\
  1017. !*** ./node_modules/axios/lib/helpers/isAbsoluteURL.js ***!
  1018. \*********************************************************/
  1019. /*! no static exports found */
  1020. /***/ (function(module, exports, __webpack_require__) {
  1021. "use strict";
  1022. /**
  1023. * Determines whether the specified URL is absolute
  1024. *
  1025. * @param {string} url The URL to test
  1026. * @returns {boolean} True if the specified URL is absolute, otherwise false
  1027. */
  1028. module.exports = function isAbsoluteURL(url) {
  1029. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  1030. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  1031. // by any combination of letters, digits, plus, period, or hyphen.
  1032. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
  1033. };
  1034. /***/ }),
  1035. /***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js":
  1036. /*!***********************************************************!*\
  1037. !*** ./node_modules/axios/lib/helpers/isURLSameOrigin.js ***!
  1038. \***********************************************************/
  1039. /*! no static exports found */
  1040. /***/ (function(module, exports, __webpack_require__) {
  1041. "use strict";
  1042. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1043. module.exports = (
  1044. utils.isStandardBrowserEnv() ?
  1045. // Standard browser envs have full support of the APIs needed to test
  1046. // whether the request URL is of the same origin as current location.
  1047. (function standardBrowserEnv() {
  1048. var msie = /(msie|trident)/i.test(navigator.userAgent);
  1049. var urlParsingNode = document.createElement('a');
  1050. var originURL;
  1051. /**
  1052. * Parse a URL to discover it's components
  1053. *
  1054. * @param {String} url The URL to be parsed
  1055. * @returns {Object}
  1056. */
  1057. function resolveURL(url) {
  1058. var href = url;
  1059. if (msie) {
  1060. // IE needs attribute set twice to normalize properties
  1061. urlParsingNode.setAttribute('href', href);
  1062. href = urlParsingNode.href;
  1063. }
  1064. urlParsingNode.setAttribute('href', href);
  1065. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  1066. return {
  1067. href: urlParsingNode.href,
  1068. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  1069. host: urlParsingNode.host,
  1070. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  1071. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  1072. hostname: urlParsingNode.hostname,
  1073. port: urlParsingNode.port,
  1074. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  1075. urlParsingNode.pathname :
  1076. '/' + urlParsingNode.pathname
  1077. };
  1078. }
  1079. originURL = resolveURL(window.location.href);
  1080. /**
  1081. * Determine if a URL shares the same origin as the current location
  1082. *
  1083. * @param {String} requestURL The URL to test
  1084. * @returns {boolean} True if URL shares the same origin, otherwise false
  1085. */
  1086. return function isURLSameOrigin(requestURL) {
  1087. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  1088. return (parsed.protocol === originURL.protocol &&
  1089. parsed.host === originURL.host);
  1090. };
  1091. })() :
  1092. // Non standard browser envs (web workers, react-native) lack needed support.
  1093. (function nonStandardBrowserEnv() {
  1094. return function isURLSameOrigin() {
  1095. return true;
  1096. };
  1097. })()
  1098. );
  1099. /***/ }),
  1100. /***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js":
  1101. /*!***************************************************************!*\
  1102. !*** ./node_modules/axios/lib/helpers/normalizeHeaderName.js ***!
  1103. \***************************************************************/
  1104. /*! no static exports found */
  1105. /***/ (function(module, exports, __webpack_require__) {
  1106. "use strict";
  1107. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  1108. module.exports = function normalizeHeaderName(headers, normalizedName) {
  1109. utils.forEach(headers, function processHeader(value, name) {
  1110. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  1111. headers[normalizedName] = value;
  1112. delete headers[name];
  1113. }
  1114. });
  1115. };
  1116. /***/ }),
  1117. /***/ "./node_modules/axios/lib/helpers/parseHeaders.js":
  1118. /*!********************************************************!*\
  1119. !*** ./node_modules/axios/lib/helpers/parseHeaders.js ***!
  1120. \********************************************************/
  1121. /*! no static exports found */
  1122. /***/ (function(module, exports, __webpack_require__) {
  1123. "use strict";
  1124. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1125. // Headers whose duplicates are ignored by node
  1126. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1127. var ignoreDuplicateOf = [
  1128. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  1129. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  1130. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  1131. 'referer', 'retry-after', 'user-agent'
  1132. ];
  1133. /**
  1134. * Parse headers into an object
  1135. *
  1136. * ```
  1137. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1138. * Content-Type: application/json
  1139. * Connection: keep-alive
  1140. * Transfer-Encoding: chunked
  1141. * ```
  1142. *
  1143. * @param {String} headers Headers needing to be parsed
  1144. * @returns {Object} Headers parsed into an object
  1145. */
  1146. module.exports = function parseHeaders(headers) {
  1147. var parsed = {};
  1148. var key;
  1149. var val;
  1150. var i;
  1151. if (!headers) { return parsed; }
  1152. utils.forEach(headers.split('\n'), function parser(line) {
  1153. i = line.indexOf(':');
  1154. key = utils.trim(line.substr(0, i)).toLowerCase();
  1155. val = utils.trim(line.substr(i + 1));
  1156. if (key) {
  1157. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  1158. return;
  1159. }
  1160. if (key === 'set-cookie') {
  1161. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  1162. } else {
  1163. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1164. }
  1165. }
  1166. });
  1167. return parsed;
  1168. };
  1169. /***/ }),
  1170. /***/ "./node_modules/axios/lib/helpers/spread.js":
  1171. /*!**************************************************!*\
  1172. !*** ./node_modules/axios/lib/helpers/spread.js ***!
  1173. \**************************************************/
  1174. /*! no static exports found */
  1175. /***/ (function(module, exports, __webpack_require__) {
  1176. "use strict";
  1177. /**
  1178. * Syntactic sugar for invoking a function and expanding an array for arguments.
  1179. *
  1180. * Common use case would be to use `Function.prototype.apply`.
  1181. *
  1182. * ```js
  1183. * function f(x, y, z) {}
  1184. * var args = [1, 2, 3];
  1185. * f.apply(null, args);
  1186. * ```
  1187. *
  1188. * With `spread` this example can be re-written.
  1189. *
  1190. * ```js
  1191. * spread(function(x, y, z) {})([1, 2, 3]);
  1192. * ```
  1193. *
  1194. * @param {Function} callback
  1195. * @returns {Function}
  1196. */
  1197. module.exports = function spread(callback) {
  1198. return function wrap(arr) {
  1199. return callback.apply(null, arr);
  1200. };
  1201. };
  1202. /***/ }),
  1203. /***/ "./node_modules/axios/lib/utils.js":
  1204. /*!*****************************************!*\
  1205. !*** ./node_modules/axios/lib/utils.js ***!
  1206. \*****************************************/
  1207. /*! no static exports found */
  1208. /***/ (function(module, exports, __webpack_require__) {
  1209. "use strict";
  1210. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  1211. var isBuffer = __webpack_require__(/*! is-buffer */ "./node_modules/axios/node_modules/is-buffer/index.js");
  1212. /*global toString:true*/
  1213. // utils is a library of generic helper functions non-specific to axios
  1214. var toString = Object.prototype.toString;
  1215. /**
  1216. * Determine if a value is an Array
  1217. *
  1218. * @param {Object} val The value to test
  1219. * @returns {boolean} True if value is an Array, otherwise false
  1220. */
  1221. function isArray(val) {
  1222. return toString.call(val) === '[object Array]';
  1223. }
  1224. /**
  1225. * Determine if a value is an ArrayBuffer
  1226. *
  1227. * @param {Object} val The value to test
  1228. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  1229. */
  1230. function isArrayBuffer(val) {
  1231. return toString.call(val) === '[object ArrayBuffer]';
  1232. }
  1233. /**
  1234. * Determine if a value is a FormData
  1235. *
  1236. * @param {Object} val The value to test
  1237. * @returns {boolean} True if value is an FormData, otherwise false
  1238. */
  1239. function isFormData(val) {
  1240. return (typeof FormData !== 'undefined') && (val instanceof FormData);
  1241. }
  1242. /**
  1243. * Determine if a value is a view on an ArrayBuffer
  1244. *
  1245. * @param {Object} val The value to test
  1246. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  1247. */
  1248. function isArrayBufferView(val) {
  1249. var result;
  1250. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  1251. result = ArrayBuffer.isView(val);
  1252. } else {
  1253. result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
  1254. }
  1255. return result;
  1256. }
  1257. /**
  1258. * Determine if a value is a String
  1259. *
  1260. * @param {Object} val The value to test
  1261. * @returns {boolean} True if value is a String, otherwise false
  1262. */
  1263. function isString(val) {
  1264. return typeof val === 'string';
  1265. }
  1266. /**
  1267. * Determine if a value is a Number
  1268. *
  1269. * @param {Object} val The value to test
  1270. * @returns {boolean} True if value is a Number, otherwise false
  1271. */
  1272. function isNumber(val) {
  1273. return typeof val === 'number';
  1274. }
  1275. /**
  1276. * Determine if a value is undefined
  1277. *
  1278. * @param {Object} val The value to test
  1279. * @returns {boolean} True if the value is undefined, otherwise false
  1280. */
  1281. function isUndefined(val) {
  1282. return typeof val === 'undefined';
  1283. }
  1284. /**
  1285. * Determine if a value is an Object
  1286. *
  1287. * @param {Object} val The value to test
  1288. * @returns {boolean} True if value is an Object, otherwise false
  1289. */
  1290. function isObject(val) {
  1291. return val !== null && typeof val === 'object';
  1292. }
  1293. /**
  1294. * Determine if a value is a Date
  1295. *
  1296. * @param {Object} val The value to test
  1297. * @returns {boolean} True if value is a Date, otherwise false
  1298. */
  1299. function isDate(val) {
  1300. return toString.call(val) === '[object Date]';
  1301. }
  1302. /**
  1303. * Determine if a value is a File
  1304. *
  1305. * @param {Object} val The value to test
  1306. * @returns {boolean} True if value is a File, otherwise false
  1307. */
  1308. function isFile(val) {
  1309. return toString.call(val) === '[object File]';
  1310. }
  1311. /**
  1312. * Determine if a value is a Blob
  1313. *
  1314. * @param {Object} val The value to test
  1315. * @returns {boolean} True if value is a Blob, otherwise false
  1316. */
  1317. function isBlob(val) {
  1318. return toString.call(val) === '[object Blob]';
  1319. }
  1320. /**
  1321. * Determine if a value is a Function
  1322. *
  1323. * @param {Object} val The value to test
  1324. * @returns {boolean} True if value is a Function, otherwise false
  1325. */
  1326. function isFunction(val) {
  1327. return toString.call(val) === '[object Function]';
  1328. }
  1329. /**
  1330. * Determine if a value is a Stream
  1331. *
  1332. * @param {Object} val The value to test
  1333. * @returns {boolean} True if value is a Stream, otherwise false
  1334. */
  1335. function isStream(val) {
  1336. return isObject(val) && isFunction(val.pipe);
  1337. }
  1338. /**
  1339. * Determine if a value is a URLSearchParams object
  1340. *
  1341. * @param {Object} val The value to test
  1342. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  1343. */
  1344. function isURLSearchParams(val) {
  1345. return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
  1346. }
  1347. /**
  1348. * Trim excess whitespace off the beginning and end of a string
  1349. *
  1350. * @param {String} str The String to trim
  1351. * @returns {String} The String freed of excess whitespace
  1352. */
  1353. function trim(str) {
  1354. return str.replace(/^\s*/, '').replace(/\s*$/, '');
  1355. }
  1356. /**
  1357. * Determine if we're running in a standard browser environment
  1358. *
  1359. * This allows axios to run in a web worker, and react-native.
  1360. * Both environments support XMLHttpRequest, but not fully standard globals.
  1361. *
  1362. * web workers:
  1363. * typeof window -> undefined
  1364. * typeof document -> undefined
  1365. *
  1366. * react-native:
  1367. * navigator.product -> 'ReactNative'
  1368. * nativescript
  1369. * navigator.product -> 'NativeScript' or 'NS'
  1370. */
  1371. function isStandardBrowserEnv() {
  1372. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  1373. navigator.product === 'NativeScript' ||
  1374. navigator.product === 'NS')) {
  1375. return false;
  1376. }
  1377. return (
  1378. typeof window !== 'undefined' &&
  1379. typeof document !== 'undefined'
  1380. );
  1381. }
  1382. /**
  1383. * Iterate over an Array or an Object invoking a function for each item.
  1384. *
  1385. * If `obj` is an Array callback will be called passing
  1386. * the value, index, and complete array for each item.
  1387. *
  1388. * If 'obj' is an Object callback will be called passing
  1389. * the value, key, and complete object for each property.
  1390. *
  1391. * @param {Object|Array} obj The object to iterate
  1392. * @param {Function} fn The callback to invoke for each item
  1393. */
  1394. function forEach(obj, fn) {
  1395. // Don't bother if no value provided
  1396. if (obj === null || typeof obj === 'undefined') {
  1397. return;
  1398. }
  1399. // Force an array if not already something iterable
  1400. if (typeof obj !== 'object') {
  1401. /*eslint no-param-reassign:0*/
  1402. obj = [obj];
  1403. }
  1404. if (isArray(obj)) {
  1405. // Iterate over array values
  1406. for (var i = 0, l = obj.length; i < l; i++) {
  1407. fn.call(null, obj[i], i, obj);
  1408. }
  1409. } else {
  1410. // Iterate over object keys
  1411. for (var key in obj) {
  1412. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  1413. fn.call(null, obj[key], key, obj);
  1414. }
  1415. }
  1416. }
  1417. }
  1418. /**
  1419. * Accepts varargs expecting each argument to be an object, then
  1420. * immutably merges the properties of each object and returns result.
  1421. *
  1422. * When multiple objects contain the same key the later object in
  1423. * the arguments list will take precedence.
  1424. *
  1425. * Example:
  1426. *
  1427. * ```js
  1428. * var result = merge({foo: 123}, {foo: 456});
  1429. * console.log(result.foo); // outputs 456
  1430. * ```
  1431. *
  1432. * @param {Object} obj1 Object to merge
  1433. * @returns {Object} Result of all merge properties
  1434. */
  1435. function merge(/* obj1, obj2, obj3, ... */) {
  1436. var result = {};
  1437. function assignValue(val, key) {
  1438. if (typeof result[key] === 'object' && typeof val === 'object') {
  1439. result[key] = merge(result[key], val);
  1440. } else {
  1441. result[key] = val;
  1442. }
  1443. }
  1444. for (var i = 0, l = arguments.length; i < l; i++) {
  1445. forEach(arguments[i], assignValue);
  1446. }
  1447. return result;
  1448. }
  1449. /**
  1450. * Function equal to merge with the difference being that no reference
  1451. * to original objects is kept.
  1452. *
  1453. * @see merge
  1454. * @param {Object} obj1 Object to merge
  1455. * @returns {Object} Result of all merge properties
  1456. */
  1457. function deepMerge(/* obj1, obj2, obj3, ... */) {
  1458. var result = {};
  1459. function assignValue(val, key) {
  1460. if (typeof result[key] === 'object' && typeof val === 'object') {
  1461. result[key] = deepMerge(result[key], val);
  1462. } else if (typeof val === 'object') {
  1463. result[key] = deepMerge({}, val);
  1464. } else {
  1465. result[key] = val;
  1466. }
  1467. }
  1468. for (var i = 0, l = arguments.length; i < l; i++) {
  1469. forEach(arguments[i], assignValue);
  1470. }
  1471. return result;
  1472. }
  1473. /**
  1474. * Extends object a by mutably adding to it the properties of object b.
  1475. *
  1476. * @param {Object} a The object to be extended
  1477. * @param {Object} b The object to copy properties from
  1478. * @param {Object} thisArg The object to bind function to
  1479. * @return {Object} The resulting value of object a
  1480. */
  1481. function extend(a, b, thisArg) {
  1482. forEach(b, function assignValue(val, key) {
  1483. if (thisArg && typeof val === 'function') {
  1484. a[key] = bind(val, thisArg);
  1485. } else {
  1486. a[key] = val;
  1487. }
  1488. });
  1489. return a;
  1490. }
  1491. module.exports = {
  1492. isArray: isArray,
  1493. isArrayBuffer: isArrayBuffer,
  1494. isBuffer: isBuffer,
  1495. isFormData: isFormData,
  1496. isArrayBufferView: isArrayBufferView,
  1497. isString: isString,
  1498. isNumber: isNumber,
  1499. isObject: isObject,
  1500. isUndefined: isUndefined,
  1501. isDate: isDate,
  1502. isFile: isFile,
  1503. isBlob: isBlob,
  1504. isFunction: isFunction,
  1505. isStream: isStream,
  1506. isURLSearchParams: isURLSearchParams,
  1507. isStandardBrowserEnv: isStandardBrowserEnv,
  1508. forEach: forEach,
  1509. merge: merge,
  1510. deepMerge: deepMerge,
  1511. extend: extend,
  1512. trim: trim
  1513. };
  1514. /***/ }),
  1515. /***/ "./node_modules/axios/node_modules/is-buffer/index.js":
  1516. /*!************************************************************!*\
  1517. !*** ./node_modules/axios/node_modules/is-buffer/index.js ***!
  1518. \************************************************************/
  1519. /*! no static exports found */
  1520. /***/ (function(module, exports) {
  1521. /*!
  1522. * Determine if an object is a Buffer
  1523. *
  1524. * @author Feross Aboukhadijeh <https://feross.org>
  1525. * @license MIT
  1526. */
  1527. module.exports = function isBuffer (obj) {
  1528. return obj != null && obj.constructor != null &&
  1529. typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
  1530. }
  1531. /***/ }),
  1532. /***/ "./node_modules/jquery/dist/jquery.js":
  1533. /*!********************************************!*\
  1534. !*** ./node_modules/jquery/dist/jquery.js ***!
  1535. \********************************************/
  1536. /*! no static exports found */
  1537. /***/ (function(module, exports, __webpack_require__) {
  1538. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  1539. * jQuery JavaScript Library v3.4.1
  1540. * https://jquery.com/
  1541. *
  1542. * Includes Sizzle.js
  1543. * https://sizzlejs.com/
  1544. *
  1545. * Copyright JS Foundation and other contributors
  1546. * Released under the MIT license
  1547. * https://jquery.org/license
  1548. *
  1549. * Date: 2019-05-01T21:04Z
  1550. */
  1551. ( function( global, factory ) {
  1552. "use strict";
  1553. if ( true && typeof module.exports === "object" ) {
  1554. // For CommonJS and CommonJS-like environments where a proper `window`
  1555. // is present, execute the factory and get jQuery.
  1556. // For environments that do not have a `window` with a `document`
  1557. // (such as Node.js), expose a factory as module.exports.
  1558. // This accentuates the need for the creation of a real `window`.
  1559. // e.g. var jQuery = require("jquery")(window);
  1560. // See ticket #14549 for more info.
  1561. module.exports = global.document ?
  1562. factory( global, true ) :
  1563. function( w ) {
  1564. if ( !w.document ) {
  1565. throw new Error( "jQuery requires a window with a document" );
  1566. }
  1567. return factory( w );
  1568. };
  1569. } else {
  1570. factory( global );
  1571. }
  1572. // Pass this if window is not defined yet
  1573. } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  1574. // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
  1575. // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
  1576. // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
  1577. // enough that all such attempts are guarded in a try block.
  1578. "use strict";
  1579. var arr = [];
  1580. var document = window.document;
  1581. var getProto = Object.getPrototypeOf;
  1582. var slice = arr.slice;
  1583. var concat = arr.concat;
  1584. var push = arr.push;
  1585. var indexOf = arr.indexOf;
  1586. var class2type = {};
  1587. var toString = class2type.toString;
  1588. var hasOwn = class2type.hasOwnProperty;
  1589. var fnToString = hasOwn.toString;
  1590. var ObjectFunctionString = fnToString.call( Object );
  1591. var support = {};
  1592. var isFunction = function isFunction( obj ) {
  1593. // Support: Chrome <=57, Firefox <=52
  1594. // In some browsers, typeof returns "function" for HTML <object> elements
  1595. // (i.e., `typeof document.createElement( "object" ) === "function"`).
  1596. // We don't want to classify *any* DOM node as a function.
  1597. return typeof obj === "function" && typeof obj.nodeType !== "number";
  1598. };
  1599. var isWindow = function isWindow( obj ) {
  1600. return obj != null && obj === obj.window;
  1601. };
  1602. var preservedScriptAttributes = {
  1603. type: true,
  1604. src: true,
  1605. nonce: true,
  1606. noModule: true
  1607. };
  1608. function DOMEval( code, node, doc ) {
  1609. doc = doc || document;
  1610. var i, val,
  1611. script = doc.createElement( "script" );
  1612. script.text = code;
  1613. if ( node ) {
  1614. for ( i in preservedScriptAttributes ) {
  1615. // Support: Firefox 64+, Edge 18+
  1616. // Some browsers don't support the "nonce" property on scripts.
  1617. // On the other hand, just using `getAttribute` is not enough as
  1618. // the `nonce` attribute is reset to an empty string whenever it
  1619. // becomes browsing-context connected.
  1620. // See https://github.com/whatwg/html/issues/2369
  1621. // See https://html.spec.whatwg.org/#nonce-attributes
  1622. // The `node.getAttribute` check was added for the sake of
  1623. // `jQuery.globalEval` so that it can fake a nonce-containing node
  1624. // via an object.
  1625. val = node[ i ] || node.getAttribute && node.getAttribute( i );
  1626. if ( val ) {
  1627. script.setAttribute( i, val );
  1628. }
  1629. }
  1630. }
  1631. doc.head.appendChild( script ).parentNode.removeChild( script );
  1632. }
  1633. function toType( obj ) {
  1634. if ( obj == null ) {
  1635. return obj + "";
  1636. }
  1637. // Support: Android <=2.3 only (functionish RegExp)
  1638. return typeof obj === "object" || typeof obj === "function" ?
  1639. class2type[ toString.call( obj ) ] || "object" :
  1640. typeof obj;
  1641. }
  1642. /* global Symbol */
  1643. // Defining this global in .eslintrc.json would create a danger of using the global
  1644. // unguarded in another place, it seems safer to define global only for this module
  1645. var
  1646. version = "3.4.1",
  1647. // Define a local copy of jQuery
  1648. jQuery = function( selector, context ) {
  1649. // The jQuery object is actually just the init constructor 'enhanced'
  1650. // Need init if jQuery is called (just allow error to be thrown if not included)
  1651. return new jQuery.fn.init( selector, context );
  1652. },
  1653. // Support: Android <=4.0 only
  1654. // Make sure we trim BOM and NBSP
  1655. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  1656. jQuery.fn = jQuery.prototype = {
  1657. // The current version of jQuery being used
  1658. jquery: version,
  1659. constructor: jQuery,
  1660. // The default length of a jQuery object is 0
  1661. length: 0,
  1662. toArray: function() {
  1663. return slice.call( this );
  1664. },
  1665. // Get the Nth element in the matched element set OR
  1666. // Get the whole matched element set as a clean array
  1667. get: function( num ) {
  1668. // Return all the elements in a clean array
  1669. if ( num == null ) {
  1670. return slice.call( this );
  1671. }
  1672. // Return just the one element from the set
  1673. return num < 0 ? this[ num + this.length ] : this[ num ];
  1674. },
  1675. // Take an array of elements and push it onto the stack
  1676. // (returning the new matched element set)
  1677. pushStack: function( elems ) {
  1678. // Build a new jQuery matched element set
  1679. var ret = jQuery.merge( this.constructor(), elems );
  1680. // Add the old object onto the stack (as a reference)
  1681. ret.prevObject = this;
  1682. // Return the newly-formed element set
  1683. return ret;
  1684. },
  1685. // Execute a callback for every element in the matched set.
  1686. each: function( callback ) {
  1687. return jQuery.each( this, callback );
  1688. },
  1689. map: function( callback ) {
  1690. return this.pushStack( jQuery.map( this, function( elem, i ) {
  1691. return callback.call( elem, i, elem );
  1692. } ) );
  1693. },
  1694. slice: function() {
  1695. return this.pushStack( slice.apply( this, arguments ) );
  1696. },
  1697. first: function() {
  1698. return this.eq( 0 );
  1699. },
  1700. last: function() {
  1701. return this.eq( -1 );
  1702. },
  1703. eq: function( i ) {
  1704. var len = this.length,
  1705. j = +i + ( i < 0 ? len : 0 );
  1706. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  1707. },
  1708. end: function() {
  1709. return this.prevObject || this.constructor();
  1710. },
  1711. // For internal use only.
  1712. // Behaves like an Array's method, not like a jQuery method.
  1713. push: push,
  1714. sort: arr.sort,
  1715. splice: arr.splice
  1716. };
  1717. jQuery.extend = jQuery.fn.extend = function() {
  1718. var options, name, src, copy, copyIsArray, clone,
  1719. target = arguments[ 0 ] || {},
  1720. i = 1,
  1721. length = arguments.length,
  1722. deep = false;
  1723. // Handle a deep copy situation
  1724. if ( typeof target === "boolean" ) {
  1725. deep = target;
  1726. // Skip the boolean and the target
  1727. target = arguments[ i ] || {};
  1728. i++;
  1729. }
  1730. // Handle case when target is a string or something (possible in deep copy)
  1731. if ( typeof target !== "object" && !isFunction( target ) ) {
  1732. target = {};
  1733. }
  1734. // Extend jQuery itself if only one argument is passed
  1735. if ( i === length ) {
  1736. target = this;
  1737. i--;
  1738. }
  1739. for ( ; i < length; i++ ) {
  1740. // Only deal with non-null/undefined values
  1741. if ( ( options = arguments[ i ] ) != null ) {
  1742. // Extend the base object
  1743. for ( name in options ) {
  1744. copy = options[ name ];
  1745. // Prevent Object.prototype pollution
  1746. // Prevent never-ending loop
  1747. if ( name === "__proto__" || target === copy ) {
  1748. continue;
  1749. }
  1750. // Recurse if we're merging plain objects or arrays
  1751. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  1752. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  1753. src = target[ name ];
  1754. // Ensure proper type for the source value
  1755. if ( copyIsArray && !Array.isArray( src ) ) {
  1756. clone = [];
  1757. } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
  1758. clone = {};
  1759. } else {
  1760. clone = src;
  1761. }
  1762. copyIsArray = false;
  1763. // Never move original objects, clone them
  1764. target[ name ] = jQuery.extend( deep, clone, copy );
  1765. // Don't bring in undefined values
  1766. } else if ( copy !== undefined ) {
  1767. target[ name ] = copy;
  1768. }
  1769. }
  1770. }
  1771. }
  1772. // Return the modified object
  1773. return target;
  1774. };
  1775. jQuery.extend( {
  1776. // Unique for each copy of jQuery on the page
  1777. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  1778. // Assume jQuery is ready without the ready module
  1779. isReady: true,
  1780. error: function( msg ) {
  1781. throw new Error( msg );
  1782. },
  1783. noop: function() {},
  1784. isPlainObject: function( obj ) {
  1785. var proto, Ctor;
  1786. // Detect obvious negatives
  1787. // Use toString instead of jQuery.type to catch host objects
  1788. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  1789. return false;
  1790. }
  1791. proto = getProto( obj );
  1792. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  1793. if ( !proto ) {
  1794. return true;
  1795. }
  1796. // Objects with prototype are plain iff they were constructed by a global Object function
  1797. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  1798. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  1799. },
  1800. isEmptyObject: function( obj ) {
  1801. var name;
  1802. for ( name in obj ) {
  1803. return false;
  1804. }
  1805. return true;
  1806. },
  1807. // Evaluates a script in a global context
  1808. globalEval: function( code, options ) {
  1809. DOMEval( code, { nonce: options && options.nonce } );
  1810. },
  1811. each: function( obj, callback ) {
  1812. var length, i = 0;
  1813. if ( isArrayLike( obj ) ) {
  1814. length = obj.length;
  1815. for ( ; i < length; i++ ) {
  1816. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  1817. break;
  1818. }
  1819. }
  1820. } else {
  1821. for ( i in obj ) {
  1822. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  1823. break;
  1824. }
  1825. }
  1826. }
  1827. return obj;
  1828. },
  1829. // Support: Android <=4.0 only
  1830. trim: function( text ) {
  1831. return text == null ?
  1832. "" :
  1833. ( text + "" ).replace( rtrim, "" );
  1834. },
  1835. // results is for internal usage only
  1836. makeArray: function( arr, results ) {
  1837. var ret = results || [];
  1838. if ( arr != null ) {
  1839. if ( isArrayLike( Object( arr ) ) ) {
  1840. jQuery.merge( ret,
  1841. typeof arr === "string" ?
  1842. [ arr ] : arr
  1843. );
  1844. } else {
  1845. push.call( ret, arr );
  1846. }
  1847. }
  1848. return ret;
  1849. },
  1850. inArray: function( elem, arr, i ) {
  1851. return arr == null ? -1 : indexOf.call( arr, elem, i );
  1852. },
  1853. // Support: Android <=4.0 only, PhantomJS 1 only
  1854. // push.apply(_, arraylike) throws on ancient WebKit
  1855. merge: function( first, second ) {
  1856. var len = +second.length,
  1857. j = 0,
  1858. i = first.length;
  1859. for ( ; j < len; j++ ) {
  1860. first[ i++ ] = second[ j ];
  1861. }
  1862. first.length = i;
  1863. return first;
  1864. },
  1865. grep: function( elems, callback, invert ) {
  1866. var callbackInverse,
  1867. matches = [],
  1868. i = 0,
  1869. length = elems.length,
  1870. callbackExpect = !invert;
  1871. // Go through the array, only saving the items
  1872. // that pass the validator function
  1873. for ( ; i < length; i++ ) {
  1874. callbackInverse = !callback( elems[ i ], i );
  1875. if ( callbackInverse !== callbackExpect ) {
  1876. matches.push( elems[ i ] );
  1877. }
  1878. }
  1879. return matches;
  1880. },
  1881. // arg is for internal usage only
  1882. map: function( elems, callback, arg ) {
  1883. var length, value,
  1884. i = 0,
  1885. ret = [];
  1886. // Go through the array, translating each of the items to their new values
  1887. if ( isArrayLike( elems ) ) {
  1888. length = elems.length;
  1889. for ( ; i < length; i++ ) {
  1890. value = callback( elems[ i ], i, arg );
  1891. if ( value != null ) {
  1892. ret.push( value );
  1893. }
  1894. }
  1895. // Go through every key on the object,
  1896. } else {
  1897. for ( i in elems ) {
  1898. value = callback( elems[ i ], i, arg );
  1899. if ( value != null ) {
  1900. ret.push( value );
  1901. }
  1902. }
  1903. }
  1904. // Flatten any nested arrays
  1905. return concat.apply( [], ret );
  1906. },
  1907. // A global GUID counter for objects
  1908. guid: 1,
  1909. // jQuery.support is not used in Core but other projects attach their
  1910. // properties to it so it needs to exist.
  1911. support: support
  1912. } );
  1913. if ( typeof Symbol === "function" ) {
  1914. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  1915. }
  1916. // Populate the class2type map
  1917. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  1918. function( i, name ) {
  1919. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  1920. } );
  1921. function isArrayLike( obj ) {
  1922. // Support: real iOS 8.2 only (not reproducible in simulator)
  1923. // `in` check used to prevent JIT error (gh-2145)
  1924. // hasOwn isn't used here due to false negatives
  1925. // regarding Nodelist length in IE
  1926. var length = !!obj && "length" in obj && obj.length,
  1927. type = toType( obj );
  1928. if ( isFunction( obj ) || isWindow( obj ) ) {
  1929. return false;
  1930. }
  1931. return type === "array" || length === 0 ||
  1932. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  1933. }
  1934. var Sizzle =
  1935. /*!
  1936. * Sizzle CSS Selector Engine v2.3.4
  1937. * https://sizzlejs.com/
  1938. *
  1939. * Copyright JS Foundation and other contributors
  1940. * Released under the MIT license
  1941. * https://js.foundation/
  1942. *
  1943. * Date: 2019-04-08
  1944. */
  1945. (function( window ) {
  1946. var i,
  1947. support,
  1948. Expr,
  1949. getText,
  1950. isXML,
  1951. tokenize,
  1952. compile,
  1953. select,
  1954. outermostContext,
  1955. sortInput,
  1956. hasDuplicate,
  1957. // Local document vars
  1958. setDocument,
  1959. document,
  1960. docElem,
  1961. documentIsHTML,
  1962. rbuggyQSA,
  1963. rbuggyMatches,
  1964. matches,
  1965. contains,
  1966. // Instance-specific data
  1967. expando = "sizzle" + 1 * new Date(),
  1968. preferredDoc = window.document,
  1969. dirruns = 0,
  1970. done = 0,
  1971. classCache = createCache(),
  1972. tokenCache = createCache(),
  1973. compilerCache = createCache(),
  1974. nonnativeSelectorCache = createCache(),
  1975. sortOrder = function( a, b ) {
  1976. if ( a === b ) {
  1977. hasDuplicate = true;
  1978. }
  1979. return 0;
  1980. },
  1981. // Instance methods
  1982. hasOwn = ({}).hasOwnProperty,
  1983. arr = [],
  1984. pop = arr.pop,
  1985. push_native = arr.push,
  1986. push = arr.push,
  1987. slice = arr.slice,
  1988. // Use a stripped-down indexOf as it's faster than native
  1989. // https://jsperf.com/thor-indexof-vs-for/5
  1990. indexOf = function( list, elem ) {
  1991. var i = 0,
  1992. len = list.length;
  1993. for ( ; i < len; i++ ) {
  1994. if ( list[i] === elem ) {
  1995. return i;
  1996. }
  1997. }
  1998. return -1;
  1999. },
  2000. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  2001. // Regular expressions
  2002. // http://www.w3.org/TR/css3-selectors/#whitespace
  2003. whitespace = "[\\x20\\t\\r\\n\\f]",
  2004. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  2005. identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
  2006. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  2007. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  2008. // Operator (capture 2)
  2009. "*([*^$|!~]?=)" + whitespace +
  2010. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  2011. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  2012. "*\\]",
  2013. pseudos = ":(" + identifier + ")(?:\\((" +
  2014. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  2015. // 1. quoted (capture 3; capture 4 or capture 5)
  2016. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  2017. // 2. simple (capture 6)
  2018. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  2019. // 3. anything else (capture 2)
  2020. ".*" +
  2021. ")\\)|)",
  2022. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  2023. rwhitespace = new RegExp( whitespace + "+", "g" ),
  2024. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  2025. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  2026. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  2027. rdescend = new RegExp( whitespace + "|>" ),
  2028. rpseudo = new RegExp( pseudos ),
  2029. ridentifier = new RegExp( "^" + identifier + "$" ),
  2030. matchExpr = {
  2031. "ID": new RegExp( "^#(" + identifier + ")" ),
  2032. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  2033. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  2034. "ATTR": new RegExp( "^" + attributes ),
  2035. "PSEUDO": new RegExp( "^" + pseudos ),
  2036. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  2037. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  2038. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  2039. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  2040. // For use in libraries implementing .is()
  2041. // We use this for POS matching in `select`
  2042. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  2043. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  2044. },
  2045. rhtml = /HTML$/i,
  2046. rinputs = /^(?:input|select|textarea|button)$/i,
  2047. rheader = /^h\d$/i,
  2048. rnative = /^[^{]+\{\s*\[native \w/,
  2049. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  2050. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  2051. rsibling = /[+~]/,
  2052. // CSS escapes
  2053. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  2054. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  2055. funescape = function( _, escaped, escapedWhitespace ) {
  2056. var high = "0x" + escaped - 0x10000;
  2057. // NaN means non-codepoint
  2058. // Support: Firefox<24
  2059. // Workaround erroneous numeric interpretation of +"0x"
  2060. return high !== high || escapedWhitespace ?
  2061. escaped :
  2062. high < 0 ?
  2063. // BMP codepoint
  2064. String.fromCharCode( high + 0x10000 ) :
  2065. // Supplemental Plane codepoint (surrogate pair)
  2066. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  2067. },
  2068. // CSS string/identifier serialization
  2069. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  2070. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  2071. fcssescape = function( ch, asCodePoint ) {
  2072. if ( asCodePoint ) {
  2073. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  2074. if ( ch === "\0" ) {
  2075. return "\uFFFD";
  2076. }
  2077. // Control characters and (dependent upon position) numbers get escaped as code points
  2078. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  2079. }
  2080. // Other potentially-special ASCII characters get backslash-escaped
  2081. return "\\" + ch;
  2082. },
  2083. // Used for iframes
  2084. // See setDocument()
  2085. // Removing the function wrapper causes a "Permission Denied"
  2086. // error in IE
  2087. unloadHandler = function() {
  2088. setDocument();
  2089. },
  2090. inDisabledFieldset = addCombinator(
  2091. function( elem ) {
  2092. return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
  2093. },
  2094. { dir: "parentNode", next: "legend" }
  2095. );
  2096. // Optimize for push.apply( _, NodeList )
  2097. try {
  2098. push.apply(
  2099. (arr = slice.call( preferredDoc.childNodes )),
  2100. preferredDoc.childNodes
  2101. );
  2102. // Support: Android<4.0
  2103. // Detect silently failing push.apply
  2104. arr[ preferredDoc.childNodes.length ].nodeType;
  2105. } catch ( e ) {
  2106. push = { apply: arr.length ?
  2107. // Leverage slice if possible
  2108. function( target, els ) {
  2109. push_native.apply( target, slice.call(els) );
  2110. } :
  2111. // Support: IE<9
  2112. // Otherwise append directly
  2113. function( target, els ) {
  2114. var j = target.length,
  2115. i = 0;
  2116. // Can't trust NodeList.length
  2117. while ( (target[j++] = els[i++]) ) {}
  2118. target.length = j - 1;
  2119. }
  2120. };
  2121. }
  2122. function Sizzle( selector, context, results, seed ) {
  2123. var m, i, elem, nid, match, groups, newSelector,
  2124. newContext = context && context.ownerDocument,
  2125. // nodeType defaults to 9, since context defaults to document
  2126. nodeType = context ? context.nodeType : 9;
  2127. results = results || [];
  2128. // Return early from calls with invalid selector or context
  2129. if ( typeof selector !== "string" || !selector ||
  2130. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  2131. return results;
  2132. }
  2133. // Try to shortcut find operations (as opposed to filters) in HTML documents
  2134. if ( !seed ) {
  2135. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  2136. setDocument( context );
  2137. }
  2138. context = context || document;
  2139. if ( documentIsHTML ) {
  2140. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  2141. // (excepting DocumentFragment context, where the methods don't exist)
  2142. if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
  2143. // ID selector
  2144. if ( (m = match[1]) ) {
  2145. // Document context
  2146. if ( nodeType === 9 ) {
  2147. if ( (elem = context.getElementById( m )) ) {
  2148. // Support: IE, Opera, Webkit
  2149. // TODO: identify versions
  2150. // getElementById can match elements by name instead of ID
  2151. if ( elem.id === m ) {
  2152. results.push( elem );
  2153. return results;
  2154. }
  2155. } else {
  2156. return results;
  2157. }
  2158. // Element context
  2159. } else {
  2160. // Support: IE, Opera, Webkit
  2161. // TODO: identify versions
  2162. // getElementById can match elements by name instead of ID
  2163. if ( newContext && (elem = newContext.getElementById( m )) &&
  2164. contains( context, elem ) &&
  2165. elem.id === m ) {
  2166. results.push( elem );
  2167. return results;
  2168. }
  2169. }
  2170. // Type selector
  2171. } else if ( match[2] ) {
  2172. push.apply( results, context.getElementsByTagName( selector ) );
  2173. return results;
  2174. // Class selector
  2175. } else if ( (m = match[3]) && support.getElementsByClassName &&
  2176. context.getElementsByClassName ) {
  2177. push.apply( results, context.getElementsByClassName( m ) );
  2178. return results;
  2179. }
  2180. }
  2181. // Take advantage of querySelectorAll
  2182. if ( support.qsa &&
  2183. !nonnativeSelectorCache[ selector + " " ] &&
  2184. (!rbuggyQSA || !rbuggyQSA.test( selector )) &&
  2185. // Support: IE 8 only
  2186. // Exclude object elements
  2187. (nodeType !== 1 || context.nodeName.toLowerCase() !== "object") ) {
  2188. newSelector = selector;
  2189. newContext = context;
  2190. // qSA considers elements outside a scoping root when evaluating child or
  2191. // descendant combinators, which is not what we want.
  2192. // In such cases, we work around the behavior by prefixing every selector in the
  2193. // list with an ID selector referencing the scope context.
  2194. // Thanks to Andrew Dupont for this technique.
  2195. if ( nodeType === 1 && rdescend.test( selector ) ) {
  2196. // Capture the context ID, setting it first if necessary
  2197. if ( (nid = context.getAttribute( "id" )) ) {
  2198. nid = nid.replace( rcssescape, fcssescape );
  2199. } else {
  2200. context.setAttribute( "id", (nid = expando) );
  2201. }
  2202. // Prefix every selector in the list
  2203. groups = tokenize( selector );
  2204. i = groups.length;
  2205. while ( i-- ) {
  2206. groups[i] = "#" + nid + " " + toSelector( groups[i] );
  2207. }
  2208. newSelector = groups.join( "," );
  2209. // Expand context for sibling selectors
  2210. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  2211. context;
  2212. }
  2213. try {
  2214. push.apply( results,
  2215. newContext.querySelectorAll( newSelector )
  2216. );
  2217. return results;
  2218. } catch ( qsaError ) {
  2219. nonnativeSelectorCache( selector, true );
  2220. } finally {
  2221. if ( nid === expando ) {
  2222. context.removeAttribute( "id" );
  2223. }
  2224. }
  2225. }
  2226. }
  2227. }
  2228. // All others
  2229. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  2230. }
  2231. /**
  2232. * Create key-value caches of limited size
  2233. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  2234. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  2235. * deleting the oldest entry
  2236. */
  2237. function createCache() {
  2238. var keys = [];
  2239. function cache( key, value ) {
  2240. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  2241. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  2242. // Only keep the most recent entries
  2243. delete cache[ keys.shift() ];
  2244. }
  2245. return (cache[ key + " " ] = value);
  2246. }
  2247. return cache;
  2248. }
  2249. /**
  2250. * Mark a function for special use by Sizzle
  2251. * @param {Function} fn The function to mark
  2252. */
  2253. function markFunction( fn ) {
  2254. fn[ expando ] = true;
  2255. return fn;
  2256. }
  2257. /**
  2258. * Support testing using an element
  2259. * @param {Function} fn Passed the created element and returns a boolean result
  2260. */
  2261. function assert( fn ) {
  2262. var el = document.createElement("fieldset");
  2263. try {
  2264. return !!fn( el );
  2265. } catch (e) {
  2266. return false;
  2267. } finally {
  2268. // Remove from its parent by default
  2269. if ( el.parentNode ) {
  2270. el.parentNode.removeChild( el );
  2271. }
  2272. // release memory in IE
  2273. el = null;
  2274. }
  2275. }
  2276. /**
  2277. * Adds the same handler for all of the specified attrs
  2278. * @param {String} attrs Pipe-separated list of attributes
  2279. * @param {Function} handler The method that will be applied
  2280. */
  2281. function addHandle( attrs, handler ) {
  2282. var arr = attrs.split("|"),
  2283. i = arr.length;
  2284. while ( i-- ) {
  2285. Expr.attrHandle[ arr[i] ] = handler;
  2286. }
  2287. }
  2288. /**
  2289. * Checks document order of two siblings
  2290. * @param {Element} a
  2291. * @param {Element} b
  2292. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  2293. */
  2294. function siblingCheck( a, b ) {
  2295. var cur = b && a,
  2296. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  2297. a.sourceIndex - b.sourceIndex;
  2298. // Use IE sourceIndex if available on both nodes
  2299. if ( diff ) {
  2300. return diff;
  2301. }
  2302. // Check if b follows a
  2303. if ( cur ) {
  2304. while ( (cur = cur.nextSibling) ) {
  2305. if ( cur === b ) {
  2306. return -1;
  2307. }
  2308. }
  2309. }
  2310. return a ? 1 : -1;
  2311. }
  2312. /**
  2313. * Returns a function to use in pseudos for input types
  2314. * @param {String} type
  2315. */
  2316. function createInputPseudo( type ) {
  2317. return function( elem ) {
  2318. var name = elem.nodeName.toLowerCase();
  2319. return name === "input" && elem.type === type;
  2320. };
  2321. }
  2322. /**
  2323. * Returns a function to use in pseudos for buttons
  2324. * @param {String} type
  2325. */
  2326. function createButtonPseudo( type ) {
  2327. return function( elem ) {
  2328. var name = elem.nodeName.toLowerCase();
  2329. return (name === "input" || name === "button") && elem.type === type;
  2330. };
  2331. }
  2332. /**
  2333. * Returns a function to use in pseudos for :enabled/:disabled
  2334. * @param {Boolean} disabled true for :disabled; false for :enabled
  2335. */
  2336. function createDisabledPseudo( disabled ) {
  2337. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  2338. return function( elem ) {
  2339. // Only certain elements can match :enabled or :disabled
  2340. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  2341. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  2342. if ( "form" in elem ) {
  2343. // Check for inherited disabledness on relevant non-disabled elements:
  2344. // * listed form-associated elements in a disabled fieldset
  2345. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  2346. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  2347. // * option elements in a disabled optgroup
  2348. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  2349. // All such elements have a "form" property.
  2350. if ( elem.parentNode && elem.disabled === false ) {
  2351. // Option elements defer to a parent optgroup if present
  2352. if ( "label" in elem ) {
  2353. if ( "label" in elem.parentNode ) {
  2354. return elem.parentNode.disabled === disabled;
  2355. } else {
  2356. return elem.disabled === disabled;
  2357. }
  2358. }
  2359. // Support: IE 6 - 11
  2360. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  2361. return elem.isDisabled === disabled ||
  2362. // Where there is no isDisabled, check manually
  2363. /* jshint -W018 */
  2364. elem.isDisabled !== !disabled &&
  2365. inDisabledFieldset( elem ) === disabled;
  2366. }
  2367. return elem.disabled === disabled;
  2368. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  2369. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  2370. // even exist on them, let alone have a boolean value.
  2371. } else if ( "label" in elem ) {
  2372. return elem.disabled === disabled;
  2373. }
  2374. // Remaining elements are neither :enabled nor :disabled
  2375. return false;
  2376. };
  2377. }
  2378. /**
  2379. * Returns a function to use in pseudos for positionals
  2380. * @param {Function} fn
  2381. */
  2382. function createPositionalPseudo( fn ) {
  2383. return markFunction(function( argument ) {
  2384. argument = +argument;
  2385. return markFunction(function( seed, matches ) {
  2386. var j,
  2387. matchIndexes = fn( [], seed.length, argument ),
  2388. i = matchIndexes.length;
  2389. // Match elements found at the specified indexes
  2390. while ( i-- ) {
  2391. if ( seed[ (j = matchIndexes[i]) ] ) {
  2392. seed[j] = !(matches[j] = seed[j]);
  2393. }
  2394. }
  2395. });
  2396. });
  2397. }
  2398. /**
  2399. * Checks a node for validity as a Sizzle context
  2400. * @param {Element|Object=} context
  2401. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  2402. */
  2403. function testContext( context ) {
  2404. return context && typeof context.getElementsByTagName !== "undefined" && context;
  2405. }
  2406. // Expose support vars for convenience
  2407. support = Sizzle.support = {};
  2408. /**
  2409. * Detects XML nodes
  2410. * @param {Element|Object} elem An element or a document
  2411. * @returns {Boolean} True iff elem is a non-HTML XML node
  2412. */
  2413. isXML = Sizzle.isXML = function( elem ) {
  2414. var namespace = elem.namespaceURI,
  2415. docElem = (elem.ownerDocument || elem).documentElement;
  2416. // Support: IE <=8
  2417. // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
  2418. // https://bugs.jquery.com/ticket/4833
  2419. return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
  2420. };
  2421. /**
  2422. * Sets document-related variables once based on the current document
  2423. * @param {Element|Object} [doc] An element or document object to use to set the document
  2424. * @returns {Object} Returns the current document
  2425. */
  2426. setDocument = Sizzle.setDocument = function( node ) {
  2427. var hasCompare, subWindow,
  2428. doc = node ? node.ownerDocument || node : preferredDoc;
  2429. // Return early if doc is invalid or already selected
  2430. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  2431. return document;
  2432. }
  2433. // Update global variables
  2434. document = doc;
  2435. docElem = document.documentElement;
  2436. documentIsHTML = !isXML( document );
  2437. // Support: IE 9-11, Edge
  2438. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  2439. if ( preferredDoc !== document &&
  2440. (subWindow = document.defaultView) && subWindow.top !== subWindow ) {
  2441. // Support: IE 11, Edge
  2442. if ( subWindow.addEventListener ) {
  2443. subWindow.addEventListener( "unload", unloadHandler, false );
  2444. // Support: IE 9 - 10 only
  2445. } else if ( subWindow.attachEvent ) {
  2446. subWindow.attachEvent( "onunload", unloadHandler );
  2447. }
  2448. }
  2449. /* Attributes
  2450. ---------------------------------------------------------------------- */
  2451. // Support: IE<8
  2452. // Verify that getAttribute really returns attributes and not properties
  2453. // (excepting IE8 booleans)
  2454. support.attributes = assert(function( el ) {
  2455. el.className = "i";
  2456. return !el.getAttribute("className");
  2457. });
  2458. /* getElement(s)By*
  2459. ---------------------------------------------------------------------- */
  2460. // Check if getElementsByTagName("*") returns only elements
  2461. support.getElementsByTagName = assert(function( el ) {
  2462. el.appendChild( document.createComment("") );
  2463. return !el.getElementsByTagName("*").length;
  2464. });
  2465. // Support: IE<9
  2466. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  2467. // Support: IE<10
  2468. // Check if getElementById returns elements by name
  2469. // The broken getElementById methods don't pick up programmatically-set names,
  2470. // so use a roundabout getElementsByName test
  2471. support.getById = assert(function( el ) {
  2472. docElem.appendChild( el ).id = expando;
  2473. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  2474. });
  2475. // ID filter and find
  2476. if ( support.getById ) {
  2477. Expr.filter["ID"] = function( id ) {
  2478. var attrId = id.replace( runescape, funescape );
  2479. return function( elem ) {
  2480. return elem.getAttribute("id") === attrId;
  2481. };
  2482. };
  2483. Expr.find["ID"] = function( id, context ) {
  2484. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  2485. var elem = context.getElementById( id );
  2486. return elem ? [ elem ] : [];
  2487. }
  2488. };
  2489. } else {
  2490. Expr.filter["ID"] = function( id ) {
  2491. var attrId = id.replace( runescape, funescape );
  2492. return function( elem ) {
  2493. var node = typeof elem.getAttributeNode !== "undefined" &&
  2494. elem.getAttributeNode("id");
  2495. return node && node.value === attrId;
  2496. };
  2497. };
  2498. // Support: IE 6 - 7 only
  2499. // getElementById is not reliable as a find shortcut
  2500. Expr.find["ID"] = function( id, context ) {
  2501. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  2502. var node, i, elems,
  2503. elem = context.getElementById( id );
  2504. if ( elem ) {
  2505. // Verify the id attribute
  2506. node = elem.getAttributeNode("id");
  2507. if ( node && node.value === id ) {
  2508. return [ elem ];
  2509. }
  2510. // Fall back on getElementsByName
  2511. elems = context.getElementsByName( id );
  2512. i = 0;
  2513. while ( (elem = elems[i++]) ) {
  2514. node = elem.getAttributeNode("id");
  2515. if ( node && node.value === id ) {
  2516. return [ elem ];
  2517. }
  2518. }
  2519. }
  2520. return [];
  2521. }
  2522. };
  2523. }
  2524. // Tag
  2525. Expr.find["TAG"] = support.getElementsByTagName ?
  2526. function( tag, context ) {
  2527. if ( typeof context.getElementsByTagName !== "undefined" ) {
  2528. return context.getElementsByTagName( tag );
  2529. // DocumentFragment nodes don't have gEBTN
  2530. } else if ( support.qsa ) {
  2531. return context.querySelectorAll( tag );
  2532. }
  2533. } :
  2534. function( tag, context ) {
  2535. var elem,
  2536. tmp = [],
  2537. i = 0,
  2538. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  2539. results = context.getElementsByTagName( tag );
  2540. // Filter out possible comments
  2541. if ( tag === "*" ) {
  2542. while ( (elem = results[i++]) ) {
  2543. if ( elem.nodeType === 1 ) {
  2544. tmp.push( elem );
  2545. }
  2546. }
  2547. return tmp;
  2548. }
  2549. return results;
  2550. };
  2551. // Class
  2552. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  2553. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  2554. return context.getElementsByClassName( className );
  2555. }
  2556. };
  2557. /* QSA/matchesSelector
  2558. ---------------------------------------------------------------------- */
  2559. // QSA and matchesSelector support
  2560. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  2561. rbuggyMatches = [];
  2562. // qSa(:focus) reports false when true (Chrome 21)
  2563. // We allow this because of a bug in IE8/9 that throws an error
  2564. // whenever `document.activeElement` is accessed on an iframe
  2565. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  2566. // See https://bugs.jquery.com/ticket/13378
  2567. rbuggyQSA = [];
  2568. if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
  2569. // Build QSA regex
  2570. // Regex strategy adopted from Diego Perini
  2571. assert(function( el ) {
  2572. // Select is set to empty string on purpose
  2573. // This is to test IE's treatment of not explicitly
  2574. // setting a boolean content attribute,
  2575. // since its presence should be enough
  2576. // https://bugs.jquery.com/ticket/12359
  2577. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  2578. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  2579. "<option selected=''></option></select>";
  2580. // Support: IE8, Opera 11-12.16
  2581. // Nothing should be selected when empty strings follow ^= or $= or *=
  2582. // The test attribute must be unknown in Opera but "safe" for WinRT
  2583. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  2584. if ( el.querySelectorAll("[msallowcapture^='']").length ) {
  2585. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  2586. }
  2587. // Support: IE8
  2588. // Boolean attributes and "value" are not treated correctly
  2589. if ( !el.querySelectorAll("[selected]").length ) {
  2590. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  2591. }
  2592. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  2593. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  2594. rbuggyQSA.push("~=");
  2595. }
  2596. // Webkit/Opera - :checked should return selected option elements
  2597. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  2598. // IE8 throws error here and will not see later tests
  2599. if ( !el.querySelectorAll(":checked").length ) {
  2600. rbuggyQSA.push(":checked");
  2601. }
  2602. // Support: Safari 8+, iOS 8+
  2603. // https://bugs.webkit.org/show_bug.cgi?id=136851
  2604. // In-page `selector#id sibling-combinator selector` fails
  2605. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  2606. rbuggyQSA.push(".#.+[+~]");
  2607. }
  2608. });
  2609. assert(function( el ) {
  2610. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  2611. "<select disabled='disabled'><option/></select>";
  2612. // Support: Windows 8 Native Apps
  2613. // The type and name attributes are restricted during .innerHTML assignment
  2614. var input = document.createElement("input");
  2615. input.setAttribute( "type", "hidden" );
  2616. el.appendChild( input ).setAttribute( "name", "D" );
  2617. // Support: IE8
  2618. // Enforce case-sensitivity of name attribute
  2619. if ( el.querySelectorAll("[name=d]").length ) {
  2620. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  2621. }
  2622. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  2623. // IE8 throws error here and will not see later tests
  2624. if ( el.querySelectorAll(":enabled").length !== 2 ) {
  2625. rbuggyQSA.push( ":enabled", ":disabled" );
  2626. }
  2627. // Support: IE9-11+
  2628. // IE's :disabled selector does not pick up the children of disabled fieldsets
  2629. docElem.appendChild( el ).disabled = true;
  2630. if ( el.querySelectorAll(":disabled").length !== 2 ) {
  2631. rbuggyQSA.push( ":enabled", ":disabled" );
  2632. }
  2633. // Opera 10-11 does not throw on post-comma invalid pseudos
  2634. el.querySelectorAll("*,:x");
  2635. rbuggyQSA.push(",.*:");
  2636. });
  2637. }
  2638. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  2639. docElem.webkitMatchesSelector ||
  2640. docElem.mozMatchesSelector ||
  2641. docElem.oMatchesSelector ||
  2642. docElem.msMatchesSelector) )) ) {
  2643. assert(function( el ) {
  2644. // Check to see if it's possible to do matchesSelector
  2645. // on a disconnected node (IE 9)
  2646. support.disconnectedMatch = matches.call( el, "*" );
  2647. // This should fail with an exception
  2648. // Gecko does not error, returns false instead
  2649. matches.call( el, "[s!='']:x" );
  2650. rbuggyMatches.push( "!=", pseudos );
  2651. });
  2652. }
  2653. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  2654. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  2655. /* Contains
  2656. ---------------------------------------------------------------------- */
  2657. hasCompare = rnative.test( docElem.compareDocumentPosition );
  2658. // Element contains another
  2659. // Purposefully self-exclusive
  2660. // As in, an element does not contain itself
  2661. contains = hasCompare || rnative.test( docElem.contains ) ?
  2662. function( a, b ) {
  2663. var adown = a.nodeType === 9 ? a.documentElement : a,
  2664. bup = b && b.parentNode;
  2665. return a === bup || !!( bup && bup.nodeType === 1 && (
  2666. adown.contains ?
  2667. adown.contains( bup ) :
  2668. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  2669. ));
  2670. } :
  2671. function( a, b ) {
  2672. if ( b ) {
  2673. while ( (b = b.parentNode) ) {
  2674. if ( b === a ) {
  2675. return true;
  2676. }
  2677. }
  2678. }
  2679. return false;
  2680. };
  2681. /* Sorting
  2682. ---------------------------------------------------------------------- */
  2683. // Document order sorting
  2684. sortOrder = hasCompare ?
  2685. function( a, b ) {
  2686. // Flag for duplicate removal
  2687. if ( a === b ) {
  2688. hasDuplicate = true;
  2689. return 0;
  2690. }
  2691. // Sort on method existence if only one input has compareDocumentPosition
  2692. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  2693. if ( compare ) {
  2694. return compare;
  2695. }
  2696. // Calculate position if both inputs belong to the same document
  2697. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  2698. a.compareDocumentPosition( b ) :
  2699. // Otherwise we know they are disconnected
  2700. 1;
  2701. // Disconnected nodes
  2702. if ( compare & 1 ||
  2703. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  2704. // Choose the first element that is related to our preferred document
  2705. if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  2706. return -1;
  2707. }
  2708. if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  2709. return 1;
  2710. }
  2711. // Maintain original order
  2712. return sortInput ?
  2713. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  2714. 0;
  2715. }
  2716. return compare & 4 ? -1 : 1;
  2717. } :
  2718. function( a, b ) {
  2719. // Exit early if the nodes are identical
  2720. if ( a === b ) {
  2721. hasDuplicate = true;
  2722. return 0;
  2723. }
  2724. var cur,
  2725. i = 0,
  2726. aup = a.parentNode,
  2727. bup = b.parentNode,
  2728. ap = [ a ],
  2729. bp = [ b ];
  2730. // Parentless nodes are either documents or disconnected
  2731. if ( !aup || !bup ) {
  2732. return a === document ? -1 :
  2733. b === document ? 1 :
  2734. aup ? -1 :
  2735. bup ? 1 :
  2736. sortInput ?
  2737. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  2738. 0;
  2739. // If the nodes are siblings, we can do a quick check
  2740. } else if ( aup === bup ) {
  2741. return siblingCheck( a, b );
  2742. }
  2743. // Otherwise we need full lists of their ancestors for comparison
  2744. cur = a;
  2745. while ( (cur = cur.parentNode) ) {
  2746. ap.unshift( cur );
  2747. }
  2748. cur = b;
  2749. while ( (cur = cur.parentNode) ) {
  2750. bp.unshift( cur );
  2751. }
  2752. // Walk down the tree looking for a discrepancy
  2753. while ( ap[i] === bp[i] ) {
  2754. i++;
  2755. }
  2756. return i ?
  2757. // Do a sibling check if the nodes have a common ancestor
  2758. siblingCheck( ap[i], bp[i] ) :
  2759. // Otherwise nodes in our document sort first
  2760. ap[i] === preferredDoc ? -1 :
  2761. bp[i] === preferredDoc ? 1 :
  2762. 0;
  2763. };
  2764. return document;
  2765. };
  2766. Sizzle.matches = function( expr, elements ) {
  2767. return Sizzle( expr, null, null, elements );
  2768. };
  2769. Sizzle.matchesSelector = function( elem, expr ) {
  2770. // Set document vars if needed
  2771. if ( ( elem.ownerDocument || elem ) !== document ) {
  2772. setDocument( elem );
  2773. }
  2774. if ( support.matchesSelector && documentIsHTML &&
  2775. !nonnativeSelectorCache[ expr + " " ] &&
  2776. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  2777. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  2778. try {
  2779. var ret = matches.call( elem, expr );
  2780. // IE 9's matchesSelector returns false on disconnected nodes
  2781. if ( ret || support.disconnectedMatch ||
  2782. // As well, disconnected nodes are said to be in a document
  2783. // fragment in IE 9
  2784. elem.document && elem.document.nodeType !== 11 ) {
  2785. return ret;
  2786. }
  2787. } catch (e) {
  2788. nonnativeSelectorCache( expr, true );
  2789. }
  2790. }
  2791. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  2792. };
  2793. Sizzle.contains = function( context, elem ) {
  2794. // Set document vars if needed
  2795. if ( ( context.ownerDocument || context ) !== document ) {
  2796. setDocument( context );
  2797. }
  2798. return contains( context, elem );
  2799. };
  2800. Sizzle.attr = function( elem, name ) {
  2801. // Set document vars if needed
  2802. if ( ( elem.ownerDocument || elem ) !== document ) {
  2803. setDocument( elem );
  2804. }
  2805. var fn = Expr.attrHandle[ name.toLowerCase() ],
  2806. // Don't get fooled by Object.prototype properties (jQuery #13807)
  2807. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  2808. fn( elem, name, !documentIsHTML ) :
  2809. undefined;
  2810. return val !== undefined ?
  2811. val :
  2812. support.attributes || !documentIsHTML ?
  2813. elem.getAttribute( name ) :
  2814. (val = elem.getAttributeNode(name)) && val.specified ?
  2815. val.value :
  2816. null;
  2817. };
  2818. Sizzle.escape = function( sel ) {
  2819. return (sel + "").replace( rcssescape, fcssescape );
  2820. };
  2821. Sizzle.error = function( msg ) {
  2822. throw new Error( "Syntax error, unrecognized expression: " + msg );
  2823. };
  2824. /**
  2825. * Document sorting and removing duplicates
  2826. * @param {ArrayLike} results
  2827. */
  2828. Sizzle.uniqueSort = function( results ) {
  2829. var elem,
  2830. duplicates = [],
  2831. j = 0,
  2832. i = 0;
  2833. // Unless we *know* we can detect duplicates, assume their presence
  2834. hasDuplicate = !support.detectDuplicates;
  2835. sortInput = !support.sortStable && results.slice( 0 );
  2836. results.sort( sortOrder );
  2837. if ( hasDuplicate ) {
  2838. while ( (elem = results[i++]) ) {
  2839. if ( elem === results[ i ] ) {
  2840. j = duplicates.push( i );
  2841. }
  2842. }
  2843. while ( j-- ) {
  2844. results.splice( duplicates[ j ], 1 );
  2845. }
  2846. }
  2847. // Clear input after sorting to release objects
  2848. // See https://github.com/jquery/sizzle/pull/225
  2849. sortInput = null;
  2850. return results;
  2851. };
  2852. /**
  2853. * Utility function for retrieving the text value of an array of DOM nodes
  2854. * @param {Array|Element} elem
  2855. */
  2856. getText = Sizzle.getText = function( elem ) {
  2857. var node,
  2858. ret = "",
  2859. i = 0,
  2860. nodeType = elem.nodeType;
  2861. if ( !nodeType ) {
  2862. // If no nodeType, this is expected to be an array
  2863. while ( (node = elem[i++]) ) {
  2864. // Do not traverse comment nodes
  2865. ret += getText( node );
  2866. }
  2867. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  2868. // Use textContent for elements
  2869. // innerText usage removed for consistency of new lines (jQuery #11153)
  2870. if ( typeof elem.textContent === "string" ) {
  2871. return elem.textContent;
  2872. } else {
  2873. // Traverse its children
  2874. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  2875. ret += getText( elem );
  2876. }
  2877. }
  2878. } else if ( nodeType === 3 || nodeType === 4 ) {
  2879. return elem.nodeValue;
  2880. }
  2881. // Do not include comment or processing instruction nodes
  2882. return ret;
  2883. };
  2884. Expr = Sizzle.selectors = {
  2885. // Can be adjusted by the user
  2886. cacheLength: 50,
  2887. createPseudo: markFunction,
  2888. match: matchExpr,
  2889. attrHandle: {},
  2890. find: {},
  2891. relative: {
  2892. ">": { dir: "parentNode", first: true },
  2893. " ": { dir: "parentNode" },
  2894. "+": { dir: "previousSibling", first: true },
  2895. "~": { dir: "previousSibling" }
  2896. },
  2897. preFilter: {
  2898. "ATTR": function( match ) {
  2899. match[1] = match[1].replace( runescape, funescape );
  2900. // Move the given value to match[3] whether quoted or unquoted
  2901. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  2902. if ( match[2] === "~=" ) {
  2903. match[3] = " " + match[3] + " ";
  2904. }
  2905. return match.slice( 0, 4 );
  2906. },
  2907. "CHILD": function( match ) {
  2908. /* matches from matchExpr["CHILD"]
  2909. 1 type (only|nth|...)
  2910. 2 what (child|of-type)
  2911. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  2912. 4 xn-component of xn+y argument ([+-]?\d*n|)
  2913. 5 sign of xn-component
  2914. 6 x of xn-component
  2915. 7 sign of y-component
  2916. 8 y of y-component
  2917. */
  2918. match[1] = match[1].toLowerCase();
  2919. if ( match[1].slice( 0, 3 ) === "nth" ) {
  2920. // nth-* requires argument
  2921. if ( !match[3] ) {
  2922. Sizzle.error( match[0] );
  2923. }
  2924. // numeric x and y parameters for Expr.filter.CHILD
  2925. // remember that false/true cast respectively to 0/1
  2926. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  2927. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  2928. // other types prohibit arguments
  2929. } else if ( match[3] ) {
  2930. Sizzle.error( match[0] );
  2931. }
  2932. return match;
  2933. },
  2934. "PSEUDO": function( match ) {
  2935. var excess,
  2936. unquoted = !match[6] && match[2];
  2937. if ( matchExpr["CHILD"].test( match[0] ) ) {
  2938. return null;
  2939. }
  2940. // Accept quoted arguments as-is
  2941. if ( match[3] ) {
  2942. match[2] = match[4] || match[5] || "";
  2943. // Strip excess characters from unquoted arguments
  2944. } else if ( unquoted && rpseudo.test( unquoted ) &&
  2945. // Get excess from tokenize (recursively)
  2946. (excess = tokenize( unquoted, true )) &&
  2947. // advance to the next closing parenthesis
  2948. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  2949. // excess is a negative index
  2950. match[0] = match[0].slice( 0, excess );
  2951. match[2] = unquoted.slice( 0, excess );
  2952. }
  2953. // Return only captures needed by the pseudo filter method (type and argument)
  2954. return match.slice( 0, 3 );
  2955. }
  2956. },
  2957. filter: {
  2958. "TAG": function( nodeNameSelector ) {
  2959. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  2960. return nodeNameSelector === "*" ?
  2961. function() { return true; } :
  2962. function( elem ) {
  2963. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  2964. };
  2965. },
  2966. "CLASS": function( className ) {
  2967. var pattern = classCache[ className + " " ];
  2968. return pattern ||
  2969. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  2970. classCache( className, function( elem ) {
  2971. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
  2972. });
  2973. },
  2974. "ATTR": function( name, operator, check ) {
  2975. return function( elem ) {
  2976. var result = Sizzle.attr( elem, name );
  2977. if ( result == null ) {
  2978. return operator === "!=";
  2979. }
  2980. if ( !operator ) {
  2981. return true;
  2982. }
  2983. result += "";
  2984. return operator === "=" ? result === check :
  2985. operator === "!=" ? result !== check :
  2986. operator === "^=" ? check && result.indexOf( check ) === 0 :
  2987. operator === "*=" ? check && result.indexOf( check ) > -1 :
  2988. operator === "$=" ? check && result.slice( -check.length ) === check :
  2989. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  2990. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  2991. false;
  2992. };
  2993. },
  2994. "CHILD": function( type, what, argument, first, last ) {
  2995. var simple = type.slice( 0, 3 ) !== "nth",
  2996. forward = type.slice( -4 ) !== "last",
  2997. ofType = what === "of-type";
  2998. return first === 1 && last === 0 ?
  2999. // Shortcut for :nth-*(n)
  3000. function( elem ) {
  3001. return !!elem.parentNode;
  3002. } :
  3003. function( elem, context, xml ) {
  3004. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  3005. dir = simple !== forward ? "nextSibling" : "previousSibling",
  3006. parent = elem.parentNode,
  3007. name = ofType && elem.nodeName.toLowerCase(),
  3008. useCache = !xml && !ofType,
  3009. diff = false;
  3010. if ( parent ) {
  3011. // :(first|last|only)-(child|of-type)
  3012. if ( simple ) {
  3013. while ( dir ) {
  3014. node = elem;
  3015. while ( (node = node[ dir ]) ) {
  3016. if ( ofType ?
  3017. node.nodeName.toLowerCase() === name :
  3018. node.nodeType === 1 ) {
  3019. return false;
  3020. }
  3021. }
  3022. // Reverse direction for :only-* (if we haven't yet done so)
  3023. start = dir = type === "only" && !start && "nextSibling";
  3024. }
  3025. return true;
  3026. }
  3027. start = [ forward ? parent.firstChild : parent.lastChild ];
  3028. // non-xml :nth-child(...) stores cache data on `parent`
  3029. if ( forward && useCache ) {
  3030. // Seek `elem` from a previously-cached index
  3031. // ...in a gzip-friendly way
  3032. node = parent;
  3033. outerCache = node[ expando ] || (node[ expando ] = {});
  3034. // Support: IE <9 only
  3035. // Defend against cloned attroperties (jQuery gh-1709)
  3036. uniqueCache = outerCache[ node.uniqueID ] ||
  3037. (outerCache[ node.uniqueID ] = {});
  3038. cache = uniqueCache[ type ] || [];
  3039. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  3040. diff = nodeIndex && cache[ 2 ];
  3041. node = nodeIndex && parent.childNodes[ nodeIndex ];
  3042. while ( (node = ++nodeIndex && node && node[ dir ] ||
  3043. // Fallback to seeking `elem` from the start
  3044. (diff = nodeIndex = 0) || start.pop()) ) {
  3045. // When found, cache indexes on `parent` and break
  3046. if ( node.nodeType === 1 && ++diff && node === elem ) {
  3047. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  3048. break;
  3049. }
  3050. }
  3051. } else {
  3052. // Use previously-cached element index if available
  3053. if ( useCache ) {
  3054. // ...in a gzip-friendly way
  3055. node = elem;
  3056. outerCache = node[ expando ] || (node[ expando ] = {});
  3057. // Support: IE <9 only
  3058. // Defend against cloned attroperties (jQuery gh-1709)
  3059. uniqueCache = outerCache[ node.uniqueID ] ||
  3060. (outerCache[ node.uniqueID ] = {});
  3061. cache = uniqueCache[ type ] || [];
  3062. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  3063. diff = nodeIndex;
  3064. }
  3065. // xml :nth-child(...)
  3066. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  3067. if ( diff === false ) {
  3068. // Use the same loop as above to seek `elem` from the start
  3069. while ( (node = ++nodeIndex && node && node[ dir ] ||
  3070. (diff = nodeIndex = 0) || start.pop()) ) {
  3071. if ( ( ofType ?
  3072. node.nodeName.toLowerCase() === name :
  3073. node.nodeType === 1 ) &&
  3074. ++diff ) {
  3075. // Cache the index of each encountered element
  3076. if ( useCache ) {
  3077. outerCache = node[ expando ] || (node[ expando ] = {});
  3078. // Support: IE <9 only
  3079. // Defend against cloned attroperties (jQuery gh-1709)
  3080. uniqueCache = outerCache[ node.uniqueID ] ||
  3081. (outerCache[ node.uniqueID ] = {});
  3082. uniqueCache[ type ] = [ dirruns, diff ];
  3083. }
  3084. if ( node === elem ) {
  3085. break;
  3086. }
  3087. }
  3088. }
  3089. }
  3090. }
  3091. // Incorporate the offset, then check against cycle size
  3092. diff -= last;
  3093. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  3094. }
  3095. };
  3096. },
  3097. "PSEUDO": function( pseudo, argument ) {
  3098. // pseudo-class names are case-insensitive
  3099. // http://www.w3.org/TR/selectors/#pseudo-classes
  3100. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  3101. // Remember that setFilters inherits from pseudos
  3102. var args,
  3103. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  3104. Sizzle.error( "unsupported pseudo: " + pseudo );
  3105. // The user may use createPseudo to indicate that
  3106. // arguments are needed to create the filter function
  3107. // just as Sizzle does
  3108. if ( fn[ expando ] ) {
  3109. return fn( argument );
  3110. }
  3111. // But maintain support for old signatures
  3112. if ( fn.length > 1 ) {
  3113. args = [ pseudo, pseudo, "", argument ];
  3114. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  3115. markFunction(function( seed, matches ) {
  3116. var idx,
  3117. matched = fn( seed, argument ),
  3118. i = matched.length;
  3119. while ( i-- ) {
  3120. idx = indexOf( seed, matched[i] );
  3121. seed[ idx ] = !( matches[ idx ] = matched[i] );
  3122. }
  3123. }) :
  3124. function( elem ) {
  3125. return fn( elem, 0, args );
  3126. };
  3127. }
  3128. return fn;
  3129. }
  3130. },
  3131. pseudos: {
  3132. // Potentially complex pseudos
  3133. "not": markFunction(function( selector ) {
  3134. // Trim the selector passed to compile
  3135. // to avoid treating leading and trailing
  3136. // spaces as combinators
  3137. var input = [],
  3138. results = [],
  3139. matcher = compile( selector.replace( rtrim, "$1" ) );
  3140. return matcher[ expando ] ?
  3141. markFunction(function( seed, matches, context, xml ) {
  3142. var elem,
  3143. unmatched = matcher( seed, null, xml, [] ),
  3144. i = seed.length;
  3145. // Match elements unmatched by `matcher`
  3146. while ( i-- ) {
  3147. if ( (elem = unmatched[i]) ) {
  3148. seed[i] = !(matches[i] = elem);
  3149. }
  3150. }
  3151. }) :
  3152. function( elem, context, xml ) {
  3153. input[0] = elem;
  3154. matcher( input, null, xml, results );
  3155. // Don't keep the element (issue #299)
  3156. input[0] = null;
  3157. return !results.pop();
  3158. };
  3159. }),
  3160. "has": markFunction(function( selector ) {
  3161. return function( elem ) {
  3162. return Sizzle( selector, elem ).length > 0;
  3163. };
  3164. }),
  3165. "contains": markFunction(function( text ) {
  3166. text = text.replace( runescape, funescape );
  3167. return function( elem ) {
  3168. return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
  3169. };
  3170. }),
  3171. // "Whether an element is represented by a :lang() selector
  3172. // is based solely on the element's language value
  3173. // being equal to the identifier C,
  3174. // or beginning with the identifier C immediately followed by "-".
  3175. // The matching of C against the element's language value is performed case-insensitively.
  3176. // The identifier C does not have to be a valid language name."
  3177. // http://www.w3.org/TR/selectors/#lang-pseudo
  3178. "lang": markFunction( function( lang ) {
  3179. // lang value must be a valid identifier
  3180. if ( !ridentifier.test(lang || "") ) {
  3181. Sizzle.error( "unsupported lang: " + lang );
  3182. }
  3183. lang = lang.replace( runescape, funescape ).toLowerCase();
  3184. return function( elem ) {
  3185. var elemLang;
  3186. do {
  3187. if ( (elemLang = documentIsHTML ?
  3188. elem.lang :
  3189. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  3190. elemLang = elemLang.toLowerCase();
  3191. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  3192. }
  3193. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  3194. return false;
  3195. };
  3196. }),
  3197. // Miscellaneous
  3198. "target": function( elem ) {
  3199. var hash = window.location && window.location.hash;
  3200. return hash && hash.slice( 1 ) === elem.id;
  3201. },
  3202. "root": function( elem ) {
  3203. return elem === docElem;
  3204. },
  3205. "focus": function( elem ) {
  3206. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  3207. },
  3208. // Boolean properties
  3209. "enabled": createDisabledPseudo( false ),
  3210. "disabled": createDisabledPseudo( true ),
  3211. "checked": function( elem ) {
  3212. // In CSS3, :checked should return both checked and selected elements
  3213. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  3214. var nodeName = elem.nodeName.toLowerCase();
  3215. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  3216. },
  3217. "selected": function( elem ) {
  3218. // Accessing this property makes selected-by-default
  3219. // options in Safari work properly
  3220. if ( elem.parentNode ) {
  3221. elem.parentNode.selectedIndex;
  3222. }
  3223. return elem.selected === true;
  3224. },
  3225. // Contents
  3226. "empty": function( elem ) {
  3227. // http://www.w3.org/TR/selectors/#empty-pseudo
  3228. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  3229. // but not by others (comment: 8; processing instruction: 7; etc.)
  3230. // nodeType < 6 works because attributes (2) do not appear as children
  3231. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  3232. if ( elem.nodeType < 6 ) {
  3233. return false;
  3234. }
  3235. }
  3236. return true;
  3237. },
  3238. "parent": function( elem ) {
  3239. return !Expr.pseudos["empty"]( elem );
  3240. },
  3241. // Element/input types
  3242. "header": function( elem ) {
  3243. return rheader.test( elem.nodeName );
  3244. },
  3245. "input": function( elem ) {
  3246. return rinputs.test( elem.nodeName );
  3247. },
  3248. "button": function( elem ) {
  3249. var name = elem.nodeName.toLowerCase();
  3250. return name === "input" && elem.type === "button" || name === "button";
  3251. },
  3252. "text": function( elem ) {
  3253. var attr;
  3254. return elem.nodeName.toLowerCase() === "input" &&
  3255. elem.type === "text" &&
  3256. // Support: IE<8
  3257. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  3258. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  3259. },
  3260. // Position-in-collection
  3261. "first": createPositionalPseudo(function() {
  3262. return [ 0 ];
  3263. }),
  3264. "last": createPositionalPseudo(function( matchIndexes, length ) {
  3265. return [ length - 1 ];
  3266. }),
  3267. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  3268. return [ argument < 0 ? argument + length : argument ];
  3269. }),
  3270. "even": createPositionalPseudo(function( matchIndexes, length ) {
  3271. var i = 0;
  3272. for ( ; i < length; i += 2 ) {
  3273. matchIndexes.push( i );
  3274. }
  3275. return matchIndexes;
  3276. }),
  3277. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  3278. var i = 1;
  3279. for ( ; i < length; i += 2 ) {
  3280. matchIndexes.push( i );
  3281. }
  3282. return matchIndexes;
  3283. }),
  3284. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  3285. var i = argument < 0 ?
  3286. argument + length :
  3287. argument > length ?
  3288. length :
  3289. argument;
  3290. for ( ; --i >= 0; ) {
  3291. matchIndexes.push( i );
  3292. }
  3293. return matchIndexes;
  3294. }),
  3295. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  3296. var i = argument < 0 ? argument + length : argument;
  3297. for ( ; ++i < length; ) {
  3298. matchIndexes.push( i );
  3299. }
  3300. return matchIndexes;
  3301. })
  3302. }
  3303. };
  3304. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  3305. // Add button/input type pseudos
  3306. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  3307. Expr.pseudos[ i ] = createInputPseudo( i );
  3308. }
  3309. for ( i in { submit: true, reset: true } ) {
  3310. Expr.pseudos[ i ] = createButtonPseudo( i );
  3311. }
  3312. // Easy API for creating new setFilters
  3313. function setFilters() {}
  3314. setFilters.prototype = Expr.filters = Expr.pseudos;
  3315. Expr.setFilters = new setFilters();
  3316. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  3317. var matched, match, tokens, type,
  3318. soFar, groups, preFilters,
  3319. cached = tokenCache[ selector + " " ];
  3320. if ( cached ) {
  3321. return parseOnly ? 0 : cached.slice( 0 );
  3322. }
  3323. soFar = selector;
  3324. groups = [];
  3325. preFilters = Expr.preFilter;
  3326. while ( soFar ) {
  3327. // Comma and first run
  3328. if ( !matched || (match = rcomma.exec( soFar )) ) {
  3329. if ( match ) {
  3330. // Don't consume trailing commas as valid
  3331. soFar = soFar.slice( match[0].length ) || soFar;
  3332. }
  3333. groups.push( (tokens = []) );
  3334. }
  3335. matched = false;
  3336. // Combinators
  3337. if ( (match = rcombinators.exec( soFar )) ) {
  3338. matched = match.shift();
  3339. tokens.push({
  3340. value: matched,
  3341. // Cast descendant combinators to space
  3342. type: match[0].replace( rtrim, " " )
  3343. });
  3344. soFar = soFar.slice( matched.length );
  3345. }
  3346. // Filters
  3347. for ( type in Expr.filter ) {
  3348. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  3349. (match = preFilters[ type ]( match ))) ) {
  3350. matched = match.shift();
  3351. tokens.push({
  3352. value: matched,
  3353. type: type,
  3354. matches: match
  3355. });
  3356. soFar = soFar.slice( matched.length );
  3357. }
  3358. }
  3359. if ( !matched ) {
  3360. break;
  3361. }
  3362. }
  3363. // Return the length of the invalid excess
  3364. // if we're just parsing
  3365. // Otherwise, throw an error or return tokens
  3366. return parseOnly ?
  3367. soFar.length :
  3368. soFar ?
  3369. Sizzle.error( selector ) :
  3370. // Cache the tokens
  3371. tokenCache( selector, groups ).slice( 0 );
  3372. };
  3373. function toSelector( tokens ) {
  3374. var i = 0,
  3375. len = tokens.length,
  3376. selector = "";
  3377. for ( ; i < len; i++ ) {
  3378. selector += tokens[i].value;
  3379. }
  3380. return selector;
  3381. }
  3382. function addCombinator( matcher, combinator, base ) {
  3383. var dir = combinator.dir,
  3384. skip = combinator.next,
  3385. key = skip || dir,
  3386. checkNonElements = base && key === "parentNode",
  3387. doneName = done++;
  3388. return combinator.first ?
  3389. // Check against closest ancestor/preceding element
  3390. function( elem, context, xml ) {
  3391. while ( (elem = elem[ dir ]) ) {
  3392. if ( elem.nodeType === 1 || checkNonElements ) {
  3393. return matcher( elem, context, xml );
  3394. }
  3395. }
  3396. return false;
  3397. } :
  3398. // Check against all ancestor/preceding elements
  3399. function( elem, context, xml ) {
  3400. var oldCache, uniqueCache, outerCache,
  3401. newCache = [ dirruns, doneName ];
  3402. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  3403. if ( xml ) {
  3404. while ( (elem = elem[ dir ]) ) {
  3405. if ( elem.nodeType === 1 || checkNonElements ) {
  3406. if ( matcher( elem, context, xml ) ) {
  3407. return true;
  3408. }
  3409. }
  3410. }
  3411. } else {
  3412. while ( (elem = elem[ dir ]) ) {
  3413. if ( elem.nodeType === 1 || checkNonElements ) {
  3414. outerCache = elem[ expando ] || (elem[ expando ] = {});
  3415. // Support: IE <9 only
  3416. // Defend against cloned attroperties (jQuery gh-1709)
  3417. uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
  3418. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  3419. elem = elem[ dir ] || elem;
  3420. } else if ( (oldCache = uniqueCache[ key ]) &&
  3421. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  3422. // Assign to newCache so results back-propagate to previous elements
  3423. return (newCache[ 2 ] = oldCache[ 2 ]);
  3424. } else {
  3425. // Reuse newcache so results back-propagate to previous elements
  3426. uniqueCache[ key ] = newCache;
  3427. // A match means we're done; a fail means we have to keep checking
  3428. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  3429. return true;
  3430. }
  3431. }
  3432. }
  3433. }
  3434. }
  3435. return false;
  3436. };
  3437. }
  3438. function elementMatcher( matchers ) {
  3439. return matchers.length > 1 ?
  3440. function( elem, context, xml ) {
  3441. var i = matchers.length;
  3442. while ( i-- ) {
  3443. if ( !matchers[i]( elem, context, xml ) ) {
  3444. return false;
  3445. }
  3446. }
  3447. return true;
  3448. } :
  3449. matchers[0];
  3450. }
  3451. function multipleContexts( selector, contexts, results ) {
  3452. var i = 0,
  3453. len = contexts.length;
  3454. for ( ; i < len; i++ ) {
  3455. Sizzle( selector, contexts[i], results );
  3456. }
  3457. return results;
  3458. }
  3459. function condense( unmatched, map, filter, context, xml ) {
  3460. var elem,
  3461. newUnmatched = [],
  3462. i = 0,
  3463. len = unmatched.length,
  3464. mapped = map != null;
  3465. for ( ; i < len; i++ ) {
  3466. if ( (elem = unmatched[i]) ) {
  3467. if ( !filter || filter( elem, context, xml ) ) {
  3468. newUnmatched.push( elem );
  3469. if ( mapped ) {
  3470. map.push( i );
  3471. }
  3472. }
  3473. }
  3474. }
  3475. return newUnmatched;
  3476. }
  3477. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  3478. if ( postFilter && !postFilter[ expando ] ) {
  3479. postFilter = setMatcher( postFilter );
  3480. }
  3481. if ( postFinder && !postFinder[ expando ] ) {
  3482. postFinder = setMatcher( postFinder, postSelector );
  3483. }
  3484. return markFunction(function( seed, results, context, xml ) {
  3485. var temp, i, elem,
  3486. preMap = [],
  3487. postMap = [],
  3488. preexisting = results.length,
  3489. // Get initial elements from seed or context
  3490. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  3491. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  3492. matcherIn = preFilter && ( seed || !selector ) ?
  3493. condense( elems, preMap, preFilter, context, xml ) :
  3494. elems,
  3495. matcherOut = matcher ?
  3496. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  3497. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  3498. // ...intermediate processing is necessary
  3499. [] :
  3500. // ...otherwise use results directly
  3501. results :
  3502. matcherIn;
  3503. // Find primary matches
  3504. if ( matcher ) {
  3505. matcher( matcherIn, matcherOut, context, xml );
  3506. }
  3507. // Apply postFilter
  3508. if ( postFilter ) {
  3509. temp = condense( matcherOut, postMap );
  3510. postFilter( temp, [], context, xml );
  3511. // Un-match failing elements by moving them back to matcherIn
  3512. i = temp.length;
  3513. while ( i-- ) {
  3514. if ( (elem = temp[i]) ) {
  3515. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  3516. }
  3517. }
  3518. }
  3519. if ( seed ) {
  3520. if ( postFinder || preFilter ) {
  3521. if ( postFinder ) {
  3522. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  3523. temp = [];
  3524. i = matcherOut.length;
  3525. while ( i-- ) {
  3526. if ( (elem = matcherOut[i]) ) {
  3527. // Restore matcherIn since elem is not yet a final match
  3528. temp.push( (matcherIn[i] = elem) );
  3529. }
  3530. }
  3531. postFinder( null, (matcherOut = []), temp, xml );
  3532. }
  3533. // Move matched elements from seed to results to keep them synchronized
  3534. i = matcherOut.length;
  3535. while ( i-- ) {
  3536. if ( (elem = matcherOut[i]) &&
  3537. (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
  3538. seed[temp] = !(results[temp] = elem);
  3539. }
  3540. }
  3541. }
  3542. // Add elements to results, through postFinder if defined
  3543. } else {
  3544. matcherOut = condense(
  3545. matcherOut === results ?
  3546. matcherOut.splice( preexisting, matcherOut.length ) :
  3547. matcherOut
  3548. );
  3549. if ( postFinder ) {
  3550. postFinder( null, results, matcherOut, xml );
  3551. } else {
  3552. push.apply( results, matcherOut );
  3553. }
  3554. }
  3555. });
  3556. }
  3557. function matcherFromTokens( tokens ) {
  3558. var checkContext, matcher, j,
  3559. len = tokens.length,
  3560. leadingRelative = Expr.relative[ tokens[0].type ],
  3561. implicitRelative = leadingRelative || Expr.relative[" "],
  3562. i = leadingRelative ? 1 : 0,
  3563. // The foundational matcher ensures that elements are reachable from top-level context(s)
  3564. matchContext = addCombinator( function( elem ) {
  3565. return elem === checkContext;
  3566. }, implicitRelative, true ),
  3567. matchAnyContext = addCombinator( function( elem ) {
  3568. return indexOf( checkContext, elem ) > -1;
  3569. }, implicitRelative, true ),
  3570. matchers = [ function( elem, context, xml ) {
  3571. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  3572. (checkContext = context).nodeType ?
  3573. matchContext( elem, context, xml ) :
  3574. matchAnyContext( elem, context, xml ) );
  3575. // Avoid hanging onto element (issue #299)
  3576. checkContext = null;
  3577. return ret;
  3578. } ];
  3579. for ( ; i < len; i++ ) {
  3580. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  3581. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  3582. } else {
  3583. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  3584. // Return special upon seeing a positional matcher
  3585. if ( matcher[ expando ] ) {
  3586. // Find the next relative operator (if any) for proper handling
  3587. j = ++i;
  3588. for ( ; j < len; j++ ) {
  3589. if ( Expr.relative[ tokens[j].type ] ) {
  3590. break;
  3591. }
  3592. }
  3593. return setMatcher(
  3594. i > 1 && elementMatcher( matchers ),
  3595. i > 1 && toSelector(
  3596. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  3597. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  3598. ).replace( rtrim, "$1" ),
  3599. matcher,
  3600. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  3601. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  3602. j < len && toSelector( tokens )
  3603. );
  3604. }
  3605. matchers.push( matcher );
  3606. }
  3607. }
  3608. return elementMatcher( matchers );
  3609. }
  3610. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  3611. var bySet = setMatchers.length > 0,
  3612. byElement = elementMatchers.length > 0,
  3613. superMatcher = function( seed, context, xml, results, outermost ) {
  3614. var elem, j, matcher,
  3615. matchedCount = 0,
  3616. i = "0",
  3617. unmatched = seed && [],
  3618. setMatched = [],
  3619. contextBackup = outermostContext,
  3620. // We must always have either seed elements or outermost context
  3621. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  3622. // Use integer dirruns iff this is the outermost matcher
  3623. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  3624. len = elems.length;
  3625. if ( outermost ) {
  3626. outermostContext = context === document || context || outermost;
  3627. }
  3628. // Add elements passing elementMatchers directly to results
  3629. // Support: IE<9, Safari
  3630. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  3631. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  3632. if ( byElement && elem ) {
  3633. j = 0;
  3634. if ( !context && elem.ownerDocument !== document ) {
  3635. setDocument( elem );
  3636. xml = !documentIsHTML;
  3637. }
  3638. while ( (matcher = elementMatchers[j++]) ) {
  3639. if ( matcher( elem, context || document, xml) ) {
  3640. results.push( elem );
  3641. break;
  3642. }
  3643. }
  3644. if ( outermost ) {
  3645. dirruns = dirrunsUnique;
  3646. }
  3647. }
  3648. // Track unmatched elements for set filters
  3649. if ( bySet ) {
  3650. // They will have gone through all possible matchers
  3651. if ( (elem = !matcher && elem) ) {
  3652. matchedCount--;
  3653. }
  3654. // Lengthen the array for every element, matched or not
  3655. if ( seed ) {
  3656. unmatched.push( elem );
  3657. }
  3658. }
  3659. }
  3660. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  3661. // makes the latter nonnegative.
  3662. matchedCount += i;
  3663. // Apply set filters to unmatched elements
  3664. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  3665. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  3666. // no element matchers and no seed.
  3667. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  3668. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  3669. // numerically zero.
  3670. if ( bySet && i !== matchedCount ) {
  3671. j = 0;
  3672. while ( (matcher = setMatchers[j++]) ) {
  3673. matcher( unmatched, setMatched, context, xml );
  3674. }
  3675. if ( seed ) {
  3676. // Reintegrate element matches to eliminate the need for sorting
  3677. if ( matchedCount > 0 ) {
  3678. while ( i-- ) {
  3679. if ( !(unmatched[i] || setMatched[i]) ) {
  3680. setMatched[i] = pop.call( results );
  3681. }
  3682. }
  3683. }
  3684. // Discard index placeholder values to get only actual matches
  3685. setMatched = condense( setMatched );
  3686. }
  3687. // Add matches to results
  3688. push.apply( results, setMatched );
  3689. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  3690. if ( outermost && !seed && setMatched.length > 0 &&
  3691. ( matchedCount + setMatchers.length ) > 1 ) {
  3692. Sizzle.uniqueSort( results );
  3693. }
  3694. }
  3695. // Override manipulation of globals by nested matchers
  3696. if ( outermost ) {
  3697. dirruns = dirrunsUnique;
  3698. outermostContext = contextBackup;
  3699. }
  3700. return unmatched;
  3701. };
  3702. return bySet ?
  3703. markFunction( superMatcher ) :
  3704. superMatcher;
  3705. }
  3706. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  3707. var i,
  3708. setMatchers = [],
  3709. elementMatchers = [],
  3710. cached = compilerCache[ selector + " " ];
  3711. if ( !cached ) {
  3712. // Generate a function of recursive functions that can be used to check each element
  3713. if ( !match ) {
  3714. match = tokenize( selector );
  3715. }
  3716. i = match.length;
  3717. while ( i-- ) {
  3718. cached = matcherFromTokens( match[i] );
  3719. if ( cached[ expando ] ) {
  3720. setMatchers.push( cached );
  3721. } else {
  3722. elementMatchers.push( cached );
  3723. }
  3724. }
  3725. // Cache the compiled function
  3726. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  3727. // Save selector and tokenization
  3728. cached.selector = selector;
  3729. }
  3730. return cached;
  3731. };
  3732. /**
  3733. * A low-level selection function that works with Sizzle's compiled
  3734. * selector functions
  3735. * @param {String|Function} selector A selector or a pre-compiled
  3736. * selector function built with Sizzle.compile
  3737. * @param {Element} context
  3738. * @param {Array} [results]
  3739. * @param {Array} [seed] A set of elements to match against
  3740. */
  3741. select = Sizzle.select = function( selector, context, results, seed ) {
  3742. var i, tokens, token, type, find,
  3743. compiled = typeof selector === "function" && selector,
  3744. match = !seed && tokenize( (selector = compiled.selector || selector) );
  3745. results = results || [];
  3746. // Try to minimize operations if there is only one selector in the list and no seed
  3747. // (the latter of which guarantees us context)
  3748. if ( match.length === 1 ) {
  3749. // Reduce context if the leading compound selector is an ID
  3750. tokens = match[0] = match[0].slice( 0 );
  3751. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  3752. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
  3753. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  3754. if ( !context ) {
  3755. return results;
  3756. // Precompiled matchers will still verify ancestry, so step up a level
  3757. } else if ( compiled ) {
  3758. context = context.parentNode;
  3759. }
  3760. selector = selector.slice( tokens.shift().value.length );
  3761. }
  3762. // Fetch a seed set for right-to-left matching
  3763. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  3764. while ( i-- ) {
  3765. token = tokens[i];
  3766. // Abort if we hit a combinator
  3767. if ( Expr.relative[ (type = token.type) ] ) {
  3768. break;
  3769. }
  3770. if ( (find = Expr.find[ type ]) ) {
  3771. // Search, expanding context for leading sibling combinators
  3772. if ( (seed = find(
  3773. token.matches[0].replace( runescape, funescape ),
  3774. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  3775. )) ) {
  3776. // If seed is empty or no tokens remain, we can return early
  3777. tokens.splice( i, 1 );
  3778. selector = seed.length && toSelector( tokens );
  3779. if ( !selector ) {
  3780. push.apply( results, seed );
  3781. return results;
  3782. }
  3783. break;
  3784. }
  3785. }
  3786. }
  3787. }
  3788. // Compile and execute a filtering function if one is not provided
  3789. // Provide `match` to avoid retokenization if we modified the selector above
  3790. ( compiled || compile( selector, match ) )(
  3791. seed,
  3792. context,
  3793. !documentIsHTML,
  3794. results,
  3795. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  3796. );
  3797. return results;
  3798. };
  3799. // One-time assignments
  3800. // Sort stability
  3801. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  3802. // Support: Chrome 14-35+
  3803. // Always assume duplicates if they aren't passed to the comparison function
  3804. support.detectDuplicates = !!hasDuplicate;
  3805. // Initialize against the default document
  3806. setDocument();
  3807. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  3808. // Detached nodes confoundingly follow *each other*
  3809. support.sortDetached = assert(function( el ) {
  3810. // Should return 1, but returns 4 (following)
  3811. return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
  3812. });
  3813. // Support: IE<8
  3814. // Prevent attribute/property "interpolation"
  3815. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  3816. if ( !assert(function( el ) {
  3817. el.innerHTML = "<a href='#'></a>";
  3818. return el.firstChild.getAttribute("href") === "#" ;
  3819. }) ) {
  3820. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  3821. if ( !isXML ) {
  3822. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  3823. }
  3824. });
  3825. }
  3826. // Support: IE<9
  3827. // Use defaultValue in place of getAttribute("value")
  3828. if ( !support.attributes || !assert(function( el ) {
  3829. el.innerHTML = "<input/>";
  3830. el.firstChild.setAttribute( "value", "" );
  3831. return el.firstChild.getAttribute( "value" ) === "";
  3832. }) ) {
  3833. addHandle( "value", function( elem, name, isXML ) {
  3834. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  3835. return elem.defaultValue;
  3836. }
  3837. });
  3838. }
  3839. // Support: IE<9
  3840. // Use getAttributeNode to fetch booleans when getAttribute lies
  3841. if ( !assert(function( el ) {
  3842. return el.getAttribute("disabled") == null;
  3843. }) ) {
  3844. addHandle( booleans, function( elem, name, isXML ) {
  3845. var val;
  3846. if ( !isXML ) {
  3847. return elem[ name ] === true ? name.toLowerCase() :
  3848. (val = elem.getAttributeNode( name )) && val.specified ?
  3849. val.value :
  3850. null;
  3851. }
  3852. });
  3853. }
  3854. return Sizzle;
  3855. })( window );
  3856. jQuery.find = Sizzle;
  3857. jQuery.expr = Sizzle.selectors;
  3858. // Deprecated
  3859. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  3860. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  3861. jQuery.text = Sizzle.getText;
  3862. jQuery.isXMLDoc = Sizzle.isXML;
  3863. jQuery.contains = Sizzle.contains;
  3864. jQuery.escapeSelector = Sizzle.escape;
  3865. var dir = function( elem, dir, until ) {
  3866. var matched = [],
  3867. truncate = until !== undefined;
  3868. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  3869. if ( elem.nodeType === 1 ) {
  3870. if ( truncate && jQuery( elem ).is( until ) ) {
  3871. break;
  3872. }
  3873. matched.push( elem );
  3874. }
  3875. }
  3876. return matched;
  3877. };
  3878. var siblings = function( n, elem ) {
  3879. var matched = [];
  3880. for ( ; n; n = n.nextSibling ) {
  3881. if ( n.nodeType === 1 && n !== elem ) {
  3882. matched.push( n );
  3883. }
  3884. }
  3885. return matched;
  3886. };
  3887. var rneedsContext = jQuery.expr.match.needsContext;
  3888. function nodeName( elem, name ) {
  3889. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  3890. };
  3891. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  3892. // Implement the identical functionality for filter and not
  3893. function winnow( elements, qualifier, not ) {
  3894. if ( isFunction( qualifier ) ) {
  3895. return jQuery.grep( elements, function( elem, i ) {
  3896. return !!qualifier.call( elem, i, elem ) !== not;
  3897. } );
  3898. }
  3899. // Single element
  3900. if ( qualifier.nodeType ) {
  3901. return jQuery.grep( elements, function( elem ) {
  3902. return ( elem === qualifier ) !== not;
  3903. } );
  3904. }
  3905. // Arraylike of elements (jQuery, arguments, Array)
  3906. if ( typeof qualifier !== "string" ) {
  3907. return jQuery.grep( elements, function( elem ) {
  3908. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  3909. } );
  3910. }
  3911. // Filtered directly for both simple and complex selectors
  3912. return jQuery.filter( qualifier, elements, not );
  3913. }
  3914. jQuery.filter = function( expr, elems, not ) {
  3915. var elem = elems[ 0 ];
  3916. if ( not ) {
  3917. expr = ":not(" + expr + ")";
  3918. }
  3919. if ( elems.length === 1 && elem.nodeType === 1 ) {
  3920. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  3921. }
  3922. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  3923. return elem.nodeType === 1;
  3924. } ) );
  3925. };
  3926. jQuery.fn.extend( {
  3927. find: function( selector ) {
  3928. var i, ret,
  3929. len = this.length,
  3930. self = this;
  3931. if ( typeof selector !== "string" ) {
  3932. return this.pushStack( jQuery( selector ).filter( function() {
  3933. for ( i = 0; i < len; i++ ) {
  3934. if ( jQuery.contains( self[ i ], this ) ) {
  3935. return true;
  3936. }
  3937. }
  3938. } ) );
  3939. }
  3940. ret = this.pushStack( [] );
  3941. for ( i = 0; i < len; i++ ) {
  3942. jQuery.find( selector, self[ i ], ret );
  3943. }
  3944. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  3945. },
  3946. filter: function( selector ) {
  3947. return this.pushStack( winnow( this, selector || [], false ) );
  3948. },
  3949. not: function( selector ) {
  3950. return this.pushStack( winnow( this, selector || [], true ) );
  3951. },
  3952. is: function( selector ) {
  3953. return !!winnow(
  3954. this,
  3955. // If this is a positional/relative selector, check membership in the returned set
  3956. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  3957. typeof selector === "string" && rneedsContext.test( selector ) ?
  3958. jQuery( selector ) :
  3959. selector || [],
  3960. false
  3961. ).length;
  3962. }
  3963. } );
  3964. // Initialize a jQuery object
  3965. // A central reference to the root jQuery(document)
  3966. var rootjQuery,
  3967. // A simple way to check for HTML strings
  3968. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  3969. // Strict HTML recognition (#11290: must start with <)
  3970. // Shortcut simple #id case for speed
  3971. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  3972. init = jQuery.fn.init = function( selector, context, root ) {
  3973. var match, elem;
  3974. // HANDLE: $(""), $(null), $(undefined), $(false)
  3975. if ( !selector ) {
  3976. return this;
  3977. }
  3978. // Method init() accepts an alternate rootjQuery
  3979. // so migrate can support jQuery.sub (gh-2101)
  3980. root = root || rootjQuery;
  3981. // Handle HTML strings
  3982. if ( typeof selector === "string" ) {
  3983. if ( selector[ 0 ] === "<" &&
  3984. selector[ selector.length - 1 ] === ">" &&
  3985. selector.length >= 3 ) {
  3986. // Assume that strings that start and end with <> are HTML and skip the regex check
  3987. match = [ null, selector, null ];
  3988. } else {
  3989. match = rquickExpr.exec( selector );
  3990. }
  3991. // Match html or make sure no context is specified for #id
  3992. if ( match && ( match[ 1 ] || !context ) ) {
  3993. // HANDLE: $(html) -> $(array)
  3994. if ( match[ 1 ] ) {
  3995. context = context instanceof jQuery ? context[ 0 ] : context;
  3996. // Option to run scripts is true for back-compat
  3997. // Intentionally let the error be thrown if parseHTML is not present
  3998. jQuery.merge( this, jQuery.parseHTML(
  3999. match[ 1 ],
  4000. context && context.nodeType ? context.ownerDocument || context : document,
  4001. true
  4002. ) );
  4003. // HANDLE: $(html, props)
  4004. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  4005. for ( match in context ) {
  4006. // Properties of context are called as methods if possible
  4007. if ( isFunction( this[ match ] ) ) {
  4008. this[ match ]( context[ match ] );
  4009. // ...and otherwise set as attributes
  4010. } else {
  4011. this.attr( match, context[ match ] );
  4012. }
  4013. }
  4014. }
  4015. return this;
  4016. // HANDLE: $(#id)
  4017. } else {
  4018. elem = document.getElementById( match[ 2 ] );
  4019. if ( elem ) {
  4020. // Inject the element directly into the jQuery object
  4021. this[ 0 ] = elem;
  4022. this.length = 1;
  4023. }
  4024. return this;
  4025. }
  4026. // HANDLE: $(expr, $(...))
  4027. } else if ( !context || context.jquery ) {
  4028. return ( context || root ).find( selector );
  4029. // HANDLE: $(expr, context)
  4030. // (which is just equivalent to: $(context).find(expr)
  4031. } else {
  4032. return this.constructor( context ).find( selector );
  4033. }
  4034. // HANDLE: $(DOMElement)
  4035. } else if ( selector.nodeType ) {
  4036. this[ 0 ] = selector;
  4037. this.length = 1;
  4038. return this;
  4039. // HANDLE: $(function)
  4040. // Shortcut for document ready
  4041. } else if ( isFunction( selector ) ) {
  4042. return root.ready !== undefined ?
  4043. root.ready( selector ) :
  4044. // Execute immediately if ready is not present
  4045. selector( jQuery );
  4046. }
  4047. return jQuery.makeArray( selector, this );
  4048. };
  4049. // Give the init function the jQuery prototype for later instantiation
  4050. init.prototype = jQuery.fn;
  4051. // Initialize central reference
  4052. rootjQuery = jQuery( document );
  4053. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  4054. // Methods guaranteed to produce a unique set when starting from a unique set
  4055. guaranteedUnique = {
  4056. children: true,
  4057. contents: true,
  4058. next: true,
  4059. prev: true
  4060. };
  4061. jQuery.fn.extend( {
  4062. has: function( target ) {
  4063. var targets = jQuery( target, this ),
  4064. l = targets.length;
  4065. return this.filter( function() {
  4066. var i = 0;
  4067. for ( ; i < l; i++ ) {
  4068. if ( jQuery.contains( this, targets[ i ] ) ) {
  4069. return true;
  4070. }
  4071. }
  4072. } );
  4073. },
  4074. closest: function( selectors, context ) {
  4075. var cur,
  4076. i = 0,
  4077. l = this.length,
  4078. matched = [],
  4079. targets = typeof selectors !== "string" && jQuery( selectors );
  4080. // Positional selectors never match, since there's no _selection_ context
  4081. if ( !rneedsContext.test( selectors ) ) {
  4082. for ( ; i < l; i++ ) {
  4083. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  4084. // Always skip document fragments
  4085. if ( cur.nodeType < 11 && ( targets ?
  4086. targets.index( cur ) > -1 :
  4087. // Don't pass non-elements to Sizzle
  4088. cur.nodeType === 1 &&
  4089. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  4090. matched.push( cur );
  4091. break;
  4092. }
  4093. }
  4094. }
  4095. }
  4096. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  4097. },
  4098. // Determine the position of an element within the set
  4099. index: function( elem ) {
  4100. // No argument, return index in parent
  4101. if ( !elem ) {
  4102. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  4103. }
  4104. // Index in selector
  4105. if ( typeof elem === "string" ) {
  4106. return indexOf.call( jQuery( elem ), this[ 0 ] );
  4107. }
  4108. // Locate the position of the desired element
  4109. return indexOf.call( this,
  4110. // If it receives a jQuery object, the first element is used
  4111. elem.jquery ? elem[ 0 ] : elem
  4112. );
  4113. },
  4114. add: function( selector, context ) {
  4115. return this.pushStack(
  4116. jQuery.uniqueSort(
  4117. jQuery.merge( this.get(), jQuery( selector, context ) )
  4118. )
  4119. );
  4120. },
  4121. addBack: function( selector ) {
  4122. return this.add( selector == null ?
  4123. this.prevObject : this.prevObject.filter( selector )
  4124. );
  4125. }
  4126. } );
  4127. function sibling( cur, dir ) {
  4128. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  4129. return cur;
  4130. }
  4131. jQuery.each( {
  4132. parent: function( elem ) {
  4133. var parent = elem.parentNode;
  4134. return parent && parent.nodeType !== 11 ? parent : null;
  4135. },
  4136. parents: function( elem ) {
  4137. return dir( elem, "parentNode" );
  4138. },
  4139. parentsUntil: function( elem, i, until ) {
  4140. return dir( elem, "parentNode", until );
  4141. },
  4142. next: function( elem ) {
  4143. return sibling( elem, "nextSibling" );
  4144. },
  4145. prev: function( elem ) {
  4146. return sibling( elem, "previousSibling" );
  4147. },
  4148. nextAll: function( elem ) {
  4149. return dir( elem, "nextSibling" );
  4150. },
  4151. prevAll: function( elem ) {
  4152. return dir( elem, "previousSibling" );
  4153. },
  4154. nextUntil: function( elem, i, until ) {
  4155. return dir( elem, "nextSibling", until );
  4156. },
  4157. prevUntil: function( elem, i, until ) {
  4158. return dir( elem, "previousSibling", until );
  4159. },
  4160. siblings: function( elem ) {
  4161. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  4162. },
  4163. children: function( elem ) {
  4164. return siblings( elem.firstChild );
  4165. },
  4166. contents: function( elem ) {
  4167. if ( typeof elem.contentDocument !== "undefined" ) {
  4168. return elem.contentDocument;
  4169. }
  4170. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  4171. // Treat the template element as a regular one in browsers that
  4172. // don't support it.
  4173. if ( nodeName( elem, "template" ) ) {
  4174. elem = elem.content || elem;
  4175. }
  4176. return jQuery.merge( [], elem.childNodes );
  4177. }
  4178. }, function( name, fn ) {
  4179. jQuery.fn[ name ] = function( until, selector ) {
  4180. var matched = jQuery.map( this, fn, until );
  4181. if ( name.slice( -5 ) !== "Until" ) {
  4182. selector = until;
  4183. }
  4184. if ( selector && typeof selector === "string" ) {
  4185. matched = jQuery.filter( selector, matched );
  4186. }
  4187. if ( this.length > 1 ) {
  4188. // Remove duplicates
  4189. if ( !guaranteedUnique[ name ] ) {
  4190. jQuery.uniqueSort( matched );
  4191. }
  4192. // Reverse order for parents* and prev-derivatives
  4193. if ( rparentsprev.test( name ) ) {
  4194. matched.reverse();
  4195. }
  4196. }
  4197. return this.pushStack( matched );
  4198. };
  4199. } );
  4200. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  4201. // Convert String-formatted options into Object-formatted ones
  4202. function createOptions( options ) {
  4203. var object = {};
  4204. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  4205. object[ flag ] = true;
  4206. } );
  4207. return object;
  4208. }
  4209. /*
  4210. * Create a callback list using the following parameters:
  4211. *
  4212. * options: an optional list of space-separated options that will change how
  4213. * the callback list behaves or a more traditional option object
  4214. *
  4215. * By default a callback list will act like an event callback list and can be
  4216. * "fired" multiple times.
  4217. *
  4218. * Possible options:
  4219. *
  4220. * once: will ensure the callback list can only be fired once (like a Deferred)
  4221. *
  4222. * memory: will keep track of previous values and will call any callback added
  4223. * after the list has been fired right away with the latest "memorized"
  4224. * values (like a Deferred)
  4225. *
  4226. * unique: will ensure a callback can only be added once (no duplicate in the list)
  4227. *
  4228. * stopOnFalse: interrupt callings when a callback returns false
  4229. *
  4230. */
  4231. jQuery.Callbacks = function( options ) {
  4232. // Convert options from String-formatted to Object-formatted if needed
  4233. // (we check in cache first)
  4234. options = typeof options === "string" ?
  4235. createOptions( options ) :
  4236. jQuery.extend( {}, options );
  4237. var // Flag to know if list is currently firing
  4238. firing,
  4239. // Last fire value for non-forgettable lists
  4240. memory,
  4241. // Flag to know if list was already fired
  4242. fired,
  4243. // Flag to prevent firing
  4244. locked,
  4245. // Actual callback list
  4246. list = [],
  4247. // Queue of execution data for repeatable lists
  4248. queue = [],
  4249. // Index of currently firing callback (modified by add/remove as needed)
  4250. firingIndex = -1,
  4251. // Fire callbacks
  4252. fire = function() {
  4253. // Enforce single-firing
  4254. locked = locked || options.once;
  4255. // Execute callbacks for all pending executions,
  4256. // respecting firingIndex overrides and runtime changes
  4257. fired = firing = true;
  4258. for ( ; queue.length; firingIndex = -1 ) {
  4259. memory = queue.shift();
  4260. while ( ++firingIndex < list.length ) {
  4261. // Run callback and check for early termination
  4262. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  4263. options.stopOnFalse ) {
  4264. // Jump to end and forget the data so .add doesn't re-fire
  4265. firingIndex = list.length;
  4266. memory = false;
  4267. }
  4268. }
  4269. }
  4270. // Forget the data if we're done with it
  4271. if ( !options.memory ) {
  4272. memory = false;
  4273. }
  4274. firing = false;
  4275. // Clean up if we're done firing for good
  4276. if ( locked ) {
  4277. // Keep an empty list if we have data for future add calls
  4278. if ( memory ) {
  4279. list = [];
  4280. // Otherwise, this object is spent
  4281. } else {
  4282. list = "";
  4283. }
  4284. }
  4285. },
  4286. // Actual Callbacks object
  4287. self = {
  4288. // Add a callback or a collection of callbacks to the list
  4289. add: function() {
  4290. if ( list ) {
  4291. // If we have memory from a past run, we should fire after adding
  4292. if ( memory && !firing ) {
  4293. firingIndex = list.length - 1;
  4294. queue.push( memory );
  4295. }
  4296. ( function add( args ) {
  4297. jQuery.each( args, function( _, arg ) {
  4298. if ( isFunction( arg ) ) {
  4299. if ( !options.unique || !self.has( arg ) ) {
  4300. list.push( arg );
  4301. }
  4302. } else if ( arg && arg.length && toType( arg ) !== "string" ) {
  4303. // Inspect recursively
  4304. add( arg );
  4305. }
  4306. } );
  4307. } )( arguments );
  4308. if ( memory && !firing ) {
  4309. fire();
  4310. }
  4311. }
  4312. return this;
  4313. },
  4314. // Remove a callback from the list
  4315. remove: function() {
  4316. jQuery.each( arguments, function( _, arg ) {
  4317. var index;
  4318. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  4319. list.splice( index, 1 );
  4320. // Handle firing indexes
  4321. if ( index <= firingIndex ) {
  4322. firingIndex--;
  4323. }
  4324. }
  4325. } );
  4326. return this;
  4327. },
  4328. // Check if a given callback is in the list.
  4329. // If no argument is given, return whether or not list has callbacks attached.
  4330. has: function( fn ) {
  4331. return fn ?
  4332. jQuery.inArray( fn, list ) > -1 :
  4333. list.length > 0;
  4334. },
  4335. // Remove all callbacks from the list
  4336. empty: function() {
  4337. if ( list ) {
  4338. list = [];
  4339. }
  4340. return this;
  4341. },
  4342. // Disable .fire and .add
  4343. // Abort any current/pending executions
  4344. // Clear all callbacks and values
  4345. disable: function() {
  4346. locked = queue = [];
  4347. list = memory = "";
  4348. return this;
  4349. },
  4350. disabled: function() {
  4351. return !list;
  4352. },
  4353. // Disable .fire
  4354. // Also disable .add unless we have memory (since it would have no effect)
  4355. // Abort any pending executions
  4356. lock: function() {
  4357. locked = queue = [];
  4358. if ( !memory && !firing ) {
  4359. list = memory = "";
  4360. }
  4361. return this;
  4362. },
  4363. locked: function() {
  4364. return !!locked;
  4365. },
  4366. // Call all callbacks with the given context and arguments
  4367. fireWith: function( context, args ) {
  4368. if ( !locked ) {
  4369. args = args || [];
  4370. args = [ context, args.slice ? args.slice() : args ];
  4371. queue.push( args );
  4372. if ( !firing ) {
  4373. fire();
  4374. }
  4375. }
  4376. return this;
  4377. },
  4378. // Call all the callbacks with the given arguments
  4379. fire: function() {
  4380. self.fireWith( this, arguments );
  4381. return this;
  4382. },
  4383. // To know if the callbacks have already been called at least once
  4384. fired: function() {
  4385. return !!fired;
  4386. }
  4387. };
  4388. return self;
  4389. };
  4390. function Identity( v ) {
  4391. return v;
  4392. }
  4393. function Thrower( ex ) {
  4394. throw ex;
  4395. }
  4396. function adoptValue( value, resolve, reject, noValue ) {
  4397. var method;
  4398. try {
  4399. // Check for promise aspect first to privilege synchronous behavior
  4400. if ( value && isFunction( ( method = value.promise ) ) ) {
  4401. method.call( value ).done( resolve ).fail( reject );
  4402. // Other thenables
  4403. } else if ( value && isFunction( ( method = value.then ) ) ) {
  4404. method.call( value, resolve, reject );
  4405. // Other non-thenables
  4406. } else {
  4407. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  4408. // * false: [ value ].slice( 0 ) => resolve( value )
  4409. // * true: [ value ].slice( 1 ) => resolve()
  4410. resolve.apply( undefined, [ value ].slice( noValue ) );
  4411. }
  4412. // For Promises/A+, convert exceptions into rejections
  4413. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  4414. // Deferred#then to conditionally suppress rejection.
  4415. } catch ( value ) {
  4416. // Support: Android 4.0 only
  4417. // Strict mode functions invoked without .call/.apply get global-object context
  4418. reject.apply( undefined, [ value ] );
  4419. }
  4420. }
  4421. jQuery.extend( {
  4422. Deferred: function( func ) {
  4423. var tuples = [
  4424. // action, add listener, callbacks,
  4425. // ... .then handlers, argument index, [final state]
  4426. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  4427. jQuery.Callbacks( "memory" ), 2 ],
  4428. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  4429. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  4430. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  4431. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  4432. ],
  4433. state = "pending",
  4434. promise = {
  4435. state: function() {
  4436. return state;
  4437. },
  4438. always: function() {
  4439. deferred.done( arguments ).fail( arguments );
  4440. return this;
  4441. },
  4442. "catch": function( fn ) {
  4443. return promise.then( null, fn );
  4444. },
  4445. // Keep pipe for back-compat
  4446. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  4447. var fns = arguments;
  4448. return jQuery.Deferred( function( newDefer ) {
  4449. jQuery.each( tuples, function( i, tuple ) {
  4450. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  4451. var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  4452. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  4453. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  4454. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  4455. deferred[ tuple[ 1 ] ]( function() {
  4456. var returned = fn && fn.apply( this, arguments );
  4457. if ( returned && isFunction( returned.promise ) ) {
  4458. returned.promise()
  4459. .progress( newDefer.notify )
  4460. .done( newDefer.resolve )
  4461. .fail( newDefer.reject );
  4462. } else {
  4463. newDefer[ tuple[ 0 ] + "With" ](
  4464. this,
  4465. fn ? [ returned ] : arguments
  4466. );
  4467. }
  4468. } );
  4469. } );
  4470. fns = null;
  4471. } ).promise();
  4472. },
  4473. then: function( onFulfilled, onRejected, onProgress ) {
  4474. var maxDepth = 0;
  4475. function resolve( depth, deferred, handler, special ) {
  4476. return function() {
  4477. var that = this,
  4478. args = arguments,
  4479. mightThrow = function() {
  4480. var returned, then;
  4481. // Support: Promises/A+ section 2.3.3.3.3
  4482. // https://promisesaplus.com/#point-59
  4483. // Ignore double-resolution attempts
  4484. if ( depth < maxDepth ) {
  4485. return;
  4486. }
  4487. returned = handler.apply( that, args );
  4488. // Support: Promises/A+ section 2.3.1
  4489. // https://promisesaplus.com/#point-48
  4490. if ( returned === deferred.promise() ) {
  4491. throw new TypeError( "Thenable self-resolution" );
  4492. }
  4493. // Support: Promises/A+ sections 2.3.3.1, 3.5
  4494. // https://promisesaplus.com/#point-54
  4495. // https://promisesaplus.com/#point-75
  4496. // Retrieve `then` only once
  4497. then = returned &&
  4498. // Support: Promises/A+ section 2.3.4
  4499. // https://promisesaplus.com/#point-64
  4500. // Only check objects and functions for thenability
  4501. ( typeof returned === "object" ||
  4502. typeof returned === "function" ) &&
  4503. returned.then;
  4504. // Handle a returned thenable
  4505. if ( isFunction( then ) ) {
  4506. // Special processors (notify) just wait for resolution
  4507. if ( special ) {
  4508. then.call(
  4509. returned,
  4510. resolve( maxDepth, deferred, Identity, special ),
  4511. resolve( maxDepth, deferred, Thrower, special )
  4512. );
  4513. // Normal processors (resolve) also hook into progress
  4514. } else {
  4515. // ...and disregard older resolution values
  4516. maxDepth++;
  4517. then.call(
  4518. returned,
  4519. resolve( maxDepth, deferred, Identity, special ),
  4520. resolve( maxDepth, deferred, Thrower, special ),
  4521. resolve( maxDepth, deferred, Identity,
  4522. deferred.notifyWith )
  4523. );
  4524. }
  4525. // Handle all other returned values
  4526. } else {
  4527. // Only substitute handlers pass on context
  4528. // and multiple values (non-spec behavior)
  4529. if ( handler !== Identity ) {
  4530. that = undefined;
  4531. args = [ returned ];
  4532. }
  4533. // Process the value(s)
  4534. // Default process is resolve
  4535. ( special || deferred.resolveWith )( that, args );
  4536. }
  4537. },
  4538. // Only normal processors (resolve) catch and reject exceptions
  4539. process = special ?
  4540. mightThrow :
  4541. function() {
  4542. try {
  4543. mightThrow();
  4544. } catch ( e ) {
  4545. if ( jQuery.Deferred.exceptionHook ) {
  4546. jQuery.Deferred.exceptionHook( e,
  4547. process.stackTrace );
  4548. }
  4549. // Support: Promises/A+ section 2.3.3.3.4.1
  4550. // https://promisesaplus.com/#point-61
  4551. // Ignore post-resolution exceptions
  4552. if ( depth + 1 >= maxDepth ) {
  4553. // Only substitute handlers pass on context
  4554. // and multiple values (non-spec behavior)
  4555. if ( handler !== Thrower ) {
  4556. that = undefined;
  4557. args = [ e ];
  4558. }
  4559. deferred.rejectWith( that, args );
  4560. }
  4561. }
  4562. };
  4563. // Support: Promises/A+ section 2.3.3.3.1
  4564. // https://promisesaplus.com/#point-57
  4565. // Re-resolve promises immediately to dodge false rejection from
  4566. // subsequent errors
  4567. if ( depth ) {
  4568. process();
  4569. } else {
  4570. // Call an optional hook to record the stack, in case of exception
  4571. // since it's otherwise lost when execution goes async
  4572. if ( jQuery.Deferred.getStackHook ) {
  4573. process.stackTrace = jQuery.Deferred.getStackHook();
  4574. }
  4575. window.setTimeout( process );
  4576. }
  4577. };
  4578. }
  4579. return jQuery.Deferred( function( newDefer ) {
  4580. // progress_handlers.add( ... )
  4581. tuples[ 0 ][ 3 ].add(
  4582. resolve(
  4583. 0,
  4584. newDefer,
  4585. isFunction( onProgress ) ?
  4586. onProgress :
  4587. Identity,
  4588. newDefer.notifyWith
  4589. )
  4590. );
  4591. // fulfilled_handlers.add( ... )
  4592. tuples[ 1 ][ 3 ].add(
  4593. resolve(
  4594. 0,
  4595. newDefer,
  4596. isFunction( onFulfilled ) ?
  4597. onFulfilled :
  4598. Identity
  4599. )
  4600. );
  4601. // rejected_handlers.add( ... )
  4602. tuples[ 2 ][ 3 ].add(
  4603. resolve(
  4604. 0,
  4605. newDefer,
  4606. isFunction( onRejected ) ?
  4607. onRejected :
  4608. Thrower
  4609. )
  4610. );
  4611. } ).promise();
  4612. },
  4613. // Get a promise for this deferred
  4614. // If obj is provided, the promise aspect is added to the object
  4615. promise: function( obj ) {
  4616. return obj != null ? jQuery.extend( obj, promise ) : promise;
  4617. }
  4618. },
  4619. deferred = {};
  4620. // Add list-specific methods
  4621. jQuery.each( tuples, function( i, tuple ) {
  4622. var list = tuple[ 2 ],
  4623. stateString = tuple[ 5 ];
  4624. // promise.progress = list.add
  4625. // promise.done = list.add
  4626. // promise.fail = list.add
  4627. promise[ tuple[ 1 ] ] = list.add;
  4628. // Handle state
  4629. if ( stateString ) {
  4630. list.add(
  4631. function() {
  4632. // state = "resolved" (i.e., fulfilled)
  4633. // state = "rejected"
  4634. state = stateString;
  4635. },
  4636. // rejected_callbacks.disable
  4637. // fulfilled_callbacks.disable
  4638. tuples[ 3 - i ][ 2 ].disable,
  4639. // rejected_handlers.disable
  4640. // fulfilled_handlers.disable
  4641. tuples[ 3 - i ][ 3 ].disable,
  4642. // progress_callbacks.lock
  4643. tuples[ 0 ][ 2 ].lock,
  4644. // progress_handlers.lock
  4645. tuples[ 0 ][ 3 ].lock
  4646. );
  4647. }
  4648. // progress_handlers.fire
  4649. // fulfilled_handlers.fire
  4650. // rejected_handlers.fire
  4651. list.add( tuple[ 3 ].fire );
  4652. // deferred.notify = function() { deferred.notifyWith(...) }
  4653. // deferred.resolve = function() { deferred.resolveWith(...) }
  4654. // deferred.reject = function() { deferred.rejectWith(...) }
  4655. deferred[ tuple[ 0 ] ] = function() {
  4656. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  4657. return this;
  4658. };
  4659. // deferred.notifyWith = list.fireWith
  4660. // deferred.resolveWith = list.fireWith
  4661. // deferred.rejectWith = list.fireWith
  4662. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  4663. } );
  4664. // Make the deferred a promise
  4665. promise.promise( deferred );
  4666. // Call given func if any
  4667. if ( func ) {
  4668. func.call( deferred, deferred );
  4669. }
  4670. // All done!
  4671. return deferred;
  4672. },
  4673. // Deferred helper
  4674. when: function( singleValue ) {
  4675. var
  4676. // count of uncompleted subordinates
  4677. remaining = arguments.length,
  4678. // count of unprocessed arguments
  4679. i = remaining,
  4680. // subordinate fulfillment data
  4681. resolveContexts = Array( i ),
  4682. resolveValues = slice.call( arguments ),
  4683. // the master Deferred
  4684. master = jQuery.Deferred(),
  4685. // subordinate callback factory
  4686. updateFunc = function( i ) {
  4687. return function( value ) {
  4688. resolveContexts[ i ] = this;
  4689. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  4690. if ( !( --remaining ) ) {
  4691. master.resolveWith( resolveContexts, resolveValues );
  4692. }
  4693. };
  4694. };
  4695. // Single- and empty arguments are adopted like Promise.resolve
  4696. if ( remaining <= 1 ) {
  4697. adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
  4698. !remaining );
  4699. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  4700. if ( master.state() === "pending" ||
  4701. isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  4702. return master.then();
  4703. }
  4704. }
  4705. // Multiple arguments are aggregated like Promise.all array elements
  4706. while ( i-- ) {
  4707. adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
  4708. }
  4709. return master.promise();
  4710. }
  4711. } );
  4712. // These usually indicate a programmer mistake during development,
  4713. // warn about them ASAP rather than swallowing them by default.
  4714. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  4715. jQuery.Deferred.exceptionHook = function( error, stack ) {
  4716. // Support: IE 8 - 9 only
  4717. // Console exists when dev tools are open, which can happen at any time
  4718. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  4719. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  4720. }
  4721. };
  4722. jQuery.readyException = function( error ) {
  4723. window.setTimeout( function() {
  4724. throw error;
  4725. } );
  4726. };
  4727. // The deferred used on DOM ready
  4728. var readyList = jQuery.Deferred();
  4729. jQuery.fn.ready = function( fn ) {
  4730. readyList
  4731. .then( fn )
  4732. // Wrap jQuery.readyException in a function so that the lookup
  4733. // happens at the time of error handling instead of callback
  4734. // registration.
  4735. .catch( function( error ) {
  4736. jQuery.readyException( error );
  4737. } );
  4738. return this;
  4739. };
  4740. jQuery.extend( {
  4741. // Is the DOM ready to be used? Set to true once it occurs.
  4742. isReady: false,
  4743. // A counter to track how many items to wait for before
  4744. // the ready event fires. See #6781
  4745. readyWait: 1,
  4746. // Handle when the DOM is ready
  4747. ready: function( wait ) {
  4748. // Abort if there are pending holds or we're already ready
  4749. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  4750. return;
  4751. }
  4752. // Remember that the DOM is ready
  4753. jQuery.isReady = true;
  4754. // If a normal DOM Ready event fired, decrement, and wait if need be
  4755. if ( wait !== true && --jQuery.readyWait > 0 ) {
  4756. return;
  4757. }
  4758. // If there are functions bound, to execute
  4759. readyList.resolveWith( document, [ jQuery ] );
  4760. }
  4761. } );
  4762. jQuery.ready.then = readyList.then;
  4763. // The ready event handler and self cleanup method
  4764. function completed() {
  4765. document.removeEventListener( "DOMContentLoaded", completed );
  4766. window.removeEventListener( "load", completed );
  4767. jQuery.ready();
  4768. }
  4769. // Catch cases where $(document).ready() is called
  4770. // after the browser event has already occurred.
  4771. // Support: IE <=9 - 10 only
  4772. // Older IE sometimes signals "interactive" too soon
  4773. if ( document.readyState === "complete" ||
  4774. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  4775. // Handle it asynchronously to allow scripts the opportunity to delay ready
  4776. window.setTimeout( jQuery.ready );
  4777. } else {
  4778. // Use the handy event callback
  4779. document.addEventListener( "DOMContentLoaded", completed );
  4780. // A fallback to window.onload, that will always work
  4781. window.addEventListener( "load", completed );
  4782. }
  4783. // Multifunctional method to get and set values of a collection
  4784. // The value/s can optionally be executed if it's a function
  4785. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  4786. var i = 0,
  4787. len = elems.length,
  4788. bulk = key == null;
  4789. // Sets many values
  4790. if ( toType( key ) === "object" ) {
  4791. chainable = true;
  4792. for ( i in key ) {
  4793. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  4794. }
  4795. // Sets one value
  4796. } else if ( value !== undefined ) {
  4797. chainable = true;
  4798. if ( !isFunction( value ) ) {
  4799. raw = true;
  4800. }
  4801. if ( bulk ) {
  4802. // Bulk operations run against the entire set
  4803. if ( raw ) {
  4804. fn.call( elems, value );
  4805. fn = null;
  4806. // ...except when executing function values
  4807. } else {
  4808. bulk = fn;
  4809. fn = function( elem, key, value ) {
  4810. return bulk.call( jQuery( elem ), value );
  4811. };
  4812. }
  4813. }
  4814. if ( fn ) {
  4815. for ( ; i < len; i++ ) {
  4816. fn(
  4817. elems[ i ], key, raw ?
  4818. value :
  4819. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  4820. );
  4821. }
  4822. }
  4823. }
  4824. if ( chainable ) {
  4825. return elems;
  4826. }
  4827. // Gets
  4828. if ( bulk ) {
  4829. return fn.call( elems );
  4830. }
  4831. return len ? fn( elems[ 0 ], key ) : emptyGet;
  4832. };
  4833. // Matches dashed string for camelizing
  4834. var rmsPrefix = /^-ms-/,
  4835. rdashAlpha = /-([a-z])/g;
  4836. // Used by camelCase as callback to replace()
  4837. function fcamelCase( all, letter ) {
  4838. return letter.toUpperCase();
  4839. }
  4840. // Convert dashed to camelCase; used by the css and data modules
  4841. // Support: IE <=9 - 11, Edge 12 - 15
  4842. // Microsoft forgot to hump their vendor prefix (#9572)
  4843. function camelCase( string ) {
  4844. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  4845. }
  4846. var acceptData = function( owner ) {
  4847. // Accepts only:
  4848. // - Node
  4849. // - Node.ELEMENT_NODE
  4850. // - Node.DOCUMENT_NODE
  4851. // - Object
  4852. // - Any
  4853. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  4854. };
  4855. function Data() {
  4856. this.expando = jQuery.expando + Data.uid++;
  4857. }
  4858. Data.uid = 1;
  4859. Data.prototype = {
  4860. cache: function( owner ) {
  4861. // Check if the owner object already has a cache
  4862. var value = owner[ this.expando ];
  4863. // If not, create one
  4864. if ( !value ) {
  4865. value = {};
  4866. // We can accept data for non-element nodes in modern browsers,
  4867. // but we should not, see #8335.
  4868. // Always return an empty object.
  4869. if ( acceptData( owner ) ) {
  4870. // If it is a node unlikely to be stringify-ed or looped over
  4871. // use plain assignment
  4872. if ( owner.nodeType ) {
  4873. owner[ this.expando ] = value;
  4874. // Otherwise secure it in a non-enumerable property
  4875. // configurable must be true to allow the property to be
  4876. // deleted when data is removed
  4877. } else {
  4878. Object.defineProperty( owner, this.expando, {
  4879. value: value,
  4880. configurable: true
  4881. } );
  4882. }
  4883. }
  4884. }
  4885. return value;
  4886. },
  4887. set: function( owner, data, value ) {
  4888. var prop,
  4889. cache = this.cache( owner );
  4890. // Handle: [ owner, key, value ] args
  4891. // Always use camelCase key (gh-2257)
  4892. if ( typeof data === "string" ) {
  4893. cache[ camelCase( data ) ] = value;
  4894. // Handle: [ owner, { properties } ] args
  4895. } else {
  4896. // Copy the properties one-by-one to the cache object
  4897. for ( prop in data ) {
  4898. cache[ camelCase( prop ) ] = data[ prop ];
  4899. }
  4900. }
  4901. return cache;
  4902. },
  4903. get: function( owner, key ) {
  4904. return key === undefined ?
  4905. this.cache( owner ) :
  4906. // Always use camelCase key (gh-2257)
  4907. owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
  4908. },
  4909. access: function( owner, key, value ) {
  4910. // In cases where either:
  4911. //
  4912. // 1. No key was specified
  4913. // 2. A string key was specified, but no value provided
  4914. //
  4915. // Take the "read" path and allow the get method to determine
  4916. // which value to return, respectively either:
  4917. //
  4918. // 1. The entire cache object
  4919. // 2. The data stored at the key
  4920. //
  4921. if ( key === undefined ||
  4922. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  4923. return this.get( owner, key );
  4924. }
  4925. // When the key is not a string, or both a key and value
  4926. // are specified, set or extend (existing objects) with either:
  4927. //
  4928. // 1. An object of properties
  4929. // 2. A key and value
  4930. //
  4931. this.set( owner, key, value );
  4932. // Since the "set" path can have two possible entry points
  4933. // return the expected data based on which path was taken[*]
  4934. return value !== undefined ? value : key;
  4935. },
  4936. remove: function( owner, key ) {
  4937. var i,
  4938. cache = owner[ this.expando ];
  4939. if ( cache === undefined ) {
  4940. return;
  4941. }
  4942. if ( key !== undefined ) {
  4943. // Support array or space separated string of keys
  4944. if ( Array.isArray( key ) ) {
  4945. // If key is an array of keys...
  4946. // We always set camelCase keys, so remove that.
  4947. key = key.map( camelCase );
  4948. } else {
  4949. key = camelCase( key );
  4950. // If a key with the spaces exists, use it.
  4951. // Otherwise, create an array by matching non-whitespace
  4952. key = key in cache ?
  4953. [ key ] :
  4954. ( key.match( rnothtmlwhite ) || [] );
  4955. }
  4956. i = key.length;
  4957. while ( i-- ) {
  4958. delete cache[ key[ i ] ];
  4959. }
  4960. }
  4961. // Remove the expando if there's no more data
  4962. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  4963. // Support: Chrome <=35 - 45
  4964. // Webkit & Blink performance suffers when deleting properties
  4965. // from DOM nodes, so set to undefined instead
  4966. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  4967. if ( owner.nodeType ) {
  4968. owner[ this.expando ] = undefined;
  4969. } else {
  4970. delete owner[ this.expando ];
  4971. }
  4972. }
  4973. },
  4974. hasData: function( owner ) {
  4975. var cache = owner[ this.expando ];
  4976. return cache !== undefined && !jQuery.isEmptyObject( cache );
  4977. }
  4978. };
  4979. var dataPriv = new Data();
  4980. var dataUser = new Data();
  4981. // Implementation Summary
  4982. //
  4983. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  4984. // 2. Improve the module's maintainability by reducing the storage
  4985. // paths to a single mechanism.
  4986. // 3. Use the same single mechanism to support "private" and "user" data.
  4987. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  4988. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  4989. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  4990. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  4991. rmultiDash = /[A-Z]/g;
  4992. function getData( data ) {
  4993. if ( data === "true" ) {
  4994. return true;
  4995. }
  4996. if ( data === "false" ) {
  4997. return false;
  4998. }
  4999. if ( data === "null" ) {
  5000. return null;
  5001. }
  5002. // Only convert to a number if it doesn't change the string
  5003. if ( data === +data + "" ) {
  5004. return +data;
  5005. }
  5006. if ( rbrace.test( data ) ) {
  5007. return JSON.parse( data );
  5008. }
  5009. return data;
  5010. }
  5011. function dataAttr( elem, key, data ) {
  5012. var name;
  5013. // If nothing was found internally, try to fetch any
  5014. // data from the HTML5 data-* attribute
  5015. if ( data === undefined && elem.nodeType === 1 ) {
  5016. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  5017. data = elem.getAttribute( name );
  5018. if ( typeof data === "string" ) {
  5019. try {
  5020. data = getData( data );
  5021. } catch ( e ) {}
  5022. // Make sure we set the data so it isn't changed later
  5023. dataUser.set( elem, key, data );
  5024. } else {
  5025. data = undefined;
  5026. }
  5027. }
  5028. return data;
  5029. }
  5030. jQuery.extend( {
  5031. hasData: function( elem ) {
  5032. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  5033. },
  5034. data: function( elem, name, data ) {
  5035. return dataUser.access( elem, name, data );
  5036. },
  5037. removeData: function( elem, name ) {
  5038. dataUser.remove( elem, name );
  5039. },
  5040. // TODO: Now that all calls to _data and _removeData have been replaced
  5041. // with direct calls to dataPriv methods, these can be deprecated.
  5042. _data: function( elem, name, data ) {
  5043. return dataPriv.access( elem, name, data );
  5044. },
  5045. _removeData: function( elem, name ) {
  5046. dataPriv.remove( elem, name );
  5047. }
  5048. } );
  5049. jQuery.fn.extend( {
  5050. data: function( key, value ) {
  5051. var i, name, data,
  5052. elem = this[ 0 ],
  5053. attrs = elem && elem.attributes;
  5054. // Gets all values
  5055. if ( key === undefined ) {
  5056. if ( this.length ) {
  5057. data = dataUser.get( elem );
  5058. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  5059. i = attrs.length;
  5060. while ( i-- ) {
  5061. // Support: IE 11 only
  5062. // The attrs elements can be null (#14894)
  5063. if ( attrs[ i ] ) {
  5064. name = attrs[ i ].name;
  5065. if ( name.indexOf( "data-" ) === 0 ) {
  5066. name = camelCase( name.slice( 5 ) );
  5067. dataAttr( elem, name, data[ name ] );
  5068. }
  5069. }
  5070. }
  5071. dataPriv.set( elem, "hasDataAttrs", true );
  5072. }
  5073. }
  5074. return data;
  5075. }
  5076. // Sets multiple values
  5077. if ( typeof key === "object" ) {
  5078. return this.each( function() {
  5079. dataUser.set( this, key );
  5080. } );
  5081. }
  5082. return access( this, function( value ) {
  5083. var data;
  5084. // The calling jQuery object (element matches) is not empty
  5085. // (and therefore has an element appears at this[ 0 ]) and the
  5086. // `value` parameter was not undefined. An empty jQuery object
  5087. // will result in `undefined` for elem = this[ 0 ] which will
  5088. // throw an exception if an attempt to read a data cache is made.
  5089. if ( elem && value === undefined ) {
  5090. // Attempt to get data from the cache
  5091. // The key will always be camelCased in Data
  5092. data = dataUser.get( elem, key );
  5093. if ( data !== undefined ) {
  5094. return data;
  5095. }
  5096. // Attempt to "discover" the data in
  5097. // HTML5 custom data-* attrs
  5098. data = dataAttr( elem, key );
  5099. if ( data !== undefined ) {
  5100. return data;
  5101. }
  5102. // We tried really hard, but the data doesn't exist.
  5103. return;
  5104. }
  5105. // Set the data...
  5106. this.each( function() {
  5107. // We always store the camelCased key
  5108. dataUser.set( this, key, value );
  5109. } );
  5110. }, null, value, arguments.length > 1, null, true );
  5111. },
  5112. removeData: function( key ) {
  5113. return this.each( function() {
  5114. dataUser.remove( this, key );
  5115. } );
  5116. }
  5117. } );
  5118. jQuery.extend( {
  5119. queue: function( elem, type, data ) {
  5120. var queue;
  5121. if ( elem ) {
  5122. type = ( type || "fx" ) + "queue";
  5123. queue = dataPriv.get( elem, type );
  5124. // Speed up dequeue by getting out quickly if this is just a lookup
  5125. if ( data ) {
  5126. if ( !queue || Array.isArray( data ) ) {
  5127. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  5128. } else {
  5129. queue.push( data );
  5130. }
  5131. }
  5132. return queue || [];
  5133. }
  5134. },
  5135. dequeue: function( elem, type ) {
  5136. type = type || "fx";
  5137. var queue = jQuery.queue( elem, type ),
  5138. startLength = queue.length,
  5139. fn = queue.shift(),
  5140. hooks = jQuery._queueHooks( elem, type ),
  5141. next = function() {
  5142. jQuery.dequeue( elem, type );
  5143. };
  5144. // If the fx queue is dequeued, always remove the progress sentinel
  5145. if ( fn === "inprogress" ) {
  5146. fn = queue.shift();
  5147. startLength--;
  5148. }
  5149. if ( fn ) {
  5150. // Add a progress sentinel to prevent the fx queue from being
  5151. // automatically dequeued
  5152. if ( type === "fx" ) {
  5153. queue.unshift( "inprogress" );
  5154. }
  5155. // Clear up the last queue stop function
  5156. delete hooks.stop;
  5157. fn.call( elem, next, hooks );
  5158. }
  5159. if ( !startLength && hooks ) {
  5160. hooks.empty.fire();
  5161. }
  5162. },
  5163. // Not public - generate a queueHooks object, or return the current one
  5164. _queueHooks: function( elem, type ) {
  5165. var key = type + "queueHooks";
  5166. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  5167. empty: jQuery.Callbacks( "once memory" ).add( function() {
  5168. dataPriv.remove( elem, [ type + "queue", key ] );
  5169. } )
  5170. } );
  5171. }
  5172. } );
  5173. jQuery.fn.extend( {
  5174. queue: function( type, data ) {
  5175. var setter = 2;
  5176. if ( typeof type !== "string" ) {
  5177. data = type;
  5178. type = "fx";
  5179. setter--;
  5180. }
  5181. if ( arguments.length < setter ) {
  5182. return jQuery.queue( this[ 0 ], type );
  5183. }
  5184. return data === undefined ?
  5185. this :
  5186. this.each( function() {
  5187. var queue = jQuery.queue( this, type, data );
  5188. // Ensure a hooks for this queue
  5189. jQuery._queueHooks( this, type );
  5190. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  5191. jQuery.dequeue( this, type );
  5192. }
  5193. } );
  5194. },
  5195. dequeue: function( type ) {
  5196. return this.each( function() {
  5197. jQuery.dequeue( this, type );
  5198. } );
  5199. },
  5200. clearQueue: function( type ) {
  5201. return this.queue( type || "fx", [] );
  5202. },
  5203. // Get a promise resolved when queues of a certain type
  5204. // are emptied (fx is the type by default)
  5205. promise: function( type, obj ) {
  5206. var tmp,
  5207. count = 1,
  5208. defer = jQuery.Deferred(),
  5209. elements = this,
  5210. i = this.length,
  5211. resolve = function() {
  5212. if ( !( --count ) ) {
  5213. defer.resolveWith( elements, [ elements ] );
  5214. }
  5215. };
  5216. if ( typeof type !== "string" ) {
  5217. obj = type;
  5218. type = undefined;
  5219. }
  5220. type = type || "fx";
  5221. while ( i-- ) {
  5222. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  5223. if ( tmp && tmp.empty ) {
  5224. count++;
  5225. tmp.empty.add( resolve );
  5226. }
  5227. }
  5228. resolve();
  5229. return defer.promise( obj );
  5230. }
  5231. } );
  5232. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  5233. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  5234. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  5235. var documentElement = document.documentElement;
  5236. var isAttached = function( elem ) {
  5237. return jQuery.contains( elem.ownerDocument, elem );
  5238. },
  5239. composed = { composed: true };
  5240. // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
  5241. // Check attachment across shadow DOM boundaries when possible (gh-3504)
  5242. // Support: iOS 10.0-10.2 only
  5243. // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
  5244. // leading to errors. We need to check for `getRootNode`.
  5245. if ( documentElement.getRootNode ) {
  5246. isAttached = function( elem ) {
  5247. return jQuery.contains( elem.ownerDocument, elem ) ||
  5248. elem.getRootNode( composed ) === elem.ownerDocument;
  5249. };
  5250. }
  5251. var isHiddenWithinTree = function( elem, el ) {
  5252. // isHiddenWithinTree might be called from jQuery#filter function;
  5253. // in that case, element will be second argument
  5254. elem = el || elem;
  5255. // Inline style trumps all
  5256. return elem.style.display === "none" ||
  5257. elem.style.display === "" &&
  5258. // Otherwise, check computed style
  5259. // Support: Firefox <=43 - 45
  5260. // Disconnected elements can have computed display: none, so first confirm that elem is
  5261. // in the document.
  5262. isAttached( elem ) &&
  5263. jQuery.css( elem, "display" ) === "none";
  5264. };
  5265. var swap = function( elem, options, callback, args ) {
  5266. var ret, name,
  5267. old = {};
  5268. // Remember the old values, and insert the new ones
  5269. for ( name in options ) {
  5270. old[ name ] = elem.style[ name ];
  5271. elem.style[ name ] = options[ name ];
  5272. }
  5273. ret = callback.apply( elem, args || [] );
  5274. // Revert the old values
  5275. for ( name in options ) {
  5276. elem.style[ name ] = old[ name ];
  5277. }
  5278. return ret;
  5279. };
  5280. function adjustCSS( elem, prop, valueParts, tween ) {
  5281. var adjusted, scale,
  5282. maxIterations = 20,
  5283. currentValue = tween ?
  5284. function() {
  5285. return tween.cur();
  5286. } :
  5287. function() {
  5288. return jQuery.css( elem, prop, "" );
  5289. },
  5290. initial = currentValue(),
  5291. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  5292. // Starting value computation is required for potential unit mismatches
  5293. initialInUnit = elem.nodeType &&
  5294. ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  5295. rcssNum.exec( jQuery.css( elem, prop ) );
  5296. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  5297. // Support: Firefox <=54
  5298. // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
  5299. initial = initial / 2;
  5300. // Trust units reported by jQuery.css
  5301. unit = unit || initialInUnit[ 3 ];
  5302. // Iteratively approximate from a nonzero starting point
  5303. initialInUnit = +initial || 1;
  5304. while ( maxIterations-- ) {
  5305. // Evaluate and update our best guess (doubling guesses that zero out).
  5306. // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
  5307. jQuery.style( elem, prop, initialInUnit + unit );
  5308. if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
  5309. maxIterations = 0;
  5310. }
  5311. initialInUnit = initialInUnit / scale;
  5312. }
  5313. initialInUnit = initialInUnit * 2;
  5314. jQuery.style( elem, prop, initialInUnit + unit );
  5315. // Make sure we update the tween properties later on
  5316. valueParts = valueParts || [];
  5317. }
  5318. if ( valueParts ) {
  5319. initialInUnit = +initialInUnit || +initial || 0;
  5320. // Apply relative offset (+=/-=) if specified
  5321. adjusted = valueParts[ 1 ] ?
  5322. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  5323. +valueParts[ 2 ];
  5324. if ( tween ) {
  5325. tween.unit = unit;
  5326. tween.start = initialInUnit;
  5327. tween.end = adjusted;
  5328. }
  5329. }
  5330. return adjusted;
  5331. }
  5332. var defaultDisplayMap = {};
  5333. function getDefaultDisplay( elem ) {
  5334. var temp,
  5335. doc = elem.ownerDocument,
  5336. nodeName = elem.nodeName,
  5337. display = defaultDisplayMap[ nodeName ];
  5338. if ( display ) {
  5339. return display;
  5340. }
  5341. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  5342. display = jQuery.css( temp, "display" );
  5343. temp.parentNode.removeChild( temp );
  5344. if ( display === "none" ) {
  5345. display = "block";
  5346. }
  5347. defaultDisplayMap[ nodeName ] = display;
  5348. return display;
  5349. }
  5350. function showHide( elements, show ) {
  5351. var display, elem,
  5352. values = [],
  5353. index = 0,
  5354. length = elements.length;
  5355. // Determine new display value for elements that need to change
  5356. for ( ; index < length; index++ ) {
  5357. elem = elements[ index ];
  5358. if ( !elem.style ) {
  5359. continue;
  5360. }
  5361. display = elem.style.display;
  5362. if ( show ) {
  5363. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  5364. // check is required in this first loop unless we have a nonempty display value (either
  5365. // inline or about-to-be-restored)
  5366. if ( display === "none" ) {
  5367. values[ index ] = dataPriv.get( elem, "display" ) || null;
  5368. if ( !values[ index ] ) {
  5369. elem.style.display = "";
  5370. }
  5371. }
  5372. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  5373. values[ index ] = getDefaultDisplay( elem );
  5374. }
  5375. } else {
  5376. if ( display !== "none" ) {
  5377. values[ index ] = "none";
  5378. // Remember what we're overwriting
  5379. dataPriv.set( elem, "display", display );
  5380. }
  5381. }
  5382. }
  5383. // Set the display of the elements in a second loop to avoid constant reflow
  5384. for ( index = 0; index < length; index++ ) {
  5385. if ( values[ index ] != null ) {
  5386. elements[ index ].style.display = values[ index ];
  5387. }
  5388. }
  5389. return elements;
  5390. }
  5391. jQuery.fn.extend( {
  5392. show: function() {
  5393. return showHide( this, true );
  5394. },
  5395. hide: function() {
  5396. return showHide( this );
  5397. },
  5398. toggle: function( state ) {
  5399. if ( typeof state === "boolean" ) {
  5400. return state ? this.show() : this.hide();
  5401. }
  5402. return this.each( function() {
  5403. if ( isHiddenWithinTree( this ) ) {
  5404. jQuery( this ).show();
  5405. } else {
  5406. jQuery( this ).hide();
  5407. }
  5408. } );
  5409. }
  5410. } );
  5411. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  5412. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
  5413. var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
  5414. // We have to close these tags to support XHTML (#13200)
  5415. var wrapMap = {
  5416. // Support: IE <=9 only
  5417. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  5418. // XHTML parsers do not magically insert elements in the
  5419. // same way that tag soup parsers do. So we cannot shorten
  5420. // this by omitting <tbody> or other required elements.
  5421. thead: [ 1, "<table>", "</table>" ],
  5422. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  5423. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  5424. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  5425. _default: [ 0, "", "" ]
  5426. };
  5427. // Support: IE <=9 only
  5428. wrapMap.optgroup = wrapMap.option;
  5429. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  5430. wrapMap.th = wrapMap.td;
  5431. function getAll( context, tag ) {
  5432. // Support: IE <=9 - 11 only
  5433. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  5434. var ret;
  5435. if ( typeof context.getElementsByTagName !== "undefined" ) {
  5436. ret = context.getElementsByTagName( tag || "*" );
  5437. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  5438. ret = context.querySelectorAll( tag || "*" );
  5439. } else {
  5440. ret = [];
  5441. }
  5442. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  5443. return jQuery.merge( [ context ], ret );
  5444. }
  5445. return ret;
  5446. }
  5447. // Mark scripts as having already been evaluated
  5448. function setGlobalEval( elems, refElements ) {
  5449. var i = 0,
  5450. l = elems.length;
  5451. for ( ; i < l; i++ ) {
  5452. dataPriv.set(
  5453. elems[ i ],
  5454. "globalEval",
  5455. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  5456. );
  5457. }
  5458. }
  5459. var rhtml = /<|&#?\w+;/;
  5460. function buildFragment( elems, context, scripts, selection, ignored ) {
  5461. var elem, tmp, tag, wrap, attached, j,
  5462. fragment = context.createDocumentFragment(),
  5463. nodes = [],
  5464. i = 0,
  5465. l = elems.length;
  5466. for ( ; i < l; i++ ) {
  5467. elem = elems[ i ];
  5468. if ( elem || elem === 0 ) {
  5469. // Add nodes directly
  5470. if ( toType( elem ) === "object" ) {
  5471. // Support: Android <=4.0 only, PhantomJS 1 only
  5472. // push.apply(_, arraylike) throws on ancient WebKit
  5473. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  5474. // Convert non-html into a text node
  5475. } else if ( !rhtml.test( elem ) ) {
  5476. nodes.push( context.createTextNode( elem ) );
  5477. // Convert html into DOM nodes
  5478. } else {
  5479. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  5480. // Deserialize a standard representation
  5481. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  5482. wrap = wrapMap[ tag ] || wrapMap._default;
  5483. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  5484. // Descend through wrappers to the right content
  5485. j = wrap[ 0 ];
  5486. while ( j-- ) {
  5487. tmp = tmp.lastChild;
  5488. }
  5489. // Support: Android <=4.0 only, PhantomJS 1 only
  5490. // push.apply(_, arraylike) throws on ancient WebKit
  5491. jQuery.merge( nodes, tmp.childNodes );
  5492. // Remember the top-level container
  5493. tmp = fragment.firstChild;
  5494. // Ensure the created nodes are orphaned (#12392)
  5495. tmp.textContent = "";
  5496. }
  5497. }
  5498. }
  5499. // Remove wrapper from fragment
  5500. fragment.textContent = "";
  5501. i = 0;
  5502. while ( ( elem = nodes[ i++ ] ) ) {
  5503. // Skip elements already in the context collection (trac-4087)
  5504. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  5505. if ( ignored ) {
  5506. ignored.push( elem );
  5507. }
  5508. continue;
  5509. }
  5510. attached = isAttached( elem );
  5511. // Append to fragment
  5512. tmp = getAll( fragment.appendChild( elem ), "script" );
  5513. // Preserve script evaluation history
  5514. if ( attached ) {
  5515. setGlobalEval( tmp );
  5516. }
  5517. // Capture executables
  5518. if ( scripts ) {
  5519. j = 0;
  5520. while ( ( elem = tmp[ j++ ] ) ) {
  5521. if ( rscriptType.test( elem.type || "" ) ) {
  5522. scripts.push( elem );
  5523. }
  5524. }
  5525. }
  5526. }
  5527. return fragment;
  5528. }
  5529. ( function() {
  5530. var fragment = document.createDocumentFragment(),
  5531. div = fragment.appendChild( document.createElement( "div" ) ),
  5532. input = document.createElement( "input" );
  5533. // Support: Android 4.0 - 4.3 only
  5534. // Check state lost if the name is set (#11217)
  5535. // Support: Windows Web Apps (WWA)
  5536. // `name` and `type` must use .setAttribute for WWA (#14901)
  5537. input.setAttribute( "type", "radio" );
  5538. input.setAttribute( "checked", "checked" );
  5539. input.setAttribute( "name", "t" );
  5540. div.appendChild( input );
  5541. // Support: Android <=4.1 only
  5542. // Older WebKit doesn't clone checked state correctly in fragments
  5543. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  5544. // Support: IE <=11 only
  5545. // Make sure textarea (and checkbox) defaultValue is properly cloned
  5546. div.innerHTML = "<textarea>x</textarea>";
  5547. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  5548. } )();
  5549. var
  5550. rkeyEvent = /^key/,
  5551. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  5552. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  5553. function returnTrue() {
  5554. return true;
  5555. }
  5556. function returnFalse() {
  5557. return false;
  5558. }
  5559. // Support: IE <=9 - 11+
  5560. // focus() and blur() are asynchronous, except when they are no-op.
  5561. // So expect focus to be synchronous when the element is already active,
  5562. // and blur to be synchronous when the element is not already active.
  5563. // (focus and blur are always synchronous in other supported browsers,
  5564. // this just defines when we can count on it).
  5565. function expectSync( elem, type ) {
  5566. return ( elem === safeActiveElement() ) === ( type === "focus" );
  5567. }
  5568. // Support: IE <=9 only
  5569. // Accessing document.activeElement can throw unexpectedly
  5570. // https://bugs.jquery.com/ticket/13393
  5571. function safeActiveElement() {
  5572. try {
  5573. return document.activeElement;
  5574. } catch ( err ) { }
  5575. }
  5576. function on( elem, types, selector, data, fn, one ) {
  5577. var origFn, type;
  5578. // Types can be a map of types/handlers
  5579. if ( typeof types === "object" ) {
  5580. // ( types-Object, selector, data )
  5581. if ( typeof selector !== "string" ) {
  5582. // ( types-Object, data )
  5583. data = data || selector;
  5584. selector = undefined;
  5585. }
  5586. for ( type in types ) {
  5587. on( elem, type, selector, data, types[ type ], one );
  5588. }
  5589. return elem;
  5590. }
  5591. if ( data == null && fn == null ) {
  5592. // ( types, fn )
  5593. fn = selector;
  5594. data = selector = undefined;
  5595. } else if ( fn == null ) {
  5596. if ( typeof selector === "string" ) {
  5597. // ( types, selector, fn )
  5598. fn = data;
  5599. data = undefined;
  5600. } else {
  5601. // ( types, data, fn )
  5602. fn = data;
  5603. data = selector;
  5604. selector = undefined;
  5605. }
  5606. }
  5607. if ( fn === false ) {
  5608. fn = returnFalse;
  5609. } else if ( !fn ) {
  5610. return elem;
  5611. }
  5612. if ( one === 1 ) {
  5613. origFn = fn;
  5614. fn = function( event ) {
  5615. // Can use an empty set, since event contains the info
  5616. jQuery().off( event );
  5617. return origFn.apply( this, arguments );
  5618. };
  5619. // Use same guid so caller can remove using origFn
  5620. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  5621. }
  5622. return elem.each( function() {
  5623. jQuery.event.add( this, types, fn, data, selector );
  5624. } );
  5625. }
  5626. /*
  5627. * Helper functions for managing events -- not part of the public interface.
  5628. * Props to Dean Edwards' addEvent library for many of the ideas.
  5629. */
  5630. jQuery.event = {
  5631. global: {},
  5632. add: function( elem, types, handler, data, selector ) {
  5633. var handleObjIn, eventHandle, tmp,
  5634. events, t, handleObj,
  5635. special, handlers, type, namespaces, origType,
  5636. elemData = dataPriv.get( elem );
  5637. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  5638. if ( !elemData ) {
  5639. return;
  5640. }
  5641. // Caller can pass in an object of custom data in lieu of the handler
  5642. if ( handler.handler ) {
  5643. handleObjIn = handler;
  5644. handler = handleObjIn.handler;
  5645. selector = handleObjIn.selector;
  5646. }
  5647. // Ensure that invalid selectors throw exceptions at attach time
  5648. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  5649. if ( selector ) {
  5650. jQuery.find.matchesSelector( documentElement, selector );
  5651. }
  5652. // Make sure that the handler has a unique ID, used to find/remove it later
  5653. if ( !handler.guid ) {
  5654. handler.guid = jQuery.guid++;
  5655. }
  5656. // Init the element's event structure and main handler, if this is the first
  5657. if ( !( events = elemData.events ) ) {
  5658. events = elemData.events = {};
  5659. }
  5660. if ( !( eventHandle = elemData.handle ) ) {
  5661. eventHandle = elemData.handle = function( e ) {
  5662. // Discard the second event of a jQuery.event.trigger() and
  5663. // when an event is called after a page has unloaded
  5664. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  5665. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  5666. };
  5667. }
  5668. // Handle multiple events separated by a space
  5669. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  5670. t = types.length;
  5671. while ( t-- ) {
  5672. tmp = rtypenamespace.exec( types[ t ] ) || [];
  5673. type = origType = tmp[ 1 ];
  5674. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  5675. // There *must* be a type, no attaching namespace-only handlers
  5676. if ( !type ) {
  5677. continue;
  5678. }
  5679. // If event changes its type, use the special event handlers for the changed type
  5680. special = jQuery.event.special[ type ] || {};
  5681. // If selector defined, determine special event api type, otherwise given type
  5682. type = ( selector ? special.delegateType : special.bindType ) || type;
  5683. // Update special based on newly reset type
  5684. special = jQuery.event.special[ type ] || {};
  5685. // handleObj is passed to all event handlers
  5686. handleObj = jQuery.extend( {
  5687. type: type,
  5688. origType: origType,
  5689. data: data,
  5690. handler: handler,
  5691. guid: handler.guid,
  5692. selector: selector,
  5693. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  5694. namespace: namespaces.join( "." )
  5695. }, handleObjIn );
  5696. // Init the event handler queue if we're the first
  5697. if ( !( handlers = events[ type ] ) ) {
  5698. handlers = events[ type ] = [];
  5699. handlers.delegateCount = 0;
  5700. // Only use addEventListener if the special events handler returns false
  5701. if ( !special.setup ||
  5702. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  5703. if ( elem.addEventListener ) {
  5704. elem.addEventListener( type, eventHandle );
  5705. }
  5706. }
  5707. }
  5708. if ( special.add ) {
  5709. special.add.call( elem, handleObj );
  5710. if ( !handleObj.handler.guid ) {
  5711. handleObj.handler.guid = handler.guid;
  5712. }
  5713. }
  5714. // Add to the element's handler list, delegates in front
  5715. if ( selector ) {
  5716. handlers.splice( handlers.delegateCount++, 0, handleObj );
  5717. } else {
  5718. handlers.push( handleObj );
  5719. }
  5720. // Keep track of which events have ever been used, for event optimization
  5721. jQuery.event.global[ type ] = true;
  5722. }
  5723. },
  5724. // Detach an event or set of events from an element
  5725. remove: function( elem, types, handler, selector, mappedTypes ) {
  5726. var j, origCount, tmp,
  5727. events, t, handleObj,
  5728. special, handlers, type, namespaces, origType,
  5729. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  5730. if ( !elemData || !( events = elemData.events ) ) {
  5731. return;
  5732. }
  5733. // Once for each type.namespace in types; type may be omitted
  5734. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  5735. t = types.length;
  5736. while ( t-- ) {
  5737. tmp = rtypenamespace.exec( types[ t ] ) || [];
  5738. type = origType = tmp[ 1 ];
  5739. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  5740. // Unbind all events (on this namespace, if provided) for the element
  5741. if ( !type ) {
  5742. for ( type in events ) {
  5743. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  5744. }
  5745. continue;
  5746. }
  5747. special = jQuery.event.special[ type ] || {};
  5748. type = ( selector ? special.delegateType : special.bindType ) || type;
  5749. handlers = events[ type ] || [];
  5750. tmp = tmp[ 2 ] &&
  5751. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  5752. // Remove matching events
  5753. origCount = j = handlers.length;
  5754. while ( j-- ) {
  5755. handleObj = handlers[ j ];
  5756. if ( ( mappedTypes || origType === handleObj.origType ) &&
  5757. ( !handler || handler.guid === handleObj.guid ) &&
  5758. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  5759. ( !selector || selector === handleObj.selector ||
  5760. selector === "**" && handleObj.selector ) ) {
  5761. handlers.splice( j, 1 );
  5762. if ( handleObj.selector ) {
  5763. handlers.delegateCount--;
  5764. }
  5765. if ( special.remove ) {
  5766. special.remove.call( elem, handleObj );
  5767. }
  5768. }
  5769. }
  5770. // Remove generic event handler if we removed something and no more handlers exist
  5771. // (avoids potential for endless recursion during removal of special event handlers)
  5772. if ( origCount && !handlers.length ) {
  5773. if ( !special.teardown ||
  5774. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  5775. jQuery.removeEvent( elem, type, elemData.handle );
  5776. }
  5777. delete events[ type ];
  5778. }
  5779. }
  5780. // Remove data and the expando if it's no longer used
  5781. if ( jQuery.isEmptyObject( events ) ) {
  5782. dataPriv.remove( elem, "handle events" );
  5783. }
  5784. },
  5785. dispatch: function( nativeEvent ) {
  5786. // Make a writable jQuery.Event from the native event object
  5787. var event = jQuery.event.fix( nativeEvent );
  5788. var i, j, ret, matched, handleObj, handlerQueue,
  5789. args = new Array( arguments.length ),
  5790. handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
  5791. special = jQuery.event.special[ event.type ] || {};
  5792. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  5793. args[ 0 ] = event;
  5794. for ( i = 1; i < arguments.length; i++ ) {
  5795. args[ i ] = arguments[ i ];
  5796. }
  5797. event.delegateTarget = this;
  5798. // Call the preDispatch hook for the mapped type, and let it bail if desired
  5799. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  5800. return;
  5801. }
  5802. // Determine handlers
  5803. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  5804. // Run delegates first; they may want to stop propagation beneath us
  5805. i = 0;
  5806. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  5807. event.currentTarget = matched.elem;
  5808. j = 0;
  5809. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  5810. !event.isImmediatePropagationStopped() ) {
  5811. // If the event is namespaced, then each handler is only invoked if it is
  5812. // specially universal or its namespaces are a superset of the event's.
  5813. if ( !event.rnamespace || handleObj.namespace === false ||
  5814. event.rnamespace.test( handleObj.namespace ) ) {
  5815. event.handleObj = handleObj;
  5816. event.data = handleObj.data;
  5817. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  5818. handleObj.handler ).apply( matched.elem, args );
  5819. if ( ret !== undefined ) {
  5820. if ( ( event.result = ret ) === false ) {
  5821. event.preventDefault();
  5822. event.stopPropagation();
  5823. }
  5824. }
  5825. }
  5826. }
  5827. }
  5828. // Call the postDispatch hook for the mapped type
  5829. if ( special.postDispatch ) {
  5830. special.postDispatch.call( this, event );
  5831. }
  5832. return event.result;
  5833. },
  5834. handlers: function( event, handlers ) {
  5835. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  5836. handlerQueue = [],
  5837. delegateCount = handlers.delegateCount,
  5838. cur = event.target;
  5839. // Find delegate handlers
  5840. if ( delegateCount &&
  5841. // Support: IE <=9
  5842. // Black-hole SVG <use> instance trees (trac-13180)
  5843. cur.nodeType &&
  5844. // Support: Firefox <=42
  5845. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  5846. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  5847. // Support: IE 11 only
  5848. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  5849. !( event.type === "click" && event.button >= 1 ) ) {
  5850. for ( ; cur !== this; cur = cur.parentNode || this ) {
  5851. // Don't check non-elements (#13208)
  5852. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  5853. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  5854. matchedHandlers = [];
  5855. matchedSelectors = {};
  5856. for ( i = 0; i < delegateCount; i++ ) {
  5857. handleObj = handlers[ i ];
  5858. // Don't conflict with Object.prototype properties (#13203)
  5859. sel = handleObj.selector + " ";
  5860. if ( matchedSelectors[ sel ] === undefined ) {
  5861. matchedSelectors[ sel ] = handleObj.needsContext ?
  5862. jQuery( sel, this ).index( cur ) > -1 :
  5863. jQuery.find( sel, this, null, [ cur ] ).length;
  5864. }
  5865. if ( matchedSelectors[ sel ] ) {
  5866. matchedHandlers.push( handleObj );
  5867. }
  5868. }
  5869. if ( matchedHandlers.length ) {
  5870. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  5871. }
  5872. }
  5873. }
  5874. }
  5875. // Add the remaining (directly-bound) handlers
  5876. cur = this;
  5877. if ( delegateCount < handlers.length ) {
  5878. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  5879. }
  5880. return handlerQueue;
  5881. },
  5882. addProp: function( name, hook ) {
  5883. Object.defineProperty( jQuery.Event.prototype, name, {
  5884. enumerable: true,
  5885. configurable: true,
  5886. get: isFunction( hook ) ?
  5887. function() {
  5888. if ( this.originalEvent ) {
  5889. return hook( this.originalEvent );
  5890. }
  5891. } :
  5892. function() {
  5893. if ( this.originalEvent ) {
  5894. return this.originalEvent[ name ];
  5895. }
  5896. },
  5897. set: function( value ) {
  5898. Object.defineProperty( this, name, {
  5899. enumerable: true,
  5900. configurable: true,
  5901. writable: true,
  5902. value: value
  5903. } );
  5904. }
  5905. } );
  5906. },
  5907. fix: function( originalEvent ) {
  5908. return originalEvent[ jQuery.expando ] ?
  5909. originalEvent :
  5910. new jQuery.Event( originalEvent );
  5911. },
  5912. special: {
  5913. load: {
  5914. // Prevent triggered image.load events from bubbling to window.load
  5915. noBubble: true
  5916. },
  5917. click: {
  5918. // Utilize native event to ensure correct state for checkable inputs
  5919. setup: function( data ) {
  5920. // For mutual compressibility with _default, replace `this` access with a local var.
  5921. // `|| data` is dead code meant only to preserve the variable through minification.
  5922. var el = this || data;
  5923. // Claim the first handler
  5924. if ( rcheckableType.test( el.type ) &&
  5925. el.click && nodeName( el, "input" ) ) {
  5926. // dataPriv.set( el, "click", ... )
  5927. leverageNative( el, "click", returnTrue );
  5928. }
  5929. // Return false to allow normal processing in the caller
  5930. return false;
  5931. },
  5932. trigger: function( data ) {
  5933. // For mutual compressibility with _default, replace `this` access with a local var.
  5934. // `|| data` is dead code meant only to preserve the variable through minification.
  5935. var el = this || data;
  5936. // Force setup before triggering a click
  5937. if ( rcheckableType.test( el.type ) &&
  5938. el.click && nodeName( el, "input" ) ) {
  5939. leverageNative( el, "click" );
  5940. }
  5941. // Return non-false to allow normal event-path propagation
  5942. return true;
  5943. },
  5944. // For cross-browser consistency, suppress native .click() on links
  5945. // Also prevent it if we're currently inside a leveraged native-event stack
  5946. _default: function( event ) {
  5947. var target = event.target;
  5948. return rcheckableType.test( target.type ) &&
  5949. target.click && nodeName( target, "input" ) &&
  5950. dataPriv.get( target, "click" ) ||
  5951. nodeName( target, "a" );
  5952. }
  5953. },
  5954. beforeunload: {
  5955. postDispatch: function( event ) {
  5956. // Support: Firefox 20+
  5957. // Firefox doesn't alert if the returnValue field is not set.
  5958. if ( event.result !== undefined && event.originalEvent ) {
  5959. event.originalEvent.returnValue = event.result;
  5960. }
  5961. }
  5962. }
  5963. }
  5964. };
  5965. // Ensure the presence of an event listener that handles manually-triggered
  5966. // synthetic events by interrupting progress until reinvoked in response to
  5967. // *native* events that it fires directly, ensuring that state changes have
  5968. // already occurred before other listeners are invoked.
  5969. function leverageNative( el, type, expectSync ) {
  5970. // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
  5971. if ( !expectSync ) {
  5972. if ( dataPriv.get( el, type ) === undefined ) {
  5973. jQuery.event.add( el, type, returnTrue );
  5974. }
  5975. return;
  5976. }
  5977. // Register the controller as a special universal handler for all event namespaces
  5978. dataPriv.set( el, type, false );
  5979. jQuery.event.add( el, type, {
  5980. namespace: false,
  5981. handler: function( event ) {
  5982. var notAsync, result,
  5983. saved = dataPriv.get( this, type );
  5984. if ( ( event.isTrigger & 1 ) && this[ type ] ) {
  5985. // Interrupt processing of the outer synthetic .trigger()ed event
  5986. // Saved data should be false in such cases, but might be a leftover capture object
  5987. // from an async native handler (gh-4350)
  5988. if ( !saved.length ) {
  5989. // Store arguments for use when handling the inner native event
  5990. // There will always be at least one argument (an event object), so this array
  5991. // will not be confused with a leftover capture object.
  5992. saved = slice.call( arguments );
  5993. dataPriv.set( this, type, saved );
  5994. // Trigger the native event and capture its result
  5995. // Support: IE <=9 - 11+
  5996. // focus() and blur() are asynchronous
  5997. notAsync = expectSync( this, type );
  5998. this[ type ]();
  5999. result = dataPriv.get( this, type );
  6000. if ( saved !== result || notAsync ) {
  6001. dataPriv.set( this, type, false );
  6002. } else {
  6003. result = {};
  6004. }
  6005. if ( saved !== result ) {
  6006. // Cancel the outer synthetic event
  6007. event.stopImmediatePropagation();
  6008. event.preventDefault();
  6009. return result.value;
  6010. }
  6011. // If this is an inner synthetic event for an event with a bubbling surrogate
  6012. // (focus or blur), assume that the surrogate already propagated from triggering the
  6013. // native event and prevent that from happening again here.
  6014. // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
  6015. // bubbling surrogate propagates *after* the non-bubbling base), but that seems
  6016. // less bad than duplication.
  6017. } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
  6018. event.stopPropagation();
  6019. }
  6020. // If this is a native event triggered above, everything is now in order
  6021. // Fire an inner synthetic event with the original arguments
  6022. } else if ( saved.length ) {
  6023. // ...and capture the result
  6024. dataPriv.set( this, type, {
  6025. value: jQuery.event.trigger(
  6026. // Support: IE <=9 - 11+
  6027. // Extend with the prototype to reset the above stopImmediatePropagation()
  6028. jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
  6029. saved.slice( 1 ),
  6030. this
  6031. )
  6032. } );
  6033. // Abort handling of the native event
  6034. event.stopImmediatePropagation();
  6035. }
  6036. }
  6037. } );
  6038. }
  6039. jQuery.removeEvent = function( elem, type, handle ) {
  6040. // This "if" is needed for plain objects
  6041. if ( elem.removeEventListener ) {
  6042. elem.removeEventListener( type, handle );
  6043. }
  6044. };
  6045. jQuery.Event = function( src, props ) {
  6046. // Allow instantiation without the 'new' keyword
  6047. if ( !( this instanceof jQuery.Event ) ) {
  6048. return new jQuery.Event( src, props );
  6049. }
  6050. // Event object
  6051. if ( src && src.type ) {
  6052. this.originalEvent = src;
  6053. this.type = src.type;
  6054. // Events bubbling up the document may have been marked as prevented
  6055. // by a handler lower down the tree; reflect the correct value.
  6056. this.isDefaultPrevented = src.defaultPrevented ||
  6057. src.defaultPrevented === undefined &&
  6058. // Support: Android <=2.3 only
  6059. src.returnValue === false ?
  6060. returnTrue :
  6061. returnFalse;
  6062. // Create target properties
  6063. // Support: Safari <=6 - 7 only
  6064. // Target should not be a text node (#504, #13143)
  6065. this.target = ( src.target && src.target.nodeType === 3 ) ?
  6066. src.target.parentNode :
  6067. src.target;
  6068. this.currentTarget = src.currentTarget;
  6069. this.relatedTarget = src.relatedTarget;
  6070. // Event type
  6071. } else {
  6072. this.type = src;
  6073. }
  6074. // Put explicitly provided properties onto the event object
  6075. if ( props ) {
  6076. jQuery.extend( this, props );
  6077. }
  6078. // Create a timestamp if incoming event doesn't have one
  6079. this.timeStamp = src && src.timeStamp || Date.now();
  6080. // Mark it as fixed
  6081. this[ jQuery.expando ] = true;
  6082. };
  6083. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  6084. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  6085. jQuery.Event.prototype = {
  6086. constructor: jQuery.Event,
  6087. isDefaultPrevented: returnFalse,
  6088. isPropagationStopped: returnFalse,
  6089. isImmediatePropagationStopped: returnFalse,
  6090. isSimulated: false,
  6091. preventDefault: function() {
  6092. var e = this.originalEvent;
  6093. this.isDefaultPrevented = returnTrue;
  6094. if ( e && !this.isSimulated ) {
  6095. e.preventDefault();
  6096. }
  6097. },
  6098. stopPropagation: function() {
  6099. var e = this.originalEvent;
  6100. this.isPropagationStopped = returnTrue;
  6101. if ( e && !this.isSimulated ) {
  6102. e.stopPropagation();
  6103. }
  6104. },
  6105. stopImmediatePropagation: function() {
  6106. var e = this.originalEvent;
  6107. this.isImmediatePropagationStopped = returnTrue;
  6108. if ( e && !this.isSimulated ) {
  6109. e.stopImmediatePropagation();
  6110. }
  6111. this.stopPropagation();
  6112. }
  6113. };
  6114. // Includes all common event props including KeyEvent and MouseEvent specific props
  6115. jQuery.each( {
  6116. altKey: true,
  6117. bubbles: true,
  6118. cancelable: true,
  6119. changedTouches: true,
  6120. ctrlKey: true,
  6121. detail: true,
  6122. eventPhase: true,
  6123. metaKey: true,
  6124. pageX: true,
  6125. pageY: true,
  6126. shiftKey: true,
  6127. view: true,
  6128. "char": true,
  6129. code: true,
  6130. charCode: true,
  6131. key: true,
  6132. keyCode: true,
  6133. button: true,
  6134. buttons: true,
  6135. clientX: true,
  6136. clientY: true,
  6137. offsetX: true,
  6138. offsetY: true,
  6139. pointerId: true,
  6140. pointerType: true,
  6141. screenX: true,
  6142. screenY: true,
  6143. targetTouches: true,
  6144. toElement: true,
  6145. touches: true,
  6146. which: function( event ) {
  6147. var button = event.button;
  6148. // Add which for key events
  6149. if ( event.which == null && rkeyEvent.test( event.type ) ) {
  6150. return event.charCode != null ? event.charCode : event.keyCode;
  6151. }
  6152. // Add which for click: 1 === left; 2 === middle; 3 === right
  6153. if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  6154. if ( button & 1 ) {
  6155. return 1;
  6156. }
  6157. if ( button & 2 ) {
  6158. return 3;
  6159. }
  6160. if ( button & 4 ) {
  6161. return 2;
  6162. }
  6163. return 0;
  6164. }
  6165. return event.which;
  6166. }
  6167. }, jQuery.event.addProp );
  6168. jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
  6169. jQuery.event.special[ type ] = {
  6170. // Utilize native event if possible so blur/focus sequence is correct
  6171. setup: function() {
  6172. // Claim the first handler
  6173. // dataPriv.set( this, "focus", ... )
  6174. // dataPriv.set( this, "blur", ... )
  6175. leverageNative( this, type, expectSync );
  6176. // Return false to allow normal processing in the caller
  6177. return false;
  6178. },
  6179. trigger: function() {
  6180. // Force setup before trigger
  6181. leverageNative( this, type );
  6182. // Return non-false to allow normal event-path propagation
  6183. return true;
  6184. },
  6185. delegateType: delegateType
  6186. };
  6187. } );
  6188. // Create mouseenter/leave events using mouseover/out and event-time checks
  6189. // so that event delegation works in jQuery.
  6190. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  6191. //
  6192. // Support: Safari 7 only
  6193. // Safari sends mouseenter too often; see:
  6194. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  6195. // for the description of the bug (it existed in older Chrome versions as well).
  6196. jQuery.each( {
  6197. mouseenter: "mouseover",
  6198. mouseleave: "mouseout",
  6199. pointerenter: "pointerover",
  6200. pointerleave: "pointerout"
  6201. }, function( orig, fix ) {
  6202. jQuery.event.special[ orig ] = {
  6203. delegateType: fix,
  6204. bindType: fix,
  6205. handle: function( event ) {
  6206. var ret,
  6207. target = this,
  6208. related = event.relatedTarget,
  6209. handleObj = event.handleObj;
  6210. // For mouseenter/leave call the handler if related is outside the target.
  6211. // NB: No relatedTarget if the mouse left/entered the browser window
  6212. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  6213. event.type = handleObj.origType;
  6214. ret = handleObj.handler.apply( this, arguments );
  6215. event.type = fix;
  6216. }
  6217. return ret;
  6218. }
  6219. };
  6220. } );
  6221. jQuery.fn.extend( {
  6222. on: function( types, selector, data, fn ) {
  6223. return on( this, types, selector, data, fn );
  6224. },
  6225. one: function( types, selector, data, fn ) {
  6226. return on( this, types, selector, data, fn, 1 );
  6227. },
  6228. off: function( types, selector, fn ) {
  6229. var handleObj, type;
  6230. if ( types && types.preventDefault && types.handleObj ) {
  6231. // ( event ) dispatched jQuery.Event
  6232. handleObj = types.handleObj;
  6233. jQuery( types.delegateTarget ).off(
  6234. handleObj.namespace ?
  6235. handleObj.origType + "." + handleObj.namespace :
  6236. handleObj.origType,
  6237. handleObj.selector,
  6238. handleObj.handler
  6239. );
  6240. return this;
  6241. }
  6242. if ( typeof types === "object" ) {
  6243. // ( types-object [, selector] )
  6244. for ( type in types ) {
  6245. this.off( type, selector, types[ type ] );
  6246. }
  6247. return this;
  6248. }
  6249. if ( selector === false || typeof selector === "function" ) {
  6250. // ( types [, fn] )
  6251. fn = selector;
  6252. selector = undefined;
  6253. }
  6254. if ( fn === false ) {
  6255. fn = returnFalse;
  6256. }
  6257. return this.each( function() {
  6258. jQuery.event.remove( this, types, fn, selector );
  6259. } );
  6260. }
  6261. } );
  6262. var
  6263. /* eslint-disable max-len */
  6264. // See https://github.com/eslint/eslint/issues/3229
  6265. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
  6266. /* eslint-enable */
  6267. // Support: IE <=10 - 11, Edge 12 - 13 only
  6268. // In IE/Edge using regex groups here causes severe slowdowns.
  6269. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  6270. rnoInnerhtml = /<script|<style|<link/i,
  6271. // checked="checked" or checked
  6272. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  6273. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  6274. // Prefer a tbody over its parent table for containing new rows
  6275. function manipulationTarget( elem, content ) {
  6276. if ( nodeName( elem, "table" ) &&
  6277. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  6278. return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
  6279. }
  6280. return elem;
  6281. }
  6282. // Replace/restore the type attribute of script elements for safe DOM manipulation
  6283. function disableScript( elem ) {
  6284. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  6285. return elem;
  6286. }
  6287. function restoreScript( elem ) {
  6288. if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
  6289. elem.type = elem.type.slice( 5 );
  6290. } else {
  6291. elem.removeAttribute( "type" );
  6292. }
  6293. return elem;
  6294. }
  6295. function cloneCopyEvent( src, dest ) {
  6296. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  6297. if ( dest.nodeType !== 1 ) {
  6298. return;
  6299. }
  6300. // 1. Copy private data: events, handlers, etc.
  6301. if ( dataPriv.hasData( src ) ) {
  6302. pdataOld = dataPriv.access( src );
  6303. pdataCur = dataPriv.set( dest, pdataOld );
  6304. events = pdataOld.events;
  6305. if ( events ) {
  6306. delete pdataCur.handle;
  6307. pdataCur.events = {};
  6308. for ( type in events ) {
  6309. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  6310. jQuery.event.add( dest, type, events[ type ][ i ] );
  6311. }
  6312. }
  6313. }
  6314. }
  6315. // 2. Copy user data
  6316. if ( dataUser.hasData( src ) ) {
  6317. udataOld = dataUser.access( src );
  6318. udataCur = jQuery.extend( {}, udataOld );
  6319. dataUser.set( dest, udataCur );
  6320. }
  6321. }
  6322. // Fix IE bugs, see support tests
  6323. function fixInput( src, dest ) {
  6324. var nodeName = dest.nodeName.toLowerCase();
  6325. // Fails to persist the checked state of a cloned checkbox or radio button.
  6326. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  6327. dest.checked = src.checked;
  6328. // Fails to return the selected option to the default selected state when cloning options
  6329. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  6330. dest.defaultValue = src.defaultValue;
  6331. }
  6332. }
  6333. function domManip( collection, args, callback, ignored ) {
  6334. // Flatten any nested arrays
  6335. args = concat.apply( [], args );
  6336. var fragment, first, scripts, hasScripts, node, doc,
  6337. i = 0,
  6338. l = collection.length,
  6339. iNoClone = l - 1,
  6340. value = args[ 0 ],
  6341. valueIsFunction = isFunction( value );
  6342. // We can't cloneNode fragments that contain checked, in WebKit
  6343. if ( valueIsFunction ||
  6344. ( l > 1 && typeof value === "string" &&
  6345. !support.checkClone && rchecked.test( value ) ) ) {
  6346. return collection.each( function( index ) {
  6347. var self = collection.eq( index );
  6348. if ( valueIsFunction ) {
  6349. args[ 0 ] = value.call( this, index, self.html() );
  6350. }
  6351. domManip( self, args, callback, ignored );
  6352. } );
  6353. }
  6354. if ( l ) {
  6355. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  6356. first = fragment.firstChild;
  6357. if ( fragment.childNodes.length === 1 ) {
  6358. fragment = first;
  6359. }
  6360. // Require either new content or an interest in ignored elements to invoke the callback
  6361. if ( first || ignored ) {
  6362. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  6363. hasScripts = scripts.length;
  6364. // Use the original fragment for the last item
  6365. // instead of the first because it can end up
  6366. // being emptied incorrectly in certain situations (#8070).
  6367. for ( ; i < l; i++ ) {
  6368. node = fragment;
  6369. if ( i !== iNoClone ) {
  6370. node = jQuery.clone( node, true, true );
  6371. // Keep references to cloned scripts for later restoration
  6372. if ( hasScripts ) {
  6373. // Support: Android <=4.0 only, PhantomJS 1 only
  6374. // push.apply(_, arraylike) throws on ancient WebKit
  6375. jQuery.merge( scripts, getAll( node, "script" ) );
  6376. }
  6377. }
  6378. callback.call( collection[ i ], node, i );
  6379. }
  6380. if ( hasScripts ) {
  6381. doc = scripts[ scripts.length - 1 ].ownerDocument;
  6382. // Reenable scripts
  6383. jQuery.map( scripts, restoreScript );
  6384. // Evaluate executable scripts on first document insertion
  6385. for ( i = 0; i < hasScripts; i++ ) {
  6386. node = scripts[ i ];
  6387. if ( rscriptType.test( node.type || "" ) &&
  6388. !dataPriv.access( node, "globalEval" ) &&
  6389. jQuery.contains( doc, node ) ) {
  6390. if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
  6391. // Optional AJAX dependency, but won't run scripts if not present
  6392. if ( jQuery._evalUrl && !node.noModule ) {
  6393. jQuery._evalUrl( node.src, {
  6394. nonce: node.nonce || node.getAttribute( "nonce" )
  6395. } );
  6396. }
  6397. } else {
  6398. DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
  6399. }
  6400. }
  6401. }
  6402. }
  6403. }
  6404. }
  6405. return collection;
  6406. }
  6407. function remove( elem, selector, keepData ) {
  6408. var node,
  6409. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  6410. i = 0;
  6411. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  6412. if ( !keepData && node.nodeType === 1 ) {
  6413. jQuery.cleanData( getAll( node ) );
  6414. }
  6415. if ( node.parentNode ) {
  6416. if ( keepData && isAttached( node ) ) {
  6417. setGlobalEval( getAll( node, "script" ) );
  6418. }
  6419. node.parentNode.removeChild( node );
  6420. }
  6421. }
  6422. return elem;
  6423. }
  6424. jQuery.extend( {
  6425. htmlPrefilter: function( html ) {
  6426. return html.replace( rxhtmlTag, "<$1></$2>" );
  6427. },
  6428. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  6429. var i, l, srcElements, destElements,
  6430. clone = elem.cloneNode( true ),
  6431. inPage = isAttached( elem );
  6432. // Fix IE cloning issues
  6433. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  6434. !jQuery.isXMLDoc( elem ) ) {
  6435. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  6436. destElements = getAll( clone );
  6437. srcElements = getAll( elem );
  6438. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  6439. fixInput( srcElements[ i ], destElements[ i ] );
  6440. }
  6441. }
  6442. // Copy the events from the original to the clone
  6443. if ( dataAndEvents ) {
  6444. if ( deepDataAndEvents ) {
  6445. srcElements = srcElements || getAll( elem );
  6446. destElements = destElements || getAll( clone );
  6447. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  6448. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  6449. }
  6450. } else {
  6451. cloneCopyEvent( elem, clone );
  6452. }
  6453. }
  6454. // Preserve script evaluation history
  6455. destElements = getAll( clone, "script" );
  6456. if ( destElements.length > 0 ) {
  6457. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  6458. }
  6459. // Return the cloned set
  6460. return clone;
  6461. },
  6462. cleanData: function( elems ) {
  6463. var data, elem, type,
  6464. special = jQuery.event.special,
  6465. i = 0;
  6466. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  6467. if ( acceptData( elem ) ) {
  6468. if ( ( data = elem[ dataPriv.expando ] ) ) {
  6469. if ( data.events ) {
  6470. for ( type in data.events ) {
  6471. if ( special[ type ] ) {
  6472. jQuery.event.remove( elem, type );
  6473. // This is a shortcut to avoid jQuery.event.remove's overhead
  6474. } else {
  6475. jQuery.removeEvent( elem, type, data.handle );
  6476. }
  6477. }
  6478. }
  6479. // Support: Chrome <=35 - 45+
  6480. // Assign undefined instead of using delete, see Data#remove
  6481. elem[ dataPriv.expando ] = undefined;
  6482. }
  6483. if ( elem[ dataUser.expando ] ) {
  6484. // Support: Chrome <=35 - 45+
  6485. // Assign undefined instead of using delete, see Data#remove
  6486. elem[ dataUser.expando ] = undefined;
  6487. }
  6488. }
  6489. }
  6490. }
  6491. } );
  6492. jQuery.fn.extend( {
  6493. detach: function( selector ) {
  6494. return remove( this, selector, true );
  6495. },
  6496. remove: function( selector ) {
  6497. return remove( this, selector );
  6498. },
  6499. text: function( value ) {
  6500. return access( this, function( value ) {
  6501. return value === undefined ?
  6502. jQuery.text( this ) :
  6503. this.empty().each( function() {
  6504. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  6505. this.textContent = value;
  6506. }
  6507. } );
  6508. }, null, value, arguments.length );
  6509. },
  6510. append: function() {
  6511. return domManip( this, arguments, function( elem ) {
  6512. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  6513. var target = manipulationTarget( this, elem );
  6514. target.appendChild( elem );
  6515. }
  6516. } );
  6517. },
  6518. prepend: function() {
  6519. return domManip( this, arguments, function( elem ) {
  6520. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  6521. var target = manipulationTarget( this, elem );
  6522. target.insertBefore( elem, target.firstChild );
  6523. }
  6524. } );
  6525. },
  6526. before: function() {
  6527. return domManip( this, arguments, function( elem ) {
  6528. if ( this.parentNode ) {
  6529. this.parentNode.insertBefore( elem, this );
  6530. }
  6531. } );
  6532. },
  6533. after: function() {
  6534. return domManip( this, arguments, function( elem ) {
  6535. if ( this.parentNode ) {
  6536. this.parentNode.insertBefore( elem, this.nextSibling );
  6537. }
  6538. } );
  6539. },
  6540. empty: function() {
  6541. var elem,
  6542. i = 0;
  6543. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  6544. if ( elem.nodeType === 1 ) {
  6545. // Prevent memory leaks
  6546. jQuery.cleanData( getAll( elem, false ) );
  6547. // Remove any remaining nodes
  6548. elem.textContent = "";
  6549. }
  6550. }
  6551. return this;
  6552. },
  6553. clone: function( dataAndEvents, deepDataAndEvents ) {
  6554. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  6555. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  6556. return this.map( function() {
  6557. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  6558. } );
  6559. },
  6560. html: function( value ) {
  6561. return access( this, function( value ) {
  6562. var elem = this[ 0 ] || {},
  6563. i = 0,
  6564. l = this.length;
  6565. if ( value === undefined && elem.nodeType === 1 ) {
  6566. return elem.innerHTML;
  6567. }
  6568. // See if we can take a shortcut and just use innerHTML
  6569. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  6570. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  6571. value = jQuery.htmlPrefilter( value );
  6572. try {
  6573. for ( ; i < l; i++ ) {
  6574. elem = this[ i ] || {};
  6575. // Remove element nodes and prevent memory leaks
  6576. if ( elem.nodeType === 1 ) {
  6577. jQuery.cleanData( getAll( elem, false ) );
  6578. elem.innerHTML = value;
  6579. }
  6580. }
  6581. elem = 0;
  6582. // If using innerHTML throws an exception, use the fallback method
  6583. } catch ( e ) {}
  6584. }
  6585. if ( elem ) {
  6586. this.empty().append( value );
  6587. }
  6588. }, null, value, arguments.length );
  6589. },
  6590. replaceWith: function() {
  6591. var ignored = [];
  6592. // Make the changes, replacing each non-ignored context element with the new content
  6593. return domManip( this, arguments, function( elem ) {
  6594. var parent = this.parentNode;
  6595. if ( jQuery.inArray( this, ignored ) < 0 ) {
  6596. jQuery.cleanData( getAll( this ) );
  6597. if ( parent ) {
  6598. parent.replaceChild( elem, this );
  6599. }
  6600. }
  6601. // Force callback invocation
  6602. }, ignored );
  6603. }
  6604. } );
  6605. jQuery.each( {
  6606. appendTo: "append",
  6607. prependTo: "prepend",
  6608. insertBefore: "before",
  6609. insertAfter: "after",
  6610. replaceAll: "replaceWith"
  6611. }, function( name, original ) {
  6612. jQuery.fn[ name ] = function( selector ) {
  6613. var elems,
  6614. ret = [],
  6615. insert = jQuery( selector ),
  6616. last = insert.length - 1,
  6617. i = 0;
  6618. for ( ; i <= last; i++ ) {
  6619. elems = i === last ? this : this.clone( true );
  6620. jQuery( insert[ i ] )[ original ]( elems );
  6621. // Support: Android <=4.0 only, PhantomJS 1 only
  6622. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  6623. push.apply( ret, elems.get() );
  6624. }
  6625. return this.pushStack( ret );
  6626. };
  6627. } );
  6628. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  6629. var getStyles = function( elem ) {
  6630. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  6631. // IE throws on elements created in popups
  6632. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  6633. var view = elem.ownerDocument.defaultView;
  6634. if ( !view || !view.opener ) {
  6635. view = window;
  6636. }
  6637. return view.getComputedStyle( elem );
  6638. };
  6639. var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
  6640. ( function() {
  6641. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  6642. // so they're executed at the same time to save the second computation.
  6643. function computeStyleTests() {
  6644. // This is a singleton, we need to execute it only once
  6645. if ( !div ) {
  6646. return;
  6647. }
  6648. container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
  6649. "margin-top:1px;padding:0;border:0";
  6650. div.style.cssText =
  6651. "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
  6652. "margin:auto;border:1px;padding:1px;" +
  6653. "width:60%;top:1%";
  6654. documentElement.appendChild( container ).appendChild( div );
  6655. var divStyle = window.getComputedStyle( div );
  6656. pixelPositionVal = divStyle.top !== "1%";
  6657. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  6658. reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
  6659. // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
  6660. // Some styles come back with percentage values, even though they shouldn't
  6661. div.style.right = "60%";
  6662. pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
  6663. // Support: IE 9 - 11 only
  6664. // Detect misreporting of content dimensions for box-sizing:border-box elements
  6665. boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
  6666. // Support: IE 9 only
  6667. // Detect overflow:scroll screwiness (gh-3699)
  6668. // Support: Chrome <=64
  6669. // Don't get tricked when zoom affects offsetWidth (gh-4029)
  6670. div.style.position = "absolute";
  6671. scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
  6672. documentElement.removeChild( container );
  6673. // Nullify the div so it wouldn't be stored in the memory and
  6674. // it will also be a sign that checks already performed
  6675. div = null;
  6676. }
  6677. function roundPixelMeasures( measure ) {
  6678. return Math.round( parseFloat( measure ) );
  6679. }
  6680. var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
  6681. reliableMarginLeftVal,
  6682. container = document.createElement( "div" ),
  6683. div = document.createElement( "div" );
  6684. // Finish early in limited (non-browser) environments
  6685. if ( !div.style ) {
  6686. return;
  6687. }
  6688. // Support: IE <=9 - 11 only
  6689. // Style of cloned element affects source element cloned (#8908)
  6690. div.style.backgroundClip = "content-box";
  6691. div.cloneNode( true ).style.backgroundClip = "";
  6692. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  6693. jQuery.extend( support, {
  6694. boxSizingReliable: function() {
  6695. computeStyleTests();
  6696. return boxSizingReliableVal;
  6697. },
  6698. pixelBoxStyles: function() {
  6699. computeStyleTests();
  6700. return pixelBoxStylesVal;
  6701. },
  6702. pixelPosition: function() {
  6703. computeStyleTests();
  6704. return pixelPositionVal;
  6705. },
  6706. reliableMarginLeft: function() {
  6707. computeStyleTests();
  6708. return reliableMarginLeftVal;
  6709. },
  6710. scrollboxSize: function() {
  6711. computeStyleTests();
  6712. return scrollboxSizeVal;
  6713. }
  6714. } );
  6715. } )();
  6716. function curCSS( elem, name, computed ) {
  6717. var width, minWidth, maxWidth, ret,
  6718. // Support: Firefox 51+
  6719. // Retrieving style before computed somehow
  6720. // fixes an issue with getting wrong values
  6721. // on detached elements
  6722. style = elem.style;
  6723. computed = computed || getStyles( elem );
  6724. // getPropertyValue is needed for:
  6725. // .css('filter') (IE 9 only, #12537)
  6726. // .css('--customProperty) (#3144)
  6727. if ( computed ) {
  6728. ret = computed.getPropertyValue( name ) || computed[ name ];
  6729. if ( ret === "" && !isAttached( elem ) ) {
  6730. ret = jQuery.style( elem, name );
  6731. }
  6732. // A tribute to the "awesome hack by Dean Edwards"
  6733. // Android Browser returns percentage for some values,
  6734. // but width seems to be reliably pixels.
  6735. // This is against the CSSOM draft spec:
  6736. // https://drafts.csswg.org/cssom/#resolved-values
  6737. if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
  6738. // Remember the original values
  6739. width = style.width;
  6740. minWidth = style.minWidth;
  6741. maxWidth = style.maxWidth;
  6742. // Put in the new values to get a computed value out
  6743. style.minWidth = style.maxWidth = style.width = ret;
  6744. ret = computed.width;
  6745. // Revert the changed values
  6746. style.width = width;
  6747. style.minWidth = minWidth;
  6748. style.maxWidth = maxWidth;
  6749. }
  6750. }
  6751. return ret !== undefined ?
  6752. // Support: IE <=9 - 11 only
  6753. // IE returns zIndex value as an integer.
  6754. ret + "" :
  6755. ret;
  6756. }
  6757. function addGetHookIf( conditionFn, hookFn ) {
  6758. // Define the hook, we'll check on the first run if it's really needed.
  6759. return {
  6760. get: function() {
  6761. if ( conditionFn() ) {
  6762. // Hook not needed (or it's not possible to use it due
  6763. // to missing dependency), remove it.
  6764. delete this.get;
  6765. return;
  6766. }
  6767. // Hook needed; redefine it so that the support test is not executed again.
  6768. return ( this.get = hookFn ).apply( this, arguments );
  6769. }
  6770. };
  6771. }
  6772. var cssPrefixes = [ "Webkit", "Moz", "ms" ],
  6773. emptyStyle = document.createElement( "div" ).style,
  6774. vendorProps = {};
  6775. // Return a vendor-prefixed property or undefined
  6776. function vendorPropName( name ) {
  6777. // Check for vendor prefixed names
  6778. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  6779. i = cssPrefixes.length;
  6780. while ( i-- ) {
  6781. name = cssPrefixes[ i ] + capName;
  6782. if ( name in emptyStyle ) {
  6783. return name;
  6784. }
  6785. }
  6786. }
  6787. // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
  6788. function finalPropName( name ) {
  6789. var final = jQuery.cssProps[ name ] || vendorProps[ name ];
  6790. if ( final ) {
  6791. return final;
  6792. }
  6793. if ( name in emptyStyle ) {
  6794. return name;
  6795. }
  6796. return vendorProps[ name ] = vendorPropName( name ) || name;
  6797. }
  6798. var
  6799. // Swappable if display is none or starts with table
  6800. // except "table", "table-cell", or "table-caption"
  6801. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  6802. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  6803. rcustomProp = /^--/,
  6804. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  6805. cssNormalTransform = {
  6806. letterSpacing: "0",
  6807. fontWeight: "400"
  6808. };
  6809. function setPositiveNumber( elem, value, subtract ) {
  6810. // Any relative (+/-) values have already been
  6811. // normalized at this point
  6812. var matches = rcssNum.exec( value );
  6813. return matches ?
  6814. // Guard against undefined "subtract", e.g., when used as in cssHooks
  6815. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  6816. value;
  6817. }
  6818. function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
  6819. var i = dimension === "width" ? 1 : 0,
  6820. extra = 0,
  6821. delta = 0;
  6822. // Adjustment may not be necessary
  6823. if ( box === ( isBorderBox ? "border" : "content" ) ) {
  6824. return 0;
  6825. }
  6826. for ( ; i < 4; i += 2 ) {
  6827. // Both box models exclude margin
  6828. if ( box === "margin" ) {
  6829. delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
  6830. }
  6831. // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
  6832. if ( !isBorderBox ) {
  6833. // Add padding
  6834. delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  6835. // For "border" or "margin", add border
  6836. if ( box !== "padding" ) {
  6837. delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  6838. // But still keep track of it otherwise
  6839. } else {
  6840. extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  6841. }
  6842. // If we get here with a border-box (content + padding + border), we're seeking "content" or
  6843. // "padding" or "margin"
  6844. } else {
  6845. // For "content", subtract padding
  6846. if ( box === "content" ) {
  6847. delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  6848. }
  6849. // For "content" or "padding", subtract border
  6850. if ( box !== "margin" ) {
  6851. delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  6852. }
  6853. }
  6854. }
  6855. // Account for positive content-box scroll gutter when requested by providing computedVal
  6856. if ( !isBorderBox && computedVal >= 0 ) {
  6857. // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
  6858. // Assuming integer scroll gutter, subtract the rest and round down
  6859. delta += Math.max( 0, Math.ceil(
  6860. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  6861. computedVal -
  6862. delta -
  6863. extra -
  6864. 0.5
  6865. // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
  6866. // Use an explicit zero to avoid NaN (gh-3964)
  6867. ) ) || 0;
  6868. }
  6869. return delta;
  6870. }
  6871. function getWidthOrHeight( elem, dimension, extra ) {
  6872. // Start with computed style
  6873. var styles = getStyles( elem ),
  6874. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
  6875. // Fake content-box until we know it's needed to know the true value.
  6876. boxSizingNeeded = !support.boxSizingReliable() || extra,
  6877. isBorderBox = boxSizingNeeded &&
  6878. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  6879. valueIsBorderBox = isBorderBox,
  6880. val = curCSS( elem, dimension, styles ),
  6881. offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
  6882. // Support: Firefox <=54
  6883. // Return a confounding non-pixel value or feign ignorance, as appropriate.
  6884. if ( rnumnonpx.test( val ) ) {
  6885. if ( !extra ) {
  6886. return val;
  6887. }
  6888. val = "auto";
  6889. }
  6890. // Fall back to offsetWidth/offsetHeight when value is "auto"
  6891. // This happens for inline elements with no explicit setting (gh-3571)
  6892. // Support: Android <=4.1 - 4.3 only
  6893. // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
  6894. // Support: IE 9-11 only
  6895. // Also use offsetWidth/offsetHeight for when box sizing is unreliable
  6896. // We use getClientRects() to check for hidden/disconnected.
  6897. // In those cases, the computed value can be trusted to be border-box
  6898. if ( ( !support.boxSizingReliable() && isBorderBox ||
  6899. val === "auto" ||
  6900. !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
  6901. elem.getClientRects().length ) {
  6902. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  6903. // Where available, offsetWidth/offsetHeight approximate border box dimensions.
  6904. // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
  6905. // retrieved value as a content box dimension.
  6906. valueIsBorderBox = offsetProp in elem;
  6907. if ( valueIsBorderBox ) {
  6908. val = elem[ offsetProp ];
  6909. }
  6910. }
  6911. // Normalize "" and auto
  6912. val = parseFloat( val ) || 0;
  6913. // Adjust for the element's box model
  6914. return ( val +
  6915. boxModelAdjustment(
  6916. elem,
  6917. dimension,
  6918. extra || ( isBorderBox ? "border" : "content" ),
  6919. valueIsBorderBox,
  6920. styles,
  6921. // Provide the current computed size to request scroll gutter calculation (gh-3589)
  6922. val
  6923. )
  6924. ) + "px";
  6925. }
  6926. jQuery.extend( {
  6927. // Add in style property hooks for overriding the default
  6928. // behavior of getting and setting a style property
  6929. cssHooks: {
  6930. opacity: {
  6931. get: function( elem, computed ) {
  6932. if ( computed ) {
  6933. // We should always get a number back from opacity
  6934. var ret = curCSS( elem, "opacity" );
  6935. return ret === "" ? "1" : ret;
  6936. }
  6937. }
  6938. }
  6939. },
  6940. // Don't automatically add "px" to these possibly-unitless properties
  6941. cssNumber: {
  6942. "animationIterationCount": true,
  6943. "columnCount": true,
  6944. "fillOpacity": true,
  6945. "flexGrow": true,
  6946. "flexShrink": true,
  6947. "fontWeight": true,
  6948. "gridArea": true,
  6949. "gridColumn": true,
  6950. "gridColumnEnd": true,
  6951. "gridColumnStart": true,
  6952. "gridRow": true,
  6953. "gridRowEnd": true,
  6954. "gridRowStart": true,
  6955. "lineHeight": true,
  6956. "opacity": true,
  6957. "order": true,
  6958. "orphans": true,
  6959. "widows": true,
  6960. "zIndex": true,
  6961. "zoom": true
  6962. },
  6963. // Add in properties whose names you wish to fix before
  6964. // setting or getting the value
  6965. cssProps: {},
  6966. // Get and set the style property on a DOM Node
  6967. style: function( elem, name, value, extra ) {
  6968. // Don't set styles on text and comment nodes
  6969. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  6970. return;
  6971. }
  6972. // Make sure that we're working with the right name
  6973. var ret, type, hooks,
  6974. origName = camelCase( name ),
  6975. isCustomProp = rcustomProp.test( name ),
  6976. style = elem.style;
  6977. // Make sure that we're working with the right name. We don't
  6978. // want to query the value if it is a CSS custom property
  6979. // since they are user-defined.
  6980. if ( !isCustomProp ) {
  6981. name = finalPropName( origName );
  6982. }
  6983. // Gets hook for the prefixed version, then unprefixed version
  6984. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  6985. // Check if we're setting a value
  6986. if ( value !== undefined ) {
  6987. type = typeof value;
  6988. // Convert "+=" or "-=" to relative numbers (#7345)
  6989. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  6990. value = adjustCSS( elem, name, ret );
  6991. // Fixes bug #9237
  6992. type = "number";
  6993. }
  6994. // Make sure that null and NaN values aren't set (#7116)
  6995. if ( value == null || value !== value ) {
  6996. return;
  6997. }
  6998. // If a number was passed in, add the unit (except for certain CSS properties)
  6999. // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
  7000. // "px" to a few hardcoded values.
  7001. if ( type === "number" && !isCustomProp ) {
  7002. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  7003. }
  7004. // background-* props affect original clone's values
  7005. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  7006. style[ name ] = "inherit";
  7007. }
  7008. // If a hook was provided, use that value, otherwise just set the specified value
  7009. if ( !hooks || !( "set" in hooks ) ||
  7010. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  7011. if ( isCustomProp ) {
  7012. style.setProperty( name, value );
  7013. } else {
  7014. style[ name ] = value;
  7015. }
  7016. }
  7017. } else {
  7018. // If a hook was provided get the non-computed value from there
  7019. if ( hooks && "get" in hooks &&
  7020. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  7021. return ret;
  7022. }
  7023. // Otherwise just get the value from the style object
  7024. return style[ name ];
  7025. }
  7026. },
  7027. css: function( elem, name, extra, styles ) {
  7028. var val, num, hooks,
  7029. origName = camelCase( name ),
  7030. isCustomProp = rcustomProp.test( name );
  7031. // Make sure that we're working with the right name. We don't
  7032. // want to modify the value if it is a CSS custom property
  7033. // since they are user-defined.
  7034. if ( !isCustomProp ) {
  7035. name = finalPropName( origName );
  7036. }
  7037. // Try prefixed name followed by the unprefixed name
  7038. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  7039. // If a hook was provided get the computed value from there
  7040. if ( hooks && "get" in hooks ) {
  7041. val = hooks.get( elem, true, extra );
  7042. }
  7043. // Otherwise, if a way to get the computed value exists, use that
  7044. if ( val === undefined ) {
  7045. val = curCSS( elem, name, styles );
  7046. }
  7047. // Convert "normal" to computed value
  7048. if ( val === "normal" && name in cssNormalTransform ) {
  7049. val = cssNormalTransform[ name ];
  7050. }
  7051. // Make numeric if forced or a qualifier was provided and val looks numeric
  7052. if ( extra === "" || extra ) {
  7053. num = parseFloat( val );
  7054. return extra === true || isFinite( num ) ? num || 0 : val;
  7055. }
  7056. return val;
  7057. }
  7058. } );
  7059. jQuery.each( [ "height", "width" ], function( i, dimension ) {
  7060. jQuery.cssHooks[ dimension ] = {
  7061. get: function( elem, computed, extra ) {
  7062. if ( computed ) {
  7063. // Certain elements can have dimension info if we invisibly show them
  7064. // but it must have a current display style that would benefit
  7065. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  7066. // Support: Safari 8+
  7067. // Table columns in Safari have non-zero offsetWidth & zero
  7068. // getBoundingClientRect().width unless display is changed.
  7069. // Support: IE <=11 only
  7070. // Running getBoundingClientRect on a disconnected node
  7071. // in IE throws an error.
  7072. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  7073. swap( elem, cssShow, function() {
  7074. return getWidthOrHeight( elem, dimension, extra );
  7075. } ) :
  7076. getWidthOrHeight( elem, dimension, extra );
  7077. }
  7078. },
  7079. set: function( elem, value, extra ) {
  7080. var matches,
  7081. styles = getStyles( elem ),
  7082. // Only read styles.position if the test has a chance to fail
  7083. // to avoid forcing a reflow.
  7084. scrollboxSizeBuggy = !support.scrollboxSize() &&
  7085. styles.position === "absolute",
  7086. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
  7087. boxSizingNeeded = scrollboxSizeBuggy || extra,
  7088. isBorderBox = boxSizingNeeded &&
  7089. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  7090. subtract = extra ?
  7091. boxModelAdjustment(
  7092. elem,
  7093. dimension,
  7094. extra,
  7095. isBorderBox,
  7096. styles
  7097. ) :
  7098. 0;
  7099. // Account for unreliable border-box dimensions by comparing offset* to computed and
  7100. // faking a content-box to get border and padding (gh-3699)
  7101. if ( isBorderBox && scrollboxSizeBuggy ) {
  7102. subtract -= Math.ceil(
  7103. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  7104. parseFloat( styles[ dimension ] ) -
  7105. boxModelAdjustment( elem, dimension, "border", false, styles ) -
  7106. 0.5
  7107. );
  7108. }
  7109. // Convert to pixels if value adjustment is needed
  7110. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  7111. ( matches[ 3 ] || "px" ) !== "px" ) {
  7112. elem.style[ dimension ] = value;
  7113. value = jQuery.css( elem, dimension );
  7114. }
  7115. return setPositiveNumber( elem, value, subtract );
  7116. }
  7117. };
  7118. } );
  7119. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  7120. function( elem, computed ) {
  7121. if ( computed ) {
  7122. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  7123. elem.getBoundingClientRect().left -
  7124. swap( elem, { marginLeft: 0 }, function() {
  7125. return elem.getBoundingClientRect().left;
  7126. } )
  7127. ) + "px";
  7128. }
  7129. }
  7130. );
  7131. // These hooks are used by animate to expand properties
  7132. jQuery.each( {
  7133. margin: "",
  7134. padding: "",
  7135. border: "Width"
  7136. }, function( prefix, suffix ) {
  7137. jQuery.cssHooks[ prefix + suffix ] = {
  7138. expand: function( value ) {
  7139. var i = 0,
  7140. expanded = {},
  7141. // Assumes a single number if not a string
  7142. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  7143. for ( ; i < 4; i++ ) {
  7144. expanded[ prefix + cssExpand[ i ] + suffix ] =
  7145. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  7146. }
  7147. return expanded;
  7148. }
  7149. };
  7150. if ( prefix !== "margin" ) {
  7151. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  7152. }
  7153. } );
  7154. jQuery.fn.extend( {
  7155. css: function( name, value ) {
  7156. return access( this, function( elem, name, value ) {
  7157. var styles, len,
  7158. map = {},
  7159. i = 0;
  7160. if ( Array.isArray( name ) ) {
  7161. styles = getStyles( elem );
  7162. len = name.length;
  7163. for ( ; i < len; i++ ) {
  7164. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  7165. }
  7166. return map;
  7167. }
  7168. return value !== undefined ?
  7169. jQuery.style( elem, name, value ) :
  7170. jQuery.css( elem, name );
  7171. }, name, value, arguments.length > 1 );
  7172. }
  7173. } );
  7174. function Tween( elem, options, prop, end, easing ) {
  7175. return new Tween.prototype.init( elem, options, prop, end, easing );
  7176. }
  7177. jQuery.Tween = Tween;
  7178. Tween.prototype = {
  7179. constructor: Tween,
  7180. init: function( elem, options, prop, end, easing, unit ) {
  7181. this.elem = elem;
  7182. this.prop = prop;
  7183. this.easing = easing || jQuery.easing._default;
  7184. this.options = options;
  7185. this.start = this.now = this.cur();
  7186. this.end = end;
  7187. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  7188. },
  7189. cur: function() {
  7190. var hooks = Tween.propHooks[ this.prop ];
  7191. return hooks && hooks.get ?
  7192. hooks.get( this ) :
  7193. Tween.propHooks._default.get( this );
  7194. },
  7195. run: function( percent ) {
  7196. var eased,
  7197. hooks = Tween.propHooks[ this.prop ];
  7198. if ( this.options.duration ) {
  7199. this.pos = eased = jQuery.easing[ this.easing ](
  7200. percent, this.options.duration * percent, 0, 1, this.options.duration
  7201. );
  7202. } else {
  7203. this.pos = eased = percent;
  7204. }
  7205. this.now = ( this.end - this.start ) * eased + this.start;
  7206. if ( this.options.step ) {
  7207. this.options.step.call( this.elem, this.now, this );
  7208. }
  7209. if ( hooks && hooks.set ) {
  7210. hooks.set( this );
  7211. } else {
  7212. Tween.propHooks._default.set( this );
  7213. }
  7214. return this;
  7215. }
  7216. };
  7217. Tween.prototype.init.prototype = Tween.prototype;
  7218. Tween.propHooks = {
  7219. _default: {
  7220. get: function( tween ) {
  7221. var result;
  7222. // Use a property on the element directly when it is not a DOM element,
  7223. // or when there is no matching style property that exists.
  7224. if ( tween.elem.nodeType !== 1 ||
  7225. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  7226. return tween.elem[ tween.prop ];
  7227. }
  7228. // Passing an empty string as a 3rd parameter to .css will automatically
  7229. // attempt a parseFloat and fallback to a string if the parse fails.
  7230. // Simple values such as "10px" are parsed to Float;
  7231. // complex values such as "rotate(1rad)" are returned as-is.
  7232. result = jQuery.css( tween.elem, tween.prop, "" );
  7233. // Empty strings, null, undefined and "auto" are converted to 0.
  7234. return !result || result === "auto" ? 0 : result;
  7235. },
  7236. set: function( tween ) {
  7237. // Use step hook for back compat.
  7238. // Use cssHook if its there.
  7239. // Use .style if available and use plain properties where available.
  7240. if ( jQuery.fx.step[ tween.prop ] ) {
  7241. jQuery.fx.step[ tween.prop ]( tween );
  7242. } else if ( tween.elem.nodeType === 1 && (
  7243. jQuery.cssHooks[ tween.prop ] ||
  7244. tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
  7245. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  7246. } else {
  7247. tween.elem[ tween.prop ] = tween.now;
  7248. }
  7249. }
  7250. }
  7251. };
  7252. // Support: IE <=9 only
  7253. // Panic based approach to setting things on disconnected nodes
  7254. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  7255. set: function( tween ) {
  7256. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  7257. tween.elem[ tween.prop ] = tween.now;
  7258. }
  7259. }
  7260. };
  7261. jQuery.easing = {
  7262. linear: function( p ) {
  7263. return p;
  7264. },
  7265. swing: function( p ) {
  7266. return 0.5 - Math.cos( p * Math.PI ) / 2;
  7267. },
  7268. _default: "swing"
  7269. };
  7270. jQuery.fx = Tween.prototype.init;
  7271. // Back compat <1.8 extension point
  7272. jQuery.fx.step = {};
  7273. var
  7274. fxNow, inProgress,
  7275. rfxtypes = /^(?:toggle|show|hide)$/,
  7276. rrun = /queueHooks$/;
  7277. function schedule() {
  7278. if ( inProgress ) {
  7279. if ( document.hidden === false && window.requestAnimationFrame ) {
  7280. window.requestAnimationFrame( schedule );
  7281. } else {
  7282. window.setTimeout( schedule, jQuery.fx.interval );
  7283. }
  7284. jQuery.fx.tick();
  7285. }
  7286. }
  7287. // Animations created synchronously will run synchronously
  7288. function createFxNow() {
  7289. window.setTimeout( function() {
  7290. fxNow = undefined;
  7291. } );
  7292. return ( fxNow = Date.now() );
  7293. }
  7294. // Generate parameters to create a standard animation
  7295. function genFx( type, includeWidth ) {
  7296. var which,
  7297. i = 0,
  7298. attrs = { height: type };
  7299. // If we include width, step value is 1 to do all cssExpand values,
  7300. // otherwise step value is 2 to skip over Left and Right
  7301. includeWidth = includeWidth ? 1 : 0;
  7302. for ( ; i < 4; i += 2 - includeWidth ) {
  7303. which = cssExpand[ i ];
  7304. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  7305. }
  7306. if ( includeWidth ) {
  7307. attrs.opacity = attrs.width = type;
  7308. }
  7309. return attrs;
  7310. }
  7311. function createTween( value, prop, animation ) {
  7312. var tween,
  7313. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  7314. index = 0,
  7315. length = collection.length;
  7316. for ( ; index < length; index++ ) {
  7317. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  7318. // We're done with this property
  7319. return tween;
  7320. }
  7321. }
  7322. }
  7323. function defaultPrefilter( elem, props, opts ) {
  7324. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  7325. isBox = "width" in props || "height" in props,
  7326. anim = this,
  7327. orig = {},
  7328. style = elem.style,
  7329. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  7330. dataShow = dataPriv.get( elem, "fxshow" );
  7331. // Queue-skipping animations hijack the fx hooks
  7332. if ( !opts.queue ) {
  7333. hooks = jQuery._queueHooks( elem, "fx" );
  7334. if ( hooks.unqueued == null ) {
  7335. hooks.unqueued = 0;
  7336. oldfire = hooks.empty.fire;
  7337. hooks.empty.fire = function() {
  7338. if ( !hooks.unqueued ) {
  7339. oldfire();
  7340. }
  7341. };
  7342. }
  7343. hooks.unqueued++;
  7344. anim.always( function() {
  7345. // Ensure the complete handler is called before this completes
  7346. anim.always( function() {
  7347. hooks.unqueued--;
  7348. if ( !jQuery.queue( elem, "fx" ).length ) {
  7349. hooks.empty.fire();
  7350. }
  7351. } );
  7352. } );
  7353. }
  7354. // Detect show/hide animations
  7355. for ( prop in props ) {
  7356. value = props[ prop ];
  7357. if ( rfxtypes.test( value ) ) {
  7358. delete props[ prop ];
  7359. toggle = toggle || value === "toggle";
  7360. if ( value === ( hidden ? "hide" : "show" ) ) {
  7361. // Pretend to be hidden if this is a "show" and
  7362. // there is still data from a stopped show/hide
  7363. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  7364. hidden = true;
  7365. // Ignore all other no-op show/hide data
  7366. } else {
  7367. continue;
  7368. }
  7369. }
  7370. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  7371. }
  7372. }
  7373. // Bail out if this is a no-op like .hide().hide()
  7374. propTween = !jQuery.isEmptyObject( props );
  7375. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  7376. return;
  7377. }
  7378. // Restrict "overflow" and "display" styles during box animations
  7379. if ( isBox && elem.nodeType === 1 ) {
  7380. // Support: IE <=9 - 11, Edge 12 - 15
  7381. // Record all 3 overflow attributes because IE does not infer the shorthand
  7382. // from identically-valued overflowX and overflowY and Edge just mirrors
  7383. // the overflowX value there.
  7384. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  7385. // Identify a display type, preferring old show/hide data over the CSS cascade
  7386. restoreDisplay = dataShow && dataShow.display;
  7387. if ( restoreDisplay == null ) {
  7388. restoreDisplay = dataPriv.get( elem, "display" );
  7389. }
  7390. display = jQuery.css( elem, "display" );
  7391. if ( display === "none" ) {
  7392. if ( restoreDisplay ) {
  7393. display = restoreDisplay;
  7394. } else {
  7395. // Get nonempty value(s) by temporarily forcing visibility
  7396. showHide( [ elem ], true );
  7397. restoreDisplay = elem.style.display || restoreDisplay;
  7398. display = jQuery.css( elem, "display" );
  7399. showHide( [ elem ] );
  7400. }
  7401. }
  7402. // Animate inline elements as inline-block
  7403. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  7404. if ( jQuery.css( elem, "float" ) === "none" ) {
  7405. // Restore the original display value at the end of pure show/hide animations
  7406. if ( !propTween ) {
  7407. anim.done( function() {
  7408. style.display = restoreDisplay;
  7409. } );
  7410. if ( restoreDisplay == null ) {
  7411. display = style.display;
  7412. restoreDisplay = display === "none" ? "" : display;
  7413. }
  7414. }
  7415. style.display = "inline-block";
  7416. }
  7417. }
  7418. }
  7419. if ( opts.overflow ) {
  7420. style.overflow = "hidden";
  7421. anim.always( function() {
  7422. style.overflow = opts.overflow[ 0 ];
  7423. style.overflowX = opts.overflow[ 1 ];
  7424. style.overflowY = opts.overflow[ 2 ];
  7425. } );
  7426. }
  7427. // Implement show/hide animations
  7428. propTween = false;
  7429. for ( prop in orig ) {
  7430. // General show/hide setup for this element animation
  7431. if ( !propTween ) {
  7432. if ( dataShow ) {
  7433. if ( "hidden" in dataShow ) {
  7434. hidden = dataShow.hidden;
  7435. }
  7436. } else {
  7437. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  7438. }
  7439. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  7440. if ( toggle ) {
  7441. dataShow.hidden = !hidden;
  7442. }
  7443. // Show elements before animating them
  7444. if ( hidden ) {
  7445. showHide( [ elem ], true );
  7446. }
  7447. /* eslint-disable no-loop-func */
  7448. anim.done( function() {
  7449. /* eslint-enable no-loop-func */
  7450. // The final step of a "hide" animation is actually hiding the element
  7451. if ( !hidden ) {
  7452. showHide( [ elem ] );
  7453. }
  7454. dataPriv.remove( elem, "fxshow" );
  7455. for ( prop in orig ) {
  7456. jQuery.style( elem, prop, orig[ prop ] );
  7457. }
  7458. } );
  7459. }
  7460. // Per-property setup
  7461. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  7462. if ( !( prop in dataShow ) ) {
  7463. dataShow[ prop ] = propTween.start;
  7464. if ( hidden ) {
  7465. propTween.end = propTween.start;
  7466. propTween.start = 0;
  7467. }
  7468. }
  7469. }
  7470. }
  7471. function propFilter( props, specialEasing ) {
  7472. var index, name, easing, value, hooks;
  7473. // camelCase, specialEasing and expand cssHook pass
  7474. for ( index in props ) {
  7475. name = camelCase( index );
  7476. easing = specialEasing[ name ];
  7477. value = props[ index ];
  7478. if ( Array.isArray( value ) ) {
  7479. easing = value[ 1 ];
  7480. value = props[ index ] = value[ 0 ];
  7481. }
  7482. if ( index !== name ) {
  7483. props[ name ] = value;
  7484. delete props[ index ];
  7485. }
  7486. hooks = jQuery.cssHooks[ name ];
  7487. if ( hooks && "expand" in hooks ) {
  7488. value = hooks.expand( value );
  7489. delete props[ name ];
  7490. // Not quite $.extend, this won't overwrite existing keys.
  7491. // Reusing 'index' because we have the correct "name"
  7492. for ( index in value ) {
  7493. if ( !( index in props ) ) {
  7494. props[ index ] = value[ index ];
  7495. specialEasing[ index ] = easing;
  7496. }
  7497. }
  7498. } else {
  7499. specialEasing[ name ] = easing;
  7500. }
  7501. }
  7502. }
  7503. function Animation( elem, properties, options ) {
  7504. var result,
  7505. stopped,
  7506. index = 0,
  7507. length = Animation.prefilters.length,
  7508. deferred = jQuery.Deferred().always( function() {
  7509. // Don't match elem in the :animated selector
  7510. delete tick.elem;
  7511. } ),
  7512. tick = function() {
  7513. if ( stopped ) {
  7514. return false;
  7515. }
  7516. var currentTime = fxNow || createFxNow(),
  7517. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  7518. // Support: Android 2.3 only
  7519. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  7520. temp = remaining / animation.duration || 0,
  7521. percent = 1 - temp,
  7522. index = 0,
  7523. length = animation.tweens.length;
  7524. for ( ; index < length; index++ ) {
  7525. animation.tweens[ index ].run( percent );
  7526. }
  7527. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  7528. // If there's more to do, yield
  7529. if ( percent < 1 && length ) {
  7530. return remaining;
  7531. }
  7532. // If this was an empty animation, synthesize a final progress notification
  7533. if ( !length ) {
  7534. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  7535. }
  7536. // Resolve the animation and report its conclusion
  7537. deferred.resolveWith( elem, [ animation ] );
  7538. return false;
  7539. },
  7540. animation = deferred.promise( {
  7541. elem: elem,
  7542. props: jQuery.extend( {}, properties ),
  7543. opts: jQuery.extend( true, {
  7544. specialEasing: {},
  7545. easing: jQuery.easing._default
  7546. }, options ),
  7547. originalProperties: properties,
  7548. originalOptions: options,
  7549. startTime: fxNow || createFxNow(),
  7550. duration: options.duration,
  7551. tweens: [],
  7552. createTween: function( prop, end ) {
  7553. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  7554. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  7555. animation.tweens.push( tween );
  7556. return tween;
  7557. },
  7558. stop: function( gotoEnd ) {
  7559. var index = 0,
  7560. // If we are going to the end, we want to run all the tweens
  7561. // otherwise we skip this part
  7562. length = gotoEnd ? animation.tweens.length : 0;
  7563. if ( stopped ) {
  7564. return this;
  7565. }
  7566. stopped = true;
  7567. for ( ; index < length; index++ ) {
  7568. animation.tweens[ index ].run( 1 );
  7569. }
  7570. // Resolve when we played the last frame; otherwise, reject
  7571. if ( gotoEnd ) {
  7572. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  7573. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  7574. } else {
  7575. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  7576. }
  7577. return this;
  7578. }
  7579. } ),
  7580. props = animation.props;
  7581. propFilter( props, animation.opts.specialEasing );
  7582. for ( ; index < length; index++ ) {
  7583. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  7584. if ( result ) {
  7585. if ( isFunction( result.stop ) ) {
  7586. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  7587. result.stop.bind( result );
  7588. }
  7589. return result;
  7590. }
  7591. }
  7592. jQuery.map( props, createTween, animation );
  7593. if ( isFunction( animation.opts.start ) ) {
  7594. animation.opts.start.call( elem, animation );
  7595. }
  7596. // Attach callbacks from options
  7597. animation
  7598. .progress( animation.opts.progress )
  7599. .done( animation.opts.done, animation.opts.complete )
  7600. .fail( animation.opts.fail )
  7601. .always( animation.opts.always );
  7602. jQuery.fx.timer(
  7603. jQuery.extend( tick, {
  7604. elem: elem,
  7605. anim: animation,
  7606. queue: animation.opts.queue
  7607. } )
  7608. );
  7609. return animation;
  7610. }
  7611. jQuery.Animation = jQuery.extend( Animation, {
  7612. tweeners: {
  7613. "*": [ function( prop, value ) {
  7614. var tween = this.createTween( prop, value );
  7615. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  7616. return tween;
  7617. } ]
  7618. },
  7619. tweener: function( props, callback ) {
  7620. if ( isFunction( props ) ) {
  7621. callback = props;
  7622. props = [ "*" ];
  7623. } else {
  7624. props = props.match( rnothtmlwhite );
  7625. }
  7626. var prop,
  7627. index = 0,
  7628. length = props.length;
  7629. for ( ; index < length; index++ ) {
  7630. prop = props[ index ];
  7631. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  7632. Animation.tweeners[ prop ].unshift( callback );
  7633. }
  7634. },
  7635. prefilters: [ defaultPrefilter ],
  7636. prefilter: function( callback, prepend ) {
  7637. if ( prepend ) {
  7638. Animation.prefilters.unshift( callback );
  7639. } else {
  7640. Animation.prefilters.push( callback );
  7641. }
  7642. }
  7643. } );
  7644. jQuery.speed = function( speed, easing, fn ) {
  7645. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  7646. complete: fn || !fn && easing ||
  7647. isFunction( speed ) && speed,
  7648. duration: speed,
  7649. easing: fn && easing || easing && !isFunction( easing ) && easing
  7650. };
  7651. // Go to the end state if fx are off
  7652. if ( jQuery.fx.off ) {
  7653. opt.duration = 0;
  7654. } else {
  7655. if ( typeof opt.duration !== "number" ) {
  7656. if ( opt.duration in jQuery.fx.speeds ) {
  7657. opt.duration = jQuery.fx.speeds[ opt.duration ];
  7658. } else {
  7659. opt.duration = jQuery.fx.speeds._default;
  7660. }
  7661. }
  7662. }
  7663. // Normalize opt.queue - true/undefined/null -> "fx"
  7664. if ( opt.queue == null || opt.queue === true ) {
  7665. opt.queue = "fx";
  7666. }
  7667. // Queueing
  7668. opt.old = opt.complete;
  7669. opt.complete = function() {
  7670. if ( isFunction( opt.old ) ) {
  7671. opt.old.call( this );
  7672. }
  7673. if ( opt.queue ) {
  7674. jQuery.dequeue( this, opt.queue );
  7675. }
  7676. };
  7677. return opt;
  7678. };
  7679. jQuery.fn.extend( {
  7680. fadeTo: function( speed, to, easing, callback ) {
  7681. // Show any hidden elements after setting opacity to 0
  7682. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  7683. // Animate to the value specified
  7684. .end().animate( { opacity: to }, speed, easing, callback );
  7685. },
  7686. animate: function( prop, speed, easing, callback ) {
  7687. var empty = jQuery.isEmptyObject( prop ),
  7688. optall = jQuery.speed( speed, easing, callback ),
  7689. doAnimation = function() {
  7690. // Operate on a copy of prop so per-property easing won't be lost
  7691. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  7692. // Empty animations, or finishing resolves immediately
  7693. if ( empty || dataPriv.get( this, "finish" ) ) {
  7694. anim.stop( true );
  7695. }
  7696. };
  7697. doAnimation.finish = doAnimation;
  7698. return empty || optall.queue === false ?
  7699. this.each( doAnimation ) :
  7700. this.queue( optall.queue, doAnimation );
  7701. },
  7702. stop: function( type, clearQueue, gotoEnd ) {
  7703. var stopQueue = function( hooks ) {
  7704. var stop = hooks.stop;
  7705. delete hooks.stop;
  7706. stop( gotoEnd );
  7707. };
  7708. if ( typeof type !== "string" ) {
  7709. gotoEnd = clearQueue;
  7710. clearQueue = type;
  7711. type = undefined;
  7712. }
  7713. if ( clearQueue && type !== false ) {
  7714. this.queue( type || "fx", [] );
  7715. }
  7716. return this.each( function() {
  7717. var dequeue = true,
  7718. index = type != null && type + "queueHooks",
  7719. timers = jQuery.timers,
  7720. data = dataPriv.get( this );
  7721. if ( index ) {
  7722. if ( data[ index ] && data[ index ].stop ) {
  7723. stopQueue( data[ index ] );
  7724. }
  7725. } else {
  7726. for ( index in data ) {
  7727. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  7728. stopQueue( data[ index ] );
  7729. }
  7730. }
  7731. }
  7732. for ( index = timers.length; index--; ) {
  7733. if ( timers[ index ].elem === this &&
  7734. ( type == null || timers[ index ].queue === type ) ) {
  7735. timers[ index ].anim.stop( gotoEnd );
  7736. dequeue = false;
  7737. timers.splice( index, 1 );
  7738. }
  7739. }
  7740. // Start the next in the queue if the last step wasn't forced.
  7741. // Timers currently will call their complete callbacks, which
  7742. // will dequeue but only if they were gotoEnd.
  7743. if ( dequeue || !gotoEnd ) {
  7744. jQuery.dequeue( this, type );
  7745. }
  7746. } );
  7747. },
  7748. finish: function( type ) {
  7749. if ( type !== false ) {
  7750. type = type || "fx";
  7751. }
  7752. return this.each( function() {
  7753. var index,
  7754. data = dataPriv.get( this ),
  7755. queue = data[ type + "queue" ],
  7756. hooks = data[ type + "queueHooks" ],
  7757. timers = jQuery.timers,
  7758. length = queue ? queue.length : 0;
  7759. // Enable finishing flag on private data
  7760. data.finish = true;
  7761. // Empty the queue first
  7762. jQuery.queue( this, type, [] );
  7763. if ( hooks && hooks.stop ) {
  7764. hooks.stop.call( this, true );
  7765. }
  7766. // Look for any active animations, and finish them
  7767. for ( index = timers.length; index--; ) {
  7768. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  7769. timers[ index ].anim.stop( true );
  7770. timers.splice( index, 1 );
  7771. }
  7772. }
  7773. // Look for any animations in the old queue and finish them
  7774. for ( index = 0; index < length; index++ ) {
  7775. if ( queue[ index ] && queue[ index ].finish ) {
  7776. queue[ index ].finish.call( this );
  7777. }
  7778. }
  7779. // Turn off finishing flag
  7780. delete data.finish;
  7781. } );
  7782. }
  7783. } );
  7784. jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
  7785. var cssFn = jQuery.fn[ name ];
  7786. jQuery.fn[ name ] = function( speed, easing, callback ) {
  7787. return speed == null || typeof speed === "boolean" ?
  7788. cssFn.apply( this, arguments ) :
  7789. this.animate( genFx( name, true ), speed, easing, callback );
  7790. };
  7791. } );
  7792. // Generate shortcuts for custom animations
  7793. jQuery.each( {
  7794. slideDown: genFx( "show" ),
  7795. slideUp: genFx( "hide" ),
  7796. slideToggle: genFx( "toggle" ),
  7797. fadeIn: { opacity: "show" },
  7798. fadeOut: { opacity: "hide" },
  7799. fadeToggle: { opacity: "toggle" }
  7800. }, function( name, props ) {
  7801. jQuery.fn[ name ] = function( speed, easing, callback ) {
  7802. return this.animate( props, speed, easing, callback );
  7803. };
  7804. } );
  7805. jQuery.timers = [];
  7806. jQuery.fx.tick = function() {
  7807. var timer,
  7808. i = 0,
  7809. timers = jQuery.timers;
  7810. fxNow = Date.now();
  7811. for ( ; i < timers.length; i++ ) {
  7812. timer = timers[ i ];
  7813. // Run the timer and safely remove it when done (allowing for external removal)
  7814. if ( !timer() && timers[ i ] === timer ) {
  7815. timers.splice( i--, 1 );
  7816. }
  7817. }
  7818. if ( !timers.length ) {
  7819. jQuery.fx.stop();
  7820. }
  7821. fxNow = undefined;
  7822. };
  7823. jQuery.fx.timer = function( timer ) {
  7824. jQuery.timers.push( timer );
  7825. jQuery.fx.start();
  7826. };
  7827. jQuery.fx.interval = 13;
  7828. jQuery.fx.start = function() {
  7829. if ( inProgress ) {
  7830. return;
  7831. }
  7832. inProgress = true;
  7833. schedule();
  7834. };
  7835. jQuery.fx.stop = function() {
  7836. inProgress = null;
  7837. };
  7838. jQuery.fx.speeds = {
  7839. slow: 600,
  7840. fast: 200,
  7841. // Default speed
  7842. _default: 400
  7843. };
  7844. // Based off of the plugin by Clint Helfers, with permission.
  7845. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  7846. jQuery.fn.delay = function( time, type ) {
  7847. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  7848. type = type || "fx";
  7849. return this.queue( type, function( next, hooks ) {
  7850. var timeout = window.setTimeout( next, time );
  7851. hooks.stop = function() {
  7852. window.clearTimeout( timeout );
  7853. };
  7854. } );
  7855. };
  7856. ( function() {
  7857. var input = document.createElement( "input" ),
  7858. select = document.createElement( "select" ),
  7859. opt = select.appendChild( document.createElement( "option" ) );
  7860. input.type = "checkbox";
  7861. // Support: Android <=4.3 only
  7862. // Default value for a checkbox should be "on"
  7863. support.checkOn = input.value !== "";
  7864. // Support: IE <=11 only
  7865. // Must access selectedIndex to make default options select
  7866. support.optSelected = opt.selected;
  7867. // Support: IE <=11 only
  7868. // An input loses its value after becoming a radio
  7869. input = document.createElement( "input" );
  7870. input.value = "t";
  7871. input.type = "radio";
  7872. support.radioValue = input.value === "t";
  7873. } )();
  7874. var boolHook,
  7875. attrHandle = jQuery.expr.attrHandle;
  7876. jQuery.fn.extend( {
  7877. attr: function( name, value ) {
  7878. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  7879. },
  7880. removeAttr: function( name ) {
  7881. return this.each( function() {
  7882. jQuery.removeAttr( this, name );
  7883. } );
  7884. }
  7885. } );
  7886. jQuery.extend( {
  7887. attr: function( elem, name, value ) {
  7888. var ret, hooks,
  7889. nType = elem.nodeType;
  7890. // Don't get/set attributes on text, comment and attribute nodes
  7891. if ( nType === 3 || nType === 8 || nType === 2 ) {
  7892. return;
  7893. }
  7894. // Fallback to prop when attributes are not supported
  7895. if ( typeof elem.getAttribute === "undefined" ) {
  7896. return jQuery.prop( elem, name, value );
  7897. }
  7898. // Attribute hooks are determined by the lowercase version
  7899. // Grab necessary hook if one is defined
  7900. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  7901. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  7902. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  7903. }
  7904. if ( value !== undefined ) {
  7905. if ( value === null ) {
  7906. jQuery.removeAttr( elem, name );
  7907. return;
  7908. }
  7909. if ( hooks && "set" in hooks &&
  7910. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  7911. return ret;
  7912. }
  7913. elem.setAttribute( name, value + "" );
  7914. return value;
  7915. }
  7916. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  7917. return ret;
  7918. }
  7919. ret = jQuery.find.attr( elem, name );
  7920. // Non-existent attributes return null, we normalize to undefined
  7921. return ret == null ? undefined : ret;
  7922. },
  7923. attrHooks: {
  7924. type: {
  7925. set: function( elem, value ) {
  7926. if ( !support.radioValue && value === "radio" &&
  7927. nodeName( elem, "input" ) ) {
  7928. var val = elem.value;
  7929. elem.setAttribute( "type", value );
  7930. if ( val ) {
  7931. elem.value = val;
  7932. }
  7933. return value;
  7934. }
  7935. }
  7936. }
  7937. },
  7938. removeAttr: function( elem, value ) {
  7939. var name,
  7940. i = 0,
  7941. // Attribute names can contain non-HTML whitespace characters
  7942. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  7943. attrNames = value && value.match( rnothtmlwhite );
  7944. if ( attrNames && elem.nodeType === 1 ) {
  7945. while ( ( name = attrNames[ i++ ] ) ) {
  7946. elem.removeAttribute( name );
  7947. }
  7948. }
  7949. }
  7950. } );
  7951. // Hooks for boolean attributes
  7952. boolHook = {
  7953. set: function( elem, value, name ) {
  7954. if ( value === false ) {
  7955. // Remove boolean attributes when set to false
  7956. jQuery.removeAttr( elem, name );
  7957. } else {
  7958. elem.setAttribute( name, name );
  7959. }
  7960. return name;
  7961. }
  7962. };
  7963. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  7964. var getter = attrHandle[ name ] || jQuery.find.attr;
  7965. attrHandle[ name ] = function( elem, name, isXML ) {
  7966. var ret, handle,
  7967. lowercaseName = name.toLowerCase();
  7968. if ( !isXML ) {
  7969. // Avoid an infinite loop by temporarily removing this function from the getter
  7970. handle = attrHandle[ lowercaseName ];
  7971. attrHandle[ lowercaseName ] = ret;
  7972. ret = getter( elem, name, isXML ) != null ?
  7973. lowercaseName :
  7974. null;
  7975. attrHandle[ lowercaseName ] = handle;
  7976. }
  7977. return ret;
  7978. };
  7979. } );
  7980. var rfocusable = /^(?:input|select|textarea|button)$/i,
  7981. rclickable = /^(?:a|area)$/i;
  7982. jQuery.fn.extend( {
  7983. prop: function( name, value ) {
  7984. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  7985. },
  7986. removeProp: function( name ) {
  7987. return this.each( function() {
  7988. delete this[ jQuery.propFix[ name ] || name ];
  7989. } );
  7990. }
  7991. } );
  7992. jQuery.extend( {
  7993. prop: function( elem, name, value ) {
  7994. var ret, hooks,
  7995. nType = elem.nodeType;
  7996. // Don't get/set properties on text, comment and attribute nodes
  7997. if ( nType === 3 || nType === 8 || nType === 2 ) {
  7998. return;
  7999. }
  8000. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  8001. // Fix name and attach hooks
  8002. name = jQuery.propFix[ name ] || name;
  8003. hooks = jQuery.propHooks[ name ];
  8004. }
  8005. if ( value !== undefined ) {
  8006. if ( hooks && "set" in hooks &&
  8007. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  8008. return ret;
  8009. }
  8010. return ( elem[ name ] = value );
  8011. }
  8012. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  8013. return ret;
  8014. }
  8015. return elem[ name ];
  8016. },
  8017. propHooks: {
  8018. tabIndex: {
  8019. get: function( elem ) {
  8020. // Support: IE <=9 - 11 only
  8021. // elem.tabIndex doesn't always return the
  8022. // correct value when it hasn't been explicitly set
  8023. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  8024. // Use proper attribute retrieval(#12072)
  8025. var tabindex = jQuery.find.attr( elem, "tabindex" );
  8026. if ( tabindex ) {
  8027. return parseInt( tabindex, 10 );
  8028. }
  8029. if (
  8030. rfocusable.test( elem.nodeName ) ||
  8031. rclickable.test( elem.nodeName ) &&
  8032. elem.href
  8033. ) {
  8034. return 0;
  8035. }
  8036. return -1;
  8037. }
  8038. }
  8039. },
  8040. propFix: {
  8041. "for": "htmlFor",
  8042. "class": "className"
  8043. }
  8044. } );
  8045. // Support: IE <=11 only
  8046. // Accessing the selectedIndex property
  8047. // forces the browser to respect setting selected
  8048. // on the option
  8049. // The getter ensures a default option is selected
  8050. // when in an optgroup
  8051. // eslint rule "no-unused-expressions" is disabled for this code
  8052. // since it considers such accessions noop
  8053. if ( !support.optSelected ) {
  8054. jQuery.propHooks.selected = {
  8055. get: function( elem ) {
  8056. /* eslint no-unused-expressions: "off" */
  8057. var parent = elem.parentNode;
  8058. if ( parent && parent.parentNode ) {
  8059. parent.parentNode.selectedIndex;
  8060. }
  8061. return null;
  8062. },
  8063. set: function( elem ) {
  8064. /* eslint no-unused-expressions: "off" */
  8065. var parent = elem.parentNode;
  8066. if ( parent ) {
  8067. parent.selectedIndex;
  8068. if ( parent.parentNode ) {
  8069. parent.parentNode.selectedIndex;
  8070. }
  8071. }
  8072. }
  8073. };
  8074. }
  8075. jQuery.each( [
  8076. "tabIndex",
  8077. "readOnly",
  8078. "maxLength",
  8079. "cellSpacing",
  8080. "cellPadding",
  8081. "rowSpan",
  8082. "colSpan",
  8083. "useMap",
  8084. "frameBorder",
  8085. "contentEditable"
  8086. ], function() {
  8087. jQuery.propFix[ this.toLowerCase() ] = this;
  8088. } );
  8089. // Strip and collapse whitespace according to HTML spec
  8090. // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
  8091. function stripAndCollapse( value ) {
  8092. var tokens = value.match( rnothtmlwhite ) || [];
  8093. return tokens.join( " " );
  8094. }
  8095. function getClass( elem ) {
  8096. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  8097. }
  8098. function classesToArray( value ) {
  8099. if ( Array.isArray( value ) ) {
  8100. return value;
  8101. }
  8102. if ( typeof value === "string" ) {
  8103. return value.match( rnothtmlwhite ) || [];
  8104. }
  8105. return [];
  8106. }
  8107. jQuery.fn.extend( {
  8108. addClass: function( value ) {
  8109. var classes, elem, cur, curValue, clazz, j, finalValue,
  8110. i = 0;
  8111. if ( isFunction( value ) ) {
  8112. return this.each( function( j ) {
  8113. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  8114. } );
  8115. }
  8116. classes = classesToArray( value );
  8117. if ( classes.length ) {
  8118. while ( ( elem = this[ i++ ] ) ) {
  8119. curValue = getClass( elem );
  8120. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  8121. if ( cur ) {
  8122. j = 0;
  8123. while ( ( clazz = classes[ j++ ] ) ) {
  8124. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  8125. cur += clazz + " ";
  8126. }
  8127. }
  8128. // Only assign if different to avoid unneeded rendering.
  8129. finalValue = stripAndCollapse( cur );
  8130. if ( curValue !== finalValue ) {
  8131. elem.setAttribute( "class", finalValue );
  8132. }
  8133. }
  8134. }
  8135. }
  8136. return this;
  8137. },
  8138. removeClass: function( value ) {
  8139. var classes, elem, cur, curValue, clazz, j, finalValue,
  8140. i = 0;
  8141. if ( isFunction( value ) ) {
  8142. return this.each( function( j ) {
  8143. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  8144. } );
  8145. }
  8146. if ( !arguments.length ) {
  8147. return this.attr( "class", "" );
  8148. }
  8149. classes = classesToArray( value );
  8150. if ( classes.length ) {
  8151. while ( ( elem = this[ i++ ] ) ) {
  8152. curValue = getClass( elem );
  8153. // This expression is here for better compressibility (see addClass)
  8154. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  8155. if ( cur ) {
  8156. j = 0;
  8157. while ( ( clazz = classes[ j++ ] ) ) {
  8158. // Remove *all* instances
  8159. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  8160. cur = cur.replace( " " + clazz + " ", " " );
  8161. }
  8162. }
  8163. // Only assign if different to avoid unneeded rendering.
  8164. finalValue = stripAndCollapse( cur );
  8165. if ( curValue !== finalValue ) {
  8166. elem.setAttribute( "class", finalValue );
  8167. }
  8168. }
  8169. }
  8170. }
  8171. return this;
  8172. },
  8173. toggleClass: function( value, stateVal ) {
  8174. var type = typeof value,
  8175. isValidValue = type === "string" || Array.isArray( value );
  8176. if ( typeof stateVal === "boolean" && isValidValue ) {
  8177. return stateVal ? this.addClass( value ) : this.removeClass( value );
  8178. }
  8179. if ( isFunction( value ) ) {
  8180. return this.each( function( i ) {
  8181. jQuery( this ).toggleClass(
  8182. value.call( this, i, getClass( this ), stateVal ),
  8183. stateVal
  8184. );
  8185. } );
  8186. }
  8187. return this.each( function() {
  8188. var className, i, self, classNames;
  8189. if ( isValidValue ) {
  8190. // Toggle individual class names
  8191. i = 0;
  8192. self = jQuery( this );
  8193. classNames = classesToArray( value );
  8194. while ( ( className = classNames[ i++ ] ) ) {
  8195. // Check each className given, space separated list
  8196. if ( self.hasClass( className ) ) {
  8197. self.removeClass( className );
  8198. } else {
  8199. self.addClass( className );
  8200. }
  8201. }
  8202. // Toggle whole class name
  8203. } else if ( value === undefined || type === "boolean" ) {
  8204. className = getClass( this );
  8205. if ( className ) {
  8206. // Store className if set
  8207. dataPriv.set( this, "__className__", className );
  8208. }
  8209. // If the element has a class name or if we're passed `false`,
  8210. // then remove the whole classname (if there was one, the above saved it).
  8211. // Otherwise bring back whatever was previously saved (if anything),
  8212. // falling back to the empty string if nothing was stored.
  8213. if ( this.setAttribute ) {
  8214. this.setAttribute( "class",
  8215. className || value === false ?
  8216. "" :
  8217. dataPriv.get( this, "__className__" ) || ""
  8218. );
  8219. }
  8220. }
  8221. } );
  8222. },
  8223. hasClass: function( selector ) {
  8224. var className, elem,
  8225. i = 0;
  8226. className = " " + selector + " ";
  8227. while ( ( elem = this[ i++ ] ) ) {
  8228. if ( elem.nodeType === 1 &&
  8229. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  8230. return true;
  8231. }
  8232. }
  8233. return false;
  8234. }
  8235. } );
  8236. var rreturn = /\r/g;
  8237. jQuery.fn.extend( {
  8238. val: function( value ) {
  8239. var hooks, ret, valueIsFunction,
  8240. elem = this[ 0 ];
  8241. if ( !arguments.length ) {
  8242. if ( elem ) {
  8243. hooks = jQuery.valHooks[ elem.type ] ||
  8244. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  8245. if ( hooks &&
  8246. "get" in hooks &&
  8247. ( ret = hooks.get( elem, "value" ) ) !== undefined
  8248. ) {
  8249. return ret;
  8250. }
  8251. ret = elem.value;
  8252. // Handle most common string cases
  8253. if ( typeof ret === "string" ) {
  8254. return ret.replace( rreturn, "" );
  8255. }
  8256. // Handle cases where value is null/undef or number
  8257. return ret == null ? "" : ret;
  8258. }
  8259. return;
  8260. }
  8261. valueIsFunction = isFunction( value );
  8262. return this.each( function( i ) {
  8263. var val;
  8264. if ( this.nodeType !== 1 ) {
  8265. return;
  8266. }
  8267. if ( valueIsFunction ) {
  8268. val = value.call( this, i, jQuery( this ).val() );
  8269. } else {
  8270. val = value;
  8271. }
  8272. // Treat null/undefined as ""; convert numbers to string
  8273. if ( val == null ) {
  8274. val = "";
  8275. } else if ( typeof val === "number" ) {
  8276. val += "";
  8277. } else if ( Array.isArray( val ) ) {
  8278. val = jQuery.map( val, function( value ) {
  8279. return value == null ? "" : value + "";
  8280. } );
  8281. }
  8282. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  8283. // If set returns undefined, fall back to normal setting
  8284. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  8285. this.value = val;
  8286. }
  8287. } );
  8288. }
  8289. } );
  8290. jQuery.extend( {
  8291. valHooks: {
  8292. option: {
  8293. get: function( elem ) {
  8294. var val = jQuery.find.attr( elem, "value" );
  8295. return val != null ?
  8296. val :
  8297. // Support: IE <=10 - 11 only
  8298. // option.text throws exceptions (#14686, #14858)
  8299. // Strip and collapse whitespace
  8300. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  8301. stripAndCollapse( jQuery.text( elem ) );
  8302. }
  8303. },
  8304. select: {
  8305. get: function( elem ) {
  8306. var value, option, i,
  8307. options = elem.options,
  8308. index = elem.selectedIndex,
  8309. one = elem.type === "select-one",
  8310. values = one ? null : [],
  8311. max = one ? index + 1 : options.length;
  8312. if ( index < 0 ) {
  8313. i = max;
  8314. } else {
  8315. i = one ? index : 0;
  8316. }
  8317. // Loop through all the selected options
  8318. for ( ; i < max; i++ ) {
  8319. option = options[ i ];
  8320. // Support: IE <=9 only
  8321. // IE8-9 doesn't update selected after form reset (#2551)
  8322. if ( ( option.selected || i === index ) &&
  8323. // Don't return options that are disabled or in a disabled optgroup
  8324. !option.disabled &&
  8325. ( !option.parentNode.disabled ||
  8326. !nodeName( option.parentNode, "optgroup" ) ) ) {
  8327. // Get the specific value for the option
  8328. value = jQuery( option ).val();
  8329. // We don't need an array for one selects
  8330. if ( one ) {
  8331. return value;
  8332. }
  8333. // Multi-Selects return an array
  8334. values.push( value );
  8335. }
  8336. }
  8337. return values;
  8338. },
  8339. set: function( elem, value ) {
  8340. var optionSet, option,
  8341. options = elem.options,
  8342. values = jQuery.makeArray( value ),
  8343. i = options.length;
  8344. while ( i-- ) {
  8345. option = options[ i ];
  8346. /* eslint-disable no-cond-assign */
  8347. if ( option.selected =
  8348. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  8349. ) {
  8350. optionSet = true;
  8351. }
  8352. /* eslint-enable no-cond-assign */
  8353. }
  8354. // Force browsers to behave consistently when non-matching value is set
  8355. if ( !optionSet ) {
  8356. elem.selectedIndex = -1;
  8357. }
  8358. return values;
  8359. }
  8360. }
  8361. }
  8362. } );
  8363. // Radios and checkboxes getter/setter
  8364. jQuery.each( [ "radio", "checkbox" ], function() {
  8365. jQuery.valHooks[ this ] = {
  8366. set: function( elem, value ) {
  8367. if ( Array.isArray( value ) ) {
  8368. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  8369. }
  8370. }
  8371. };
  8372. if ( !support.checkOn ) {
  8373. jQuery.valHooks[ this ].get = function( elem ) {
  8374. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  8375. };
  8376. }
  8377. } );
  8378. // Return jQuery for attributes-only inclusion
  8379. support.focusin = "onfocusin" in window;
  8380. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  8381. stopPropagationCallback = function( e ) {
  8382. e.stopPropagation();
  8383. };
  8384. jQuery.extend( jQuery.event, {
  8385. trigger: function( event, data, elem, onlyHandlers ) {
  8386. var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
  8387. eventPath = [ elem || document ],
  8388. type = hasOwn.call( event, "type" ) ? event.type : event,
  8389. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  8390. cur = lastElement = tmp = elem = elem || document;
  8391. // Don't do events on text and comment nodes
  8392. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  8393. return;
  8394. }
  8395. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  8396. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  8397. return;
  8398. }
  8399. if ( type.indexOf( "." ) > -1 ) {
  8400. // Namespaced trigger; create a regexp to match event type in handle()
  8401. namespaces = type.split( "." );
  8402. type = namespaces.shift();
  8403. namespaces.sort();
  8404. }
  8405. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  8406. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  8407. event = event[ jQuery.expando ] ?
  8408. event :
  8409. new jQuery.Event( type, typeof event === "object" && event );
  8410. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  8411. event.isTrigger = onlyHandlers ? 2 : 3;
  8412. event.namespace = namespaces.join( "." );
  8413. event.rnamespace = event.namespace ?
  8414. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  8415. null;
  8416. // Clean up the event in case it is being reused
  8417. event.result = undefined;
  8418. if ( !event.target ) {
  8419. event.target = elem;
  8420. }
  8421. // Clone any incoming data and prepend the event, creating the handler arg list
  8422. data = data == null ?
  8423. [ event ] :
  8424. jQuery.makeArray( data, [ event ] );
  8425. // Allow special events to draw outside the lines
  8426. special = jQuery.event.special[ type ] || {};
  8427. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  8428. return;
  8429. }
  8430. // Determine event propagation path in advance, per W3C events spec (#9951)
  8431. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  8432. if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
  8433. bubbleType = special.delegateType || type;
  8434. if ( !rfocusMorph.test( bubbleType + type ) ) {
  8435. cur = cur.parentNode;
  8436. }
  8437. for ( ; cur; cur = cur.parentNode ) {
  8438. eventPath.push( cur );
  8439. tmp = cur;
  8440. }
  8441. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  8442. if ( tmp === ( elem.ownerDocument || document ) ) {
  8443. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  8444. }
  8445. }
  8446. // Fire handlers on the event path
  8447. i = 0;
  8448. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  8449. lastElement = cur;
  8450. event.type = i > 1 ?
  8451. bubbleType :
  8452. special.bindType || type;
  8453. // jQuery handler
  8454. handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
  8455. dataPriv.get( cur, "handle" );
  8456. if ( handle ) {
  8457. handle.apply( cur, data );
  8458. }
  8459. // Native handler
  8460. handle = ontype && cur[ ontype ];
  8461. if ( handle && handle.apply && acceptData( cur ) ) {
  8462. event.result = handle.apply( cur, data );
  8463. if ( event.result === false ) {
  8464. event.preventDefault();
  8465. }
  8466. }
  8467. }
  8468. event.type = type;
  8469. // If nobody prevented the default action, do it now
  8470. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  8471. if ( ( !special._default ||
  8472. special._default.apply( eventPath.pop(), data ) === false ) &&
  8473. acceptData( elem ) ) {
  8474. // Call a native DOM method on the target with the same name as the event.
  8475. // Don't do default actions on window, that's where global variables be (#6170)
  8476. if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
  8477. // Don't re-trigger an onFOO event when we call its FOO() method
  8478. tmp = elem[ ontype ];
  8479. if ( tmp ) {
  8480. elem[ ontype ] = null;
  8481. }
  8482. // Prevent re-triggering of the same event, since we already bubbled it above
  8483. jQuery.event.triggered = type;
  8484. if ( event.isPropagationStopped() ) {
  8485. lastElement.addEventListener( type, stopPropagationCallback );
  8486. }
  8487. elem[ type ]();
  8488. if ( event.isPropagationStopped() ) {
  8489. lastElement.removeEventListener( type, stopPropagationCallback );
  8490. }
  8491. jQuery.event.triggered = undefined;
  8492. if ( tmp ) {
  8493. elem[ ontype ] = tmp;
  8494. }
  8495. }
  8496. }
  8497. }
  8498. return event.result;
  8499. },
  8500. // Piggyback on a donor event to simulate a different one
  8501. // Used only for `focus(in | out)` events
  8502. simulate: function( type, elem, event ) {
  8503. var e = jQuery.extend(
  8504. new jQuery.Event(),
  8505. event,
  8506. {
  8507. type: type,
  8508. isSimulated: true
  8509. }
  8510. );
  8511. jQuery.event.trigger( e, null, elem );
  8512. }
  8513. } );
  8514. jQuery.fn.extend( {
  8515. trigger: function( type, data ) {
  8516. return this.each( function() {
  8517. jQuery.event.trigger( type, data, this );
  8518. } );
  8519. },
  8520. triggerHandler: function( type, data ) {
  8521. var elem = this[ 0 ];
  8522. if ( elem ) {
  8523. return jQuery.event.trigger( type, data, elem, true );
  8524. }
  8525. }
  8526. } );
  8527. // Support: Firefox <=44
  8528. // Firefox doesn't have focus(in | out) events
  8529. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  8530. //
  8531. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  8532. // focus(in | out) events fire after focus & blur events,
  8533. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  8534. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  8535. if ( !support.focusin ) {
  8536. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  8537. // Attach a single capturing handler on the document while someone wants focusin/focusout
  8538. var handler = function( event ) {
  8539. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  8540. };
  8541. jQuery.event.special[ fix ] = {
  8542. setup: function() {
  8543. var doc = this.ownerDocument || this,
  8544. attaches = dataPriv.access( doc, fix );
  8545. if ( !attaches ) {
  8546. doc.addEventListener( orig, handler, true );
  8547. }
  8548. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  8549. },
  8550. teardown: function() {
  8551. var doc = this.ownerDocument || this,
  8552. attaches = dataPriv.access( doc, fix ) - 1;
  8553. if ( !attaches ) {
  8554. doc.removeEventListener( orig, handler, true );
  8555. dataPriv.remove( doc, fix );
  8556. } else {
  8557. dataPriv.access( doc, fix, attaches );
  8558. }
  8559. }
  8560. };
  8561. } );
  8562. }
  8563. var location = window.location;
  8564. var nonce = Date.now();
  8565. var rquery = ( /\?/ );
  8566. // Cross-browser xml parsing
  8567. jQuery.parseXML = function( data ) {
  8568. var xml;
  8569. if ( !data || typeof data !== "string" ) {
  8570. return null;
  8571. }
  8572. // Support: IE 9 - 11 only
  8573. // IE throws on parseFromString with invalid input.
  8574. try {
  8575. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  8576. } catch ( e ) {
  8577. xml = undefined;
  8578. }
  8579. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  8580. jQuery.error( "Invalid XML: " + data );
  8581. }
  8582. return xml;
  8583. };
  8584. var
  8585. rbracket = /\[\]$/,
  8586. rCRLF = /\r?\n/g,
  8587. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  8588. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  8589. function buildParams( prefix, obj, traditional, add ) {
  8590. var name;
  8591. if ( Array.isArray( obj ) ) {
  8592. // Serialize array item.
  8593. jQuery.each( obj, function( i, v ) {
  8594. if ( traditional || rbracket.test( prefix ) ) {
  8595. // Treat each array item as a scalar.
  8596. add( prefix, v );
  8597. } else {
  8598. // Item is non-scalar (array or object), encode its numeric index.
  8599. buildParams(
  8600. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  8601. v,
  8602. traditional,
  8603. add
  8604. );
  8605. }
  8606. } );
  8607. } else if ( !traditional && toType( obj ) === "object" ) {
  8608. // Serialize object item.
  8609. for ( name in obj ) {
  8610. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  8611. }
  8612. } else {
  8613. // Serialize scalar item.
  8614. add( prefix, obj );
  8615. }
  8616. }
  8617. // Serialize an array of form elements or a set of
  8618. // key/values into a query string
  8619. jQuery.param = function( a, traditional ) {
  8620. var prefix,
  8621. s = [],
  8622. add = function( key, valueOrFunction ) {
  8623. // If value is a function, invoke it and use its return value
  8624. var value = isFunction( valueOrFunction ) ?
  8625. valueOrFunction() :
  8626. valueOrFunction;
  8627. s[ s.length ] = encodeURIComponent( key ) + "=" +
  8628. encodeURIComponent( value == null ? "" : value );
  8629. };
  8630. if ( a == null ) {
  8631. return "";
  8632. }
  8633. // If an array was passed in, assume that it is an array of form elements.
  8634. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  8635. // Serialize the form elements
  8636. jQuery.each( a, function() {
  8637. add( this.name, this.value );
  8638. } );
  8639. } else {
  8640. // If traditional, encode the "old" way (the way 1.3.2 or older
  8641. // did it), otherwise encode params recursively.
  8642. for ( prefix in a ) {
  8643. buildParams( prefix, a[ prefix ], traditional, add );
  8644. }
  8645. }
  8646. // Return the resulting serialization
  8647. return s.join( "&" );
  8648. };
  8649. jQuery.fn.extend( {
  8650. serialize: function() {
  8651. return jQuery.param( this.serializeArray() );
  8652. },
  8653. serializeArray: function() {
  8654. return this.map( function() {
  8655. // Can add propHook for "elements" to filter or add form elements
  8656. var elements = jQuery.prop( this, "elements" );
  8657. return elements ? jQuery.makeArray( elements ) : this;
  8658. } )
  8659. .filter( function() {
  8660. var type = this.type;
  8661. // Use .is( ":disabled" ) so that fieldset[disabled] works
  8662. return this.name && !jQuery( this ).is( ":disabled" ) &&
  8663. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  8664. ( this.checked || !rcheckableType.test( type ) );
  8665. } )
  8666. .map( function( i, elem ) {
  8667. var val = jQuery( this ).val();
  8668. if ( val == null ) {
  8669. return null;
  8670. }
  8671. if ( Array.isArray( val ) ) {
  8672. return jQuery.map( val, function( val ) {
  8673. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  8674. } );
  8675. }
  8676. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  8677. } ).get();
  8678. }
  8679. } );
  8680. var
  8681. r20 = /%20/g,
  8682. rhash = /#.*$/,
  8683. rantiCache = /([?&])_=[^&]*/,
  8684. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  8685. // #7653, #8125, #8152: local protocol detection
  8686. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  8687. rnoContent = /^(?:GET|HEAD)$/,
  8688. rprotocol = /^\/\//,
  8689. /* Prefilters
  8690. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  8691. * 2) These are called:
  8692. * - BEFORE asking for a transport
  8693. * - AFTER param serialization (s.data is a string if s.processData is true)
  8694. * 3) key is the dataType
  8695. * 4) the catchall symbol "*" can be used
  8696. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  8697. */
  8698. prefilters = {},
  8699. /* Transports bindings
  8700. * 1) key is the dataType
  8701. * 2) the catchall symbol "*" can be used
  8702. * 3) selection will start with transport dataType and THEN go to "*" if needed
  8703. */
  8704. transports = {},
  8705. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  8706. allTypes = "*/".concat( "*" ),
  8707. // Anchor tag for parsing the document origin
  8708. originAnchor = document.createElement( "a" );
  8709. originAnchor.href = location.href;
  8710. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  8711. function addToPrefiltersOrTransports( structure ) {
  8712. // dataTypeExpression is optional and defaults to "*"
  8713. return function( dataTypeExpression, func ) {
  8714. if ( typeof dataTypeExpression !== "string" ) {
  8715. func = dataTypeExpression;
  8716. dataTypeExpression = "*";
  8717. }
  8718. var dataType,
  8719. i = 0,
  8720. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  8721. if ( isFunction( func ) ) {
  8722. // For each dataType in the dataTypeExpression
  8723. while ( ( dataType = dataTypes[ i++ ] ) ) {
  8724. // Prepend if requested
  8725. if ( dataType[ 0 ] === "+" ) {
  8726. dataType = dataType.slice( 1 ) || "*";
  8727. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  8728. // Otherwise append
  8729. } else {
  8730. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  8731. }
  8732. }
  8733. }
  8734. };
  8735. }
  8736. // Base inspection function for prefilters and transports
  8737. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  8738. var inspected = {},
  8739. seekingTransport = ( structure === transports );
  8740. function inspect( dataType ) {
  8741. var selected;
  8742. inspected[ dataType ] = true;
  8743. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  8744. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  8745. if ( typeof dataTypeOrTransport === "string" &&
  8746. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  8747. options.dataTypes.unshift( dataTypeOrTransport );
  8748. inspect( dataTypeOrTransport );
  8749. return false;
  8750. } else if ( seekingTransport ) {
  8751. return !( selected = dataTypeOrTransport );
  8752. }
  8753. } );
  8754. return selected;
  8755. }
  8756. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  8757. }
  8758. // A special extend for ajax options
  8759. // that takes "flat" options (not to be deep extended)
  8760. // Fixes #9887
  8761. function ajaxExtend( target, src ) {
  8762. var key, deep,
  8763. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  8764. for ( key in src ) {
  8765. if ( src[ key ] !== undefined ) {
  8766. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  8767. }
  8768. }
  8769. if ( deep ) {
  8770. jQuery.extend( true, target, deep );
  8771. }
  8772. return target;
  8773. }
  8774. /* Handles responses to an ajax request:
  8775. * - finds the right dataType (mediates between content-type and expected dataType)
  8776. * - returns the corresponding response
  8777. */
  8778. function ajaxHandleResponses( s, jqXHR, responses ) {
  8779. var ct, type, finalDataType, firstDataType,
  8780. contents = s.contents,
  8781. dataTypes = s.dataTypes;
  8782. // Remove auto dataType and get content-type in the process
  8783. while ( dataTypes[ 0 ] === "*" ) {
  8784. dataTypes.shift();
  8785. if ( ct === undefined ) {
  8786. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  8787. }
  8788. }
  8789. // Check if we're dealing with a known content-type
  8790. if ( ct ) {
  8791. for ( type in contents ) {
  8792. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  8793. dataTypes.unshift( type );
  8794. break;
  8795. }
  8796. }
  8797. }
  8798. // Check to see if we have a response for the expected dataType
  8799. if ( dataTypes[ 0 ] in responses ) {
  8800. finalDataType = dataTypes[ 0 ];
  8801. } else {
  8802. // Try convertible dataTypes
  8803. for ( type in responses ) {
  8804. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  8805. finalDataType = type;
  8806. break;
  8807. }
  8808. if ( !firstDataType ) {
  8809. firstDataType = type;
  8810. }
  8811. }
  8812. // Or just use first one
  8813. finalDataType = finalDataType || firstDataType;
  8814. }
  8815. // If we found a dataType
  8816. // We add the dataType to the list if needed
  8817. // and return the corresponding response
  8818. if ( finalDataType ) {
  8819. if ( finalDataType !== dataTypes[ 0 ] ) {
  8820. dataTypes.unshift( finalDataType );
  8821. }
  8822. return responses[ finalDataType ];
  8823. }
  8824. }
  8825. /* Chain conversions given the request and the original response
  8826. * Also sets the responseXXX fields on the jqXHR instance
  8827. */
  8828. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  8829. var conv2, current, conv, tmp, prev,
  8830. converters = {},
  8831. // Work with a copy of dataTypes in case we need to modify it for conversion
  8832. dataTypes = s.dataTypes.slice();
  8833. // Create converters map with lowercased keys
  8834. if ( dataTypes[ 1 ] ) {
  8835. for ( conv in s.converters ) {
  8836. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  8837. }
  8838. }
  8839. current = dataTypes.shift();
  8840. // Convert to each sequential dataType
  8841. while ( current ) {
  8842. if ( s.responseFields[ current ] ) {
  8843. jqXHR[ s.responseFields[ current ] ] = response;
  8844. }
  8845. // Apply the dataFilter if provided
  8846. if ( !prev && isSuccess && s.dataFilter ) {
  8847. response = s.dataFilter( response, s.dataType );
  8848. }
  8849. prev = current;
  8850. current = dataTypes.shift();
  8851. if ( current ) {
  8852. // There's only work to do if current dataType is non-auto
  8853. if ( current === "*" ) {
  8854. current = prev;
  8855. // Convert response if prev dataType is non-auto and differs from current
  8856. } else if ( prev !== "*" && prev !== current ) {
  8857. // Seek a direct converter
  8858. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  8859. // If none found, seek a pair
  8860. if ( !conv ) {
  8861. for ( conv2 in converters ) {
  8862. // If conv2 outputs current
  8863. tmp = conv2.split( " " );
  8864. if ( tmp[ 1 ] === current ) {
  8865. // If prev can be converted to accepted input
  8866. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  8867. converters[ "* " + tmp[ 0 ] ];
  8868. if ( conv ) {
  8869. // Condense equivalence converters
  8870. if ( conv === true ) {
  8871. conv = converters[ conv2 ];
  8872. // Otherwise, insert the intermediate dataType
  8873. } else if ( converters[ conv2 ] !== true ) {
  8874. current = tmp[ 0 ];
  8875. dataTypes.unshift( tmp[ 1 ] );
  8876. }
  8877. break;
  8878. }
  8879. }
  8880. }
  8881. }
  8882. // Apply converter (if not an equivalence)
  8883. if ( conv !== true ) {
  8884. // Unless errors are allowed to bubble, catch and return them
  8885. if ( conv && s.throws ) {
  8886. response = conv( response );
  8887. } else {
  8888. try {
  8889. response = conv( response );
  8890. } catch ( e ) {
  8891. return {
  8892. state: "parsererror",
  8893. error: conv ? e : "No conversion from " + prev + " to " + current
  8894. };
  8895. }
  8896. }
  8897. }
  8898. }
  8899. }
  8900. }
  8901. return { state: "success", data: response };
  8902. }
  8903. jQuery.extend( {
  8904. // Counter for holding the number of active queries
  8905. active: 0,
  8906. // Last-Modified header cache for next request
  8907. lastModified: {},
  8908. etag: {},
  8909. ajaxSettings: {
  8910. url: location.href,
  8911. type: "GET",
  8912. isLocal: rlocalProtocol.test( location.protocol ),
  8913. global: true,
  8914. processData: true,
  8915. async: true,
  8916. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  8917. /*
  8918. timeout: 0,
  8919. data: null,
  8920. dataType: null,
  8921. username: null,
  8922. password: null,
  8923. cache: null,
  8924. throws: false,
  8925. traditional: false,
  8926. headers: {},
  8927. */
  8928. accepts: {
  8929. "*": allTypes,
  8930. text: "text/plain",
  8931. html: "text/html",
  8932. xml: "application/xml, text/xml",
  8933. json: "application/json, text/javascript"
  8934. },
  8935. contents: {
  8936. xml: /\bxml\b/,
  8937. html: /\bhtml/,
  8938. json: /\bjson\b/
  8939. },
  8940. responseFields: {
  8941. xml: "responseXML",
  8942. text: "responseText",
  8943. json: "responseJSON"
  8944. },
  8945. // Data converters
  8946. // Keys separate source (or catchall "*") and destination types with a single space
  8947. converters: {
  8948. // Convert anything to text
  8949. "* text": String,
  8950. // Text to html (true = no transformation)
  8951. "text html": true,
  8952. // Evaluate text as a json expression
  8953. "text json": JSON.parse,
  8954. // Parse text as xml
  8955. "text xml": jQuery.parseXML
  8956. },
  8957. // For options that shouldn't be deep extended:
  8958. // you can add your own custom options here if
  8959. // and when you create one that shouldn't be
  8960. // deep extended (see ajaxExtend)
  8961. flatOptions: {
  8962. url: true,
  8963. context: true
  8964. }
  8965. },
  8966. // Creates a full fledged settings object into target
  8967. // with both ajaxSettings and settings fields.
  8968. // If target is omitted, writes into ajaxSettings.
  8969. ajaxSetup: function( target, settings ) {
  8970. return settings ?
  8971. // Building a settings object
  8972. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  8973. // Extending ajaxSettings
  8974. ajaxExtend( jQuery.ajaxSettings, target );
  8975. },
  8976. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  8977. ajaxTransport: addToPrefiltersOrTransports( transports ),
  8978. // Main method
  8979. ajax: function( url, options ) {
  8980. // If url is an object, simulate pre-1.5 signature
  8981. if ( typeof url === "object" ) {
  8982. options = url;
  8983. url = undefined;
  8984. }
  8985. // Force options to be an object
  8986. options = options || {};
  8987. var transport,
  8988. // URL without anti-cache param
  8989. cacheURL,
  8990. // Response headers
  8991. responseHeadersString,
  8992. responseHeaders,
  8993. // timeout handle
  8994. timeoutTimer,
  8995. // Url cleanup var
  8996. urlAnchor,
  8997. // Request state (becomes false upon send and true upon completion)
  8998. completed,
  8999. // To know if global events are to be dispatched
  9000. fireGlobals,
  9001. // Loop variable
  9002. i,
  9003. // uncached part of the url
  9004. uncached,
  9005. // Create the final options object
  9006. s = jQuery.ajaxSetup( {}, options ),
  9007. // Callbacks context
  9008. callbackContext = s.context || s,
  9009. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  9010. globalEventContext = s.context &&
  9011. ( callbackContext.nodeType || callbackContext.jquery ) ?
  9012. jQuery( callbackContext ) :
  9013. jQuery.event,
  9014. // Deferreds
  9015. deferred = jQuery.Deferred(),
  9016. completeDeferred = jQuery.Callbacks( "once memory" ),
  9017. // Status-dependent callbacks
  9018. statusCode = s.statusCode || {},
  9019. // Headers (they are sent all at once)
  9020. requestHeaders = {},
  9021. requestHeadersNames = {},
  9022. // Default abort message
  9023. strAbort = "canceled",
  9024. // Fake xhr
  9025. jqXHR = {
  9026. readyState: 0,
  9027. // Builds headers hashtable if needed
  9028. getResponseHeader: function( key ) {
  9029. var match;
  9030. if ( completed ) {
  9031. if ( !responseHeaders ) {
  9032. responseHeaders = {};
  9033. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  9034. responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
  9035. ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
  9036. .concat( match[ 2 ] );
  9037. }
  9038. }
  9039. match = responseHeaders[ key.toLowerCase() + " " ];
  9040. }
  9041. return match == null ? null : match.join( ", " );
  9042. },
  9043. // Raw string
  9044. getAllResponseHeaders: function() {
  9045. return completed ? responseHeadersString : null;
  9046. },
  9047. // Caches the header
  9048. setRequestHeader: function( name, value ) {
  9049. if ( completed == null ) {
  9050. name = requestHeadersNames[ name.toLowerCase() ] =
  9051. requestHeadersNames[ name.toLowerCase() ] || name;
  9052. requestHeaders[ name ] = value;
  9053. }
  9054. return this;
  9055. },
  9056. // Overrides response content-type header
  9057. overrideMimeType: function( type ) {
  9058. if ( completed == null ) {
  9059. s.mimeType = type;
  9060. }
  9061. return this;
  9062. },
  9063. // Status-dependent callbacks
  9064. statusCode: function( map ) {
  9065. var code;
  9066. if ( map ) {
  9067. if ( completed ) {
  9068. // Execute the appropriate callbacks
  9069. jqXHR.always( map[ jqXHR.status ] );
  9070. } else {
  9071. // Lazy-add the new callbacks in a way that preserves old ones
  9072. for ( code in map ) {
  9073. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  9074. }
  9075. }
  9076. }
  9077. return this;
  9078. },
  9079. // Cancel the request
  9080. abort: function( statusText ) {
  9081. var finalText = statusText || strAbort;
  9082. if ( transport ) {
  9083. transport.abort( finalText );
  9084. }
  9085. done( 0, finalText );
  9086. return this;
  9087. }
  9088. };
  9089. // Attach deferreds
  9090. deferred.promise( jqXHR );
  9091. // Add protocol if not provided (prefilters might expect it)
  9092. // Handle falsy url in the settings object (#10093: consistency with old signature)
  9093. // We also use the url parameter if available
  9094. s.url = ( ( url || s.url || location.href ) + "" )
  9095. .replace( rprotocol, location.protocol + "//" );
  9096. // Alias method option to type as per ticket #12004
  9097. s.type = options.method || options.type || s.method || s.type;
  9098. // Extract dataTypes list
  9099. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  9100. // A cross-domain request is in order when the origin doesn't match the current origin.
  9101. if ( s.crossDomain == null ) {
  9102. urlAnchor = document.createElement( "a" );
  9103. // Support: IE <=8 - 11, Edge 12 - 15
  9104. // IE throws exception on accessing the href property if url is malformed,
  9105. // e.g. http://example.com:80x/
  9106. try {
  9107. urlAnchor.href = s.url;
  9108. // Support: IE <=8 - 11 only
  9109. // Anchor's host property isn't correctly set when s.url is relative
  9110. urlAnchor.href = urlAnchor.href;
  9111. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  9112. urlAnchor.protocol + "//" + urlAnchor.host;
  9113. } catch ( e ) {
  9114. // If there is an error parsing the URL, assume it is crossDomain,
  9115. // it can be rejected by the transport if it is invalid
  9116. s.crossDomain = true;
  9117. }
  9118. }
  9119. // Convert data if not already a string
  9120. if ( s.data && s.processData && typeof s.data !== "string" ) {
  9121. s.data = jQuery.param( s.data, s.traditional );
  9122. }
  9123. // Apply prefilters
  9124. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  9125. // If request was aborted inside a prefilter, stop there
  9126. if ( completed ) {
  9127. return jqXHR;
  9128. }
  9129. // We can fire global events as of now if asked to
  9130. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  9131. fireGlobals = jQuery.event && s.global;
  9132. // Watch for a new set of requests
  9133. if ( fireGlobals && jQuery.active++ === 0 ) {
  9134. jQuery.event.trigger( "ajaxStart" );
  9135. }
  9136. // Uppercase the type
  9137. s.type = s.type.toUpperCase();
  9138. // Determine if request has content
  9139. s.hasContent = !rnoContent.test( s.type );
  9140. // Save the URL in case we're toying with the If-Modified-Since
  9141. // and/or If-None-Match header later on
  9142. // Remove hash to simplify url manipulation
  9143. cacheURL = s.url.replace( rhash, "" );
  9144. // More options handling for requests with no content
  9145. if ( !s.hasContent ) {
  9146. // Remember the hash so we can put it back
  9147. uncached = s.url.slice( cacheURL.length );
  9148. // If data is available and should be processed, append data to url
  9149. if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
  9150. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  9151. // #9682: remove data so that it's not used in an eventual retry
  9152. delete s.data;
  9153. }
  9154. // Add or update anti-cache param if needed
  9155. if ( s.cache === false ) {
  9156. cacheURL = cacheURL.replace( rantiCache, "$1" );
  9157. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
  9158. }
  9159. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  9160. s.url = cacheURL + uncached;
  9161. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  9162. } else if ( s.data && s.processData &&
  9163. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  9164. s.data = s.data.replace( r20, "+" );
  9165. }
  9166. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  9167. if ( s.ifModified ) {
  9168. if ( jQuery.lastModified[ cacheURL ] ) {
  9169. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  9170. }
  9171. if ( jQuery.etag[ cacheURL ] ) {
  9172. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  9173. }
  9174. }
  9175. // Set the correct header, if data is being sent
  9176. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  9177. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  9178. }
  9179. // Set the Accepts header for the server, depending on the dataType
  9180. jqXHR.setRequestHeader(
  9181. "Accept",
  9182. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  9183. s.accepts[ s.dataTypes[ 0 ] ] +
  9184. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  9185. s.accepts[ "*" ]
  9186. );
  9187. // Check for headers option
  9188. for ( i in s.headers ) {
  9189. jqXHR.setRequestHeader( i, s.headers[ i ] );
  9190. }
  9191. // Allow custom headers/mimetypes and early abort
  9192. if ( s.beforeSend &&
  9193. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  9194. // Abort if not done already and return
  9195. return jqXHR.abort();
  9196. }
  9197. // Aborting is no longer a cancellation
  9198. strAbort = "abort";
  9199. // Install callbacks on deferreds
  9200. completeDeferred.add( s.complete );
  9201. jqXHR.done( s.success );
  9202. jqXHR.fail( s.error );
  9203. // Get transport
  9204. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  9205. // If no transport, we auto-abort
  9206. if ( !transport ) {
  9207. done( -1, "No Transport" );
  9208. } else {
  9209. jqXHR.readyState = 1;
  9210. // Send global event
  9211. if ( fireGlobals ) {
  9212. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  9213. }
  9214. // If request was aborted inside ajaxSend, stop there
  9215. if ( completed ) {
  9216. return jqXHR;
  9217. }
  9218. // Timeout
  9219. if ( s.async && s.timeout > 0 ) {
  9220. timeoutTimer = window.setTimeout( function() {
  9221. jqXHR.abort( "timeout" );
  9222. }, s.timeout );
  9223. }
  9224. try {
  9225. completed = false;
  9226. transport.send( requestHeaders, done );
  9227. } catch ( e ) {
  9228. // Rethrow post-completion exceptions
  9229. if ( completed ) {
  9230. throw e;
  9231. }
  9232. // Propagate others as results
  9233. done( -1, e );
  9234. }
  9235. }
  9236. // Callback for when everything is done
  9237. function done( status, nativeStatusText, responses, headers ) {
  9238. var isSuccess, success, error, response, modified,
  9239. statusText = nativeStatusText;
  9240. // Ignore repeat invocations
  9241. if ( completed ) {
  9242. return;
  9243. }
  9244. completed = true;
  9245. // Clear timeout if it exists
  9246. if ( timeoutTimer ) {
  9247. window.clearTimeout( timeoutTimer );
  9248. }
  9249. // Dereference transport for early garbage collection
  9250. // (no matter how long the jqXHR object will be used)
  9251. transport = undefined;
  9252. // Cache response headers
  9253. responseHeadersString = headers || "";
  9254. // Set readyState
  9255. jqXHR.readyState = status > 0 ? 4 : 0;
  9256. // Determine if successful
  9257. isSuccess = status >= 200 && status < 300 || status === 304;
  9258. // Get response data
  9259. if ( responses ) {
  9260. response = ajaxHandleResponses( s, jqXHR, responses );
  9261. }
  9262. // Convert no matter what (that way responseXXX fields are always set)
  9263. response = ajaxConvert( s, response, jqXHR, isSuccess );
  9264. // If successful, handle type chaining
  9265. if ( isSuccess ) {
  9266. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  9267. if ( s.ifModified ) {
  9268. modified = jqXHR.getResponseHeader( "Last-Modified" );
  9269. if ( modified ) {
  9270. jQuery.lastModified[ cacheURL ] = modified;
  9271. }
  9272. modified = jqXHR.getResponseHeader( "etag" );
  9273. if ( modified ) {
  9274. jQuery.etag[ cacheURL ] = modified;
  9275. }
  9276. }
  9277. // if no content
  9278. if ( status === 204 || s.type === "HEAD" ) {
  9279. statusText = "nocontent";
  9280. // if not modified
  9281. } else if ( status === 304 ) {
  9282. statusText = "notmodified";
  9283. // If we have data, let's convert it
  9284. } else {
  9285. statusText = response.state;
  9286. success = response.data;
  9287. error = response.error;
  9288. isSuccess = !error;
  9289. }
  9290. } else {
  9291. // Extract error from statusText and normalize for non-aborts
  9292. error = statusText;
  9293. if ( status || !statusText ) {
  9294. statusText = "error";
  9295. if ( status < 0 ) {
  9296. status = 0;
  9297. }
  9298. }
  9299. }
  9300. // Set data for the fake xhr object
  9301. jqXHR.status = status;
  9302. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  9303. // Success/Error
  9304. if ( isSuccess ) {
  9305. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  9306. } else {
  9307. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  9308. }
  9309. // Status-dependent callbacks
  9310. jqXHR.statusCode( statusCode );
  9311. statusCode = undefined;
  9312. if ( fireGlobals ) {
  9313. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  9314. [ jqXHR, s, isSuccess ? success : error ] );
  9315. }
  9316. // Complete
  9317. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  9318. if ( fireGlobals ) {
  9319. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  9320. // Handle the global AJAX counter
  9321. if ( !( --jQuery.active ) ) {
  9322. jQuery.event.trigger( "ajaxStop" );
  9323. }
  9324. }
  9325. }
  9326. return jqXHR;
  9327. },
  9328. getJSON: function( url, data, callback ) {
  9329. return jQuery.get( url, data, callback, "json" );
  9330. },
  9331. getScript: function( url, callback ) {
  9332. return jQuery.get( url, undefined, callback, "script" );
  9333. }
  9334. } );
  9335. jQuery.each( [ "get", "post" ], function( i, method ) {
  9336. jQuery[ method ] = function( url, data, callback, type ) {
  9337. // Shift arguments if data argument was omitted
  9338. if ( isFunction( data ) ) {
  9339. type = type || callback;
  9340. callback = data;
  9341. data = undefined;
  9342. }
  9343. // The url can be an options object (which then must have .url)
  9344. return jQuery.ajax( jQuery.extend( {
  9345. url: url,
  9346. type: method,
  9347. dataType: type,
  9348. data: data,
  9349. success: callback
  9350. }, jQuery.isPlainObject( url ) && url ) );
  9351. };
  9352. } );
  9353. jQuery._evalUrl = function( url, options ) {
  9354. return jQuery.ajax( {
  9355. url: url,
  9356. // Make this explicit, since user can override this through ajaxSetup (#11264)
  9357. type: "GET",
  9358. dataType: "script",
  9359. cache: true,
  9360. async: false,
  9361. global: false,
  9362. // Only evaluate the response if it is successful (gh-4126)
  9363. // dataFilter is not invoked for failure responses, so using it instead
  9364. // of the default converter is kludgy but it works.
  9365. converters: {
  9366. "text script": function() {}
  9367. },
  9368. dataFilter: function( response ) {
  9369. jQuery.globalEval( response, options );
  9370. }
  9371. } );
  9372. };
  9373. jQuery.fn.extend( {
  9374. wrapAll: function( html ) {
  9375. var wrap;
  9376. if ( this[ 0 ] ) {
  9377. if ( isFunction( html ) ) {
  9378. html = html.call( this[ 0 ] );
  9379. }
  9380. // The elements to wrap the target around
  9381. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  9382. if ( this[ 0 ].parentNode ) {
  9383. wrap.insertBefore( this[ 0 ] );
  9384. }
  9385. wrap.map( function() {
  9386. var elem = this;
  9387. while ( elem.firstElementChild ) {
  9388. elem = elem.firstElementChild;
  9389. }
  9390. return elem;
  9391. } ).append( this );
  9392. }
  9393. return this;
  9394. },
  9395. wrapInner: function( html ) {
  9396. if ( isFunction( html ) ) {
  9397. return this.each( function( i ) {
  9398. jQuery( this ).wrapInner( html.call( this, i ) );
  9399. } );
  9400. }
  9401. return this.each( function() {
  9402. var self = jQuery( this ),
  9403. contents = self.contents();
  9404. if ( contents.length ) {
  9405. contents.wrapAll( html );
  9406. } else {
  9407. self.append( html );
  9408. }
  9409. } );
  9410. },
  9411. wrap: function( html ) {
  9412. var htmlIsFunction = isFunction( html );
  9413. return this.each( function( i ) {
  9414. jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
  9415. } );
  9416. },
  9417. unwrap: function( selector ) {
  9418. this.parent( selector ).not( "body" ).each( function() {
  9419. jQuery( this ).replaceWith( this.childNodes );
  9420. } );
  9421. return this;
  9422. }
  9423. } );
  9424. jQuery.expr.pseudos.hidden = function( elem ) {
  9425. return !jQuery.expr.pseudos.visible( elem );
  9426. };
  9427. jQuery.expr.pseudos.visible = function( elem ) {
  9428. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  9429. };
  9430. jQuery.ajaxSettings.xhr = function() {
  9431. try {
  9432. return new window.XMLHttpRequest();
  9433. } catch ( e ) {}
  9434. };
  9435. var xhrSuccessStatus = {
  9436. // File protocol always yields status code 0, assume 200
  9437. 0: 200,
  9438. // Support: IE <=9 only
  9439. // #1450: sometimes IE returns 1223 when it should be 204
  9440. 1223: 204
  9441. },
  9442. xhrSupported = jQuery.ajaxSettings.xhr();
  9443. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  9444. support.ajax = xhrSupported = !!xhrSupported;
  9445. jQuery.ajaxTransport( function( options ) {
  9446. var callback, errorCallback;
  9447. // Cross domain only allowed if supported through XMLHttpRequest
  9448. if ( support.cors || xhrSupported && !options.crossDomain ) {
  9449. return {
  9450. send: function( headers, complete ) {
  9451. var i,
  9452. xhr = options.xhr();
  9453. xhr.open(
  9454. options.type,
  9455. options.url,
  9456. options.async,
  9457. options.username,
  9458. options.password
  9459. );
  9460. // Apply custom fields if provided
  9461. if ( options.xhrFields ) {
  9462. for ( i in options.xhrFields ) {
  9463. xhr[ i ] = options.xhrFields[ i ];
  9464. }
  9465. }
  9466. // Override mime type if needed
  9467. if ( options.mimeType && xhr.overrideMimeType ) {
  9468. xhr.overrideMimeType( options.mimeType );
  9469. }
  9470. // X-Requested-With header
  9471. // For cross-domain requests, seeing as conditions for a preflight are
  9472. // akin to a jigsaw puzzle, we simply never set it to be sure.
  9473. // (it can always be set on a per-request basis or even using ajaxSetup)
  9474. // For same-domain requests, won't change header if already provided.
  9475. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  9476. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  9477. }
  9478. // Set headers
  9479. for ( i in headers ) {
  9480. xhr.setRequestHeader( i, headers[ i ] );
  9481. }
  9482. // Callback
  9483. callback = function( type ) {
  9484. return function() {
  9485. if ( callback ) {
  9486. callback = errorCallback = xhr.onload =
  9487. xhr.onerror = xhr.onabort = xhr.ontimeout =
  9488. xhr.onreadystatechange = null;
  9489. if ( type === "abort" ) {
  9490. xhr.abort();
  9491. } else if ( type === "error" ) {
  9492. // Support: IE <=9 only
  9493. // On a manual native abort, IE9 throws
  9494. // errors on any property access that is not readyState
  9495. if ( typeof xhr.status !== "number" ) {
  9496. complete( 0, "error" );
  9497. } else {
  9498. complete(
  9499. // File: protocol always yields status 0; see #8605, #14207
  9500. xhr.status,
  9501. xhr.statusText
  9502. );
  9503. }
  9504. } else {
  9505. complete(
  9506. xhrSuccessStatus[ xhr.status ] || xhr.status,
  9507. xhr.statusText,
  9508. // Support: IE <=9 only
  9509. // IE9 has no XHR2 but throws on binary (trac-11426)
  9510. // For XHR2 non-text, let the caller handle it (gh-2498)
  9511. ( xhr.responseType || "text" ) !== "text" ||
  9512. typeof xhr.responseText !== "string" ?
  9513. { binary: xhr.response } :
  9514. { text: xhr.responseText },
  9515. xhr.getAllResponseHeaders()
  9516. );
  9517. }
  9518. }
  9519. };
  9520. };
  9521. // Listen to events
  9522. xhr.onload = callback();
  9523. errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
  9524. // Support: IE 9 only
  9525. // Use onreadystatechange to replace onabort
  9526. // to handle uncaught aborts
  9527. if ( xhr.onabort !== undefined ) {
  9528. xhr.onabort = errorCallback;
  9529. } else {
  9530. xhr.onreadystatechange = function() {
  9531. // Check readyState before timeout as it changes
  9532. if ( xhr.readyState === 4 ) {
  9533. // Allow onerror to be called first,
  9534. // but that will not handle a native abort
  9535. // Also, save errorCallback to a variable
  9536. // as xhr.onerror cannot be accessed
  9537. window.setTimeout( function() {
  9538. if ( callback ) {
  9539. errorCallback();
  9540. }
  9541. } );
  9542. }
  9543. };
  9544. }
  9545. // Create the abort callback
  9546. callback = callback( "abort" );
  9547. try {
  9548. // Do send the request (this may raise an exception)
  9549. xhr.send( options.hasContent && options.data || null );
  9550. } catch ( e ) {
  9551. // #14683: Only rethrow if this hasn't been notified as an error yet
  9552. if ( callback ) {
  9553. throw e;
  9554. }
  9555. }
  9556. },
  9557. abort: function() {
  9558. if ( callback ) {
  9559. callback();
  9560. }
  9561. }
  9562. };
  9563. }
  9564. } );
  9565. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  9566. jQuery.ajaxPrefilter( function( s ) {
  9567. if ( s.crossDomain ) {
  9568. s.contents.script = false;
  9569. }
  9570. } );
  9571. // Install script dataType
  9572. jQuery.ajaxSetup( {
  9573. accepts: {
  9574. script: "text/javascript, application/javascript, " +
  9575. "application/ecmascript, application/x-ecmascript"
  9576. },
  9577. contents: {
  9578. script: /\b(?:java|ecma)script\b/
  9579. },
  9580. converters: {
  9581. "text script": function( text ) {
  9582. jQuery.globalEval( text );
  9583. return text;
  9584. }
  9585. }
  9586. } );
  9587. // Handle cache's special case and crossDomain
  9588. jQuery.ajaxPrefilter( "script", function( s ) {
  9589. if ( s.cache === undefined ) {
  9590. s.cache = false;
  9591. }
  9592. if ( s.crossDomain ) {
  9593. s.type = "GET";
  9594. }
  9595. } );
  9596. // Bind script tag hack transport
  9597. jQuery.ajaxTransport( "script", function( s ) {
  9598. // This transport only deals with cross domain or forced-by-attrs requests
  9599. if ( s.crossDomain || s.scriptAttrs ) {
  9600. var script, callback;
  9601. return {
  9602. send: function( _, complete ) {
  9603. script = jQuery( "<script>" )
  9604. .attr( s.scriptAttrs || {} )
  9605. .prop( { charset: s.scriptCharset, src: s.url } )
  9606. .on( "load error", callback = function( evt ) {
  9607. script.remove();
  9608. callback = null;
  9609. if ( evt ) {
  9610. complete( evt.type === "error" ? 404 : 200, evt.type );
  9611. }
  9612. } );
  9613. // Use native DOM manipulation to avoid our domManip AJAX trickery
  9614. document.head.appendChild( script[ 0 ] );
  9615. },
  9616. abort: function() {
  9617. if ( callback ) {
  9618. callback();
  9619. }
  9620. }
  9621. };
  9622. }
  9623. } );
  9624. var oldCallbacks = [],
  9625. rjsonp = /(=)\?(?=&|$)|\?\?/;
  9626. // Default jsonp settings
  9627. jQuery.ajaxSetup( {
  9628. jsonp: "callback",
  9629. jsonpCallback: function() {
  9630. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  9631. this[ callback ] = true;
  9632. return callback;
  9633. }
  9634. } );
  9635. // Detect, normalize options and install callbacks for jsonp requests
  9636. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  9637. var callbackName, overwritten, responseContainer,
  9638. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  9639. "url" :
  9640. typeof s.data === "string" &&
  9641. ( s.contentType || "" )
  9642. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  9643. rjsonp.test( s.data ) && "data"
  9644. );
  9645. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  9646. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  9647. // Get callback name, remembering preexisting value associated with it
  9648. callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
  9649. s.jsonpCallback() :
  9650. s.jsonpCallback;
  9651. // Insert callback into url or form data
  9652. if ( jsonProp ) {
  9653. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  9654. } else if ( s.jsonp !== false ) {
  9655. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  9656. }
  9657. // Use data converter to retrieve json after script execution
  9658. s.converters[ "script json" ] = function() {
  9659. if ( !responseContainer ) {
  9660. jQuery.error( callbackName + " was not called" );
  9661. }
  9662. return responseContainer[ 0 ];
  9663. };
  9664. // Force json dataType
  9665. s.dataTypes[ 0 ] = "json";
  9666. // Install callback
  9667. overwritten = window[ callbackName ];
  9668. window[ callbackName ] = function() {
  9669. responseContainer = arguments;
  9670. };
  9671. // Clean-up function (fires after converters)
  9672. jqXHR.always( function() {
  9673. // If previous value didn't exist - remove it
  9674. if ( overwritten === undefined ) {
  9675. jQuery( window ).removeProp( callbackName );
  9676. // Otherwise restore preexisting value
  9677. } else {
  9678. window[ callbackName ] = overwritten;
  9679. }
  9680. // Save back as free
  9681. if ( s[ callbackName ] ) {
  9682. // Make sure that re-using the options doesn't screw things around
  9683. s.jsonpCallback = originalSettings.jsonpCallback;
  9684. // Save the callback name for future use
  9685. oldCallbacks.push( callbackName );
  9686. }
  9687. // Call if it was a function and we have a response
  9688. if ( responseContainer && isFunction( overwritten ) ) {
  9689. overwritten( responseContainer[ 0 ] );
  9690. }
  9691. responseContainer = overwritten = undefined;
  9692. } );
  9693. // Delegate to script
  9694. return "script";
  9695. }
  9696. } );
  9697. // Support: Safari 8 only
  9698. // In Safari 8 documents created via document.implementation.createHTMLDocument
  9699. // collapse sibling forms: the second one becomes a child of the first one.
  9700. // Because of that, this security measure has to be disabled in Safari 8.
  9701. // https://bugs.webkit.org/show_bug.cgi?id=137337
  9702. support.createHTMLDocument = ( function() {
  9703. var body = document.implementation.createHTMLDocument( "" ).body;
  9704. body.innerHTML = "<form></form><form></form>";
  9705. return body.childNodes.length === 2;
  9706. } )();
  9707. // Argument "data" should be string of html
  9708. // context (optional): If specified, the fragment will be created in this context,
  9709. // defaults to document
  9710. // keepScripts (optional): If true, will include scripts passed in the html string
  9711. jQuery.parseHTML = function( data, context, keepScripts ) {
  9712. if ( typeof data !== "string" ) {
  9713. return [];
  9714. }
  9715. if ( typeof context === "boolean" ) {
  9716. keepScripts = context;
  9717. context = false;
  9718. }
  9719. var base, parsed, scripts;
  9720. if ( !context ) {
  9721. // Stop scripts or inline event handlers from being executed immediately
  9722. // by using document.implementation
  9723. if ( support.createHTMLDocument ) {
  9724. context = document.implementation.createHTMLDocument( "" );
  9725. // Set the base href for the created document
  9726. // so any parsed elements with URLs
  9727. // are based on the document's URL (gh-2965)
  9728. base = context.createElement( "base" );
  9729. base.href = document.location.href;
  9730. context.head.appendChild( base );
  9731. } else {
  9732. context = document;
  9733. }
  9734. }
  9735. parsed = rsingleTag.exec( data );
  9736. scripts = !keepScripts && [];
  9737. // Single tag
  9738. if ( parsed ) {
  9739. return [ context.createElement( parsed[ 1 ] ) ];
  9740. }
  9741. parsed = buildFragment( [ data ], context, scripts );
  9742. if ( scripts && scripts.length ) {
  9743. jQuery( scripts ).remove();
  9744. }
  9745. return jQuery.merge( [], parsed.childNodes );
  9746. };
  9747. /**
  9748. * Load a url into a page
  9749. */
  9750. jQuery.fn.load = function( url, params, callback ) {
  9751. var selector, type, response,
  9752. self = this,
  9753. off = url.indexOf( " " );
  9754. if ( off > -1 ) {
  9755. selector = stripAndCollapse( url.slice( off ) );
  9756. url = url.slice( 0, off );
  9757. }
  9758. // If it's a function
  9759. if ( isFunction( params ) ) {
  9760. // We assume that it's the callback
  9761. callback = params;
  9762. params = undefined;
  9763. // Otherwise, build a param string
  9764. } else if ( params && typeof params === "object" ) {
  9765. type = "POST";
  9766. }
  9767. // If we have elements to modify, make the request
  9768. if ( self.length > 0 ) {
  9769. jQuery.ajax( {
  9770. url: url,
  9771. // If "type" variable is undefined, then "GET" method will be used.
  9772. // Make value of this field explicit since
  9773. // user can override it through ajaxSetup method
  9774. type: type || "GET",
  9775. dataType: "html",
  9776. data: params
  9777. } ).done( function( responseText ) {
  9778. // Save response for use in complete callback
  9779. response = arguments;
  9780. self.html( selector ?
  9781. // If a selector was specified, locate the right elements in a dummy div
  9782. // Exclude scripts to avoid IE 'Permission Denied' errors
  9783. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  9784. // Otherwise use the full result
  9785. responseText );
  9786. // If the request succeeds, this function gets "data", "status", "jqXHR"
  9787. // but they are ignored because response was set above.
  9788. // If it fails, this function gets "jqXHR", "status", "error"
  9789. } ).always( callback && function( jqXHR, status ) {
  9790. self.each( function() {
  9791. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  9792. } );
  9793. } );
  9794. }
  9795. return this;
  9796. };
  9797. // Attach a bunch of functions for handling common AJAX events
  9798. jQuery.each( [
  9799. "ajaxStart",
  9800. "ajaxStop",
  9801. "ajaxComplete",
  9802. "ajaxError",
  9803. "ajaxSuccess",
  9804. "ajaxSend"
  9805. ], function( i, type ) {
  9806. jQuery.fn[ type ] = function( fn ) {
  9807. return this.on( type, fn );
  9808. };
  9809. } );
  9810. jQuery.expr.pseudos.animated = function( elem ) {
  9811. return jQuery.grep( jQuery.timers, function( fn ) {
  9812. return elem === fn.elem;
  9813. } ).length;
  9814. };
  9815. jQuery.offset = {
  9816. setOffset: function( elem, options, i ) {
  9817. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  9818. position = jQuery.css( elem, "position" ),
  9819. curElem = jQuery( elem ),
  9820. props = {};
  9821. // Set position first, in-case top/left are set even on static elem
  9822. if ( position === "static" ) {
  9823. elem.style.position = "relative";
  9824. }
  9825. curOffset = curElem.offset();
  9826. curCSSTop = jQuery.css( elem, "top" );
  9827. curCSSLeft = jQuery.css( elem, "left" );
  9828. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  9829. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  9830. // Need to be able to calculate position if either
  9831. // top or left is auto and position is either absolute or fixed
  9832. if ( calculatePosition ) {
  9833. curPosition = curElem.position();
  9834. curTop = curPosition.top;
  9835. curLeft = curPosition.left;
  9836. } else {
  9837. curTop = parseFloat( curCSSTop ) || 0;
  9838. curLeft = parseFloat( curCSSLeft ) || 0;
  9839. }
  9840. if ( isFunction( options ) ) {
  9841. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  9842. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  9843. }
  9844. if ( options.top != null ) {
  9845. props.top = ( options.top - curOffset.top ) + curTop;
  9846. }
  9847. if ( options.left != null ) {
  9848. props.left = ( options.left - curOffset.left ) + curLeft;
  9849. }
  9850. if ( "using" in options ) {
  9851. options.using.call( elem, props );
  9852. } else {
  9853. curElem.css( props );
  9854. }
  9855. }
  9856. };
  9857. jQuery.fn.extend( {
  9858. // offset() relates an element's border box to the document origin
  9859. offset: function( options ) {
  9860. // Preserve chaining for setter
  9861. if ( arguments.length ) {
  9862. return options === undefined ?
  9863. this :
  9864. this.each( function( i ) {
  9865. jQuery.offset.setOffset( this, options, i );
  9866. } );
  9867. }
  9868. var rect, win,
  9869. elem = this[ 0 ];
  9870. if ( !elem ) {
  9871. return;
  9872. }
  9873. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  9874. // Support: IE <=11 only
  9875. // Running getBoundingClientRect on a
  9876. // disconnected node in IE throws an error
  9877. if ( !elem.getClientRects().length ) {
  9878. return { top: 0, left: 0 };
  9879. }
  9880. // Get document-relative position by adding viewport scroll to viewport-relative gBCR
  9881. rect = elem.getBoundingClientRect();
  9882. win = elem.ownerDocument.defaultView;
  9883. return {
  9884. top: rect.top + win.pageYOffset,
  9885. left: rect.left + win.pageXOffset
  9886. };
  9887. },
  9888. // position() relates an element's margin box to its offset parent's padding box
  9889. // This corresponds to the behavior of CSS absolute positioning
  9890. position: function() {
  9891. if ( !this[ 0 ] ) {
  9892. return;
  9893. }
  9894. var offsetParent, offset, doc,
  9895. elem = this[ 0 ],
  9896. parentOffset = { top: 0, left: 0 };
  9897. // position:fixed elements are offset from the viewport, which itself always has zero offset
  9898. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  9899. // Assume position:fixed implies availability of getBoundingClientRect
  9900. offset = elem.getBoundingClientRect();
  9901. } else {
  9902. offset = this.offset();
  9903. // Account for the *real* offset parent, which can be the document or its root element
  9904. // when a statically positioned element is identified
  9905. doc = elem.ownerDocument;
  9906. offsetParent = elem.offsetParent || doc.documentElement;
  9907. while ( offsetParent &&
  9908. ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
  9909. jQuery.css( offsetParent, "position" ) === "static" ) {
  9910. offsetParent = offsetParent.parentNode;
  9911. }
  9912. if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
  9913. // Incorporate borders into its offset, since they are outside its content origin
  9914. parentOffset = jQuery( offsetParent ).offset();
  9915. parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
  9916. parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
  9917. }
  9918. }
  9919. // Subtract parent offsets and element margins
  9920. return {
  9921. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  9922. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  9923. };
  9924. },
  9925. // This method will return documentElement in the following cases:
  9926. // 1) For the element inside the iframe without offsetParent, this method will return
  9927. // documentElement of the parent window
  9928. // 2) For the hidden or detached element
  9929. // 3) For body or html element, i.e. in case of the html node - it will return itself
  9930. //
  9931. // but those exceptions were never presented as a real life use-cases
  9932. // and might be considered as more preferable results.
  9933. //
  9934. // This logic, however, is not guaranteed and can change at any point in the future
  9935. offsetParent: function() {
  9936. return this.map( function() {
  9937. var offsetParent = this.offsetParent;
  9938. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  9939. offsetParent = offsetParent.offsetParent;
  9940. }
  9941. return offsetParent || documentElement;
  9942. } );
  9943. }
  9944. } );
  9945. // Create scrollLeft and scrollTop methods
  9946. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  9947. var top = "pageYOffset" === prop;
  9948. jQuery.fn[ method ] = function( val ) {
  9949. return access( this, function( elem, method, val ) {
  9950. // Coalesce documents and windows
  9951. var win;
  9952. if ( isWindow( elem ) ) {
  9953. win = elem;
  9954. } else if ( elem.nodeType === 9 ) {
  9955. win = elem.defaultView;
  9956. }
  9957. if ( val === undefined ) {
  9958. return win ? win[ prop ] : elem[ method ];
  9959. }
  9960. if ( win ) {
  9961. win.scrollTo(
  9962. !top ? val : win.pageXOffset,
  9963. top ? val : win.pageYOffset
  9964. );
  9965. } else {
  9966. elem[ method ] = val;
  9967. }
  9968. }, method, val, arguments.length );
  9969. };
  9970. } );
  9971. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  9972. // Add the top/left cssHooks using jQuery.fn.position
  9973. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  9974. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  9975. // getComputedStyle returns percent when specified for top/left/bottom/right;
  9976. // rather than make the css module depend on the offset module, just check for it here
  9977. jQuery.each( [ "top", "left" ], function( i, prop ) {
  9978. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  9979. function( elem, computed ) {
  9980. if ( computed ) {
  9981. computed = curCSS( elem, prop );
  9982. // If curCSS returns percentage, fallback to offset
  9983. return rnumnonpx.test( computed ) ?
  9984. jQuery( elem ).position()[ prop ] + "px" :
  9985. computed;
  9986. }
  9987. }
  9988. );
  9989. } );
  9990. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  9991. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  9992. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  9993. function( defaultExtra, funcName ) {
  9994. // Margin is only for outerHeight, outerWidth
  9995. jQuery.fn[ funcName ] = function( margin, value ) {
  9996. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  9997. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  9998. return access( this, function( elem, type, value ) {
  9999. var doc;
  10000. if ( isWindow( elem ) ) {
  10001. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  10002. return funcName.indexOf( "outer" ) === 0 ?
  10003. elem[ "inner" + name ] :
  10004. elem.document.documentElement[ "client" + name ];
  10005. }
  10006. // Get document width or height
  10007. if ( elem.nodeType === 9 ) {
  10008. doc = elem.documentElement;
  10009. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  10010. // whichever is greatest
  10011. return Math.max(
  10012. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  10013. elem.body[ "offset" + name ], doc[ "offset" + name ],
  10014. doc[ "client" + name ]
  10015. );
  10016. }
  10017. return value === undefined ?
  10018. // Get width or height on the element, requesting but not forcing parseFloat
  10019. jQuery.css( elem, type, extra ) :
  10020. // Set width or height on the element
  10021. jQuery.style( elem, type, value, extra );
  10022. }, type, chainable ? margin : undefined, chainable );
  10023. };
  10024. } );
  10025. } );
  10026. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  10027. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  10028. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  10029. function( i, name ) {
  10030. // Handle event binding
  10031. jQuery.fn[ name ] = function( data, fn ) {
  10032. return arguments.length > 0 ?
  10033. this.on( name, null, data, fn ) :
  10034. this.trigger( name );
  10035. };
  10036. } );
  10037. jQuery.fn.extend( {
  10038. hover: function( fnOver, fnOut ) {
  10039. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  10040. }
  10041. } );
  10042. jQuery.fn.extend( {
  10043. bind: function( types, data, fn ) {
  10044. return this.on( types, null, data, fn );
  10045. },
  10046. unbind: function( types, fn ) {
  10047. return this.off( types, null, fn );
  10048. },
  10049. delegate: function( selector, types, data, fn ) {
  10050. return this.on( types, selector, data, fn );
  10051. },
  10052. undelegate: function( selector, types, fn ) {
  10053. // ( namespace ) or ( selector, types [, fn] )
  10054. return arguments.length === 1 ?
  10055. this.off( selector, "**" ) :
  10056. this.off( types, selector || "**", fn );
  10057. }
  10058. } );
  10059. // Bind a function to a context, optionally partially applying any
  10060. // arguments.
  10061. // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
  10062. // However, it is not slated for removal any time soon
  10063. jQuery.proxy = function( fn, context ) {
  10064. var tmp, args, proxy;
  10065. if ( typeof context === "string" ) {
  10066. tmp = fn[ context ];
  10067. context = fn;
  10068. fn = tmp;
  10069. }
  10070. // Quick check to determine if target is callable, in the spec
  10071. // this throws a TypeError, but we will just return undefined.
  10072. if ( !isFunction( fn ) ) {
  10073. return undefined;
  10074. }
  10075. // Simulated bind
  10076. args = slice.call( arguments, 2 );
  10077. proxy = function() {
  10078. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  10079. };
  10080. // Set the guid of unique handler to the same of original handler, so it can be removed
  10081. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  10082. return proxy;
  10083. };
  10084. jQuery.holdReady = function( hold ) {
  10085. if ( hold ) {
  10086. jQuery.readyWait++;
  10087. } else {
  10088. jQuery.ready( true );
  10089. }
  10090. };
  10091. jQuery.isArray = Array.isArray;
  10092. jQuery.parseJSON = JSON.parse;
  10093. jQuery.nodeName = nodeName;
  10094. jQuery.isFunction = isFunction;
  10095. jQuery.isWindow = isWindow;
  10096. jQuery.camelCase = camelCase;
  10097. jQuery.type = toType;
  10098. jQuery.now = Date.now;
  10099. jQuery.isNumeric = function( obj ) {
  10100. // As of jQuery 3.0, isNumeric is limited to
  10101. // strings and numbers (primitives or objects)
  10102. // that can be coerced to finite numbers (gh-2662)
  10103. var type = jQuery.type( obj );
  10104. return ( type === "number" || type === "string" ) &&
  10105. // parseFloat NaNs numeric-cast false positives ("")
  10106. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  10107. // subtraction forces infinities to NaN
  10108. !isNaN( obj - parseFloat( obj ) );
  10109. };
  10110. // Register as a named AMD module, since jQuery can be concatenated with other
  10111. // files that may use define, but not via a proper concatenation script that
  10112. // understands anonymous AMD modules. A named AMD is safest and most robust
  10113. // way to register. Lowercase jquery is used because AMD module names are
  10114. // derived from file names, and jQuery is normally delivered in a lowercase
  10115. // file name. Do this after creating the global so that if an AMD module wants
  10116. // to call noConflict to hide this version of jQuery, it will work.
  10117. // Note that for maximum portability, libraries that are not jQuery should
  10118. // declare themselves as anonymous modules, and avoid setting a global if an
  10119. // AMD loader is present. jQuery is a special case. For more information, see
  10120. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  10121. if ( true ) {
  10122. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  10123. return jQuery;
  10124. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  10125. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  10126. }
  10127. var
  10128. // Map over jQuery in case of overwrite
  10129. _jQuery = window.jQuery,
  10130. // Map over the $ in case of overwrite
  10131. _$ = window.$;
  10132. jQuery.noConflict = function( deep ) {
  10133. if ( window.$ === jQuery ) {
  10134. window.$ = _$;
  10135. }
  10136. if ( deep && window.jQuery === jQuery ) {
  10137. window.jQuery = _jQuery;
  10138. }
  10139. return jQuery;
  10140. };
  10141. // Expose jQuery and $ identifiers, even in AMD
  10142. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  10143. // and CommonJS for browser emulators (#13566)
  10144. if ( !noGlobal ) {
  10145. window.jQuery = window.$ = jQuery;
  10146. }
  10147. return jQuery;
  10148. } );
  10149. /***/ }),
  10150. /***/ "./node_modules/lodash/lodash.js":
  10151. /*!***************************************!*\
  10152. !*** ./node_modules/lodash/lodash.js ***!
  10153. \***************************************/
  10154. /*! no static exports found */
  10155. /***/ (function(module, exports, __webpack_require__) {
  10156. /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
  10157. * @license
  10158. * Lodash <https://lodash.com/>
  10159. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  10160. * Released under MIT license <https://lodash.com/license>
  10161. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  10162. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  10163. */
  10164. ;(function() {
  10165. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  10166. var undefined;
  10167. /** Used as the semantic version number. */
  10168. var VERSION = '4.17.15';
  10169. /** Used as the size to enable large array optimizations. */
  10170. var LARGE_ARRAY_SIZE = 200;
  10171. /** Error message constants. */
  10172. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  10173. FUNC_ERROR_TEXT = 'Expected a function';
  10174. /** Used to stand-in for `undefined` hash values. */
  10175. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  10176. /** Used as the maximum memoize cache size. */
  10177. var MAX_MEMOIZE_SIZE = 500;
  10178. /** Used as the internal argument placeholder. */
  10179. var PLACEHOLDER = '__lodash_placeholder__';
  10180. /** Used to compose bitmasks for cloning. */
  10181. var CLONE_DEEP_FLAG = 1,
  10182. CLONE_FLAT_FLAG = 2,
  10183. CLONE_SYMBOLS_FLAG = 4;
  10184. /** Used to compose bitmasks for value comparisons. */
  10185. var COMPARE_PARTIAL_FLAG = 1,
  10186. COMPARE_UNORDERED_FLAG = 2;
  10187. /** Used to compose bitmasks for function metadata. */
  10188. var WRAP_BIND_FLAG = 1,
  10189. WRAP_BIND_KEY_FLAG = 2,
  10190. WRAP_CURRY_BOUND_FLAG = 4,
  10191. WRAP_CURRY_FLAG = 8,
  10192. WRAP_CURRY_RIGHT_FLAG = 16,
  10193. WRAP_PARTIAL_FLAG = 32,
  10194. WRAP_PARTIAL_RIGHT_FLAG = 64,
  10195. WRAP_ARY_FLAG = 128,
  10196. WRAP_REARG_FLAG = 256,
  10197. WRAP_FLIP_FLAG = 512;
  10198. /** Used as default options for `_.truncate`. */
  10199. var DEFAULT_TRUNC_LENGTH = 30,
  10200. DEFAULT_TRUNC_OMISSION = '...';
  10201. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  10202. var HOT_COUNT = 800,
  10203. HOT_SPAN = 16;
  10204. /** Used to indicate the type of lazy iteratees. */
  10205. var LAZY_FILTER_FLAG = 1,
  10206. LAZY_MAP_FLAG = 2,
  10207. LAZY_WHILE_FLAG = 3;
  10208. /** Used as references for various `Number` constants. */
  10209. var INFINITY = 1 / 0,
  10210. MAX_SAFE_INTEGER = 9007199254740991,
  10211. MAX_INTEGER = 1.7976931348623157e+308,
  10212. NAN = 0 / 0;
  10213. /** Used as references for the maximum length and index of an array. */
  10214. var MAX_ARRAY_LENGTH = 4294967295,
  10215. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  10216. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  10217. /** Used to associate wrap methods with their bit flags. */
  10218. var wrapFlags = [
  10219. ['ary', WRAP_ARY_FLAG],
  10220. ['bind', WRAP_BIND_FLAG],
  10221. ['bindKey', WRAP_BIND_KEY_FLAG],
  10222. ['curry', WRAP_CURRY_FLAG],
  10223. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  10224. ['flip', WRAP_FLIP_FLAG],
  10225. ['partial', WRAP_PARTIAL_FLAG],
  10226. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  10227. ['rearg', WRAP_REARG_FLAG]
  10228. ];
  10229. /** `Object#toString` result references. */
  10230. var argsTag = '[object Arguments]',
  10231. arrayTag = '[object Array]',
  10232. asyncTag = '[object AsyncFunction]',
  10233. boolTag = '[object Boolean]',
  10234. dateTag = '[object Date]',
  10235. domExcTag = '[object DOMException]',
  10236. errorTag = '[object Error]',
  10237. funcTag = '[object Function]',
  10238. genTag = '[object GeneratorFunction]',
  10239. mapTag = '[object Map]',
  10240. numberTag = '[object Number]',
  10241. nullTag = '[object Null]',
  10242. objectTag = '[object Object]',
  10243. promiseTag = '[object Promise]',
  10244. proxyTag = '[object Proxy]',
  10245. regexpTag = '[object RegExp]',
  10246. setTag = '[object Set]',
  10247. stringTag = '[object String]',
  10248. symbolTag = '[object Symbol]',
  10249. undefinedTag = '[object Undefined]',
  10250. weakMapTag = '[object WeakMap]',
  10251. weakSetTag = '[object WeakSet]';
  10252. var arrayBufferTag = '[object ArrayBuffer]',
  10253. dataViewTag = '[object DataView]',
  10254. float32Tag = '[object Float32Array]',
  10255. float64Tag = '[object Float64Array]',
  10256. int8Tag = '[object Int8Array]',
  10257. int16Tag = '[object Int16Array]',
  10258. int32Tag = '[object Int32Array]',
  10259. uint8Tag = '[object Uint8Array]',
  10260. uint8ClampedTag = '[object Uint8ClampedArray]',
  10261. uint16Tag = '[object Uint16Array]',
  10262. uint32Tag = '[object Uint32Array]';
  10263. /** Used to match empty string literals in compiled template source. */
  10264. var reEmptyStringLeading = /\b__p \+= '';/g,
  10265. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  10266. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  10267. /** Used to match HTML entities and HTML characters. */
  10268. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  10269. reUnescapedHtml = /[&<>"']/g,
  10270. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  10271. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  10272. /** Used to match template delimiters. */
  10273. var reEscape = /<%-([\s\S]+?)%>/g,
  10274. reEvaluate = /<%([\s\S]+?)%>/g,
  10275. reInterpolate = /<%=([\s\S]+?)%>/g;
  10276. /** Used to match property names within property paths. */
  10277. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  10278. reIsPlainProp = /^\w*$/,
  10279. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  10280. /**
  10281. * Used to match `RegExp`
  10282. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  10283. */
  10284. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  10285. reHasRegExpChar = RegExp(reRegExpChar.source);
  10286. /** Used to match leading and trailing whitespace. */
  10287. var reTrim = /^\s+|\s+$/g,
  10288. reTrimStart = /^\s+/,
  10289. reTrimEnd = /\s+$/;
  10290. /** Used to match wrap detail comments. */
  10291. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  10292. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  10293. reSplitDetails = /,? & /;
  10294. /** Used to match words composed of alphanumeric characters. */
  10295. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  10296. /** Used to match backslashes in property paths. */
  10297. var reEscapeChar = /\\(\\)?/g;
  10298. /**
  10299. * Used to match
  10300. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  10301. */
  10302. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  10303. /** Used to match `RegExp` flags from their coerced string values. */
  10304. var reFlags = /\w*$/;
  10305. /** Used to detect bad signed hexadecimal string values. */
  10306. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  10307. /** Used to detect binary string values. */
  10308. var reIsBinary = /^0b[01]+$/i;
  10309. /** Used to detect host constructors (Safari). */
  10310. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  10311. /** Used to detect octal string values. */
  10312. var reIsOctal = /^0o[0-7]+$/i;
  10313. /** Used to detect unsigned integer values. */
  10314. var reIsUint = /^(?:0|[1-9]\d*)$/;
  10315. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  10316. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  10317. /** Used to ensure capturing order of template delimiters. */
  10318. var reNoMatch = /($^)/;
  10319. /** Used to match unescaped characters in compiled string literals. */
  10320. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  10321. /** Used to compose unicode character classes. */
  10322. var rsAstralRange = '\\ud800-\\udfff',
  10323. rsComboMarksRange = '\\u0300-\\u036f',
  10324. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  10325. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  10326. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  10327. rsDingbatRange = '\\u2700-\\u27bf',
  10328. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  10329. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  10330. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  10331. rsPunctuationRange = '\\u2000-\\u206f',
  10332. 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',
  10333. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  10334. rsVarRange = '\\ufe0e\\ufe0f',
  10335. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  10336. /** Used to compose unicode capture groups. */
  10337. var rsApos = "['\u2019]",
  10338. rsAstral = '[' + rsAstralRange + ']',
  10339. rsBreak = '[' + rsBreakRange + ']',
  10340. rsCombo = '[' + rsComboRange + ']',
  10341. rsDigits = '\\d+',
  10342. rsDingbat = '[' + rsDingbatRange + ']',
  10343. rsLower = '[' + rsLowerRange + ']',
  10344. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  10345. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  10346. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  10347. rsNonAstral = '[^' + rsAstralRange + ']',
  10348. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  10349. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  10350. rsUpper = '[' + rsUpperRange + ']',
  10351. rsZWJ = '\\u200d';
  10352. /** Used to compose unicode regexes. */
  10353. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  10354. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  10355. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  10356. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  10357. reOptMod = rsModifier + '?',
  10358. rsOptVar = '[' + rsVarRange + ']?',
  10359. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  10360. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  10361. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  10362. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  10363. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  10364. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  10365. /** Used to match apostrophes. */
  10366. var reApos = RegExp(rsApos, 'g');
  10367. /**
  10368. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  10369. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  10370. */
  10371. var reComboMark = RegExp(rsCombo, 'g');
  10372. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  10373. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  10374. /** Used to match complex or compound words. */
  10375. var reUnicodeWord = RegExp([
  10376. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  10377. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  10378. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  10379. rsUpper + '+' + rsOptContrUpper,
  10380. rsOrdUpper,
  10381. rsOrdLower,
  10382. rsDigits,
  10383. rsEmoji
  10384. ].join('|'), 'g');
  10385. /** 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/). */
  10386. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  10387. /** Used to detect strings that need a more robust regexp to match words. */
  10388. 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 ]/;
  10389. /** Used to assign default `context` object properties. */
  10390. var contextProps = [
  10391. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  10392. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  10393. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  10394. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  10395. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  10396. ];
  10397. /** Used to make template sourceURLs easier to identify. */
  10398. var templateCounter = -1;
  10399. /** Used to identify `toStringTag` values of typed arrays. */
  10400. var typedArrayTags = {};
  10401. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  10402. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  10403. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  10404. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  10405. typedArrayTags[uint32Tag] = true;
  10406. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  10407. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  10408. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  10409. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  10410. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  10411. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  10412. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  10413. typedArrayTags[weakMapTag] = false;
  10414. /** Used to identify `toStringTag` values supported by `_.clone`. */
  10415. var cloneableTags = {};
  10416. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  10417. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  10418. cloneableTags[boolTag] = cloneableTags[dateTag] =
  10419. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  10420. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  10421. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  10422. cloneableTags[numberTag] = cloneableTags[objectTag] =
  10423. cloneableTags[regexpTag] = cloneableTags[setTag] =
  10424. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  10425. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  10426. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  10427. cloneableTags[errorTag] = cloneableTags[funcTag] =
  10428. cloneableTags[weakMapTag] = false;
  10429. /** Used to map Latin Unicode letters to basic Latin letters. */
  10430. var deburredLetters = {
  10431. // Latin-1 Supplement block.
  10432. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  10433. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  10434. '\xc7': 'C', '\xe7': 'c',
  10435. '\xd0': 'D', '\xf0': 'd',
  10436. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  10437. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  10438. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  10439. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  10440. '\xd1': 'N', '\xf1': 'n',
  10441. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  10442. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  10443. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  10444. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  10445. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  10446. '\xc6': 'Ae', '\xe6': 'ae',
  10447. '\xde': 'Th', '\xfe': 'th',
  10448. '\xdf': 'ss',
  10449. // Latin Extended-A block.
  10450. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  10451. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  10452. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  10453. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  10454. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  10455. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  10456. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  10457. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  10458. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  10459. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  10460. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  10461. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  10462. '\u0134': 'J', '\u0135': 'j',
  10463. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  10464. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  10465. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  10466. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  10467. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  10468. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  10469. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  10470. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  10471. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  10472. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  10473. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  10474. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  10475. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  10476. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  10477. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  10478. '\u0174': 'W', '\u0175': 'w',
  10479. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  10480. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  10481. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  10482. '\u0132': 'IJ', '\u0133': 'ij',
  10483. '\u0152': 'Oe', '\u0153': 'oe',
  10484. '\u0149': "'n", '\u017f': 's'
  10485. };
  10486. /** Used to map characters to HTML entities. */
  10487. var htmlEscapes = {
  10488. '&': '&amp;',
  10489. '<': '&lt;',
  10490. '>': '&gt;',
  10491. '"': '&quot;',
  10492. "'": '&#39;'
  10493. };
  10494. /** Used to map HTML entities to characters. */
  10495. var htmlUnescapes = {
  10496. '&amp;': '&',
  10497. '&lt;': '<',
  10498. '&gt;': '>',
  10499. '&quot;': '"',
  10500. '&#39;': "'"
  10501. };
  10502. /** Used to escape characters for inclusion in compiled string literals. */
  10503. var stringEscapes = {
  10504. '\\': '\\',
  10505. "'": "'",
  10506. '\n': 'n',
  10507. '\r': 'r',
  10508. '\u2028': 'u2028',
  10509. '\u2029': 'u2029'
  10510. };
  10511. /** Built-in method references without a dependency on `root`. */
  10512. var freeParseFloat = parseFloat,
  10513. freeParseInt = parseInt;
  10514. /** Detect free variable `global` from Node.js. */
  10515. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  10516. /** Detect free variable `self`. */
  10517. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  10518. /** Used as a reference to the global object. */
  10519. var root = freeGlobal || freeSelf || Function('return this')();
  10520. /** Detect free variable `exports`. */
  10521. var freeExports = true && exports && !exports.nodeType && exports;
  10522. /** Detect free variable `module`. */
  10523. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  10524. /** Detect the popular CommonJS extension `module.exports`. */
  10525. var moduleExports = freeModule && freeModule.exports === freeExports;
  10526. /** Detect free variable `process` from Node.js. */
  10527. var freeProcess = moduleExports && freeGlobal.process;
  10528. /** Used to access faster Node.js helpers. */
  10529. var nodeUtil = (function() {
  10530. try {
  10531. // Use `util.types` for Node.js 10+.
  10532. var types = freeModule && freeModule.require && freeModule.require('util').types;
  10533. if (types) {
  10534. return types;
  10535. }
  10536. // Legacy `process.binding('util')` for Node.js < 10.
  10537. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  10538. } catch (e) {}
  10539. }());
  10540. /* Node.js helper references. */
  10541. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  10542. nodeIsDate = nodeUtil && nodeUtil.isDate,
  10543. nodeIsMap = nodeUtil && nodeUtil.isMap,
  10544. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  10545. nodeIsSet = nodeUtil && nodeUtil.isSet,
  10546. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  10547. /*--------------------------------------------------------------------------*/
  10548. /**
  10549. * A faster alternative to `Function#apply`, this function invokes `func`
  10550. * with the `this` binding of `thisArg` and the arguments of `args`.
  10551. *
  10552. * @private
  10553. * @param {Function} func The function to invoke.
  10554. * @param {*} thisArg The `this` binding of `func`.
  10555. * @param {Array} args The arguments to invoke `func` with.
  10556. * @returns {*} Returns the result of `func`.
  10557. */
  10558. function apply(func, thisArg, args) {
  10559. switch (args.length) {
  10560. case 0: return func.call(thisArg);
  10561. case 1: return func.call(thisArg, args[0]);
  10562. case 2: return func.call(thisArg, args[0], args[1]);
  10563. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  10564. }
  10565. return func.apply(thisArg, args);
  10566. }
  10567. /**
  10568. * A specialized version of `baseAggregator` for arrays.
  10569. *
  10570. * @private
  10571. * @param {Array} [array] The array to iterate over.
  10572. * @param {Function} setter The function to set `accumulator` values.
  10573. * @param {Function} iteratee The iteratee to transform keys.
  10574. * @param {Object} accumulator The initial aggregated object.
  10575. * @returns {Function} Returns `accumulator`.
  10576. */
  10577. function arrayAggregator(array, setter, iteratee, accumulator) {
  10578. var index = -1,
  10579. length = array == null ? 0 : array.length;
  10580. while (++index < length) {
  10581. var value = array[index];
  10582. setter(accumulator, value, iteratee(value), array);
  10583. }
  10584. return accumulator;
  10585. }
  10586. /**
  10587. * A specialized version of `_.forEach` for arrays without support for
  10588. * iteratee shorthands.
  10589. *
  10590. * @private
  10591. * @param {Array} [array] The array to iterate over.
  10592. * @param {Function} iteratee The function invoked per iteration.
  10593. * @returns {Array} Returns `array`.
  10594. */
  10595. function arrayEach(array, iteratee) {
  10596. var index = -1,
  10597. length = array == null ? 0 : array.length;
  10598. while (++index < length) {
  10599. if (iteratee(array[index], index, array) === false) {
  10600. break;
  10601. }
  10602. }
  10603. return array;
  10604. }
  10605. /**
  10606. * A specialized version of `_.forEachRight` for arrays without support for
  10607. * iteratee shorthands.
  10608. *
  10609. * @private
  10610. * @param {Array} [array] The array to iterate over.
  10611. * @param {Function} iteratee The function invoked per iteration.
  10612. * @returns {Array} Returns `array`.
  10613. */
  10614. function arrayEachRight(array, iteratee) {
  10615. var length = array == null ? 0 : array.length;
  10616. while (length--) {
  10617. if (iteratee(array[length], length, array) === false) {
  10618. break;
  10619. }
  10620. }
  10621. return array;
  10622. }
  10623. /**
  10624. * A specialized version of `_.every` for arrays without support for
  10625. * iteratee shorthands.
  10626. *
  10627. * @private
  10628. * @param {Array} [array] The array to iterate over.
  10629. * @param {Function} predicate The function invoked per iteration.
  10630. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  10631. * else `false`.
  10632. */
  10633. function arrayEvery(array, predicate) {
  10634. var index = -1,
  10635. length = array == null ? 0 : array.length;
  10636. while (++index < length) {
  10637. if (!predicate(array[index], index, array)) {
  10638. return false;
  10639. }
  10640. }
  10641. return true;
  10642. }
  10643. /**
  10644. * A specialized version of `_.filter` for arrays without support for
  10645. * iteratee shorthands.
  10646. *
  10647. * @private
  10648. * @param {Array} [array] The array to iterate over.
  10649. * @param {Function} predicate The function invoked per iteration.
  10650. * @returns {Array} Returns the new filtered array.
  10651. */
  10652. function arrayFilter(array, predicate) {
  10653. var index = -1,
  10654. length = array == null ? 0 : array.length,
  10655. resIndex = 0,
  10656. result = [];
  10657. while (++index < length) {
  10658. var value = array[index];
  10659. if (predicate(value, index, array)) {
  10660. result[resIndex++] = value;
  10661. }
  10662. }
  10663. return result;
  10664. }
  10665. /**
  10666. * A specialized version of `_.includes` for arrays without support for
  10667. * specifying an index to search from.
  10668. *
  10669. * @private
  10670. * @param {Array} [array] The array to inspect.
  10671. * @param {*} target The value to search for.
  10672. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  10673. */
  10674. function arrayIncludes(array, value) {
  10675. var length = array == null ? 0 : array.length;
  10676. return !!length && baseIndexOf(array, value, 0) > -1;
  10677. }
  10678. /**
  10679. * This function is like `arrayIncludes` except that it accepts a comparator.
  10680. *
  10681. * @private
  10682. * @param {Array} [array] The array to inspect.
  10683. * @param {*} target The value to search for.
  10684. * @param {Function} comparator The comparator invoked per element.
  10685. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  10686. */
  10687. function arrayIncludesWith(array, value, comparator) {
  10688. var index = -1,
  10689. length = array == null ? 0 : array.length;
  10690. while (++index < length) {
  10691. if (comparator(value, array[index])) {
  10692. return true;
  10693. }
  10694. }
  10695. return false;
  10696. }
  10697. /**
  10698. * A specialized version of `_.map` for arrays without support for iteratee
  10699. * shorthands.
  10700. *
  10701. * @private
  10702. * @param {Array} [array] The array to iterate over.
  10703. * @param {Function} iteratee The function invoked per iteration.
  10704. * @returns {Array} Returns the new mapped array.
  10705. */
  10706. function arrayMap(array, iteratee) {
  10707. var index = -1,
  10708. length = array == null ? 0 : array.length,
  10709. result = Array(length);
  10710. while (++index < length) {
  10711. result[index] = iteratee(array[index], index, array);
  10712. }
  10713. return result;
  10714. }
  10715. /**
  10716. * Appends the elements of `values` to `array`.
  10717. *
  10718. * @private
  10719. * @param {Array} array The array to modify.
  10720. * @param {Array} values The values to append.
  10721. * @returns {Array} Returns `array`.
  10722. */
  10723. function arrayPush(array, values) {
  10724. var index = -1,
  10725. length = values.length,
  10726. offset = array.length;
  10727. while (++index < length) {
  10728. array[offset + index] = values[index];
  10729. }
  10730. return array;
  10731. }
  10732. /**
  10733. * A specialized version of `_.reduce` for arrays without support for
  10734. * iteratee shorthands.
  10735. *
  10736. * @private
  10737. * @param {Array} [array] The array to iterate over.
  10738. * @param {Function} iteratee The function invoked per iteration.
  10739. * @param {*} [accumulator] The initial value.
  10740. * @param {boolean} [initAccum] Specify using the first element of `array` as
  10741. * the initial value.
  10742. * @returns {*} Returns the accumulated value.
  10743. */
  10744. function arrayReduce(array, iteratee, accumulator, initAccum) {
  10745. var index = -1,
  10746. length = array == null ? 0 : array.length;
  10747. if (initAccum && length) {
  10748. accumulator = array[++index];
  10749. }
  10750. while (++index < length) {
  10751. accumulator = iteratee(accumulator, array[index], index, array);
  10752. }
  10753. return accumulator;
  10754. }
  10755. /**
  10756. * A specialized version of `_.reduceRight` for arrays without support for
  10757. * iteratee shorthands.
  10758. *
  10759. * @private
  10760. * @param {Array} [array] The array to iterate over.
  10761. * @param {Function} iteratee The function invoked per iteration.
  10762. * @param {*} [accumulator] The initial value.
  10763. * @param {boolean} [initAccum] Specify using the last element of `array` as
  10764. * the initial value.
  10765. * @returns {*} Returns the accumulated value.
  10766. */
  10767. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  10768. var length = array == null ? 0 : array.length;
  10769. if (initAccum && length) {
  10770. accumulator = array[--length];
  10771. }
  10772. while (length--) {
  10773. accumulator = iteratee(accumulator, array[length], length, array);
  10774. }
  10775. return accumulator;
  10776. }
  10777. /**
  10778. * A specialized version of `_.some` for arrays without support for iteratee
  10779. * shorthands.
  10780. *
  10781. * @private
  10782. * @param {Array} [array] The array to iterate over.
  10783. * @param {Function} predicate The function invoked per iteration.
  10784. * @returns {boolean} Returns `true` if any element passes the predicate check,
  10785. * else `false`.
  10786. */
  10787. function arraySome(array, predicate) {
  10788. var index = -1,
  10789. length = array == null ? 0 : array.length;
  10790. while (++index < length) {
  10791. if (predicate(array[index], index, array)) {
  10792. return true;
  10793. }
  10794. }
  10795. return false;
  10796. }
  10797. /**
  10798. * Gets the size of an ASCII `string`.
  10799. *
  10800. * @private
  10801. * @param {string} string The string inspect.
  10802. * @returns {number} Returns the string size.
  10803. */
  10804. var asciiSize = baseProperty('length');
  10805. /**
  10806. * Converts an ASCII `string` to an array.
  10807. *
  10808. * @private
  10809. * @param {string} string The string to convert.
  10810. * @returns {Array} Returns the converted array.
  10811. */
  10812. function asciiToArray(string) {
  10813. return string.split('');
  10814. }
  10815. /**
  10816. * Splits an ASCII `string` into an array of its words.
  10817. *
  10818. * @private
  10819. * @param {string} The string to inspect.
  10820. * @returns {Array} Returns the words of `string`.
  10821. */
  10822. function asciiWords(string) {
  10823. return string.match(reAsciiWord) || [];
  10824. }
  10825. /**
  10826. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  10827. * without support for iteratee shorthands, which iterates over `collection`
  10828. * using `eachFunc`.
  10829. *
  10830. * @private
  10831. * @param {Array|Object} collection The collection to inspect.
  10832. * @param {Function} predicate The function invoked per iteration.
  10833. * @param {Function} eachFunc The function to iterate over `collection`.
  10834. * @returns {*} Returns the found element or its key, else `undefined`.
  10835. */
  10836. function baseFindKey(collection, predicate, eachFunc) {
  10837. var result;
  10838. eachFunc(collection, function(value, key, collection) {
  10839. if (predicate(value, key, collection)) {
  10840. result = key;
  10841. return false;
  10842. }
  10843. });
  10844. return result;
  10845. }
  10846. /**
  10847. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  10848. * support for iteratee shorthands.
  10849. *
  10850. * @private
  10851. * @param {Array} array The array to inspect.
  10852. * @param {Function} predicate The function invoked per iteration.
  10853. * @param {number} fromIndex The index to search from.
  10854. * @param {boolean} [fromRight] Specify iterating from right to left.
  10855. * @returns {number} Returns the index of the matched value, else `-1`.
  10856. */
  10857. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  10858. var length = array.length,
  10859. index = fromIndex + (fromRight ? 1 : -1);
  10860. while ((fromRight ? index-- : ++index < length)) {
  10861. if (predicate(array[index], index, array)) {
  10862. return index;
  10863. }
  10864. }
  10865. return -1;
  10866. }
  10867. /**
  10868. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  10869. *
  10870. * @private
  10871. * @param {Array} array The array to inspect.
  10872. * @param {*} value The value to search for.
  10873. * @param {number} fromIndex The index to search from.
  10874. * @returns {number} Returns the index of the matched value, else `-1`.
  10875. */
  10876. function baseIndexOf(array, value, fromIndex) {
  10877. return value === value
  10878. ? strictIndexOf(array, value, fromIndex)
  10879. : baseFindIndex(array, baseIsNaN, fromIndex);
  10880. }
  10881. /**
  10882. * This function is like `baseIndexOf` except that it accepts a comparator.
  10883. *
  10884. * @private
  10885. * @param {Array} array The array to inspect.
  10886. * @param {*} value The value to search for.
  10887. * @param {number} fromIndex The index to search from.
  10888. * @param {Function} comparator The comparator invoked per element.
  10889. * @returns {number} Returns the index of the matched value, else `-1`.
  10890. */
  10891. function baseIndexOfWith(array, value, fromIndex, comparator) {
  10892. var index = fromIndex - 1,
  10893. length = array.length;
  10894. while (++index < length) {
  10895. if (comparator(array[index], value)) {
  10896. return index;
  10897. }
  10898. }
  10899. return -1;
  10900. }
  10901. /**
  10902. * The base implementation of `_.isNaN` without support for number objects.
  10903. *
  10904. * @private
  10905. * @param {*} value The value to check.
  10906. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  10907. */
  10908. function baseIsNaN(value) {
  10909. return value !== value;
  10910. }
  10911. /**
  10912. * The base implementation of `_.mean` and `_.meanBy` without support for
  10913. * iteratee shorthands.
  10914. *
  10915. * @private
  10916. * @param {Array} array The array to iterate over.
  10917. * @param {Function} iteratee The function invoked per iteration.
  10918. * @returns {number} Returns the mean.
  10919. */
  10920. function baseMean(array, iteratee) {
  10921. var length = array == null ? 0 : array.length;
  10922. return length ? (baseSum(array, iteratee) / length) : NAN;
  10923. }
  10924. /**
  10925. * The base implementation of `_.property` without support for deep paths.
  10926. *
  10927. * @private
  10928. * @param {string} key The key of the property to get.
  10929. * @returns {Function} Returns the new accessor function.
  10930. */
  10931. function baseProperty(key) {
  10932. return function(object) {
  10933. return object == null ? undefined : object[key];
  10934. };
  10935. }
  10936. /**
  10937. * The base implementation of `_.propertyOf` without support for deep paths.
  10938. *
  10939. * @private
  10940. * @param {Object} object The object to query.
  10941. * @returns {Function} Returns the new accessor function.
  10942. */
  10943. function basePropertyOf(object) {
  10944. return function(key) {
  10945. return object == null ? undefined : object[key];
  10946. };
  10947. }
  10948. /**
  10949. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  10950. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  10951. *
  10952. * @private
  10953. * @param {Array|Object} collection The collection to iterate over.
  10954. * @param {Function} iteratee The function invoked per iteration.
  10955. * @param {*} accumulator The initial value.
  10956. * @param {boolean} initAccum Specify using the first or last element of
  10957. * `collection` as the initial value.
  10958. * @param {Function} eachFunc The function to iterate over `collection`.
  10959. * @returns {*} Returns the accumulated value.
  10960. */
  10961. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  10962. eachFunc(collection, function(value, index, collection) {
  10963. accumulator = initAccum
  10964. ? (initAccum = false, value)
  10965. : iteratee(accumulator, value, index, collection);
  10966. });
  10967. return accumulator;
  10968. }
  10969. /**
  10970. * The base implementation of `_.sortBy` which uses `comparer` to define the
  10971. * sort order of `array` and replaces criteria objects with their corresponding
  10972. * values.
  10973. *
  10974. * @private
  10975. * @param {Array} array The array to sort.
  10976. * @param {Function} comparer The function to define sort order.
  10977. * @returns {Array} Returns `array`.
  10978. */
  10979. function baseSortBy(array, comparer) {
  10980. var length = array.length;
  10981. array.sort(comparer);
  10982. while (length--) {
  10983. array[length] = array[length].value;
  10984. }
  10985. return array;
  10986. }
  10987. /**
  10988. * The base implementation of `_.sum` and `_.sumBy` without support for
  10989. * iteratee shorthands.
  10990. *
  10991. * @private
  10992. * @param {Array} array The array to iterate over.
  10993. * @param {Function} iteratee The function invoked per iteration.
  10994. * @returns {number} Returns the sum.
  10995. */
  10996. function baseSum(array, iteratee) {
  10997. var result,
  10998. index = -1,
  10999. length = array.length;
  11000. while (++index < length) {
  11001. var current = iteratee(array[index]);
  11002. if (current !== undefined) {
  11003. result = result === undefined ? current : (result + current);
  11004. }
  11005. }
  11006. return result;
  11007. }
  11008. /**
  11009. * The base implementation of `_.times` without support for iteratee shorthands
  11010. * or max array length checks.
  11011. *
  11012. * @private
  11013. * @param {number} n The number of times to invoke `iteratee`.
  11014. * @param {Function} iteratee The function invoked per iteration.
  11015. * @returns {Array} Returns the array of results.
  11016. */
  11017. function baseTimes(n, iteratee) {
  11018. var index = -1,
  11019. result = Array(n);
  11020. while (++index < n) {
  11021. result[index] = iteratee(index);
  11022. }
  11023. return result;
  11024. }
  11025. /**
  11026. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  11027. * of key-value pairs for `object` corresponding to the property names of `props`.
  11028. *
  11029. * @private
  11030. * @param {Object} object The object to query.
  11031. * @param {Array} props The property names to get values for.
  11032. * @returns {Object} Returns the key-value pairs.
  11033. */
  11034. function baseToPairs(object, props) {
  11035. return arrayMap(props, function(key) {
  11036. return [key, object[key]];
  11037. });
  11038. }
  11039. /**
  11040. * The base implementation of `_.unary` without support for storing metadata.
  11041. *
  11042. * @private
  11043. * @param {Function} func The function to cap arguments for.
  11044. * @returns {Function} Returns the new capped function.
  11045. */
  11046. function baseUnary(func) {
  11047. return function(value) {
  11048. return func(value);
  11049. };
  11050. }
  11051. /**
  11052. * The base implementation of `_.values` and `_.valuesIn` which creates an
  11053. * array of `object` property values corresponding to the property names
  11054. * of `props`.
  11055. *
  11056. * @private
  11057. * @param {Object} object The object to query.
  11058. * @param {Array} props The property names to get values for.
  11059. * @returns {Object} Returns the array of property values.
  11060. */
  11061. function baseValues(object, props) {
  11062. return arrayMap(props, function(key) {
  11063. return object[key];
  11064. });
  11065. }
  11066. /**
  11067. * Checks if a `cache` value for `key` exists.
  11068. *
  11069. * @private
  11070. * @param {Object} cache The cache to query.
  11071. * @param {string} key The key of the entry to check.
  11072. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  11073. */
  11074. function cacheHas(cache, key) {
  11075. return cache.has(key);
  11076. }
  11077. /**
  11078. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  11079. * that is not found in the character symbols.
  11080. *
  11081. * @private
  11082. * @param {Array} strSymbols The string symbols to inspect.
  11083. * @param {Array} chrSymbols The character symbols to find.
  11084. * @returns {number} Returns the index of the first unmatched string symbol.
  11085. */
  11086. function charsStartIndex(strSymbols, chrSymbols) {
  11087. var index = -1,
  11088. length = strSymbols.length;
  11089. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  11090. return index;
  11091. }
  11092. /**
  11093. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  11094. * that is not found in the character symbols.
  11095. *
  11096. * @private
  11097. * @param {Array} strSymbols The string symbols to inspect.
  11098. * @param {Array} chrSymbols The character symbols to find.
  11099. * @returns {number} Returns the index of the last unmatched string symbol.
  11100. */
  11101. function charsEndIndex(strSymbols, chrSymbols) {
  11102. var index = strSymbols.length;
  11103. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  11104. return index;
  11105. }
  11106. /**
  11107. * Gets the number of `placeholder` occurrences in `array`.
  11108. *
  11109. * @private
  11110. * @param {Array} array The array to inspect.
  11111. * @param {*} placeholder The placeholder to search for.
  11112. * @returns {number} Returns the placeholder count.
  11113. */
  11114. function countHolders(array, placeholder) {
  11115. var length = array.length,
  11116. result = 0;
  11117. while (length--) {
  11118. if (array[length] === placeholder) {
  11119. ++result;
  11120. }
  11121. }
  11122. return result;
  11123. }
  11124. /**
  11125. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  11126. * letters to basic Latin letters.
  11127. *
  11128. * @private
  11129. * @param {string} letter The matched letter to deburr.
  11130. * @returns {string} Returns the deburred letter.
  11131. */
  11132. var deburrLetter = basePropertyOf(deburredLetters);
  11133. /**
  11134. * Used by `_.escape` to convert characters to HTML entities.
  11135. *
  11136. * @private
  11137. * @param {string} chr The matched character to escape.
  11138. * @returns {string} Returns the escaped character.
  11139. */
  11140. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  11141. /**
  11142. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  11143. *
  11144. * @private
  11145. * @param {string} chr The matched character to escape.
  11146. * @returns {string} Returns the escaped character.
  11147. */
  11148. function escapeStringChar(chr) {
  11149. return '\\' + stringEscapes[chr];
  11150. }
  11151. /**
  11152. * Gets the value at `key` of `object`.
  11153. *
  11154. * @private
  11155. * @param {Object} [object] The object to query.
  11156. * @param {string} key The key of the property to get.
  11157. * @returns {*} Returns the property value.
  11158. */
  11159. function getValue(object, key) {
  11160. return object == null ? undefined : object[key];
  11161. }
  11162. /**
  11163. * Checks if `string` contains Unicode symbols.
  11164. *
  11165. * @private
  11166. * @param {string} string The string to inspect.
  11167. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  11168. */
  11169. function hasUnicode(string) {
  11170. return reHasUnicode.test(string);
  11171. }
  11172. /**
  11173. * Checks if `string` contains a word composed of Unicode symbols.
  11174. *
  11175. * @private
  11176. * @param {string} string The string to inspect.
  11177. * @returns {boolean} Returns `true` if a word is found, else `false`.
  11178. */
  11179. function hasUnicodeWord(string) {
  11180. return reHasUnicodeWord.test(string);
  11181. }
  11182. /**
  11183. * Converts `iterator` to an array.
  11184. *
  11185. * @private
  11186. * @param {Object} iterator The iterator to convert.
  11187. * @returns {Array} Returns the converted array.
  11188. */
  11189. function iteratorToArray(iterator) {
  11190. var data,
  11191. result = [];
  11192. while (!(data = iterator.next()).done) {
  11193. result.push(data.value);
  11194. }
  11195. return result;
  11196. }
  11197. /**
  11198. * Converts `map` to its key-value pairs.
  11199. *
  11200. * @private
  11201. * @param {Object} map The map to convert.
  11202. * @returns {Array} Returns the key-value pairs.
  11203. */
  11204. function mapToArray(map) {
  11205. var index = -1,
  11206. result = Array(map.size);
  11207. map.forEach(function(value, key) {
  11208. result[++index] = [key, value];
  11209. });
  11210. return result;
  11211. }
  11212. /**
  11213. * Creates a unary function that invokes `func` with its argument transformed.
  11214. *
  11215. * @private
  11216. * @param {Function} func The function to wrap.
  11217. * @param {Function} transform The argument transform.
  11218. * @returns {Function} Returns the new function.
  11219. */
  11220. function overArg(func, transform) {
  11221. return function(arg) {
  11222. return func(transform(arg));
  11223. };
  11224. }
  11225. /**
  11226. * Replaces all `placeholder` elements in `array` with an internal placeholder
  11227. * and returns an array of their indexes.
  11228. *
  11229. * @private
  11230. * @param {Array} array The array to modify.
  11231. * @param {*} placeholder The placeholder to replace.
  11232. * @returns {Array} Returns the new array of placeholder indexes.
  11233. */
  11234. function replaceHolders(array, placeholder) {
  11235. var index = -1,
  11236. length = array.length,
  11237. resIndex = 0,
  11238. result = [];
  11239. while (++index < length) {
  11240. var value = array[index];
  11241. if (value === placeholder || value === PLACEHOLDER) {
  11242. array[index] = PLACEHOLDER;
  11243. result[resIndex++] = index;
  11244. }
  11245. }
  11246. return result;
  11247. }
  11248. /**
  11249. * Converts `set` to an array of its values.
  11250. *
  11251. * @private
  11252. * @param {Object} set The set to convert.
  11253. * @returns {Array} Returns the values.
  11254. */
  11255. function setToArray(set) {
  11256. var index = -1,
  11257. result = Array(set.size);
  11258. set.forEach(function(value) {
  11259. result[++index] = value;
  11260. });
  11261. return result;
  11262. }
  11263. /**
  11264. * Converts `set` to its value-value pairs.
  11265. *
  11266. * @private
  11267. * @param {Object} set The set to convert.
  11268. * @returns {Array} Returns the value-value pairs.
  11269. */
  11270. function setToPairs(set) {
  11271. var index = -1,
  11272. result = Array(set.size);
  11273. set.forEach(function(value) {
  11274. result[++index] = [value, value];
  11275. });
  11276. return result;
  11277. }
  11278. /**
  11279. * A specialized version of `_.indexOf` which performs strict equality
  11280. * comparisons of values, i.e. `===`.
  11281. *
  11282. * @private
  11283. * @param {Array} array The array to inspect.
  11284. * @param {*} value The value to search for.
  11285. * @param {number} fromIndex The index to search from.
  11286. * @returns {number} Returns the index of the matched value, else `-1`.
  11287. */
  11288. function strictIndexOf(array, value, fromIndex) {
  11289. var index = fromIndex - 1,
  11290. length = array.length;
  11291. while (++index < length) {
  11292. if (array[index] === value) {
  11293. return index;
  11294. }
  11295. }
  11296. return -1;
  11297. }
  11298. /**
  11299. * A specialized version of `_.lastIndexOf` which performs strict equality
  11300. * comparisons of values, i.e. `===`.
  11301. *
  11302. * @private
  11303. * @param {Array} array The array to inspect.
  11304. * @param {*} value The value to search for.
  11305. * @param {number} fromIndex The index to search from.
  11306. * @returns {number} Returns the index of the matched value, else `-1`.
  11307. */
  11308. function strictLastIndexOf(array, value, fromIndex) {
  11309. var index = fromIndex + 1;
  11310. while (index--) {
  11311. if (array[index] === value) {
  11312. return index;
  11313. }
  11314. }
  11315. return index;
  11316. }
  11317. /**
  11318. * Gets the number of symbols in `string`.
  11319. *
  11320. * @private
  11321. * @param {string} string The string to inspect.
  11322. * @returns {number} Returns the string size.
  11323. */
  11324. function stringSize(string) {
  11325. return hasUnicode(string)
  11326. ? unicodeSize(string)
  11327. : asciiSize(string);
  11328. }
  11329. /**
  11330. * Converts `string` to an array.
  11331. *
  11332. * @private
  11333. * @param {string} string The string to convert.
  11334. * @returns {Array} Returns the converted array.
  11335. */
  11336. function stringToArray(string) {
  11337. return hasUnicode(string)
  11338. ? unicodeToArray(string)
  11339. : asciiToArray(string);
  11340. }
  11341. /**
  11342. * Used by `_.unescape` to convert HTML entities to characters.
  11343. *
  11344. * @private
  11345. * @param {string} chr The matched character to unescape.
  11346. * @returns {string} Returns the unescaped character.
  11347. */
  11348. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  11349. /**
  11350. * Gets the size of a Unicode `string`.
  11351. *
  11352. * @private
  11353. * @param {string} string The string inspect.
  11354. * @returns {number} Returns the string size.
  11355. */
  11356. function unicodeSize(string) {
  11357. var result = reUnicode.lastIndex = 0;
  11358. while (reUnicode.test(string)) {
  11359. ++result;
  11360. }
  11361. return result;
  11362. }
  11363. /**
  11364. * Converts a Unicode `string` to an array.
  11365. *
  11366. * @private
  11367. * @param {string} string The string to convert.
  11368. * @returns {Array} Returns the converted array.
  11369. */
  11370. function unicodeToArray(string) {
  11371. return string.match(reUnicode) || [];
  11372. }
  11373. /**
  11374. * Splits a Unicode `string` into an array of its words.
  11375. *
  11376. * @private
  11377. * @param {string} The string to inspect.
  11378. * @returns {Array} Returns the words of `string`.
  11379. */
  11380. function unicodeWords(string) {
  11381. return string.match(reUnicodeWord) || [];
  11382. }
  11383. /*--------------------------------------------------------------------------*/
  11384. /**
  11385. * Create a new pristine `lodash` function using the `context` object.
  11386. *
  11387. * @static
  11388. * @memberOf _
  11389. * @since 1.1.0
  11390. * @category Util
  11391. * @param {Object} [context=root] The context object.
  11392. * @returns {Function} Returns a new `lodash` function.
  11393. * @example
  11394. *
  11395. * _.mixin({ 'foo': _.constant('foo') });
  11396. *
  11397. * var lodash = _.runInContext();
  11398. * lodash.mixin({ 'bar': lodash.constant('bar') });
  11399. *
  11400. * _.isFunction(_.foo);
  11401. * // => true
  11402. * _.isFunction(_.bar);
  11403. * // => false
  11404. *
  11405. * lodash.isFunction(lodash.foo);
  11406. * // => false
  11407. * lodash.isFunction(lodash.bar);
  11408. * // => true
  11409. *
  11410. * // Create a suped-up `defer` in Node.js.
  11411. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  11412. */
  11413. var runInContext = (function runInContext(context) {
  11414. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  11415. /** Built-in constructor references. */
  11416. var Array = context.Array,
  11417. Date = context.Date,
  11418. Error = context.Error,
  11419. Function = context.Function,
  11420. Math = context.Math,
  11421. Object = context.Object,
  11422. RegExp = context.RegExp,
  11423. String = context.String,
  11424. TypeError = context.TypeError;
  11425. /** Used for built-in method references. */
  11426. var arrayProto = Array.prototype,
  11427. funcProto = Function.prototype,
  11428. objectProto = Object.prototype;
  11429. /** Used to detect overreaching core-js shims. */
  11430. var coreJsData = context['__core-js_shared__'];
  11431. /** Used to resolve the decompiled source of functions. */
  11432. var funcToString = funcProto.toString;
  11433. /** Used to check objects for own properties. */
  11434. var hasOwnProperty = objectProto.hasOwnProperty;
  11435. /** Used to generate unique IDs. */
  11436. var idCounter = 0;
  11437. /** Used to detect methods masquerading as native. */
  11438. var maskSrcKey = (function() {
  11439. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  11440. return uid ? ('Symbol(src)_1.' + uid) : '';
  11441. }());
  11442. /**
  11443. * Used to resolve the
  11444. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  11445. * of values.
  11446. */
  11447. var nativeObjectToString = objectProto.toString;
  11448. /** Used to infer the `Object` constructor. */
  11449. var objectCtorString = funcToString.call(Object);
  11450. /** Used to restore the original `_` reference in `_.noConflict`. */
  11451. var oldDash = root._;
  11452. /** Used to detect if a method is native. */
  11453. var reIsNative = RegExp('^' +
  11454. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  11455. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  11456. );
  11457. /** Built-in value references. */
  11458. var Buffer = moduleExports ? context.Buffer : undefined,
  11459. Symbol = context.Symbol,
  11460. Uint8Array = context.Uint8Array,
  11461. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  11462. getPrototype = overArg(Object.getPrototypeOf, Object),
  11463. objectCreate = Object.create,
  11464. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  11465. splice = arrayProto.splice,
  11466. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  11467. symIterator = Symbol ? Symbol.iterator : undefined,
  11468. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  11469. var defineProperty = (function() {
  11470. try {
  11471. var func = getNative(Object, 'defineProperty');
  11472. func({}, '', {});
  11473. return func;
  11474. } catch (e) {}
  11475. }());
  11476. /** Mocked built-ins. */
  11477. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  11478. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  11479. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  11480. /* Built-in method references for those with the same name as other `lodash` methods. */
  11481. var nativeCeil = Math.ceil,
  11482. nativeFloor = Math.floor,
  11483. nativeGetSymbols = Object.getOwnPropertySymbols,
  11484. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  11485. nativeIsFinite = context.isFinite,
  11486. nativeJoin = arrayProto.join,
  11487. nativeKeys = overArg(Object.keys, Object),
  11488. nativeMax = Math.max,
  11489. nativeMin = Math.min,
  11490. nativeNow = Date.now,
  11491. nativeParseInt = context.parseInt,
  11492. nativeRandom = Math.random,
  11493. nativeReverse = arrayProto.reverse;
  11494. /* Built-in method references that are verified to be native. */
  11495. var DataView = getNative(context, 'DataView'),
  11496. Map = getNative(context, 'Map'),
  11497. Promise = getNative(context, 'Promise'),
  11498. Set = getNative(context, 'Set'),
  11499. WeakMap = getNative(context, 'WeakMap'),
  11500. nativeCreate = getNative(Object, 'create');
  11501. /** Used to store function metadata. */
  11502. var metaMap = WeakMap && new WeakMap;
  11503. /** Used to lookup unminified function names. */
  11504. var realNames = {};
  11505. /** Used to detect maps, sets, and weakmaps. */
  11506. var dataViewCtorString = toSource(DataView),
  11507. mapCtorString = toSource(Map),
  11508. promiseCtorString = toSource(Promise),
  11509. setCtorString = toSource(Set),
  11510. weakMapCtorString = toSource(WeakMap);
  11511. /** Used to convert symbols to primitives and strings. */
  11512. var symbolProto = Symbol ? Symbol.prototype : undefined,
  11513. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  11514. symbolToString = symbolProto ? symbolProto.toString : undefined;
  11515. /*------------------------------------------------------------------------*/
  11516. /**
  11517. * Creates a `lodash` object which wraps `value` to enable implicit method
  11518. * chain sequences. Methods that operate on and return arrays, collections,
  11519. * and functions can be chained together. Methods that retrieve a single value
  11520. * or may return a primitive value will automatically end the chain sequence
  11521. * and return the unwrapped value. Otherwise, the value must be unwrapped
  11522. * with `_#value`.
  11523. *
  11524. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  11525. * enabled using `_.chain`.
  11526. *
  11527. * The execution of chained methods is lazy, that is, it's deferred until
  11528. * `_#value` is implicitly or explicitly called.
  11529. *
  11530. * Lazy evaluation allows several methods to support shortcut fusion.
  11531. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  11532. * the creation of intermediate arrays and can greatly reduce the number of
  11533. * iteratee executions. Sections of a chain sequence qualify for shortcut
  11534. * fusion if the section is applied to an array and iteratees accept only
  11535. * one argument. The heuristic for whether a section qualifies for shortcut
  11536. * fusion is subject to change.
  11537. *
  11538. * Chaining is supported in custom builds as long as the `_#value` method is
  11539. * directly or indirectly included in the build.
  11540. *
  11541. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  11542. *
  11543. * The wrapper `Array` methods are:
  11544. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  11545. *
  11546. * The wrapper `String` methods are:
  11547. * `replace` and `split`
  11548. *
  11549. * The wrapper methods that support shortcut fusion are:
  11550. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  11551. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  11552. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  11553. *
  11554. * The chainable wrapper methods are:
  11555. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  11556. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  11557. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  11558. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  11559. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  11560. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  11561. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  11562. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  11563. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  11564. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  11565. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  11566. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  11567. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  11568. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  11569. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  11570. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  11571. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  11572. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  11573. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  11574. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  11575. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  11576. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  11577. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  11578. * `zipObject`, `zipObjectDeep`, and `zipWith`
  11579. *
  11580. * The wrapper methods that are **not** chainable by default are:
  11581. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  11582. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  11583. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  11584. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  11585. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  11586. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  11587. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  11588. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  11589. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  11590. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  11591. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  11592. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  11593. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  11594. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  11595. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  11596. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  11597. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  11598. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  11599. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  11600. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  11601. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  11602. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  11603. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  11604. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  11605. * `upperFirst`, `value`, and `words`
  11606. *
  11607. * @name _
  11608. * @constructor
  11609. * @category Seq
  11610. * @param {*} value The value to wrap in a `lodash` instance.
  11611. * @returns {Object} Returns the new `lodash` wrapper instance.
  11612. * @example
  11613. *
  11614. * function square(n) {
  11615. * return n * n;
  11616. * }
  11617. *
  11618. * var wrapped = _([1, 2, 3]);
  11619. *
  11620. * // Returns an unwrapped value.
  11621. * wrapped.reduce(_.add);
  11622. * // => 6
  11623. *
  11624. * // Returns a wrapped value.
  11625. * var squares = wrapped.map(square);
  11626. *
  11627. * _.isArray(squares);
  11628. * // => false
  11629. *
  11630. * _.isArray(squares.value());
  11631. * // => true
  11632. */
  11633. function lodash(value) {
  11634. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  11635. if (value instanceof LodashWrapper) {
  11636. return value;
  11637. }
  11638. if (hasOwnProperty.call(value, '__wrapped__')) {
  11639. return wrapperClone(value);
  11640. }
  11641. }
  11642. return new LodashWrapper(value);
  11643. }
  11644. /**
  11645. * The base implementation of `_.create` without support for assigning
  11646. * properties to the created object.
  11647. *
  11648. * @private
  11649. * @param {Object} proto The object to inherit from.
  11650. * @returns {Object} Returns the new object.
  11651. */
  11652. var baseCreate = (function() {
  11653. function object() {}
  11654. return function(proto) {
  11655. if (!isObject(proto)) {
  11656. return {};
  11657. }
  11658. if (objectCreate) {
  11659. return objectCreate(proto);
  11660. }
  11661. object.prototype = proto;
  11662. var result = new object;
  11663. object.prototype = undefined;
  11664. return result;
  11665. };
  11666. }());
  11667. /**
  11668. * The function whose prototype chain sequence wrappers inherit from.
  11669. *
  11670. * @private
  11671. */
  11672. function baseLodash() {
  11673. // No operation performed.
  11674. }
  11675. /**
  11676. * The base constructor for creating `lodash` wrapper objects.
  11677. *
  11678. * @private
  11679. * @param {*} value The value to wrap.
  11680. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  11681. */
  11682. function LodashWrapper(value, chainAll) {
  11683. this.__wrapped__ = value;
  11684. this.__actions__ = [];
  11685. this.__chain__ = !!chainAll;
  11686. this.__index__ = 0;
  11687. this.__values__ = undefined;
  11688. }
  11689. /**
  11690. * By default, the template delimiters used by lodash are like those in
  11691. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  11692. * following template settings to use alternative delimiters.
  11693. *
  11694. * @static
  11695. * @memberOf _
  11696. * @type {Object}
  11697. */
  11698. lodash.templateSettings = {
  11699. /**
  11700. * Used to detect `data` property values to be HTML-escaped.
  11701. *
  11702. * @memberOf _.templateSettings
  11703. * @type {RegExp}
  11704. */
  11705. 'escape': reEscape,
  11706. /**
  11707. * Used to detect code to be evaluated.
  11708. *
  11709. * @memberOf _.templateSettings
  11710. * @type {RegExp}
  11711. */
  11712. 'evaluate': reEvaluate,
  11713. /**
  11714. * Used to detect `data` property values to inject.
  11715. *
  11716. * @memberOf _.templateSettings
  11717. * @type {RegExp}
  11718. */
  11719. 'interpolate': reInterpolate,
  11720. /**
  11721. * Used to reference the data object in the template text.
  11722. *
  11723. * @memberOf _.templateSettings
  11724. * @type {string}
  11725. */
  11726. 'variable': '',
  11727. /**
  11728. * Used to import variables into the compiled template.
  11729. *
  11730. * @memberOf _.templateSettings
  11731. * @type {Object}
  11732. */
  11733. 'imports': {
  11734. /**
  11735. * A reference to the `lodash` function.
  11736. *
  11737. * @memberOf _.templateSettings.imports
  11738. * @type {Function}
  11739. */
  11740. '_': lodash
  11741. }
  11742. };
  11743. // Ensure wrappers are instances of `baseLodash`.
  11744. lodash.prototype = baseLodash.prototype;
  11745. lodash.prototype.constructor = lodash;
  11746. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  11747. LodashWrapper.prototype.constructor = LodashWrapper;
  11748. /*------------------------------------------------------------------------*/
  11749. /**
  11750. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  11751. *
  11752. * @private
  11753. * @constructor
  11754. * @param {*} value The value to wrap.
  11755. */
  11756. function LazyWrapper(value) {
  11757. this.__wrapped__ = value;
  11758. this.__actions__ = [];
  11759. this.__dir__ = 1;
  11760. this.__filtered__ = false;
  11761. this.__iteratees__ = [];
  11762. this.__takeCount__ = MAX_ARRAY_LENGTH;
  11763. this.__views__ = [];
  11764. }
  11765. /**
  11766. * Creates a clone of the lazy wrapper object.
  11767. *
  11768. * @private
  11769. * @name clone
  11770. * @memberOf LazyWrapper
  11771. * @returns {Object} Returns the cloned `LazyWrapper` object.
  11772. */
  11773. function lazyClone() {
  11774. var result = new LazyWrapper(this.__wrapped__);
  11775. result.__actions__ = copyArray(this.__actions__);
  11776. result.__dir__ = this.__dir__;
  11777. result.__filtered__ = this.__filtered__;
  11778. result.__iteratees__ = copyArray(this.__iteratees__);
  11779. result.__takeCount__ = this.__takeCount__;
  11780. result.__views__ = copyArray(this.__views__);
  11781. return result;
  11782. }
  11783. /**
  11784. * Reverses the direction of lazy iteration.
  11785. *
  11786. * @private
  11787. * @name reverse
  11788. * @memberOf LazyWrapper
  11789. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  11790. */
  11791. function lazyReverse() {
  11792. if (this.__filtered__) {
  11793. var result = new LazyWrapper(this);
  11794. result.__dir__ = -1;
  11795. result.__filtered__ = true;
  11796. } else {
  11797. result = this.clone();
  11798. result.__dir__ *= -1;
  11799. }
  11800. return result;
  11801. }
  11802. /**
  11803. * Extracts the unwrapped value from its lazy wrapper.
  11804. *
  11805. * @private
  11806. * @name value
  11807. * @memberOf LazyWrapper
  11808. * @returns {*} Returns the unwrapped value.
  11809. */
  11810. function lazyValue() {
  11811. var array = this.__wrapped__.value(),
  11812. dir = this.__dir__,
  11813. isArr = isArray(array),
  11814. isRight = dir < 0,
  11815. arrLength = isArr ? array.length : 0,
  11816. view = getView(0, arrLength, this.__views__),
  11817. start = view.start,
  11818. end = view.end,
  11819. length = end - start,
  11820. index = isRight ? end : (start - 1),
  11821. iteratees = this.__iteratees__,
  11822. iterLength = iteratees.length,
  11823. resIndex = 0,
  11824. takeCount = nativeMin(length, this.__takeCount__);
  11825. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  11826. return baseWrapperValue(array, this.__actions__);
  11827. }
  11828. var result = [];
  11829. outer:
  11830. while (length-- && resIndex < takeCount) {
  11831. index += dir;
  11832. var iterIndex = -1,
  11833. value = array[index];
  11834. while (++iterIndex < iterLength) {
  11835. var data = iteratees[iterIndex],
  11836. iteratee = data.iteratee,
  11837. type = data.type,
  11838. computed = iteratee(value);
  11839. if (type == LAZY_MAP_FLAG) {
  11840. value = computed;
  11841. } else if (!computed) {
  11842. if (type == LAZY_FILTER_FLAG) {
  11843. continue outer;
  11844. } else {
  11845. break outer;
  11846. }
  11847. }
  11848. }
  11849. result[resIndex++] = value;
  11850. }
  11851. return result;
  11852. }
  11853. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  11854. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  11855. LazyWrapper.prototype.constructor = LazyWrapper;
  11856. /*------------------------------------------------------------------------*/
  11857. /**
  11858. * Creates a hash object.
  11859. *
  11860. * @private
  11861. * @constructor
  11862. * @param {Array} [entries] The key-value pairs to cache.
  11863. */
  11864. function Hash(entries) {
  11865. var index = -1,
  11866. length = entries == null ? 0 : entries.length;
  11867. this.clear();
  11868. while (++index < length) {
  11869. var entry = entries[index];
  11870. this.set(entry[0], entry[1]);
  11871. }
  11872. }
  11873. /**
  11874. * Removes all key-value entries from the hash.
  11875. *
  11876. * @private
  11877. * @name clear
  11878. * @memberOf Hash
  11879. */
  11880. function hashClear() {
  11881. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  11882. this.size = 0;
  11883. }
  11884. /**
  11885. * Removes `key` and its value from the hash.
  11886. *
  11887. * @private
  11888. * @name delete
  11889. * @memberOf Hash
  11890. * @param {Object} hash The hash to modify.
  11891. * @param {string} key The key of the value to remove.
  11892. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  11893. */
  11894. function hashDelete(key) {
  11895. var result = this.has(key) && delete this.__data__[key];
  11896. this.size -= result ? 1 : 0;
  11897. return result;
  11898. }
  11899. /**
  11900. * Gets the hash value for `key`.
  11901. *
  11902. * @private
  11903. * @name get
  11904. * @memberOf Hash
  11905. * @param {string} key The key of the value to get.
  11906. * @returns {*} Returns the entry value.
  11907. */
  11908. function hashGet(key) {
  11909. var data = this.__data__;
  11910. if (nativeCreate) {
  11911. var result = data[key];
  11912. return result === HASH_UNDEFINED ? undefined : result;
  11913. }
  11914. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  11915. }
  11916. /**
  11917. * Checks if a hash value for `key` exists.
  11918. *
  11919. * @private
  11920. * @name has
  11921. * @memberOf Hash
  11922. * @param {string} key The key of the entry to check.
  11923. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  11924. */
  11925. function hashHas(key) {
  11926. var data = this.__data__;
  11927. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  11928. }
  11929. /**
  11930. * Sets the hash `key` to `value`.
  11931. *
  11932. * @private
  11933. * @name set
  11934. * @memberOf Hash
  11935. * @param {string} key The key of the value to set.
  11936. * @param {*} value The value to set.
  11937. * @returns {Object} Returns the hash instance.
  11938. */
  11939. function hashSet(key, value) {
  11940. var data = this.__data__;
  11941. this.size += this.has(key) ? 0 : 1;
  11942. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  11943. return this;
  11944. }
  11945. // Add methods to `Hash`.
  11946. Hash.prototype.clear = hashClear;
  11947. Hash.prototype['delete'] = hashDelete;
  11948. Hash.prototype.get = hashGet;
  11949. Hash.prototype.has = hashHas;
  11950. Hash.prototype.set = hashSet;
  11951. /*------------------------------------------------------------------------*/
  11952. /**
  11953. * Creates an list cache object.
  11954. *
  11955. * @private
  11956. * @constructor
  11957. * @param {Array} [entries] The key-value pairs to cache.
  11958. */
  11959. function ListCache(entries) {
  11960. var index = -1,
  11961. length = entries == null ? 0 : entries.length;
  11962. this.clear();
  11963. while (++index < length) {
  11964. var entry = entries[index];
  11965. this.set(entry[0], entry[1]);
  11966. }
  11967. }
  11968. /**
  11969. * Removes all key-value entries from the list cache.
  11970. *
  11971. * @private
  11972. * @name clear
  11973. * @memberOf ListCache
  11974. */
  11975. function listCacheClear() {
  11976. this.__data__ = [];
  11977. this.size = 0;
  11978. }
  11979. /**
  11980. * Removes `key` and its value from the list cache.
  11981. *
  11982. * @private
  11983. * @name delete
  11984. * @memberOf ListCache
  11985. * @param {string} key The key of the value to remove.
  11986. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  11987. */
  11988. function listCacheDelete(key) {
  11989. var data = this.__data__,
  11990. index = assocIndexOf(data, key);
  11991. if (index < 0) {
  11992. return false;
  11993. }
  11994. var lastIndex = data.length - 1;
  11995. if (index == lastIndex) {
  11996. data.pop();
  11997. } else {
  11998. splice.call(data, index, 1);
  11999. }
  12000. --this.size;
  12001. return true;
  12002. }
  12003. /**
  12004. * Gets the list cache value for `key`.
  12005. *
  12006. * @private
  12007. * @name get
  12008. * @memberOf ListCache
  12009. * @param {string} key The key of the value to get.
  12010. * @returns {*} Returns the entry value.
  12011. */
  12012. function listCacheGet(key) {
  12013. var data = this.__data__,
  12014. index = assocIndexOf(data, key);
  12015. return index < 0 ? undefined : data[index][1];
  12016. }
  12017. /**
  12018. * Checks if a list cache value for `key` exists.
  12019. *
  12020. * @private
  12021. * @name has
  12022. * @memberOf ListCache
  12023. * @param {string} key The key of the entry to check.
  12024. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  12025. */
  12026. function listCacheHas(key) {
  12027. return assocIndexOf(this.__data__, key) > -1;
  12028. }
  12029. /**
  12030. * Sets the list cache `key` to `value`.
  12031. *
  12032. * @private
  12033. * @name set
  12034. * @memberOf ListCache
  12035. * @param {string} key The key of the value to set.
  12036. * @param {*} value The value to set.
  12037. * @returns {Object} Returns the list cache instance.
  12038. */
  12039. function listCacheSet(key, value) {
  12040. var data = this.__data__,
  12041. index = assocIndexOf(data, key);
  12042. if (index < 0) {
  12043. ++this.size;
  12044. data.push([key, value]);
  12045. } else {
  12046. data[index][1] = value;
  12047. }
  12048. return this;
  12049. }
  12050. // Add methods to `ListCache`.
  12051. ListCache.prototype.clear = listCacheClear;
  12052. ListCache.prototype['delete'] = listCacheDelete;
  12053. ListCache.prototype.get = listCacheGet;
  12054. ListCache.prototype.has = listCacheHas;
  12055. ListCache.prototype.set = listCacheSet;
  12056. /*------------------------------------------------------------------------*/
  12057. /**
  12058. * Creates a map cache object to store key-value pairs.
  12059. *
  12060. * @private
  12061. * @constructor
  12062. * @param {Array} [entries] The key-value pairs to cache.
  12063. */
  12064. function MapCache(entries) {
  12065. var index = -1,
  12066. length = entries == null ? 0 : entries.length;
  12067. this.clear();
  12068. while (++index < length) {
  12069. var entry = entries[index];
  12070. this.set(entry[0], entry[1]);
  12071. }
  12072. }
  12073. /**
  12074. * Removes all key-value entries from the map.
  12075. *
  12076. * @private
  12077. * @name clear
  12078. * @memberOf MapCache
  12079. */
  12080. function mapCacheClear() {
  12081. this.size = 0;
  12082. this.__data__ = {
  12083. 'hash': new Hash,
  12084. 'map': new (Map || ListCache),
  12085. 'string': new Hash
  12086. };
  12087. }
  12088. /**
  12089. * Removes `key` and its value from the map.
  12090. *
  12091. * @private
  12092. * @name delete
  12093. * @memberOf MapCache
  12094. * @param {string} key The key of the value to remove.
  12095. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  12096. */
  12097. function mapCacheDelete(key) {
  12098. var result = getMapData(this, key)['delete'](key);
  12099. this.size -= result ? 1 : 0;
  12100. return result;
  12101. }
  12102. /**
  12103. * Gets the map value for `key`.
  12104. *
  12105. * @private
  12106. * @name get
  12107. * @memberOf MapCache
  12108. * @param {string} key The key of the value to get.
  12109. * @returns {*} Returns the entry value.
  12110. */
  12111. function mapCacheGet(key) {
  12112. return getMapData(this, key).get(key);
  12113. }
  12114. /**
  12115. * Checks if a map value for `key` exists.
  12116. *
  12117. * @private
  12118. * @name has
  12119. * @memberOf MapCache
  12120. * @param {string} key The key of the entry to check.
  12121. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  12122. */
  12123. function mapCacheHas(key) {
  12124. return getMapData(this, key).has(key);
  12125. }
  12126. /**
  12127. * Sets the map `key` to `value`.
  12128. *
  12129. * @private
  12130. * @name set
  12131. * @memberOf MapCache
  12132. * @param {string} key The key of the value to set.
  12133. * @param {*} value The value to set.
  12134. * @returns {Object} Returns the map cache instance.
  12135. */
  12136. function mapCacheSet(key, value) {
  12137. var data = getMapData(this, key),
  12138. size = data.size;
  12139. data.set(key, value);
  12140. this.size += data.size == size ? 0 : 1;
  12141. return this;
  12142. }
  12143. // Add methods to `MapCache`.
  12144. MapCache.prototype.clear = mapCacheClear;
  12145. MapCache.prototype['delete'] = mapCacheDelete;
  12146. MapCache.prototype.get = mapCacheGet;
  12147. MapCache.prototype.has = mapCacheHas;
  12148. MapCache.prototype.set = mapCacheSet;
  12149. /*------------------------------------------------------------------------*/
  12150. /**
  12151. *
  12152. * Creates an array cache object to store unique values.
  12153. *
  12154. * @private
  12155. * @constructor
  12156. * @param {Array} [values] The values to cache.
  12157. */
  12158. function SetCache(values) {
  12159. var index = -1,
  12160. length = values == null ? 0 : values.length;
  12161. this.__data__ = new MapCache;
  12162. while (++index < length) {
  12163. this.add(values[index]);
  12164. }
  12165. }
  12166. /**
  12167. * Adds `value` to the array cache.
  12168. *
  12169. * @private
  12170. * @name add
  12171. * @memberOf SetCache
  12172. * @alias push
  12173. * @param {*} value The value to cache.
  12174. * @returns {Object} Returns the cache instance.
  12175. */
  12176. function setCacheAdd(value) {
  12177. this.__data__.set(value, HASH_UNDEFINED);
  12178. return this;
  12179. }
  12180. /**
  12181. * Checks if `value` is in the array cache.
  12182. *
  12183. * @private
  12184. * @name has
  12185. * @memberOf SetCache
  12186. * @param {*} value The value to search for.
  12187. * @returns {number} Returns `true` if `value` is found, else `false`.
  12188. */
  12189. function setCacheHas(value) {
  12190. return this.__data__.has(value);
  12191. }
  12192. // Add methods to `SetCache`.
  12193. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  12194. SetCache.prototype.has = setCacheHas;
  12195. /*------------------------------------------------------------------------*/
  12196. /**
  12197. * Creates a stack cache object to store key-value pairs.
  12198. *
  12199. * @private
  12200. * @constructor
  12201. * @param {Array} [entries] The key-value pairs to cache.
  12202. */
  12203. function Stack(entries) {
  12204. var data = this.__data__ = new ListCache(entries);
  12205. this.size = data.size;
  12206. }
  12207. /**
  12208. * Removes all key-value entries from the stack.
  12209. *
  12210. * @private
  12211. * @name clear
  12212. * @memberOf Stack
  12213. */
  12214. function stackClear() {
  12215. this.__data__ = new ListCache;
  12216. this.size = 0;
  12217. }
  12218. /**
  12219. * Removes `key` and its value from the stack.
  12220. *
  12221. * @private
  12222. * @name delete
  12223. * @memberOf Stack
  12224. * @param {string} key The key of the value to remove.
  12225. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  12226. */
  12227. function stackDelete(key) {
  12228. var data = this.__data__,
  12229. result = data['delete'](key);
  12230. this.size = data.size;
  12231. return result;
  12232. }
  12233. /**
  12234. * Gets the stack value for `key`.
  12235. *
  12236. * @private
  12237. * @name get
  12238. * @memberOf Stack
  12239. * @param {string} key The key of the value to get.
  12240. * @returns {*} Returns the entry value.
  12241. */
  12242. function stackGet(key) {
  12243. return this.__data__.get(key);
  12244. }
  12245. /**
  12246. * Checks if a stack value for `key` exists.
  12247. *
  12248. * @private
  12249. * @name has
  12250. * @memberOf Stack
  12251. * @param {string} key The key of the entry to check.
  12252. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  12253. */
  12254. function stackHas(key) {
  12255. return this.__data__.has(key);
  12256. }
  12257. /**
  12258. * Sets the stack `key` to `value`.
  12259. *
  12260. * @private
  12261. * @name set
  12262. * @memberOf Stack
  12263. * @param {string} key The key of the value to set.
  12264. * @param {*} value The value to set.
  12265. * @returns {Object} Returns the stack cache instance.
  12266. */
  12267. function stackSet(key, value) {
  12268. var data = this.__data__;
  12269. if (data instanceof ListCache) {
  12270. var pairs = data.__data__;
  12271. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  12272. pairs.push([key, value]);
  12273. this.size = ++data.size;
  12274. return this;
  12275. }
  12276. data = this.__data__ = new MapCache(pairs);
  12277. }
  12278. data.set(key, value);
  12279. this.size = data.size;
  12280. return this;
  12281. }
  12282. // Add methods to `Stack`.
  12283. Stack.prototype.clear = stackClear;
  12284. Stack.prototype['delete'] = stackDelete;
  12285. Stack.prototype.get = stackGet;
  12286. Stack.prototype.has = stackHas;
  12287. Stack.prototype.set = stackSet;
  12288. /*------------------------------------------------------------------------*/
  12289. /**
  12290. * Creates an array of the enumerable property names of the array-like `value`.
  12291. *
  12292. * @private
  12293. * @param {*} value The value to query.
  12294. * @param {boolean} inherited Specify returning inherited property names.
  12295. * @returns {Array} Returns the array of property names.
  12296. */
  12297. function arrayLikeKeys(value, inherited) {
  12298. var isArr = isArray(value),
  12299. isArg = !isArr && isArguments(value),
  12300. isBuff = !isArr && !isArg && isBuffer(value),
  12301. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  12302. skipIndexes = isArr || isArg || isBuff || isType,
  12303. result = skipIndexes ? baseTimes(value.length, String) : [],
  12304. length = result.length;
  12305. for (var key in value) {
  12306. if ((inherited || hasOwnProperty.call(value, key)) &&
  12307. !(skipIndexes && (
  12308. // Safari 9 has enumerable `arguments.length` in strict mode.
  12309. key == 'length' ||
  12310. // Node.js 0.10 has enumerable non-index properties on buffers.
  12311. (isBuff && (key == 'offset' || key == 'parent')) ||
  12312. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  12313. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  12314. // Skip index properties.
  12315. isIndex(key, length)
  12316. ))) {
  12317. result.push(key);
  12318. }
  12319. }
  12320. return result;
  12321. }
  12322. /**
  12323. * A specialized version of `_.sample` for arrays.
  12324. *
  12325. * @private
  12326. * @param {Array} array The array to sample.
  12327. * @returns {*} Returns the random element.
  12328. */
  12329. function arraySample(array) {
  12330. var length = array.length;
  12331. return length ? array[baseRandom(0, length - 1)] : undefined;
  12332. }
  12333. /**
  12334. * A specialized version of `_.sampleSize` for arrays.
  12335. *
  12336. * @private
  12337. * @param {Array} array The array to sample.
  12338. * @param {number} n The number of elements to sample.
  12339. * @returns {Array} Returns the random elements.
  12340. */
  12341. function arraySampleSize(array, n) {
  12342. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  12343. }
  12344. /**
  12345. * A specialized version of `_.shuffle` for arrays.
  12346. *
  12347. * @private
  12348. * @param {Array} array The array to shuffle.
  12349. * @returns {Array} Returns the new shuffled array.
  12350. */
  12351. function arrayShuffle(array) {
  12352. return shuffleSelf(copyArray(array));
  12353. }
  12354. /**
  12355. * This function is like `assignValue` except that it doesn't assign
  12356. * `undefined` values.
  12357. *
  12358. * @private
  12359. * @param {Object} object The object to modify.
  12360. * @param {string} key The key of the property to assign.
  12361. * @param {*} value The value to assign.
  12362. */
  12363. function assignMergeValue(object, key, value) {
  12364. if ((value !== undefined && !eq(object[key], value)) ||
  12365. (value === undefined && !(key in object))) {
  12366. baseAssignValue(object, key, value);
  12367. }
  12368. }
  12369. /**
  12370. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  12371. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  12372. * for equality comparisons.
  12373. *
  12374. * @private
  12375. * @param {Object} object The object to modify.
  12376. * @param {string} key The key of the property to assign.
  12377. * @param {*} value The value to assign.
  12378. */
  12379. function assignValue(object, key, value) {
  12380. var objValue = object[key];
  12381. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  12382. (value === undefined && !(key in object))) {
  12383. baseAssignValue(object, key, value);
  12384. }
  12385. }
  12386. /**
  12387. * Gets the index at which the `key` is found in `array` of key-value pairs.
  12388. *
  12389. * @private
  12390. * @param {Array} array The array to inspect.
  12391. * @param {*} key The key to search for.
  12392. * @returns {number} Returns the index of the matched value, else `-1`.
  12393. */
  12394. function assocIndexOf(array, key) {
  12395. var length = array.length;
  12396. while (length--) {
  12397. if (eq(array[length][0], key)) {
  12398. return length;
  12399. }
  12400. }
  12401. return -1;
  12402. }
  12403. /**
  12404. * Aggregates elements of `collection` on `accumulator` with keys transformed
  12405. * by `iteratee` and values set by `setter`.
  12406. *
  12407. * @private
  12408. * @param {Array|Object} collection The collection to iterate over.
  12409. * @param {Function} setter The function to set `accumulator` values.
  12410. * @param {Function} iteratee The iteratee to transform keys.
  12411. * @param {Object} accumulator The initial aggregated object.
  12412. * @returns {Function} Returns `accumulator`.
  12413. */
  12414. function baseAggregator(collection, setter, iteratee, accumulator) {
  12415. baseEach(collection, function(value, key, collection) {
  12416. setter(accumulator, value, iteratee(value), collection);
  12417. });
  12418. return accumulator;
  12419. }
  12420. /**
  12421. * The base implementation of `_.assign` without support for multiple sources
  12422. * or `customizer` functions.
  12423. *
  12424. * @private
  12425. * @param {Object} object The destination object.
  12426. * @param {Object} source The source object.
  12427. * @returns {Object} Returns `object`.
  12428. */
  12429. function baseAssign(object, source) {
  12430. return object && copyObject(source, keys(source), object);
  12431. }
  12432. /**
  12433. * The base implementation of `_.assignIn` without support for multiple sources
  12434. * or `customizer` functions.
  12435. *
  12436. * @private
  12437. * @param {Object} object The destination object.
  12438. * @param {Object} source The source object.
  12439. * @returns {Object} Returns `object`.
  12440. */
  12441. function baseAssignIn(object, source) {
  12442. return object && copyObject(source, keysIn(source), object);
  12443. }
  12444. /**
  12445. * The base implementation of `assignValue` and `assignMergeValue` without
  12446. * value checks.
  12447. *
  12448. * @private
  12449. * @param {Object} object The object to modify.
  12450. * @param {string} key The key of the property to assign.
  12451. * @param {*} value The value to assign.
  12452. */
  12453. function baseAssignValue(object, key, value) {
  12454. if (key == '__proto__' && defineProperty) {
  12455. defineProperty(object, key, {
  12456. 'configurable': true,
  12457. 'enumerable': true,
  12458. 'value': value,
  12459. 'writable': true
  12460. });
  12461. } else {
  12462. object[key] = value;
  12463. }
  12464. }
  12465. /**
  12466. * The base implementation of `_.at` without support for individual paths.
  12467. *
  12468. * @private
  12469. * @param {Object} object The object to iterate over.
  12470. * @param {string[]} paths The property paths to pick.
  12471. * @returns {Array} Returns the picked elements.
  12472. */
  12473. function baseAt(object, paths) {
  12474. var index = -1,
  12475. length = paths.length,
  12476. result = Array(length),
  12477. skip = object == null;
  12478. while (++index < length) {
  12479. result[index] = skip ? undefined : get(object, paths[index]);
  12480. }
  12481. return result;
  12482. }
  12483. /**
  12484. * The base implementation of `_.clamp` which doesn't coerce arguments.
  12485. *
  12486. * @private
  12487. * @param {number} number The number to clamp.
  12488. * @param {number} [lower] The lower bound.
  12489. * @param {number} upper The upper bound.
  12490. * @returns {number} Returns the clamped number.
  12491. */
  12492. function baseClamp(number, lower, upper) {
  12493. if (number === number) {
  12494. if (upper !== undefined) {
  12495. number = number <= upper ? number : upper;
  12496. }
  12497. if (lower !== undefined) {
  12498. number = number >= lower ? number : lower;
  12499. }
  12500. }
  12501. return number;
  12502. }
  12503. /**
  12504. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  12505. * traversed objects.
  12506. *
  12507. * @private
  12508. * @param {*} value The value to clone.
  12509. * @param {boolean} bitmask The bitmask flags.
  12510. * 1 - Deep clone
  12511. * 2 - Flatten inherited properties
  12512. * 4 - Clone symbols
  12513. * @param {Function} [customizer] The function to customize cloning.
  12514. * @param {string} [key] The key of `value`.
  12515. * @param {Object} [object] The parent object of `value`.
  12516. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  12517. * @returns {*} Returns the cloned value.
  12518. */
  12519. function baseClone(value, bitmask, customizer, key, object, stack) {
  12520. var result,
  12521. isDeep = bitmask & CLONE_DEEP_FLAG,
  12522. isFlat = bitmask & CLONE_FLAT_FLAG,
  12523. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  12524. if (customizer) {
  12525. result = object ? customizer(value, key, object, stack) : customizer(value);
  12526. }
  12527. if (result !== undefined) {
  12528. return result;
  12529. }
  12530. if (!isObject(value)) {
  12531. return value;
  12532. }
  12533. var isArr = isArray(value);
  12534. if (isArr) {
  12535. result = initCloneArray(value);
  12536. if (!isDeep) {
  12537. return copyArray(value, result);
  12538. }
  12539. } else {
  12540. var tag = getTag(value),
  12541. isFunc = tag == funcTag || tag == genTag;
  12542. if (isBuffer(value)) {
  12543. return cloneBuffer(value, isDeep);
  12544. }
  12545. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  12546. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  12547. if (!isDeep) {
  12548. return isFlat
  12549. ? copySymbolsIn(value, baseAssignIn(result, value))
  12550. : copySymbols(value, baseAssign(result, value));
  12551. }
  12552. } else {
  12553. if (!cloneableTags[tag]) {
  12554. return object ? value : {};
  12555. }
  12556. result = initCloneByTag(value, tag, isDeep);
  12557. }
  12558. }
  12559. // Check for circular references and return its corresponding clone.
  12560. stack || (stack = new Stack);
  12561. var stacked = stack.get(value);
  12562. if (stacked) {
  12563. return stacked;
  12564. }
  12565. stack.set(value, result);
  12566. if (isSet(value)) {
  12567. value.forEach(function(subValue) {
  12568. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  12569. });
  12570. } else if (isMap(value)) {
  12571. value.forEach(function(subValue, key) {
  12572. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  12573. });
  12574. }
  12575. var keysFunc = isFull
  12576. ? (isFlat ? getAllKeysIn : getAllKeys)
  12577. : (isFlat ? keysIn : keys);
  12578. var props = isArr ? undefined : keysFunc(value);
  12579. arrayEach(props || value, function(subValue, key) {
  12580. if (props) {
  12581. key = subValue;
  12582. subValue = value[key];
  12583. }
  12584. // Recursively populate clone (susceptible to call stack limits).
  12585. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  12586. });
  12587. return result;
  12588. }
  12589. /**
  12590. * The base implementation of `_.conforms` which doesn't clone `source`.
  12591. *
  12592. * @private
  12593. * @param {Object} source The object of property predicates to conform to.
  12594. * @returns {Function} Returns the new spec function.
  12595. */
  12596. function baseConforms(source) {
  12597. var props = keys(source);
  12598. return function(object) {
  12599. return baseConformsTo(object, source, props);
  12600. };
  12601. }
  12602. /**
  12603. * The base implementation of `_.conformsTo` which accepts `props` to check.
  12604. *
  12605. * @private
  12606. * @param {Object} object The object to inspect.
  12607. * @param {Object} source The object of property predicates to conform to.
  12608. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  12609. */
  12610. function baseConformsTo(object, source, props) {
  12611. var length = props.length;
  12612. if (object == null) {
  12613. return !length;
  12614. }
  12615. object = Object(object);
  12616. while (length--) {
  12617. var key = props[length],
  12618. predicate = source[key],
  12619. value = object[key];
  12620. if ((value === undefined && !(key in object)) || !predicate(value)) {
  12621. return false;
  12622. }
  12623. }
  12624. return true;
  12625. }
  12626. /**
  12627. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  12628. * to provide to `func`.
  12629. *
  12630. * @private
  12631. * @param {Function} func The function to delay.
  12632. * @param {number} wait The number of milliseconds to delay invocation.
  12633. * @param {Array} args The arguments to provide to `func`.
  12634. * @returns {number|Object} Returns the timer id or timeout object.
  12635. */
  12636. function baseDelay(func, wait, args) {
  12637. if (typeof func != 'function') {
  12638. throw new TypeError(FUNC_ERROR_TEXT);
  12639. }
  12640. return setTimeout(function() { func.apply(undefined, args); }, wait);
  12641. }
  12642. /**
  12643. * The base implementation of methods like `_.difference` without support
  12644. * for excluding multiple arrays or iteratee shorthands.
  12645. *
  12646. * @private
  12647. * @param {Array} array The array to inspect.
  12648. * @param {Array} values The values to exclude.
  12649. * @param {Function} [iteratee] The iteratee invoked per element.
  12650. * @param {Function} [comparator] The comparator invoked per element.
  12651. * @returns {Array} Returns the new array of filtered values.
  12652. */
  12653. function baseDifference(array, values, iteratee, comparator) {
  12654. var index = -1,
  12655. includes = arrayIncludes,
  12656. isCommon = true,
  12657. length = array.length,
  12658. result = [],
  12659. valuesLength = values.length;
  12660. if (!length) {
  12661. return result;
  12662. }
  12663. if (iteratee) {
  12664. values = arrayMap(values, baseUnary(iteratee));
  12665. }
  12666. if (comparator) {
  12667. includes = arrayIncludesWith;
  12668. isCommon = false;
  12669. }
  12670. else if (values.length >= LARGE_ARRAY_SIZE) {
  12671. includes = cacheHas;
  12672. isCommon = false;
  12673. values = new SetCache(values);
  12674. }
  12675. outer:
  12676. while (++index < length) {
  12677. var value = array[index],
  12678. computed = iteratee == null ? value : iteratee(value);
  12679. value = (comparator || value !== 0) ? value : 0;
  12680. if (isCommon && computed === computed) {
  12681. var valuesIndex = valuesLength;
  12682. while (valuesIndex--) {
  12683. if (values[valuesIndex] === computed) {
  12684. continue outer;
  12685. }
  12686. }
  12687. result.push(value);
  12688. }
  12689. else if (!includes(values, computed, comparator)) {
  12690. result.push(value);
  12691. }
  12692. }
  12693. return result;
  12694. }
  12695. /**
  12696. * The base implementation of `_.forEach` without support for iteratee shorthands.
  12697. *
  12698. * @private
  12699. * @param {Array|Object} collection The collection to iterate over.
  12700. * @param {Function} iteratee The function invoked per iteration.
  12701. * @returns {Array|Object} Returns `collection`.
  12702. */
  12703. var baseEach = createBaseEach(baseForOwn);
  12704. /**
  12705. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  12706. *
  12707. * @private
  12708. * @param {Array|Object} collection The collection to iterate over.
  12709. * @param {Function} iteratee The function invoked per iteration.
  12710. * @returns {Array|Object} Returns `collection`.
  12711. */
  12712. var baseEachRight = createBaseEach(baseForOwnRight, true);
  12713. /**
  12714. * The base implementation of `_.every` without support for iteratee shorthands.
  12715. *
  12716. * @private
  12717. * @param {Array|Object} collection The collection to iterate over.
  12718. * @param {Function} predicate The function invoked per iteration.
  12719. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  12720. * else `false`
  12721. */
  12722. function baseEvery(collection, predicate) {
  12723. var result = true;
  12724. baseEach(collection, function(value, index, collection) {
  12725. result = !!predicate(value, index, collection);
  12726. return result;
  12727. });
  12728. return result;
  12729. }
  12730. /**
  12731. * The base implementation of methods like `_.max` and `_.min` which accepts a
  12732. * `comparator` to determine the extremum value.
  12733. *
  12734. * @private
  12735. * @param {Array} array The array to iterate over.
  12736. * @param {Function} iteratee The iteratee invoked per iteration.
  12737. * @param {Function} comparator The comparator used to compare values.
  12738. * @returns {*} Returns the extremum value.
  12739. */
  12740. function baseExtremum(array, iteratee, comparator) {
  12741. var index = -1,
  12742. length = array.length;
  12743. while (++index < length) {
  12744. var value = array[index],
  12745. current = iteratee(value);
  12746. if (current != null && (computed === undefined
  12747. ? (current === current && !isSymbol(current))
  12748. : comparator(current, computed)
  12749. )) {
  12750. var computed = current,
  12751. result = value;
  12752. }
  12753. }
  12754. return result;
  12755. }
  12756. /**
  12757. * The base implementation of `_.fill` without an iteratee call guard.
  12758. *
  12759. * @private
  12760. * @param {Array} array The array to fill.
  12761. * @param {*} value The value to fill `array` with.
  12762. * @param {number} [start=0] The start position.
  12763. * @param {number} [end=array.length] The end position.
  12764. * @returns {Array} Returns `array`.
  12765. */
  12766. function baseFill(array, value, start, end) {
  12767. var length = array.length;
  12768. start = toInteger(start);
  12769. if (start < 0) {
  12770. start = -start > length ? 0 : (length + start);
  12771. }
  12772. end = (end === undefined || end > length) ? length : toInteger(end);
  12773. if (end < 0) {
  12774. end += length;
  12775. }
  12776. end = start > end ? 0 : toLength(end);
  12777. while (start < end) {
  12778. array[start++] = value;
  12779. }
  12780. return array;
  12781. }
  12782. /**
  12783. * The base implementation of `_.filter` without support for iteratee shorthands.
  12784. *
  12785. * @private
  12786. * @param {Array|Object} collection The collection to iterate over.
  12787. * @param {Function} predicate The function invoked per iteration.
  12788. * @returns {Array} Returns the new filtered array.
  12789. */
  12790. function baseFilter(collection, predicate) {
  12791. var result = [];
  12792. baseEach(collection, function(value, index, collection) {
  12793. if (predicate(value, index, collection)) {
  12794. result.push(value);
  12795. }
  12796. });
  12797. return result;
  12798. }
  12799. /**
  12800. * The base implementation of `_.flatten` with support for restricting flattening.
  12801. *
  12802. * @private
  12803. * @param {Array} array The array to flatten.
  12804. * @param {number} depth The maximum recursion depth.
  12805. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  12806. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  12807. * @param {Array} [result=[]] The initial result value.
  12808. * @returns {Array} Returns the new flattened array.
  12809. */
  12810. function baseFlatten(array, depth, predicate, isStrict, result) {
  12811. var index = -1,
  12812. length = array.length;
  12813. predicate || (predicate = isFlattenable);
  12814. result || (result = []);
  12815. while (++index < length) {
  12816. var value = array[index];
  12817. if (depth > 0 && predicate(value)) {
  12818. if (depth > 1) {
  12819. // Recursively flatten arrays (susceptible to call stack limits).
  12820. baseFlatten(value, depth - 1, predicate, isStrict, result);
  12821. } else {
  12822. arrayPush(result, value);
  12823. }
  12824. } else if (!isStrict) {
  12825. result[result.length] = value;
  12826. }
  12827. }
  12828. return result;
  12829. }
  12830. /**
  12831. * The base implementation of `baseForOwn` which iterates over `object`
  12832. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  12833. * Iteratee functions may exit iteration early by explicitly returning `false`.
  12834. *
  12835. * @private
  12836. * @param {Object} object The object to iterate over.
  12837. * @param {Function} iteratee The function invoked per iteration.
  12838. * @param {Function} keysFunc The function to get the keys of `object`.
  12839. * @returns {Object} Returns `object`.
  12840. */
  12841. var baseFor = createBaseFor();
  12842. /**
  12843. * This function is like `baseFor` except that it iterates over properties
  12844. * in the opposite order.
  12845. *
  12846. * @private
  12847. * @param {Object} object The object to iterate over.
  12848. * @param {Function} iteratee The function invoked per iteration.
  12849. * @param {Function} keysFunc The function to get the keys of `object`.
  12850. * @returns {Object} Returns `object`.
  12851. */
  12852. var baseForRight = createBaseFor(true);
  12853. /**
  12854. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  12855. *
  12856. * @private
  12857. * @param {Object} object The object to iterate over.
  12858. * @param {Function} iteratee The function invoked per iteration.
  12859. * @returns {Object} Returns `object`.
  12860. */
  12861. function baseForOwn(object, iteratee) {
  12862. return object && baseFor(object, iteratee, keys);
  12863. }
  12864. /**
  12865. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  12866. *
  12867. * @private
  12868. * @param {Object} object The object to iterate over.
  12869. * @param {Function} iteratee The function invoked per iteration.
  12870. * @returns {Object} Returns `object`.
  12871. */
  12872. function baseForOwnRight(object, iteratee) {
  12873. return object && baseForRight(object, iteratee, keys);
  12874. }
  12875. /**
  12876. * The base implementation of `_.functions` which creates an array of
  12877. * `object` function property names filtered from `props`.
  12878. *
  12879. * @private
  12880. * @param {Object} object The object to inspect.
  12881. * @param {Array} props The property names to filter.
  12882. * @returns {Array} Returns the function names.
  12883. */
  12884. function baseFunctions(object, props) {
  12885. return arrayFilter(props, function(key) {
  12886. return isFunction(object[key]);
  12887. });
  12888. }
  12889. /**
  12890. * The base implementation of `_.get` without support for default values.
  12891. *
  12892. * @private
  12893. * @param {Object} object The object to query.
  12894. * @param {Array|string} path The path of the property to get.
  12895. * @returns {*} Returns the resolved value.
  12896. */
  12897. function baseGet(object, path) {
  12898. path = castPath(path, object);
  12899. var index = 0,
  12900. length = path.length;
  12901. while (object != null && index < length) {
  12902. object = object[toKey(path[index++])];
  12903. }
  12904. return (index && index == length) ? object : undefined;
  12905. }
  12906. /**
  12907. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  12908. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  12909. * symbols of `object`.
  12910. *
  12911. * @private
  12912. * @param {Object} object The object to query.
  12913. * @param {Function} keysFunc The function to get the keys of `object`.
  12914. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  12915. * @returns {Array} Returns the array of property names and symbols.
  12916. */
  12917. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  12918. var result = keysFunc(object);
  12919. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  12920. }
  12921. /**
  12922. * The base implementation of `getTag` without fallbacks for buggy environments.
  12923. *
  12924. * @private
  12925. * @param {*} value The value to query.
  12926. * @returns {string} Returns the `toStringTag`.
  12927. */
  12928. function baseGetTag(value) {
  12929. if (value == null) {
  12930. return value === undefined ? undefinedTag : nullTag;
  12931. }
  12932. return (symToStringTag && symToStringTag in Object(value))
  12933. ? getRawTag(value)
  12934. : objectToString(value);
  12935. }
  12936. /**
  12937. * The base implementation of `_.gt` which doesn't coerce arguments.
  12938. *
  12939. * @private
  12940. * @param {*} value The value to compare.
  12941. * @param {*} other The other value to compare.
  12942. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  12943. * else `false`.
  12944. */
  12945. function baseGt(value, other) {
  12946. return value > other;
  12947. }
  12948. /**
  12949. * The base implementation of `_.has` without support for deep paths.
  12950. *
  12951. * @private
  12952. * @param {Object} [object] The object to query.
  12953. * @param {Array|string} key The key to check.
  12954. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  12955. */
  12956. function baseHas(object, key) {
  12957. return object != null && hasOwnProperty.call(object, key);
  12958. }
  12959. /**
  12960. * The base implementation of `_.hasIn` without support for deep paths.
  12961. *
  12962. * @private
  12963. * @param {Object} [object] The object to query.
  12964. * @param {Array|string} key The key to check.
  12965. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  12966. */
  12967. function baseHasIn(object, key) {
  12968. return object != null && key in Object(object);
  12969. }
  12970. /**
  12971. * The base implementation of `_.inRange` which doesn't coerce arguments.
  12972. *
  12973. * @private
  12974. * @param {number} number The number to check.
  12975. * @param {number} start The start of the range.
  12976. * @param {number} end The end of the range.
  12977. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  12978. */
  12979. function baseInRange(number, start, end) {
  12980. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  12981. }
  12982. /**
  12983. * The base implementation of methods like `_.intersection`, without support
  12984. * for iteratee shorthands, that accepts an array of arrays to inspect.
  12985. *
  12986. * @private
  12987. * @param {Array} arrays The arrays to inspect.
  12988. * @param {Function} [iteratee] The iteratee invoked per element.
  12989. * @param {Function} [comparator] The comparator invoked per element.
  12990. * @returns {Array} Returns the new array of shared values.
  12991. */
  12992. function baseIntersection(arrays, iteratee, comparator) {
  12993. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  12994. length = arrays[0].length,
  12995. othLength = arrays.length,
  12996. othIndex = othLength,
  12997. caches = Array(othLength),
  12998. maxLength = Infinity,
  12999. result = [];
  13000. while (othIndex--) {
  13001. var array = arrays[othIndex];
  13002. if (othIndex && iteratee) {
  13003. array = arrayMap(array, baseUnary(iteratee));
  13004. }
  13005. maxLength = nativeMin(array.length, maxLength);
  13006. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  13007. ? new SetCache(othIndex && array)
  13008. : undefined;
  13009. }
  13010. array = arrays[0];
  13011. var index = -1,
  13012. seen = caches[0];
  13013. outer:
  13014. while (++index < length && result.length < maxLength) {
  13015. var value = array[index],
  13016. computed = iteratee ? iteratee(value) : value;
  13017. value = (comparator || value !== 0) ? value : 0;
  13018. if (!(seen
  13019. ? cacheHas(seen, computed)
  13020. : includes(result, computed, comparator)
  13021. )) {
  13022. othIndex = othLength;
  13023. while (--othIndex) {
  13024. var cache = caches[othIndex];
  13025. if (!(cache
  13026. ? cacheHas(cache, computed)
  13027. : includes(arrays[othIndex], computed, comparator))
  13028. ) {
  13029. continue outer;
  13030. }
  13031. }
  13032. if (seen) {
  13033. seen.push(computed);
  13034. }
  13035. result.push(value);
  13036. }
  13037. }
  13038. return result;
  13039. }
  13040. /**
  13041. * The base implementation of `_.invert` and `_.invertBy` which inverts
  13042. * `object` with values transformed by `iteratee` and set by `setter`.
  13043. *
  13044. * @private
  13045. * @param {Object} object The object to iterate over.
  13046. * @param {Function} setter The function to set `accumulator` values.
  13047. * @param {Function} iteratee The iteratee to transform values.
  13048. * @param {Object} accumulator The initial inverted object.
  13049. * @returns {Function} Returns `accumulator`.
  13050. */
  13051. function baseInverter(object, setter, iteratee, accumulator) {
  13052. baseForOwn(object, function(value, key, object) {
  13053. setter(accumulator, iteratee(value), key, object);
  13054. });
  13055. return accumulator;
  13056. }
  13057. /**
  13058. * The base implementation of `_.invoke` without support for individual
  13059. * method arguments.
  13060. *
  13061. * @private
  13062. * @param {Object} object The object to query.
  13063. * @param {Array|string} path The path of the method to invoke.
  13064. * @param {Array} args The arguments to invoke the method with.
  13065. * @returns {*} Returns the result of the invoked method.
  13066. */
  13067. function baseInvoke(object, path, args) {
  13068. path = castPath(path, object);
  13069. object = parent(object, path);
  13070. var func = object == null ? object : object[toKey(last(path))];
  13071. return func == null ? undefined : apply(func, object, args);
  13072. }
  13073. /**
  13074. * The base implementation of `_.isArguments`.
  13075. *
  13076. * @private
  13077. * @param {*} value The value to check.
  13078. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  13079. */
  13080. function baseIsArguments(value) {
  13081. return isObjectLike(value) && baseGetTag(value) == argsTag;
  13082. }
  13083. /**
  13084. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  13085. *
  13086. * @private
  13087. * @param {*} value The value to check.
  13088. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  13089. */
  13090. function baseIsArrayBuffer(value) {
  13091. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  13092. }
  13093. /**
  13094. * The base implementation of `_.isDate` without Node.js optimizations.
  13095. *
  13096. * @private
  13097. * @param {*} value The value to check.
  13098. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  13099. */
  13100. function baseIsDate(value) {
  13101. return isObjectLike(value) && baseGetTag(value) == dateTag;
  13102. }
  13103. /**
  13104. * The base implementation of `_.isEqual` which supports partial comparisons
  13105. * and tracks traversed objects.
  13106. *
  13107. * @private
  13108. * @param {*} value The value to compare.
  13109. * @param {*} other The other value to compare.
  13110. * @param {boolean} bitmask The bitmask flags.
  13111. * 1 - Unordered comparison
  13112. * 2 - Partial comparison
  13113. * @param {Function} [customizer] The function to customize comparisons.
  13114. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  13115. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  13116. */
  13117. function baseIsEqual(value, other, bitmask, customizer, stack) {
  13118. if (value === other) {
  13119. return true;
  13120. }
  13121. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  13122. return value !== value && other !== other;
  13123. }
  13124. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  13125. }
  13126. /**
  13127. * A specialized version of `baseIsEqual` for arrays and objects which performs
  13128. * deep comparisons and tracks traversed objects enabling objects with circular
  13129. * references to be compared.
  13130. *
  13131. * @private
  13132. * @param {Object} object The object to compare.
  13133. * @param {Object} other The other object to compare.
  13134. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  13135. * @param {Function} customizer The function to customize comparisons.
  13136. * @param {Function} equalFunc The function to determine equivalents of values.
  13137. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  13138. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  13139. */
  13140. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  13141. var objIsArr = isArray(object),
  13142. othIsArr = isArray(other),
  13143. objTag = objIsArr ? arrayTag : getTag(object),
  13144. othTag = othIsArr ? arrayTag : getTag(other);
  13145. objTag = objTag == argsTag ? objectTag : objTag;
  13146. othTag = othTag == argsTag ? objectTag : othTag;
  13147. var objIsObj = objTag == objectTag,
  13148. othIsObj = othTag == objectTag,
  13149. isSameTag = objTag == othTag;
  13150. if (isSameTag && isBuffer(object)) {
  13151. if (!isBuffer(other)) {
  13152. return false;
  13153. }
  13154. objIsArr = true;
  13155. objIsObj = false;
  13156. }
  13157. if (isSameTag && !objIsObj) {
  13158. stack || (stack = new Stack);
  13159. return (objIsArr || isTypedArray(object))
  13160. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  13161. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  13162. }
  13163. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  13164. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  13165. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  13166. if (objIsWrapped || othIsWrapped) {
  13167. var objUnwrapped = objIsWrapped ? object.value() : object,
  13168. othUnwrapped = othIsWrapped ? other.value() : other;
  13169. stack || (stack = new Stack);
  13170. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  13171. }
  13172. }
  13173. if (!isSameTag) {
  13174. return false;
  13175. }
  13176. stack || (stack = new Stack);
  13177. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  13178. }
  13179. /**
  13180. * The base implementation of `_.isMap` without Node.js optimizations.
  13181. *
  13182. * @private
  13183. * @param {*} value The value to check.
  13184. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  13185. */
  13186. function baseIsMap(value) {
  13187. return isObjectLike(value) && getTag(value) == mapTag;
  13188. }
  13189. /**
  13190. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  13191. *
  13192. * @private
  13193. * @param {Object} object The object to inspect.
  13194. * @param {Object} source The object of property values to match.
  13195. * @param {Array} matchData The property names, values, and compare flags to match.
  13196. * @param {Function} [customizer] The function to customize comparisons.
  13197. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  13198. */
  13199. function baseIsMatch(object, source, matchData, customizer) {
  13200. var index = matchData.length,
  13201. length = index,
  13202. noCustomizer = !customizer;
  13203. if (object == null) {
  13204. return !length;
  13205. }
  13206. object = Object(object);
  13207. while (index--) {
  13208. var data = matchData[index];
  13209. if ((noCustomizer && data[2])
  13210. ? data[1] !== object[data[0]]
  13211. : !(data[0] in object)
  13212. ) {
  13213. return false;
  13214. }
  13215. }
  13216. while (++index < length) {
  13217. data = matchData[index];
  13218. var key = data[0],
  13219. objValue = object[key],
  13220. srcValue = data[1];
  13221. if (noCustomizer && data[2]) {
  13222. if (objValue === undefined && !(key in object)) {
  13223. return false;
  13224. }
  13225. } else {
  13226. var stack = new Stack;
  13227. if (customizer) {
  13228. var result = customizer(objValue, srcValue, key, object, source, stack);
  13229. }
  13230. if (!(result === undefined
  13231. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  13232. : result
  13233. )) {
  13234. return false;
  13235. }
  13236. }
  13237. }
  13238. return true;
  13239. }
  13240. /**
  13241. * The base implementation of `_.isNative` without bad shim checks.
  13242. *
  13243. * @private
  13244. * @param {*} value The value to check.
  13245. * @returns {boolean} Returns `true` if `value` is a native function,
  13246. * else `false`.
  13247. */
  13248. function baseIsNative(value) {
  13249. if (!isObject(value) || isMasked(value)) {
  13250. return false;
  13251. }
  13252. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  13253. return pattern.test(toSource(value));
  13254. }
  13255. /**
  13256. * The base implementation of `_.isRegExp` without Node.js optimizations.
  13257. *
  13258. * @private
  13259. * @param {*} value The value to check.
  13260. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  13261. */
  13262. function baseIsRegExp(value) {
  13263. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  13264. }
  13265. /**
  13266. * The base implementation of `_.isSet` without Node.js optimizations.
  13267. *
  13268. * @private
  13269. * @param {*} value The value to check.
  13270. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  13271. */
  13272. function baseIsSet(value) {
  13273. return isObjectLike(value) && getTag(value) == setTag;
  13274. }
  13275. /**
  13276. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  13277. *
  13278. * @private
  13279. * @param {*} value The value to check.
  13280. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  13281. */
  13282. function baseIsTypedArray(value) {
  13283. return isObjectLike(value) &&
  13284. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  13285. }
  13286. /**
  13287. * The base implementation of `_.iteratee`.
  13288. *
  13289. * @private
  13290. * @param {*} [value=_.identity] The value to convert to an iteratee.
  13291. * @returns {Function} Returns the iteratee.
  13292. */
  13293. function baseIteratee(value) {
  13294. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  13295. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  13296. if (typeof value == 'function') {
  13297. return value;
  13298. }
  13299. if (value == null) {
  13300. return identity;
  13301. }
  13302. if (typeof value == 'object') {
  13303. return isArray(value)
  13304. ? baseMatchesProperty(value[0], value[1])
  13305. : baseMatches(value);
  13306. }
  13307. return property(value);
  13308. }
  13309. /**
  13310. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  13311. *
  13312. * @private
  13313. * @param {Object} object The object to query.
  13314. * @returns {Array} Returns the array of property names.
  13315. */
  13316. function baseKeys(object) {
  13317. if (!isPrototype(object)) {
  13318. return nativeKeys(object);
  13319. }
  13320. var result = [];
  13321. for (var key in Object(object)) {
  13322. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  13323. result.push(key);
  13324. }
  13325. }
  13326. return result;
  13327. }
  13328. /**
  13329. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  13330. *
  13331. * @private
  13332. * @param {Object} object The object to query.
  13333. * @returns {Array} Returns the array of property names.
  13334. */
  13335. function baseKeysIn(object) {
  13336. if (!isObject(object)) {
  13337. return nativeKeysIn(object);
  13338. }
  13339. var isProto = isPrototype(object),
  13340. result = [];
  13341. for (var key in object) {
  13342. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  13343. result.push(key);
  13344. }
  13345. }
  13346. return result;
  13347. }
  13348. /**
  13349. * The base implementation of `_.lt` which doesn't coerce arguments.
  13350. *
  13351. * @private
  13352. * @param {*} value The value to compare.
  13353. * @param {*} other The other value to compare.
  13354. * @returns {boolean} Returns `true` if `value` is less than `other`,
  13355. * else `false`.
  13356. */
  13357. function baseLt(value, other) {
  13358. return value < other;
  13359. }
  13360. /**
  13361. * The base implementation of `_.map` without support for iteratee shorthands.
  13362. *
  13363. * @private
  13364. * @param {Array|Object} collection The collection to iterate over.
  13365. * @param {Function} iteratee The function invoked per iteration.
  13366. * @returns {Array} Returns the new mapped array.
  13367. */
  13368. function baseMap(collection, iteratee) {
  13369. var index = -1,
  13370. result = isArrayLike(collection) ? Array(collection.length) : [];
  13371. baseEach(collection, function(value, key, collection) {
  13372. result[++index] = iteratee(value, key, collection);
  13373. });
  13374. return result;
  13375. }
  13376. /**
  13377. * The base implementation of `_.matches` which doesn't clone `source`.
  13378. *
  13379. * @private
  13380. * @param {Object} source The object of property values to match.
  13381. * @returns {Function} Returns the new spec function.
  13382. */
  13383. function baseMatches(source) {
  13384. var matchData = getMatchData(source);
  13385. if (matchData.length == 1 && matchData[0][2]) {
  13386. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  13387. }
  13388. return function(object) {
  13389. return object === source || baseIsMatch(object, source, matchData);
  13390. };
  13391. }
  13392. /**
  13393. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  13394. *
  13395. * @private
  13396. * @param {string} path The path of the property to get.
  13397. * @param {*} srcValue The value to match.
  13398. * @returns {Function} Returns the new spec function.
  13399. */
  13400. function baseMatchesProperty(path, srcValue) {
  13401. if (isKey(path) && isStrictComparable(srcValue)) {
  13402. return matchesStrictComparable(toKey(path), srcValue);
  13403. }
  13404. return function(object) {
  13405. var objValue = get(object, path);
  13406. return (objValue === undefined && objValue === srcValue)
  13407. ? hasIn(object, path)
  13408. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  13409. };
  13410. }
  13411. /**
  13412. * The base implementation of `_.merge` without support for multiple sources.
  13413. *
  13414. * @private
  13415. * @param {Object} object The destination object.
  13416. * @param {Object} source The source object.
  13417. * @param {number} srcIndex The index of `source`.
  13418. * @param {Function} [customizer] The function to customize merged values.
  13419. * @param {Object} [stack] Tracks traversed source values and their merged
  13420. * counterparts.
  13421. */
  13422. function baseMerge(object, source, srcIndex, customizer, stack) {
  13423. if (object === source) {
  13424. return;
  13425. }
  13426. baseFor(source, function(srcValue, key) {
  13427. stack || (stack = new Stack);
  13428. if (isObject(srcValue)) {
  13429. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  13430. }
  13431. else {
  13432. var newValue = customizer
  13433. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  13434. : undefined;
  13435. if (newValue === undefined) {
  13436. newValue = srcValue;
  13437. }
  13438. assignMergeValue(object, key, newValue);
  13439. }
  13440. }, keysIn);
  13441. }
  13442. /**
  13443. * A specialized version of `baseMerge` for arrays and objects which performs
  13444. * deep merges and tracks traversed objects enabling objects with circular
  13445. * references to be merged.
  13446. *
  13447. * @private
  13448. * @param {Object} object The destination object.
  13449. * @param {Object} source The source object.
  13450. * @param {string} key The key of the value to merge.
  13451. * @param {number} srcIndex The index of `source`.
  13452. * @param {Function} mergeFunc The function to merge values.
  13453. * @param {Function} [customizer] The function to customize assigned values.
  13454. * @param {Object} [stack] Tracks traversed source values and their merged
  13455. * counterparts.
  13456. */
  13457. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  13458. var objValue = safeGet(object, key),
  13459. srcValue = safeGet(source, key),
  13460. stacked = stack.get(srcValue);
  13461. if (stacked) {
  13462. assignMergeValue(object, key, stacked);
  13463. return;
  13464. }
  13465. var newValue = customizer
  13466. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  13467. : undefined;
  13468. var isCommon = newValue === undefined;
  13469. if (isCommon) {
  13470. var isArr = isArray(srcValue),
  13471. isBuff = !isArr && isBuffer(srcValue),
  13472. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  13473. newValue = srcValue;
  13474. if (isArr || isBuff || isTyped) {
  13475. if (isArray(objValue)) {
  13476. newValue = objValue;
  13477. }
  13478. else if (isArrayLikeObject(objValue)) {
  13479. newValue = copyArray(objValue);
  13480. }
  13481. else if (isBuff) {
  13482. isCommon = false;
  13483. newValue = cloneBuffer(srcValue, true);
  13484. }
  13485. else if (isTyped) {
  13486. isCommon = false;
  13487. newValue = cloneTypedArray(srcValue, true);
  13488. }
  13489. else {
  13490. newValue = [];
  13491. }
  13492. }
  13493. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  13494. newValue = objValue;
  13495. if (isArguments(objValue)) {
  13496. newValue = toPlainObject(objValue);
  13497. }
  13498. else if (!isObject(objValue) || isFunction(objValue)) {
  13499. newValue = initCloneObject(srcValue);
  13500. }
  13501. }
  13502. else {
  13503. isCommon = false;
  13504. }
  13505. }
  13506. if (isCommon) {
  13507. // Recursively merge objects and arrays (susceptible to call stack limits).
  13508. stack.set(srcValue, newValue);
  13509. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  13510. stack['delete'](srcValue);
  13511. }
  13512. assignMergeValue(object, key, newValue);
  13513. }
  13514. /**
  13515. * The base implementation of `_.nth` which doesn't coerce arguments.
  13516. *
  13517. * @private
  13518. * @param {Array} array The array to query.
  13519. * @param {number} n The index of the element to return.
  13520. * @returns {*} Returns the nth element of `array`.
  13521. */
  13522. function baseNth(array, n) {
  13523. var length = array.length;
  13524. if (!length) {
  13525. return;
  13526. }
  13527. n += n < 0 ? length : 0;
  13528. return isIndex(n, length) ? array[n] : undefined;
  13529. }
  13530. /**
  13531. * The base implementation of `_.orderBy` without param guards.
  13532. *
  13533. * @private
  13534. * @param {Array|Object} collection The collection to iterate over.
  13535. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  13536. * @param {string[]} orders The sort orders of `iteratees`.
  13537. * @returns {Array} Returns the new sorted array.
  13538. */
  13539. function baseOrderBy(collection, iteratees, orders) {
  13540. var index = -1;
  13541. iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
  13542. var result = baseMap(collection, function(value, key, collection) {
  13543. var criteria = arrayMap(iteratees, function(iteratee) {
  13544. return iteratee(value);
  13545. });
  13546. return { 'criteria': criteria, 'index': ++index, 'value': value };
  13547. });
  13548. return baseSortBy(result, function(object, other) {
  13549. return compareMultiple(object, other, orders);
  13550. });
  13551. }
  13552. /**
  13553. * The base implementation of `_.pick` without support for individual
  13554. * property identifiers.
  13555. *
  13556. * @private
  13557. * @param {Object} object The source object.
  13558. * @param {string[]} paths The property paths to pick.
  13559. * @returns {Object} Returns the new object.
  13560. */
  13561. function basePick(object, paths) {
  13562. return basePickBy(object, paths, function(value, path) {
  13563. return hasIn(object, path);
  13564. });
  13565. }
  13566. /**
  13567. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  13568. *
  13569. * @private
  13570. * @param {Object} object The source object.
  13571. * @param {string[]} paths The property paths to pick.
  13572. * @param {Function} predicate The function invoked per property.
  13573. * @returns {Object} Returns the new object.
  13574. */
  13575. function basePickBy(object, paths, predicate) {
  13576. var index = -1,
  13577. length = paths.length,
  13578. result = {};
  13579. while (++index < length) {
  13580. var path = paths[index],
  13581. value = baseGet(object, path);
  13582. if (predicate(value, path)) {
  13583. baseSet(result, castPath(path, object), value);
  13584. }
  13585. }
  13586. return result;
  13587. }
  13588. /**
  13589. * A specialized version of `baseProperty` which supports deep paths.
  13590. *
  13591. * @private
  13592. * @param {Array|string} path The path of the property to get.
  13593. * @returns {Function} Returns the new accessor function.
  13594. */
  13595. function basePropertyDeep(path) {
  13596. return function(object) {
  13597. return baseGet(object, path);
  13598. };
  13599. }
  13600. /**
  13601. * The base implementation of `_.pullAllBy` without support for iteratee
  13602. * shorthands.
  13603. *
  13604. * @private
  13605. * @param {Array} array The array to modify.
  13606. * @param {Array} values The values to remove.
  13607. * @param {Function} [iteratee] The iteratee invoked per element.
  13608. * @param {Function} [comparator] The comparator invoked per element.
  13609. * @returns {Array} Returns `array`.
  13610. */
  13611. function basePullAll(array, values, iteratee, comparator) {
  13612. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  13613. index = -1,
  13614. length = values.length,
  13615. seen = array;
  13616. if (array === values) {
  13617. values = copyArray(values);
  13618. }
  13619. if (iteratee) {
  13620. seen = arrayMap(array, baseUnary(iteratee));
  13621. }
  13622. while (++index < length) {
  13623. var fromIndex = 0,
  13624. value = values[index],
  13625. computed = iteratee ? iteratee(value) : value;
  13626. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  13627. if (seen !== array) {
  13628. splice.call(seen, fromIndex, 1);
  13629. }
  13630. splice.call(array, fromIndex, 1);
  13631. }
  13632. }
  13633. return array;
  13634. }
  13635. /**
  13636. * The base implementation of `_.pullAt` without support for individual
  13637. * indexes or capturing the removed elements.
  13638. *
  13639. * @private
  13640. * @param {Array} array The array to modify.
  13641. * @param {number[]} indexes The indexes of elements to remove.
  13642. * @returns {Array} Returns `array`.
  13643. */
  13644. function basePullAt(array, indexes) {
  13645. var length = array ? indexes.length : 0,
  13646. lastIndex = length - 1;
  13647. while (length--) {
  13648. var index = indexes[length];
  13649. if (length == lastIndex || index !== previous) {
  13650. var previous = index;
  13651. if (isIndex(index)) {
  13652. splice.call(array, index, 1);
  13653. } else {
  13654. baseUnset(array, index);
  13655. }
  13656. }
  13657. }
  13658. return array;
  13659. }
  13660. /**
  13661. * The base implementation of `_.random` without support for returning
  13662. * floating-point numbers.
  13663. *
  13664. * @private
  13665. * @param {number} lower The lower bound.
  13666. * @param {number} upper The upper bound.
  13667. * @returns {number} Returns the random number.
  13668. */
  13669. function baseRandom(lower, upper) {
  13670. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  13671. }
  13672. /**
  13673. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  13674. * coerce arguments.
  13675. *
  13676. * @private
  13677. * @param {number} start The start of the range.
  13678. * @param {number} end The end of the range.
  13679. * @param {number} step The value to increment or decrement by.
  13680. * @param {boolean} [fromRight] Specify iterating from right to left.
  13681. * @returns {Array} Returns the range of numbers.
  13682. */
  13683. function baseRange(start, end, step, fromRight) {
  13684. var index = -1,
  13685. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  13686. result = Array(length);
  13687. while (length--) {
  13688. result[fromRight ? length : ++index] = start;
  13689. start += step;
  13690. }
  13691. return result;
  13692. }
  13693. /**
  13694. * The base implementation of `_.repeat` which doesn't coerce arguments.
  13695. *
  13696. * @private
  13697. * @param {string} string The string to repeat.
  13698. * @param {number} n The number of times to repeat the string.
  13699. * @returns {string} Returns the repeated string.
  13700. */
  13701. function baseRepeat(string, n) {
  13702. var result = '';
  13703. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  13704. return result;
  13705. }
  13706. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  13707. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  13708. do {
  13709. if (n % 2) {
  13710. result += string;
  13711. }
  13712. n = nativeFloor(n / 2);
  13713. if (n) {
  13714. string += string;
  13715. }
  13716. } while (n);
  13717. return result;
  13718. }
  13719. /**
  13720. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  13721. *
  13722. * @private
  13723. * @param {Function} func The function to apply a rest parameter to.
  13724. * @param {number} [start=func.length-1] The start position of the rest parameter.
  13725. * @returns {Function} Returns the new function.
  13726. */
  13727. function baseRest(func, start) {
  13728. return setToString(overRest(func, start, identity), func + '');
  13729. }
  13730. /**
  13731. * The base implementation of `_.sample`.
  13732. *
  13733. * @private
  13734. * @param {Array|Object} collection The collection to sample.
  13735. * @returns {*} Returns the random element.
  13736. */
  13737. function baseSample(collection) {
  13738. return arraySample(values(collection));
  13739. }
  13740. /**
  13741. * The base implementation of `_.sampleSize` without param guards.
  13742. *
  13743. * @private
  13744. * @param {Array|Object} collection The collection to sample.
  13745. * @param {number} n The number of elements to sample.
  13746. * @returns {Array} Returns the random elements.
  13747. */
  13748. function baseSampleSize(collection, n) {
  13749. var array = values(collection);
  13750. return shuffleSelf(array, baseClamp(n, 0, array.length));
  13751. }
  13752. /**
  13753. * The base implementation of `_.set`.
  13754. *
  13755. * @private
  13756. * @param {Object} object The object to modify.
  13757. * @param {Array|string} path The path of the property to set.
  13758. * @param {*} value The value to set.
  13759. * @param {Function} [customizer] The function to customize path creation.
  13760. * @returns {Object} Returns `object`.
  13761. */
  13762. function baseSet(object, path, value, customizer) {
  13763. if (!isObject(object)) {
  13764. return object;
  13765. }
  13766. path = castPath(path, object);
  13767. var index = -1,
  13768. length = path.length,
  13769. lastIndex = length - 1,
  13770. nested = object;
  13771. while (nested != null && ++index < length) {
  13772. var key = toKey(path[index]),
  13773. newValue = value;
  13774. if (index != lastIndex) {
  13775. var objValue = nested[key];
  13776. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  13777. if (newValue === undefined) {
  13778. newValue = isObject(objValue)
  13779. ? objValue
  13780. : (isIndex(path[index + 1]) ? [] : {});
  13781. }
  13782. }
  13783. assignValue(nested, key, newValue);
  13784. nested = nested[key];
  13785. }
  13786. return object;
  13787. }
  13788. /**
  13789. * The base implementation of `setData` without support for hot loop shorting.
  13790. *
  13791. * @private
  13792. * @param {Function} func The function to associate metadata with.
  13793. * @param {*} data The metadata.
  13794. * @returns {Function} Returns `func`.
  13795. */
  13796. var baseSetData = !metaMap ? identity : function(func, data) {
  13797. metaMap.set(func, data);
  13798. return func;
  13799. };
  13800. /**
  13801. * The base implementation of `setToString` without support for hot loop shorting.
  13802. *
  13803. * @private
  13804. * @param {Function} func The function to modify.
  13805. * @param {Function} string The `toString` result.
  13806. * @returns {Function} Returns `func`.
  13807. */
  13808. var baseSetToString = !defineProperty ? identity : function(func, string) {
  13809. return defineProperty(func, 'toString', {
  13810. 'configurable': true,
  13811. 'enumerable': false,
  13812. 'value': constant(string),
  13813. 'writable': true
  13814. });
  13815. };
  13816. /**
  13817. * The base implementation of `_.shuffle`.
  13818. *
  13819. * @private
  13820. * @param {Array|Object} collection The collection to shuffle.
  13821. * @returns {Array} Returns the new shuffled array.
  13822. */
  13823. function baseShuffle(collection) {
  13824. return shuffleSelf(values(collection));
  13825. }
  13826. /**
  13827. * The base implementation of `_.slice` without an iteratee call guard.
  13828. *
  13829. * @private
  13830. * @param {Array} array The array to slice.
  13831. * @param {number} [start=0] The start position.
  13832. * @param {number} [end=array.length] The end position.
  13833. * @returns {Array} Returns the slice of `array`.
  13834. */
  13835. function baseSlice(array, start, end) {
  13836. var index = -1,
  13837. length = array.length;
  13838. if (start < 0) {
  13839. start = -start > length ? 0 : (length + start);
  13840. }
  13841. end = end > length ? length : end;
  13842. if (end < 0) {
  13843. end += length;
  13844. }
  13845. length = start > end ? 0 : ((end - start) >>> 0);
  13846. start >>>= 0;
  13847. var result = Array(length);
  13848. while (++index < length) {
  13849. result[index] = array[index + start];
  13850. }
  13851. return result;
  13852. }
  13853. /**
  13854. * The base implementation of `_.some` without support for iteratee shorthands.
  13855. *
  13856. * @private
  13857. * @param {Array|Object} collection The collection to iterate over.
  13858. * @param {Function} predicate The function invoked per iteration.
  13859. * @returns {boolean} Returns `true` if any element passes the predicate check,
  13860. * else `false`.
  13861. */
  13862. function baseSome(collection, predicate) {
  13863. var result;
  13864. baseEach(collection, function(value, index, collection) {
  13865. result = predicate(value, index, collection);
  13866. return !result;
  13867. });
  13868. return !!result;
  13869. }
  13870. /**
  13871. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  13872. * performs a binary search of `array` to determine the index at which `value`
  13873. * should be inserted into `array` in order to maintain its sort order.
  13874. *
  13875. * @private
  13876. * @param {Array} array The sorted array to inspect.
  13877. * @param {*} value The value to evaluate.
  13878. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  13879. * @returns {number} Returns the index at which `value` should be inserted
  13880. * into `array`.
  13881. */
  13882. function baseSortedIndex(array, value, retHighest) {
  13883. var low = 0,
  13884. high = array == null ? low : array.length;
  13885. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  13886. while (low < high) {
  13887. var mid = (low + high) >>> 1,
  13888. computed = array[mid];
  13889. if (computed !== null && !isSymbol(computed) &&
  13890. (retHighest ? (computed <= value) : (computed < value))) {
  13891. low = mid + 1;
  13892. } else {
  13893. high = mid;
  13894. }
  13895. }
  13896. return high;
  13897. }
  13898. return baseSortedIndexBy(array, value, identity, retHighest);
  13899. }
  13900. /**
  13901. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  13902. * which invokes `iteratee` for `value` and each element of `array` to compute
  13903. * their sort ranking. The iteratee is invoked with one argument; (value).
  13904. *
  13905. * @private
  13906. * @param {Array} array The sorted array to inspect.
  13907. * @param {*} value The value to evaluate.
  13908. * @param {Function} iteratee The iteratee invoked per element.
  13909. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  13910. * @returns {number} Returns the index at which `value` should be inserted
  13911. * into `array`.
  13912. */
  13913. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  13914. value = iteratee(value);
  13915. var low = 0,
  13916. high = array == null ? 0 : array.length,
  13917. valIsNaN = value !== value,
  13918. valIsNull = value === null,
  13919. valIsSymbol = isSymbol(value),
  13920. valIsUndefined = value === undefined;
  13921. while (low < high) {
  13922. var mid = nativeFloor((low + high) / 2),
  13923. computed = iteratee(array[mid]),
  13924. othIsDefined = computed !== undefined,
  13925. othIsNull = computed === null,
  13926. othIsReflexive = computed === computed,
  13927. othIsSymbol = isSymbol(computed);
  13928. if (valIsNaN) {
  13929. var setLow = retHighest || othIsReflexive;
  13930. } else if (valIsUndefined) {
  13931. setLow = othIsReflexive && (retHighest || othIsDefined);
  13932. } else if (valIsNull) {
  13933. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  13934. } else if (valIsSymbol) {
  13935. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  13936. } else if (othIsNull || othIsSymbol) {
  13937. setLow = false;
  13938. } else {
  13939. setLow = retHighest ? (computed <= value) : (computed < value);
  13940. }
  13941. if (setLow) {
  13942. low = mid + 1;
  13943. } else {
  13944. high = mid;
  13945. }
  13946. }
  13947. return nativeMin(high, MAX_ARRAY_INDEX);
  13948. }
  13949. /**
  13950. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  13951. * support for iteratee shorthands.
  13952. *
  13953. * @private
  13954. * @param {Array} array The array to inspect.
  13955. * @param {Function} [iteratee] The iteratee invoked per element.
  13956. * @returns {Array} Returns the new duplicate free array.
  13957. */
  13958. function baseSortedUniq(array, iteratee) {
  13959. var index = -1,
  13960. length = array.length,
  13961. resIndex = 0,
  13962. result = [];
  13963. while (++index < length) {
  13964. var value = array[index],
  13965. computed = iteratee ? iteratee(value) : value;
  13966. if (!index || !eq(computed, seen)) {
  13967. var seen = computed;
  13968. result[resIndex++] = value === 0 ? 0 : value;
  13969. }
  13970. }
  13971. return result;
  13972. }
  13973. /**
  13974. * The base implementation of `_.toNumber` which doesn't ensure correct
  13975. * conversions of binary, hexadecimal, or octal string values.
  13976. *
  13977. * @private
  13978. * @param {*} value The value to process.
  13979. * @returns {number} Returns the number.
  13980. */
  13981. function baseToNumber(value) {
  13982. if (typeof value == 'number') {
  13983. return value;
  13984. }
  13985. if (isSymbol(value)) {
  13986. return NAN;
  13987. }
  13988. return +value;
  13989. }
  13990. /**
  13991. * The base implementation of `_.toString` which doesn't convert nullish
  13992. * values to empty strings.
  13993. *
  13994. * @private
  13995. * @param {*} value The value to process.
  13996. * @returns {string} Returns the string.
  13997. */
  13998. function baseToString(value) {
  13999. // Exit early for strings to avoid a performance hit in some environments.
  14000. if (typeof value == 'string') {
  14001. return value;
  14002. }
  14003. if (isArray(value)) {
  14004. // Recursively convert values (susceptible to call stack limits).
  14005. return arrayMap(value, baseToString) + '';
  14006. }
  14007. if (isSymbol(value)) {
  14008. return symbolToString ? symbolToString.call(value) : '';
  14009. }
  14010. var result = (value + '');
  14011. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  14012. }
  14013. /**
  14014. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  14015. *
  14016. * @private
  14017. * @param {Array} array The array to inspect.
  14018. * @param {Function} [iteratee] The iteratee invoked per element.
  14019. * @param {Function} [comparator] The comparator invoked per element.
  14020. * @returns {Array} Returns the new duplicate free array.
  14021. */
  14022. function baseUniq(array, iteratee, comparator) {
  14023. var index = -1,
  14024. includes = arrayIncludes,
  14025. length = array.length,
  14026. isCommon = true,
  14027. result = [],
  14028. seen = result;
  14029. if (comparator) {
  14030. isCommon = false;
  14031. includes = arrayIncludesWith;
  14032. }
  14033. else if (length >= LARGE_ARRAY_SIZE) {
  14034. var set = iteratee ? null : createSet(array);
  14035. if (set) {
  14036. return setToArray(set);
  14037. }
  14038. isCommon = false;
  14039. includes = cacheHas;
  14040. seen = new SetCache;
  14041. }
  14042. else {
  14043. seen = iteratee ? [] : result;
  14044. }
  14045. outer:
  14046. while (++index < length) {
  14047. var value = array[index],
  14048. computed = iteratee ? iteratee(value) : value;
  14049. value = (comparator || value !== 0) ? value : 0;
  14050. if (isCommon && computed === computed) {
  14051. var seenIndex = seen.length;
  14052. while (seenIndex--) {
  14053. if (seen[seenIndex] === computed) {
  14054. continue outer;
  14055. }
  14056. }
  14057. if (iteratee) {
  14058. seen.push(computed);
  14059. }
  14060. result.push(value);
  14061. }
  14062. else if (!includes(seen, computed, comparator)) {
  14063. if (seen !== result) {
  14064. seen.push(computed);
  14065. }
  14066. result.push(value);
  14067. }
  14068. }
  14069. return result;
  14070. }
  14071. /**
  14072. * The base implementation of `_.unset`.
  14073. *
  14074. * @private
  14075. * @param {Object} object The object to modify.
  14076. * @param {Array|string} path The property path to unset.
  14077. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  14078. */
  14079. function baseUnset(object, path) {
  14080. path = castPath(path, object);
  14081. object = parent(object, path);
  14082. return object == null || delete object[toKey(last(path))];
  14083. }
  14084. /**
  14085. * The base implementation of `_.update`.
  14086. *
  14087. * @private
  14088. * @param {Object} object The object to modify.
  14089. * @param {Array|string} path The path of the property to update.
  14090. * @param {Function} updater The function to produce the updated value.
  14091. * @param {Function} [customizer] The function to customize path creation.
  14092. * @returns {Object} Returns `object`.
  14093. */
  14094. function baseUpdate(object, path, updater, customizer) {
  14095. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  14096. }
  14097. /**
  14098. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  14099. * without support for iteratee shorthands.
  14100. *
  14101. * @private
  14102. * @param {Array} array The array to query.
  14103. * @param {Function} predicate The function invoked per iteration.
  14104. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  14105. * @param {boolean} [fromRight] Specify iterating from right to left.
  14106. * @returns {Array} Returns the slice of `array`.
  14107. */
  14108. function baseWhile(array, predicate, isDrop, fromRight) {
  14109. var length = array.length,
  14110. index = fromRight ? length : -1;
  14111. while ((fromRight ? index-- : ++index < length) &&
  14112. predicate(array[index], index, array)) {}
  14113. return isDrop
  14114. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  14115. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  14116. }
  14117. /**
  14118. * The base implementation of `wrapperValue` which returns the result of
  14119. * performing a sequence of actions on the unwrapped `value`, where each
  14120. * successive action is supplied the return value of the previous.
  14121. *
  14122. * @private
  14123. * @param {*} value The unwrapped value.
  14124. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  14125. * @returns {*} Returns the resolved value.
  14126. */
  14127. function baseWrapperValue(value, actions) {
  14128. var result = value;
  14129. if (result instanceof LazyWrapper) {
  14130. result = result.value();
  14131. }
  14132. return arrayReduce(actions, function(result, action) {
  14133. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  14134. }, result);
  14135. }
  14136. /**
  14137. * The base implementation of methods like `_.xor`, without support for
  14138. * iteratee shorthands, that accepts an array of arrays to inspect.
  14139. *
  14140. * @private
  14141. * @param {Array} arrays The arrays to inspect.
  14142. * @param {Function} [iteratee] The iteratee invoked per element.
  14143. * @param {Function} [comparator] The comparator invoked per element.
  14144. * @returns {Array} Returns the new array of values.
  14145. */
  14146. function baseXor(arrays, iteratee, comparator) {
  14147. var length = arrays.length;
  14148. if (length < 2) {
  14149. return length ? baseUniq(arrays[0]) : [];
  14150. }
  14151. var index = -1,
  14152. result = Array(length);
  14153. while (++index < length) {
  14154. var array = arrays[index],
  14155. othIndex = -1;
  14156. while (++othIndex < length) {
  14157. if (othIndex != index) {
  14158. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  14159. }
  14160. }
  14161. }
  14162. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  14163. }
  14164. /**
  14165. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  14166. *
  14167. * @private
  14168. * @param {Array} props The property identifiers.
  14169. * @param {Array} values The property values.
  14170. * @param {Function} assignFunc The function to assign values.
  14171. * @returns {Object} Returns the new object.
  14172. */
  14173. function baseZipObject(props, values, assignFunc) {
  14174. var index = -1,
  14175. length = props.length,
  14176. valsLength = values.length,
  14177. result = {};
  14178. while (++index < length) {
  14179. var value = index < valsLength ? values[index] : undefined;
  14180. assignFunc(result, props[index], value);
  14181. }
  14182. return result;
  14183. }
  14184. /**
  14185. * Casts `value` to an empty array if it's not an array like object.
  14186. *
  14187. * @private
  14188. * @param {*} value The value to inspect.
  14189. * @returns {Array|Object} Returns the cast array-like object.
  14190. */
  14191. function castArrayLikeObject(value) {
  14192. return isArrayLikeObject(value) ? value : [];
  14193. }
  14194. /**
  14195. * Casts `value` to `identity` if it's not a function.
  14196. *
  14197. * @private
  14198. * @param {*} value The value to inspect.
  14199. * @returns {Function} Returns cast function.
  14200. */
  14201. function castFunction(value) {
  14202. return typeof value == 'function' ? value : identity;
  14203. }
  14204. /**
  14205. * Casts `value` to a path array if it's not one.
  14206. *
  14207. * @private
  14208. * @param {*} value The value to inspect.
  14209. * @param {Object} [object] The object to query keys on.
  14210. * @returns {Array} Returns the cast property path array.
  14211. */
  14212. function castPath(value, object) {
  14213. if (isArray(value)) {
  14214. return value;
  14215. }
  14216. return isKey(value, object) ? [value] : stringToPath(toString(value));
  14217. }
  14218. /**
  14219. * A `baseRest` alias which can be replaced with `identity` by module
  14220. * replacement plugins.
  14221. *
  14222. * @private
  14223. * @type {Function}
  14224. * @param {Function} func The function to apply a rest parameter to.
  14225. * @returns {Function} Returns the new function.
  14226. */
  14227. var castRest = baseRest;
  14228. /**
  14229. * Casts `array` to a slice if it's needed.
  14230. *
  14231. * @private
  14232. * @param {Array} array The array to inspect.
  14233. * @param {number} start The start position.
  14234. * @param {number} [end=array.length] The end position.
  14235. * @returns {Array} Returns the cast slice.
  14236. */
  14237. function castSlice(array, start, end) {
  14238. var length = array.length;
  14239. end = end === undefined ? length : end;
  14240. return (!start && end >= length) ? array : baseSlice(array, start, end);
  14241. }
  14242. /**
  14243. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  14244. *
  14245. * @private
  14246. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  14247. */
  14248. var clearTimeout = ctxClearTimeout || function(id) {
  14249. return root.clearTimeout(id);
  14250. };
  14251. /**
  14252. * Creates a clone of `buffer`.
  14253. *
  14254. * @private
  14255. * @param {Buffer} buffer The buffer to clone.
  14256. * @param {boolean} [isDeep] Specify a deep clone.
  14257. * @returns {Buffer} Returns the cloned buffer.
  14258. */
  14259. function cloneBuffer(buffer, isDeep) {
  14260. if (isDeep) {
  14261. return buffer.slice();
  14262. }
  14263. var length = buffer.length,
  14264. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  14265. buffer.copy(result);
  14266. return result;
  14267. }
  14268. /**
  14269. * Creates a clone of `arrayBuffer`.
  14270. *
  14271. * @private
  14272. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  14273. * @returns {ArrayBuffer} Returns the cloned array buffer.
  14274. */
  14275. function cloneArrayBuffer(arrayBuffer) {
  14276. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  14277. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  14278. return result;
  14279. }
  14280. /**
  14281. * Creates a clone of `dataView`.
  14282. *
  14283. * @private
  14284. * @param {Object} dataView The data view to clone.
  14285. * @param {boolean} [isDeep] Specify a deep clone.
  14286. * @returns {Object} Returns the cloned data view.
  14287. */
  14288. function cloneDataView(dataView, isDeep) {
  14289. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  14290. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  14291. }
  14292. /**
  14293. * Creates a clone of `regexp`.
  14294. *
  14295. * @private
  14296. * @param {Object} regexp The regexp to clone.
  14297. * @returns {Object} Returns the cloned regexp.
  14298. */
  14299. function cloneRegExp(regexp) {
  14300. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  14301. result.lastIndex = regexp.lastIndex;
  14302. return result;
  14303. }
  14304. /**
  14305. * Creates a clone of the `symbol` object.
  14306. *
  14307. * @private
  14308. * @param {Object} symbol The symbol object to clone.
  14309. * @returns {Object} Returns the cloned symbol object.
  14310. */
  14311. function cloneSymbol(symbol) {
  14312. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  14313. }
  14314. /**
  14315. * Creates a clone of `typedArray`.
  14316. *
  14317. * @private
  14318. * @param {Object} typedArray The typed array to clone.
  14319. * @param {boolean} [isDeep] Specify a deep clone.
  14320. * @returns {Object} Returns the cloned typed array.
  14321. */
  14322. function cloneTypedArray(typedArray, isDeep) {
  14323. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  14324. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  14325. }
  14326. /**
  14327. * Compares values to sort them in ascending order.
  14328. *
  14329. * @private
  14330. * @param {*} value The value to compare.
  14331. * @param {*} other The other value to compare.
  14332. * @returns {number} Returns the sort order indicator for `value`.
  14333. */
  14334. function compareAscending(value, other) {
  14335. if (value !== other) {
  14336. var valIsDefined = value !== undefined,
  14337. valIsNull = value === null,
  14338. valIsReflexive = value === value,
  14339. valIsSymbol = isSymbol(value);
  14340. var othIsDefined = other !== undefined,
  14341. othIsNull = other === null,
  14342. othIsReflexive = other === other,
  14343. othIsSymbol = isSymbol(other);
  14344. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  14345. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  14346. (valIsNull && othIsDefined && othIsReflexive) ||
  14347. (!valIsDefined && othIsReflexive) ||
  14348. !valIsReflexive) {
  14349. return 1;
  14350. }
  14351. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  14352. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  14353. (othIsNull && valIsDefined && valIsReflexive) ||
  14354. (!othIsDefined && valIsReflexive) ||
  14355. !othIsReflexive) {
  14356. return -1;
  14357. }
  14358. }
  14359. return 0;
  14360. }
  14361. /**
  14362. * Used by `_.orderBy` to compare multiple properties of a value to another
  14363. * and stable sort them.
  14364. *
  14365. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  14366. * specify an order of "desc" for descending or "asc" for ascending sort order
  14367. * of corresponding values.
  14368. *
  14369. * @private
  14370. * @param {Object} object The object to compare.
  14371. * @param {Object} other The other object to compare.
  14372. * @param {boolean[]|string[]} orders The order to sort by for each property.
  14373. * @returns {number} Returns the sort order indicator for `object`.
  14374. */
  14375. function compareMultiple(object, other, orders) {
  14376. var index = -1,
  14377. objCriteria = object.criteria,
  14378. othCriteria = other.criteria,
  14379. length = objCriteria.length,
  14380. ordersLength = orders.length;
  14381. while (++index < length) {
  14382. var result = compareAscending(objCriteria[index], othCriteria[index]);
  14383. if (result) {
  14384. if (index >= ordersLength) {
  14385. return result;
  14386. }
  14387. var order = orders[index];
  14388. return result * (order == 'desc' ? -1 : 1);
  14389. }
  14390. }
  14391. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  14392. // that causes it, under certain circumstances, to provide the same value for
  14393. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  14394. // for more details.
  14395. //
  14396. // This also ensures a stable sort in V8 and other engines.
  14397. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  14398. return object.index - other.index;
  14399. }
  14400. /**
  14401. * Creates an array that is the composition of partially applied arguments,
  14402. * placeholders, and provided arguments into a single array of arguments.
  14403. *
  14404. * @private
  14405. * @param {Array} args The provided arguments.
  14406. * @param {Array} partials The arguments to prepend to those provided.
  14407. * @param {Array} holders The `partials` placeholder indexes.
  14408. * @params {boolean} [isCurried] Specify composing for a curried function.
  14409. * @returns {Array} Returns the new array of composed arguments.
  14410. */
  14411. function composeArgs(args, partials, holders, isCurried) {
  14412. var argsIndex = -1,
  14413. argsLength = args.length,
  14414. holdersLength = holders.length,
  14415. leftIndex = -1,
  14416. leftLength = partials.length,
  14417. rangeLength = nativeMax(argsLength - holdersLength, 0),
  14418. result = Array(leftLength + rangeLength),
  14419. isUncurried = !isCurried;
  14420. while (++leftIndex < leftLength) {
  14421. result[leftIndex] = partials[leftIndex];
  14422. }
  14423. while (++argsIndex < holdersLength) {
  14424. if (isUncurried || argsIndex < argsLength) {
  14425. result[holders[argsIndex]] = args[argsIndex];
  14426. }
  14427. }
  14428. while (rangeLength--) {
  14429. result[leftIndex++] = args[argsIndex++];
  14430. }
  14431. return result;
  14432. }
  14433. /**
  14434. * This function is like `composeArgs` except that the arguments composition
  14435. * is tailored for `_.partialRight`.
  14436. *
  14437. * @private
  14438. * @param {Array} args The provided arguments.
  14439. * @param {Array} partials The arguments to append to those provided.
  14440. * @param {Array} holders The `partials` placeholder indexes.
  14441. * @params {boolean} [isCurried] Specify composing for a curried function.
  14442. * @returns {Array} Returns the new array of composed arguments.
  14443. */
  14444. function composeArgsRight(args, partials, holders, isCurried) {
  14445. var argsIndex = -1,
  14446. argsLength = args.length,
  14447. holdersIndex = -1,
  14448. holdersLength = holders.length,
  14449. rightIndex = -1,
  14450. rightLength = partials.length,
  14451. rangeLength = nativeMax(argsLength - holdersLength, 0),
  14452. result = Array(rangeLength + rightLength),
  14453. isUncurried = !isCurried;
  14454. while (++argsIndex < rangeLength) {
  14455. result[argsIndex] = args[argsIndex];
  14456. }
  14457. var offset = argsIndex;
  14458. while (++rightIndex < rightLength) {
  14459. result[offset + rightIndex] = partials[rightIndex];
  14460. }
  14461. while (++holdersIndex < holdersLength) {
  14462. if (isUncurried || argsIndex < argsLength) {
  14463. result[offset + holders[holdersIndex]] = args[argsIndex++];
  14464. }
  14465. }
  14466. return result;
  14467. }
  14468. /**
  14469. * Copies the values of `source` to `array`.
  14470. *
  14471. * @private
  14472. * @param {Array} source The array to copy values from.
  14473. * @param {Array} [array=[]] The array to copy values to.
  14474. * @returns {Array} Returns `array`.
  14475. */
  14476. function copyArray(source, array) {
  14477. var index = -1,
  14478. length = source.length;
  14479. array || (array = Array(length));
  14480. while (++index < length) {
  14481. array[index] = source[index];
  14482. }
  14483. return array;
  14484. }
  14485. /**
  14486. * Copies properties of `source` to `object`.
  14487. *
  14488. * @private
  14489. * @param {Object} source The object to copy properties from.
  14490. * @param {Array} props The property identifiers to copy.
  14491. * @param {Object} [object={}] The object to copy properties to.
  14492. * @param {Function} [customizer] The function to customize copied values.
  14493. * @returns {Object} Returns `object`.
  14494. */
  14495. function copyObject(source, props, object, customizer) {
  14496. var isNew = !object;
  14497. object || (object = {});
  14498. var index = -1,
  14499. length = props.length;
  14500. while (++index < length) {
  14501. var key = props[index];
  14502. var newValue = customizer
  14503. ? customizer(object[key], source[key], key, object, source)
  14504. : undefined;
  14505. if (newValue === undefined) {
  14506. newValue = source[key];
  14507. }
  14508. if (isNew) {
  14509. baseAssignValue(object, key, newValue);
  14510. } else {
  14511. assignValue(object, key, newValue);
  14512. }
  14513. }
  14514. return object;
  14515. }
  14516. /**
  14517. * Copies own symbols of `source` to `object`.
  14518. *
  14519. * @private
  14520. * @param {Object} source The object to copy symbols from.
  14521. * @param {Object} [object={}] The object to copy symbols to.
  14522. * @returns {Object} Returns `object`.
  14523. */
  14524. function copySymbols(source, object) {
  14525. return copyObject(source, getSymbols(source), object);
  14526. }
  14527. /**
  14528. * Copies own and inherited symbols of `source` to `object`.
  14529. *
  14530. * @private
  14531. * @param {Object} source The object to copy symbols from.
  14532. * @param {Object} [object={}] The object to copy symbols to.
  14533. * @returns {Object} Returns `object`.
  14534. */
  14535. function copySymbolsIn(source, object) {
  14536. return copyObject(source, getSymbolsIn(source), object);
  14537. }
  14538. /**
  14539. * Creates a function like `_.groupBy`.
  14540. *
  14541. * @private
  14542. * @param {Function} setter The function to set accumulator values.
  14543. * @param {Function} [initializer] The accumulator object initializer.
  14544. * @returns {Function} Returns the new aggregator function.
  14545. */
  14546. function createAggregator(setter, initializer) {
  14547. return function(collection, iteratee) {
  14548. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  14549. accumulator = initializer ? initializer() : {};
  14550. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  14551. };
  14552. }
  14553. /**
  14554. * Creates a function like `_.assign`.
  14555. *
  14556. * @private
  14557. * @param {Function} assigner The function to assign values.
  14558. * @returns {Function} Returns the new assigner function.
  14559. */
  14560. function createAssigner(assigner) {
  14561. return baseRest(function(object, sources) {
  14562. var index = -1,
  14563. length = sources.length,
  14564. customizer = length > 1 ? sources[length - 1] : undefined,
  14565. guard = length > 2 ? sources[2] : undefined;
  14566. customizer = (assigner.length > 3 && typeof customizer == 'function')
  14567. ? (length--, customizer)
  14568. : undefined;
  14569. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  14570. customizer = length < 3 ? undefined : customizer;
  14571. length = 1;
  14572. }
  14573. object = Object(object);
  14574. while (++index < length) {
  14575. var source = sources[index];
  14576. if (source) {
  14577. assigner(object, source, index, customizer);
  14578. }
  14579. }
  14580. return object;
  14581. });
  14582. }
  14583. /**
  14584. * Creates a `baseEach` or `baseEachRight` function.
  14585. *
  14586. * @private
  14587. * @param {Function} eachFunc The function to iterate over a collection.
  14588. * @param {boolean} [fromRight] Specify iterating from right to left.
  14589. * @returns {Function} Returns the new base function.
  14590. */
  14591. function createBaseEach(eachFunc, fromRight) {
  14592. return function(collection, iteratee) {
  14593. if (collection == null) {
  14594. return collection;
  14595. }
  14596. if (!isArrayLike(collection)) {
  14597. return eachFunc(collection, iteratee);
  14598. }
  14599. var length = collection.length,
  14600. index = fromRight ? length : -1,
  14601. iterable = Object(collection);
  14602. while ((fromRight ? index-- : ++index < length)) {
  14603. if (iteratee(iterable[index], index, iterable) === false) {
  14604. break;
  14605. }
  14606. }
  14607. return collection;
  14608. };
  14609. }
  14610. /**
  14611. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  14612. *
  14613. * @private
  14614. * @param {boolean} [fromRight] Specify iterating from right to left.
  14615. * @returns {Function} Returns the new base function.
  14616. */
  14617. function createBaseFor(fromRight) {
  14618. return function(object, iteratee, keysFunc) {
  14619. var index = -1,
  14620. iterable = Object(object),
  14621. props = keysFunc(object),
  14622. length = props.length;
  14623. while (length--) {
  14624. var key = props[fromRight ? length : ++index];
  14625. if (iteratee(iterable[key], key, iterable) === false) {
  14626. break;
  14627. }
  14628. }
  14629. return object;
  14630. };
  14631. }
  14632. /**
  14633. * Creates a function that wraps `func` to invoke it with the optional `this`
  14634. * binding of `thisArg`.
  14635. *
  14636. * @private
  14637. * @param {Function} func The function to wrap.
  14638. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  14639. * @param {*} [thisArg] The `this` binding of `func`.
  14640. * @returns {Function} Returns the new wrapped function.
  14641. */
  14642. function createBind(func, bitmask, thisArg) {
  14643. var isBind = bitmask & WRAP_BIND_FLAG,
  14644. Ctor = createCtor(func);
  14645. function wrapper() {
  14646. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  14647. return fn.apply(isBind ? thisArg : this, arguments);
  14648. }
  14649. return wrapper;
  14650. }
  14651. /**
  14652. * Creates a function like `_.lowerFirst`.
  14653. *
  14654. * @private
  14655. * @param {string} methodName The name of the `String` case method to use.
  14656. * @returns {Function} Returns the new case function.
  14657. */
  14658. function createCaseFirst(methodName) {
  14659. return function(string) {
  14660. string = toString(string);
  14661. var strSymbols = hasUnicode(string)
  14662. ? stringToArray(string)
  14663. : undefined;
  14664. var chr = strSymbols
  14665. ? strSymbols[0]
  14666. : string.charAt(0);
  14667. var trailing = strSymbols
  14668. ? castSlice(strSymbols, 1).join('')
  14669. : string.slice(1);
  14670. return chr[methodName]() + trailing;
  14671. };
  14672. }
  14673. /**
  14674. * Creates a function like `_.camelCase`.
  14675. *
  14676. * @private
  14677. * @param {Function} callback The function to combine each word.
  14678. * @returns {Function} Returns the new compounder function.
  14679. */
  14680. function createCompounder(callback) {
  14681. return function(string) {
  14682. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  14683. };
  14684. }
  14685. /**
  14686. * Creates a function that produces an instance of `Ctor` regardless of
  14687. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  14688. *
  14689. * @private
  14690. * @param {Function} Ctor The constructor to wrap.
  14691. * @returns {Function} Returns the new wrapped function.
  14692. */
  14693. function createCtor(Ctor) {
  14694. return function() {
  14695. // Use a `switch` statement to work with class constructors. See
  14696. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  14697. // for more details.
  14698. var args = arguments;
  14699. switch (args.length) {
  14700. case 0: return new Ctor;
  14701. case 1: return new Ctor(args[0]);
  14702. case 2: return new Ctor(args[0], args[1]);
  14703. case 3: return new Ctor(args[0], args[1], args[2]);
  14704. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  14705. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  14706. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  14707. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  14708. }
  14709. var thisBinding = baseCreate(Ctor.prototype),
  14710. result = Ctor.apply(thisBinding, args);
  14711. // Mimic the constructor's `return` behavior.
  14712. // See https://es5.github.io/#x13.2.2 for more details.
  14713. return isObject(result) ? result : thisBinding;
  14714. };
  14715. }
  14716. /**
  14717. * Creates a function that wraps `func` to enable currying.
  14718. *
  14719. * @private
  14720. * @param {Function} func The function to wrap.
  14721. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  14722. * @param {number} arity The arity of `func`.
  14723. * @returns {Function} Returns the new wrapped function.
  14724. */
  14725. function createCurry(func, bitmask, arity) {
  14726. var Ctor = createCtor(func);
  14727. function wrapper() {
  14728. var length = arguments.length,
  14729. args = Array(length),
  14730. index = length,
  14731. placeholder = getHolder(wrapper);
  14732. while (index--) {
  14733. args[index] = arguments[index];
  14734. }
  14735. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  14736. ? []
  14737. : replaceHolders(args, placeholder);
  14738. length -= holders.length;
  14739. if (length < arity) {
  14740. return createRecurry(
  14741. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  14742. args, holders, undefined, undefined, arity - length);
  14743. }
  14744. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  14745. return apply(fn, this, args);
  14746. }
  14747. return wrapper;
  14748. }
  14749. /**
  14750. * Creates a `_.find` or `_.findLast` function.
  14751. *
  14752. * @private
  14753. * @param {Function} findIndexFunc The function to find the collection index.
  14754. * @returns {Function} Returns the new find function.
  14755. */
  14756. function createFind(findIndexFunc) {
  14757. return function(collection, predicate, fromIndex) {
  14758. var iterable = Object(collection);
  14759. if (!isArrayLike(collection)) {
  14760. var iteratee = getIteratee(predicate, 3);
  14761. collection = keys(collection);
  14762. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  14763. }
  14764. var index = findIndexFunc(collection, predicate, fromIndex);
  14765. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  14766. };
  14767. }
  14768. /**
  14769. * Creates a `_.flow` or `_.flowRight` function.
  14770. *
  14771. * @private
  14772. * @param {boolean} [fromRight] Specify iterating from right to left.
  14773. * @returns {Function} Returns the new flow function.
  14774. */
  14775. function createFlow(fromRight) {
  14776. return flatRest(function(funcs) {
  14777. var length = funcs.length,
  14778. index = length,
  14779. prereq = LodashWrapper.prototype.thru;
  14780. if (fromRight) {
  14781. funcs.reverse();
  14782. }
  14783. while (index--) {
  14784. var func = funcs[index];
  14785. if (typeof func != 'function') {
  14786. throw new TypeError(FUNC_ERROR_TEXT);
  14787. }
  14788. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  14789. var wrapper = new LodashWrapper([], true);
  14790. }
  14791. }
  14792. index = wrapper ? index : length;
  14793. while (++index < length) {
  14794. func = funcs[index];
  14795. var funcName = getFuncName(func),
  14796. data = funcName == 'wrapper' ? getData(func) : undefined;
  14797. if (data && isLaziable(data[0]) &&
  14798. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  14799. !data[4].length && data[9] == 1
  14800. ) {
  14801. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  14802. } else {
  14803. wrapper = (func.length == 1 && isLaziable(func))
  14804. ? wrapper[funcName]()
  14805. : wrapper.thru(func);
  14806. }
  14807. }
  14808. return function() {
  14809. var args = arguments,
  14810. value = args[0];
  14811. if (wrapper && args.length == 1 && isArray(value)) {
  14812. return wrapper.plant(value).value();
  14813. }
  14814. var index = 0,
  14815. result = length ? funcs[index].apply(this, args) : value;
  14816. while (++index < length) {
  14817. result = funcs[index].call(this, result);
  14818. }
  14819. return result;
  14820. };
  14821. });
  14822. }
  14823. /**
  14824. * Creates a function that wraps `func` to invoke it with optional `this`
  14825. * binding of `thisArg`, partial application, and currying.
  14826. *
  14827. * @private
  14828. * @param {Function|string} func The function or method name to wrap.
  14829. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  14830. * @param {*} [thisArg] The `this` binding of `func`.
  14831. * @param {Array} [partials] The arguments to prepend to those provided to
  14832. * the new function.
  14833. * @param {Array} [holders] The `partials` placeholder indexes.
  14834. * @param {Array} [partialsRight] The arguments to append to those provided
  14835. * to the new function.
  14836. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  14837. * @param {Array} [argPos] The argument positions of the new function.
  14838. * @param {number} [ary] The arity cap of `func`.
  14839. * @param {number} [arity] The arity of `func`.
  14840. * @returns {Function} Returns the new wrapped function.
  14841. */
  14842. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  14843. var isAry = bitmask & WRAP_ARY_FLAG,
  14844. isBind = bitmask & WRAP_BIND_FLAG,
  14845. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  14846. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  14847. isFlip = bitmask & WRAP_FLIP_FLAG,
  14848. Ctor = isBindKey ? undefined : createCtor(func);
  14849. function wrapper() {
  14850. var length = arguments.length,
  14851. args = Array(length),
  14852. index = length;
  14853. while (index--) {
  14854. args[index] = arguments[index];
  14855. }
  14856. if (isCurried) {
  14857. var placeholder = getHolder(wrapper),
  14858. holdersCount = countHolders(args, placeholder);
  14859. }
  14860. if (partials) {
  14861. args = composeArgs(args, partials, holders, isCurried);
  14862. }
  14863. if (partialsRight) {
  14864. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  14865. }
  14866. length -= holdersCount;
  14867. if (isCurried && length < arity) {
  14868. var newHolders = replaceHolders(args, placeholder);
  14869. return createRecurry(
  14870. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  14871. args, newHolders, argPos, ary, arity - length
  14872. );
  14873. }
  14874. var thisBinding = isBind ? thisArg : this,
  14875. fn = isBindKey ? thisBinding[func] : func;
  14876. length = args.length;
  14877. if (argPos) {
  14878. args = reorder(args, argPos);
  14879. } else if (isFlip && length > 1) {
  14880. args.reverse();
  14881. }
  14882. if (isAry && ary < length) {
  14883. args.length = ary;
  14884. }
  14885. if (this && this !== root && this instanceof wrapper) {
  14886. fn = Ctor || createCtor(fn);
  14887. }
  14888. return fn.apply(thisBinding, args);
  14889. }
  14890. return wrapper;
  14891. }
  14892. /**
  14893. * Creates a function like `_.invertBy`.
  14894. *
  14895. * @private
  14896. * @param {Function} setter The function to set accumulator values.
  14897. * @param {Function} toIteratee The function to resolve iteratees.
  14898. * @returns {Function} Returns the new inverter function.
  14899. */
  14900. function createInverter(setter, toIteratee) {
  14901. return function(object, iteratee) {
  14902. return baseInverter(object, setter, toIteratee(iteratee), {});
  14903. };
  14904. }
  14905. /**
  14906. * Creates a function that performs a mathematical operation on two values.
  14907. *
  14908. * @private
  14909. * @param {Function} operator The function to perform the operation.
  14910. * @param {number} [defaultValue] The value used for `undefined` arguments.
  14911. * @returns {Function} Returns the new mathematical operation function.
  14912. */
  14913. function createMathOperation(operator, defaultValue) {
  14914. return function(value, other) {
  14915. var result;
  14916. if (value === undefined && other === undefined) {
  14917. return defaultValue;
  14918. }
  14919. if (value !== undefined) {
  14920. result = value;
  14921. }
  14922. if (other !== undefined) {
  14923. if (result === undefined) {
  14924. return other;
  14925. }
  14926. if (typeof value == 'string' || typeof other == 'string') {
  14927. value = baseToString(value);
  14928. other = baseToString(other);
  14929. } else {
  14930. value = baseToNumber(value);
  14931. other = baseToNumber(other);
  14932. }
  14933. result = operator(value, other);
  14934. }
  14935. return result;
  14936. };
  14937. }
  14938. /**
  14939. * Creates a function like `_.over`.
  14940. *
  14941. * @private
  14942. * @param {Function} arrayFunc The function to iterate over iteratees.
  14943. * @returns {Function} Returns the new over function.
  14944. */
  14945. function createOver(arrayFunc) {
  14946. return flatRest(function(iteratees) {
  14947. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  14948. return baseRest(function(args) {
  14949. var thisArg = this;
  14950. return arrayFunc(iteratees, function(iteratee) {
  14951. return apply(iteratee, thisArg, args);
  14952. });
  14953. });
  14954. });
  14955. }
  14956. /**
  14957. * Creates the padding for `string` based on `length`. The `chars` string
  14958. * is truncated if the number of characters exceeds `length`.
  14959. *
  14960. * @private
  14961. * @param {number} length The padding length.
  14962. * @param {string} [chars=' '] The string used as padding.
  14963. * @returns {string} Returns the padding for `string`.
  14964. */
  14965. function createPadding(length, chars) {
  14966. chars = chars === undefined ? ' ' : baseToString(chars);
  14967. var charsLength = chars.length;
  14968. if (charsLength < 2) {
  14969. return charsLength ? baseRepeat(chars, length) : chars;
  14970. }
  14971. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  14972. return hasUnicode(chars)
  14973. ? castSlice(stringToArray(result), 0, length).join('')
  14974. : result.slice(0, length);
  14975. }
  14976. /**
  14977. * Creates a function that wraps `func` to invoke it with the `this` binding
  14978. * of `thisArg` and `partials` prepended to the arguments it receives.
  14979. *
  14980. * @private
  14981. * @param {Function} func The function to wrap.
  14982. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  14983. * @param {*} thisArg The `this` binding of `func`.
  14984. * @param {Array} partials The arguments to prepend to those provided to
  14985. * the new function.
  14986. * @returns {Function} Returns the new wrapped function.
  14987. */
  14988. function createPartial(func, bitmask, thisArg, partials) {
  14989. var isBind = bitmask & WRAP_BIND_FLAG,
  14990. Ctor = createCtor(func);
  14991. function wrapper() {
  14992. var argsIndex = -1,
  14993. argsLength = arguments.length,
  14994. leftIndex = -1,
  14995. leftLength = partials.length,
  14996. args = Array(leftLength + argsLength),
  14997. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  14998. while (++leftIndex < leftLength) {
  14999. args[leftIndex] = partials[leftIndex];
  15000. }
  15001. while (argsLength--) {
  15002. args[leftIndex++] = arguments[++argsIndex];
  15003. }
  15004. return apply(fn, isBind ? thisArg : this, args);
  15005. }
  15006. return wrapper;
  15007. }
  15008. /**
  15009. * Creates a `_.range` or `_.rangeRight` function.
  15010. *
  15011. * @private
  15012. * @param {boolean} [fromRight] Specify iterating from right to left.
  15013. * @returns {Function} Returns the new range function.
  15014. */
  15015. function createRange(fromRight) {
  15016. return function(start, end, step) {
  15017. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  15018. end = step = undefined;
  15019. }
  15020. // Ensure the sign of `-0` is preserved.
  15021. start = toFinite(start);
  15022. if (end === undefined) {
  15023. end = start;
  15024. start = 0;
  15025. } else {
  15026. end = toFinite(end);
  15027. }
  15028. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  15029. return baseRange(start, end, step, fromRight);
  15030. };
  15031. }
  15032. /**
  15033. * Creates a function that performs a relational operation on two values.
  15034. *
  15035. * @private
  15036. * @param {Function} operator The function to perform the operation.
  15037. * @returns {Function} Returns the new relational operation function.
  15038. */
  15039. function createRelationalOperation(operator) {
  15040. return function(value, other) {
  15041. if (!(typeof value == 'string' && typeof other == 'string')) {
  15042. value = toNumber(value);
  15043. other = toNumber(other);
  15044. }
  15045. return operator(value, other);
  15046. };
  15047. }
  15048. /**
  15049. * Creates a function that wraps `func` to continue currying.
  15050. *
  15051. * @private
  15052. * @param {Function} func The function to wrap.
  15053. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  15054. * @param {Function} wrapFunc The function to create the `func` wrapper.
  15055. * @param {*} placeholder The placeholder value.
  15056. * @param {*} [thisArg] The `this` binding of `func`.
  15057. * @param {Array} [partials] The arguments to prepend to those provided to
  15058. * the new function.
  15059. * @param {Array} [holders] The `partials` placeholder indexes.
  15060. * @param {Array} [argPos] The argument positions of the new function.
  15061. * @param {number} [ary] The arity cap of `func`.
  15062. * @param {number} [arity] The arity of `func`.
  15063. * @returns {Function} Returns the new wrapped function.
  15064. */
  15065. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  15066. var isCurry = bitmask & WRAP_CURRY_FLAG,
  15067. newHolders = isCurry ? holders : undefined,
  15068. newHoldersRight = isCurry ? undefined : holders,
  15069. newPartials = isCurry ? partials : undefined,
  15070. newPartialsRight = isCurry ? undefined : partials;
  15071. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  15072. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  15073. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  15074. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  15075. }
  15076. var newData = [
  15077. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  15078. newHoldersRight, argPos, ary, arity
  15079. ];
  15080. var result = wrapFunc.apply(undefined, newData);
  15081. if (isLaziable(func)) {
  15082. setData(result, newData);
  15083. }
  15084. result.placeholder = placeholder;
  15085. return setWrapToString(result, func, bitmask);
  15086. }
  15087. /**
  15088. * Creates a function like `_.round`.
  15089. *
  15090. * @private
  15091. * @param {string} methodName The name of the `Math` method to use when rounding.
  15092. * @returns {Function} Returns the new round function.
  15093. */
  15094. function createRound(methodName) {
  15095. var func = Math[methodName];
  15096. return function(number, precision) {
  15097. number = toNumber(number);
  15098. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  15099. if (precision && nativeIsFinite(number)) {
  15100. // Shift with exponential notation to avoid floating-point issues.
  15101. // See [MDN](https://mdn.io/round#Examples) for more details.
  15102. var pair = (toString(number) + 'e').split('e'),
  15103. value = func(pair[0] + 'e' + (+pair[1] + precision));
  15104. pair = (toString(value) + 'e').split('e');
  15105. return +(pair[0] + 'e' + (+pair[1] - precision));
  15106. }
  15107. return func(number);
  15108. };
  15109. }
  15110. /**
  15111. * Creates a set object of `values`.
  15112. *
  15113. * @private
  15114. * @param {Array} values The values to add to the set.
  15115. * @returns {Object} Returns the new set.
  15116. */
  15117. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  15118. return new Set(values);
  15119. };
  15120. /**
  15121. * Creates a `_.toPairs` or `_.toPairsIn` function.
  15122. *
  15123. * @private
  15124. * @param {Function} keysFunc The function to get the keys of a given object.
  15125. * @returns {Function} Returns the new pairs function.
  15126. */
  15127. function createToPairs(keysFunc) {
  15128. return function(object) {
  15129. var tag = getTag(object);
  15130. if (tag == mapTag) {
  15131. return mapToArray(object);
  15132. }
  15133. if (tag == setTag) {
  15134. return setToPairs(object);
  15135. }
  15136. return baseToPairs(object, keysFunc(object));
  15137. };
  15138. }
  15139. /**
  15140. * Creates a function that either curries or invokes `func` with optional
  15141. * `this` binding and partially applied arguments.
  15142. *
  15143. * @private
  15144. * @param {Function|string} func The function or method name to wrap.
  15145. * @param {number} bitmask The bitmask flags.
  15146. * 1 - `_.bind`
  15147. * 2 - `_.bindKey`
  15148. * 4 - `_.curry` or `_.curryRight` of a bound function
  15149. * 8 - `_.curry`
  15150. * 16 - `_.curryRight`
  15151. * 32 - `_.partial`
  15152. * 64 - `_.partialRight`
  15153. * 128 - `_.rearg`
  15154. * 256 - `_.ary`
  15155. * 512 - `_.flip`
  15156. * @param {*} [thisArg] The `this` binding of `func`.
  15157. * @param {Array} [partials] The arguments to be partially applied.
  15158. * @param {Array} [holders] The `partials` placeholder indexes.
  15159. * @param {Array} [argPos] The argument positions of the new function.
  15160. * @param {number} [ary] The arity cap of `func`.
  15161. * @param {number} [arity] The arity of `func`.
  15162. * @returns {Function} Returns the new wrapped function.
  15163. */
  15164. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  15165. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  15166. if (!isBindKey && typeof func != 'function') {
  15167. throw new TypeError(FUNC_ERROR_TEXT);
  15168. }
  15169. var length = partials ? partials.length : 0;
  15170. if (!length) {
  15171. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  15172. partials = holders = undefined;
  15173. }
  15174. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  15175. arity = arity === undefined ? arity : toInteger(arity);
  15176. length -= holders ? holders.length : 0;
  15177. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  15178. var partialsRight = partials,
  15179. holdersRight = holders;
  15180. partials = holders = undefined;
  15181. }
  15182. var data = isBindKey ? undefined : getData(func);
  15183. var newData = [
  15184. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  15185. argPos, ary, arity
  15186. ];
  15187. if (data) {
  15188. mergeData(newData, data);
  15189. }
  15190. func = newData[0];
  15191. bitmask = newData[1];
  15192. thisArg = newData[2];
  15193. partials = newData[3];
  15194. holders = newData[4];
  15195. arity = newData[9] = newData[9] === undefined
  15196. ? (isBindKey ? 0 : func.length)
  15197. : nativeMax(newData[9] - length, 0);
  15198. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  15199. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  15200. }
  15201. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  15202. var result = createBind(func, bitmask, thisArg);
  15203. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  15204. result = createCurry(func, bitmask, arity);
  15205. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  15206. result = createPartial(func, bitmask, thisArg, partials);
  15207. } else {
  15208. result = createHybrid.apply(undefined, newData);
  15209. }
  15210. var setter = data ? baseSetData : setData;
  15211. return setWrapToString(setter(result, newData), func, bitmask);
  15212. }
  15213. /**
  15214. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  15215. * of source objects to the destination object for all destination properties
  15216. * that resolve to `undefined`.
  15217. *
  15218. * @private
  15219. * @param {*} objValue The destination value.
  15220. * @param {*} srcValue The source value.
  15221. * @param {string} key The key of the property to assign.
  15222. * @param {Object} object The parent object of `objValue`.
  15223. * @returns {*} Returns the value to assign.
  15224. */
  15225. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  15226. if (objValue === undefined ||
  15227. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  15228. return srcValue;
  15229. }
  15230. return objValue;
  15231. }
  15232. /**
  15233. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  15234. * objects into destination objects that are passed thru.
  15235. *
  15236. * @private
  15237. * @param {*} objValue The destination value.
  15238. * @param {*} srcValue The source value.
  15239. * @param {string} key The key of the property to merge.
  15240. * @param {Object} object The parent object of `objValue`.
  15241. * @param {Object} source The parent object of `srcValue`.
  15242. * @param {Object} [stack] Tracks traversed source values and their merged
  15243. * counterparts.
  15244. * @returns {*} Returns the value to assign.
  15245. */
  15246. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  15247. if (isObject(objValue) && isObject(srcValue)) {
  15248. // Recursively merge objects and arrays (susceptible to call stack limits).
  15249. stack.set(srcValue, objValue);
  15250. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  15251. stack['delete'](srcValue);
  15252. }
  15253. return objValue;
  15254. }
  15255. /**
  15256. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  15257. * objects.
  15258. *
  15259. * @private
  15260. * @param {*} value The value to inspect.
  15261. * @param {string} key The key of the property to inspect.
  15262. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  15263. */
  15264. function customOmitClone(value) {
  15265. return isPlainObject(value) ? undefined : value;
  15266. }
  15267. /**
  15268. * A specialized version of `baseIsEqualDeep` for arrays with support for
  15269. * partial deep comparisons.
  15270. *
  15271. * @private
  15272. * @param {Array} array The array to compare.
  15273. * @param {Array} other The other array to compare.
  15274. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  15275. * @param {Function} customizer The function to customize comparisons.
  15276. * @param {Function} equalFunc The function to determine equivalents of values.
  15277. * @param {Object} stack Tracks traversed `array` and `other` objects.
  15278. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  15279. */
  15280. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  15281. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  15282. arrLength = array.length,
  15283. othLength = other.length;
  15284. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  15285. return false;
  15286. }
  15287. // Assume cyclic values are equal.
  15288. var stacked = stack.get(array);
  15289. if (stacked && stack.get(other)) {
  15290. return stacked == other;
  15291. }
  15292. var index = -1,
  15293. result = true,
  15294. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  15295. stack.set(array, other);
  15296. stack.set(other, array);
  15297. // Ignore non-index properties.
  15298. while (++index < arrLength) {
  15299. var arrValue = array[index],
  15300. othValue = other[index];
  15301. if (customizer) {
  15302. var compared = isPartial
  15303. ? customizer(othValue, arrValue, index, other, array, stack)
  15304. : customizer(arrValue, othValue, index, array, other, stack);
  15305. }
  15306. if (compared !== undefined) {
  15307. if (compared) {
  15308. continue;
  15309. }
  15310. result = false;
  15311. break;
  15312. }
  15313. // Recursively compare arrays (susceptible to call stack limits).
  15314. if (seen) {
  15315. if (!arraySome(other, function(othValue, othIndex) {
  15316. if (!cacheHas(seen, othIndex) &&
  15317. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  15318. return seen.push(othIndex);
  15319. }
  15320. })) {
  15321. result = false;
  15322. break;
  15323. }
  15324. } else if (!(
  15325. arrValue === othValue ||
  15326. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  15327. )) {
  15328. result = false;
  15329. break;
  15330. }
  15331. }
  15332. stack['delete'](array);
  15333. stack['delete'](other);
  15334. return result;
  15335. }
  15336. /**
  15337. * A specialized version of `baseIsEqualDeep` for comparing objects of
  15338. * the same `toStringTag`.
  15339. *
  15340. * **Note:** This function only supports comparing values with tags of
  15341. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  15342. *
  15343. * @private
  15344. * @param {Object} object The object to compare.
  15345. * @param {Object} other The other object to compare.
  15346. * @param {string} tag The `toStringTag` of the objects to compare.
  15347. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  15348. * @param {Function} customizer The function to customize comparisons.
  15349. * @param {Function} equalFunc The function to determine equivalents of values.
  15350. * @param {Object} stack Tracks traversed `object` and `other` objects.
  15351. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  15352. */
  15353. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  15354. switch (tag) {
  15355. case dataViewTag:
  15356. if ((object.byteLength != other.byteLength) ||
  15357. (object.byteOffset != other.byteOffset)) {
  15358. return false;
  15359. }
  15360. object = object.buffer;
  15361. other = other.buffer;
  15362. case arrayBufferTag:
  15363. if ((object.byteLength != other.byteLength) ||
  15364. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  15365. return false;
  15366. }
  15367. return true;
  15368. case boolTag:
  15369. case dateTag:
  15370. case numberTag:
  15371. // Coerce booleans to `1` or `0` and dates to milliseconds.
  15372. // Invalid dates are coerced to `NaN`.
  15373. return eq(+object, +other);
  15374. case errorTag:
  15375. return object.name == other.name && object.message == other.message;
  15376. case regexpTag:
  15377. case stringTag:
  15378. // Coerce regexes to strings and treat strings, primitives and objects,
  15379. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  15380. // for more details.
  15381. return object == (other + '');
  15382. case mapTag:
  15383. var convert = mapToArray;
  15384. case setTag:
  15385. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  15386. convert || (convert = setToArray);
  15387. if (object.size != other.size && !isPartial) {
  15388. return false;
  15389. }
  15390. // Assume cyclic values are equal.
  15391. var stacked = stack.get(object);
  15392. if (stacked) {
  15393. return stacked == other;
  15394. }
  15395. bitmask |= COMPARE_UNORDERED_FLAG;
  15396. // Recursively compare objects (susceptible to call stack limits).
  15397. stack.set(object, other);
  15398. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  15399. stack['delete'](object);
  15400. return result;
  15401. case symbolTag:
  15402. if (symbolValueOf) {
  15403. return symbolValueOf.call(object) == symbolValueOf.call(other);
  15404. }
  15405. }
  15406. return false;
  15407. }
  15408. /**
  15409. * A specialized version of `baseIsEqualDeep` for objects with support for
  15410. * partial deep comparisons.
  15411. *
  15412. * @private
  15413. * @param {Object} object The object to compare.
  15414. * @param {Object} other The other object to compare.
  15415. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  15416. * @param {Function} customizer The function to customize comparisons.
  15417. * @param {Function} equalFunc The function to determine equivalents of values.
  15418. * @param {Object} stack Tracks traversed `object` and `other` objects.
  15419. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  15420. */
  15421. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  15422. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  15423. objProps = getAllKeys(object),
  15424. objLength = objProps.length,
  15425. othProps = getAllKeys(other),
  15426. othLength = othProps.length;
  15427. if (objLength != othLength && !isPartial) {
  15428. return false;
  15429. }
  15430. var index = objLength;
  15431. while (index--) {
  15432. var key = objProps[index];
  15433. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  15434. return false;
  15435. }
  15436. }
  15437. // Assume cyclic values are equal.
  15438. var stacked = stack.get(object);
  15439. if (stacked && stack.get(other)) {
  15440. return stacked == other;
  15441. }
  15442. var result = true;
  15443. stack.set(object, other);
  15444. stack.set(other, object);
  15445. var skipCtor = isPartial;
  15446. while (++index < objLength) {
  15447. key = objProps[index];
  15448. var objValue = object[key],
  15449. othValue = other[key];
  15450. if (customizer) {
  15451. var compared = isPartial
  15452. ? customizer(othValue, objValue, key, other, object, stack)
  15453. : customizer(objValue, othValue, key, object, other, stack);
  15454. }
  15455. // Recursively compare objects (susceptible to call stack limits).
  15456. if (!(compared === undefined
  15457. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  15458. : compared
  15459. )) {
  15460. result = false;
  15461. break;
  15462. }
  15463. skipCtor || (skipCtor = key == 'constructor');
  15464. }
  15465. if (result && !skipCtor) {
  15466. var objCtor = object.constructor,
  15467. othCtor = other.constructor;
  15468. // Non `Object` object instances with different constructors are not equal.
  15469. if (objCtor != othCtor &&
  15470. ('constructor' in object && 'constructor' in other) &&
  15471. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  15472. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  15473. result = false;
  15474. }
  15475. }
  15476. stack['delete'](object);
  15477. stack['delete'](other);
  15478. return result;
  15479. }
  15480. /**
  15481. * A specialized version of `baseRest` which flattens the rest array.
  15482. *
  15483. * @private
  15484. * @param {Function} func The function to apply a rest parameter to.
  15485. * @returns {Function} Returns the new function.
  15486. */
  15487. function flatRest(func) {
  15488. return setToString(overRest(func, undefined, flatten), func + '');
  15489. }
  15490. /**
  15491. * Creates an array of own enumerable property names and symbols of `object`.
  15492. *
  15493. * @private
  15494. * @param {Object} object The object to query.
  15495. * @returns {Array} Returns the array of property names and symbols.
  15496. */
  15497. function getAllKeys(object) {
  15498. return baseGetAllKeys(object, keys, getSymbols);
  15499. }
  15500. /**
  15501. * Creates an array of own and inherited enumerable property names and
  15502. * symbols of `object`.
  15503. *
  15504. * @private
  15505. * @param {Object} object The object to query.
  15506. * @returns {Array} Returns the array of property names and symbols.
  15507. */
  15508. function getAllKeysIn(object) {
  15509. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  15510. }
  15511. /**
  15512. * Gets metadata for `func`.
  15513. *
  15514. * @private
  15515. * @param {Function} func The function to query.
  15516. * @returns {*} Returns the metadata for `func`.
  15517. */
  15518. var getData = !metaMap ? noop : function(func) {
  15519. return metaMap.get(func);
  15520. };
  15521. /**
  15522. * Gets the name of `func`.
  15523. *
  15524. * @private
  15525. * @param {Function} func The function to query.
  15526. * @returns {string} Returns the function name.
  15527. */
  15528. function getFuncName(func) {
  15529. var result = (func.name + ''),
  15530. array = realNames[result],
  15531. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  15532. while (length--) {
  15533. var data = array[length],
  15534. otherFunc = data.func;
  15535. if (otherFunc == null || otherFunc == func) {
  15536. return data.name;
  15537. }
  15538. }
  15539. return result;
  15540. }
  15541. /**
  15542. * Gets the argument placeholder value for `func`.
  15543. *
  15544. * @private
  15545. * @param {Function} func The function to inspect.
  15546. * @returns {*} Returns the placeholder value.
  15547. */
  15548. function getHolder(func) {
  15549. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  15550. return object.placeholder;
  15551. }
  15552. /**
  15553. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  15554. * this function returns the custom method, otherwise it returns `baseIteratee`.
  15555. * If arguments are provided, the chosen function is invoked with them and
  15556. * its result is returned.
  15557. *
  15558. * @private
  15559. * @param {*} [value] The value to convert to an iteratee.
  15560. * @param {number} [arity] The arity of the created iteratee.
  15561. * @returns {Function} Returns the chosen function or its result.
  15562. */
  15563. function getIteratee() {
  15564. var result = lodash.iteratee || iteratee;
  15565. result = result === iteratee ? baseIteratee : result;
  15566. return arguments.length ? result(arguments[0], arguments[1]) : result;
  15567. }
  15568. /**
  15569. * Gets the data for `map`.
  15570. *
  15571. * @private
  15572. * @param {Object} map The map to query.
  15573. * @param {string} key The reference key.
  15574. * @returns {*} Returns the map data.
  15575. */
  15576. function getMapData(map, key) {
  15577. var data = map.__data__;
  15578. return isKeyable(key)
  15579. ? data[typeof key == 'string' ? 'string' : 'hash']
  15580. : data.map;
  15581. }
  15582. /**
  15583. * Gets the property names, values, and compare flags of `object`.
  15584. *
  15585. * @private
  15586. * @param {Object} object The object to query.
  15587. * @returns {Array} Returns the match data of `object`.
  15588. */
  15589. function getMatchData(object) {
  15590. var result = keys(object),
  15591. length = result.length;
  15592. while (length--) {
  15593. var key = result[length],
  15594. value = object[key];
  15595. result[length] = [key, value, isStrictComparable(value)];
  15596. }
  15597. return result;
  15598. }
  15599. /**
  15600. * Gets the native function at `key` of `object`.
  15601. *
  15602. * @private
  15603. * @param {Object} object The object to query.
  15604. * @param {string} key The key of the method to get.
  15605. * @returns {*} Returns the function if it's native, else `undefined`.
  15606. */
  15607. function getNative(object, key) {
  15608. var value = getValue(object, key);
  15609. return baseIsNative(value) ? value : undefined;
  15610. }
  15611. /**
  15612. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  15613. *
  15614. * @private
  15615. * @param {*} value The value to query.
  15616. * @returns {string} Returns the raw `toStringTag`.
  15617. */
  15618. function getRawTag(value) {
  15619. var isOwn = hasOwnProperty.call(value, symToStringTag),
  15620. tag = value[symToStringTag];
  15621. try {
  15622. value[symToStringTag] = undefined;
  15623. var unmasked = true;
  15624. } catch (e) {}
  15625. var result = nativeObjectToString.call(value);
  15626. if (unmasked) {
  15627. if (isOwn) {
  15628. value[symToStringTag] = tag;
  15629. } else {
  15630. delete value[symToStringTag];
  15631. }
  15632. }
  15633. return result;
  15634. }
  15635. /**
  15636. * Creates an array of the own enumerable symbols of `object`.
  15637. *
  15638. * @private
  15639. * @param {Object} object The object to query.
  15640. * @returns {Array} Returns the array of symbols.
  15641. */
  15642. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  15643. if (object == null) {
  15644. return [];
  15645. }
  15646. object = Object(object);
  15647. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  15648. return propertyIsEnumerable.call(object, symbol);
  15649. });
  15650. };
  15651. /**
  15652. * Creates an array of the own and inherited enumerable symbols of `object`.
  15653. *
  15654. * @private
  15655. * @param {Object} object The object to query.
  15656. * @returns {Array} Returns the array of symbols.
  15657. */
  15658. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  15659. var result = [];
  15660. while (object) {
  15661. arrayPush(result, getSymbols(object));
  15662. object = getPrototype(object);
  15663. }
  15664. return result;
  15665. };
  15666. /**
  15667. * Gets the `toStringTag` of `value`.
  15668. *
  15669. * @private
  15670. * @param {*} value The value to query.
  15671. * @returns {string} Returns the `toStringTag`.
  15672. */
  15673. var getTag = baseGetTag;
  15674. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  15675. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  15676. (Map && getTag(new Map) != mapTag) ||
  15677. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  15678. (Set && getTag(new Set) != setTag) ||
  15679. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  15680. getTag = function(value) {
  15681. var result = baseGetTag(value),
  15682. Ctor = result == objectTag ? value.constructor : undefined,
  15683. ctorString = Ctor ? toSource(Ctor) : '';
  15684. if (ctorString) {
  15685. switch (ctorString) {
  15686. case dataViewCtorString: return dataViewTag;
  15687. case mapCtorString: return mapTag;
  15688. case promiseCtorString: return promiseTag;
  15689. case setCtorString: return setTag;
  15690. case weakMapCtorString: return weakMapTag;
  15691. }
  15692. }
  15693. return result;
  15694. };
  15695. }
  15696. /**
  15697. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  15698. *
  15699. * @private
  15700. * @param {number} start The start of the view.
  15701. * @param {number} end The end of the view.
  15702. * @param {Array} transforms The transformations to apply to the view.
  15703. * @returns {Object} Returns an object containing the `start` and `end`
  15704. * positions of the view.
  15705. */
  15706. function getView(start, end, transforms) {
  15707. var index = -1,
  15708. length = transforms.length;
  15709. while (++index < length) {
  15710. var data = transforms[index],
  15711. size = data.size;
  15712. switch (data.type) {
  15713. case 'drop': start += size; break;
  15714. case 'dropRight': end -= size; break;
  15715. case 'take': end = nativeMin(end, start + size); break;
  15716. case 'takeRight': start = nativeMax(start, end - size); break;
  15717. }
  15718. }
  15719. return { 'start': start, 'end': end };
  15720. }
  15721. /**
  15722. * Extracts wrapper details from the `source` body comment.
  15723. *
  15724. * @private
  15725. * @param {string} source The source to inspect.
  15726. * @returns {Array} Returns the wrapper details.
  15727. */
  15728. function getWrapDetails(source) {
  15729. var match = source.match(reWrapDetails);
  15730. return match ? match[1].split(reSplitDetails) : [];
  15731. }
  15732. /**
  15733. * Checks if `path` exists on `object`.
  15734. *
  15735. * @private
  15736. * @param {Object} object The object to query.
  15737. * @param {Array|string} path The path to check.
  15738. * @param {Function} hasFunc The function to check properties.
  15739. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  15740. */
  15741. function hasPath(object, path, hasFunc) {
  15742. path = castPath(path, object);
  15743. var index = -1,
  15744. length = path.length,
  15745. result = false;
  15746. while (++index < length) {
  15747. var key = toKey(path[index]);
  15748. if (!(result = object != null && hasFunc(object, key))) {
  15749. break;
  15750. }
  15751. object = object[key];
  15752. }
  15753. if (result || ++index != length) {
  15754. return result;
  15755. }
  15756. length = object == null ? 0 : object.length;
  15757. return !!length && isLength(length) && isIndex(key, length) &&
  15758. (isArray(object) || isArguments(object));
  15759. }
  15760. /**
  15761. * Initializes an array clone.
  15762. *
  15763. * @private
  15764. * @param {Array} array The array to clone.
  15765. * @returns {Array} Returns the initialized clone.
  15766. */
  15767. function initCloneArray(array) {
  15768. var length = array.length,
  15769. result = new array.constructor(length);
  15770. // Add properties assigned by `RegExp#exec`.
  15771. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  15772. result.index = array.index;
  15773. result.input = array.input;
  15774. }
  15775. return result;
  15776. }
  15777. /**
  15778. * Initializes an object clone.
  15779. *
  15780. * @private
  15781. * @param {Object} object The object to clone.
  15782. * @returns {Object} Returns the initialized clone.
  15783. */
  15784. function initCloneObject(object) {
  15785. return (typeof object.constructor == 'function' && !isPrototype(object))
  15786. ? baseCreate(getPrototype(object))
  15787. : {};
  15788. }
  15789. /**
  15790. * Initializes an object clone based on its `toStringTag`.
  15791. *
  15792. * **Note:** This function only supports cloning values with tags of
  15793. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  15794. *
  15795. * @private
  15796. * @param {Object} object The object to clone.
  15797. * @param {string} tag The `toStringTag` of the object to clone.
  15798. * @param {boolean} [isDeep] Specify a deep clone.
  15799. * @returns {Object} Returns the initialized clone.
  15800. */
  15801. function initCloneByTag(object, tag, isDeep) {
  15802. var Ctor = object.constructor;
  15803. switch (tag) {
  15804. case arrayBufferTag:
  15805. return cloneArrayBuffer(object);
  15806. case boolTag:
  15807. case dateTag:
  15808. return new Ctor(+object);
  15809. case dataViewTag:
  15810. return cloneDataView(object, isDeep);
  15811. case float32Tag: case float64Tag:
  15812. case int8Tag: case int16Tag: case int32Tag:
  15813. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  15814. return cloneTypedArray(object, isDeep);
  15815. case mapTag:
  15816. return new Ctor;
  15817. case numberTag:
  15818. case stringTag:
  15819. return new Ctor(object);
  15820. case regexpTag:
  15821. return cloneRegExp(object);
  15822. case setTag:
  15823. return new Ctor;
  15824. case symbolTag:
  15825. return cloneSymbol(object);
  15826. }
  15827. }
  15828. /**
  15829. * Inserts wrapper `details` in a comment at the top of the `source` body.
  15830. *
  15831. * @private
  15832. * @param {string} source The source to modify.
  15833. * @returns {Array} details The details to insert.
  15834. * @returns {string} Returns the modified source.
  15835. */
  15836. function insertWrapDetails(source, details) {
  15837. var length = details.length;
  15838. if (!length) {
  15839. return source;
  15840. }
  15841. var lastIndex = length - 1;
  15842. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  15843. details = details.join(length > 2 ? ', ' : ' ');
  15844. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  15845. }
  15846. /**
  15847. * Checks if `value` is a flattenable `arguments` object or array.
  15848. *
  15849. * @private
  15850. * @param {*} value The value to check.
  15851. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  15852. */
  15853. function isFlattenable(value) {
  15854. return isArray(value) || isArguments(value) ||
  15855. !!(spreadableSymbol && value && value[spreadableSymbol]);
  15856. }
  15857. /**
  15858. * Checks if `value` is a valid array-like index.
  15859. *
  15860. * @private
  15861. * @param {*} value The value to check.
  15862. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  15863. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  15864. */
  15865. function isIndex(value, length) {
  15866. var type = typeof value;
  15867. length = length == null ? MAX_SAFE_INTEGER : length;
  15868. return !!length &&
  15869. (type == 'number' ||
  15870. (type != 'symbol' && reIsUint.test(value))) &&
  15871. (value > -1 && value % 1 == 0 && value < length);
  15872. }
  15873. /**
  15874. * Checks if the given arguments are from an iteratee call.
  15875. *
  15876. * @private
  15877. * @param {*} value The potential iteratee value argument.
  15878. * @param {*} index The potential iteratee index or key argument.
  15879. * @param {*} object The potential iteratee object argument.
  15880. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  15881. * else `false`.
  15882. */
  15883. function isIterateeCall(value, index, object) {
  15884. if (!isObject(object)) {
  15885. return false;
  15886. }
  15887. var type = typeof index;
  15888. if (type == 'number'
  15889. ? (isArrayLike(object) && isIndex(index, object.length))
  15890. : (type == 'string' && index in object)
  15891. ) {
  15892. return eq(object[index], value);
  15893. }
  15894. return false;
  15895. }
  15896. /**
  15897. * Checks if `value` is a property name and not a property path.
  15898. *
  15899. * @private
  15900. * @param {*} value The value to check.
  15901. * @param {Object} [object] The object to query keys on.
  15902. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  15903. */
  15904. function isKey(value, object) {
  15905. if (isArray(value)) {
  15906. return false;
  15907. }
  15908. var type = typeof value;
  15909. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  15910. value == null || isSymbol(value)) {
  15911. return true;
  15912. }
  15913. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  15914. (object != null && value in Object(object));
  15915. }
  15916. /**
  15917. * Checks if `value` is suitable for use as unique object key.
  15918. *
  15919. * @private
  15920. * @param {*} value The value to check.
  15921. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  15922. */
  15923. function isKeyable(value) {
  15924. var type = typeof value;
  15925. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  15926. ? (value !== '__proto__')
  15927. : (value === null);
  15928. }
  15929. /**
  15930. * Checks if `func` has a lazy counterpart.
  15931. *
  15932. * @private
  15933. * @param {Function} func The function to check.
  15934. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  15935. * else `false`.
  15936. */
  15937. function isLaziable(func) {
  15938. var funcName = getFuncName(func),
  15939. other = lodash[funcName];
  15940. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  15941. return false;
  15942. }
  15943. if (func === other) {
  15944. return true;
  15945. }
  15946. var data = getData(other);
  15947. return !!data && func === data[0];
  15948. }
  15949. /**
  15950. * Checks if `func` has its source masked.
  15951. *
  15952. * @private
  15953. * @param {Function} func The function to check.
  15954. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  15955. */
  15956. function isMasked(func) {
  15957. return !!maskSrcKey && (maskSrcKey in func);
  15958. }
  15959. /**
  15960. * Checks if `func` is capable of being masked.
  15961. *
  15962. * @private
  15963. * @param {*} value The value to check.
  15964. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  15965. */
  15966. var isMaskable = coreJsData ? isFunction : stubFalse;
  15967. /**
  15968. * Checks if `value` is likely a prototype object.
  15969. *
  15970. * @private
  15971. * @param {*} value The value to check.
  15972. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  15973. */
  15974. function isPrototype(value) {
  15975. var Ctor = value && value.constructor,
  15976. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  15977. return value === proto;
  15978. }
  15979. /**
  15980. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  15981. *
  15982. * @private
  15983. * @param {*} value The value to check.
  15984. * @returns {boolean} Returns `true` if `value` if suitable for strict
  15985. * equality comparisons, else `false`.
  15986. */
  15987. function isStrictComparable(value) {
  15988. return value === value && !isObject(value);
  15989. }
  15990. /**
  15991. * A specialized version of `matchesProperty` for source values suitable
  15992. * for strict equality comparisons, i.e. `===`.
  15993. *
  15994. * @private
  15995. * @param {string} key The key of the property to get.
  15996. * @param {*} srcValue The value to match.
  15997. * @returns {Function} Returns the new spec function.
  15998. */
  15999. function matchesStrictComparable(key, srcValue) {
  16000. return function(object) {
  16001. if (object == null) {
  16002. return false;
  16003. }
  16004. return object[key] === srcValue &&
  16005. (srcValue !== undefined || (key in Object(object)));
  16006. };
  16007. }
  16008. /**
  16009. * A specialized version of `_.memoize` which clears the memoized function's
  16010. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  16011. *
  16012. * @private
  16013. * @param {Function} func The function to have its output memoized.
  16014. * @returns {Function} Returns the new memoized function.
  16015. */
  16016. function memoizeCapped(func) {
  16017. var result = memoize(func, function(key) {
  16018. if (cache.size === MAX_MEMOIZE_SIZE) {
  16019. cache.clear();
  16020. }
  16021. return key;
  16022. });
  16023. var cache = result.cache;
  16024. return result;
  16025. }
  16026. /**
  16027. * Merges the function metadata of `source` into `data`.
  16028. *
  16029. * Merging metadata reduces the number of wrappers used to invoke a function.
  16030. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  16031. * may be applied regardless of execution order. Methods like `_.ary` and
  16032. * `_.rearg` modify function arguments, making the order in which they are
  16033. * executed important, preventing the merging of metadata. However, we make
  16034. * an exception for a safe combined case where curried functions have `_.ary`
  16035. * and or `_.rearg` applied.
  16036. *
  16037. * @private
  16038. * @param {Array} data The destination metadata.
  16039. * @param {Array} source The source metadata.
  16040. * @returns {Array} Returns `data`.
  16041. */
  16042. function mergeData(data, source) {
  16043. var bitmask = data[1],
  16044. srcBitmask = source[1],
  16045. newBitmask = bitmask | srcBitmask,
  16046. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  16047. var isCombo =
  16048. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  16049. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  16050. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  16051. // Exit early if metadata can't be merged.
  16052. if (!(isCommon || isCombo)) {
  16053. return data;
  16054. }
  16055. // Use source `thisArg` if available.
  16056. if (srcBitmask & WRAP_BIND_FLAG) {
  16057. data[2] = source[2];
  16058. // Set when currying a bound function.
  16059. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  16060. }
  16061. // Compose partial arguments.
  16062. var value = source[3];
  16063. if (value) {
  16064. var partials = data[3];
  16065. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  16066. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  16067. }
  16068. // Compose partial right arguments.
  16069. value = source[5];
  16070. if (value) {
  16071. partials = data[5];
  16072. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  16073. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  16074. }
  16075. // Use source `argPos` if available.
  16076. value = source[7];
  16077. if (value) {
  16078. data[7] = value;
  16079. }
  16080. // Use source `ary` if it's smaller.
  16081. if (srcBitmask & WRAP_ARY_FLAG) {
  16082. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  16083. }
  16084. // Use source `arity` if one is not provided.
  16085. if (data[9] == null) {
  16086. data[9] = source[9];
  16087. }
  16088. // Use source `func` and merge bitmasks.
  16089. data[0] = source[0];
  16090. data[1] = newBitmask;
  16091. return data;
  16092. }
  16093. /**
  16094. * This function is like
  16095. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  16096. * except that it includes inherited enumerable properties.
  16097. *
  16098. * @private
  16099. * @param {Object} object The object to query.
  16100. * @returns {Array} Returns the array of property names.
  16101. */
  16102. function nativeKeysIn(object) {
  16103. var result = [];
  16104. if (object != null) {
  16105. for (var key in Object(object)) {
  16106. result.push(key);
  16107. }
  16108. }
  16109. return result;
  16110. }
  16111. /**
  16112. * Converts `value` to a string using `Object.prototype.toString`.
  16113. *
  16114. * @private
  16115. * @param {*} value The value to convert.
  16116. * @returns {string} Returns the converted string.
  16117. */
  16118. function objectToString(value) {
  16119. return nativeObjectToString.call(value);
  16120. }
  16121. /**
  16122. * A specialized version of `baseRest` which transforms the rest array.
  16123. *
  16124. * @private
  16125. * @param {Function} func The function to apply a rest parameter to.
  16126. * @param {number} [start=func.length-1] The start position of the rest parameter.
  16127. * @param {Function} transform The rest array transform.
  16128. * @returns {Function} Returns the new function.
  16129. */
  16130. function overRest(func, start, transform) {
  16131. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  16132. return function() {
  16133. var args = arguments,
  16134. index = -1,
  16135. length = nativeMax(args.length - start, 0),
  16136. array = Array(length);
  16137. while (++index < length) {
  16138. array[index] = args[start + index];
  16139. }
  16140. index = -1;
  16141. var otherArgs = Array(start + 1);
  16142. while (++index < start) {
  16143. otherArgs[index] = args[index];
  16144. }
  16145. otherArgs[start] = transform(array);
  16146. return apply(func, this, otherArgs);
  16147. };
  16148. }
  16149. /**
  16150. * Gets the parent value at `path` of `object`.
  16151. *
  16152. * @private
  16153. * @param {Object} object The object to query.
  16154. * @param {Array} path The path to get the parent value of.
  16155. * @returns {*} Returns the parent value.
  16156. */
  16157. function parent(object, path) {
  16158. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  16159. }
  16160. /**
  16161. * Reorder `array` according to the specified indexes where the element at
  16162. * the first index is assigned as the first element, the element at
  16163. * the second index is assigned as the second element, and so on.
  16164. *
  16165. * @private
  16166. * @param {Array} array The array to reorder.
  16167. * @param {Array} indexes The arranged array indexes.
  16168. * @returns {Array} Returns `array`.
  16169. */
  16170. function reorder(array, indexes) {
  16171. var arrLength = array.length,
  16172. length = nativeMin(indexes.length, arrLength),
  16173. oldArray = copyArray(array);
  16174. while (length--) {
  16175. var index = indexes[length];
  16176. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  16177. }
  16178. return array;
  16179. }
  16180. /**
  16181. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  16182. *
  16183. * @private
  16184. * @param {Object} object The object to query.
  16185. * @param {string} key The key of the property to get.
  16186. * @returns {*} Returns the property value.
  16187. */
  16188. function safeGet(object, key) {
  16189. if (key === 'constructor' && typeof object[key] === 'function') {
  16190. return;
  16191. }
  16192. if (key == '__proto__') {
  16193. return;
  16194. }
  16195. return object[key];
  16196. }
  16197. /**
  16198. * Sets metadata for `func`.
  16199. *
  16200. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  16201. * period of time, it will trip its breaker and transition to an identity
  16202. * function to avoid garbage collection pauses in V8. See
  16203. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  16204. * for more details.
  16205. *
  16206. * @private
  16207. * @param {Function} func The function to associate metadata with.
  16208. * @param {*} data The metadata.
  16209. * @returns {Function} Returns `func`.
  16210. */
  16211. var setData = shortOut(baseSetData);
  16212. /**
  16213. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  16214. *
  16215. * @private
  16216. * @param {Function} func The function to delay.
  16217. * @param {number} wait The number of milliseconds to delay invocation.
  16218. * @returns {number|Object} Returns the timer id or timeout object.
  16219. */
  16220. var setTimeout = ctxSetTimeout || function(func, wait) {
  16221. return root.setTimeout(func, wait);
  16222. };
  16223. /**
  16224. * Sets the `toString` method of `func` to return `string`.
  16225. *
  16226. * @private
  16227. * @param {Function} func The function to modify.
  16228. * @param {Function} string The `toString` result.
  16229. * @returns {Function} Returns `func`.
  16230. */
  16231. var setToString = shortOut(baseSetToString);
  16232. /**
  16233. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  16234. * with wrapper details in a comment at the top of the source body.
  16235. *
  16236. * @private
  16237. * @param {Function} wrapper The function to modify.
  16238. * @param {Function} reference The reference function.
  16239. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  16240. * @returns {Function} Returns `wrapper`.
  16241. */
  16242. function setWrapToString(wrapper, reference, bitmask) {
  16243. var source = (reference + '');
  16244. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  16245. }
  16246. /**
  16247. * Creates a function that'll short out and invoke `identity` instead
  16248. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  16249. * milliseconds.
  16250. *
  16251. * @private
  16252. * @param {Function} func The function to restrict.
  16253. * @returns {Function} Returns the new shortable function.
  16254. */
  16255. function shortOut(func) {
  16256. var count = 0,
  16257. lastCalled = 0;
  16258. return function() {
  16259. var stamp = nativeNow(),
  16260. remaining = HOT_SPAN - (stamp - lastCalled);
  16261. lastCalled = stamp;
  16262. if (remaining > 0) {
  16263. if (++count >= HOT_COUNT) {
  16264. return arguments[0];
  16265. }
  16266. } else {
  16267. count = 0;
  16268. }
  16269. return func.apply(undefined, arguments);
  16270. };
  16271. }
  16272. /**
  16273. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  16274. *
  16275. * @private
  16276. * @param {Array} array The array to shuffle.
  16277. * @param {number} [size=array.length] The size of `array`.
  16278. * @returns {Array} Returns `array`.
  16279. */
  16280. function shuffleSelf(array, size) {
  16281. var index = -1,
  16282. length = array.length,
  16283. lastIndex = length - 1;
  16284. size = size === undefined ? length : size;
  16285. while (++index < size) {
  16286. var rand = baseRandom(index, lastIndex),
  16287. value = array[rand];
  16288. array[rand] = array[index];
  16289. array[index] = value;
  16290. }
  16291. array.length = size;
  16292. return array;
  16293. }
  16294. /**
  16295. * Converts `string` to a property path array.
  16296. *
  16297. * @private
  16298. * @param {string} string The string to convert.
  16299. * @returns {Array} Returns the property path array.
  16300. */
  16301. var stringToPath = memoizeCapped(function(string) {
  16302. var result = [];
  16303. if (string.charCodeAt(0) === 46 /* . */) {
  16304. result.push('');
  16305. }
  16306. string.replace(rePropName, function(match, number, quote, subString) {
  16307. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  16308. });
  16309. return result;
  16310. });
  16311. /**
  16312. * Converts `value` to a string key if it's not a string or symbol.
  16313. *
  16314. * @private
  16315. * @param {*} value The value to inspect.
  16316. * @returns {string|symbol} Returns the key.
  16317. */
  16318. function toKey(value) {
  16319. if (typeof value == 'string' || isSymbol(value)) {
  16320. return value;
  16321. }
  16322. var result = (value + '');
  16323. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  16324. }
  16325. /**
  16326. * Converts `func` to its source code.
  16327. *
  16328. * @private
  16329. * @param {Function} func The function to convert.
  16330. * @returns {string} Returns the source code.
  16331. */
  16332. function toSource(func) {
  16333. if (func != null) {
  16334. try {
  16335. return funcToString.call(func);
  16336. } catch (e) {}
  16337. try {
  16338. return (func + '');
  16339. } catch (e) {}
  16340. }
  16341. return '';
  16342. }
  16343. /**
  16344. * Updates wrapper `details` based on `bitmask` flags.
  16345. *
  16346. * @private
  16347. * @returns {Array} details The details to modify.
  16348. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  16349. * @returns {Array} Returns `details`.
  16350. */
  16351. function updateWrapDetails(details, bitmask) {
  16352. arrayEach(wrapFlags, function(pair) {
  16353. var value = '_.' + pair[0];
  16354. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  16355. details.push(value);
  16356. }
  16357. });
  16358. return details.sort();
  16359. }
  16360. /**
  16361. * Creates a clone of `wrapper`.
  16362. *
  16363. * @private
  16364. * @param {Object} wrapper The wrapper to clone.
  16365. * @returns {Object} Returns the cloned wrapper.
  16366. */
  16367. function wrapperClone(wrapper) {
  16368. if (wrapper instanceof LazyWrapper) {
  16369. return wrapper.clone();
  16370. }
  16371. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  16372. result.__actions__ = copyArray(wrapper.__actions__);
  16373. result.__index__ = wrapper.__index__;
  16374. result.__values__ = wrapper.__values__;
  16375. return result;
  16376. }
  16377. /*------------------------------------------------------------------------*/
  16378. /**
  16379. * Creates an array of elements split into groups the length of `size`.
  16380. * If `array` can't be split evenly, the final chunk will be the remaining
  16381. * elements.
  16382. *
  16383. * @static
  16384. * @memberOf _
  16385. * @since 3.0.0
  16386. * @category Array
  16387. * @param {Array} array The array to process.
  16388. * @param {number} [size=1] The length of each chunk
  16389. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  16390. * @returns {Array} Returns the new array of chunks.
  16391. * @example
  16392. *
  16393. * _.chunk(['a', 'b', 'c', 'd'], 2);
  16394. * // => [['a', 'b'], ['c', 'd']]
  16395. *
  16396. * _.chunk(['a', 'b', 'c', 'd'], 3);
  16397. * // => [['a', 'b', 'c'], ['d']]
  16398. */
  16399. function chunk(array, size, guard) {
  16400. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  16401. size = 1;
  16402. } else {
  16403. size = nativeMax(toInteger(size), 0);
  16404. }
  16405. var length = array == null ? 0 : array.length;
  16406. if (!length || size < 1) {
  16407. return [];
  16408. }
  16409. var index = 0,
  16410. resIndex = 0,
  16411. result = Array(nativeCeil(length / size));
  16412. while (index < length) {
  16413. result[resIndex++] = baseSlice(array, index, (index += size));
  16414. }
  16415. return result;
  16416. }
  16417. /**
  16418. * Creates an array with all falsey values removed. The values `false`, `null`,
  16419. * `0`, `""`, `undefined`, and `NaN` are falsey.
  16420. *
  16421. * @static
  16422. * @memberOf _
  16423. * @since 0.1.0
  16424. * @category Array
  16425. * @param {Array} array The array to compact.
  16426. * @returns {Array} Returns the new array of filtered values.
  16427. * @example
  16428. *
  16429. * _.compact([0, 1, false, 2, '', 3]);
  16430. * // => [1, 2, 3]
  16431. */
  16432. function compact(array) {
  16433. var index = -1,
  16434. length = array == null ? 0 : array.length,
  16435. resIndex = 0,
  16436. result = [];
  16437. while (++index < length) {
  16438. var value = array[index];
  16439. if (value) {
  16440. result[resIndex++] = value;
  16441. }
  16442. }
  16443. return result;
  16444. }
  16445. /**
  16446. * Creates a new array concatenating `array` with any additional arrays
  16447. * and/or values.
  16448. *
  16449. * @static
  16450. * @memberOf _
  16451. * @since 4.0.0
  16452. * @category Array
  16453. * @param {Array} array The array to concatenate.
  16454. * @param {...*} [values] The values to concatenate.
  16455. * @returns {Array} Returns the new concatenated array.
  16456. * @example
  16457. *
  16458. * var array = [1];
  16459. * var other = _.concat(array, 2, [3], [[4]]);
  16460. *
  16461. * console.log(other);
  16462. * // => [1, 2, 3, [4]]
  16463. *
  16464. * console.log(array);
  16465. * // => [1]
  16466. */
  16467. function concat() {
  16468. var length = arguments.length;
  16469. if (!length) {
  16470. return [];
  16471. }
  16472. var args = Array(length - 1),
  16473. array = arguments[0],
  16474. index = length;
  16475. while (index--) {
  16476. args[index - 1] = arguments[index];
  16477. }
  16478. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  16479. }
  16480. /**
  16481. * Creates an array of `array` values not included in the other given arrays
  16482. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  16483. * for equality comparisons. The order and references of result values are
  16484. * determined by the first array.
  16485. *
  16486. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  16487. *
  16488. * @static
  16489. * @memberOf _
  16490. * @since 0.1.0
  16491. * @category Array
  16492. * @param {Array} array The array to inspect.
  16493. * @param {...Array} [values] The values to exclude.
  16494. * @returns {Array} Returns the new array of filtered values.
  16495. * @see _.without, _.xor
  16496. * @example
  16497. *
  16498. * _.difference([2, 1], [2, 3]);
  16499. * // => [1]
  16500. */
  16501. var difference = baseRest(function(array, values) {
  16502. return isArrayLikeObject(array)
  16503. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  16504. : [];
  16505. });
  16506. /**
  16507. * This method is like `_.difference` except that it accepts `iteratee` which
  16508. * is invoked for each element of `array` and `values` to generate the criterion
  16509. * by which they're compared. The order and references of result values are
  16510. * determined by the first array. The iteratee is invoked with one argument:
  16511. * (value).
  16512. *
  16513. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  16514. *
  16515. * @static
  16516. * @memberOf _
  16517. * @since 4.0.0
  16518. * @category Array
  16519. * @param {Array} array The array to inspect.
  16520. * @param {...Array} [values] The values to exclude.
  16521. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  16522. * @returns {Array} Returns the new array of filtered values.
  16523. * @example
  16524. *
  16525. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  16526. * // => [1.2]
  16527. *
  16528. * // The `_.property` iteratee shorthand.
  16529. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  16530. * // => [{ 'x': 2 }]
  16531. */
  16532. var differenceBy = baseRest(function(array, values) {
  16533. var iteratee = last(values);
  16534. if (isArrayLikeObject(iteratee)) {
  16535. iteratee = undefined;
  16536. }
  16537. return isArrayLikeObject(array)
  16538. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  16539. : [];
  16540. });
  16541. /**
  16542. * This method is like `_.difference` except that it accepts `comparator`
  16543. * which is invoked to compare elements of `array` to `values`. The order and
  16544. * references of result values are determined by the first array. The comparator
  16545. * is invoked with two arguments: (arrVal, othVal).
  16546. *
  16547. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  16548. *
  16549. * @static
  16550. * @memberOf _
  16551. * @since 4.0.0
  16552. * @category Array
  16553. * @param {Array} array The array to inspect.
  16554. * @param {...Array} [values] The values to exclude.
  16555. * @param {Function} [comparator] The comparator invoked per element.
  16556. * @returns {Array} Returns the new array of filtered values.
  16557. * @example
  16558. *
  16559. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  16560. *
  16561. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  16562. * // => [{ 'x': 2, 'y': 1 }]
  16563. */
  16564. var differenceWith = baseRest(function(array, values) {
  16565. var comparator = last(values);
  16566. if (isArrayLikeObject(comparator)) {
  16567. comparator = undefined;
  16568. }
  16569. return isArrayLikeObject(array)
  16570. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  16571. : [];
  16572. });
  16573. /**
  16574. * Creates a slice of `array` with `n` elements dropped from the beginning.
  16575. *
  16576. * @static
  16577. * @memberOf _
  16578. * @since 0.5.0
  16579. * @category Array
  16580. * @param {Array} array The array to query.
  16581. * @param {number} [n=1] The number of elements to drop.
  16582. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  16583. * @returns {Array} Returns the slice of `array`.
  16584. * @example
  16585. *
  16586. * _.drop([1, 2, 3]);
  16587. * // => [2, 3]
  16588. *
  16589. * _.drop([1, 2, 3], 2);
  16590. * // => [3]
  16591. *
  16592. * _.drop([1, 2, 3], 5);
  16593. * // => []
  16594. *
  16595. * _.drop([1, 2, 3], 0);
  16596. * // => [1, 2, 3]
  16597. */
  16598. function drop(array, n, guard) {
  16599. var length = array == null ? 0 : array.length;
  16600. if (!length) {
  16601. return [];
  16602. }
  16603. n = (guard || n === undefined) ? 1 : toInteger(n);
  16604. return baseSlice(array, n < 0 ? 0 : n, length);
  16605. }
  16606. /**
  16607. * Creates a slice of `array` with `n` elements dropped from the end.
  16608. *
  16609. * @static
  16610. * @memberOf _
  16611. * @since 3.0.0
  16612. * @category Array
  16613. * @param {Array} array The array to query.
  16614. * @param {number} [n=1] The number of elements to drop.
  16615. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  16616. * @returns {Array} Returns the slice of `array`.
  16617. * @example
  16618. *
  16619. * _.dropRight([1, 2, 3]);
  16620. * // => [1, 2]
  16621. *
  16622. * _.dropRight([1, 2, 3], 2);
  16623. * // => [1]
  16624. *
  16625. * _.dropRight([1, 2, 3], 5);
  16626. * // => []
  16627. *
  16628. * _.dropRight([1, 2, 3], 0);
  16629. * // => [1, 2, 3]
  16630. */
  16631. function dropRight(array, n, guard) {
  16632. var length = array == null ? 0 : array.length;
  16633. if (!length) {
  16634. return [];
  16635. }
  16636. n = (guard || n === undefined) ? 1 : toInteger(n);
  16637. n = length - n;
  16638. return baseSlice(array, 0, n < 0 ? 0 : n);
  16639. }
  16640. /**
  16641. * Creates a slice of `array` excluding elements dropped from the end.
  16642. * Elements are dropped until `predicate` returns falsey. The predicate is
  16643. * invoked with three arguments: (value, index, array).
  16644. *
  16645. * @static
  16646. * @memberOf _
  16647. * @since 3.0.0
  16648. * @category Array
  16649. * @param {Array} array The array to query.
  16650. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  16651. * @returns {Array} Returns the slice of `array`.
  16652. * @example
  16653. *
  16654. * var users = [
  16655. * { 'user': 'barney', 'active': true },
  16656. * { 'user': 'fred', 'active': false },
  16657. * { 'user': 'pebbles', 'active': false }
  16658. * ];
  16659. *
  16660. * _.dropRightWhile(users, function(o) { return !o.active; });
  16661. * // => objects for ['barney']
  16662. *
  16663. * // The `_.matches` iteratee shorthand.
  16664. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  16665. * // => objects for ['barney', 'fred']
  16666. *
  16667. * // The `_.matchesProperty` iteratee shorthand.
  16668. * _.dropRightWhile(users, ['active', false]);
  16669. * // => objects for ['barney']
  16670. *
  16671. * // The `_.property` iteratee shorthand.
  16672. * _.dropRightWhile(users, 'active');
  16673. * // => objects for ['barney', 'fred', 'pebbles']
  16674. */
  16675. function dropRightWhile(array, predicate) {
  16676. return (array && array.length)
  16677. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  16678. : [];
  16679. }
  16680. /**
  16681. * Creates a slice of `array` excluding elements dropped from the beginning.
  16682. * Elements are dropped until `predicate` returns falsey. The predicate is
  16683. * invoked with three arguments: (value, index, array).
  16684. *
  16685. * @static
  16686. * @memberOf _
  16687. * @since 3.0.0
  16688. * @category Array
  16689. * @param {Array} array The array to query.
  16690. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  16691. * @returns {Array} Returns the slice of `array`.
  16692. * @example
  16693. *
  16694. * var users = [
  16695. * { 'user': 'barney', 'active': false },
  16696. * { 'user': 'fred', 'active': false },
  16697. * { 'user': 'pebbles', 'active': true }
  16698. * ];
  16699. *
  16700. * _.dropWhile(users, function(o) { return !o.active; });
  16701. * // => objects for ['pebbles']
  16702. *
  16703. * // The `_.matches` iteratee shorthand.
  16704. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  16705. * // => objects for ['fred', 'pebbles']
  16706. *
  16707. * // The `_.matchesProperty` iteratee shorthand.
  16708. * _.dropWhile(users, ['active', false]);
  16709. * // => objects for ['pebbles']
  16710. *
  16711. * // The `_.property` iteratee shorthand.
  16712. * _.dropWhile(users, 'active');
  16713. * // => objects for ['barney', 'fred', 'pebbles']
  16714. */
  16715. function dropWhile(array, predicate) {
  16716. return (array && array.length)
  16717. ? baseWhile(array, getIteratee(predicate, 3), true)
  16718. : [];
  16719. }
  16720. /**
  16721. * Fills elements of `array` with `value` from `start` up to, but not
  16722. * including, `end`.
  16723. *
  16724. * **Note:** This method mutates `array`.
  16725. *
  16726. * @static
  16727. * @memberOf _
  16728. * @since 3.2.0
  16729. * @category Array
  16730. * @param {Array} array The array to fill.
  16731. * @param {*} value The value to fill `array` with.
  16732. * @param {number} [start=0] The start position.
  16733. * @param {number} [end=array.length] The end position.
  16734. * @returns {Array} Returns `array`.
  16735. * @example
  16736. *
  16737. * var array = [1, 2, 3];
  16738. *
  16739. * _.fill(array, 'a');
  16740. * console.log(array);
  16741. * // => ['a', 'a', 'a']
  16742. *
  16743. * _.fill(Array(3), 2);
  16744. * // => [2, 2, 2]
  16745. *
  16746. * _.fill([4, 6, 8, 10], '*', 1, 3);
  16747. * // => [4, '*', '*', 10]
  16748. */
  16749. function fill(array, value, start, end) {
  16750. var length = array == null ? 0 : array.length;
  16751. if (!length) {
  16752. return [];
  16753. }
  16754. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  16755. start = 0;
  16756. end = length;
  16757. }
  16758. return baseFill(array, value, start, end);
  16759. }
  16760. /**
  16761. * This method is like `_.find` except that it returns the index of the first
  16762. * element `predicate` returns truthy for instead of the element itself.
  16763. *
  16764. * @static
  16765. * @memberOf _
  16766. * @since 1.1.0
  16767. * @category Array
  16768. * @param {Array} array The array to inspect.
  16769. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  16770. * @param {number} [fromIndex=0] The index to search from.
  16771. * @returns {number} Returns the index of the found element, else `-1`.
  16772. * @example
  16773. *
  16774. * var users = [
  16775. * { 'user': 'barney', 'active': false },
  16776. * { 'user': 'fred', 'active': false },
  16777. * { 'user': 'pebbles', 'active': true }
  16778. * ];
  16779. *
  16780. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  16781. * // => 0
  16782. *
  16783. * // The `_.matches` iteratee shorthand.
  16784. * _.findIndex(users, { 'user': 'fred', 'active': false });
  16785. * // => 1
  16786. *
  16787. * // The `_.matchesProperty` iteratee shorthand.
  16788. * _.findIndex(users, ['active', false]);
  16789. * // => 0
  16790. *
  16791. * // The `_.property` iteratee shorthand.
  16792. * _.findIndex(users, 'active');
  16793. * // => 2
  16794. */
  16795. function findIndex(array, predicate, fromIndex) {
  16796. var length = array == null ? 0 : array.length;
  16797. if (!length) {
  16798. return -1;
  16799. }
  16800. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  16801. if (index < 0) {
  16802. index = nativeMax(length + index, 0);
  16803. }
  16804. return baseFindIndex(array, getIteratee(predicate, 3), index);
  16805. }
  16806. /**
  16807. * This method is like `_.findIndex` except that it iterates over elements
  16808. * of `collection` from right to left.
  16809. *
  16810. * @static
  16811. * @memberOf _
  16812. * @since 2.0.0
  16813. * @category Array
  16814. * @param {Array} array The array to inspect.
  16815. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  16816. * @param {number} [fromIndex=array.length-1] The index to search from.
  16817. * @returns {number} Returns the index of the found element, else `-1`.
  16818. * @example
  16819. *
  16820. * var users = [
  16821. * { 'user': 'barney', 'active': true },
  16822. * { 'user': 'fred', 'active': false },
  16823. * { 'user': 'pebbles', 'active': false }
  16824. * ];
  16825. *
  16826. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  16827. * // => 2
  16828. *
  16829. * // The `_.matches` iteratee shorthand.
  16830. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  16831. * // => 0
  16832. *
  16833. * // The `_.matchesProperty` iteratee shorthand.
  16834. * _.findLastIndex(users, ['active', false]);
  16835. * // => 2
  16836. *
  16837. * // The `_.property` iteratee shorthand.
  16838. * _.findLastIndex(users, 'active');
  16839. * // => 0
  16840. */
  16841. function findLastIndex(array, predicate, fromIndex) {
  16842. var length = array == null ? 0 : array.length;
  16843. if (!length) {
  16844. return -1;
  16845. }
  16846. var index = length - 1;
  16847. if (fromIndex !== undefined) {
  16848. index = toInteger(fromIndex);
  16849. index = fromIndex < 0
  16850. ? nativeMax(length + index, 0)
  16851. : nativeMin(index, length - 1);
  16852. }
  16853. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  16854. }
  16855. /**
  16856. * Flattens `array` a single level deep.
  16857. *
  16858. * @static
  16859. * @memberOf _
  16860. * @since 0.1.0
  16861. * @category Array
  16862. * @param {Array} array The array to flatten.
  16863. * @returns {Array} Returns the new flattened array.
  16864. * @example
  16865. *
  16866. * _.flatten([1, [2, [3, [4]], 5]]);
  16867. * // => [1, 2, [3, [4]], 5]
  16868. */
  16869. function flatten(array) {
  16870. var length = array == null ? 0 : array.length;
  16871. return length ? baseFlatten(array, 1) : [];
  16872. }
  16873. /**
  16874. * Recursively flattens `array`.
  16875. *
  16876. * @static
  16877. * @memberOf _
  16878. * @since 3.0.0
  16879. * @category Array
  16880. * @param {Array} array The array to flatten.
  16881. * @returns {Array} Returns the new flattened array.
  16882. * @example
  16883. *
  16884. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  16885. * // => [1, 2, 3, 4, 5]
  16886. */
  16887. function flattenDeep(array) {
  16888. var length = array == null ? 0 : array.length;
  16889. return length ? baseFlatten(array, INFINITY) : [];
  16890. }
  16891. /**
  16892. * Recursively flatten `array` up to `depth` times.
  16893. *
  16894. * @static
  16895. * @memberOf _
  16896. * @since 4.4.0
  16897. * @category Array
  16898. * @param {Array} array The array to flatten.
  16899. * @param {number} [depth=1] The maximum recursion depth.
  16900. * @returns {Array} Returns the new flattened array.
  16901. * @example
  16902. *
  16903. * var array = [1, [2, [3, [4]], 5]];
  16904. *
  16905. * _.flattenDepth(array, 1);
  16906. * // => [1, 2, [3, [4]], 5]
  16907. *
  16908. * _.flattenDepth(array, 2);
  16909. * // => [1, 2, 3, [4], 5]
  16910. */
  16911. function flattenDepth(array, depth) {
  16912. var length = array == null ? 0 : array.length;
  16913. if (!length) {
  16914. return [];
  16915. }
  16916. depth = depth === undefined ? 1 : toInteger(depth);
  16917. return baseFlatten(array, depth);
  16918. }
  16919. /**
  16920. * The inverse of `_.toPairs`; this method returns an object composed
  16921. * from key-value `pairs`.
  16922. *
  16923. * @static
  16924. * @memberOf _
  16925. * @since 4.0.0
  16926. * @category Array
  16927. * @param {Array} pairs The key-value pairs.
  16928. * @returns {Object} Returns the new object.
  16929. * @example
  16930. *
  16931. * _.fromPairs([['a', 1], ['b', 2]]);
  16932. * // => { 'a': 1, 'b': 2 }
  16933. */
  16934. function fromPairs(pairs) {
  16935. var index = -1,
  16936. length = pairs == null ? 0 : pairs.length,
  16937. result = {};
  16938. while (++index < length) {
  16939. var pair = pairs[index];
  16940. result[pair[0]] = pair[1];
  16941. }
  16942. return result;
  16943. }
  16944. /**
  16945. * Gets the first element of `array`.
  16946. *
  16947. * @static
  16948. * @memberOf _
  16949. * @since 0.1.0
  16950. * @alias first
  16951. * @category Array
  16952. * @param {Array} array The array to query.
  16953. * @returns {*} Returns the first element of `array`.
  16954. * @example
  16955. *
  16956. * _.head([1, 2, 3]);
  16957. * // => 1
  16958. *
  16959. * _.head([]);
  16960. * // => undefined
  16961. */
  16962. function head(array) {
  16963. return (array && array.length) ? array[0] : undefined;
  16964. }
  16965. /**
  16966. * Gets the index at which the first occurrence of `value` is found in `array`
  16967. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  16968. * for equality comparisons. If `fromIndex` is negative, it's used as the
  16969. * offset from the end of `array`.
  16970. *
  16971. * @static
  16972. * @memberOf _
  16973. * @since 0.1.0
  16974. * @category Array
  16975. * @param {Array} array The array to inspect.
  16976. * @param {*} value The value to search for.
  16977. * @param {number} [fromIndex=0] The index to search from.
  16978. * @returns {number} Returns the index of the matched value, else `-1`.
  16979. * @example
  16980. *
  16981. * _.indexOf([1, 2, 1, 2], 2);
  16982. * // => 1
  16983. *
  16984. * // Search from the `fromIndex`.
  16985. * _.indexOf([1, 2, 1, 2], 2, 2);
  16986. * // => 3
  16987. */
  16988. function indexOf(array, value, fromIndex) {
  16989. var length = array == null ? 0 : array.length;
  16990. if (!length) {
  16991. return -1;
  16992. }
  16993. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  16994. if (index < 0) {
  16995. index = nativeMax(length + index, 0);
  16996. }
  16997. return baseIndexOf(array, value, index);
  16998. }
  16999. /**
  17000. * Gets all but the last element of `array`.
  17001. *
  17002. * @static
  17003. * @memberOf _
  17004. * @since 0.1.0
  17005. * @category Array
  17006. * @param {Array} array The array to query.
  17007. * @returns {Array} Returns the slice of `array`.
  17008. * @example
  17009. *
  17010. * _.initial([1, 2, 3]);
  17011. * // => [1, 2]
  17012. */
  17013. function initial(array) {
  17014. var length = array == null ? 0 : array.length;
  17015. return length ? baseSlice(array, 0, -1) : [];
  17016. }
  17017. /**
  17018. * Creates an array of unique values that are included in all given arrays
  17019. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  17020. * for equality comparisons. The order and references of result values are
  17021. * determined by the first array.
  17022. *
  17023. * @static
  17024. * @memberOf _
  17025. * @since 0.1.0
  17026. * @category Array
  17027. * @param {...Array} [arrays] The arrays to inspect.
  17028. * @returns {Array} Returns the new array of intersecting values.
  17029. * @example
  17030. *
  17031. * _.intersection([2, 1], [2, 3]);
  17032. * // => [2]
  17033. */
  17034. var intersection = baseRest(function(arrays) {
  17035. var mapped = arrayMap(arrays, castArrayLikeObject);
  17036. return (mapped.length && mapped[0] === arrays[0])
  17037. ? baseIntersection(mapped)
  17038. : [];
  17039. });
  17040. /**
  17041. * This method is like `_.intersection` except that it accepts `iteratee`
  17042. * which is invoked for each element of each `arrays` to generate the criterion
  17043. * by which they're compared. The order and references of result values are
  17044. * determined by the first array. The iteratee is invoked with one argument:
  17045. * (value).
  17046. *
  17047. * @static
  17048. * @memberOf _
  17049. * @since 4.0.0
  17050. * @category Array
  17051. * @param {...Array} [arrays] The arrays to inspect.
  17052. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  17053. * @returns {Array} Returns the new array of intersecting values.
  17054. * @example
  17055. *
  17056. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  17057. * // => [2.1]
  17058. *
  17059. * // The `_.property` iteratee shorthand.
  17060. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  17061. * // => [{ 'x': 1 }]
  17062. */
  17063. var intersectionBy = baseRest(function(arrays) {
  17064. var iteratee = last(arrays),
  17065. mapped = arrayMap(arrays, castArrayLikeObject);
  17066. if (iteratee === last(mapped)) {
  17067. iteratee = undefined;
  17068. } else {
  17069. mapped.pop();
  17070. }
  17071. return (mapped.length && mapped[0] === arrays[0])
  17072. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  17073. : [];
  17074. });
  17075. /**
  17076. * This method is like `_.intersection` except that it accepts `comparator`
  17077. * which is invoked to compare elements of `arrays`. The order and references
  17078. * of result values are determined by the first array. The comparator is
  17079. * invoked with two arguments: (arrVal, othVal).
  17080. *
  17081. * @static
  17082. * @memberOf _
  17083. * @since 4.0.0
  17084. * @category Array
  17085. * @param {...Array} [arrays] The arrays to inspect.
  17086. * @param {Function} [comparator] The comparator invoked per element.
  17087. * @returns {Array} Returns the new array of intersecting values.
  17088. * @example
  17089. *
  17090. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  17091. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  17092. *
  17093. * _.intersectionWith(objects, others, _.isEqual);
  17094. * // => [{ 'x': 1, 'y': 2 }]
  17095. */
  17096. var intersectionWith = baseRest(function(arrays) {
  17097. var comparator = last(arrays),
  17098. mapped = arrayMap(arrays, castArrayLikeObject);
  17099. comparator = typeof comparator == 'function' ? comparator : undefined;
  17100. if (comparator) {
  17101. mapped.pop();
  17102. }
  17103. return (mapped.length && mapped[0] === arrays[0])
  17104. ? baseIntersection(mapped, undefined, comparator)
  17105. : [];
  17106. });
  17107. /**
  17108. * Converts all elements in `array` into a string separated by `separator`.
  17109. *
  17110. * @static
  17111. * @memberOf _
  17112. * @since 4.0.0
  17113. * @category Array
  17114. * @param {Array} array The array to convert.
  17115. * @param {string} [separator=','] The element separator.
  17116. * @returns {string} Returns the joined string.
  17117. * @example
  17118. *
  17119. * _.join(['a', 'b', 'c'], '~');
  17120. * // => 'a~b~c'
  17121. */
  17122. function join(array, separator) {
  17123. return array == null ? '' : nativeJoin.call(array, separator);
  17124. }
  17125. /**
  17126. * Gets the last element of `array`.
  17127. *
  17128. * @static
  17129. * @memberOf _
  17130. * @since 0.1.0
  17131. * @category Array
  17132. * @param {Array} array The array to query.
  17133. * @returns {*} Returns the last element of `array`.
  17134. * @example
  17135. *
  17136. * _.last([1, 2, 3]);
  17137. * // => 3
  17138. */
  17139. function last(array) {
  17140. var length = array == null ? 0 : array.length;
  17141. return length ? array[length - 1] : undefined;
  17142. }
  17143. /**
  17144. * This method is like `_.indexOf` except that it iterates over elements of
  17145. * `array` from right to left.
  17146. *
  17147. * @static
  17148. * @memberOf _
  17149. * @since 0.1.0
  17150. * @category Array
  17151. * @param {Array} array The array to inspect.
  17152. * @param {*} value The value to search for.
  17153. * @param {number} [fromIndex=array.length-1] The index to search from.
  17154. * @returns {number} Returns the index of the matched value, else `-1`.
  17155. * @example
  17156. *
  17157. * _.lastIndexOf([1, 2, 1, 2], 2);
  17158. * // => 3
  17159. *
  17160. * // Search from the `fromIndex`.
  17161. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  17162. * // => 1
  17163. */
  17164. function lastIndexOf(array, value, fromIndex) {
  17165. var length = array == null ? 0 : array.length;
  17166. if (!length) {
  17167. return -1;
  17168. }
  17169. var index = length;
  17170. if (fromIndex !== undefined) {
  17171. index = toInteger(fromIndex);
  17172. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  17173. }
  17174. return value === value
  17175. ? strictLastIndexOf(array, value, index)
  17176. : baseFindIndex(array, baseIsNaN, index, true);
  17177. }
  17178. /**
  17179. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  17180. * element from the end is returned.
  17181. *
  17182. * @static
  17183. * @memberOf _
  17184. * @since 4.11.0
  17185. * @category Array
  17186. * @param {Array} array The array to query.
  17187. * @param {number} [n=0] The index of the element to return.
  17188. * @returns {*} Returns the nth element of `array`.
  17189. * @example
  17190. *
  17191. * var array = ['a', 'b', 'c', 'd'];
  17192. *
  17193. * _.nth(array, 1);
  17194. * // => 'b'
  17195. *
  17196. * _.nth(array, -2);
  17197. * // => 'c';
  17198. */
  17199. function nth(array, n) {
  17200. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  17201. }
  17202. /**
  17203. * Removes all given values from `array` using
  17204. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  17205. * for equality comparisons.
  17206. *
  17207. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  17208. * to remove elements from an array by predicate.
  17209. *
  17210. * @static
  17211. * @memberOf _
  17212. * @since 2.0.0
  17213. * @category Array
  17214. * @param {Array} array The array to modify.
  17215. * @param {...*} [values] The values to remove.
  17216. * @returns {Array} Returns `array`.
  17217. * @example
  17218. *
  17219. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  17220. *
  17221. * _.pull(array, 'a', 'c');
  17222. * console.log(array);
  17223. * // => ['b', 'b']
  17224. */
  17225. var pull = baseRest(pullAll);
  17226. /**
  17227. * This method is like `_.pull` except that it accepts an array of values to remove.
  17228. *
  17229. * **Note:** Unlike `_.difference`, this method mutates `array`.
  17230. *
  17231. * @static
  17232. * @memberOf _
  17233. * @since 4.0.0
  17234. * @category Array
  17235. * @param {Array} array The array to modify.
  17236. * @param {Array} values The values to remove.
  17237. * @returns {Array} Returns `array`.
  17238. * @example
  17239. *
  17240. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  17241. *
  17242. * _.pullAll(array, ['a', 'c']);
  17243. * console.log(array);
  17244. * // => ['b', 'b']
  17245. */
  17246. function pullAll(array, values) {
  17247. return (array && array.length && values && values.length)
  17248. ? basePullAll(array, values)
  17249. : array;
  17250. }
  17251. /**
  17252. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  17253. * invoked for each element of `array` and `values` to generate the criterion
  17254. * by which they're compared. The iteratee is invoked with one argument: (value).
  17255. *
  17256. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  17257. *
  17258. * @static
  17259. * @memberOf _
  17260. * @since 4.0.0
  17261. * @category Array
  17262. * @param {Array} array The array to modify.
  17263. * @param {Array} values The values to remove.
  17264. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  17265. * @returns {Array} Returns `array`.
  17266. * @example
  17267. *
  17268. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  17269. *
  17270. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  17271. * console.log(array);
  17272. * // => [{ 'x': 2 }]
  17273. */
  17274. function pullAllBy(array, values, iteratee) {
  17275. return (array && array.length && values && values.length)
  17276. ? basePullAll(array, values, getIteratee(iteratee, 2))
  17277. : array;
  17278. }
  17279. /**
  17280. * This method is like `_.pullAll` except that it accepts `comparator` which
  17281. * is invoked to compare elements of `array` to `values`. The comparator is
  17282. * invoked with two arguments: (arrVal, othVal).
  17283. *
  17284. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  17285. *
  17286. * @static
  17287. * @memberOf _
  17288. * @since 4.6.0
  17289. * @category Array
  17290. * @param {Array} array The array to modify.
  17291. * @param {Array} values The values to remove.
  17292. * @param {Function} [comparator] The comparator invoked per element.
  17293. * @returns {Array} Returns `array`.
  17294. * @example
  17295. *
  17296. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  17297. *
  17298. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  17299. * console.log(array);
  17300. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  17301. */
  17302. function pullAllWith(array, values, comparator) {
  17303. return (array && array.length && values && values.length)
  17304. ? basePullAll(array, values, undefined, comparator)
  17305. : array;
  17306. }
  17307. /**
  17308. * Removes elements from `array` corresponding to `indexes` and returns an
  17309. * array of removed elements.
  17310. *
  17311. * **Note:** Unlike `_.at`, this method mutates `array`.
  17312. *
  17313. * @static
  17314. * @memberOf _
  17315. * @since 3.0.0
  17316. * @category Array
  17317. * @param {Array} array The array to modify.
  17318. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  17319. * @returns {Array} Returns the new array of removed elements.
  17320. * @example
  17321. *
  17322. * var array = ['a', 'b', 'c', 'd'];
  17323. * var pulled = _.pullAt(array, [1, 3]);
  17324. *
  17325. * console.log(array);
  17326. * // => ['a', 'c']
  17327. *
  17328. * console.log(pulled);
  17329. * // => ['b', 'd']
  17330. */
  17331. var pullAt = flatRest(function(array, indexes) {
  17332. var length = array == null ? 0 : array.length,
  17333. result = baseAt(array, indexes);
  17334. basePullAt(array, arrayMap(indexes, function(index) {
  17335. return isIndex(index, length) ? +index : index;
  17336. }).sort(compareAscending));
  17337. return result;
  17338. });
  17339. /**
  17340. * Removes all elements from `array` that `predicate` returns truthy for
  17341. * and returns an array of the removed elements. The predicate is invoked
  17342. * with three arguments: (value, index, array).
  17343. *
  17344. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  17345. * to pull elements from an array by value.
  17346. *
  17347. * @static
  17348. * @memberOf _
  17349. * @since 2.0.0
  17350. * @category Array
  17351. * @param {Array} array The array to modify.
  17352. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  17353. * @returns {Array} Returns the new array of removed elements.
  17354. * @example
  17355. *
  17356. * var array = [1, 2, 3, 4];
  17357. * var evens = _.remove(array, function(n) {
  17358. * return n % 2 == 0;
  17359. * });
  17360. *
  17361. * console.log(array);
  17362. * // => [1, 3]
  17363. *
  17364. * console.log(evens);
  17365. * // => [2, 4]
  17366. */
  17367. function remove(array, predicate) {
  17368. var result = [];
  17369. if (!(array && array.length)) {
  17370. return result;
  17371. }
  17372. var index = -1,
  17373. indexes = [],
  17374. length = array.length;
  17375. predicate = getIteratee(predicate, 3);
  17376. while (++index < length) {
  17377. var value = array[index];
  17378. if (predicate(value, index, array)) {
  17379. result.push(value);
  17380. indexes.push(index);
  17381. }
  17382. }
  17383. basePullAt(array, indexes);
  17384. return result;
  17385. }
  17386. /**
  17387. * Reverses `array` so that the first element becomes the last, the second
  17388. * element becomes the second to last, and so on.
  17389. *
  17390. * **Note:** This method mutates `array` and is based on
  17391. * [`Array#reverse`](https://mdn.io/Array/reverse).
  17392. *
  17393. * @static
  17394. * @memberOf _
  17395. * @since 4.0.0
  17396. * @category Array
  17397. * @param {Array} array The array to modify.
  17398. * @returns {Array} Returns `array`.
  17399. * @example
  17400. *
  17401. * var array = [1, 2, 3];
  17402. *
  17403. * _.reverse(array);
  17404. * // => [3, 2, 1]
  17405. *
  17406. * console.log(array);
  17407. * // => [3, 2, 1]
  17408. */
  17409. function reverse(array) {
  17410. return array == null ? array : nativeReverse.call(array);
  17411. }
  17412. /**
  17413. * Creates a slice of `array` from `start` up to, but not including, `end`.
  17414. *
  17415. * **Note:** This method is used instead of
  17416. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  17417. * returned.
  17418. *
  17419. * @static
  17420. * @memberOf _
  17421. * @since 3.0.0
  17422. * @category Array
  17423. * @param {Array} array The array to slice.
  17424. * @param {number} [start=0] The start position.
  17425. * @param {number} [end=array.length] The end position.
  17426. * @returns {Array} Returns the slice of `array`.
  17427. */
  17428. function slice(array, start, end) {
  17429. var length = array == null ? 0 : array.length;
  17430. if (!length) {
  17431. return [];
  17432. }
  17433. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  17434. start = 0;
  17435. end = length;
  17436. }
  17437. else {
  17438. start = start == null ? 0 : toInteger(start);
  17439. end = end === undefined ? length : toInteger(end);
  17440. }
  17441. return baseSlice(array, start, end);
  17442. }
  17443. /**
  17444. * Uses a binary search to determine the lowest index at which `value`
  17445. * should be inserted into `array` in order to maintain its sort order.
  17446. *
  17447. * @static
  17448. * @memberOf _
  17449. * @since 0.1.0
  17450. * @category Array
  17451. * @param {Array} array The sorted array to inspect.
  17452. * @param {*} value The value to evaluate.
  17453. * @returns {number} Returns the index at which `value` should be inserted
  17454. * into `array`.
  17455. * @example
  17456. *
  17457. * _.sortedIndex([30, 50], 40);
  17458. * // => 1
  17459. */
  17460. function sortedIndex(array, value) {
  17461. return baseSortedIndex(array, value);
  17462. }
  17463. /**
  17464. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  17465. * which is invoked for `value` and each element of `array` to compute their
  17466. * sort ranking. The iteratee is invoked with one argument: (value).
  17467. *
  17468. * @static
  17469. * @memberOf _
  17470. * @since 4.0.0
  17471. * @category Array
  17472. * @param {Array} array The sorted array to inspect.
  17473. * @param {*} value The value to evaluate.
  17474. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  17475. * @returns {number} Returns the index at which `value` should be inserted
  17476. * into `array`.
  17477. * @example
  17478. *
  17479. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  17480. *
  17481. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  17482. * // => 0
  17483. *
  17484. * // The `_.property` iteratee shorthand.
  17485. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  17486. * // => 0
  17487. */
  17488. function sortedIndexBy(array, value, iteratee) {
  17489. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  17490. }
  17491. /**
  17492. * This method is like `_.indexOf` except that it performs a binary
  17493. * search on a sorted `array`.
  17494. *
  17495. * @static
  17496. * @memberOf _
  17497. * @since 4.0.0
  17498. * @category Array
  17499. * @param {Array} array The array to inspect.
  17500. * @param {*} value The value to search for.
  17501. * @returns {number} Returns the index of the matched value, else `-1`.
  17502. * @example
  17503. *
  17504. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  17505. * // => 1
  17506. */
  17507. function sortedIndexOf(array, value) {
  17508. var length = array == null ? 0 : array.length;
  17509. if (length) {
  17510. var index = baseSortedIndex(array, value);
  17511. if (index < length && eq(array[index], value)) {
  17512. return index;
  17513. }
  17514. }
  17515. return -1;
  17516. }
  17517. /**
  17518. * This method is like `_.sortedIndex` except that it returns the highest
  17519. * index at which `value` should be inserted into `array` in order to
  17520. * maintain its sort order.
  17521. *
  17522. * @static
  17523. * @memberOf _
  17524. * @since 3.0.0
  17525. * @category Array
  17526. * @param {Array} array The sorted array to inspect.
  17527. * @param {*} value The value to evaluate.
  17528. * @returns {number} Returns the index at which `value` should be inserted
  17529. * into `array`.
  17530. * @example
  17531. *
  17532. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  17533. * // => 4
  17534. */
  17535. function sortedLastIndex(array, value) {
  17536. return baseSortedIndex(array, value, true);
  17537. }
  17538. /**
  17539. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  17540. * which is invoked for `value` and each element of `array` to compute their
  17541. * sort ranking. The iteratee is invoked with one argument: (value).
  17542. *
  17543. * @static
  17544. * @memberOf _
  17545. * @since 4.0.0
  17546. * @category Array
  17547. * @param {Array} array The sorted array to inspect.
  17548. * @param {*} value The value to evaluate.
  17549. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  17550. * @returns {number} Returns the index at which `value` should be inserted
  17551. * into `array`.
  17552. * @example
  17553. *
  17554. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  17555. *
  17556. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  17557. * // => 1
  17558. *
  17559. * // The `_.property` iteratee shorthand.
  17560. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  17561. * // => 1
  17562. */
  17563. function sortedLastIndexBy(array, value, iteratee) {
  17564. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  17565. }
  17566. /**
  17567. * This method is like `_.lastIndexOf` except that it performs a binary
  17568. * search on a sorted `array`.
  17569. *
  17570. * @static
  17571. * @memberOf _
  17572. * @since 4.0.0
  17573. * @category Array
  17574. * @param {Array} array The array to inspect.
  17575. * @param {*} value The value to search for.
  17576. * @returns {number} Returns the index of the matched value, else `-1`.
  17577. * @example
  17578. *
  17579. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  17580. * // => 3
  17581. */
  17582. function sortedLastIndexOf(array, value) {
  17583. var length = array == null ? 0 : array.length;
  17584. if (length) {
  17585. var index = baseSortedIndex(array, value, true) - 1;
  17586. if (eq(array[index], value)) {
  17587. return index;
  17588. }
  17589. }
  17590. return -1;
  17591. }
  17592. /**
  17593. * This method is like `_.uniq` except that it's designed and optimized
  17594. * for sorted arrays.
  17595. *
  17596. * @static
  17597. * @memberOf _
  17598. * @since 4.0.0
  17599. * @category Array
  17600. * @param {Array} array The array to inspect.
  17601. * @returns {Array} Returns the new duplicate free array.
  17602. * @example
  17603. *
  17604. * _.sortedUniq([1, 1, 2]);
  17605. * // => [1, 2]
  17606. */
  17607. function sortedUniq(array) {
  17608. return (array && array.length)
  17609. ? baseSortedUniq(array)
  17610. : [];
  17611. }
  17612. /**
  17613. * This method is like `_.uniqBy` except that it's designed and optimized
  17614. * for sorted arrays.
  17615. *
  17616. * @static
  17617. * @memberOf _
  17618. * @since 4.0.0
  17619. * @category Array
  17620. * @param {Array} array The array to inspect.
  17621. * @param {Function} [iteratee] The iteratee invoked per element.
  17622. * @returns {Array} Returns the new duplicate free array.
  17623. * @example
  17624. *
  17625. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  17626. * // => [1.1, 2.3]
  17627. */
  17628. function sortedUniqBy(array, iteratee) {
  17629. return (array && array.length)
  17630. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  17631. : [];
  17632. }
  17633. /**
  17634. * Gets all but the first element of `array`.
  17635. *
  17636. * @static
  17637. * @memberOf _
  17638. * @since 4.0.0
  17639. * @category Array
  17640. * @param {Array} array The array to query.
  17641. * @returns {Array} Returns the slice of `array`.
  17642. * @example
  17643. *
  17644. * _.tail([1, 2, 3]);
  17645. * // => [2, 3]
  17646. */
  17647. function tail(array) {
  17648. var length = array == null ? 0 : array.length;
  17649. return length ? baseSlice(array, 1, length) : [];
  17650. }
  17651. /**
  17652. * Creates a slice of `array` with `n` elements taken from the beginning.
  17653. *
  17654. * @static
  17655. * @memberOf _
  17656. * @since 0.1.0
  17657. * @category Array
  17658. * @param {Array} array The array to query.
  17659. * @param {number} [n=1] The number of elements to take.
  17660. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  17661. * @returns {Array} Returns the slice of `array`.
  17662. * @example
  17663. *
  17664. * _.take([1, 2, 3]);
  17665. * // => [1]
  17666. *
  17667. * _.take([1, 2, 3], 2);
  17668. * // => [1, 2]
  17669. *
  17670. * _.take([1, 2, 3], 5);
  17671. * // => [1, 2, 3]
  17672. *
  17673. * _.take([1, 2, 3], 0);
  17674. * // => []
  17675. */
  17676. function take(array, n, guard) {
  17677. if (!(array && array.length)) {
  17678. return [];
  17679. }
  17680. n = (guard || n === undefined) ? 1 : toInteger(n);
  17681. return baseSlice(array, 0, n < 0 ? 0 : n);
  17682. }
  17683. /**
  17684. * Creates a slice of `array` with `n` elements taken from the end.
  17685. *
  17686. * @static
  17687. * @memberOf _
  17688. * @since 3.0.0
  17689. * @category Array
  17690. * @param {Array} array The array to query.
  17691. * @param {number} [n=1] The number of elements to take.
  17692. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  17693. * @returns {Array} Returns the slice of `array`.
  17694. * @example
  17695. *
  17696. * _.takeRight([1, 2, 3]);
  17697. * // => [3]
  17698. *
  17699. * _.takeRight([1, 2, 3], 2);
  17700. * // => [2, 3]
  17701. *
  17702. * _.takeRight([1, 2, 3], 5);
  17703. * // => [1, 2, 3]
  17704. *
  17705. * _.takeRight([1, 2, 3], 0);
  17706. * // => []
  17707. */
  17708. function takeRight(array, n, guard) {
  17709. var length = array == null ? 0 : array.length;
  17710. if (!length) {
  17711. return [];
  17712. }
  17713. n = (guard || n === undefined) ? 1 : toInteger(n);
  17714. n = length - n;
  17715. return baseSlice(array, n < 0 ? 0 : n, length);
  17716. }
  17717. /**
  17718. * Creates a slice of `array` with elements taken from the end. Elements are
  17719. * taken until `predicate` returns falsey. The predicate is invoked with
  17720. * three arguments: (value, index, array).
  17721. *
  17722. * @static
  17723. * @memberOf _
  17724. * @since 3.0.0
  17725. * @category Array
  17726. * @param {Array} array The array to query.
  17727. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  17728. * @returns {Array} Returns the slice of `array`.
  17729. * @example
  17730. *
  17731. * var users = [
  17732. * { 'user': 'barney', 'active': true },
  17733. * { 'user': 'fred', 'active': false },
  17734. * { 'user': 'pebbles', 'active': false }
  17735. * ];
  17736. *
  17737. * _.takeRightWhile(users, function(o) { return !o.active; });
  17738. * // => objects for ['fred', 'pebbles']
  17739. *
  17740. * // The `_.matches` iteratee shorthand.
  17741. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  17742. * // => objects for ['pebbles']
  17743. *
  17744. * // The `_.matchesProperty` iteratee shorthand.
  17745. * _.takeRightWhile(users, ['active', false]);
  17746. * // => objects for ['fred', 'pebbles']
  17747. *
  17748. * // The `_.property` iteratee shorthand.
  17749. * _.takeRightWhile(users, 'active');
  17750. * // => []
  17751. */
  17752. function takeRightWhile(array, predicate) {
  17753. return (array && array.length)
  17754. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  17755. : [];
  17756. }
  17757. /**
  17758. * Creates a slice of `array` with elements taken from the beginning. Elements
  17759. * are taken until `predicate` returns falsey. The predicate is invoked with
  17760. * three arguments: (value, index, array).
  17761. *
  17762. * @static
  17763. * @memberOf _
  17764. * @since 3.0.0
  17765. * @category Array
  17766. * @param {Array} array The array to query.
  17767. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  17768. * @returns {Array} Returns the slice of `array`.
  17769. * @example
  17770. *
  17771. * var users = [
  17772. * { 'user': 'barney', 'active': false },
  17773. * { 'user': 'fred', 'active': false },
  17774. * { 'user': 'pebbles', 'active': true }
  17775. * ];
  17776. *
  17777. * _.takeWhile(users, function(o) { return !o.active; });
  17778. * // => objects for ['barney', 'fred']
  17779. *
  17780. * // The `_.matches` iteratee shorthand.
  17781. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  17782. * // => objects for ['barney']
  17783. *
  17784. * // The `_.matchesProperty` iteratee shorthand.
  17785. * _.takeWhile(users, ['active', false]);
  17786. * // => objects for ['barney', 'fred']
  17787. *
  17788. * // The `_.property` iteratee shorthand.
  17789. * _.takeWhile(users, 'active');
  17790. * // => []
  17791. */
  17792. function takeWhile(array, predicate) {
  17793. return (array && array.length)
  17794. ? baseWhile(array, getIteratee(predicate, 3))
  17795. : [];
  17796. }
  17797. /**
  17798. * Creates an array of unique values, in order, from all given arrays using
  17799. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  17800. * for equality comparisons.
  17801. *
  17802. * @static
  17803. * @memberOf _
  17804. * @since 0.1.0
  17805. * @category Array
  17806. * @param {...Array} [arrays] The arrays to inspect.
  17807. * @returns {Array} Returns the new array of combined values.
  17808. * @example
  17809. *
  17810. * _.union([2], [1, 2]);
  17811. * // => [2, 1]
  17812. */
  17813. var union = baseRest(function(arrays) {
  17814. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  17815. });
  17816. /**
  17817. * This method is like `_.union` except that it accepts `iteratee` which is
  17818. * invoked for each element of each `arrays` to generate the criterion by
  17819. * which uniqueness is computed. Result values are chosen from the first
  17820. * array in which the value occurs. The iteratee is invoked with one argument:
  17821. * (value).
  17822. *
  17823. * @static
  17824. * @memberOf _
  17825. * @since 4.0.0
  17826. * @category Array
  17827. * @param {...Array} [arrays] The arrays to inspect.
  17828. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  17829. * @returns {Array} Returns the new array of combined values.
  17830. * @example
  17831. *
  17832. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  17833. * // => [2.1, 1.2]
  17834. *
  17835. * // The `_.property` iteratee shorthand.
  17836. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  17837. * // => [{ 'x': 1 }, { 'x': 2 }]
  17838. */
  17839. var unionBy = baseRest(function(arrays) {
  17840. var iteratee = last(arrays);
  17841. if (isArrayLikeObject(iteratee)) {
  17842. iteratee = undefined;
  17843. }
  17844. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  17845. });
  17846. /**
  17847. * This method is like `_.union` except that it accepts `comparator` which
  17848. * is invoked to compare elements of `arrays`. Result values are chosen from
  17849. * the first array in which the value occurs. The comparator is invoked
  17850. * with two arguments: (arrVal, othVal).
  17851. *
  17852. * @static
  17853. * @memberOf _
  17854. * @since 4.0.0
  17855. * @category Array
  17856. * @param {...Array} [arrays] The arrays to inspect.
  17857. * @param {Function} [comparator] The comparator invoked per element.
  17858. * @returns {Array} Returns the new array of combined values.
  17859. * @example
  17860. *
  17861. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  17862. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  17863. *
  17864. * _.unionWith(objects, others, _.isEqual);
  17865. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  17866. */
  17867. var unionWith = baseRest(function(arrays) {
  17868. var comparator = last(arrays);
  17869. comparator = typeof comparator == 'function' ? comparator : undefined;
  17870. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  17871. });
  17872. /**
  17873. * Creates a duplicate-free version of an array, using
  17874. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  17875. * for equality comparisons, in which only the first occurrence of each element
  17876. * is kept. The order of result values is determined by the order they occur
  17877. * in the array.
  17878. *
  17879. * @static
  17880. * @memberOf _
  17881. * @since 0.1.0
  17882. * @category Array
  17883. * @param {Array} array The array to inspect.
  17884. * @returns {Array} Returns the new duplicate free array.
  17885. * @example
  17886. *
  17887. * _.uniq([2, 1, 2]);
  17888. * // => [2, 1]
  17889. */
  17890. function uniq(array) {
  17891. return (array && array.length) ? baseUniq(array) : [];
  17892. }
  17893. /**
  17894. * This method is like `_.uniq` except that it accepts `iteratee` which is
  17895. * invoked for each element in `array` to generate the criterion by which
  17896. * uniqueness is computed. The order of result values is determined by the
  17897. * order they occur in the array. The iteratee is invoked with one argument:
  17898. * (value).
  17899. *
  17900. * @static
  17901. * @memberOf _
  17902. * @since 4.0.0
  17903. * @category Array
  17904. * @param {Array} array The array to inspect.
  17905. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  17906. * @returns {Array} Returns the new duplicate free array.
  17907. * @example
  17908. *
  17909. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  17910. * // => [2.1, 1.2]
  17911. *
  17912. * // The `_.property` iteratee shorthand.
  17913. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  17914. * // => [{ 'x': 1 }, { 'x': 2 }]
  17915. */
  17916. function uniqBy(array, iteratee) {
  17917. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  17918. }
  17919. /**
  17920. * This method is like `_.uniq` except that it accepts `comparator` which
  17921. * is invoked to compare elements of `array`. The order of result values is
  17922. * determined by the order they occur in the array.The comparator is invoked
  17923. * with two arguments: (arrVal, othVal).
  17924. *
  17925. * @static
  17926. * @memberOf _
  17927. * @since 4.0.0
  17928. * @category Array
  17929. * @param {Array} array The array to inspect.
  17930. * @param {Function} [comparator] The comparator invoked per element.
  17931. * @returns {Array} Returns the new duplicate free array.
  17932. * @example
  17933. *
  17934. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  17935. *
  17936. * _.uniqWith(objects, _.isEqual);
  17937. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  17938. */
  17939. function uniqWith(array, comparator) {
  17940. comparator = typeof comparator == 'function' ? comparator : undefined;
  17941. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  17942. }
  17943. /**
  17944. * This method is like `_.zip` except that it accepts an array of grouped
  17945. * elements and creates an array regrouping the elements to their pre-zip
  17946. * configuration.
  17947. *
  17948. * @static
  17949. * @memberOf _
  17950. * @since 1.2.0
  17951. * @category Array
  17952. * @param {Array} array The array of grouped elements to process.
  17953. * @returns {Array} Returns the new array of regrouped elements.
  17954. * @example
  17955. *
  17956. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  17957. * // => [['a', 1, true], ['b', 2, false]]
  17958. *
  17959. * _.unzip(zipped);
  17960. * // => [['a', 'b'], [1, 2], [true, false]]
  17961. */
  17962. function unzip(array) {
  17963. if (!(array && array.length)) {
  17964. return [];
  17965. }
  17966. var length = 0;
  17967. array = arrayFilter(array, function(group) {
  17968. if (isArrayLikeObject(group)) {
  17969. length = nativeMax(group.length, length);
  17970. return true;
  17971. }
  17972. });
  17973. return baseTimes(length, function(index) {
  17974. return arrayMap(array, baseProperty(index));
  17975. });
  17976. }
  17977. /**
  17978. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  17979. * how regrouped values should be combined. The iteratee is invoked with the
  17980. * elements of each group: (...group).
  17981. *
  17982. * @static
  17983. * @memberOf _
  17984. * @since 3.8.0
  17985. * @category Array
  17986. * @param {Array} array The array of grouped elements to process.
  17987. * @param {Function} [iteratee=_.identity] The function to combine
  17988. * regrouped values.
  17989. * @returns {Array} Returns the new array of regrouped elements.
  17990. * @example
  17991. *
  17992. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  17993. * // => [[1, 10, 100], [2, 20, 200]]
  17994. *
  17995. * _.unzipWith(zipped, _.add);
  17996. * // => [3, 30, 300]
  17997. */
  17998. function unzipWith(array, iteratee) {
  17999. if (!(array && array.length)) {
  18000. return [];
  18001. }
  18002. var result = unzip(array);
  18003. if (iteratee == null) {
  18004. return result;
  18005. }
  18006. return arrayMap(result, function(group) {
  18007. return apply(iteratee, undefined, group);
  18008. });
  18009. }
  18010. /**
  18011. * Creates an array excluding all given values using
  18012. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  18013. * for equality comparisons.
  18014. *
  18015. * **Note:** Unlike `_.pull`, this method returns a new array.
  18016. *
  18017. * @static
  18018. * @memberOf _
  18019. * @since 0.1.0
  18020. * @category Array
  18021. * @param {Array} array The array to inspect.
  18022. * @param {...*} [values] The values to exclude.
  18023. * @returns {Array} Returns the new array of filtered values.
  18024. * @see _.difference, _.xor
  18025. * @example
  18026. *
  18027. * _.without([2, 1, 2, 3], 1, 2);
  18028. * // => [3]
  18029. */
  18030. var without = baseRest(function(array, values) {
  18031. return isArrayLikeObject(array)
  18032. ? baseDifference(array, values)
  18033. : [];
  18034. });
  18035. /**
  18036. * Creates an array of unique values that is the
  18037. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  18038. * of the given arrays. The order of result values is determined by the order
  18039. * they occur in the arrays.
  18040. *
  18041. * @static
  18042. * @memberOf _
  18043. * @since 2.4.0
  18044. * @category Array
  18045. * @param {...Array} [arrays] The arrays to inspect.
  18046. * @returns {Array} Returns the new array of filtered values.
  18047. * @see _.difference, _.without
  18048. * @example
  18049. *
  18050. * _.xor([2, 1], [2, 3]);
  18051. * // => [1, 3]
  18052. */
  18053. var xor = baseRest(function(arrays) {
  18054. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  18055. });
  18056. /**
  18057. * This method is like `_.xor` except that it accepts `iteratee` which is
  18058. * invoked for each element of each `arrays` to generate the criterion by
  18059. * which by which they're compared. The order of result values is determined
  18060. * by the order they occur in the arrays. The iteratee is invoked with one
  18061. * argument: (value).
  18062. *
  18063. * @static
  18064. * @memberOf _
  18065. * @since 4.0.0
  18066. * @category Array
  18067. * @param {...Array} [arrays] The arrays to inspect.
  18068. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  18069. * @returns {Array} Returns the new array of filtered values.
  18070. * @example
  18071. *
  18072. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  18073. * // => [1.2, 3.4]
  18074. *
  18075. * // The `_.property` iteratee shorthand.
  18076. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  18077. * // => [{ 'x': 2 }]
  18078. */
  18079. var xorBy = baseRest(function(arrays) {
  18080. var iteratee = last(arrays);
  18081. if (isArrayLikeObject(iteratee)) {
  18082. iteratee = undefined;
  18083. }
  18084. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  18085. });
  18086. /**
  18087. * This method is like `_.xor` except that it accepts `comparator` which is
  18088. * invoked to compare elements of `arrays`. The order of result values is
  18089. * determined by the order they occur in the arrays. The comparator is invoked
  18090. * with two arguments: (arrVal, othVal).
  18091. *
  18092. * @static
  18093. * @memberOf _
  18094. * @since 4.0.0
  18095. * @category Array
  18096. * @param {...Array} [arrays] The arrays to inspect.
  18097. * @param {Function} [comparator] The comparator invoked per element.
  18098. * @returns {Array} Returns the new array of filtered values.
  18099. * @example
  18100. *
  18101. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  18102. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  18103. *
  18104. * _.xorWith(objects, others, _.isEqual);
  18105. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  18106. */
  18107. var xorWith = baseRest(function(arrays) {
  18108. var comparator = last(arrays);
  18109. comparator = typeof comparator == 'function' ? comparator : undefined;
  18110. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  18111. });
  18112. /**
  18113. * Creates an array of grouped elements, the first of which contains the
  18114. * first elements of the given arrays, the second of which contains the
  18115. * second elements of the given arrays, and so on.
  18116. *
  18117. * @static
  18118. * @memberOf _
  18119. * @since 0.1.0
  18120. * @category Array
  18121. * @param {...Array} [arrays] The arrays to process.
  18122. * @returns {Array} Returns the new array of grouped elements.
  18123. * @example
  18124. *
  18125. * _.zip(['a', 'b'], [1, 2], [true, false]);
  18126. * // => [['a', 1, true], ['b', 2, false]]
  18127. */
  18128. var zip = baseRest(unzip);
  18129. /**
  18130. * This method is like `_.fromPairs` except that it accepts two arrays,
  18131. * one of property identifiers and one of corresponding values.
  18132. *
  18133. * @static
  18134. * @memberOf _
  18135. * @since 0.4.0
  18136. * @category Array
  18137. * @param {Array} [props=[]] The property identifiers.
  18138. * @param {Array} [values=[]] The property values.
  18139. * @returns {Object} Returns the new object.
  18140. * @example
  18141. *
  18142. * _.zipObject(['a', 'b'], [1, 2]);
  18143. * // => { 'a': 1, 'b': 2 }
  18144. */
  18145. function zipObject(props, values) {
  18146. return baseZipObject(props || [], values || [], assignValue);
  18147. }
  18148. /**
  18149. * This method is like `_.zipObject` except that it supports property paths.
  18150. *
  18151. * @static
  18152. * @memberOf _
  18153. * @since 4.1.0
  18154. * @category Array
  18155. * @param {Array} [props=[]] The property identifiers.
  18156. * @param {Array} [values=[]] The property values.
  18157. * @returns {Object} Returns the new object.
  18158. * @example
  18159. *
  18160. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  18161. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  18162. */
  18163. function zipObjectDeep(props, values) {
  18164. return baseZipObject(props || [], values || [], baseSet);
  18165. }
  18166. /**
  18167. * This method is like `_.zip` except that it accepts `iteratee` to specify
  18168. * how grouped values should be combined. The iteratee is invoked with the
  18169. * elements of each group: (...group).
  18170. *
  18171. * @static
  18172. * @memberOf _
  18173. * @since 3.8.0
  18174. * @category Array
  18175. * @param {...Array} [arrays] The arrays to process.
  18176. * @param {Function} [iteratee=_.identity] The function to combine
  18177. * grouped values.
  18178. * @returns {Array} Returns the new array of grouped elements.
  18179. * @example
  18180. *
  18181. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  18182. * return a + b + c;
  18183. * });
  18184. * // => [111, 222]
  18185. */
  18186. var zipWith = baseRest(function(arrays) {
  18187. var length = arrays.length,
  18188. iteratee = length > 1 ? arrays[length - 1] : undefined;
  18189. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  18190. return unzipWith(arrays, iteratee);
  18191. });
  18192. /*------------------------------------------------------------------------*/
  18193. /**
  18194. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  18195. * chain sequences enabled. The result of such sequences must be unwrapped
  18196. * with `_#value`.
  18197. *
  18198. * @static
  18199. * @memberOf _
  18200. * @since 1.3.0
  18201. * @category Seq
  18202. * @param {*} value The value to wrap.
  18203. * @returns {Object} Returns the new `lodash` wrapper instance.
  18204. * @example
  18205. *
  18206. * var users = [
  18207. * { 'user': 'barney', 'age': 36 },
  18208. * { 'user': 'fred', 'age': 40 },
  18209. * { 'user': 'pebbles', 'age': 1 }
  18210. * ];
  18211. *
  18212. * var youngest = _
  18213. * .chain(users)
  18214. * .sortBy('age')
  18215. * .map(function(o) {
  18216. * return o.user + ' is ' + o.age;
  18217. * })
  18218. * .head()
  18219. * .value();
  18220. * // => 'pebbles is 1'
  18221. */
  18222. function chain(value) {
  18223. var result = lodash(value);
  18224. result.__chain__ = true;
  18225. return result;
  18226. }
  18227. /**
  18228. * This method invokes `interceptor` and returns `value`. The interceptor
  18229. * is invoked with one argument; (value). The purpose of this method is to
  18230. * "tap into" a method chain sequence in order to modify intermediate results.
  18231. *
  18232. * @static
  18233. * @memberOf _
  18234. * @since 0.1.0
  18235. * @category Seq
  18236. * @param {*} value The value to provide to `interceptor`.
  18237. * @param {Function} interceptor The function to invoke.
  18238. * @returns {*} Returns `value`.
  18239. * @example
  18240. *
  18241. * _([1, 2, 3])
  18242. * .tap(function(array) {
  18243. * // Mutate input array.
  18244. * array.pop();
  18245. * })
  18246. * .reverse()
  18247. * .value();
  18248. * // => [2, 1]
  18249. */
  18250. function tap(value, interceptor) {
  18251. interceptor(value);
  18252. return value;
  18253. }
  18254. /**
  18255. * This method is like `_.tap` except that it returns the result of `interceptor`.
  18256. * The purpose of this method is to "pass thru" values replacing intermediate
  18257. * results in a method chain sequence.
  18258. *
  18259. * @static
  18260. * @memberOf _
  18261. * @since 3.0.0
  18262. * @category Seq
  18263. * @param {*} value The value to provide to `interceptor`.
  18264. * @param {Function} interceptor The function to invoke.
  18265. * @returns {*} Returns the result of `interceptor`.
  18266. * @example
  18267. *
  18268. * _(' abc ')
  18269. * .chain()
  18270. * .trim()
  18271. * .thru(function(value) {
  18272. * return [value];
  18273. * })
  18274. * .value();
  18275. * // => ['abc']
  18276. */
  18277. function thru(value, interceptor) {
  18278. return interceptor(value);
  18279. }
  18280. /**
  18281. * This method is the wrapper version of `_.at`.
  18282. *
  18283. * @name at
  18284. * @memberOf _
  18285. * @since 1.0.0
  18286. * @category Seq
  18287. * @param {...(string|string[])} [paths] The property paths to pick.
  18288. * @returns {Object} Returns the new `lodash` wrapper instance.
  18289. * @example
  18290. *
  18291. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  18292. *
  18293. * _(object).at(['a[0].b.c', 'a[1]']).value();
  18294. * // => [3, 4]
  18295. */
  18296. var wrapperAt = flatRest(function(paths) {
  18297. var length = paths.length,
  18298. start = length ? paths[0] : 0,
  18299. value = this.__wrapped__,
  18300. interceptor = function(object) { return baseAt(object, paths); };
  18301. if (length > 1 || this.__actions__.length ||
  18302. !(value instanceof LazyWrapper) || !isIndex(start)) {
  18303. return this.thru(interceptor);
  18304. }
  18305. value = value.slice(start, +start + (length ? 1 : 0));
  18306. value.__actions__.push({
  18307. 'func': thru,
  18308. 'args': [interceptor],
  18309. 'thisArg': undefined
  18310. });
  18311. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  18312. if (length && !array.length) {
  18313. array.push(undefined);
  18314. }
  18315. return array;
  18316. });
  18317. });
  18318. /**
  18319. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  18320. *
  18321. * @name chain
  18322. * @memberOf _
  18323. * @since 0.1.0
  18324. * @category Seq
  18325. * @returns {Object} Returns the new `lodash` wrapper instance.
  18326. * @example
  18327. *
  18328. * var users = [
  18329. * { 'user': 'barney', 'age': 36 },
  18330. * { 'user': 'fred', 'age': 40 }
  18331. * ];
  18332. *
  18333. * // A sequence without explicit chaining.
  18334. * _(users).head();
  18335. * // => { 'user': 'barney', 'age': 36 }
  18336. *
  18337. * // A sequence with explicit chaining.
  18338. * _(users)
  18339. * .chain()
  18340. * .head()
  18341. * .pick('user')
  18342. * .value();
  18343. * // => { 'user': 'barney' }
  18344. */
  18345. function wrapperChain() {
  18346. return chain(this);
  18347. }
  18348. /**
  18349. * Executes the chain sequence and returns the wrapped result.
  18350. *
  18351. * @name commit
  18352. * @memberOf _
  18353. * @since 3.2.0
  18354. * @category Seq
  18355. * @returns {Object} Returns the new `lodash` wrapper instance.
  18356. * @example
  18357. *
  18358. * var array = [1, 2];
  18359. * var wrapped = _(array).push(3);
  18360. *
  18361. * console.log(array);
  18362. * // => [1, 2]
  18363. *
  18364. * wrapped = wrapped.commit();
  18365. * console.log(array);
  18366. * // => [1, 2, 3]
  18367. *
  18368. * wrapped.last();
  18369. * // => 3
  18370. *
  18371. * console.log(array);
  18372. * // => [1, 2, 3]
  18373. */
  18374. function wrapperCommit() {
  18375. return new LodashWrapper(this.value(), this.__chain__);
  18376. }
  18377. /**
  18378. * Gets the next value on a wrapped object following the
  18379. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  18380. *
  18381. * @name next
  18382. * @memberOf _
  18383. * @since 4.0.0
  18384. * @category Seq
  18385. * @returns {Object} Returns the next iterator value.
  18386. * @example
  18387. *
  18388. * var wrapped = _([1, 2]);
  18389. *
  18390. * wrapped.next();
  18391. * // => { 'done': false, 'value': 1 }
  18392. *
  18393. * wrapped.next();
  18394. * // => { 'done': false, 'value': 2 }
  18395. *
  18396. * wrapped.next();
  18397. * // => { 'done': true, 'value': undefined }
  18398. */
  18399. function wrapperNext() {
  18400. if (this.__values__ === undefined) {
  18401. this.__values__ = toArray(this.value());
  18402. }
  18403. var done = this.__index__ >= this.__values__.length,
  18404. value = done ? undefined : this.__values__[this.__index__++];
  18405. return { 'done': done, 'value': value };
  18406. }
  18407. /**
  18408. * Enables the wrapper to be iterable.
  18409. *
  18410. * @name Symbol.iterator
  18411. * @memberOf _
  18412. * @since 4.0.0
  18413. * @category Seq
  18414. * @returns {Object} Returns the wrapper object.
  18415. * @example
  18416. *
  18417. * var wrapped = _([1, 2]);
  18418. *
  18419. * wrapped[Symbol.iterator]() === wrapped;
  18420. * // => true
  18421. *
  18422. * Array.from(wrapped);
  18423. * // => [1, 2]
  18424. */
  18425. function wrapperToIterator() {
  18426. return this;
  18427. }
  18428. /**
  18429. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  18430. *
  18431. * @name plant
  18432. * @memberOf _
  18433. * @since 3.2.0
  18434. * @category Seq
  18435. * @param {*} value The value to plant.
  18436. * @returns {Object} Returns the new `lodash` wrapper instance.
  18437. * @example
  18438. *
  18439. * function square(n) {
  18440. * return n * n;
  18441. * }
  18442. *
  18443. * var wrapped = _([1, 2]).map(square);
  18444. * var other = wrapped.plant([3, 4]);
  18445. *
  18446. * other.value();
  18447. * // => [9, 16]
  18448. *
  18449. * wrapped.value();
  18450. * // => [1, 4]
  18451. */
  18452. function wrapperPlant(value) {
  18453. var result,
  18454. parent = this;
  18455. while (parent instanceof baseLodash) {
  18456. var clone = wrapperClone(parent);
  18457. clone.__index__ = 0;
  18458. clone.__values__ = undefined;
  18459. if (result) {
  18460. previous.__wrapped__ = clone;
  18461. } else {
  18462. result = clone;
  18463. }
  18464. var previous = clone;
  18465. parent = parent.__wrapped__;
  18466. }
  18467. previous.__wrapped__ = value;
  18468. return result;
  18469. }
  18470. /**
  18471. * This method is the wrapper version of `_.reverse`.
  18472. *
  18473. * **Note:** This method mutates the wrapped array.
  18474. *
  18475. * @name reverse
  18476. * @memberOf _
  18477. * @since 0.1.0
  18478. * @category Seq
  18479. * @returns {Object} Returns the new `lodash` wrapper instance.
  18480. * @example
  18481. *
  18482. * var array = [1, 2, 3];
  18483. *
  18484. * _(array).reverse().value()
  18485. * // => [3, 2, 1]
  18486. *
  18487. * console.log(array);
  18488. * // => [3, 2, 1]
  18489. */
  18490. function wrapperReverse() {
  18491. var value = this.__wrapped__;
  18492. if (value instanceof LazyWrapper) {
  18493. var wrapped = value;
  18494. if (this.__actions__.length) {
  18495. wrapped = new LazyWrapper(this);
  18496. }
  18497. wrapped = wrapped.reverse();
  18498. wrapped.__actions__.push({
  18499. 'func': thru,
  18500. 'args': [reverse],
  18501. 'thisArg': undefined
  18502. });
  18503. return new LodashWrapper(wrapped, this.__chain__);
  18504. }
  18505. return this.thru(reverse);
  18506. }
  18507. /**
  18508. * Executes the chain sequence to resolve the unwrapped value.
  18509. *
  18510. * @name value
  18511. * @memberOf _
  18512. * @since 0.1.0
  18513. * @alias toJSON, valueOf
  18514. * @category Seq
  18515. * @returns {*} Returns the resolved unwrapped value.
  18516. * @example
  18517. *
  18518. * _([1, 2, 3]).value();
  18519. * // => [1, 2, 3]
  18520. */
  18521. function wrapperValue() {
  18522. return baseWrapperValue(this.__wrapped__, this.__actions__);
  18523. }
  18524. /*------------------------------------------------------------------------*/
  18525. /**
  18526. * Creates an object composed of keys generated from the results of running
  18527. * each element of `collection` thru `iteratee`. The corresponding value of
  18528. * each key is the number of times the key was returned by `iteratee`. The
  18529. * iteratee is invoked with one argument: (value).
  18530. *
  18531. * @static
  18532. * @memberOf _
  18533. * @since 0.5.0
  18534. * @category Collection
  18535. * @param {Array|Object} collection The collection to iterate over.
  18536. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  18537. * @returns {Object} Returns the composed aggregate object.
  18538. * @example
  18539. *
  18540. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  18541. * // => { '4': 1, '6': 2 }
  18542. *
  18543. * // The `_.property` iteratee shorthand.
  18544. * _.countBy(['one', 'two', 'three'], 'length');
  18545. * // => { '3': 2, '5': 1 }
  18546. */
  18547. var countBy = createAggregator(function(result, value, key) {
  18548. if (hasOwnProperty.call(result, key)) {
  18549. ++result[key];
  18550. } else {
  18551. baseAssignValue(result, key, 1);
  18552. }
  18553. });
  18554. /**
  18555. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  18556. * Iteration is stopped once `predicate` returns falsey. The predicate is
  18557. * invoked with three arguments: (value, index|key, collection).
  18558. *
  18559. * **Note:** This method returns `true` for
  18560. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  18561. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  18562. * elements of empty collections.
  18563. *
  18564. * @static
  18565. * @memberOf _
  18566. * @since 0.1.0
  18567. * @category Collection
  18568. * @param {Array|Object} collection The collection to iterate over.
  18569. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  18570. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  18571. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  18572. * else `false`.
  18573. * @example
  18574. *
  18575. * _.every([true, 1, null, 'yes'], Boolean);
  18576. * // => false
  18577. *
  18578. * var users = [
  18579. * { 'user': 'barney', 'age': 36, 'active': false },
  18580. * { 'user': 'fred', 'age': 40, 'active': false }
  18581. * ];
  18582. *
  18583. * // The `_.matches` iteratee shorthand.
  18584. * _.every(users, { 'user': 'barney', 'active': false });
  18585. * // => false
  18586. *
  18587. * // The `_.matchesProperty` iteratee shorthand.
  18588. * _.every(users, ['active', false]);
  18589. * // => true
  18590. *
  18591. * // The `_.property` iteratee shorthand.
  18592. * _.every(users, 'active');
  18593. * // => false
  18594. */
  18595. function every(collection, predicate, guard) {
  18596. var func = isArray(collection) ? arrayEvery : baseEvery;
  18597. if (guard && isIterateeCall(collection, predicate, guard)) {
  18598. predicate = undefined;
  18599. }
  18600. return func(collection, getIteratee(predicate, 3));
  18601. }
  18602. /**
  18603. * Iterates over elements of `collection`, returning an array of all elements
  18604. * `predicate` returns truthy for. The predicate is invoked with three
  18605. * arguments: (value, index|key, collection).
  18606. *
  18607. * **Note:** Unlike `_.remove`, this method returns a new array.
  18608. *
  18609. * @static
  18610. * @memberOf _
  18611. * @since 0.1.0
  18612. * @category Collection
  18613. * @param {Array|Object} collection The collection to iterate over.
  18614. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  18615. * @returns {Array} Returns the new filtered array.
  18616. * @see _.reject
  18617. * @example
  18618. *
  18619. * var users = [
  18620. * { 'user': 'barney', 'age': 36, 'active': true },
  18621. * { 'user': 'fred', 'age': 40, 'active': false }
  18622. * ];
  18623. *
  18624. * _.filter(users, function(o) { return !o.active; });
  18625. * // => objects for ['fred']
  18626. *
  18627. * // The `_.matches` iteratee shorthand.
  18628. * _.filter(users, { 'age': 36, 'active': true });
  18629. * // => objects for ['barney']
  18630. *
  18631. * // The `_.matchesProperty` iteratee shorthand.
  18632. * _.filter(users, ['active', false]);
  18633. * // => objects for ['fred']
  18634. *
  18635. * // The `_.property` iteratee shorthand.
  18636. * _.filter(users, 'active');
  18637. * // => objects for ['barney']
  18638. */
  18639. function filter(collection, predicate) {
  18640. var func = isArray(collection) ? arrayFilter : baseFilter;
  18641. return func(collection, getIteratee(predicate, 3));
  18642. }
  18643. /**
  18644. * Iterates over elements of `collection`, returning the first element
  18645. * `predicate` returns truthy for. The predicate is invoked with three
  18646. * arguments: (value, index|key, collection).
  18647. *
  18648. * @static
  18649. * @memberOf _
  18650. * @since 0.1.0
  18651. * @category Collection
  18652. * @param {Array|Object} collection The collection to inspect.
  18653. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  18654. * @param {number} [fromIndex=0] The index to search from.
  18655. * @returns {*} Returns the matched element, else `undefined`.
  18656. * @example
  18657. *
  18658. * var users = [
  18659. * { 'user': 'barney', 'age': 36, 'active': true },
  18660. * { 'user': 'fred', 'age': 40, 'active': false },
  18661. * { 'user': 'pebbles', 'age': 1, 'active': true }
  18662. * ];
  18663. *
  18664. * _.find(users, function(o) { return o.age < 40; });
  18665. * // => object for 'barney'
  18666. *
  18667. * // The `_.matches` iteratee shorthand.
  18668. * _.find(users, { 'age': 1, 'active': true });
  18669. * // => object for 'pebbles'
  18670. *
  18671. * // The `_.matchesProperty` iteratee shorthand.
  18672. * _.find(users, ['active', false]);
  18673. * // => object for 'fred'
  18674. *
  18675. * // The `_.property` iteratee shorthand.
  18676. * _.find(users, 'active');
  18677. * // => object for 'barney'
  18678. */
  18679. var find = createFind(findIndex);
  18680. /**
  18681. * This method is like `_.find` except that it iterates over elements of
  18682. * `collection` from right to left.
  18683. *
  18684. * @static
  18685. * @memberOf _
  18686. * @since 2.0.0
  18687. * @category Collection
  18688. * @param {Array|Object} collection The collection to inspect.
  18689. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  18690. * @param {number} [fromIndex=collection.length-1] The index to search from.
  18691. * @returns {*} Returns the matched element, else `undefined`.
  18692. * @example
  18693. *
  18694. * _.findLast([1, 2, 3, 4], function(n) {
  18695. * return n % 2 == 1;
  18696. * });
  18697. * // => 3
  18698. */
  18699. var findLast = createFind(findLastIndex);
  18700. /**
  18701. * Creates a flattened array of values by running each element in `collection`
  18702. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  18703. * with three arguments: (value, index|key, collection).
  18704. *
  18705. * @static
  18706. * @memberOf _
  18707. * @since 4.0.0
  18708. * @category Collection
  18709. * @param {Array|Object} collection The collection to iterate over.
  18710. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  18711. * @returns {Array} Returns the new flattened array.
  18712. * @example
  18713. *
  18714. * function duplicate(n) {
  18715. * return [n, n];
  18716. * }
  18717. *
  18718. * _.flatMap([1, 2], duplicate);
  18719. * // => [1, 1, 2, 2]
  18720. */
  18721. function flatMap(collection, iteratee) {
  18722. return baseFlatten(map(collection, iteratee), 1);
  18723. }
  18724. /**
  18725. * This method is like `_.flatMap` except that it recursively flattens the
  18726. * mapped results.
  18727. *
  18728. * @static
  18729. * @memberOf _
  18730. * @since 4.7.0
  18731. * @category Collection
  18732. * @param {Array|Object} collection The collection to iterate over.
  18733. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  18734. * @returns {Array} Returns the new flattened array.
  18735. * @example
  18736. *
  18737. * function duplicate(n) {
  18738. * return [[[n, n]]];
  18739. * }
  18740. *
  18741. * _.flatMapDeep([1, 2], duplicate);
  18742. * // => [1, 1, 2, 2]
  18743. */
  18744. function flatMapDeep(collection, iteratee) {
  18745. return baseFlatten(map(collection, iteratee), INFINITY);
  18746. }
  18747. /**
  18748. * This method is like `_.flatMap` except that it recursively flattens the
  18749. * mapped results up to `depth` times.
  18750. *
  18751. * @static
  18752. * @memberOf _
  18753. * @since 4.7.0
  18754. * @category Collection
  18755. * @param {Array|Object} collection The collection to iterate over.
  18756. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  18757. * @param {number} [depth=1] The maximum recursion depth.
  18758. * @returns {Array} Returns the new flattened array.
  18759. * @example
  18760. *
  18761. * function duplicate(n) {
  18762. * return [[[n, n]]];
  18763. * }
  18764. *
  18765. * _.flatMapDepth([1, 2], duplicate, 2);
  18766. * // => [[1, 1], [2, 2]]
  18767. */
  18768. function flatMapDepth(collection, iteratee, depth) {
  18769. depth = depth === undefined ? 1 : toInteger(depth);
  18770. return baseFlatten(map(collection, iteratee), depth);
  18771. }
  18772. /**
  18773. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  18774. * The iteratee is invoked with three arguments: (value, index|key, collection).
  18775. * Iteratee functions may exit iteration early by explicitly returning `false`.
  18776. *
  18777. * **Note:** As with other "Collections" methods, objects with a "length"
  18778. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  18779. * or `_.forOwn` for object iteration.
  18780. *
  18781. * @static
  18782. * @memberOf _
  18783. * @since 0.1.0
  18784. * @alias each
  18785. * @category Collection
  18786. * @param {Array|Object} collection The collection to iterate over.
  18787. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  18788. * @returns {Array|Object} Returns `collection`.
  18789. * @see _.forEachRight
  18790. * @example
  18791. *
  18792. * _.forEach([1, 2], function(value) {
  18793. * console.log(value);
  18794. * });
  18795. * // => Logs `1` then `2`.
  18796. *
  18797. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  18798. * console.log(key);
  18799. * });
  18800. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  18801. */
  18802. function forEach(collection, iteratee) {
  18803. var func = isArray(collection) ? arrayEach : baseEach;
  18804. return func(collection, getIteratee(iteratee, 3));
  18805. }
  18806. /**
  18807. * This method is like `_.forEach` except that it iterates over elements of
  18808. * `collection` from right to left.
  18809. *
  18810. * @static
  18811. * @memberOf _
  18812. * @since 2.0.0
  18813. * @alias eachRight
  18814. * @category Collection
  18815. * @param {Array|Object} collection The collection to iterate over.
  18816. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  18817. * @returns {Array|Object} Returns `collection`.
  18818. * @see _.forEach
  18819. * @example
  18820. *
  18821. * _.forEachRight([1, 2], function(value) {
  18822. * console.log(value);
  18823. * });
  18824. * // => Logs `2` then `1`.
  18825. */
  18826. function forEachRight(collection, iteratee) {
  18827. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  18828. return func(collection, getIteratee(iteratee, 3));
  18829. }
  18830. /**
  18831. * Creates an object composed of keys generated from the results of running
  18832. * each element of `collection` thru `iteratee`. The order of grouped values
  18833. * is determined by the order they occur in `collection`. The corresponding
  18834. * value of each key is an array of elements responsible for generating the
  18835. * key. The iteratee is invoked with one argument: (value).
  18836. *
  18837. * @static
  18838. * @memberOf _
  18839. * @since 0.1.0
  18840. * @category Collection
  18841. * @param {Array|Object} collection The collection to iterate over.
  18842. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  18843. * @returns {Object} Returns the composed aggregate object.
  18844. * @example
  18845. *
  18846. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  18847. * // => { '4': [4.2], '6': [6.1, 6.3] }
  18848. *
  18849. * // The `_.property` iteratee shorthand.
  18850. * _.groupBy(['one', 'two', 'three'], 'length');
  18851. * // => { '3': ['one', 'two'], '5': ['three'] }
  18852. */
  18853. var groupBy = createAggregator(function(result, value, key) {
  18854. if (hasOwnProperty.call(result, key)) {
  18855. result[key].push(value);
  18856. } else {
  18857. baseAssignValue(result, key, [value]);
  18858. }
  18859. });
  18860. /**
  18861. * Checks if `value` is in `collection`. If `collection` is a string, it's
  18862. * checked for a substring of `value`, otherwise
  18863. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  18864. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  18865. * the offset from the end of `collection`.
  18866. *
  18867. * @static
  18868. * @memberOf _
  18869. * @since 0.1.0
  18870. * @category Collection
  18871. * @param {Array|Object|string} collection The collection to inspect.
  18872. * @param {*} value The value to search for.
  18873. * @param {number} [fromIndex=0] The index to search from.
  18874. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  18875. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  18876. * @example
  18877. *
  18878. * _.includes([1, 2, 3], 1);
  18879. * // => true
  18880. *
  18881. * _.includes([1, 2, 3], 1, 2);
  18882. * // => false
  18883. *
  18884. * _.includes({ 'a': 1, 'b': 2 }, 1);
  18885. * // => true
  18886. *
  18887. * _.includes('abcd', 'bc');
  18888. * // => true
  18889. */
  18890. function includes(collection, value, fromIndex, guard) {
  18891. collection = isArrayLike(collection) ? collection : values(collection);
  18892. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  18893. var length = collection.length;
  18894. if (fromIndex < 0) {
  18895. fromIndex = nativeMax(length + fromIndex, 0);
  18896. }
  18897. return isString(collection)
  18898. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  18899. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  18900. }
  18901. /**
  18902. * Invokes the method at `path` of each element in `collection`, returning
  18903. * an array of the results of each invoked method. Any additional arguments
  18904. * are provided to each invoked method. If `path` is a function, it's invoked
  18905. * for, and `this` bound to, each element in `collection`.
  18906. *
  18907. * @static
  18908. * @memberOf _
  18909. * @since 4.0.0
  18910. * @category Collection
  18911. * @param {Array|Object} collection The collection to iterate over.
  18912. * @param {Array|Function|string} path The path of the method to invoke or
  18913. * the function invoked per iteration.
  18914. * @param {...*} [args] The arguments to invoke each method with.
  18915. * @returns {Array} Returns the array of results.
  18916. * @example
  18917. *
  18918. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  18919. * // => [[1, 5, 7], [1, 2, 3]]
  18920. *
  18921. * _.invokeMap([123, 456], String.prototype.split, '');
  18922. * // => [['1', '2', '3'], ['4', '5', '6']]
  18923. */
  18924. var invokeMap = baseRest(function(collection, path, args) {
  18925. var index = -1,
  18926. isFunc = typeof path == 'function',
  18927. result = isArrayLike(collection) ? Array(collection.length) : [];
  18928. baseEach(collection, function(value) {
  18929. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  18930. });
  18931. return result;
  18932. });
  18933. /**
  18934. * Creates an object composed of keys generated from the results of running
  18935. * each element of `collection` thru `iteratee`. The corresponding value of
  18936. * each key is the last element responsible for generating the key. The
  18937. * iteratee is invoked with one argument: (value).
  18938. *
  18939. * @static
  18940. * @memberOf _
  18941. * @since 4.0.0
  18942. * @category Collection
  18943. * @param {Array|Object} collection The collection to iterate over.
  18944. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  18945. * @returns {Object} Returns the composed aggregate object.
  18946. * @example
  18947. *
  18948. * var array = [
  18949. * { 'dir': 'left', 'code': 97 },
  18950. * { 'dir': 'right', 'code': 100 }
  18951. * ];
  18952. *
  18953. * _.keyBy(array, function(o) {
  18954. * return String.fromCharCode(o.code);
  18955. * });
  18956. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  18957. *
  18958. * _.keyBy(array, 'dir');
  18959. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  18960. */
  18961. var keyBy = createAggregator(function(result, value, key) {
  18962. baseAssignValue(result, key, value);
  18963. });
  18964. /**
  18965. * Creates an array of values by running each element in `collection` thru
  18966. * `iteratee`. The iteratee is invoked with three arguments:
  18967. * (value, index|key, collection).
  18968. *
  18969. * Many lodash methods are guarded to work as iteratees for methods like
  18970. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  18971. *
  18972. * The guarded methods are:
  18973. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  18974. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  18975. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  18976. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  18977. *
  18978. * @static
  18979. * @memberOf _
  18980. * @since 0.1.0
  18981. * @category Collection
  18982. * @param {Array|Object} collection The collection to iterate over.
  18983. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  18984. * @returns {Array} Returns the new mapped array.
  18985. * @example
  18986. *
  18987. * function square(n) {
  18988. * return n * n;
  18989. * }
  18990. *
  18991. * _.map([4, 8], square);
  18992. * // => [16, 64]
  18993. *
  18994. * _.map({ 'a': 4, 'b': 8 }, square);
  18995. * // => [16, 64] (iteration order is not guaranteed)
  18996. *
  18997. * var users = [
  18998. * { 'user': 'barney' },
  18999. * { 'user': 'fred' }
  19000. * ];
  19001. *
  19002. * // The `_.property` iteratee shorthand.
  19003. * _.map(users, 'user');
  19004. * // => ['barney', 'fred']
  19005. */
  19006. function map(collection, iteratee) {
  19007. var func = isArray(collection) ? arrayMap : baseMap;
  19008. return func(collection, getIteratee(iteratee, 3));
  19009. }
  19010. /**
  19011. * This method is like `_.sortBy` except that it allows specifying the sort
  19012. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  19013. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  19014. * descending or "asc" for ascending sort order of corresponding values.
  19015. *
  19016. * @static
  19017. * @memberOf _
  19018. * @since 4.0.0
  19019. * @category Collection
  19020. * @param {Array|Object} collection The collection to iterate over.
  19021. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  19022. * The iteratees to sort by.
  19023. * @param {string[]} [orders] The sort orders of `iteratees`.
  19024. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  19025. * @returns {Array} Returns the new sorted array.
  19026. * @example
  19027. *
  19028. * var users = [
  19029. * { 'user': 'fred', 'age': 48 },
  19030. * { 'user': 'barney', 'age': 34 },
  19031. * { 'user': 'fred', 'age': 40 },
  19032. * { 'user': 'barney', 'age': 36 }
  19033. * ];
  19034. *
  19035. * // Sort by `user` in ascending order and by `age` in descending order.
  19036. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  19037. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  19038. */
  19039. function orderBy(collection, iteratees, orders, guard) {
  19040. if (collection == null) {
  19041. return [];
  19042. }
  19043. if (!isArray(iteratees)) {
  19044. iteratees = iteratees == null ? [] : [iteratees];
  19045. }
  19046. orders = guard ? undefined : orders;
  19047. if (!isArray(orders)) {
  19048. orders = orders == null ? [] : [orders];
  19049. }
  19050. return baseOrderBy(collection, iteratees, orders);
  19051. }
  19052. /**
  19053. * Creates an array of elements split into two groups, the first of which
  19054. * contains elements `predicate` returns truthy for, the second of which
  19055. * contains elements `predicate` returns falsey for. The predicate is
  19056. * invoked with one argument: (value).
  19057. *
  19058. * @static
  19059. * @memberOf _
  19060. * @since 3.0.0
  19061. * @category Collection
  19062. * @param {Array|Object} collection The collection to iterate over.
  19063. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  19064. * @returns {Array} Returns the array of grouped elements.
  19065. * @example
  19066. *
  19067. * var users = [
  19068. * { 'user': 'barney', 'age': 36, 'active': false },
  19069. * { 'user': 'fred', 'age': 40, 'active': true },
  19070. * { 'user': 'pebbles', 'age': 1, 'active': false }
  19071. * ];
  19072. *
  19073. * _.partition(users, function(o) { return o.active; });
  19074. * // => objects for [['fred'], ['barney', 'pebbles']]
  19075. *
  19076. * // The `_.matches` iteratee shorthand.
  19077. * _.partition(users, { 'age': 1, 'active': false });
  19078. * // => objects for [['pebbles'], ['barney', 'fred']]
  19079. *
  19080. * // The `_.matchesProperty` iteratee shorthand.
  19081. * _.partition(users, ['active', false]);
  19082. * // => objects for [['barney', 'pebbles'], ['fred']]
  19083. *
  19084. * // The `_.property` iteratee shorthand.
  19085. * _.partition(users, 'active');
  19086. * // => objects for [['fred'], ['barney', 'pebbles']]
  19087. */
  19088. var partition = createAggregator(function(result, value, key) {
  19089. result[key ? 0 : 1].push(value);
  19090. }, function() { return [[], []]; });
  19091. /**
  19092. * Reduces `collection` to a value which is the accumulated result of running
  19093. * each element in `collection` thru `iteratee`, where each successive
  19094. * invocation is supplied the return value of the previous. If `accumulator`
  19095. * is not given, the first element of `collection` is used as the initial
  19096. * value. The iteratee is invoked with four arguments:
  19097. * (accumulator, value, index|key, collection).
  19098. *
  19099. * Many lodash methods are guarded to work as iteratees for methods like
  19100. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  19101. *
  19102. * The guarded methods are:
  19103. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  19104. * and `sortBy`
  19105. *
  19106. * @static
  19107. * @memberOf _
  19108. * @since 0.1.0
  19109. * @category Collection
  19110. * @param {Array|Object} collection The collection to iterate over.
  19111. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  19112. * @param {*} [accumulator] The initial value.
  19113. * @returns {*} Returns the accumulated value.
  19114. * @see _.reduceRight
  19115. * @example
  19116. *
  19117. * _.reduce([1, 2], function(sum, n) {
  19118. * return sum + n;
  19119. * }, 0);
  19120. * // => 3
  19121. *
  19122. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  19123. * (result[value] || (result[value] = [])).push(key);
  19124. * return result;
  19125. * }, {});
  19126. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  19127. */
  19128. function reduce(collection, iteratee, accumulator) {
  19129. var func = isArray(collection) ? arrayReduce : baseReduce,
  19130. initAccum = arguments.length < 3;
  19131. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  19132. }
  19133. /**
  19134. * This method is like `_.reduce` except that it iterates over elements of
  19135. * `collection` from right to left.
  19136. *
  19137. * @static
  19138. * @memberOf _
  19139. * @since 0.1.0
  19140. * @category Collection
  19141. * @param {Array|Object} collection The collection to iterate over.
  19142. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  19143. * @param {*} [accumulator] The initial value.
  19144. * @returns {*} Returns the accumulated value.
  19145. * @see _.reduce
  19146. * @example
  19147. *
  19148. * var array = [[0, 1], [2, 3], [4, 5]];
  19149. *
  19150. * _.reduceRight(array, function(flattened, other) {
  19151. * return flattened.concat(other);
  19152. * }, []);
  19153. * // => [4, 5, 2, 3, 0, 1]
  19154. */
  19155. function reduceRight(collection, iteratee, accumulator) {
  19156. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  19157. initAccum = arguments.length < 3;
  19158. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  19159. }
  19160. /**
  19161. * The opposite of `_.filter`; this method returns the elements of `collection`
  19162. * that `predicate` does **not** return truthy for.
  19163. *
  19164. * @static
  19165. * @memberOf _
  19166. * @since 0.1.0
  19167. * @category Collection
  19168. * @param {Array|Object} collection The collection to iterate over.
  19169. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  19170. * @returns {Array} Returns the new filtered array.
  19171. * @see _.filter
  19172. * @example
  19173. *
  19174. * var users = [
  19175. * { 'user': 'barney', 'age': 36, 'active': false },
  19176. * { 'user': 'fred', 'age': 40, 'active': true }
  19177. * ];
  19178. *
  19179. * _.reject(users, function(o) { return !o.active; });
  19180. * // => objects for ['fred']
  19181. *
  19182. * // The `_.matches` iteratee shorthand.
  19183. * _.reject(users, { 'age': 40, 'active': true });
  19184. * // => objects for ['barney']
  19185. *
  19186. * // The `_.matchesProperty` iteratee shorthand.
  19187. * _.reject(users, ['active', false]);
  19188. * // => objects for ['fred']
  19189. *
  19190. * // The `_.property` iteratee shorthand.
  19191. * _.reject(users, 'active');
  19192. * // => objects for ['barney']
  19193. */
  19194. function reject(collection, predicate) {
  19195. var func = isArray(collection) ? arrayFilter : baseFilter;
  19196. return func(collection, negate(getIteratee(predicate, 3)));
  19197. }
  19198. /**
  19199. * Gets a random element from `collection`.
  19200. *
  19201. * @static
  19202. * @memberOf _
  19203. * @since 2.0.0
  19204. * @category Collection
  19205. * @param {Array|Object} collection The collection to sample.
  19206. * @returns {*} Returns the random element.
  19207. * @example
  19208. *
  19209. * _.sample([1, 2, 3, 4]);
  19210. * // => 2
  19211. */
  19212. function sample(collection) {
  19213. var func = isArray(collection) ? arraySample : baseSample;
  19214. return func(collection);
  19215. }
  19216. /**
  19217. * Gets `n` random elements at unique keys from `collection` up to the
  19218. * size of `collection`.
  19219. *
  19220. * @static
  19221. * @memberOf _
  19222. * @since 4.0.0
  19223. * @category Collection
  19224. * @param {Array|Object} collection The collection to sample.
  19225. * @param {number} [n=1] The number of elements to sample.
  19226. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  19227. * @returns {Array} Returns the random elements.
  19228. * @example
  19229. *
  19230. * _.sampleSize([1, 2, 3], 2);
  19231. * // => [3, 1]
  19232. *
  19233. * _.sampleSize([1, 2, 3], 4);
  19234. * // => [2, 3, 1]
  19235. */
  19236. function sampleSize(collection, n, guard) {
  19237. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  19238. n = 1;
  19239. } else {
  19240. n = toInteger(n);
  19241. }
  19242. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  19243. return func(collection, n);
  19244. }
  19245. /**
  19246. * Creates an array of shuffled values, using a version of the
  19247. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  19248. *
  19249. * @static
  19250. * @memberOf _
  19251. * @since 0.1.0
  19252. * @category Collection
  19253. * @param {Array|Object} collection The collection to shuffle.
  19254. * @returns {Array} Returns the new shuffled array.
  19255. * @example
  19256. *
  19257. * _.shuffle([1, 2, 3, 4]);
  19258. * // => [4, 1, 3, 2]
  19259. */
  19260. function shuffle(collection) {
  19261. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  19262. return func(collection);
  19263. }
  19264. /**
  19265. * Gets the size of `collection` by returning its length for array-like
  19266. * values or the number of own enumerable string keyed properties for objects.
  19267. *
  19268. * @static
  19269. * @memberOf _
  19270. * @since 0.1.0
  19271. * @category Collection
  19272. * @param {Array|Object|string} collection The collection to inspect.
  19273. * @returns {number} Returns the collection size.
  19274. * @example
  19275. *
  19276. * _.size([1, 2, 3]);
  19277. * // => 3
  19278. *
  19279. * _.size({ 'a': 1, 'b': 2 });
  19280. * // => 2
  19281. *
  19282. * _.size('pebbles');
  19283. * // => 7
  19284. */
  19285. function size(collection) {
  19286. if (collection == null) {
  19287. return 0;
  19288. }
  19289. if (isArrayLike(collection)) {
  19290. return isString(collection) ? stringSize(collection) : collection.length;
  19291. }
  19292. var tag = getTag(collection);
  19293. if (tag == mapTag || tag == setTag) {
  19294. return collection.size;
  19295. }
  19296. return baseKeys(collection).length;
  19297. }
  19298. /**
  19299. * Checks if `predicate` returns truthy for **any** element of `collection`.
  19300. * Iteration is stopped once `predicate` returns truthy. The predicate is
  19301. * invoked with three arguments: (value, index|key, collection).
  19302. *
  19303. * @static
  19304. * @memberOf _
  19305. * @since 0.1.0
  19306. * @category Collection
  19307. * @param {Array|Object} collection The collection to iterate over.
  19308. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  19309. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  19310. * @returns {boolean} Returns `true` if any element passes the predicate check,
  19311. * else `false`.
  19312. * @example
  19313. *
  19314. * _.some([null, 0, 'yes', false], Boolean);
  19315. * // => true
  19316. *
  19317. * var users = [
  19318. * { 'user': 'barney', 'active': true },
  19319. * { 'user': 'fred', 'active': false }
  19320. * ];
  19321. *
  19322. * // The `_.matches` iteratee shorthand.
  19323. * _.some(users, { 'user': 'barney', 'active': false });
  19324. * // => false
  19325. *
  19326. * // The `_.matchesProperty` iteratee shorthand.
  19327. * _.some(users, ['active', false]);
  19328. * // => true
  19329. *
  19330. * // The `_.property` iteratee shorthand.
  19331. * _.some(users, 'active');
  19332. * // => true
  19333. */
  19334. function some(collection, predicate, guard) {
  19335. var func = isArray(collection) ? arraySome : baseSome;
  19336. if (guard && isIterateeCall(collection, predicate, guard)) {
  19337. predicate = undefined;
  19338. }
  19339. return func(collection, getIteratee(predicate, 3));
  19340. }
  19341. /**
  19342. * Creates an array of elements, sorted in ascending order by the results of
  19343. * running each element in a collection thru each iteratee. This method
  19344. * performs a stable sort, that is, it preserves the original sort order of
  19345. * equal elements. The iteratees are invoked with one argument: (value).
  19346. *
  19347. * @static
  19348. * @memberOf _
  19349. * @since 0.1.0
  19350. * @category Collection
  19351. * @param {Array|Object} collection The collection to iterate over.
  19352. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  19353. * The iteratees to sort by.
  19354. * @returns {Array} Returns the new sorted array.
  19355. * @example
  19356. *
  19357. * var users = [
  19358. * { 'user': 'fred', 'age': 48 },
  19359. * { 'user': 'barney', 'age': 36 },
  19360. * { 'user': 'fred', 'age': 40 },
  19361. * { 'user': 'barney', 'age': 34 }
  19362. * ];
  19363. *
  19364. * _.sortBy(users, [function(o) { return o.user; }]);
  19365. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  19366. *
  19367. * _.sortBy(users, ['user', 'age']);
  19368. * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
  19369. */
  19370. var sortBy = baseRest(function(collection, iteratees) {
  19371. if (collection == null) {
  19372. return [];
  19373. }
  19374. var length = iteratees.length;
  19375. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  19376. iteratees = [];
  19377. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  19378. iteratees = [iteratees[0]];
  19379. }
  19380. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  19381. });
  19382. /*------------------------------------------------------------------------*/
  19383. /**
  19384. * Gets the timestamp of the number of milliseconds that have elapsed since
  19385. * the Unix epoch (1 January 1970 00:00:00 UTC).
  19386. *
  19387. * @static
  19388. * @memberOf _
  19389. * @since 2.4.0
  19390. * @category Date
  19391. * @returns {number} Returns the timestamp.
  19392. * @example
  19393. *
  19394. * _.defer(function(stamp) {
  19395. * console.log(_.now() - stamp);
  19396. * }, _.now());
  19397. * // => Logs the number of milliseconds it took for the deferred invocation.
  19398. */
  19399. var now = ctxNow || function() {
  19400. return root.Date.now();
  19401. };
  19402. /*------------------------------------------------------------------------*/
  19403. /**
  19404. * The opposite of `_.before`; this method creates a function that invokes
  19405. * `func` once it's called `n` or more times.
  19406. *
  19407. * @static
  19408. * @memberOf _
  19409. * @since 0.1.0
  19410. * @category Function
  19411. * @param {number} n The number of calls before `func` is invoked.
  19412. * @param {Function} func The function to restrict.
  19413. * @returns {Function} Returns the new restricted function.
  19414. * @example
  19415. *
  19416. * var saves = ['profile', 'settings'];
  19417. *
  19418. * var done = _.after(saves.length, function() {
  19419. * console.log('done saving!');
  19420. * });
  19421. *
  19422. * _.forEach(saves, function(type) {
  19423. * asyncSave({ 'type': type, 'complete': done });
  19424. * });
  19425. * // => Logs 'done saving!' after the two async saves have completed.
  19426. */
  19427. function after(n, func) {
  19428. if (typeof func != 'function') {
  19429. throw new TypeError(FUNC_ERROR_TEXT);
  19430. }
  19431. n = toInteger(n);
  19432. return function() {
  19433. if (--n < 1) {
  19434. return func.apply(this, arguments);
  19435. }
  19436. };
  19437. }
  19438. /**
  19439. * Creates a function that invokes `func`, with up to `n` arguments,
  19440. * ignoring any additional arguments.
  19441. *
  19442. * @static
  19443. * @memberOf _
  19444. * @since 3.0.0
  19445. * @category Function
  19446. * @param {Function} func The function to cap arguments for.
  19447. * @param {number} [n=func.length] The arity cap.
  19448. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  19449. * @returns {Function} Returns the new capped function.
  19450. * @example
  19451. *
  19452. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  19453. * // => [6, 8, 10]
  19454. */
  19455. function ary(func, n, guard) {
  19456. n = guard ? undefined : n;
  19457. n = (func && n == null) ? func.length : n;
  19458. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  19459. }
  19460. /**
  19461. * Creates a function that invokes `func`, with the `this` binding and arguments
  19462. * of the created function, while it's called less than `n` times. Subsequent
  19463. * calls to the created function return the result of the last `func` invocation.
  19464. *
  19465. * @static
  19466. * @memberOf _
  19467. * @since 3.0.0
  19468. * @category Function
  19469. * @param {number} n The number of calls at which `func` is no longer invoked.
  19470. * @param {Function} func The function to restrict.
  19471. * @returns {Function} Returns the new restricted function.
  19472. * @example
  19473. *
  19474. * jQuery(element).on('click', _.before(5, addContactToList));
  19475. * // => Allows adding up to 4 contacts to the list.
  19476. */
  19477. function before(n, func) {
  19478. var result;
  19479. if (typeof func != 'function') {
  19480. throw new TypeError(FUNC_ERROR_TEXT);
  19481. }
  19482. n = toInteger(n);
  19483. return function() {
  19484. if (--n > 0) {
  19485. result = func.apply(this, arguments);
  19486. }
  19487. if (n <= 1) {
  19488. func = undefined;
  19489. }
  19490. return result;
  19491. };
  19492. }
  19493. /**
  19494. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  19495. * and `partials` prepended to the arguments it receives.
  19496. *
  19497. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  19498. * may be used as a placeholder for partially applied arguments.
  19499. *
  19500. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  19501. * property of bound functions.
  19502. *
  19503. * @static
  19504. * @memberOf _
  19505. * @since 0.1.0
  19506. * @category Function
  19507. * @param {Function} func The function to bind.
  19508. * @param {*} thisArg The `this` binding of `func`.
  19509. * @param {...*} [partials] The arguments to be partially applied.
  19510. * @returns {Function} Returns the new bound function.
  19511. * @example
  19512. *
  19513. * function greet(greeting, punctuation) {
  19514. * return greeting + ' ' + this.user + punctuation;
  19515. * }
  19516. *
  19517. * var object = { 'user': 'fred' };
  19518. *
  19519. * var bound = _.bind(greet, object, 'hi');
  19520. * bound('!');
  19521. * // => 'hi fred!'
  19522. *
  19523. * // Bound with placeholders.
  19524. * var bound = _.bind(greet, object, _, '!');
  19525. * bound('hi');
  19526. * // => 'hi fred!'
  19527. */
  19528. var bind = baseRest(function(func, thisArg, partials) {
  19529. var bitmask = WRAP_BIND_FLAG;
  19530. if (partials.length) {
  19531. var holders = replaceHolders(partials, getHolder(bind));
  19532. bitmask |= WRAP_PARTIAL_FLAG;
  19533. }
  19534. return createWrap(func, bitmask, thisArg, partials, holders);
  19535. });
  19536. /**
  19537. * Creates a function that invokes the method at `object[key]` with `partials`
  19538. * prepended to the arguments it receives.
  19539. *
  19540. * This method differs from `_.bind` by allowing bound functions to reference
  19541. * methods that may be redefined or don't yet exist. See
  19542. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  19543. * for more details.
  19544. *
  19545. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  19546. * builds, may be used as a placeholder for partially applied arguments.
  19547. *
  19548. * @static
  19549. * @memberOf _
  19550. * @since 0.10.0
  19551. * @category Function
  19552. * @param {Object} object The object to invoke the method on.
  19553. * @param {string} key The key of the method.
  19554. * @param {...*} [partials] The arguments to be partially applied.
  19555. * @returns {Function} Returns the new bound function.
  19556. * @example
  19557. *
  19558. * var object = {
  19559. * 'user': 'fred',
  19560. * 'greet': function(greeting, punctuation) {
  19561. * return greeting + ' ' + this.user + punctuation;
  19562. * }
  19563. * };
  19564. *
  19565. * var bound = _.bindKey(object, 'greet', 'hi');
  19566. * bound('!');
  19567. * // => 'hi fred!'
  19568. *
  19569. * object.greet = function(greeting, punctuation) {
  19570. * return greeting + 'ya ' + this.user + punctuation;
  19571. * };
  19572. *
  19573. * bound('!');
  19574. * // => 'hiya fred!'
  19575. *
  19576. * // Bound with placeholders.
  19577. * var bound = _.bindKey(object, 'greet', _, '!');
  19578. * bound('hi');
  19579. * // => 'hiya fred!'
  19580. */
  19581. var bindKey = baseRest(function(object, key, partials) {
  19582. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  19583. if (partials.length) {
  19584. var holders = replaceHolders(partials, getHolder(bindKey));
  19585. bitmask |= WRAP_PARTIAL_FLAG;
  19586. }
  19587. return createWrap(key, bitmask, object, partials, holders);
  19588. });
  19589. /**
  19590. * Creates a function that accepts arguments of `func` and either invokes
  19591. * `func` returning its result, if at least `arity` number of arguments have
  19592. * been provided, or returns a function that accepts the remaining `func`
  19593. * arguments, and so on. The arity of `func` may be specified if `func.length`
  19594. * is not sufficient.
  19595. *
  19596. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  19597. * may be used as a placeholder for provided arguments.
  19598. *
  19599. * **Note:** This method doesn't set the "length" property of curried functions.
  19600. *
  19601. * @static
  19602. * @memberOf _
  19603. * @since 2.0.0
  19604. * @category Function
  19605. * @param {Function} func The function to curry.
  19606. * @param {number} [arity=func.length] The arity of `func`.
  19607. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  19608. * @returns {Function} Returns the new curried function.
  19609. * @example
  19610. *
  19611. * var abc = function(a, b, c) {
  19612. * return [a, b, c];
  19613. * };
  19614. *
  19615. * var curried = _.curry(abc);
  19616. *
  19617. * curried(1)(2)(3);
  19618. * // => [1, 2, 3]
  19619. *
  19620. * curried(1, 2)(3);
  19621. * // => [1, 2, 3]
  19622. *
  19623. * curried(1, 2, 3);
  19624. * // => [1, 2, 3]
  19625. *
  19626. * // Curried with placeholders.
  19627. * curried(1)(_, 3)(2);
  19628. * // => [1, 2, 3]
  19629. */
  19630. function curry(func, arity, guard) {
  19631. arity = guard ? undefined : arity;
  19632. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  19633. result.placeholder = curry.placeholder;
  19634. return result;
  19635. }
  19636. /**
  19637. * This method is like `_.curry` except that arguments are applied to `func`
  19638. * in the manner of `_.partialRight` instead of `_.partial`.
  19639. *
  19640. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  19641. * builds, may be used as a placeholder for provided arguments.
  19642. *
  19643. * **Note:** This method doesn't set the "length" property of curried functions.
  19644. *
  19645. * @static
  19646. * @memberOf _
  19647. * @since 3.0.0
  19648. * @category Function
  19649. * @param {Function} func The function to curry.
  19650. * @param {number} [arity=func.length] The arity of `func`.
  19651. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  19652. * @returns {Function} Returns the new curried function.
  19653. * @example
  19654. *
  19655. * var abc = function(a, b, c) {
  19656. * return [a, b, c];
  19657. * };
  19658. *
  19659. * var curried = _.curryRight(abc);
  19660. *
  19661. * curried(3)(2)(1);
  19662. * // => [1, 2, 3]
  19663. *
  19664. * curried(2, 3)(1);
  19665. * // => [1, 2, 3]
  19666. *
  19667. * curried(1, 2, 3);
  19668. * // => [1, 2, 3]
  19669. *
  19670. * // Curried with placeholders.
  19671. * curried(3)(1, _)(2);
  19672. * // => [1, 2, 3]
  19673. */
  19674. function curryRight(func, arity, guard) {
  19675. arity = guard ? undefined : arity;
  19676. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  19677. result.placeholder = curryRight.placeholder;
  19678. return result;
  19679. }
  19680. /**
  19681. * Creates a debounced function that delays invoking `func` until after `wait`
  19682. * milliseconds have elapsed since the last time the debounced function was
  19683. * invoked. The debounced function comes with a `cancel` method to cancel
  19684. * delayed `func` invocations and a `flush` method to immediately invoke them.
  19685. * Provide `options` to indicate whether `func` should be invoked on the
  19686. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  19687. * with the last arguments provided to the debounced function. Subsequent
  19688. * calls to the debounced function return the result of the last `func`
  19689. * invocation.
  19690. *
  19691. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  19692. * invoked on the trailing edge of the timeout only if the debounced function
  19693. * is invoked more than once during the `wait` timeout.
  19694. *
  19695. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  19696. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  19697. *
  19698. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  19699. * for details over the differences between `_.debounce` and `_.throttle`.
  19700. *
  19701. * @static
  19702. * @memberOf _
  19703. * @since 0.1.0
  19704. * @category Function
  19705. * @param {Function} func The function to debounce.
  19706. * @param {number} [wait=0] The number of milliseconds to delay.
  19707. * @param {Object} [options={}] The options object.
  19708. * @param {boolean} [options.leading=false]
  19709. * Specify invoking on the leading edge of the timeout.
  19710. * @param {number} [options.maxWait]
  19711. * The maximum time `func` is allowed to be delayed before it's invoked.
  19712. * @param {boolean} [options.trailing=true]
  19713. * Specify invoking on the trailing edge of the timeout.
  19714. * @returns {Function} Returns the new debounced function.
  19715. * @example
  19716. *
  19717. * // Avoid costly calculations while the window size is in flux.
  19718. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  19719. *
  19720. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  19721. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  19722. * 'leading': true,
  19723. * 'trailing': false
  19724. * }));
  19725. *
  19726. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  19727. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  19728. * var source = new EventSource('/stream');
  19729. * jQuery(source).on('message', debounced);
  19730. *
  19731. * // Cancel the trailing debounced invocation.
  19732. * jQuery(window).on('popstate', debounced.cancel);
  19733. */
  19734. function debounce(func, wait, options) {
  19735. var lastArgs,
  19736. lastThis,
  19737. maxWait,
  19738. result,
  19739. timerId,
  19740. lastCallTime,
  19741. lastInvokeTime = 0,
  19742. leading = false,
  19743. maxing = false,
  19744. trailing = true;
  19745. if (typeof func != 'function') {
  19746. throw new TypeError(FUNC_ERROR_TEXT);
  19747. }
  19748. wait = toNumber(wait) || 0;
  19749. if (isObject(options)) {
  19750. leading = !!options.leading;
  19751. maxing = 'maxWait' in options;
  19752. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  19753. trailing = 'trailing' in options ? !!options.trailing : trailing;
  19754. }
  19755. function invokeFunc(time) {
  19756. var args = lastArgs,
  19757. thisArg = lastThis;
  19758. lastArgs = lastThis = undefined;
  19759. lastInvokeTime = time;
  19760. result = func.apply(thisArg, args);
  19761. return result;
  19762. }
  19763. function leadingEdge(time) {
  19764. // Reset any `maxWait` timer.
  19765. lastInvokeTime = time;
  19766. // Start the timer for the trailing edge.
  19767. timerId = setTimeout(timerExpired, wait);
  19768. // Invoke the leading edge.
  19769. return leading ? invokeFunc(time) : result;
  19770. }
  19771. function remainingWait(time) {
  19772. var timeSinceLastCall = time - lastCallTime,
  19773. timeSinceLastInvoke = time - lastInvokeTime,
  19774. timeWaiting = wait - timeSinceLastCall;
  19775. return maxing
  19776. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  19777. : timeWaiting;
  19778. }
  19779. function shouldInvoke(time) {
  19780. var timeSinceLastCall = time - lastCallTime,
  19781. timeSinceLastInvoke = time - lastInvokeTime;
  19782. // Either this is the first call, activity has stopped and we're at the
  19783. // trailing edge, the system time has gone backwards and we're treating
  19784. // it as the trailing edge, or we've hit the `maxWait` limit.
  19785. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  19786. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  19787. }
  19788. function timerExpired() {
  19789. var time = now();
  19790. if (shouldInvoke(time)) {
  19791. return trailingEdge(time);
  19792. }
  19793. // Restart the timer.
  19794. timerId = setTimeout(timerExpired, remainingWait(time));
  19795. }
  19796. function trailingEdge(time) {
  19797. timerId = undefined;
  19798. // Only invoke if we have `lastArgs` which means `func` has been
  19799. // debounced at least once.
  19800. if (trailing && lastArgs) {
  19801. return invokeFunc(time);
  19802. }
  19803. lastArgs = lastThis = undefined;
  19804. return result;
  19805. }
  19806. function cancel() {
  19807. if (timerId !== undefined) {
  19808. clearTimeout(timerId);
  19809. }
  19810. lastInvokeTime = 0;
  19811. lastArgs = lastCallTime = lastThis = timerId = undefined;
  19812. }
  19813. function flush() {
  19814. return timerId === undefined ? result : trailingEdge(now());
  19815. }
  19816. function debounced() {
  19817. var time = now(),
  19818. isInvoking = shouldInvoke(time);
  19819. lastArgs = arguments;
  19820. lastThis = this;
  19821. lastCallTime = time;
  19822. if (isInvoking) {
  19823. if (timerId === undefined) {
  19824. return leadingEdge(lastCallTime);
  19825. }
  19826. if (maxing) {
  19827. // Handle invocations in a tight loop.
  19828. clearTimeout(timerId);
  19829. timerId = setTimeout(timerExpired, wait);
  19830. return invokeFunc(lastCallTime);
  19831. }
  19832. }
  19833. if (timerId === undefined) {
  19834. timerId = setTimeout(timerExpired, wait);
  19835. }
  19836. return result;
  19837. }
  19838. debounced.cancel = cancel;
  19839. debounced.flush = flush;
  19840. return debounced;
  19841. }
  19842. /**
  19843. * Defers invoking the `func` until the current call stack has cleared. Any
  19844. * additional arguments are provided to `func` when it's invoked.
  19845. *
  19846. * @static
  19847. * @memberOf _
  19848. * @since 0.1.0
  19849. * @category Function
  19850. * @param {Function} func The function to defer.
  19851. * @param {...*} [args] The arguments to invoke `func` with.
  19852. * @returns {number} Returns the timer id.
  19853. * @example
  19854. *
  19855. * _.defer(function(text) {
  19856. * console.log(text);
  19857. * }, 'deferred');
  19858. * // => Logs 'deferred' after one millisecond.
  19859. */
  19860. var defer = baseRest(function(func, args) {
  19861. return baseDelay(func, 1, args);
  19862. });
  19863. /**
  19864. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  19865. * provided to `func` when it's invoked.
  19866. *
  19867. * @static
  19868. * @memberOf _
  19869. * @since 0.1.0
  19870. * @category Function
  19871. * @param {Function} func The function to delay.
  19872. * @param {number} wait The number of milliseconds to delay invocation.
  19873. * @param {...*} [args] The arguments to invoke `func` with.
  19874. * @returns {number} Returns the timer id.
  19875. * @example
  19876. *
  19877. * _.delay(function(text) {
  19878. * console.log(text);
  19879. * }, 1000, 'later');
  19880. * // => Logs 'later' after one second.
  19881. */
  19882. var delay = baseRest(function(func, wait, args) {
  19883. return baseDelay(func, toNumber(wait) || 0, args);
  19884. });
  19885. /**
  19886. * Creates a function that invokes `func` with arguments reversed.
  19887. *
  19888. * @static
  19889. * @memberOf _
  19890. * @since 4.0.0
  19891. * @category Function
  19892. * @param {Function} func The function to flip arguments for.
  19893. * @returns {Function} Returns the new flipped function.
  19894. * @example
  19895. *
  19896. * var flipped = _.flip(function() {
  19897. * return _.toArray(arguments);
  19898. * });
  19899. *
  19900. * flipped('a', 'b', 'c', 'd');
  19901. * // => ['d', 'c', 'b', 'a']
  19902. */
  19903. function flip(func) {
  19904. return createWrap(func, WRAP_FLIP_FLAG);
  19905. }
  19906. /**
  19907. * Creates a function that memoizes the result of `func`. If `resolver` is
  19908. * provided, it determines the cache key for storing the result based on the
  19909. * arguments provided to the memoized function. By default, the first argument
  19910. * provided to the memoized function is used as the map cache key. The `func`
  19911. * is invoked with the `this` binding of the memoized function.
  19912. *
  19913. * **Note:** The cache is exposed as the `cache` property on the memoized
  19914. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  19915. * constructor with one whose instances implement the
  19916. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  19917. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  19918. *
  19919. * @static
  19920. * @memberOf _
  19921. * @since 0.1.0
  19922. * @category Function
  19923. * @param {Function} func The function to have its output memoized.
  19924. * @param {Function} [resolver] The function to resolve the cache key.
  19925. * @returns {Function} Returns the new memoized function.
  19926. * @example
  19927. *
  19928. * var object = { 'a': 1, 'b': 2 };
  19929. * var other = { 'c': 3, 'd': 4 };
  19930. *
  19931. * var values = _.memoize(_.values);
  19932. * values(object);
  19933. * // => [1, 2]
  19934. *
  19935. * values(other);
  19936. * // => [3, 4]
  19937. *
  19938. * object.a = 2;
  19939. * values(object);
  19940. * // => [1, 2]
  19941. *
  19942. * // Modify the result cache.
  19943. * values.cache.set(object, ['a', 'b']);
  19944. * values(object);
  19945. * // => ['a', 'b']
  19946. *
  19947. * // Replace `_.memoize.Cache`.
  19948. * _.memoize.Cache = WeakMap;
  19949. */
  19950. function memoize(func, resolver) {
  19951. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  19952. throw new TypeError(FUNC_ERROR_TEXT);
  19953. }
  19954. var memoized = function() {
  19955. var args = arguments,
  19956. key = resolver ? resolver.apply(this, args) : args[0],
  19957. cache = memoized.cache;
  19958. if (cache.has(key)) {
  19959. return cache.get(key);
  19960. }
  19961. var result = func.apply(this, args);
  19962. memoized.cache = cache.set(key, result) || cache;
  19963. return result;
  19964. };
  19965. memoized.cache = new (memoize.Cache || MapCache);
  19966. return memoized;
  19967. }
  19968. // Expose `MapCache`.
  19969. memoize.Cache = MapCache;
  19970. /**
  19971. * Creates a function that negates the result of the predicate `func`. The
  19972. * `func` predicate is invoked with the `this` binding and arguments of the
  19973. * created function.
  19974. *
  19975. * @static
  19976. * @memberOf _
  19977. * @since 3.0.0
  19978. * @category Function
  19979. * @param {Function} predicate The predicate to negate.
  19980. * @returns {Function} Returns the new negated function.
  19981. * @example
  19982. *
  19983. * function isEven(n) {
  19984. * return n % 2 == 0;
  19985. * }
  19986. *
  19987. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  19988. * // => [1, 3, 5]
  19989. */
  19990. function negate(predicate) {
  19991. if (typeof predicate != 'function') {
  19992. throw new TypeError(FUNC_ERROR_TEXT);
  19993. }
  19994. return function() {
  19995. var args = arguments;
  19996. switch (args.length) {
  19997. case 0: return !predicate.call(this);
  19998. case 1: return !predicate.call(this, args[0]);
  19999. case 2: return !predicate.call(this, args[0], args[1]);
  20000. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  20001. }
  20002. return !predicate.apply(this, args);
  20003. };
  20004. }
  20005. /**
  20006. * Creates a function that is restricted to invoking `func` once. Repeat calls
  20007. * to the function return the value of the first invocation. The `func` is
  20008. * invoked with the `this` binding and arguments of the created function.
  20009. *
  20010. * @static
  20011. * @memberOf _
  20012. * @since 0.1.0
  20013. * @category Function
  20014. * @param {Function} func The function to restrict.
  20015. * @returns {Function} Returns the new restricted function.
  20016. * @example
  20017. *
  20018. * var initialize = _.once(createApplication);
  20019. * initialize();
  20020. * initialize();
  20021. * // => `createApplication` is invoked once
  20022. */
  20023. function once(func) {
  20024. return before(2, func);
  20025. }
  20026. /**
  20027. * Creates a function that invokes `func` with its arguments transformed.
  20028. *
  20029. * @static
  20030. * @since 4.0.0
  20031. * @memberOf _
  20032. * @category Function
  20033. * @param {Function} func The function to wrap.
  20034. * @param {...(Function|Function[])} [transforms=[_.identity]]
  20035. * The argument transforms.
  20036. * @returns {Function} Returns the new function.
  20037. * @example
  20038. *
  20039. * function doubled(n) {
  20040. * return n * 2;
  20041. * }
  20042. *
  20043. * function square(n) {
  20044. * return n * n;
  20045. * }
  20046. *
  20047. * var func = _.overArgs(function(x, y) {
  20048. * return [x, y];
  20049. * }, [square, doubled]);
  20050. *
  20051. * func(9, 3);
  20052. * // => [81, 6]
  20053. *
  20054. * func(10, 5);
  20055. * // => [100, 10]
  20056. */
  20057. var overArgs = castRest(function(func, transforms) {
  20058. transforms = (transforms.length == 1 && isArray(transforms[0]))
  20059. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  20060. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  20061. var funcsLength = transforms.length;
  20062. return baseRest(function(args) {
  20063. var index = -1,
  20064. length = nativeMin(args.length, funcsLength);
  20065. while (++index < length) {
  20066. args[index] = transforms[index].call(this, args[index]);
  20067. }
  20068. return apply(func, this, args);
  20069. });
  20070. });
  20071. /**
  20072. * Creates a function that invokes `func` with `partials` prepended to the
  20073. * arguments it receives. This method is like `_.bind` except it does **not**
  20074. * alter the `this` binding.
  20075. *
  20076. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  20077. * builds, may be used as a placeholder for partially applied arguments.
  20078. *
  20079. * **Note:** This method doesn't set the "length" property of partially
  20080. * applied functions.
  20081. *
  20082. * @static
  20083. * @memberOf _
  20084. * @since 0.2.0
  20085. * @category Function
  20086. * @param {Function} func The function to partially apply arguments to.
  20087. * @param {...*} [partials] The arguments to be partially applied.
  20088. * @returns {Function} Returns the new partially applied function.
  20089. * @example
  20090. *
  20091. * function greet(greeting, name) {
  20092. * return greeting + ' ' + name;
  20093. * }
  20094. *
  20095. * var sayHelloTo = _.partial(greet, 'hello');
  20096. * sayHelloTo('fred');
  20097. * // => 'hello fred'
  20098. *
  20099. * // Partially applied with placeholders.
  20100. * var greetFred = _.partial(greet, _, 'fred');
  20101. * greetFred('hi');
  20102. * // => 'hi fred'
  20103. */
  20104. var partial = baseRest(function(func, partials) {
  20105. var holders = replaceHolders(partials, getHolder(partial));
  20106. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  20107. });
  20108. /**
  20109. * This method is like `_.partial` except that partially applied arguments
  20110. * are appended to the arguments it receives.
  20111. *
  20112. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  20113. * builds, may be used as a placeholder for partially applied arguments.
  20114. *
  20115. * **Note:** This method doesn't set the "length" property of partially
  20116. * applied functions.
  20117. *
  20118. * @static
  20119. * @memberOf _
  20120. * @since 1.0.0
  20121. * @category Function
  20122. * @param {Function} func The function to partially apply arguments to.
  20123. * @param {...*} [partials] The arguments to be partially applied.
  20124. * @returns {Function} Returns the new partially applied function.
  20125. * @example
  20126. *
  20127. * function greet(greeting, name) {
  20128. * return greeting + ' ' + name;
  20129. * }
  20130. *
  20131. * var greetFred = _.partialRight(greet, 'fred');
  20132. * greetFred('hi');
  20133. * // => 'hi fred'
  20134. *
  20135. * // Partially applied with placeholders.
  20136. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  20137. * sayHelloTo('fred');
  20138. * // => 'hello fred'
  20139. */
  20140. var partialRight = baseRest(function(func, partials) {
  20141. var holders = replaceHolders(partials, getHolder(partialRight));
  20142. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  20143. });
  20144. /**
  20145. * Creates a function that invokes `func` with arguments arranged according
  20146. * to the specified `indexes` where the argument value at the first index is
  20147. * provided as the first argument, the argument value at the second index is
  20148. * provided as the second argument, and so on.
  20149. *
  20150. * @static
  20151. * @memberOf _
  20152. * @since 3.0.0
  20153. * @category Function
  20154. * @param {Function} func The function to rearrange arguments for.
  20155. * @param {...(number|number[])} indexes The arranged argument indexes.
  20156. * @returns {Function} Returns the new function.
  20157. * @example
  20158. *
  20159. * var rearged = _.rearg(function(a, b, c) {
  20160. * return [a, b, c];
  20161. * }, [2, 0, 1]);
  20162. *
  20163. * rearged('b', 'c', 'a')
  20164. * // => ['a', 'b', 'c']
  20165. */
  20166. var rearg = flatRest(function(func, indexes) {
  20167. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  20168. });
  20169. /**
  20170. * Creates a function that invokes `func` with the `this` binding of the
  20171. * created function and arguments from `start` and beyond provided as
  20172. * an array.
  20173. *
  20174. * **Note:** This method is based on the
  20175. * [rest parameter](https://mdn.io/rest_parameters).
  20176. *
  20177. * @static
  20178. * @memberOf _
  20179. * @since 4.0.0
  20180. * @category Function
  20181. * @param {Function} func The function to apply a rest parameter to.
  20182. * @param {number} [start=func.length-1] The start position of the rest parameter.
  20183. * @returns {Function} Returns the new function.
  20184. * @example
  20185. *
  20186. * var say = _.rest(function(what, names) {
  20187. * return what + ' ' + _.initial(names).join(', ') +
  20188. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  20189. * });
  20190. *
  20191. * say('hello', 'fred', 'barney', 'pebbles');
  20192. * // => 'hello fred, barney, & pebbles'
  20193. */
  20194. function rest(func, start) {
  20195. if (typeof func != 'function') {
  20196. throw new TypeError(FUNC_ERROR_TEXT);
  20197. }
  20198. start = start === undefined ? start : toInteger(start);
  20199. return baseRest(func, start);
  20200. }
  20201. /**
  20202. * Creates a function that invokes `func` with the `this` binding of the
  20203. * create function and an array of arguments much like
  20204. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  20205. *
  20206. * **Note:** This method is based on the
  20207. * [spread operator](https://mdn.io/spread_operator).
  20208. *
  20209. * @static
  20210. * @memberOf _
  20211. * @since 3.2.0
  20212. * @category Function
  20213. * @param {Function} func The function to spread arguments over.
  20214. * @param {number} [start=0] The start position of the spread.
  20215. * @returns {Function} Returns the new function.
  20216. * @example
  20217. *
  20218. * var say = _.spread(function(who, what) {
  20219. * return who + ' says ' + what;
  20220. * });
  20221. *
  20222. * say(['fred', 'hello']);
  20223. * // => 'fred says hello'
  20224. *
  20225. * var numbers = Promise.all([
  20226. * Promise.resolve(40),
  20227. * Promise.resolve(36)
  20228. * ]);
  20229. *
  20230. * numbers.then(_.spread(function(x, y) {
  20231. * return x + y;
  20232. * }));
  20233. * // => a Promise of 76
  20234. */
  20235. function spread(func, start) {
  20236. if (typeof func != 'function') {
  20237. throw new TypeError(FUNC_ERROR_TEXT);
  20238. }
  20239. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  20240. return baseRest(function(args) {
  20241. var array = args[start],
  20242. otherArgs = castSlice(args, 0, start);
  20243. if (array) {
  20244. arrayPush(otherArgs, array);
  20245. }
  20246. return apply(func, this, otherArgs);
  20247. });
  20248. }
  20249. /**
  20250. * Creates a throttled function that only invokes `func` at most once per
  20251. * every `wait` milliseconds. The throttled function comes with a `cancel`
  20252. * method to cancel delayed `func` invocations and a `flush` method to
  20253. * immediately invoke them. Provide `options` to indicate whether `func`
  20254. * should be invoked on the leading and/or trailing edge of the `wait`
  20255. * timeout. The `func` is invoked with the last arguments provided to the
  20256. * throttled function. Subsequent calls to the throttled function return the
  20257. * result of the last `func` invocation.
  20258. *
  20259. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  20260. * invoked on the trailing edge of the timeout only if the throttled function
  20261. * is invoked more than once during the `wait` timeout.
  20262. *
  20263. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  20264. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  20265. *
  20266. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  20267. * for details over the differences between `_.throttle` and `_.debounce`.
  20268. *
  20269. * @static
  20270. * @memberOf _
  20271. * @since 0.1.0
  20272. * @category Function
  20273. * @param {Function} func The function to throttle.
  20274. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  20275. * @param {Object} [options={}] The options object.
  20276. * @param {boolean} [options.leading=true]
  20277. * Specify invoking on the leading edge of the timeout.
  20278. * @param {boolean} [options.trailing=true]
  20279. * Specify invoking on the trailing edge of the timeout.
  20280. * @returns {Function} Returns the new throttled function.
  20281. * @example
  20282. *
  20283. * // Avoid excessively updating the position while scrolling.
  20284. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  20285. *
  20286. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  20287. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  20288. * jQuery(element).on('click', throttled);
  20289. *
  20290. * // Cancel the trailing throttled invocation.
  20291. * jQuery(window).on('popstate', throttled.cancel);
  20292. */
  20293. function throttle(func, wait, options) {
  20294. var leading = true,
  20295. trailing = true;
  20296. if (typeof func != 'function') {
  20297. throw new TypeError(FUNC_ERROR_TEXT);
  20298. }
  20299. if (isObject(options)) {
  20300. leading = 'leading' in options ? !!options.leading : leading;
  20301. trailing = 'trailing' in options ? !!options.trailing : trailing;
  20302. }
  20303. return debounce(func, wait, {
  20304. 'leading': leading,
  20305. 'maxWait': wait,
  20306. 'trailing': trailing
  20307. });
  20308. }
  20309. /**
  20310. * Creates a function that accepts up to one argument, ignoring any
  20311. * additional arguments.
  20312. *
  20313. * @static
  20314. * @memberOf _
  20315. * @since 4.0.0
  20316. * @category Function
  20317. * @param {Function} func The function to cap arguments for.
  20318. * @returns {Function} Returns the new capped function.
  20319. * @example
  20320. *
  20321. * _.map(['6', '8', '10'], _.unary(parseInt));
  20322. * // => [6, 8, 10]
  20323. */
  20324. function unary(func) {
  20325. return ary(func, 1);
  20326. }
  20327. /**
  20328. * Creates a function that provides `value` to `wrapper` as its first
  20329. * argument. Any additional arguments provided to the function are appended
  20330. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  20331. * binding of the created function.
  20332. *
  20333. * @static
  20334. * @memberOf _
  20335. * @since 0.1.0
  20336. * @category Function
  20337. * @param {*} value The value to wrap.
  20338. * @param {Function} [wrapper=identity] The wrapper function.
  20339. * @returns {Function} Returns the new function.
  20340. * @example
  20341. *
  20342. * var p = _.wrap(_.escape, function(func, text) {
  20343. * return '<p>' + func(text) + '</p>';
  20344. * });
  20345. *
  20346. * p('fred, barney, & pebbles');
  20347. * // => '<p>fred, barney, &amp; pebbles</p>'
  20348. */
  20349. function wrap(value, wrapper) {
  20350. return partial(castFunction(wrapper), value);
  20351. }
  20352. /*------------------------------------------------------------------------*/
  20353. /**
  20354. * Casts `value` as an array if it's not one.
  20355. *
  20356. * @static
  20357. * @memberOf _
  20358. * @since 4.4.0
  20359. * @category Lang
  20360. * @param {*} value The value to inspect.
  20361. * @returns {Array} Returns the cast array.
  20362. * @example
  20363. *
  20364. * _.castArray(1);
  20365. * // => [1]
  20366. *
  20367. * _.castArray({ 'a': 1 });
  20368. * // => [{ 'a': 1 }]
  20369. *
  20370. * _.castArray('abc');
  20371. * // => ['abc']
  20372. *
  20373. * _.castArray(null);
  20374. * // => [null]
  20375. *
  20376. * _.castArray(undefined);
  20377. * // => [undefined]
  20378. *
  20379. * _.castArray();
  20380. * // => []
  20381. *
  20382. * var array = [1, 2, 3];
  20383. * console.log(_.castArray(array) === array);
  20384. * // => true
  20385. */
  20386. function castArray() {
  20387. if (!arguments.length) {
  20388. return [];
  20389. }
  20390. var value = arguments[0];
  20391. return isArray(value) ? value : [value];
  20392. }
  20393. /**
  20394. * Creates a shallow clone of `value`.
  20395. *
  20396. * **Note:** This method is loosely based on the
  20397. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  20398. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  20399. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  20400. * arrays. The own enumerable properties of `arguments` objects are cloned
  20401. * as plain objects. An empty object is returned for uncloneable values such
  20402. * as error objects, functions, DOM nodes, and WeakMaps.
  20403. *
  20404. * @static
  20405. * @memberOf _
  20406. * @since 0.1.0
  20407. * @category Lang
  20408. * @param {*} value The value to clone.
  20409. * @returns {*} Returns the cloned value.
  20410. * @see _.cloneDeep
  20411. * @example
  20412. *
  20413. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  20414. *
  20415. * var shallow = _.clone(objects);
  20416. * console.log(shallow[0] === objects[0]);
  20417. * // => true
  20418. */
  20419. function clone(value) {
  20420. return baseClone(value, CLONE_SYMBOLS_FLAG);
  20421. }
  20422. /**
  20423. * This method is like `_.clone` except that it accepts `customizer` which
  20424. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  20425. * cloning is handled by the method instead. The `customizer` is invoked with
  20426. * up to four arguments; (value [, index|key, object, stack]).
  20427. *
  20428. * @static
  20429. * @memberOf _
  20430. * @since 4.0.0
  20431. * @category Lang
  20432. * @param {*} value The value to clone.
  20433. * @param {Function} [customizer] The function to customize cloning.
  20434. * @returns {*} Returns the cloned value.
  20435. * @see _.cloneDeepWith
  20436. * @example
  20437. *
  20438. * function customizer(value) {
  20439. * if (_.isElement(value)) {
  20440. * return value.cloneNode(false);
  20441. * }
  20442. * }
  20443. *
  20444. * var el = _.cloneWith(document.body, customizer);
  20445. *
  20446. * console.log(el === document.body);
  20447. * // => false
  20448. * console.log(el.nodeName);
  20449. * // => 'BODY'
  20450. * console.log(el.childNodes.length);
  20451. * // => 0
  20452. */
  20453. function cloneWith(value, customizer) {
  20454. customizer = typeof customizer == 'function' ? customizer : undefined;
  20455. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  20456. }
  20457. /**
  20458. * This method is like `_.clone` except that it recursively clones `value`.
  20459. *
  20460. * @static
  20461. * @memberOf _
  20462. * @since 1.0.0
  20463. * @category Lang
  20464. * @param {*} value The value to recursively clone.
  20465. * @returns {*} Returns the deep cloned value.
  20466. * @see _.clone
  20467. * @example
  20468. *
  20469. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  20470. *
  20471. * var deep = _.cloneDeep(objects);
  20472. * console.log(deep[0] === objects[0]);
  20473. * // => false
  20474. */
  20475. function cloneDeep(value) {
  20476. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  20477. }
  20478. /**
  20479. * This method is like `_.cloneWith` except that it recursively clones `value`.
  20480. *
  20481. * @static
  20482. * @memberOf _
  20483. * @since 4.0.0
  20484. * @category Lang
  20485. * @param {*} value The value to recursively clone.
  20486. * @param {Function} [customizer] The function to customize cloning.
  20487. * @returns {*} Returns the deep cloned value.
  20488. * @see _.cloneWith
  20489. * @example
  20490. *
  20491. * function customizer(value) {
  20492. * if (_.isElement(value)) {
  20493. * return value.cloneNode(true);
  20494. * }
  20495. * }
  20496. *
  20497. * var el = _.cloneDeepWith(document.body, customizer);
  20498. *
  20499. * console.log(el === document.body);
  20500. * // => false
  20501. * console.log(el.nodeName);
  20502. * // => 'BODY'
  20503. * console.log(el.childNodes.length);
  20504. * // => 20
  20505. */
  20506. function cloneDeepWith(value, customizer) {
  20507. customizer = typeof customizer == 'function' ? customizer : undefined;
  20508. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  20509. }
  20510. /**
  20511. * Checks if `object` conforms to `source` by invoking the predicate
  20512. * properties of `source` with the corresponding property values of `object`.
  20513. *
  20514. * **Note:** This method is equivalent to `_.conforms` when `source` is
  20515. * partially applied.
  20516. *
  20517. * @static
  20518. * @memberOf _
  20519. * @since 4.14.0
  20520. * @category Lang
  20521. * @param {Object} object The object to inspect.
  20522. * @param {Object} source The object of property predicates to conform to.
  20523. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  20524. * @example
  20525. *
  20526. * var object = { 'a': 1, 'b': 2 };
  20527. *
  20528. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  20529. * // => true
  20530. *
  20531. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  20532. * // => false
  20533. */
  20534. function conformsTo(object, source) {
  20535. return source == null || baseConformsTo(object, source, keys(source));
  20536. }
  20537. /**
  20538. * Performs a
  20539. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  20540. * comparison between two values to determine if they are equivalent.
  20541. *
  20542. * @static
  20543. * @memberOf _
  20544. * @since 4.0.0
  20545. * @category Lang
  20546. * @param {*} value The value to compare.
  20547. * @param {*} other The other value to compare.
  20548. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  20549. * @example
  20550. *
  20551. * var object = { 'a': 1 };
  20552. * var other = { 'a': 1 };
  20553. *
  20554. * _.eq(object, object);
  20555. * // => true
  20556. *
  20557. * _.eq(object, other);
  20558. * // => false
  20559. *
  20560. * _.eq('a', 'a');
  20561. * // => true
  20562. *
  20563. * _.eq('a', Object('a'));
  20564. * // => false
  20565. *
  20566. * _.eq(NaN, NaN);
  20567. * // => true
  20568. */
  20569. function eq(value, other) {
  20570. return value === other || (value !== value && other !== other);
  20571. }
  20572. /**
  20573. * Checks if `value` is greater than `other`.
  20574. *
  20575. * @static
  20576. * @memberOf _
  20577. * @since 3.9.0
  20578. * @category Lang
  20579. * @param {*} value The value to compare.
  20580. * @param {*} other The other value to compare.
  20581. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  20582. * else `false`.
  20583. * @see _.lt
  20584. * @example
  20585. *
  20586. * _.gt(3, 1);
  20587. * // => true
  20588. *
  20589. * _.gt(3, 3);
  20590. * // => false
  20591. *
  20592. * _.gt(1, 3);
  20593. * // => false
  20594. */
  20595. var gt = createRelationalOperation(baseGt);
  20596. /**
  20597. * Checks if `value` is greater than or equal to `other`.
  20598. *
  20599. * @static
  20600. * @memberOf _
  20601. * @since 3.9.0
  20602. * @category Lang
  20603. * @param {*} value The value to compare.
  20604. * @param {*} other The other value to compare.
  20605. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  20606. * `other`, else `false`.
  20607. * @see _.lte
  20608. * @example
  20609. *
  20610. * _.gte(3, 1);
  20611. * // => true
  20612. *
  20613. * _.gte(3, 3);
  20614. * // => true
  20615. *
  20616. * _.gte(1, 3);
  20617. * // => false
  20618. */
  20619. var gte = createRelationalOperation(function(value, other) {
  20620. return value >= other;
  20621. });
  20622. /**
  20623. * Checks if `value` is likely an `arguments` object.
  20624. *
  20625. * @static
  20626. * @memberOf _
  20627. * @since 0.1.0
  20628. * @category Lang
  20629. * @param {*} value The value to check.
  20630. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  20631. * else `false`.
  20632. * @example
  20633. *
  20634. * _.isArguments(function() { return arguments; }());
  20635. * // => true
  20636. *
  20637. * _.isArguments([1, 2, 3]);
  20638. * // => false
  20639. */
  20640. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  20641. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  20642. !propertyIsEnumerable.call(value, 'callee');
  20643. };
  20644. /**
  20645. * Checks if `value` is classified as an `Array` object.
  20646. *
  20647. * @static
  20648. * @memberOf _
  20649. * @since 0.1.0
  20650. * @category Lang
  20651. * @param {*} value The value to check.
  20652. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  20653. * @example
  20654. *
  20655. * _.isArray([1, 2, 3]);
  20656. * // => true
  20657. *
  20658. * _.isArray(document.body.children);
  20659. * // => false
  20660. *
  20661. * _.isArray('abc');
  20662. * // => false
  20663. *
  20664. * _.isArray(_.noop);
  20665. * // => false
  20666. */
  20667. var isArray = Array.isArray;
  20668. /**
  20669. * Checks if `value` is classified as an `ArrayBuffer` object.
  20670. *
  20671. * @static
  20672. * @memberOf _
  20673. * @since 4.3.0
  20674. * @category Lang
  20675. * @param {*} value The value to check.
  20676. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  20677. * @example
  20678. *
  20679. * _.isArrayBuffer(new ArrayBuffer(2));
  20680. * // => true
  20681. *
  20682. * _.isArrayBuffer(new Array(2));
  20683. * // => false
  20684. */
  20685. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  20686. /**
  20687. * Checks if `value` is array-like. A value is considered array-like if it's
  20688. * not a function and has a `value.length` that's an integer greater than or
  20689. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  20690. *
  20691. * @static
  20692. * @memberOf _
  20693. * @since 4.0.0
  20694. * @category Lang
  20695. * @param {*} value The value to check.
  20696. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  20697. * @example
  20698. *
  20699. * _.isArrayLike([1, 2, 3]);
  20700. * // => true
  20701. *
  20702. * _.isArrayLike(document.body.children);
  20703. * // => true
  20704. *
  20705. * _.isArrayLike('abc');
  20706. * // => true
  20707. *
  20708. * _.isArrayLike(_.noop);
  20709. * // => false
  20710. */
  20711. function isArrayLike(value) {
  20712. return value != null && isLength(value.length) && !isFunction(value);
  20713. }
  20714. /**
  20715. * This method is like `_.isArrayLike` except that it also checks if `value`
  20716. * is an object.
  20717. *
  20718. * @static
  20719. * @memberOf _
  20720. * @since 4.0.0
  20721. * @category Lang
  20722. * @param {*} value The value to check.
  20723. * @returns {boolean} Returns `true` if `value` is an array-like object,
  20724. * else `false`.
  20725. * @example
  20726. *
  20727. * _.isArrayLikeObject([1, 2, 3]);
  20728. * // => true
  20729. *
  20730. * _.isArrayLikeObject(document.body.children);
  20731. * // => true
  20732. *
  20733. * _.isArrayLikeObject('abc');
  20734. * // => false
  20735. *
  20736. * _.isArrayLikeObject(_.noop);
  20737. * // => false
  20738. */
  20739. function isArrayLikeObject(value) {
  20740. return isObjectLike(value) && isArrayLike(value);
  20741. }
  20742. /**
  20743. * Checks if `value` is classified as a boolean primitive or object.
  20744. *
  20745. * @static
  20746. * @memberOf _
  20747. * @since 0.1.0
  20748. * @category Lang
  20749. * @param {*} value The value to check.
  20750. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  20751. * @example
  20752. *
  20753. * _.isBoolean(false);
  20754. * // => true
  20755. *
  20756. * _.isBoolean(null);
  20757. * // => false
  20758. */
  20759. function isBoolean(value) {
  20760. return value === true || value === false ||
  20761. (isObjectLike(value) && baseGetTag(value) == boolTag);
  20762. }
  20763. /**
  20764. * Checks if `value` is a buffer.
  20765. *
  20766. * @static
  20767. * @memberOf _
  20768. * @since 4.3.0
  20769. * @category Lang
  20770. * @param {*} value The value to check.
  20771. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  20772. * @example
  20773. *
  20774. * _.isBuffer(new Buffer(2));
  20775. * // => true
  20776. *
  20777. * _.isBuffer(new Uint8Array(2));
  20778. * // => false
  20779. */
  20780. var isBuffer = nativeIsBuffer || stubFalse;
  20781. /**
  20782. * Checks if `value` is classified as a `Date` object.
  20783. *
  20784. * @static
  20785. * @memberOf _
  20786. * @since 0.1.0
  20787. * @category Lang
  20788. * @param {*} value The value to check.
  20789. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  20790. * @example
  20791. *
  20792. * _.isDate(new Date);
  20793. * // => true
  20794. *
  20795. * _.isDate('Mon April 23 2012');
  20796. * // => false
  20797. */
  20798. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  20799. /**
  20800. * Checks if `value` is likely a DOM element.
  20801. *
  20802. * @static
  20803. * @memberOf _
  20804. * @since 0.1.0
  20805. * @category Lang
  20806. * @param {*} value The value to check.
  20807. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  20808. * @example
  20809. *
  20810. * _.isElement(document.body);
  20811. * // => true
  20812. *
  20813. * _.isElement('<body>');
  20814. * // => false
  20815. */
  20816. function isElement(value) {
  20817. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  20818. }
  20819. /**
  20820. * Checks if `value` is an empty object, collection, map, or set.
  20821. *
  20822. * Objects are considered empty if they have no own enumerable string keyed
  20823. * properties.
  20824. *
  20825. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  20826. * jQuery-like collections are considered empty if they have a `length` of `0`.
  20827. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  20828. *
  20829. * @static
  20830. * @memberOf _
  20831. * @since 0.1.0
  20832. * @category Lang
  20833. * @param {*} value The value to check.
  20834. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  20835. * @example
  20836. *
  20837. * _.isEmpty(null);
  20838. * // => true
  20839. *
  20840. * _.isEmpty(true);
  20841. * // => true
  20842. *
  20843. * _.isEmpty(1);
  20844. * // => true
  20845. *
  20846. * _.isEmpty([1, 2, 3]);
  20847. * // => false
  20848. *
  20849. * _.isEmpty({ 'a': 1 });
  20850. * // => false
  20851. */
  20852. function isEmpty(value) {
  20853. if (value == null) {
  20854. return true;
  20855. }
  20856. if (isArrayLike(value) &&
  20857. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  20858. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  20859. return !value.length;
  20860. }
  20861. var tag = getTag(value);
  20862. if (tag == mapTag || tag == setTag) {
  20863. return !value.size;
  20864. }
  20865. if (isPrototype(value)) {
  20866. return !baseKeys(value).length;
  20867. }
  20868. for (var key in value) {
  20869. if (hasOwnProperty.call(value, key)) {
  20870. return false;
  20871. }
  20872. }
  20873. return true;
  20874. }
  20875. /**
  20876. * Performs a deep comparison between two values to determine if they are
  20877. * equivalent.
  20878. *
  20879. * **Note:** This method supports comparing arrays, array buffers, booleans,
  20880. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  20881. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  20882. * by their own, not inherited, enumerable properties. Functions and DOM
  20883. * nodes are compared by strict equality, i.e. `===`.
  20884. *
  20885. * @static
  20886. * @memberOf _
  20887. * @since 0.1.0
  20888. * @category Lang
  20889. * @param {*} value The value to compare.
  20890. * @param {*} other The other value to compare.
  20891. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  20892. * @example
  20893. *
  20894. * var object = { 'a': 1 };
  20895. * var other = { 'a': 1 };
  20896. *
  20897. * _.isEqual(object, other);
  20898. * // => true
  20899. *
  20900. * object === other;
  20901. * // => false
  20902. */
  20903. function isEqual(value, other) {
  20904. return baseIsEqual(value, other);
  20905. }
  20906. /**
  20907. * This method is like `_.isEqual` except that it accepts `customizer` which
  20908. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  20909. * are handled by the method instead. The `customizer` is invoked with up to
  20910. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  20911. *
  20912. * @static
  20913. * @memberOf _
  20914. * @since 4.0.0
  20915. * @category Lang
  20916. * @param {*} value The value to compare.
  20917. * @param {*} other The other value to compare.
  20918. * @param {Function} [customizer] The function to customize comparisons.
  20919. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  20920. * @example
  20921. *
  20922. * function isGreeting(value) {
  20923. * return /^h(?:i|ello)$/.test(value);
  20924. * }
  20925. *
  20926. * function customizer(objValue, othValue) {
  20927. * if (isGreeting(objValue) && isGreeting(othValue)) {
  20928. * return true;
  20929. * }
  20930. * }
  20931. *
  20932. * var array = ['hello', 'goodbye'];
  20933. * var other = ['hi', 'goodbye'];
  20934. *
  20935. * _.isEqualWith(array, other, customizer);
  20936. * // => true
  20937. */
  20938. function isEqualWith(value, other, customizer) {
  20939. customizer = typeof customizer == 'function' ? customizer : undefined;
  20940. var result = customizer ? customizer(value, other) : undefined;
  20941. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  20942. }
  20943. /**
  20944. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  20945. * `SyntaxError`, `TypeError`, or `URIError` object.
  20946. *
  20947. * @static
  20948. * @memberOf _
  20949. * @since 3.0.0
  20950. * @category Lang
  20951. * @param {*} value The value to check.
  20952. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  20953. * @example
  20954. *
  20955. * _.isError(new Error);
  20956. * // => true
  20957. *
  20958. * _.isError(Error);
  20959. * // => false
  20960. */
  20961. function isError(value) {
  20962. if (!isObjectLike(value)) {
  20963. return false;
  20964. }
  20965. var tag = baseGetTag(value);
  20966. return tag == errorTag || tag == domExcTag ||
  20967. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  20968. }
  20969. /**
  20970. * Checks if `value` is a finite primitive number.
  20971. *
  20972. * **Note:** This method is based on
  20973. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  20974. *
  20975. * @static
  20976. * @memberOf _
  20977. * @since 0.1.0
  20978. * @category Lang
  20979. * @param {*} value The value to check.
  20980. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  20981. * @example
  20982. *
  20983. * _.isFinite(3);
  20984. * // => true
  20985. *
  20986. * _.isFinite(Number.MIN_VALUE);
  20987. * // => true
  20988. *
  20989. * _.isFinite(Infinity);
  20990. * // => false
  20991. *
  20992. * _.isFinite('3');
  20993. * // => false
  20994. */
  20995. function isFinite(value) {
  20996. return typeof value == 'number' && nativeIsFinite(value);
  20997. }
  20998. /**
  20999. * Checks if `value` is classified as a `Function` object.
  21000. *
  21001. * @static
  21002. * @memberOf _
  21003. * @since 0.1.0
  21004. * @category Lang
  21005. * @param {*} value The value to check.
  21006. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  21007. * @example
  21008. *
  21009. * _.isFunction(_);
  21010. * // => true
  21011. *
  21012. * _.isFunction(/abc/);
  21013. * // => false
  21014. */
  21015. function isFunction(value) {
  21016. if (!isObject(value)) {
  21017. return false;
  21018. }
  21019. // The use of `Object#toString` avoids issues with the `typeof` operator
  21020. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  21021. var tag = baseGetTag(value);
  21022. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  21023. }
  21024. /**
  21025. * Checks if `value` is an integer.
  21026. *
  21027. * **Note:** This method is based on
  21028. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  21029. *
  21030. * @static
  21031. * @memberOf _
  21032. * @since 4.0.0
  21033. * @category Lang
  21034. * @param {*} value The value to check.
  21035. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  21036. * @example
  21037. *
  21038. * _.isInteger(3);
  21039. * // => true
  21040. *
  21041. * _.isInteger(Number.MIN_VALUE);
  21042. * // => false
  21043. *
  21044. * _.isInteger(Infinity);
  21045. * // => false
  21046. *
  21047. * _.isInteger('3');
  21048. * // => false
  21049. */
  21050. function isInteger(value) {
  21051. return typeof value == 'number' && value == toInteger(value);
  21052. }
  21053. /**
  21054. * Checks if `value` is a valid array-like length.
  21055. *
  21056. * **Note:** This method is loosely based on
  21057. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  21058. *
  21059. * @static
  21060. * @memberOf _
  21061. * @since 4.0.0
  21062. * @category Lang
  21063. * @param {*} value The value to check.
  21064. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  21065. * @example
  21066. *
  21067. * _.isLength(3);
  21068. * // => true
  21069. *
  21070. * _.isLength(Number.MIN_VALUE);
  21071. * // => false
  21072. *
  21073. * _.isLength(Infinity);
  21074. * // => false
  21075. *
  21076. * _.isLength('3');
  21077. * // => false
  21078. */
  21079. function isLength(value) {
  21080. return typeof value == 'number' &&
  21081. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  21082. }
  21083. /**
  21084. * Checks if `value` is the
  21085. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  21086. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  21087. *
  21088. * @static
  21089. * @memberOf _
  21090. * @since 0.1.0
  21091. * @category Lang
  21092. * @param {*} value The value to check.
  21093. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  21094. * @example
  21095. *
  21096. * _.isObject({});
  21097. * // => true
  21098. *
  21099. * _.isObject([1, 2, 3]);
  21100. * // => true
  21101. *
  21102. * _.isObject(_.noop);
  21103. * // => true
  21104. *
  21105. * _.isObject(null);
  21106. * // => false
  21107. */
  21108. function isObject(value) {
  21109. var type = typeof value;
  21110. return value != null && (type == 'object' || type == 'function');
  21111. }
  21112. /**
  21113. * Checks if `value` is object-like. A value is object-like if it's not `null`
  21114. * and has a `typeof` result of "object".
  21115. *
  21116. * @static
  21117. * @memberOf _
  21118. * @since 4.0.0
  21119. * @category Lang
  21120. * @param {*} value The value to check.
  21121. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  21122. * @example
  21123. *
  21124. * _.isObjectLike({});
  21125. * // => true
  21126. *
  21127. * _.isObjectLike([1, 2, 3]);
  21128. * // => true
  21129. *
  21130. * _.isObjectLike(_.noop);
  21131. * // => false
  21132. *
  21133. * _.isObjectLike(null);
  21134. * // => false
  21135. */
  21136. function isObjectLike(value) {
  21137. return value != null && typeof value == 'object';
  21138. }
  21139. /**
  21140. * Checks if `value` is classified as a `Map` object.
  21141. *
  21142. * @static
  21143. * @memberOf _
  21144. * @since 4.3.0
  21145. * @category Lang
  21146. * @param {*} value The value to check.
  21147. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  21148. * @example
  21149. *
  21150. * _.isMap(new Map);
  21151. * // => true
  21152. *
  21153. * _.isMap(new WeakMap);
  21154. * // => false
  21155. */
  21156. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  21157. /**
  21158. * Performs a partial deep comparison between `object` and `source` to
  21159. * determine if `object` contains equivalent property values.
  21160. *
  21161. * **Note:** This method is equivalent to `_.matches` when `source` is
  21162. * partially applied.
  21163. *
  21164. * Partial comparisons will match empty array and empty object `source`
  21165. * values against any array or object value, respectively. See `_.isEqual`
  21166. * for a list of supported value comparisons.
  21167. *
  21168. * @static
  21169. * @memberOf _
  21170. * @since 3.0.0
  21171. * @category Lang
  21172. * @param {Object} object The object to inspect.
  21173. * @param {Object} source The object of property values to match.
  21174. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  21175. * @example
  21176. *
  21177. * var object = { 'a': 1, 'b': 2 };
  21178. *
  21179. * _.isMatch(object, { 'b': 2 });
  21180. * // => true
  21181. *
  21182. * _.isMatch(object, { 'b': 1 });
  21183. * // => false
  21184. */
  21185. function isMatch(object, source) {
  21186. return object === source || baseIsMatch(object, source, getMatchData(source));
  21187. }
  21188. /**
  21189. * This method is like `_.isMatch` except that it accepts `customizer` which
  21190. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  21191. * are handled by the method instead. The `customizer` is invoked with five
  21192. * arguments: (objValue, srcValue, index|key, object, source).
  21193. *
  21194. * @static
  21195. * @memberOf _
  21196. * @since 4.0.0
  21197. * @category Lang
  21198. * @param {Object} object The object to inspect.
  21199. * @param {Object} source The object of property values to match.
  21200. * @param {Function} [customizer] The function to customize comparisons.
  21201. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  21202. * @example
  21203. *
  21204. * function isGreeting(value) {
  21205. * return /^h(?:i|ello)$/.test(value);
  21206. * }
  21207. *
  21208. * function customizer(objValue, srcValue) {
  21209. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  21210. * return true;
  21211. * }
  21212. * }
  21213. *
  21214. * var object = { 'greeting': 'hello' };
  21215. * var source = { 'greeting': 'hi' };
  21216. *
  21217. * _.isMatchWith(object, source, customizer);
  21218. * // => true
  21219. */
  21220. function isMatchWith(object, source, customizer) {
  21221. customizer = typeof customizer == 'function' ? customizer : undefined;
  21222. return baseIsMatch(object, source, getMatchData(source), customizer);
  21223. }
  21224. /**
  21225. * Checks if `value` is `NaN`.
  21226. *
  21227. * **Note:** This method is based on
  21228. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  21229. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  21230. * `undefined` and other non-number values.
  21231. *
  21232. * @static
  21233. * @memberOf _
  21234. * @since 0.1.0
  21235. * @category Lang
  21236. * @param {*} value The value to check.
  21237. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  21238. * @example
  21239. *
  21240. * _.isNaN(NaN);
  21241. * // => true
  21242. *
  21243. * _.isNaN(new Number(NaN));
  21244. * // => true
  21245. *
  21246. * isNaN(undefined);
  21247. * // => true
  21248. *
  21249. * _.isNaN(undefined);
  21250. * // => false
  21251. */
  21252. function isNaN(value) {
  21253. // An `NaN` primitive is the only value that is not equal to itself.
  21254. // Perform the `toStringTag` check first to avoid errors with some
  21255. // ActiveX objects in IE.
  21256. return isNumber(value) && value != +value;
  21257. }
  21258. /**
  21259. * Checks if `value` is a pristine native function.
  21260. *
  21261. * **Note:** This method can't reliably detect native functions in the presence
  21262. * of the core-js package because core-js circumvents this kind of detection.
  21263. * Despite multiple requests, the core-js maintainer has made it clear: any
  21264. * attempt to fix the detection will be obstructed. As a result, we're left
  21265. * with little choice but to throw an error. Unfortunately, this also affects
  21266. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  21267. * which rely on core-js.
  21268. *
  21269. * @static
  21270. * @memberOf _
  21271. * @since 3.0.0
  21272. * @category Lang
  21273. * @param {*} value The value to check.
  21274. * @returns {boolean} Returns `true` if `value` is a native function,
  21275. * else `false`.
  21276. * @example
  21277. *
  21278. * _.isNative(Array.prototype.push);
  21279. * // => true
  21280. *
  21281. * _.isNative(_);
  21282. * // => false
  21283. */
  21284. function isNative(value) {
  21285. if (isMaskable(value)) {
  21286. throw new Error(CORE_ERROR_TEXT);
  21287. }
  21288. return baseIsNative(value);
  21289. }
  21290. /**
  21291. * Checks if `value` is `null`.
  21292. *
  21293. * @static
  21294. * @memberOf _
  21295. * @since 0.1.0
  21296. * @category Lang
  21297. * @param {*} value The value to check.
  21298. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  21299. * @example
  21300. *
  21301. * _.isNull(null);
  21302. * // => true
  21303. *
  21304. * _.isNull(void 0);
  21305. * // => false
  21306. */
  21307. function isNull(value) {
  21308. return value === null;
  21309. }
  21310. /**
  21311. * Checks if `value` is `null` or `undefined`.
  21312. *
  21313. * @static
  21314. * @memberOf _
  21315. * @since 4.0.0
  21316. * @category Lang
  21317. * @param {*} value The value to check.
  21318. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  21319. * @example
  21320. *
  21321. * _.isNil(null);
  21322. * // => true
  21323. *
  21324. * _.isNil(void 0);
  21325. * // => true
  21326. *
  21327. * _.isNil(NaN);
  21328. * // => false
  21329. */
  21330. function isNil(value) {
  21331. return value == null;
  21332. }
  21333. /**
  21334. * Checks if `value` is classified as a `Number` primitive or object.
  21335. *
  21336. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  21337. * classified as numbers, use the `_.isFinite` method.
  21338. *
  21339. * @static
  21340. * @memberOf _
  21341. * @since 0.1.0
  21342. * @category Lang
  21343. * @param {*} value The value to check.
  21344. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  21345. * @example
  21346. *
  21347. * _.isNumber(3);
  21348. * // => true
  21349. *
  21350. * _.isNumber(Number.MIN_VALUE);
  21351. * // => true
  21352. *
  21353. * _.isNumber(Infinity);
  21354. * // => true
  21355. *
  21356. * _.isNumber('3');
  21357. * // => false
  21358. */
  21359. function isNumber(value) {
  21360. return typeof value == 'number' ||
  21361. (isObjectLike(value) && baseGetTag(value) == numberTag);
  21362. }
  21363. /**
  21364. * Checks if `value` is a plain object, that is, an object created by the
  21365. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  21366. *
  21367. * @static
  21368. * @memberOf _
  21369. * @since 0.8.0
  21370. * @category Lang
  21371. * @param {*} value The value to check.
  21372. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  21373. * @example
  21374. *
  21375. * function Foo() {
  21376. * this.a = 1;
  21377. * }
  21378. *
  21379. * _.isPlainObject(new Foo);
  21380. * // => false
  21381. *
  21382. * _.isPlainObject([1, 2, 3]);
  21383. * // => false
  21384. *
  21385. * _.isPlainObject({ 'x': 0, 'y': 0 });
  21386. * // => true
  21387. *
  21388. * _.isPlainObject(Object.create(null));
  21389. * // => true
  21390. */
  21391. function isPlainObject(value) {
  21392. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  21393. return false;
  21394. }
  21395. var proto = getPrototype(value);
  21396. if (proto === null) {
  21397. return true;
  21398. }
  21399. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  21400. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  21401. funcToString.call(Ctor) == objectCtorString;
  21402. }
  21403. /**
  21404. * Checks if `value` is classified as a `RegExp` object.
  21405. *
  21406. * @static
  21407. * @memberOf _
  21408. * @since 0.1.0
  21409. * @category Lang
  21410. * @param {*} value The value to check.
  21411. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  21412. * @example
  21413. *
  21414. * _.isRegExp(/abc/);
  21415. * // => true
  21416. *
  21417. * _.isRegExp('/abc/');
  21418. * // => false
  21419. */
  21420. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  21421. /**
  21422. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  21423. * double precision number which isn't the result of a rounded unsafe integer.
  21424. *
  21425. * **Note:** This method is based on
  21426. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  21427. *
  21428. * @static
  21429. * @memberOf _
  21430. * @since 4.0.0
  21431. * @category Lang
  21432. * @param {*} value The value to check.
  21433. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  21434. * @example
  21435. *
  21436. * _.isSafeInteger(3);
  21437. * // => true
  21438. *
  21439. * _.isSafeInteger(Number.MIN_VALUE);
  21440. * // => false
  21441. *
  21442. * _.isSafeInteger(Infinity);
  21443. * // => false
  21444. *
  21445. * _.isSafeInteger('3');
  21446. * // => false
  21447. */
  21448. function isSafeInteger(value) {
  21449. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  21450. }
  21451. /**
  21452. * Checks if `value` is classified as a `Set` object.
  21453. *
  21454. * @static
  21455. * @memberOf _
  21456. * @since 4.3.0
  21457. * @category Lang
  21458. * @param {*} value The value to check.
  21459. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  21460. * @example
  21461. *
  21462. * _.isSet(new Set);
  21463. * // => true
  21464. *
  21465. * _.isSet(new WeakSet);
  21466. * // => false
  21467. */
  21468. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  21469. /**
  21470. * Checks if `value` is classified as a `String` primitive or object.
  21471. *
  21472. * @static
  21473. * @since 0.1.0
  21474. * @memberOf _
  21475. * @category Lang
  21476. * @param {*} value The value to check.
  21477. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  21478. * @example
  21479. *
  21480. * _.isString('abc');
  21481. * // => true
  21482. *
  21483. * _.isString(1);
  21484. * // => false
  21485. */
  21486. function isString(value) {
  21487. return typeof value == 'string' ||
  21488. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  21489. }
  21490. /**
  21491. * Checks if `value` is classified as a `Symbol` primitive or object.
  21492. *
  21493. * @static
  21494. * @memberOf _
  21495. * @since 4.0.0
  21496. * @category Lang
  21497. * @param {*} value The value to check.
  21498. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  21499. * @example
  21500. *
  21501. * _.isSymbol(Symbol.iterator);
  21502. * // => true
  21503. *
  21504. * _.isSymbol('abc');
  21505. * // => false
  21506. */
  21507. function isSymbol(value) {
  21508. return typeof value == 'symbol' ||
  21509. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  21510. }
  21511. /**
  21512. * Checks if `value` is classified as a typed array.
  21513. *
  21514. * @static
  21515. * @memberOf _
  21516. * @since 3.0.0
  21517. * @category Lang
  21518. * @param {*} value The value to check.
  21519. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  21520. * @example
  21521. *
  21522. * _.isTypedArray(new Uint8Array);
  21523. * // => true
  21524. *
  21525. * _.isTypedArray([]);
  21526. * // => false
  21527. */
  21528. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  21529. /**
  21530. * Checks if `value` is `undefined`.
  21531. *
  21532. * @static
  21533. * @since 0.1.0
  21534. * @memberOf _
  21535. * @category Lang
  21536. * @param {*} value The value to check.
  21537. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  21538. * @example
  21539. *
  21540. * _.isUndefined(void 0);
  21541. * // => true
  21542. *
  21543. * _.isUndefined(null);
  21544. * // => false
  21545. */
  21546. function isUndefined(value) {
  21547. return value === undefined;
  21548. }
  21549. /**
  21550. * Checks if `value` is classified as a `WeakMap` object.
  21551. *
  21552. * @static
  21553. * @memberOf _
  21554. * @since 4.3.0
  21555. * @category Lang
  21556. * @param {*} value The value to check.
  21557. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  21558. * @example
  21559. *
  21560. * _.isWeakMap(new WeakMap);
  21561. * // => true
  21562. *
  21563. * _.isWeakMap(new Map);
  21564. * // => false
  21565. */
  21566. function isWeakMap(value) {
  21567. return isObjectLike(value) && getTag(value) == weakMapTag;
  21568. }
  21569. /**
  21570. * Checks if `value` is classified as a `WeakSet` object.
  21571. *
  21572. * @static
  21573. * @memberOf _
  21574. * @since 4.3.0
  21575. * @category Lang
  21576. * @param {*} value The value to check.
  21577. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  21578. * @example
  21579. *
  21580. * _.isWeakSet(new WeakSet);
  21581. * // => true
  21582. *
  21583. * _.isWeakSet(new Set);
  21584. * // => false
  21585. */
  21586. function isWeakSet(value) {
  21587. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  21588. }
  21589. /**
  21590. * Checks if `value` is less than `other`.
  21591. *
  21592. * @static
  21593. * @memberOf _
  21594. * @since 3.9.0
  21595. * @category Lang
  21596. * @param {*} value The value to compare.
  21597. * @param {*} other The other value to compare.
  21598. * @returns {boolean} Returns `true` if `value` is less than `other`,
  21599. * else `false`.
  21600. * @see _.gt
  21601. * @example
  21602. *
  21603. * _.lt(1, 3);
  21604. * // => true
  21605. *
  21606. * _.lt(3, 3);
  21607. * // => false
  21608. *
  21609. * _.lt(3, 1);
  21610. * // => false
  21611. */
  21612. var lt = createRelationalOperation(baseLt);
  21613. /**
  21614. * Checks if `value` is less than or equal to `other`.
  21615. *
  21616. * @static
  21617. * @memberOf _
  21618. * @since 3.9.0
  21619. * @category Lang
  21620. * @param {*} value The value to compare.
  21621. * @param {*} other The other value to compare.
  21622. * @returns {boolean} Returns `true` if `value` is less than or equal to
  21623. * `other`, else `false`.
  21624. * @see _.gte
  21625. * @example
  21626. *
  21627. * _.lte(1, 3);
  21628. * // => true
  21629. *
  21630. * _.lte(3, 3);
  21631. * // => true
  21632. *
  21633. * _.lte(3, 1);
  21634. * // => false
  21635. */
  21636. var lte = createRelationalOperation(function(value, other) {
  21637. return value <= other;
  21638. });
  21639. /**
  21640. * Converts `value` to an array.
  21641. *
  21642. * @static
  21643. * @since 0.1.0
  21644. * @memberOf _
  21645. * @category Lang
  21646. * @param {*} value The value to convert.
  21647. * @returns {Array} Returns the converted array.
  21648. * @example
  21649. *
  21650. * _.toArray({ 'a': 1, 'b': 2 });
  21651. * // => [1, 2]
  21652. *
  21653. * _.toArray('abc');
  21654. * // => ['a', 'b', 'c']
  21655. *
  21656. * _.toArray(1);
  21657. * // => []
  21658. *
  21659. * _.toArray(null);
  21660. * // => []
  21661. */
  21662. function toArray(value) {
  21663. if (!value) {
  21664. return [];
  21665. }
  21666. if (isArrayLike(value)) {
  21667. return isString(value) ? stringToArray(value) : copyArray(value);
  21668. }
  21669. if (symIterator && value[symIterator]) {
  21670. return iteratorToArray(value[symIterator]());
  21671. }
  21672. var tag = getTag(value),
  21673. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  21674. return func(value);
  21675. }
  21676. /**
  21677. * Converts `value` to a finite number.
  21678. *
  21679. * @static
  21680. * @memberOf _
  21681. * @since 4.12.0
  21682. * @category Lang
  21683. * @param {*} value The value to convert.
  21684. * @returns {number} Returns the converted number.
  21685. * @example
  21686. *
  21687. * _.toFinite(3.2);
  21688. * // => 3.2
  21689. *
  21690. * _.toFinite(Number.MIN_VALUE);
  21691. * // => 5e-324
  21692. *
  21693. * _.toFinite(Infinity);
  21694. * // => 1.7976931348623157e+308
  21695. *
  21696. * _.toFinite('3.2');
  21697. * // => 3.2
  21698. */
  21699. function toFinite(value) {
  21700. if (!value) {
  21701. return value === 0 ? value : 0;
  21702. }
  21703. value = toNumber(value);
  21704. if (value === INFINITY || value === -INFINITY) {
  21705. var sign = (value < 0 ? -1 : 1);
  21706. return sign * MAX_INTEGER;
  21707. }
  21708. return value === value ? value : 0;
  21709. }
  21710. /**
  21711. * Converts `value` to an integer.
  21712. *
  21713. * **Note:** This method is loosely based on
  21714. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  21715. *
  21716. * @static
  21717. * @memberOf _
  21718. * @since 4.0.0
  21719. * @category Lang
  21720. * @param {*} value The value to convert.
  21721. * @returns {number} Returns the converted integer.
  21722. * @example
  21723. *
  21724. * _.toInteger(3.2);
  21725. * // => 3
  21726. *
  21727. * _.toInteger(Number.MIN_VALUE);
  21728. * // => 0
  21729. *
  21730. * _.toInteger(Infinity);
  21731. * // => 1.7976931348623157e+308
  21732. *
  21733. * _.toInteger('3.2');
  21734. * // => 3
  21735. */
  21736. function toInteger(value) {
  21737. var result = toFinite(value),
  21738. remainder = result % 1;
  21739. return result === result ? (remainder ? result - remainder : result) : 0;
  21740. }
  21741. /**
  21742. * Converts `value` to an integer suitable for use as the length of an
  21743. * array-like object.
  21744. *
  21745. * **Note:** This method is based on
  21746. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  21747. *
  21748. * @static
  21749. * @memberOf _
  21750. * @since 4.0.0
  21751. * @category Lang
  21752. * @param {*} value The value to convert.
  21753. * @returns {number} Returns the converted integer.
  21754. * @example
  21755. *
  21756. * _.toLength(3.2);
  21757. * // => 3
  21758. *
  21759. * _.toLength(Number.MIN_VALUE);
  21760. * // => 0
  21761. *
  21762. * _.toLength(Infinity);
  21763. * // => 4294967295
  21764. *
  21765. * _.toLength('3.2');
  21766. * // => 3
  21767. */
  21768. function toLength(value) {
  21769. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  21770. }
  21771. /**
  21772. * Converts `value` to a number.
  21773. *
  21774. * @static
  21775. * @memberOf _
  21776. * @since 4.0.0
  21777. * @category Lang
  21778. * @param {*} value The value to process.
  21779. * @returns {number} Returns the number.
  21780. * @example
  21781. *
  21782. * _.toNumber(3.2);
  21783. * // => 3.2
  21784. *
  21785. * _.toNumber(Number.MIN_VALUE);
  21786. * // => 5e-324
  21787. *
  21788. * _.toNumber(Infinity);
  21789. * // => Infinity
  21790. *
  21791. * _.toNumber('3.2');
  21792. * // => 3.2
  21793. */
  21794. function toNumber(value) {
  21795. if (typeof value == 'number') {
  21796. return value;
  21797. }
  21798. if (isSymbol(value)) {
  21799. return NAN;
  21800. }
  21801. if (isObject(value)) {
  21802. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  21803. value = isObject(other) ? (other + '') : other;
  21804. }
  21805. if (typeof value != 'string') {
  21806. return value === 0 ? value : +value;
  21807. }
  21808. value = value.replace(reTrim, '');
  21809. var isBinary = reIsBinary.test(value);
  21810. return (isBinary || reIsOctal.test(value))
  21811. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  21812. : (reIsBadHex.test(value) ? NAN : +value);
  21813. }
  21814. /**
  21815. * Converts `value` to a plain object flattening inherited enumerable string
  21816. * keyed properties of `value` to own properties of the plain object.
  21817. *
  21818. * @static
  21819. * @memberOf _
  21820. * @since 3.0.0
  21821. * @category Lang
  21822. * @param {*} value The value to convert.
  21823. * @returns {Object} Returns the converted plain object.
  21824. * @example
  21825. *
  21826. * function Foo() {
  21827. * this.b = 2;
  21828. * }
  21829. *
  21830. * Foo.prototype.c = 3;
  21831. *
  21832. * _.assign({ 'a': 1 }, new Foo);
  21833. * // => { 'a': 1, 'b': 2 }
  21834. *
  21835. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  21836. * // => { 'a': 1, 'b': 2, 'c': 3 }
  21837. */
  21838. function toPlainObject(value) {
  21839. return copyObject(value, keysIn(value));
  21840. }
  21841. /**
  21842. * Converts `value` to a safe integer. A safe integer can be compared and
  21843. * represented correctly.
  21844. *
  21845. * @static
  21846. * @memberOf _
  21847. * @since 4.0.0
  21848. * @category Lang
  21849. * @param {*} value The value to convert.
  21850. * @returns {number} Returns the converted integer.
  21851. * @example
  21852. *
  21853. * _.toSafeInteger(3.2);
  21854. * // => 3
  21855. *
  21856. * _.toSafeInteger(Number.MIN_VALUE);
  21857. * // => 0
  21858. *
  21859. * _.toSafeInteger(Infinity);
  21860. * // => 9007199254740991
  21861. *
  21862. * _.toSafeInteger('3.2');
  21863. * // => 3
  21864. */
  21865. function toSafeInteger(value) {
  21866. return value
  21867. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  21868. : (value === 0 ? value : 0);
  21869. }
  21870. /**
  21871. * Converts `value` to a string. An empty string is returned for `null`
  21872. * and `undefined` values. The sign of `-0` is preserved.
  21873. *
  21874. * @static
  21875. * @memberOf _
  21876. * @since 4.0.0
  21877. * @category Lang
  21878. * @param {*} value The value to convert.
  21879. * @returns {string} Returns the converted string.
  21880. * @example
  21881. *
  21882. * _.toString(null);
  21883. * // => ''
  21884. *
  21885. * _.toString(-0);
  21886. * // => '-0'
  21887. *
  21888. * _.toString([1, 2, 3]);
  21889. * // => '1,2,3'
  21890. */
  21891. function toString(value) {
  21892. return value == null ? '' : baseToString(value);
  21893. }
  21894. /*------------------------------------------------------------------------*/
  21895. /**
  21896. * Assigns own enumerable string keyed properties of source objects to the
  21897. * destination object. Source objects are applied from left to right.
  21898. * Subsequent sources overwrite property assignments of previous sources.
  21899. *
  21900. * **Note:** This method mutates `object` and is loosely based on
  21901. * [`Object.assign`](https://mdn.io/Object/assign).
  21902. *
  21903. * @static
  21904. * @memberOf _
  21905. * @since 0.10.0
  21906. * @category Object
  21907. * @param {Object} object The destination object.
  21908. * @param {...Object} [sources] The source objects.
  21909. * @returns {Object} Returns `object`.
  21910. * @see _.assignIn
  21911. * @example
  21912. *
  21913. * function Foo() {
  21914. * this.a = 1;
  21915. * }
  21916. *
  21917. * function Bar() {
  21918. * this.c = 3;
  21919. * }
  21920. *
  21921. * Foo.prototype.b = 2;
  21922. * Bar.prototype.d = 4;
  21923. *
  21924. * _.assign({ 'a': 0 }, new Foo, new Bar);
  21925. * // => { 'a': 1, 'c': 3 }
  21926. */
  21927. var assign = createAssigner(function(object, source) {
  21928. if (isPrototype(source) || isArrayLike(source)) {
  21929. copyObject(source, keys(source), object);
  21930. return;
  21931. }
  21932. for (var key in source) {
  21933. if (hasOwnProperty.call(source, key)) {
  21934. assignValue(object, key, source[key]);
  21935. }
  21936. }
  21937. });
  21938. /**
  21939. * This method is like `_.assign` except that it iterates over own and
  21940. * inherited source properties.
  21941. *
  21942. * **Note:** This method mutates `object`.
  21943. *
  21944. * @static
  21945. * @memberOf _
  21946. * @since 4.0.0
  21947. * @alias extend
  21948. * @category Object
  21949. * @param {Object} object The destination object.
  21950. * @param {...Object} [sources] The source objects.
  21951. * @returns {Object} Returns `object`.
  21952. * @see _.assign
  21953. * @example
  21954. *
  21955. * function Foo() {
  21956. * this.a = 1;
  21957. * }
  21958. *
  21959. * function Bar() {
  21960. * this.c = 3;
  21961. * }
  21962. *
  21963. * Foo.prototype.b = 2;
  21964. * Bar.prototype.d = 4;
  21965. *
  21966. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  21967. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  21968. */
  21969. var assignIn = createAssigner(function(object, source) {
  21970. copyObject(source, keysIn(source), object);
  21971. });
  21972. /**
  21973. * This method is like `_.assignIn` except that it accepts `customizer`
  21974. * which is invoked to produce the assigned values. If `customizer` returns
  21975. * `undefined`, assignment is handled by the method instead. The `customizer`
  21976. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  21977. *
  21978. * **Note:** This method mutates `object`.
  21979. *
  21980. * @static
  21981. * @memberOf _
  21982. * @since 4.0.0
  21983. * @alias extendWith
  21984. * @category Object
  21985. * @param {Object} object The destination object.
  21986. * @param {...Object} sources The source objects.
  21987. * @param {Function} [customizer] The function to customize assigned values.
  21988. * @returns {Object} Returns `object`.
  21989. * @see _.assignWith
  21990. * @example
  21991. *
  21992. * function customizer(objValue, srcValue) {
  21993. * return _.isUndefined(objValue) ? srcValue : objValue;
  21994. * }
  21995. *
  21996. * var defaults = _.partialRight(_.assignInWith, customizer);
  21997. *
  21998. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  21999. * // => { 'a': 1, 'b': 2 }
  22000. */
  22001. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  22002. copyObject(source, keysIn(source), object, customizer);
  22003. });
  22004. /**
  22005. * This method is like `_.assign` except that it accepts `customizer`
  22006. * which is invoked to produce the assigned values. If `customizer` returns
  22007. * `undefined`, assignment is handled by the method instead. The `customizer`
  22008. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  22009. *
  22010. * **Note:** This method mutates `object`.
  22011. *
  22012. * @static
  22013. * @memberOf _
  22014. * @since 4.0.0
  22015. * @category Object
  22016. * @param {Object} object The destination object.
  22017. * @param {...Object} sources The source objects.
  22018. * @param {Function} [customizer] The function to customize assigned values.
  22019. * @returns {Object} Returns `object`.
  22020. * @see _.assignInWith
  22021. * @example
  22022. *
  22023. * function customizer(objValue, srcValue) {
  22024. * return _.isUndefined(objValue) ? srcValue : objValue;
  22025. * }
  22026. *
  22027. * var defaults = _.partialRight(_.assignWith, customizer);
  22028. *
  22029. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  22030. * // => { 'a': 1, 'b': 2 }
  22031. */
  22032. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  22033. copyObject(source, keys(source), object, customizer);
  22034. });
  22035. /**
  22036. * Creates an array of values corresponding to `paths` of `object`.
  22037. *
  22038. * @static
  22039. * @memberOf _
  22040. * @since 1.0.0
  22041. * @category Object
  22042. * @param {Object} object The object to iterate over.
  22043. * @param {...(string|string[])} [paths] The property paths to pick.
  22044. * @returns {Array} Returns the picked values.
  22045. * @example
  22046. *
  22047. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  22048. *
  22049. * _.at(object, ['a[0].b.c', 'a[1]']);
  22050. * // => [3, 4]
  22051. */
  22052. var at = flatRest(baseAt);
  22053. /**
  22054. * Creates an object that inherits from the `prototype` object. If a
  22055. * `properties` object is given, its own enumerable string keyed properties
  22056. * are assigned to the created object.
  22057. *
  22058. * @static
  22059. * @memberOf _
  22060. * @since 2.3.0
  22061. * @category Object
  22062. * @param {Object} prototype The object to inherit from.
  22063. * @param {Object} [properties] The properties to assign to the object.
  22064. * @returns {Object} Returns the new object.
  22065. * @example
  22066. *
  22067. * function Shape() {
  22068. * this.x = 0;
  22069. * this.y = 0;
  22070. * }
  22071. *
  22072. * function Circle() {
  22073. * Shape.call(this);
  22074. * }
  22075. *
  22076. * Circle.prototype = _.create(Shape.prototype, {
  22077. * 'constructor': Circle
  22078. * });
  22079. *
  22080. * var circle = new Circle;
  22081. * circle instanceof Circle;
  22082. * // => true
  22083. *
  22084. * circle instanceof Shape;
  22085. * // => true
  22086. */
  22087. function create(prototype, properties) {
  22088. var result = baseCreate(prototype);
  22089. return properties == null ? result : baseAssign(result, properties);
  22090. }
  22091. /**
  22092. * Assigns own and inherited enumerable string keyed properties of source
  22093. * objects to the destination object for all destination properties that
  22094. * resolve to `undefined`. Source objects are applied from left to right.
  22095. * Once a property is set, additional values of the same property are ignored.
  22096. *
  22097. * **Note:** This method mutates `object`.
  22098. *
  22099. * @static
  22100. * @since 0.1.0
  22101. * @memberOf _
  22102. * @category Object
  22103. * @param {Object} object The destination object.
  22104. * @param {...Object} [sources] The source objects.
  22105. * @returns {Object} Returns `object`.
  22106. * @see _.defaultsDeep
  22107. * @example
  22108. *
  22109. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  22110. * // => { 'a': 1, 'b': 2 }
  22111. */
  22112. var defaults = baseRest(function(object, sources) {
  22113. object = Object(object);
  22114. var index = -1;
  22115. var length = sources.length;
  22116. var guard = length > 2 ? sources[2] : undefined;
  22117. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  22118. length = 1;
  22119. }
  22120. while (++index < length) {
  22121. var source = sources[index];
  22122. var props = keysIn(source);
  22123. var propsIndex = -1;
  22124. var propsLength = props.length;
  22125. while (++propsIndex < propsLength) {
  22126. var key = props[propsIndex];
  22127. var value = object[key];
  22128. if (value === undefined ||
  22129. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  22130. object[key] = source[key];
  22131. }
  22132. }
  22133. }
  22134. return object;
  22135. });
  22136. /**
  22137. * This method is like `_.defaults` except that it recursively assigns
  22138. * default properties.
  22139. *
  22140. * **Note:** This method mutates `object`.
  22141. *
  22142. * @static
  22143. * @memberOf _
  22144. * @since 3.10.0
  22145. * @category Object
  22146. * @param {Object} object The destination object.
  22147. * @param {...Object} [sources] The source objects.
  22148. * @returns {Object} Returns `object`.
  22149. * @see _.defaults
  22150. * @example
  22151. *
  22152. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  22153. * // => { 'a': { 'b': 2, 'c': 3 } }
  22154. */
  22155. var defaultsDeep = baseRest(function(args) {
  22156. args.push(undefined, customDefaultsMerge);
  22157. return apply(mergeWith, undefined, args);
  22158. });
  22159. /**
  22160. * This method is like `_.find` except that it returns the key of the first
  22161. * element `predicate` returns truthy for instead of the element itself.
  22162. *
  22163. * @static
  22164. * @memberOf _
  22165. * @since 1.1.0
  22166. * @category Object
  22167. * @param {Object} object The object to inspect.
  22168. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22169. * @returns {string|undefined} Returns the key of the matched element,
  22170. * else `undefined`.
  22171. * @example
  22172. *
  22173. * var users = {
  22174. * 'barney': { 'age': 36, 'active': true },
  22175. * 'fred': { 'age': 40, 'active': false },
  22176. * 'pebbles': { 'age': 1, 'active': true }
  22177. * };
  22178. *
  22179. * _.findKey(users, function(o) { return o.age < 40; });
  22180. * // => 'barney' (iteration order is not guaranteed)
  22181. *
  22182. * // The `_.matches` iteratee shorthand.
  22183. * _.findKey(users, { 'age': 1, 'active': true });
  22184. * // => 'pebbles'
  22185. *
  22186. * // The `_.matchesProperty` iteratee shorthand.
  22187. * _.findKey(users, ['active', false]);
  22188. * // => 'fred'
  22189. *
  22190. * // The `_.property` iteratee shorthand.
  22191. * _.findKey(users, 'active');
  22192. * // => 'barney'
  22193. */
  22194. function findKey(object, predicate) {
  22195. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  22196. }
  22197. /**
  22198. * This method is like `_.findKey` except that it iterates over elements of
  22199. * a collection in the opposite order.
  22200. *
  22201. * @static
  22202. * @memberOf _
  22203. * @since 2.0.0
  22204. * @category Object
  22205. * @param {Object} object The object to inspect.
  22206. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22207. * @returns {string|undefined} Returns the key of the matched element,
  22208. * else `undefined`.
  22209. * @example
  22210. *
  22211. * var users = {
  22212. * 'barney': { 'age': 36, 'active': true },
  22213. * 'fred': { 'age': 40, 'active': false },
  22214. * 'pebbles': { 'age': 1, 'active': true }
  22215. * };
  22216. *
  22217. * _.findLastKey(users, function(o) { return o.age < 40; });
  22218. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  22219. *
  22220. * // The `_.matches` iteratee shorthand.
  22221. * _.findLastKey(users, { 'age': 36, 'active': true });
  22222. * // => 'barney'
  22223. *
  22224. * // The `_.matchesProperty` iteratee shorthand.
  22225. * _.findLastKey(users, ['active', false]);
  22226. * // => 'fred'
  22227. *
  22228. * // The `_.property` iteratee shorthand.
  22229. * _.findLastKey(users, 'active');
  22230. * // => 'pebbles'
  22231. */
  22232. function findLastKey(object, predicate) {
  22233. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  22234. }
  22235. /**
  22236. * Iterates over own and inherited enumerable string keyed properties of an
  22237. * object and invokes `iteratee` for each property. The iteratee is invoked
  22238. * with three arguments: (value, key, object). Iteratee functions may exit
  22239. * iteration early by explicitly returning `false`.
  22240. *
  22241. * @static
  22242. * @memberOf _
  22243. * @since 0.3.0
  22244. * @category Object
  22245. * @param {Object} object The object to iterate over.
  22246. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22247. * @returns {Object} Returns `object`.
  22248. * @see _.forInRight
  22249. * @example
  22250. *
  22251. * function Foo() {
  22252. * this.a = 1;
  22253. * this.b = 2;
  22254. * }
  22255. *
  22256. * Foo.prototype.c = 3;
  22257. *
  22258. * _.forIn(new Foo, function(value, key) {
  22259. * console.log(key);
  22260. * });
  22261. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  22262. */
  22263. function forIn(object, iteratee) {
  22264. return object == null
  22265. ? object
  22266. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  22267. }
  22268. /**
  22269. * This method is like `_.forIn` except that it iterates over properties of
  22270. * `object` in the opposite order.
  22271. *
  22272. * @static
  22273. * @memberOf _
  22274. * @since 2.0.0
  22275. * @category Object
  22276. * @param {Object} object The object to iterate over.
  22277. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22278. * @returns {Object} Returns `object`.
  22279. * @see _.forIn
  22280. * @example
  22281. *
  22282. * function Foo() {
  22283. * this.a = 1;
  22284. * this.b = 2;
  22285. * }
  22286. *
  22287. * Foo.prototype.c = 3;
  22288. *
  22289. * _.forInRight(new Foo, function(value, key) {
  22290. * console.log(key);
  22291. * });
  22292. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  22293. */
  22294. function forInRight(object, iteratee) {
  22295. return object == null
  22296. ? object
  22297. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  22298. }
  22299. /**
  22300. * Iterates over own enumerable string keyed properties of an object and
  22301. * invokes `iteratee` for each property. The iteratee is invoked with three
  22302. * arguments: (value, key, object). Iteratee functions may exit iteration
  22303. * early by explicitly returning `false`.
  22304. *
  22305. * @static
  22306. * @memberOf _
  22307. * @since 0.3.0
  22308. * @category Object
  22309. * @param {Object} object The object to iterate over.
  22310. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22311. * @returns {Object} Returns `object`.
  22312. * @see _.forOwnRight
  22313. * @example
  22314. *
  22315. * function Foo() {
  22316. * this.a = 1;
  22317. * this.b = 2;
  22318. * }
  22319. *
  22320. * Foo.prototype.c = 3;
  22321. *
  22322. * _.forOwn(new Foo, function(value, key) {
  22323. * console.log(key);
  22324. * });
  22325. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  22326. */
  22327. function forOwn(object, iteratee) {
  22328. return object && baseForOwn(object, getIteratee(iteratee, 3));
  22329. }
  22330. /**
  22331. * This method is like `_.forOwn` except that it iterates over properties of
  22332. * `object` in the opposite order.
  22333. *
  22334. * @static
  22335. * @memberOf _
  22336. * @since 2.0.0
  22337. * @category Object
  22338. * @param {Object} object The object to iterate over.
  22339. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22340. * @returns {Object} Returns `object`.
  22341. * @see _.forOwn
  22342. * @example
  22343. *
  22344. * function Foo() {
  22345. * this.a = 1;
  22346. * this.b = 2;
  22347. * }
  22348. *
  22349. * Foo.prototype.c = 3;
  22350. *
  22351. * _.forOwnRight(new Foo, function(value, key) {
  22352. * console.log(key);
  22353. * });
  22354. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  22355. */
  22356. function forOwnRight(object, iteratee) {
  22357. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  22358. }
  22359. /**
  22360. * Creates an array of function property names from own enumerable properties
  22361. * of `object`.
  22362. *
  22363. * @static
  22364. * @since 0.1.0
  22365. * @memberOf _
  22366. * @category Object
  22367. * @param {Object} object The object to inspect.
  22368. * @returns {Array} Returns the function names.
  22369. * @see _.functionsIn
  22370. * @example
  22371. *
  22372. * function Foo() {
  22373. * this.a = _.constant('a');
  22374. * this.b = _.constant('b');
  22375. * }
  22376. *
  22377. * Foo.prototype.c = _.constant('c');
  22378. *
  22379. * _.functions(new Foo);
  22380. * // => ['a', 'b']
  22381. */
  22382. function functions(object) {
  22383. return object == null ? [] : baseFunctions(object, keys(object));
  22384. }
  22385. /**
  22386. * Creates an array of function property names from own and inherited
  22387. * enumerable properties of `object`.
  22388. *
  22389. * @static
  22390. * @memberOf _
  22391. * @since 4.0.0
  22392. * @category Object
  22393. * @param {Object} object The object to inspect.
  22394. * @returns {Array} Returns the function names.
  22395. * @see _.functions
  22396. * @example
  22397. *
  22398. * function Foo() {
  22399. * this.a = _.constant('a');
  22400. * this.b = _.constant('b');
  22401. * }
  22402. *
  22403. * Foo.prototype.c = _.constant('c');
  22404. *
  22405. * _.functionsIn(new Foo);
  22406. * // => ['a', 'b', 'c']
  22407. */
  22408. function functionsIn(object) {
  22409. return object == null ? [] : baseFunctions(object, keysIn(object));
  22410. }
  22411. /**
  22412. * Gets the value at `path` of `object`. If the resolved value is
  22413. * `undefined`, the `defaultValue` is returned in its place.
  22414. *
  22415. * @static
  22416. * @memberOf _
  22417. * @since 3.7.0
  22418. * @category Object
  22419. * @param {Object} object The object to query.
  22420. * @param {Array|string} path The path of the property to get.
  22421. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  22422. * @returns {*} Returns the resolved value.
  22423. * @example
  22424. *
  22425. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  22426. *
  22427. * _.get(object, 'a[0].b.c');
  22428. * // => 3
  22429. *
  22430. * _.get(object, ['a', '0', 'b', 'c']);
  22431. * // => 3
  22432. *
  22433. * _.get(object, 'a.b.c', 'default');
  22434. * // => 'default'
  22435. */
  22436. function get(object, path, defaultValue) {
  22437. var result = object == null ? undefined : baseGet(object, path);
  22438. return result === undefined ? defaultValue : result;
  22439. }
  22440. /**
  22441. * Checks if `path` is a direct property of `object`.
  22442. *
  22443. * @static
  22444. * @since 0.1.0
  22445. * @memberOf _
  22446. * @category Object
  22447. * @param {Object} object The object to query.
  22448. * @param {Array|string} path The path to check.
  22449. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  22450. * @example
  22451. *
  22452. * var object = { 'a': { 'b': 2 } };
  22453. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  22454. *
  22455. * _.has(object, 'a');
  22456. * // => true
  22457. *
  22458. * _.has(object, 'a.b');
  22459. * // => true
  22460. *
  22461. * _.has(object, ['a', 'b']);
  22462. * // => true
  22463. *
  22464. * _.has(other, 'a');
  22465. * // => false
  22466. */
  22467. function has(object, path) {
  22468. return object != null && hasPath(object, path, baseHas);
  22469. }
  22470. /**
  22471. * Checks if `path` is a direct or inherited property of `object`.
  22472. *
  22473. * @static
  22474. * @memberOf _
  22475. * @since 4.0.0
  22476. * @category Object
  22477. * @param {Object} object The object to query.
  22478. * @param {Array|string} path The path to check.
  22479. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  22480. * @example
  22481. *
  22482. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  22483. *
  22484. * _.hasIn(object, 'a');
  22485. * // => true
  22486. *
  22487. * _.hasIn(object, 'a.b');
  22488. * // => true
  22489. *
  22490. * _.hasIn(object, ['a', 'b']);
  22491. * // => true
  22492. *
  22493. * _.hasIn(object, 'b');
  22494. * // => false
  22495. */
  22496. function hasIn(object, path) {
  22497. return object != null && hasPath(object, path, baseHasIn);
  22498. }
  22499. /**
  22500. * Creates an object composed of the inverted keys and values of `object`.
  22501. * If `object` contains duplicate values, subsequent values overwrite
  22502. * property assignments of previous values.
  22503. *
  22504. * @static
  22505. * @memberOf _
  22506. * @since 0.7.0
  22507. * @category Object
  22508. * @param {Object} object The object to invert.
  22509. * @returns {Object} Returns the new inverted object.
  22510. * @example
  22511. *
  22512. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  22513. *
  22514. * _.invert(object);
  22515. * // => { '1': 'c', '2': 'b' }
  22516. */
  22517. var invert = createInverter(function(result, value, key) {
  22518. if (value != null &&
  22519. typeof value.toString != 'function') {
  22520. value = nativeObjectToString.call(value);
  22521. }
  22522. result[value] = key;
  22523. }, constant(identity));
  22524. /**
  22525. * This method is like `_.invert` except that the inverted object is generated
  22526. * from the results of running each element of `object` thru `iteratee`. The
  22527. * corresponding inverted value of each inverted key is an array of keys
  22528. * responsible for generating the inverted value. The iteratee is invoked
  22529. * with one argument: (value).
  22530. *
  22531. * @static
  22532. * @memberOf _
  22533. * @since 4.1.0
  22534. * @category Object
  22535. * @param {Object} object The object to invert.
  22536. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  22537. * @returns {Object} Returns the new inverted object.
  22538. * @example
  22539. *
  22540. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  22541. *
  22542. * _.invertBy(object);
  22543. * // => { '1': ['a', 'c'], '2': ['b'] }
  22544. *
  22545. * _.invertBy(object, function(value) {
  22546. * return 'group' + value;
  22547. * });
  22548. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  22549. */
  22550. var invertBy = createInverter(function(result, value, key) {
  22551. if (value != null &&
  22552. typeof value.toString != 'function') {
  22553. value = nativeObjectToString.call(value);
  22554. }
  22555. if (hasOwnProperty.call(result, value)) {
  22556. result[value].push(key);
  22557. } else {
  22558. result[value] = [key];
  22559. }
  22560. }, getIteratee);
  22561. /**
  22562. * Invokes the method at `path` of `object`.
  22563. *
  22564. * @static
  22565. * @memberOf _
  22566. * @since 4.0.0
  22567. * @category Object
  22568. * @param {Object} object The object to query.
  22569. * @param {Array|string} path The path of the method to invoke.
  22570. * @param {...*} [args] The arguments to invoke the method with.
  22571. * @returns {*} Returns the result of the invoked method.
  22572. * @example
  22573. *
  22574. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  22575. *
  22576. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  22577. * // => [2, 3]
  22578. */
  22579. var invoke = baseRest(baseInvoke);
  22580. /**
  22581. * Creates an array of the own enumerable property names of `object`.
  22582. *
  22583. * **Note:** Non-object values are coerced to objects. See the
  22584. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  22585. * for more details.
  22586. *
  22587. * @static
  22588. * @since 0.1.0
  22589. * @memberOf _
  22590. * @category Object
  22591. * @param {Object} object The object to query.
  22592. * @returns {Array} Returns the array of property names.
  22593. * @example
  22594. *
  22595. * function Foo() {
  22596. * this.a = 1;
  22597. * this.b = 2;
  22598. * }
  22599. *
  22600. * Foo.prototype.c = 3;
  22601. *
  22602. * _.keys(new Foo);
  22603. * // => ['a', 'b'] (iteration order is not guaranteed)
  22604. *
  22605. * _.keys('hi');
  22606. * // => ['0', '1']
  22607. */
  22608. function keys(object) {
  22609. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  22610. }
  22611. /**
  22612. * Creates an array of the own and inherited enumerable property names of `object`.
  22613. *
  22614. * **Note:** Non-object values are coerced to objects.
  22615. *
  22616. * @static
  22617. * @memberOf _
  22618. * @since 3.0.0
  22619. * @category Object
  22620. * @param {Object} object The object to query.
  22621. * @returns {Array} Returns the array of property names.
  22622. * @example
  22623. *
  22624. * function Foo() {
  22625. * this.a = 1;
  22626. * this.b = 2;
  22627. * }
  22628. *
  22629. * Foo.prototype.c = 3;
  22630. *
  22631. * _.keysIn(new Foo);
  22632. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  22633. */
  22634. function keysIn(object) {
  22635. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  22636. }
  22637. /**
  22638. * The opposite of `_.mapValues`; this method creates an object with the
  22639. * same values as `object` and keys generated by running each own enumerable
  22640. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  22641. * with three arguments: (value, key, object).
  22642. *
  22643. * @static
  22644. * @memberOf _
  22645. * @since 3.8.0
  22646. * @category Object
  22647. * @param {Object} object The object to iterate over.
  22648. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22649. * @returns {Object} Returns the new mapped object.
  22650. * @see _.mapValues
  22651. * @example
  22652. *
  22653. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  22654. * return key + value;
  22655. * });
  22656. * // => { 'a1': 1, 'b2': 2 }
  22657. */
  22658. function mapKeys(object, iteratee) {
  22659. var result = {};
  22660. iteratee = getIteratee(iteratee, 3);
  22661. baseForOwn(object, function(value, key, object) {
  22662. baseAssignValue(result, iteratee(value, key, object), value);
  22663. });
  22664. return result;
  22665. }
  22666. /**
  22667. * Creates an object with the same keys as `object` and values generated
  22668. * by running each own enumerable string keyed property of `object` thru
  22669. * `iteratee`. The iteratee is invoked with three arguments:
  22670. * (value, key, object).
  22671. *
  22672. * @static
  22673. * @memberOf _
  22674. * @since 2.4.0
  22675. * @category Object
  22676. * @param {Object} object The object to iterate over.
  22677. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22678. * @returns {Object} Returns the new mapped object.
  22679. * @see _.mapKeys
  22680. * @example
  22681. *
  22682. * var users = {
  22683. * 'fred': { 'user': 'fred', 'age': 40 },
  22684. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  22685. * };
  22686. *
  22687. * _.mapValues(users, function(o) { return o.age; });
  22688. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  22689. *
  22690. * // The `_.property` iteratee shorthand.
  22691. * _.mapValues(users, 'age');
  22692. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  22693. */
  22694. function mapValues(object, iteratee) {
  22695. var result = {};
  22696. iteratee = getIteratee(iteratee, 3);
  22697. baseForOwn(object, function(value, key, object) {
  22698. baseAssignValue(result, key, iteratee(value, key, object));
  22699. });
  22700. return result;
  22701. }
  22702. /**
  22703. * This method is like `_.assign` except that it recursively merges own and
  22704. * inherited enumerable string keyed properties of source objects into the
  22705. * destination object. Source properties that resolve to `undefined` are
  22706. * skipped if a destination value exists. Array and plain object properties
  22707. * are merged recursively. Other objects and value types are overridden by
  22708. * assignment. Source objects are applied from left to right. Subsequent
  22709. * sources overwrite property assignments of previous sources.
  22710. *
  22711. * **Note:** This method mutates `object`.
  22712. *
  22713. * @static
  22714. * @memberOf _
  22715. * @since 0.5.0
  22716. * @category Object
  22717. * @param {Object} object The destination object.
  22718. * @param {...Object} [sources] The source objects.
  22719. * @returns {Object} Returns `object`.
  22720. * @example
  22721. *
  22722. * var object = {
  22723. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  22724. * };
  22725. *
  22726. * var other = {
  22727. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  22728. * };
  22729. *
  22730. * _.merge(object, other);
  22731. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  22732. */
  22733. var merge = createAssigner(function(object, source, srcIndex) {
  22734. baseMerge(object, source, srcIndex);
  22735. });
  22736. /**
  22737. * This method is like `_.merge` except that it accepts `customizer` which
  22738. * is invoked to produce the merged values of the destination and source
  22739. * properties. If `customizer` returns `undefined`, merging is handled by the
  22740. * method instead. The `customizer` is invoked with six arguments:
  22741. * (objValue, srcValue, key, object, source, stack).
  22742. *
  22743. * **Note:** This method mutates `object`.
  22744. *
  22745. * @static
  22746. * @memberOf _
  22747. * @since 4.0.0
  22748. * @category Object
  22749. * @param {Object} object The destination object.
  22750. * @param {...Object} sources The source objects.
  22751. * @param {Function} customizer The function to customize assigned values.
  22752. * @returns {Object} Returns `object`.
  22753. * @example
  22754. *
  22755. * function customizer(objValue, srcValue) {
  22756. * if (_.isArray(objValue)) {
  22757. * return objValue.concat(srcValue);
  22758. * }
  22759. * }
  22760. *
  22761. * var object = { 'a': [1], 'b': [2] };
  22762. * var other = { 'a': [3], 'b': [4] };
  22763. *
  22764. * _.mergeWith(object, other, customizer);
  22765. * // => { 'a': [1, 3], 'b': [2, 4] }
  22766. */
  22767. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  22768. baseMerge(object, source, srcIndex, customizer);
  22769. });
  22770. /**
  22771. * The opposite of `_.pick`; this method creates an object composed of the
  22772. * own and inherited enumerable property paths of `object` that are not omitted.
  22773. *
  22774. * **Note:** This method is considerably slower than `_.pick`.
  22775. *
  22776. * @static
  22777. * @since 0.1.0
  22778. * @memberOf _
  22779. * @category Object
  22780. * @param {Object} object The source object.
  22781. * @param {...(string|string[])} [paths] The property paths to omit.
  22782. * @returns {Object} Returns the new object.
  22783. * @example
  22784. *
  22785. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  22786. *
  22787. * _.omit(object, ['a', 'c']);
  22788. * // => { 'b': '2' }
  22789. */
  22790. var omit = flatRest(function(object, paths) {
  22791. var result = {};
  22792. if (object == null) {
  22793. return result;
  22794. }
  22795. var isDeep = false;
  22796. paths = arrayMap(paths, function(path) {
  22797. path = castPath(path, object);
  22798. isDeep || (isDeep = path.length > 1);
  22799. return path;
  22800. });
  22801. copyObject(object, getAllKeysIn(object), result);
  22802. if (isDeep) {
  22803. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  22804. }
  22805. var length = paths.length;
  22806. while (length--) {
  22807. baseUnset(result, paths[length]);
  22808. }
  22809. return result;
  22810. });
  22811. /**
  22812. * The opposite of `_.pickBy`; this method creates an object composed of
  22813. * the own and inherited enumerable string keyed properties of `object` that
  22814. * `predicate` doesn't return truthy for. The predicate is invoked with two
  22815. * arguments: (value, key).
  22816. *
  22817. * @static
  22818. * @memberOf _
  22819. * @since 4.0.0
  22820. * @category Object
  22821. * @param {Object} object The source object.
  22822. * @param {Function} [predicate=_.identity] The function invoked per property.
  22823. * @returns {Object} Returns the new object.
  22824. * @example
  22825. *
  22826. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  22827. *
  22828. * _.omitBy(object, _.isNumber);
  22829. * // => { 'b': '2' }
  22830. */
  22831. function omitBy(object, predicate) {
  22832. return pickBy(object, negate(getIteratee(predicate)));
  22833. }
  22834. /**
  22835. * Creates an object composed of the picked `object` properties.
  22836. *
  22837. * @static
  22838. * @since 0.1.0
  22839. * @memberOf _
  22840. * @category Object
  22841. * @param {Object} object The source object.
  22842. * @param {...(string|string[])} [paths] The property paths to pick.
  22843. * @returns {Object} Returns the new object.
  22844. * @example
  22845. *
  22846. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  22847. *
  22848. * _.pick(object, ['a', 'c']);
  22849. * // => { 'a': 1, 'c': 3 }
  22850. */
  22851. var pick = flatRest(function(object, paths) {
  22852. return object == null ? {} : basePick(object, paths);
  22853. });
  22854. /**
  22855. * Creates an object composed of the `object` properties `predicate` returns
  22856. * truthy for. The predicate is invoked with two arguments: (value, key).
  22857. *
  22858. * @static
  22859. * @memberOf _
  22860. * @since 4.0.0
  22861. * @category Object
  22862. * @param {Object} object The source object.
  22863. * @param {Function} [predicate=_.identity] The function invoked per property.
  22864. * @returns {Object} Returns the new object.
  22865. * @example
  22866. *
  22867. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  22868. *
  22869. * _.pickBy(object, _.isNumber);
  22870. * // => { 'a': 1, 'c': 3 }
  22871. */
  22872. function pickBy(object, predicate) {
  22873. if (object == null) {
  22874. return {};
  22875. }
  22876. var props = arrayMap(getAllKeysIn(object), function(prop) {
  22877. return [prop];
  22878. });
  22879. predicate = getIteratee(predicate);
  22880. return basePickBy(object, props, function(value, path) {
  22881. return predicate(value, path[0]);
  22882. });
  22883. }
  22884. /**
  22885. * This method is like `_.get` except that if the resolved value is a
  22886. * function it's invoked with the `this` binding of its parent object and
  22887. * its result is returned.
  22888. *
  22889. * @static
  22890. * @since 0.1.0
  22891. * @memberOf _
  22892. * @category Object
  22893. * @param {Object} object The object to query.
  22894. * @param {Array|string} path The path of the property to resolve.
  22895. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  22896. * @returns {*} Returns the resolved value.
  22897. * @example
  22898. *
  22899. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  22900. *
  22901. * _.result(object, 'a[0].b.c1');
  22902. * // => 3
  22903. *
  22904. * _.result(object, 'a[0].b.c2');
  22905. * // => 4
  22906. *
  22907. * _.result(object, 'a[0].b.c3', 'default');
  22908. * // => 'default'
  22909. *
  22910. * _.result(object, 'a[0].b.c3', _.constant('default'));
  22911. * // => 'default'
  22912. */
  22913. function result(object, path, defaultValue) {
  22914. path = castPath(path, object);
  22915. var index = -1,
  22916. length = path.length;
  22917. // Ensure the loop is entered when path is empty.
  22918. if (!length) {
  22919. length = 1;
  22920. object = undefined;
  22921. }
  22922. while (++index < length) {
  22923. var value = object == null ? undefined : object[toKey(path[index])];
  22924. if (value === undefined) {
  22925. index = length;
  22926. value = defaultValue;
  22927. }
  22928. object = isFunction(value) ? value.call(object) : value;
  22929. }
  22930. return object;
  22931. }
  22932. /**
  22933. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  22934. * it's created. Arrays are created for missing index properties while objects
  22935. * are created for all other missing properties. Use `_.setWith` to customize
  22936. * `path` creation.
  22937. *
  22938. * **Note:** This method mutates `object`.
  22939. *
  22940. * @static
  22941. * @memberOf _
  22942. * @since 3.7.0
  22943. * @category Object
  22944. * @param {Object} object The object to modify.
  22945. * @param {Array|string} path The path of the property to set.
  22946. * @param {*} value The value to set.
  22947. * @returns {Object} Returns `object`.
  22948. * @example
  22949. *
  22950. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  22951. *
  22952. * _.set(object, 'a[0].b.c', 4);
  22953. * console.log(object.a[0].b.c);
  22954. * // => 4
  22955. *
  22956. * _.set(object, ['x', '0', 'y', 'z'], 5);
  22957. * console.log(object.x[0].y.z);
  22958. * // => 5
  22959. */
  22960. function set(object, path, value) {
  22961. return object == null ? object : baseSet(object, path, value);
  22962. }
  22963. /**
  22964. * This method is like `_.set` except that it accepts `customizer` which is
  22965. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  22966. * path creation is handled by the method instead. The `customizer` is invoked
  22967. * with three arguments: (nsValue, key, nsObject).
  22968. *
  22969. * **Note:** This method mutates `object`.
  22970. *
  22971. * @static
  22972. * @memberOf _
  22973. * @since 4.0.0
  22974. * @category Object
  22975. * @param {Object} object The object to modify.
  22976. * @param {Array|string} path The path of the property to set.
  22977. * @param {*} value The value to set.
  22978. * @param {Function} [customizer] The function to customize assigned values.
  22979. * @returns {Object} Returns `object`.
  22980. * @example
  22981. *
  22982. * var object = {};
  22983. *
  22984. * _.setWith(object, '[0][1]', 'a', Object);
  22985. * // => { '0': { '1': 'a' } }
  22986. */
  22987. function setWith(object, path, value, customizer) {
  22988. customizer = typeof customizer == 'function' ? customizer : undefined;
  22989. return object == null ? object : baseSet(object, path, value, customizer);
  22990. }
  22991. /**
  22992. * Creates an array of own enumerable string keyed-value pairs for `object`
  22993. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  22994. * entries are returned.
  22995. *
  22996. * @static
  22997. * @memberOf _
  22998. * @since 4.0.0
  22999. * @alias entries
  23000. * @category Object
  23001. * @param {Object} object The object to query.
  23002. * @returns {Array} Returns the key-value pairs.
  23003. * @example
  23004. *
  23005. * function Foo() {
  23006. * this.a = 1;
  23007. * this.b = 2;
  23008. * }
  23009. *
  23010. * Foo.prototype.c = 3;
  23011. *
  23012. * _.toPairs(new Foo);
  23013. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  23014. */
  23015. var toPairs = createToPairs(keys);
  23016. /**
  23017. * Creates an array of own and inherited enumerable string keyed-value pairs
  23018. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  23019. * or set, its entries are returned.
  23020. *
  23021. * @static
  23022. * @memberOf _
  23023. * @since 4.0.0
  23024. * @alias entriesIn
  23025. * @category Object
  23026. * @param {Object} object The object to query.
  23027. * @returns {Array} Returns the key-value pairs.
  23028. * @example
  23029. *
  23030. * function Foo() {
  23031. * this.a = 1;
  23032. * this.b = 2;
  23033. * }
  23034. *
  23035. * Foo.prototype.c = 3;
  23036. *
  23037. * _.toPairsIn(new Foo);
  23038. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  23039. */
  23040. var toPairsIn = createToPairs(keysIn);
  23041. /**
  23042. * An alternative to `_.reduce`; this method transforms `object` to a new
  23043. * `accumulator` object which is the result of running each of its own
  23044. * enumerable string keyed properties thru `iteratee`, with each invocation
  23045. * potentially mutating the `accumulator` object. If `accumulator` is not
  23046. * provided, a new object with the same `[[Prototype]]` will be used. The
  23047. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  23048. * Iteratee functions may exit iteration early by explicitly returning `false`.
  23049. *
  23050. * @static
  23051. * @memberOf _
  23052. * @since 1.3.0
  23053. * @category Object
  23054. * @param {Object} object The object to iterate over.
  23055. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  23056. * @param {*} [accumulator] The custom accumulator value.
  23057. * @returns {*} Returns the accumulated value.
  23058. * @example
  23059. *
  23060. * _.transform([2, 3, 4], function(result, n) {
  23061. * result.push(n *= n);
  23062. * return n % 2 == 0;
  23063. * }, []);
  23064. * // => [4, 9]
  23065. *
  23066. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  23067. * (result[value] || (result[value] = [])).push(key);
  23068. * }, {});
  23069. * // => { '1': ['a', 'c'], '2': ['b'] }
  23070. */
  23071. function transform(object, iteratee, accumulator) {
  23072. var isArr = isArray(object),
  23073. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  23074. iteratee = getIteratee(iteratee, 4);
  23075. if (accumulator == null) {
  23076. var Ctor = object && object.constructor;
  23077. if (isArrLike) {
  23078. accumulator = isArr ? new Ctor : [];
  23079. }
  23080. else if (isObject(object)) {
  23081. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  23082. }
  23083. else {
  23084. accumulator = {};
  23085. }
  23086. }
  23087. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  23088. return iteratee(accumulator, value, index, object);
  23089. });
  23090. return accumulator;
  23091. }
  23092. /**
  23093. * Removes the property at `path` of `object`.
  23094. *
  23095. * **Note:** This method mutates `object`.
  23096. *
  23097. * @static
  23098. * @memberOf _
  23099. * @since 4.0.0
  23100. * @category Object
  23101. * @param {Object} object The object to modify.
  23102. * @param {Array|string} path The path of the property to unset.
  23103. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  23104. * @example
  23105. *
  23106. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  23107. * _.unset(object, 'a[0].b.c');
  23108. * // => true
  23109. *
  23110. * console.log(object);
  23111. * // => { 'a': [{ 'b': {} }] };
  23112. *
  23113. * _.unset(object, ['a', '0', 'b', 'c']);
  23114. * // => true
  23115. *
  23116. * console.log(object);
  23117. * // => { 'a': [{ 'b': {} }] };
  23118. */
  23119. function unset(object, path) {
  23120. return object == null ? true : baseUnset(object, path);
  23121. }
  23122. /**
  23123. * This method is like `_.set` except that accepts `updater` to produce the
  23124. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  23125. * is invoked with one argument: (value).
  23126. *
  23127. * **Note:** This method mutates `object`.
  23128. *
  23129. * @static
  23130. * @memberOf _
  23131. * @since 4.6.0
  23132. * @category Object
  23133. * @param {Object} object The object to modify.
  23134. * @param {Array|string} path The path of the property to set.
  23135. * @param {Function} updater The function to produce the updated value.
  23136. * @returns {Object} Returns `object`.
  23137. * @example
  23138. *
  23139. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  23140. *
  23141. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  23142. * console.log(object.a[0].b.c);
  23143. * // => 9
  23144. *
  23145. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  23146. * console.log(object.x[0].y.z);
  23147. * // => 0
  23148. */
  23149. function update(object, path, updater) {
  23150. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  23151. }
  23152. /**
  23153. * This method is like `_.update` except that it accepts `customizer` which is
  23154. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  23155. * path creation is handled by the method instead. The `customizer` is invoked
  23156. * with three arguments: (nsValue, key, nsObject).
  23157. *
  23158. * **Note:** This method mutates `object`.
  23159. *
  23160. * @static
  23161. * @memberOf _
  23162. * @since 4.6.0
  23163. * @category Object
  23164. * @param {Object} object The object to modify.
  23165. * @param {Array|string} path The path of the property to set.
  23166. * @param {Function} updater The function to produce the updated value.
  23167. * @param {Function} [customizer] The function to customize assigned values.
  23168. * @returns {Object} Returns `object`.
  23169. * @example
  23170. *
  23171. * var object = {};
  23172. *
  23173. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  23174. * // => { '0': { '1': 'a' } }
  23175. */
  23176. function updateWith(object, path, updater, customizer) {
  23177. customizer = typeof customizer == 'function' ? customizer : undefined;
  23178. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  23179. }
  23180. /**
  23181. * Creates an array of the own enumerable string keyed property values of `object`.
  23182. *
  23183. * **Note:** Non-object values are coerced to objects.
  23184. *
  23185. * @static
  23186. * @since 0.1.0
  23187. * @memberOf _
  23188. * @category Object
  23189. * @param {Object} object The object to query.
  23190. * @returns {Array} Returns the array of property values.
  23191. * @example
  23192. *
  23193. * function Foo() {
  23194. * this.a = 1;
  23195. * this.b = 2;
  23196. * }
  23197. *
  23198. * Foo.prototype.c = 3;
  23199. *
  23200. * _.values(new Foo);
  23201. * // => [1, 2] (iteration order is not guaranteed)
  23202. *
  23203. * _.values('hi');
  23204. * // => ['h', 'i']
  23205. */
  23206. function values(object) {
  23207. return object == null ? [] : baseValues(object, keys(object));
  23208. }
  23209. /**
  23210. * Creates an array of the own and inherited enumerable string keyed property
  23211. * values of `object`.
  23212. *
  23213. * **Note:** Non-object values are coerced to objects.
  23214. *
  23215. * @static
  23216. * @memberOf _
  23217. * @since 3.0.0
  23218. * @category Object
  23219. * @param {Object} object The object to query.
  23220. * @returns {Array} Returns the array of property values.
  23221. * @example
  23222. *
  23223. * function Foo() {
  23224. * this.a = 1;
  23225. * this.b = 2;
  23226. * }
  23227. *
  23228. * Foo.prototype.c = 3;
  23229. *
  23230. * _.valuesIn(new Foo);
  23231. * // => [1, 2, 3] (iteration order is not guaranteed)
  23232. */
  23233. function valuesIn(object) {
  23234. return object == null ? [] : baseValues(object, keysIn(object));
  23235. }
  23236. /*------------------------------------------------------------------------*/
  23237. /**
  23238. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  23239. *
  23240. * @static
  23241. * @memberOf _
  23242. * @since 4.0.0
  23243. * @category Number
  23244. * @param {number} number The number to clamp.
  23245. * @param {number} [lower] The lower bound.
  23246. * @param {number} upper The upper bound.
  23247. * @returns {number} Returns the clamped number.
  23248. * @example
  23249. *
  23250. * _.clamp(-10, -5, 5);
  23251. * // => -5
  23252. *
  23253. * _.clamp(10, -5, 5);
  23254. * // => 5
  23255. */
  23256. function clamp(number, lower, upper) {
  23257. if (upper === undefined) {
  23258. upper = lower;
  23259. lower = undefined;
  23260. }
  23261. if (upper !== undefined) {
  23262. upper = toNumber(upper);
  23263. upper = upper === upper ? upper : 0;
  23264. }
  23265. if (lower !== undefined) {
  23266. lower = toNumber(lower);
  23267. lower = lower === lower ? lower : 0;
  23268. }
  23269. return baseClamp(toNumber(number), lower, upper);
  23270. }
  23271. /**
  23272. * Checks if `n` is between `start` and up to, but not including, `end`. If
  23273. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  23274. * If `start` is greater than `end` the params are swapped to support
  23275. * negative ranges.
  23276. *
  23277. * @static
  23278. * @memberOf _
  23279. * @since 3.3.0
  23280. * @category Number
  23281. * @param {number} number The number to check.
  23282. * @param {number} [start=0] The start of the range.
  23283. * @param {number} end The end of the range.
  23284. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  23285. * @see _.range, _.rangeRight
  23286. * @example
  23287. *
  23288. * _.inRange(3, 2, 4);
  23289. * // => true
  23290. *
  23291. * _.inRange(4, 8);
  23292. * // => true
  23293. *
  23294. * _.inRange(4, 2);
  23295. * // => false
  23296. *
  23297. * _.inRange(2, 2);
  23298. * // => false
  23299. *
  23300. * _.inRange(1.2, 2);
  23301. * // => true
  23302. *
  23303. * _.inRange(5.2, 4);
  23304. * // => false
  23305. *
  23306. * _.inRange(-3, -2, -6);
  23307. * // => true
  23308. */
  23309. function inRange(number, start, end) {
  23310. start = toFinite(start);
  23311. if (end === undefined) {
  23312. end = start;
  23313. start = 0;
  23314. } else {
  23315. end = toFinite(end);
  23316. }
  23317. number = toNumber(number);
  23318. return baseInRange(number, start, end);
  23319. }
  23320. /**
  23321. * Produces a random number between the inclusive `lower` and `upper` bounds.
  23322. * If only one argument is provided a number between `0` and the given number
  23323. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  23324. * floats, a floating-point number is returned instead of an integer.
  23325. *
  23326. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  23327. * floating-point values which can produce unexpected results.
  23328. *
  23329. * @static
  23330. * @memberOf _
  23331. * @since 0.7.0
  23332. * @category Number
  23333. * @param {number} [lower=0] The lower bound.
  23334. * @param {number} [upper=1] The upper bound.
  23335. * @param {boolean} [floating] Specify returning a floating-point number.
  23336. * @returns {number} Returns the random number.
  23337. * @example
  23338. *
  23339. * _.random(0, 5);
  23340. * // => an integer between 0 and 5
  23341. *
  23342. * _.random(5);
  23343. * // => also an integer between 0 and 5
  23344. *
  23345. * _.random(5, true);
  23346. * // => a floating-point number between 0 and 5
  23347. *
  23348. * _.random(1.2, 5.2);
  23349. * // => a floating-point number between 1.2 and 5.2
  23350. */
  23351. function random(lower, upper, floating) {
  23352. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  23353. upper = floating = undefined;
  23354. }
  23355. if (floating === undefined) {
  23356. if (typeof upper == 'boolean') {
  23357. floating = upper;
  23358. upper = undefined;
  23359. }
  23360. else if (typeof lower == 'boolean') {
  23361. floating = lower;
  23362. lower = undefined;
  23363. }
  23364. }
  23365. if (lower === undefined && upper === undefined) {
  23366. lower = 0;
  23367. upper = 1;
  23368. }
  23369. else {
  23370. lower = toFinite(lower);
  23371. if (upper === undefined) {
  23372. upper = lower;
  23373. lower = 0;
  23374. } else {
  23375. upper = toFinite(upper);
  23376. }
  23377. }
  23378. if (lower > upper) {
  23379. var temp = lower;
  23380. lower = upper;
  23381. upper = temp;
  23382. }
  23383. if (floating || lower % 1 || upper % 1) {
  23384. var rand = nativeRandom();
  23385. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  23386. }
  23387. return baseRandom(lower, upper);
  23388. }
  23389. /*------------------------------------------------------------------------*/
  23390. /**
  23391. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  23392. *
  23393. * @static
  23394. * @memberOf _
  23395. * @since 3.0.0
  23396. * @category String
  23397. * @param {string} [string=''] The string to convert.
  23398. * @returns {string} Returns the camel cased string.
  23399. * @example
  23400. *
  23401. * _.camelCase('Foo Bar');
  23402. * // => 'fooBar'
  23403. *
  23404. * _.camelCase('--foo-bar--');
  23405. * // => 'fooBar'
  23406. *
  23407. * _.camelCase('__FOO_BAR__');
  23408. * // => 'fooBar'
  23409. */
  23410. var camelCase = createCompounder(function(result, word, index) {
  23411. word = word.toLowerCase();
  23412. return result + (index ? capitalize(word) : word);
  23413. });
  23414. /**
  23415. * Converts the first character of `string` to upper case and the remaining
  23416. * to lower case.
  23417. *
  23418. * @static
  23419. * @memberOf _
  23420. * @since 3.0.0
  23421. * @category String
  23422. * @param {string} [string=''] The string to capitalize.
  23423. * @returns {string} Returns the capitalized string.
  23424. * @example
  23425. *
  23426. * _.capitalize('FRED');
  23427. * // => 'Fred'
  23428. */
  23429. function capitalize(string) {
  23430. return upperFirst(toString(string).toLowerCase());
  23431. }
  23432. /**
  23433. * Deburrs `string` by converting
  23434. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  23435. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  23436. * letters to basic Latin letters and removing
  23437. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  23438. *
  23439. * @static
  23440. * @memberOf _
  23441. * @since 3.0.0
  23442. * @category String
  23443. * @param {string} [string=''] The string to deburr.
  23444. * @returns {string} Returns the deburred string.
  23445. * @example
  23446. *
  23447. * _.deburr('déjà vu');
  23448. * // => 'deja vu'
  23449. */
  23450. function deburr(string) {
  23451. string = toString(string);
  23452. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  23453. }
  23454. /**
  23455. * Checks if `string` ends with the given target string.
  23456. *
  23457. * @static
  23458. * @memberOf _
  23459. * @since 3.0.0
  23460. * @category String
  23461. * @param {string} [string=''] The string to inspect.
  23462. * @param {string} [target] The string to search for.
  23463. * @param {number} [position=string.length] The position to search up to.
  23464. * @returns {boolean} Returns `true` if `string` ends with `target`,
  23465. * else `false`.
  23466. * @example
  23467. *
  23468. * _.endsWith('abc', 'c');
  23469. * // => true
  23470. *
  23471. * _.endsWith('abc', 'b');
  23472. * // => false
  23473. *
  23474. * _.endsWith('abc', 'b', 2);
  23475. * // => true
  23476. */
  23477. function endsWith(string, target, position) {
  23478. string = toString(string);
  23479. target = baseToString(target);
  23480. var length = string.length;
  23481. position = position === undefined
  23482. ? length
  23483. : baseClamp(toInteger(position), 0, length);
  23484. var end = position;
  23485. position -= target.length;
  23486. return position >= 0 && string.slice(position, end) == target;
  23487. }
  23488. /**
  23489. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  23490. * corresponding HTML entities.
  23491. *
  23492. * **Note:** No other characters are escaped. To escape additional
  23493. * characters use a third-party library like [_he_](https://mths.be/he).
  23494. *
  23495. * Though the ">" character is escaped for symmetry, characters like
  23496. * ">" and "/" don't need escaping in HTML and have no special meaning
  23497. * unless they're part of a tag or unquoted attribute value. See
  23498. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  23499. * (under "semi-related fun fact") for more details.
  23500. *
  23501. * When working with HTML you should always
  23502. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  23503. * XSS vectors.
  23504. *
  23505. * @static
  23506. * @since 0.1.0
  23507. * @memberOf _
  23508. * @category String
  23509. * @param {string} [string=''] The string to escape.
  23510. * @returns {string} Returns the escaped string.
  23511. * @example
  23512. *
  23513. * _.escape('fred, barney, & pebbles');
  23514. * // => 'fred, barney, &amp; pebbles'
  23515. */
  23516. function escape(string) {
  23517. string = toString(string);
  23518. return (string && reHasUnescapedHtml.test(string))
  23519. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  23520. : string;
  23521. }
  23522. /**
  23523. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  23524. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  23525. *
  23526. * @static
  23527. * @memberOf _
  23528. * @since 3.0.0
  23529. * @category String
  23530. * @param {string} [string=''] The string to escape.
  23531. * @returns {string} Returns the escaped string.
  23532. * @example
  23533. *
  23534. * _.escapeRegExp('[lodash](https://lodash.com/)');
  23535. * // => '\[lodash\]\(https://lodash\.com/\)'
  23536. */
  23537. function escapeRegExp(string) {
  23538. string = toString(string);
  23539. return (string && reHasRegExpChar.test(string))
  23540. ? string.replace(reRegExpChar, '\\$&')
  23541. : string;
  23542. }
  23543. /**
  23544. * Converts `string` to
  23545. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  23546. *
  23547. * @static
  23548. * @memberOf _
  23549. * @since 3.0.0
  23550. * @category String
  23551. * @param {string} [string=''] The string to convert.
  23552. * @returns {string} Returns the kebab cased string.
  23553. * @example
  23554. *
  23555. * _.kebabCase('Foo Bar');
  23556. * // => 'foo-bar'
  23557. *
  23558. * _.kebabCase('fooBar');
  23559. * // => 'foo-bar'
  23560. *
  23561. * _.kebabCase('__FOO_BAR__');
  23562. * // => 'foo-bar'
  23563. */
  23564. var kebabCase = createCompounder(function(result, word, index) {
  23565. return result + (index ? '-' : '') + word.toLowerCase();
  23566. });
  23567. /**
  23568. * Converts `string`, as space separated words, to lower case.
  23569. *
  23570. * @static
  23571. * @memberOf _
  23572. * @since 4.0.0
  23573. * @category String
  23574. * @param {string} [string=''] The string to convert.
  23575. * @returns {string} Returns the lower cased string.
  23576. * @example
  23577. *
  23578. * _.lowerCase('--Foo-Bar--');
  23579. * // => 'foo bar'
  23580. *
  23581. * _.lowerCase('fooBar');
  23582. * // => 'foo bar'
  23583. *
  23584. * _.lowerCase('__FOO_BAR__');
  23585. * // => 'foo bar'
  23586. */
  23587. var lowerCase = createCompounder(function(result, word, index) {
  23588. return result + (index ? ' ' : '') + word.toLowerCase();
  23589. });
  23590. /**
  23591. * Converts the first character of `string` to lower case.
  23592. *
  23593. * @static
  23594. * @memberOf _
  23595. * @since 4.0.0
  23596. * @category String
  23597. * @param {string} [string=''] The string to convert.
  23598. * @returns {string} Returns the converted string.
  23599. * @example
  23600. *
  23601. * _.lowerFirst('Fred');
  23602. * // => 'fred'
  23603. *
  23604. * _.lowerFirst('FRED');
  23605. * // => 'fRED'
  23606. */
  23607. var lowerFirst = createCaseFirst('toLowerCase');
  23608. /**
  23609. * Pads `string` on the left and right sides if it's shorter than `length`.
  23610. * Padding characters are truncated if they can't be evenly divided by `length`.
  23611. *
  23612. * @static
  23613. * @memberOf _
  23614. * @since 3.0.0
  23615. * @category String
  23616. * @param {string} [string=''] The string to pad.
  23617. * @param {number} [length=0] The padding length.
  23618. * @param {string} [chars=' '] The string used as padding.
  23619. * @returns {string} Returns the padded string.
  23620. * @example
  23621. *
  23622. * _.pad('abc', 8);
  23623. * // => ' abc '
  23624. *
  23625. * _.pad('abc', 8, '_-');
  23626. * // => '_-abc_-_'
  23627. *
  23628. * _.pad('abc', 3);
  23629. * // => 'abc'
  23630. */
  23631. function pad(string, length, chars) {
  23632. string = toString(string);
  23633. length = toInteger(length);
  23634. var strLength = length ? stringSize(string) : 0;
  23635. if (!length || strLength >= length) {
  23636. return string;
  23637. }
  23638. var mid = (length - strLength) / 2;
  23639. return (
  23640. createPadding(nativeFloor(mid), chars) +
  23641. string +
  23642. createPadding(nativeCeil(mid), chars)
  23643. );
  23644. }
  23645. /**
  23646. * Pads `string` on the right side if it's shorter than `length`. Padding
  23647. * characters are truncated if they exceed `length`.
  23648. *
  23649. * @static
  23650. * @memberOf _
  23651. * @since 4.0.0
  23652. * @category String
  23653. * @param {string} [string=''] The string to pad.
  23654. * @param {number} [length=0] The padding length.
  23655. * @param {string} [chars=' '] The string used as padding.
  23656. * @returns {string} Returns the padded string.
  23657. * @example
  23658. *
  23659. * _.padEnd('abc', 6);
  23660. * // => 'abc '
  23661. *
  23662. * _.padEnd('abc', 6, '_-');
  23663. * // => 'abc_-_'
  23664. *
  23665. * _.padEnd('abc', 3);
  23666. * // => 'abc'
  23667. */
  23668. function padEnd(string, length, chars) {
  23669. string = toString(string);
  23670. length = toInteger(length);
  23671. var strLength = length ? stringSize(string) : 0;
  23672. return (length && strLength < length)
  23673. ? (string + createPadding(length - strLength, chars))
  23674. : string;
  23675. }
  23676. /**
  23677. * Pads `string` on the left side if it's shorter than `length`. Padding
  23678. * characters are truncated if they exceed `length`.
  23679. *
  23680. * @static
  23681. * @memberOf _
  23682. * @since 4.0.0
  23683. * @category String
  23684. * @param {string} [string=''] The string to pad.
  23685. * @param {number} [length=0] The padding length.
  23686. * @param {string} [chars=' '] The string used as padding.
  23687. * @returns {string} Returns the padded string.
  23688. * @example
  23689. *
  23690. * _.padStart('abc', 6);
  23691. * // => ' abc'
  23692. *
  23693. * _.padStart('abc', 6, '_-');
  23694. * // => '_-_abc'
  23695. *
  23696. * _.padStart('abc', 3);
  23697. * // => 'abc'
  23698. */
  23699. function padStart(string, length, chars) {
  23700. string = toString(string);
  23701. length = toInteger(length);
  23702. var strLength = length ? stringSize(string) : 0;
  23703. return (length && strLength < length)
  23704. ? (createPadding(length - strLength, chars) + string)
  23705. : string;
  23706. }
  23707. /**
  23708. * Converts `string` to an integer of the specified radix. If `radix` is
  23709. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  23710. * hexadecimal, in which case a `radix` of `16` is used.
  23711. *
  23712. * **Note:** This method aligns with the
  23713. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  23714. *
  23715. * @static
  23716. * @memberOf _
  23717. * @since 1.1.0
  23718. * @category String
  23719. * @param {string} string The string to convert.
  23720. * @param {number} [radix=10] The radix to interpret `value` by.
  23721. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23722. * @returns {number} Returns the converted integer.
  23723. * @example
  23724. *
  23725. * _.parseInt('08');
  23726. * // => 8
  23727. *
  23728. * _.map(['6', '08', '10'], _.parseInt);
  23729. * // => [6, 8, 10]
  23730. */
  23731. function parseInt(string, radix, guard) {
  23732. if (guard || radix == null) {
  23733. radix = 0;
  23734. } else if (radix) {
  23735. radix = +radix;
  23736. }
  23737. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  23738. }
  23739. /**
  23740. * Repeats the given string `n` times.
  23741. *
  23742. * @static
  23743. * @memberOf _
  23744. * @since 3.0.0
  23745. * @category String
  23746. * @param {string} [string=''] The string to repeat.
  23747. * @param {number} [n=1] The number of times to repeat the string.
  23748. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23749. * @returns {string} Returns the repeated string.
  23750. * @example
  23751. *
  23752. * _.repeat('*', 3);
  23753. * // => '***'
  23754. *
  23755. * _.repeat('abc', 2);
  23756. * // => 'abcabc'
  23757. *
  23758. * _.repeat('abc', 0);
  23759. * // => ''
  23760. */
  23761. function repeat(string, n, guard) {
  23762. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  23763. n = 1;
  23764. } else {
  23765. n = toInteger(n);
  23766. }
  23767. return baseRepeat(toString(string), n);
  23768. }
  23769. /**
  23770. * Replaces matches for `pattern` in `string` with `replacement`.
  23771. *
  23772. * **Note:** This method is based on
  23773. * [`String#replace`](https://mdn.io/String/replace).
  23774. *
  23775. * @static
  23776. * @memberOf _
  23777. * @since 4.0.0
  23778. * @category String
  23779. * @param {string} [string=''] The string to modify.
  23780. * @param {RegExp|string} pattern The pattern to replace.
  23781. * @param {Function|string} replacement The match replacement.
  23782. * @returns {string} Returns the modified string.
  23783. * @example
  23784. *
  23785. * _.replace('Hi Fred', 'Fred', 'Barney');
  23786. * // => 'Hi Barney'
  23787. */
  23788. function replace() {
  23789. var args = arguments,
  23790. string = toString(args[0]);
  23791. return args.length < 3 ? string : string.replace(args[1], args[2]);
  23792. }
  23793. /**
  23794. * Converts `string` to
  23795. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  23796. *
  23797. * @static
  23798. * @memberOf _
  23799. * @since 3.0.0
  23800. * @category String
  23801. * @param {string} [string=''] The string to convert.
  23802. * @returns {string} Returns the snake cased string.
  23803. * @example
  23804. *
  23805. * _.snakeCase('Foo Bar');
  23806. * // => 'foo_bar'
  23807. *
  23808. * _.snakeCase('fooBar');
  23809. * // => 'foo_bar'
  23810. *
  23811. * _.snakeCase('--FOO-BAR--');
  23812. * // => 'foo_bar'
  23813. */
  23814. var snakeCase = createCompounder(function(result, word, index) {
  23815. return result + (index ? '_' : '') + word.toLowerCase();
  23816. });
  23817. /**
  23818. * Splits `string` by `separator`.
  23819. *
  23820. * **Note:** This method is based on
  23821. * [`String#split`](https://mdn.io/String/split).
  23822. *
  23823. * @static
  23824. * @memberOf _
  23825. * @since 4.0.0
  23826. * @category String
  23827. * @param {string} [string=''] The string to split.
  23828. * @param {RegExp|string} separator The separator pattern to split by.
  23829. * @param {number} [limit] The length to truncate results to.
  23830. * @returns {Array} Returns the string segments.
  23831. * @example
  23832. *
  23833. * _.split('a-b-c', '-', 2);
  23834. * // => ['a', 'b']
  23835. */
  23836. function split(string, separator, limit) {
  23837. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  23838. separator = limit = undefined;
  23839. }
  23840. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  23841. if (!limit) {
  23842. return [];
  23843. }
  23844. string = toString(string);
  23845. if (string && (
  23846. typeof separator == 'string' ||
  23847. (separator != null && !isRegExp(separator))
  23848. )) {
  23849. separator = baseToString(separator);
  23850. if (!separator && hasUnicode(string)) {
  23851. return castSlice(stringToArray(string), 0, limit);
  23852. }
  23853. }
  23854. return string.split(separator, limit);
  23855. }
  23856. /**
  23857. * Converts `string` to
  23858. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  23859. *
  23860. * @static
  23861. * @memberOf _
  23862. * @since 3.1.0
  23863. * @category String
  23864. * @param {string} [string=''] The string to convert.
  23865. * @returns {string} Returns the start cased string.
  23866. * @example
  23867. *
  23868. * _.startCase('--foo-bar--');
  23869. * // => 'Foo Bar'
  23870. *
  23871. * _.startCase('fooBar');
  23872. * // => 'Foo Bar'
  23873. *
  23874. * _.startCase('__FOO_BAR__');
  23875. * // => 'FOO BAR'
  23876. */
  23877. var startCase = createCompounder(function(result, word, index) {
  23878. return result + (index ? ' ' : '') + upperFirst(word);
  23879. });
  23880. /**
  23881. * Checks if `string` starts with the given target string.
  23882. *
  23883. * @static
  23884. * @memberOf _
  23885. * @since 3.0.0
  23886. * @category String
  23887. * @param {string} [string=''] The string to inspect.
  23888. * @param {string} [target] The string to search for.
  23889. * @param {number} [position=0] The position to search from.
  23890. * @returns {boolean} Returns `true` if `string` starts with `target`,
  23891. * else `false`.
  23892. * @example
  23893. *
  23894. * _.startsWith('abc', 'a');
  23895. * // => true
  23896. *
  23897. * _.startsWith('abc', 'b');
  23898. * // => false
  23899. *
  23900. * _.startsWith('abc', 'b', 1);
  23901. * // => true
  23902. */
  23903. function startsWith(string, target, position) {
  23904. string = toString(string);
  23905. position = position == null
  23906. ? 0
  23907. : baseClamp(toInteger(position), 0, string.length);
  23908. target = baseToString(target);
  23909. return string.slice(position, position + target.length) == target;
  23910. }
  23911. /**
  23912. * Creates a compiled template function that can interpolate data properties
  23913. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  23914. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  23915. * properties may be accessed as free variables in the template. If a setting
  23916. * object is given, it takes precedence over `_.templateSettings` values.
  23917. *
  23918. * **Note:** In the development build `_.template` utilizes
  23919. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  23920. * for easier debugging.
  23921. *
  23922. * For more information on precompiling templates see
  23923. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  23924. *
  23925. * For more information on Chrome extension sandboxes see
  23926. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  23927. *
  23928. * @static
  23929. * @since 0.1.0
  23930. * @memberOf _
  23931. * @category String
  23932. * @param {string} [string=''] The template string.
  23933. * @param {Object} [options={}] The options object.
  23934. * @param {RegExp} [options.escape=_.templateSettings.escape]
  23935. * The HTML "escape" delimiter.
  23936. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  23937. * The "evaluate" delimiter.
  23938. * @param {Object} [options.imports=_.templateSettings.imports]
  23939. * An object to import into the template as free variables.
  23940. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  23941. * The "interpolate" delimiter.
  23942. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  23943. * The sourceURL of the compiled template.
  23944. * @param {string} [options.variable='obj']
  23945. * The data object variable name.
  23946. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23947. * @returns {Function} Returns the compiled template function.
  23948. * @example
  23949. *
  23950. * // Use the "interpolate" delimiter to create a compiled template.
  23951. * var compiled = _.template('hello <%= user %>!');
  23952. * compiled({ 'user': 'fred' });
  23953. * // => 'hello fred!'
  23954. *
  23955. * // Use the HTML "escape" delimiter to escape data property values.
  23956. * var compiled = _.template('<b><%- value %></b>');
  23957. * compiled({ 'value': '<script>' });
  23958. * // => '<b>&lt;script&gt;</b>'
  23959. *
  23960. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  23961. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  23962. * compiled({ 'users': ['fred', 'barney'] });
  23963. * // => '<li>fred</li><li>barney</li>'
  23964. *
  23965. * // Use the internal `print` function in "evaluate" delimiters.
  23966. * var compiled = _.template('<% print("hello " + user); %>!');
  23967. * compiled({ 'user': 'barney' });
  23968. * // => 'hello barney!'
  23969. *
  23970. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  23971. * // Disable support by replacing the "interpolate" delimiter.
  23972. * var compiled = _.template('hello ${ user }!');
  23973. * compiled({ 'user': 'pebbles' });
  23974. * // => 'hello pebbles!'
  23975. *
  23976. * // Use backslashes to treat delimiters as plain text.
  23977. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  23978. * compiled({ 'value': 'ignored' });
  23979. * // => '<%- value %>'
  23980. *
  23981. * // Use the `imports` option to import `jQuery` as `jq`.
  23982. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  23983. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  23984. * compiled({ 'users': ['fred', 'barney'] });
  23985. * // => '<li>fred</li><li>barney</li>'
  23986. *
  23987. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  23988. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  23989. * compiled(data);
  23990. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  23991. *
  23992. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  23993. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  23994. * compiled.source;
  23995. * // => function(data) {
  23996. * // var __t, __p = '';
  23997. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  23998. * // return __p;
  23999. * // }
  24000. *
  24001. * // Use custom template delimiters.
  24002. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  24003. * var compiled = _.template('hello {{ user }}!');
  24004. * compiled({ 'user': 'mustache' });
  24005. * // => 'hello mustache!'
  24006. *
  24007. * // Use the `source` property to inline compiled templates for meaningful
  24008. * // line numbers in error messages and stack traces.
  24009. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  24010. * var JST = {\
  24011. * "main": ' + _.template(mainText).source + '\
  24012. * };\
  24013. * ');
  24014. */
  24015. function template(string, options, guard) {
  24016. // Based on John Resig's `tmpl` implementation
  24017. // (http://ejohn.org/blog/javascript-micro-templating/)
  24018. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  24019. var settings = lodash.templateSettings;
  24020. if (guard && isIterateeCall(string, options, guard)) {
  24021. options = undefined;
  24022. }
  24023. string = toString(string);
  24024. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  24025. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  24026. importsKeys = keys(imports),
  24027. importsValues = baseValues(imports, importsKeys);
  24028. var isEscaping,
  24029. isEvaluating,
  24030. index = 0,
  24031. interpolate = options.interpolate || reNoMatch,
  24032. source = "__p += '";
  24033. // Compile the regexp to match each delimiter.
  24034. var reDelimiters = RegExp(
  24035. (options.escape || reNoMatch).source + '|' +
  24036. interpolate.source + '|' +
  24037. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  24038. (options.evaluate || reNoMatch).source + '|$'
  24039. , 'g');
  24040. // Use a sourceURL for easier debugging.
  24041. // The sourceURL gets injected into the source that's eval-ed, so be careful
  24042. // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
  24043. // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
  24044. var sourceURL = '//# sourceURL=' +
  24045. (hasOwnProperty.call(options, 'sourceURL')
  24046. ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
  24047. : ('lodash.templateSources[' + (++templateCounter) + ']')
  24048. ) + '\n';
  24049. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  24050. interpolateValue || (interpolateValue = esTemplateValue);
  24051. // Escape characters that can't be included in string literals.
  24052. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  24053. // Replace delimiters with snippets.
  24054. if (escapeValue) {
  24055. isEscaping = true;
  24056. source += "' +\n__e(" + escapeValue + ") +\n'";
  24057. }
  24058. if (evaluateValue) {
  24059. isEvaluating = true;
  24060. source += "';\n" + evaluateValue + ";\n__p += '";
  24061. }
  24062. if (interpolateValue) {
  24063. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  24064. }
  24065. index = offset + match.length;
  24066. // The JS engine embedded in Adobe products needs `match` returned in
  24067. // order to produce the correct `offset` value.
  24068. return match;
  24069. });
  24070. source += "';\n";
  24071. // If `variable` is not specified wrap a with-statement around the generated
  24072. // code to add the data object to the top of the scope chain.
  24073. // Like with sourceURL, we take care to not check the option's prototype,
  24074. // as this configuration is a code injection vector.
  24075. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  24076. if (!variable) {
  24077. source = 'with (obj) {\n' + source + '\n}\n';
  24078. }
  24079. // Cleanup code by stripping empty strings.
  24080. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  24081. .replace(reEmptyStringMiddle, '$1')
  24082. .replace(reEmptyStringTrailing, '$1;');
  24083. // Frame code as the function body.
  24084. source = 'function(' + (variable || 'obj') + ') {\n' +
  24085. (variable
  24086. ? ''
  24087. : 'obj || (obj = {});\n'
  24088. ) +
  24089. "var __t, __p = ''" +
  24090. (isEscaping
  24091. ? ', __e = _.escape'
  24092. : ''
  24093. ) +
  24094. (isEvaluating
  24095. ? ', __j = Array.prototype.join;\n' +
  24096. "function print() { __p += __j.call(arguments, '') }\n"
  24097. : ';\n'
  24098. ) +
  24099. source +
  24100. 'return __p\n}';
  24101. var result = attempt(function() {
  24102. return Function(importsKeys, sourceURL + 'return ' + source)
  24103. .apply(undefined, importsValues);
  24104. });
  24105. // Provide the compiled function's source by its `toString` method or
  24106. // the `source` property as a convenience for inlining compiled templates.
  24107. result.source = source;
  24108. if (isError(result)) {
  24109. throw result;
  24110. }
  24111. return result;
  24112. }
  24113. /**
  24114. * Converts `string`, as a whole, to lower case just like
  24115. * [String#toLowerCase](https://mdn.io/toLowerCase).
  24116. *
  24117. * @static
  24118. * @memberOf _
  24119. * @since 4.0.0
  24120. * @category String
  24121. * @param {string} [string=''] The string to convert.
  24122. * @returns {string} Returns the lower cased string.
  24123. * @example
  24124. *
  24125. * _.toLower('--Foo-Bar--');
  24126. * // => '--foo-bar--'
  24127. *
  24128. * _.toLower('fooBar');
  24129. * // => 'foobar'
  24130. *
  24131. * _.toLower('__FOO_BAR__');
  24132. * // => '__foo_bar__'
  24133. */
  24134. function toLower(value) {
  24135. return toString(value).toLowerCase();
  24136. }
  24137. /**
  24138. * Converts `string`, as a whole, to upper case just like
  24139. * [String#toUpperCase](https://mdn.io/toUpperCase).
  24140. *
  24141. * @static
  24142. * @memberOf _
  24143. * @since 4.0.0
  24144. * @category String
  24145. * @param {string} [string=''] The string to convert.
  24146. * @returns {string} Returns the upper cased string.
  24147. * @example
  24148. *
  24149. * _.toUpper('--foo-bar--');
  24150. * // => '--FOO-BAR--'
  24151. *
  24152. * _.toUpper('fooBar');
  24153. * // => 'FOOBAR'
  24154. *
  24155. * _.toUpper('__foo_bar__');
  24156. * // => '__FOO_BAR__'
  24157. */
  24158. function toUpper(value) {
  24159. return toString(value).toUpperCase();
  24160. }
  24161. /**
  24162. * Removes leading and trailing whitespace or specified characters from `string`.
  24163. *
  24164. * @static
  24165. * @memberOf _
  24166. * @since 3.0.0
  24167. * @category String
  24168. * @param {string} [string=''] The string to trim.
  24169. * @param {string} [chars=whitespace] The characters to trim.
  24170. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24171. * @returns {string} Returns the trimmed string.
  24172. * @example
  24173. *
  24174. * _.trim(' abc ');
  24175. * // => 'abc'
  24176. *
  24177. * _.trim('-_-abc-_-', '_-');
  24178. * // => 'abc'
  24179. *
  24180. * _.map([' foo ', ' bar '], _.trim);
  24181. * // => ['foo', 'bar']
  24182. */
  24183. function trim(string, chars, guard) {
  24184. string = toString(string);
  24185. if (string && (guard || chars === undefined)) {
  24186. return string.replace(reTrim, '');
  24187. }
  24188. if (!string || !(chars = baseToString(chars))) {
  24189. return string;
  24190. }
  24191. var strSymbols = stringToArray(string),
  24192. chrSymbols = stringToArray(chars),
  24193. start = charsStartIndex(strSymbols, chrSymbols),
  24194. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  24195. return castSlice(strSymbols, start, end).join('');
  24196. }
  24197. /**
  24198. * Removes trailing whitespace or specified characters from `string`.
  24199. *
  24200. * @static
  24201. * @memberOf _
  24202. * @since 4.0.0
  24203. * @category String
  24204. * @param {string} [string=''] The string to trim.
  24205. * @param {string} [chars=whitespace] The characters to trim.
  24206. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24207. * @returns {string} Returns the trimmed string.
  24208. * @example
  24209. *
  24210. * _.trimEnd(' abc ');
  24211. * // => ' abc'
  24212. *
  24213. * _.trimEnd('-_-abc-_-', '_-');
  24214. * // => '-_-abc'
  24215. */
  24216. function trimEnd(string, chars, guard) {
  24217. string = toString(string);
  24218. if (string && (guard || chars === undefined)) {
  24219. return string.replace(reTrimEnd, '');
  24220. }
  24221. if (!string || !(chars = baseToString(chars))) {
  24222. return string;
  24223. }
  24224. var strSymbols = stringToArray(string),
  24225. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  24226. return castSlice(strSymbols, 0, end).join('');
  24227. }
  24228. /**
  24229. * Removes leading whitespace or specified characters from `string`.
  24230. *
  24231. * @static
  24232. * @memberOf _
  24233. * @since 4.0.0
  24234. * @category String
  24235. * @param {string} [string=''] The string to trim.
  24236. * @param {string} [chars=whitespace] The characters to trim.
  24237. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24238. * @returns {string} Returns the trimmed string.
  24239. * @example
  24240. *
  24241. * _.trimStart(' abc ');
  24242. * // => 'abc '
  24243. *
  24244. * _.trimStart('-_-abc-_-', '_-');
  24245. * // => 'abc-_-'
  24246. */
  24247. function trimStart(string, chars, guard) {
  24248. string = toString(string);
  24249. if (string && (guard || chars === undefined)) {
  24250. return string.replace(reTrimStart, '');
  24251. }
  24252. if (!string || !(chars = baseToString(chars))) {
  24253. return string;
  24254. }
  24255. var strSymbols = stringToArray(string),
  24256. start = charsStartIndex(strSymbols, stringToArray(chars));
  24257. return castSlice(strSymbols, start).join('');
  24258. }
  24259. /**
  24260. * Truncates `string` if it's longer than the given maximum string length.
  24261. * The last characters of the truncated string are replaced with the omission
  24262. * string which defaults to "...".
  24263. *
  24264. * @static
  24265. * @memberOf _
  24266. * @since 4.0.0
  24267. * @category String
  24268. * @param {string} [string=''] The string to truncate.
  24269. * @param {Object} [options={}] The options object.
  24270. * @param {number} [options.length=30] The maximum string length.
  24271. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  24272. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  24273. * @returns {string} Returns the truncated string.
  24274. * @example
  24275. *
  24276. * _.truncate('hi-diddly-ho there, neighborino');
  24277. * // => 'hi-diddly-ho there, neighbo...'
  24278. *
  24279. * _.truncate('hi-diddly-ho there, neighborino', {
  24280. * 'length': 24,
  24281. * 'separator': ' '
  24282. * });
  24283. * // => 'hi-diddly-ho there,...'
  24284. *
  24285. * _.truncate('hi-diddly-ho there, neighborino', {
  24286. * 'length': 24,
  24287. * 'separator': /,? +/
  24288. * });
  24289. * // => 'hi-diddly-ho there...'
  24290. *
  24291. * _.truncate('hi-diddly-ho there, neighborino', {
  24292. * 'omission': ' [...]'
  24293. * });
  24294. * // => 'hi-diddly-ho there, neig [...]'
  24295. */
  24296. function truncate(string, options) {
  24297. var length = DEFAULT_TRUNC_LENGTH,
  24298. omission = DEFAULT_TRUNC_OMISSION;
  24299. if (isObject(options)) {
  24300. var separator = 'separator' in options ? options.separator : separator;
  24301. length = 'length' in options ? toInteger(options.length) : length;
  24302. omission = 'omission' in options ? baseToString(options.omission) : omission;
  24303. }
  24304. string = toString(string);
  24305. var strLength = string.length;
  24306. if (hasUnicode(string)) {
  24307. var strSymbols = stringToArray(string);
  24308. strLength = strSymbols.length;
  24309. }
  24310. if (length >= strLength) {
  24311. return string;
  24312. }
  24313. var end = length - stringSize(omission);
  24314. if (end < 1) {
  24315. return omission;
  24316. }
  24317. var result = strSymbols
  24318. ? castSlice(strSymbols, 0, end).join('')
  24319. : string.slice(0, end);
  24320. if (separator === undefined) {
  24321. return result + omission;
  24322. }
  24323. if (strSymbols) {
  24324. end += (result.length - end);
  24325. }
  24326. if (isRegExp(separator)) {
  24327. if (string.slice(end).search(separator)) {
  24328. var match,
  24329. substring = result;
  24330. if (!separator.global) {
  24331. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  24332. }
  24333. separator.lastIndex = 0;
  24334. while ((match = separator.exec(substring))) {
  24335. var newEnd = match.index;
  24336. }
  24337. result = result.slice(0, newEnd === undefined ? end : newEnd);
  24338. }
  24339. } else if (string.indexOf(baseToString(separator), end) != end) {
  24340. var index = result.lastIndexOf(separator);
  24341. if (index > -1) {
  24342. result = result.slice(0, index);
  24343. }
  24344. }
  24345. return result + omission;
  24346. }
  24347. /**
  24348. * The inverse of `_.escape`; this method converts the HTML entities
  24349. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  24350. * their corresponding characters.
  24351. *
  24352. * **Note:** No other HTML entities are unescaped. To unescape additional
  24353. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  24354. *
  24355. * @static
  24356. * @memberOf _
  24357. * @since 0.6.0
  24358. * @category String
  24359. * @param {string} [string=''] The string to unescape.
  24360. * @returns {string} Returns the unescaped string.
  24361. * @example
  24362. *
  24363. * _.unescape('fred, barney, &amp; pebbles');
  24364. * // => 'fred, barney, & pebbles'
  24365. */
  24366. function unescape(string) {
  24367. string = toString(string);
  24368. return (string && reHasEscapedHtml.test(string))
  24369. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  24370. : string;
  24371. }
  24372. /**
  24373. * Converts `string`, as space separated words, to upper case.
  24374. *
  24375. * @static
  24376. * @memberOf _
  24377. * @since 4.0.0
  24378. * @category String
  24379. * @param {string} [string=''] The string to convert.
  24380. * @returns {string} Returns the upper cased string.
  24381. * @example
  24382. *
  24383. * _.upperCase('--foo-bar');
  24384. * // => 'FOO BAR'
  24385. *
  24386. * _.upperCase('fooBar');
  24387. * // => 'FOO BAR'
  24388. *
  24389. * _.upperCase('__foo_bar__');
  24390. * // => 'FOO BAR'
  24391. */
  24392. var upperCase = createCompounder(function(result, word, index) {
  24393. return result + (index ? ' ' : '') + word.toUpperCase();
  24394. });
  24395. /**
  24396. * Converts the first character of `string` to upper case.
  24397. *
  24398. * @static
  24399. * @memberOf _
  24400. * @since 4.0.0
  24401. * @category String
  24402. * @param {string} [string=''] The string to convert.
  24403. * @returns {string} Returns the converted string.
  24404. * @example
  24405. *
  24406. * _.upperFirst('fred');
  24407. * // => 'Fred'
  24408. *
  24409. * _.upperFirst('FRED');
  24410. * // => 'FRED'
  24411. */
  24412. var upperFirst = createCaseFirst('toUpperCase');
  24413. /**
  24414. * Splits `string` into an array of its words.
  24415. *
  24416. * @static
  24417. * @memberOf _
  24418. * @since 3.0.0
  24419. * @category String
  24420. * @param {string} [string=''] The string to inspect.
  24421. * @param {RegExp|string} [pattern] The pattern to match words.
  24422. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24423. * @returns {Array} Returns the words of `string`.
  24424. * @example
  24425. *
  24426. * _.words('fred, barney, & pebbles');
  24427. * // => ['fred', 'barney', 'pebbles']
  24428. *
  24429. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  24430. * // => ['fred', 'barney', '&', 'pebbles']
  24431. */
  24432. function words(string, pattern, guard) {
  24433. string = toString(string);
  24434. pattern = guard ? undefined : pattern;
  24435. if (pattern === undefined) {
  24436. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  24437. }
  24438. return string.match(pattern) || [];
  24439. }
  24440. /*------------------------------------------------------------------------*/
  24441. /**
  24442. * Attempts to invoke `func`, returning either the result or the caught error
  24443. * object. Any additional arguments are provided to `func` when it's invoked.
  24444. *
  24445. * @static
  24446. * @memberOf _
  24447. * @since 3.0.0
  24448. * @category Util
  24449. * @param {Function} func The function to attempt.
  24450. * @param {...*} [args] The arguments to invoke `func` with.
  24451. * @returns {*} Returns the `func` result or error object.
  24452. * @example
  24453. *
  24454. * // Avoid throwing errors for invalid selectors.
  24455. * var elements = _.attempt(function(selector) {
  24456. * return document.querySelectorAll(selector);
  24457. * }, '>_>');
  24458. *
  24459. * if (_.isError(elements)) {
  24460. * elements = [];
  24461. * }
  24462. */
  24463. var attempt = baseRest(function(func, args) {
  24464. try {
  24465. return apply(func, undefined, args);
  24466. } catch (e) {
  24467. return isError(e) ? e : new Error(e);
  24468. }
  24469. });
  24470. /**
  24471. * Binds methods of an object to the object itself, overwriting the existing
  24472. * method.
  24473. *
  24474. * **Note:** This method doesn't set the "length" property of bound functions.
  24475. *
  24476. * @static
  24477. * @since 0.1.0
  24478. * @memberOf _
  24479. * @category Util
  24480. * @param {Object} object The object to bind and assign the bound methods to.
  24481. * @param {...(string|string[])} methodNames The object method names to bind.
  24482. * @returns {Object} Returns `object`.
  24483. * @example
  24484. *
  24485. * var view = {
  24486. * 'label': 'docs',
  24487. * 'click': function() {
  24488. * console.log('clicked ' + this.label);
  24489. * }
  24490. * };
  24491. *
  24492. * _.bindAll(view, ['click']);
  24493. * jQuery(element).on('click', view.click);
  24494. * // => Logs 'clicked docs' when clicked.
  24495. */
  24496. var bindAll = flatRest(function(object, methodNames) {
  24497. arrayEach(methodNames, function(key) {
  24498. key = toKey(key);
  24499. baseAssignValue(object, key, bind(object[key], object));
  24500. });
  24501. return object;
  24502. });
  24503. /**
  24504. * Creates a function that iterates over `pairs` and invokes the corresponding
  24505. * function of the first predicate to return truthy. The predicate-function
  24506. * pairs are invoked with the `this` binding and arguments of the created
  24507. * function.
  24508. *
  24509. * @static
  24510. * @memberOf _
  24511. * @since 4.0.0
  24512. * @category Util
  24513. * @param {Array} pairs The predicate-function pairs.
  24514. * @returns {Function} Returns the new composite function.
  24515. * @example
  24516. *
  24517. * var func = _.cond([
  24518. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  24519. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  24520. * [_.stubTrue, _.constant('no match')]
  24521. * ]);
  24522. *
  24523. * func({ 'a': 1, 'b': 2 });
  24524. * // => 'matches A'
  24525. *
  24526. * func({ 'a': 0, 'b': 1 });
  24527. * // => 'matches B'
  24528. *
  24529. * func({ 'a': '1', 'b': '2' });
  24530. * // => 'no match'
  24531. */
  24532. function cond(pairs) {
  24533. var length = pairs == null ? 0 : pairs.length,
  24534. toIteratee = getIteratee();
  24535. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  24536. if (typeof pair[1] != 'function') {
  24537. throw new TypeError(FUNC_ERROR_TEXT);
  24538. }
  24539. return [toIteratee(pair[0]), pair[1]];
  24540. });
  24541. return baseRest(function(args) {
  24542. var index = -1;
  24543. while (++index < length) {
  24544. var pair = pairs[index];
  24545. if (apply(pair[0], this, args)) {
  24546. return apply(pair[1], this, args);
  24547. }
  24548. }
  24549. });
  24550. }
  24551. /**
  24552. * Creates a function that invokes the predicate properties of `source` with
  24553. * the corresponding property values of a given object, returning `true` if
  24554. * all predicates return truthy, else `false`.
  24555. *
  24556. * **Note:** The created function is equivalent to `_.conformsTo` with
  24557. * `source` partially applied.
  24558. *
  24559. * @static
  24560. * @memberOf _
  24561. * @since 4.0.0
  24562. * @category Util
  24563. * @param {Object} source The object of property predicates to conform to.
  24564. * @returns {Function} Returns the new spec function.
  24565. * @example
  24566. *
  24567. * var objects = [
  24568. * { 'a': 2, 'b': 1 },
  24569. * { 'a': 1, 'b': 2 }
  24570. * ];
  24571. *
  24572. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  24573. * // => [{ 'a': 1, 'b': 2 }]
  24574. */
  24575. function conforms(source) {
  24576. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  24577. }
  24578. /**
  24579. * Creates a function that returns `value`.
  24580. *
  24581. * @static
  24582. * @memberOf _
  24583. * @since 2.4.0
  24584. * @category Util
  24585. * @param {*} value The value to return from the new function.
  24586. * @returns {Function} Returns the new constant function.
  24587. * @example
  24588. *
  24589. * var objects = _.times(2, _.constant({ 'a': 1 }));
  24590. *
  24591. * console.log(objects);
  24592. * // => [{ 'a': 1 }, { 'a': 1 }]
  24593. *
  24594. * console.log(objects[0] === objects[1]);
  24595. * // => true
  24596. */
  24597. function constant(value) {
  24598. return function() {
  24599. return value;
  24600. };
  24601. }
  24602. /**
  24603. * Checks `value` to determine whether a default value should be returned in
  24604. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  24605. * or `undefined`.
  24606. *
  24607. * @static
  24608. * @memberOf _
  24609. * @since 4.14.0
  24610. * @category Util
  24611. * @param {*} value The value to check.
  24612. * @param {*} defaultValue The default value.
  24613. * @returns {*} Returns the resolved value.
  24614. * @example
  24615. *
  24616. * _.defaultTo(1, 10);
  24617. * // => 1
  24618. *
  24619. * _.defaultTo(undefined, 10);
  24620. * // => 10
  24621. */
  24622. function defaultTo(value, defaultValue) {
  24623. return (value == null || value !== value) ? defaultValue : value;
  24624. }
  24625. /**
  24626. * Creates a function that returns the result of invoking the given functions
  24627. * with the `this` binding of the created function, where each successive
  24628. * invocation is supplied the return value of the previous.
  24629. *
  24630. * @static
  24631. * @memberOf _
  24632. * @since 3.0.0
  24633. * @category Util
  24634. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  24635. * @returns {Function} Returns the new composite function.
  24636. * @see _.flowRight
  24637. * @example
  24638. *
  24639. * function square(n) {
  24640. * return n * n;
  24641. * }
  24642. *
  24643. * var addSquare = _.flow([_.add, square]);
  24644. * addSquare(1, 2);
  24645. * // => 9
  24646. */
  24647. var flow = createFlow();
  24648. /**
  24649. * This method is like `_.flow` except that it creates a function that
  24650. * invokes the given functions from right to left.
  24651. *
  24652. * @static
  24653. * @since 3.0.0
  24654. * @memberOf _
  24655. * @category Util
  24656. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  24657. * @returns {Function} Returns the new composite function.
  24658. * @see _.flow
  24659. * @example
  24660. *
  24661. * function square(n) {
  24662. * return n * n;
  24663. * }
  24664. *
  24665. * var addSquare = _.flowRight([square, _.add]);
  24666. * addSquare(1, 2);
  24667. * // => 9
  24668. */
  24669. var flowRight = createFlow(true);
  24670. /**
  24671. * This method returns the first argument it receives.
  24672. *
  24673. * @static
  24674. * @since 0.1.0
  24675. * @memberOf _
  24676. * @category Util
  24677. * @param {*} value Any value.
  24678. * @returns {*} Returns `value`.
  24679. * @example
  24680. *
  24681. * var object = { 'a': 1 };
  24682. *
  24683. * console.log(_.identity(object) === object);
  24684. * // => true
  24685. */
  24686. function identity(value) {
  24687. return value;
  24688. }
  24689. /**
  24690. * Creates a function that invokes `func` with the arguments of the created
  24691. * function. If `func` is a property name, the created function returns the
  24692. * property value for a given element. If `func` is an array or object, the
  24693. * created function returns `true` for elements that contain the equivalent
  24694. * source properties, otherwise it returns `false`.
  24695. *
  24696. * @static
  24697. * @since 4.0.0
  24698. * @memberOf _
  24699. * @category Util
  24700. * @param {*} [func=_.identity] The value to convert to a callback.
  24701. * @returns {Function} Returns the callback.
  24702. * @example
  24703. *
  24704. * var users = [
  24705. * { 'user': 'barney', 'age': 36, 'active': true },
  24706. * { 'user': 'fred', 'age': 40, 'active': false }
  24707. * ];
  24708. *
  24709. * // The `_.matches` iteratee shorthand.
  24710. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  24711. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  24712. *
  24713. * // The `_.matchesProperty` iteratee shorthand.
  24714. * _.filter(users, _.iteratee(['user', 'fred']));
  24715. * // => [{ 'user': 'fred', 'age': 40 }]
  24716. *
  24717. * // The `_.property` iteratee shorthand.
  24718. * _.map(users, _.iteratee('user'));
  24719. * // => ['barney', 'fred']
  24720. *
  24721. * // Create custom iteratee shorthands.
  24722. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  24723. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  24724. * return func.test(string);
  24725. * };
  24726. * });
  24727. *
  24728. * _.filter(['abc', 'def'], /ef/);
  24729. * // => ['def']
  24730. */
  24731. function iteratee(func) {
  24732. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  24733. }
  24734. /**
  24735. * Creates a function that performs a partial deep comparison between a given
  24736. * object and `source`, returning `true` if the given object has equivalent
  24737. * property values, else `false`.
  24738. *
  24739. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  24740. * partially applied.
  24741. *
  24742. * Partial comparisons will match empty array and empty object `source`
  24743. * values against any array or object value, respectively. See `_.isEqual`
  24744. * for a list of supported value comparisons.
  24745. *
  24746. * @static
  24747. * @memberOf _
  24748. * @since 3.0.0
  24749. * @category Util
  24750. * @param {Object} source The object of property values to match.
  24751. * @returns {Function} Returns the new spec function.
  24752. * @example
  24753. *
  24754. * var objects = [
  24755. * { 'a': 1, 'b': 2, 'c': 3 },
  24756. * { 'a': 4, 'b': 5, 'c': 6 }
  24757. * ];
  24758. *
  24759. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  24760. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  24761. */
  24762. function matches(source) {
  24763. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  24764. }
  24765. /**
  24766. * Creates a function that performs a partial deep comparison between the
  24767. * value at `path` of a given object to `srcValue`, returning `true` if the
  24768. * object value is equivalent, else `false`.
  24769. *
  24770. * **Note:** Partial comparisons will match empty array and empty object
  24771. * `srcValue` values against any array or object value, respectively. See
  24772. * `_.isEqual` for a list of supported value comparisons.
  24773. *
  24774. * @static
  24775. * @memberOf _
  24776. * @since 3.2.0
  24777. * @category Util
  24778. * @param {Array|string} path The path of the property to get.
  24779. * @param {*} srcValue The value to match.
  24780. * @returns {Function} Returns the new spec function.
  24781. * @example
  24782. *
  24783. * var objects = [
  24784. * { 'a': 1, 'b': 2, 'c': 3 },
  24785. * { 'a': 4, 'b': 5, 'c': 6 }
  24786. * ];
  24787. *
  24788. * _.find(objects, _.matchesProperty('a', 4));
  24789. * // => { 'a': 4, 'b': 5, 'c': 6 }
  24790. */
  24791. function matchesProperty(path, srcValue) {
  24792. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  24793. }
  24794. /**
  24795. * Creates a function that invokes the method at `path` of a given object.
  24796. * Any additional arguments are provided to the invoked method.
  24797. *
  24798. * @static
  24799. * @memberOf _
  24800. * @since 3.7.0
  24801. * @category Util
  24802. * @param {Array|string} path The path of the method to invoke.
  24803. * @param {...*} [args] The arguments to invoke the method with.
  24804. * @returns {Function} Returns the new invoker function.
  24805. * @example
  24806. *
  24807. * var objects = [
  24808. * { 'a': { 'b': _.constant(2) } },
  24809. * { 'a': { 'b': _.constant(1) } }
  24810. * ];
  24811. *
  24812. * _.map(objects, _.method('a.b'));
  24813. * // => [2, 1]
  24814. *
  24815. * _.map(objects, _.method(['a', 'b']));
  24816. * // => [2, 1]
  24817. */
  24818. var method = baseRest(function(path, args) {
  24819. return function(object) {
  24820. return baseInvoke(object, path, args);
  24821. };
  24822. });
  24823. /**
  24824. * The opposite of `_.method`; this method creates a function that invokes
  24825. * the method at a given path of `object`. Any additional arguments are
  24826. * provided to the invoked method.
  24827. *
  24828. * @static
  24829. * @memberOf _
  24830. * @since 3.7.0
  24831. * @category Util
  24832. * @param {Object} object The object to query.
  24833. * @param {...*} [args] The arguments to invoke the method with.
  24834. * @returns {Function} Returns the new invoker function.
  24835. * @example
  24836. *
  24837. * var array = _.times(3, _.constant),
  24838. * object = { 'a': array, 'b': array, 'c': array };
  24839. *
  24840. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  24841. * // => [2, 0]
  24842. *
  24843. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  24844. * // => [2, 0]
  24845. */
  24846. var methodOf = baseRest(function(object, args) {
  24847. return function(path) {
  24848. return baseInvoke(object, path, args);
  24849. };
  24850. });
  24851. /**
  24852. * Adds all own enumerable string keyed function properties of a source
  24853. * object to the destination object. If `object` is a function, then methods
  24854. * are added to its prototype as well.
  24855. *
  24856. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  24857. * avoid conflicts caused by modifying the original.
  24858. *
  24859. * @static
  24860. * @since 0.1.0
  24861. * @memberOf _
  24862. * @category Util
  24863. * @param {Function|Object} [object=lodash] The destination object.
  24864. * @param {Object} source The object of functions to add.
  24865. * @param {Object} [options={}] The options object.
  24866. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  24867. * @returns {Function|Object} Returns `object`.
  24868. * @example
  24869. *
  24870. * function vowels(string) {
  24871. * return _.filter(string, function(v) {
  24872. * return /[aeiou]/i.test(v);
  24873. * });
  24874. * }
  24875. *
  24876. * _.mixin({ 'vowels': vowels });
  24877. * _.vowels('fred');
  24878. * // => ['e']
  24879. *
  24880. * _('fred').vowels().value();
  24881. * // => ['e']
  24882. *
  24883. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  24884. * _('fred').vowels();
  24885. * // => ['e']
  24886. */
  24887. function mixin(object, source, options) {
  24888. var props = keys(source),
  24889. methodNames = baseFunctions(source, props);
  24890. if (options == null &&
  24891. !(isObject(source) && (methodNames.length || !props.length))) {
  24892. options = source;
  24893. source = object;
  24894. object = this;
  24895. methodNames = baseFunctions(source, keys(source));
  24896. }
  24897. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  24898. isFunc = isFunction(object);
  24899. arrayEach(methodNames, function(methodName) {
  24900. var func = source[methodName];
  24901. object[methodName] = func;
  24902. if (isFunc) {
  24903. object.prototype[methodName] = function() {
  24904. var chainAll = this.__chain__;
  24905. if (chain || chainAll) {
  24906. var result = object(this.__wrapped__),
  24907. actions = result.__actions__ = copyArray(this.__actions__);
  24908. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  24909. result.__chain__ = chainAll;
  24910. return result;
  24911. }
  24912. return func.apply(object, arrayPush([this.value()], arguments));
  24913. };
  24914. }
  24915. });
  24916. return object;
  24917. }
  24918. /**
  24919. * Reverts the `_` variable to its previous value and returns a reference to
  24920. * the `lodash` function.
  24921. *
  24922. * @static
  24923. * @since 0.1.0
  24924. * @memberOf _
  24925. * @category Util
  24926. * @returns {Function} Returns the `lodash` function.
  24927. * @example
  24928. *
  24929. * var lodash = _.noConflict();
  24930. */
  24931. function noConflict() {
  24932. if (root._ === this) {
  24933. root._ = oldDash;
  24934. }
  24935. return this;
  24936. }
  24937. /**
  24938. * This method returns `undefined`.
  24939. *
  24940. * @static
  24941. * @memberOf _
  24942. * @since 2.3.0
  24943. * @category Util
  24944. * @example
  24945. *
  24946. * _.times(2, _.noop);
  24947. * // => [undefined, undefined]
  24948. */
  24949. function noop() {
  24950. // No operation performed.
  24951. }
  24952. /**
  24953. * Creates a function that gets the argument at index `n`. If `n` is negative,
  24954. * the nth argument from the end is returned.
  24955. *
  24956. * @static
  24957. * @memberOf _
  24958. * @since 4.0.0
  24959. * @category Util
  24960. * @param {number} [n=0] The index of the argument to return.
  24961. * @returns {Function} Returns the new pass-thru function.
  24962. * @example
  24963. *
  24964. * var func = _.nthArg(1);
  24965. * func('a', 'b', 'c', 'd');
  24966. * // => 'b'
  24967. *
  24968. * var func = _.nthArg(-2);
  24969. * func('a', 'b', 'c', 'd');
  24970. * // => 'c'
  24971. */
  24972. function nthArg(n) {
  24973. n = toInteger(n);
  24974. return baseRest(function(args) {
  24975. return baseNth(args, n);
  24976. });
  24977. }
  24978. /**
  24979. * Creates a function that invokes `iteratees` with the arguments it receives
  24980. * and returns their results.
  24981. *
  24982. * @static
  24983. * @memberOf _
  24984. * @since 4.0.0
  24985. * @category Util
  24986. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  24987. * The iteratees to invoke.
  24988. * @returns {Function} Returns the new function.
  24989. * @example
  24990. *
  24991. * var func = _.over([Math.max, Math.min]);
  24992. *
  24993. * func(1, 2, 3, 4);
  24994. * // => [4, 1]
  24995. */
  24996. var over = createOver(arrayMap);
  24997. /**
  24998. * Creates a function that checks if **all** of the `predicates` return
  24999. * truthy when invoked with the arguments it receives.
  25000. *
  25001. * @static
  25002. * @memberOf _
  25003. * @since 4.0.0
  25004. * @category Util
  25005. * @param {...(Function|Function[])} [predicates=[_.identity]]
  25006. * The predicates to check.
  25007. * @returns {Function} Returns the new function.
  25008. * @example
  25009. *
  25010. * var func = _.overEvery([Boolean, isFinite]);
  25011. *
  25012. * func('1');
  25013. * // => true
  25014. *
  25015. * func(null);
  25016. * // => false
  25017. *
  25018. * func(NaN);
  25019. * // => false
  25020. */
  25021. var overEvery = createOver(arrayEvery);
  25022. /**
  25023. * Creates a function that checks if **any** of the `predicates` return
  25024. * truthy when invoked with the arguments it receives.
  25025. *
  25026. * @static
  25027. * @memberOf _
  25028. * @since 4.0.0
  25029. * @category Util
  25030. * @param {...(Function|Function[])} [predicates=[_.identity]]
  25031. * The predicates to check.
  25032. * @returns {Function} Returns the new function.
  25033. * @example
  25034. *
  25035. * var func = _.overSome([Boolean, isFinite]);
  25036. *
  25037. * func('1');
  25038. * // => true
  25039. *
  25040. * func(null);
  25041. * // => true
  25042. *
  25043. * func(NaN);
  25044. * // => false
  25045. */
  25046. var overSome = createOver(arraySome);
  25047. /**
  25048. * Creates a function that returns the value at `path` of a given object.
  25049. *
  25050. * @static
  25051. * @memberOf _
  25052. * @since 2.4.0
  25053. * @category Util
  25054. * @param {Array|string} path The path of the property to get.
  25055. * @returns {Function} Returns the new accessor function.
  25056. * @example
  25057. *
  25058. * var objects = [
  25059. * { 'a': { 'b': 2 } },
  25060. * { 'a': { 'b': 1 } }
  25061. * ];
  25062. *
  25063. * _.map(objects, _.property('a.b'));
  25064. * // => [2, 1]
  25065. *
  25066. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  25067. * // => [1, 2]
  25068. */
  25069. function property(path) {
  25070. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  25071. }
  25072. /**
  25073. * The opposite of `_.property`; this method creates a function that returns
  25074. * the value at a given path of `object`.
  25075. *
  25076. * @static
  25077. * @memberOf _
  25078. * @since 3.0.0
  25079. * @category Util
  25080. * @param {Object} object The object to query.
  25081. * @returns {Function} Returns the new accessor function.
  25082. * @example
  25083. *
  25084. * var array = [0, 1, 2],
  25085. * object = { 'a': array, 'b': array, 'c': array };
  25086. *
  25087. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  25088. * // => [2, 0]
  25089. *
  25090. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  25091. * // => [2, 0]
  25092. */
  25093. function propertyOf(object) {
  25094. return function(path) {
  25095. return object == null ? undefined : baseGet(object, path);
  25096. };
  25097. }
  25098. /**
  25099. * Creates an array of numbers (positive and/or negative) progressing from
  25100. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  25101. * `start` is specified without an `end` or `step`. If `end` is not specified,
  25102. * it's set to `start` with `start` then set to `0`.
  25103. *
  25104. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  25105. * floating-point values which can produce unexpected results.
  25106. *
  25107. * @static
  25108. * @since 0.1.0
  25109. * @memberOf _
  25110. * @category Util
  25111. * @param {number} [start=0] The start of the range.
  25112. * @param {number} end The end of the range.
  25113. * @param {number} [step=1] The value to increment or decrement by.
  25114. * @returns {Array} Returns the range of numbers.
  25115. * @see _.inRange, _.rangeRight
  25116. * @example
  25117. *
  25118. * _.range(4);
  25119. * // => [0, 1, 2, 3]
  25120. *
  25121. * _.range(-4);
  25122. * // => [0, -1, -2, -3]
  25123. *
  25124. * _.range(1, 5);
  25125. * // => [1, 2, 3, 4]
  25126. *
  25127. * _.range(0, 20, 5);
  25128. * // => [0, 5, 10, 15]
  25129. *
  25130. * _.range(0, -4, -1);
  25131. * // => [0, -1, -2, -3]
  25132. *
  25133. * _.range(1, 4, 0);
  25134. * // => [1, 1, 1]
  25135. *
  25136. * _.range(0);
  25137. * // => []
  25138. */
  25139. var range = createRange();
  25140. /**
  25141. * This method is like `_.range` except that it populates values in
  25142. * descending order.
  25143. *
  25144. * @static
  25145. * @memberOf _
  25146. * @since 4.0.0
  25147. * @category Util
  25148. * @param {number} [start=0] The start of the range.
  25149. * @param {number} end The end of the range.
  25150. * @param {number} [step=1] The value to increment or decrement by.
  25151. * @returns {Array} Returns the range of numbers.
  25152. * @see _.inRange, _.range
  25153. * @example
  25154. *
  25155. * _.rangeRight(4);
  25156. * // => [3, 2, 1, 0]
  25157. *
  25158. * _.rangeRight(-4);
  25159. * // => [-3, -2, -1, 0]
  25160. *
  25161. * _.rangeRight(1, 5);
  25162. * // => [4, 3, 2, 1]
  25163. *
  25164. * _.rangeRight(0, 20, 5);
  25165. * // => [15, 10, 5, 0]
  25166. *
  25167. * _.rangeRight(0, -4, -1);
  25168. * // => [-3, -2, -1, 0]
  25169. *
  25170. * _.rangeRight(1, 4, 0);
  25171. * // => [1, 1, 1]
  25172. *
  25173. * _.rangeRight(0);
  25174. * // => []
  25175. */
  25176. var rangeRight = createRange(true);
  25177. /**
  25178. * This method returns a new empty array.
  25179. *
  25180. * @static
  25181. * @memberOf _
  25182. * @since 4.13.0
  25183. * @category Util
  25184. * @returns {Array} Returns the new empty array.
  25185. * @example
  25186. *
  25187. * var arrays = _.times(2, _.stubArray);
  25188. *
  25189. * console.log(arrays);
  25190. * // => [[], []]
  25191. *
  25192. * console.log(arrays[0] === arrays[1]);
  25193. * // => false
  25194. */
  25195. function stubArray() {
  25196. return [];
  25197. }
  25198. /**
  25199. * This method returns `false`.
  25200. *
  25201. * @static
  25202. * @memberOf _
  25203. * @since 4.13.0
  25204. * @category Util
  25205. * @returns {boolean} Returns `false`.
  25206. * @example
  25207. *
  25208. * _.times(2, _.stubFalse);
  25209. * // => [false, false]
  25210. */
  25211. function stubFalse() {
  25212. return false;
  25213. }
  25214. /**
  25215. * This method returns a new empty object.
  25216. *
  25217. * @static
  25218. * @memberOf _
  25219. * @since 4.13.0
  25220. * @category Util
  25221. * @returns {Object} Returns the new empty object.
  25222. * @example
  25223. *
  25224. * var objects = _.times(2, _.stubObject);
  25225. *
  25226. * console.log(objects);
  25227. * // => [{}, {}]
  25228. *
  25229. * console.log(objects[0] === objects[1]);
  25230. * // => false
  25231. */
  25232. function stubObject() {
  25233. return {};
  25234. }
  25235. /**
  25236. * This method returns an empty string.
  25237. *
  25238. * @static
  25239. * @memberOf _
  25240. * @since 4.13.0
  25241. * @category Util
  25242. * @returns {string} Returns the empty string.
  25243. * @example
  25244. *
  25245. * _.times(2, _.stubString);
  25246. * // => ['', '']
  25247. */
  25248. function stubString() {
  25249. return '';
  25250. }
  25251. /**
  25252. * This method returns `true`.
  25253. *
  25254. * @static
  25255. * @memberOf _
  25256. * @since 4.13.0
  25257. * @category Util
  25258. * @returns {boolean} Returns `true`.
  25259. * @example
  25260. *
  25261. * _.times(2, _.stubTrue);
  25262. * // => [true, true]
  25263. */
  25264. function stubTrue() {
  25265. return true;
  25266. }
  25267. /**
  25268. * Invokes the iteratee `n` times, returning an array of the results of
  25269. * each invocation. The iteratee is invoked with one argument; (index).
  25270. *
  25271. * @static
  25272. * @since 0.1.0
  25273. * @memberOf _
  25274. * @category Util
  25275. * @param {number} n The number of times to invoke `iteratee`.
  25276. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  25277. * @returns {Array} Returns the array of results.
  25278. * @example
  25279. *
  25280. * _.times(3, String);
  25281. * // => ['0', '1', '2']
  25282. *
  25283. * _.times(4, _.constant(0));
  25284. * // => [0, 0, 0, 0]
  25285. */
  25286. function times(n, iteratee) {
  25287. n = toInteger(n);
  25288. if (n < 1 || n > MAX_SAFE_INTEGER) {
  25289. return [];
  25290. }
  25291. var index = MAX_ARRAY_LENGTH,
  25292. length = nativeMin(n, MAX_ARRAY_LENGTH);
  25293. iteratee = getIteratee(iteratee);
  25294. n -= MAX_ARRAY_LENGTH;
  25295. var result = baseTimes(length, iteratee);
  25296. while (++index < n) {
  25297. iteratee(index);
  25298. }
  25299. return result;
  25300. }
  25301. /**
  25302. * Converts `value` to a property path array.
  25303. *
  25304. * @static
  25305. * @memberOf _
  25306. * @since 4.0.0
  25307. * @category Util
  25308. * @param {*} value The value to convert.
  25309. * @returns {Array} Returns the new property path array.
  25310. * @example
  25311. *
  25312. * _.toPath('a.b.c');
  25313. * // => ['a', 'b', 'c']
  25314. *
  25315. * _.toPath('a[0].b.c');
  25316. * // => ['a', '0', 'b', 'c']
  25317. */
  25318. function toPath(value) {
  25319. if (isArray(value)) {
  25320. return arrayMap(value, toKey);
  25321. }
  25322. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  25323. }
  25324. /**
  25325. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  25326. *
  25327. * @static
  25328. * @since 0.1.0
  25329. * @memberOf _
  25330. * @category Util
  25331. * @param {string} [prefix=''] The value to prefix the ID with.
  25332. * @returns {string} Returns the unique ID.
  25333. * @example
  25334. *
  25335. * _.uniqueId('contact_');
  25336. * // => 'contact_104'
  25337. *
  25338. * _.uniqueId();
  25339. * // => '105'
  25340. */
  25341. function uniqueId(prefix) {
  25342. var id = ++idCounter;
  25343. return toString(prefix) + id;
  25344. }
  25345. /*------------------------------------------------------------------------*/
  25346. /**
  25347. * Adds two numbers.
  25348. *
  25349. * @static
  25350. * @memberOf _
  25351. * @since 3.4.0
  25352. * @category Math
  25353. * @param {number} augend The first number in an addition.
  25354. * @param {number} addend The second number in an addition.
  25355. * @returns {number} Returns the total.
  25356. * @example
  25357. *
  25358. * _.add(6, 4);
  25359. * // => 10
  25360. */
  25361. var add = createMathOperation(function(augend, addend) {
  25362. return augend + addend;
  25363. }, 0);
  25364. /**
  25365. * Computes `number` rounded up to `precision`.
  25366. *
  25367. * @static
  25368. * @memberOf _
  25369. * @since 3.10.0
  25370. * @category Math
  25371. * @param {number} number The number to round up.
  25372. * @param {number} [precision=0] The precision to round up to.
  25373. * @returns {number} Returns the rounded up number.
  25374. * @example
  25375. *
  25376. * _.ceil(4.006);
  25377. * // => 5
  25378. *
  25379. * _.ceil(6.004, 2);
  25380. * // => 6.01
  25381. *
  25382. * _.ceil(6040, -2);
  25383. * // => 6100
  25384. */
  25385. var ceil = createRound('ceil');
  25386. /**
  25387. * Divide two numbers.
  25388. *
  25389. * @static
  25390. * @memberOf _
  25391. * @since 4.7.0
  25392. * @category Math
  25393. * @param {number} dividend The first number in a division.
  25394. * @param {number} divisor The second number in a division.
  25395. * @returns {number} Returns the quotient.
  25396. * @example
  25397. *
  25398. * _.divide(6, 4);
  25399. * // => 1.5
  25400. */
  25401. var divide = createMathOperation(function(dividend, divisor) {
  25402. return dividend / divisor;
  25403. }, 1);
  25404. /**
  25405. * Computes `number` rounded down to `precision`.
  25406. *
  25407. * @static
  25408. * @memberOf _
  25409. * @since 3.10.0
  25410. * @category Math
  25411. * @param {number} number The number to round down.
  25412. * @param {number} [precision=0] The precision to round down to.
  25413. * @returns {number} Returns the rounded down number.
  25414. * @example
  25415. *
  25416. * _.floor(4.006);
  25417. * // => 4
  25418. *
  25419. * _.floor(0.046, 2);
  25420. * // => 0.04
  25421. *
  25422. * _.floor(4060, -2);
  25423. * // => 4000
  25424. */
  25425. var floor = createRound('floor');
  25426. /**
  25427. * Computes the maximum value of `array`. If `array` is empty or falsey,
  25428. * `undefined` is returned.
  25429. *
  25430. * @static
  25431. * @since 0.1.0
  25432. * @memberOf _
  25433. * @category Math
  25434. * @param {Array} array The array to iterate over.
  25435. * @returns {*} Returns the maximum value.
  25436. * @example
  25437. *
  25438. * _.max([4, 2, 8, 6]);
  25439. * // => 8
  25440. *
  25441. * _.max([]);
  25442. * // => undefined
  25443. */
  25444. function max(array) {
  25445. return (array && array.length)
  25446. ? baseExtremum(array, identity, baseGt)
  25447. : undefined;
  25448. }
  25449. /**
  25450. * This method is like `_.max` except that it accepts `iteratee` which is
  25451. * invoked for each element in `array` to generate the criterion by which
  25452. * the value is ranked. The iteratee is invoked with one argument: (value).
  25453. *
  25454. * @static
  25455. * @memberOf _
  25456. * @since 4.0.0
  25457. * @category Math
  25458. * @param {Array} array The array to iterate over.
  25459. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25460. * @returns {*} Returns the maximum value.
  25461. * @example
  25462. *
  25463. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  25464. *
  25465. * _.maxBy(objects, function(o) { return o.n; });
  25466. * // => { 'n': 2 }
  25467. *
  25468. * // The `_.property` iteratee shorthand.
  25469. * _.maxBy(objects, 'n');
  25470. * // => { 'n': 2 }
  25471. */
  25472. function maxBy(array, iteratee) {
  25473. return (array && array.length)
  25474. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  25475. : undefined;
  25476. }
  25477. /**
  25478. * Computes the mean of the values in `array`.
  25479. *
  25480. * @static
  25481. * @memberOf _
  25482. * @since 4.0.0
  25483. * @category Math
  25484. * @param {Array} array The array to iterate over.
  25485. * @returns {number} Returns the mean.
  25486. * @example
  25487. *
  25488. * _.mean([4, 2, 8, 6]);
  25489. * // => 5
  25490. */
  25491. function mean(array) {
  25492. return baseMean(array, identity);
  25493. }
  25494. /**
  25495. * This method is like `_.mean` except that it accepts `iteratee` which is
  25496. * invoked for each element in `array` to generate the value to be averaged.
  25497. * The iteratee is invoked with one argument: (value).
  25498. *
  25499. * @static
  25500. * @memberOf _
  25501. * @since 4.7.0
  25502. * @category Math
  25503. * @param {Array} array The array to iterate over.
  25504. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25505. * @returns {number} Returns the mean.
  25506. * @example
  25507. *
  25508. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  25509. *
  25510. * _.meanBy(objects, function(o) { return o.n; });
  25511. * // => 5
  25512. *
  25513. * // The `_.property` iteratee shorthand.
  25514. * _.meanBy(objects, 'n');
  25515. * // => 5
  25516. */
  25517. function meanBy(array, iteratee) {
  25518. return baseMean(array, getIteratee(iteratee, 2));
  25519. }
  25520. /**
  25521. * Computes the minimum value of `array`. If `array` is empty or falsey,
  25522. * `undefined` is returned.
  25523. *
  25524. * @static
  25525. * @since 0.1.0
  25526. * @memberOf _
  25527. * @category Math
  25528. * @param {Array} array The array to iterate over.
  25529. * @returns {*} Returns the minimum value.
  25530. * @example
  25531. *
  25532. * _.min([4, 2, 8, 6]);
  25533. * // => 2
  25534. *
  25535. * _.min([]);
  25536. * // => undefined
  25537. */
  25538. function min(array) {
  25539. return (array && array.length)
  25540. ? baseExtremum(array, identity, baseLt)
  25541. : undefined;
  25542. }
  25543. /**
  25544. * This method is like `_.min` except that it accepts `iteratee` which is
  25545. * invoked for each element in `array` to generate the criterion by which
  25546. * the value is ranked. The iteratee is invoked with one argument: (value).
  25547. *
  25548. * @static
  25549. * @memberOf _
  25550. * @since 4.0.0
  25551. * @category Math
  25552. * @param {Array} array The array to iterate over.
  25553. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25554. * @returns {*} Returns the minimum value.
  25555. * @example
  25556. *
  25557. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  25558. *
  25559. * _.minBy(objects, function(o) { return o.n; });
  25560. * // => { 'n': 1 }
  25561. *
  25562. * // The `_.property` iteratee shorthand.
  25563. * _.minBy(objects, 'n');
  25564. * // => { 'n': 1 }
  25565. */
  25566. function minBy(array, iteratee) {
  25567. return (array && array.length)
  25568. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  25569. : undefined;
  25570. }
  25571. /**
  25572. * Multiply two numbers.
  25573. *
  25574. * @static
  25575. * @memberOf _
  25576. * @since 4.7.0
  25577. * @category Math
  25578. * @param {number} multiplier The first number in a multiplication.
  25579. * @param {number} multiplicand The second number in a multiplication.
  25580. * @returns {number} Returns the product.
  25581. * @example
  25582. *
  25583. * _.multiply(6, 4);
  25584. * // => 24
  25585. */
  25586. var multiply = createMathOperation(function(multiplier, multiplicand) {
  25587. return multiplier * multiplicand;
  25588. }, 1);
  25589. /**
  25590. * Computes `number` rounded to `precision`.
  25591. *
  25592. * @static
  25593. * @memberOf _
  25594. * @since 3.10.0
  25595. * @category Math
  25596. * @param {number} number The number to round.
  25597. * @param {number} [precision=0] The precision to round to.
  25598. * @returns {number} Returns the rounded number.
  25599. * @example
  25600. *
  25601. * _.round(4.006);
  25602. * // => 4
  25603. *
  25604. * _.round(4.006, 2);
  25605. * // => 4.01
  25606. *
  25607. * _.round(4060, -2);
  25608. * // => 4100
  25609. */
  25610. var round = createRound('round');
  25611. /**
  25612. * Subtract two numbers.
  25613. *
  25614. * @static
  25615. * @memberOf _
  25616. * @since 4.0.0
  25617. * @category Math
  25618. * @param {number} minuend The first number in a subtraction.
  25619. * @param {number} subtrahend The second number in a subtraction.
  25620. * @returns {number} Returns the difference.
  25621. * @example
  25622. *
  25623. * _.subtract(6, 4);
  25624. * // => 2
  25625. */
  25626. var subtract = createMathOperation(function(minuend, subtrahend) {
  25627. return minuend - subtrahend;
  25628. }, 0);
  25629. /**
  25630. * Computes the sum of the values in `array`.
  25631. *
  25632. * @static
  25633. * @memberOf _
  25634. * @since 3.4.0
  25635. * @category Math
  25636. * @param {Array} array The array to iterate over.
  25637. * @returns {number} Returns the sum.
  25638. * @example
  25639. *
  25640. * _.sum([4, 2, 8, 6]);
  25641. * // => 20
  25642. */
  25643. function sum(array) {
  25644. return (array && array.length)
  25645. ? baseSum(array, identity)
  25646. : 0;
  25647. }
  25648. /**
  25649. * This method is like `_.sum` except that it accepts `iteratee` which is
  25650. * invoked for each element in `array` to generate the value to be summed.
  25651. * The iteratee is invoked with one argument: (value).
  25652. *
  25653. * @static
  25654. * @memberOf _
  25655. * @since 4.0.0
  25656. * @category Math
  25657. * @param {Array} array The array to iterate over.
  25658. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25659. * @returns {number} Returns the sum.
  25660. * @example
  25661. *
  25662. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  25663. *
  25664. * _.sumBy(objects, function(o) { return o.n; });
  25665. * // => 20
  25666. *
  25667. * // The `_.property` iteratee shorthand.
  25668. * _.sumBy(objects, 'n');
  25669. * // => 20
  25670. */
  25671. function sumBy(array, iteratee) {
  25672. return (array && array.length)
  25673. ? baseSum(array, getIteratee(iteratee, 2))
  25674. : 0;
  25675. }
  25676. /*------------------------------------------------------------------------*/
  25677. // Add methods that return wrapped values in chain sequences.
  25678. lodash.after = after;
  25679. lodash.ary = ary;
  25680. lodash.assign = assign;
  25681. lodash.assignIn = assignIn;
  25682. lodash.assignInWith = assignInWith;
  25683. lodash.assignWith = assignWith;
  25684. lodash.at = at;
  25685. lodash.before = before;
  25686. lodash.bind = bind;
  25687. lodash.bindAll = bindAll;
  25688. lodash.bindKey = bindKey;
  25689. lodash.castArray = castArray;
  25690. lodash.chain = chain;
  25691. lodash.chunk = chunk;
  25692. lodash.compact = compact;
  25693. lodash.concat = concat;
  25694. lodash.cond = cond;
  25695. lodash.conforms = conforms;
  25696. lodash.constant = constant;
  25697. lodash.countBy = countBy;
  25698. lodash.create = create;
  25699. lodash.curry = curry;
  25700. lodash.curryRight = curryRight;
  25701. lodash.debounce = debounce;
  25702. lodash.defaults = defaults;
  25703. lodash.defaultsDeep = defaultsDeep;
  25704. lodash.defer = defer;
  25705. lodash.delay = delay;
  25706. lodash.difference = difference;
  25707. lodash.differenceBy = differenceBy;
  25708. lodash.differenceWith = differenceWith;
  25709. lodash.drop = drop;
  25710. lodash.dropRight = dropRight;
  25711. lodash.dropRightWhile = dropRightWhile;
  25712. lodash.dropWhile = dropWhile;
  25713. lodash.fill = fill;
  25714. lodash.filter = filter;
  25715. lodash.flatMap = flatMap;
  25716. lodash.flatMapDeep = flatMapDeep;
  25717. lodash.flatMapDepth = flatMapDepth;
  25718. lodash.flatten = flatten;
  25719. lodash.flattenDeep = flattenDeep;
  25720. lodash.flattenDepth = flattenDepth;
  25721. lodash.flip = flip;
  25722. lodash.flow = flow;
  25723. lodash.flowRight = flowRight;
  25724. lodash.fromPairs = fromPairs;
  25725. lodash.functions = functions;
  25726. lodash.functionsIn = functionsIn;
  25727. lodash.groupBy = groupBy;
  25728. lodash.initial = initial;
  25729. lodash.intersection = intersection;
  25730. lodash.intersectionBy = intersectionBy;
  25731. lodash.intersectionWith = intersectionWith;
  25732. lodash.invert = invert;
  25733. lodash.invertBy = invertBy;
  25734. lodash.invokeMap = invokeMap;
  25735. lodash.iteratee = iteratee;
  25736. lodash.keyBy = keyBy;
  25737. lodash.keys = keys;
  25738. lodash.keysIn = keysIn;
  25739. lodash.map = map;
  25740. lodash.mapKeys = mapKeys;
  25741. lodash.mapValues = mapValues;
  25742. lodash.matches = matches;
  25743. lodash.matchesProperty = matchesProperty;
  25744. lodash.memoize = memoize;
  25745. lodash.merge = merge;
  25746. lodash.mergeWith = mergeWith;
  25747. lodash.method = method;
  25748. lodash.methodOf = methodOf;
  25749. lodash.mixin = mixin;
  25750. lodash.negate = negate;
  25751. lodash.nthArg = nthArg;
  25752. lodash.omit = omit;
  25753. lodash.omitBy = omitBy;
  25754. lodash.once = once;
  25755. lodash.orderBy = orderBy;
  25756. lodash.over = over;
  25757. lodash.overArgs = overArgs;
  25758. lodash.overEvery = overEvery;
  25759. lodash.overSome = overSome;
  25760. lodash.partial = partial;
  25761. lodash.partialRight = partialRight;
  25762. lodash.partition = partition;
  25763. lodash.pick = pick;
  25764. lodash.pickBy = pickBy;
  25765. lodash.property = property;
  25766. lodash.propertyOf = propertyOf;
  25767. lodash.pull = pull;
  25768. lodash.pullAll = pullAll;
  25769. lodash.pullAllBy = pullAllBy;
  25770. lodash.pullAllWith = pullAllWith;
  25771. lodash.pullAt = pullAt;
  25772. lodash.range = range;
  25773. lodash.rangeRight = rangeRight;
  25774. lodash.rearg = rearg;
  25775. lodash.reject = reject;
  25776. lodash.remove = remove;
  25777. lodash.rest = rest;
  25778. lodash.reverse = reverse;
  25779. lodash.sampleSize = sampleSize;
  25780. lodash.set = set;
  25781. lodash.setWith = setWith;
  25782. lodash.shuffle = shuffle;
  25783. lodash.slice = slice;
  25784. lodash.sortBy = sortBy;
  25785. lodash.sortedUniq = sortedUniq;
  25786. lodash.sortedUniqBy = sortedUniqBy;
  25787. lodash.split = split;
  25788. lodash.spread = spread;
  25789. lodash.tail = tail;
  25790. lodash.take = take;
  25791. lodash.takeRight = takeRight;
  25792. lodash.takeRightWhile = takeRightWhile;
  25793. lodash.takeWhile = takeWhile;
  25794. lodash.tap = tap;
  25795. lodash.throttle = throttle;
  25796. lodash.thru = thru;
  25797. lodash.toArray = toArray;
  25798. lodash.toPairs = toPairs;
  25799. lodash.toPairsIn = toPairsIn;
  25800. lodash.toPath = toPath;
  25801. lodash.toPlainObject = toPlainObject;
  25802. lodash.transform = transform;
  25803. lodash.unary = unary;
  25804. lodash.union = union;
  25805. lodash.unionBy = unionBy;
  25806. lodash.unionWith = unionWith;
  25807. lodash.uniq = uniq;
  25808. lodash.uniqBy = uniqBy;
  25809. lodash.uniqWith = uniqWith;
  25810. lodash.unset = unset;
  25811. lodash.unzip = unzip;
  25812. lodash.unzipWith = unzipWith;
  25813. lodash.update = update;
  25814. lodash.updateWith = updateWith;
  25815. lodash.values = values;
  25816. lodash.valuesIn = valuesIn;
  25817. lodash.without = without;
  25818. lodash.words = words;
  25819. lodash.wrap = wrap;
  25820. lodash.xor = xor;
  25821. lodash.xorBy = xorBy;
  25822. lodash.xorWith = xorWith;
  25823. lodash.zip = zip;
  25824. lodash.zipObject = zipObject;
  25825. lodash.zipObjectDeep = zipObjectDeep;
  25826. lodash.zipWith = zipWith;
  25827. // Add aliases.
  25828. lodash.entries = toPairs;
  25829. lodash.entriesIn = toPairsIn;
  25830. lodash.extend = assignIn;
  25831. lodash.extendWith = assignInWith;
  25832. // Add methods to `lodash.prototype`.
  25833. mixin(lodash, lodash);
  25834. /*------------------------------------------------------------------------*/
  25835. // Add methods that return unwrapped values in chain sequences.
  25836. lodash.add = add;
  25837. lodash.attempt = attempt;
  25838. lodash.camelCase = camelCase;
  25839. lodash.capitalize = capitalize;
  25840. lodash.ceil = ceil;
  25841. lodash.clamp = clamp;
  25842. lodash.clone = clone;
  25843. lodash.cloneDeep = cloneDeep;
  25844. lodash.cloneDeepWith = cloneDeepWith;
  25845. lodash.cloneWith = cloneWith;
  25846. lodash.conformsTo = conformsTo;
  25847. lodash.deburr = deburr;
  25848. lodash.defaultTo = defaultTo;
  25849. lodash.divide = divide;
  25850. lodash.endsWith = endsWith;
  25851. lodash.eq = eq;
  25852. lodash.escape = escape;
  25853. lodash.escapeRegExp = escapeRegExp;
  25854. lodash.every = every;
  25855. lodash.find = find;
  25856. lodash.findIndex = findIndex;
  25857. lodash.findKey = findKey;
  25858. lodash.findLast = findLast;
  25859. lodash.findLastIndex = findLastIndex;
  25860. lodash.findLastKey = findLastKey;
  25861. lodash.floor = floor;
  25862. lodash.forEach = forEach;
  25863. lodash.forEachRight = forEachRight;
  25864. lodash.forIn = forIn;
  25865. lodash.forInRight = forInRight;
  25866. lodash.forOwn = forOwn;
  25867. lodash.forOwnRight = forOwnRight;
  25868. lodash.get = get;
  25869. lodash.gt = gt;
  25870. lodash.gte = gte;
  25871. lodash.has = has;
  25872. lodash.hasIn = hasIn;
  25873. lodash.head = head;
  25874. lodash.identity = identity;
  25875. lodash.includes = includes;
  25876. lodash.indexOf = indexOf;
  25877. lodash.inRange = inRange;
  25878. lodash.invoke = invoke;
  25879. lodash.isArguments = isArguments;
  25880. lodash.isArray = isArray;
  25881. lodash.isArrayBuffer = isArrayBuffer;
  25882. lodash.isArrayLike = isArrayLike;
  25883. lodash.isArrayLikeObject = isArrayLikeObject;
  25884. lodash.isBoolean = isBoolean;
  25885. lodash.isBuffer = isBuffer;
  25886. lodash.isDate = isDate;
  25887. lodash.isElement = isElement;
  25888. lodash.isEmpty = isEmpty;
  25889. lodash.isEqual = isEqual;
  25890. lodash.isEqualWith = isEqualWith;
  25891. lodash.isError = isError;
  25892. lodash.isFinite = isFinite;
  25893. lodash.isFunction = isFunction;
  25894. lodash.isInteger = isInteger;
  25895. lodash.isLength = isLength;
  25896. lodash.isMap = isMap;
  25897. lodash.isMatch = isMatch;
  25898. lodash.isMatchWith = isMatchWith;
  25899. lodash.isNaN = isNaN;
  25900. lodash.isNative = isNative;
  25901. lodash.isNil = isNil;
  25902. lodash.isNull = isNull;
  25903. lodash.isNumber = isNumber;
  25904. lodash.isObject = isObject;
  25905. lodash.isObjectLike = isObjectLike;
  25906. lodash.isPlainObject = isPlainObject;
  25907. lodash.isRegExp = isRegExp;
  25908. lodash.isSafeInteger = isSafeInteger;
  25909. lodash.isSet = isSet;
  25910. lodash.isString = isString;
  25911. lodash.isSymbol = isSymbol;
  25912. lodash.isTypedArray = isTypedArray;
  25913. lodash.isUndefined = isUndefined;
  25914. lodash.isWeakMap = isWeakMap;
  25915. lodash.isWeakSet = isWeakSet;
  25916. lodash.join = join;
  25917. lodash.kebabCase = kebabCase;
  25918. lodash.last = last;
  25919. lodash.lastIndexOf = lastIndexOf;
  25920. lodash.lowerCase = lowerCase;
  25921. lodash.lowerFirst = lowerFirst;
  25922. lodash.lt = lt;
  25923. lodash.lte = lte;
  25924. lodash.max = max;
  25925. lodash.maxBy = maxBy;
  25926. lodash.mean = mean;
  25927. lodash.meanBy = meanBy;
  25928. lodash.min = min;
  25929. lodash.minBy = minBy;
  25930. lodash.stubArray = stubArray;
  25931. lodash.stubFalse = stubFalse;
  25932. lodash.stubObject = stubObject;
  25933. lodash.stubString = stubString;
  25934. lodash.stubTrue = stubTrue;
  25935. lodash.multiply = multiply;
  25936. lodash.nth = nth;
  25937. lodash.noConflict = noConflict;
  25938. lodash.noop = noop;
  25939. lodash.now = now;
  25940. lodash.pad = pad;
  25941. lodash.padEnd = padEnd;
  25942. lodash.padStart = padStart;
  25943. lodash.parseInt = parseInt;
  25944. lodash.random = random;
  25945. lodash.reduce = reduce;
  25946. lodash.reduceRight = reduceRight;
  25947. lodash.repeat = repeat;
  25948. lodash.replace = replace;
  25949. lodash.result = result;
  25950. lodash.round = round;
  25951. lodash.runInContext = runInContext;
  25952. lodash.sample = sample;
  25953. lodash.size = size;
  25954. lodash.snakeCase = snakeCase;
  25955. lodash.some = some;
  25956. lodash.sortedIndex = sortedIndex;
  25957. lodash.sortedIndexBy = sortedIndexBy;
  25958. lodash.sortedIndexOf = sortedIndexOf;
  25959. lodash.sortedLastIndex = sortedLastIndex;
  25960. lodash.sortedLastIndexBy = sortedLastIndexBy;
  25961. lodash.sortedLastIndexOf = sortedLastIndexOf;
  25962. lodash.startCase = startCase;
  25963. lodash.startsWith = startsWith;
  25964. lodash.subtract = subtract;
  25965. lodash.sum = sum;
  25966. lodash.sumBy = sumBy;
  25967. lodash.template = template;
  25968. lodash.times = times;
  25969. lodash.toFinite = toFinite;
  25970. lodash.toInteger = toInteger;
  25971. lodash.toLength = toLength;
  25972. lodash.toLower = toLower;
  25973. lodash.toNumber = toNumber;
  25974. lodash.toSafeInteger = toSafeInteger;
  25975. lodash.toString = toString;
  25976. lodash.toUpper = toUpper;
  25977. lodash.trim = trim;
  25978. lodash.trimEnd = trimEnd;
  25979. lodash.trimStart = trimStart;
  25980. lodash.truncate = truncate;
  25981. lodash.unescape = unescape;
  25982. lodash.uniqueId = uniqueId;
  25983. lodash.upperCase = upperCase;
  25984. lodash.upperFirst = upperFirst;
  25985. // Add aliases.
  25986. lodash.each = forEach;
  25987. lodash.eachRight = forEachRight;
  25988. lodash.first = head;
  25989. mixin(lodash, (function() {
  25990. var source = {};
  25991. baseForOwn(lodash, function(func, methodName) {
  25992. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  25993. source[methodName] = func;
  25994. }
  25995. });
  25996. return source;
  25997. }()), { 'chain': false });
  25998. /*------------------------------------------------------------------------*/
  25999. /**
  26000. * The semantic version number.
  26001. *
  26002. * @static
  26003. * @memberOf _
  26004. * @type {string}
  26005. */
  26006. lodash.VERSION = VERSION;
  26007. // Assign default placeholders.
  26008. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  26009. lodash[methodName].placeholder = lodash;
  26010. });
  26011. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  26012. arrayEach(['drop', 'take'], function(methodName, index) {
  26013. LazyWrapper.prototype[methodName] = function(n) {
  26014. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  26015. var result = (this.__filtered__ && !index)
  26016. ? new LazyWrapper(this)
  26017. : this.clone();
  26018. if (result.__filtered__) {
  26019. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  26020. } else {
  26021. result.__views__.push({
  26022. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  26023. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  26024. });
  26025. }
  26026. return result;
  26027. };
  26028. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  26029. return this.reverse()[methodName](n).reverse();
  26030. };
  26031. });
  26032. // Add `LazyWrapper` methods that accept an `iteratee` value.
  26033. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  26034. var type = index + 1,
  26035. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  26036. LazyWrapper.prototype[methodName] = function(iteratee) {
  26037. var result = this.clone();
  26038. result.__iteratees__.push({
  26039. 'iteratee': getIteratee(iteratee, 3),
  26040. 'type': type
  26041. });
  26042. result.__filtered__ = result.__filtered__ || isFilter;
  26043. return result;
  26044. };
  26045. });
  26046. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  26047. arrayEach(['head', 'last'], function(methodName, index) {
  26048. var takeName = 'take' + (index ? 'Right' : '');
  26049. LazyWrapper.prototype[methodName] = function() {
  26050. return this[takeName](1).value()[0];
  26051. };
  26052. });
  26053. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  26054. arrayEach(['initial', 'tail'], function(methodName, index) {
  26055. var dropName = 'drop' + (index ? '' : 'Right');
  26056. LazyWrapper.prototype[methodName] = function() {
  26057. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  26058. };
  26059. });
  26060. LazyWrapper.prototype.compact = function() {
  26061. return this.filter(identity);
  26062. };
  26063. LazyWrapper.prototype.find = function(predicate) {
  26064. return this.filter(predicate).head();
  26065. };
  26066. LazyWrapper.prototype.findLast = function(predicate) {
  26067. return this.reverse().find(predicate);
  26068. };
  26069. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  26070. if (typeof path == 'function') {
  26071. return new LazyWrapper(this);
  26072. }
  26073. return this.map(function(value) {
  26074. return baseInvoke(value, path, args);
  26075. });
  26076. });
  26077. LazyWrapper.prototype.reject = function(predicate) {
  26078. return this.filter(negate(getIteratee(predicate)));
  26079. };
  26080. LazyWrapper.prototype.slice = function(start, end) {
  26081. start = toInteger(start);
  26082. var result = this;
  26083. if (result.__filtered__ && (start > 0 || end < 0)) {
  26084. return new LazyWrapper(result);
  26085. }
  26086. if (start < 0) {
  26087. result = result.takeRight(-start);
  26088. } else if (start) {
  26089. result = result.drop(start);
  26090. }
  26091. if (end !== undefined) {
  26092. end = toInteger(end);
  26093. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  26094. }
  26095. return result;
  26096. };
  26097. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  26098. return this.reverse().takeWhile(predicate).reverse();
  26099. };
  26100. LazyWrapper.prototype.toArray = function() {
  26101. return this.take(MAX_ARRAY_LENGTH);
  26102. };
  26103. // Add `LazyWrapper` methods to `lodash.prototype`.
  26104. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  26105. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  26106. isTaker = /^(?:head|last)$/.test(methodName),
  26107. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  26108. retUnwrapped = isTaker || /^find/.test(methodName);
  26109. if (!lodashFunc) {
  26110. return;
  26111. }
  26112. lodash.prototype[methodName] = function() {
  26113. var value = this.__wrapped__,
  26114. args = isTaker ? [1] : arguments,
  26115. isLazy = value instanceof LazyWrapper,
  26116. iteratee = args[0],
  26117. useLazy = isLazy || isArray(value);
  26118. var interceptor = function(value) {
  26119. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  26120. return (isTaker && chainAll) ? result[0] : result;
  26121. };
  26122. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  26123. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  26124. isLazy = useLazy = false;
  26125. }
  26126. var chainAll = this.__chain__,
  26127. isHybrid = !!this.__actions__.length,
  26128. isUnwrapped = retUnwrapped && !chainAll,
  26129. onlyLazy = isLazy && !isHybrid;
  26130. if (!retUnwrapped && useLazy) {
  26131. value = onlyLazy ? value : new LazyWrapper(this);
  26132. var result = func.apply(value, args);
  26133. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  26134. return new LodashWrapper(result, chainAll);
  26135. }
  26136. if (isUnwrapped && onlyLazy) {
  26137. return func.apply(this, args);
  26138. }
  26139. result = this.thru(interceptor);
  26140. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  26141. };
  26142. });
  26143. // Add `Array` methods to `lodash.prototype`.
  26144. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  26145. var func = arrayProto[methodName],
  26146. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  26147. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  26148. lodash.prototype[methodName] = function() {
  26149. var args = arguments;
  26150. if (retUnwrapped && !this.__chain__) {
  26151. var value = this.value();
  26152. return func.apply(isArray(value) ? value : [], args);
  26153. }
  26154. return this[chainName](function(value) {
  26155. return func.apply(isArray(value) ? value : [], args);
  26156. });
  26157. };
  26158. });
  26159. // Map minified method names to their real names.
  26160. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  26161. var lodashFunc = lodash[methodName];
  26162. if (lodashFunc) {
  26163. var key = lodashFunc.name + '';
  26164. if (!hasOwnProperty.call(realNames, key)) {
  26165. realNames[key] = [];
  26166. }
  26167. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  26168. }
  26169. });
  26170. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  26171. 'name': 'wrapper',
  26172. 'func': undefined
  26173. }];
  26174. // Add methods to `LazyWrapper`.
  26175. LazyWrapper.prototype.clone = lazyClone;
  26176. LazyWrapper.prototype.reverse = lazyReverse;
  26177. LazyWrapper.prototype.value = lazyValue;
  26178. // Add chain sequence methods to the `lodash` wrapper.
  26179. lodash.prototype.at = wrapperAt;
  26180. lodash.prototype.chain = wrapperChain;
  26181. lodash.prototype.commit = wrapperCommit;
  26182. lodash.prototype.next = wrapperNext;
  26183. lodash.prototype.plant = wrapperPlant;
  26184. lodash.prototype.reverse = wrapperReverse;
  26185. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  26186. // Add lazy aliases.
  26187. lodash.prototype.first = lodash.prototype.head;
  26188. if (symIterator) {
  26189. lodash.prototype[symIterator] = wrapperToIterator;
  26190. }
  26191. return lodash;
  26192. });
  26193. /*--------------------------------------------------------------------------*/
  26194. // Export lodash.
  26195. var _ = runInContext();
  26196. // Some AMD build optimizers, like r.js, check for condition patterns like:
  26197. if (true) {
  26198. // Expose Lodash on the global object to prevent errors when Lodash is
  26199. // loaded by a script tag in the presence of an AMD loader.
  26200. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  26201. // Use `_.noConflict` to remove Lodash from the global object.
  26202. root._ = _;
  26203. // Define as an anonymous module so, through path mapping, it can be
  26204. // referenced as the "underscore" module.
  26205. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  26206. return _;
  26207. }).call(exports, __webpack_require__, exports, module),
  26208. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  26209. }
  26210. // Check for `exports` after `define` in case a build optimizer adds it.
  26211. else {}
  26212. }.call(this));
  26213. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"), __webpack_require__(/*! ./../webpack/buildin/module.js */ "./node_modules/webpack/buildin/module.js")(module)))
  26214. /***/ }),
  26215. /***/ "./node_modules/popper.js/dist/esm/popper.js":
  26216. /*!***************************************************!*\
  26217. !*** ./node_modules/popper.js/dist/esm/popper.js ***!
  26218. \***************************************************/
  26219. /*! exports provided: default */
  26220. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26221. "use strict";
  26222. __webpack_require__.r(__webpack_exports__);
  26223. /* WEBPACK VAR INJECTION */(function(global) {/**!
  26224. * @fileOverview Kickass library to create and place poppers near their reference elements.
  26225. * @version 1.16.0
  26226. * @license
  26227. * Copyright (c) 2016 Federico Zivolo and contributors
  26228. *
  26229. * Permission is hereby granted, free of charge, to any person obtaining a copy
  26230. * of this software and associated documentation files (the "Software"), to deal
  26231. * in the Software without restriction, including without limitation the rights
  26232. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  26233. * copies of the Software, and to permit persons to whom the Software is
  26234. * furnished to do so, subject to the following conditions:
  26235. *
  26236. * The above copyright notice and this permission notice shall be included in all
  26237. * copies or substantial portions of the Software.
  26238. *
  26239. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  26240. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  26241. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  26242. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  26243. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  26244. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  26245. * SOFTWARE.
  26246. */
  26247. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
  26248. var timeoutDuration = function () {
  26249. var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
  26250. for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
  26251. if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
  26252. return 1;
  26253. }
  26254. }
  26255. return 0;
  26256. }();
  26257. function microtaskDebounce(fn) {
  26258. var called = false;
  26259. return function () {
  26260. if (called) {
  26261. return;
  26262. }
  26263. called = true;
  26264. window.Promise.resolve().then(function () {
  26265. called = false;
  26266. fn();
  26267. });
  26268. };
  26269. }
  26270. function taskDebounce(fn) {
  26271. var scheduled = false;
  26272. return function () {
  26273. if (!scheduled) {
  26274. scheduled = true;
  26275. setTimeout(function () {
  26276. scheduled = false;
  26277. fn();
  26278. }, timeoutDuration);
  26279. }
  26280. };
  26281. }
  26282. var supportsMicroTasks = isBrowser && window.Promise;
  26283. /**
  26284. * Create a debounced version of a method, that's asynchronously deferred
  26285. * but called in the minimum time possible.
  26286. *
  26287. * @method
  26288. * @memberof Popper.Utils
  26289. * @argument {Function} fn
  26290. * @returns {Function}
  26291. */
  26292. var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
  26293. /**
  26294. * Check if the given variable is a function
  26295. * @method
  26296. * @memberof Popper.Utils
  26297. * @argument {Any} functionToCheck - variable to check
  26298. * @returns {Boolean} answer to: is a function?
  26299. */
  26300. function isFunction(functionToCheck) {
  26301. var getType = {};
  26302. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  26303. }
  26304. /**
  26305. * Get CSS computed property of the given element
  26306. * @method
  26307. * @memberof Popper.Utils
  26308. * @argument {Eement} element
  26309. * @argument {String} property
  26310. */
  26311. function getStyleComputedProperty(element, property) {
  26312. if (element.nodeType !== 1) {
  26313. return [];
  26314. }
  26315. // NOTE: 1 DOM access here
  26316. var window = element.ownerDocument.defaultView;
  26317. var css = window.getComputedStyle(element, null);
  26318. return property ? css[property] : css;
  26319. }
  26320. /**
  26321. * Returns the parentNode or the host of the element
  26322. * @method
  26323. * @memberof Popper.Utils
  26324. * @argument {Element} element
  26325. * @returns {Element} parent
  26326. */
  26327. function getParentNode(element) {
  26328. if (element.nodeName === 'HTML') {
  26329. return element;
  26330. }
  26331. return element.parentNode || element.host;
  26332. }
  26333. /**
  26334. * Returns the scrolling parent of the given element
  26335. * @method
  26336. * @memberof Popper.Utils
  26337. * @argument {Element} element
  26338. * @returns {Element} scroll parent
  26339. */
  26340. function getScrollParent(element) {
  26341. // Return body, `getScroll` will take care to get the correct `scrollTop` from it
  26342. if (!element) {
  26343. return document.body;
  26344. }
  26345. switch (element.nodeName) {
  26346. case 'HTML':
  26347. case 'BODY':
  26348. return element.ownerDocument.body;
  26349. case '#document':
  26350. return element.body;
  26351. }
  26352. // Firefox want us to check `-x` and `-y` variations as well
  26353. var _getStyleComputedProp = getStyleComputedProperty(element),
  26354. overflow = _getStyleComputedProp.overflow,
  26355. overflowX = _getStyleComputedProp.overflowX,
  26356. overflowY = _getStyleComputedProp.overflowY;
  26357. if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
  26358. return element;
  26359. }
  26360. return getScrollParent(getParentNode(element));
  26361. }
  26362. /**
  26363. * Returns the reference node of the reference object, or the reference object itself.
  26364. * @method
  26365. * @memberof Popper.Utils
  26366. * @param {Element|Object} reference - the reference element (the popper will be relative to this)
  26367. * @returns {Element} parent
  26368. */
  26369. function getReferenceNode(reference) {
  26370. return reference && reference.referenceNode ? reference.referenceNode : reference;
  26371. }
  26372. var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
  26373. var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
  26374. /**
  26375. * Determines if the browser is Internet Explorer
  26376. * @method
  26377. * @memberof Popper.Utils
  26378. * @param {Number} version to check
  26379. * @returns {Boolean} isIE
  26380. */
  26381. function isIE(version) {
  26382. if (version === 11) {
  26383. return isIE11;
  26384. }
  26385. if (version === 10) {
  26386. return isIE10;
  26387. }
  26388. return isIE11 || isIE10;
  26389. }
  26390. /**
  26391. * Returns the offset parent of the given element
  26392. * @method
  26393. * @memberof Popper.Utils
  26394. * @argument {Element} element
  26395. * @returns {Element} offset parent
  26396. */
  26397. function getOffsetParent(element) {
  26398. if (!element) {
  26399. return document.documentElement;
  26400. }
  26401. var noOffsetParent = isIE(10) ? document.body : null;
  26402. // NOTE: 1 DOM access here
  26403. var offsetParent = element.offsetParent || null;
  26404. // Skip hidden elements which don't have an offsetParent
  26405. while (offsetParent === noOffsetParent && element.nextElementSibling) {
  26406. offsetParent = (element = element.nextElementSibling).offsetParent;
  26407. }
  26408. var nodeName = offsetParent && offsetParent.nodeName;
  26409. if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
  26410. return element ? element.ownerDocument.documentElement : document.documentElement;
  26411. }
  26412. // .offsetParent will return the closest TH, TD or TABLE in case
  26413. // no offsetParent is present, I hate this job...
  26414. if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
  26415. return getOffsetParent(offsetParent);
  26416. }
  26417. return offsetParent;
  26418. }
  26419. function isOffsetContainer(element) {
  26420. var nodeName = element.nodeName;
  26421. if (nodeName === 'BODY') {
  26422. return false;
  26423. }
  26424. return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
  26425. }
  26426. /**
  26427. * Finds the root node (document, shadowDOM root) of the given element
  26428. * @method
  26429. * @memberof Popper.Utils
  26430. * @argument {Element} node
  26431. * @returns {Element} root node
  26432. */
  26433. function getRoot(node) {
  26434. if (node.parentNode !== null) {
  26435. return getRoot(node.parentNode);
  26436. }
  26437. return node;
  26438. }
  26439. /**
  26440. * Finds the offset parent common to the two provided nodes
  26441. * @method
  26442. * @memberof Popper.Utils
  26443. * @argument {Element} element1
  26444. * @argument {Element} element2
  26445. * @returns {Element} common offset parent
  26446. */
  26447. function findCommonOffsetParent(element1, element2) {
  26448. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  26449. if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
  26450. return document.documentElement;
  26451. }
  26452. // Here we make sure to give as "start" the element that comes first in the DOM
  26453. var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
  26454. var start = order ? element1 : element2;
  26455. var end = order ? element2 : element1;
  26456. // Get common ancestor container
  26457. var range = document.createRange();
  26458. range.setStart(start, 0);
  26459. range.setEnd(end, 0);
  26460. var commonAncestorContainer = range.commonAncestorContainer;
  26461. // Both nodes are inside #document
  26462. if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
  26463. if (isOffsetContainer(commonAncestorContainer)) {
  26464. return commonAncestorContainer;
  26465. }
  26466. return getOffsetParent(commonAncestorContainer);
  26467. }
  26468. // one of the nodes is inside shadowDOM, find which one
  26469. var element1root = getRoot(element1);
  26470. if (element1root.host) {
  26471. return findCommonOffsetParent(element1root.host, element2);
  26472. } else {
  26473. return findCommonOffsetParent(element1, getRoot(element2).host);
  26474. }
  26475. }
  26476. /**
  26477. * Gets the scroll value of the given element in the given side (top and left)
  26478. * @method
  26479. * @memberof Popper.Utils
  26480. * @argument {Element} element
  26481. * @argument {String} side `top` or `left`
  26482. * @returns {number} amount of scrolled pixels
  26483. */
  26484. function getScroll(element) {
  26485. var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
  26486. var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
  26487. var nodeName = element.nodeName;
  26488. if (nodeName === 'BODY' || nodeName === 'HTML') {
  26489. var html = element.ownerDocument.documentElement;
  26490. var scrollingElement = element.ownerDocument.scrollingElement || html;
  26491. return scrollingElement[upperSide];
  26492. }
  26493. return element[upperSide];
  26494. }
  26495. /*
  26496. * Sum or subtract the element scroll values (left and top) from a given rect object
  26497. * @method
  26498. * @memberof Popper.Utils
  26499. * @param {Object} rect - Rect object you want to change
  26500. * @param {HTMLElement} element - The element from the function reads the scroll values
  26501. * @param {Boolean} subtract - set to true if you want to subtract the scroll values
  26502. * @return {Object} rect - The modifier rect object
  26503. */
  26504. function includeScroll(rect, element) {
  26505. var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  26506. var scrollTop = getScroll(element, 'top');
  26507. var scrollLeft = getScroll(element, 'left');
  26508. var modifier = subtract ? -1 : 1;
  26509. rect.top += scrollTop * modifier;
  26510. rect.bottom += scrollTop * modifier;
  26511. rect.left += scrollLeft * modifier;
  26512. rect.right += scrollLeft * modifier;
  26513. return rect;
  26514. }
  26515. /*
  26516. * Helper to detect borders of a given element
  26517. * @method
  26518. * @memberof Popper.Utils
  26519. * @param {CSSStyleDeclaration} styles
  26520. * Result of `getStyleComputedProperty` on the given element
  26521. * @param {String} axis - `x` or `y`
  26522. * @return {number} borders - The borders size of the given axis
  26523. */
  26524. function getBordersSize(styles, axis) {
  26525. var sideA = axis === 'x' ? 'Left' : 'Top';
  26526. var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
  26527. return parseFloat(styles['border' + sideA + 'Width'], 10) + parseFloat(styles['border' + sideB + 'Width'], 10);
  26528. }
  26529. function getSize(axis, body, html, computedStyle) {
  26530. return Math.max(body['offset' + axis], body['scroll' + axis], html['client' + axis], html['offset' + axis], html['scroll' + axis], isIE(10) ? parseInt(html['offset' + axis]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Top' : 'Left')]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Bottom' : 'Right')]) : 0);
  26531. }
  26532. function getWindowSizes(document) {
  26533. var body = document.body;
  26534. var html = document.documentElement;
  26535. var computedStyle = isIE(10) && getComputedStyle(html);
  26536. return {
  26537. height: getSize('Height', body, html, computedStyle),
  26538. width: getSize('Width', body, html, computedStyle)
  26539. };
  26540. }
  26541. var classCallCheck = function (instance, Constructor) {
  26542. if (!(instance instanceof Constructor)) {
  26543. throw new TypeError("Cannot call a class as a function");
  26544. }
  26545. };
  26546. var createClass = function () {
  26547. function defineProperties(target, props) {
  26548. for (var i = 0; i < props.length; i++) {
  26549. var descriptor = props[i];
  26550. descriptor.enumerable = descriptor.enumerable || false;
  26551. descriptor.configurable = true;
  26552. if ("value" in descriptor) descriptor.writable = true;
  26553. Object.defineProperty(target, descriptor.key, descriptor);
  26554. }
  26555. }
  26556. return function (Constructor, protoProps, staticProps) {
  26557. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  26558. if (staticProps) defineProperties(Constructor, staticProps);
  26559. return Constructor;
  26560. };
  26561. }();
  26562. var defineProperty = function (obj, key, value) {
  26563. if (key in obj) {
  26564. Object.defineProperty(obj, key, {
  26565. value: value,
  26566. enumerable: true,
  26567. configurable: true,
  26568. writable: true
  26569. });
  26570. } else {
  26571. obj[key] = value;
  26572. }
  26573. return obj;
  26574. };
  26575. var _extends = Object.assign || function (target) {
  26576. for (var i = 1; i < arguments.length; i++) {
  26577. var source = arguments[i];
  26578. for (var key in source) {
  26579. if (Object.prototype.hasOwnProperty.call(source, key)) {
  26580. target[key] = source[key];
  26581. }
  26582. }
  26583. }
  26584. return target;
  26585. };
  26586. /**
  26587. * Given element offsets, generate an output similar to getBoundingClientRect
  26588. * @method
  26589. * @memberof Popper.Utils
  26590. * @argument {Object} offsets
  26591. * @returns {Object} ClientRect like output
  26592. */
  26593. function getClientRect(offsets) {
  26594. return _extends({}, offsets, {
  26595. right: offsets.left + offsets.width,
  26596. bottom: offsets.top + offsets.height
  26597. });
  26598. }
  26599. /**
  26600. * Get bounding client rect of given element
  26601. * @method
  26602. * @memberof Popper.Utils
  26603. * @param {HTMLElement} element
  26604. * @return {Object} client rect
  26605. */
  26606. function getBoundingClientRect(element) {
  26607. var rect = {};
  26608. // IE10 10 FIX: Please, don't ask, the element isn't
  26609. // considered in DOM in some circumstances...
  26610. // This isn't reproducible in IE10 compatibility mode of IE11
  26611. try {
  26612. if (isIE(10)) {
  26613. rect = element.getBoundingClientRect();
  26614. var scrollTop = getScroll(element, 'top');
  26615. var scrollLeft = getScroll(element, 'left');
  26616. rect.top += scrollTop;
  26617. rect.left += scrollLeft;
  26618. rect.bottom += scrollTop;
  26619. rect.right += scrollLeft;
  26620. } else {
  26621. rect = element.getBoundingClientRect();
  26622. }
  26623. } catch (e) {}
  26624. var result = {
  26625. left: rect.left,
  26626. top: rect.top,
  26627. width: rect.right - rect.left,
  26628. height: rect.bottom - rect.top
  26629. };
  26630. // subtract scrollbar size from sizes
  26631. var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
  26632. var width = sizes.width || element.clientWidth || result.width;
  26633. var height = sizes.height || element.clientHeight || result.height;
  26634. var horizScrollbar = element.offsetWidth - width;
  26635. var vertScrollbar = element.offsetHeight - height;
  26636. // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
  26637. // we make this check conditional for performance reasons
  26638. if (horizScrollbar || vertScrollbar) {
  26639. var styles = getStyleComputedProperty(element);
  26640. horizScrollbar -= getBordersSize(styles, 'x');
  26641. vertScrollbar -= getBordersSize(styles, 'y');
  26642. result.width -= horizScrollbar;
  26643. result.height -= vertScrollbar;
  26644. }
  26645. return getClientRect(result);
  26646. }
  26647. function getOffsetRectRelativeToArbitraryNode(children, parent) {
  26648. var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  26649. var isIE10 = isIE(10);
  26650. var isHTML = parent.nodeName === 'HTML';
  26651. var childrenRect = getBoundingClientRect(children);
  26652. var parentRect = getBoundingClientRect(parent);
  26653. var scrollParent = getScrollParent(children);
  26654. var styles = getStyleComputedProperty(parent);
  26655. var borderTopWidth = parseFloat(styles.borderTopWidth, 10);
  26656. var borderLeftWidth = parseFloat(styles.borderLeftWidth, 10);
  26657. // In cases where the parent is fixed, we must ignore negative scroll in offset calc
  26658. if (fixedPosition && isHTML) {
  26659. parentRect.top = Math.max(parentRect.top, 0);
  26660. parentRect.left = Math.max(parentRect.left, 0);
  26661. }
  26662. var offsets = getClientRect({
  26663. top: childrenRect.top - parentRect.top - borderTopWidth,
  26664. left: childrenRect.left - parentRect.left - borderLeftWidth,
  26665. width: childrenRect.width,
  26666. height: childrenRect.height
  26667. });
  26668. offsets.marginTop = 0;
  26669. offsets.marginLeft = 0;
  26670. // Subtract margins of documentElement in case it's being used as parent
  26671. // we do this only on HTML because it's the only element that behaves
  26672. // differently when margins are applied to it. The margins are included in
  26673. // the box of the documentElement, in the other cases not.
  26674. if (!isIE10 && isHTML) {
  26675. var marginTop = parseFloat(styles.marginTop, 10);
  26676. var marginLeft = parseFloat(styles.marginLeft, 10);
  26677. offsets.top -= borderTopWidth - marginTop;
  26678. offsets.bottom -= borderTopWidth - marginTop;
  26679. offsets.left -= borderLeftWidth - marginLeft;
  26680. offsets.right -= borderLeftWidth - marginLeft;
  26681. // Attach marginTop and marginLeft because in some circumstances we may need them
  26682. offsets.marginTop = marginTop;
  26683. offsets.marginLeft = marginLeft;
  26684. }
  26685. if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
  26686. offsets = includeScroll(offsets, parent);
  26687. }
  26688. return offsets;
  26689. }
  26690. function getViewportOffsetRectRelativeToArtbitraryNode(element) {
  26691. var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  26692. var html = element.ownerDocument.documentElement;
  26693. var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
  26694. var width = Math.max(html.clientWidth, window.innerWidth || 0);
  26695. var height = Math.max(html.clientHeight, window.innerHeight || 0);
  26696. var scrollTop = !excludeScroll ? getScroll(html) : 0;
  26697. var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
  26698. var offset = {
  26699. top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
  26700. left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
  26701. width: width,
  26702. height: height
  26703. };
  26704. return getClientRect(offset);
  26705. }
  26706. /**
  26707. * Check if the given element is fixed or is inside a fixed parent
  26708. * @method
  26709. * @memberof Popper.Utils
  26710. * @argument {Element} element
  26711. * @argument {Element} customContainer
  26712. * @returns {Boolean} answer to "isFixed?"
  26713. */
  26714. function isFixed(element) {
  26715. var nodeName = element.nodeName;
  26716. if (nodeName === 'BODY' || nodeName === 'HTML') {
  26717. return false;
  26718. }
  26719. if (getStyleComputedProperty(element, 'position') === 'fixed') {
  26720. return true;
  26721. }
  26722. var parentNode = getParentNode(element);
  26723. if (!parentNode) {
  26724. return false;
  26725. }
  26726. return isFixed(parentNode);
  26727. }
  26728. /**
  26729. * Finds the first parent of an element that has a transformed property defined
  26730. * @method
  26731. * @memberof Popper.Utils
  26732. * @argument {Element} element
  26733. * @returns {Element} first transformed parent or documentElement
  26734. */
  26735. function getFixedPositionOffsetParent(element) {
  26736. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  26737. if (!element || !element.parentElement || isIE()) {
  26738. return document.documentElement;
  26739. }
  26740. var el = element.parentElement;
  26741. while (el && getStyleComputedProperty(el, 'transform') === 'none') {
  26742. el = el.parentElement;
  26743. }
  26744. return el || document.documentElement;
  26745. }
  26746. /**
  26747. * Computed the boundaries limits and return them
  26748. * @method
  26749. * @memberof Popper.Utils
  26750. * @param {HTMLElement} popper
  26751. * @param {HTMLElement} reference
  26752. * @param {number} padding
  26753. * @param {HTMLElement} boundariesElement - Element used to define the boundaries
  26754. * @param {Boolean} fixedPosition - Is in fixed position mode
  26755. * @returns {Object} Coordinates of the boundaries
  26756. */
  26757. function getBoundaries(popper, reference, padding, boundariesElement) {
  26758. var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  26759. // NOTE: 1 DOM access here
  26760. var boundaries = { top: 0, left: 0 };
  26761. var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  26762. // Handle viewport case
  26763. if (boundariesElement === 'viewport') {
  26764. boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
  26765. } else {
  26766. // Handle other cases based on DOM element used as boundaries
  26767. var boundariesNode = void 0;
  26768. if (boundariesElement === 'scrollParent') {
  26769. boundariesNode = getScrollParent(getParentNode(reference));
  26770. if (boundariesNode.nodeName === 'BODY') {
  26771. boundariesNode = popper.ownerDocument.documentElement;
  26772. }
  26773. } else if (boundariesElement === 'window') {
  26774. boundariesNode = popper.ownerDocument.documentElement;
  26775. } else {
  26776. boundariesNode = boundariesElement;
  26777. }
  26778. var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
  26779. // In case of HTML, we need a different computation
  26780. if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
  26781. var _getWindowSizes = getWindowSizes(popper.ownerDocument),
  26782. height = _getWindowSizes.height,
  26783. width = _getWindowSizes.width;
  26784. boundaries.top += offsets.top - offsets.marginTop;
  26785. boundaries.bottom = height + offsets.top;
  26786. boundaries.left += offsets.left - offsets.marginLeft;
  26787. boundaries.right = width + offsets.left;
  26788. } else {
  26789. // for all the other DOM elements, this one is good
  26790. boundaries = offsets;
  26791. }
  26792. }
  26793. // Add paddings
  26794. padding = padding || 0;
  26795. var isPaddingNumber = typeof padding === 'number';
  26796. boundaries.left += isPaddingNumber ? padding : padding.left || 0;
  26797. boundaries.top += isPaddingNumber ? padding : padding.top || 0;
  26798. boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
  26799. boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
  26800. return boundaries;
  26801. }
  26802. function getArea(_ref) {
  26803. var width = _ref.width,
  26804. height = _ref.height;
  26805. return width * height;
  26806. }
  26807. /**
  26808. * Utility used to transform the `auto` placement to the placement with more
  26809. * available space.
  26810. * @method
  26811. * @memberof Popper.Utils
  26812. * @argument {Object} data - The data object generated by update method
  26813. * @argument {Object} options - Modifiers configuration and options
  26814. * @returns {Object} The data object, properly modified
  26815. */
  26816. function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
  26817. var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  26818. if (placement.indexOf('auto') === -1) {
  26819. return placement;
  26820. }
  26821. var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
  26822. var rects = {
  26823. top: {
  26824. width: boundaries.width,
  26825. height: refRect.top - boundaries.top
  26826. },
  26827. right: {
  26828. width: boundaries.right - refRect.right,
  26829. height: boundaries.height
  26830. },
  26831. bottom: {
  26832. width: boundaries.width,
  26833. height: boundaries.bottom - refRect.bottom
  26834. },
  26835. left: {
  26836. width: refRect.left - boundaries.left,
  26837. height: boundaries.height
  26838. }
  26839. };
  26840. var sortedAreas = Object.keys(rects).map(function (key) {
  26841. return _extends({
  26842. key: key
  26843. }, rects[key], {
  26844. area: getArea(rects[key])
  26845. });
  26846. }).sort(function (a, b) {
  26847. return b.area - a.area;
  26848. });
  26849. var filteredAreas = sortedAreas.filter(function (_ref2) {
  26850. var width = _ref2.width,
  26851. height = _ref2.height;
  26852. return width >= popper.clientWidth && height >= popper.clientHeight;
  26853. });
  26854. var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
  26855. var variation = placement.split('-')[1];
  26856. return computedPlacement + (variation ? '-' + variation : '');
  26857. }
  26858. /**
  26859. * Get offsets to the reference element
  26860. * @method
  26861. * @memberof Popper.Utils
  26862. * @param {Object} state
  26863. * @param {Element} popper - the popper element
  26864. * @param {Element} reference - the reference element (the popper will be relative to this)
  26865. * @param {Element} fixedPosition - is in fixed position mode
  26866. * @returns {Object} An object containing the offsets which will be applied to the popper
  26867. */
  26868. function getReferenceOffsets(state, popper, reference) {
  26869. var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  26870. var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  26871. return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
  26872. }
  26873. /**
  26874. * Get the outer sizes of the given element (offset size + margins)
  26875. * @method
  26876. * @memberof Popper.Utils
  26877. * @argument {Element} element
  26878. * @returns {Object} object containing width and height properties
  26879. */
  26880. function getOuterSizes(element) {
  26881. var window = element.ownerDocument.defaultView;
  26882. var styles = window.getComputedStyle(element);
  26883. var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
  26884. var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
  26885. var result = {
  26886. width: element.offsetWidth + y,
  26887. height: element.offsetHeight + x
  26888. };
  26889. return result;
  26890. }
  26891. /**
  26892. * Get the opposite placement of the given one
  26893. * @method
  26894. * @memberof Popper.Utils
  26895. * @argument {String} placement
  26896. * @returns {String} flipped placement
  26897. */
  26898. function getOppositePlacement(placement) {
  26899. var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
  26900. return placement.replace(/left|right|bottom|top/g, function (matched) {
  26901. return hash[matched];
  26902. });
  26903. }
  26904. /**
  26905. * Get offsets to the popper
  26906. * @method
  26907. * @memberof Popper.Utils
  26908. * @param {Object} position - CSS position the Popper will get applied
  26909. * @param {HTMLElement} popper - the popper element
  26910. * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
  26911. * @param {String} placement - one of the valid placement options
  26912. * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
  26913. */
  26914. function getPopperOffsets(popper, referenceOffsets, placement) {
  26915. placement = placement.split('-')[0];
  26916. // Get popper node sizes
  26917. var popperRect = getOuterSizes(popper);
  26918. // Add position, width and height to our offsets object
  26919. var popperOffsets = {
  26920. width: popperRect.width,
  26921. height: popperRect.height
  26922. };
  26923. // depending by the popper placement we have to compute its offsets slightly differently
  26924. var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
  26925. var mainSide = isHoriz ? 'top' : 'left';
  26926. var secondarySide = isHoriz ? 'left' : 'top';
  26927. var measurement = isHoriz ? 'height' : 'width';
  26928. var secondaryMeasurement = !isHoriz ? 'height' : 'width';
  26929. popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
  26930. if (placement === secondarySide) {
  26931. popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
  26932. } else {
  26933. popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
  26934. }
  26935. return popperOffsets;
  26936. }
  26937. /**
  26938. * Mimics the `find` method of Array
  26939. * @method
  26940. * @memberof Popper.Utils
  26941. * @argument {Array} arr
  26942. * @argument prop
  26943. * @argument value
  26944. * @returns index or -1
  26945. */
  26946. function find(arr, check) {
  26947. // use native find if supported
  26948. if (Array.prototype.find) {
  26949. return arr.find(check);
  26950. }
  26951. // use `filter` to obtain the same behavior of `find`
  26952. return arr.filter(check)[0];
  26953. }
  26954. /**
  26955. * Return the index of the matching object
  26956. * @method
  26957. * @memberof Popper.Utils
  26958. * @argument {Array} arr
  26959. * @argument prop
  26960. * @argument value
  26961. * @returns index or -1
  26962. */
  26963. function findIndex(arr, prop, value) {
  26964. // use native findIndex if supported
  26965. if (Array.prototype.findIndex) {
  26966. return arr.findIndex(function (cur) {
  26967. return cur[prop] === value;
  26968. });
  26969. }
  26970. // use `find` + `indexOf` if `findIndex` isn't supported
  26971. var match = find(arr, function (obj) {
  26972. return obj[prop] === value;
  26973. });
  26974. return arr.indexOf(match);
  26975. }
  26976. /**
  26977. * Loop trough the list of modifiers and run them in order,
  26978. * each of them will then edit the data object.
  26979. * @method
  26980. * @memberof Popper.Utils
  26981. * @param {dataObject} data
  26982. * @param {Array} modifiers
  26983. * @param {String} ends - Optional modifier name used as stopper
  26984. * @returns {dataObject}
  26985. */
  26986. function runModifiers(modifiers, data, ends) {
  26987. var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
  26988. modifiersToRun.forEach(function (modifier) {
  26989. if (modifier['function']) {
  26990. // eslint-disable-line dot-notation
  26991. console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
  26992. }
  26993. var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
  26994. if (modifier.enabled && isFunction(fn)) {
  26995. // Add properties to offsets to make them a complete clientRect object
  26996. // we do this before each modifier to make sure the previous one doesn't
  26997. // mess with these values
  26998. data.offsets.popper = getClientRect(data.offsets.popper);
  26999. data.offsets.reference = getClientRect(data.offsets.reference);
  27000. data = fn(data, modifier);
  27001. }
  27002. });
  27003. return data;
  27004. }
  27005. /**
  27006. * Updates the position of the popper, computing the new offsets and applying
  27007. * the new style.<br />
  27008. * Prefer `scheduleUpdate` over `update` because of performance reasons.
  27009. * @method
  27010. * @memberof Popper
  27011. */
  27012. function update() {
  27013. // if popper is destroyed, don't perform any further update
  27014. if (this.state.isDestroyed) {
  27015. return;
  27016. }
  27017. var data = {
  27018. instance: this,
  27019. styles: {},
  27020. arrowStyles: {},
  27021. attributes: {},
  27022. flipped: false,
  27023. offsets: {}
  27024. };
  27025. // compute reference element offsets
  27026. data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
  27027. // compute auto placement, store placement inside the data object,
  27028. // modifiers will be able to edit `placement` if needed
  27029. // and refer to originalPlacement to know the original value
  27030. data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
  27031. // store the computed placement inside `originalPlacement`
  27032. data.originalPlacement = data.placement;
  27033. data.positionFixed = this.options.positionFixed;
  27034. // compute the popper offsets
  27035. data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
  27036. data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
  27037. // run the modifiers
  27038. data = runModifiers(this.modifiers, data);
  27039. // the first `update` will call `onCreate` callback
  27040. // the other ones will call `onUpdate` callback
  27041. if (!this.state.isCreated) {
  27042. this.state.isCreated = true;
  27043. this.options.onCreate(data);
  27044. } else {
  27045. this.options.onUpdate(data);
  27046. }
  27047. }
  27048. /**
  27049. * Helper used to know if the given modifier is enabled.
  27050. * @method
  27051. * @memberof Popper.Utils
  27052. * @returns {Boolean}
  27053. */
  27054. function isModifierEnabled(modifiers, modifierName) {
  27055. return modifiers.some(function (_ref) {
  27056. var name = _ref.name,
  27057. enabled = _ref.enabled;
  27058. return enabled && name === modifierName;
  27059. });
  27060. }
  27061. /**
  27062. * Get the prefixed supported property name
  27063. * @method
  27064. * @memberof Popper.Utils
  27065. * @argument {String} property (camelCase)
  27066. * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
  27067. */
  27068. function getSupportedPropertyName(property) {
  27069. var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
  27070. var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
  27071. for (var i = 0; i < prefixes.length; i++) {
  27072. var prefix = prefixes[i];
  27073. var toCheck = prefix ? '' + prefix + upperProp : property;
  27074. if (typeof document.body.style[toCheck] !== 'undefined') {
  27075. return toCheck;
  27076. }
  27077. }
  27078. return null;
  27079. }
  27080. /**
  27081. * Destroys the popper.
  27082. * @method
  27083. * @memberof Popper
  27084. */
  27085. function destroy() {
  27086. this.state.isDestroyed = true;
  27087. // touch DOM only if `applyStyle` modifier is enabled
  27088. if (isModifierEnabled(this.modifiers, 'applyStyle')) {
  27089. this.popper.removeAttribute('x-placement');
  27090. this.popper.style.position = '';
  27091. this.popper.style.top = '';
  27092. this.popper.style.left = '';
  27093. this.popper.style.right = '';
  27094. this.popper.style.bottom = '';
  27095. this.popper.style.willChange = '';
  27096. this.popper.style[getSupportedPropertyName('transform')] = '';
  27097. }
  27098. this.disableEventListeners();
  27099. // remove the popper if user explicitly asked for the deletion on destroy
  27100. // do not use `remove` because IE11 doesn't support it
  27101. if (this.options.removeOnDestroy) {
  27102. this.popper.parentNode.removeChild(this.popper);
  27103. }
  27104. return this;
  27105. }
  27106. /**
  27107. * Get the window associated with the element
  27108. * @argument {Element} element
  27109. * @returns {Window}
  27110. */
  27111. function getWindow(element) {
  27112. var ownerDocument = element.ownerDocument;
  27113. return ownerDocument ? ownerDocument.defaultView : window;
  27114. }
  27115. function attachToScrollParents(scrollParent, event, callback, scrollParents) {
  27116. var isBody = scrollParent.nodeName === 'BODY';
  27117. var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
  27118. target.addEventListener(event, callback, { passive: true });
  27119. if (!isBody) {
  27120. attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
  27121. }
  27122. scrollParents.push(target);
  27123. }
  27124. /**
  27125. * Setup needed event listeners used to update the popper position
  27126. * @method
  27127. * @memberof Popper.Utils
  27128. * @private
  27129. */
  27130. function setupEventListeners(reference, options, state, updateBound) {
  27131. // Resize event listener on window
  27132. state.updateBound = updateBound;
  27133. getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
  27134. // Scroll event listener on scroll parents
  27135. var scrollElement = getScrollParent(reference);
  27136. attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
  27137. state.scrollElement = scrollElement;
  27138. state.eventsEnabled = true;
  27139. return state;
  27140. }
  27141. /**
  27142. * It will add resize/scroll events and start recalculating
  27143. * position of the popper element when they are triggered.
  27144. * @method
  27145. * @memberof Popper
  27146. */
  27147. function enableEventListeners() {
  27148. if (!this.state.eventsEnabled) {
  27149. this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
  27150. }
  27151. }
  27152. /**
  27153. * Remove event listeners used to update the popper position
  27154. * @method
  27155. * @memberof Popper.Utils
  27156. * @private
  27157. */
  27158. function removeEventListeners(reference, state) {
  27159. // Remove resize event listener on window
  27160. getWindow(reference).removeEventListener('resize', state.updateBound);
  27161. // Remove scroll event listener on scroll parents
  27162. state.scrollParents.forEach(function (target) {
  27163. target.removeEventListener('scroll', state.updateBound);
  27164. });
  27165. // Reset state
  27166. state.updateBound = null;
  27167. state.scrollParents = [];
  27168. state.scrollElement = null;
  27169. state.eventsEnabled = false;
  27170. return state;
  27171. }
  27172. /**
  27173. * It will remove resize/scroll events and won't recalculate popper position
  27174. * when they are triggered. It also won't trigger `onUpdate` callback anymore,
  27175. * unless you call `update` method manually.
  27176. * @method
  27177. * @memberof Popper
  27178. */
  27179. function disableEventListeners() {
  27180. if (this.state.eventsEnabled) {
  27181. cancelAnimationFrame(this.scheduleUpdate);
  27182. this.state = removeEventListeners(this.reference, this.state);
  27183. }
  27184. }
  27185. /**
  27186. * Tells if a given input is a number
  27187. * @method
  27188. * @memberof Popper.Utils
  27189. * @param {*} input to check
  27190. * @return {Boolean}
  27191. */
  27192. function isNumeric(n) {
  27193. return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
  27194. }
  27195. /**
  27196. * Set the style to the given popper
  27197. * @method
  27198. * @memberof Popper.Utils
  27199. * @argument {Element} element - Element to apply the style to
  27200. * @argument {Object} styles
  27201. * Object with a list of properties and values which will be applied to the element
  27202. */
  27203. function setStyles(element, styles) {
  27204. Object.keys(styles).forEach(function (prop) {
  27205. var unit = '';
  27206. // add unit if the value is numeric and is one of the following
  27207. if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
  27208. unit = 'px';
  27209. }
  27210. element.style[prop] = styles[prop] + unit;
  27211. });
  27212. }
  27213. /**
  27214. * Set the attributes to the given popper
  27215. * @method
  27216. * @memberof Popper.Utils
  27217. * @argument {Element} element - Element to apply the attributes to
  27218. * @argument {Object} styles
  27219. * Object with a list of properties and values which will be applied to the element
  27220. */
  27221. function setAttributes(element, attributes) {
  27222. Object.keys(attributes).forEach(function (prop) {
  27223. var value = attributes[prop];
  27224. if (value !== false) {
  27225. element.setAttribute(prop, attributes[prop]);
  27226. } else {
  27227. element.removeAttribute(prop);
  27228. }
  27229. });
  27230. }
  27231. /**
  27232. * @function
  27233. * @memberof Modifiers
  27234. * @argument {Object} data - The data object generated by `update` method
  27235. * @argument {Object} data.styles - List of style properties - values to apply to popper element
  27236. * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
  27237. * @argument {Object} options - Modifiers configuration and options
  27238. * @returns {Object} The same data object
  27239. */
  27240. function applyStyle(data) {
  27241. // any property present in `data.styles` will be applied to the popper,
  27242. // in this way we can make the 3rd party modifiers add custom styles to it
  27243. // Be aware, modifiers could override the properties defined in the previous
  27244. // lines of this modifier!
  27245. setStyles(data.instance.popper, data.styles);
  27246. // any property present in `data.attributes` will be applied to the popper,
  27247. // they will be set as HTML attributes of the element
  27248. setAttributes(data.instance.popper, data.attributes);
  27249. // if arrowElement is defined and arrowStyles has some properties
  27250. if (data.arrowElement && Object.keys(data.arrowStyles).length) {
  27251. setStyles(data.arrowElement, data.arrowStyles);
  27252. }
  27253. return data;
  27254. }
  27255. /**
  27256. * Set the x-placement attribute before everything else because it could be used
  27257. * to add margins to the popper margins needs to be calculated to get the
  27258. * correct popper offsets.
  27259. * @method
  27260. * @memberof Popper.modifiers
  27261. * @param {HTMLElement} reference - The reference element used to position the popper
  27262. * @param {HTMLElement} popper - The HTML element used as popper
  27263. * @param {Object} options - Popper.js options
  27264. */
  27265. function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
  27266. // compute reference element offsets
  27267. var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
  27268. // compute auto placement, store placement inside the data object,
  27269. // modifiers will be able to edit `placement` if needed
  27270. // and refer to originalPlacement to know the original value
  27271. var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
  27272. popper.setAttribute('x-placement', placement);
  27273. // Apply `position` to popper before anything else because
  27274. // without the position applied we can't guarantee correct computations
  27275. setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
  27276. return options;
  27277. }
  27278. /**
  27279. * @function
  27280. * @memberof Popper.Utils
  27281. * @argument {Object} data - The data object generated by `update` method
  27282. * @argument {Boolean} shouldRound - If the offsets should be rounded at all
  27283. * @returns {Object} The popper's position offsets rounded
  27284. *
  27285. * The tale of pixel-perfect positioning. It's still not 100% perfect, but as
  27286. * good as it can be within reason.
  27287. * Discussion here: https://github.com/FezVrasta/popper.js/pull/715
  27288. *
  27289. * Low DPI screens cause a popper to be blurry if not using full pixels (Safari
  27290. * as well on High DPI screens).
  27291. *
  27292. * Firefox prefers no rounding for positioning and does not have blurriness on
  27293. * high DPI screens.
  27294. *
  27295. * Only horizontal placement and left/right values need to be considered.
  27296. */
  27297. function getRoundedOffsets(data, shouldRound) {
  27298. var _data$offsets = data.offsets,
  27299. popper = _data$offsets.popper,
  27300. reference = _data$offsets.reference;
  27301. var round = Math.round,
  27302. floor = Math.floor;
  27303. var noRound = function noRound(v) {
  27304. return v;
  27305. };
  27306. var referenceWidth = round(reference.width);
  27307. var popperWidth = round(popper.width);
  27308. var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
  27309. var isVariation = data.placement.indexOf('-') !== -1;
  27310. var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
  27311. var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
  27312. var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
  27313. var verticalToInteger = !shouldRound ? noRound : round;
  27314. return {
  27315. left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
  27316. top: verticalToInteger(popper.top),
  27317. bottom: verticalToInteger(popper.bottom),
  27318. right: horizontalToInteger(popper.right)
  27319. };
  27320. }
  27321. var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
  27322. /**
  27323. * @function
  27324. * @memberof Modifiers
  27325. * @argument {Object} data - The data object generated by `update` method
  27326. * @argument {Object} options - Modifiers configuration and options
  27327. * @returns {Object} The data object, properly modified
  27328. */
  27329. function computeStyle(data, options) {
  27330. var x = options.x,
  27331. y = options.y;
  27332. var popper = data.offsets.popper;
  27333. // Remove this legacy support in Popper.js v2
  27334. var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
  27335. return modifier.name === 'applyStyle';
  27336. }).gpuAcceleration;
  27337. if (legacyGpuAccelerationOption !== undefined) {
  27338. console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
  27339. }
  27340. var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
  27341. var offsetParent = getOffsetParent(data.instance.popper);
  27342. var offsetParentRect = getBoundingClientRect(offsetParent);
  27343. // Styles
  27344. var styles = {
  27345. position: popper.position
  27346. };
  27347. var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
  27348. var sideA = x === 'bottom' ? 'top' : 'bottom';
  27349. var sideB = y === 'right' ? 'left' : 'right';
  27350. // if gpuAcceleration is set to `true` and transform is supported,
  27351. // we use `translate3d` to apply the position to the popper we
  27352. // automatically use the supported prefixed version if needed
  27353. var prefixedProperty = getSupportedPropertyName('transform');
  27354. // now, let's make a step back and look at this code closely (wtf?)
  27355. // If the content of the popper grows once it's been positioned, it
  27356. // may happen that the popper gets misplaced because of the new content
  27357. // overflowing its reference element
  27358. // To avoid this problem, we provide two options (x and y), which allow
  27359. // the consumer to define the offset origin.
  27360. // If we position a popper on top of a reference element, we can set
  27361. // `x` to `top` to make the popper grow towards its top instead of
  27362. // its bottom.
  27363. var left = void 0,
  27364. top = void 0;
  27365. if (sideA === 'bottom') {
  27366. // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
  27367. // and not the bottom of the html element
  27368. if (offsetParent.nodeName === 'HTML') {
  27369. top = -offsetParent.clientHeight + offsets.bottom;
  27370. } else {
  27371. top = -offsetParentRect.height + offsets.bottom;
  27372. }
  27373. } else {
  27374. top = offsets.top;
  27375. }
  27376. if (sideB === 'right') {
  27377. if (offsetParent.nodeName === 'HTML') {
  27378. left = -offsetParent.clientWidth + offsets.right;
  27379. } else {
  27380. left = -offsetParentRect.width + offsets.right;
  27381. }
  27382. } else {
  27383. left = offsets.left;
  27384. }
  27385. if (gpuAcceleration && prefixedProperty) {
  27386. styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
  27387. styles[sideA] = 0;
  27388. styles[sideB] = 0;
  27389. styles.willChange = 'transform';
  27390. } else {
  27391. // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
  27392. var invertTop = sideA === 'bottom' ? -1 : 1;
  27393. var invertLeft = sideB === 'right' ? -1 : 1;
  27394. styles[sideA] = top * invertTop;
  27395. styles[sideB] = left * invertLeft;
  27396. styles.willChange = sideA + ', ' + sideB;
  27397. }
  27398. // Attributes
  27399. var attributes = {
  27400. 'x-placement': data.placement
  27401. };
  27402. // Update `data` attributes, styles and arrowStyles
  27403. data.attributes = _extends({}, attributes, data.attributes);
  27404. data.styles = _extends({}, styles, data.styles);
  27405. data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);
  27406. return data;
  27407. }
  27408. /**
  27409. * Helper used to know if the given modifier depends from another one.<br />
  27410. * It checks if the needed modifier is listed and enabled.
  27411. * @method
  27412. * @memberof Popper.Utils
  27413. * @param {Array} modifiers - list of modifiers
  27414. * @param {String} requestingName - name of requesting modifier
  27415. * @param {String} requestedName - name of requested modifier
  27416. * @returns {Boolean}
  27417. */
  27418. function isModifierRequired(modifiers, requestingName, requestedName) {
  27419. var requesting = find(modifiers, function (_ref) {
  27420. var name = _ref.name;
  27421. return name === requestingName;
  27422. });
  27423. var isRequired = !!requesting && modifiers.some(function (modifier) {
  27424. return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
  27425. });
  27426. if (!isRequired) {
  27427. var _requesting = '`' + requestingName + '`';
  27428. var requested = '`' + requestedName + '`';
  27429. console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
  27430. }
  27431. return isRequired;
  27432. }
  27433. /**
  27434. * @function
  27435. * @memberof Modifiers
  27436. * @argument {Object} data - The data object generated by update method
  27437. * @argument {Object} options - Modifiers configuration and options
  27438. * @returns {Object} The data object, properly modified
  27439. */
  27440. function arrow(data, options) {
  27441. var _data$offsets$arrow;
  27442. // arrow depends on keepTogether in order to work
  27443. if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
  27444. return data;
  27445. }
  27446. var arrowElement = options.element;
  27447. // if arrowElement is a string, suppose it's a CSS selector
  27448. if (typeof arrowElement === 'string') {
  27449. arrowElement = data.instance.popper.querySelector(arrowElement);
  27450. // if arrowElement is not found, don't run the modifier
  27451. if (!arrowElement) {
  27452. return data;
  27453. }
  27454. } else {
  27455. // if the arrowElement isn't a query selector we must check that the
  27456. // provided DOM node is child of its popper node
  27457. if (!data.instance.popper.contains(arrowElement)) {
  27458. console.warn('WARNING: `arrow.element` must be child of its popper element!');
  27459. return data;
  27460. }
  27461. }
  27462. var placement = data.placement.split('-')[0];
  27463. var _data$offsets = data.offsets,
  27464. popper = _data$offsets.popper,
  27465. reference = _data$offsets.reference;
  27466. var isVertical = ['left', 'right'].indexOf(placement) !== -1;
  27467. var len = isVertical ? 'height' : 'width';
  27468. var sideCapitalized = isVertical ? 'Top' : 'Left';
  27469. var side = sideCapitalized.toLowerCase();
  27470. var altSide = isVertical ? 'left' : 'top';
  27471. var opSide = isVertical ? 'bottom' : 'right';
  27472. var arrowElementSize = getOuterSizes(arrowElement)[len];
  27473. //
  27474. // extends keepTogether behavior making sure the popper and its
  27475. // reference have enough pixels in conjunction
  27476. //
  27477. // top/left side
  27478. if (reference[opSide] - arrowElementSize < popper[side]) {
  27479. data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
  27480. }
  27481. // bottom/right side
  27482. if (reference[side] + arrowElementSize > popper[opSide]) {
  27483. data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
  27484. }
  27485. data.offsets.popper = getClientRect(data.offsets.popper);
  27486. // compute center of the popper
  27487. var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
  27488. // Compute the sideValue using the updated popper offsets
  27489. // take popper margin in account because we don't have this info available
  27490. var css = getStyleComputedProperty(data.instance.popper);
  27491. var popperMarginSide = parseFloat(css['margin' + sideCapitalized], 10);
  27492. var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width'], 10);
  27493. var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
  27494. // prevent arrowElement from being placed not contiguously to its popper
  27495. sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
  27496. data.arrowElement = arrowElement;
  27497. data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
  27498. return data;
  27499. }
  27500. /**
  27501. * Get the opposite placement variation of the given one
  27502. * @method
  27503. * @memberof Popper.Utils
  27504. * @argument {String} placement variation
  27505. * @returns {String} flipped placement variation
  27506. */
  27507. function getOppositeVariation(variation) {
  27508. if (variation === 'end') {
  27509. return 'start';
  27510. } else if (variation === 'start') {
  27511. return 'end';
  27512. }
  27513. return variation;
  27514. }
  27515. /**
  27516. * List of accepted placements to use as values of the `placement` option.<br />
  27517. * Valid placements are:
  27518. * - `auto`
  27519. * - `top`
  27520. * - `right`
  27521. * - `bottom`
  27522. * - `left`
  27523. *
  27524. * Each placement can have a variation from this list:
  27525. * - `-start`
  27526. * - `-end`
  27527. *
  27528. * Variations are interpreted easily if you think of them as the left to right
  27529. * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
  27530. * is right.<br />
  27531. * Vertically (`left` and `right`), `start` is top and `end` is bottom.
  27532. *
  27533. * Some valid examples are:
  27534. * - `top-end` (on top of reference, right aligned)
  27535. * - `right-start` (on right of reference, top aligned)
  27536. * - `bottom` (on bottom, centered)
  27537. * - `auto-end` (on the side with more space available, alignment depends by placement)
  27538. *
  27539. * @static
  27540. * @type {Array}
  27541. * @enum {String}
  27542. * @readonly
  27543. * @method placements
  27544. * @memberof Popper
  27545. */
  27546. var placements = ['auto-start', 'auto', 'auto-end', 'top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start'];
  27547. // Get rid of `auto` `auto-start` and `auto-end`
  27548. var validPlacements = placements.slice(3);
  27549. /**
  27550. * Given an initial placement, returns all the subsequent placements
  27551. * clockwise (or counter-clockwise).
  27552. *
  27553. * @method
  27554. * @memberof Popper.Utils
  27555. * @argument {String} placement - A valid placement (it accepts variations)
  27556. * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
  27557. * @returns {Array} placements including their variations
  27558. */
  27559. function clockwise(placement) {
  27560. var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  27561. var index = validPlacements.indexOf(placement);
  27562. var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
  27563. return counter ? arr.reverse() : arr;
  27564. }
  27565. var BEHAVIORS = {
  27566. FLIP: 'flip',
  27567. CLOCKWISE: 'clockwise',
  27568. COUNTERCLOCKWISE: 'counterclockwise'
  27569. };
  27570. /**
  27571. * @function
  27572. * @memberof Modifiers
  27573. * @argument {Object} data - The data object generated by update method
  27574. * @argument {Object} options - Modifiers configuration and options
  27575. * @returns {Object} The data object, properly modified
  27576. */
  27577. function flip(data, options) {
  27578. // if `inner` modifier is enabled, we can't use the `flip` modifier
  27579. if (isModifierEnabled(data.instance.modifiers, 'inner')) {
  27580. return data;
  27581. }
  27582. if (data.flipped && data.placement === data.originalPlacement) {
  27583. // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
  27584. return data;
  27585. }
  27586. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
  27587. var placement = data.placement.split('-')[0];
  27588. var placementOpposite = getOppositePlacement(placement);
  27589. var variation = data.placement.split('-')[1] || '';
  27590. var flipOrder = [];
  27591. switch (options.behavior) {
  27592. case BEHAVIORS.FLIP:
  27593. flipOrder = [placement, placementOpposite];
  27594. break;
  27595. case BEHAVIORS.CLOCKWISE:
  27596. flipOrder = clockwise(placement);
  27597. break;
  27598. case BEHAVIORS.COUNTERCLOCKWISE:
  27599. flipOrder = clockwise(placement, true);
  27600. break;
  27601. default:
  27602. flipOrder = options.behavior;
  27603. }
  27604. flipOrder.forEach(function (step, index) {
  27605. if (placement !== step || flipOrder.length === index + 1) {
  27606. return data;
  27607. }
  27608. placement = data.placement.split('-')[0];
  27609. placementOpposite = getOppositePlacement(placement);
  27610. var popperOffsets = data.offsets.popper;
  27611. var refOffsets = data.offsets.reference;
  27612. // using floor because the reference offsets may contain decimals we are not going to consider here
  27613. var floor = Math.floor;
  27614. var overlapsRef = placement === 'left' && floor(popperOffsets.right) > floor(refOffsets.left) || placement === 'right' && floor(popperOffsets.left) < floor(refOffsets.right) || placement === 'top' && floor(popperOffsets.bottom) > floor(refOffsets.top) || placement === 'bottom' && floor(popperOffsets.top) < floor(refOffsets.bottom);
  27615. var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
  27616. var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
  27617. var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
  27618. var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
  27619. var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
  27620. // flip the variation if required
  27621. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  27622. // flips variation if reference element overflows boundaries
  27623. var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
  27624. // flips variation if popper content overflows boundaries
  27625. var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
  27626. var flippedVariation = flippedVariationByRef || flippedVariationByContent;
  27627. if (overlapsRef || overflowsBoundaries || flippedVariation) {
  27628. // this boolean to detect any flip loop
  27629. data.flipped = true;
  27630. if (overlapsRef || overflowsBoundaries) {
  27631. placement = flipOrder[index + 1];
  27632. }
  27633. if (flippedVariation) {
  27634. variation = getOppositeVariation(variation);
  27635. }
  27636. data.placement = placement + (variation ? '-' + variation : '');
  27637. // this object contains `position`, we want to preserve it along with
  27638. // any additional property we may add in the future
  27639. data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
  27640. data = runModifiers(data.instance.modifiers, data, 'flip');
  27641. }
  27642. });
  27643. return data;
  27644. }
  27645. /**
  27646. * @function
  27647. * @memberof Modifiers
  27648. * @argument {Object} data - The data object generated by update method
  27649. * @argument {Object} options - Modifiers configuration and options
  27650. * @returns {Object} The data object, properly modified
  27651. */
  27652. function keepTogether(data) {
  27653. var _data$offsets = data.offsets,
  27654. popper = _data$offsets.popper,
  27655. reference = _data$offsets.reference;
  27656. var placement = data.placement.split('-')[0];
  27657. var floor = Math.floor;
  27658. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  27659. var side = isVertical ? 'right' : 'bottom';
  27660. var opSide = isVertical ? 'left' : 'top';
  27661. var measurement = isVertical ? 'width' : 'height';
  27662. if (popper[side] < floor(reference[opSide])) {
  27663. data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
  27664. }
  27665. if (popper[opSide] > floor(reference[side])) {
  27666. data.offsets.popper[opSide] = floor(reference[side]);
  27667. }
  27668. return data;
  27669. }
  27670. /**
  27671. * Converts a string containing value + unit into a px value number
  27672. * @function
  27673. * @memberof {modifiers~offset}
  27674. * @private
  27675. * @argument {String} str - Value + unit string
  27676. * @argument {String} measurement - `height` or `width`
  27677. * @argument {Object} popperOffsets
  27678. * @argument {Object} referenceOffsets
  27679. * @returns {Number|String}
  27680. * Value in pixels, or original string if no values were extracted
  27681. */
  27682. function toValue(str, measurement, popperOffsets, referenceOffsets) {
  27683. // separate value from unit
  27684. var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
  27685. var value = +split[1];
  27686. var unit = split[2];
  27687. // If it's not a number it's an operator, I guess
  27688. if (!value) {
  27689. return str;
  27690. }
  27691. if (unit.indexOf('%') === 0) {
  27692. var element = void 0;
  27693. switch (unit) {
  27694. case '%p':
  27695. element = popperOffsets;
  27696. break;
  27697. case '%':
  27698. case '%r':
  27699. default:
  27700. element = referenceOffsets;
  27701. }
  27702. var rect = getClientRect(element);
  27703. return rect[measurement] / 100 * value;
  27704. } else if (unit === 'vh' || unit === 'vw') {
  27705. // if is a vh or vw, we calculate the size based on the viewport
  27706. var size = void 0;
  27707. if (unit === 'vh') {
  27708. size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
  27709. } else {
  27710. size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
  27711. }
  27712. return size / 100 * value;
  27713. } else {
  27714. // if is an explicit pixel unit, we get rid of the unit and keep the value
  27715. // if is an implicit unit, it's px, and we return just the value
  27716. return value;
  27717. }
  27718. }
  27719. /**
  27720. * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
  27721. * @function
  27722. * @memberof {modifiers~offset}
  27723. * @private
  27724. * @argument {String} offset
  27725. * @argument {Object} popperOffsets
  27726. * @argument {Object} referenceOffsets
  27727. * @argument {String} basePlacement
  27728. * @returns {Array} a two cells array with x and y offsets in numbers
  27729. */
  27730. function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
  27731. var offsets = [0, 0];
  27732. // Use height if placement is left or right and index is 0 otherwise use width
  27733. // in this way the first offset will use an axis and the second one
  27734. // will use the other one
  27735. var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
  27736. // Split the offset string to obtain a list of values and operands
  27737. // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
  27738. var fragments = offset.split(/(\+|\-)/).map(function (frag) {
  27739. return frag.trim();
  27740. });
  27741. // Detect if the offset string contains a pair of values or a single one
  27742. // they could be separated by comma or space
  27743. var divider = fragments.indexOf(find(fragments, function (frag) {
  27744. return frag.search(/,|\s/) !== -1;
  27745. }));
  27746. if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
  27747. console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
  27748. }
  27749. // If divider is found, we divide the list of values and operands to divide
  27750. // them by ofset X and Y.
  27751. var splitRegex = /\s*,\s*|\s+/;
  27752. var ops = divider !== -1 ? [fragments.slice(0, divider).concat([fragments[divider].split(splitRegex)[0]]), [fragments[divider].split(splitRegex)[1]].concat(fragments.slice(divider + 1))] : [fragments];
  27753. // Convert the values with units to absolute pixels to allow our computations
  27754. ops = ops.map(function (op, index) {
  27755. // Most of the units rely on the orientation of the popper
  27756. var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
  27757. var mergeWithPrevious = false;
  27758. return op
  27759. // This aggregates any `+` or `-` sign that aren't considered operators
  27760. // e.g.: 10 + +5 => [10, +, +5]
  27761. .reduce(function (a, b) {
  27762. if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
  27763. a[a.length - 1] = b;
  27764. mergeWithPrevious = true;
  27765. return a;
  27766. } else if (mergeWithPrevious) {
  27767. a[a.length - 1] += b;
  27768. mergeWithPrevious = false;
  27769. return a;
  27770. } else {
  27771. return a.concat(b);
  27772. }
  27773. }, [])
  27774. // Here we convert the string values into number values (in px)
  27775. .map(function (str) {
  27776. return toValue(str, measurement, popperOffsets, referenceOffsets);
  27777. });
  27778. });
  27779. // Loop trough the offsets arrays and execute the operations
  27780. ops.forEach(function (op, index) {
  27781. op.forEach(function (frag, index2) {
  27782. if (isNumeric(frag)) {
  27783. offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
  27784. }
  27785. });
  27786. });
  27787. return offsets;
  27788. }
  27789. /**
  27790. * @function
  27791. * @memberof Modifiers
  27792. * @argument {Object} data - The data object generated by update method
  27793. * @argument {Object} options - Modifiers configuration and options
  27794. * @argument {Number|String} options.offset=0
  27795. * The offset value as described in the modifier description
  27796. * @returns {Object} The data object, properly modified
  27797. */
  27798. function offset(data, _ref) {
  27799. var offset = _ref.offset;
  27800. var placement = data.placement,
  27801. _data$offsets = data.offsets,
  27802. popper = _data$offsets.popper,
  27803. reference = _data$offsets.reference;
  27804. var basePlacement = placement.split('-')[0];
  27805. var offsets = void 0;
  27806. if (isNumeric(+offset)) {
  27807. offsets = [+offset, 0];
  27808. } else {
  27809. offsets = parseOffset(offset, popper, reference, basePlacement);
  27810. }
  27811. if (basePlacement === 'left') {
  27812. popper.top += offsets[0];
  27813. popper.left -= offsets[1];
  27814. } else if (basePlacement === 'right') {
  27815. popper.top += offsets[0];
  27816. popper.left += offsets[1];
  27817. } else if (basePlacement === 'top') {
  27818. popper.left += offsets[0];
  27819. popper.top -= offsets[1];
  27820. } else if (basePlacement === 'bottom') {
  27821. popper.left += offsets[0];
  27822. popper.top += offsets[1];
  27823. }
  27824. data.popper = popper;
  27825. return data;
  27826. }
  27827. /**
  27828. * @function
  27829. * @memberof Modifiers
  27830. * @argument {Object} data - The data object generated by `update` method
  27831. * @argument {Object} options - Modifiers configuration and options
  27832. * @returns {Object} The data object, properly modified
  27833. */
  27834. function preventOverflow(data, options) {
  27835. var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
  27836. // If offsetParent is the reference element, we really want to
  27837. // go one step up and use the next offsetParent as reference to
  27838. // avoid to make this modifier completely useless and look like broken
  27839. if (data.instance.reference === boundariesElement) {
  27840. boundariesElement = getOffsetParent(boundariesElement);
  27841. }
  27842. // NOTE: DOM access here
  27843. // resets the popper's position so that the document size can be calculated excluding
  27844. // the size of the popper element itself
  27845. var transformProp = getSupportedPropertyName('transform');
  27846. var popperStyles = data.instance.popper.style; // assignment to help minification
  27847. var top = popperStyles.top,
  27848. left = popperStyles.left,
  27849. transform = popperStyles[transformProp];
  27850. popperStyles.top = '';
  27851. popperStyles.left = '';
  27852. popperStyles[transformProp] = '';
  27853. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
  27854. // NOTE: DOM access here
  27855. // restores the original style properties after the offsets have been computed
  27856. popperStyles.top = top;
  27857. popperStyles.left = left;
  27858. popperStyles[transformProp] = transform;
  27859. options.boundaries = boundaries;
  27860. var order = options.priority;
  27861. var popper = data.offsets.popper;
  27862. var check = {
  27863. primary: function primary(placement) {
  27864. var value = popper[placement];
  27865. if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
  27866. value = Math.max(popper[placement], boundaries[placement]);
  27867. }
  27868. return defineProperty({}, placement, value);
  27869. },
  27870. secondary: function secondary(placement) {
  27871. var mainSide = placement === 'right' ? 'left' : 'top';
  27872. var value = popper[mainSide];
  27873. if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
  27874. value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
  27875. }
  27876. return defineProperty({}, mainSide, value);
  27877. }
  27878. };
  27879. order.forEach(function (placement) {
  27880. var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
  27881. popper = _extends({}, popper, check[side](placement));
  27882. });
  27883. data.offsets.popper = popper;
  27884. return data;
  27885. }
  27886. /**
  27887. * @function
  27888. * @memberof Modifiers
  27889. * @argument {Object} data - The data object generated by `update` method
  27890. * @argument {Object} options - Modifiers configuration and options
  27891. * @returns {Object} The data object, properly modified
  27892. */
  27893. function shift(data) {
  27894. var placement = data.placement;
  27895. var basePlacement = placement.split('-')[0];
  27896. var shiftvariation = placement.split('-')[1];
  27897. // if shift shiftvariation is specified, run the modifier
  27898. if (shiftvariation) {
  27899. var _data$offsets = data.offsets,
  27900. reference = _data$offsets.reference,
  27901. popper = _data$offsets.popper;
  27902. var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
  27903. var side = isVertical ? 'left' : 'top';
  27904. var measurement = isVertical ? 'width' : 'height';
  27905. var shiftOffsets = {
  27906. start: defineProperty({}, side, reference[side]),
  27907. end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
  27908. };
  27909. data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
  27910. }
  27911. return data;
  27912. }
  27913. /**
  27914. * @function
  27915. * @memberof Modifiers
  27916. * @argument {Object} data - The data object generated by update method
  27917. * @argument {Object} options - Modifiers configuration and options
  27918. * @returns {Object} The data object, properly modified
  27919. */
  27920. function hide(data) {
  27921. if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
  27922. return data;
  27923. }
  27924. var refRect = data.offsets.reference;
  27925. var bound = find(data.instance.modifiers, function (modifier) {
  27926. return modifier.name === 'preventOverflow';
  27927. }).boundaries;
  27928. if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
  27929. // Avoid unnecessary DOM access if visibility hasn't changed
  27930. if (data.hide === true) {
  27931. return data;
  27932. }
  27933. data.hide = true;
  27934. data.attributes['x-out-of-boundaries'] = '';
  27935. } else {
  27936. // Avoid unnecessary DOM access if visibility hasn't changed
  27937. if (data.hide === false) {
  27938. return data;
  27939. }
  27940. data.hide = false;
  27941. data.attributes['x-out-of-boundaries'] = false;
  27942. }
  27943. return data;
  27944. }
  27945. /**
  27946. * @function
  27947. * @memberof Modifiers
  27948. * @argument {Object} data - The data object generated by `update` method
  27949. * @argument {Object} options - Modifiers configuration and options
  27950. * @returns {Object} The data object, properly modified
  27951. */
  27952. function inner(data) {
  27953. var placement = data.placement;
  27954. var basePlacement = placement.split('-')[0];
  27955. var _data$offsets = data.offsets,
  27956. popper = _data$offsets.popper,
  27957. reference = _data$offsets.reference;
  27958. var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
  27959. var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
  27960. popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
  27961. data.placement = getOppositePlacement(placement);
  27962. data.offsets.popper = getClientRect(popper);
  27963. return data;
  27964. }
  27965. /**
  27966. * Modifier function, each modifier can have a function of this type assigned
  27967. * to its `fn` property.<br />
  27968. * These functions will be called on each update, this means that you must
  27969. * make sure they are performant enough to avoid performance bottlenecks.
  27970. *
  27971. * @function ModifierFn
  27972. * @argument {dataObject} data - The data object generated by `update` method
  27973. * @argument {Object} options - Modifiers configuration and options
  27974. * @returns {dataObject} The data object, properly modified
  27975. */
  27976. /**
  27977. * Modifiers are plugins used to alter the behavior of your poppers.<br />
  27978. * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
  27979. * needed by the library.
  27980. *
  27981. * Usually you don't want to override the `order`, `fn` and `onLoad` props.
  27982. * All the other properties are configurations that could be tweaked.
  27983. * @namespace modifiers
  27984. */
  27985. var modifiers = {
  27986. /**
  27987. * Modifier used to shift the popper on the start or end of its reference
  27988. * element.<br />
  27989. * It will read the variation of the `placement` property.<br />
  27990. * It can be one either `-end` or `-start`.
  27991. * @memberof modifiers
  27992. * @inner
  27993. */
  27994. shift: {
  27995. /** @prop {number} order=100 - Index used to define the order of execution */
  27996. order: 100,
  27997. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  27998. enabled: true,
  27999. /** @prop {ModifierFn} */
  28000. fn: shift
  28001. },
  28002. /**
  28003. * The `offset` modifier can shift your popper on both its axis.
  28004. *
  28005. * It accepts the following units:
  28006. * - `px` or unit-less, interpreted as pixels
  28007. * - `%` or `%r`, percentage relative to the length of the reference element
  28008. * - `%p`, percentage relative to the length of the popper element
  28009. * - `vw`, CSS viewport width unit
  28010. * - `vh`, CSS viewport height unit
  28011. *
  28012. * For length is intended the main axis relative to the placement of the popper.<br />
  28013. * This means that if the placement is `top` or `bottom`, the length will be the
  28014. * `width`. In case of `left` or `right`, it will be the `height`.
  28015. *
  28016. * You can provide a single value (as `Number` or `String`), or a pair of values
  28017. * as `String` divided by a comma or one (or more) white spaces.<br />
  28018. * The latter is a deprecated method because it leads to confusion and will be
  28019. * removed in v2.<br />
  28020. * Additionally, it accepts additions and subtractions between different units.
  28021. * Note that multiplications and divisions aren't supported.
  28022. *
  28023. * Valid examples are:
  28024. * ```
  28025. * 10
  28026. * '10%'
  28027. * '10, 10'
  28028. * '10%, 10'
  28029. * '10 + 10%'
  28030. * '10 - 5vh + 3%'
  28031. * '-10px + 5vh, 5px - 6%'
  28032. * ```
  28033. * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
  28034. * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
  28035. * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
  28036. *
  28037. * @memberof modifiers
  28038. * @inner
  28039. */
  28040. offset: {
  28041. /** @prop {number} order=200 - Index used to define the order of execution */
  28042. order: 200,
  28043. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  28044. enabled: true,
  28045. /** @prop {ModifierFn} */
  28046. fn: offset,
  28047. /** @prop {Number|String} offset=0
  28048. * The offset value as described in the modifier description
  28049. */
  28050. offset: 0
  28051. },
  28052. /**
  28053. * Modifier used to prevent the popper from being positioned outside the boundary.
  28054. *
  28055. * A scenario exists where the reference itself is not within the boundaries.<br />
  28056. * We can say it has "escaped the boundaries" — or just "escaped".<br />
  28057. * In this case we need to decide whether the popper should either:
  28058. *
  28059. * - detach from the reference and remain "trapped" in the boundaries, or
  28060. * - if it should ignore the boundary and "escape with its reference"
  28061. *
  28062. * When `escapeWithReference` is set to`true` and reference is completely
  28063. * outside its boundaries, the popper will overflow (or completely leave)
  28064. * the boundaries in order to remain attached to the edge of the reference.
  28065. *
  28066. * @memberof modifiers
  28067. * @inner
  28068. */
  28069. preventOverflow: {
  28070. /** @prop {number} order=300 - Index used to define the order of execution */
  28071. order: 300,
  28072. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  28073. enabled: true,
  28074. /** @prop {ModifierFn} */
  28075. fn: preventOverflow,
  28076. /**
  28077. * @prop {Array} [priority=['left','right','top','bottom']]
  28078. * Popper will try to prevent overflow following these priorities by default,
  28079. * then, it could overflow on the left and on top of the `boundariesElement`
  28080. */
  28081. priority: ['left', 'right', 'top', 'bottom'],
  28082. /**
  28083. * @prop {number} padding=5
  28084. * Amount of pixel used to define a minimum distance between the boundaries
  28085. * and the popper. This makes sure the popper always has a little padding
  28086. * between the edges of its container
  28087. */
  28088. padding: 5,
  28089. /**
  28090. * @prop {String|HTMLElement} boundariesElement='scrollParent'
  28091. * Boundaries used by the modifier. Can be `scrollParent`, `window`,
  28092. * `viewport` or any DOM element.
  28093. */
  28094. boundariesElement: 'scrollParent'
  28095. },
  28096. /**
  28097. * Modifier used to make sure the reference and its popper stay near each other
  28098. * without leaving any gap between the two. Especially useful when the arrow is
  28099. * enabled and you want to ensure that it points to its reference element.
  28100. * It cares only about the first axis. You can still have poppers with margin
  28101. * between the popper and its reference element.
  28102. * @memberof modifiers
  28103. * @inner
  28104. */
  28105. keepTogether: {
  28106. /** @prop {number} order=400 - Index used to define the order of execution */
  28107. order: 400,
  28108. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  28109. enabled: true,
  28110. /** @prop {ModifierFn} */
  28111. fn: keepTogether
  28112. },
  28113. /**
  28114. * This modifier is used to move the `arrowElement` of the popper to make
  28115. * sure it is positioned between the reference element and its popper element.
  28116. * It will read the outer size of the `arrowElement` node to detect how many
  28117. * pixels of conjunction are needed.
  28118. *
  28119. * It has no effect if no `arrowElement` is provided.
  28120. * @memberof modifiers
  28121. * @inner
  28122. */
  28123. arrow: {
  28124. /** @prop {number} order=500 - Index used to define the order of execution */
  28125. order: 500,
  28126. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  28127. enabled: true,
  28128. /** @prop {ModifierFn} */
  28129. fn: arrow,
  28130. /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
  28131. element: '[x-arrow]'
  28132. },
  28133. /**
  28134. * Modifier used to flip the popper's placement when it starts to overlap its
  28135. * reference element.
  28136. *
  28137. * Requires the `preventOverflow` modifier before it in order to work.
  28138. *
  28139. * **NOTE:** this modifier will interrupt the current update cycle and will
  28140. * restart it if it detects the need to flip the placement.
  28141. * @memberof modifiers
  28142. * @inner
  28143. */
  28144. flip: {
  28145. /** @prop {number} order=600 - Index used to define the order of execution */
  28146. order: 600,
  28147. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  28148. enabled: true,
  28149. /** @prop {ModifierFn} */
  28150. fn: flip,
  28151. /**
  28152. * @prop {String|Array} behavior='flip'
  28153. * The behavior used to change the popper's placement. It can be one of
  28154. * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
  28155. * placements (with optional variations)
  28156. */
  28157. behavior: 'flip',
  28158. /**
  28159. * @prop {number} padding=5
  28160. * The popper will flip if it hits the edges of the `boundariesElement`
  28161. */
  28162. padding: 5,
  28163. /**
  28164. * @prop {String|HTMLElement} boundariesElement='viewport'
  28165. * The element which will define the boundaries of the popper position.
  28166. * The popper will never be placed outside of the defined boundaries
  28167. * (except if `keepTogether` is enabled)
  28168. */
  28169. boundariesElement: 'viewport',
  28170. /**
  28171. * @prop {Boolean} flipVariations=false
  28172. * The popper will switch placement variation between `-start` and `-end` when
  28173. * the reference element overlaps its boundaries.
  28174. *
  28175. * The original placement should have a set variation.
  28176. */
  28177. flipVariations: false,
  28178. /**
  28179. * @prop {Boolean} flipVariationsByContent=false
  28180. * The popper will switch placement variation between `-start` and `-end` when
  28181. * the popper element overlaps its reference boundaries.
  28182. *
  28183. * The original placement should have a set variation.
  28184. */
  28185. flipVariationsByContent: false
  28186. },
  28187. /**
  28188. * Modifier used to make the popper flow toward the inner of the reference element.
  28189. * By default, when this modifier is disabled, the popper will be placed outside
  28190. * the reference element.
  28191. * @memberof modifiers
  28192. * @inner
  28193. */
  28194. inner: {
  28195. /** @prop {number} order=700 - Index used to define the order of execution */
  28196. order: 700,
  28197. /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
  28198. enabled: false,
  28199. /** @prop {ModifierFn} */
  28200. fn: inner
  28201. },
  28202. /**
  28203. * Modifier used to hide the popper when its reference element is outside of the
  28204. * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
  28205. * be used to hide with a CSS selector the popper when its reference is
  28206. * out of boundaries.
  28207. *
  28208. * Requires the `preventOverflow` modifier before it in order to work.
  28209. * @memberof modifiers
  28210. * @inner
  28211. */
  28212. hide: {
  28213. /** @prop {number} order=800 - Index used to define the order of execution */
  28214. order: 800,
  28215. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  28216. enabled: true,
  28217. /** @prop {ModifierFn} */
  28218. fn: hide
  28219. },
  28220. /**
  28221. * Computes the style that will be applied to the popper element to gets
  28222. * properly positioned.
  28223. *
  28224. * Note that this modifier will not touch the DOM, it just prepares the styles
  28225. * so that `applyStyle` modifier can apply it. This separation is useful
  28226. * in case you need to replace `applyStyle` with a custom implementation.
  28227. *
  28228. * This modifier has `850` as `order` value to maintain backward compatibility
  28229. * with previous versions of Popper.js. Expect the modifiers ordering method
  28230. * to change in future major versions of the library.
  28231. *
  28232. * @memberof modifiers
  28233. * @inner
  28234. */
  28235. computeStyle: {
  28236. /** @prop {number} order=850 - Index used to define the order of execution */
  28237. order: 850,
  28238. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  28239. enabled: true,
  28240. /** @prop {ModifierFn} */
  28241. fn: computeStyle,
  28242. /**
  28243. * @prop {Boolean} gpuAcceleration=true
  28244. * If true, it uses the CSS 3D transformation to position the popper.
  28245. * Otherwise, it will use the `top` and `left` properties
  28246. */
  28247. gpuAcceleration: true,
  28248. /**
  28249. * @prop {string} [x='bottom']
  28250. * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
  28251. * Change this if your popper should grow in a direction different from `bottom`
  28252. */
  28253. x: 'bottom',
  28254. /**
  28255. * @prop {string} [x='left']
  28256. * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
  28257. * Change this if your popper should grow in a direction different from `right`
  28258. */
  28259. y: 'right'
  28260. },
  28261. /**
  28262. * Applies the computed styles to the popper element.
  28263. *
  28264. * All the DOM manipulations are limited to this modifier. This is useful in case
  28265. * you want to integrate Popper.js inside a framework or view library and you
  28266. * want to delegate all the DOM manipulations to it.
  28267. *
  28268. * Note that if you disable this modifier, you must make sure the popper element
  28269. * has its position set to `absolute` before Popper.js can do its work!
  28270. *
  28271. * Just disable this modifier and define your own to achieve the desired effect.
  28272. *
  28273. * @memberof modifiers
  28274. * @inner
  28275. */
  28276. applyStyle: {
  28277. /** @prop {number} order=900 - Index used to define the order of execution */
  28278. order: 900,
  28279. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  28280. enabled: true,
  28281. /** @prop {ModifierFn} */
  28282. fn: applyStyle,
  28283. /** @prop {Function} */
  28284. onLoad: applyStyleOnLoad,
  28285. /**
  28286. * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
  28287. * @prop {Boolean} gpuAcceleration=true
  28288. * If true, it uses the CSS 3D transformation to position the popper.
  28289. * Otherwise, it will use the `top` and `left` properties
  28290. */
  28291. gpuAcceleration: undefined
  28292. }
  28293. };
  28294. /**
  28295. * The `dataObject` is an object containing all the information used by Popper.js.
  28296. * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
  28297. * @name dataObject
  28298. * @property {Object} data.instance The Popper.js instance
  28299. * @property {String} data.placement Placement applied to popper
  28300. * @property {String} data.originalPlacement Placement originally defined on init
  28301. * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
  28302. * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
  28303. * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
  28304. * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
  28305. * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
  28306. * @property {Object} data.boundaries Offsets of the popper boundaries
  28307. * @property {Object} data.offsets The measurements of popper, reference and arrow elements
  28308. * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
  28309. * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
  28310. * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
  28311. */
  28312. /**
  28313. * Default options provided to Popper.js constructor.<br />
  28314. * These can be overridden using the `options` argument of Popper.js.<br />
  28315. * To override an option, simply pass an object with the same
  28316. * structure of the `options` object, as the 3rd argument. For example:
  28317. * ```
  28318. * new Popper(ref, pop, {
  28319. * modifiers: {
  28320. * preventOverflow: { enabled: false }
  28321. * }
  28322. * })
  28323. * ```
  28324. * @type {Object}
  28325. * @static
  28326. * @memberof Popper
  28327. */
  28328. var Defaults = {
  28329. /**
  28330. * Popper's placement.
  28331. * @prop {Popper.placements} placement='bottom'
  28332. */
  28333. placement: 'bottom',
  28334. /**
  28335. * Set this to true if you want popper to position it self in 'fixed' mode
  28336. * @prop {Boolean} positionFixed=false
  28337. */
  28338. positionFixed: false,
  28339. /**
  28340. * Whether events (resize, scroll) are initially enabled.
  28341. * @prop {Boolean} eventsEnabled=true
  28342. */
  28343. eventsEnabled: true,
  28344. /**
  28345. * Set to true if you want to automatically remove the popper when
  28346. * you call the `destroy` method.
  28347. * @prop {Boolean} removeOnDestroy=false
  28348. */
  28349. removeOnDestroy: false,
  28350. /**
  28351. * Callback called when the popper is created.<br />
  28352. * By default, it is set to no-op.<br />
  28353. * Access Popper.js instance with `data.instance`.
  28354. * @prop {onCreate}
  28355. */
  28356. onCreate: function onCreate() {},
  28357. /**
  28358. * Callback called when the popper is updated. This callback is not called
  28359. * on the initialization/creation of the popper, but only on subsequent
  28360. * updates.<br />
  28361. * By default, it is set to no-op.<br />
  28362. * Access Popper.js instance with `data.instance`.
  28363. * @prop {onUpdate}
  28364. */
  28365. onUpdate: function onUpdate() {},
  28366. /**
  28367. * List of modifiers used to modify the offsets before they are applied to the popper.
  28368. * They provide most of the functionalities of Popper.js.
  28369. * @prop {modifiers}
  28370. */
  28371. modifiers: modifiers
  28372. };
  28373. /**
  28374. * @callback onCreate
  28375. * @param {dataObject} data
  28376. */
  28377. /**
  28378. * @callback onUpdate
  28379. * @param {dataObject} data
  28380. */
  28381. // Utils
  28382. // Methods
  28383. var Popper = function () {
  28384. /**
  28385. * Creates a new Popper.js instance.
  28386. * @class Popper
  28387. * @param {Element|referenceObject} reference - The reference element used to position the popper
  28388. * @param {Element} popper - The HTML / XML element used as the popper
  28389. * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
  28390. * @return {Object} instance - The generated Popper.js instance
  28391. */
  28392. function Popper(reference, popper) {
  28393. var _this = this;
  28394. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  28395. classCallCheck(this, Popper);
  28396. this.scheduleUpdate = function () {
  28397. return requestAnimationFrame(_this.update);
  28398. };
  28399. // make update() debounced, so that it only runs at most once-per-tick
  28400. this.update = debounce(this.update.bind(this));
  28401. // with {} we create a new object with the options inside it
  28402. this.options = _extends({}, Popper.Defaults, options);
  28403. // init state
  28404. this.state = {
  28405. isDestroyed: false,
  28406. isCreated: false,
  28407. scrollParents: []
  28408. };
  28409. // get reference and popper elements (allow jQuery wrappers)
  28410. this.reference = reference && reference.jquery ? reference[0] : reference;
  28411. this.popper = popper && popper.jquery ? popper[0] : popper;
  28412. // Deep merge modifiers options
  28413. this.options.modifiers = {};
  28414. Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
  28415. _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
  28416. });
  28417. // Refactoring modifiers' list (Object => Array)
  28418. this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
  28419. return _extends({
  28420. name: name
  28421. }, _this.options.modifiers[name]);
  28422. })
  28423. // sort the modifiers by order
  28424. .sort(function (a, b) {
  28425. return a.order - b.order;
  28426. });
  28427. // modifiers have the ability to execute arbitrary code when Popper.js get inited
  28428. // such code is executed in the same order of its modifier
  28429. // they could add new properties to their options configuration
  28430. // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
  28431. this.modifiers.forEach(function (modifierOptions) {
  28432. if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
  28433. modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
  28434. }
  28435. });
  28436. // fire the first update to position the popper in the right place
  28437. this.update();
  28438. var eventsEnabled = this.options.eventsEnabled;
  28439. if (eventsEnabled) {
  28440. // setup event listeners, they will take care of update the position in specific situations
  28441. this.enableEventListeners();
  28442. }
  28443. this.state.eventsEnabled = eventsEnabled;
  28444. }
  28445. // We can't use class properties because they don't get listed in the
  28446. // class prototype and break stuff like Sinon stubs
  28447. createClass(Popper, [{
  28448. key: 'update',
  28449. value: function update$$1() {
  28450. return update.call(this);
  28451. }
  28452. }, {
  28453. key: 'destroy',
  28454. value: function destroy$$1() {
  28455. return destroy.call(this);
  28456. }
  28457. }, {
  28458. key: 'enableEventListeners',
  28459. value: function enableEventListeners$$1() {
  28460. return enableEventListeners.call(this);
  28461. }
  28462. }, {
  28463. key: 'disableEventListeners',
  28464. value: function disableEventListeners$$1() {
  28465. return disableEventListeners.call(this);
  28466. }
  28467. /**
  28468. * Schedules an update. It will run on the next UI update available.
  28469. * @method scheduleUpdate
  28470. * @memberof Popper
  28471. */
  28472. /**
  28473. * Collection of utilities useful when writing custom modifiers.
  28474. * Starting from version 1.7, this method is available only if you
  28475. * include `popper-utils.js` before `popper.js`.
  28476. *
  28477. * **DEPRECATION**: This way to access PopperUtils is deprecated
  28478. * and will be removed in v2! Use the PopperUtils module directly instead.
  28479. * Due to the high instability of the methods contained in Utils, we can't
  28480. * guarantee them to follow semver. Use them at your own risk!
  28481. * @static
  28482. * @private
  28483. * @type {Object}
  28484. * @deprecated since version 1.8
  28485. * @member Utils
  28486. * @memberof Popper
  28487. */
  28488. }]);
  28489. return Popper;
  28490. }();
  28491. /**
  28492. * The `referenceObject` is an object that provides an interface compatible with Popper.js
  28493. * and lets you use it as replacement of a real DOM node.<br />
  28494. * You can use this method to position a popper relatively to a set of coordinates
  28495. * in case you don't have a DOM node to use as reference.
  28496. *
  28497. * ```
  28498. * new Popper(referenceObject, popperNode);
  28499. * ```
  28500. *
  28501. * NB: This feature isn't supported in Internet Explorer 10.
  28502. * @name referenceObject
  28503. * @property {Function} data.getBoundingClientRect
  28504. * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
  28505. * @property {number} data.clientWidth
  28506. * An ES6 getter that will return the width of the virtual reference element.
  28507. * @property {number} data.clientHeight
  28508. * An ES6 getter that will return the height of the virtual reference element.
  28509. */
  28510. Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
  28511. Popper.placements = placements;
  28512. Popper.Defaults = Defaults;
  28513. /* harmony default export */ __webpack_exports__["default"] = (Popper);
  28514. //# sourceMappingURL=popper.js.map
  28515. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  28516. /***/ }),
  28517. /***/ "./node_modules/process/browser.js":
  28518. /*!*****************************************!*\
  28519. !*** ./node_modules/process/browser.js ***!
  28520. \*****************************************/
  28521. /*! no static exports found */
  28522. /***/ (function(module, exports) {
  28523. // shim for using process in browser
  28524. var process = module.exports = {};
  28525. // cached from whatever global is present so that test runners that stub it
  28526. // don't break things. But we need to wrap it in a try catch in case it is
  28527. // wrapped in strict mode code which doesn't define any globals. It's inside a
  28528. // function because try/catches deoptimize in certain engines.
  28529. var cachedSetTimeout;
  28530. var cachedClearTimeout;
  28531. function defaultSetTimout() {
  28532. throw new Error('setTimeout has not been defined');
  28533. }
  28534. function defaultClearTimeout () {
  28535. throw new Error('clearTimeout has not been defined');
  28536. }
  28537. (function () {
  28538. try {
  28539. if (typeof setTimeout === 'function') {
  28540. cachedSetTimeout = setTimeout;
  28541. } else {
  28542. cachedSetTimeout = defaultSetTimout;
  28543. }
  28544. } catch (e) {
  28545. cachedSetTimeout = defaultSetTimout;
  28546. }
  28547. try {
  28548. if (typeof clearTimeout === 'function') {
  28549. cachedClearTimeout = clearTimeout;
  28550. } else {
  28551. cachedClearTimeout = defaultClearTimeout;
  28552. }
  28553. } catch (e) {
  28554. cachedClearTimeout = defaultClearTimeout;
  28555. }
  28556. } ())
  28557. function runTimeout(fun) {
  28558. if (cachedSetTimeout === setTimeout) {
  28559. //normal enviroments in sane situations
  28560. return setTimeout(fun, 0);
  28561. }
  28562. // if setTimeout wasn't available but was latter defined
  28563. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  28564. cachedSetTimeout = setTimeout;
  28565. return setTimeout(fun, 0);
  28566. }
  28567. try {
  28568. // when when somebody has screwed with setTimeout but no I.E. maddness
  28569. return cachedSetTimeout(fun, 0);
  28570. } catch(e){
  28571. try {
  28572. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  28573. return cachedSetTimeout.call(null, fun, 0);
  28574. } catch(e){
  28575. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  28576. return cachedSetTimeout.call(this, fun, 0);
  28577. }
  28578. }
  28579. }
  28580. function runClearTimeout(marker) {
  28581. if (cachedClearTimeout === clearTimeout) {
  28582. //normal enviroments in sane situations
  28583. return clearTimeout(marker);
  28584. }
  28585. // if clearTimeout wasn't available but was latter defined
  28586. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  28587. cachedClearTimeout = clearTimeout;
  28588. return clearTimeout(marker);
  28589. }
  28590. try {
  28591. // when when somebody has screwed with setTimeout but no I.E. maddness
  28592. return cachedClearTimeout(marker);
  28593. } catch (e){
  28594. try {
  28595. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  28596. return cachedClearTimeout.call(null, marker);
  28597. } catch (e){
  28598. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  28599. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  28600. return cachedClearTimeout.call(this, marker);
  28601. }
  28602. }
  28603. }
  28604. var queue = [];
  28605. var draining = false;
  28606. var currentQueue;
  28607. var queueIndex = -1;
  28608. function cleanUpNextTick() {
  28609. if (!draining || !currentQueue) {
  28610. return;
  28611. }
  28612. draining = false;
  28613. if (currentQueue.length) {
  28614. queue = currentQueue.concat(queue);
  28615. } else {
  28616. queueIndex = -1;
  28617. }
  28618. if (queue.length) {
  28619. drainQueue();
  28620. }
  28621. }
  28622. function drainQueue() {
  28623. if (draining) {
  28624. return;
  28625. }
  28626. var timeout = runTimeout(cleanUpNextTick);
  28627. draining = true;
  28628. var len = queue.length;
  28629. while(len) {
  28630. currentQueue = queue;
  28631. queue = [];
  28632. while (++queueIndex < len) {
  28633. if (currentQueue) {
  28634. currentQueue[queueIndex].run();
  28635. }
  28636. }
  28637. queueIndex = -1;
  28638. len = queue.length;
  28639. }
  28640. currentQueue = null;
  28641. draining = false;
  28642. runClearTimeout(timeout);
  28643. }
  28644. process.nextTick = function (fun) {
  28645. var args = new Array(arguments.length - 1);
  28646. if (arguments.length > 1) {
  28647. for (var i = 1; i < arguments.length; i++) {
  28648. args[i - 1] = arguments[i];
  28649. }
  28650. }
  28651. queue.push(new Item(fun, args));
  28652. if (queue.length === 1 && !draining) {
  28653. runTimeout(drainQueue);
  28654. }
  28655. };
  28656. // v8 likes predictible objects
  28657. function Item(fun, array) {
  28658. this.fun = fun;
  28659. this.array = array;
  28660. }
  28661. Item.prototype.run = function () {
  28662. this.fun.apply(null, this.array);
  28663. };
  28664. process.title = 'browser';
  28665. process.browser = true;
  28666. process.env = {};
  28667. process.argv = [];
  28668. process.version = ''; // empty string to avoid regexp issues
  28669. process.versions = {};
  28670. function noop() {}
  28671. process.on = noop;
  28672. process.addListener = noop;
  28673. process.once = noop;
  28674. process.off = noop;
  28675. process.removeListener = noop;
  28676. process.removeAllListeners = noop;
  28677. process.emit = noop;
  28678. process.prependListener = noop;
  28679. process.prependOnceListener = noop;
  28680. process.listeners = function (name) { return [] }
  28681. process.binding = function (name) {
  28682. throw new Error('process.binding is not supported');
  28683. };
  28684. process.cwd = function () { return '/' };
  28685. process.chdir = function (dir) {
  28686. throw new Error('process.chdir is not supported');
  28687. };
  28688. process.umask = function() { return 0; };
  28689. /***/ }),
  28690. /***/ "./node_modules/webpack/buildin/global.js":
  28691. /*!***********************************!*\
  28692. !*** (webpack)/buildin/global.js ***!
  28693. \***********************************/
  28694. /*! no static exports found */
  28695. /***/ (function(module, exports) {
  28696. var g;
  28697. // This works in non-strict mode
  28698. g = (function() {
  28699. return this;
  28700. })();
  28701. try {
  28702. // This works if eval is allowed (see CSP)
  28703. g = g || new Function("return this")();
  28704. } catch (e) {
  28705. // This works if the window reference is available
  28706. if (typeof window === "object") g = window;
  28707. }
  28708. // g can still be undefined, but nothing to do about it...
  28709. // We return undefined, instead of nothing here, so it's
  28710. // easier to handle this case. if(!global) { ...}
  28711. module.exports = g;
  28712. /***/ }),
  28713. /***/ "./node_modules/webpack/buildin/module.js":
  28714. /*!***********************************!*\
  28715. !*** (webpack)/buildin/module.js ***!
  28716. \***********************************/
  28717. /*! no static exports found */
  28718. /***/ (function(module, exports) {
  28719. module.exports = function(module) {
  28720. if (!module.webpackPolyfill) {
  28721. module.deprecate = function() {};
  28722. module.paths = [];
  28723. // module.parent = undefined by default
  28724. if (!module.children) module.children = [];
  28725. Object.defineProperty(module, "loaded", {
  28726. enumerable: true,
  28727. get: function() {
  28728. return module.l;
  28729. }
  28730. });
  28731. Object.defineProperty(module, "id", {
  28732. enumerable: true,
  28733. get: function() {
  28734. return module.i;
  28735. }
  28736. });
  28737. module.webpackPolyfill = 1;
  28738. }
  28739. return module;
  28740. };
  28741. /***/ }),
  28742. /***/ "./resources/js/bootstrap.js":
  28743. /*!***********************************!*\
  28744. !*** ./resources/js/bootstrap.js ***!
  28745. \***********************************/
  28746. /*! no static exports found */
  28747. /***/ (function(module, exports, __webpack_require__) {
  28748. window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
  28749. /**
  28750. * We'll load jQuery and the Bootstrap jQuery plugin which provides support
  28751. * for JavaScript based Bootstrap features such as modals and tabs. This
  28752. * code may be modified to fit the specific needs of your application.
  28753. */
  28754. try {
  28755. window.Popper = __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")["default"];
  28756. window.$ = window.jQuery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"); //require('bootstrap');
  28757. } catch (e) {}
  28758. /**
  28759. * We'll load the axios HTTP library which allows us to easily issue requests
  28760. * to our Laravel back-end. This library automatically handles sending the
  28761. * CSRF token as a header based on the value of the "XSRF" token cookie.
  28762. */
  28763. window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  28764. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  28765. /**
  28766. * Next we will register the CSRF Token as a common header with Axios so that
  28767. * all outgoing HTTP requests automatically have it attached. This is just
  28768. * a simple convenience so we don't have to attach every token manually.
  28769. */
  28770. var token = document.head.querySelector('meta[name="csrf-token"]');
  28771. if (token) {
  28772. window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
  28773. } else {
  28774. console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
  28775. }
  28776. /**
  28777. * Echo exposes an expressive API for subscribing to channels and listening
  28778. * for events that are broadcast by Laravel. Echo and event broadcasting
  28779. * allows your team to easily build robust real-time web applications.
  28780. */
  28781. // import Echo from 'laravel-echo'
  28782. // window.Pusher = require('pusher-js');
  28783. // window.Echo = new Echo({
  28784. // broadcaster: 'pusher',
  28785. // key: process.env.MIX_PUSHER_APP_KEY,
  28786. // cluster: process.env.MIX_PUSHER_APP_CLUSTER,
  28787. // encrypted: true
  28788. // });
  28789. /***/ }),
  28790. /***/ 1:
  28791. /*!*****************************************!*\
  28792. !*** multi ./resources/js/bootstrap.js ***!
  28793. \*****************************************/
  28794. /*! no static exports found */
  28795. /***/ (function(module, exports, __webpack_require__) {
  28796. module.exports = __webpack_require__(/*! C:\Users\lf151415\Code Hub\Repositories\2FAuth\resources\js\bootstrap.js */"./resources/js/bootstrap.js");
  28797. /***/ })
  28798. /******/ });