app.js 1.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290
  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 = 0);
  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 buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./node_modules/axios/lib/core/buildFullPath.js");
  107. var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js");
  108. var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js");
  109. var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js");
  110. module.exports = function xhrAdapter(config) {
  111. return new Promise(function dispatchXhrRequest(resolve, reject) {
  112. var requestData = config.data;
  113. var requestHeaders = config.headers;
  114. if (utils.isFormData(requestData)) {
  115. delete requestHeaders['Content-Type']; // Let the browser set it
  116. }
  117. var request = new XMLHttpRequest();
  118. // HTTP basic authentication
  119. if (config.auth) {
  120. var username = config.auth.username || '';
  121. var password = config.auth.password || '';
  122. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  123. }
  124. var fullPath = buildFullPath(config.baseURL, config.url);
  125. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  126. // Set the request timeout in MS
  127. request.timeout = config.timeout;
  128. // Listen for ready state
  129. request.onreadystatechange = function handleLoad() {
  130. if (!request || request.readyState !== 4) {
  131. return;
  132. }
  133. // The request errored out and we didn't get a response, this will be
  134. // handled by onerror instead
  135. // With one exception: request that using file: protocol, most browsers
  136. // will return status as 0 even though it's a successful request
  137. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  138. return;
  139. }
  140. // Prepare the response
  141. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  142. var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
  143. var response = {
  144. data: responseData,
  145. status: request.status,
  146. statusText: request.statusText,
  147. headers: responseHeaders,
  148. config: config,
  149. request: request
  150. };
  151. settle(resolve, reject, response);
  152. // Clean up request
  153. request = null;
  154. };
  155. // Handle browser request cancellation (as opposed to a manual cancellation)
  156. request.onabort = function handleAbort() {
  157. if (!request) {
  158. return;
  159. }
  160. reject(createError('Request aborted', config, 'ECONNABORTED', request));
  161. // Clean up request
  162. request = null;
  163. };
  164. // Handle low level network errors
  165. request.onerror = function handleError() {
  166. // Real errors are hidden from us by the browser
  167. // onerror should only fire if it's a network error
  168. reject(createError('Network Error', config, null, request));
  169. // Clean up request
  170. request = null;
  171. };
  172. // Handle timeout
  173. request.ontimeout = function handleTimeout() {
  174. var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
  175. if (config.timeoutErrorMessage) {
  176. timeoutErrorMessage = config.timeoutErrorMessage;
  177. }
  178. reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',
  179. request));
  180. // Clean up request
  181. request = null;
  182. };
  183. // Add xsrf header
  184. // This is only done if running in a standard browser environment.
  185. // Specifically not if we're in a web worker, or react-native.
  186. if (utils.isStandardBrowserEnv()) {
  187. var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./node_modules/axios/lib/helpers/cookies.js");
  188. // Add xsrf header
  189. var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
  190. cookies.read(config.xsrfCookieName) :
  191. undefined;
  192. if (xsrfValue) {
  193. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  194. }
  195. }
  196. // Add headers to the request
  197. if ('setRequestHeader' in request) {
  198. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  199. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  200. // Remove Content-Type if data is undefined
  201. delete requestHeaders[key];
  202. } else {
  203. // Otherwise add header to the request
  204. request.setRequestHeader(key, val);
  205. }
  206. });
  207. }
  208. // Add withCredentials to request if needed
  209. if (!utils.isUndefined(config.withCredentials)) {
  210. request.withCredentials = !!config.withCredentials;
  211. }
  212. // Add responseType to request if needed
  213. if (config.responseType) {
  214. try {
  215. request.responseType = config.responseType;
  216. } catch (e) {
  217. // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
  218. // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
  219. if (config.responseType !== 'json') {
  220. throw e;
  221. }
  222. }
  223. }
  224. // Handle progress if needed
  225. if (typeof config.onDownloadProgress === 'function') {
  226. request.addEventListener('progress', config.onDownloadProgress);
  227. }
  228. // Not all browsers support upload events
  229. if (typeof config.onUploadProgress === 'function' && request.upload) {
  230. request.upload.addEventListener('progress', config.onUploadProgress);
  231. }
  232. if (config.cancelToken) {
  233. // Handle cancellation
  234. config.cancelToken.promise.then(function onCanceled(cancel) {
  235. if (!request) {
  236. return;
  237. }
  238. request.abort();
  239. reject(cancel);
  240. // Clean up request
  241. request = null;
  242. });
  243. }
  244. if (requestData === undefined) {
  245. requestData = null;
  246. }
  247. // Send the request
  248. request.send(requestData);
  249. });
  250. };
  251. /***/ }),
  252. /***/ "./node_modules/axios/lib/axios.js":
  253. /*!*****************************************!*\
  254. !*** ./node_modules/axios/lib/axios.js ***!
  255. \*****************************************/
  256. /*! no static exports found */
  257. /***/ (function(module, exports, __webpack_require__) {
  258. "use strict";
  259. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  260. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  261. var Axios = __webpack_require__(/*! ./core/Axios */ "./node_modules/axios/lib/core/Axios.js");
  262. var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  263. var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/axios/lib/defaults.js");
  264. /**
  265. * Create an instance of Axios
  266. *
  267. * @param {Object} defaultConfig The default config for the instance
  268. * @return {Axios} A new instance of Axios
  269. */
  270. function createInstance(defaultConfig) {
  271. var context = new Axios(defaultConfig);
  272. var instance = bind(Axios.prototype.request, context);
  273. // Copy axios.prototype to instance
  274. utils.extend(instance, Axios.prototype, context);
  275. // Copy context to instance
  276. utils.extend(instance, context);
  277. return instance;
  278. }
  279. // Create the default instance to be exported
  280. var axios = createInstance(defaults);
  281. // Expose Axios class to allow class inheritance
  282. axios.Axios = Axios;
  283. // Factory for creating new instances
  284. axios.create = function create(instanceConfig) {
  285. return createInstance(mergeConfig(axios.defaults, instanceConfig));
  286. };
  287. // Expose Cancel & CancelToken
  288. axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  289. axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js");
  290. axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  291. // Expose all/spread
  292. axios.all = function all(promises) {
  293. return Promise.all(promises);
  294. };
  295. axios.spread = __webpack_require__(/*! ./helpers/spread */ "./node_modules/axios/lib/helpers/spread.js");
  296. module.exports = axios;
  297. // Allow use of default import syntax in TypeScript
  298. module.exports.default = axios;
  299. /***/ }),
  300. /***/ "./node_modules/axios/lib/cancel/Cancel.js":
  301. /*!*************************************************!*\
  302. !*** ./node_modules/axios/lib/cancel/Cancel.js ***!
  303. \*************************************************/
  304. /*! no static exports found */
  305. /***/ (function(module, exports, __webpack_require__) {
  306. "use strict";
  307. /**
  308. * A `Cancel` is an object that is thrown when an operation is canceled.
  309. *
  310. * @class
  311. * @param {string=} message The message.
  312. */
  313. function Cancel(message) {
  314. this.message = message;
  315. }
  316. Cancel.prototype.toString = function toString() {
  317. return 'Cancel' + (this.message ? ': ' + this.message : '');
  318. };
  319. Cancel.prototype.__CANCEL__ = true;
  320. module.exports = Cancel;
  321. /***/ }),
  322. /***/ "./node_modules/axios/lib/cancel/CancelToken.js":
  323. /*!******************************************************!*\
  324. !*** ./node_modules/axios/lib/cancel/CancelToken.js ***!
  325. \******************************************************/
  326. /*! no static exports found */
  327. /***/ (function(module, exports, __webpack_require__) {
  328. "use strict";
  329. var Cancel = __webpack_require__(/*! ./Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  330. /**
  331. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  332. *
  333. * @class
  334. * @param {Function} executor The executor function.
  335. */
  336. function CancelToken(executor) {
  337. if (typeof executor !== 'function') {
  338. throw new TypeError('executor must be a function.');
  339. }
  340. var resolvePromise;
  341. this.promise = new Promise(function promiseExecutor(resolve) {
  342. resolvePromise = resolve;
  343. });
  344. var token = this;
  345. executor(function cancel(message) {
  346. if (token.reason) {
  347. // Cancellation has already been requested
  348. return;
  349. }
  350. token.reason = new Cancel(message);
  351. resolvePromise(token.reason);
  352. });
  353. }
  354. /**
  355. * Throws a `Cancel` if cancellation has been requested.
  356. */
  357. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  358. if (this.reason) {
  359. throw this.reason;
  360. }
  361. };
  362. /**
  363. * Returns an object that contains a new `CancelToken` and a function that, when called,
  364. * cancels the `CancelToken`.
  365. */
  366. CancelToken.source = function source() {
  367. var cancel;
  368. var token = new CancelToken(function executor(c) {
  369. cancel = c;
  370. });
  371. return {
  372. token: token,
  373. cancel: cancel
  374. };
  375. };
  376. module.exports = CancelToken;
  377. /***/ }),
  378. /***/ "./node_modules/axios/lib/cancel/isCancel.js":
  379. /*!***************************************************!*\
  380. !*** ./node_modules/axios/lib/cancel/isCancel.js ***!
  381. \***************************************************/
  382. /*! no static exports found */
  383. /***/ (function(module, exports, __webpack_require__) {
  384. "use strict";
  385. module.exports = function isCancel(value) {
  386. return !!(value && value.__CANCEL__);
  387. };
  388. /***/ }),
  389. /***/ "./node_modules/axios/lib/core/Axios.js":
  390. /*!**********************************************!*\
  391. !*** ./node_modules/axios/lib/core/Axios.js ***!
  392. \**********************************************/
  393. /*! no static exports found */
  394. /***/ (function(module, exports, __webpack_require__) {
  395. "use strict";
  396. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  397. var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  398. var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./node_modules/axios/lib/core/InterceptorManager.js");
  399. var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./node_modules/axios/lib/core/dispatchRequest.js");
  400. var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  401. /**
  402. * Create a new instance of Axios
  403. *
  404. * @param {Object} instanceConfig The default config for the instance
  405. */
  406. function Axios(instanceConfig) {
  407. this.defaults = instanceConfig;
  408. this.interceptors = {
  409. request: new InterceptorManager(),
  410. response: new InterceptorManager()
  411. };
  412. }
  413. /**
  414. * Dispatch a request
  415. *
  416. * @param {Object} config The config specific for this request (merged with this.defaults)
  417. */
  418. Axios.prototype.request = function request(config) {
  419. /*eslint no-param-reassign:0*/
  420. // Allow for axios('example/url'[, config]) a la fetch API
  421. if (typeof config === 'string') {
  422. config = arguments[1] || {};
  423. config.url = arguments[0];
  424. } else {
  425. config = config || {};
  426. }
  427. config = mergeConfig(this.defaults, config);
  428. // Set config.method
  429. if (config.method) {
  430. config.method = config.method.toLowerCase();
  431. } else if (this.defaults.method) {
  432. config.method = this.defaults.method.toLowerCase();
  433. } else {
  434. config.method = 'get';
  435. }
  436. // Hook up interceptors middleware
  437. var chain = [dispatchRequest, undefined];
  438. var promise = Promise.resolve(config);
  439. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  440. chain.unshift(interceptor.fulfilled, interceptor.rejected);
  441. });
  442. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  443. chain.push(interceptor.fulfilled, interceptor.rejected);
  444. });
  445. while (chain.length) {
  446. promise = promise.then(chain.shift(), chain.shift());
  447. }
  448. return promise;
  449. };
  450. Axios.prototype.getUri = function getUri(config) {
  451. config = mergeConfig(this.defaults, config);
  452. return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
  453. };
  454. // Provide aliases for supported request methods
  455. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  456. /*eslint func-names:0*/
  457. Axios.prototype[method] = function(url, config) {
  458. return this.request(utils.merge(config || {}, {
  459. method: method,
  460. url: url
  461. }));
  462. };
  463. });
  464. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  465. /*eslint func-names:0*/
  466. Axios.prototype[method] = function(url, data, config) {
  467. return this.request(utils.merge(config || {}, {
  468. method: method,
  469. url: url,
  470. data: data
  471. }));
  472. };
  473. });
  474. module.exports = Axios;
  475. /***/ }),
  476. /***/ "./node_modules/axios/lib/core/InterceptorManager.js":
  477. /*!***********************************************************!*\
  478. !*** ./node_modules/axios/lib/core/InterceptorManager.js ***!
  479. \***********************************************************/
  480. /*! no static exports found */
  481. /***/ (function(module, exports, __webpack_require__) {
  482. "use strict";
  483. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  484. function InterceptorManager() {
  485. this.handlers = [];
  486. }
  487. /**
  488. * Add a new interceptor to the stack
  489. *
  490. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  491. * @param {Function} rejected The function to handle `reject` for a `Promise`
  492. *
  493. * @return {Number} An ID used to remove interceptor later
  494. */
  495. InterceptorManager.prototype.use = function use(fulfilled, rejected) {
  496. this.handlers.push({
  497. fulfilled: fulfilled,
  498. rejected: rejected
  499. });
  500. return this.handlers.length - 1;
  501. };
  502. /**
  503. * Remove an interceptor from the stack
  504. *
  505. * @param {Number} id The ID that was returned by `use`
  506. */
  507. InterceptorManager.prototype.eject = function eject(id) {
  508. if (this.handlers[id]) {
  509. this.handlers[id] = null;
  510. }
  511. };
  512. /**
  513. * Iterate over all the registered interceptors
  514. *
  515. * This method is particularly useful for skipping over any
  516. * interceptors that may have become `null` calling `eject`.
  517. *
  518. * @param {Function} fn The function to call for each interceptor
  519. */
  520. InterceptorManager.prototype.forEach = function forEach(fn) {
  521. utils.forEach(this.handlers, function forEachHandler(h) {
  522. if (h !== null) {
  523. fn(h);
  524. }
  525. });
  526. };
  527. module.exports = InterceptorManager;
  528. /***/ }),
  529. /***/ "./node_modules/axios/lib/core/buildFullPath.js":
  530. /*!******************************************************!*\
  531. !*** ./node_modules/axios/lib/core/buildFullPath.js ***!
  532. \******************************************************/
  533. /*! no static exports found */
  534. /***/ (function(module, exports, __webpack_require__) {
  535. "use strict";
  536. var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./node_modules/axios/lib/helpers/isAbsoluteURL.js");
  537. var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./node_modules/axios/lib/helpers/combineURLs.js");
  538. /**
  539. * Creates a new URL by combining the baseURL with the requestedURL,
  540. * only when the requestedURL is not already an absolute URL.
  541. * If the requestURL is absolute, this function returns the requestedURL untouched.
  542. *
  543. * @param {string} baseURL The base URL
  544. * @param {string} requestedURL Absolute or relative URL to combine
  545. * @returns {string} The combined full path
  546. */
  547. module.exports = function buildFullPath(baseURL, requestedURL) {
  548. if (baseURL && !isAbsoluteURL(requestedURL)) {
  549. return combineURLs(baseURL, requestedURL);
  550. }
  551. return requestedURL;
  552. };
  553. /***/ }),
  554. /***/ "./node_modules/axios/lib/core/createError.js":
  555. /*!****************************************************!*\
  556. !*** ./node_modules/axios/lib/core/createError.js ***!
  557. \****************************************************/
  558. /*! no static exports found */
  559. /***/ (function(module, exports, __webpack_require__) {
  560. "use strict";
  561. var enhanceError = __webpack_require__(/*! ./enhanceError */ "./node_modules/axios/lib/core/enhanceError.js");
  562. /**
  563. * Create an Error with the specified message, config, error code, request and response.
  564. *
  565. * @param {string} message The error message.
  566. * @param {Object} config The config.
  567. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  568. * @param {Object} [request] The request.
  569. * @param {Object} [response] The response.
  570. * @returns {Error} The created error.
  571. */
  572. module.exports = function createError(message, config, code, request, response) {
  573. var error = new Error(message);
  574. return enhanceError(error, config, code, request, response);
  575. };
  576. /***/ }),
  577. /***/ "./node_modules/axios/lib/core/dispatchRequest.js":
  578. /*!********************************************************!*\
  579. !*** ./node_modules/axios/lib/core/dispatchRequest.js ***!
  580. \********************************************************/
  581. /*! no static exports found */
  582. /***/ (function(module, exports, __webpack_require__) {
  583. "use strict";
  584. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  585. var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js");
  586. var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  587. var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js");
  588. /**
  589. * Throws a `Cancel` if cancellation has been requested.
  590. */
  591. function throwIfCancellationRequested(config) {
  592. if (config.cancelToken) {
  593. config.cancelToken.throwIfRequested();
  594. }
  595. }
  596. /**
  597. * Dispatch a request to the server using the configured adapter.
  598. *
  599. * @param {object} config The config that is to be used for the request
  600. * @returns {Promise} The Promise to be fulfilled
  601. */
  602. module.exports = function dispatchRequest(config) {
  603. throwIfCancellationRequested(config);
  604. // Ensure headers exist
  605. config.headers = config.headers || {};
  606. // Transform request data
  607. config.data = transformData(
  608. config.data,
  609. config.headers,
  610. config.transformRequest
  611. );
  612. // Flatten headers
  613. config.headers = utils.merge(
  614. config.headers.common || {},
  615. config.headers[config.method] || {},
  616. config.headers
  617. );
  618. utils.forEach(
  619. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  620. function cleanHeaderConfig(method) {
  621. delete config.headers[method];
  622. }
  623. );
  624. var adapter = config.adapter || defaults.adapter;
  625. return adapter(config).then(function onAdapterResolution(response) {
  626. throwIfCancellationRequested(config);
  627. // Transform response data
  628. response.data = transformData(
  629. response.data,
  630. response.headers,
  631. config.transformResponse
  632. );
  633. return response;
  634. }, function onAdapterRejection(reason) {
  635. if (!isCancel(reason)) {
  636. throwIfCancellationRequested(config);
  637. // Transform response data
  638. if (reason && reason.response) {
  639. reason.response.data = transformData(
  640. reason.response.data,
  641. reason.response.headers,
  642. config.transformResponse
  643. );
  644. }
  645. }
  646. return Promise.reject(reason);
  647. });
  648. };
  649. /***/ }),
  650. /***/ "./node_modules/axios/lib/core/enhanceError.js":
  651. /*!*****************************************************!*\
  652. !*** ./node_modules/axios/lib/core/enhanceError.js ***!
  653. \*****************************************************/
  654. /*! no static exports found */
  655. /***/ (function(module, exports, __webpack_require__) {
  656. "use strict";
  657. /**
  658. * Update an Error with the specified config, error code, and response.
  659. *
  660. * @param {Error} error The error to update.
  661. * @param {Object} config The config.
  662. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  663. * @param {Object} [request] The request.
  664. * @param {Object} [response] The response.
  665. * @returns {Error} The error.
  666. */
  667. module.exports = function enhanceError(error, config, code, request, response) {
  668. error.config = config;
  669. if (code) {
  670. error.code = code;
  671. }
  672. error.request = request;
  673. error.response = response;
  674. error.isAxiosError = true;
  675. error.toJSON = function() {
  676. return {
  677. // Standard
  678. message: this.message,
  679. name: this.name,
  680. // Microsoft
  681. description: this.description,
  682. number: this.number,
  683. // Mozilla
  684. fileName: this.fileName,
  685. lineNumber: this.lineNumber,
  686. columnNumber: this.columnNumber,
  687. stack: this.stack,
  688. // Axios
  689. config: this.config,
  690. code: this.code
  691. };
  692. };
  693. return error;
  694. };
  695. /***/ }),
  696. /***/ "./node_modules/axios/lib/core/mergeConfig.js":
  697. /*!****************************************************!*\
  698. !*** ./node_modules/axios/lib/core/mergeConfig.js ***!
  699. \****************************************************/
  700. /*! no static exports found */
  701. /***/ (function(module, exports, __webpack_require__) {
  702. "use strict";
  703. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  704. /**
  705. * Config-specific merge-function which creates a new config-object
  706. * by merging two configuration objects together.
  707. *
  708. * @param {Object} config1
  709. * @param {Object} config2
  710. * @returns {Object} New object resulting from merging config2 to config1
  711. */
  712. module.exports = function mergeConfig(config1, config2) {
  713. // eslint-disable-next-line no-param-reassign
  714. config2 = config2 || {};
  715. var config = {};
  716. var valueFromConfig2Keys = ['url', 'method', 'params', 'data'];
  717. var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy'];
  718. var defaultToConfig2Keys = [
  719. 'baseURL', 'url', 'transformRequest', 'transformResponse', 'paramsSerializer',
  720. 'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
  721. 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress',
  722. 'maxContentLength', 'validateStatus', 'maxRedirects', 'httpAgent',
  723. 'httpsAgent', 'cancelToken', 'socketPath'
  724. ];
  725. utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
  726. if (typeof config2[prop] !== 'undefined') {
  727. config[prop] = config2[prop];
  728. }
  729. });
  730. utils.forEach(mergeDeepPropertiesKeys, function mergeDeepProperties(prop) {
  731. if (utils.isObject(config2[prop])) {
  732. config[prop] = utils.deepMerge(config1[prop], config2[prop]);
  733. } else if (typeof config2[prop] !== 'undefined') {
  734. config[prop] = config2[prop];
  735. } else if (utils.isObject(config1[prop])) {
  736. config[prop] = utils.deepMerge(config1[prop]);
  737. } else if (typeof config1[prop] !== 'undefined') {
  738. config[prop] = config1[prop];
  739. }
  740. });
  741. utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
  742. if (typeof config2[prop] !== 'undefined') {
  743. config[prop] = config2[prop];
  744. } else if (typeof config1[prop] !== 'undefined') {
  745. config[prop] = config1[prop];
  746. }
  747. });
  748. var axiosKeys = valueFromConfig2Keys
  749. .concat(mergeDeepPropertiesKeys)
  750. .concat(defaultToConfig2Keys);
  751. var otherKeys = Object
  752. .keys(config2)
  753. .filter(function filterAxiosKeys(key) {
  754. return axiosKeys.indexOf(key) === -1;
  755. });
  756. utils.forEach(otherKeys, function otherKeysDefaultToConfig2(prop) {
  757. if (typeof config2[prop] !== 'undefined') {
  758. config[prop] = config2[prop];
  759. } else if (typeof config1[prop] !== 'undefined') {
  760. config[prop] = config1[prop];
  761. }
  762. });
  763. return config;
  764. };
  765. /***/ }),
  766. /***/ "./node_modules/axios/lib/core/settle.js":
  767. /*!***********************************************!*\
  768. !*** ./node_modules/axios/lib/core/settle.js ***!
  769. \***********************************************/
  770. /*! no static exports found */
  771. /***/ (function(module, exports, __webpack_require__) {
  772. "use strict";
  773. var createError = __webpack_require__(/*! ./createError */ "./node_modules/axios/lib/core/createError.js");
  774. /**
  775. * Resolve or reject a Promise based on response status.
  776. *
  777. * @param {Function} resolve A function that resolves the promise.
  778. * @param {Function} reject A function that rejects the promise.
  779. * @param {object} response The response.
  780. */
  781. module.exports = function settle(resolve, reject, response) {
  782. var validateStatus = response.config.validateStatus;
  783. if (!validateStatus || validateStatus(response.status)) {
  784. resolve(response);
  785. } else {
  786. reject(createError(
  787. 'Request failed with status code ' + response.status,
  788. response.config,
  789. null,
  790. response.request,
  791. response
  792. ));
  793. }
  794. };
  795. /***/ }),
  796. /***/ "./node_modules/axios/lib/core/transformData.js":
  797. /*!******************************************************!*\
  798. !*** ./node_modules/axios/lib/core/transformData.js ***!
  799. \******************************************************/
  800. /*! no static exports found */
  801. /***/ (function(module, exports, __webpack_require__) {
  802. "use strict";
  803. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  804. /**
  805. * Transform the data for a request or a response
  806. *
  807. * @param {Object|String} data The data to be transformed
  808. * @param {Array} headers The headers for the request or response
  809. * @param {Array|Function} fns A single function or Array of functions
  810. * @returns {*} The resulting transformed data
  811. */
  812. module.exports = function transformData(data, headers, fns) {
  813. /*eslint no-param-reassign:0*/
  814. utils.forEach(fns, function transform(fn) {
  815. data = fn(data, headers);
  816. });
  817. return data;
  818. };
  819. /***/ }),
  820. /***/ "./node_modules/axios/lib/defaults.js":
  821. /*!********************************************!*\
  822. !*** ./node_modules/axios/lib/defaults.js ***!
  823. \********************************************/
  824. /*! no static exports found */
  825. /***/ (function(module, exports, __webpack_require__) {
  826. "use strict";
  827. /* WEBPACK VAR INJECTION */(function(process) {
  828. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  829. var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./node_modules/axios/lib/helpers/normalizeHeaderName.js");
  830. var DEFAULT_CONTENT_TYPE = {
  831. 'Content-Type': 'application/x-www-form-urlencoded'
  832. };
  833. function setContentTypeIfUnset(headers, value) {
  834. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  835. headers['Content-Type'] = value;
  836. }
  837. }
  838. function getDefaultAdapter() {
  839. var adapter;
  840. if (typeof XMLHttpRequest !== 'undefined') {
  841. // For browsers use XHR adapter
  842. adapter = __webpack_require__(/*! ./adapters/xhr */ "./node_modules/axios/lib/adapters/xhr.js");
  843. } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  844. // For node use HTTP adapter
  845. adapter = __webpack_require__(/*! ./adapters/http */ "./node_modules/axios/lib/adapters/xhr.js");
  846. }
  847. return adapter;
  848. }
  849. var defaults = {
  850. adapter: getDefaultAdapter(),
  851. transformRequest: [function transformRequest(data, headers) {
  852. normalizeHeaderName(headers, 'Accept');
  853. normalizeHeaderName(headers, 'Content-Type');
  854. if (utils.isFormData(data) ||
  855. utils.isArrayBuffer(data) ||
  856. utils.isBuffer(data) ||
  857. utils.isStream(data) ||
  858. utils.isFile(data) ||
  859. utils.isBlob(data)
  860. ) {
  861. return data;
  862. }
  863. if (utils.isArrayBufferView(data)) {
  864. return data.buffer;
  865. }
  866. if (utils.isURLSearchParams(data)) {
  867. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  868. return data.toString();
  869. }
  870. if (utils.isObject(data)) {
  871. setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
  872. return JSON.stringify(data);
  873. }
  874. return data;
  875. }],
  876. transformResponse: [function transformResponse(data) {
  877. /*eslint no-param-reassign:0*/
  878. if (typeof data === 'string') {
  879. try {
  880. data = JSON.parse(data);
  881. } catch (e) { /* Ignore */ }
  882. }
  883. return data;
  884. }],
  885. /**
  886. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  887. * timeout is not created.
  888. */
  889. timeout: 0,
  890. xsrfCookieName: 'XSRF-TOKEN',
  891. xsrfHeaderName: 'X-XSRF-TOKEN',
  892. maxContentLength: -1,
  893. validateStatus: function validateStatus(status) {
  894. return status >= 200 && status < 300;
  895. }
  896. };
  897. defaults.headers = {
  898. common: {
  899. 'Accept': 'application/json, text/plain, */*'
  900. }
  901. };
  902. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  903. defaults.headers[method] = {};
  904. });
  905. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  906. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  907. });
  908. module.exports = defaults;
  909. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "./node_modules/process/browser.js")))
  910. /***/ }),
  911. /***/ "./node_modules/axios/lib/helpers/bind.js":
  912. /*!************************************************!*\
  913. !*** ./node_modules/axios/lib/helpers/bind.js ***!
  914. \************************************************/
  915. /*! no static exports found */
  916. /***/ (function(module, exports, __webpack_require__) {
  917. "use strict";
  918. module.exports = function bind(fn, thisArg) {
  919. return function wrap() {
  920. var args = new Array(arguments.length);
  921. for (var i = 0; i < args.length; i++) {
  922. args[i] = arguments[i];
  923. }
  924. return fn.apply(thisArg, args);
  925. };
  926. };
  927. /***/ }),
  928. /***/ "./node_modules/axios/lib/helpers/buildURL.js":
  929. /*!****************************************************!*\
  930. !*** ./node_modules/axios/lib/helpers/buildURL.js ***!
  931. \****************************************************/
  932. /*! no static exports found */
  933. /***/ (function(module, exports, __webpack_require__) {
  934. "use strict";
  935. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  936. function encode(val) {
  937. return encodeURIComponent(val).
  938. replace(/%40/gi, '@').
  939. replace(/%3A/gi, ':').
  940. replace(/%24/g, '$').
  941. replace(/%2C/gi, ',').
  942. replace(/%20/g, '+').
  943. replace(/%5B/gi, '[').
  944. replace(/%5D/gi, ']');
  945. }
  946. /**
  947. * Build a URL by appending params to the end
  948. *
  949. * @param {string} url The base of the url (e.g., http://www.google.com)
  950. * @param {object} [params] The params to be appended
  951. * @returns {string} The formatted url
  952. */
  953. module.exports = function buildURL(url, params, paramsSerializer) {
  954. /*eslint no-param-reassign:0*/
  955. if (!params) {
  956. return url;
  957. }
  958. var serializedParams;
  959. if (paramsSerializer) {
  960. serializedParams = paramsSerializer(params);
  961. } else if (utils.isURLSearchParams(params)) {
  962. serializedParams = params.toString();
  963. } else {
  964. var parts = [];
  965. utils.forEach(params, function serialize(val, key) {
  966. if (val === null || typeof val === 'undefined') {
  967. return;
  968. }
  969. if (utils.isArray(val)) {
  970. key = key + '[]';
  971. } else {
  972. val = [val];
  973. }
  974. utils.forEach(val, function parseValue(v) {
  975. if (utils.isDate(v)) {
  976. v = v.toISOString();
  977. } else if (utils.isObject(v)) {
  978. v = JSON.stringify(v);
  979. }
  980. parts.push(encode(key) + '=' + encode(v));
  981. });
  982. });
  983. serializedParams = parts.join('&');
  984. }
  985. if (serializedParams) {
  986. var hashmarkIndex = url.indexOf('#');
  987. if (hashmarkIndex !== -1) {
  988. url = url.slice(0, hashmarkIndex);
  989. }
  990. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  991. }
  992. return url;
  993. };
  994. /***/ }),
  995. /***/ "./node_modules/axios/lib/helpers/combineURLs.js":
  996. /*!*******************************************************!*\
  997. !*** ./node_modules/axios/lib/helpers/combineURLs.js ***!
  998. \*******************************************************/
  999. /*! no static exports found */
  1000. /***/ (function(module, exports, __webpack_require__) {
  1001. "use strict";
  1002. /**
  1003. * Creates a new URL by combining the specified URLs
  1004. *
  1005. * @param {string} baseURL The base URL
  1006. * @param {string} relativeURL The relative URL
  1007. * @returns {string} The combined URL
  1008. */
  1009. module.exports = function combineURLs(baseURL, relativeURL) {
  1010. return relativeURL
  1011. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  1012. : baseURL;
  1013. };
  1014. /***/ }),
  1015. /***/ "./node_modules/axios/lib/helpers/cookies.js":
  1016. /*!***************************************************!*\
  1017. !*** ./node_modules/axios/lib/helpers/cookies.js ***!
  1018. \***************************************************/
  1019. /*! no static exports found */
  1020. /***/ (function(module, exports, __webpack_require__) {
  1021. "use strict";
  1022. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1023. module.exports = (
  1024. utils.isStandardBrowserEnv() ?
  1025. // Standard browser envs support document.cookie
  1026. (function standardBrowserEnv() {
  1027. return {
  1028. write: function write(name, value, expires, path, domain, secure) {
  1029. var cookie = [];
  1030. cookie.push(name + '=' + encodeURIComponent(value));
  1031. if (utils.isNumber(expires)) {
  1032. cookie.push('expires=' + new Date(expires).toGMTString());
  1033. }
  1034. if (utils.isString(path)) {
  1035. cookie.push('path=' + path);
  1036. }
  1037. if (utils.isString(domain)) {
  1038. cookie.push('domain=' + domain);
  1039. }
  1040. if (secure === true) {
  1041. cookie.push('secure');
  1042. }
  1043. document.cookie = cookie.join('; ');
  1044. },
  1045. read: function read(name) {
  1046. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  1047. return (match ? decodeURIComponent(match[3]) : null);
  1048. },
  1049. remove: function remove(name) {
  1050. this.write(name, '', Date.now() - 86400000);
  1051. }
  1052. };
  1053. })() :
  1054. // Non standard browser env (web workers, react-native) lack needed support.
  1055. (function nonStandardBrowserEnv() {
  1056. return {
  1057. write: function write() {},
  1058. read: function read() { return null; },
  1059. remove: function remove() {}
  1060. };
  1061. })()
  1062. );
  1063. /***/ }),
  1064. /***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js":
  1065. /*!*********************************************************!*\
  1066. !*** ./node_modules/axios/lib/helpers/isAbsoluteURL.js ***!
  1067. \*********************************************************/
  1068. /*! no static exports found */
  1069. /***/ (function(module, exports, __webpack_require__) {
  1070. "use strict";
  1071. /**
  1072. * Determines whether the specified URL is absolute
  1073. *
  1074. * @param {string} url The URL to test
  1075. * @returns {boolean} True if the specified URL is absolute, otherwise false
  1076. */
  1077. module.exports = function isAbsoluteURL(url) {
  1078. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  1079. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  1080. // by any combination of letters, digits, plus, period, or hyphen.
  1081. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
  1082. };
  1083. /***/ }),
  1084. /***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js":
  1085. /*!***********************************************************!*\
  1086. !*** ./node_modules/axios/lib/helpers/isURLSameOrigin.js ***!
  1087. \***********************************************************/
  1088. /*! no static exports found */
  1089. /***/ (function(module, exports, __webpack_require__) {
  1090. "use strict";
  1091. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1092. module.exports = (
  1093. utils.isStandardBrowserEnv() ?
  1094. // Standard browser envs have full support of the APIs needed to test
  1095. // whether the request URL is of the same origin as current location.
  1096. (function standardBrowserEnv() {
  1097. var msie = /(msie|trident)/i.test(navigator.userAgent);
  1098. var urlParsingNode = document.createElement('a');
  1099. var originURL;
  1100. /**
  1101. * Parse a URL to discover it's components
  1102. *
  1103. * @param {String} url The URL to be parsed
  1104. * @returns {Object}
  1105. */
  1106. function resolveURL(url) {
  1107. var href = url;
  1108. if (msie) {
  1109. // IE needs attribute set twice to normalize properties
  1110. urlParsingNode.setAttribute('href', href);
  1111. href = urlParsingNode.href;
  1112. }
  1113. urlParsingNode.setAttribute('href', href);
  1114. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  1115. return {
  1116. href: urlParsingNode.href,
  1117. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  1118. host: urlParsingNode.host,
  1119. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  1120. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  1121. hostname: urlParsingNode.hostname,
  1122. port: urlParsingNode.port,
  1123. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  1124. urlParsingNode.pathname :
  1125. '/' + urlParsingNode.pathname
  1126. };
  1127. }
  1128. originURL = resolveURL(window.location.href);
  1129. /**
  1130. * Determine if a URL shares the same origin as the current location
  1131. *
  1132. * @param {String} requestURL The URL to test
  1133. * @returns {boolean} True if URL shares the same origin, otherwise false
  1134. */
  1135. return function isURLSameOrigin(requestURL) {
  1136. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  1137. return (parsed.protocol === originURL.protocol &&
  1138. parsed.host === originURL.host);
  1139. };
  1140. })() :
  1141. // Non standard browser envs (web workers, react-native) lack needed support.
  1142. (function nonStandardBrowserEnv() {
  1143. return function isURLSameOrigin() {
  1144. return true;
  1145. };
  1146. })()
  1147. );
  1148. /***/ }),
  1149. /***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js":
  1150. /*!***************************************************************!*\
  1151. !*** ./node_modules/axios/lib/helpers/normalizeHeaderName.js ***!
  1152. \***************************************************************/
  1153. /*! no static exports found */
  1154. /***/ (function(module, exports, __webpack_require__) {
  1155. "use strict";
  1156. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  1157. module.exports = function normalizeHeaderName(headers, normalizedName) {
  1158. utils.forEach(headers, function processHeader(value, name) {
  1159. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  1160. headers[normalizedName] = value;
  1161. delete headers[name];
  1162. }
  1163. });
  1164. };
  1165. /***/ }),
  1166. /***/ "./node_modules/axios/lib/helpers/parseHeaders.js":
  1167. /*!********************************************************!*\
  1168. !*** ./node_modules/axios/lib/helpers/parseHeaders.js ***!
  1169. \********************************************************/
  1170. /*! no static exports found */
  1171. /***/ (function(module, exports, __webpack_require__) {
  1172. "use strict";
  1173. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1174. // Headers whose duplicates are ignored by node
  1175. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1176. var ignoreDuplicateOf = [
  1177. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  1178. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  1179. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  1180. 'referer', 'retry-after', 'user-agent'
  1181. ];
  1182. /**
  1183. * Parse headers into an object
  1184. *
  1185. * ```
  1186. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1187. * Content-Type: application/json
  1188. * Connection: keep-alive
  1189. * Transfer-Encoding: chunked
  1190. * ```
  1191. *
  1192. * @param {String} headers Headers needing to be parsed
  1193. * @returns {Object} Headers parsed into an object
  1194. */
  1195. module.exports = function parseHeaders(headers) {
  1196. var parsed = {};
  1197. var key;
  1198. var val;
  1199. var i;
  1200. if (!headers) { return parsed; }
  1201. utils.forEach(headers.split('\n'), function parser(line) {
  1202. i = line.indexOf(':');
  1203. key = utils.trim(line.substr(0, i)).toLowerCase();
  1204. val = utils.trim(line.substr(i + 1));
  1205. if (key) {
  1206. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  1207. return;
  1208. }
  1209. if (key === 'set-cookie') {
  1210. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  1211. } else {
  1212. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1213. }
  1214. }
  1215. });
  1216. return parsed;
  1217. };
  1218. /***/ }),
  1219. /***/ "./node_modules/axios/lib/helpers/spread.js":
  1220. /*!**************************************************!*\
  1221. !*** ./node_modules/axios/lib/helpers/spread.js ***!
  1222. \**************************************************/
  1223. /*! no static exports found */
  1224. /***/ (function(module, exports, __webpack_require__) {
  1225. "use strict";
  1226. /**
  1227. * Syntactic sugar for invoking a function and expanding an array for arguments.
  1228. *
  1229. * Common use case would be to use `Function.prototype.apply`.
  1230. *
  1231. * ```js
  1232. * function f(x, y, z) {}
  1233. * var args = [1, 2, 3];
  1234. * f.apply(null, args);
  1235. * ```
  1236. *
  1237. * With `spread` this example can be re-written.
  1238. *
  1239. * ```js
  1240. * spread(function(x, y, z) {})([1, 2, 3]);
  1241. * ```
  1242. *
  1243. * @param {Function} callback
  1244. * @returns {Function}
  1245. */
  1246. module.exports = function spread(callback) {
  1247. return function wrap(arr) {
  1248. return callback.apply(null, arr);
  1249. };
  1250. };
  1251. /***/ }),
  1252. /***/ "./node_modules/axios/lib/utils.js":
  1253. /*!*****************************************!*\
  1254. !*** ./node_modules/axios/lib/utils.js ***!
  1255. \*****************************************/
  1256. /*! no static exports found */
  1257. /***/ (function(module, exports, __webpack_require__) {
  1258. "use strict";
  1259. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  1260. /*global toString:true*/
  1261. // utils is a library of generic helper functions non-specific to axios
  1262. var toString = Object.prototype.toString;
  1263. /**
  1264. * Determine if a value is an Array
  1265. *
  1266. * @param {Object} val The value to test
  1267. * @returns {boolean} True if value is an Array, otherwise false
  1268. */
  1269. function isArray(val) {
  1270. return toString.call(val) === '[object Array]';
  1271. }
  1272. /**
  1273. * Determine if a value is undefined
  1274. *
  1275. * @param {Object} val The value to test
  1276. * @returns {boolean} True if the value is undefined, otherwise false
  1277. */
  1278. function isUndefined(val) {
  1279. return typeof val === 'undefined';
  1280. }
  1281. /**
  1282. * Determine if a value is a Buffer
  1283. *
  1284. * @param {Object} val The value to test
  1285. * @returns {boolean} True if value is a Buffer, otherwise false
  1286. */
  1287. function isBuffer(val) {
  1288. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  1289. && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
  1290. }
  1291. /**
  1292. * Determine if a value is an ArrayBuffer
  1293. *
  1294. * @param {Object} val The value to test
  1295. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  1296. */
  1297. function isArrayBuffer(val) {
  1298. return toString.call(val) === '[object ArrayBuffer]';
  1299. }
  1300. /**
  1301. * Determine if a value is a FormData
  1302. *
  1303. * @param {Object} val The value to test
  1304. * @returns {boolean} True if value is an FormData, otherwise false
  1305. */
  1306. function isFormData(val) {
  1307. return (typeof FormData !== 'undefined') && (val instanceof FormData);
  1308. }
  1309. /**
  1310. * Determine if a value is a view on an ArrayBuffer
  1311. *
  1312. * @param {Object} val The value to test
  1313. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  1314. */
  1315. function isArrayBufferView(val) {
  1316. var result;
  1317. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  1318. result = ArrayBuffer.isView(val);
  1319. } else {
  1320. result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
  1321. }
  1322. return result;
  1323. }
  1324. /**
  1325. * Determine if a value is a String
  1326. *
  1327. * @param {Object} val The value to test
  1328. * @returns {boolean} True if value is a String, otherwise false
  1329. */
  1330. function isString(val) {
  1331. return typeof val === 'string';
  1332. }
  1333. /**
  1334. * Determine if a value is a Number
  1335. *
  1336. * @param {Object} val The value to test
  1337. * @returns {boolean} True if value is a Number, otherwise false
  1338. */
  1339. function isNumber(val) {
  1340. return typeof val === 'number';
  1341. }
  1342. /**
  1343. * Determine if a value is an Object
  1344. *
  1345. * @param {Object} val The value to test
  1346. * @returns {boolean} True if value is an Object, otherwise false
  1347. */
  1348. function isObject(val) {
  1349. return val !== null && typeof val === 'object';
  1350. }
  1351. /**
  1352. * Determine if a value is a Date
  1353. *
  1354. * @param {Object} val The value to test
  1355. * @returns {boolean} True if value is a Date, otherwise false
  1356. */
  1357. function isDate(val) {
  1358. return toString.call(val) === '[object Date]';
  1359. }
  1360. /**
  1361. * Determine if a value is a File
  1362. *
  1363. * @param {Object} val The value to test
  1364. * @returns {boolean} True if value is a File, otherwise false
  1365. */
  1366. function isFile(val) {
  1367. return toString.call(val) === '[object File]';
  1368. }
  1369. /**
  1370. * Determine if a value is a Blob
  1371. *
  1372. * @param {Object} val The value to test
  1373. * @returns {boolean} True if value is a Blob, otherwise false
  1374. */
  1375. function isBlob(val) {
  1376. return toString.call(val) === '[object Blob]';
  1377. }
  1378. /**
  1379. * Determine if a value is a Function
  1380. *
  1381. * @param {Object} val The value to test
  1382. * @returns {boolean} True if value is a Function, otherwise false
  1383. */
  1384. function isFunction(val) {
  1385. return toString.call(val) === '[object Function]';
  1386. }
  1387. /**
  1388. * Determine if a value is a Stream
  1389. *
  1390. * @param {Object} val The value to test
  1391. * @returns {boolean} True if value is a Stream, otherwise false
  1392. */
  1393. function isStream(val) {
  1394. return isObject(val) && isFunction(val.pipe);
  1395. }
  1396. /**
  1397. * Determine if a value is a URLSearchParams object
  1398. *
  1399. * @param {Object} val The value to test
  1400. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  1401. */
  1402. function isURLSearchParams(val) {
  1403. return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
  1404. }
  1405. /**
  1406. * Trim excess whitespace off the beginning and end of a string
  1407. *
  1408. * @param {String} str The String to trim
  1409. * @returns {String} The String freed of excess whitespace
  1410. */
  1411. function trim(str) {
  1412. return str.replace(/^\s*/, '').replace(/\s*$/, '');
  1413. }
  1414. /**
  1415. * Determine if we're running in a standard browser environment
  1416. *
  1417. * This allows axios to run in a web worker, and react-native.
  1418. * Both environments support XMLHttpRequest, but not fully standard globals.
  1419. *
  1420. * web workers:
  1421. * typeof window -> undefined
  1422. * typeof document -> undefined
  1423. *
  1424. * react-native:
  1425. * navigator.product -> 'ReactNative'
  1426. * nativescript
  1427. * navigator.product -> 'NativeScript' or 'NS'
  1428. */
  1429. function isStandardBrowserEnv() {
  1430. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  1431. navigator.product === 'NativeScript' ||
  1432. navigator.product === 'NS')) {
  1433. return false;
  1434. }
  1435. return (
  1436. typeof window !== 'undefined' &&
  1437. typeof document !== 'undefined'
  1438. );
  1439. }
  1440. /**
  1441. * Iterate over an Array or an Object invoking a function for each item.
  1442. *
  1443. * If `obj` is an Array callback will be called passing
  1444. * the value, index, and complete array for each item.
  1445. *
  1446. * If 'obj' is an Object callback will be called passing
  1447. * the value, key, and complete object for each property.
  1448. *
  1449. * @param {Object|Array} obj The object to iterate
  1450. * @param {Function} fn The callback to invoke for each item
  1451. */
  1452. function forEach(obj, fn) {
  1453. // Don't bother if no value provided
  1454. if (obj === null || typeof obj === 'undefined') {
  1455. return;
  1456. }
  1457. // Force an array if not already something iterable
  1458. if (typeof obj !== 'object') {
  1459. /*eslint no-param-reassign:0*/
  1460. obj = [obj];
  1461. }
  1462. if (isArray(obj)) {
  1463. // Iterate over array values
  1464. for (var i = 0, l = obj.length; i < l; i++) {
  1465. fn.call(null, obj[i], i, obj);
  1466. }
  1467. } else {
  1468. // Iterate over object keys
  1469. for (var key in obj) {
  1470. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  1471. fn.call(null, obj[key], key, obj);
  1472. }
  1473. }
  1474. }
  1475. }
  1476. /**
  1477. * Accepts varargs expecting each argument to be an object, then
  1478. * immutably merges the properties of each object and returns result.
  1479. *
  1480. * When multiple objects contain the same key the later object in
  1481. * the arguments list will take precedence.
  1482. *
  1483. * Example:
  1484. *
  1485. * ```js
  1486. * var result = merge({foo: 123}, {foo: 456});
  1487. * console.log(result.foo); // outputs 456
  1488. * ```
  1489. *
  1490. * @param {Object} obj1 Object to merge
  1491. * @returns {Object} Result of all merge properties
  1492. */
  1493. function merge(/* obj1, obj2, obj3, ... */) {
  1494. var result = {};
  1495. function assignValue(val, key) {
  1496. if (typeof result[key] === 'object' && typeof val === 'object') {
  1497. result[key] = merge(result[key], val);
  1498. } else {
  1499. result[key] = val;
  1500. }
  1501. }
  1502. for (var i = 0, l = arguments.length; i < l; i++) {
  1503. forEach(arguments[i], assignValue);
  1504. }
  1505. return result;
  1506. }
  1507. /**
  1508. * Function equal to merge with the difference being that no reference
  1509. * to original objects is kept.
  1510. *
  1511. * @see merge
  1512. * @param {Object} obj1 Object to merge
  1513. * @returns {Object} Result of all merge properties
  1514. */
  1515. function deepMerge(/* obj1, obj2, obj3, ... */) {
  1516. var result = {};
  1517. function assignValue(val, key) {
  1518. if (typeof result[key] === 'object' && typeof val === 'object') {
  1519. result[key] = deepMerge(result[key], val);
  1520. } else if (typeof val === 'object') {
  1521. result[key] = deepMerge({}, val);
  1522. } else {
  1523. result[key] = val;
  1524. }
  1525. }
  1526. for (var i = 0, l = arguments.length; i < l; i++) {
  1527. forEach(arguments[i], assignValue);
  1528. }
  1529. return result;
  1530. }
  1531. /**
  1532. * Extends object a by mutably adding to it the properties of object b.
  1533. *
  1534. * @param {Object} a The object to be extended
  1535. * @param {Object} b The object to copy properties from
  1536. * @param {Object} thisArg The object to bind function to
  1537. * @return {Object} The resulting value of object a
  1538. */
  1539. function extend(a, b, thisArg) {
  1540. forEach(b, function assignValue(val, key) {
  1541. if (thisArg && typeof val === 'function') {
  1542. a[key] = bind(val, thisArg);
  1543. } else {
  1544. a[key] = val;
  1545. }
  1546. });
  1547. return a;
  1548. }
  1549. module.exports = {
  1550. isArray: isArray,
  1551. isArrayBuffer: isArrayBuffer,
  1552. isBuffer: isBuffer,
  1553. isFormData: isFormData,
  1554. isArrayBufferView: isArrayBufferView,
  1555. isString: isString,
  1556. isNumber: isNumber,
  1557. isObject: isObject,
  1558. isUndefined: isUndefined,
  1559. isDate: isDate,
  1560. isFile: isFile,
  1561. isBlob: isBlob,
  1562. isFunction: isFunction,
  1563. isStream: isStream,
  1564. isURLSearchParams: isURLSearchParams,
  1565. isStandardBrowserEnv: isStandardBrowserEnv,
  1566. forEach: forEach,
  1567. merge: merge,
  1568. deepMerge: deepMerge,
  1569. extend: extend,
  1570. trim: trim
  1571. };
  1572. /***/ }),
  1573. /***/ "./node_modules/bootstrap/dist/js/bootstrap.js":
  1574. /*!*****************************************************!*\
  1575. !*** ./node_modules/bootstrap/dist/js/bootstrap.js ***!
  1576. \*****************************************************/
  1577. /*! no static exports found */
  1578. /***/ (function(module, exports, __webpack_require__) {
  1579. /*!
  1580. * Bootstrap v4.5.0 (https://getbootstrap.com/)
  1581. * Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  1582. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1583. */
  1584. (function (global, factory) {
  1585. true ? factory(exports, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"), __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")) :
  1586. undefined;
  1587. }(this, (function (exports, $, Popper) { 'use strict';
  1588. $ = $ && Object.prototype.hasOwnProperty.call($, 'default') ? $['default'] : $;
  1589. Popper = Popper && Object.prototype.hasOwnProperty.call(Popper, 'default') ? Popper['default'] : Popper;
  1590. function _defineProperties(target, props) {
  1591. for (var i = 0; i < props.length; i++) {
  1592. var descriptor = props[i];
  1593. descriptor.enumerable = descriptor.enumerable || false;
  1594. descriptor.configurable = true;
  1595. if ("value" in descriptor) descriptor.writable = true;
  1596. Object.defineProperty(target, descriptor.key, descriptor);
  1597. }
  1598. }
  1599. function _createClass(Constructor, protoProps, staticProps) {
  1600. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  1601. if (staticProps) _defineProperties(Constructor, staticProps);
  1602. return Constructor;
  1603. }
  1604. function _defineProperty(obj, key, value) {
  1605. if (key in obj) {
  1606. Object.defineProperty(obj, key, {
  1607. value: value,
  1608. enumerable: true,
  1609. configurable: true,
  1610. writable: true
  1611. });
  1612. } else {
  1613. obj[key] = value;
  1614. }
  1615. return obj;
  1616. }
  1617. function ownKeys(object, enumerableOnly) {
  1618. var keys = Object.keys(object);
  1619. if (Object.getOwnPropertySymbols) {
  1620. var symbols = Object.getOwnPropertySymbols(object);
  1621. if (enumerableOnly) symbols = symbols.filter(function (sym) {
  1622. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  1623. });
  1624. keys.push.apply(keys, symbols);
  1625. }
  1626. return keys;
  1627. }
  1628. function _objectSpread2(target) {
  1629. for (var i = 1; i < arguments.length; i++) {
  1630. var source = arguments[i] != null ? arguments[i] : {};
  1631. if (i % 2) {
  1632. ownKeys(Object(source), true).forEach(function (key) {
  1633. _defineProperty(target, key, source[key]);
  1634. });
  1635. } else if (Object.getOwnPropertyDescriptors) {
  1636. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  1637. } else {
  1638. ownKeys(Object(source)).forEach(function (key) {
  1639. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  1640. });
  1641. }
  1642. }
  1643. return target;
  1644. }
  1645. function _inheritsLoose(subClass, superClass) {
  1646. subClass.prototype = Object.create(superClass.prototype);
  1647. subClass.prototype.constructor = subClass;
  1648. subClass.__proto__ = superClass;
  1649. }
  1650. /**
  1651. * --------------------------------------------------------------------------
  1652. * Bootstrap (v4.5.0): util.js
  1653. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1654. * --------------------------------------------------------------------------
  1655. */
  1656. /**
  1657. * ------------------------------------------------------------------------
  1658. * Private TransitionEnd Helpers
  1659. * ------------------------------------------------------------------------
  1660. */
  1661. var TRANSITION_END = 'transitionend';
  1662. var MAX_UID = 1000000;
  1663. var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
  1664. function toType(obj) {
  1665. if (obj === null || typeof obj === 'undefined') {
  1666. return "" + obj;
  1667. }
  1668. return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
  1669. }
  1670. function getSpecialTransitionEndEvent() {
  1671. return {
  1672. bindType: TRANSITION_END,
  1673. delegateType: TRANSITION_END,
  1674. handle: function handle(event) {
  1675. if ($(event.target).is(this)) {
  1676. return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
  1677. }
  1678. return undefined;
  1679. }
  1680. };
  1681. }
  1682. function transitionEndEmulator(duration) {
  1683. var _this = this;
  1684. var called = false;
  1685. $(this).one(Util.TRANSITION_END, function () {
  1686. called = true;
  1687. });
  1688. setTimeout(function () {
  1689. if (!called) {
  1690. Util.triggerTransitionEnd(_this);
  1691. }
  1692. }, duration);
  1693. return this;
  1694. }
  1695. function setTransitionEndSupport() {
  1696. $.fn.emulateTransitionEnd = transitionEndEmulator;
  1697. $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
  1698. }
  1699. /**
  1700. * --------------------------------------------------------------------------
  1701. * Public Util Api
  1702. * --------------------------------------------------------------------------
  1703. */
  1704. var Util = {
  1705. TRANSITION_END: 'bsTransitionEnd',
  1706. getUID: function getUID(prefix) {
  1707. do {
  1708. // eslint-disable-next-line no-bitwise
  1709. prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
  1710. } while (document.getElementById(prefix));
  1711. return prefix;
  1712. },
  1713. getSelectorFromElement: function getSelectorFromElement(element) {
  1714. var selector = element.getAttribute('data-target');
  1715. if (!selector || selector === '#') {
  1716. var hrefAttr = element.getAttribute('href');
  1717. selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : '';
  1718. }
  1719. try {
  1720. return document.querySelector(selector) ? selector : null;
  1721. } catch (err) {
  1722. return null;
  1723. }
  1724. },
  1725. getTransitionDurationFromElement: function getTransitionDurationFromElement(element) {
  1726. if (!element) {
  1727. return 0;
  1728. } // Get transition-duration of the element
  1729. var transitionDuration = $(element).css('transition-duration');
  1730. var transitionDelay = $(element).css('transition-delay');
  1731. var floatTransitionDuration = parseFloat(transitionDuration);
  1732. var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
  1733. if (!floatTransitionDuration && !floatTransitionDelay) {
  1734. return 0;
  1735. } // If multiple durations are defined, take the first
  1736. transitionDuration = transitionDuration.split(',')[0];
  1737. transitionDelay = transitionDelay.split(',')[0];
  1738. return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  1739. },
  1740. reflow: function reflow(element) {
  1741. return element.offsetHeight;
  1742. },
  1743. triggerTransitionEnd: function triggerTransitionEnd(element) {
  1744. $(element).trigger(TRANSITION_END);
  1745. },
  1746. // TODO: Remove in v5
  1747. supportsTransitionEnd: function supportsTransitionEnd() {
  1748. return Boolean(TRANSITION_END);
  1749. },
  1750. isElement: function isElement(obj) {
  1751. return (obj[0] || obj).nodeType;
  1752. },
  1753. typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
  1754. for (var property in configTypes) {
  1755. if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
  1756. var expectedTypes = configTypes[property];
  1757. var value = config[property];
  1758. var valueType = value && Util.isElement(value) ? 'element' : toType(value);
  1759. if (!new RegExp(expectedTypes).test(valueType)) {
  1760. throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
  1761. }
  1762. }
  1763. }
  1764. },
  1765. findShadowRoot: function findShadowRoot(element) {
  1766. if (!document.documentElement.attachShadow) {
  1767. return null;
  1768. } // Can find the shadow root otherwise it'll return the document
  1769. if (typeof element.getRootNode === 'function') {
  1770. var root = element.getRootNode();
  1771. return root instanceof ShadowRoot ? root : null;
  1772. }
  1773. if (element instanceof ShadowRoot) {
  1774. return element;
  1775. } // when we don't find a shadow root
  1776. if (!element.parentNode) {
  1777. return null;
  1778. }
  1779. return Util.findShadowRoot(element.parentNode);
  1780. },
  1781. jQueryDetection: function jQueryDetection() {
  1782. if (typeof $ === 'undefined') {
  1783. throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.');
  1784. }
  1785. var version = $.fn.jquery.split(' ')[0].split('.');
  1786. var minMajor = 1;
  1787. var ltMajor = 2;
  1788. var minMinor = 9;
  1789. var minPatch = 1;
  1790. var maxMajor = 4;
  1791. if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) {
  1792. throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0');
  1793. }
  1794. }
  1795. };
  1796. Util.jQueryDetection();
  1797. setTransitionEndSupport();
  1798. /**
  1799. * ------------------------------------------------------------------------
  1800. * Constants
  1801. * ------------------------------------------------------------------------
  1802. */
  1803. var NAME = 'alert';
  1804. var VERSION = '4.5.0';
  1805. var DATA_KEY = 'bs.alert';
  1806. var EVENT_KEY = "." + DATA_KEY;
  1807. var DATA_API_KEY = '.data-api';
  1808. var JQUERY_NO_CONFLICT = $.fn[NAME];
  1809. var SELECTOR_DISMISS = '[data-dismiss="alert"]';
  1810. var EVENT_CLOSE = "close" + EVENT_KEY;
  1811. var EVENT_CLOSED = "closed" + EVENT_KEY;
  1812. var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY;
  1813. var CLASS_NAME_ALERT = 'alert';
  1814. var CLASS_NAME_FADE = 'fade';
  1815. var CLASS_NAME_SHOW = 'show';
  1816. /**
  1817. * ------------------------------------------------------------------------
  1818. * Class Definition
  1819. * ------------------------------------------------------------------------
  1820. */
  1821. var Alert = /*#__PURE__*/function () {
  1822. function Alert(element) {
  1823. this._element = element;
  1824. } // Getters
  1825. var _proto = Alert.prototype;
  1826. // Public
  1827. _proto.close = function close(element) {
  1828. var rootElement = this._element;
  1829. if (element) {
  1830. rootElement = this._getRootElement(element);
  1831. }
  1832. var customEvent = this._triggerCloseEvent(rootElement);
  1833. if (customEvent.isDefaultPrevented()) {
  1834. return;
  1835. }
  1836. this._removeElement(rootElement);
  1837. };
  1838. _proto.dispose = function dispose() {
  1839. $.removeData(this._element, DATA_KEY);
  1840. this._element = null;
  1841. } // Private
  1842. ;
  1843. _proto._getRootElement = function _getRootElement(element) {
  1844. var selector = Util.getSelectorFromElement(element);
  1845. var parent = false;
  1846. if (selector) {
  1847. parent = document.querySelector(selector);
  1848. }
  1849. if (!parent) {
  1850. parent = $(element).closest("." + CLASS_NAME_ALERT)[0];
  1851. }
  1852. return parent;
  1853. };
  1854. _proto._triggerCloseEvent = function _triggerCloseEvent(element) {
  1855. var closeEvent = $.Event(EVENT_CLOSE);
  1856. $(element).trigger(closeEvent);
  1857. return closeEvent;
  1858. };
  1859. _proto._removeElement = function _removeElement(element) {
  1860. var _this = this;
  1861. $(element).removeClass(CLASS_NAME_SHOW);
  1862. if (!$(element).hasClass(CLASS_NAME_FADE)) {
  1863. this._destroyElement(element);
  1864. return;
  1865. }
  1866. var transitionDuration = Util.getTransitionDurationFromElement(element);
  1867. $(element).one(Util.TRANSITION_END, function (event) {
  1868. return _this._destroyElement(element, event);
  1869. }).emulateTransitionEnd(transitionDuration);
  1870. };
  1871. _proto._destroyElement = function _destroyElement(element) {
  1872. $(element).detach().trigger(EVENT_CLOSED).remove();
  1873. } // Static
  1874. ;
  1875. Alert._jQueryInterface = function _jQueryInterface(config) {
  1876. return this.each(function () {
  1877. var $element = $(this);
  1878. var data = $element.data(DATA_KEY);
  1879. if (!data) {
  1880. data = new Alert(this);
  1881. $element.data(DATA_KEY, data);
  1882. }
  1883. if (config === 'close') {
  1884. data[config](this);
  1885. }
  1886. });
  1887. };
  1888. Alert._handleDismiss = function _handleDismiss(alertInstance) {
  1889. return function (event) {
  1890. if (event) {
  1891. event.preventDefault();
  1892. }
  1893. alertInstance.close(this);
  1894. };
  1895. };
  1896. _createClass(Alert, null, [{
  1897. key: "VERSION",
  1898. get: function get() {
  1899. return VERSION;
  1900. }
  1901. }]);
  1902. return Alert;
  1903. }();
  1904. /**
  1905. * ------------------------------------------------------------------------
  1906. * Data Api implementation
  1907. * ------------------------------------------------------------------------
  1908. */
  1909. $(document).on(EVENT_CLICK_DATA_API, SELECTOR_DISMISS, Alert._handleDismiss(new Alert()));
  1910. /**
  1911. * ------------------------------------------------------------------------
  1912. * jQuery
  1913. * ------------------------------------------------------------------------
  1914. */
  1915. $.fn[NAME] = Alert._jQueryInterface;
  1916. $.fn[NAME].Constructor = Alert;
  1917. $.fn[NAME].noConflict = function () {
  1918. $.fn[NAME] = JQUERY_NO_CONFLICT;
  1919. return Alert._jQueryInterface;
  1920. };
  1921. /**
  1922. * ------------------------------------------------------------------------
  1923. * Constants
  1924. * ------------------------------------------------------------------------
  1925. */
  1926. var NAME$1 = 'button';
  1927. var VERSION$1 = '4.5.0';
  1928. var DATA_KEY$1 = 'bs.button';
  1929. var EVENT_KEY$1 = "." + DATA_KEY$1;
  1930. var DATA_API_KEY$1 = '.data-api';
  1931. var JQUERY_NO_CONFLICT$1 = $.fn[NAME$1];
  1932. var CLASS_NAME_ACTIVE = 'active';
  1933. var CLASS_NAME_BUTTON = 'btn';
  1934. var CLASS_NAME_FOCUS = 'focus';
  1935. var SELECTOR_DATA_TOGGLE_CARROT = '[data-toggle^="button"]';
  1936. var SELECTOR_DATA_TOGGLES = '[data-toggle="buttons"]';
  1937. var SELECTOR_DATA_TOGGLE = '[data-toggle="button"]';
  1938. var SELECTOR_DATA_TOGGLES_BUTTONS = '[data-toggle="buttons"] .btn';
  1939. var SELECTOR_INPUT = 'input:not([type="hidden"])';
  1940. var SELECTOR_ACTIVE = '.active';
  1941. var SELECTOR_BUTTON = '.btn';
  1942. var EVENT_CLICK_DATA_API$1 = "click" + EVENT_KEY$1 + DATA_API_KEY$1;
  1943. var EVENT_FOCUS_BLUR_DATA_API = "focus" + EVENT_KEY$1 + DATA_API_KEY$1 + " " + ("blur" + EVENT_KEY$1 + DATA_API_KEY$1);
  1944. var EVENT_LOAD_DATA_API = "load" + EVENT_KEY$1 + DATA_API_KEY$1;
  1945. /**
  1946. * ------------------------------------------------------------------------
  1947. * Class Definition
  1948. * ------------------------------------------------------------------------
  1949. */
  1950. var Button = /*#__PURE__*/function () {
  1951. function Button(element) {
  1952. this._element = element;
  1953. } // Getters
  1954. var _proto = Button.prototype;
  1955. // Public
  1956. _proto.toggle = function toggle() {
  1957. var triggerChangeEvent = true;
  1958. var addAriaPressed = true;
  1959. var rootElement = $(this._element).closest(SELECTOR_DATA_TOGGLES)[0];
  1960. if (rootElement) {
  1961. var input = this._element.querySelector(SELECTOR_INPUT);
  1962. if (input) {
  1963. if (input.type === 'radio') {
  1964. if (input.checked && this._element.classList.contains(CLASS_NAME_ACTIVE)) {
  1965. triggerChangeEvent = false;
  1966. } else {
  1967. var activeElement = rootElement.querySelector(SELECTOR_ACTIVE);
  1968. if (activeElement) {
  1969. $(activeElement).removeClass(CLASS_NAME_ACTIVE);
  1970. }
  1971. }
  1972. }
  1973. if (triggerChangeEvent) {
  1974. // if it's not a radio button or checkbox don't add a pointless/invalid checked property to the input
  1975. if (input.type === 'checkbox' || input.type === 'radio') {
  1976. input.checked = !this._element.classList.contains(CLASS_NAME_ACTIVE);
  1977. }
  1978. $(input).trigger('change');
  1979. }
  1980. input.focus();
  1981. addAriaPressed = false;
  1982. }
  1983. }
  1984. if (!(this._element.hasAttribute('disabled') || this._element.classList.contains('disabled'))) {
  1985. if (addAriaPressed) {
  1986. this._element.setAttribute('aria-pressed', !this._element.classList.contains(CLASS_NAME_ACTIVE));
  1987. }
  1988. if (triggerChangeEvent) {
  1989. $(this._element).toggleClass(CLASS_NAME_ACTIVE);
  1990. }
  1991. }
  1992. };
  1993. _proto.dispose = function dispose() {
  1994. $.removeData(this._element, DATA_KEY$1);
  1995. this._element = null;
  1996. } // Static
  1997. ;
  1998. Button._jQueryInterface = function _jQueryInterface(config) {
  1999. return this.each(function () {
  2000. var data = $(this).data(DATA_KEY$1);
  2001. if (!data) {
  2002. data = new Button(this);
  2003. $(this).data(DATA_KEY$1, data);
  2004. }
  2005. if (config === 'toggle') {
  2006. data[config]();
  2007. }
  2008. });
  2009. };
  2010. _createClass(Button, null, [{
  2011. key: "VERSION",
  2012. get: function get() {
  2013. return VERSION$1;
  2014. }
  2015. }]);
  2016. return Button;
  2017. }();
  2018. /**
  2019. * ------------------------------------------------------------------------
  2020. * Data Api implementation
  2021. * ------------------------------------------------------------------------
  2022. */
  2023. $(document).on(EVENT_CLICK_DATA_API$1, SELECTOR_DATA_TOGGLE_CARROT, function (event) {
  2024. var button = event.target;
  2025. var initialButton = button;
  2026. if (!$(button).hasClass(CLASS_NAME_BUTTON)) {
  2027. button = $(button).closest(SELECTOR_BUTTON)[0];
  2028. }
  2029. if (!button || button.hasAttribute('disabled') || button.classList.contains('disabled')) {
  2030. event.preventDefault(); // work around Firefox bug #1540995
  2031. } else {
  2032. var inputBtn = button.querySelector(SELECTOR_INPUT);
  2033. if (inputBtn && (inputBtn.hasAttribute('disabled') || inputBtn.classList.contains('disabled'))) {
  2034. event.preventDefault(); // work around Firefox bug #1540995
  2035. return;
  2036. }
  2037. if (initialButton.tagName === 'LABEL' && inputBtn && inputBtn.type === 'checkbox') {
  2038. event.preventDefault(); // work around event sent to label and input
  2039. }
  2040. Button._jQueryInterface.call($(button), 'toggle');
  2041. }
  2042. }).on(EVENT_FOCUS_BLUR_DATA_API, SELECTOR_DATA_TOGGLE_CARROT, function (event) {
  2043. var button = $(event.target).closest(SELECTOR_BUTTON)[0];
  2044. $(button).toggleClass(CLASS_NAME_FOCUS, /^focus(in)?$/.test(event.type));
  2045. });
  2046. $(window).on(EVENT_LOAD_DATA_API, function () {
  2047. // ensure correct active class is set to match the controls' actual values/states
  2048. // find all checkboxes/readio buttons inside data-toggle groups
  2049. var buttons = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLES_BUTTONS));
  2050. for (var i = 0, len = buttons.length; i < len; i++) {
  2051. var button = buttons[i];
  2052. var input = button.querySelector(SELECTOR_INPUT);
  2053. if (input.checked || input.hasAttribute('checked')) {
  2054. button.classList.add(CLASS_NAME_ACTIVE);
  2055. } else {
  2056. button.classList.remove(CLASS_NAME_ACTIVE);
  2057. }
  2058. } // find all button toggles
  2059. buttons = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLE));
  2060. for (var _i = 0, _len = buttons.length; _i < _len; _i++) {
  2061. var _button = buttons[_i];
  2062. if (_button.getAttribute('aria-pressed') === 'true') {
  2063. _button.classList.add(CLASS_NAME_ACTIVE);
  2064. } else {
  2065. _button.classList.remove(CLASS_NAME_ACTIVE);
  2066. }
  2067. }
  2068. });
  2069. /**
  2070. * ------------------------------------------------------------------------
  2071. * jQuery
  2072. * ------------------------------------------------------------------------
  2073. */
  2074. $.fn[NAME$1] = Button._jQueryInterface;
  2075. $.fn[NAME$1].Constructor = Button;
  2076. $.fn[NAME$1].noConflict = function () {
  2077. $.fn[NAME$1] = JQUERY_NO_CONFLICT$1;
  2078. return Button._jQueryInterface;
  2079. };
  2080. /**
  2081. * ------------------------------------------------------------------------
  2082. * Constants
  2083. * ------------------------------------------------------------------------
  2084. */
  2085. var NAME$2 = 'carousel';
  2086. var VERSION$2 = '4.5.0';
  2087. var DATA_KEY$2 = 'bs.carousel';
  2088. var EVENT_KEY$2 = "." + DATA_KEY$2;
  2089. var DATA_API_KEY$2 = '.data-api';
  2090. var JQUERY_NO_CONFLICT$2 = $.fn[NAME$2];
  2091. var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
  2092. var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
  2093. var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  2094. var SWIPE_THRESHOLD = 40;
  2095. var Default = {
  2096. interval: 5000,
  2097. keyboard: true,
  2098. slide: false,
  2099. pause: 'hover',
  2100. wrap: true,
  2101. touch: true
  2102. };
  2103. var DefaultType = {
  2104. interval: '(number|boolean)',
  2105. keyboard: 'boolean',
  2106. slide: '(boolean|string)',
  2107. pause: '(string|boolean)',
  2108. wrap: 'boolean',
  2109. touch: 'boolean'
  2110. };
  2111. var DIRECTION_NEXT = 'next';
  2112. var DIRECTION_PREV = 'prev';
  2113. var DIRECTION_LEFT = 'left';
  2114. var DIRECTION_RIGHT = 'right';
  2115. var EVENT_SLIDE = "slide" + EVENT_KEY$2;
  2116. var EVENT_SLID = "slid" + EVENT_KEY$2;
  2117. var EVENT_KEYDOWN = "keydown" + EVENT_KEY$2;
  2118. var EVENT_MOUSEENTER = "mouseenter" + EVENT_KEY$2;
  2119. var EVENT_MOUSELEAVE = "mouseleave" + EVENT_KEY$2;
  2120. var EVENT_TOUCHSTART = "touchstart" + EVENT_KEY$2;
  2121. var EVENT_TOUCHMOVE = "touchmove" + EVENT_KEY$2;
  2122. var EVENT_TOUCHEND = "touchend" + EVENT_KEY$2;
  2123. var EVENT_POINTERDOWN = "pointerdown" + EVENT_KEY$2;
  2124. var EVENT_POINTERUP = "pointerup" + EVENT_KEY$2;
  2125. var EVENT_DRAG_START = "dragstart" + EVENT_KEY$2;
  2126. var EVENT_LOAD_DATA_API$1 = "load" + EVENT_KEY$2 + DATA_API_KEY$2;
  2127. var EVENT_CLICK_DATA_API$2 = "click" + EVENT_KEY$2 + DATA_API_KEY$2;
  2128. var CLASS_NAME_CAROUSEL = 'carousel';
  2129. var CLASS_NAME_ACTIVE$1 = 'active';
  2130. var CLASS_NAME_SLIDE = 'slide';
  2131. var CLASS_NAME_RIGHT = 'carousel-item-right';
  2132. var CLASS_NAME_LEFT = 'carousel-item-left';
  2133. var CLASS_NAME_NEXT = 'carousel-item-next';
  2134. var CLASS_NAME_PREV = 'carousel-item-prev';
  2135. var CLASS_NAME_POINTER_EVENT = 'pointer-event';
  2136. var SELECTOR_ACTIVE$1 = '.active';
  2137. var SELECTOR_ACTIVE_ITEM = '.active.carousel-item';
  2138. var SELECTOR_ITEM = '.carousel-item';
  2139. var SELECTOR_ITEM_IMG = '.carousel-item img';
  2140. var SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev';
  2141. var SELECTOR_INDICATORS = '.carousel-indicators';
  2142. var SELECTOR_DATA_SLIDE = '[data-slide], [data-slide-to]';
  2143. var SELECTOR_DATA_RIDE = '[data-ride="carousel"]';
  2144. var PointerType = {
  2145. TOUCH: 'touch',
  2146. PEN: 'pen'
  2147. };
  2148. /**
  2149. * ------------------------------------------------------------------------
  2150. * Class Definition
  2151. * ------------------------------------------------------------------------
  2152. */
  2153. var Carousel = /*#__PURE__*/function () {
  2154. function Carousel(element, config) {
  2155. this._items = null;
  2156. this._interval = null;
  2157. this._activeElement = null;
  2158. this._isPaused = false;
  2159. this._isSliding = false;
  2160. this.touchTimeout = null;
  2161. this.touchStartX = 0;
  2162. this.touchDeltaX = 0;
  2163. this._config = this._getConfig(config);
  2164. this._element = element;
  2165. this._indicatorsElement = this._element.querySelector(SELECTOR_INDICATORS);
  2166. this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  2167. this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
  2168. this._addEventListeners();
  2169. } // Getters
  2170. var _proto = Carousel.prototype;
  2171. // Public
  2172. _proto.next = function next() {
  2173. if (!this._isSliding) {
  2174. this._slide(DIRECTION_NEXT);
  2175. }
  2176. };
  2177. _proto.nextWhenVisible = function nextWhenVisible() {
  2178. // Don't call next when the page isn't visible
  2179. // or the carousel or its parent isn't visible
  2180. if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') {
  2181. this.next();
  2182. }
  2183. };
  2184. _proto.prev = function prev() {
  2185. if (!this._isSliding) {
  2186. this._slide(DIRECTION_PREV);
  2187. }
  2188. };
  2189. _proto.pause = function pause(event) {
  2190. if (!event) {
  2191. this._isPaused = true;
  2192. }
  2193. if (this._element.querySelector(SELECTOR_NEXT_PREV)) {
  2194. Util.triggerTransitionEnd(this._element);
  2195. this.cycle(true);
  2196. }
  2197. clearInterval(this._interval);
  2198. this._interval = null;
  2199. };
  2200. _proto.cycle = function cycle(event) {
  2201. if (!event) {
  2202. this._isPaused = false;
  2203. }
  2204. if (this._interval) {
  2205. clearInterval(this._interval);
  2206. this._interval = null;
  2207. }
  2208. if (this._config.interval && !this._isPaused) {
  2209. this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
  2210. }
  2211. };
  2212. _proto.to = function to(index) {
  2213. var _this = this;
  2214. this._activeElement = this._element.querySelector(SELECTOR_ACTIVE_ITEM);
  2215. var activeIndex = this._getItemIndex(this._activeElement);
  2216. if (index > this._items.length - 1 || index < 0) {
  2217. return;
  2218. }
  2219. if (this._isSliding) {
  2220. $(this._element).one(EVENT_SLID, function () {
  2221. return _this.to(index);
  2222. });
  2223. return;
  2224. }
  2225. if (activeIndex === index) {
  2226. this.pause();
  2227. this.cycle();
  2228. return;
  2229. }
  2230. var direction = index > activeIndex ? DIRECTION_NEXT : DIRECTION_PREV;
  2231. this._slide(direction, this._items[index]);
  2232. };
  2233. _proto.dispose = function dispose() {
  2234. $(this._element).off(EVENT_KEY$2);
  2235. $.removeData(this._element, DATA_KEY$2);
  2236. this._items = null;
  2237. this._config = null;
  2238. this._element = null;
  2239. this._interval = null;
  2240. this._isPaused = null;
  2241. this._isSliding = null;
  2242. this._activeElement = null;
  2243. this._indicatorsElement = null;
  2244. } // Private
  2245. ;
  2246. _proto._getConfig = function _getConfig(config) {
  2247. config = _objectSpread2(_objectSpread2({}, Default), config);
  2248. Util.typeCheckConfig(NAME$2, config, DefaultType);
  2249. return config;
  2250. };
  2251. _proto._handleSwipe = function _handleSwipe() {
  2252. var absDeltax = Math.abs(this.touchDeltaX);
  2253. if (absDeltax <= SWIPE_THRESHOLD) {
  2254. return;
  2255. }
  2256. var direction = absDeltax / this.touchDeltaX;
  2257. this.touchDeltaX = 0; // swipe left
  2258. if (direction > 0) {
  2259. this.prev();
  2260. } // swipe right
  2261. if (direction < 0) {
  2262. this.next();
  2263. }
  2264. };
  2265. _proto._addEventListeners = function _addEventListeners() {
  2266. var _this2 = this;
  2267. if (this._config.keyboard) {
  2268. $(this._element).on(EVENT_KEYDOWN, function (event) {
  2269. return _this2._keydown(event);
  2270. });
  2271. }
  2272. if (this._config.pause === 'hover') {
  2273. $(this._element).on(EVENT_MOUSEENTER, function (event) {
  2274. return _this2.pause(event);
  2275. }).on(EVENT_MOUSELEAVE, function (event) {
  2276. return _this2.cycle(event);
  2277. });
  2278. }
  2279. if (this._config.touch) {
  2280. this._addTouchEventListeners();
  2281. }
  2282. };
  2283. _proto._addTouchEventListeners = function _addTouchEventListeners() {
  2284. var _this3 = this;
  2285. if (!this._touchSupported) {
  2286. return;
  2287. }
  2288. var start = function start(event) {
  2289. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2290. _this3.touchStartX = event.originalEvent.clientX;
  2291. } else if (!_this3._pointerEvent) {
  2292. _this3.touchStartX = event.originalEvent.touches[0].clientX;
  2293. }
  2294. };
  2295. var move = function move(event) {
  2296. // ensure swiping with one touch and not pinching
  2297. if (event.originalEvent.touches && event.originalEvent.touches.length > 1) {
  2298. _this3.touchDeltaX = 0;
  2299. } else {
  2300. _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX;
  2301. }
  2302. };
  2303. var end = function end(event) {
  2304. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2305. _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
  2306. }
  2307. _this3._handleSwipe();
  2308. if (_this3._config.pause === 'hover') {
  2309. // If it's a touch-enabled device, mouseenter/leave are fired as
  2310. // part of the mouse compatibility events on first tap - the carousel
  2311. // would stop cycling until user tapped out of it;
  2312. // here, we listen for touchend, explicitly pause the carousel
  2313. // (as if it's the second time we tap on it, mouseenter compat event
  2314. // is NOT fired) and after a timeout (to allow for mouse compatibility
  2315. // events to fire) we explicitly restart cycling
  2316. _this3.pause();
  2317. if (_this3.touchTimeout) {
  2318. clearTimeout(_this3.touchTimeout);
  2319. }
  2320. _this3.touchTimeout = setTimeout(function (event) {
  2321. return _this3.cycle(event);
  2322. }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
  2323. }
  2324. };
  2325. $(this._element.querySelectorAll(SELECTOR_ITEM_IMG)).on(EVENT_DRAG_START, function (e) {
  2326. return e.preventDefault();
  2327. });
  2328. if (this._pointerEvent) {
  2329. $(this._element).on(EVENT_POINTERDOWN, function (event) {
  2330. return start(event);
  2331. });
  2332. $(this._element).on(EVENT_POINTERUP, function (event) {
  2333. return end(event);
  2334. });
  2335. this._element.classList.add(CLASS_NAME_POINTER_EVENT);
  2336. } else {
  2337. $(this._element).on(EVENT_TOUCHSTART, function (event) {
  2338. return start(event);
  2339. });
  2340. $(this._element).on(EVENT_TOUCHMOVE, function (event) {
  2341. return move(event);
  2342. });
  2343. $(this._element).on(EVENT_TOUCHEND, function (event) {
  2344. return end(event);
  2345. });
  2346. }
  2347. };
  2348. _proto._keydown = function _keydown(event) {
  2349. if (/input|textarea/i.test(event.target.tagName)) {
  2350. return;
  2351. }
  2352. switch (event.which) {
  2353. case ARROW_LEFT_KEYCODE:
  2354. event.preventDefault();
  2355. this.prev();
  2356. break;
  2357. case ARROW_RIGHT_KEYCODE:
  2358. event.preventDefault();
  2359. this.next();
  2360. break;
  2361. }
  2362. };
  2363. _proto._getItemIndex = function _getItemIndex(element) {
  2364. this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(SELECTOR_ITEM)) : [];
  2365. return this._items.indexOf(element);
  2366. };
  2367. _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
  2368. var isNextDirection = direction === DIRECTION_NEXT;
  2369. var isPrevDirection = direction === DIRECTION_PREV;
  2370. var activeIndex = this._getItemIndex(activeElement);
  2371. var lastItemIndex = this._items.length - 1;
  2372. var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
  2373. if (isGoingToWrap && !this._config.wrap) {
  2374. return activeElement;
  2375. }
  2376. var delta = direction === DIRECTION_PREV ? -1 : 1;
  2377. var itemIndex = (activeIndex + delta) % this._items.length;
  2378. return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
  2379. };
  2380. _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
  2381. var targetIndex = this._getItemIndex(relatedTarget);
  2382. var fromIndex = this._getItemIndex(this._element.querySelector(SELECTOR_ACTIVE_ITEM));
  2383. var slideEvent = $.Event(EVENT_SLIDE, {
  2384. relatedTarget: relatedTarget,
  2385. direction: eventDirectionName,
  2386. from: fromIndex,
  2387. to: targetIndex
  2388. });
  2389. $(this._element).trigger(slideEvent);
  2390. return slideEvent;
  2391. };
  2392. _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
  2393. if (this._indicatorsElement) {
  2394. var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(SELECTOR_ACTIVE$1));
  2395. $(indicators).removeClass(CLASS_NAME_ACTIVE$1);
  2396. var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
  2397. if (nextIndicator) {
  2398. $(nextIndicator).addClass(CLASS_NAME_ACTIVE$1);
  2399. }
  2400. }
  2401. };
  2402. _proto._slide = function _slide(direction, element) {
  2403. var _this4 = this;
  2404. var activeElement = this._element.querySelector(SELECTOR_ACTIVE_ITEM);
  2405. var activeElementIndex = this._getItemIndex(activeElement);
  2406. var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
  2407. var nextElementIndex = this._getItemIndex(nextElement);
  2408. var isCycling = Boolean(this._interval);
  2409. var directionalClassName;
  2410. var orderClassName;
  2411. var eventDirectionName;
  2412. if (direction === DIRECTION_NEXT) {
  2413. directionalClassName = CLASS_NAME_LEFT;
  2414. orderClassName = CLASS_NAME_NEXT;
  2415. eventDirectionName = DIRECTION_LEFT;
  2416. } else {
  2417. directionalClassName = CLASS_NAME_RIGHT;
  2418. orderClassName = CLASS_NAME_PREV;
  2419. eventDirectionName = DIRECTION_RIGHT;
  2420. }
  2421. if (nextElement && $(nextElement).hasClass(CLASS_NAME_ACTIVE$1)) {
  2422. this._isSliding = false;
  2423. return;
  2424. }
  2425. var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
  2426. if (slideEvent.isDefaultPrevented()) {
  2427. return;
  2428. }
  2429. if (!activeElement || !nextElement) {
  2430. // Some weirdness is happening, so we bail
  2431. return;
  2432. }
  2433. this._isSliding = true;
  2434. if (isCycling) {
  2435. this.pause();
  2436. }
  2437. this._setActiveIndicatorElement(nextElement);
  2438. var slidEvent = $.Event(EVENT_SLID, {
  2439. relatedTarget: nextElement,
  2440. direction: eventDirectionName,
  2441. from: activeElementIndex,
  2442. to: nextElementIndex
  2443. });
  2444. if ($(this._element).hasClass(CLASS_NAME_SLIDE)) {
  2445. $(nextElement).addClass(orderClassName);
  2446. Util.reflow(nextElement);
  2447. $(activeElement).addClass(directionalClassName);
  2448. $(nextElement).addClass(directionalClassName);
  2449. var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
  2450. if (nextElementInterval) {
  2451. this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
  2452. this._config.interval = nextElementInterval;
  2453. } else {
  2454. this._config.interval = this._config.defaultInterval || this._config.interval;
  2455. }
  2456. var transitionDuration = Util.getTransitionDurationFromElement(activeElement);
  2457. $(activeElement).one(Util.TRANSITION_END, function () {
  2458. $(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(CLASS_NAME_ACTIVE$1);
  2459. $(activeElement).removeClass(CLASS_NAME_ACTIVE$1 + " " + orderClassName + " " + directionalClassName);
  2460. _this4._isSliding = false;
  2461. setTimeout(function () {
  2462. return $(_this4._element).trigger(slidEvent);
  2463. }, 0);
  2464. }).emulateTransitionEnd(transitionDuration);
  2465. } else {
  2466. $(activeElement).removeClass(CLASS_NAME_ACTIVE$1);
  2467. $(nextElement).addClass(CLASS_NAME_ACTIVE$1);
  2468. this._isSliding = false;
  2469. $(this._element).trigger(slidEvent);
  2470. }
  2471. if (isCycling) {
  2472. this.cycle();
  2473. }
  2474. } // Static
  2475. ;
  2476. Carousel._jQueryInterface = function _jQueryInterface(config) {
  2477. return this.each(function () {
  2478. var data = $(this).data(DATA_KEY$2);
  2479. var _config = _objectSpread2(_objectSpread2({}, Default), $(this).data());
  2480. if (typeof config === 'object') {
  2481. _config = _objectSpread2(_objectSpread2({}, _config), config);
  2482. }
  2483. var action = typeof config === 'string' ? config : _config.slide;
  2484. if (!data) {
  2485. data = new Carousel(this, _config);
  2486. $(this).data(DATA_KEY$2, data);
  2487. }
  2488. if (typeof config === 'number') {
  2489. data.to(config);
  2490. } else if (typeof action === 'string') {
  2491. if (typeof data[action] === 'undefined') {
  2492. throw new TypeError("No method named \"" + action + "\"");
  2493. }
  2494. data[action]();
  2495. } else if (_config.interval && _config.ride) {
  2496. data.pause();
  2497. data.cycle();
  2498. }
  2499. });
  2500. };
  2501. Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
  2502. var selector = Util.getSelectorFromElement(this);
  2503. if (!selector) {
  2504. return;
  2505. }
  2506. var target = $(selector)[0];
  2507. if (!target || !$(target).hasClass(CLASS_NAME_CAROUSEL)) {
  2508. return;
  2509. }
  2510. var config = _objectSpread2(_objectSpread2({}, $(target).data()), $(this).data());
  2511. var slideIndex = this.getAttribute('data-slide-to');
  2512. if (slideIndex) {
  2513. config.interval = false;
  2514. }
  2515. Carousel._jQueryInterface.call($(target), config);
  2516. if (slideIndex) {
  2517. $(target).data(DATA_KEY$2).to(slideIndex);
  2518. }
  2519. event.preventDefault();
  2520. };
  2521. _createClass(Carousel, null, [{
  2522. key: "VERSION",
  2523. get: function get() {
  2524. return VERSION$2;
  2525. }
  2526. }, {
  2527. key: "Default",
  2528. get: function get() {
  2529. return Default;
  2530. }
  2531. }]);
  2532. return Carousel;
  2533. }();
  2534. /**
  2535. * ------------------------------------------------------------------------
  2536. * Data Api implementation
  2537. * ------------------------------------------------------------------------
  2538. */
  2539. $(document).on(EVENT_CLICK_DATA_API$2, SELECTOR_DATA_SLIDE, Carousel._dataApiClickHandler);
  2540. $(window).on(EVENT_LOAD_DATA_API$1, function () {
  2541. var carousels = [].slice.call(document.querySelectorAll(SELECTOR_DATA_RIDE));
  2542. for (var i = 0, len = carousels.length; i < len; i++) {
  2543. var $carousel = $(carousels[i]);
  2544. Carousel._jQueryInterface.call($carousel, $carousel.data());
  2545. }
  2546. });
  2547. /**
  2548. * ------------------------------------------------------------------------
  2549. * jQuery
  2550. * ------------------------------------------------------------------------
  2551. */
  2552. $.fn[NAME$2] = Carousel._jQueryInterface;
  2553. $.fn[NAME$2].Constructor = Carousel;
  2554. $.fn[NAME$2].noConflict = function () {
  2555. $.fn[NAME$2] = JQUERY_NO_CONFLICT$2;
  2556. return Carousel._jQueryInterface;
  2557. };
  2558. /**
  2559. * ------------------------------------------------------------------------
  2560. * Constants
  2561. * ------------------------------------------------------------------------
  2562. */
  2563. var NAME$3 = 'collapse';
  2564. var VERSION$3 = '4.5.0';
  2565. var DATA_KEY$3 = 'bs.collapse';
  2566. var EVENT_KEY$3 = "." + DATA_KEY$3;
  2567. var DATA_API_KEY$3 = '.data-api';
  2568. var JQUERY_NO_CONFLICT$3 = $.fn[NAME$3];
  2569. var Default$1 = {
  2570. toggle: true,
  2571. parent: ''
  2572. };
  2573. var DefaultType$1 = {
  2574. toggle: 'boolean',
  2575. parent: '(string|element)'
  2576. };
  2577. var EVENT_SHOW = "show" + EVENT_KEY$3;
  2578. var EVENT_SHOWN = "shown" + EVENT_KEY$3;
  2579. var EVENT_HIDE = "hide" + EVENT_KEY$3;
  2580. var EVENT_HIDDEN = "hidden" + EVENT_KEY$3;
  2581. var EVENT_CLICK_DATA_API$3 = "click" + EVENT_KEY$3 + DATA_API_KEY$3;
  2582. var CLASS_NAME_SHOW$1 = 'show';
  2583. var CLASS_NAME_COLLAPSE = 'collapse';
  2584. var CLASS_NAME_COLLAPSING = 'collapsing';
  2585. var CLASS_NAME_COLLAPSED = 'collapsed';
  2586. var DIMENSION_WIDTH = 'width';
  2587. var DIMENSION_HEIGHT = 'height';
  2588. var SELECTOR_ACTIVES = '.show, .collapsing';
  2589. var SELECTOR_DATA_TOGGLE$1 = '[data-toggle="collapse"]';
  2590. /**
  2591. * ------------------------------------------------------------------------
  2592. * Class Definition
  2593. * ------------------------------------------------------------------------
  2594. */
  2595. var Collapse = /*#__PURE__*/function () {
  2596. function Collapse(element, config) {
  2597. this._isTransitioning = false;
  2598. this._element = element;
  2599. this._config = this._getConfig(config);
  2600. this._triggerArray = [].slice.call(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]")));
  2601. var toggleList = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLE$1));
  2602. for (var i = 0, len = toggleList.length; i < len; i++) {
  2603. var elem = toggleList[i];
  2604. var selector = Util.getSelectorFromElement(elem);
  2605. var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function (foundElem) {
  2606. return foundElem === element;
  2607. });
  2608. if (selector !== null && filterElement.length > 0) {
  2609. this._selector = selector;
  2610. this._triggerArray.push(elem);
  2611. }
  2612. }
  2613. this._parent = this._config.parent ? this._getParent() : null;
  2614. if (!this._config.parent) {
  2615. this._addAriaAndCollapsedClass(this._element, this._triggerArray);
  2616. }
  2617. if (this._config.toggle) {
  2618. this.toggle();
  2619. }
  2620. } // Getters
  2621. var _proto = Collapse.prototype;
  2622. // Public
  2623. _proto.toggle = function toggle() {
  2624. if ($(this._element).hasClass(CLASS_NAME_SHOW$1)) {
  2625. this.hide();
  2626. } else {
  2627. this.show();
  2628. }
  2629. };
  2630. _proto.show = function show() {
  2631. var _this = this;
  2632. if (this._isTransitioning || $(this._element).hasClass(CLASS_NAME_SHOW$1)) {
  2633. return;
  2634. }
  2635. var actives;
  2636. var activesData;
  2637. if (this._parent) {
  2638. actives = [].slice.call(this._parent.querySelectorAll(SELECTOR_ACTIVES)).filter(function (elem) {
  2639. if (typeof _this._config.parent === 'string') {
  2640. return elem.getAttribute('data-parent') === _this._config.parent;
  2641. }
  2642. return elem.classList.contains(CLASS_NAME_COLLAPSE);
  2643. });
  2644. if (actives.length === 0) {
  2645. actives = null;
  2646. }
  2647. }
  2648. if (actives) {
  2649. activesData = $(actives).not(this._selector).data(DATA_KEY$3);
  2650. if (activesData && activesData._isTransitioning) {
  2651. return;
  2652. }
  2653. }
  2654. var startEvent = $.Event(EVENT_SHOW);
  2655. $(this._element).trigger(startEvent);
  2656. if (startEvent.isDefaultPrevented()) {
  2657. return;
  2658. }
  2659. if (actives) {
  2660. Collapse._jQueryInterface.call($(actives).not(this._selector), 'hide');
  2661. if (!activesData) {
  2662. $(actives).data(DATA_KEY$3, null);
  2663. }
  2664. }
  2665. var dimension = this._getDimension();
  2666. $(this._element).removeClass(CLASS_NAME_COLLAPSE).addClass(CLASS_NAME_COLLAPSING);
  2667. this._element.style[dimension] = 0;
  2668. if (this._triggerArray.length) {
  2669. $(this._triggerArray).removeClass(CLASS_NAME_COLLAPSED).attr('aria-expanded', true);
  2670. }
  2671. this.setTransitioning(true);
  2672. var complete = function complete() {
  2673. $(_this._element).removeClass(CLASS_NAME_COLLAPSING).addClass(CLASS_NAME_COLLAPSE + " " + CLASS_NAME_SHOW$1);
  2674. _this._element.style[dimension] = '';
  2675. _this.setTransitioning(false);
  2676. $(_this._element).trigger(EVENT_SHOWN);
  2677. };
  2678. var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  2679. var scrollSize = "scroll" + capitalizedDimension;
  2680. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  2681. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  2682. this._element.style[dimension] = this._element[scrollSize] + "px";
  2683. };
  2684. _proto.hide = function hide() {
  2685. var _this2 = this;
  2686. if (this._isTransitioning || !$(this._element).hasClass(CLASS_NAME_SHOW$1)) {
  2687. return;
  2688. }
  2689. var startEvent = $.Event(EVENT_HIDE);
  2690. $(this._element).trigger(startEvent);
  2691. if (startEvent.isDefaultPrevented()) {
  2692. return;
  2693. }
  2694. var dimension = this._getDimension();
  2695. this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
  2696. Util.reflow(this._element);
  2697. $(this._element).addClass(CLASS_NAME_COLLAPSING).removeClass(CLASS_NAME_COLLAPSE + " " + CLASS_NAME_SHOW$1);
  2698. var triggerArrayLength = this._triggerArray.length;
  2699. if (triggerArrayLength > 0) {
  2700. for (var i = 0; i < triggerArrayLength; i++) {
  2701. var trigger = this._triggerArray[i];
  2702. var selector = Util.getSelectorFromElement(trigger);
  2703. if (selector !== null) {
  2704. var $elem = $([].slice.call(document.querySelectorAll(selector)));
  2705. if (!$elem.hasClass(CLASS_NAME_SHOW$1)) {
  2706. $(trigger).addClass(CLASS_NAME_COLLAPSED).attr('aria-expanded', false);
  2707. }
  2708. }
  2709. }
  2710. }
  2711. this.setTransitioning(true);
  2712. var complete = function complete() {
  2713. _this2.setTransitioning(false);
  2714. $(_this2._element).removeClass(CLASS_NAME_COLLAPSING).addClass(CLASS_NAME_COLLAPSE).trigger(EVENT_HIDDEN);
  2715. };
  2716. this._element.style[dimension] = '';
  2717. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  2718. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  2719. };
  2720. _proto.setTransitioning = function setTransitioning(isTransitioning) {
  2721. this._isTransitioning = isTransitioning;
  2722. };
  2723. _proto.dispose = function dispose() {
  2724. $.removeData(this._element, DATA_KEY$3);
  2725. this._config = null;
  2726. this._parent = null;
  2727. this._element = null;
  2728. this._triggerArray = null;
  2729. this._isTransitioning = null;
  2730. } // Private
  2731. ;
  2732. _proto._getConfig = function _getConfig(config) {
  2733. config = _objectSpread2(_objectSpread2({}, Default$1), config);
  2734. config.toggle = Boolean(config.toggle); // Coerce string values
  2735. Util.typeCheckConfig(NAME$3, config, DefaultType$1);
  2736. return config;
  2737. };
  2738. _proto._getDimension = function _getDimension() {
  2739. var hasWidth = $(this._element).hasClass(DIMENSION_WIDTH);
  2740. return hasWidth ? DIMENSION_WIDTH : DIMENSION_HEIGHT;
  2741. };
  2742. _proto._getParent = function _getParent() {
  2743. var _this3 = this;
  2744. var parent;
  2745. if (Util.isElement(this._config.parent)) {
  2746. parent = this._config.parent; // It's a jQuery object
  2747. if (typeof this._config.parent.jquery !== 'undefined') {
  2748. parent = this._config.parent[0];
  2749. }
  2750. } else {
  2751. parent = document.querySelector(this._config.parent);
  2752. }
  2753. var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]";
  2754. var children = [].slice.call(parent.querySelectorAll(selector));
  2755. $(children).each(function (i, element) {
  2756. _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]);
  2757. });
  2758. return parent;
  2759. };
  2760. _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
  2761. var isOpen = $(element).hasClass(CLASS_NAME_SHOW$1);
  2762. if (triggerArray.length) {
  2763. $(triggerArray).toggleClass(CLASS_NAME_COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
  2764. }
  2765. } // Static
  2766. ;
  2767. Collapse._getTargetFromElement = function _getTargetFromElement(element) {
  2768. var selector = Util.getSelectorFromElement(element);
  2769. return selector ? document.querySelector(selector) : null;
  2770. };
  2771. Collapse._jQueryInterface = function _jQueryInterface(config) {
  2772. return this.each(function () {
  2773. var $this = $(this);
  2774. var data = $this.data(DATA_KEY$3);
  2775. var _config = _objectSpread2(_objectSpread2(_objectSpread2({}, Default$1), $this.data()), typeof config === 'object' && config ? config : {});
  2776. if (!data && _config.toggle && typeof config === 'string' && /show|hide/.test(config)) {
  2777. _config.toggle = false;
  2778. }
  2779. if (!data) {
  2780. data = new Collapse(this, _config);
  2781. $this.data(DATA_KEY$3, data);
  2782. }
  2783. if (typeof config === 'string') {
  2784. if (typeof data[config] === 'undefined') {
  2785. throw new TypeError("No method named \"" + config + "\"");
  2786. }
  2787. data[config]();
  2788. }
  2789. });
  2790. };
  2791. _createClass(Collapse, null, [{
  2792. key: "VERSION",
  2793. get: function get() {
  2794. return VERSION$3;
  2795. }
  2796. }, {
  2797. key: "Default",
  2798. get: function get() {
  2799. return Default$1;
  2800. }
  2801. }]);
  2802. return Collapse;
  2803. }();
  2804. /**
  2805. * ------------------------------------------------------------------------
  2806. * Data Api implementation
  2807. * ------------------------------------------------------------------------
  2808. */
  2809. $(document).on(EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$1, function (event) {
  2810. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  2811. if (event.currentTarget.tagName === 'A') {
  2812. event.preventDefault();
  2813. }
  2814. var $trigger = $(this);
  2815. var selector = Util.getSelectorFromElement(this);
  2816. var selectors = [].slice.call(document.querySelectorAll(selector));
  2817. $(selectors).each(function () {
  2818. var $target = $(this);
  2819. var data = $target.data(DATA_KEY$3);
  2820. var config = data ? 'toggle' : $trigger.data();
  2821. Collapse._jQueryInterface.call($target, config);
  2822. });
  2823. });
  2824. /**
  2825. * ------------------------------------------------------------------------
  2826. * jQuery
  2827. * ------------------------------------------------------------------------
  2828. */
  2829. $.fn[NAME$3] = Collapse._jQueryInterface;
  2830. $.fn[NAME$3].Constructor = Collapse;
  2831. $.fn[NAME$3].noConflict = function () {
  2832. $.fn[NAME$3] = JQUERY_NO_CONFLICT$3;
  2833. return Collapse._jQueryInterface;
  2834. };
  2835. /**
  2836. * ------------------------------------------------------------------------
  2837. * Constants
  2838. * ------------------------------------------------------------------------
  2839. */
  2840. var NAME$4 = 'dropdown';
  2841. var VERSION$4 = '4.5.0';
  2842. var DATA_KEY$4 = 'bs.dropdown';
  2843. var EVENT_KEY$4 = "." + DATA_KEY$4;
  2844. var DATA_API_KEY$4 = '.data-api';
  2845. var JQUERY_NO_CONFLICT$4 = $.fn[NAME$4];
  2846. var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
  2847. var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key
  2848. var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key
  2849. var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key
  2850. var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key
  2851. var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)
  2852. var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
  2853. var EVENT_HIDE$1 = "hide" + EVENT_KEY$4;
  2854. var EVENT_HIDDEN$1 = "hidden" + EVENT_KEY$4;
  2855. var EVENT_SHOW$1 = "show" + EVENT_KEY$4;
  2856. var EVENT_SHOWN$1 = "shown" + EVENT_KEY$4;
  2857. var EVENT_CLICK = "click" + EVENT_KEY$4;
  2858. var EVENT_CLICK_DATA_API$4 = "click" + EVENT_KEY$4 + DATA_API_KEY$4;
  2859. var EVENT_KEYDOWN_DATA_API = "keydown" + EVENT_KEY$4 + DATA_API_KEY$4;
  2860. var EVENT_KEYUP_DATA_API = "keyup" + EVENT_KEY$4 + DATA_API_KEY$4;
  2861. var CLASS_NAME_DISABLED = 'disabled';
  2862. var CLASS_NAME_SHOW$2 = 'show';
  2863. var CLASS_NAME_DROPUP = 'dropup';
  2864. var CLASS_NAME_DROPRIGHT = 'dropright';
  2865. var CLASS_NAME_DROPLEFT = 'dropleft';
  2866. var CLASS_NAME_MENURIGHT = 'dropdown-menu-right';
  2867. var CLASS_NAME_POSITION_STATIC = 'position-static';
  2868. var SELECTOR_DATA_TOGGLE$2 = '[data-toggle="dropdown"]';
  2869. var SELECTOR_FORM_CHILD = '.dropdown form';
  2870. var SELECTOR_MENU = '.dropdown-menu';
  2871. var SELECTOR_NAVBAR_NAV = '.navbar-nav';
  2872. var SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)';
  2873. var PLACEMENT_TOP = 'top-start';
  2874. var PLACEMENT_TOPEND = 'top-end';
  2875. var PLACEMENT_BOTTOM = 'bottom-start';
  2876. var PLACEMENT_BOTTOMEND = 'bottom-end';
  2877. var PLACEMENT_RIGHT = 'right-start';
  2878. var PLACEMENT_LEFT = 'left-start';
  2879. var Default$2 = {
  2880. offset: 0,
  2881. flip: true,
  2882. boundary: 'scrollParent',
  2883. reference: 'toggle',
  2884. display: 'dynamic',
  2885. popperConfig: null
  2886. };
  2887. var DefaultType$2 = {
  2888. offset: '(number|string|function)',
  2889. flip: 'boolean',
  2890. boundary: '(string|element)',
  2891. reference: '(string|element)',
  2892. display: 'string',
  2893. popperConfig: '(null|object)'
  2894. };
  2895. /**
  2896. * ------------------------------------------------------------------------
  2897. * Class Definition
  2898. * ------------------------------------------------------------------------
  2899. */
  2900. var Dropdown = /*#__PURE__*/function () {
  2901. function Dropdown(element, config) {
  2902. this._element = element;
  2903. this._popper = null;
  2904. this._config = this._getConfig(config);
  2905. this._menu = this._getMenuElement();
  2906. this._inNavbar = this._detectNavbar();
  2907. this._addEventListeners();
  2908. } // Getters
  2909. var _proto = Dropdown.prototype;
  2910. // Public
  2911. _proto.toggle = function toggle() {
  2912. if (this._element.disabled || $(this._element).hasClass(CLASS_NAME_DISABLED)) {
  2913. return;
  2914. }
  2915. var isActive = $(this._menu).hasClass(CLASS_NAME_SHOW$2);
  2916. Dropdown._clearMenus();
  2917. if (isActive) {
  2918. return;
  2919. }
  2920. this.show(true);
  2921. };
  2922. _proto.show = function show(usePopper) {
  2923. if (usePopper === void 0) {
  2924. usePopper = false;
  2925. }
  2926. if (this._element.disabled || $(this._element).hasClass(CLASS_NAME_DISABLED) || $(this._menu).hasClass(CLASS_NAME_SHOW$2)) {
  2927. return;
  2928. }
  2929. var relatedTarget = {
  2930. relatedTarget: this._element
  2931. };
  2932. var showEvent = $.Event(EVENT_SHOW$1, relatedTarget);
  2933. var parent = Dropdown._getParentFromElement(this._element);
  2934. $(parent).trigger(showEvent);
  2935. if (showEvent.isDefaultPrevented()) {
  2936. return;
  2937. } // Disable totally Popper.js for Dropdown in Navbar
  2938. if (!this._inNavbar && usePopper) {
  2939. /**
  2940. * Check for Popper dependency
  2941. * Popper - https://popper.js.org
  2942. */
  2943. if (typeof Popper === 'undefined') {
  2944. throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)');
  2945. }
  2946. var referenceElement = this._element;
  2947. if (this._config.reference === 'parent') {
  2948. referenceElement = parent;
  2949. } else if (Util.isElement(this._config.reference)) {
  2950. referenceElement = this._config.reference; // Check if it's jQuery element
  2951. if (typeof this._config.reference.jquery !== 'undefined') {
  2952. referenceElement = this._config.reference[0];
  2953. }
  2954. } // If boundary is not `scrollParent`, then set position to `static`
  2955. // to allow the menu to "escape" the scroll parent's boundaries
  2956. // https://github.com/twbs/bootstrap/issues/24251
  2957. if (this._config.boundary !== 'scrollParent') {
  2958. $(parent).addClass(CLASS_NAME_POSITION_STATIC);
  2959. }
  2960. this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
  2961. } // If this is a touch-enabled device we add extra
  2962. // empty mouseover listeners to the body's immediate children;
  2963. // only needed because of broken event delegation on iOS
  2964. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  2965. if ('ontouchstart' in document.documentElement && $(parent).closest(SELECTOR_NAVBAR_NAV).length === 0) {
  2966. $(document.body).children().on('mouseover', null, $.noop);
  2967. }
  2968. this._element.focus();
  2969. this._element.setAttribute('aria-expanded', true);
  2970. $(this._menu).toggleClass(CLASS_NAME_SHOW$2);
  2971. $(parent).toggleClass(CLASS_NAME_SHOW$2).trigger($.Event(EVENT_SHOWN$1, relatedTarget));
  2972. };
  2973. _proto.hide = function hide() {
  2974. if (this._element.disabled || $(this._element).hasClass(CLASS_NAME_DISABLED) || !$(this._menu).hasClass(CLASS_NAME_SHOW$2)) {
  2975. return;
  2976. }
  2977. var relatedTarget = {
  2978. relatedTarget: this._element
  2979. };
  2980. var hideEvent = $.Event(EVENT_HIDE$1, relatedTarget);
  2981. var parent = Dropdown._getParentFromElement(this._element);
  2982. $(parent).trigger(hideEvent);
  2983. if (hideEvent.isDefaultPrevented()) {
  2984. return;
  2985. }
  2986. if (this._popper) {
  2987. this._popper.destroy();
  2988. }
  2989. $(this._menu).toggleClass(CLASS_NAME_SHOW$2);
  2990. $(parent).toggleClass(CLASS_NAME_SHOW$2).trigger($.Event(EVENT_HIDDEN$1, relatedTarget));
  2991. };
  2992. _proto.dispose = function dispose() {
  2993. $.removeData(this._element, DATA_KEY$4);
  2994. $(this._element).off(EVENT_KEY$4);
  2995. this._element = null;
  2996. this._menu = null;
  2997. if (this._popper !== null) {
  2998. this._popper.destroy();
  2999. this._popper = null;
  3000. }
  3001. };
  3002. _proto.update = function update() {
  3003. this._inNavbar = this._detectNavbar();
  3004. if (this._popper !== null) {
  3005. this._popper.scheduleUpdate();
  3006. }
  3007. } // Private
  3008. ;
  3009. _proto._addEventListeners = function _addEventListeners() {
  3010. var _this = this;
  3011. $(this._element).on(EVENT_CLICK, function (event) {
  3012. event.preventDefault();
  3013. event.stopPropagation();
  3014. _this.toggle();
  3015. });
  3016. };
  3017. _proto._getConfig = function _getConfig(config) {
  3018. config = _objectSpread2(_objectSpread2(_objectSpread2({}, this.constructor.Default), $(this._element).data()), config);
  3019. Util.typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
  3020. return config;
  3021. };
  3022. _proto._getMenuElement = function _getMenuElement() {
  3023. if (!this._menu) {
  3024. var parent = Dropdown._getParentFromElement(this._element);
  3025. if (parent) {
  3026. this._menu = parent.querySelector(SELECTOR_MENU);
  3027. }
  3028. }
  3029. return this._menu;
  3030. };
  3031. _proto._getPlacement = function _getPlacement() {
  3032. var $parentDropdown = $(this._element.parentNode);
  3033. var placement = PLACEMENT_BOTTOM; // Handle dropup
  3034. if ($parentDropdown.hasClass(CLASS_NAME_DROPUP)) {
  3035. placement = $(this._menu).hasClass(CLASS_NAME_MENURIGHT) ? PLACEMENT_TOPEND : PLACEMENT_TOP;
  3036. } else if ($parentDropdown.hasClass(CLASS_NAME_DROPRIGHT)) {
  3037. placement = PLACEMENT_RIGHT;
  3038. } else if ($parentDropdown.hasClass(CLASS_NAME_DROPLEFT)) {
  3039. placement = PLACEMENT_LEFT;
  3040. } else if ($(this._menu).hasClass(CLASS_NAME_MENURIGHT)) {
  3041. placement = PLACEMENT_BOTTOMEND;
  3042. }
  3043. return placement;
  3044. };
  3045. _proto._detectNavbar = function _detectNavbar() {
  3046. return $(this._element).closest('.navbar').length > 0;
  3047. };
  3048. _proto._getOffset = function _getOffset() {
  3049. var _this2 = this;
  3050. var offset = {};
  3051. if (typeof this._config.offset === 'function') {
  3052. offset.fn = function (data) {
  3053. data.offsets = _objectSpread2(_objectSpread2({}, data.offsets), _this2._config.offset(data.offsets, _this2._element) || {});
  3054. return data;
  3055. };
  3056. } else {
  3057. offset.offset = this._config.offset;
  3058. }
  3059. return offset;
  3060. };
  3061. _proto._getPopperConfig = function _getPopperConfig() {
  3062. var popperConfig = {
  3063. placement: this._getPlacement(),
  3064. modifiers: {
  3065. offset: this._getOffset(),
  3066. flip: {
  3067. enabled: this._config.flip
  3068. },
  3069. preventOverflow: {
  3070. boundariesElement: this._config.boundary
  3071. }
  3072. }
  3073. }; // Disable Popper.js if we have a static display
  3074. if (this._config.display === 'static') {
  3075. popperConfig.modifiers.applyStyle = {
  3076. enabled: false
  3077. };
  3078. }
  3079. return _objectSpread2(_objectSpread2({}, popperConfig), this._config.popperConfig);
  3080. } // Static
  3081. ;
  3082. Dropdown._jQueryInterface = function _jQueryInterface(config) {
  3083. return this.each(function () {
  3084. var data = $(this).data(DATA_KEY$4);
  3085. var _config = typeof config === 'object' ? config : null;
  3086. if (!data) {
  3087. data = new Dropdown(this, _config);
  3088. $(this).data(DATA_KEY$4, data);
  3089. }
  3090. if (typeof config === 'string') {
  3091. if (typeof data[config] === 'undefined') {
  3092. throw new TypeError("No method named \"" + config + "\"");
  3093. }
  3094. data[config]();
  3095. }
  3096. });
  3097. };
  3098. Dropdown._clearMenus = function _clearMenus(event) {
  3099. if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
  3100. return;
  3101. }
  3102. var toggles = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLE$2));
  3103. for (var i = 0, len = toggles.length; i < len; i++) {
  3104. var parent = Dropdown._getParentFromElement(toggles[i]);
  3105. var context = $(toggles[i]).data(DATA_KEY$4);
  3106. var relatedTarget = {
  3107. relatedTarget: toggles[i]
  3108. };
  3109. if (event && event.type === 'click') {
  3110. relatedTarget.clickEvent = event;
  3111. }
  3112. if (!context) {
  3113. continue;
  3114. }
  3115. var dropdownMenu = context._menu;
  3116. if (!$(parent).hasClass(CLASS_NAME_SHOW$2)) {
  3117. continue;
  3118. }
  3119. if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $.contains(parent, event.target)) {
  3120. continue;
  3121. }
  3122. var hideEvent = $.Event(EVENT_HIDE$1, relatedTarget);
  3123. $(parent).trigger(hideEvent);
  3124. if (hideEvent.isDefaultPrevented()) {
  3125. continue;
  3126. } // If this is a touch-enabled device we remove the extra
  3127. // empty mouseover listeners we added for iOS support
  3128. if ('ontouchstart' in document.documentElement) {
  3129. $(document.body).children().off('mouseover', null, $.noop);
  3130. }
  3131. toggles[i].setAttribute('aria-expanded', 'false');
  3132. if (context._popper) {
  3133. context._popper.destroy();
  3134. }
  3135. $(dropdownMenu).removeClass(CLASS_NAME_SHOW$2);
  3136. $(parent).removeClass(CLASS_NAME_SHOW$2).trigger($.Event(EVENT_HIDDEN$1, relatedTarget));
  3137. }
  3138. };
  3139. Dropdown._getParentFromElement = function _getParentFromElement(element) {
  3140. var parent;
  3141. var selector = Util.getSelectorFromElement(element);
  3142. if (selector) {
  3143. parent = document.querySelector(selector);
  3144. }
  3145. return parent || element.parentNode;
  3146. } // eslint-disable-next-line complexity
  3147. ;
  3148. Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) {
  3149. // If not input/textarea:
  3150. // - And not a key in REGEXP_KEYDOWN => not a dropdown command
  3151. // If input/textarea:
  3152. // - If space key => not a dropdown command
  3153. // - If key is other than escape
  3154. // - If key is not up or down => not a dropdown command
  3155. // - If trigger inside the menu => not a dropdown command
  3156. if (/input|textarea/i.test(event.target.tagName) ? event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE && (event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE || $(event.target).closest(SELECTOR_MENU).length) : !REGEXP_KEYDOWN.test(event.which)) {
  3157. return;
  3158. }
  3159. if (this.disabled || $(this).hasClass(CLASS_NAME_DISABLED)) {
  3160. return;
  3161. }
  3162. var parent = Dropdown._getParentFromElement(this);
  3163. var isActive = $(parent).hasClass(CLASS_NAME_SHOW$2);
  3164. if (!isActive && event.which === ESCAPE_KEYCODE) {
  3165. return;
  3166. }
  3167. event.preventDefault();
  3168. event.stopPropagation();
  3169. if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
  3170. if (event.which === ESCAPE_KEYCODE) {
  3171. $(parent.querySelector(SELECTOR_DATA_TOGGLE$2)).trigger('focus');
  3172. }
  3173. $(this).trigger('click');
  3174. return;
  3175. }
  3176. var items = [].slice.call(parent.querySelectorAll(SELECTOR_VISIBLE_ITEMS)).filter(function (item) {
  3177. return $(item).is(':visible');
  3178. });
  3179. if (items.length === 0) {
  3180. return;
  3181. }
  3182. var index = items.indexOf(event.target);
  3183. if (event.which === ARROW_UP_KEYCODE && index > 0) {
  3184. // Up
  3185. index--;
  3186. }
  3187. if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) {
  3188. // Down
  3189. index++;
  3190. }
  3191. if (index < 0) {
  3192. index = 0;
  3193. }
  3194. items[index].focus();
  3195. };
  3196. _createClass(Dropdown, null, [{
  3197. key: "VERSION",
  3198. get: function get() {
  3199. return VERSION$4;
  3200. }
  3201. }, {
  3202. key: "Default",
  3203. get: function get() {
  3204. return Default$2;
  3205. }
  3206. }, {
  3207. key: "DefaultType",
  3208. get: function get() {
  3209. return DefaultType$2;
  3210. }
  3211. }]);
  3212. return Dropdown;
  3213. }();
  3214. /**
  3215. * ------------------------------------------------------------------------
  3216. * Data Api implementation
  3217. * ------------------------------------------------------------------------
  3218. */
  3219. $(document).on(EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE$2, Dropdown._dataApiKeydownHandler).on(EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown._dataApiKeydownHandler).on(EVENT_CLICK_DATA_API$4 + " " + EVENT_KEYUP_DATA_API, Dropdown._clearMenus).on(EVENT_CLICK_DATA_API$4, SELECTOR_DATA_TOGGLE$2, function (event) {
  3220. event.preventDefault();
  3221. event.stopPropagation();
  3222. Dropdown._jQueryInterface.call($(this), 'toggle');
  3223. }).on(EVENT_CLICK_DATA_API$4, SELECTOR_FORM_CHILD, function (e) {
  3224. e.stopPropagation();
  3225. });
  3226. /**
  3227. * ------------------------------------------------------------------------
  3228. * jQuery
  3229. * ------------------------------------------------------------------------
  3230. */
  3231. $.fn[NAME$4] = Dropdown._jQueryInterface;
  3232. $.fn[NAME$4].Constructor = Dropdown;
  3233. $.fn[NAME$4].noConflict = function () {
  3234. $.fn[NAME$4] = JQUERY_NO_CONFLICT$4;
  3235. return Dropdown._jQueryInterface;
  3236. };
  3237. /**
  3238. * ------------------------------------------------------------------------
  3239. * Constants
  3240. * ------------------------------------------------------------------------
  3241. */
  3242. var NAME$5 = 'modal';
  3243. var VERSION$5 = '4.5.0';
  3244. var DATA_KEY$5 = 'bs.modal';
  3245. var EVENT_KEY$5 = "." + DATA_KEY$5;
  3246. var DATA_API_KEY$5 = '.data-api';
  3247. var JQUERY_NO_CONFLICT$5 = $.fn[NAME$5];
  3248. var ESCAPE_KEYCODE$1 = 27; // KeyboardEvent.which value for Escape (Esc) key
  3249. var Default$3 = {
  3250. backdrop: true,
  3251. keyboard: true,
  3252. focus: true,
  3253. show: true
  3254. };
  3255. var DefaultType$3 = {
  3256. backdrop: '(boolean|string)',
  3257. keyboard: 'boolean',
  3258. focus: 'boolean',
  3259. show: 'boolean'
  3260. };
  3261. var EVENT_HIDE$2 = "hide" + EVENT_KEY$5;
  3262. var EVENT_HIDE_PREVENTED = "hidePrevented" + EVENT_KEY$5;
  3263. var EVENT_HIDDEN$2 = "hidden" + EVENT_KEY$5;
  3264. var EVENT_SHOW$2 = "show" + EVENT_KEY$5;
  3265. var EVENT_SHOWN$2 = "shown" + EVENT_KEY$5;
  3266. var EVENT_FOCUSIN = "focusin" + EVENT_KEY$5;
  3267. var EVENT_RESIZE = "resize" + EVENT_KEY$5;
  3268. var EVENT_CLICK_DISMISS = "click.dismiss" + EVENT_KEY$5;
  3269. var EVENT_KEYDOWN_DISMISS = "keydown.dismiss" + EVENT_KEY$5;
  3270. var EVENT_MOUSEUP_DISMISS = "mouseup.dismiss" + EVENT_KEY$5;
  3271. var EVENT_MOUSEDOWN_DISMISS = "mousedown.dismiss" + EVENT_KEY$5;
  3272. var EVENT_CLICK_DATA_API$5 = "click" + EVENT_KEY$5 + DATA_API_KEY$5;
  3273. var CLASS_NAME_SCROLLABLE = 'modal-dialog-scrollable';
  3274. var CLASS_NAME_SCROLLBAR_MEASURER = 'modal-scrollbar-measure';
  3275. var CLASS_NAME_BACKDROP = 'modal-backdrop';
  3276. var CLASS_NAME_OPEN = 'modal-open';
  3277. var CLASS_NAME_FADE$1 = 'fade';
  3278. var CLASS_NAME_SHOW$3 = 'show';
  3279. var CLASS_NAME_STATIC = 'modal-static';
  3280. var SELECTOR_DIALOG = '.modal-dialog';
  3281. var SELECTOR_MODAL_BODY = '.modal-body';
  3282. var SELECTOR_DATA_TOGGLE$3 = '[data-toggle="modal"]';
  3283. var SELECTOR_DATA_DISMISS = '[data-dismiss="modal"]';
  3284. var SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';
  3285. var SELECTOR_STICKY_CONTENT = '.sticky-top';
  3286. /**
  3287. * ------------------------------------------------------------------------
  3288. * Class Definition
  3289. * ------------------------------------------------------------------------
  3290. */
  3291. var Modal = /*#__PURE__*/function () {
  3292. function Modal(element, config) {
  3293. this._config = this._getConfig(config);
  3294. this._element = element;
  3295. this._dialog = element.querySelector(SELECTOR_DIALOG);
  3296. this._backdrop = null;
  3297. this._isShown = false;
  3298. this._isBodyOverflowing = false;
  3299. this._ignoreBackdropClick = false;
  3300. this._isTransitioning = false;
  3301. this._scrollbarWidth = 0;
  3302. } // Getters
  3303. var _proto = Modal.prototype;
  3304. // Public
  3305. _proto.toggle = function toggle(relatedTarget) {
  3306. return this._isShown ? this.hide() : this.show(relatedTarget);
  3307. };
  3308. _proto.show = function show(relatedTarget) {
  3309. var _this = this;
  3310. if (this._isShown || this._isTransitioning) {
  3311. return;
  3312. }
  3313. if ($(this._element).hasClass(CLASS_NAME_FADE$1)) {
  3314. this._isTransitioning = true;
  3315. }
  3316. var showEvent = $.Event(EVENT_SHOW$2, {
  3317. relatedTarget: relatedTarget
  3318. });
  3319. $(this._element).trigger(showEvent);
  3320. if (this._isShown || showEvent.isDefaultPrevented()) {
  3321. return;
  3322. }
  3323. this._isShown = true;
  3324. this._checkScrollbar();
  3325. this._setScrollbar();
  3326. this._adjustDialog();
  3327. this._setEscapeEvent();
  3328. this._setResizeEvent();
  3329. $(this._element).on(EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, function (event) {
  3330. return _this.hide(event);
  3331. });
  3332. $(this._dialog).on(EVENT_MOUSEDOWN_DISMISS, function () {
  3333. $(_this._element).one(EVENT_MOUSEUP_DISMISS, function (event) {
  3334. if ($(event.target).is(_this._element)) {
  3335. _this._ignoreBackdropClick = true;
  3336. }
  3337. });
  3338. });
  3339. this._showBackdrop(function () {
  3340. return _this._showElement(relatedTarget);
  3341. });
  3342. };
  3343. _proto.hide = function hide(event) {
  3344. var _this2 = this;
  3345. if (event) {
  3346. event.preventDefault();
  3347. }
  3348. if (!this._isShown || this._isTransitioning) {
  3349. return;
  3350. }
  3351. var hideEvent = $.Event(EVENT_HIDE$2);
  3352. $(this._element).trigger(hideEvent);
  3353. if (!this._isShown || hideEvent.isDefaultPrevented()) {
  3354. return;
  3355. }
  3356. this._isShown = false;
  3357. var transition = $(this._element).hasClass(CLASS_NAME_FADE$1);
  3358. if (transition) {
  3359. this._isTransitioning = true;
  3360. }
  3361. this._setEscapeEvent();
  3362. this._setResizeEvent();
  3363. $(document).off(EVENT_FOCUSIN);
  3364. $(this._element).removeClass(CLASS_NAME_SHOW$3);
  3365. $(this._element).off(EVENT_CLICK_DISMISS);
  3366. $(this._dialog).off(EVENT_MOUSEDOWN_DISMISS);
  3367. if (transition) {
  3368. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3369. $(this._element).one(Util.TRANSITION_END, function (event) {
  3370. return _this2._hideModal(event);
  3371. }).emulateTransitionEnd(transitionDuration);
  3372. } else {
  3373. this._hideModal();
  3374. }
  3375. };
  3376. _proto.dispose = function dispose() {
  3377. [window, this._element, this._dialog].forEach(function (htmlElement) {
  3378. return $(htmlElement).off(EVENT_KEY$5);
  3379. });
  3380. /**
  3381. * `document` has 2 events `EVENT_FOCUSIN` and `EVENT_CLICK_DATA_API`
  3382. * Do not move `document` in `htmlElements` array
  3383. * It will remove `EVENT_CLICK_DATA_API` event that should remain
  3384. */
  3385. $(document).off(EVENT_FOCUSIN);
  3386. $.removeData(this._element, DATA_KEY$5);
  3387. this._config = null;
  3388. this._element = null;
  3389. this._dialog = null;
  3390. this._backdrop = null;
  3391. this._isShown = null;
  3392. this._isBodyOverflowing = null;
  3393. this._ignoreBackdropClick = null;
  3394. this._isTransitioning = null;
  3395. this._scrollbarWidth = null;
  3396. };
  3397. _proto.handleUpdate = function handleUpdate() {
  3398. this._adjustDialog();
  3399. } // Private
  3400. ;
  3401. _proto._getConfig = function _getConfig(config) {
  3402. config = _objectSpread2(_objectSpread2({}, Default$3), config);
  3403. Util.typeCheckConfig(NAME$5, config, DefaultType$3);
  3404. return config;
  3405. };
  3406. _proto._triggerBackdropTransition = function _triggerBackdropTransition() {
  3407. var _this3 = this;
  3408. if (this._config.backdrop === 'static') {
  3409. var hideEventPrevented = $.Event(EVENT_HIDE_PREVENTED);
  3410. $(this._element).trigger(hideEventPrevented);
  3411. if (hideEventPrevented.defaultPrevented) {
  3412. return;
  3413. }
  3414. this._element.classList.add(CLASS_NAME_STATIC);
  3415. var modalTransitionDuration = Util.getTransitionDurationFromElement(this._element);
  3416. $(this._element).one(Util.TRANSITION_END, function () {
  3417. _this3._element.classList.remove(CLASS_NAME_STATIC);
  3418. }).emulateTransitionEnd(modalTransitionDuration);
  3419. this._element.focus();
  3420. } else {
  3421. this.hide();
  3422. }
  3423. };
  3424. _proto._showElement = function _showElement(relatedTarget) {
  3425. var _this4 = this;
  3426. var transition = $(this._element).hasClass(CLASS_NAME_FADE$1);
  3427. var modalBody = this._dialog ? this._dialog.querySelector(SELECTOR_MODAL_BODY) : null;
  3428. if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
  3429. // Don't move modal's DOM position
  3430. document.body.appendChild(this._element);
  3431. }
  3432. this._element.style.display = 'block';
  3433. this._element.removeAttribute('aria-hidden');
  3434. this._element.setAttribute('aria-modal', true);
  3435. if ($(this._dialog).hasClass(CLASS_NAME_SCROLLABLE) && modalBody) {
  3436. modalBody.scrollTop = 0;
  3437. } else {
  3438. this._element.scrollTop = 0;
  3439. }
  3440. if (transition) {
  3441. Util.reflow(this._element);
  3442. }
  3443. $(this._element).addClass(CLASS_NAME_SHOW$3);
  3444. if (this._config.focus) {
  3445. this._enforceFocus();
  3446. }
  3447. var shownEvent = $.Event(EVENT_SHOWN$2, {
  3448. relatedTarget: relatedTarget
  3449. });
  3450. var transitionComplete = function transitionComplete() {
  3451. if (_this4._config.focus) {
  3452. _this4._element.focus();
  3453. }
  3454. _this4._isTransitioning = false;
  3455. $(_this4._element).trigger(shownEvent);
  3456. };
  3457. if (transition) {
  3458. var transitionDuration = Util.getTransitionDurationFromElement(this._dialog);
  3459. $(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration);
  3460. } else {
  3461. transitionComplete();
  3462. }
  3463. };
  3464. _proto._enforceFocus = function _enforceFocus() {
  3465. var _this5 = this;
  3466. $(document).off(EVENT_FOCUSIN) // Guard against infinite focus loop
  3467. .on(EVENT_FOCUSIN, function (event) {
  3468. if (document !== event.target && _this5._element !== event.target && $(_this5._element).has(event.target).length === 0) {
  3469. _this5._element.focus();
  3470. }
  3471. });
  3472. };
  3473. _proto._setEscapeEvent = function _setEscapeEvent() {
  3474. var _this6 = this;
  3475. if (this._isShown) {
  3476. $(this._element).on(EVENT_KEYDOWN_DISMISS, function (event) {
  3477. if (_this6._config.keyboard && event.which === ESCAPE_KEYCODE$1) {
  3478. event.preventDefault();
  3479. _this6.hide();
  3480. } else if (!_this6._config.keyboard && event.which === ESCAPE_KEYCODE$1) {
  3481. _this6._triggerBackdropTransition();
  3482. }
  3483. });
  3484. } else if (!this._isShown) {
  3485. $(this._element).off(EVENT_KEYDOWN_DISMISS);
  3486. }
  3487. };
  3488. _proto._setResizeEvent = function _setResizeEvent() {
  3489. var _this7 = this;
  3490. if (this._isShown) {
  3491. $(window).on(EVENT_RESIZE, function (event) {
  3492. return _this7.handleUpdate(event);
  3493. });
  3494. } else {
  3495. $(window).off(EVENT_RESIZE);
  3496. }
  3497. };
  3498. _proto._hideModal = function _hideModal() {
  3499. var _this8 = this;
  3500. this._element.style.display = 'none';
  3501. this._element.setAttribute('aria-hidden', true);
  3502. this._element.removeAttribute('aria-modal');
  3503. this._isTransitioning = false;
  3504. this._showBackdrop(function () {
  3505. $(document.body).removeClass(CLASS_NAME_OPEN);
  3506. _this8._resetAdjustments();
  3507. _this8._resetScrollbar();
  3508. $(_this8._element).trigger(EVENT_HIDDEN$2);
  3509. });
  3510. };
  3511. _proto._removeBackdrop = function _removeBackdrop() {
  3512. if (this._backdrop) {
  3513. $(this._backdrop).remove();
  3514. this._backdrop = null;
  3515. }
  3516. };
  3517. _proto._showBackdrop = function _showBackdrop(callback) {
  3518. var _this9 = this;
  3519. var animate = $(this._element).hasClass(CLASS_NAME_FADE$1) ? CLASS_NAME_FADE$1 : '';
  3520. if (this._isShown && this._config.backdrop) {
  3521. this._backdrop = document.createElement('div');
  3522. this._backdrop.className = CLASS_NAME_BACKDROP;
  3523. if (animate) {
  3524. this._backdrop.classList.add(animate);
  3525. }
  3526. $(this._backdrop).appendTo(document.body);
  3527. $(this._element).on(EVENT_CLICK_DISMISS, function (event) {
  3528. if (_this9._ignoreBackdropClick) {
  3529. _this9._ignoreBackdropClick = false;
  3530. return;
  3531. }
  3532. if (event.target !== event.currentTarget) {
  3533. return;
  3534. }
  3535. _this9._triggerBackdropTransition();
  3536. });
  3537. if (animate) {
  3538. Util.reflow(this._backdrop);
  3539. }
  3540. $(this._backdrop).addClass(CLASS_NAME_SHOW$3);
  3541. if (!callback) {
  3542. return;
  3543. }
  3544. if (!animate) {
  3545. callback();
  3546. return;
  3547. }
  3548. var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3549. $(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration);
  3550. } else if (!this._isShown && this._backdrop) {
  3551. $(this._backdrop).removeClass(CLASS_NAME_SHOW$3);
  3552. var callbackRemove = function callbackRemove() {
  3553. _this9._removeBackdrop();
  3554. if (callback) {
  3555. callback();
  3556. }
  3557. };
  3558. if ($(this._element).hasClass(CLASS_NAME_FADE$1)) {
  3559. var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3560. $(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration);
  3561. } else {
  3562. callbackRemove();
  3563. }
  3564. } else if (callback) {
  3565. callback();
  3566. }
  3567. } // ----------------------------------------------------------------------
  3568. // the following methods are used to handle overflowing modals
  3569. // todo (fat): these should probably be refactored out of modal.js
  3570. // ----------------------------------------------------------------------
  3571. ;
  3572. _proto._adjustDialog = function _adjustDialog() {
  3573. var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  3574. if (!this._isBodyOverflowing && isModalOverflowing) {
  3575. this._element.style.paddingLeft = this._scrollbarWidth + "px";
  3576. }
  3577. if (this._isBodyOverflowing && !isModalOverflowing) {
  3578. this._element.style.paddingRight = this._scrollbarWidth + "px";
  3579. }
  3580. };
  3581. _proto._resetAdjustments = function _resetAdjustments() {
  3582. this._element.style.paddingLeft = '';
  3583. this._element.style.paddingRight = '';
  3584. };
  3585. _proto._checkScrollbar = function _checkScrollbar() {
  3586. var rect = document.body.getBoundingClientRect();
  3587. this._isBodyOverflowing = Math.round(rect.left + rect.right) < window.innerWidth;
  3588. this._scrollbarWidth = this._getScrollbarWidth();
  3589. };
  3590. _proto._setScrollbar = function _setScrollbar() {
  3591. var _this10 = this;
  3592. if (this._isBodyOverflowing) {
  3593. // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
  3594. // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
  3595. var fixedContent = [].slice.call(document.querySelectorAll(SELECTOR_FIXED_CONTENT));
  3596. var stickyContent = [].slice.call(document.querySelectorAll(SELECTOR_STICKY_CONTENT)); // Adjust fixed content padding
  3597. $(fixedContent).each(function (index, element) {
  3598. var actualPadding = element.style.paddingRight;
  3599. var calculatedPadding = $(element).css('padding-right');
  3600. $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px");
  3601. }); // Adjust sticky content margin
  3602. $(stickyContent).each(function (index, element) {
  3603. var actualMargin = element.style.marginRight;
  3604. var calculatedMargin = $(element).css('margin-right');
  3605. $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px");
  3606. }); // Adjust body padding
  3607. var actualPadding = document.body.style.paddingRight;
  3608. var calculatedPadding = $(document.body).css('padding-right');
  3609. $(document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px");
  3610. }
  3611. $(document.body).addClass(CLASS_NAME_OPEN);
  3612. };
  3613. _proto._resetScrollbar = function _resetScrollbar() {
  3614. // Restore fixed content padding
  3615. var fixedContent = [].slice.call(document.querySelectorAll(SELECTOR_FIXED_CONTENT));
  3616. $(fixedContent).each(function (index, element) {
  3617. var padding = $(element).data('padding-right');
  3618. $(element).removeData('padding-right');
  3619. element.style.paddingRight = padding ? padding : '';
  3620. }); // Restore sticky content
  3621. var elements = [].slice.call(document.querySelectorAll("" + SELECTOR_STICKY_CONTENT));
  3622. $(elements).each(function (index, element) {
  3623. var margin = $(element).data('margin-right');
  3624. if (typeof margin !== 'undefined') {
  3625. $(element).css('margin-right', margin).removeData('margin-right');
  3626. }
  3627. }); // Restore body padding
  3628. var padding = $(document.body).data('padding-right');
  3629. $(document.body).removeData('padding-right');
  3630. document.body.style.paddingRight = padding ? padding : '';
  3631. };
  3632. _proto._getScrollbarWidth = function _getScrollbarWidth() {
  3633. // thx d.walsh
  3634. var scrollDiv = document.createElement('div');
  3635. scrollDiv.className = CLASS_NAME_SCROLLBAR_MEASURER;
  3636. document.body.appendChild(scrollDiv);
  3637. var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
  3638. document.body.removeChild(scrollDiv);
  3639. return scrollbarWidth;
  3640. } // Static
  3641. ;
  3642. Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) {
  3643. return this.each(function () {
  3644. var data = $(this).data(DATA_KEY$5);
  3645. var _config = _objectSpread2(_objectSpread2(_objectSpread2({}, Default$3), $(this).data()), typeof config === 'object' && config ? config : {});
  3646. if (!data) {
  3647. data = new Modal(this, _config);
  3648. $(this).data(DATA_KEY$5, data);
  3649. }
  3650. if (typeof config === 'string') {
  3651. if (typeof data[config] === 'undefined') {
  3652. throw new TypeError("No method named \"" + config + "\"");
  3653. }
  3654. data[config](relatedTarget);
  3655. } else if (_config.show) {
  3656. data.show(relatedTarget);
  3657. }
  3658. });
  3659. };
  3660. _createClass(Modal, null, [{
  3661. key: "VERSION",
  3662. get: function get() {
  3663. return VERSION$5;
  3664. }
  3665. }, {
  3666. key: "Default",
  3667. get: function get() {
  3668. return Default$3;
  3669. }
  3670. }]);
  3671. return Modal;
  3672. }();
  3673. /**
  3674. * ------------------------------------------------------------------------
  3675. * Data Api implementation
  3676. * ------------------------------------------------------------------------
  3677. */
  3678. $(document).on(EVENT_CLICK_DATA_API$5, SELECTOR_DATA_TOGGLE$3, function (event) {
  3679. var _this11 = this;
  3680. var target;
  3681. var selector = Util.getSelectorFromElement(this);
  3682. if (selector) {
  3683. target = document.querySelector(selector);
  3684. }
  3685. var config = $(target).data(DATA_KEY$5) ? 'toggle' : _objectSpread2(_objectSpread2({}, $(target).data()), $(this).data());
  3686. if (this.tagName === 'A' || this.tagName === 'AREA') {
  3687. event.preventDefault();
  3688. }
  3689. var $target = $(target).one(EVENT_SHOW$2, function (showEvent) {
  3690. if (showEvent.isDefaultPrevented()) {
  3691. // Only register focus restorer if modal will actually get shown
  3692. return;
  3693. }
  3694. $target.one(EVENT_HIDDEN$2, function () {
  3695. if ($(_this11).is(':visible')) {
  3696. _this11.focus();
  3697. }
  3698. });
  3699. });
  3700. Modal._jQueryInterface.call($(target), config, this);
  3701. });
  3702. /**
  3703. * ------------------------------------------------------------------------
  3704. * jQuery
  3705. * ------------------------------------------------------------------------
  3706. */
  3707. $.fn[NAME$5] = Modal._jQueryInterface;
  3708. $.fn[NAME$5].Constructor = Modal;
  3709. $.fn[NAME$5].noConflict = function () {
  3710. $.fn[NAME$5] = JQUERY_NO_CONFLICT$5;
  3711. return Modal._jQueryInterface;
  3712. };
  3713. /**
  3714. * --------------------------------------------------------------------------
  3715. * Bootstrap (v4.5.0): tools/sanitizer.js
  3716. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  3717. * --------------------------------------------------------------------------
  3718. */
  3719. var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href'];
  3720. var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  3721. var DefaultWhitelist = {
  3722. // Global attributes allowed on any supplied element below.
  3723. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  3724. a: ['target', 'href', 'title', 'rel'],
  3725. area: [],
  3726. b: [],
  3727. br: [],
  3728. col: [],
  3729. code: [],
  3730. div: [],
  3731. em: [],
  3732. hr: [],
  3733. h1: [],
  3734. h2: [],
  3735. h3: [],
  3736. h4: [],
  3737. h5: [],
  3738. h6: [],
  3739. i: [],
  3740. img: ['src', 'srcset', 'alt', 'title', 'width', 'height'],
  3741. li: [],
  3742. ol: [],
  3743. p: [],
  3744. pre: [],
  3745. s: [],
  3746. small: [],
  3747. span: [],
  3748. sub: [],
  3749. sup: [],
  3750. strong: [],
  3751. u: [],
  3752. ul: []
  3753. };
  3754. /**
  3755. * A pattern that recognizes a commonly useful subset of URLs that are safe.
  3756. *
  3757. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  3758. */
  3759. var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^#&/:?]*(?:[#/?]|$))/gi;
  3760. /**
  3761. * A pattern that matches safe data URLs. Only matches image, video and audio types.
  3762. *
  3763. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  3764. */
  3765. var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[\d+/a-z]+=*$/i;
  3766. function allowedAttribute(attr, allowedAttributeList) {
  3767. var attrName = attr.nodeName.toLowerCase();
  3768. if (allowedAttributeList.indexOf(attrName) !== -1) {
  3769. if (uriAttrs.indexOf(attrName) !== -1) {
  3770. return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN));
  3771. }
  3772. return true;
  3773. }
  3774. var regExp = allowedAttributeList.filter(function (attrRegex) {
  3775. return attrRegex instanceof RegExp;
  3776. }); // Check if a regular expression validates the attribute.
  3777. for (var i = 0, len = regExp.length; i < len; i++) {
  3778. if (attrName.match(regExp[i])) {
  3779. return true;
  3780. }
  3781. }
  3782. return false;
  3783. }
  3784. function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
  3785. if (unsafeHtml.length === 0) {
  3786. return unsafeHtml;
  3787. }
  3788. if (sanitizeFn && typeof sanitizeFn === 'function') {
  3789. return sanitizeFn(unsafeHtml);
  3790. }
  3791. var domParser = new window.DOMParser();
  3792. var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  3793. var whitelistKeys = Object.keys(whiteList);
  3794. var elements = [].slice.call(createdDocument.body.querySelectorAll('*'));
  3795. var _loop = function _loop(i, len) {
  3796. var el = elements[i];
  3797. var elName = el.nodeName.toLowerCase();
  3798. if (whitelistKeys.indexOf(el.nodeName.toLowerCase()) === -1) {
  3799. el.parentNode.removeChild(el);
  3800. return "continue";
  3801. }
  3802. var attributeList = [].slice.call(el.attributes);
  3803. var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
  3804. attributeList.forEach(function (attr) {
  3805. if (!allowedAttribute(attr, whitelistedAttributes)) {
  3806. el.removeAttribute(attr.nodeName);
  3807. }
  3808. });
  3809. };
  3810. for (var i = 0, len = elements.length; i < len; i++) {
  3811. var _ret = _loop(i);
  3812. if (_ret === "continue") continue;
  3813. }
  3814. return createdDocument.body.innerHTML;
  3815. }
  3816. /**
  3817. * ------------------------------------------------------------------------
  3818. * Constants
  3819. * ------------------------------------------------------------------------
  3820. */
  3821. var NAME$6 = 'tooltip';
  3822. var VERSION$6 = '4.5.0';
  3823. var DATA_KEY$6 = 'bs.tooltip';
  3824. var EVENT_KEY$6 = "." + DATA_KEY$6;
  3825. var JQUERY_NO_CONFLICT$6 = $.fn[NAME$6];
  3826. var CLASS_PREFIX = 'bs-tooltip';
  3827. var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
  3828. var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
  3829. var DefaultType$4 = {
  3830. animation: 'boolean',
  3831. template: 'string',
  3832. title: '(string|element|function)',
  3833. trigger: 'string',
  3834. delay: '(number|object)',
  3835. html: 'boolean',
  3836. selector: '(string|boolean)',
  3837. placement: '(string|function)',
  3838. offset: '(number|string|function)',
  3839. container: '(string|element|boolean)',
  3840. fallbackPlacement: '(string|array)',
  3841. boundary: '(string|element)',
  3842. sanitize: 'boolean',
  3843. sanitizeFn: '(null|function)',
  3844. whiteList: 'object',
  3845. popperConfig: '(null|object)'
  3846. };
  3847. var AttachmentMap = {
  3848. AUTO: 'auto',
  3849. TOP: 'top',
  3850. RIGHT: 'right',
  3851. BOTTOM: 'bottom',
  3852. LEFT: 'left'
  3853. };
  3854. var Default$4 = {
  3855. animation: true,
  3856. template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>',
  3857. trigger: 'hover focus',
  3858. title: '',
  3859. delay: 0,
  3860. html: false,
  3861. selector: false,
  3862. placement: 'top',
  3863. offset: 0,
  3864. container: false,
  3865. fallbackPlacement: 'flip',
  3866. boundary: 'scrollParent',
  3867. sanitize: true,
  3868. sanitizeFn: null,
  3869. whiteList: DefaultWhitelist,
  3870. popperConfig: null
  3871. };
  3872. var HOVER_STATE_SHOW = 'show';
  3873. var HOVER_STATE_OUT = 'out';
  3874. var Event = {
  3875. HIDE: "hide" + EVENT_KEY$6,
  3876. HIDDEN: "hidden" + EVENT_KEY$6,
  3877. SHOW: "show" + EVENT_KEY$6,
  3878. SHOWN: "shown" + EVENT_KEY$6,
  3879. INSERTED: "inserted" + EVENT_KEY$6,
  3880. CLICK: "click" + EVENT_KEY$6,
  3881. FOCUSIN: "focusin" + EVENT_KEY$6,
  3882. FOCUSOUT: "focusout" + EVENT_KEY$6,
  3883. MOUSEENTER: "mouseenter" + EVENT_KEY$6,
  3884. MOUSELEAVE: "mouseleave" + EVENT_KEY$6
  3885. };
  3886. var CLASS_NAME_FADE$2 = 'fade';
  3887. var CLASS_NAME_SHOW$4 = 'show';
  3888. var SELECTOR_TOOLTIP_INNER = '.tooltip-inner';
  3889. var SELECTOR_ARROW = '.arrow';
  3890. var TRIGGER_HOVER = 'hover';
  3891. var TRIGGER_FOCUS = 'focus';
  3892. var TRIGGER_CLICK = 'click';
  3893. var TRIGGER_MANUAL = 'manual';
  3894. /**
  3895. * ------------------------------------------------------------------------
  3896. * Class Definition
  3897. * ------------------------------------------------------------------------
  3898. */
  3899. var Tooltip = /*#__PURE__*/function () {
  3900. function Tooltip(element, config) {
  3901. if (typeof Popper === 'undefined') {
  3902. throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org/)');
  3903. } // private
  3904. this._isEnabled = true;
  3905. this._timeout = 0;
  3906. this._hoverState = '';
  3907. this._activeTrigger = {};
  3908. this._popper = null; // Protected
  3909. this.element = element;
  3910. this.config = this._getConfig(config);
  3911. this.tip = null;
  3912. this._setListeners();
  3913. } // Getters
  3914. var _proto = Tooltip.prototype;
  3915. // Public
  3916. _proto.enable = function enable() {
  3917. this._isEnabled = true;
  3918. };
  3919. _proto.disable = function disable() {
  3920. this._isEnabled = false;
  3921. };
  3922. _proto.toggleEnabled = function toggleEnabled() {
  3923. this._isEnabled = !this._isEnabled;
  3924. };
  3925. _proto.toggle = function toggle(event) {
  3926. if (!this._isEnabled) {
  3927. return;
  3928. }
  3929. if (event) {
  3930. var dataKey = this.constructor.DATA_KEY;
  3931. var context = $(event.currentTarget).data(dataKey);
  3932. if (!context) {
  3933. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  3934. $(event.currentTarget).data(dataKey, context);
  3935. }
  3936. context._activeTrigger.click = !context._activeTrigger.click;
  3937. if (context._isWithActiveTrigger()) {
  3938. context._enter(null, context);
  3939. } else {
  3940. context._leave(null, context);
  3941. }
  3942. } else {
  3943. if ($(this.getTipElement()).hasClass(CLASS_NAME_SHOW$4)) {
  3944. this._leave(null, this);
  3945. return;
  3946. }
  3947. this._enter(null, this);
  3948. }
  3949. };
  3950. _proto.dispose = function dispose() {
  3951. clearTimeout(this._timeout);
  3952. $.removeData(this.element, this.constructor.DATA_KEY);
  3953. $(this.element).off(this.constructor.EVENT_KEY);
  3954. $(this.element).closest('.modal').off('hide.bs.modal', this._hideModalHandler);
  3955. if (this.tip) {
  3956. $(this.tip).remove();
  3957. }
  3958. this._isEnabled = null;
  3959. this._timeout = null;
  3960. this._hoverState = null;
  3961. this._activeTrigger = null;
  3962. if (this._popper) {
  3963. this._popper.destroy();
  3964. }
  3965. this._popper = null;
  3966. this.element = null;
  3967. this.config = null;
  3968. this.tip = null;
  3969. };
  3970. _proto.show = function show() {
  3971. var _this = this;
  3972. if ($(this.element).css('display') === 'none') {
  3973. throw new Error('Please use show on visible elements');
  3974. }
  3975. var showEvent = $.Event(this.constructor.Event.SHOW);
  3976. if (this.isWithContent() && this._isEnabled) {
  3977. $(this.element).trigger(showEvent);
  3978. var shadowRoot = Util.findShadowRoot(this.element);
  3979. var isInTheDom = $.contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element);
  3980. if (showEvent.isDefaultPrevented() || !isInTheDom) {
  3981. return;
  3982. }
  3983. var tip = this.getTipElement();
  3984. var tipId = Util.getUID(this.constructor.NAME);
  3985. tip.setAttribute('id', tipId);
  3986. this.element.setAttribute('aria-describedby', tipId);
  3987. this.setContent();
  3988. if (this.config.animation) {
  3989. $(tip).addClass(CLASS_NAME_FADE$2);
  3990. }
  3991. var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
  3992. var attachment = this._getAttachment(placement);
  3993. this.addAttachmentClass(attachment);
  3994. var container = this._getContainer();
  3995. $(tip).data(this.constructor.DATA_KEY, this);
  3996. if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) {
  3997. $(tip).appendTo(container);
  3998. }
  3999. $(this.element).trigger(this.constructor.Event.INSERTED);
  4000. this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment));
  4001. $(tip).addClass(CLASS_NAME_SHOW$4); // If this is a touch-enabled device we add extra
  4002. // empty mouseover listeners to the body's immediate children;
  4003. // only needed because of broken event delegation on iOS
  4004. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  4005. if ('ontouchstart' in document.documentElement) {
  4006. $(document.body).children().on('mouseover', null, $.noop);
  4007. }
  4008. var complete = function complete() {
  4009. if (_this.config.animation) {
  4010. _this._fixTransition();
  4011. }
  4012. var prevHoverState = _this._hoverState;
  4013. _this._hoverState = null;
  4014. $(_this.element).trigger(_this.constructor.Event.SHOWN);
  4015. if (prevHoverState === HOVER_STATE_OUT) {
  4016. _this._leave(null, _this);
  4017. }
  4018. };
  4019. if ($(this.tip).hasClass(CLASS_NAME_FADE$2)) {
  4020. var transitionDuration = Util.getTransitionDurationFromElement(this.tip);
  4021. $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4022. } else {
  4023. complete();
  4024. }
  4025. }
  4026. };
  4027. _proto.hide = function hide(callback) {
  4028. var _this2 = this;
  4029. var tip = this.getTipElement();
  4030. var hideEvent = $.Event(this.constructor.Event.HIDE);
  4031. var complete = function complete() {
  4032. if (_this2._hoverState !== HOVER_STATE_SHOW && tip.parentNode) {
  4033. tip.parentNode.removeChild(tip);
  4034. }
  4035. _this2._cleanTipClass();
  4036. _this2.element.removeAttribute('aria-describedby');
  4037. $(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
  4038. if (_this2._popper !== null) {
  4039. _this2._popper.destroy();
  4040. }
  4041. if (callback) {
  4042. callback();
  4043. }
  4044. };
  4045. $(this.element).trigger(hideEvent);
  4046. if (hideEvent.isDefaultPrevented()) {
  4047. return;
  4048. }
  4049. $(tip).removeClass(CLASS_NAME_SHOW$4); // If this is a touch-enabled device we remove the extra
  4050. // empty mouseover listeners we added for iOS support
  4051. if ('ontouchstart' in document.documentElement) {
  4052. $(document.body).children().off('mouseover', null, $.noop);
  4053. }
  4054. this._activeTrigger[TRIGGER_CLICK] = false;
  4055. this._activeTrigger[TRIGGER_FOCUS] = false;
  4056. this._activeTrigger[TRIGGER_HOVER] = false;
  4057. if ($(this.tip).hasClass(CLASS_NAME_FADE$2)) {
  4058. var transitionDuration = Util.getTransitionDurationFromElement(tip);
  4059. $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4060. } else {
  4061. complete();
  4062. }
  4063. this._hoverState = '';
  4064. };
  4065. _proto.update = function update() {
  4066. if (this._popper !== null) {
  4067. this._popper.scheduleUpdate();
  4068. }
  4069. } // Protected
  4070. ;
  4071. _proto.isWithContent = function isWithContent() {
  4072. return Boolean(this.getTitle());
  4073. };
  4074. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4075. $(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
  4076. };
  4077. _proto.getTipElement = function getTipElement() {
  4078. this.tip = this.tip || $(this.config.template)[0];
  4079. return this.tip;
  4080. };
  4081. _proto.setContent = function setContent() {
  4082. var tip = this.getTipElement();
  4083. this.setElementContent($(tip.querySelectorAll(SELECTOR_TOOLTIP_INNER)), this.getTitle());
  4084. $(tip).removeClass(CLASS_NAME_FADE$2 + " " + CLASS_NAME_SHOW$4);
  4085. };
  4086. _proto.setElementContent = function setElementContent($element, content) {
  4087. if (typeof content === 'object' && (content.nodeType || content.jquery)) {
  4088. // Content is a DOM node or a jQuery
  4089. if (this.config.html) {
  4090. if (!$(content).parent().is($element)) {
  4091. $element.empty().append(content);
  4092. }
  4093. } else {
  4094. $element.text($(content).text());
  4095. }
  4096. return;
  4097. }
  4098. if (this.config.html) {
  4099. if (this.config.sanitize) {
  4100. content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn);
  4101. }
  4102. $element.html(content);
  4103. } else {
  4104. $element.text(content);
  4105. }
  4106. };
  4107. _proto.getTitle = function getTitle() {
  4108. var title = this.element.getAttribute('data-original-title');
  4109. if (!title) {
  4110. title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
  4111. }
  4112. return title;
  4113. } // Private
  4114. ;
  4115. _proto._getPopperConfig = function _getPopperConfig(attachment) {
  4116. var _this3 = this;
  4117. var defaultBsConfig = {
  4118. placement: attachment,
  4119. modifiers: {
  4120. offset: this._getOffset(),
  4121. flip: {
  4122. behavior: this.config.fallbackPlacement
  4123. },
  4124. arrow: {
  4125. element: SELECTOR_ARROW
  4126. },
  4127. preventOverflow: {
  4128. boundariesElement: this.config.boundary
  4129. }
  4130. },
  4131. onCreate: function onCreate(data) {
  4132. if (data.originalPlacement !== data.placement) {
  4133. _this3._handlePopperPlacementChange(data);
  4134. }
  4135. },
  4136. onUpdate: function onUpdate(data) {
  4137. return _this3._handlePopperPlacementChange(data);
  4138. }
  4139. };
  4140. return _objectSpread2(_objectSpread2({}, defaultBsConfig), this.config.popperConfig);
  4141. };
  4142. _proto._getOffset = function _getOffset() {
  4143. var _this4 = this;
  4144. var offset = {};
  4145. if (typeof this.config.offset === 'function') {
  4146. offset.fn = function (data) {
  4147. data.offsets = _objectSpread2(_objectSpread2({}, data.offsets), _this4.config.offset(data.offsets, _this4.element) || {});
  4148. return data;
  4149. };
  4150. } else {
  4151. offset.offset = this.config.offset;
  4152. }
  4153. return offset;
  4154. };
  4155. _proto._getContainer = function _getContainer() {
  4156. if (this.config.container === false) {
  4157. return document.body;
  4158. }
  4159. if (Util.isElement(this.config.container)) {
  4160. return $(this.config.container);
  4161. }
  4162. return $(document).find(this.config.container);
  4163. };
  4164. _proto._getAttachment = function _getAttachment(placement) {
  4165. return AttachmentMap[placement.toUpperCase()];
  4166. };
  4167. _proto._setListeners = function _setListeners() {
  4168. var _this5 = this;
  4169. var triggers = this.config.trigger.split(' ');
  4170. triggers.forEach(function (trigger) {
  4171. if (trigger === 'click') {
  4172. $(_this5.element).on(_this5.constructor.Event.CLICK, _this5.config.selector, function (event) {
  4173. return _this5.toggle(event);
  4174. });
  4175. } else if (trigger !== TRIGGER_MANUAL) {
  4176. var eventIn = trigger === TRIGGER_HOVER ? _this5.constructor.Event.MOUSEENTER : _this5.constructor.Event.FOCUSIN;
  4177. var eventOut = trigger === TRIGGER_HOVER ? _this5.constructor.Event.MOUSELEAVE : _this5.constructor.Event.FOCUSOUT;
  4178. $(_this5.element).on(eventIn, _this5.config.selector, function (event) {
  4179. return _this5._enter(event);
  4180. }).on(eventOut, _this5.config.selector, function (event) {
  4181. return _this5._leave(event);
  4182. });
  4183. }
  4184. });
  4185. this._hideModalHandler = function () {
  4186. if (_this5.element) {
  4187. _this5.hide();
  4188. }
  4189. };
  4190. $(this.element).closest('.modal').on('hide.bs.modal', this._hideModalHandler);
  4191. if (this.config.selector) {
  4192. this.config = _objectSpread2(_objectSpread2({}, this.config), {}, {
  4193. trigger: 'manual',
  4194. selector: ''
  4195. });
  4196. } else {
  4197. this._fixTitle();
  4198. }
  4199. };
  4200. _proto._fixTitle = function _fixTitle() {
  4201. var titleType = typeof this.element.getAttribute('data-original-title');
  4202. if (this.element.getAttribute('title') || titleType !== 'string') {
  4203. this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
  4204. this.element.setAttribute('title', '');
  4205. }
  4206. };
  4207. _proto._enter = function _enter(event, context) {
  4208. var dataKey = this.constructor.DATA_KEY;
  4209. context = context || $(event.currentTarget).data(dataKey);
  4210. if (!context) {
  4211. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4212. $(event.currentTarget).data(dataKey, context);
  4213. }
  4214. if (event) {
  4215. context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true;
  4216. }
  4217. if ($(context.getTipElement()).hasClass(CLASS_NAME_SHOW$4) || context._hoverState === HOVER_STATE_SHOW) {
  4218. context._hoverState = HOVER_STATE_SHOW;
  4219. return;
  4220. }
  4221. clearTimeout(context._timeout);
  4222. context._hoverState = HOVER_STATE_SHOW;
  4223. if (!context.config.delay || !context.config.delay.show) {
  4224. context.show();
  4225. return;
  4226. }
  4227. context._timeout = setTimeout(function () {
  4228. if (context._hoverState === HOVER_STATE_SHOW) {
  4229. context.show();
  4230. }
  4231. }, context.config.delay.show);
  4232. };
  4233. _proto._leave = function _leave(event, context) {
  4234. var dataKey = this.constructor.DATA_KEY;
  4235. context = context || $(event.currentTarget).data(dataKey);
  4236. if (!context) {
  4237. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4238. $(event.currentTarget).data(dataKey, context);
  4239. }
  4240. if (event) {
  4241. context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = false;
  4242. }
  4243. if (context._isWithActiveTrigger()) {
  4244. return;
  4245. }
  4246. clearTimeout(context._timeout);
  4247. context._hoverState = HOVER_STATE_OUT;
  4248. if (!context.config.delay || !context.config.delay.hide) {
  4249. context.hide();
  4250. return;
  4251. }
  4252. context._timeout = setTimeout(function () {
  4253. if (context._hoverState === HOVER_STATE_OUT) {
  4254. context.hide();
  4255. }
  4256. }, context.config.delay.hide);
  4257. };
  4258. _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
  4259. for (var trigger in this._activeTrigger) {
  4260. if (this._activeTrigger[trigger]) {
  4261. return true;
  4262. }
  4263. }
  4264. return false;
  4265. };
  4266. _proto._getConfig = function _getConfig(config) {
  4267. var dataAttributes = $(this.element).data();
  4268. Object.keys(dataAttributes).forEach(function (dataAttr) {
  4269. if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
  4270. delete dataAttributes[dataAttr];
  4271. }
  4272. });
  4273. config = _objectSpread2(_objectSpread2(_objectSpread2({}, this.constructor.Default), dataAttributes), typeof config === 'object' && config ? config : {});
  4274. if (typeof config.delay === 'number') {
  4275. config.delay = {
  4276. show: config.delay,
  4277. hide: config.delay
  4278. };
  4279. }
  4280. if (typeof config.title === 'number') {
  4281. config.title = config.title.toString();
  4282. }
  4283. if (typeof config.content === 'number') {
  4284. config.content = config.content.toString();
  4285. }
  4286. Util.typeCheckConfig(NAME$6, config, this.constructor.DefaultType);
  4287. if (config.sanitize) {
  4288. config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn);
  4289. }
  4290. return config;
  4291. };
  4292. _proto._getDelegateConfig = function _getDelegateConfig() {
  4293. var config = {};
  4294. if (this.config) {
  4295. for (var key in this.config) {
  4296. if (this.constructor.Default[key] !== this.config[key]) {
  4297. config[key] = this.config[key];
  4298. }
  4299. }
  4300. }
  4301. return config;
  4302. };
  4303. _proto._cleanTipClass = function _cleanTipClass() {
  4304. var $tip = $(this.getTipElement());
  4305. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
  4306. if (tabClass !== null && tabClass.length) {
  4307. $tip.removeClass(tabClass.join(''));
  4308. }
  4309. };
  4310. _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
  4311. this.tip = popperData.instance.popper;
  4312. this._cleanTipClass();
  4313. this.addAttachmentClass(this._getAttachment(popperData.placement));
  4314. };
  4315. _proto._fixTransition = function _fixTransition() {
  4316. var tip = this.getTipElement();
  4317. var initConfigAnimation = this.config.animation;
  4318. if (tip.getAttribute('x-placement') !== null) {
  4319. return;
  4320. }
  4321. $(tip).removeClass(CLASS_NAME_FADE$2);
  4322. this.config.animation = false;
  4323. this.hide();
  4324. this.show();
  4325. this.config.animation = initConfigAnimation;
  4326. } // Static
  4327. ;
  4328. Tooltip._jQueryInterface = function _jQueryInterface(config) {
  4329. return this.each(function () {
  4330. var data = $(this).data(DATA_KEY$6);
  4331. var _config = typeof config === 'object' && config;
  4332. if (!data && /dispose|hide/.test(config)) {
  4333. return;
  4334. }
  4335. if (!data) {
  4336. data = new Tooltip(this, _config);
  4337. $(this).data(DATA_KEY$6, data);
  4338. }
  4339. if (typeof config === 'string') {
  4340. if (typeof data[config] === 'undefined') {
  4341. throw new TypeError("No method named \"" + config + "\"");
  4342. }
  4343. data[config]();
  4344. }
  4345. });
  4346. };
  4347. _createClass(Tooltip, null, [{
  4348. key: "VERSION",
  4349. get: function get() {
  4350. return VERSION$6;
  4351. }
  4352. }, {
  4353. key: "Default",
  4354. get: function get() {
  4355. return Default$4;
  4356. }
  4357. }, {
  4358. key: "NAME",
  4359. get: function get() {
  4360. return NAME$6;
  4361. }
  4362. }, {
  4363. key: "DATA_KEY",
  4364. get: function get() {
  4365. return DATA_KEY$6;
  4366. }
  4367. }, {
  4368. key: "Event",
  4369. get: function get() {
  4370. return Event;
  4371. }
  4372. }, {
  4373. key: "EVENT_KEY",
  4374. get: function get() {
  4375. return EVENT_KEY$6;
  4376. }
  4377. }, {
  4378. key: "DefaultType",
  4379. get: function get() {
  4380. return DefaultType$4;
  4381. }
  4382. }]);
  4383. return Tooltip;
  4384. }();
  4385. /**
  4386. * ------------------------------------------------------------------------
  4387. * jQuery
  4388. * ------------------------------------------------------------------------
  4389. */
  4390. $.fn[NAME$6] = Tooltip._jQueryInterface;
  4391. $.fn[NAME$6].Constructor = Tooltip;
  4392. $.fn[NAME$6].noConflict = function () {
  4393. $.fn[NAME$6] = JQUERY_NO_CONFLICT$6;
  4394. return Tooltip._jQueryInterface;
  4395. };
  4396. /**
  4397. * ------------------------------------------------------------------------
  4398. * Constants
  4399. * ------------------------------------------------------------------------
  4400. */
  4401. var NAME$7 = 'popover';
  4402. var VERSION$7 = '4.5.0';
  4403. var DATA_KEY$7 = 'bs.popover';
  4404. var EVENT_KEY$7 = "." + DATA_KEY$7;
  4405. var JQUERY_NO_CONFLICT$7 = $.fn[NAME$7];
  4406. var CLASS_PREFIX$1 = 'bs-popover';
  4407. var BSCLS_PREFIX_REGEX$1 = new RegExp("(^|\\s)" + CLASS_PREFIX$1 + "\\S+", 'g');
  4408. var Default$5 = _objectSpread2(_objectSpread2({}, Tooltip.Default), {}, {
  4409. placement: 'right',
  4410. trigger: 'click',
  4411. content: '',
  4412. template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
  4413. });
  4414. var DefaultType$5 = _objectSpread2(_objectSpread2({}, Tooltip.DefaultType), {}, {
  4415. content: '(string|element|function)'
  4416. });
  4417. var CLASS_NAME_FADE$3 = 'fade';
  4418. var CLASS_NAME_SHOW$5 = 'show';
  4419. var SELECTOR_TITLE = '.popover-header';
  4420. var SELECTOR_CONTENT = '.popover-body';
  4421. var Event$1 = {
  4422. HIDE: "hide" + EVENT_KEY$7,
  4423. HIDDEN: "hidden" + EVENT_KEY$7,
  4424. SHOW: "show" + EVENT_KEY$7,
  4425. SHOWN: "shown" + EVENT_KEY$7,
  4426. INSERTED: "inserted" + EVENT_KEY$7,
  4427. CLICK: "click" + EVENT_KEY$7,
  4428. FOCUSIN: "focusin" + EVENT_KEY$7,
  4429. FOCUSOUT: "focusout" + EVENT_KEY$7,
  4430. MOUSEENTER: "mouseenter" + EVENT_KEY$7,
  4431. MOUSELEAVE: "mouseleave" + EVENT_KEY$7
  4432. };
  4433. /**
  4434. * ------------------------------------------------------------------------
  4435. * Class Definition
  4436. * ------------------------------------------------------------------------
  4437. */
  4438. var Popover = /*#__PURE__*/function (_Tooltip) {
  4439. _inheritsLoose(Popover, _Tooltip);
  4440. function Popover() {
  4441. return _Tooltip.apply(this, arguments) || this;
  4442. }
  4443. var _proto = Popover.prototype;
  4444. // Overrides
  4445. _proto.isWithContent = function isWithContent() {
  4446. return this.getTitle() || this._getContent();
  4447. };
  4448. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4449. $(this.getTipElement()).addClass(CLASS_PREFIX$1 + "-" + attachment);
  4450. };
  4451. _proto.getTipElement = function getTipElement() {
  4452. this.tip = this.tip || $(this.config.template)[0];
  4453. return this.tip;
  4454. };
  4455. _proto.setContent = function setContent() {
  4456. var $tip = $(this.getTipElement()); // We use append for html objects to maintain js events
  4457. this.setElementContent($tip.find(SELECTOR_TITLE), this.getTitle());
  4458. var content = this._getContent();
  4459. if (typeof content === 'function') {
  4460. content = content.call(this.element);
  4461. }
  4462. this.setElementContent($tip.find(SELECTOR_CONTENT), content);
  4463. $tip.removeClass(CLASS_NAME_FADE$3 + " " + CLASS_NAME_SHOW$5);
  4464. } // Private
  4465. ;
  4466. _proto._getContent = function _getContent() {
  4467. return this.element.getAttribute('data-content') || this.config.content;
  4468. };
  4469. _proto._cleanTipClass = function _cleanTipClass() {
  4470. var $tip = $(this.getTipElement());
  4471. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX$1);
  4472. if (tabClass !== null && tabClass.length > 0) {
  4473. $tip.removeClass(tabClass.join(''));
  4474. }
  4475. } // Static
  4476. ;
  4477. Popover._jQueryInterface = function _jQueryInterface(config) {
  4478. return this.each(function () {
  4479. var data = $(this).data(DATA_KEY$7);
  4480. var _config = typeof config === 'object' ? config : null;
  4481. if (!data && /dispose|hide/.test(config)) {
  4482. return;
  4483. }
  4484. if (!data) {
  4485. data = new Popover(this, _config);
  4486. $(this).data(DATA_KEY$7, data);
  4487. }
  4488. if (typeof config === 'string') {
  4489. if (typeof data[config] === 'undefined') {
  4490. throw new TypeError("No method named \"" + config + "\"");
  4491. }
  4492. data[config]();
  4493. }
  4494. });
  4495. };
  4496. _createClass(Popover, null, [{
  4497. key: "VERSION",
  4498. // Getters
  4499. get: function get() {
  4500. return VERSION$7;
  4501. }
  4502. }, {
  4503. key: "Default",
  4504. get: function get() {
  4505. return Default$5;
  4506. }
  4507. }, {
  4508. key: "NAME",
  4509. get: function get() {
  4510. return NAME$7;
  4511. }
  4512. }, {
  4513. key: "DATA_KEY",
  4514. get: function get() {
  4515. return DATA_KEY$7;
  4516. }
  4517. }, {
  4518. key: "Event",
  4519. get: function get() {
  4520. return Event$1;
  4521. }
  4522. }, {
  4523. key: "EVENT_KEY",
  4524. get: function get() {
  4525. return EVENT_KEY$7;
  4526. }
  4527. }, {
  4528. key: "DefaultType",
  4529. get: function get() {
  4530. return DefaultType$5;
  4531. }
  4532. }]);
  4533. return Popover;
  4534. }(Tooltip);
  4535. /**
  4536. * ------------------------------------------------------------------------
  4537. * jQuery
  4538. * ------------------------------------------------------------------------
  4539. */
  4540. $.fn[NAME$7] = Popover._jQueryInterface;
  4541. $.fn[NAME$7].Constructor = Popover;
  4542. $.fn[NAME$7].noConflict = function () {
  4543. $.fn[NAME$7] = JQUERY_NO_CONFLICT$7;
  4544. return Popover._jQueryInterface;
  4545. };
  4546. /**
  4547. * ------------------------------------------------------------------------
  4548. * Constants
  4549. * ------------------------------------------------------------------------
  4550. */
  4551. var NAME$8 = 'scrollspy';
  4552. var VERSION$8 = '4.5.0';
  4553. var DATA_KEY$8 = 'bs.scrollspy';
  4554. var EVENT_KEY$8 = "." + DATA_KEY$8;
  4555. var DATA_API_KEY$6 = '.data-api';
  4556. var JQUERY_NO_CONFLICT$8 = $.fn[NAME$8];
  4557. var Default$6 = {
  4558. offset: 10,
  4559. method: 'auto',
  4560. target: ''
  4561. };
  4562. var DefaultType$6 = {
  4563. offset: 'number',
  4564. method: 'string',
  4565. target: '(string|element)'
  4566. };
  4567. var EVENT_ACTIVATE = "activate" + EVENT_KEY$8;
  4568. var EVENT_SCROLL = "scroll" + EVENT_KEY$8;
  4569. var EVENT_LOAD_DATA_API$2 = "load" + EVENT_KEY$8 + DATA_API_KEY$6;
  4570. var CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item';
  4571. var CLASS_NAME_ACTIVE$2 = 'active';
  4572. var SELECTOR_DATA_SPY = '[data-spy="scroll"]';
  4573. var SELECTOR_NAV_LIST_GROUP = '.nav, .list-group';
  4574. var SELECTOR_NAV_LINKS = '.nav-link';
  4575. var SELECTOR_NAV_ITEMS = '.nav-item';
  4576. var SELECTOR_LIST_ITEMS = '.list-group-item';
  4577. var SELECTOR_DROPDOWN = '.dropdown';
  4578. var SELECTOR_DROPDOWN_ITEMS = '.dropdown-item';
  4579. var SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
  4580. var METHOD_OFFSET = 'offset';
  4581. var METHOD_POSITION = 'position';
  4582. /**
  4583. * ------------------------------------------------------------------------
  4584. * Class Definition
  4585. * ------------------------------------------------------------------------
  4586. */
  4587. var ScrollSpy = /*#__PURE__*/function () {
  4588. function ScrollSpy(element, config) {
  4589. var _this = this;
  4590. this._element = element;
  4591. this._scrollElement = element.tagName === 'BODY' ? window : element;
  4592. this._config = this._getConfig(config);
  4593. this._selector = this._config.target + " " + SELECTOR_NAV_LINKS + "," + (this._config.target + " " + SELECTOR_LIST_ITEMS + ",") + (this._config.target + " " + SELECTOR_DROPDOWN_ITEMS);
  4594. this._offsets = [];
  4595. this._targets = [];
  4596. this._activeTarget = null;
  4597. this._scrollHeight = 0;
  4598. $(this._scrollElement).on(EVENT_SCROLL, function (event) {
  4599. return _this._process(event);
  4600. });
  4601. this.refresh();
  4602. this._process();
  4603. } // Getters
  4604. var _proto = ScrollSpy.prototype;
  4605. // Public
  4606. _proto.refresh = function refresh() {
  4607. var _this2 = this;
  4608. var autoMethod = this._scrollElement === this._scrollElement.window ? METHOD_OFFSET : METHOD_POSITION;
  4609. var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
  4610. var offsetBase = offsetMethod === METHOD_POSITION ? this._getScrollTop() : 0;
  4611. this._offsets = [];
  4612. this._targets = [];
  4613. this._scrollHeight = this._getScrollHeight();
  4614. var targets = [].slice.call(document.querySelectorAll(this._selector));
  4615. targets.map(function (element) {
  4616. var target;
  4617. var targetSelector = Util.getSelectorFromElement(element);
  4618. if (targetSelector) {
  4619. target = document.querySelector(targetSelector);
  4620. }
  4621. if (target) {
  4622. var targetBCR = target.getBoundingClientRect();
  4623. if (targetBCR.width || targetBCR.height) {
  4624. // TODO (fat): remove sketch reliance on jQuery position/offset
  4625. return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
  4626. }
  4627. }
  4628. return null;
  4629. }).filter(function (item) {
  4630. return item;
  4631. }).sort(function (a, b) {
  4632. return a[0] - b[0];
  4633. }).forEach(function (item) {
  4634. _this2._offsets.push(item[0]);
  4635. _this2._targets.push(item[1]);
  4636. });
  4637. };
  4638. _proto.dispose = function dispose() {
  4639. $.removeData(this._element, DATA_KEY$8);
  4640. $(this._scrollElement).off(EVENT_KEY$8);
  4641. this._element = null;
  4642. this._scrollElement = null;
  4643. this._config = null;
  4644. this._selector = null;
  4645. this._offsets = null;
  4646. this._targets = null;
  4647. this._activeTarget = null;
  4648. this._scrollHeight = null;
  4649. } // Private
  4650. ;
  4651. _proto._getConfig = function _getConfig(config) {
  4652. config = _objectSpread2(_objectSpread2({}, Default$6), typeof config === 'object' && config ? config : {});
  4653. if (typeof config.target !== 'string' && Util.isElement(config.target)) {
  4654. var id = $(config.target).attr('id');
  4655. if (!id) {
  4656. id = Util.getUID(NAME$8);
  4657. $(config.target).attr('id', id);
  4658. }
  4659. config.target = "#" + id;
  4660. }
  4661. Util.typeCheckConfig(NAME$8, config, DefaultType$6);
  4662. return config;
  4663. };
  4664. _proto._getScrollTop = function _getScrollTop() {
  4665. return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
  4666. };
  4667. _proto._getScrollHeight = function _getScrollHeight() {
  4668. return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
  4669. };
  4670. _proto._getOffsetHeight = function _getOffsetHeight() {
  4671. return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
  4672. };
  4673. _proto._process = function _process() {
  4674. var scrollTop = this._getScrollTop() + this._config.offset;
  4675. var scrollHeight = this._getScrollHeight();
  4676. var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
  4677. if (this._scrollHeight !== scrollHeight) {
  4678. this.refresh();
  4679. }
  4680. if (scrollTop >= maxScroll) {
  4681. var target = this._targets[this._targets.length - 1];
  4682. if (this._activeTarget !== target) {
  4683. this._activate(target);
  4684. }
  4685. return;
  4686. }
  4687. if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
  4688. this._activeTarget = null;
  4689. this._clear();
  4690. return;
  4691. }
  4692. for (var i = this._offsets.length; i--;) {
  4693. var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
  4694. if (isActiveTarget) {
  4695. this._activate(this._targets[i]);
  4696. }
  4697. }
  4698. };
  4699. _proto._activate = function _activate(target) {
  4700. this._activeTarget = target;
  4701. this._clear();
  4702. var queries = this._selector.split(',').map(function (selector) {
  4703. return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]";
  4704. });
  4705. var $link = $([].slice.call(document.querySelectorAll(queries.join(','))));
  4706. if ($link.hasClass(CLASS_NAME_DROPDOWN_ITEM)) {
  4707. $link.closest(SELECTOR_DROPDOWN).find(SELECTOR_DROPDOWN_TOGGLE).addClass(CLASS_NAME_ACTIVE$2);
  4708. $link.addClass(CLASS_NAME_ACTIVE$2);
  4709. } else {
  4710. // Set triggered link as active
  4711. $link.addClass(CLASS_NAME_ACTIVE$2); // Set triggered links parents as active
  4712. // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
  4713. $link.parents(SELECTOR_NAV_LIST_GROUP).prev(SELECTOR_NAV_LINKS + ", " + SELECTOR_LIST_ITEMS).addClass(CLASS_NAME_ACTIVE$2); // Handle special case when .nav-link is inside .nav-item
  4714. $link.parents(SELECTOR_NAV_LIST_GROUP).prev(SELECTOR_NAV_ITEMS).children(SELECTOR_NAV_LINKS).addClass(CLASS_NAME_ACTIVE$2);
  4715. }
  4716. $(this._scrollElement).trigger(EVENT_ACTIVATE, {
  4717. relatedTarget: target
  4718. });
  4719. };
  4720. _proto._clear = function _clear() {
  4721. [].slice.call(document.querySelectorAll(this._selector)).filter(function (node) {
  4722. return node.classList.contains(CLASS_NAME_ACTIVE$2);
  4723. }).forEach(function (node) {
  4724. return node.classList.remove(CLASS_NAME_ACTIVE$2);
  4725. });
  4726. } // Static
  4727. ;
  4728. ScrollSpy._jQueryInterface = function _jQueryInterface(config) {
  4729. return this.each(function () {
  4730. var data = $(this).data(DATA_KEY$8);
  4731. var _config = typeof config === 'object' && config;
  4732. if (!data) {
  4733. data = new ScrollSpy(this, _config);
  4734. $(this).data(DATA_KEY$8, data);
  4735. }
  4736. if (typeof config === 'string') {
  4737. if (typeof data[config] === 'undefined') {
  4738. throw new TypeError("No method named \"" + config + "\"");
  4739. }
  4740. data[config]();
  4741. }
  4742. });
  4743. };
  4744. _createClass(ScrollSpy, null, [{
  4745. key: "VERSION",
  4746. get: function get() {
  4747. return VERSION$8;
  4748. }
  4749. }, {
  4750. key: "Default",
  4751. get: function get() {
  4752. return Default$6;
  4753. }
  4754. }]);
  4755. return ScrollSpy;
  4756. }();
  4757. /**
  4758. * ------------------------------------------------------------------------
  4759. * Data Api implementation
  4760. * ------------------------------------------------------------------------
  4761. */
  4762. $(window).on(EVENT_LOAD_DATA_API$2, function () {
  4763. var scrollSpys = [].slice.call(document.querySelectorAll(SELECTOR_DATA_SPY));
  4764. var scrollSpysLength = scrollSpys.length;
  4765. for (var i = scrollSpysLength; i--;) {
  4766. var $spy = $(scrollSpys[i]);
  4767. ScrollSpy._jQueryInterface.call($spy, $spy.data());
  4768. }
  4769. });
  4770. /**
  4771. * ------------------------------------------------------------------------
  4772. * jQuery
  4773. * ------------------------------------------------------------------------
  4774. */
  4775. $.fn[NAME$8] = ScrollSpy._jQueryInterface;
  4776. $.fn[NAME$8].Constructor = ScrollSpy;
  4777. $.fn[NAME$8].noConflict = function () {
  4778. $.fn[NAME$8] = JQUERY_NO_CONFLICT$8;
  4779. return ScrollSpy._jQueryInterface;
  4780. };
  4781. /**
  4782. * ------------------------------------------------------------------------
  4783. * Constants
  4784. * ------------------------------------------------------------------------
  4785. */
  4786. var NAME$9 = 'tab';
  4787. var VERSION$9 = '4.5.0';
  4788. var DATA_KEY$9 = 'bs.tab';
  4789. var EVENT_KEY$9 = "." + DATA_KEY$9;
  4790. var DATA_API_KEY$7 = '.data-api';
  4791. var JQUERY_NO_CONFLICT$9 = $.fn[NAME$9];
  4792. var EVENT_HIDE$3 = "hide" + EVENT_KEY$9;
  4793. var EVENT_HIDDEN$3 = "hidden" + EVENT_KEY$9;
  4794. var EVENT_SHOW$3 = "show" + EVENT_KEY$9;
  4795. var EVENT_SHOWN$3 = "shown" + EVENT_KEY$9;
  4796. var EVENT_CLICK_DATA_API$6 = "click" + EVENT_KEY$9 + DATA_API_KEY$7;
  4797. var CLASS_NAME_DROPDOWN_MENU = 'dropdown-menu';
  4798. var CLASS_NAME_ACTIVE$3 = 'active';
  4799. var CLASS_NAME_DISABLED$1 = 'disabled';
  4800. var CLASS_NAME_FADE$4 = 'fade';
  4801. var CLASS_NAME_SHOW$6 = 'show';
  4802. var SELECTOR_DROPDOWN$1 = '.dropdown';
  4803. var SELECTOR_NAV_LIST_GROUP$1 = '.nav, .list-group';
  4804. var SELECTOR_ACTIVE$2 = '.active';
  4805. var SELECTOR_ACTIVE_UL = '> li > .active';
  4806. var SELECTOR_DATA_TOGGLE$4 = '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]';
  4807. var SELECTOR_DROPDOWN_TOGGLE$1 = '.dropdown-toggle';
  4808. var SELECTOR_DROPDOWN_ACTIVE_CHILD = '> .dropdown-menu .active';
  4809. /**
  4810. * ------------------------------------------------------------------------
  4811. * Class Definition
  4812. * ------------------------------------------------------------------------
  4813. */
  4814. var Tab = /*#__PURE__*/function () {
  4815. function Tab(element) {
  4816. this._element = element;
  4817. } // Getters
  4818. var _proto = Tab.prototype;
  4819. // Public
  4820. _proto.show = function show() {
  4821. var _this = this;
  4822. if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(CLASS_NAME_ACTIVE$3) || $(this._element).hasClass(CLASS_NAME_DISABLED$1)) {
  4823. return;
  4824. }
  4825. var target;
  4826. var previous;
  4827. var listElement = $(this._element).closest(SELECTOR_NAV_LIST_GROUP$1)[0];
  4828. var selector = Util.getSelectorFromElement(this._element);
  4829. if (listElement) {
  4830. var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? SELECTOR_ACTIVE_UL : SELECTOR_ACTIVE$2;
  4831. previous = $.makeArray($(listElement).find(itemSelector));
  4832. previous = previous[previous.length - 1];
  4833. }
  4834. var hideEvent = $.Event(EVENT_HIDE$3, {
  4835. relatedTarget: this._element
  4836. });
  4837. var showEvent = $.Event(EVENT_SHOW$3, {
  4838. relatedTarget: previous
  4839. });
  4840. if (previous) {
  4841. $(previous).trigger(hideEvent);
  4842. }
  4843. $(this._element).trigger(showEvent);
  4844. if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) {
  4845. return;
  4846. }
  4847. if (selector) {
  4848. target = document.querySelector(selector);
  4849. }
  4850. this._activate(this._element, listElement);
  4851. var complete = function complete() {
  4852. var hiddenEvent = $.Event(EVENT_HIDDEN$3, {
  4853. relatedTarget: _this._element
  4854. });
  4855. var shownEvent = $.Event(EVENT_SHOWN$3, {
  4856. relatedTarget: previous
  4857. });
  4858. $(previous).trigger(hiddenEvent);
  4859. $(_this._element).trigger(shownEvent);
  4860. };
  4861. if (target) {
  4862. this._activate(target, target.parentNode, complete);
  4863. } else {
  4864. complete();
  4865. }
  4866. };
  4867. _proto.dispose = function dispose() {
  4868. $.removeData(this._element, DATA_KEY$9);
  4869. this._element = null;
  4870. } // Private
  4871. ;
  4872. _proto._activate = function _activate(element, container, callback) {
  4873. var _this2 = this;
  4874. var activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? $(container).find(SELECTOR_ACTIVE_UL) : $(container).children(SELECTOR_ACTIVE$2);
  4875. var active = activeElements[0];
  4876. var isTransitioning = callback && active && $(active).hasClass(CLASS_NAME_FADE$4);
  4877. var complete = function complete() {
  4878. return _this2._transitionComplete(element, active, callback);
  4879. };
  4880. if (active && isTransitioning) {
  4881. var transitionDuration = Util.getTransitionDurationFromElement(active);
  4882. $(active).removeClass(CLASS_NAME_SHOW$6).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4883. } else {
  4884. complete();
  4885. }
  4886. };
  4887. _proto._transitionComplete = function _transitionComplete(element, active, callback) {
  4888. if (active) {
  4889. $(active).removeClass(CLASS_NAME_ACTIVE$3);
  4890. var dropdownChild = $(active.parentNode).find(SELECTOR_DROPDOWN_ACTIVE_CHILD)[0];
  4891. if (dropdownChild) {
  4892. $(dropdownChild).removeClass(CLASS_NAME_ACTIVE$3);
  4893. }
  4894. if (active.getAttribute('role') === 'tab') {
  4895. active.setAttribute('aria-selected', false);
  4896. }
  4897. }
  4898. $(element).addClass(CLASS_NAME_ACTIVE$3);
  4899. if (element.getAttribute('role') === 'tab') {
  4900. element.setAttribute('aria-selected', true);
  4901. }
  4902. Util.reflow(element);
  4903. if (element.classList.contains(CLASS_NAME_FADE$4)) {
  4904. element.classList.add(CLASS_NAME_SHOW$6);
  4905. }
  4906. if (element.parentNode && $(element.parentNode).hasClass(CLASS_NAME_DROPDOWN_MENU)) {
  4907. var dropdownElement = $(element).closest(SELECTOR_DROPDOWN$1)[0];
  4908. if (dropdownElement) {
  4909. var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(SELECTOR_DROPDOWN_TOGGLE$1));
  4910. $(dropdownToggleList).addClass(CLASS_NAME_ACTIVE$3);
  4911. }
  4912. element.setAttribute('aria-expanded', true);
  4913. }
  4914. if (callback) {
  4915. callback();
  4916. }
  4917. } // Static
  4918. ;
  4919. Tab._jQueryInterface = function _jQueryInterface(config) {
  4920. return this.each(function () {
  4921. var $this = $(this);
  4922. var data = $this.data(DATA_KEY$9);
  4923. if (!data) {
  4924. data = new Tab(this);
  4925. $this.data(DATA_KEY$9, data);
  4926. }
  4927. if (typeof config === 'string') {
  4928. if (typeof data[config] === 'undefined') {
  4929. throw new TypeError("No method named \"" + config + "\"");
  4930. }
  4931. data[config]();
  4932. }
  4933. });
  4934. };
  4935. _createClass(Tab, null, [{
  4936. key: "VERSION",
  4937. get: function get() {
  4938. return VERSION$9;
  4939. }
  4940. }]);
  4941. return Tab;
  4942. }();
  4943. /**
  4944. * ------------------------------------------------------------------------
  4945. * Data Api implementation
  4946. * ------------------------------------------------------------------------
  4947. */
  4948. $(document).on(EVENT_CLICK_DATA_API$6, SELECTOR_DATA_TOGGLE$4, function (event) {
  4949. event.preventDefault();
  4950. Tab._jQueryInterface.call($(this), 'show');
  4951. });
  4952. /**
  4953. * ------------------------------------------------------------------------
  4954. * jQuery
  4955. * ------------------------------------------------------------------------
  4956. */
  4957. $.fn[NAME$9] = Tab._jQueryInterface;
  4958. $.fn[NAME$9].Constructor = Tab;
  4959. $.fn[NAME$9].noConflict = function () {
  4960. $.fn[NAME$9] = JQUERY_NO_CONFLICT$9;
  4961. return Tab._jQueryInterface;
  4962. };
  4963. /**
  4964. * ------------------------------------------------------------------------
  4965. * Constants
  4966. * ------------------------------------------------------------------------
  4967. */
  4968. var NAME$a = 'toast';
  4969. var VERSION$a = '4.5.0';
  4970. var DATA_KEY$a = 'bs.toast';
  4971. var EVENT_KEY$a = "." + DATA_KEY$a;
  4972. var JQUERY_NO_CONFLICT$a = $.fn[NAME$a];
  4973. var EVENT_CLICK_DISMISS$1 = "click.dismiss" + EVENT_KEY$a;
  4974. var EVENT_HIDE$4 = "hide" + EVENT_KEY$a;
  4975. var EVENT_HIDDEN$4 = "hidden" + EVENT_KEY$a;
  4976. var EVENT_SHOW$4 = "show" + EVENT_KEY$a;
  4977. var EVENT_SHOWN$4 = "shown" + EVENT_KEY$a;
  4978. var CLASS_NAME_FADE$5 = 'fade';
  4979. var CLASS_NAME_HIDE = 'hide';
  4980. var CLASS_NAME_SHOW$7 = 'show';
  4981. var CLASS_NAME_SHOWING = 'showing';
  4982. var DefaultType$7 = {
  4983. animation: 'boolean',
  4984. autohide: 'boolean',
  4985. delay: 'number'
  4986. };
  4987. var Default$7 = {
  4988. animation: true,
  4989. autohide: true,
  4990. delay: 500
  4991. };
  4992. var SELECTOR_DATA_DISMISS$1 = '[data-dismiss="toast"]';
  4993. /**
  4994. * ------------------------------------------------------------------------
  4995. * Class Definition
  4996. * ------------------------------------------------------------------------
  4997. */
  4998. var Toast = /*#__PURE__*/function () {
  4999. function Toast(element, config) {
  5000. this._element = element;
  5001. this._config = this._getConfig(config);
  5002. this._timeout = null;
  5003. this._setListeners();
  5004. } // Getters
  5005. var _proto = Toast.prototype;
  5006. // Public
  5007. _proto.show = function show() {
  5008. var _this = this;
  5009. var showEvent = $.Event(EVENT_SHOW$4);
  5010. $(this._element).trigger(showEvent);
  5011. if (showEvent.isDefaultPrevented()) {
  5012. return;
  5013. }
  5014. if (this._config.animation) {
  5015. this._element.classList.add(CLASS_NAME_FADE$5);
  5016. }
  5017. var complete = function complete() {
  5018. _this._element.classList.remove(CLASS_NAME_SHOWING);
  5019. _this._element.classList.add(CLASS_NAME_SHOW$7);
  5020. $(_this._element).trigger(EVENT_SHOWN$4);
  5021. if (_this._config.autohide) {
  5022. _this._timeout = setTimeout(function () {
  5023. _this.hide();
  5024. }, _this._config.delay);
  5025. }
  5026. };
  5027. this._element.classList.remove(CLASS_NAME_HIDE);
  5028. Util.reflow(this._element);
  5029. this._element.classList.add(CLASS_NAME_SHOWING);
  5030. if (this._config.animation) {
  5031. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5032. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5033. } else {
  5034. complete();
  5035. }
  5036. };
  5037. _proto.hide = function hide() {
  5038. if (!this._element.classList.contains(CLASS_NAME_SHOW$7)) {
  5039. return;
  5040. }
  5041. var hideEvent = $.Event(EVENT_HIDE$4);
  5042. $(this._element).trigger(hideEvent);
  5043. if (hideEvent.isDefaultPrevented()) {
  5044. return;
  5045. }
  5046. this._close();
  5047. };
  5048. _proto.dispose = function dispose() {
  5049. clearTimeout(this._timeout);
  5050. this._timeout = null;
  5051. if (this._element.classList.contains(CLASS_NAME_SHOW$7)) {
  5052. this._element.classList.remove(CLASS_NAME_SHOW$7);
  5053. }
  5054. $(this._element).off(EVENT_CLICK_DISMISS$1);
  5055. $.removeData(this._element, DATA_KEY$a);
  5056. this._element = null;
  5057. this._config = null;
  5058. } // Private
  5059. ;
  5060. _proto._getConfig = function _getConfig(config) {
  5061. config = _objectSpread2(_objectSpread2(_objectSpread2({}, Default$7), $(this._element).data()), typeof config === 'object' && config ? config : {});
  5062. Util.typeCheckConfig(NAME$a, config, this.constructor.DefaultType);
  5063. return config;
  5064. };
  5065. _proto._setListeners = function _setListeners() {
  5066. var _this2 = this;
  5067. $(this._element).on(EVENT_CLICK_DISMISS$1, SELECTOR_DATA_DISMISS$1, function () {
  5068. return _this2.hide();
  5069. });
  5070. };
  5071. _proto._close = function _close() {
  5072. var _this3 = this;
  5073. var complete = function complete() {
  5074. _this3._element.classList.add(CLASS_NAME_HIDE);
  5075. $(_this3._element).trigger(EVENT_HIDDEN$4);
  5076. };
  5077. this._element.classList.remove(CLASS_NAME_SHOW$7);
  5078. if (this._config.animation) {
  5079. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5080. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5081. } else {
  5082. complete();
  5083. }
  5084. } // Static
  5085. ;
  5086. Toast._jQueryInterface = function _jQueryInterface(config) {
  5087. return this.each(function () {
  5088. var $element = $(this);
  5089. var data = $element.data(DATA_KEY$a);
  5090. var _config = typeof config === 'object' && config;
  5091. if (!data) {
  5092. data = new Toast(this, _config);
  5093. $element.data(DATA_KEY$a, data);
  5094. }
  5095. if (typeof config === 'string') {
  5096. if (typeof data[config] === 'undefined') {
  5097. throw new TypeError("No method named \"" + config + "\"");
  5098. }
  5099. data[config](this);
  5100. }
  5101. });
  5102. };
  5103. _createClass(Toast, null, [{
  5104. key: "VERSION",
  5105. get: function get() {
  5106. return VERSION$a;
  5107. }
  5108. }, {
  5109. key: "DefaultType",
  5110. get: function get() {
  5111. return DefaultType$7;
  5112. }
  5113. }, {
  5114. key: "Default",
  5115. get: function get() {
  5116. return Default$7;
  5117. }
  5118. }]);
  5119. return Toast;
  5120. }();
  5121. /**
  5122. * ------------------------------------------------------------------------
  5123. * jQuery
  5124. * ------------------------------------------------------------------------
  5125. */
  5126. $.fn[NAME$a] = Toast._jQueryInterface;
  5127. $.fn[NAME$a].Constructor = Toast;
  5128. $.fn[NAME$a].noConflict = function () {
  5129. $.fn[NAME$a] = JQUERY_NO_CONFLICT$a;
  5130. return Toast._jQueryInterface;
  5131. };
  5132. exports.Alert = Alert;
  5133. exports.Button = Button;
  5134. exports.Carousel = Carousel;
  5135. exports.Collapse = Collapse;
  5136. exports.Dropdown = Dropdown;
  5137. exports.Modal = Modal;
  5138. exports.Popover = Popover;
  5139. exports.Scrollspy = ScrollSpy;
  5140. exports.Tab = Tab;
  5141. exports.Toast = Toast;
  5142. exports.Tooltip = Tooltip;
  5143. exports.Util = Util;
  5144. Object.defineProperty(exports, '__esModule', { value: true });
  5145. })));
  5146. //# sourceMappingURL=bootstrap.js.map
  5147. /***/ }),
  5148. /***/ "./node_modules/jquery/dist/jquery.js":
  5149. /*!********************************************!*\
  5150. !*** ./node_modules/jquery/dist/jquery.js ***!
  5151. \********************************************/
  5152. /*! no static exports found */
  5153. /***/ (function(module, exports, __webpack_require__) {
  5154. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  5155. * jQuery JavaScript Library v3.5.1
  5156. * https://jquery.com/
  5157. *
  5158. * Includes Sizzle.js
  5159. * https://sizzlejs.com/
  5160. *
  5161. * Copyright JS Foundation and other contributors
  5162. * Released under the MIT license
  5163. * https://jquery.org/license
  5164. *
  5165. * Date: 2020-05-04T22:49Z
  5166. */
  5167. ( function( global, factory ) {
  5168. "use strict";
  5169. if ( true && typeof module.exports === "object" ) {
  5170. // For CommonJS and CommonJS-like environments where a proper `window`
  5171. // is present, execute the factory and get jQuery.
  5172. // For environments that do not have a `window` with a `document`
  5173. // (such as Node.js), expose a factory as module.exports.
  5174. // This accentuates the need for the creation of a real `window`.
  5175. // e.g. var jQuery = require("jquery")(window);
  5176. // See ticket #14549 for more info.
  5177. module.exports = global.document ?
  5178. factory( global, true ) :
  5179. function( w ) {
  5180. if ( !w.document ) {
  5181. throw new Error( "jQuery requires a window with a document" );
  5182. }
  5183. return factory( w );
  5184. };
  5185. } else {
  5186. factory( global );
  5187. }
  5188. // Pass this if window is not defined yet
  5189. } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  5190. // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
  5191. // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
  5192. // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
  5193. // enough that all such attempts are guarded in a try block.
  5194. "use strict";
  5195. var arr = [];
  5196. var getProto = Object.getPrototypeOf;
  5197. var slice = arr.slice;
  5198. var flat = arr.flat ? function( array ) {
  5199. return arr.flat.call( array );
  5200. } : function( array ) {
  5201. return arr.concat.apply( [], array );
  5202. };
  5203. var push = arr.push;
  5204. var indexOf = arr.indexOf;
  5205. var class2type = {};
  5206. var toString = class2type.toString;
  5207. var hasOwn = class2type.hasOwnProperty;
  5208. var fnToString = hasOwn.toString;
  5209. var ObjectFunctionString = fnToString.call( Object );
  5210. var support = {};
  5211. var isFunction = function isFunction( obj ) {
  5212. // Support: Chrome <=57, Firefox <=52
  5213. // In some browsers, typeof returns "function" for HTML <object> elements
  5214. // (i.e., `typeof document.createElement( "object" ) === "function"`).
  5215. // We don't want to classify *any* DOM node as a function.
  5216. return typeof obj === "function" && typeof obj.nodeType !== "number";
  5217. };
  5218. var isWindow = function isWindow( obj ) {
  5219. return obj != null && obj === obj.window;
  5220. };
  5221. var document = window.document;
  5222. var preservedScriptAttributes = {
  5223. type: true,
  5224. src: true,
  5225. nonce: true,
  5226. noModule: true
  5227. };
  5228. function DOMEval( code, node, doc ) {
  5229. doc = doc || document;
  5230. var i, val,
  5231. script = doc.createElement( "script" );
  5232. script.text = code;
  5233. if ( node ) {
  5234. for ( i in preservedScriptAttributes ) {
  5235. // Support: Firefox 64+, Edge 18+
  5236. // Some browsers don't support the "nonce" property on scripts.
  5237. // On the other hand, just using `getAttribute` is not enough as
  5238. // the `nonce` attribute is reset to an empty string whenever it
  5239. // becomes browsing-context connected.
  5240. // See https://github.com/whatwg/html/issues/2369
  5241. // See https://html.spec.whatwg.org/#nonce-attributes
  5242. // The `node.getAttribute` check was added for the sake of
  5243. // `jQuery.globalEval` so that it can fake a nonce-containing node
  5244. // via an object.
  5245. val = node[ i ] || node.getAttribute && node.getAttribute( i );
  5246. if ( val ) {
  5247. script.setAttribute( i, val );
  5248. }
  5249. }
  5250. }
  5251. doc.head.appendChild( script ).parentNode.removeChild( script );
  5252. }
  5253. function toType( obj ) {
  5254. if ( obj == null ) {
  5255. return obj + "";
  5256. }
  5257. // Support: Android <=2.3 only (functionish RegExp)
  5258. return typeof obj === "object" || typeof obj === "function" ?
  5259. class2type[ toString.call( obj ) ] || "object" :
  5260. typeof obj;
  5261. }
  5262. /* global Symbol */
  5263. // Defining this global in .eslintrc.json would create a danger of using the global
  5264. // unguarded in another place, it seems safer to define global only for this module
  5265. var
  5266. version = "3.5.1",
  5267. // Define a local copy of jQuery
  5268. jQuery = function( selector, context ) {
  5269. // The jQuery object is actually just the init constructor 'enhanced'
  5270. // Need init if jQuery is called (just allow error to be thrown if not included)
  5271. return new jQuery.fn.init( selector, context );
  5272. };
  5273. jQuery.fn = jQuery.prototype = {
  5274. // The current version of jQuery being used
  5275. jquery: version,
  5276. constructor: jQuery,
  5277. // The default length of a jQuery object is 0
  5278. length: 0,
  5279. toArray: function() {
  5280. return slice.call( this );
  5281. },
  5282. // Get the Nth element in the matched element set OR
  5283. // Get the whole matched element set as a clean array
  5284. get: function( num ) {
  5285. // Return all the elements in a clean array
  5286. if ( num == null ) {
  5287. return slice.call( this );
  5288. }
  5289. // Return just the one element from the set
  5290. return num < 0 ? this[ num + this.length ] : this[ num ];
  5291. },
  5292. // Take an array of elements and push it onto the stack
  5293. // (returning the new matched element set)
  5294. pushStack: function( elems ) {
  5295. // Build a new jQuery matched element set
  5296. var ret = jQuery.merge( this.constructor(), elems );
  5297. // Add the old object onto the stack (as a reference)
  5298. ret.prevObject = this;
  5299. // Return the newly-formed element set
  5300. return ret;
  5301. },
  5302. // Execute a callback for every element in the matched set.
  5303. each: function( callback ) {
  5304. return jQuery.each( this, callback );
  5305. },
  5306. map: function( callback ) {
  5307. return this.pushStack( jQuery.map( this, function( elem, i ) {
  5308. return callback.call( elem, i, elem );
  5309. } ) );
  5310. },
  5311. slice: function() {
  5312. return this.pushStack( slice.apply( this, arguments ) );
  5313. },
  5314. first: function() {
  5315. return this.eq( 0 );
  5316. },
  5317. last: function() {
  5318. return this.eq( -1 );
  5319. },
  5320. even: function() {
  5321. return this.pushStack( jQuery.grep( this, function( _elem, i ) {
  5322. return ( i + 1 ) % 2;
  5323. } ) );
  5324. },
  5325. odd: function() {
  5326. return this.pushStack( jQuery.grep( this, function( _elem, i ) {
  5327. return i % 2;
  5328. } ) );
  5329. },
  5330. eq: function( i ) {
  5331. var len = this.length,
  5332. j = +i + ( i < 0 ? len : 0 );
  5333. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  5334. },
  5335. end: function() {
  5336. return this.prevObject || this.constructor();
  5337. },
  5338. // For internal use only.
  5339. // Behaves like an Array's method, not like a jQuery method.
  5340. push: push,
  5341. sort: arr.sort,
  5342. splice: arr.splice
  5343. };
  5344. jQuery.extend = jQuery.fn.extend = function() {
  5345. var options, name, src, copy, copyIsArray, clone,
  5346. target = arguments[ 0 ] || {},
  5347. i = 1,
  5348. length = arguments.length,
  5349. deep = false;
  5350. // Handle a deep copy situation
  5351. if ( typeof target === "boolean" ) {
  5352. deep = target;
  5353. // Skip the boolean and the target
  5354. target = arguments[ i ] || {};
  5355. i++;
  5356. }
  5357. // Handle case when target is a string or something (possible in deep copy)
  5358. if ( typeof target !== "object" && !isFunction( target ) ) {
  5359. target = {};
  5360. }
  5361. // Extend jQuery itself if only one argument is passed
  5362. if ( i === length ) {
  5363. target = this;
  5364. i--;
  5365. }
  5366. for ( ; i < length; i++ ) {
  5367. // Only deal with non-null/undefined values
  5368. if ( ( options = arguments[ i ] ) != null ) {
  5369. // Extend the base object
  5370. for ( name in options ) {
  5371. copy = options[ name ];
  5372. // Prevent Object.prototype pollution
  5373. // Prevent never-ending loop
  5374. if ( name === "__proto__" || target === copy ) {
  5375. continue;
  5376. }
  5377. // Recurse if we're merging plain objects or arrays
  5378. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  5379. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  5380. src = target[ name ];
  5381. // Ensure proper type for the source value
  5382. if ( copyIsArray && !Array.isArray( src ) ) {
  5383. clone = [];
  5384. } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
  5385. clone = {};
  5386. } else {
  5387. clone = src;
  5388. }
  5389. copyIsArray = false;
  5390. // Never move original objects, clone them
  5391. target[ name ] = jQuery.extend( deep, clone, copy );
  5392. // Don't bring in undefined values
  5393. } else if ( copy !== undefined ) {
  5394. target[ name ] = copy;
  5395. }
  5396. }
  5397. }
  5398. }
  5399. // Return the modified object
  5400. return target;
  5401. };
  5402. jQuery.extend( {
  5403. // Unique for each copy of jQuery on the page
  5404. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  5405. // Assume jQuery is ready without the ready module
  5406. isReady: true,
  5407. error: function( msg ) {
  5408. throw new Error( msg );
  5409. },
  5410. noop: function() {},
  5411. isPlainObject: function( obj ) {
  5412. var proto, Ctor;
  5413. // Detect obvious negatives
  5414. // Use toString instead of jQuery.type to catch host objects
  5415. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  5416. return false;
  5417. }
  5418. proto = getProto( obj );
  5419. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  5420. if ( !proto ) {
  5421. return true;
  5422. }
  5423. // Objects with prototype are plain iff they were constructed by a global Object function
  5424. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  5425. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  5426. },
  5427. isEmptyObject: function( obj ) {
  5428. var name;
  5429. for ( name in obj ) {
  5430. return false;
  5431. }
  5432. return true;
  5433. },
  5434. // Evaluates a script in a provided context; falls back to the global one
  5435. // if not specified.
  5436. globalEval: function( code, options, doc ) {
  5437. DOMEval( code, { nonce: options && options.nonce }, doc );
  5438. },
  5439. each: function( obj, callback ) {
  5440. var length, i = 0;
  5441. if ( isArrayLike( obj ) ) {
  5442. length = obj.length;
  5443. for ( ; i < length; i++ ) {
  5444. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  5445. break;
  5446. }
  5447. }
  5448. } else {
  5449. for ( i in obj ) {
  5450. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  5451. break;
  5452. }
  5453. }
  5454. }
  5455. return obj;
  5456. },
  5457. // results is for internal usage only
  5458. makeArray: function( arr, results ) {
  5459. var ret = results || [];
  5460. if ( arr != null ) {
  5461. if ( isArrayLike( Object( arr ) ) ) {
  5462. jQuery.merge( ret,
  5463. typeof arr === "string" ?
  5464. [ arr ] : arr
  5465. );
  5466. } else {
  5467. push.call( ret, arr );
  5468. }
  5469. }
  5470. return ret;
  5471. },
  5472. inArray: function( elem, arr, i ) {
  5473. return arr == null ? -1 : indexOf.call( arr, elem, i );
  5474. },
  5475. // Support: Android <=4.0 only, PhantomJS 1 only
  5476. // push.apply(_, arraylike) throws on ancient WebKit
  5477. merge: function( first, second ) {
  5478. var len = +second.length,
  5479. j = 0,
  5480. i = first.length;
  5481. for ( ; j < len; j++ ) {
  5482. first[ i++ ] = second[ j ];
  5483. }
  5484. first.length = i;
  5485. return first;
  5486. },
  5487. grep: function( elems, callback, invert ) {
  5488. var callbackInverse,
  5489. matches = [],
  5490. i = 0,
  5491. length = elems.length,
  5492. callbackExpect = !invert;
  5493. // Go through the array, only saving the items
  5494. // that pass the validator function
  5495. for ( ; i < length; i++ ) {
  5496. callbackInverse = !callback( elems[ i ], i );
  5497. if ( callbackInverse !== callbackExpect ) {
  5498. matches.push( elems[ i ] );
  5499. }
  5500. }
  5501. return matches;
  5502. },
  5503. // arg is for internal usage only
  5504. map: function( elems, callback, arg ) {
  5505. var length, value,
  5506. i = 0,
  5507. ret = [];
  5508. // Go through the array, translating each of the items to their new values
  5509. if ( isArrayLike( elems ) ) {
  5510. length = elems.length;
  5511. for ( ; i < length; i++ ) {
  5512. value = callback( elems[ i ], i, arg );
  5513. if ( value != null ) {
  5514. ret.push( value );
  5515. }
  5516. }
  5517. // Go through every key on the object,
  5518. } else {
  5519. for ( i in elems ) {
  5520. value = callback( elems[ i ], i, arg );
  5521. if ( value != null ) {
  5522. ret.push( value );
  5523. }
  5524. }
  5525. }
  5526. // Flatten any nested arrays
  5527. return flat( ret );
  5528. },
  5529. // A global GUID counter for objects
  5530. guid: 1,
  5531. // jQuery.support is not used in Core but other projects attach their
  5532. // properties to it so it needs to exist.
  5533. support: support
  5534. } );
  5535. if ( typeof Symbol === "function" ) {
  5536. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  5537. }
  5538. // Populate the class2type map
  5539. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  5540. function( _i, name ) {
  5541. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  5542. } );
  5543. function isArrayLike( obj ) {
  5544. // Support: real iOS 8.2 only (not reproducible in simulator)
  5545. // `in` check used to prevent JIT error (gh-2145)
  5546. // hasOwn isn't used here due to false negatives
  5547. // regarding Nodelist length in IE
  5548. var length = !!obj && "length" in obj && obj.length,
  5549. type = toType( obj );
  5550. if ( isFunction( obj ) || isWindow( obj ) ) {
  5551. return false;
  5552. }
  5553. return type === "array" || length === 0 ||
  5554. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  5555. }
  5556. var Sizzle =
  5557. /*!
  5558. * Sizzle CSS Selector Engine v2.3.5
  5559. * https://sizzlejs.com/
  5560. *
  5561. * Copyright JS Foundation and other contributors
  5562. * Released under the MIT license
  5563. * https://js.foundation/
  5564. *
  5565. * Date: 2020-03-14
  5566. */
  5567. ( function( window ) {
  5568. var i,
  5569. support,
  5570. Expr,
  5571. getText,
  5572. isXML,
  5573. tokenize,
  5574. compile,
  5575. select,
  5576. outermostContext,
  5577. sortInput,
  5578. hasDuplicate,
  5579. // Local document vars
  5580. setDocument,
  5581. document,
  5582. docElem,
  5583. documentIsHTML,
  5584. rbuggyQSA,
  5585. rbuggyMatches,
  5586. matches,
  5587. contains,
  5588. // Instance-specific data
  5589. expando = "sizzle" + 1 * new Date(),
  5590. preferredDoc = window.document,
  5591. dirruns = 0,
  5592. done = 0,
  5593. classCache = createCache(),
  5594. tokenCache = createCache(),
  5595. compilerCache = createCache(),
  5596. nonnativeSelectorCache = createCache(),
  5597. sortOrder = function( a, b ) {
  5598. if ( a === b ) {
  5599. hasDuplicate = true;
  5600. }
  5601. return 0;
  5602. },
  5603. // Instance methods
  5604. hasOwn = ( {} ).hasOwnProperty,
  5605. arr = [],
  5606. pop = arr.pop,
  5607. pushNative = arr.push,
  5608. push = arr.push,
  5609. slice = arr.slice,
  5610. // Use a stripped-down indexOf as it's faster than native
  5611. // https://jsperf.com/thor-indexof-vs-for/5
  5612. indexOf = function( list, elem ) {
  5613. var i = 0,
  5614. len = list.length;
  5615. for ( ; i < len; i++ ) {
  5616. if ( list[ i ] === elem ) {
  5617. return i;
  5618. }
  5619. }
  5620. return -1;
  5621. },
  5622. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|" +
  5623. "ismap|loop|multiple|open|readonly|required|scoped",
  5624. // Regular expressions
  5625. // http://www.w3.org/TR/css3-selectors/#whitespace
  5626. whitespace = "[\\x20\\t\\r\\n\\f]",
  5627. // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram
  5628. identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace +
  5629. "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",
  5630. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  5631. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  5632. // Operator (capture 2)
  5633. "*([*^$|!~]?=)" + whitespace +
  5634. // "Attribute values must be CSS identifiers [capture 5]
  5635. // or strings [capture 3 or capture 4]"
  5636. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" +
  5637. whitespace + "*\\]",
  5638. pseudos = ":(" + identifier + ")(?:\\((" +
  5639. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  5640. // 1. quoted (capture 3; capture 4 or capture 5)
  5641. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  5642. // 2. simple (capture 6)
  5643. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  5644. // 3. anything else (capture 2)
  5645. ".*" +
  5646. ")\\)|)",
  5647. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  5648. rwhitespace = new RegExp( whitespace + "+", "g" ),
  5649. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" +
  5650. whitespace + "+$", "g" ),
  5651. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  5652. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace +
  5653. "*" ),
  5654. rdescend = new RegExp( whitespace + "|>" ),
  5655. rpseudo = new RegExp( pseudos ),
  5656. ridentifier = new RegExp( "^" + identifier + "$" ),
  5657. matchExpr = {
  5658. "ID": new RegExp( "^#(" + identifier + ")" ),
  5659. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  5660. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  5661. "ATTR": new RegExp( "^" + attributes ),
  5662. "PSEUDO": new RegExp( "^" + pseudos ),
  5663. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" +
  5664. whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" +
  5665. whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  5666. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  5667. // For use in libraries implementing .is()
  5668. // We use this for POS matching in `select`
  5669. "needsContext": new RegExp( "^" + whitespace +
  5670. "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
  5671. "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  5672. },
  5673. rhtml = /HTML$/i,
  5674. rinputs = /^(?:input|select|textarea|button)$/i,
  5675. rheader = /^h\d$/i,
  5676. rnative = /^[^{]+\{\s*\[native \w/,
  5677. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  5678. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  5679. rsibling = /[+~]/,
  5680. // CSS escapes
  5681. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  5682. runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g" ),
  5683. funescape = function( escape, nonHex ) {
  5684. var high = "0x" + escape.slice( 1 ) - 0x10000;
  5685. return nonHex ?
  5686. // Strip the backslash prefix from a non-hex escape sequence
  5687. nonHex :
  5688. // Replace a hexadecimal escape sequence with the encoded Unicode code point
  5689. // Support: IE <=11+
  5690. // For values outside the Basic Multilingual Plane (BMP), manually construct a
  5691. // surrogate pair
  5692. high < 0 ?
  5693. String.fromCharCode( high + 0x10000 ) :
  5694. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  5695. },
  5696. // CSS string/identifier serialization
  5697. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  5698. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  5699. fcssescape = function( ch, asCodePoint ) {
  5700. if ( asCodePoint ) {
  5701. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  5702. if ( ch === "\0" ) {
  5703. return "\uFFFD";
  5704. }
  5705. // Control characters and (dependent upon position) numbers get escaped as code points
  5706. return ch.slice( 0, -1 ) + "\\" +
  5707. ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  5708. }
  5709. // Other potentially-special ASCII characters get backslash-escaped
  5710. return "\\" + ch;
  5711. },
  5712. // Used for iframes
  5713. // See setDocument()
  5714. // Removing the function wrapper causes a "Permission Denied"
  5715. // error in IE
  5716. unloadHandler = function() {
  5717. setDocument();
  5718. },
  5719. inDisabledFieldset = addCombinator(
  5720. function( elem ) {
  5721. return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
  5722. },
  5723. { dir: "parentNode", next: "legend" }
  5724. );
  5725. // Optimize for push.apply( _, NodeList )
  5726. try {
  5727. push.apply(
  5728. ( arr = slice.call( preferredDoc.childNodes ) ),
  5729. preferredDoc.childNodes
  5730. );
  5731. // Support: Android<4.0
  5732. // Detect silently failing push.apply
  5733. // eslint-disable-next-line no-unused-expressions
  5734. arr[ preferredDoc.childNodes.length ].nodeType;
  5735. } catch ( e ) {
  5736. push = { apply: arr.length ?
  5737. // Leverage slice if possible
  5738. function( target, els ) {
  5739. pushNative.apply( target, slice.call( els ) );
  5740. } :
  5741. // Support: IE<9
  5742. // Otherwise append directly
  5743. function( target, els ) {
  5744. var j = target.length,
  5745. i = 0;
  5746. // Can't trust NodeList.length
  5747. while ( ( target[ j++ ] = els[ i++ ] ) ) {}
  5748. target.length = j - 1;
  5749. }
  5750. };
  5751. }
  5752. function Sizzle( selector, context, results, seed ) {
  5753. var m, i, elem, nid, match, groups, newSelector,
  5754. newContext = context && context.ownerDocument,
  5755. // nodeType defaults to 9, since context defaults to document
  5756. nodeType = context ? context.nodeType : 9;
  5757. results = results || [];
  5758. // Return early from calls with invalid selector or context
  5759. if ( typeof selector !== "string" || !selector ||
  5760. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  5761. return results;
  5762. }
  5763. // Try to shortcut find operations (as opposed to filters) in HTML documents
  5764. if ( !seed ) {
  5765. setDocument( context );
  5766. context = context || document;
  5767. if ( documentIsHTML ) {
  5768. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  5769. // (excepting DocumentFragment context, where the methods don't exist)
  5770. if ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) {
  5771. // ID selector
  5772. if ( ( m = match[ 1 ] ) ) {
  5773. // Document context
  5774. if ( nodeType === 9 ) {
  5775. if ( ( elem = context.getElementById( m ) ) ) {
  5776. // Support: IE, Opera, Webkit
  5777. // TODO: identify versions
  5778. // getElementById can match elements by name instead of ID
  5779. if ( elem.id === m ) {
  5780. results.push( elem );
  5781. return results;
  5782. }
  5783. } else {
  5784. return results;
  5785. }
  5786. // Element context
  5787. } else {
  5788. // Support: IE, Opera, Webkit
  5789. // TODO: identify versions
  5790. // getElementById can match elements by name instead of ID
  5791. if ( newContext && ( elem = newContext.getElementById( m ) ) &&
  5792. contains( context, elem ) &&
  5793. elem.id === m ) {
  5794. results.push( elem );
  5795. return results;
  5796. }
  5797. }
  5798. // Type selector
  5799. } else if ( match[ 2 ] ) {
  5800. push.apply( results, context.getElementsByTagName( selector ) );
  5801. return results;
  5802. // Class selector
  5803. } else if ( ( m = match[ 3 ] ) && support.getElementsByClassName &&
  5804. context.getElementsByClassName ) {
  5805. push.apply( results, context.getElementsByClassName( m ) );
  5806. return results;
  5807. }
  5808. }
  5809. // Take advantage of querySelectorAll
  5810. if ( support.qsa &&
  5811. !nonnativeSelectorCache[ selector + " " ] &&
  5812. ( !rbuggyQSA || !rbuggyQSA.test( selector ) ) &&
  5813. // Support: IE 8 only
  5814. // Exclude object elements
  5815. ( nodeType !== 1 || context.nodeName.toLowerCase() !== "object" ) ) {
  5816. newSelector = selector;
  5817. newContext = context;
  5818. // qSA considers elements outside a scoping root when evaluating child or
  5819. // descendant combinators, which is not what we want.
  5820. // In such cases, we work around the behavior by prefixing every selector in the
  5821. // list with an ID selector referencing the scope context.
  5822. // The technique has to be used as well when a leading combinator is used
  5823. // as such selectors are not recognized by querySelectorAll.
  5824. // Thanks to Andrew Dupont for this technique.
  5825. if ( nodeType === 1 &&
  5826. ( rdescend.test( selector ) || rcombinators.test( selector ) ) ) {
  5827. // Expand context for sibling selectors
  5828. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  5829. context;
  5830. // We can use :scope instead of the ID hack if the browser
  5831. // supports it & if we're not changing the context.
  5832. if ( newContext !== context || !support.scope ) {
  5833. // Capture the context ID, setting it first if necessary
  5834. if ( ( nid = context.getAttribute( "id" ) ) ) {
  5835. nid = nid.replace( rcssescape, fcssescape );
  5836. } else {
  5837. context.setAttribute( "id", ( nid = expando ) );
  5838. }
  5839. }
  5840. // Prefix every selector in the list
  5841. groups = tokenize( selector );
  5842. i = groups.length;
  5843. while ( i-- ) {
  5844. groups[ i ] = ( nid ? "#" + nid : ":scope" ) + " " +
  5845. toSelector( groups[ i ] );
  5846. }
  5847. newSelector = groups.join( "," );
  5848. }
  5849. try {
  5850. push.apply( results,
  5851. newContext.querySelectorAll( newSelector )
  5852. );
  5853. return results;
  5854. } catch ( qsaError ) {
  5855. nonnativeSelectorCache( selector, true );
  5856. } finally {
  5857. if ( nid === expando ) {
  5858. context.removeAttribute( "id" );
  5859. }
  5860. }
  5861. }
  5862. }
  5863. }
  5864. // All others
  5865. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  5866. }
  5867. /**
  5868. * Create key-value caches of limited size
  5869. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  5870. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  5871. * deleting the oldest entry
  5872. */
  5873. function createCache() {
  5874. var keys = [];
  5875. function cache( key, value ) {
  5876. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  5877. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  5878. // Only keep the most recent entries
  5879. delete cache[ keys.shift() ];
  5880. }
  5881. return ( cache[ key + " " ] = value );
  5882. }
  5883. return cache;
  5884. }
  5885. /**
  5886. * Mark a function for special use by Sizzle
  5887. * @param {Function} fn The function to mark
  5888. */
  5889. function markFunction( fn ) {
  5890. fn[ expando ] = true;
  5891. return fn;
  5892. }
  5893. /**
  5894. * Support testing using an element
  5895. * @param {Function} fn Passed the created element and returns a boolean result
  5896. */
  5897. function assert( fn ) {
  5898. var el = document.createElement( "fieldset" );
  5899. try {
  5900. return !!fn( el );
  5901. } catch ( e ) {
  5902. return false;
  5903. } finally {
  5904. // Remove from its parent by default
  5905. if ( el.parentNode ) {
  5906. el.parentNode.removeChild( el );
  5907. }
  5908. // release memory in IE
  5909. el = null;
  5910. }
  5911. }
  5912. /**
  5913. * Adds the same handler for all of the specified attrs
  5914. * @param {String} attrs Pipe-separated list of attributes
  5915. * @param {Function} handler The method that will be applied
  5916. */
  5917. function addHandle( attrs, handler ) {
  5918. var arr = attrs.split( "|" ),
  5919. i = arr.length;
  5920. while ( i-- ) {
  5921. Expr.attrHandle[ arr[ i ] ] = handler;
  5922. }
  5923. }
  5924. /**
  5925. * Checks document order of two siblings
  5926. * @param {Element} a
  5927. * @param {Element} b
  5928. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  5929. */
  5930. function siblingCheck( a, b ) {
  5931. var cur = b && a,
  5932. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  5933. a.sourceIndex - b.sourceIndex;
  5934. // Use IE sourceIndex if available on both nodes
  5935. if ( diff ) {
  5936. return diff;
  5937. }
  5938. // Check if b follows a
  5939. if ( cur ) {
  5940. while ( ( cur = cur.nextSibling ) ) {
  5941. if ( cur === b ) {
  5942. return -1;
  5943. }
  5944. }
  5945. }
  5946. return a ? 1 : -1;
  5947. }
  5948. /**
  5949. * Returns a function to use in pseudos for input types
  5950. * @param {String} type
  5951. */
  5952. function createInputPseudo( type ) {
  5953. return function( elem ) {
  5954. var name = elem.nodeName.toLowerCase();
  5955. return name === "input" && elem.type === type;
  5956. };
  5957. }
  5958. /**
  5959. * Returns a function to use in pseudos for buttons
  5960. * @param {String} type
  5961. */
  5962. function createButtonPseudo( type ) {
  5963. return function( elem ) {
  5964. var name = elem.nodeName.toLowerCase();
  5965. return ( name === "input" || name === "button" ) && elem.type === type;
  5966. };
  5967. }
  5968. /**
  5969. * Returns a function to use in pseudos for :enabled/:disabled
  5970. * @param {Boolean} disabled true for :disabled; false for :enabled
  5971. */
  5972. function createDisabledPseudo( disabled ) {
  5973. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  5974. return function( elem ) {
  5975. // Only certain elements can match :enabled or :disabled
  5976. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  5977. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  5978. if ( "form" in elem ) {
  5979. // Check for inherited disabledness on relevant non-disabled elements:
  5980. // * listed form-associated elements in a disabled fieldset
  5981. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  5982. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  5983. // * option elements in a disabled optgroup
  5984. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  5985. // All such elements have a "form" property.
  5986. if ( elem.parentNode && elem.disabled === false ) {
  5987. // Option elements defer to a parent optgroup if present
  5988. if ( "label" in elem ) {
  5989. if ( "label" in elem.parentNode ) {
  5990. return elem.parentNode.disabled === disabled;
  5991. } else {
  5992. return elem.disabled === disabled;
  5993. }
  5994. }
  5995. // Support: IE 6 - 11
  5996. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  5997. return elem.isDisabled === disabled ||
  5998. // Where there is no isDisabled, check manually
  5999. /* jshint -W018 */
  6000. elem.isDisabled !== !disabled &&
  6001. inDisabledFieldset( elem ) === disabled;
  6002. }
  6003. return elem.disabled === disabled;
  6004. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  6005. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  6006. // even exist on them, let alone have a boolean value.
  6007. } else if ( "label" in elem ) {
  6008. return elem.disabled === disabled;
  6009. }
  6010. // Remaining elements are neither :enabled nor :disabled
  6011. return false;
  6012. };
  6013. }
  6014. /**
  6015. * Returns a function to use in pseudos for positionals
  6016. * @param {Function} fn
  6017. */
  6018. function createPositionalPseudo( fn ) {
  6019. return markFunction( function( argument ) {
  6020. argument = +argument;
  6021. return markFunction( function( seed, matches ) {
  6022. var j,
  6023. matchIndexes = fn( [], seed.length, argument ),
  6024. i = matchIndexes.length;
  6025. // Match elements found at the specified indexes
  6026. while ( i-- ) {
  6027. if ( seed[ ( j = matchIndexes[ i ] ) ] ) {
  6028. seed[ j ] = !( matches[ j ] = seed[ j ] );
  6029. }
  6030. }
  6031. } );
  6032. } );
  6033. }
  6034. /**
  6035. * Checks a node for validity as a Sizzle context
  6036. * @param {Element|Object=} context
  6037. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  6038. */
  6039. function testContext( context ) {
  6040. return context && typeof context.getElementsByTagName !== "undefined" && context;
  6041. }
  6042. // Expose support vars for convenience
  6043. support = Sizzle.support = {};
  6044. /**
  6045. * Detects XML nodes
  6046. * @param {Element|Object} elem An element or a document
  6047. * @returns {Boolean} True iff elem is a non-HTML XML node
  6048. */
  6049. isXML = Sizzle.isXML = function( elem ) {
  6050. var namespace = elem.namespaceURI,
  6051. docElem = ( elem.ownerDocument || elem ).documentElement;
  6052. // Support: IE <=8
  6053. // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
  6054. // https://bugs.jquery.com/ticket/4833
  6055. return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
  6056. };
  6057. /**
  6058. * Sets document-related variables once based on the current document
  6059. * @param {Element|Object} [doc] An element or document object to use to set the document
  6060. * @returns {Object} Returns the current document
  6061. */
  6062. setDocument = Sizzle.setDocument = function( node ) {
  6063. var hasCompare, subWindow,
  6064. doc = node ? node.ownerDocument || node : preferredDoc;
  6065. // Return early if doc is invalid or already selected
  6066. // Support: IE 11+, Edge 17 - 18+
  6067. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  6068. // two documents; shallow comparisons work.
  6069. // eslint-disable-next-line eqeqeq
  6070. if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) {
  6071. return document;
  6072. }
  6073. // Update global variables
  6074. document = doc;
  6075. docElem = document.documentElement;
  6076. documentIsHTML = !isXML( document );
  6077. // Support: IE 9 - 11+, Edge 12 - 18+
  6078. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  6079. // Support: IE 11+, Edge 17 - 18+
  6080. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  6081. // two documents; shallow comparisons work.
  6082. // eslint-disable-next-line eqeqeq
  6083. if ( preferredDoc != document &&
  6084. ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) {
  6085. // Support: IE 11, Edge
  6086. if ( subWindow.addEventListener ) {
  6087. subWindow.addEventListener( "unload", unloadHandler, false );
  6088. // Support: IE 9 - 10 only
  6089. } else if ( subWindow.attachEvent ) {
  6090. subWindow.attachEvent( "onunload", unloadHandler );
  6091. }
  6092. }
  6093. // Support: IE 8 - 11+, Edge 12 - 18+, Chrome <=16 - 25 only, Firefox <=3.6 - 31 only,
  6094. // Safari 4 - 5 only, Opera <=11.6 - 12.x only
  6095. // IE/Edge & older browsers don't support the :scope pseudo-class.
  6096. // Support: Safari 6.0 only
  6097. // Safari 6.0 supports :scope but it's an alias of :root there.
  6098. support.scope = assert( function( el ) {
  6099. docElem.appendChild( el ).appendChild( document.createElement( "div" ) );
  6100. return typeof el.querySelectorAll !== "undefined" &&
  6101. !el.querySelectorAll( ":scope fieldset div" ).length;
  6102. } );
  6103. /* Attributes
  6104. ---------------------------------------------------------------------- */
  6105. // Support: IE<8
  6106. // Verify that getAttribute really returns attributes and not properties
  6107. // (excepting IE8 booleans)
  6108. support.attributes = assert( function( el ) {
  6109. el.className = "i";
  6110. return !el.getAttribute( "className" );
  6111. } );
  6112. /* getElement(s)By*
  6113. ---------------------------------------------------------------------- */
  6114. // Check if getElementsByTagName("*") returns only elements
  6115. support.getElementsByTagName = assert( function( el ) {
  6116. el.appendChild( document.createComment( "" ) );
  6117. return !el.getElementsByTagName( "*" ).length;
  6118. } );
  6119. // Support: IE<9
  6120. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  6121. // Support: IE<10
  6122. // Check if getElementById returns elements by name
  6123. // The broken getElementById methods don't pick up programmatically-set names,
  6124. // so use a roundabout getElementsByName test
  6125. support.getById = assert( function( el ) {
  6126. docElem.appendChild( el ).id = expando;
  6127. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  6128. } );
  6129. // ID filter and find
  6130. if ( support.getById ) {
  6131. Expr.filter[ "ID" ] = function( id ) {
  6132. var attrId = id.replace( runescape, funescape );
  6133. return function( elem ) {
  6134. return elem.getAttribute( "id" ) === attrId;
  6135. };
  6136. };
  6137. Expr.find[ "ID" ] = function( id, context ) {
  6138. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  6139. var elem = context.getElementById( id );
  6140. return elem ? [ elem ] : [];
  6141. }
  6142. };
  6143. } else {
  6144. Expr.filter[ "ID" ] = function( id ) {
  6145. var attrId = id.replace( runescape, funescape );
  6146. return function( elem ) {
  6147. var node = typeof elem.getAttributeNode !== "undefined" &&
  6148. elem.getAttributeNode( "id" );
  6149. return node && node.value === attrId;
  6150. };
  6151. };
  6152. // Support: IE 6 - 7 only
  6153. // getElementById is not reliable as a find shortcut
  6154. Expr.find[ "ID" ] = function( id, context ) {
  6155. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  6156. var node, i, elems,
  6157. elem = context.getElementById( id );
  6158. if ( elem ) {
  6159. // Verify the id attribute
  6160. node = elem.getAttributeNode( "id" );
  6161. if ( node && node.value === id ) {
  6162. return [ elem ];
  6163. }
  6164. // Fall back on getElementsByName
  6165. elems = context.getElementsByName( id );
  6166. i = 0;
  6167. while ( ( elem = elems[ i++ ] ) ) {
  6168. node = elem.getAttributeNode( "id" );
  6169. if ( node && node.value === id ) {
  6170. return [ elem ];
  6171. }
  6172. }
  6173. }
  6174. return [];
  6175. }
  6176. };
  6177. }
  6178. // Tag
  6179. Expr.find[ "TAG" ] = support.getElementsByTagName ?
  6180. function( tag, context ) {
  6181. if ( typeof context.getElementsByTagName !== "undefined" ) {
  6182. return context.getElementsByTagName( tag );
  6183. // DocumentFragment nodes don't have gEBTN
  6184. } else if ( support.qsa ) {
  6185. return context.querySelectorAll( tag );
  6186. }
  6187. } :
  6188. function( tag, context ) {
  6189. var elem,
  6190. tmp = [],
  6191. i = 0,
  6192. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  6193. results = context.getElementsByTagName( tag );
  6194. // Filter out possible comments
  6195. if ( tag === "*" ) {
  6196. while ( ( elem = results[ i++ ] ) ) {
  6197. if ( elem.nodeType === 1 ) {
  6198. tmp.push( elem );
  6199. }
  6200. }
  6201. return tmp;
  6202. }
  6203. return results;
  6204. };
  6205. // Class
  6206. Expr.find[ "CLASS" ] = support.getElementsByClassName && function( className, context ) {
  6207. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  6208. return context.getElementsByClassName( className );
  6209. }
  6210. };
  6211. /* QSA/matchesSelector
  6212. ---------------------------------------------------------------------- */
  6213. // QSA and matchesSelector support
  6214. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  6215. rbuggyMatches = [];
  6216. // qSa(:focus) reports false when true (Chrome 21)
  6217. // We allow this because of a bug in IE8/9 that throws an error
  6218. // whenever `document.activeElement` is accessed on an iframe
  6219. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  6220. // See https://bugs.jquery.com/ticket/13378
  6221. rbuggyQSA = [];
  6222. if ( ( support.qsa = rnative.test( document.querySelectorAll ) ) ) {
  6223. // Build QSA regex
  6224. // Regex strategy adopted from Diego Perini
  6225. assert( function( el ) {
  6226. var input;
  6227. // Select is set to empty string on purpose
  6228. // This is to test IE's treatment of not explicitly
  6229. // setting a boolean content attribute,
  6230. // since its presence should be enough
  6231. // https://bugs.jquery.com/ticket/12359
  6232. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  6233. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  6234. "<option selected=''></option></select>";
  6235. // Support: IE8, Opera 11-12.16
  6236. // Nothing should be selected when empty strings follow ^= or $= or *=
  6237. // The test attribute must be unknown in Opera but "safe" for WinRT
  6238. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  6239. if ( el.querySelectorAll( "[msallowcapture^='']" ).length ) {
  6240. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  6241. }
  6242. // Support: IE8
  6243. // Boolean attributes and "value" are not treated correctly
  6244. if ( !el.querySelectorAll( "[selected]" ).length ) {
  6245. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  6246. }
  6247. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  6248. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  6249. rbuggyQSA.push( "~=" );
  6250. }
  6251. // Support: IE 11+, Edge 15 - 18+
  6252. // IE 11/Edge don't find elements on a `[name='']` query in some cases.
  6253. // Adding a temporary attribute to the document before the selection works
  6254. // around the issue.
  6255. // Interestingly, IE 10 & older don't seem to have the issue.
  6256. input = document.createElement( "input" );
  6257. input.setAttribute( "name", "" );
  6258. el.appendChild( input );
  6259. if ( !el.querySelectorAll( "[name='']" ).length ) {
  6260. rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" +
  6261. whitespace + "*(?:''|\"\")" );
  6262. }
  6263. // Webkit/Opera - :checked should return selected option elements
  6264. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  6265. // IE8 throws error here and will not see later tests
  6266. if ( !el.querySelectorAll( ":checked" ).length ) {
  6267. rbuggyQSA.push( ":checked" );
  6268. }
  6269. // Support: Safari 8+, iOS 8+
  6270. // https://bugs.webkit.org/show_bug.cgi?id=136851
  6271. // In-page `selector#id sibling-combinator selector` fails
  6272. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  6273. rbuggyQSA.push( ".#.+[+~]" );
  6274. }
  6275. // Support: Firefox <=3.6 - 5 only
  6276. // Old Firefox doesn't throw on a badly-escaped identifier.
  6277. el.querySelectorAll( "\\\f" );
  6278. rbuggyQSA.push( "[\\r\\n\\f]" );
  6279. } );
  6280. assert( function( el ) {
  6281. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  6282. "<select disabled='disabled'><option/></select>";
  6283. // Support: Windows 8 Native Apps
  6284. // The type and name attributes are restricted during .innerHTML assignment
  6285. var input = document.createElement( "input" );
  6286. input.setAttribute( "type", "hidden" );
  6287. el.appendChild( input ).setAttribute( "name", "D" );
  6288. // Support: IE8
  6289. // Enforce case-sensitivity of name attribute
  6290. if ( el.querySelectorAll( "[name=d]" ).length ) {
  6291. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  6292. }
  6293. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  6294. // IE8 throws error here and will not see later tests
  6295. if ( el.querySelectorAll( ":enabled" ).length !== 2 ) {
  6296. rbuggyQSA.push( ":enabled", ":disabled" );
  6297. }
  6298. // Support: IE9-11+
  6299. // IE's :disabled selector does not pick up the children of disabled fieldsets
  6300. docElem.appendChild( el ).disabled = true;
  6301. if ( el.querySelectorAll( ":disabled" ).length !== 2 ) {
  6302. rbuggyQSA.push( ":enabled", ":disabled" );
  6303. }
  6304. // Support: Opera 10 - 11 only
  6305. // Opera 10-11 does not throw on post-comma invalid pseudos
  6306. el.querySelectorAll( "*,:x" );
  6307. rbuggyQSA.push( ",.*:" );
  6308. } );
  6309. }
  6310. if ( ( support.matchesSelector = rnative.test( ( matches = docElem.matches ||
  6311. docElem.webkitMatchesSelector ||
  6312. docElem.mozMatchesSelector ||
  6313. docElem.oMatchesSelector ||
  6314. docElem.msMatchesSelector ) ) ) ) {
  6315. assert( function( el ) {
  6316. // Check to see if it's possible to do matchesSelector
  6317. // on a disconnected node (IE 9)
  6318. support.disconnectedMatch = matches.call( el, "*" );
  6319. // This should fail with an exception
  6320. // Gecko does not error, returns false instead
  6321. matches.call( el, "[s!='']:x" );
  6322. rbuggyMatches.push( "!=", pseudos );
  6323. } );
  6324. }
  6325. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) );
  6326. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join( "|" ) );
  6327. /* Contains
  6328. ---------------------------------------------------------------------- */
  6329. hasCompare = rnative.test( docElem.compareDocumentPosition );
  6330. // Element contains another
  6331. // Purposefully self-exclusive
  6332. // As in, an element does not contain itself
  6333. contains = hasCompare || rnative.test( docElem.contains ) ?
  6334. function( a, b ) {
  6335. var adown = a.nodeType === 9 ? a.documentElement : a,
  6336. bup = b && b.parentNode;
  6337. return a === bup || !!( bup && bup.nodeType === 1 && (
  6338. adown.contains ?
  6339. adown.contains( bup ) :
  6340. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  6341. ) );
  6342. } :
  6343. function( a, b ) {
  6344. if ( b ) {
  6345. while ( ( b = b.parentNode ) ) {
  6346. if ( b === a ) {
  6347. return true;
  6348. }
  6349. }
  6350. }
  6351. return false;
  6352. };
  6353. /* Sorting
  6354. ---------------------------------------------------------------------- */
  6355. // Document order sorting
  6356. sortOrder = hasCompare ?
  6357. function( a, b ) {
  6358. // Flag for duplicate removal
  6359. if ( a === b ) {
  6360. hasDuplicate = true;
  6361. return 0;
  6362. }
  6363. // Sort on method existence if only one input has compareDocumentPosition
  6364. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  6365. if ( compare ) {
  6366. return compare;
  6367. }
  6368. // Calculate position if both inputs belong to the same document
  6369. // Support: IE 11+, Edge 17 - 18+
  6370. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  6371. // two documents; shallow comparisons work.
  6372. // eslint-disable-next-line eqeqeq
  6373. compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ?
  6374. a.compareDocumentPosition( b ) :
  6375. // Otherwise we know they are disconnected
  6376. 1;
  6377. // Disconnected nodes
  6378. if ( compare & 1 ||
  6379. ( !support.sortDetached && b.compareDocumentPosition( a ) === compare ) ) {
  6380. // Choose the first element that is related to our preferred document
  6381. // Support: IE 11+, Edge 17 - 18+
  6382. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  6383. // two documents; shallow comparisons work.
  6384. // eslint-disable-next-line eqeqeq
  6385. if ( a == document || a.ownerDocument == preferredDoc &&
  6386. contains( preferredDoc, a ) ) {
  6387. return -1;
  6388. }
  6389. // Support: IE 11+, Edge 17 - 18+
  6390. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  6391. // two documents; shallow comparisons work.
  6392. // eslint-disable-next-line eqeqeq
  6393. if ( b == document || b.ownerDocument == preferredDoc &&
  6394. contains( preferredDoc, b ) ) {
  6395. return 1;
  6396. }
  6397. // Maintain original order
  6398. return sortInput ?
  6399. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  6400. 0;
  6401. }
  6402. return compare & 4 ? -1 : 1;
  6403. } :
  6404. function( a, b ) {
  6405. // Exit early if the nodes are identical
  6406. if ( a === b ) {
  6407. hasDuplicate = true;
  6408. return 0;
  6409. }
  6410. var cur,
  6411. i = 0,
  6412. aup = a.parentNode,
  6413. bup = b.parentNode,
  6414. ap = [ a ],
  6415. bp = [ b ];
  6416. // Parentless nodes are either documents or disconnected
  6417. if ( !aup || !bup ) {
  6418. // Support: IE 11+, Edge 17 - 18+
  6419. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  6420. // two documents; shallow comparisons work.
  6421. /* eslint-disable eqeqeq */
  6422. return a == document ? -1 :
  6423. b == document ? 1 :
  6424. /* eslint-enable eqeqeq */
  6425. aup ? -1 :
  6426. bup ? 1 :
  6427. sortInput ?
  6428. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  6429. 0;
  6430. // If the nodes are siblings, we can do a quick check
  6431. } else if ( aup === bup ) {
  6432. return siblingCheck( a, b );
  6433. }
  6434. // Otherwise we need full lists of their ancestors for comparison
  6435. cur = a;
  6436. while ( ( cur = cur.parentNode ) ) {
  6437. ap.unshift( cur );
  6438. }
  6439. cur = b;
  6440. while ( ( cur = cur.parentNode ) ) {
  6441. bp.unshift( cur );
  6442. }
  6443. // Walk down the tree looking for a discrepancy
  6444. while ( ap[ i ] === bp[ i ] ) {
  6445. i++;
  6446. }
  6447. return i ?
  6448. // Do a sibling check if the nodes have a common ancestor
  6449. siblingCheck( ap[ i ], bp[ i ] ) :
  6450. // Otherwise nodes in our document sort first
  6451. // Support: IE 11+, Edge 17 - 18+
  6452. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  6453. // two documents; shallow comparisons work.
  6454. /* eslint-disable eqeqeq */
  6455. ap[ i ] == preferredDoc ? -1 :
  6456. bp[ i ] == preferredDoc ? 1 :
  6457. /* eslint-enable eqeqeq */
  6458. 0;
  6459. };
  6460. return document;
  6461. };
  6462. Sizzle.matches = function( expr, elements ) {
  6463. return Sizzle( expr, null, null, elements );
  6464. };
  6465. Sizzle.matchesSelector = function( elem, expr ) {
  6466. setDocument( elem );
  6467. if ( support.matchesSelector && documentIsHTML &&
  6468. !nonnativeSelectorCache[ expr + " " ] &&
  6469. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  6470. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  6471. try {
  6472. var ret = matches.call( elem, expr );
  6473. // IE 9's matchesSelector returns false on disconnected nodes
  6474. if ( ret || support.disconnectedMatch ||
  6475. // As well, disconnected nodes are said to be in a document
  6476. // fragment in IE 9
  6477. elem.document && elem.document.nodeType !== 11 ) {
  6478. return ret;
  6479. }
  6480. } catch ( e ) {
  6481. nonnativeSelectorCache( expr, true );
  6482. }
  6483. }
  6484. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  6485. };
  6486. Sizzle.contains = function( context, elem ) {
  6487. // Set document vars if needed
  6488. // Support: IE 11+, Edge 17 - 18+
  6489. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  6490. // two documents; shallow comparisons work.
  6491. // eslint-disable-next-line eqeqeq
  6492. if ( ( context.ownerDocument || context ) != document ) {
  6493. setDocument( context );
  6494. }
  6495. return contains( context, elem );
  6496. };
  6497. Sizzle.attr = function( elem, name ) {
  6498. // Set document vars if needed
  6499. // Support: IE 11+, Edge 17 - 18+
  6500. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  6501. // two documents; shallow comparisons work.
  6502. // eslint-disable-next-line eqeqeq
  6503. if ( ( elem.ownerDocument || elem ) != document ) {
  6504. setDocument( elem );
  6505. }
  6506. var fn = Expr.attrHandle[ name.toLowerCase() ],
  6507. // Don't get fooled by Object.prototype properties (jQuery #13807)
  6508. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  6509. fn( elem, name, !documentIsHTML ) :
  6510. undefined;
  6511. return val !== undefined ?
  6512. val :
  6513. support.attributes || !documentIsHTML ?
  6514. elem.getAttribute( name ) :
  6515. ( val = elem.getAttributeNode( name ) ) && val.specified ?
  6516. val.value :
  6517. null;
  6518. };
  6519. Sizzle.escape = function( sel ) {
  6520. return ( sel + "" ).replace( rcssescape, fcssescape );
  6521. };
  6522. Sizzle.error = function( msg ) {
  6523. throw new Error( "Syntax error, unrecognized expression: " + msg );
  6524. };
  6525. /**
  6526. * Document sorting and removing duplicates
  6527. * @param {ArrayLike} results
  6528. */
  6529. Sizzle.uniqueSort = function( results ) {
  6530. var elem,
  6531. duplicates = [],
  6532. j = 0,
  6533. i = 0;
  6534. // Unless we *know* we can detect duplicates, assume their presence
  6535. hasDuplicate = !support.detectDuplicates;
  6536. sortInput = !support.sortStable && results.slice( 0 );
  6537. results.sort( sortOrder );
  6538. if ( hasDuplicate ) {
  6539. while ( ( elem = results[ i++ ] ) ) {
  6540. if ( elem === results[ i ] ) {
  6541. j = duplicates.push( i );
  6542. }
  6543. }
  6544. while ( j-- ) {
  6545. results.splice( duplicates[ j ], 1 );
  6546. }
  6547. }
  6548. // Clear input after sorting to release objects
  6549. // See https://github.com/jquery/sizzle/pull/225
  6550. sortInput = null;
  6551. return results;
  6552. };
  6553. /**
  6554. * Utility function for retrieving the text value of an array of DOM nodes
  6555. * @param {Array|Element} elem
  6556. */
  6557. getText = Sizzle.getText = function( elem ) {
  6558. var node,
  6559. ret = "",
  6560. i = 0,
  6561. nodeType = elem.nodeType;
  6562. if ( !nodeType ) {
  6563. // If no nodeType, this is expected to be an array
  6564. while ( ( node = elem[ i++ ] ) ) {
  6565. // Do not traverse comment nodes
  6566. ret += getText( node );
  6567. }
  6568. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  6569. // Use textContent for elements
  6570. // innerText usage removed for consistency of new lines (jQuery #11153)
  6571. if ( typeof elem.textContent === "string" ) {
  6572. return elem.textContent;
  6573. } else {
  6574. // Traverse its children
  6575. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  6576. ret += getText( elem );
  6577. }
  6578. }
  6579. } else if ( nodeType === 3 || nodeType === 4 ) {
  6580. return elem.nodeValue;
  6581. }
  6582. // Do not include comment or processing instruction nodes
  6583. return ret;
  6584. };
  6585. Expr = Sizzle.selectors = {
  6586. // Can be adjusted by the user
  6587. cacheLength: 50,
  6588. createPseudo: markFunction,
  6589. match: matchExpr,
  6590. attrHandle: {},
  6591. find: {},
  6592. relative: {
  6593. ">": { dir: "parentNode", first: true },
  6594. " ": { dir: "parentNode" },
  6595. "+": { dir: "previousSibling", first: true },
  6596. "~": { dir: "previousSibling" }
  6597. },
  6598. preFilter: {
  6599. "ATTR": function( match ) {
  6600. match[ 1 ] = match[ 1 ].replace( runescape, funescape );
  6601. // Move the given value to match[3] whether quoted or unquoted
  6602. match[ 3 ] = ( match[ 3 ] || match[ 4 ] ||
  6603. match[ 5 ] || "" ).replace( runescape, funescape );
  6604. if ( match[ 2 ] === "~=" ) {
  6605. match[ 3 ] = " " + match[ 3 ] + " ";
  6606. }
  6607. return match.slice( 0, 4 );
  6608. },
  6609. "CHILD": function( match ) {
  6610. /* matches from matchExpr["CHILD"]
  6611. 1 type (only|nth|...)
  6612. 2 what (child|of-type)
  6613. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  6614. 4 xn-component of xn+y argument ([+-]?\d*n|)
  6615. 5 sign of xn-component
  6616. 6 x of xn-component
  6617. 7 sign of y-component
  6618. 8 y of y-component
  6619. */
  6620. match[ 1 ] = match[ 1 ].toLowerCase();
  6621. if ( match[ 1 ].slice( 0, 3 ) === "nth" ) {
  6622. // nth-* requires argument
  6623. if ( !match[ 3 ] ) {
  6624. Sizzle.error( match[ 0 ] );
  6625. }
  6626. // numeric x and y parameters for Expr.filter.CHILD
  6627. // remember that false/true cast respectively to 0/1
  6628. match[ 4 ] = +( match[ 4 ] ?
  6629. match[ 5 ] + ( match[ 6 ] || 1 ) :
  6630. 2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" ) );
  6631. match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" );
  6632. // other types prohibit arguments
  6633. } else if ( match[ 3 ] ) {
  6634. Sizzle.error( match[ 0 ] );
  6635. }
  6636. return match;
  6637. },
  6638. "PSEUDO": function( match ) {
  6639. var excess,
  6640. unquoted = !match[ 6 ] && match[ 2 ];
  6641. if ( matchExpr[ "CHILD" ].test( match[ 0 ] ) ) {
  6642. return null;
  6643. }
  6644. // Accept quoted arguments as-is
  6645. if ( match[ 3 ] ) {
  6646. match[ 2 ] = match[ 4 ] || match[ 5 ] || "";
  6647. // Strip excess characters from unquoted arguments
  6648. } else if ( unquoted && rpseudo.test( unquoted ) &&
  6649. // Get excess from tokenize (recursively)
  6650. ( excess = tokenize( unquoted, true ) ) &&
  6651. // advance to the next closing parenthesis
  6652. ( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) {
  6653. // excess is a negative index
  6654. match[ 0 ] = match[ 0 ].slice( 0, excess );
  6655. match[ 2 ] = unquoted.slice( 0, excess );
  6656. }
  6657. // Return only captures needed by the pseudo filter method (type and argument)
  6658. return match.slice( 0, 3 );
  6659. }
  6660. },
  6661. filter: {
  6662. "TAG": function( nodeNameSelector ) {
  6663. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  6664. return nodeNameSelector === "*" ?
  6665. function() {
  6666. return true;
  6667. } :
  6668. function( elem ) {
  6669. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  6670. };
  6671. },
  6672. "CLASS": function( className ) {
  6673. var pattern = classCache[ className + " " ];
  6674. return pattern ||
  6675. ( pattern = new RegExp( "(^|" + whitespace +
  6676. ")" + className + "(" + whitespace + "|$)" ) ) && classCache(
  6677. className, function( elem ) {
  6678. return pattern.test(
  6679. typeof elem.className === "string" && elem.className ||
  6680. typeof elem.getAttribute !== "undefined" &&
  6681. elem.getAttribute( "class" ) ||
  6682. ""
  6683. );
  6684. } );
  6685. },
  6686. "ATTR": function( name, operator, check ) {
  6687. return function( elem ) {
  6688. var result = Sizzle.attr( elem, name );
  6689. if ( result == null ) {
  6690. return operator === "!=";
  6691. }
  6692. if ( !operator ) {
  6693. return true;
  6694. }
  6695. result += "";
  6696. /* eslint-disable max-len */
  6697. return operator === "=" ? result === check :
  6698. operator === "!=" ? result !== check :
  6699. operator === "^=" ? check && result.indexOf( check ) === 0 :
  6700. operator === "*=" ? check && result.indexOf( check ) > -1 :
  6701. operator === "$=" ? check && result.slice( -check.length ) === check :
  6702. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  6703. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  6704. false;
  6705. /* eslint-enable max-len */
  6706. };
  6707. },
  6708. "CHILD": function( type, what, _argument, first, last ) {
  6709. var simple = type.slice( 0, 3 ) !== "nth",
  6710. forward = type.slice( -4 ) !== "last",
  6711. ofType = what === "of-type";
  6712. return first === 1 && last === 0 ?
  6713. // Shortcut for :nth-*(n)
  6714. function( elem ) {
  6715. return !!elem.parentNode;
  6716. } :
  6717. function( elem, _context, xml ) {
  6718. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  6719. dir = simple !== forward ? "nextSibling" : "previousSibling",
  6720. parent = elem.parentNode,
  6721. name = ofType && elem.nodeName.toLowerCase(),
  6722. useCache = !xml && !ofType,
  6723. diff = false;
  6724. if ( parent ) {
  6725. // :(first|last|only)-(child|of-type)
  6726. if ( simple ) {
  6727. while ( dir ) {
  6728. node = elem;
  6729. while ( ( node = node[ dir ] ) ) {
  6730. if ( ofType ?
  6731. node.nodeName.toLowerCase() === name :
  6732. node.nodeType === 1 ) {
  6733. return false;
  6734. }
  6735. }
  6736. // Reverse direction for :only-* (if we haven't yet done so)
  6737. start = dir = type === "only" && !start && "nextSibling";
  6738. }
  6739. return true;
  6740. }
  6741. start = [ forward ? parent.firstChild : parent.lastChild ];
  6742. // non-xml :nth-child(...) stores cache data on `parent`
  6743. if ( forward && useCache ) {
  6744. // Seek `elem` from a previously-cached index
  6745. // ...in a gzip-friendly way
  6746. node = parent;
  6747. outerCache = node[ expando ] || ( node[ expando ] = {} );
  6748. // Support: IE <9 only
  6749. // Defend against cloned attroperties (jQuery gh-1709)
  6750. uniqueCache = outerCache[ node.uniqueID ] ||
  6751. ( outerCache[ node.uniqueID ] = {} );
  6752. cache = uniqueCache[ type ] || [];
  6753. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  6754. diff = nodeIndex && cache[ 2 ];
  6755. node = nodeIndex && parent.childNodes[ nodeIndex ];
  6756. while ( ( node = ++nodeIndex && node && node[ dir ] ||
  6757. // Fallback to seeking `elem` from the start
  6758. ( diff = nodeIndex = 0 ) || start.pop() ) ) {
  6759. // When found, cache indexes on `parent` and break
  6760. if ( node.nodeType === 1 && ++diff && node === elem ) {
  6761. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  6762. break;
  6763. }
  6764. }
  6765. } else {
  6766. // Use previously-cached element index if available
  6767. if ( useCache ) {
  6768. // ...in a gzip-friendly way
  6769. node = elem;
  6770. outerCache = node[ expando ] || ( node[ expando ] = {} );
  6771. // Support: IE <9 only
  6772. // Defend against cloned attroperties (jQuery gh-1709)
  6773. uniqueCache = outerCache[ node.uniqueID ] ||
  6774. ( outerCache[ node.uniqueID ] = {} );
  6775. cache = uniqueCache[ type ] || [];
  6776. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  6777. diff = nodeIndex;
  6778. }
  6779. // xml :nth-child(...)
  6780. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  6781. if ( diff === false ) {
  6782. // Use the same loop as above to seek `elem` from the start
  6783. while ( ( node = ++nodeIndex && node && node[ dir ] ||
  6784. ( diff = nodeIndex = 0 ) || start.pop() ) ) {
  6785. if ( ( ofType ?
  6786. node.nodeName.toLowerCase() === name :
  6787. node.nodeType === 1 ) &&
  6788. ++diff ) {
  6789. // Cache the index of each encountered element
  6790. if ( useCache ) {
  6791. outerCache = node[ expando ] ||
  6792. ( node[ expando ] = {} );
  6793. // Support: IE <9 only
  6794. // Defend against cloned attroperties (jQuery gh-1709)
  6795. uniqueCache = outerCache[ node.uniqueID ] ||
  6796. ( outerCache[ node.uniqueID ] = {} );
  6797. uniqueCache[ type ] = [ dirruns, diff ];
  6798. }
  6799. if ( node === elem ) {
  6800. break;
  6801. }
  6802. }
  6803. }
  6804. }
  6805. }
  6806. // Incorporate the offset, then check against cycle size
  6807. diff -= last;
  6808. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  6809. }
  6810. };
  6811. },
  6812. "PSEUDO": function( pseudo, argument ) {
  6813. // pseudo-class names are case-insensitive
  6814. // http://www.w3.org/TR/selectors/#pseudo-classes
  6815. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  6816. // Remember that setFilters inherits from pseudos
  6817. var args,
  6818. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  6819. Sizzle.error( "unsupported pseudo: " + pseudo );
  6820. // The user may use createPseudo to indicate that
  6821. // arguments are needed to create the filter function
  6822. // just as Sizzle does
  6823. if ( fn[ expando ] ) {
  6824. return fn( argument );
  6825. }
  6826. // But maintain support for old signatures
  6827. if ( fn.length > 1 ) {
  6828. args = [ pseudo, pseudo, "", argument ];
  6829. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  6830. markFunction( function( seed, matches ) {
  6831. var idx,
  6832. matched = fn( seed, argument ),
  6833. i = matched.length;
  6834. while ( i-- ) {
  6835. idx = indexOf( seed, matched[ i ] );
  6836. seed[ idx ] = !( matches[ idx ] = matched[ i ] );
  6837. }
  6838. } ) :
  6839. function( elem ) {
  6840. return fn( elem, 0, args );
  6841. };
  6842. }
  6843. return fn;
  6844. }
  6845. },
  6846. pseudos: {
  6847. // Potentially complex pseudos
  6848. "not": markFunction( function( selector ) {
  6849. // Trim the selector passed to compile
  6850. // to avoid treating leading and trailing
  6851. // spaces as combinators
  6852. var input = [],
  6853. results = [],
  6854. matcher = compile( selector.replace( rtrim, "$1" ) );
  6855. return matcher[ expando ] ?
  6856. markFunction( function( seed, matches, _context, xml ) {
  6857. var elem,
  6858. unmatched = matcher( seed, null, xml, [] ),
  6859. i = seed.length;
  6860. // Match elements unmatched by `matcher`
  6861. while ( i-- ) {
  6862. if ( ( elem = unmatched[ i ] ) ) {
  6863. seed[ i ] = !( matches[ i ] = elem );
  6864. }
  6865. }
  6866. } ) :
  6867. function( elem, _context, xml ) {
  6868. input[ 0 ] = elem;
  6869. matcher( input, null, xml, results );
  6870. // Don't keep the element (issue #299)
  6871. input[ 0 ] = null;
  6872. return !results.pop();
  6873. };
  6874. } ),
  6875. "has": markFunction( function( selector ) {
  6876. return function( elem ) {
  6877. return Sizzle( selector, elem ).length > 0;
  6878. };
  6879. } ),
  6880. "contains": markFunction( function( text ) {
  6881. text = text.replace( runescape, funescape );
  6882. return function( elem ) {
  6883. return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
  6884. };
  6885. } ),
  6886. // "Whether an element is represented by a :lang() selector
  6887. // is based solely on the element's language value
  6888. // being equal to the identifier C,
  6889. // or beginning with the identifier C immediately followed by "-".
  6890. // The matching of C against the element's language value is performed case-insensitively.
  6891. // The identifier C does not have to be a valid language name."
  6892. // http://www.w3.org/TR/selectors/#lang-pseudo
  6893. "lang": markFunction( function( lang ) {
  6894. // lang value must be a valid identifier
  6895. if ( !ridentifier.test( lang || "" ) ) {
  6896. Sizzle.error( "unsupported lang: " + lang );
  6897. }
  6898. lang = lang.replace( runescape, funescape ).toLowerCase();
  6899. return function( elem ) {
  6900. var elemLang;
  6901. do {
  6902. if ( ( elemLang = documentIsHTML ?
  6903. elem.lang :
  6904. elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) {
  6905. elemLang = elemLang.toLowerCase();
  6906. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  6907. }
  6908. } while ( ( elem = elem.parentNode ) && elem.nodeType === 1 );
  6909. return false;
  6910. };
  6911. } ),
  6912. // Miscellaneous
  6913. "target": function( elem ) {
  6914. var hash = window.location && window.location.hash;
  6915. return hash && hash.slice( 1 ) === elem.id;
  6916. },
  6917. "root": function( elem ) {
  6918. return elem === docElem;
  6919. },
  6920. "focus": function( elem ) {
  6921. return elem === document.activeElement &&
  6922. ( !document.hasFocus || document.hasFocus() ) &&
  6923. !!( elem.type || elem.href || ~elem.tabIndex );
  6924. },
  6925. // Boolean properties
  6926. "enabled": createDisabledPseudo( false ),
  6927. "disabled": createDisabledPseudo( true ),
  6928. "checked": function( elem ) {
  6929. // In CSS3, :checked should return both checked and selected elements
  6930. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  6931. var nodeName = elem.nodeName.toLowerCase();
  6932. return ( nodeName === "input" && !!elem.checked ) ||
  6933. ( nodeName === "option" && !!elem.selected );
  6934. },
  6935. "selected": function( elem ) {
  6936. // Accessing this property makes selected-by-default
  6937. // options in Safari work properly
  6938. if ( elem.parentNode ) {
  6939. // eslint-disable-next-line no-unused-expressions
  6940. elem.parentNode.selectedIndex;
  6941. }
  6942. return elem.selected === true;
  6943. },
  6944. // Contents
  6945. "empty": function( elem ) {
  6946. // http://www.w3.org/TR/selectors/#empty-pseudo
  6947. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  6948. // but not by others (comment: 8; processing instruction: 7; etc.)
  6949. // nodeType < 6 works because attributes (2) do not appear as children
  6950. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  6951. if ( elem.nodeType < 6 ) {
  6952. return false;
  6953. }
  6954. }
  6955. return true;
  6956. },
  6957. "parent": function( elem ) {
  6958. return !Expr.pseudos[ "empty" ]( elem );
  6959. },
  6960. // Element/input types
  6961. "header": function( elem ) {
  6962. return rheader.test( elem.nodeName );
  6963. },
  6964. "input": function( elem ) {
  6965. return rinputs.test( elem.nodeName );
  6966. },
  6967. "button": function( elem ) {
  6968. var name = elem.nodeName.toLowerCase();
  6969. return name === "input" && elem.type === "button" || name === "button";
  6970. },
  6971. "text": function( elem ) {
  6972. var attr;
  6973. return elem.nodeName.toLowerCase() === "input" &&
  6974. elem.type === "text" &&
  6975. // Support: IE<8
  6976. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  6977. ( ( attr = elem.getAttribute( "type" ) ) == null ||
  6978. attr.toLowerCase() === "text" );
  6979. },
  6980. // Position-in-collection
  6981. "first": createPositionalPseudo( function() {
  6982. return [ 0 ];
  6983. } ),
  6984. "last": createPositionalPseudo( function( _matchIndexes, length ) {
  6985. return [ length - 1 ];
  6986. } ),
  6987. "eq": createPositionalPseudo( function( _matchIndexes, length, argument ) {
  6988. return [ argument < 0 ? argument + length : argument ];
  6989. } ),
  6990. "even": createPositionalPseudo( function( matchIndexes, length ) {
  6991. var i = 0;
  6992. for ( ; i < length; i += 2 ) {
  6993. matchIndexes.push( i );
  6994. }
  6995. return matchIndexes;
  6996. } ),
  6997. "odd": createPositionalPseudo( function( matchIndexes, length ) {
  6998. var i = 1;
  6999. for ( ; i < length; i += 2 ) {
  7000. matchIndexes.push( i );
  7001. }
  7002. return matchIndexes;
  7003. } ),
  7004. "lt": createPositionalPseudo( function( matchIndexes, length, argument ) {
  7005. var i = argument < 0 ?
  7006. argument + length :
  7007. argument > length ?
  7008. length :
  7009. argument;
  7010. for ( ; --i >= 0; ) {
  7011. matchIndexes.push( i );
  7012. }
  7013. return matchIndexes;
  7014. } ),
  7015. "gt": createPositionalPseudo( function( matchIndexes, length, argument ) {
  7016. var i = argument < 0 ? argument + length : argument;
  7017. for ( ; ++i < length; ) {
  7018. matchIndexes.push( i );
  7019. }
  7020. return matchIndexes;
  7021. } )
  7022. }
  7023. };
  7024. Expr.pseudos[ "nth" ] = Expr.pseudos[ "eq" ];
  7025. // Add button/input type pseudos
  7026. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  7027. Expr.pseudos[ i ] = createInputPseudo( i );
  7028. }
  7029. for ( i in { submit: true, reset: true } ) {
  7030. Expr.pseudos[ i ] = createButtonPseudo( i );
  7031. }
  7032. // Easy API for creating new setFilters
  7033. function setFilters() {}
  7034. setFilters.prototype = Expr.filters = Expr.pseudos;
  7035. Expr.setFilters = new setFilters();
  7036. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  7037. var matched, match, tokens, type,
  7038. soFar, groups, preFilters,
  7039. cached = tokenCache[ selector + " " ];
  7040. if ( cached ) {
  7041. return parseOnly ? 0 : cached.slice( 0 );
  7042. }
  7043. soFar = selector;
  7044. groups = [];
  7045. preFilters = Expr.preFilter;
  7046. while ( soFar ) {
  7047. // Comma and first run
  7048. if ( !matched || ( match = rcomma.exec( soFar ) ) ) {
  7049. if ( match ) {
  7050. // Don't consume trailing commas as valid
  7051. soFar = soFar.slice( match[ 0 ].length ) || soFar;
  7052. }
  7053. groups.push( ( tokens = [] ) );
  7054. }
  7055. matched = false;
  7056. // Combinators
  7057. if ( ( match = rcombinators.exec( soFar ) ) ) {
  7058. matched = match.shift();
  7059. tokens.push( {
  7060. value: matched,
  7061. // Cast descendant combinators to space
  7062. type: match[ 0 ].replace( rtrim, " " )
  7063. } );
  7064. soFar = soFar.slice( matched.length );
  7065. }
  7066. // Filters
  7067. for ( type in Expr.filter ) {
  7068. if ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] ||
  7069. ( match = preFilters[ type ]( match ) ) ) ) {
  7070. matched = match.shift();
  7071. tokens.push( {
  7072. value: matched,
  7073. type: type,
  7074. matches: match
  7075. } );
  7076. soFar = soFar.slice( matched.length );
  7077. }
  7078. }
  7079. if ( !matched ) {
  7080. break;
  7081. }
  7082. }
  7083. // Return the length of the invalid excess
  7084. // if we're just parsing
  7085. // Otherwise, throw an error or return tokens
  7086. return parseOnly ?
  7087. soFar.length :
  7088. soFar ?
  7089. Sizzle.error( selector ) :
  7090. // Cache the tokens
  7091. tokenCache( selector, groups ).slice( 0 );
  7092. };
  7093. function toSelector( tokens ) {
  7094. var i = 0,
  7095. len = tokens.length,
  7096. selector = "";
  7097. for ( ; i < len; i++ ) {
  7098. selector += tokens[ i ].value;
  7099. }
  7100. return selector;
  7101. }
  7102. function addCombinator( matcher, combinator, base ) {
  7103. var dir = combinator.dir,
  7104. skip = combinator.next,
  7105. key = skip || dir,
  7106. checkNonElements = base && key === "parentNode",
  7107. doneName = done++;
  7108. return combinator.first ?
  7109. // Check against closest ancestor/preceding element
  7110. function( elem, context, xml ) {
  7111. while ( ( elem = elem[ dir ] ) ) {
  7112. if ( elem.nodeType === 1 || checkNonElements ) {
  7113. return matcher( elem, context, xml );
  7114. }
  7115. }
  7116. return false;
  7117. } :
  7118. // Check against all ancestor/preceding elements
  7119. function( elem, context, xml ) {
  7120. var oldCache, uniqueCache, outerCache,
  7121. newCache = [ dirruns, doneName ];
  7122. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  7123. if ( xml ) {
  7124. while ( ( elem = elem[ dir ] ) ) {
  7125. if ( elem.nodeType === 1 || checkNonElements ) {
  7126. if ( matcher( elem, context, xml ) ) {
  7127. return true;
  7128. }
  7129. }
  7130. }
  7131. } else {
  7132. while ( ( elem = elem[ dir ] ) ) {
  7133. if ( elem.nodeType === 1 || checkNonElements ) {
  7134. outerCache = elem[ expando ] || ( elem[ expando ] = {} );
  7135. // Support: IE <9 only
  7136. // Defend against cloned attroperties (jQuery gh-1709)
  7137. uniqueCache = outerCache[ elem.uniqueID ] ||
  7138. ( outerCache[ elem.uniqueID ] = {} );
  7139. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  7140. elem = elem[ dir ] || elem;
  7141. } else if ( ( oldCache = uniqueCache[ key ] ) &&
  7142. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  7143. // Assign to newCache so results back-propagate to previous elements
  7144. return ( newCache[ 2 ] = oldCache[ 2 ] );
  7145. } else {
  7146. // Reuse newcache so results back-propagate to previous elements
  7147. uniqueCache[ key ] = newCache;
  7148. // A match means we're done; a fail means we have to keep checking
  7149. if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) {
  7150. return true;
  7151. }
  7152. }
  7153. }
  7154. }
  7155. }
  7156. return false;
  7157. };
  7158. }
  7159. function elementMatcher( matchers ) {
  7160. return matchers.length > 1 ?
  7161. function( elem, context, xml ) {
  7162. var i = matchers.length;
  7163. while ( i-- ) {
  7164. if ( !matchers[ i ]( elem, context, xml ) ) {
  7165. return false;
  7166. }
  7167. }
  7168. return true;
  7169. } :
  7170. matchers[ 0 ];
  7171. }
  7172. function multipleContexts( selector, contexts, results ) {
  7173. var i = 0,
  7174. len = contexts.length;
  7175. for ( ; i < len; i++ ) {
  7176. Sizzle( selector, contexts[ i ], results );
  7177. }
  7178. return results;
  7179. }
  7180. function condense( unmatched, map, filter, context, xml ) {
  7181. var elem,
  7182. newUnmatched = [],
  7183. i = 0,
  7184. len = unmatched.length,
  7185. mapped = map != null;
  7186. for ( ; i < len; i++ ) {
  7187. if ( ( elem = unmatched[ i ] ) ) {
  7188. if ( !filter || filter( elem, context, xml ) ) {
  7189. newUnmatched.push( elem );
  7190. if ( mapped ) {
  7191. map.push( i );
  7192. }
  7193. }
  7194. }
  7195. }
  7196. return newUnmatched;
  7197. }
  7198. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  7199. if ( postFilter && !postFilter[ expando ] ) {
  7200. postFilter = setMatcher( postFilter );
  7201. }
  7202. if ( postFinder && !postFinder[ expando ] ) {
  7203. postFinder = setMatcher( postFinder, postSelector );
  7204. }
  7205. return markFunction( function( seed, results, context, xml ) {
  7206. var temp, i, elem,
  7207. preMap = [],
  7208. postMap = [],
  7209. preexisting = results.length,
  7210. // Get initial elements from seed or context
  7211. elems = seed || multipleContexts(
  7212. selector || "*",
  7213. context.nodeType ? [ context ] : context,
  7214. []
  7215. ),
  7216. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  7217. matcherIn = preFilter && ( seed || !selector ) ?
  7218. condense( elems, preMap, preFilter, context, xml ) :
  7219. elems,
  7220. matcherOut = matcher ?
  7221. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  7222. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  7223. // ...intermediate processing is necessary
  7224. [] :
  7225. // ...otherwise use results directly
  7226. results :
  7227. matcherIn;
  7228. // Find primary matches
  7229. if ( matcher ) {
  7230. matcher( matcherIn, matcherOut, context, xml );
  7231. }
  7232. // Apply postFilter
  7233. if ( postFilter ) {
  7234. temp = condense( matcherOut, postMap );
  7235. postFilter( temp, [], context, xml );
  7236. // Un-match failing elements by moving them back to matcherIn
  7237. i = temp.length;
  7238. while ( i-- ) {
  7239. if ( ( elem = temp[ i ] ) ) {
  7240. matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem );
  7241. }
  7242. }
  7243. }
  7244. if ( seed ) {
  7245. if ( postFinder || preFilter ) {
  7246. if ( postFinder ) {
  7247. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  7248. temp = [];
  7249. i = matcherOut.length;
  7250. while ( i-- ) {
  7251. if ( ( elem = matcherOut[ i ] ) ) {
  7252. // Restore matcherIn since elem is not yet a final match
  7253. temp.push( ( matcherIn[ i ] = elem ) );
  7254. }
  7255. }
  7256. postFinder( null, ( matcherOut = [] ), temp, xml );
  7257. }
  7258. // Move matched elements from seed to results to keep them synchronized
  7259. i = matcherOut.length;
  7260. while ( i-- ) {
  7261. if ( ( elem = matcherOut[ i ] ) &&
  7262. ( temp = postFinder ? indexOf( seed, elem ) : preMap[ i ] ) > -1 ) {
  7263. seed[ temp ] = !( results[ temp ] = elem );
  7264. }
  7265. }
  7266. }
  7267. // Add elements to results, through postFinder if defined
  7268. } else {
  7269. matcherOut = condense(
  7270. matcherOut === results ?
  7271. matcherOut.splice( preexisting, matcherOut.length ) :
  7272. matcherOut
  7273. );
  7274. if ( postFinder ) {
  7275. postFinder( null, results, matcherOut, xml );
  7276. } else {
  7277. push.apply( results, matcherOut );
  7278. }
  7279. }
  7280. } );
  7281. }
  7282. function matcherFromTokens( tokens ) {
  7283. var checkContext, matcher, j,
  7284. len = tokens.length,
  7285. leadingRelative = Expr.relative[ tokens[ 0 ].type ],
  7286. implicitRelative = leadingRelative || Expr.relative[ " " ],
  7287. i = leadingRelative ? 1 : 0,
  7288. // The foundational matcher ensures that elements are reachable from top-level context(s)
  7289. matchContext = addCombinator( function( elem ) {
  7290. return elem === checkContext;
  7291. }, implicitRelative, true ),
  7292. matchAnyContext = addCombinator( function( elem ) {
  7293. return indexOf( checkContext, elem ) > -1;
  7294. }, implicitRelative, true ),
  7295. matchers = [ function( elem, context, xml ) {
  7296. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  7297. ( checkContext = context ).nodeType ?
  7298. matchContext( elem, context, xml ) :
  7299. matchAnyContext( elem, context, xml ) );
  7300. // Avoid hanging onto element (issue #299)
  7301. checkContext = null;
  7302. return ret;
  7303. } ];
  7304. for ( ; i < len; i++ ) {
  7305. if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) {
  7306. matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
  7307. } else {
  7308. matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches );
  7309. // Return special upon seeing a positional matcher
  7310. if ( matcher[ expando ] ) {
  7311. // Find the next relative operator (if any) for proper handling
  7312. j = ++i;
  7313. for ( ; j < len; j++ ) {
  7314. if ( Expr.relative[ tokens[ j ].type ] ) {
  7315. break;
  7316. }
  7317. }
  7318. return setMatcher(
  7319. i > 1 && elementMatcher( matchers ),
  7320. i > 1 && toSelector(
  7321. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  7322. tokens
  7323. .slice( 0, i - 1 )
  7324. .concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } )
  7325. ).replace( rtrim, "$1" ),
  7326. matcher,
  7327. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  7328. j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ),
  7329. j < len && toSelector( tokens )
  7330. );
  7331. }
  7332. matchers.push( matcher );
  7333. }
  7334. }
  7335. return elementMatcher( matchers );
  7336. }
  7337. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  7338. var bySet = setMatchers.length > 0,
  7339. byElement = elementMatchers.length > 0,
  7340. superMatcher = function( seed, context, xml, results, outermost ) {
  7341. var elem, j, matcher,
  7342. matchedCount = 0,
  7343. i = "0",
  7344. unmatched = seed && [],
  7345. setMatched = [],
  7346. contextBackup = outermostContext,
  7347. // We must always have either seed elements or outermost context
  7348. elems = seed || byElement && Expr.find[ "TAG" ]( "*", outermost ),
  7349. // Use integer dirruns iff this is the outermost matcher
  7350. dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 ),
  7351. len = elems.length;
  7352. if ( outermost ) {
  7353. // Support: IE 11+, Edge 17 - 18+
  7354. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  7355. // two documents; shallow comparisons work.
  7356. // eslint-disable-next-line eqeqeq
  7357. outermostContext = context == document || context || outermost;
  7358. }
  7359. // Add elements passing elementMatchers directly to results
  7360. // Support: IE<9, Safari
  7361. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  7362. for ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) {
  7363. if ( byElement && elem ) {
  7364. j = 0;
  7365. // Support: IE 11+, Edge 17 - 18+
  7366. // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
  7367. // two documents; shallow comparisons work.
  7368. // eslint-disable-next-line eqeqeq
  7369. if ( !context && elem.ownerDocument != document ) {
  7370. setDocument( elem );
  7371. xml = !documentIsHTML;
  7372. }
  7373. while ( ( matcher = elementMatchers[ j++ ] ) ) {
  7374. if ( matcher( elem, context || document, xml ) ) {
  7375. results.push( elem );
  7376. break;
  7377. }
  7378. }
  7379. if ( outermost ) {
  7380. dirruns = dirrunsUnique;
  7381. }
  7382. }
  7383. // Track unmatched elements for set filters
  7384. if ( bySet ) {
  7385. // They will have gone through all possible matchers
  7386. if ( ( elem = !matcher && elem ) ) {
  7387. matchedCount--;
  7388. }
  7389. // Lengthen the array for every element, matched or not
  7390. if ( seed ) {
  7391. unmatched.push( elem );
  7392. }
  7393. }
  7394. }
  7395. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  7396. // makes the latter nonnegative.
  7397. matchedCount += i;
  7398. // Apply set filters to unmatched elements
  7399. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  7400. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  7401. // no element matchers and no seed.
  7402. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  7403. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  7404. // numerically zero.
  7405. if ( bySet && i !== matchedCount ) {
  7406. j = 0;
  7407. while ( ( matcher = setMatchers[ j++ ] ) ) {
  7408. matcher( unmatched, setMatched, context, xml );
  7409. }
  7410. if ( seed ) {
  7411. // Reintegrate element matches to eliminate the need for sorting
  7412. if ( matchedCount > 0 ) {
  7413. while ( i-- ) {
  7414. if ( !( unmatched[ i ] || setMatched[ i ] ) ) {
  7415. setMatched[ i ] = pop.call( results );
  7416. }
  7417. }
  7418. }
  7419. // Discard index placeholder values to get only actual matches
  7420. setMatched = condense( setMatched );
  7421. }
  7422. // Add matches to results
  7423. push.apply( results, setMatched );
  7424. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  7425. if ( outermost && !seed && setMatched.length > 0 &&
  7426. ( matchedCount + setMatchers.length ) > 1 ) {
  7427. Sizzle.uniqueSort( results );
  7428. }
  7429. }
  7430. // Override manipulation of globals by nested matchers
  7431. if ( outermost ) {
  7432. dirruns = dirrunsUnique;
  7433. outermostContext = contextBackup;
  7434. }
  7435. return unmatched;
  7436. };
  7437. return bySet ?
  7438. markFunction( superMatcher ) :
  7439. superMatcher;
  7440. }
  7441. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  7442. var i,
  7443. setMatchers = [],
  7444. elementMatchers = [],
  7445. cached = compilerCache[ selector + " " ];
  7446. if ( !cached ) {
  7447. // Generate a function of recursive functions that can be used to check each element
  7448. if ( !match ) {
  7449. match = tokenize( selector );
  7450. }
  7451. i = match.length;
  7452. while ( i-- ) {
  7453. cached = matcherFromTokens( match[ i ] );
  7454. if ( cached[ expando ] ) {
  7455. setMatchers.push( cached );
  7456. } else {
  7457. elementMatchers.push( cached );
  7458. }
  7459. }
  7460. // Cache the compiled function
  7461. cached = compilerCache(
  7462. selector,
  7463. matcherFromGroupMatchers( elementMatchers, setMatchers )
  7464. );
  7465. // Save selector and tokenization
  7466. cached.selector = selector;
  7467. }
  7468. return cached;
  7469. };
  7470. /**
  7471. * A low-level selection function that works with Sizzle's compiled
  7472. * selector functions
  7473. * @param {String|Function} selector A selector or a pre-compiled
  7474. * selector function built with Sizzle.compile
  7475. * @param {Element} context
  7476. * @param {Array} [results]
  7477. * @param {Array} [seed] A set of elements to match against
  7478. */
  7479. select = Sizzle.select = function( selector, context, results, seed ) {
  7480. var i, tokens, token, type, find,
  7481. compiled = typeof selector === "function" && selector,
  7482. match = !seed && tokenize( ( selector = compiled.selector || selector ) );
  7483. results = results || [];
  7484. // Try to minimize operations if there is only one selector in the list and no seed
  7485. // (the latter of which guarantees us context)
  7486. if ( match.length === 1 ) {
  7487. // Reduce context if the leading compound selector is an ID
  7488. tokens = match[ 0 ] = match[ 0 ].slice( 0 );
  7489. if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" &&
  7490. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) {
  7491. context = ( Expr.find[ "ID" ]( token.matches[ 0 ]
  7492. .replace( runescape, funescape ), context ) || [] )[ 0 ];
  7493. if ( !context ) {
  7494. return results;
  7495. // Precompiled matchers will still verify ancestry, so step up a level
  7496. } else if ( compiled ) {
  7497. context = context.parentNode;
  7498. }
  7499. selector = selector.slice( tokens.shift().value.length );
  7500. }
  7501. // Fetch a seed set for right-to-left matching
  7502. i = matchExpr[ "needsContext" ].test( selector ) ? 0 : tokens.length;
  7503. while ( i-- ) {
  7504. token = tokens[ i ];
  7505. // Abort if we hit a combinator
  7506. if ( Expr.relative[ ( type = token.type ) ] ) {
  7507. break;
  7508. }
  7509. if ( ( find = Expr.find[ type ] ) ) {
  7510. // Search, expanding context for leading sibling combinators
  7511. if ( ( seed = find(
  7512. token.matches[ 0 ].replace( runescape, funescape ),
  7513. rsibling.test( tokens[ 0 ].type ) && testContext( context.parentNode ) ||
  7514. context
  7515. ) ) ) {
  7516. // If seed is empty or no tokens remain, we can return early
  7517. tokens.splice( i, 1 );
  7518. selector = seed.length && toSelector( tokens );
  7519. if ( !selector ) {
  7520. push.apply( results, seed );
  7521. return results;
  7522. }
  7523. break;
  7524. }
  7525. }
  7526. }
  7527. }
  7528. // Compile and execute a filtering function if one is not provided
  7529. // Provide `match` to avoid retokenization if we modified the selector above
  7530. ( compiled || compile( selector, match ) )(
  7531. seed,
  7532. context,
  7533. !documentIsHTML,
  7534. results,
  7535. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  7536. );
  7537. return results;
  7538. };
  7539. // One-time assignments
  7540. // Sort stability
  7541. support.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando;
  7542. // Support: Chrome 14-35+
  7543. // Always assume duplicates if they aren't passed to the comparison function
  7544. support.detectDuplicates = !!hasDuplicate;
  7545. // Initialize against the default document
  7546. setDocument();
  7547. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  7548. // Detached nodes confoundingly follow *each other*
  7549. support.sortDetached = assert( function( el ) {
  7550. // Should return 1, but returns 4 (following)
  7551. return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1;
  7552. } );
  7553. // Support: IE<8
  7554. // Prevent attribute/property "interpolation"
  7555. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  7556. if ( !assert( function( el ) {
  7557. el.innerHTML = "<a href='#'></a>";
  7558. return el.firstChild.getAttribute( "href" ) === "#";
  7559. } ) ) {
  7560. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  7561. if ( !isXML ) {
  7562. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  7563. }
  7564. } );
  7565. }
  7566. // Support: IE<9
  7567. // Use defaultValue in place of getAttribute("value")
  7568. if ( !support.attributes || !assert( function( el ) {
  7569. el.innerHTML = "<input/>";
  7570. el.firstChild.setAttribute( "value", "" );
  7571. return el.firstChild.getAttribute( "value" ) === "";
  7572. } ) ) {
  7573. addHandle( "value", function( elem, _name, isXML ) {
  7574. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  7575. return elem.defaultValue;
  7576. }
  7577. } );
  7578. }
  7579. // Support: IE<9
  7580. // Use getAttributeNode to fetch booleans when getAttribute lies
  7581. if ( !assert( function( el ) {
  7582. return el.getAttribute( "disabled" ) == null;
  7583. } ) ) {
  7584. addHandle( booleans, function( elem, name, isXML ) {
  7585. var val;
  7586. if ( !isXML ) {
  7587. return elem[ name ] === true ? name.toLowerCase() :
  7588. ( val = elem.getAttributeNode( name ) ) && val.specified ?
  7589. val.value :
  7590. null;
  7591. }
  7592. } );
  7593. }
  7594. return Sizzle;
  7595. } )( window );
  7596. jQuery.find = Sizzle;
  7597. jQuery.expr = Sizzle.selectors;
  7598. // Deprecated
  7599. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  7600. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  7601. jQuery.text = Sizzle.getText;
  7602. jQuery.isXMLDoc = Sizzle.isXML;
  7603. jQuery.contains = Sizzle.contains;
  7604. jQuery.escapeSelector = Sizzle.escape;
  7605. var dir = function( elem, dir, until ) {
  7606. var matched = [],
  7607. truncate = until !== undefined;
  7608. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  7609. if ( elem.nodeType === 1 ) {
  7610. if ( truncate && jQuery( elem ).is( until ) ) {
  7611. break;
  7612. }
  7613. matched.push( elem );
  7614. }
  7615. }
  7616. return matched;
  7617. };
  7618. var siblings = function( n, elem ) {
  7619. var matched = [];
  7620. for ( ; n; n = n.nextSibling ) {
  7621. if ( n.nodeType === 1 && n !== elem ) {
  7622. matched.push( n );
  7623. }
  7624. }
  7625. return matched;
  7626. };
  7627. var rneedsContext = jQuery.expr.match.needsContext;
  7628. function nodeName( elem, name ) {
  7629. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  7630. };
  7631. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  7632. // Implement the identical functionality for filter and not
  7633. function winnow( elements, qualifier, not ) {
  7634. if ( isFunction( qualifier ) ) {
  7635. return jQuery.grep( elements, function( elem, i ) {
  7636. return !!qualifier.call( elem, i, elem ) !== not;
  7637. } );
  7638. }
  7639. // Single element
  7640. if ( qualifier.nodeType ) {
  7641. return jQuery.grep( elements, function( elem ) {
  7642. return ( elem === qualifier ) !== not;
  7643. } );
  7644. }
  7645. // Arraylike of elements (jQuery, arguments, Array)
  7646. if ( typeof qualifier !== "string" ) {
  7647. return jQuery.grep( elements, function( elem ) {
  7648. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  7649. } );
  7650. }
  7651. // Filtered directly for both simple and complex selectors
  7652. return jQuery.filter( qualifier, elements, not );
  7653. }
  7654. jQuery.filter = function( expr, elems, not ) {
  7655. var elem = elems[ 0 ];
  7656. if ( not ) {
  7657. expr = ":not(" + expr + ")";
  7658. }
  7659. if ( elems.length === 1 && elem.nodeType === 1 ) {
  7660. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  7661. }
  7662. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  7663. return elem.nodeType === 1;
  7664. } ) );
  7665. };
  7666. jQuery.fn.extend( {
  7667. find: function( selector ) {
  7668. var i, ret,
  7669. len = this.length,
  7670. self = this;
  7671. if ( typeof selector !== "string" ) {
  7672. return this.pushStack( jQuery( selector ).filter( function() {
  7673. for ( i = 0; i < len; i++ ) {
  7674. if ( jQuery.contains( self[ i ], this ) ) {
  7675. return true;
  7676. }
  7677. }
  7678. } ) );
  7679. }
  7680. ret = this.pushStack( [] );
  7681. for ( i = 0; i < len; i++ ) {
  7682. jQuery.find( selector, self[ i ], ret );
  7683. }
  7684. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  7685. },
  7686. filter: function( selector ) {
  7687. return this.pushStack( winnow( this, selector || [], false ) );
  7688. },
  7689. not: function( selector ) {
  7690. return this.pushStack( winnow( this, selector || [], true ) );
  7691. },
  7692. is: function( selector ) {
  7693. return !!winnow(
  7694. this,
  7695. // If this is a positional/relative selector, check membership in the returned set
  7696. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  7697. typeof selector === "string" && rneedsContext.test( selector ) ?
  7698. jQuery( selector ) :
  7699. selector || [],
  7700. false
  7701. ).length;
  7702. }
  7703. } );
  7704. // Initialize a jQuery object
  7705. // A central reference to the root jQuery(document)
  7706. var rootjQuery,
  7707. // A simple way to check for HTML strings
  7708. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  7709. // Strict HTML recognition (#11290: must start with <)
  7710. // Shortcut simple #id case for speed
  7711. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  7712. init = jQuery.fn.init = function( selector, context, root ) {
  7713. var match, elem;
  7714. // HANDLE: $(""), $(null), $(undefined), $(false)
  7715. if ( !selector ) {
  7716. return this;
  7717. }
  7718. // Method init() accepts an alternate rootjQuery
  7719. // so migrate can support jQuery.sub (gh-2101)
  7720. root = root || rootjQuery;
  7721. // Handle HTML strings
  7722. if ( typeof selector === "string" ) {
  7723. if ( selector[ 0 ] === "<" &&
  7724. selector[ selector.length - 1 ] === ">" &&
  7725. selector.length >= 3 ) {
  7726. // Assume that strings that start and end with <> are HTML and skip the regex check
  7727. match = [ null, selector, null ];
  7728. } else {
  7729. match = rquickExpr.exec( selector );
  7730. }
  7731. // Match html or make sure no context is specified for #id
  7732. if ( match && ( match[ 1 ] || !context ) ) {
  7733. // HANDLE: $(html) -> $(array)
  7734. if ( match[ 1 ] ) {
  7735. context = context instanceof jQuery ? context[ 0 ] : context;
  7736. // Option to run scripts is true for back-compat
  7737. // Intentionally let the error be thrown if parseHTML is not present
  7738. jQuery.merge( this, jQuery.parseHTML(
  7739. match[ 1 ],
  7740. context && context.nodeType ? context.ownerDocument || context : document,
  7741. true
  7742. ) );
  7743. // HANDLE: $(html, props)
  7744. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  7745. for ( match in context ) {
  7746. // Properties of context are called as methods if possible
  7747. if ( isFunction( this[ match ] ) ) {
  7748. this[ match ]( context[ match ] );
  7749. // ...and otherwise set as attributes
  7750. } else {
  7751. this.attr( match, context[ match ] );
  7752. }
  7753. }
  7754. }
  7755. return this;
  7756. // HANDLE: $(#id)
  7757. } else {
  7758. elem = document.getElementById( match[ 2 ] );
  7759. if ( elem ) {
  7760. // Inject the element directly into the jQuery object
  7761. this[ 0 ] = elem;
  7762. this.length = 1;
  7763. }
  7764. return this;
  7765. }
  7766. // HANDLE: $(expr, $(...))
  7767. } else if ( !context || context.jquery ) {
  7768. return ( context || root ).find( selector );
  7769. // HANDLE: $(expr, context)
  7770. // (which is just equivalent to: $(context).find(expr)
  7771. } else {
  7772. return this.constructor( context ).find( selector );
  7773. }
  7774. // HANDLE: $(DOMElement)
  7775. } else if ( selector.nodeType ) {
  7776. this[ 0 ] = selector;
  7777. this.length = 1;
  7778. return this;
  7779. // HANDLE: $(function)
  7780. // Shortcut for document ready
  7781. } else if ( isFunction( selector ) ) {
  7782. return root.ready !== undefined ?
  7783. root.ready( selector ) :
  7784. // Execute immediately if ready is not present
  7785. selector( jQuery );
  7786. }
  7787. return jQuery.makeArray( selector, this );
  7788. };
  7789. // Give the init function the jQuery prototype for later instantiation
  7790. init.prototype = jQuery.fn;
  7791. // Initialize central reference
  7792. rootjQuery = jQuery( document );
  7793. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  7794. // Methods guaranteed to produce a unique set when starting from a unique set
  7795. guaranteedUnique = {
  7796. children: true,
  7797. contents: true,
  7798. next: true,
  7799. prev: true
  7800. };
  7801. jQuery.fn.extend( {
  7802. has: function( target ) {
  7803. var targets = jQuery( target, this ),
  7804. l = targets.length;
  7805. return this.filter( function() {
  7806. var i = 0;
  7807. for ( ; i < l; i++ ) {
  7808. if ( jQuery.contains( this, targets[ i ] ) ) {
  7809. return true;
  7810. }
  7811. }
  7812. } );
  7813. },
  7814. closest: function( selectors, context ) {
  7815. var cur,
  7816. i = 0,
  7817. l = this.length,
  7818. matched = [],
  7819. targets = typeof selectors !== "string" && jQuery( selectors );
  7820. // Positional selectors never match, since there's no _selection_ context
  7821. if ( !rneedsContext.test( selectors ) ) {
  7822. for ( ; i < l; i++ ) {
  7823. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  7824. // Always skip document fragments
  7825. if ( cur.nodeType < 11 && ( targets ?
  7826. targets.index( cur ) > -1 :
  7827. // Don't pass non-elements to Sizzle
  7828. cur.nodeType === 1 &&
  7829. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  7830. matched.push( cur );
  7831. break;
  7832. }
  7833. }
  7834. }
  7835. }
  7836. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  7837. },
  7838. // Determine the position of an element within the set
  7839. index: function( elem ) {
  7840. // No argument, return index in parent
  7841. if ( !elem ) {
  7842. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  7843. }
  7844. // Index in selector
  7845. if ( typeof elem === "string" ) {
  7846. return indexOf.call( jQuery( elem ), this[ 0 ] );
  7847. }
  7848. // Locate the position of the desired element
  7849. return indexOf.call( this,
  7850. // If it receives a jQuery object, the first element is used
  7851. elem.jquery ? elem[ 0 ] : elem
  7852. );
  7853. },
  7854. add: function( selector, context ) {
  7855. return this.pushStack(
  7856. jQuery.uniqueSort(
  7857. jQuery.merge( this.get(), jQuery( selector, context ) )
  7858. )
  7859. );
  7860. },
  7861. addBack: function( selector ) {
  7862. return this.add( selector == null ?
  7863. this.prevObject : this.prevObject.filter( selector )
  7864. );
  7865. }
  7866. } );
  7867. function sibling( cur, dir ) {
  7868. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  7869. return cur;
  7870. }
  7871. jQuery.each( {
  7872. parent: function( elem ) {
  7873. var parent = elem.parentNode;
  7874. return parent && parent.nodeType !== 11 ? parent : null;
  7875. },
  7876. parents: function( elem ) {
  7877. return dir( elem, "parentNode" );
  7878. },
  7879. parentsUntil: function( elem, _i, until ) {
  7880. return dir( elem, "parentNode", until );
  7881. },
  7882. next: function( elem ) {
  7883. return sibling( elem, "nextSibling" );
  7884. },
  7885. prev: function( elem ) {
  7886. return sibling( elem, "previousSibling" );
  7887. },
  7888. nextAll: function( elem ) {
  7889. return dir( elem, "nextSibling" );
  7890. },
  7891. prevAll: function( elem ) {
  7892. return dir( elem, "previousSibling" );
  7893. },
  7894. nextUntil: function( elem, _i, until ) {
  7895. return dir( elem, "nextSibling", until );
  7896. },
  7897. prevUntil: function( elem, _i, until ) {
  7898. return dir( elem, "previousSibling", until );
  7899. },
  7900. siblings: function( elem ) {
  7901. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  7902. },
  7903. children: function( elem ) {
  7904. return siblings( elem.firstChild );
  7905. },
  7906. contents: function( elem ) {
  7907. if ( elem.contentDocument != null &&
  7908. // Support: IE 11+
  7909. // <object> elements with no `data` attribute has an object
  7910. // `contentDocument` with a `null` prototype.
  7911. getProto( elem.contentDocument ) ) {
  7912. return elem.contentDocument;
  7913. }
  7914. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  7915. // Treat the template element as a regular one in browsers that
  7916. // don't support it.
  7917. if ( nodeName( elem, "template" ) ) {
  7918. elem = elem.content || elem;
  7919. }
  7920. return jQuery.merge( [], elem.childNodes );
  7921. }
  7922. }, function( name, fn ) {
  7923. jQuery.fn[ name ] = function( until, selector ) {
  7924. var matched = jQuery.map( this, fn, until );
  7925. if ( name.slice( -5 ) !== "Until" ) {
  7926. selector = until;
  7927. }
  7928. if ( selector && typeof selector === "string" ) {
  7929. matched = jQuery.filter( selector, matched );
  7930. }
  7931. if ( this.length > 1 ) {
  7932. // Remove duplicates
  7933. if ( !guaranteedUnique[ name ] ) {
  7934. jQuery.uniqueSort( matched );
  7935. }
  7936. // Reverse order for parents* and prev-derivatives
  7937. if ( rparentsprev.test( name ) ) {
  7938. matched.reverse();
  7939. }
  7940. }
  7941. return this.pushStack( matched );
  7942. };
  7943. } );
  7944. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  7945. // Convert String-formatted options into Object-formatted ones
  7946. function createOptions( options ) {
  7947. var object = {};
  7948. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  7949. object[ flag ] = true;
  7950. } );
  7951. return object;
  7952. }
  7953. /*
  7954. * Create a callback list using the following parameters:
  7955. *
  7956. * options: an optional list of space-separated options that will change how
  7957. * the callback list behaves or a more traditional option object
  7958. *
  7959. * By default a callback list will act like an event callback list and can be
  7960. * "fired" multiple times.
  7961. *
  7962. * Possible options:
  7963. *
  7964. * once: will ensure the callback list can only be fired once (like a Deferred)
  7965. *
  7966. * memory: will keep track of previous values and will call any callback added
  7967. * after the list has been fired right away with the latest "memorized"
  7968. * values (like a Deferred)
  7969. *
  7970. * unique: will ensure a callback can only be added once (no duplicate in the list)
  7971. *
  7972. * stopOnFalse: interrupt callings when a callback returns false
  7973. *
  7974. */
  7975. jQuery.Callbacks = function( options ) {
  7976. // Convert options from String-formatted to Object-formatted if needed
  7977. // (we check in cache first)
  7978. options = typeof options === "string" ?
  7979. createOptions( options ) :
  7980. jQuery.extend( {}, options );
  7981. var // Flag to know if list is currently firing
  7982. firing,
  7983. // Last fire value for non-forgettable lists
  7984. memory,
  7985. // Flag to know if list was already fired
  7986. fired,
  7987. // Flag to prevent firing
  7988. locked,
  7989. // Actual callback list
  7990. list = [],
  7991. // Queue of execution data for repeatable lists
  7992. queue = [],
  7993. // Index of currently firing callback (modified by add/remove as needed)
  7994. firingIndex = -1,
  7995. // Fire callbacks
  7996. fire = function() {
  7997. // Enforce single-firing
  7998. locked = locked || options.once;
  7999. // Execute callbacks for all pending executions,
  8000. // respecting firingIndex overrides and runtime changes
  8001. fired = firing = true;
  8002. for ( ; queue.length; firingIndex = -1 ) {
  8003. memory = queue.shift();
  8004. while ( ++firingIndex < list.length ) {
  8005. // Run callback and check for early termination
  8006. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  8007. options.stopOnFalse ) {
  8008. // Jump to end and forget the data so .add doesn't re-fire
  8009. firingIndex = list.length;
  8010. memory = false;
  8011. }
  8012. }
  8013. }
  8014. // Forget the data if we're done with it
  8015. if ( !options.memory ) {
  8016. memory = false;
  8017. }
  8018. firing = false;
  8019. // Clean up if we're done firing for good
  8020. if ( locked ) {
  8021. // Keep an empty list if we have data for future add calls
  8022. if ( memory ) {
  8023. list = [];
  8024. // Otherwise, this object is spent
  8025. } else {
  8026. list = "";
  8027. }
  8028. }
  8029. },
  8030. // Actual Callbacks object
  8031. self = {
  8032. // Add a callback or a collection of callbacks to the list
  8033. add: function() {
  8034. if ( list ) {
  8035. // If we have memory from a past run, we should fire after adding
  8036. if ( memory && !firing ) {
  8037. firingIndex = list.length - 1;
  8038. queue.push( memory );
  8039. }
  8040. ( function add( args ) {
  8041. jQuery.each( args, function( _, arg ) {
  8042. if ( isFunction( arg ) ) {
  8043. if ( !options.unique || !self.has( arg ) ) {
  8044. list.push( arg );
  8045. }
  8046. } else if ( arg && arg.length && toType( arg ) !== "string" ) {
  8047. // Inspect recursively
  8048. add( arg );
  8049. }
  8050. } );
  8051. } )( arguments );
  8052. if ( memory && !firing ) {
  8053. fire();
  8054. }
  8055. }
  8056. return this;
  8057. },
  8058. // Remove a callback from the list
  8059. remove: function() {
  8060. jQuery.each( arguments, function( _, arg ) {
  8061. var index;
  8062. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  8063. list.splice( index, 1 );
  8064. // Handle firing indexes
  8065. if ( index <= firingIndex ) {
  8066. firingIndex--;
  8067. }
  8068. }
  8069. } );
  8070. return this;
  8071. },
  8072. // Check if a given callback is in the list.
  8073. // If no argument is given, return whether or not list has callbacks attached.
  8074. has: function( fn ) {
  8075. return fn ?
  8076. jQuery.inArray( fn, list ) > -1 :
  8077. list.length > 0;
  8078. },
  8079. // Remove all callbacks from the list
  8080. empty: function() {
  8081. if ( list ) {
  8082. list = [];
  8083. }
  8084. return this;
  8085. },
  8086. // Disable .fire and .add
  8087. // Abort any current/pending executions
  8088. // Clear all callbacks and values
  8089. disable: function() {
  8090. locked = queue = [];
  8091. list = memory = "";
  8092. return this;
  8093. },
  8094. disabled: function() {
  8095. return !list;
  8096. },
  8097. // Disable .fire
  8098. // Also disable .add unless we have memory (since it would have no effect)
  8099. // Abort any pending executions
  8100. lock: function() {
  8101. locked = queue = [];
  8102. if ( !memory && !firing ) {
  8103. list = memory = "";
  8104. }
  8105. return this;
  8106. },
  8107. locked: function() {
  8108. return !!locked;
  8109. },
  8110. // Call all callbacks with the given context and arguments
  8111. fireWith: function( context, args ) {
  8112. if ( !locked ) {
  8113. args = args || [];
  8114. args = [ context, args.slice ? args.slice() : args ];
  8115. queue.push( args );
  8116. if ( !firing ) {
  8117. fire();
  8118. }
  8119. }
  8120. return this;
  8121. },
  8122. // Call all the callbacks with the given arguments
  8123. fire: function() {
  8124. self.fireWith( this, arguments );
  8125. return this;
  8126. },
  8127. // To know if the callbacks have already been called at least once
  8128. fired: function() {
  8129. return !!fired;
  8130. }
  8131. };
  8132. return self;
  8133. };
  8134. function Identity( v ) {
  8135. return v;
  8136. }
  8137. function Thrower( ex ) {
  8138. throw ex;
  8139. }
  8140. function adoptValue( value, resolve, reject, noValue ) {
  8141. var method;
  8142. try {
  8143. // Check for promise aspect first to privilege synchronous behavior
  8144. if ( value && isFunction( ( method = value.promise ) ) ) {
  8145. method.call( value ).done( resolve ).fail( reject );
  8146. // Other thenables
  8147. } else if ( value && isFunction( ( method = value.then ) ) ) {
  8148. method.call( value, resolve, reject );
  8149. // Other non-thenables
  8150. } else {
  8151. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  8152. // * false: [ value ].slice( 0 ) => resolve( value )
  8153. // * true: [ value ].slice( 1 ) => resolve()
  8154. resolve.apply( undefined, [ value ].slice( noValue ) );
  8155. }
  8156. // For Promises/A+, convert exceptions into rejections
  8157. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  8158. // Deferred#then to conditionally suppress rejection.
  8159. } catch ( value ) {
  8160. // Support: Android 4.0 only
  8161. // Strict mode functions invoked without .call/.apply get global-object context
  8162. reject.apply( undefined, [ value ] );
  8163. }
  8164. }
  8165. jQuery.extend( {
  8166. Deferred: function( func ) {
  8167. var tuples = [
  8168. // action, add listener, callbacks,
  8169. // ... .then handlers, argument index, [final state]
  8170. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  8171. jQuery.Callbacks( "memory" ), 2 ],
  8172. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  8173. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  8174. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  8175. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  8176. ],
  8177. state = "pending",
  8178. promise = {
  8179. state: function() {
  8180. return state;
  8181. },
  8182. always: function() {
  8183. deferred.done( arguments ).fail( arguments );
  8184. return this;
  8185. },
  8186. "catch": function( fn ) {
  8187. return promise.then( null, fn );
  8188. },
  8189. // Keep pipe for back-compat
  8190. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  8191. var fns = arguments;
  8192. return jQuery.Deferred( function( newDefer ) {
  8193. jQuery.each( tuples, function( _i, tuple ) {
  8194. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  8195. var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  8196. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  8197. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  8198. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  8199. deferred[ tuple[ 1 ] ]( function() {
  8200. var returned = fn && fn.apply( this, arguments );
  8201. if ( returned && isFunction( returned.promise ) ) {
  8202. returned.promise()
  8203. .progress( newDefer.notify )
  8204. .done( newDefer.resolve )
  8205. .fail( newDefer.reject );
  8206. } else {
  8207. newDefer[ tuple[ 0 ] + "With" ](
  8208. this,
  8209. fn ? [ returned ] : arguments
  8210. );
  8211. }
  8212. } );
  8213. } );
  8214. fns = null;
  8215. } ).promise();
  8216. },
  8217. then: function( onFulfilled, onRejected, onProgress ) {
  8218. var maxDepth = 0;
  8219. function resolve( depth, deferred, handler, special ) {
  8220. return function() {
  8221. var that = this,
  8222. args = arguments,
  8223. mightThrow = function() {
  8224. var returned, then;
  8225. // Support: Promises/A+ section 2.3.3.3.3
  8226. // https://promisesaplus.com/#point-59
  8227. // Ignore double-resolution attempts
  8228. if ( depth < maxDepth ) {
  8229. return;
  8230. }
  8231. returned = handler.apply( that, args );
  8232. // Support: Promises/A+ section 2.3.1
  8233. // https://promisesaplus.com/#point-48
  8234. if ( returned === deferred.promise() ) {
  8235. throw new TypeError( "Thenable self-resolution" );
  8236. }
  8237. // Support: Promises/A+ sections 2.3.3.1, 3.5
  8238. // https://promisesaplus.com/#point-54
  8239. // https://promisesaplus.com/#point-75
  8240. // Retrieve `then` only once
  8241. then = returned &&
  8242. // Support: Promises/A+ section 2.3.4
  8243. // https://promisesaplus.com/#point-64
  8244. // Only check objects and functions for thenability
  8245. ( typeof returned === "object" ||
  8246. typeof returned === "function" ) &&
  8247. returned.then;
  8248. // Handle a returned thenable
  8249. if ( isFunction( then ) ) {
  8250. // Special processors (notify) just wait for resolution
  8251. if ( special ) {
  8252. then.call(
  8253. returned,
  8254. resolve( maxDepth, deferred, Identity, special ),
  8255. resolve( maxDepth, deferred, Thrower, special )
  8256. );
  8257. // Normal processors (resolve) also hook into progress
  8258. } else {
  8259. // ...and disregard older resolution values
  8260. maxDepth++;
  8261. then.call(
  8262. returned,
  8263. resolve( maxDepth, deferred, Identity, special ),
  8264. resolve( maxDepth, deferred, Thrower, special ),
  8265. resolve( maxDepth, deferred, Identity,
  8266. deferred.notifyWith )
  8267. );
  8268. }
  8269. // Handle all other returned values
  8270. } else {
  8271. // Only substitute handlers pass on context
  8272. // and multiple values (non-spec behavior)
  8273. if ( handler !== Identity ) {
  8274. that = undefined;
  8275. args = [ returned ];
  8276. }
  8277. // Process the value(s)
  8278. // Default process is resolve
  8279. ( special || deferred.resolveWith )( that, args );
  8280. }
  8281. },
  8282. // Only normal processors (resolve) catch and reject exceptions
  8283. process = special ?
  8284. mightThrow :
  8285. function() {
  8286. try {
  8287. mightThrow();
  8288. } catch ( e ) {
  8289. if ( jQuery.Deferred.exceptionHook ) {
  8290. jQuery.Deferred.exceptionHook( e,
  8291. process.stackTrace );
  8292. }
  8293. // Support: Promises/A+ section 2.3.3.3.4.1
  8294. // https://promisesaplus.com/#point-61
  8295. // Ignore post-resolution exceptions
  8296. if ( depth + 1 >= maxDepth ) {
  8297. // Only substitute handlers pass on context
  8298. // and multiple values (non-spec behavior)
  8299. if ( handler !== Thrower ) {
  8300. that = undefined;
  8301. args = [ e ];
  8302. }
  8303. deferred.rejectWith( that, args );
  8304. }
  8305. }
  8306. };
  8307. // Support: Promises/A+ section 2.3.3.3.1
  8308. // https://promisesaplus.com/#point-57
  8309. // Re-resolve promises immediately to dodge false rejection from
  8310. // subsequent errors
  8311. if ( depth ) {
  8312. process();
  8313. } else {
  8314. // Call an optional hook to record the stack, in case of exception
  8315. // since it's otherwise lost when execution goes async
  8316. if ( jQuery.Deferred.getStackHook ) {
  8317. process.stackTrace = jQuery.Deferred.getStackHook();
  8318. }
  8319. window.setTimeout( process );
  8320. }
  8321. };
  8322. }
  8323. return jQuery.Deferred( function( newDefer ) {
  8324. // progress_handlers.add( ... )
  8325. tuples[ 0 ][ 3 ].add(
  8326. resolve(
  8327. 0,
  8328. newDefer,
  8329. isFunction( onProgress ) ?
  8330. onProgress :
  8331. Identity,
  8332. newDefer.notifyWith
  8333. )
  8334. );
  8335. // fulfilled_handlers.add( ... )
  8336. tuples[ 1 ][ 3 ].add(
  8337. resolve(
  8338. 0,
  8339. newDefer,
  8340. isFunction( onFulfilled ) ?
  8341. onFulfilled :
  8342. Identity
  8343. )
  8344. );
  8345. // rejected_handlers.add( ... )
  8346. tuples[ 2 ][ 3 ].add(
  8347. resolve(
  8348. 0,
  8349. newDefer,
  8350. isFunction( onRejected ) ?
  8351. onRejected :
  8352. Thrower
  8353. )
  8354. );
  8355. } ).promise();
  8356. },
  8357. // Get a promise for this deferred
  8358. // If obj is provided, the promise aspect is added to the object
  8359. promise: function( obj ) {
  8360. return obj != null ? jQuery.extend( obj, promise ) : promise;
  8361. }
  8362. },
  8363. deferred = {};
  8364. // Add list-specific methods
  8365. jQuery.each( tuples, function( i, tuple ) {
  8366. var list = tuple[ 2 ],
  8367. stateString = tuple[ 5 ];
  8368. // promise.progress = list.add
  8369. // promise.done = list.add
  8370. // promise.fail = list.add
  8371. promise[ tuple[ 1 ] ] = list.add;
  8372. // Handle state
  8373. if ( stateString ) {
  8374. list.add(
  8375. function() {
  8376. // state = "resolved" (i.e., fulfilled)
  8377. // state = "rejected"
  8378. state = stateString;
  8379. },
  8380. // rejected_callbacks.disable
  8381. // fulfilled_callbacks.disable
  8382. tuples[ 3 - i ][ 2 ].disable,
  8383. // rejected_handlers.disable
  8384. // fulfilled_handlers.disable
  8385. tuples[ 3 - i ][ 3 ].disable,
  8386. // progress_callbacks.lock
  8387. tuples[ 0 ][ 2 ].lock,
  8388. // progress_handlers.lock
  8389. tuples[ 0 ][ 3 ].lock
  8390. );
  8391. }
  8392. // progress_handlers.fire
  8393. // fulfilled_handlers.fire
  8394. // rejected_handlers.fire
  8395. list.add( tuple[ 3 ].fire );
  8396. // deferred.notify = function() { deferred.notifyWith(...) }
  8397. // deferred.resolve = function() { deferred.resolveWith(...) }
  8398. // deferred.reject = function() { deferred.rejectWith(...) }
  8399. deferred[ tuple[ 0 ] ] = function() {
  8400. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  8401. return this;
  8402. };
  8403. // deferred.notifyWith = list.fireWith
  8404. // deferred.resolveWith = list.fireWith
  8405. // deferred.rejectWith = list.fireWith
  8406. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  8407. } );
  8408. // Make the deferred a promise
  8409. promise.promise( deferred );
  8410. // Call given func if any
  8411. if ( func ) {
  8412. func.call( deferred, deferred );
  8413. }
  8414. // All done!
  8415. return deferred;
  8416. },
  8417. // Deferred helper
  8418. when: function( singleValue ) {
  8419. var
  8420. // count of uncompleted subordinates
  8421. remaining = arguments.length,
  8422. // count of unprocessed arguments
  8423. i = remaining,
  8424. // subordinate fulfillment data
  8425. resolveContexts = Array( i ),
  8426. resolveValues = slice.call( arguments ),
  8427. // the master Deferred
  8428. master = jQuery.Deferred(),
  8429. // subordinate callback factory
  8430. updateFunc = function( i ) {
  8431. return function( value ) {
  8432. resolveContexts[ i ] = this;
  8433. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  8434. if ( !( --remaining ) ) {
  8435. master.resolveWith( resolveContexts, resolveValues );
  8436. }
  8437. };
  8438. };
  8439. // Single- and empty arguments are adopted like Promise.resolve
  8440. if ( remaining <= 1 ) {
  8441. adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
  8442. !remaining );
  8443. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  8444. if ( master.state() === "pending" ||
  8445. isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  8446. return master.then();
  8447. }
  8448. }
  8449. // Multiple arguments are aggregated like Promise.all array elements
  8450. while ( i-- ) {
  8451. adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
  8452. }
  8453. return master.promise();
  8454. }
  8455. } );
  8456. // These usually indicate a programmer mistake during development,
  8457. // warn about them ASAP rather than swallowing them by default.
  8458. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  8459. jQuery.Deferred.exceptionHook = function( error, stack ) {
  8460. // Support: IE 8 - 9 only
  8461. // Console exists when dev tools are open, which can happen at any time
  8462. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  8463. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  8464. }
  8465. };
  8466. jQuery.readyException = function( error ) {
  8467. window.setTimeout( function() {
  8468. throw error;
  8469. } );
  8470. };
  8471. // The deferred used on DOM ready
  8472. var readyList = jQuery.Deferred();
  8473. jQuery.fn.ready = function( fn ) {
  8474. readyList
  8475. .then( fn )
  8476. // Wrap jQuery.readyException in a function so that the lookup
  8477. // happens at the time of error handling instead of callback
  8478. // registration.
  8479. .catch( function( error ) {
  8480. jQuery.readyException( error );
  8481. } );
  8482. return this;
  8483. };
  8484. jQuery.extend( {
  8485. // Is the DOM ready to be used? Set to true once it occurs.
  8486. isReady: false,
  8487. // A counter to track how many items to wait for before
  8488. // the ready event fires. See #6781
  8489. readyWait: 1,
  8490. // Handle when the DOM is ready
  8491. ready: function( wait ) {
  8492. // Abort if there are pending holds or we're already ready
  8493. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  8494. return;
  8495. }
  8496. // Remember that the DOM is ready
  8497. jQuery.isReady = true;
  8498. // If a normal DOM Ready event fired, decrement, and wait if need be
  8499. if ( wait !== true && --jQuery.readyWait > 0 ) {
  8500. return;
  8501. }
  8502. // If there are functions bound, to execute
  8503. readyList.resolveWith( document, [ jQuery ] );
  8504. }
  8505. } );
  8506. jQuery.ready.then = readyList.then;
  8507. // The ready event handler and self cleanup method
  8508. function completed() {
  8509. document.removeEventListener( "DOMContentLoaded", completed );
  8510. window.removeEventListener( "load", completed );
  8511. jQuery.ready();
  8512. }
  8513. // Catch cases where $(document).ready() is called
  8514. // after the browser event has already occurred.
  8515. // Support: IE <=9 - 10 only
  8516. // Older IE sometimes signals "interactive" too soon
  8517. if ( document.readyState === "complete" ||
  8518. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  8519. // Handle it asynchronously to allow scripts the opportunity to delay ready
  8520. window.setTimeout( jQuery.ready );
  8521. } else {
  8522. // Use the handy event callback
  8523. document.addEventListener( "DOMContentLoaded", completed );
  8524. // A fallback to window.onload, that will always work
  8525. window.addEventListener( "load", completed );
  8526. }
  8527. // Multifunctional method to get and set values of a collection
  8528. // The value/s can optionally be executed if it's a function
  8529. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  8530. var i = 0,
  8531. len = elems.length,
  8532. bulk = key == null;
  8533. // Sets many values
  8534. if ( toType( key ) === "object" ) {
  8535. chainable = true;
  8536. for ( i in key ) {
  8537. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  8538. }
  8539. // Sets one value
  8540. } else if ( value !== undefined ) {
  8541. chainable = true;
  8542. if ( !isFunction( value ) ) {
  8543. raw = true;
  8544. }
  8545. if ( bulk ) {
  8546. // Bulk operations run against the entire set
  8547. if ( raw ) {
  8548. fn.call( elems, value );
  8549. fn = null;
  8550. // ...except when executing function values
  8551. } else {
  8552. bulk = fn;
  8553. fn = function( elem, _key, value ) {
  8554. return bulk.call( jQuery( elem ), value );
  8555. };
  8556. }
  8557. }
  8558. if ( fn ) {
  8559. for ( ; i < len; i++ ) {
  8560. fn(
  8561. elems[ i ], key, raw ?
  8562. value :
  8563. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  8564. );
  8565. }
  8566. }
  8567. }
  8568. if ( chainable ) {
  8569. return elems;
  8570. }
  8571. // Gets
  8572. if ( bulk ) {
  8573. return fn.call( elems );
  8574. }
  8575. return len ? fn( elems[ 0 ], key ) : emptyGet;
  8576. };
  8577. // Matches dashed string for camelizing
  8578. var rmsPrefix = /^-ms-/,
  8579. rdashAlpha = /-([a-z])/g;
  8580. // Used by camelCase as callback to replace()
  8581. function fcamelCase( _all, letter ) {
  8582. return letter.toUpperCase();
  8583. }
  8584. // Convert dashed to camelCase; used by the css and data modules
  8585. // Support: IE <=9 - 11, Edge 12 - 15
  8586. // Microsoft forgot to hump their vendor prefix (#9572)
  8587. function camelCase( string ) {
  8588. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  8589. }
  8590. var acceptData = function( owner ) {
  8591. // Accepts only:
  8592. // - Node
  8593. // - Node.ELEMENT_NODE
  8594. // - Node.DOCUMENT_NODE
  8595. // - Object
  8596. // - Any
  8597. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  8598. };
  8599. function Data() {
  8600. this.expando = jQuery.expando + Data.uid++;
  8601. }
  8602. Data.uid = 1;
  8603. Data.prototype = {
  8604. cache: function( owner ) {
  8605. // Check if the owner object already has a cache
  8606. var value = owner[ this.expando ];
  8607. // If not, create one
  8608. if ( !value ) {
  8609. value = {};
  8610. // We can accept data for non-element nodes in modern browsers,
  8611. // but we should not, see #8335.
  8612. // Always return an empty object.
  8613. if ( acceptData( owner ) ) {
  8614. // If it is a node unlikely to be stringify-ed or looped over
  8615. // use plain assignment
  8616. if ( owner.nodeType ) {
  8617. owner[ this.expando ] = value;
  8618. // Otherwise secure it in a non-enumerable property
  8619. // configurable must be true to allow the property to be
  8620. // deleted when data is removed
  8621. } else {
  8622. Object.defineProperty( owner, this.expando, {
  8623. value: value,
  8624. configurable: true
  8625. } );
  8626. }
  8627. }
  8628. }
  8629. return value;
  8630. },
  8631. set: function( owner, data, value ) {
  8632. var prop,
  8633. cache = this.cache( owner );
  8634. // Handle: [ owner, key, value ] args
  8635. // Always use camelCase key (gh-2257)
  8636. if ( typeof data === "string" ) {
  8637. cache[ camelCase( data ) ] = value;
  8638. // Handle: [ owner, { properties } ] args
  8639. } else {
  8640. // Copy the properties one-by-one to the cache object
  8641. for ( prop in data ) {
  8642. cache[ camelCase( prop ) ] = data[ prop ];
  8643. }
  8644. }
  8645. return cache;
  8646. },
  8647. get: function( owner, key ) {
  8648. return key === undefined ?
  8649. this.cache( owner ) :
  8650. // Always use camelCase key (gh-2257)
  8651. owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
  8652. },
  8653. access: function( owner, key, value ) {
  8654. // In cases where either:
  8655. //
  8656. // 1. No key was specified
  8657. // 2. A string key was specified, but no value provided
  8658. //
  8659. // Take the "read" path and allow the get method to determine
  8660. // which value to return, respectively either:
  8661. //
  8662. // 1. The entire cache object
  8663. // 2. The data stored at the key
  8664. //
  8665. if ( key === undefined ||
  8666. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  8667. return this.get( owner, key );
  8668. }
  8669. // When the key is not a string, or both a key and value
  8670. // are specified, set or extend (existing objects) with either:
  8671. //
  8672. // 1. An object of properties
  8673. // 2. A key and value
  8674. //
  8675. this.set( owner, key, value );
  8676. // Since the "set" path can have two possible entry points
  8677. // return the expected data based on which path was taken[*]
  8678. return value !== undefined ? value : key;
  8679. },
  8680. remove: function( owner, key ) {
  8681. var i,
  8682. cache = owner[ this.expando ];
  8683. if ( cache === undefined ) {
  8684. return;
  8685. }
  8686. if ( key !== undefined ) {
  8687. // Support array or space separated string of keys
  8688. if ( Array.isArray( key ) ) {
  8689. // If key is an array of keys...
  8690. // We always set camelCase keys, so remove that.
  8691. key = key.map( camelCase );
  8692. } else {
  8693. key = camelCase( key );
  8694. // If a key with the spaces exists, use it.
  8695. // Otherwise, create an array by matching non-whitespace
  8696. key = key in cache ?
  8697. [ key ] :
  8698. ( key.match( rnothtmlwhite ) || [] );
  8699. }
  8700. i = key.length;
  8701. while ( i-- ) {
  8702. delete cache[ key[ i ] ];
  8703. }
  8704. }
  8705. // Remove the expando if there's no more data
  8706. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  8707. // Support: Chrome <=35 - 45
  8708. // Webkit & Blink performance suffers when deleting properties
  8709. // from DOM nodes, so set to undefined instead
  8710. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  8711. if ( owner.nodeType ) {
  8712. owner[ this.expando ] = undefined;
  8713. } else {
  8714. delete owner[ this.expando ];
  8715. }
  8716. }
  8717. },
  8718. hasData: function( owner ) {
  8719. var cache = owner[ this.expando ];
  8720. return cache !== undefined && !jQuery.isEmptyObject( cache );
  8721. }
  8722. };
  8723. var dataPriv = new Data();
  8724. var dataUser = new Data();
  8725. // Implementation Summary
  8726. //
  8727. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  8728. // 2. Improve the module's maintainability by reducing the storage
  8729. // paths to a single mechanism.
  8730. // 3. Use the same single mechanism to support "private" and "user" data.
  8731. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  8732. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  8733. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  8734. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  8735. rmultiDash = /[A-Z]/g;
  8736. function getData( data ) {
  8737. if ( data === "true" ) {
  8738. return true;
  8739. }
  8740. if ( data === "false" ) {
  8741. return false;
  8742. }
  8743. if ( data === "null" ) {
  8744. return null;
  8745. }
  8746. // Only convert to a number if it doesn't change the string
  8747. if ( data === +data + "" ) {
  8748. return +data;
  8749. }
  8750. if ( rbrace.test( data ) ) {
  8751. return JSON.parse( data );
  8752. }
  8753. return data;
  8754. }
  8755. function dataAttr( elem, key, data ) {
  8756. var name;
  8757. // If nothing was found internally, try to fetch any
  8758. // data from the HTML5 data-* attribute
  8759. if ( data === undefined && elem.nodeType === 1 ) {
  8760. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  8761. data = elem.getAttribute( name );
  8762. if ( typeof data === "string" ) {
  8763. try {
  8764. data = getData( data );
  8765. } catch ( e ) {}
  8766. // Make sure we set the data so it isn't changed later
  8767. dataUser.set( elem, key, data );
  8768. } else {
  8769. data = undefined;
  8770. }
  8771. }
  8772. return data;
  8773. }
  8774. jQuery.extend( {
  8775. hasData: function( elem ) {
  8776. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  8777. },
  8778. data: function( elem, name, data ) {
  8779. return dataUser.access( elem, name, data );
  8780. },
  8781. removeData: function( elem, name ) {
  8782. dataUser.remove( elem, name );
  8783. },
  8784. // TODO: Now that all calls to _data and _removeData have been replaced
  8785. // with direct calls to dataPriv methods, these can be deprecated.
  8786. _data: function( elem, name, data ) {
  8787. return dataPriv.access( elem, name, data );
  8788. },
  8789. _removeData: function( elem, name ) {
  8790. dataPriv.remove( elem, name );
  8791. }
  8792. } );
  8793. jQuery.fn.extend( {
  8794. data: function( key, value ) {
  8795. var i, name, data,
  8796. elem = this[ 0 ],
  8797. attrs = elem && elem.attributes;
  8798. // Gets all values
  8799. if ( key === undefined ) {
  8800. if ( this.length ) {
  8801. data = dataUser.get( elem );
  8802. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  8803. i = attrs.length;
  8804. while ( i-- ) {
  8805. // Support: IE 11 only
  8806. // The attrs elements can be null (#14894)
  8807. if ( attrs[ i ] ) {
  8808. name = attrs[ i ].name;
  8809. if ( name.indexOf( "data-" ) === 0 ) {
  8810. name = camelCase( name.slice( 5 ) );
  8811. dataAttr( elem, name, data[ name ] );
  8812. }
  8813. }
  8814. }
  8815. dataPriv.set( elem, "hasDataAttrs", true );
  8816. }
  8817. }
  8818. return data;
  8819. }
  8820. // Sets multiple values
  8821. if ( typeof key === "object" ) {
  8822. return this.each( function() {
  8823. dataUser.set( this, key );
  8824. } );
  8825. }
  8826. return access( this, function( value ) {
  8827. var data;
  8828. // The calling jQuery object (element matches) is not empty
  8829. // (and therefore has an element appears at this[ 0 ]) and the
  8830. // `value` parameter was not undefined. An empty jQuery object
  8831. // will result in `undefined` for elem = this[ 0 ] which will
  8832. // throw an exception if an attempt to read a data cache is made.
  8833. if ( elem && value === undefined ) {
  8834. // Attempt to get data from the cache
  8835. // The key will always be camelCased in Data
  8836. data = dataUser.get( elem, key );
  8837. if ( data !== undefined ) {
  8838. return data;
  8839. }
  8840. // Attempt to "discover" the data in
  8841. // HTML5 custom data-* attrs
  8842. data = dataAttr( elem, key );
  8843. if ( data !== undefined ) {
  8844. return data;
  8845. }
  8846. // We tried really hard, but the data doesn't exist.
  8847. return;
  8848. }
  8849. // Set the data...
  8850. this.each( function() {
  8851. // We always store the camelCased key
  8852. dataUser.set( this, key, value );
  8853. } );
  8854. }, null, value, arguments.length > 1, null, true );
  8855. },
  8856. removeData: function( key ) {
  8857. return this.each( function() {
  8858. dataUser.remove( this, key );
  8859. } );
  8860. }
  8861. } );
  8862. jQuery.extend( {
  8863. queue: function( elem, type, data ) {
  8864. var queue;
  8865. if ( elem ) {
  8866. type = ( type || "fx" ) + "queue";
  8867. queue = dataPriv.get( elem, type );
  8868. // Speed up dequeue by getting out quickly if this is just a lookup
  8869. if ( data ) {
  8870. if ( !queue || Array.isArray( data ) ) {
  8871. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  8872. } else {
  8873. queue.push( data );
  8874. }
  8875. }
  8876. return queue || [];
  8877. }
  8878. },
  8879. dequeue: function( elem, type ) {
  8880. type = type || "fx";
  8881. var queue = jQuery.queue( elem, type ),
  8882. startLength = queue.length,
  8883. fn = queue.shift(),
  8884. hooks = jQuery._queueHooks( elem, type ),
  8885. next = function() {
  8886. jQuery.dequeue( elem, type );
  8887. };
  8888. // If the fx queue is dequeued, always remove the progress sentinel
  8889. if ( fn === "inprogress" ) {
  8890. fn = queue.shift();
  8891. startLength--;
  8892. }
  8893. if ( fn ) {
  8894. // Add a progress sentinel to prevent the fx queue from being
  8895. // automatically dequeued
  8896. if ( type === "fx" ) {
  8897. queue.unshift( "inprogress" );
  8898. }
  8899. // Clear up the last queue stop function
  8900. delete hooks.stop;
  8901. fn.call( elem, next, hooks );
  8902. }
  8903. if ( !startLength && hooks ) {
  8904. hooks.empty.fire();
  8905. }
  8906. },
  8907. // Not public - generate a queueHooks object, or return the current one
  8908. _queueHooks: function( elem, type ) {
  8909. var key = type + "queueHooks";
  8910. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  8911. empty: jQuery.Callbacks( "once memory" ).add( function() {
  8912. dataPriv.remove( elem, [ type + "queue", key ] );
  8913. } )
  8914. } );
  8915. }
  8916. } );
  8917. jQuery.fn.extend( {
  8918. queue: function( type, data ) {
  8919. var setter = 2;
  8920. if ( typeof type !== "string" ) {
  8921. data = type;
  8922. type = "fx";
  8923. setter--;
  8924. }
  8925. if ( arguments.length < setter ) {
  8926. return jQuery.queue( this[ 0 ], type );
  8927. }
  8928. return data === undefined ?
  8929. this :
  8930. this.each( function() {
  8931. var queue = jQuery.queue( this, type, data );
  8932. // Ensure a hooks for this queue
  8933. jQuery._queueHooks( this, type );
  8934. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  8935. jQuery.dequeue( this, type );
  8936. }
  8937. } );
  8938. },
  8939. dequeue: function( type ) {
  8940. return this.each( function() {
  8941. jQuery.dequeue( this, type );
  8942. } );
  8943. },
  8944. clearQueue: function( type ) {
  8945. return this.queue( type || "fx", [] );
  8946. },
  8947. // Get a promise resolved when queues of a certain type
  8948. // are emptied (fx is the type by default)
  8949. promise: function( type, obj ) {
  8950. var tmp,
  8951. count = 1,
  8952. defer = jQuery.Deferred(),
  8953. elements = this,
  8954. i = this.length,
  8955. resolve = function() {
  8956. if ( !( --count ) ) {
  8957. defer.resolveWith( elements, [ elements ] );
  8958. }
  8959. };
  8960. if ( typeof type !== "string" ) {
  8961. obj = type;
  8962. type = undefined;
  8963. }
  8964. type = type || "fx";
  8965. while ( i-- ) {
  8966. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  8967. if ( tmp && tmp.empty ) {
  8968. count++;
  8969. tmp.empty.add( resolve );
  8970. }
  8971. }
  8972. resolve();
  8973. return defer.promise( obj );
  8974. }
  8975. } );
  8976. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  8977. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  8978. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  8979. var documentElement = document.documentElement;
  8980. var isAttached = function( elem ) {
  8981. return jQuery.contains( elem.ownerDocument, elem );
  8982. },
  8983. composed = { composed: true };
  8984. // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
  8985. // Check attachment across shadow DOM boundaries when possible (gh-3504)
  8986. // Support: iOS 10.0-10.2 only
  8987. // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
  8988. // leading to errors. We need to check for `getRootNode`.
  8989. if ( documentElement.getRootNode ) {
  8990. isAttached = function( elem ) {
  8991. return jQuery.contains( elem.ownerDocument, elem ) ||
  8992. elem.getRootNode( composed ) === elem.ownerDocument;
  8993. };
  8994. }
  8995. var isHiddenWithinTree = function( elem, el ) {
  8996. // isHiddenWithinTree might be called from jQuery#filter function;
  8997. // in that case, element will be second argument
  8998. elem = el || elem;
  8999. // Inline style trumps all
  9000. return elem.style.display === "none" ||
  9001. elem.style.display === "" &&
  9002. // Otherwise, check computed style
  9003. // Support: Firefox <=43 - 45
  9004. // Disconnected elements can have computed display: none, so first confirm that elem is
  9005. // in the document.
  9006. isAttached( elem ) &&
  9007. jQuery.css( elem, "display" ) === "none";
  9008. };
  9009. function adjustCSS( elem, prop, valueParts, tween ) {
  9010. var adjusted, scale,
  9011. maxIterations = 20,
  9012. currentValue = tween ?
  9013. function() {
  9014. return tween.cur();
  9015. } :
  9016. function() {
  9017. return jQuery.css( elem, prop, "" );
  9018. },
  9019. initial = currentValue(),
  9020. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  9021. // Starting value computation is required for potential unit mismatches
  9022. initialInUnit = elem.nodeType &&
  9023. ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  9024. rcssNum.exec( jQuery.css( elem, prop ) );
  9025. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  9026. // Support: Firefox <=54
  9027. // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
  9028. initial = initial / 2;
  9029. // Trust units reported by jQuery.css
  9030. unit = unit || initialInUnit[ 3 ];
  9031. // Iteratively approximate from a nonzero starting point
  9032. initialInUnit = +initial || 1;
  9033. while ( maxIterations-- ) {
  9034. // Evaluate and update our best guess (doubling guesses that zero out).
  9035. // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
  9036. jQuery.style( elem, prop, initialInUnit + unit );
  9037. if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
  9038. maxIterations = 0;
  9039. }
  9040. initialInUnit = initialInUnit / scale;
  9041. }
  9042. initialInUnit = initialInUnit * 2;
  9043. jQuery.style( elem, prop, initialInUnit + unit );
  9044. // Make sure we update the tween properties later on
  9045. valueParts = valueParts || [];
  9046. }
  9047. if ( valueParts ) {
  9048. initialInUnit = +initialInUnit || +initial || 0;
  9049. // Apply relative offset (+=/-=) if specified
  9050. adjusted = valueParts[ 1 ] ?
  9051. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  9052. +valueParts[ 2 ];
  9053. if ( tween ) {
  9054. tween.unit = unit;
  9055. tween.start = initialInUnit;
  9056. tween.end = adjusted;
  9057. }
  9058. }
  9059. return adjusted;
  9060. }
  9061. var defaultDisplayMap = {};
  9062. function getDefaultDisplay( elem ) {
  9063. var temp,
  9064. doc = elem.ownerDocument,
  9065. nodeName = elem.nodeName,
  9066. display = defaultDisplayMap[ nodeName ];
  9067. if ( display ) {
  9068. return display;
  9069. }
  9070. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  9071. display = jQuery.css( temp, "display" );
  9072. temp.parentNode.removeChild( temp );
  9073. if ( display === "none" ) {
  9074. display = "block";
  9075. }
  9076. defaultDisplayMap[ nodeName ] = display;
  9077. return display;
  9078. }
  9079. function showHide( elements, show ) {
  9080. var display, elem,
  9081. values = [],
  9082. index = 0,
  9083. length = elements.length;
  9084. // Determine new display value for elements that need to change
  9085. for ( ; index < length; index++ ) {
  9086. elem = elements[ index ];
  9087. if ( !elem.style ) {
  9088. continue;
  9089. }
  9090. display = elem.style.display;
  9091. if ( show ) {
  9092. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  9093. // check is required in this first loop unless we have a nonempty display value (either
  9094. // inline or about-to-be-restored)
  9095. if ( display === "none" ) {
  9096. values[ index ] = dataPriv.get( elem, "display" ) || null;
  9097. if ( !values[ index ] ) {
  9098. elem.style.display = "";
  9099. }
  9100. }
  9101. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  9102. values[ index ] = getDefaultDisplay( elem );
  9103. }
  9104. } else {
  9105. if ( display !== "none" ) {
  9106. values[ index ] = "none";
  9107. // Remember what we're overwriting
  9108. dataPriv.set( elem, "display", display );
  9109. }
  9110. }
  9111. }
  9112. // Set the display of the elements in a second loop to avoid constant reflow
  9113. for ( index = 0; index < length; index++ ) {
  9114. if ( values[ index ] != null ) {
  9115. elements[ index ].style.display = values[ index ];
  9116. }
  9117. }
  9118. return elements;
  9119. }
  9120. jQuery.fn.extend( {
  9121. show: function() {
  9122. return showHide( this, true );
  9123. },
  9124. hide: function() {
  9125. return showHide( this );
  9126. },
  9127. toggle: function( state ) {
  9128. if ( typeof state === "boolean" ) {
  9129. return state ? this.show() : this.hide();
  9130. }
  9131. return this.each( function() {
  9132. if ( isHiddenWithinTree( this ) ) {
  9133. jQuery( this ).show();
  9134. } else {
  9135. jQuery( this ).hide();
  9136. }
  9137. } );
  9138. }
  9139. } );
  9140. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  9141. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
  9142. var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
  9143. ( function() {
  9144. var fragment = document.createDocumentFragment(),
  9145. div = fragment.appendChild( document.createElement( "div" ) ),
  9146. input = document.createElement( "input" );
  9147. // Support: Android 4.0 - 4.3 only
  9148. // Check state lost if the name is set (#11217)
  9149. // Support: Windows Web Apps (WWA)
  9150. // `name` and `type` must use .setAttribute for WWA (#14901)
  9151. input.setAttribute( "type", "radio" );
  9152. input.setAttribute( "checked", "checked" );
  9153. input.setAttribute( "name", "t" );
  9154. div.appendChild( input );
  9155. // Support: Android <=4.1 only
  9156. // Older WebKit doesn't clone checked state correctly in fragments
  9157. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  9158. // Support: IE <=11 only
  9159. // Make sure textarea (and checkbox) defaultValue is properly cloned
  9160. div.innerHTML = "<textarea>x</textarea>";
  9161. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  9162. // Support: IE <=9 only
  9163. // IE <=9 replaces <option> tags with their contents when inserted outside of
  9164. // the select element.
  9165. div.innerHTML = "<option></option>";
  9166. support.option = !!div.lastChild;
  9167. } )();
  9168. // We have to close these tags to support XHTML (#13200)
  9169. var wrapMap = {
  9170. // XHTML parsers do not magically insert elements in the
  9171. // same way that tag soup parsers do. So we cannot shorten
  9172. // this by omitting <tbody> or other required elements.
  9173. thead: [ 1, "<table>", "</table>" ],
  9174. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  9175. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  9176. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  9177. _default: [ 0, "", "" ]
  9178. };
  9179. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  9180. wrapMap.th = wrapMap.td;
  9181. // Support: IE <=9 only
  9182. if ( !support.option ) {
  9183. wrapMap.optgroup = wrapMap.option = [ 1, "<select multiple='multiple'>", "</select>" ];
  9184. }
  9185. function getAll( context, tag ) {
  9186. // Support: IE <=9 - 11 only
  9187. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  9188. var ret;
  9189. if ( typeof context.getElementsByTagName !== "undefined" ) {
  9190. ret = context.getElementsByTagName( tag || "*" );
  9191. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  9192. ret = context.querySelectorAll( tag || "*" );
  9193. } else {
  9194. ret = [];
  9195. }
  9196. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  9197. return jQuery.merge( [ context ], ret );
  9198. }
  9199. return ret;
  9200. }
  9201. // Mark scripts as having already been evaluated
  9202. function setGlobalEval( elems, refElements ) {
  9203. var i = 0,
  9204. l = elems.length;
  9205. for ( ; i < l; i++ ) {
  9206. dataPriv.set(
  9207. elems[ i ],
  9208. "globalEval",
  9209. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  9210. );
  9211. }
  9212. }
  9213. var rhtml = /<|&#?\w+;/;
  9214. function buildFragment( elems, context, scripts, selection, ignored ) {
  9215. var elem, tmp, tag, wrap, attached, j,
  9216. fragment = context.createDocumentFragment(),
  9217. nodes = [],
  9218. i = 0,
  9219. l = elems.length;
  9220. for ( ; i < l; i++ ) {
  9221. elem = elems[ i ];
  9222. if ( elem || elem === 0 ) {
  9223. // Add nodes directly
  9224. if ( toType( elem ) === "object" ) {
  9225. // Support: Android <=4.0 only, PhantomJS 1 only
  9226. // push.apply(_, arraylike) throws on ancient WebKit
  9227. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  9228. // Convert non-html into a text node
  9229. } else if ( !rhtml.test( elem ) ) {
  9230. nodes.push( context.createTextNode( elem ) );
  9231. // Convert html into DOM nodes
  9232. } else {
  9233. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  9234. // Deserialize a standard representation
  9235. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  9236. wrap = wrapMap[ tag ] || wrapMap._default;
  9237. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  9238. // Descend through wrappers to the right content
  9239. j = wrap[ 0 ];
  9240. while ( j-- ) {
  9241. tmp = tmp.lastChild;
  9242. }
  9243. // Support: Android <=4.0 only, PhantomJS 1 only
  9244. // push.apply(_, arraylike) throws on ancient WebKit
  9245. jQuery.merge( nodes, tmp.childNodes );
  9246. // Remember the top-level container
  9247. tmp = fragment.firstChild;
  9248. // Ensure the created nodes are orphaned (#12392)
  9249. tmp.textContent = "";
  9250. }
  9251. }
  9252. }
  9253. // Remove wrapper from fragment
  9254. fragment.textContent = "";
  9255. i = 0;
  9256. while ( ( elem = nodes[ i++ ] ) ) {
  9257. // Skip elements already in the context collection (trac-4087)
  9258. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  9259. if ( ignored ) {
  9260. ignored.push( elem );
  9261. }
  9262. continue;
  9263. }
  9264. attached = isAttached( elem );
  9265. // Append to fragment
  9266. tmp = getAll( fragment.appendChild( elem ), "script" );
  9267. // Preserve script evaluation history
  9268. if ( attached ) {
  9269. setGlobalEval( tmp );
  9270. }
  9271. // Capture executables
  9272. if ( scripts ) {
  9273. j = 0;
  9274. while ( ( elem = tmp[ j++ ] ) ) {
  9275. if ( rscriptType.test( elem.type || "" ) ) {
  9276. scripts.push( elem );
  9277. }
  9278. }
  9279. }
  9280. }
  9281. return fragment;
  9282. }
  9283. var
  9284. rkeyEvent = /^key/,
  9285. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  9286. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  9287. function returnTrue() {
  9288. return true;
  9289. }
  9290. function returnFalse() {
  9291. return false;
  9292. }
  9293. // Support: IE <=9 - 11+
  9294. // focus() and blur() are asynchronous, except when they are no-op.
  9295. // So expect focus to be synchronous when the element is already active,
  9296. // and blur to be synchronous when the element is not already active.
  9297. // (focus and blur are always synchronous in other supported browsers,
  9298. // this just defines when we can count on it).
  9299. function expectSync( elem, type ) {
  9300. return ( elem === safeActiveElement() ) === ( type === "focus" );
  9301. }
  9302. // Support: IE <=9 only
  9303. // Accessing document.activeElement can throw unexpectedly
  9304. // https://bugs.jquery.com/ticket/13393
  9305. function safeActiveElement() {
  9306. try {
  9307. return document.activeElement;
  9308. } catch ( err ) { }
  9309. }
  9310. function on( elem, types, selector, data, fn, one ) {
  9311. var origFn, type;
  9312. // Types can be a map of types/handlers
  9313. if ( typeof types === "object" ) {
  9314. // ( types-Object, selector, data )
  9315. if ( typeof selector !== "string" ) {
  9316. // ( types-Object, data )
  9317. data = data || selector;
  9318. selector = undefined;
  9319. }
  9320. for ( type in types ) {
  9321. on( elem, type, selector, data, types[ type ], one );
  9322. }
  9323. return elem;
  9324. }
  9325. if ( data == null && fn == null ) {
  9326. // ( types, fn )
  9327. fn = selector;
  9328. data = selector = undefined;
  9329. } else if ( fn == null ) {
  9330. if ( typeof selector === "string" ) {
  9331. // ( types, selector, fn )
  9332. fn = data;
  9333. data = undefined;
  9334. } else {
  9335. // ( types, data, fn )
  9336. fn = data;
  9337. data = selector;
  9338. selector = undefined;
  9339. }
  9340. }
  9341. if ( fn === false ) {
  9342. fn = returnFalse;
  9343. } else if ( !fn ) {
  9344. return elem;
  9345. }
  9346. if ( one === 1 ) {
  9347. origFn = fn;
  9348. fn = function( event ) {
  9349. // Can use an empty set, since event contains the info
  9350. jQuery().off( event );
  9351. return origFn.apply( this, arguments );
  9352. };
  9353. // Use same guid so caller can remove using origFn
  9354. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  9355. }
  9356. return elem.each( function() {
  9357. jQuery.event.add( this, types, fn, data, selector );
  9358. } );
  9359. }
  9360. /*
  9361. * Helper functions for managing events -- not part of the public interface.
  9362. * Props to Dean Edwards' addEvent library for many of the ideas.
  9363. */
  9364. jQuery.event = {
  9365. global: {},
  9366. add: function( elem, types, handler, data, selector ) {
  9367. var handleObjIn, eventHandle, tmp,
  9368. events, t, handleObj,
  9369. special, handlers, type, namespaces, origType,
  9370. elemData = dataPriv.get( elem );
  9371. // Only attach events to objects that accept data
  9372. if ( !acceptData( elem ) ) {
  9373. return;
  9374. }
  9375. // Caller can pass in an object of custom data in lieu of the handler
  9376. if ( handler.handler ) {
  9377. handleObjIn = handler;
  9378. handler = handleObjIn.handler;
  9379. selector = handleObjIn.selector;
  9380. }
  9381. // Ensure that invalid selectors throw exceptions at attach time
  9382. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  9383. if ( selector ) {
  9384. jQuery.find.matchesSelector( documentElement, selector );
  9385. }
  9386. // Make sure that the handler has a unique ID, used to find/remove it later
  9387. if ( !handler.guid ) {
  9388. handler.guid = jQuery.guid++;
  9389. }
  9390. // Init the element's event structure and main handler, if this is the first
  9391. if ( !( events = elemData.events ) ) {
  9392. events = elemData.events = Object.create( null );
  9393. }
  9394. if ( !( eventHandle = elemData.handle ) ) {
  9395. eventHandle = elemData.handle = function( e ) {
  9396. // Discard the second event of a jQuery.event.trigger() and
  9397. // when an event is called after a page has unloaded
  9398. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  9399. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  9400. };
  9401. }
  9402. // Handle multiple events separated by a space
  9403. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  9404. t = types.length;
  9405. while ( t-- ) {
  9406. tmp = rtypenamespace.exec( types[ t ] ) || [];
  9407. type = origType = tmp[ 1 ];
  9408. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  9409. // There *must* be a type, no attaching namespace-only handlers
  9410. if ( !type ) {
  9411. continue;
  9412. }
  9413. // If event changes its type, use the special event handlers for the changed type
  9414. special = jQuery.event.special[ type ] || {};
  9415. // If selector defined, determine special event api type, otherwise given type
  9416. type = ( selector ? special.delegateType : special.bindType ) || type;
  9417. // Update special based on newly reset type
  9418. special = jQuery.event.special[ type ] || {};
  9419. // handleObj is passed to all event handlers
  9420. handleObj = jQuery.extend( {
  9421. type: type,
  9422. origType: origType,
  9423. data: data,
  9424. handler: handler,
  9425. guid: handler.guid,
  9426. selector: selector,
  9427. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  9428. namespace: namespaces.join( "." )
  9429. }, handleObjIn );
  9430. // Init the event handler queue if we're the first
  9431. if ( !( handlers = events[ type ] ) ) {
  9432. handlers = events[ type ] = [];
  9433. handlers.delegateCount = 0;
  9434. // Only use addEventListener if the special events handler returns false
  9435. if ( !special.setup ||
  9436. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  9437. if ( elem.addEventListener ) {
  9438. elem.addEventListener( type, eventHandle );
  9439. }
  9440. }
  9441. }
  9442. if ( special.add ) {
  9443. special.add.call( elem, handleObj );
  9444. if ( !handleObj.handler.guid ) {
  9445. handleObj.handler.guid = handler.guid;
  9446. }
  9447. }
  9448. // Add to the element's handler list, delegates in front
  9449. if ( selector ) {
  9450. handlers.splice( handlers.delegateCount++, 0, handleObj );
  9451. } else {
  9452. handlers.push( handleObj );
  9453. }
  9454. // Keep track of which events have ever been used, for event optimization
  9455. jQuery.event.global[ type ] = true;
  9456. }
  9457. },
  9458. // Detach an event or set of events from an element
  9459. remove: function( elem, types, handler, selector, mappedTypes ) {
  9460. var j, origCount, tmp,
  9461. events, t, handleObj,
  9462. special, handlers, type, namespaces, origType,
  9463. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  9464. if ( !elemData || !( events = elemData.events ) ) {
  9465. return;
  9466. }
  9467. // Once for each type.namespace in types; type may be omitted
  9468. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  9469. t = types.length;
  9470. while ( t-- ) {
  9471. tmp = rtypenamespace.exec( types[ t ] ) || [];
  9472. type = origType = tmp[ 1 ];
  9473. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  9474. // Unbind all events (on this namespace, if provided) for the element
  9475. if ( !type ) {
  9476. for ( type in events ) {
  9477. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  9478. }
  9479. continue;
  9480. }
  9481. special = jQuery.event.special[ type ] || {};
  9482. type = ( selector ? special.delegateType : special.bindType ) || type;
  9483. handlers = events[ type ] || [];
  9484. tmp = tmp[ 2 ] &&
  9485. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  9486. // Remove matching events
  9487. origCount = j = handlers.length;
  9488. while ( j-- ) {
  9489. handleObj = handlers[ j ];
  9490. if ( ( mappedTypes || origType === handleObj.origType ) &&
  9491. ( !handler || handler.guid === handleObj.guid ) &&
  9492. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  9493. ( !selector || selector === handleObj.selector ||
  9494. selector === "**" && handleObj.selector ) ) {
  9495. handlers.splice( j, 1 );
  9496. if ( handleObj.selector ) {
  9497. handlers.delegateCount--;
  9498. }
  9499. if ( special.remove ) {
  9500. special.remove.call( elem, handleObj );
  9501. }
  9502. }
  9503. }
  9504. // Remove generic event handler if we removed something and no more handlers exist
  9505. // (avoids potential for endless recursion during removal of special event handlers)
  9506. if ( origCount && !handlers.length ) {
  9507. if ( !special.teardown ||
  9508. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  9509. jQuery.removeEvent( elem, type, elemData.handle );
  9510. }
  9511. delete events[ type ];
  9512. }
  9513. }
  9514. // Remove data and the expando if it's no longer used
  9515. if ( jQuery.isEmptyObject( events ) ) {
  9516. dataPriv.remove( elem, "handle events" );
  9517. }
  9518. },
  9519. dispatch: function( nativeEvent ) {
  9520. var i, j, ret, matched, handleObj, handlerQueue,
  9521. args = new Array( arguments.length ),
  9522. // Make a writable jQuery.Event from the native event object
  9523. event = jQuery.event.fix( nativeEvent ),
  9524. handlers = (
  9525. dataPriv.get( this, "events" ) || Object.create( null )
  9526. )[ event.type ] || [],
  9527. special = jQuery.event.special[ event.type ] || {};
  9528. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  9529. args[ 0 ] = event;
  9530. for ( i = 1; i < arguments.length; i++ ) {
  9531. args[ i ] = arguments[ i ];
  9532. }
  9533. event.delegateTarget = this;
  9534. // Call the preDispatch hook for the mapped type, and let it bail if desired
  9535. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  9536. return;
  9537. }
  9538. // Determine handlers
  9539. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  9540. // Run delegates first; they may want to stop propagation beneath us
  9541. i = 0;
  9542. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  9543. event.currentTarget = matched.elem;
  9544. j = 0;
  9545. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  9546. !event.isImmediatePropagationStopped() ) {
  9547. // If the event is namespaced, then each handler is only invoked if it is
  9548. // specially universal or its namespaces are a superset of the event's.
  9549. if ( !event.rnamespace || handleObj.namespace === false ||
  9550. event.rnamespace.test( handleObj.namespace ) ) {
  9551. event.handleObj = handleObj;
  9552. event.data = handleObj.data;
  9553. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  9554. handleObj.handler ).apply( matched.elem, args );
  9555. if ( ret !== undefined ) {
  9556. if ( ( event.result = ret ) === false ) {
  9557. event.preventDefault();
  9558. event.stopPropagation();
  9559. }
  9560. }
  9561. }
  9562. }
  9563. }
  9564. // Call the postDispatch hook for the mapped type
  9565. if ( special.postDispatch ) {
  9566. special.postDispatch.call( this, event );
  9567. }
  9568. return event.result;
  9569. },
  9570. handlers: function( event, handlers ) {
  9571. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  9572. handlerQueue = [],
  9573. delegateCount = handlers.delegateCount,
  9574. cur = event.target;
  9575. // Find delegate handlers
  9576. if ( delegateCount &&
  9577. // Support: IE <=9
  9578. // Black-hole SVG <use> instance trees (trac-13180)
  9579. cur.nodeType &&
  9580. // Support: Firefox <=42
  9581. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  9582. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  9583. // Support: IE 11 only
  9584. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  9585. !( event.type === "click" && event.button >= 1 ) ) {
  9586. for ( ; cur !== this; cur = cur.parentNode || this ) {
  9587. // Don't check non-elements (#13208)
  9588. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  9589. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  9590. matchedHandlers = [];
  9591. matchedSelectors = {};
  9592. for ( i = 0; i < delegateCount; i++ ) {
  9593. handleObj = handlers[ i ];
  9594. // Don't conflict with Object.prototype properties (#13203)
  9595. sel = handleObj.selector + " ";
  9596. if ( matchedSelectors[ sel ] === undefined ) {
  9597. matchedSelectors[ sel ] = handleObj.needsContext ?
  9598. jQuery( sel, this ).index( cur ) > -1 :
  9599. jQuery.find( sel, this, null, [ cur ] ).length;
  9600. }
  9601. if ( matchedSelectors[ sel ] ) {
  9602. matchedHandlers.push( handleObj );
  9603. }
  9604. }
  9605. if ( matchedHandlers.length ) {
  9606. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  9607. }
  9608. }
  9609. }
  9610. }
  9611. // Add the remaining (directly-bound) handlers
  9612. cur = this;
  9613. if ( delegateCount < handlers.length ) {
  9614. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  9615. }
  9616. return handlerQueue;
  9617. },
  9618. addProp: function( name, hook ) {
  9619. Object.defineProperty( jQuery.Event.prototype, name, {
  9620. enumerable: true,
  9621. configurable: true,
  9622. get: isFunction( hook ) ?
  9623. function() {
  9624. if ( this.originalEvent ) {
  9625. return hook( this.originalEvent );
  9626. }
  9627. } :
  9628. function() {
  9629. if ( this.originalEvent ) {
  9630. return this.originalEvent[ name ];
  9631. }
  9632. },
  9633. set: function( value ) {
  9634. Object.defineProperty( this, name, {
  9635. enumerable: true,
  9636. configurable: true,
  9637. writable: true,
  9638. value: value
  9639. } );
  9640. }
  9641. } );
  9642. },
  9643. fix: function( originalEvent ) {
  9644. return originalEvent[ jQuery.expando ] ?
  9645. originalEvent :
  9646. new jQuery.Event( originalEvent );
  9647. },
  9648. special: {
  9649. load: {
  9650. // Prevent triggered image.load events from bubbling to window.load
  9651. noBubble: true
  9652. },
  9653. click: {
  9654. // Utilize native event to ensure correct state for checkable inputs
  9655. setup: function( data ) {
  9656. // For mutual compressibility with _default, replace `this` access with a local var.
  9657. // `|| data` is dead code meant only to preserve the variable through minification.
  9658. var el = this || data;
  9659. // Claim the first handler
  9660. if ( rcheckableType.test( el.type ) &&
  9661. el.click && nodeName( el, "input" ) ) {
  9662. // dataPriv.set( el, "click", ... )
  9663. leverageNative( el, "click", returnTrue );
  9664. }
  9665. // Return false to allow normal processing in the caller
  9666. return false;
  9667. },
  9668. trigger: function( data ) {
  9669. // For mutual compressibility with _default, replace `this` access with a local var.
  9670. // `|| data` is dead code meant only to preserve the variable through minification.
  9671. var el = this || data;
  9672. // Force setup before triggering a click
  9673. if ( rcheckableType.test( el.type ) &&
  9674. el.click && nodeName( el, "input" ) ) {
  9675. leverageNative( el, "click" );
  9676. }
  9677. // Return non-false to allow normal event-path propagation
  9678. return true;
  9679. },
  9680. // For cross-browser consistency, suppress native .click() on links
  9681. // Also prevent it if we're currently inside a leveraged native-event stack
  9682. _default: function( event ) {
  9683. var target = event.target;
  9684. return rcheckableType.test( target.type ) &&
  9685. target.click && nodeName( target, "input" ) &&
  9686. dataPriv.get( target, "click" ) ||
  9687. nodeName( target, "a" );
  9688. }
  9689. },
  9690. beforeunload: {
  9691. postDispatch: function( event ) {
  9692. // Support: Firefox 20+
  9693. // Firefox doesn't alert if the returnValue field is not set.
  9694. if ( event.result !== undefined && event.originalEvent ) {
  9695. event.originalEvent.returnValue = event.result;
  9696. }
  9697. }
  9698. }
  9699. }
  9700. };
  9701. // Ensure the presence of an event listener that handles manually-triggered
  9702. // synthetic events by interrupting progress until reinvoked in response to
  9703. // *native* events that it fires directly, ensuring that state changes have
  9704. // already occurred before other listeners are invoked.
  9705. function leverageNative( el, type, expectSync ) {
  9706. // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
  9707. if ( !expectSync ) {
  9708. if ( dataPriv.get( el, type ) === undefined ) {
  9709. jQuery.event.add( el, type, returnTrue );
  9710. }
  9711. return;
  9712. }
  9713. // Register the controller as a special universal handler for all event namespaces
  9714. dataPriv.set( el, type, false );
  9715. jQuery.event.add( el, type, {
  9716. namespace: false,
  9717. handler: function( event ) {
  9718. var notAsync, result,
  9719. saved = dataPriv.get( this, type );
  9720. if ( ( event.isTrigger & 1 ) && this[ type ] ) {
  9721. // Interrupt processing of the outer synthetic .trigger()ed event
  9722. // Saved data should be false in such cases, but might be a leftover capture object
  9723. // from an async native handler (gh-4350)
  9724. if ( !saved.length ) {
  9725. // Store arguments for use when handling the inner native event
  9726. // There will always be at least one argument (an event object), so this array
  9727. // will not be confused with a leftover capture object.
  9728. saved = slice.call( arguments );
  9729. dataPriv.set( this, type, saved );
  9730. // Trigger the native event and capture its result
  9731. // Support: IE <=9 - 11+
  9732. // focus() and blur() are asynchronous
  9733. notAsync = expectSync( this, type );
  9734. this[ type ]();
  9735. result = dataPriv.get( this, type );
  9736. if ( saved !== result || notAsync ) {
  9737. dataPriv.set( this, type, false );
  9738. } else {
  9739. result = {};
  9740. }
  9741. if ( saved !== result ) {
  9742. // Cancel the outer synthetic event
  9743. event.stopImmediatePropagation();
  9744. event.preventDefault();
  9745. return result.value;
  9746. }
  9747. // If this is an inner synthetic event for an event with a bubbling surrogate
  9748. // (focus or blur), assume that the surrogate already propagated from triggering the
  9749. // native event and prevent that from happening again here.
  9750. // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
  9751. // bubbling surrogate propagates *after* the non-bubbling base), but that seems
  9752. // less bad than duplication.
  9753. } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
  9754. event.stopPropagation();
  9755. }
  9756. // If this is a native event triggered above, everything is now in order
  9757. // Fire an inner synthetic event with the original arguments
  9758. } else if ( saved.length ) {
  9759. // ...and capture the result
  9760. dataPriv.set( this, type, {
  9761. value: jQuery.event.trigger(
  9762. // Support: IE <=9 - 11+
  9763. // Extend with the prototype to reset the above stopImmediatePropagation()
  9764. jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
  9765. saved.slice( 1 ),
  9766. this
  9767. )
  9768. } );
  9769. // Abort handling of the native event
  9770. event.stopImmediatePropagation();
  9771. }
  9772. }
  9773. } );
  9774. }
  9775. jQuery.removeEvent = function( elem, type, handle ) {
  9776. // This "if" is needed for plain objects
  9777. if ( elem.removeEventListener ) {
  9778. elem.removeEventListener( type, handle );
  9779. }
  9780. };
  9781. jQuery.Event = function( src, props ) {
  9782. // Allow instantiation without the 'new' keyword
  9783. if ( !( this instanceof jQuery.Event ) ) {
  9784. return new jQuery.Event( src, props );
  9785. }
  9786. // Event object
  9787. if ( src && src.type ) {
  9788. this.originalEvent = src;
  9789. this.type = src.type;
  9790. // Events bubbling up the document may have been marked as prevented
  9791. // by a handler lower down the tree; reflect the correct value.
  9792. this.isDefaultPrevented = src.defaultPrevented ||
  9793. src.defaultPrevented === undefined &&
  9794. // Support: Android <=2.3 only
  9795. src.returnValue === false ?
  9796. returnTrue :
  9797. returnFalse;
  9798. // Create target properties
  9799. // Support: Safari <=6 - 7 only
  9800. // Target should not be a text node (#504, #13143)
  9801. this.target = ( src.target && src.target.nodeType === 3 ) ?
  9802. src.target.parentNode :
  9803. src.target;
  9804. this.currentTarget = src.currentTarget;
  9805. this.relatedTarget = src.relatedTarget;
  9806. // Event type
  9807. } else {
  9808. this.type = src;
  9809. }
  9810. // Put explicitly provided properties onto the event object
  9811. if ( props ) {
  9812. jQuery.extend( this, props );
  9813. }
  9814. // Create a timestamp if incoming event doesn't have one
  9815. this.timeStamp = src && src.timeStamp || Date.now();
  9816. // Mark it as fixed
  9817. this[ jQuery.expando ] = true;
  9818. };
  9819. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  9820. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  9821. jQuery.Event.prototype = {
  9822. constructor: jQuery.Event,
  9823. isDefaultPrevented: returnFalse,
  9824. isPropagationStopped: returnFalse,
  9825. isImmediatePropagationStopped: returnFalse,
  9826. isSimulated: false,
  9827. preventDefault: function() {
  9828. var e = this.originalEvent;
  9829. this.isDefaultPrevented = returnTrue;
  9830. if ( e && !this.isSimulated ) {
  9831. e.preventDefault();
  9832. }
  9833. },
  9834. stopPropagation: function() {
  9835. var e = this.originalEvent;
  9836. this.isPropagationStopped = returnTrue;
  9837. if ( e && !this.isSimulated ) {
  9838. e.stopPropagation();
  9839. }
  9840. },
  9841. stopImmediatePropagation: function() {
  9842. var e = this.originalEvent;
  9843. this.isImmediatePropagationStopped = returnTrue;
  9844. if ( e && !this.isSimulated ) {
  9845. e.stopImmediatePropagation();
  9846. }
  9847. this.stopPropagation();
  9848. }
  9849. };
  9850. // Includes all common event props including KeyEvent and MouseEvent specific props
  9851. jQuery.each( {
  9852. altKey: true,
  9853. bubbles: true,
  9854. cancelable: true,
  9855. changedTouches: true,
  9856. ctrlKey: true,
  9857. detail: true,
  9858. eventPhase: true,
  9859. metaKey: true,
  9860. pageX: true,
  9861. pageY: true,
  9862. shiftKey: true,
  9863. view: true,
  9864. "char": true,
  9865. code: true,
  9866. charCode: true,
  9867. key: true,
  9868. keyCode: true,
  9869. button: true,
  9870. buttons: true,
  9871. clientX: true,
  9872. clientY: true,
  9873. offsetX: true,
  9874. offsetY: true,
  9875. pointerId: true,
  9876. pointerType: true,
  9877. screenX: true,
  9878. screenY: true,
  9879. targetTouches: true,
  9880. toElement: true,
  9881. touches: true,
  9882. which: function( event ) {
  9883. var button = event.button;
  9884. // Add which for key events
  9885. if ( event.which == null && rkeyEvent.test( event.type ) ) {
  9886. return event.charCode != null ? event.charCode : event.keyCode;
  9887. }
  9888. // Add which for click: 1 === left; 2 === middle; 3 === right
  9889. if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  9890. if ( button & 1 ) {
  9891. return 1;
  9892. }
  9893. if ( button & 2 ) {
  9894. return 3;
  9895. }
  9896. if ( button & 4 ) {
  9897. return 2;
  9898. }
  9899. return 0;
  9900. }
  9901. return event.which;
  9902. }
  9903. }, jQuery.event.addProp );
  9904. jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
  9905. jQuery.event.special[ type ] = {
  9906. // Utilize native event if possible so blur/focus sequence is correct
  9907. setup: function() {
  9908. // Claim the first handler
  9909. // dataPriv.set( this, "focus", ... )
  9910. // dataPriv.set( this, "blur", ... )
  9911. leverageNative( this, type, expectSync );
  9912. // Return false to allow normal processing in the caller
  9913. return false;
  9914. },
  9915. trigger: function() {
  9916. // Force setup before trigger
  9917. leverageNative( this, type );
  9918. // Return non-false to allow normal event-path propagation
  9919. return true;
  9920. },
  9921. delegateType: delegateType
  9922. };
  9923. } );
  9924. // Create mouseenter/leave events using mouseover/out and event-time checks
  9925. // so that event delegation works in jQuery.
  9926. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  9927. //
  9928. // Support: Safari 7 only
  9929. // Safari sends mouseenter too often; see:
  9930. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  9931. // for the description of the bug (it existed in older Chrome versions as well).
  9932. jQuery.each( {
  9933. mouseenter: "mouseover",
  9934. mouseleave: "mouseout",
  9935. pointerenter: "pointerover",
  9936. pointerleave: "pointerout"
  9937. }, function( orig, fix ) {
  9938. jQuery.event.special[ orig ] = {
  9939. delegateType: fix,
  9940. bindType: fix,
  9941. handle: function( event ) {
  9942. var ret,
  9943. target = this,
  9944. related = event.relatedTarget,
  9945. handleObj = event.handleObj;
  9946. // For mouseenter/leave call the handler if related is outside the target.
  9947. // NB: No relatedTarget if the mouse left/entered the browser window
  9948. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  9949. event.type = handleObj.origType;
  9950. ret = handleObj.handler.apply( this, arguments );
  9951. event.type = fix;
  9952. }
  9953. return ret;
  9954. }
  9955. };
  9956. } );
  9957. jQuery.fn.extend( {
  9958. on: function( types, selector, data, fn ) {
  9959. return on( this, types, selector, data, fn );
  9960. },
  9961. one: function( types, selector, data, fn ) {
  9962. return on( this, types, selector, data, fn, 1 );
  9963. },
  9964. off: function( types, selector, fn ) {
  9965. var handleObj, type;
  9966. if ( types && types.preventDefault && types.handleObj ) {
  9967. // ( event ) dispatched jQuery.Event
  9968. handleObj = types.handleObj;
  9969. jQuery( types.delegateTarget ).off(
  9970. handleObj.namespace ?
  9971. handleObj.origType + "." + handleObj.namespace :
  9972. handleObj.origType,
  9973. handleObj.selector,
  9974. handleObj.handler
  9975. );
  9976. return this;
  9977. }
  9978. if ( typeof types === "object" ) {
  9979. // ( types-object [, selector] )
  9980. for ( type in types ) {
  9981. this.off( type, selector, types[ type ] );
  9982. }
  9983. return this;
  9984. }
  9985. if ( selector === false || typeof selector === "function" ) {
  9986. // ( types [, fn] )
  9987. fn = selector;
  9988. selector = undefined;
  9989. }
  9990. if ( fn === false ) {
  9991. fn = returnFalse;
  9992. }
  9993. return this.each( function() {
  9994. jQuery.event.remove( this, types, fn, selector );
  9995. } );
  9996. }
  9997. } );
  9998. var
  9999. // Support: IE <=10 - 11, Edge 12 - 13 only
  10000. // In IE/Edge using regex groups here causes severe slowdowns.
  10001. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  10002. rnoInnerhtml = /<script|<style|<link/i,
  10003. // checked="checked" or checked
  10004. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  10005. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  10006. // Prefer a tbody over its parent table for containing new rows
  10007. function manipulationTarget( elem, content ) {
  10008. if ( nodeName( elem, "table" ) &&
  10009. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  10010. return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
  10011. }
  10012. return elem;
  10013. }
  10014. // Replace/restore the type attribute of script elements for safe DOM manipulation
  10015. function disableScript( elem ) {
  10016. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  10017. return elem;
  10018. }
  10019. function restoreScript( elem ) {
  10020. if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
  10021. elem.type = elem.type.slice( 5 );
  10022. } else {
  10023. elem.removeAttribute( "type" );
  10024. }
  10025. return elem;
  10026. }
  10027. function cloneCopyEvent( src, dest ) {
  10028. var i, l, type, pdataOld, udataOld, udataCur, events;
  10029. if ( dest.nodeType !== 1 ) {
  10030. return;
  10031. }
  10032. // 1. Copy private data: events, handlers, etc.
  10033. if ( dataPriv.hasData( src ) ) {
  10034. pdataOld = dataPriv.get( src );
  10035. events = pdataOld.events;
  10036. if ( events ) {
  10037. dataPriv.remove( dest, "handle events" );
  10038. for ( type in events ) {
  10039. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  10040. jQuery.event.add( dest, type, events[ type ][ i ] );
  10041. }
  10042. }
  10043. }
  10044. }
  10045. // 2. Copy user data
  10046. if ( dataUser.hasData( src ) ) {
  10047. udataOld = dataUser.access( src );
  10048. udataCur = jQuery.extend( {}, udataOld );
  10049. dataUser.set( dest, udataCur );
  10050. }
  10051. }
  10052. // Fix IE bugs, see support tests
  10053. function fixInput( src, dest ) {
  10054. var nodeName = dest.nodeName.toLowerCase();
  10055. // Fails to persist the checked state of a cloned checkbox or radio button.
  10056. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  10057. dest.checked = src.checked;
  10058. // Fails to return the selected option to the default selected state when cloning options
  10059. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  10060. dest.defaultValue = src.defaultValue;
  10061. }
  10062. }
  10063. function domManip( collection, args, callback, ignored ) {
  10064. // Flatten any nested arrays
  10065. args = flat( args );
  10066. var fragment, first, scripts, hasScripts, node, doc,
  10067. i = 0,
  10068. l = collection.length,
  10069. iNoClone = l - 1,
  10070. value = args[ 0 ],
  10071. valueIsFunction = isFunction( value );
  10072. // We can't cloneNode fragments that contain checked, in WebKit
  10073. if ( valueIsFunction ||
  10074. ( l > 1 && typeof value === "string" &&
  10075. !support.checkClone && rchecked.test( value ) ) ) {
  10076. return collection.each( function( index ) {
  10077. var self = collection.eq( index );
  10078. if ( valueIsFunction ) {
  10079. args[ 0 ] = value.call( this, index, self.html() );
  10080. }
  10081. domManip( self, args, callback, ignored );
  10082. } );
  10083. }
  10084. if ( l ) {
  10085. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  10086. first = fragment.firstChild;
  10087. if ( fragment.childNodes.length === 1 ) {
  10088. fragment = first;
  10089. }
  10090. // Require either new content or an interest in ignored elements to invoke the callback
  10091. if ( first || ignored ) {
  10092. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  10093. hasScripts = scripts.length;
  10094. // Use the original fragment for the last item
  10095. // instead of the first because it can end up
  10096. // being emptied incorrectly in certain situations (#8070).
  10097. for ( ; i < l; i++ ) {
  10098. node = fragment;
  10099. if ( i !== iNoClone ) {
  10100. node = jQuery.clone( node, true, true );
  10101. // Keep references to cloned scripts for later restoration
  10102. if ( hasScripts ) {
  10103. // Support: Android <=4.0 only, PhantomJS 1 only
  10104. // push.apply(_, arraylike) throws on ancient WebKit
  10105. jQuery.merge( scripts, getAll( node, "script" ) );
  10106. }
  10107. }
  10108. callback.call( collection[ i ], node, i );
  10109. }
  10110. if ( hasScripts ) {
  10111. doc = scripts[ scripts.length - 1 ].ownerDocument;
  10112. // Reenable scripts
  10113. jQuery.map( scripts, restoreScript );
  10114. // Evaluate executable scripts on first document insertion
  10115. for ( i = 0; i < hasScripts; i++ ) {
  10116. node = scripts[ i ];
  10117. if ( rscriptType.test( node.type || "" ) &&
  10118. !dataPriv.access( node, "globalEval" ) &&
  10119. jQuery.contains( doc, node ) ) {
  10120. if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
  10121. // Optional AJAX dependency, but won't run scripts if not present
  10122. if ( jQuery._evalUrl && !node.noModule ) {
  10123. jQuery._evalUrl( node.src, {
  10124. nonce: node.nonce || node.getAttribute( "nonce" )
  10125. }, doc );
  10126. }
  10127. } else {
  10128. DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
  10129. }
  10130. }
  10131. }
  10132. }
  10133. }
  10134. }
  10135. return collection;
  10136. }
  10137. function remove( elem, selector, keepData ) {
  10138. var node,
  10139. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  10140. i = 0;
  10141. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  10142. if ( !keepData && node.nodeType === 1 ) {
  10143. jQuery.cleanData( getAll( node ) );
  10144. }
  10145. if ( node.parentNode ) {
  10146. if ( keepData && isAttached( node ) ) {
  10147. setGlobalEval( getAll( node, "script" ) );
  10148. }
  10149. node.parentNode.removeChild( node );
  10150. }
  10151. }
  10152. return elem;
  10153. }
  10154. jQuery.extend( {
  10155. htmlPrefilter: function( html ) {
  10156. return html;
  10157. },
  10158. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  10159. var i, l, srcElements, destElements,
  10160. clone = elem.cloneNode( true ),
  10161. inPage = isAttached( elem );
  10162. // Fix IE cloning issues
  10163. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  10164. !jQuery.isXMLDoc( elem ) ) {
  10165. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  10166. destElements = getAll( clone );
  10167. srcElements = getAll( elem );
  10168. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  10169. fixInput( srcElements[ i ], destElements[ i ] );
  10170. }
  10171. }
  10172. // Copy the events from the original to the clone
  10173. if ( dataAndEvents ) {
  10174. if ( deepDataAndEvents ) {
  10175. srcElements = srcElements || getAll( elem );
  10176. destElements = destElements || getAll( clone );
  10177. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  10178. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  10179. }
  10180. } else {
  10181. cloneCopyEvent( elem, clone );
  10182. }
  10183. }
  10184. // Preserve script evaluation history
  10185. destElements = getAll( clone, "script" );
  10186. if ( destElements.length > 0 ) {
  10187. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  10188. }
  10189. // Return the cloned set
  10190. return clone;
  10191. },
  10192. cleanData: function( elems ) {
  10193. var data, elem, type,
  10194. special = jQuery.event.special,
  10195. i = 0;
  10196. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  10197. if ( acceptData( elem ) ) {
  10198. if ( ( data = elem[ dataPriv.expando ] ) ) {
  10199. if ( data.events ) {
  10200. for ( type in data.events ) {
  10201. if ( special[ type ] ) {
  10202. jQuery.event.remove( elem, type );
  10203. // This is a shortcut to avoid jQuery.event.remove's overhead
  10204. } else {
  10205. jQuery.removeEvent( elem, type, data.handle );
  10206. }
  10207. }
  10208. }
  10209. // Support: Chrome <=35 - 45+
  10210. // Assign undefined instead of using delete, see Data#remove
  10211. elem[ dataPriv.expando ] = undefined;
  10212. }
  10213. if ( elem[ dataUser.expando ] ) {
  10214. // Support: Chrome <=35 - 45+
  10215. // Assign undefined instead of using delete, see Data#remove
  10216. elem[ dataUser.expando ] = undefined;
  10217. }
  10218. }
  10219. }
  10220. }
  10221. } );
  10222. jQuery.fn.extend( {
  10223. detach: function( selector ) {
  10224. return remove( this, selector, true );
  10225. },
  10226. remove: function( selector ) {
  10227. return remove( this, selector );
  10228. },
  10229. text: function( value ) {
  10230. return access( this, function( value ) {
  10231. return value === undefined ?
  10232. jQuery.text( this ) :
  10233. this.empty().each( function() {
  10234. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  10235. this.textContent = value;
  10236. }
  10237. } );
  10238. }, null, value, arguments.length );
  10239. },
  10240. append: function() {
  10241. return domManip( this, arguments, function( elem ) {
  10242. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  10243. var target = manipulationTarget( this, elem );
  10244. target.appendChild( elem );
  10245. }
  10246. } );
  10247. },
  10248. prepend: function() {
  10249. return domManip( this, arguments, function( elem ) {
  10250. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  10251. var target = manipulationTarget( this, elem );
  10252. target.insertBefore( elem, target.firstChild );
  10253. }
  10254. } );
  10255. },
  10256. before: function() {
  10257. return domManip( this, arguments, function( elem ) {
  10258. if ( this.parentNode ) {
  10259. this.parentNode.insertBefore( elem, this );
  10260. }
  10261. } );
  10262. },
  10263. after: function() {
  10264. return domManip( this, arguments, function( elem ) {
  10265. if ( this.parentNode ) {
  10266. this.parentNode.insertBefore( elem, this.nextSibling );
  10267. }
  10268. } );
  10269. },
  10270. empty: function() {
  10271. var elem,
  10272. i = 0;
  10273. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  10274. if ( elem.nodeType === 1 ) {
  10275. // Prevent memory leaks
  10276. jQuery.cleanData( getAll( elem, false ) );
  10277. // Remove any remaining nodes
  10278. elem.textContent = "";
  10279. }
  10280. }
  10281. return this;
  10282. },
  10283. clone: function( dataAndEvents, deepDataAndEvents ) {
  10284. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  10285. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  10286. return this.map( function() {
  10287. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  10288. } );
  10289. },
  10290. html: function( value ) {
  10291. return access( this, function( value ) {
  10292. var elem = this[ 0 ] || {},
  10293. i = 0,
  10294. l = this.length;
  10295. if ( value === undefined && elem.nodeType === 1 ) {
  10296. return elem.innerHTML;
  10297. }
  10298. // See if we can take a shortcut and just use innerHTML
  10299. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  10300. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  10301. value = jQuery.htmlPrefilter( value );
  10302. try {
  10303. for ( ; i < l; i++ ) {
  10304. elem = this[ i ] || {};
  10305. // Remove element nodes and prevent memory leaks
  10306. if ( elem.nodeType === 1 ) {
  10307. jQuery.cleanData( getAll( elem, false ) );
  10308. elem.innerHTML = value;
  10309. }
  10310. }
  10311. elem = 0;
  10312. // If using innerHTML throws an exception, use the fallback method
  10313. } catch ( e ) {}
  10314. }
  10315. if ( elem ) {
  10316. this.empty().append( value );
  10317. }
  10318. }, null, value, arguments.length );
  10319. },
  10320. replaceWith: function() {
  10321. var ignored = [];
  10322. // Make the changes, replacing each non-ignored context element with the new content
  10323. return domManip( this, arguments, function( elem ) {
  10324. var parent = this.parentNode;
  10325. if ( jQuery.inArray( this, ignored ) < 0 ) {
  10326. jQuery.cleanData( getAll( this ) );
  10327. if ( parent ) {
  10328. parent.replaceChild( elem, this );
  10329. }
  10330. }
  10331. // Force callback invocation
  10332. }, ignored );
  10333. }
  10334. } );
  10335. jQuery.each( {
  10336. appendTo: "append",
  10337. prependTo: "prepend",
  10338. insertBefore: "before",
  10339. insertAfter: "after",
  10340. replaceAll: "replaceWith"
  10341. }, function( name, original ) {
  10342. jQuery.fn[ name ] = function( selector ) {
  10343. var elems,
  10344. ret = [],
  10345. insert = jQuery( selector ),
  10346. last = insert.length - 1,
  10347. i = 0;
  10348. for ( ; i <= last; i++ ) {
  10349. elems = i === last ? this : this.clone( true );
  10350. jQuery( insert[ i ] )[ original ]( elems );
  10351. // Support: Android <=4.0 only, PhantomJS 1 only
  10352. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  10353. push.apply( ret, elems.get() );
  10354. }
  10355. return this.pushStack( ret );
  10356. };
  10357. } );
  10358. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  10359. var getStyles = function( elem ) {
  10360. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  10361. // IE throws on elements created in popups
  10362. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  10363. var view = elem.ownerDocument.defaultView;
  10364. if ( !view || !view.opener ) {
  10365. view = window;
  10366. }
  10367. return view.getComputedStyle( elem );
  10368. };
  10369. var swap = function( elem, options, callback ) {
  10370. var ret, name,
  10371. old = {};
  10372. // Remember the old values, and insert the new ones
  10373. for ( name in options ) {
  10374. old[ name ] = elem.style[ name ];
  10375. elem.style[ name ] = options[ name ];
  10376. }
  10377. ret = callback.call( elem );
  10378. // Revert the old values
  10379. for ( name in options ) {
  10380. elem.style[ name ] = old[ name ];
  10381. }
  10382. return ret;
  10383. };
  10384. var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
  10385. ( function() {
  10386. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  10387. // so they're executed at the same time to save the second computation.
  10388. function computeStyleTests() {
  10389. // This is a singleton, we need to execute it only once
  10390. if ( !div ) {
  10391. return;
  10392. }
  10393. container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
  10394. "margin-top:1px;padding:0;border:0";
  10395. div.style.cssText =
  10396. "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
  10397. "margin:auto;border:1px;padding:1px;" +
  10398. "width:60%;top:1%";
  10399. documentElement.appendChild( container ).appendChild( div );
  10400. var divStyle = window.getComputedStyle( div );
  10401. pixelPositionVal = divStyle.top !== "1%";
  10402. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  10403. reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
  10404. // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
  10405. // Some styles come back with percentage values, even though they shouldn't
  10406. div.style.right = "60%";
  10407. pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
  10408. // Support: IE 9 - 11 only
  10409. // Detect misreporting of content dimensions for box-sizing:border-box elements
  10410. boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
  10411. // Support: IE 9 only
  10412. // Detect overflow:scroll screwiness (gh-3699)
  10413. // Support: Chrome <=64
  10414. // Don't get tricked when zoom affects offsetWidth (gh-4029)
  10415. div.style.position = "absolute";
  10416. scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
  10417. documentElement.removeChild( container );
  10418. // Nullify the div so it wouldn't be stored in the memory and
  10419. // it will also be a sign that checks already performed
  10420. div = null;
  10421. }
  10422. function roundPixelMeasures( measure ) {
  10423. return Math.round( parseFloat( measure ) );
  10424. }
  10425. var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
  10426. reliableTrDimensionsVal, reliableMarginLeftVal,
  10427. container = document.createElement( "div" ),
  10428. div = document.createElement( "div" );
  10429. // Finish early in limited (non-browser) environments
  10430. if ( !div.style ) {
  10431. return;
  10432. }
  10433. // Support: IE <=9 - 11 only
  10434. // Style of cloned element affects source element cloned (#8908)
  10435. div.style.backgroundClip = "content-box";
  10436. div.cloneNode( true ).style.backgroundClip = "";
  10437. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  10438. jQuery.extend( support, {
  10439. boxSizingReliable: function() {
  10440. computeStyleTests();
  10441. return boxSizingReliableVal;
  10442. },
  10443. pixelBoxStyles: function() {
  10444. computeStyleTests();
  10445. return pixelBoxStylesVal;
  10446. },
  10447. pixelPosition: function() {
  10448. computeStyleTests();
  10449. return pixelPositionVal;
  10450. },
  10451. reliableMarginLeft: function() {
  10452. computeStyleTests();
  10453. return reliableMarginLeftVal;
  10454. },
  10455. scrollboxSize: function() {
  10456. computeStyleTests();
  10457. return scrollboxSizeVal;
  10458. },
  10459. // Support: IE 9 - 11+, Edge 15 - 18+
  10460. // IE/Edge misreport `getComputedStyle` of table rows with width/height
  10461. // set in CSS while `offset*` properties report correct values.
  10462. // Behavior in IE 9 is more subtle than in newer versions & it passes
  10463. // some versions of this test; make sure not to make it pass there!
  10464. reliableTrDimensions: function() {
  10465. var table, tr, trChild, trStyle;
  10466. if ( reliableTrDimensionsVal == null ) {
  10467. table = document.createElement( "table" );
  10468. tr = document.createElement( "tr" );
  10469. trChild = document.createElement( "div" );
  10470. table.style.cssText = "position:absolute;left:-11111px";
  10471. tr.style.height = "1px";
  10472. trChild.style.height = "9px";
  10473. documentElement
  10474. .appendChild( table )
  10475. .appendChild( tr )
  10476. .appendChild( trChild );
  10477. trStyle = window.getComputedStyle( tr );
  10478. reliableTrDimensionsVal = parseInt( trStyle.height ) > 3;
  10479. documentElement.removeChild( table );
  10480. }
  10481. return reliableTrDimensionsVal;
  10482. }
  10483. } );
  10484. } )();
  10485. function curCSS( elem, name, computed ) {
  10486. var width, minWidth, maxWidth, ret,
  10487. // Support: Firefox 51+
  10488. // Retrieving style before computed somehow
  10489. // fixes an issue with getting wrong values
  10490. // on detached elements
  10491. style = elem.style;
  10492. computed = computed || getStyles( elem );
  10493. // getPropertyValue is needed for:
  10494. // .css('filter') (IE 9 only, #12537)
  10495. // .css('--customProperty) (#3144)
  10496. if ( computed ) {
  10497. ret = computed.getPropertyValue( name ) || computed[ name ];
  10498. if ( ret === "" && !isAttached( elem ) ) {
  10499. ret = jQuery.style( elem, name );
  10500. }
  10501. // A tribute to the "awesome hack by Dean Edwards"
  10502. // Android Browser returns percentage for some values,
  10503. // but width seems to be reliably pixels.
  10504. // This is against the CSSOM draft spec:
  10505. // https://drafts.csswg.org/cssom/#resolved-values
  10506. if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
  10507. // Remember the original values
  10508. width = style.width;
  10509. minWidth = style.minWidth;
  10510. maxWidth = style.maxWidth;
  10511. // Put in the new values to get a computed value out
  10512. style.minWidth = style.maxWidth = style.width = ret;
  10513. ret = computed.width;
  10514. // Revert the changed values
  10515. style.width = width;
  10516. style.minWidth = minWidth;
  10517. style.maxWidth = maxWidth;
  10518. }
  10519. }
  10520. return ret !== undefined ?
  10521. // Support: IE <=9 - 11 only
  10522. // IE returns zIndex value as an integer.
  10523. ret + "" :
  10524. ret;
  10525. }
  10526. function addGetHookIf( conditionFn, hookFn ) {
  10527. // Define the hook, we'll check on the first run if it's really needed.
  10528. return {
  10529. get: function() {
  10530. if ( conditionFn() ) {
  10531. // Hook not needed (or it's not possible to use it due
  10532. // to missing dependency), remove it.
  10533. delete this.get;
  10534. return;
  10535. }
  10536. // Hook needed; redefine it so that the support test is not executed again.
  10537. return ( this.get = hookFn ).apply( this, arguments );
  10538. }
  10539. };
  10540. }
  10541. var cssPrefixes = [ "Webkit", "Moz", "ms" ],
  10542. emptyStyle = document.createElement( "div" ).style,
  10543. vendorProps = {};
  10544. // Return a vendor-prefixed property or undefined
  10545. function vendorPropName( name ) {
  10546. // Check for vendor prefixed names
  10547. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  10548. i = cssPrefixes.length;
  10549. while ( i-- ) {
  10550. name = cssPrefixes[ i ] + capName;
  10551. if ( name in emptyStyle ) {
  10552. return name;
  10553. }
  10554. }
  10555. }
  10556. // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
  10557. function finalPropName( name ) {
  10558. var final = jQuery.cssProps[ name ] || vendorProps[ name ];
  10559. if ( final ) {
  10560. return final;
  10561. }
  10562. if ( name in emptyStyle ) {
  10563. return name;
  10564. }
  10565. return vendorProps[ name ] = vendorPropName( name ) || name;
  10566. }
  10567. var
  10568. // Swappable if display is none or starts with table
  10569. // except "table", "table-cell", or "table-caption"
  10570. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  10571. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  10572. rcustomProp = /^--/,
  10573. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  10574. cssNormalTransform = {
  10575. letterSpacing: "0",
  10576. fontWeight: "400"
  10577. };
  10578. function setPositiveNumber( _elem, value, subtract ) {
  10579. // Any relative (+/-) values have already been
  10580. // normalized at this point
  10581. var matches = rcssNum.exec( value );
  10582. return matches ?
  10583. // Guard against undefined "subtract", e.g., when used as in cssHooks
  10584. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  10585. value;
  10586. }
  10587. function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
  10588. var i = dimension === "width" ? 1 : 0,
  10589. extra = 0,
  10590. delta = 0;
  10591. // Adjustment may not be necessary
  10592. if ( box === ( isBorderBox ? "border" : "content" ) ) {
  10593. return 0;
  10594. }
  10595. for ( ; i < 4; i += 2 ) {
  10596. // Both box models exclude margin
  10597. if ( box === "margin" ) {
  10598. delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
  10599. }
  10600. // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
  10601. if ( !isBorderBox ) {
  10602. // Add padding
  10603. delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  10604. // For "border" or "margin", add border
  10605. if ( box !== "padding" ) {
  10606. delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  10607. // But still keep track of it otherwise
  10608. } else {
  10609. extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  10610. }
  10611. // If we get here with a border-box (content + padding + border), we're seeking "content" or
  10612. // "padding" or "margin"
  10613. } else {
  10614. // For "content", subtract padding
  10615. if ( box === "content" ) {
  10616. delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  10617. }
  10618. // For "content" or "padding", subtract border
  10619. if ( box !== "margin" ) {
  10620. delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  10621. }
  10622. }
  10623. }
  10624. // Account for positive content-box scroll gutter when requested by providing computedVal
  10625. if ( !isBorderBox && computedVal >= 0 ) {
  10626. // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
  10627. // Assuming integer scroll gutter, subtract the rest and round down
  10628. delta += Math.max( 0, Math.ceil(
  10629. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  10630. computedVal -
  10631. delta -
  10632. extra -
  10633. 0.5
  10634. // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
  10635. // Use an explicit zero to avoid NaN (gh-3964)
  10636. ) ) || 0;
  10637. }
  10638. return delta;
  10639. }
  10640. function getWidthOrHeight( elem, dimension, extra ) {
  10641. // Start with computed style
  10642. var styles = getStyles( elem ),
  10643. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
  10644. // Fake content-box until we know it's needed to know the true value.
  10645. boxSizingNeeded = !support.boxSizingReliable() || extra,
  10646. isBorderBox = boxSizingNeeded &&
  10647. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  10648. valueIsBorderBox = isBorderBox,
  10649. val = curCSS( elem, dimension, styles ),
  10650. offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
  10651. // Support: Firefox <=54
  10652. // Return a confounding non-pixel value or feign ignorance, as appropriate.
  10653. if ( rnumnonpx.test( val ) ) {
  10654. if ( !extra ) {
  10655. return val;
  10656. }
  10657. val = "auto";
  10658. }
  10659. // Support: IE 9 - 11 only
  10660. // Use offsetWidth/offsetHeight for when box sizing is unreliable.
  10661. // In those cases, the computed value can be trusted to be border-box.
  10662. if ( ( !support.boxSizingReliable() && isBorderBox ||
  10663. // Support: IE 10 - 11+, Edge 15 - 18+
  10664. // IE/Edge misreport `getComputedStyle` of table rows with width/height
  10665. // set in CSS while `offset*` properties report correct values.
  10666. // Interestingly, in some cases IE 9 doesn't suffer from this issue.
  10667. !support.reliableTrDimensions() && nodeName( elem, "tr" ) ||
  10668. // Fall back to offsetWidth/offsetHeight when value is "auto"
  10669. // This happens for inline elements with no explicit setting (gh-3571)
  10670. val === "auto" ||
  10671. // Support: Android <=4.1 - 4.3 only
  10672. // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
  10673. !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
  10674. // Make sure the element is visible & connected
  10675. elem.getClientRects().length ) {
  10676. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  10677. // Where available, offsetWidth/offsetHeight approximate border box dimensions.
  10678. // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
  10679. // retrieved value as a content box dimension.
  10680. valueIsBorderBox = offsetProp in elem;
  10681. if ( valueIsBorderBox ) {
  10682. val = elem[ offsetProp ];
  10683. }
  10684. }
  10685. // Normalize "" and auto
  10686. val = parseFloat( val ) || 0;
  10687. // Adjust for the element's box model
  10688. return ( val +
  10689. boxModelAdjustment(
  10690. elem,
  10691. dimension,
  10692. extra || ( isBorderBox ? "border" : "content" ),
  10693. valueIsBorderBox,
  10694. styles,
  10695. // Provide the current computed size to request scroll gutter calculation (gh-3589)
  10696. val
  10697. )
  10698. ) + "px";
  10699. }
  10700. jQuery.extend( {
  10701. // Add in style property hooks for overriding the default
  10702. // behavior of getting and setting a style property
  10703. cssHooks: {
  10704. opacity: {
  10705. get: function( elem, computed ) {
  10706. if ( computed ) {
  10707. // We should always get a number back from opacity
  10708. var ret = curCSS( elem, "opacity" );
  10709. return ret === "" ? "1" : ret;
  10710. }
  10711. }
  10712. }
  10713. },
  10714. // Don't automatically add "px" to these possibly-unitless properties
  10715. cssNumber: {
  10716. "animationIterationCount": true,
  10717. "columnCount": true,
  10718. "fillOpacity": true,
  10719. "flexGrow": true,
  10720. "flexShrink": true,
  10721. "fontWeight": true,
  10722. "gridArea": true,
  10723. "gridColumn": true,
  10724. "gridColumnEnd": true,
  10725. "gridColumnStart": true,
  10726. "gridRow": true,
  10727. "gridRowEnd": true,
  10728. "gridRowStart": true,
  10729. "lineHeight": true,
  10730. "opacity": true,
  10731. "order": true,
  10732. "orphans": true,
  10733. "widows": true,
  10734. "zIndex": true,
  10735. "zoom": true
  10736. },
  10737. // Add in properties whose names you wish to fix before
  10738. // setting or getting the value
  10739. cssProps: {},
  10740. // Get and set the style property on a DOM Node
  10741. style: function( elem, name, value, extra ) {
  10742. // Don't set styles on text and comment nodes
  10743. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  10744. return;
  10745. }
  10746. // Make sure that we're working with the right name
  10747. var ret, type, hooks,
  10748. origName = camelCase( name ),
  10749. isCustomProp = rcustomProp.test( name ),
  10750. style = elem.style;
  10751. // Make sure that we're working with the right name. We don't
  10752. // want to query the value if it is a CSS custom property
  10753. // since they are user-defined.
  10754. if ( !isCustomProp ) {
  10755. name = finalPropName( origName );
  10756. }
  10757. // Gets hook for the prefixed version, then unprefixed version
  10758. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  10759. // Check if we're setting a value
  10760. if ( value !== undefined ) {
  10761. type = typeof value;
  10762. // Convert "+=" or "-=" to relative numbers (#7345)
  10763. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  10764. value = adjustCSS( elem, name, ret );
  10765. // Fixes bug #9237
  10766. type = "number";
  10767. }
  10768. // Make sure that null and NaN values aren't set (#7116)
  10769. if ( value == null || value !== value ) {
  10770. return;
  10771. }
  10772. // If a number was passed in, add the unit (except for certain CSS properties)
  10773. // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
  10774. // "px" to a few hardcoded values.
  10775. if ( type === "number" && !isCustomProp ) {
  10776. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  10777. }
  10778. // background-* props affect original clone's values
  10779. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  10780. style[ name ] = "inherit";
  10781. }
  10782. // If a hook was provided, use that value, otherwise just set the specified value
  10783. if ( !hooks || !( "set" in hooks ) ||
  10784. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  10785. if ( isCustomProp ) {
  10786. style.setProperty( name, value );
  10787. } else {
  10788. style[ name ] = value;
  10789. }
  10790. }
  10791. } else {
  10792. // If a hook was provided get the non-computed value from there
  10793. if ( hooks && "get" in hooks &&
  10794. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  10795. return ret;
  10796. }
  10797. // Otherwise just get the value from the style object
  10798. return style[ name ];
  10799. }
  10800. },
  10801. css: function( elem, name, extra, styles ) {
  10802. var val, num, hooks,
  10803. origName = camelCase( name ),
  10804. isCustomProp = rcustomProp.test( name );
  10805. // Make sure that we're working with the right name. We don't
  10806. // want to modify the value if it is a CSS custom property
  10807. // since they are user-defined.
  10808. if ( !isCustomProp ) {
  10809. name = finalPropName( origName );
  10810. }
  10811. // Try prefixed name followed by the unprefixed name
  10812. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  10813. // If a hook was provided get the computed value from there
  10814. if ( hooks && "get" in hooks ) {
  10815. val = hooks.get( elem, true, extra );
  10816. }
  10817. // Otherwise, if a way to get the computed value exists, use that
  10818. if ( val === undefined ) {
  10819. val = curCSS( elem, name, styles );
  10820. }
  10821. // Convert "normal" to computed value
  10822. if ( val === "normal" && name in cssNormalTransform ) {
  10823. val = cssNormalTransform[ name ];
  10824. }
  10825. // Make numeric if forced or a qualifier was provided and val looks numeric
  10826. if ( extra === "" || extra ) {
  10827. num = parseFloat( val );
  10828. return extra === true || isFinite( num ) ? num || 0 : val;
  10829. }
  10830. return val;
  10831. }
  10832. } );
  10833. jQuery.each( [ "height", "width" ], function( _i, dimension ) {
  10834. jQuery.cssHooks[ dimension ] = {
  10835. get: function( elem, computed, extra ) {
  10836. if ( computed ) {
  10837. // Certain elements can have dimension info if we invisibly show them
  10838. // but it must have a current display style that would benefit
  10839. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  10840. // Support: Safari 8+
  10841. // Table columns in Safari have non-zero offsetWidth & zero
  10842. // getBoundingClientRect().width unless display is changed.
  10843. // Support: IE <=11 only
  10844. // Running getBoundingClientRect on a disconnected node
  10845. // in IE throws an error.
  10846. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  10847. swap( elem, cssShow, function() {
  10848. return getWidthOrHeight( elem, dimension, extra );
  10849. } ) :
  10850. getWidthOrHeight( elem, dimension, extra );
  10851. }
  10852. },
  10853. set: function( elem, value, extra ) {
  10854. var matches,
  10855. styles = getStyles( elem ),
  10856. // Only read styles.position if the test has a chance to fail
  10857. // to avoid forcing a reflow.
  10858. scrollboxSizeBuggy = !support.scrollboxSize() &&
  10859. styles.position === "absolute",
  10860. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
  10861. boxSizingNeeded = scrollboxSizeBuggy || extra,
  10862. isBorderBox = boxSizingNeeded &&
  10863. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  10864. subtract = extra ?
  10865. boxModelAdjustment(
  10866. elem,
  10867. dimension,
  10868. extra,
  10869. isBorderBox,
  10870. styles
  10871. ) :
  10872. 0;
  10873. // Account for unreliable border-box dimensions by comparing offset* to computed and
  10874. // faking a content-box to get border and padding (gh-3699)
  10875. if ( isBorderBox && scrollboxSizeBuggy ) {
  10876. subtract -= Math.ceil(
  10877. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  10878. parseFloat( styles[ dimension ] ) -
  10879. boxModelAdjustment( elem, dimension, "border", false, styles ) -
  10880. 0.5
  10881. );
  10882. }
  10883. // Convert to pixels if value adjustment is needed
  10884. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  10885. ( matches[ 3 ] || "px" ) !== "px" ) {
  10886. elem.style[ dimension ] = value;
  10887. value = jQuery.css( elem, dimension );
  10888. }
  10889. return setPositiveNumber( elem, value, subtract );
  10890. }
  10891. };
  10892. } );
  10893. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  10894. function( elem, computed ) {
  10895. if ( computed ) {
  10896. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  10897. elem.getBoundingClientRect().left -
  10898. swap( elem, { marginLeft: 0 }, function() {
  10899. return elem.getBoundingClientRect().left;
  10900. } )
  10901. ) + "px";
  10902. }
  10903. }
  10904. );
  10905. // These hooks are used by animate to expand properties
  10906. jQuery.each( {
  10907. margin: "",
  10908. padding: "",
  10909. border: "Width"
  10910. }, function( prefix, suffix ) {
  10911. jQuery.cssHooks[ prefix + suffix ] = {
  10912. expand: function( value ) {
  10913. var i = 0,
  10914. expanded = {},
  10915. // Assumes a single number if not a string
  10916. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  10917. for ( ; i < 4; i++ ) {
  10918. expanded[ prefix + cssExpand[ i ] + suffix ] =
  10919. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  10920. }
  10921. return expanded;
  10922. }
  10923. };
  10924. if ( prefix !== "margin" ) {
  10925. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  10926. }
  10927. } );
  10928. jQuery.fn.extend( {
  10929. css: function( name, value ) {
  10930. return access( this, function( elem, name, value ) {
  10931. var styles, len,
  10932. map = {},
  10933. i = 0;
  10934. if ( Array.isArray( name ) ) {
  10935. styles = getStyles( elem );
  10936. len = name.length;
  10937. for ( ; i < len; i++ ) {
  10938. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  10939. }
  10940. return map;
  10941. }
  10942. return value !== undefined ?
  10943. jQuery.style( elem, name, value ) :
  10944. jQuery.css( elem, name );
  10945. }, name, value, arguments.length > 1 );
  10946. }
  10947. } );
  10948. function Tween( elem, options, prop, end, easing ) {
  10949. return new Tween.prototype.init( elem, options, prop, end, easing );
  10950. }
  10951. jQuery.Tween = Tween;
  10952. Tween.prototype = {
  10953. constructor: Tween,
  10954. init: function( elem, options, prop, end, easing, unit ) {
  10955. this.elem = elem;
  10956. this.prop = prop;
  10957. this.easing = easing || jQuery.easing._default;
  10958. this.options = options;
  10959. this.start = this.now = this.cur();
  10960. this.end = end;
  10961. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  10962. },
  10963. cur: function() {
  10964. var hooks = Tween.propHooks[ this.prop ];
  10965. return hooks && hooks.get ?
  10966. hooks.get( this ) :
  10967. Tween.propHooks._default.get( this );
  10968. },
  10969. run: function( percent ) {
  10970. var eased,
  10971. hooks = Tween.propHooks[ this.prop ];
  10972. if ( this.options.duration ) {
  10973. this.pos = eased = jQuery.easing[ this.easing ](
  10974. percent, this.options.duration * percent, 0, 1, this.options.duration
  10975. );
  10976. } else {
  10977. this.pos = eased = percent;
  10978. }
  10979. this.now = ( this.end - this.start ) * eased + this.start;
  10980. if ( this.options.step ) {
  10981. this.options.step.call( this.elem, this.now, this );
  10982. }
  10983. if ( hooks && hooks.set ) {
  10984. hooks.set( this );
  10985. } else {
  10986. Tween.propHooks._default.set( this );
  10987. }
  10988. return this;
  10989. }
  10990. };
  10991. Tween.prototype.init.prototype = Tween.prototype;
  10992. Tween.propHooks = {
  10993. _default: {
  10994. get: function( tween ) {
  10995. var result;
  10996. // Use a property on the element directly when it is not a DOM element,
  10997. // or when there is no matching style property that exists.
  10998. if ( tween.elem.nodeType !== 1 ||
  10999. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  11000. return tween.elem[ tween.prop ];
  11001. }
  11002. // Passing an empty string as a 3rd parameter to .css will automatically
  11003. // attempt a parseFloat and fallback to a string if the parse fails.
  11004. // Simple values such as "10px" are parsed to Float;
  11005. // complex values such as "rotate(1rad)" are returned as-is.
  11006. result = jQuery.css( tween.elem, tween.prop, "" );
  11007. // Empty strings, null, undefined and "auto" are converted to 0.
  11008. return !result || result === "auto" ? 0 : result;
  11009. },
  11010. set: function( tween ) {
  11011. // Use step hook for back compat.
  11012. // Use cssHook if its there.
  11013. // Use .style if available and use plain properties where available.
  11014. if ( jQuery.fx.step[ tween.prop ] ) {
  11015. jQuery.fx.step[ tween.prop ]( tween );
  11016. } else if ( tween.elem.nodeType === 1 && (
  11017. jQuery.cssHooks[ tween.prop ] ||
  11018. tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
  11019. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  11020. } else {
  11021. tween.elem[ tween.prop ] = tween.now;
  11022. }
  11023. }
  11024. }
  11025. };
  11026. // Support: IE <=9 only
  11027. // Panic based approach to setting things on disconnected nodes
  11028. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  11029. set: function( tween ) {
  11030. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  11031. tween.elem[ tween.prop ] = tween.now;
  11032. }
  11033. }
  11034. };
  11035. jQuery.easing = {
  11036. linear: function( p ) {
  11037. return p;
  11038. },
  11039. swing: function( p ) {
  11040. return 0.5 - Math.cos( p * Math.PI ) / 2;
  11041. },
  11042. _default: "swing"
  11043. };
  11044. jQuery.fx = Tween.prototype.init;
  11045. // Back compat <1.8 extension point
  11046. jQuery.fx.step = {};
  11047. var
  11048. fxNow, inProgress,
  11049. rfxtypes = /^(?:toggle|show|hide)$/,
  11050. rrun = /queueHooks$/;
  11051. function schedule() {
  11052. if ( inProgress ) {
  11053. if ( document.hidden === false && window.requestAnimationFrame ) {
  11054. window.requestAnimationFrame( schedule );
  11055. } else {
  11056. window.setTimeout( schedule, jQuery.fx.interval );
  11057. }
  11058. jQuery.fx.tick();
  11059. }
  11060. }
  11061. // Animations created synchronously will run synchronously
  11062. function createFxNow() {
  11063. window.setTimeout( function() {
  11064. fxNow = undefined;
  11065. } );
  11066. return ( fxNow = Date.now() );
  11067. }
  11068. // Generate parameters to create a standard animation
  11069. function genFx( type, includeWidth ) {
  11070. var which,
  11071. i = 0,
  11072. attrs = { height: type };
  11073. // If we include width, step value is 1 to do all cssExpand values,
  11074. // otherwise step value is 2 to skip over Left and Right
  11075. includeWidth = includeWidth ? 1 : 0;
  11076. for ( ; i < 4; i += 2 - includeWidth ) {
  11077. which = cssExpand[ i ];
  11078. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  11079. }
  11080. if ( includeWidth ) {
  11081. attrs.opacity = attrs.width = type;
  11082. }
  11083. return attrs;
  11084. }
  11085. function createTween( value, prop, animation ) {
  11086. var tween,
  11087. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  11088. index = 0,
  11089. length = collection.length;
  11090. for ( ; index < length; index++ ) {
  11091. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  11092. // We're done with this property
  11093. return tween;
  11094. }
  11095. }
  11096. }
  11097. function defaultPrefilter( elem, props, opts ) {
  11098. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  11099. isBox = "width" in props || "height" in props,
  11100. anim = this,
  11101. orig = {},
  11102. style = elem.style,
  11103. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  11104. dataShow = dataPriv.get( elem, "fxshow" );
  11105. // Queue-skipping animations hijack the fx hooks
  11106. if ( !opts.queue ) {
  11107. hooks = jQuery._queueHooks( elem, "fx" );
  11108. if ( hooks.unqueued == null ) {
  11109. hooks.unqueued = 0;
  11110. oldfire = hooks.empty.fire;
  11111. hooks.empty.fire = function() {
  11112. if ( !hooks.unqueued ) {
  11113. oldfire();
  11114. }
  11115. };
  11116. }
  11117. hooks.unqueued++;
  11118. anim.always( function() {
  11119. // Ensure the complete handler is called before this completes
  11120. anim.always( function() {
  11121. hooks.unqueued--;
  11122. if ( !jQuery.queue( elem, "fx" ).length ) {
  11123. hooks.empty.fire();
  11124. }
  11125. } );
  11126. } );
  11127. }
  11128. // Detect show/hide animations
  11129. for ( prop in props ) {
  11130. value = props[ prop ];
  11131. if ( rfxtypes.test( value ) ) {
  11132. delete props[ prop ];
  11133. toggle = toggle || value === "toggle";
  11134. if ( value === ( hidden ? "hide" : "show" ) ) {
  11135. // Pretend to be hidden if this is a "show" and
  11136. // there is still data from a stopped show/hide
  11137. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  11138. hidden = true;
  11139. // Ignore all other no-op show/hide data
  11140. } else {
  11141. continue;
  11142. }
  11143. }
  11144. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  11145. }
  11146. }
  11147. // Bail out if this is a no-op like .hide().hide()
  11148. propTween = !jQuery.isEmptyObject( props );
  11149. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  11150. return;
  11151. }
  11152. // Restrict "overflow" and "display" styles during box animations
  11153. if ( isBox && elem.nodeType === 1 ) {
  11154. // Support: IE <=9 - 11, Edge 12 - 15
  11155. // Record all 3 overflow attributes because IE does not infer the shorthand
  11156. // from identically-valued overflowX and overflowY and Edge just mirrors
  11157. // the overflowX value there.
  11158. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  11159. // Identify a display type, preferring old show/hide data over the CSS cascade
  11160. restoreDisplay = dataShow && dataShow.display;
  11161. if ( restoreDisplay == null ) {
  11162. restoreDisplay = dataPriv.get( elem, "display" );
  11163. }
  11164. display = jQuery.css( elem, "display" );
  11165. if ( display === "none" ) {
  11166. if ( restoreDisplay ) {
  11167. display = restoreDisplay;
  11168. } else {
  11169. // Get nonempty value(s) by temporarily forcing visibility
  11170. showHide( [ elem ], true );
  11171. restoreDisplay = elem.style.display || restoreDisplay;
  11172. display = jQuery.css( elem, "display" );
  11173. showHide( [ elem ] );
  11174. }
  11175. }
  11176. // Animate inline elements as inline-block
  11177. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  11178. if ( jQuery.css( elem, "float" ) === "none" ) {
  11179. // Restore the original display value at the end of pure show/hide animations
  11180. if ( !propTween ) {
  11181. anim.done( function() {
  11182. style.display = restoreDisplay;
  11183. } );
  11184. if ( restoreDisplay == null ) {
  11185. display = style.display;
  11186. restoreDisplay = display === "none" ? "" : display;
  11187. }
  11188. }
  11189. style.display = "inline-block";
  11190. }
  11191. }
  11192. }
  11193. if ( opts.overflow ) {
  11194. style.overflow = "hidden";
  11195. anim.always( function() {
  11196. style.overflow = opts.overflow[ 0 ];
  11197. style.overflowX = opts.overflow[ 1 ];
  11198. style.overflowY = opts.overflow[ 2 ];
  11199. } );
  11200. }
  11201. // Implement show/hide animations
  11202. propTween = false;
  11203. for ( prop in orig ) {
  11204. // General show/hide setup for this element animation
  11205. if ( !propTween ) {
  11206. if ( dataShow ) {
  11207. if ( "hidden" in dataShow ) {
  11208. hidden = dataShow.hidden;
  11209. }
  11210. } else {
  11211. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  11212. }
  11213. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  11214. if ( toggle ) {
  11215. dataShow.hidden = !hidden;
  11216. }
  11217. // Show elements before animating them
  11218. if ( hidden ) {
  11219. showHide( [ elem ], true );
  11220. }
  11221. /* eslint-disable no-loop-func */
  11222. anim.done( function() {
  11223. /* eslint-enable no-loop-func */
  11224. // The final step of a "hide" animation is actually hiding the element
  11225. if ( !hidden ) {
  11226. showHide( [ elem ] );
  11227. }
  11228. dataPriv.remove( elem, "fxshow" );
  11229. for ( prop in orig ) {
  11230. jQuery.style( elem, prop, orig[ prop ] );
  11231. }
  11232. } );
  11233. }
  11234. // Per-property setup
  11235. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  11236. if ( !( prop in dataShow ) ) {
  11237. dataShow[ prop ] = propTween.start;
  11238. if ( hidden ) {
  11239. propTween.end = propTween.start;
  11240. propTween.start = 0;
  11241. }
  11242. }
  11243. }
  11244. }
  11245. function propFilter( props, specialEasing ) {
  11246. var index, name, easing, value, hooks;
  11247. // camelCase, specialEasing and expand cssHook pass
  11248. for ( index in props ) {
  11249. name = camelCase( index );
  11250. easing = specialEasing[ name ];
  11251. value = props[ index ];
  11252. if ( Array.isArray( value ) ) {
  11253. easing = value[ 1 ];
  11254. value = props[ index ] = value[ 0 ];
  11255. }
  11256. if ( index !== name ) {
  11257. props[ name ] = value;
  11258. delete props[ index ];
  11259. }
  11260. hooks = jQuery.cssHooks[ name ];
  11261. if ( hooks && "expand" in hooks ) {
  11262. value = hooks.expand( value );
  11263. delete props[ name ];
  11264. // Not quite $.extend, this won't overwrite existing keys.
  11265. // Reusing 'index' because we have the correct "name"
  11266. for ( index in value ) {
  11267. if ( !( index in props ) ) {
  11268. props[ index ] = value[ index ];
  11269. specialEasing[ index ] = easing;
  11270. }
  11271. }
  11272. } else {
  11273. specialEasing[ name ] = easing;
  11274. }
  11275. }
  11276. }
  11277. function Animation( elem, properties, options ) {
  11278. var result,
  11279. stopped,
  11280. index = 0,
  11281. length = Animation.prefilters.length,
  11282. deferred = jQuery.Deferred().always( function() {
  11283. // Don't match elem in the :animated selector
  11284. delete tick.elem;
  11285. } ),
  11286. tick = function() {
  11287. if ( stopped ) {
  11288. return false;
  11289. }
  11290. var currentTime = fxNow || createFxNow(),
  11291. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  11292. // Support: Android 2.3 only
  11293. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  11294. temp = remaining / animation.duration || 0,
  11295. percent = 1 - temp,
  11296. index = 0,
  11297. length = animation.tweens.length;
  11298. for ( ; index < length; index++ ) {
  11299. animation.tweens[ index ].run( percent );
  11300. }
  11301. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  11302. // If there's more to do, yield
  11303. if ( percent < 1 && length ) {
  11304. return remaining;
  11305. }
  11306. // If this was an empty animation, synthesize a final progress notification
  11307. if ( !length ) {
  11308. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  11309. }
  11310. // Resolve the animation and report its conclusion
  11311. deferred.resolveWith( elem, [ animation ] );
  11312. return false;
  11313. },
  11314. animation = deferred.promise( {
  11315. elem: elem,
  11316. props: jQuery.extend( {}, properties ),
  11317. opts: jQuery.extend( true, {
  11318. specialEasing: {},
  11319. easing: jQuery.easing._default
  11320. }, options ),
  11321. originalProperties: properties,
  11322. originalOptions: options,
  11323. startTime: fxNow || createFxNow(),
  11324. duration: options.duration,
  11325. tweens: [],
  11326. createTween: function( prop, end ) {
  11327. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  11328. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  11329. animation.tweens.push( tween );
  11330. return tween;
  11331. },
  11332. stop: function( gotoEnd ) {
  11333. var index = 0,
  11334. // If we are going to the end, we want to run all the tweens
  11335. // otherwise we skip this part
  11336. length = gotoEnd ? animation.tweens.length : 0;
  11337. if ( stopped ) {
  11338. return this;
  11339. }
  11340. stopped = true;
  11341. for ( ; index < length; index++ ) {
  11342. animation.tweens[ index ].run( 1 );
  11343. }
  11344. // Resolve when we played the last frame; otherwise, reject
  11345. if ( gotoEnd ) {
  11346. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  11347. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  11348. } else {
  11349. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  11350. }
  11351. return this;
  11352. }
  11353. } ),
  11354. props = animation.props;
  11355. propFilter( props, animation.opts.specialEasing );
  11356. for ( ; index < length; index++ ) {
  11357. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  11358. if ( result ) {
  11359. if ( isFunction( result.stop ) ) {
  11360. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  11361. result.stop.bind( result );
  11362. }
  11363. return result;
  11364. }
  11365. }
  11366. jQuery.map( props, createTween, animation );
  11367. if ( isFunction( animation.opts.start ) ) {
  11368. animation.opts.start.call( elem, animation );
  11369. }
  11370. // Attach callbacks from options
  11371. animation
  11372. .progress( animation.opts.progress )
  11373. .done( animation.opts.done, animation.opts.complete )
  11374. .fail( animation.opts.fail )
  11375. .always( animation.opts.always );
  11376. jQuery.fx.timer(
  11377. jQuery.extend( tick, {
  11378. elem: elem,
  11379. anim: animation,
  11380. queue: animation.opts.queue
  11381. } )
  11382. );
  11383. return animation;
  11384. }
  11385. jQuery.Animation = jQuery.extend( Animation, {
  11386. tweeners: {
  11387. "*": [ function( prop, value ) {
  11388. var tween = this.createTween( prop, value );
  11389. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  11390. return tween;
  11391. } ]
  11392. },
  11393. tweener: function( props, callback ) {
  11394. if ( isFunction( props ) ) {
  11395. callback = props;
  11396. props = [ "*" ];
  11397. } else {
  11398. props = props.match( rnothtmlwhite );
  11399. }
  11400. var prop,
  11401. index = 0,
  11402. length = props.length;
  11403. for ( ; index < length; index++ ) {
  11404. prop = props[ index ];
  11405. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  11406. Animation.tweeners[ prop ].unshift( callback );
  11407. }
  11408. },
  11409. prefilters: [ defaultPrefilter ],
  11410. prefilter: function( callback, prepend ) {
  11411. if ( prepend ) {
  11412. Animation.prefilters.unshift( callback );
  11413. } else {
  11414. Animation.prefilters.push( callback );
  11415. }
  11416. }
  11417. } );
  11418. jQuery.speed = function( speed, easing, fn ) {
  11419. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  11420. complete: fn || !fn && easing ||
  11421. isFunction( speed ) && speed,
  11422. duration: speed,
  11423. easing: fn && easing || easing && !isFunction( easing ) && easing
  11424. };
  11425. // Go to the end state if fx are off
  11426. if ( jQuery.fx.off ) {
  11427. opt.duration = 0;
  11428. } else {
  11429. if ( typeof opt.duration !== "number" ) {
  11430. if ( opt.duration in jQuery.fx.speeds ) {
  11431. opt.duration = jQuery.fx.speeds[ opt.duration ];
  11432. } else {
  11433. opt.duration = jQuery.fx.speeds._default;
  11434. }
  11435. }
  11436. }
  11437. // Normalize opt.queue - true/undefined/null -> "fx"
  11438. if ( opt.queue == null || opt.queue === true ) {
  11439. opt.queue = "fx";
  11440. }
  11441. // Queueing
  11442. opt.old = opt.complete;
  11443. opt.complete = function() {
  11444. if ( isFunction( opt.old ) ) {
  11445. opt.old.call( this );
  11446. }
  11447. if ( opt.queue ) {
  11448. jQuery.dequeue( this, opt.queue );
  11449. }
  11450. };
  11451. return opt;
  11452. };
  11453. jQuery.fn.extend( {
  11454. fadeTo: function( speed, to, easing, callback ) {
  11455. // Show any hidden elements after setting opacity to 0
  11456. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  11457. // Animate to the value specified
  11458. .end().animate( { opacity: to }, speed, easing, callback );
  11459. },
  11460. animate: function( prop, speed, easing, callback ) {
  11461. var empty = jQuery.isEmptyObject( prop ),
  11462. optall = jQuery.speed( speed, easing, callback ),
  11463. doAnimation = function() {
  11464. // Operate on a copy of prop so per-property easing won't be lost
  11465. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  11466. // Empty animations, or finishing resolves immediately
  11467. if ( empty || dataPriv.get( this, "finish" ) ) {
  11468. anim.stop( true );
  11469. }
  11470. };
  11471. doAnimation.finish = doAnimation;
  11472. return empty || optall.queue === false ?
  11473. this.each( doAnimation ) :
  11474. this.queue( optall.queue, doAnimation );
  11475. },
  11476. stop: function( type, clearQueue, gotoEnd ) {
  11477. var stopQueue = function( hooks ) {
  11478. var stop = hooks.stop;
  11479. delete hooks.stop;
  11480. stop( gotoEnd );
  11481. };
  11482. if ( typeof type !== "string" ) {
  11483. gotoEnd = clearQueue;
  11484. clearQueue = type;
  11485. type = undefined;
  11486. }
  11487. if ( clearQueue ) {
  11488. this.queue( type || "fx", [] );
  11489. }
  11490. return this.each( function() {
  11491. var dequeue = true,
  11492. index = type != null && type + "queueHooks",
  11493. timers = jQuery.timers,
  11494. data = dataPriv.get( this );
  11495. if ( index ) {
  11496. if ( data[ index ] && data[ index ].stop ) {
  11497. stopQueue( data[ index ] );
  11498. }
  11499. } else {
  11500. for ( index in data ) {
  11501. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  11502. stopQueue( data[ index ] );
  11503. }
  11504. }
  11505. }
  11506. for ( index = timers.length; index--; ) {
  11507. if ( timers[ index ].elem === this &&
  11508. ( type == null || timers[ index ].queue === type ) ) {
  11509. timers[ index ].anim.stop( gotoEnd );
  11510. dequeue = false;
  11511. timers.splice( index, 1 );
  11512. }
  11513. }
  11514. // Start the next in the queue if the last step wasn't forced.
  11515. // Timers currently will call their complete callbacks, which
  11516. // will dequeue but only if they were gotoEnd.
  11517. if ( dequeue || !gotoEnd ) {
  11518. jQuery.dequeue( this, type );
  11519. }
  11520. } );
  11521. },
  11522. finish: function( type ) {
  11523. if ( type !== false ) {
  11524. type = type || "fx";
  11525. }
  11526. return this.each( function() {
  11527. var index,
  11528. data = dataPriv.get( this ),
  11529. queue = data[ type + "queue" ],
  11530. hooks = data[ type + "queueHooks" ],
  11531. timers = jQuery.timers,
  11532. length = queue ? queue.length : 0;
  11533. // Enable finishing flag on private data
  11534. data.finish = true;
  11535. // Empty the queue first
  11536. jQuery.queue( this, type, [] );
  11537. if ( hooks && hooks.stop ) {
  11538. hooks.stop.call( this, true );
  11539. }
  11540. // Look for any active animations, and finish them
  11541. for ( index = timers.length; index--; ) {
  11542. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  11543. timers[ index ].anim.stop( true );
  11544. timers.splice( index, 1 );
  11545. }
  11546. }
  11547. // Look for any animations in the old queue and finish them
  11548. for ( index = 0; index < length; index++ ) {
  11549. if ( queue[ index ] && queue[ index ].finish ) {
  11550. queue[ index ].finish.call( this );
  11551. }
  11552. }
  11553. // Turn off finishing flag
  11554. delete data.finish;
  11555. } );
  11556. }
  11557. } );
  11558. jQuery.each( [ "toggle", "show", "hide" ], function( _i, name ) {
  11559. var cssFn = jQuery.fn[ name ];
  11560. jQuery.fn[ name ] = function( speed, easing, callback ) {
  11561. return speed == null || typeof speed === "boolean" ?
  11562. cssFn.apply( this, arguments ) :
  11563. this.animate( genFx( name, true ), speed, easing, callback );
  11564. };
  11565. } );
  11566. // Generate shortcuts for custom animations
  11567. jQuery.each( {
  11568. slideDown: genFx( "show" ),
  11569. slideUp: genFx( "hide" ),
  11570. slideToggle: genFx( "toggle" ),
  11571. fadeIn: { opacity: "show" },
  11572. fadeOut: { opacity: "hide" },
  11573. fadeToggle: { opacity: "toggle" }
  11574. }, function( name, props ) {
  11575. jQuery.fn[ name ] = function( speed, easing, callback ) {
  11576. return this.animate( props, speed, easing, callback );
  11577. };
  11578. } );
  11579. jQuery.timers = [];
  11580. jQuery.fx.tick = function() {
  11581. var timer,
  11582. i = 0,
  11583. timers = jQuery.timers;
  11584. fxNow = Date.now();
  11585. for ( ; i < timers.length; i++ ) {
  11586. timer = timers[ i ];
  11587. // Run the timer and safely remove it when done (allowing for external removal)
  11588. if ( !timer() && timers[ i ] === timer ) {
  11589. timers.splice( i--, 1 );
  11590. }
  11591. }
  11592. if ( !timers.length ) {
  11593. jQuery.fx.stop();
  11594. }
  11595. fxNow = undefined;
  11596. };
  11597. jQuery.fx.timer = function( timer ) {
  11598. jQuery.timers.push( timer );
  11599. jQuery.fx.start();
  11600. };
  11601. jQuery.fx.interval = 13;
  11602. jQuery.fx.start = function() {
  11603. if ( inProgress ) {
  11604. return;
  11605. }
  11606. inProgress = true;
  11607. schedule();
  11608. };
  11609. jQuery.fx.stop = function() {
  11610. inProgress = null;
  11611. };
  11612. jQuery.fx.speeds = {
  11613. slow: 600,
  11614. fast: 200,
  11615. // Default speed
  11616. _default: 400
  11617. };
  11618. // Based off of the plugin by Clint Helfers, with permission.
  11619. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  11620. jQuery.fn.delay = function( time, type ) {
  11621. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  11622. type = type || "fx";
  11623. return this.queue( type, function( next, hooks ) {
  11624. var timeout = window.setTimeout( next, time );
  11625. hooks.stop = function() {
  11626. window.clearTimeout( timeout );
  11627. };
  11628. } );
  11629. };
  11630. ( function() {
  11631. var input = document.createElement( "input" ),
  11632. select = document.createElement( "select" ),
  11633. opt = select.appendChild( document.createElement( "option" ) );
  11634. input.type = "checkbox";
  11635. // Support: Android <=4.3 only
  11636. // Default value for a checkbox should be "on"
  11637. support.checkOn = input.value !== "";
  11638. // Support: IE <=11 only
  11639. // Must access selectedIndex to make default options select
  11640. support.optSelected = opt.selected;
  11641. // Support: IE <=11 only
  11642. // An input loses its value after becoming a radio
  11643. input = document.createElement( "input" );
  11644. input.value = "t";
  11645. input.type = "radio";
  11646. support.radioValue = input.value === "t";
  11647. } )();
  11648. var boolHook,
  11649. attrHandle = jQuery.expr.attrHandle;
  11650. jQuery.fn.extend( {
  11651. attr: function( name, value ) {
  11652. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  11653. },
  11654. removeAttr: function( name ) {
  11655. return this.each( function() {
  11656. jQuery.removeAttr( this, name );
  11657. } );
  11658. }
  11659. } );
  11660. jQuery.extend( {
  11661. attr: function( elem, name, value ) {
  11662. var ret, hooks,
  11663. nType = elem.nodeType;
  11664. // Don't get/set attributes on text, comment and attribute nodes
  11665. if ( nType === 3 || nType === 8 || nType === 2 ) {
  11666. return;
  11667. }
  11668. // Fallback to prop when attributes are not supported
  11669. if ( typeof elem.getAttribute === "undefined" ) {
  11670. return jQuery.prop( elem, name, value );
  11671. }
  11672. // Attribute hooks are determined by the lowercase version
  11673. // Grab necessary hook if one is defined
  11674. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  11675. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  11676. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  11677. }
  11678. if ( value !== undefined ) {
  11679. if ( value === null ) {
  11680. jQuery.removeAttr( elem, name );
  11681. return;
  11682. }
  11683. if ( hooks && "set" in hooks &&
  11684. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  11685. return ret;
  11686. }
  11687. elem.setAttribute( name, value + "" );
  11688. return value;
  11689. }
  11690. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  11691. return ret;
  11692. }
  11693. ret = jQuery.find.attr( elem, name );
  11694. // Non-existent attributes return null, we normalize to undefined
  11695. return ret == null ? undefined : ret;
  11696. },
  11697. attrHooks: {
  11698. type: {
  11699. set: function( elem, value ) {
  11700. if ( !support.radioValue && value === "radio" &&
  11701. nodeName( elem, "input" ) ) {
  11702. var val = elem.value;
  11703. elem.setAttribute( "type", value );
  11704. if ( val ) {
  11705. elem.value = val;
  11706. }
  11707. return value;
  11708. }
  11709. }
  11710. }
  11711. },
  11712. removeAttr: function( elem, value ) {
  11713. var name,
  11714. i = 0,
  11715. // Attribute names can contain non-HTML whitespace characters
  11716. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  11717. attrNames = value && value.match( rnothtmlwhite );
  11718. if ( attrNames && elem.nodeType === 1 ) {
  11719. while ( ( name = attrNames[ i++ ] ) ) {
  11720. elem.removeAttribute( name );
  11721. }
  11722. }
  11723. }
  11724. } );
  11725. // Hooks for boolean attributes
  11726. boolHook = {
  11727. set: function( elem, value, name ) {
  11728. if ( value === false ) {
  11729. // Remove boolean attributes when set to false
  11730. jQuery.removeAttr( elem, name );
  11731. } else {
  11732. elem.setAttribute( name, name );
  11733. }
  11734. return name;
  11735. }
  11736. };
  11737. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( _i, name ) {
  11738. var getter = attrHandle[ name ] || jQuery.find.attr;
  11739. attrHandle[ name ] = function( elem, name, isXML ) {
  11740. var ret, handle,
  11741. lowercaseName = name.toLowerCase();
  11742. if ( !isXML ) {
  11743. // Avoid an infinite loop by temporarily removing this function from the getter
  11744. handle = attrHandle[ lowercaseName ];
  11745. attrHandle[ lowercaseName ] = ret;
  11746. ret = getter( elem, name, isXML ) != null ?
  11747. lowercaseName :
  11748. null;
  11749. attrHandle[ lowercaseName ] = handle;
  11750. }
  11751. return ret;
  11752. };
  11753. } );
  11754. var rfocusable = /^(?:input|select|textarea|button)$/i,
  11755. rclickable = /^(?:a|area)$/i;
  11756. jQuery.fn.extend( {
  11757. prop: function( name, value ) {
  11758. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  11759. },
  11760. removeProp: function( name ) {
  11761. return this.each( function() {
  11762. delete this[ jQuery.propFix[ name ] || name ];
  11763. } );
  11764. }
  11765. } );
  11766. jQuery.extend( {
  11767. prop: function( elem, name, value ) {
  11768. var ret, hooks,
  11769. nType = elem.nodeType;
  11770. // Don't get/set properties on text, comment and attribute nodes
  11771. if ( nType === 3 || nType === 8 || nType === 2 ) {
  11772. return;
  11773. }
  11774. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  11775. // Fix name and attach hooks
  11776. name = jQuery.propFix[ name ] || name;
  11777. hooks = jQuery.propHooks[ name ];
  11778. }
  11779. if ( value !== undefined ) {
  11780. if ( hooks && "set" in hooks &&
  11781. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  11782. return ret;
  11783. }
  11784. return ( elem[ name ] = value );
  11785. }
  11786. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  11787. return ret;
  11788. }
  11789. return elem[ name ];
  11790. },
  11791. propHooks: {
  11792. tabIndex: {
  11793. get: function( elem ) {
  11794. // Support: IE <=9 - 11 only
  11795. // elem.tabIndex doesn't always return the
  11796. // correct value when it hasn't been explicitly set
  11797. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  11798. // Use proper attribute retrieval(#12072)
  11799. var tabindex = jQuery.find.attr( elem, "tabindex" );
  11800. if ( tabindex ) {
  11801. return parseInt( tabindex, 10 );
  11802. }
  11803. if (
  11804. rfocusable.test( elem.nodeName ) ||
  11805. rclickable.test( elem.nodeName ) &&
  11806. elem.href
  11807. ) {
  11808. return 0;
  11809. }
  11810. return -1;
  11811. }
  11812. }
  11813. },
  11814. propFix: {
  11815. "for": "htmlFor",
  11816. "class": "className"
  11817. }
  11818. } );
  11819. // Support: IE <=11 only
  11820. // Accessing the selectedIndex property
  11821. // forces the browser to respect setting selected
  11822. // on the option
  11823. // The getter ensures a default option is selected
  11824. // when in an optgroup
  11825. // eslint rule "no-unused-expressions" is disabled for this code
  11826. // since it considers such accessions noop
  11827. if ( !support.optSelected ) {
  11828. jQuery.propHooks.selected = {
  11829. get: function( elem ) {
  11830. /* eslint no-unused-expressions: "off" */
  11831. var parent = elem.parentNode;
  11832. if ( parent && parent.parentNode ) {
  11833. parent.parentNode.selectedIndex;
  11834. }
  11835. return null;
  11836. },
  11837. set: function( elem ) {
  11838. /* eslint no-unused-expressions: "off" */
  11839. var parent = elem.parentNode;
  11840. if ( parent ) {
  11841. parent.selectedIndex;
  11842. if ( parent.parentNode ) {
  11843. parent.parentNode.selectedIndex;
  11844. }
  11845. }
  11846. }
  11847. };
  11848. }
  11849. jQuery.each( [
  11850. "tabIndex",
  11851. "readOnly",
  11852. "maxLength",
  11853. "cellSpacing",
  11854. "cellPadding",
  11855. "rowSpan",
  11856. "colSpan",
  11857. "useMap",
  11858. "frameBorder",
  11859. "contentEditable"
  11860. ], function() {
  11861. jQuery.propFix[ this.toLowerCase() ] = this;
  11862. } );
  11863. // Strip and collapse whitespace according to HTML spec
  11864. // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
  11865. function stripAndCollapse( value ) {
  11866. var tokens = value.match( rnothtmlwhite ) || [];
  11867. return tokens.join( " " );
  11868. }
  11869. function getClass( elem ) {
  11870. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  11871. }
  11872. function classesToArray( value ) {
  11873. if ( Array.isArray( value ) ) {
  11874. return value;
  11875. }
  11876. if ( typeof value === "string" ) {
  11877. return value.match( rnothtmlwhite ) || [];
  11878. }
  11879. return [];
  11880. }
  11881. jQuery.fn.extend( {
  11882. addClass: function( value ) {
  11883. var classes, elem, cur, curValue, clazz, j, finalValue,
  11884. i = 0;
  11885. if ( isFunction( value ) ) {
  11886. return this.each( function( j ) {
  11887. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  11888. } );
  11889. }
  11890. classes = classesToArray( value );
  11891. if ( classes.length ) {
  11892. while ( ( elem = this[ i++ ] ) ) {
  11893. curValue = getClass( elem );
  11894. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  11895. if ( cur ) {
  11896. j = 0;
  11897. while ( ( clazz = classes[ j++ ] ) ) {
  11898. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  11899. cur += clazz + " ";
  11900. }
  11901. }
  11902. // Only assign if different to avoid unneeded rendering.
  11903. finalValue = stripAndCollapse( cur );
  11904. if ( curValue !== finalValue ) {
  11905. elem.setAttribute( "class", finalValue );
  11906. }
  11907. }
  11908. }
  11909. }
  11910. return this;
  11911. },
  11912. removeClass: function( value ) {
  11913. var classes, elem, cur, curValue, clazz, j, finalValue,
  11914. i = 0;
  11915. if ( isFunction( value ) ) {
  11916. return this.each( function( j ) {
  11917. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  11918. } );
  11919. }
  11920. if ( !arguments.length ) {
  11921. return this.attr( "class", "" );
  11922. }
  11923. classes = classesToArray( value );
  11924. if ( classes.length ) {
  11925. while ( ( elem = this[ i++ ] ) ) {
  11926. curValue = getClass( elem );
  11927. // This expression is here for better compressibility (see addClass)
  11928. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  11929. if ( cur ) {
  11930. j = 0;
  11931. while ( ( clazz = classes[ j++ ] ) ) {
  11932. // Remove *all* instances
  11933. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  11934. cur = cur.replace( " " + clazz + " ", " " );
  11935. }
  11936. }
  11937. // Only assign if different to avoid unneeded rendering.
  11938. finalValue = stripAndCollapse( cur );
  11939. if ( curValue !== finalValue ) {
  11940. elem.setAttribute( "class", finalValue );
  11941. }
  11942. }
  11943. }
  11944. }
  11945. return this;
  11946. },
  11947. toggleClass: function( value, stateVal ) {
  11948. var type = typeof value,
  11949. isValidValue = type === "string" || Array.isArray( value );
  11950. if ( typeof stateVal === "boolean" && isValidValue ) {
  11951. return stateVal ? this.addClass( value ) : this.removeClass( value );
  11952. }
  11953. if ( isFunction( value ) ) {
  11954. return this.each( function( i ) {
  11955. jQuery( this ).toggleClass(
  11956. value.call( this, i, getClass( this ), stateVal ),
  11957. stateVal
  11958. );
  11959. } );
  11960. }
  11961. return this.each( function() {
  11962. var className, i, self, classNames;
  11963. if ( isValidValue ) {
  11964. // Toggle individual class names
  11965. i = 0;
  11966. self = jQuery( this );
  11967. classNames = classesToArray( value );
  11968. while ( ( className = classNames[ i++ ] ) ) {
  11969. // Check each className given, space separated list
  11970. if ( self.hasClass( className ) ) {
  11971. self.removeClass( className );
  11972. } else {
  11973. self.addClass( className );
  11974. }
  11975. }
  11976. // Toggle whole class name
  11977. } else if ( value === undefined || type === "boolean" ) {
  11978. className = getClass( this );
  11979. if ( className ) {
  11980. // Store className if set
  11981. dataPriv.set( this, "__className__", className );
  11982. }
  11983. // If the element has a class name or if we're passed `false`,
  11984. // then remove the whole classname (if there was one, the above saved it).
  11985. // Otherwise bring back whatever was previously saved (if anything),
  11986. // falling back to the empty string if nothing was stored.
  11987. if ( this.setAttribute ) {
  11988. this.setAttribute( "class",
  11989. className || value === false ?
  11990. "" :
  11991. dataPriv.get( this, "__className__" ) || ""
  11992. );
  11993. }
  11994. }
  11995. } );
  11996. },
  11997. hasClass: function( selector ) {
  11998. var className, elem,
  11999. i = 0;
  12000. className = " " + selector + " ";
  12001. while ( ( elem = this[ i++ ] ) ) {
  12002. if ( elem.nodeType === 1 &&
  12003. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  12004. return true;
  12005. }
  12006. }
  12007. return false;
  12008. }
  12009. } );
  12010. var rreturn = /\r/g;
  12011. jQuery.fn.extend( {
  12012. val: function( value ) {
  12013. var hooks, ret, valueIsFunction,
  12014. elem = this[ 0 ];
  12015. if ( !arguments.length ) {
  12016. if ( elem ) {
  12017. hooks = jQuery.valHooks[ elem.type ] ||
  12018. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  12019. if ( hooks &&
  12020. "get" in hooks &&
  12021. ( ret = hooks.get( elem, "value" ) ) !== undefined
  12022. ) {
  12023. return ret;
  12024. }
  12025. ret = elem.value;
  12026. // Handle most common string cases
  12027. if ( typeof ret === "string" ) {
  12028. return ret.replace( rreturn, "" );
  12029. }
  12030. // Handle cases where value is null/undef or number
  12031. return ret == null ? "" : ret;
  12032. }
  12033. return;
  12034. }
  12035. valueIsFunction = isFunction( value );
  12036. return this.each( function( i ) {
  12037. var val;
  12038. if ( this.nodeType !== 1 ) {
  12039. return;
  12040. }
  12041. if ( valueIsFunction ) {
  12042. val = value.call( this, i, jQuery( this ).val() );
  12043. } else {
  12044. val = value;
  12045. }
  12046. // Treat null/undefined as ""; convert numbers to string
  12047. if ( val == null ) {
  12048. val = "";
  12049. } else if ( typeof val === "number" ) {
  12050. val += "";
  12051. } else if ( Array.isArray( val ) ) {
  12052. val = jQuery.map( val, function( value ) {
  12053. return value == null ? "" : value + "";
  12054. } );
  12055. }
  12056. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  12057. // If set returns undefined, fall back to normal setting
  12058. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  12059. this.value = val;
  12060. }
  12061. } );
  12062. }
  12063. } );
  12064. jQuery.extend( {
  12065. valHooks: {
  12066. option: {
  12067. get: function( elem ) {
  12068. var val = jQuery.find.attr( elem, "value" );
  12069. return val != null ?
  12070. val :
  12071. // Support: IE <=10 - 11 only
  12072. // option.text throws exceptions (#14686, #14858)
  12073. // Strip and collapse whitespace
  12074. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  12075. stripAndCollapse( jQuery.text( elem ) );
  12076. }
  12077. },
  12078. select: {
  12079. get: function( elem ) {
  12080. var value, option, i,
  12081. options = elem.options,
  12082. index = elem.selectedIndex,
  12083. one = elem.type === "select-one",
  12084. values = one ? null : [],
  12085. max = one ? index + 1 : options.length;
  12086. if ( index < 0 ) {
  12087. i = max;
  12088. } else {
  12089. i = one ? index : 0;
  12090. }
  12091. // Loop through all the selected options
  12092. for ( ; i < max; i++ ) {
  12093. option = options[ i ];
  12094. // Support: IE <=9 only
  12095. // IE8-9 doesn't update selected after form reset (#2551)
  12096. if ( ( option.selected || i === index ) &&
  12097. // Don't return options that are disabled or in a disabled optgroup
  12098. !option.disabled &&
  12099. ( !option.parentNode.disabled ||
  12100. !nodeName( option.parentNode, "optgroup" ) ) ) {
  12101. // Get the specific value for the option
  12102. value = jQuery( option ).val();
  12103. // We don't need an array for one selects
  12104. if ( one ) {
  12105. return value;
  12106. }
  12107. // Multi-Selects return an array
  12108. values.push( value );
  12109. }
  12110. }
  12111. return values;
  12112. },
  12113. set: function( elem, value ) {
  12114. var optionSet, option,
  12115. options = elem.options,
  12116. values = jQuery.makeArray( value ),
  12117. i = options.length;
  12118. while ( i-- ) {
  12119. option = options[ i ];
  12120. /* eslint-disable no-cond-assign */
  12121. if ( option.selected =
  12122. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  12123. ) {
  12124. optionSet = true;
  12125. }
  12126. /* eslint-enable no-cond-assign */
  12127. }
  12128. // Force browsers to behave consistently when non-matching value is set
  12129. if ( !optionSet ) {
  12130. elem.selectedIndex = -1;
  12131. }
  12132. return values;
  12133. }
  12134. }
  12135. }
  12136. } );
  12137. // Radios and checkboxes getter/setter
  12138. jQuery.each( [ "radio", "checkbox" ], function() {
  12139. jQuery.valHooks[ this ] = {
  12140. set: function( elem, value ) {
  12141. if ( Array.isArray( value ) ) {
  12142. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  12143. }
  12144. }
  12145. };
  12146. if ( !support.checkOn ) {
  12147. jQuery.valHooks[ this ].get = function( elem ) {
  12148. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  12149. };
  12150. }
  12151. } );
  12152. // Return jQuery for attributes-only inclusion
  12153. support.focusin = "onfocusin" in window;
  12154. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  12155. stopPropagationCallback = function( e ) {
  12156. e.stopPropagation();
  12157. };
  12158. jQuery.extend( jQuery.event, {
  12159. trigger: function( event, data, elem, onlyHandlers ) {
  12160. var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
  12161. eventPath = [ elem || document ],
  12162. type = hasOwn.call( event, "type" ) ? event.type : event,
  12163. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  12164. cur = lastElement = tmp = elem = elem || document;
  12165. // Don't do events on text and comment nodes
  12166. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  12167. return;
  12168. }
  12169. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  12170. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  12171. return;
  12172. }
  12173. if ( type.indexOf( "." ) > -1 ) {
  12174. // Namespaced trigger; create a regexp to match event type in handle()
  12175. namespaces = type.split( "." );
  12176. type = namespaces.shift();
  12177. namespaces.sort();
  12178. }
  12179. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  12180. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  12181. event = event[ jQuery.expando ] ?
  12182. event :
  12183. new jQuery.Event( type, typeof event === "object" && event );
  12184. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  12185. event.isTrigger = onlyHandlers ? 2 : 3;
  12186. event.namespace = namespaces.join( "." );
  12187. event.rnamespace = event.namespace ?
  12188. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  12189. null;
  12190. // Clean up the event in case it is being reused
  12191. event.result = undefined;
  12192. if ( !event.target ) {
  12193. event.target = elem;
  12194. }
  12195. // Clone any incoming data and prepend the event, creating the handler arg list
  12196. data = data == null ?
  12197. [ event ] :
  12198. jQuery.makeArray( data, [ event ] );
  12199. // Allow special events to draw outside the lines
  12200. special = jQuery.event.special[ type ] || {};
  12201. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  12202. return;
  12203. }
  12204. // Determine event propagation path in advance, per W3C events spec (#9951)
  12205. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  12206. if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
  12207. bubbleType = special.delegateType || type;
  12208. if ( !rfocusMorph.test( bubbleType + type ) ) {
  12209. cur = cur.parentNode;
  12210. }
  12211. for ( ; cur; cur = cur.parentNode ) {
  12212. eventPath.push( cur );
  12213. tmp = cur;
  12214. }
  12215. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  12216. if ( tmp === ( elem.ownerDocument || document ) ) {
  12217. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  12218. }
  12219. }
  12220. // Fire handlers on the event path
  12221. i = 0;
  12222. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  12223. lastElement = cur;
  12224. event.type = i > 1 ?
  12225. bubbleType :
  12226. special.bindType || type;
  12227. // jQuery handler
  12228. handle = (
  12229. dataPriv.get( cur, "events" ) || Object.create( null )
  12230. )[ event.type ] &&
  12231. dataPriv.get( cur, "handle" );
  12232. if ( handle ) {
  12233. handle.apply( cur, data );
  12234. }
  12235. // Native handler
  12236. handle = ontype && cur[ ontype ];
  12237. if ( handle && handle.apply && acceptData( cur ) ) {
  12238. event.result = handle.apply( cur, data );
  12239. if ( event.result === false ) {
  12240. event.preventDefault();
  12241. }
  12242. }
  12243. }
  12244. event.type = type;
  12245. // If nobody prevented the default action, do it now
  12246. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  12247. if ( ( !special._default ||
  12248. special._default.apply( eventPath.pop(), data ) === false ) &&
  12249. acceptData( elem ) ) {
  12250. // Call a native DOM method on the target with the same name as the event.
  12251. // Don't do default actions on window, that's where global variables be (#6170)
  12252. if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
  12253. // Don't re-trigger an onFOO event when we call its FOO() method
  12254. tmp = elem[ ontype ];
  12255. if ( tmp ) {
  12256. elem[ ontype ] = null;
  12257. }
  12258. // Prevent re-triggering of the same event, since we already bubbled it above
  12259. jQuery.event.triggered = type;
  12260. if ( event.isPropagationStopped() ) {
  12261. lastElement.addEventListener( type, stopPropagationCallback );
  12262. }
  12263. elem[ type ]();
  12264. if ( event.isPropagationStopped() ) {
  12265. lastElement.removeEventListener( type, stopPropagationCallback );
  12266. }
  12267. jQuery.event.triggered = undefined;
  12268. if ( tmp ) {
  12269. elem[ ontype ] = tmp;
  12270. }
  12271. }
  12272. }
  12273. }
  12274. return event.result;
  12275. },
  12276. // Piggyback on a donor event to simulate a different one
  12277. // Used only for `focus(in | out)` events
  12278. simulate: function( type, elem, event ) {
  12279. var e = jQuery.extend(
  12280. new jQuery.Event(),
  12281. event,
  12282. {
  12283. type: type,
  12284. isSimulated: true
  12285. }
  12286. );
  12287. jQuery.event.trigger( e, null, elem );
  12288. }
  12289. } );
  12290. jQuery.fn.extend( {
  12291. trigger: function( type, data ) {
  12292. return this.each( function() {
  12293. jQuery.event.trigger( type, data, this );
  12294. } );
  12295. },
  12296. triggerHandler: function( type, data ) {
  12297. var elem = this[ 0 ];
  12298. if ( elem ) {
  12299. return jQuery.event.trigger( type, data, elem, true );
  12300. }
  12301. }
  12302. } );
  12303. // Support: Firefox <=44
  12304. // Firefox doesn't have focus(in | out) events
  12305. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  12306. //
  12307. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  12308. // focus(in | out) events fire after focus & blur events,
  12309. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  12310. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  12311. if ( !support.focusin ) {
  12312. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  12313. // Attach a single capturing handler on the document while someone wants focusin/focusout
  12314. var handler = function( event ) {
  12315. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  12316. };
  12317. jQuery.event.special[ fix ] = {
  12318. setup: function() {
  12319. // Handle: regular nodes (via `this.ownerDocument`), window
  12320. // (via `this.document`) & document (via `this`).
  12321. var doc = this.ownerDocument || this.document || this,
  12322. attaches = dataPriv.access( doc, fix );
  12323. if ( !attaches ) {
  12324. doc.addEventListener( orig, handler, true );
  12325. }
  12326. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  12327. },
  12328. teardown: function() {
  12329. var doc = this.ownerDocument || this.document || this,
  12330. attaches = dataPriv.access( doc, fix ) - 1;
  12331. if ( !attaches ) {
  12332. doc.removeEventListener( orig, handler, true );
  12333. dataPriv.remove( doc, fix );
  12334. } else {
  12335. dataPriv.access( doc, fix, attaches );
  12336. }
  12337. }
  12338. };
  12339. } );
  12340. }
  12341. var location = window.location;
  12342. var nonce = { guid: Date.now() };
  12343. var rquery = ( /\?/ );
  12344. // Cross-browser xml parsing
  12345. jQuery.parseXML = function( data ) {
  12346. var xml;
  12347. if ( !data || typeof data !== "string" ) {
  12348. return null;
  12349. }
  12350. // Support: IE 9 - 11 only
  12351. // IE throws on parseFromString with invalid input.
  12352. try {
  12353. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  12354. } catch ( e ) {
  12355. xml = undefined;
  12356. }
  12357. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  12358. jQuery.error( "Invalid XML: " + data );
  12359. }
  12360. return xml;
  12361. };
  12362. var
  12363. rbracket = /\[\]$/,
  12364. rCRLF = /\r?\n/g,
  12365. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  12366. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  12367. function buildParams( prefix, obj, traditional, add ) {
  12368. var name;
  12369. if ( Array.isArray( obj ) ) {
  12370. // Serialize array item.
  12371. jQuery.each( obj, function( i, v ) {
  12372. if ( traditional || rbracket.test( prefix ) ) {
  12373. // Treat each array item as a scalar.
  12374. add( prefix, v );
  12375. } else {
  12376. // Item is non-scalar (array or object), encode its numeric index.
  12377. buildParams(
  12378. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  12379. v,
  12380. traditional,
  12381. add
  12382. );
  12383. }
  12384. } );
  12385. } else if ( !traditional && toType( obj ) === "object" ) {
  12386. // Serialize object item.
  12387. for ( name in obj ) {
  12388. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  12389. }
  12390. } else {
  12391. // Serialize scalar item.
  12392. add( prefix, obj );
  12393. }
  12394. }
  12395. // Serialize an array of form elements or a set of
  12396. // key/values into a query string
  12397. jQuery.param = function( a, traditional ) {
  12398. var prefix,
  12399. s = [],
  12400. add = function( key, valueOrFunction ) {
  12401. // If value is a function, invoke it and use its return value
  12402. var value = isFunction( valueOrFunction ) ?
  12403. valueOrFunction() :
  12404. valueOrFunction;
  12405. s[ s.length ] = encodeURIComponent( key ) + "=" +
  12406. encodeURIComponent( value == null ? "" : value );
  12407. };
  12408. if ( a == null ) {
  12409. return "";
  12410. }
  12411. // If an array was passed in, assume that it is an array of form elements.
  12412. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  12413. // Serialize the form elements
  12414. jQuery.each( a, function() {
  12415. add( this.name, this.value );
  12416. } );
  12417. } else {
  12418. // If traditional, encode the "old" way (the way 1.3.2 or older
  12419. // did it), otherwise encode params recursively.
  12420. for ( prefix in a ) {
  12421. buildParams( prefix, a[ prefix ], traditional, add );
  12422. }
  12423. }
  12424. // Return the resulting serialization
  12425. return s.join( "&" );
  12426. };
  12427. jQuery.fn.extend( {
  12428. serialize: function() {
  12429. return jQuery.param( this.serializeArray() );
  12430. },
  12431. serializeArray: function() {
  12432. return this.map( function() {
  12433. // Can add propHook for "elements" to filter or add form elements
  12434. var elements = jQuery.prop( this, "elements" );
  12435. return elements ? jQuery.makeArray( elements ) : this;
  12436. } )
  12437. .filter( function() {
  12438. var type = this.type;
  12439. // Use .is( ":disabled" ) so that fieldset[disabled] works
  12440. return this.name && !jQuery( this ).is( ":disabled" ) &&
  12441. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  12442. ( this.checked || !rcheckableType.test( type ) );
  12443. } )
  12444. .map( function( _i, elem ) {
  12445. var val = jQuery( this ).val();
  12446. if ( val == null ) {
  12447. return null;
  12448. }
  12449. if ( Array.isArray( val ) ) {
  12450. return jQuery.map( val, function( val ) {
  12451. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  12452. } );
  12453. }
  12454. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  12455. } ).get();
  12456. }
  12457. } );
  12458. var
  12459. r20 = /%20/g,
  12460. rhash = /#.*$/,
  12461. rantiCache = /([?&])_=[^&]*/,
  12462. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  12463. // #7653, #8125, #8152: local protocol detection
  12464. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  12465. rnoContent = /^(?:GET|HEAD)$/,
  12466. rprotocol = /^\/\//,
  12467. /* Prefilters
  12468. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  12469. * 2) These are called:
  12470. * - BEFORE asking for a transport
  12471. * - AFTER param serialization (s.data is a string if s.processData is true)
  12472. * 3) key is the dataType
  12473. * 4) the catchall symbol "*" can be used
  12474. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  12475. */
  12476. prefilters = {},
  12477. /* Transports bindings
  12478. * 1) key is the dataType
  12479. * 2) the catchall symbol "*" can be used
  12480. * 3) selection will start with transport dataType and THEN go to "*" if needed
  12481. */
  12482. transports = {},
  12483. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  12484. allTypes = "*/".concat( "*" ),
  12485. // Anchor tag for parsing the document origin
  12486. originAnchor = document.createElement( "a" );
  12487. originAnchor.href = location.href;
  12488. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  12489. function addToPrefiltersOrTransports( structure ) {
  12490. // dataTypeExpression is optional and defaults to "*"
  12491. return function( dataTypeExpression, func ) {
  12492. if ( typeof dataTypeExpression !== "string" ) {
  12493. func = dataTypeExpression;
  12494. dataTypeExpression = "*";
  12495. }
  12496. var dataType,
  12497. i = 0,
  12498. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  12499. if ( isFunction( func ) ) {
  12500. // For each dataType in the dataTypeExpression
  12501. while ( ( dataType = dataTypes[ i++ ] ) ) {
  12502. // Prepend if requested
  12503. if ( dataType[ 0 ] === "+" ) {
  12504. dataType = dataType.slice( 1 ) || "*";
  12505. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  12506. // Otherwise append
  12507. } else {
  12508. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  12509. }
  12510. }
  12511. }
  12512. };
  12513. }
  12514. // Base inspection function for prefilters and transports
  12515. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  12516. var inspected = {},
  12517. seekingTransport = ( structure === transports );
  12518. function inspect( dataType ) {
  12519. var selected;
  12520. inspected[ dataType ] = true;
  12521. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  12522. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  12523. if ( typeof dataTypeOrTransport === "string" &&
  12524. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  12525. options.dataTypes.unshift( dataTypeOrTransport );
  12526. inspect( dataTypeOrTransport );
  12527. return false;
  12528. } else if ( seekingTransport ) {
  12529. return !( selected = dataTypeOrTransport );
  12530. }
  12531. } );
  12532. return selected;
  12533. }
  12534. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  12535. }
  12536. // A special extend for ajax options
  12537. // that takes "flat" options (not to be deep extended)
  12538. // Fixes #9887
  12539. function ajaxExtend( target, src ) {
  12540. var key, deep,
  12541. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  12542. for ( key in src ) {
  12543. if ( src[ key ] !== undefined ) {
  12544. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  12545. }
  12546. }
  12547. if ( deep ) {
  12548. jQuery.extend( true, target, deep );
  12549. }
  12550. return target;
  12551. }
  12552. /* Handles responses to an ajax request:
  12553. * - finds the right dataType (mediates between content-type and expected dataType)
  12554. * - returns the corresponding response
  12555. */
  12556. function ajaxHandleResponses( s, jqXHR, responses ) {
  12557. var ct, type, finalDataType, firstDataType,
  12558. contents = s.contents,
  12559. dataTypes = s.dataTypes;
  12560. // Remove auto dataType and get content-type in the process
  12561. while ( dataTypes[ 0 ] === "*" ) {
  12562. dataTypes.shift();
  12563. if ( ct === undefined ) {
  12564. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  12565. }
  12566. }
  12567. // Check if we're dealing with a known content-type
  12568. if ( ct ) {
  12569. for ( type in contents ) {
  12570. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  12571. dataTypes.unshift( type );
  12572. break;
  12573. }
  12574. }
  12575. }
  12576. // Check to see if we have a response for the expected dataType
  12577. if ( dataTypes[ 0 ] in responses ) {
  12578. finalDataType = dataTypes[ 0 ];
  12579. } else {
  12580. // Try convertible dataTypes
  12581. for ( type in responses ) {
  12582. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  12583. finalDataType = type;
  12584. break;
  12585. }
  12586. if ( !firstDataType ) {
  12587. firstDataType = type;
  12588. }
  12589. }
  12590. // Or just use first one
  12591. finalDataType = finalDataType || firstDataType;
  12592. }
  12593. // If we found a dataType
  12594. // We add the dataType to the list if needed
  12595. // and return the corresponding response
  12596. if ( finalDataType ) {
  12597. if ( finalDataType !== dataTypes[ 0 ] ) {
  12598. dataTypes.unshift( finalDataType );
  12599. }
  12600. return responses[ finalDataType ];
  12601. }
  12602. }
  12603. /* Chain conversions given the request and the original response
  12604. * Also sets the responseXXX fields on the jqXHR instance
  12605. */
  12606. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  12607. var conv2, current, conv, tmp, prev,
  12608. converters = {},
  12609. // Work with a copy of dataTypes in case we need to modify it for conversion
  12610. dataTypes = s.dataTypes.slice();
  12611. // Create converters map with lowercased keys
  12612. if ( dataTypes[ 1 ] ) {
  12613. for ( conv in s.converters ) {
  12614. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  12615. }
  12616. }
  12617. current = dataTypes.shift();
  12618. // Convert to each sequential dataType
  12619. while ( current ) {
  12620. if ( s.responseFields[ current ] ) {
  12621. jqXHR[ s.responseFields[ current ] ] = response;
  12622. }
  12623. // Apply the dataFilter if provided
  12624. if ( !prev && isSuccess && s.dataFilter ) {
  12625. response = s.dataFilter( response, s.dataType );
  12626. }
  12627. prev = current;
  12628. current = dataTypes.shift();
  12629. if ( current ) {
  12630. // There's only work to do if current dataType is non-auto
  12631. if ( current === "*" ) {
  12632. current = prev;
  12633. // Convert response if prev dataType is non-auto and differs from current
  12634. } else if ( prev !== "*" && prev !== current ) {
  12635. // Seek a direct converter
  12636. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  12637. // If none found, seek a pair
  12638. if ( !conv ) {
  12639. for ( conv2 in converters ) {
  12640. // If conv2 outputs current
  12641. tmp = conv2.split( " " );
  12642. if ( tmp[ 1 ] === current ) {
  12643. // If prev can be converted to accepted input
  12644. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  12645. converters[ "* " + tmp[ 0 ] ];
  12646. if ( conv ) {
  12647. // Condense equivalence converters
  12648. if ( conv === true ) {
  12649. conv = converters[ conv2 ];
  12650. // Otherwise, insert the intermediate dataType
  12651. } else if ( converters[ conv2 ] !== true ) {
  12652. current = tmp[ 0 ];
  12653. dataTypes.unshift( tmp[ 1 ] );
  12654. }
  12655. break;
  12656. }
  12657. }
  12658. }
  12659. }
  12660. // Apply converter (if not an equivalence)
  12661. if ( conv !== true ) {
  12662. // Unless errors are allowed to bubble, catch and return them
  12663. if ( conv && s.throws ) {
  12664. response = conv( response );
  12665. } else {
  12666. try {
  12667. response = conv( response );
  12668. } catch ( e ) {
  12669. return {
  12670. state: "parsererror",
  12671. error: conv ? e : "No conversion from " + prev + " to " + current
  12672. };
  12673. }
  12674. }
  12675. }
  12676. }
  12677. }
  12678. }
  12679. return { state: "success", data: response };
  12680. }
  12681. jQuery.extend( {
  12682. // Counter for holding the number of active queries
  12683. active: 0,
  12684. // Last-Modified header cache for next request
  12685. lastModified: {},
  12686. etag: {},
  12687. ajaxSettings: {
  12688. url: location.href,
  12689. type: "GET",
  12690. isLocal: rlocalProtocol.test( location.protocol ),
  12691. global: true,
  12692. processData: true,
  12693. async: true,
  12694. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  12695. /*
  12696. timeout: 0,
  12697. data: null,
  12698. dataType: null,
  12699. username: null,
  12700. password: null,
  12701. cache: null,
  12702. throws: false,
  12703. traditional: false,
  12704. headers: {},
  12705. */
  12706. accepts: {
  12707. "*": allTypes,
  12708. text: "text/plain",
  12709. html: "text/html",
  12710. xml: "application/xml, text/xml",
  12711. json: "application/json, text/javascript"
  12712. },
  12713. contents: {
  12714. xml: /\bxml\b/,
  12715. html: /\bhtml/,
  12716. json: /\bjson\b/
  12717. },
  12718. responseFields: {
  12719. xml: "responseXML",
  12720. text: "responseText",
  12721. json: "responseJSON"
  12722. },
  12723. // Data converters
  12724. // Keys separate source (or catchall "*") and destination types with a single space
  12725. converters: {
  12726. // Convert anything to text
  12727. "* text": String,
  12728. // Text to html (true = no transformation)
  12729. "text html": true,
  12730. // Evaluate text as a json expression
  12731. "text json": JSON.parse,
  12732. // Parse text as xml
  12733. "text xml": jQuery.parseXML
  12734. },
  12735. // For options that shouldn't be deep extended:
  12736. // you can add your own custom options here if
  12737. // and when you create one that shouldn't be
  12738. // deep extended (see ajaxExtend)
  12739. flatOptions: {
  12740. url: true,
  12741. context: true
  12742. }
  12743. },
  12744. // Creates a full fledged settings object into target
  12745. // with both ajaxSettings and settings fields.
  12746. // If target is omitted, writes into ajaxSettings.
  12747. ajaxSetup: function( target, settings ) {
  12748. return settings ?
  12749. // Building a settings object
  12750. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  12751. // Extending ajaxSettings
  12752. ajaxExtend( jQuery.ajaxSettings, target );
  12753. },
  12754. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  12755. ajaxTransport: addToPrefiltersOrTransports( transports ),
  12756. // Main method
  12757. ajax: function( url, options ) {
  12758. // If url is an object, simulate pre-1.5 signature
  12759. if ( typeof url === "object" ) {
  12760. options = url;
  12761. url = undefined;
  12762. }
  12763. // Force options to be an object
  12764. options = options || {};
  12765. var transport,
  12766. // URL without anti-cache param
  12767. cacheURL,
  12768. // Response headers
  12769. responseHeadersString,
  12770. responseHeaders,
  12771. // timeout handle
  12772. timeoutTimer,
  12773. // Url cleanup var
  12774. urlAnchor,
  12775. // Request state (becomes false upon send and true upon completion)
  12776. completed,
  12777. // To know if global events are to be dispatched
  12778. fireGlobals,
  12779. // Loop variable
  12780. i,
  12781. // uncached part of the url
  12782. uncached,
  12783. // Create the final options object
  12784. s = jQuery.ajaxSetup( {}, options ),
  12785. // Callbacks context
  12786. callbackContext = s.context || s,
  12787. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  12788. globalEventContext = s.context &&
  12789. ( callbackContext.nodeType || callbackContext.jquery ) ?
  12790. jQuery( callbackContext ) :
  12791. jQuery.event,
  12792. // Deferreds
  12793. deferred = jQuery.Deferred(),
  12794. completeDeferred = jQuery.Callbacks( "once memory" ),
  12795. // Status-dependent callbacks
  12796. statusCode = s.statusCode || {},
  12797. // Headers (they are sent all at once)
  12798. requestHeaders = {},
  12799. requestHeadersNames = {},
  12800. // Default abort message
  12801. strAbort = "canceled",
  12802. // Fake xhr
  12803. jqXHR = {
  12804. readyState: 0,
  12805. // Builds headers hashtable if needed
  12806. getResponseHeader: function( key ) {
  12807. var match;
  12808. if ( completed ) {
  12809. if ( !responseHeaders ) {
  12810. responseHeaders = {};
  12811. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  12812. responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
  12813. ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
  12814. .concat( match[ 2 ] );
  12815. }
  12816. }
  12817. match = responseHeaders[ key.toLowerCase() + " " ];
  12818. }
  12819. return match == null ? null : match.join( ", " );
  12820. },
  12821. // Raw string
  12822. getAllResponseHeaders: function() {
  12823. return completed ? responseHeadersString : null;
  12824. },
  12825. // Caches the header
  12826. setRequestHeader: function( name, value ) {
  12827. if ( completed == null ) {
  12828. name = requestHeadersNames[ name.toLowerCase() ] =
  12829. requestHeadersNames[ name.toLowerCase() ] || name;
  12830. requestHeaders[ name ] = value;
  12831. }
  12832. return this;
  12833. },
  12834. // Overrides response content-type header
  12835. overrideMimeType: function( type ) {
  12836. if ( completed == null ) {
  12837. s.mimeType = type;
  12838. }
  12839. return this;
  12840. },
  12841. // Status-dependent callbacks
  12842. statusCode: function( map ) {
  12843. var code;
  12844. if ( map ) {
  12845. if ( completed ) {
  12846. // Execute the appropriate callbacks
  12847. jqXHR.always( map[ jqXHR.status ] );
  12848. } else {
  12849. // Lazy-add the new callbacks in a way that preserves old ones
  12850. for ( code in map ) {
  12851. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  12852. }
  12853. }
  12854. }
  12855. return this;
  12856. },
  12857. // Cancel the request
  12858. abort: function( statusText ) {
  12859. var finalText = statusText || strAbort;
  12860. if ( transport ) {
  12861. transport.abort( finalText );
  12862. }
  12863. done( 0, finalText );
  12864. return this;
  12865. }
  12866. };
  12867. // Attach deferreds
  12868. deferred.promise( jqXHR );
  12869. // Add protocol if not provided (prefilters might expect it)
  12870. // Handle falsy url in the settings object (#10093: consistency with old signature)
  12871. // We also use the url parameter if available
  12872. s.url = ( ( url || s.url || location.href ) + "" )
  12873. .replace( rprotocol, location.protocol + "//" );
  12874. // Alias method option to type as per ticket #12004
  12875. s.type = options.method || options.type || s.method || s.type;
  12876. // Extract dataTypes list
  12877. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  12878. // A cross-domain request is in order when the origin doesn't match the current origin.
  12879. if ( s.crossDomain == null ) {
  12880. urlAnchor = document.createElement( "a" );
  12881. // Support: IE <=8 - 11, Edge 12 - 15
  12882. // IE throws exception on accessing the href property if url is malformed,
  12883. // e.g. http://example.com:80x/
  12884. try {
  12885. urlAnchor.href = s.url;
  12886. // Support: IE <=8 - 11 only
  12887. // Anchor's host property isn't correctly set when s.url is relative
  12888. urlAnchor.href = urlAnchor.href;
  12889. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  12890. urlAnchor.protocol + "//" + urlAnchor.host;
  12891. } catch ( e ) {
  12892. // If there is an error parsing the URL, assume it is crossDomain,
  12893. // it can be rejected by the transport if it is invalid
  12894. s.crossDomain = true;
  12895. }
  12896. }
  12897. // Convert data if not already a string
  12898. if ( s.data && s.processData && typeof s.data !== "string" ) {
  12899. s.data = jQuery.param( s.data, s.traditional );
  12900. }
  12901. // Apply prefilters
  12902. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  12903. // If request was aborted inside a prefilter, stop there
  12904. if ( completed ) {
  12905. return jqXHR;
  12906. }
  12907. // We can fire global events as of now if asked to
  12908. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  12909. fireGlobals = jQuery.event && s.global;
  12910. // Watch for a new set of requests
  12911. if ( fireGlobals && jQuery.active++ === 0 ) {
  12912. jQuery.event.trigger( "ajaxStart" );
  12913. }
  12914. // Uppercase the type
  12915. s.type = s.type.toUpperCase();
  12916. // Determine if request has content
  12917. s.hasContent = !rnoContent.test( s.type );
  12918. // Save the URL in case we're toying with the If-Modified-Since
  12919. // and/or If-None-Match header later on
  12920. // Remove hash to simplify url manipulation
  12921. cacheURL = s.url.replace( rhash, "" );
  12922. // More options handling for requests with no content
  12923. if ( !s.hasContent ) {
  12924. // Remember the hash so we can put it back
  12925. uncached = s.url.slice( cacheURL.length );
  12926. // If data is available and should be processed, append data to url
  12927. if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
  12928. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  12929. // #9682: remove data so that it's not used in an eventual retry
  12930. delete s.data;
  12931. }
  12932. // Add or update anti-cache param if needed
  12933. if ( s.cache === false ) {
  12934. cacheURL = cacheURL.replace( rantiCache, "$1" );
  12935. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce.guid++ ) +
  12936. uncached;
  12937. }
  12938. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  12939. s.url = cacheURL + uncached;
  12940. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  12941. } else if ( s.data && s.processData &&
  12942. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  12943. s.data = s.data.replace( r20, "+" );
  12944. }
  12945. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  12946. if ( s.ifModified ) {
  12947. if ( jQuery.lastModified[ cacheURL ] ) {
  12948. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  12949. }
  12950. if ( jQuery.etag[ cacheURL ] ) {
  12951. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  12952. }
  12953. }
  12954. // Set the correct header, if data is being sent
  12955. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  12956. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  12957. }
  12958. // Set the Accepts header for the server, depending on the dataType
  12959. jqXHR.setRequestHeader(
  12960. "Accept",
  12961. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  12962. s.accepts[ s.dataTypes[ 0 ] ] +
  12963. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  12964. s.accepts[ "*" ]
  12965. );
  12966. // Check for headers option
  12967. for ( i in s.headers ) {
  12968. jqXHR.setRequestHeader( i, s.headers[ i ] );
  12969. }
  12970. // Allow custom headers/mimetypes and early abort
  12971. if ( s.beforeSend &&
  12972. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  12973. // Abort if not done already and return
  12974. return jqXHR.abort();
  12975. }
  12976. // Aborting is no longer a cancellation
  12977. strAbort = "abort";
  12978. // Install callbacks on deferreds
  12979. completeDeferred.add( s.complete );
  12980. jqXHR.done( s.success );
  12981. jqXHR.fail( s.error );
  12982. // Get transport
  12983. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  12984. // If no transport, we auto-abort
  12985. if ( !transport ) {
  12986. done( -1, "No Transport" );
  12987. } else {
  12988. jqXHR.readyState = 1;
  12989. // Send global event
  12990. if ( fireGlobals ) {
  12991. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  12992. }
  12993. // If request was aborted inside ajaxSend, stop there
  12994. if ( completed ) {
  12995. return jqXHR;
  12996. }
  12997. // Timeout
  12998. if ( s.async && s.timeout > 0 ) {
  12999. timeoutTimer = window.setTimeout( function() {
  13000. jqXHR.abort( "timeout" );
  13001. }, s.timeout );
  13002. }
  13003. try {
  13004. completed = false;
  13005. transport.send( requestHeaders, done );
  13006. } catch ( e ) {
  13007. // Rethrow post-completion exceptions
  13008. if ( completed ) {
  13009. throw e;
  13010. }
  13011. // Propagate others as results
  13012. done( -1, e );
  13013. }
  13014. }
  13015. // Callback for when everything is done
  13016. function done( status, nativeStatusText, responses, headers ) {
  13017. var isSuccess, success, error, response, modified,
  13018. statusText = nativeStatusText;
  13019. // Ignore repeat invocations
  13020. if ( completed ) {
  13021. return;
  13022. }
  13023. completed = true;
  13024. // Clear timeout if it exists
  13025. if ( timeoutTimer ) {
  13026. window.clearTimeout( timeoutTimer );
  13027. }
  13028. // Dereference transport for early garbage collection
  13029. // (no matter how long the jqXHR object will be used)
  13030. transport = undefined;
  13031. // Cache response headers
  13032. responseHeadersString = headers || "";
  13033. // Set readyState
  13034. jqXHR.readyState = status > 0 ? 4 : 0;
  13035. // Determine if successful
  13036. isSuccess = status >= 200 && status < 300 || status === 304;
  13037. // Get response data
  13038. if ( responses ) {
  13039. response = ajaxHandleResponses( s, jqXHR, responses );
  13040. }
  13041. // Use a noop converter for missing script
  13042. if ( !isSuccess && jQuery.inArray( "script", s.dataTypes ) > -1 ) {
  13043. s.converters[ "text script" ] = function() {};
  13044. }
  13045. // Convert no matter what (that way responseXXX fields are always set)
  13046. response = ajaxConvert( s, response, jqXHR, isSuccess );
  13047. // If successful, handle type chaining
  13048. if ( isSuccess ) {
  13049. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  13050. if ( s.ifModified ) {
  13051. modified = jqXHR.getResponseHeader( "Last-Modified" );
  13052. if ( modified ) {
  13053. jQuery.lastModified[ cacheURL ] = modified;
  13054. }
  13055. modified = jqXHR.getResponseHeader( "etag" );
  13056. if ( modified ) {
  13057. jQuery.etag[ cacheURL ] = modified;
  13058. }
  13059. }
  13060. // if no content
  13061. if ( status === 204 || s.type === "HEAD" ) {
  13062. statusText = "nocontent";
  13063. // if not modified
  13064. } else if ( status === 304 ) {
  13065. statusText = "notmodified";
  13066. // If we have data, let's convert it
  13067. } else {
  13068. statusText = response.state;
  13069. success = response.data;
  13070. error = response.error;
  13071. isSuccess = !error;
  13072. }
  13073. } else {
  13074. // Extract error from statusText and normalize for non-aborts
  13075. error = statusText;
  13076. if ( status || !statusText ) {
  13077. statusText = "error";
  13078. if ( status < 0 ) {
  13079. status = 0;
  13080. }
  13081. }
  13082. }
  13083. // Set data for the fake xhr object
  13084. jqXHR.status = status;
  13085. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  13086. // Success/Error
  13087. if ( isSuccess ) {
  13088. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  13089. } else {
  13090. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  13091. }
  13092. // Status-dependent callbacks
  13093. jqXHR.statusCode( statusCode );
  13094. statusCode = undefined;
  13095. if ( fireGlobals ) {
  13096. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  13097. [ jqXHR, s, isSuccess ? success : error ] );
  13098. }
  13099. // Complete
  13100. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  13101. if ( fireGlobals ) {
  13102. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  13103. // Handle the global AJAX counter
  13104. if ( !( --jQuery.active ) ) {
  13105. jQuery.event.trigger( "ajaxStop" );
  13106. }
  13107. }
  13108. }
  13109. return jqXHR;
  13110. },
  13111. getJSON: function( url, data, callback ) {
  13112. return jQuery.get( url, data, callback, "json" );
  13113. },
  13114. getScript: function( url, callback ) {
  13115. return jQuery.get( url, undefined, callback, "script" );
  13116. }
  13117. } );
  13118. jQuery.each( [ "get", "post" ], function( _i, method ) {
  13119. jQuery[ method ] = function( url, data, callback, type ) {
  13120. // Shift arguments if data argument was omitted
  13121. if ( isFunction( data ) ) {
  13122. type = type || callback;
  13123. callback = data;
  13124. data = undefined;
  13125. }
  13126. // The url can be an options object (which then must have .url)
  13127. return jQuery.ajax( jQuery.extend( {
  13128. url: url,
  13129. type: method,
  13130. dataType: type,
  13131. data: data,
  13132. success: callback
  13133. }, jQuery.isPlainObject( url ) && url ) );
  13134. };
  13135. } );
  13136. jQuery.ajaxPrefilter( function( s ) {
  13137. var i;
  13138. for ( i in s.headers ) {
  13139. if ( i.toLowerCase() === "content-type" ) {
  13140. s.contentType = s.headers[ i ] || "";
  13141. }
  13142. }
  13143. } );
  13144. jQuery._evalUrl = function( url, options, doc ) {
  13145. return jQuery.ajax( {
  13146. url: url,
  13147. // Make this explicit, since user can override this through ajaxSetup (#11264)
  13148. type: "GET",
  13149. dataType: "script",
  13150. cache: true,
  13151. async: false,
  13152. global: false,
  13153. // Only evaluate the response if it is successful (gh-4126)
  13154. // dataFilter is not invoked for failure responses, so using it instead
  13155. // of the default converter is kludgy but it works.
  13156. converters: {
  13157. "text script": function() {}
  13158. },
  13159. dataFilter: function( response ) {
  13160. jQuery.globalEval( response, options, doc );
  13161. }
  13162. } );
  13163. };
  13164. jQuery.fn.extend( {
  13165. wrapAll: function( html ) {
  13166. var wrap;
  13167. if ( this[ 0 ] ) {
  13168. if ( isFunction( html ) ) {
  13169. html = html.call( this[ 0 ] );
  13170. }
  13171. // The elements to wrap the target around
  13172. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  13173. if ( this[ 0 ].parentNode ) {
  13174. wrap.insertBefore( this[ 0 ] );
  13175. }
  13176. wrap.map( function() {
  13177. var elem = this;
  13178. while ( elem.firstElementChild ) {
  13179. elem = elem.firstElementChild;
  13180. }
  13181. return elem;
  13182. } ).append( this );
  13183. }
  13184. return this;
  13185. },
  13186. wrapInner: function( html ) {
  13187. if ( isFunction( html ) ) {
  13188. return this.each( function( i ) {
  13189. jQuery( this ).wrapInner( html.call( this, i ) );
  13190. } );
  13191. }
  13192. return this.each( function() {
  13193. var self = jQuery( this ),
  13194. contents = self.contents();
  13195. if ( contents.length ) {
  13196. contents.wrapAll( html );
  13197. } else {
  13198. self.append( html );
  13199. }
  13200. } );
  13201. },
  13202. wrap: function( html ) {
  13203. var htmlIsFunction = isFunction( html );
  13204. return this.each( function( i ) {
  13205. jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
  13206. } );
  13207. },
  13208. unwrap: function( selector ) {
  13209. this.parent( selector ).not( "body" ).each( function() {
  13210. jQuery( this ).replaceWith( this.childNodes );
  13211. } );
  13212. return this;
  13213. }
  13214. } );
  13215. jQuery.expr.pseudos.hidden = function( elem ) {
  13216. return !jQuery.expr.pseudos.visible( elem );
  13217. };
  13218. jQuery.expr.pseudos.visible = function( elem ) {
  13219. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  13220. };
  13221. jQuery.ajaxSettings.xhr = function() {
  13222. try {
  13223. return new window.XMLHttpRequest();
  13224. } catch ( e ) {}
  13225. };
  13226. var xhrSuccessStatus = {
  13227. // File protocol always yields status code 0, assume 200
  13228. 0: 200,
  13229. // Support: IE <=9 only
  13230. // #1450: sometimes IE returns 1223 when it should be 204
  13231. 1223: 204
  13232. },
  13233. xhrSupported = jQuery.ajaxSettings.xhr();
  13234. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  13235. support.ajax = xhrSupported = !!xhrSupported;
  13236. jQuery.ajaxTransport( function( options ) {
  13237. var callback, errorCallback;
  13238. // Cross domain only allowed if supported through XMLHttpRequest
  13239. if ( support.cors || xhrSupported && !options.crossDomain ) {
  13240. return {
  13241. send: function( headers, complete ) {
  13242. var i,
  13243. xhr = options.xhr();
  13244. xhr.open(
  13245. options.type,
  13246. options.url,
  13247. options.async,
  13248. options.username,
  13249. options.password
  13250. );
  13251. // Apply custom fields if provided
  13252. if ( options.xhrFields ) {
  13253. for ( i in options.xhrFields ) {
  13254. xhr[ i ] = options.xhrFields[ i ];
  13255. }
  13256. }
  13257. // Override mime type if needed
  13258. if ( options.mimeType && xhr.overrideMimeType ) {
  13259. xhr.overrideMimeType( options.mimeType );
  13260. }
  13261. // X-Requested-With header
  13262. // For cross-domain requests, seeing as conditions for a preflight are
  13263. // akin to a jigsaw puzzle, we simply never set it to be sure.
  13264. // (it can always be set on a per-request basis or even using ajaxSetup)
  13265. // For same-domain requests, won't change header if already provided.
  13266. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  13267. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  13268. }
  13269. // Set headers
  13270. for ( i in headers ) {
  13271. xhr.setRequestHeader( i, headers[ i ] );
  13272. }
  13273. // Callback
  13274. callback = function( type ) {
  13275. return function() {
  13276. if ( callback ) {
  13277. callback = errorCallback = xhr.onload =
  13278. xhr.onerror = xhr.onabort = xhr.ontimeout =
  13279. xhr.onreadystatechange = null;
  13280. if ( type === "abort" ) {
  13281. xhr.abort();
  13282. } else if ( type === "error" ) {
  13283. // Support: IE <=9 only
  13284. // On a manual native abort, IE9 throws
  13285. // errors on any property access that is not readyState
  13286. if ( typeof xhr.status !== "number" ) {
  13287. complete( 0, "error" );
  13288. } else {
  13289. complete(
  13290. // File: protocol always yields status 0; see #8605, #14207
  13291. xhr.status,
  13292. xhr.statusText
  13293. );
  13294. }
  13295. } else {
  13296. complete(
  13297. xhrSuccessStatus[ xhr.status ] || xhr.status,
  13298. xhr.statusText,
  13299. // Support: IE <=9 only
  13300. // IE9 has no XHR2 but throws on binary (trac-11426)
  13301. // For XHR2 non-text, let the caller handle it (gh-2498)
  13302. ( xhr.responseType || "text" ) !== "text" ||
  13303. typeof xhr.responseText !== "string" ?
  13304. { binary: xhr.response } :
  13305. { text: xhr.responseText },
  13306. xhr.getAllResponseHeaders()
  13307. );
  13308. }
  13309. }
  13310. };
  13311. };
  13312. // Listen to events
  13313. xhr.onload = callback();
  13314. errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
  13315. // Support: IE 9 only
  13316. // Use onreadystatechange to replace onabort
  13317. // to handle uncaught aborts
  13318. if ( xhr.onabort !== undefined ) {
  13319. xhr.onabort = errorCallback;
  13320. } else {
  13321. xhr.onreadystatechange = function() {
  13322. // Check readyState before timeout as it changes
  13323. if ( xhr.readyState === 4 ) {
  13324. // Allow onerror to be called first,
  13325. // but that will not handle a native abort
  13326. // Also, save errorCallback to a variable
  13327. // as xhr.onerror cannot be accessed
  13328. window.setTimeout( function() {
  13329. if ( callback ) {
  13330. errorCallback();
  13331. }
  13332. } );
  13333. }
  13334. };
  13335. }
  13336. // Create the abort callback
  13337. callback = callback( "abort" );
  13338. try {
  13339. // Do send the request (this may raise an exception)
  13340. xhr.send( options.hasContent && options.data || null );
  13341. } catch ( e ) {
  13342. // #14683: Only rethrow if this hasn't been notified as an error yet
  13343. if ( callback ) {
  13344. throw e;
  13345. }
  13346. }
  13347. },
  13348. abort: function() {
  13349. if ( callback ) {
  13350. callback();
  13351. }
  13352. }
  13353. };
  13354. }
  13355. } );
  13356. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  13357. jQuery.ajaxPrefilter( function( s ) {
  13358. if ( s.crossDomain ) {
  13359. s.contents.script = false;
  13360. }
  13361. } );
  13362. // Install script dataType
  13363. jQuery.ajaxSetup( {
  13364. accepts: {
  13365. script: "text/javascript, application/javascript, " +
  13366. "application/ecmascript, application/x-ecmascript"
  13367. },
  13368. contents: {
  13369. script: /\b(?:java|ecma)script\b/
  13370. },
  13371. converters: {
  13372. "text script": function( text ) {
  13373. jQuery.globalEval( text );
  13374. return text;
  13375. }
  13376. }
  13377. } );
  13378. // Handle cache's special case and crossDomain
  13379. jQuery.ajaxPrefilter( "script", function( s ) {
  13380. if ( s.cache === undefined ) {
  13381. s.cache = false;
  13382. }
  13383. if ( s.crossDomain ) {
  13384. s.type = "GET";
  13385. }
  13386. } );
  13387. // Bind script tag hack transport
  13388. jQuery.ajaxTransport( "script", function( s ) {
  13389. // This transport only deals with cross domain or forced-by-attrs requests
  13390. if ( s.crossDomain || s.scriptAttrs ) {
  13391. var script, callback;
  13392. return {
  13393. send: function( _, complete ) {
  13394. script = jQuery( "<script>" )
  13395. .attr( s.scriptAttrs || {} )
  13396. .prop( { charset: s.scriptCharset, src: s.url } )
  13397. .on( "load error", callback = function( evt ) {
  13398. script.remove();
  13399. callback = null;
  13400. if ( evt ) {
  13401. complete( evt.type === "error" ? 404 : 200, evt.type );
  13402. }
  13403. } );
  13404. // Use native DOM manipulation to avoid our domManip AJAX trickery
  13405. document.head.appendChild( script[ 0 ] );
  13406. },
  13407. abort: function() {
  13408. if ( callback ) {
  13409. callback();
  13410. }
  13411. }
  13412. };
  13413. }
  13414. } );
  13415. var oldCallbacks = [],
  13416. rjsonp = /(=)\?(?=&|$)|\?\?/;
  13417. // Default jsonp settings
  13418. jQuery.ajaxSetup( {
  13419. jsonp: "callback",
  13420. jsonpCallback: function() {
  13421. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce.guid++ ) );
  13422. this[ callback ] = true;
  13423. return callback;
  13424. }
  13425. } );
  13426. // Detect, normalize options and install callbacks for jsonp requests
  13427. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  13428. var callbackName, overwritten, responseContainer,
  13429. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  13430. "url" :
  13431. typeof s.data === "string" &&
  13432. ( s.contentType || "" )
  13433. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  13434. rjsonp.test( s.data ) && "data"
  13435. );
  13436. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  13437. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  13438. // Get callback name, remembering preexisting value associated with it
  13439. callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
  13440. s.jsonpCallback() :
  13441. s.jsonpCallback;
  13442. // Insert callback into url or form data
  13443. if ( jsonProp ) {
  13444. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  13445. } else if ( s.jsonp !== false ) {
  13446. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  13447. }
  13448. // Use data converter to retrieve json after script execution
  13449. s.converters[ "script json" ] = function() {
  13450. if ( !responseContainer ) {
  13451. jQuery.error( callbackName + " was not called" );
  13452. }
  13453. return responseContainer[ 0 ];
  13454. };
  13455. // Force json dataType
  13456. s.dataTypes[ 0 ] = "json";
  13457. // Install callback
  13458. overwritten = window[ callbackName ];
  13459. window[ callbackName ] = function() {
  13460. responseContainer = arguments;
  13461. };
  13462. // Clean-up function (fires after converters)
  13463. jqXHR.always( function() {
  13464. // If previous value didn't exist - remove it
  13465. if ( overwritten === undefined ) {
  13466. jQuery( window ).removeProp( callbackName );
  13467. // Otherwise restore preexisting value
  13468. } else {
  13469. window[ callbackName ] = overwritten;
  13470. }
  13471. // Save back as free
  13472. if ( s[ callbackName ] ) {
  13473. // Make sure that re-using the options doesn't screw things around
  13474. s.jsonpCallback = originalSettings.jsonpCallback;
  13475. // Save the callback name for future use
  13476. oldCallbacks.push( callbackName );
  13477. }
  13478. // Call if it was a function and we have a response
  13479. if ( responseContainer && isFunction( overwritten ) ) {
  13480. overwritten( responseContainer[ 0 ] );
  13481. }
  13482. responseContainer = overwritten = undefined;
  13483. } );
  13484. // Delegate to script
  13485. return "script";
  13486. }
  13487. } );
  13488. // Support: Safari 8 only
  13489. // In Safari 8 documents created via document.implementation.createHTMLDocument
  13490. // collapse sibling forms: the second one becomes a child of the first one.
  13491. // Because of that, this security measure has to be disabled in Safari 8.
  13492. // https://bugs.webkit.org/show_bug.cgi?id=137337
  13493. support.createHTMLDocument = ( function() {
  13494. var body = document.implementation.createHTMLDocument( "" ).body;
  13495. body.innerHTML = "<form></form><form></form>";
  13496. return body.childNodes.length === 2;
  13497. } )();
  13498. // Argument "data" should be string of html
  13499. // context (optional): If specified, the fragment will be created in this context,
  13500. // defaults to document
  13501. // keepScripts (optional): If true, will include scripts passed in the html string
  13502. jQuery.parseHTML = function( data, context, keepScripts ) {
  13503. if ( typeof data !== "string" ) {
  13504. return [];
  13505. }
  13506. if ( typeof context === "boolean" ) {
  13507. keepScripts = context;
  13508. context = false;
  13509. }
  13510. var base, parsed, scripts;
  13511. if ( !context ) {
  13512. // Stop scripts or inline event handlers from being executed immediately
  13513. // by using document.implementation
  13514. if ( support.createHTMLDocument ) {
  13515. context = document.implementation.createHTMLDocument( "" );
  13516. // Set the base href for the created document
  13517. // so any parsed elements with URLs
  13518. // are based on the document's URL (gh-2965)
  13519. base = context.createElement( "base" );
  13520. base.href = document.location.href;
  13521. context.head.appendChild( base );
  13522. } else {
  13523. context = document;
  13524. }
  13525. }
  13526. parsed = rsingleTag.exec( data );
  13527. scripts = !keepScripts && [];
  13528. // Single tag
  13529. if ( parsed ) {
  13530. return [ context.createElement( parsed[ 1 ] ) ];
  13531. }
  13532. parsed = buildFragment( [ data ], context, scripts );
  13533. if ( scripts && scripts.length ) {
  13534. jQuery( scripts ).remove();
  13535. }
  13536. return jQuery.merge( [], parsed.childNodes );
  13537. };
  13538. /**
  13539. * Load a url into a page
  13540. */
  13541. jQuery.fn.load = function( url, params, callback ) {
  13542. var selector, type, response,
  13543. self = this,
  13544. off = url.indexOf( " " );
  13545. if ( off > -1 ) {
  13546. selector = stripAndCollapse( url.slice( off ) );
  13547. url = url.slice( 0, off );
  13548. }
  13549. // If it's a function
  13550. if ( isFunction( params ) ) {
  13551. // We assume that it's the callback
  13552. callback = params;
  13553. params = undefined;
  13554. // Otherwise, build a param string
  13555. } else if ( params && typeof params === "object" ) {
  13556. type = "POST";
  13557. }
  13558. // If we have elements to modify, make the request
  13559. if ( self.length > 0 ) {
  13560. jQuery.ajax( {
  13561. url: url,
  13562. // If "type" variable is undefined, then "GET" method will be used.
  13563. // Make value of this field explicit since
  13564. // user can override it through ajaxSetup method
  13565. type: type || "GET",
  13566. dataType: "html",
  13567. data: params
  13568. } ).done( function( responseText ) {
  13569. // Save response for use in complete callback
  13570. response = arguments;
  13571. self.html( selector ?
  13572. // If a selector was specified, locate the right elements in a dummy div
  13573. // Exclude scripts to avoid IE 'Permission Denied' errors
  13574. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  13575. // Otherwise use the full result
  13576. responseText );
  13577. // If the request succeeds, this function gets "data", "status", "jqXHR"
  13578. // but they are ignored because response was set above.
  13579. // If it fails, this function gets "jqXHR", "status", "error"
  13580. } ).always( callback && function( jqXHR, status ) {
  13581. self.each( function() {
  13582. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  13583. } );
  13584. } );
  13585. }
  13586. return this;
  13587. };
  13588. jQuery.expr.pseudos.animated = function( elem ) {
  13589. return jQuery.grep( jQuery.timers, function( fn ) {
  13590. return elem === fn.elem;
  13591. } ).length;
  13592. };
  13593. jQuery.offset = {
  13594. setOffset: function( elem, options, i ) {
  13595. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  13596. position = jQuery.css( elem, "position" ),
  13597. curElem = jQuery( elem ),
  13598. props = {};
  13599. // Set position first, in-case top/left are set even on static elem
  13600. if ( position === "static" ) {
  13601. elem.style.position = "relative";
  13602. }
  13603. curOffset = curElem.offset();
  13604. curCSSTop = jQuery.css( elem, "top" );
  13605. curCSSLeft = jQuery.css( elem, "left" );
  13606. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  13607. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  13608. // Need to be able to calculate position if either
  13609. // top or left is auto and position is either absolute or fixed
  13610. if ( calculatePosition ) {
  13611. curPosition = curElem.position();
  13612. curTop = curPosition.top;
  13613. curLeft = curPosition.left;
  13614. } else {
  13615. curTop = parseFloat( curCSSTop ) || 0;
  13616. curLeft = parseFloat( curCSSLeft ) || 0;
  13617. }
  13618. if ( isFunction( options ) ) {
  13619. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  13620. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  13621. }
  13622. if ( options.top != null ) {
  13623. props.top = ( options.top - curOffset.top ) + curTop;
  13624. }
  13625. if ( options.left != null ) {
  13626. props.left = ( options.left - curOffset.left ) + curLeft;
  13627. }
  13628. if ( "using" in options ) {
  13629. options.using.call( elem, props );
  13630. } else {
  13631. if ( typeof props.top === "number" ) {
  13632. props.top += "px";
  13633. }
  13634. if ( typeof props.left === "number" ) {
  13635. props.left += "px";
  13636. }
  13637. curElem.css( props );
  13638. }
  13639. }
  13640. };
  13641. jQuery.fn.extend( {
  13642. // offset() relates an element's border box to the document origin
  13643. offset: function( options ) {
  13644. // Preserve chaining for setter
  13645. if ( arguments.length ) {
  13646. return options === undefined ?
  13647. this :
  13648. this.each( function( i ) {
  13649. jQuery.offset.setOffset( this, options, i );
  13650. } );
  13651. }
  13652. var rect, win,
  13653. elem = this[ 0 ];
  13654. if ( !elem ) {
  13655. return;
  13656. }
  13657. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  13658. // Support: IE <=11 only
  13659. // Running getBoundingClientRect on a
  13660. // disconnected node in IE throws an error
  13661. if ( !elem.getClientRects().length ) {
  13662. return { top: 0, left: 0 };
  13663. }
  13664. // Get document-relative position by adding viewport scroll to viewport-relative gBCR
  13665. rect = elem.getBoundingClientRect();
  13666. win = elem.ownerDocument.defaultView;
  13667. return {
  13668. top: rect.top + win.pageYOffset,
  13669. left: rect.left + win.pageXOffset
  13670. };
  13671. },
  13672. // position() relates an element's margin box to its offset parent's padding box
  13673. // This corresponds to the behavior of CSS absolute positioning
  13674. position: function() {
  13675. if ( !this[ 0 ] ) {
  13676. return;
  13677. }
  13678. var offsetParent, offset, doc,
  13679. elem = this[ 0 ],
  13680. parentOffset = { top: 0, left: 0 };
  13681. // position:fixed elements are offset from the viewport, which itself always has zero offset
  13682. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  13683. // Assume position:fixed implies availability of getBoundingClientRect
  13684. offset = elem.getBoundingClientRect();
  13685. } else {
  13686. offset = this.offset();
  13687. // Account for the *real* offset parent, which can be the document or its root element
  13688. // when a statically positioned element is identified
  13689. doc = elem.ownerDocument;
  13690. offsetParent = elem.offsetParent || doc.documentElement;
  13691. while ( offsetParent &&
  13692. ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
  13693. jQuery.css( offsetParent, "position" ) === "static" ) {
  13694. offsetParent = offsetParent.parentNode;
  13695. }
  13696. if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
  13697. // Incorporate borders into its offset, since they are outside its content origin
  13698. parentOffset = jQuery( offsetParent ).offset();
  13699. parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
  13700. parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
  13701. }
  13702. }
  13703. // Subtract parent offsets and element margins
  13704. return {
  13705. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  13706. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  13707. };
  13708. },
  13709. // This method will return documentElement in the following cases:
  13710. // 1) For the element inside the iframe without offsetParent, this method will return
  13711. // documentElement of the parent window
  13712. // 2) For the hidden or detached element
  13713. // 3) For body or html element, i.e. in case of the html node - it will return itself
  13714. //
  13715. // but those exceptions were never presented as a real life use-cases
  13716. // and might be considered as more preferable results.
  13717. //
  13718. // This logic, however, is not guaranteed and can change at any point in the future
  13719. offsetParent: function() {
  13720. return this.map( function() {
  13721. var offsetParent = this.offsetParent;
  13722. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  13723. offsetParent = offsetParent.offsetParent;
  13724. }
  13725. return offsetParent || documentElement;
  13726. } );
  13727. }
  13728. } );
  13729. // Create scrollLeft and scrollTop methods
  13730. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  13731. var top = "pageYOffset" === prop;
  13732. jQuery.fn[ method ] = function( val ) {
  13733. return access( this, function( elem, method, val ) {
  13734. // Coalesce documents and windows
  13735. var win;
  13736. if ( isWindow( elem ) ) {
  13737. win = elem;
  13738. } else if ( elem.nodeType === 9 ) {
  13739. win = elem.defaultView;
  13740. }
  13741. if ( val === undefined ) {
  13742. return win ? win[ prop ] : elem[ method ];
  13743. }
  13744. if ( win ) {
  13745. win.scrollTo(
  13746. !top ? val : win.pageXOffset,
  13747. top ? val : win.pageYOffset
  13748. );
  13749. } else {
  13750. elem[ method ] = val;
  13751. }
  13752. }, method, val, arguments.length );
  13753. };
  13754. } );
  13755. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  13756. // Add the top/left cssHooks using jQuery.fn.position
  13757. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  13758. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  13759. // getComputedStyle returns percent when specified for top/left/bottom/right;
  13760. // rather than make the css module depend on the offset module, just check for it here
  13761. jQuery.each( [ "top", "left" ], function( _i, prop ) {
  13762. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  13763. function( elem, computed ) {
  13764. if ( computed ) {
  13765. computed = curCSS( elem, prop );
  13766. // If curCSS returns percentage, fallback to offset
  13767. return rnumnonpx.test( computed ) ?
  13768. jQuery( elem ).position()[ prop ] + "px" :
  13769. computed;
  13770. }
  13771. }
  13772. );
  13773. } );
  13774. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  13775. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  13776. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  13777. function( defaultExtra, funcName ) {
  13778. // Margin is only for outerHeight, outerWidth
  13779. jQuery.fn[ funcName ] = function( margin, value ) {
  13780. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  13781. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  13782. return access( this, function( elem, type, value ) {
  13783. var doc;
  13784. if ( isWindow( elem ) ) {
  13785. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  13786. return funcName.indexOf( "outer" ) === 0 ?
  13787. elem[ "inner" + name ] :
  13788. elem.document.documentElement[ "client" + name ];
  13789. }
  13790. // Get document width or height
  13791. if ( elem.nodeType === 9 ) {
  13792. doc = elem.documentElement;
  13793. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  13794. // whichever is greatest
  13795. return Math.max(
  13796. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  13797. elem.body[ "offset" + name ], doc[ "offset" + name ],
  13798. doc[ "client" + name ]
  13799. );
  13800. }
  13801. return value === undefined ?
  13802. // Get width or height on the element, requesting but not forcing parseFloat
  13803. jQuery.css( elem, type, extra ) :
  13804. // Set width or height on the element
  13805. jQuery.style( elem, type, value, extra );
  13806. }, type, chainable ? margin : undefined, chainable );
  13807. };
  13808. } );
  13809. } );
  13810. jQuery.each( [
  13811. "ajaxStart",
  13812. "ajaxStop",
  13813. "ajaxComplete",
  13814. "ajaxError",
  13815. "ajaxSuccess",
  13816. "ajaxSend"
  13817. ], function( _i, type ) {
  13818. jQuery.fn[ type ] = function( fn ) {
  13819. return this.on( type, fn );
  13820. };
  13821. } );
  13822. jQuery.fn.extend( {
  13823. bind: function( types, data, fn ) {
  13824. return this.on( types, null, data, fn );
  13825. },
  13826. unbind: function( types, fn ) {
  13827. return this.off( types, null, fn );
  13828. },
  13829. delegate: function( selector, types, data, fn ) {
  13830. return this.on( types, selector, data, fn );
  13831. },
  13832. undelegate: function( selector, types, fn ) {
  13833. // ( namespace ) or ( selector, types [, fn] )
  13834. return arguments.length === 1 ?
  13835. this.off( selector, "**" ) :
  13836. this.off( types, selector || "**", fn );
  13837. },
  13838. hover: function( fnOver, fnOut ) {
  13839. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  13840. }
  13841. } );
  13842. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  13843. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  13844. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  13845. function( _i, name ) {
  13846. // Handle event binding
  13847. jQuery.fn[ name ] = function( data, fn ) {
  13848. return arguments.length > 0 ?
  13849. this.on( name, null, data, fn ) :
  13850. this.trigger( name );
  13851. };
  13852. } );
  13853. // Support: Android <=4.0 only
  13854. // Make sure we trim BOM and NBSP
  13855. var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  13856. // Bind a function to a context, optionally partially applying any
  13857. // arguments.
  13858. // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
  13859. // However, it is not slated for removal any time soon
  13860. jQuery.proxy = function( fn, context ) {
  13861. var tmp, args, proxy;
  13862. if ( typeof context === "string" ) {
  13863. tmp = fn[ context ];
  13864. context = fn;
  13865. fn = tmp;
  13866. }
  13867. // Quick check to determine if target is callable, in the spec
  13868. // this throws a TypeError, but we will just return undefined.
  13869. if ( !isFunction( fn ) ) {
  13870. return undefined;
  13871. }
  13872. // Simulated bind
  13873. args = slice.call( arguments, 2 );
  13874. proxy = function() {
  13875. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  13876. };
  13877. // Set the guid of unique handler to the same of original handler, so it can be removed
  13878. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  13879. return proxy;
  13880. };
  13881. jQuery.holdReady = function( hold ) {
  13882. if ( hold ) {
  13883. jQuery.readyWait++;
  13884. } else {
  13885. jQuery.ready( true );
  13886. }
  13887. };
  13888. jQuery.isArray = Array.isArray;
  13889. jQuery.parseJSON = JSON.parse;
  13890. jQuery.nodeName = nodeName;
  13891. jQuery.isFunction = isFunction;
  13892. jQuery.isWindow = isWindow;
  13893. jQuery.camelCase = camelCase;
  13894. jQuery.type = toType;
  13895. jQuery.now = Date.now;
  13896. jQuery.isNumeric = function( obj ) {
  13897. // As of jQuery 3.0, isNumeric is limited to
  13898. // strings and numbers (primitives or objects)
  13899. // that can be coerced to finite numbers (gh-2662)
  13900. var type = jQuery.type( obj );
  13901. return ( type === "number" || type === "string" ) &&
  13902. // parseFloat NaNs numeric-cast false positives ("")
  13903. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  13904. // subtraction forces infinities to NaN
  13905. !isNaN( obj - parseFloat( obj ) );
  13906. };
  13907. jQuery.trim = function( text ) {
  13908. return text == null ?
  13909. "" :
  13910. ( text + "" ).replace( rtrim, "" );
  13911. };
  13912. // Register as a named AMD module, since jQuery can be concatenated with other
  13913. // files that may use define, but not via a proper concatenation script that
  13914. // understands anonymous AMD modules. A named AMD is safest and most robust
  13915. // way to register. Lowercase jquery is used because AMD module names are
  13916. // derived from file names, and jQuery is normally delivered in a lowercase
  13917. // file name. Do this after creating the global so that if an AMD module wants
  13918. // to call noConflict to hide this version of jQuery, it will work.
  13919. // Note that for maximum portability, libraries that are not jQuery should
  13920. // declare themselves as anonymous modules, and avoid setting a global if an
  13921. // AMD loader is present. jQuery is a special case. For more information, see
  13922. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  13923. if ( true ) {
  13924. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  13925. return jQuery;
  13926. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  13927. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  13928. }
  13929. var
  13930. // Map over jQuery in case of overwrite
  13931. _jQuery = window.jQuery,
  13932. // Map over the $ in case of overwrite
  13933. _$ = window.$;
  13934. jQuery.noConflict = function( deep ) {
  13935. if ( window.$ === jQuery ) {
  13936. window.$ = _$;
  13937. }
  13938. if ( deep && window.jQuery === jQuery ) {
  13939. window.jQuery = _jQuery;
  13940. }
  13941. return jQuery;
  13942. };
  13943. // Expose jQuery and $ identifiers, even in AMD
  13944. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  13945. // and CommonJS for browser emulators (#13566)
  13946. if ( typeof noGlobal === "undefined" ) {
  13947. window.jQuery = window.$ = jQuery;
  13948. }
  13949. return jQuery;
  13950. } );
  13951. /***/ }),
  13952. /***/ "./node_modules/lodash/lodash.js":
  13953. /*!***************************************!*\
  13954. !*** ./node_modules/lodash/lodash.js ***!
  13955. \***************************************/
  13956. /*! no static exports found */
  13957. /***/ (function(module, exports, __webpack_require__) {
  13958. /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
  13959. * @license
  13960. * Lodash <https://lodash.com/>
  13961. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  13962. * Released under MIT license <https://lodash.com/license>
  13963. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  13964. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  13965. */
  13966. ;(function() {
  13967. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  13968. var undefined;
  13969. /** Used as the semantic version number. */
  13970. var VERSION = '4.17.15';
  13971. /** Used as the size to enable large array optimizations. */
  13972. var LARGE_ARRAY_SIZE = 200;
  13973. /** Error message constants. */
  13974. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  13975. FUNC_ERROR_TEXT = 'Expected a function';
  13976. /** Used to stand-in for `undefined` hash values. */
  13977. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  13978. /** Used as the maximum memoize cache size. */
  13979. var MAX_MEMOIZE_SIZE = 500;
  13980. /** Used as the internal argument placeholder. */
  13981. var PLACEHOLDER = '__lodash_placeholder__';
  13982. /** Used to compose bitmasks for cloning. */
  13983. var CLONE_DEEP_FLAG = 1,
  13984. CLONE_FLAT_FLAG = 2,
  13985. CLONE_SYMBOLS_FLAG = 4;
  13986. /** Used to compose bitmasks for value comparisons. */
  13987. var COMPARE_PARTIAL_FLAG = 1,
  13988. COMPARE_UNORDERED_FLAG = 2;
  13989. /** Used to compose bitmasks for function metadata. */
  13990. var WRAP_BIND_FLAG = 1,
  13991. WRAP_BIND_KEY_FLAG = 2,
  13992. WRAP_CURRY_BOUND_FLAG = 4,
  13993. WRAP_CURRY_FLAG = 8,
  13994. WRAP_CURRY_RIGHT_FLAG = 16,
  13995. WRAP_PARTIAL_FLAG = 32,
  13996. WRAP_PARTIAL_RIGHT_FLAG = 64,
  13997. WRAP_ARY_FLAG = 128,
  13998. WRAP_REARG_FLAG = 256,
  13999. WRAP_FLIP_FLAG = 512;
  14000. /** Used as default options for `_.truncate`. */
  14001. var DEFAULT_TRUNC_LENGTH = 30,
  14002. DEFAULT_TRUNC_OMISSION = '...';
  14003. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  14004. var HOT_COUNT = 800,
  14005. HOT_SPAN = 16;
  14006. /** Used to indicate the type of lazy iteratees. */
  14007. var LAZY_FILTER_FLAG = 1,
  14008. LAZY_MAP_FLAG = 2,
  14009. LAZY_WHILE_FLAG = 3;
  14010. /** Used as references for various `Number` constants. */
  14011. var INFINITY = 1 / 0,
  14012. MAX_SAFE_INTEGER = 9007199254740991,
  14013. MAX_INTEGER = 1.7976931348623157e+308,
  14014. NAN = 0 / 0;
  14015. /** Used as references for the maximum length and index of an array. */
  14016. var MAX_ARRAY_LENGTH = 4294967295,
  14017. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  14018. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  14019. /** Used to associate wrap methods with their bit flags. */
  14020. var wrapFlags = [
  14021. ['ary', WRAP_ARY_FLAG],
  14022. ['bind', WRAP_BIND_FLAG],
  14023. ['bindKey', WRAP_BIND_KEY_FLAG],
  14024. ['curry', WRAP_CURRY_FLAG],
  14025. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  14026. ['flip', WRAP_FLIP_FLAG],
  14027. ['partial', WRAP_PARTIAL_FLAG],
  14028. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  14029. ['rearg', WRAP_REARG_FLAG]
  14030. ];
  14031. /** `Object#toString` result references. */
  14032. var argsTag = '[object Arguments]',
  14033. arrayTag = '[object Array]',
  14034. asyncTag = '[object AsyncFunction]',
  14035. boolTag = '[object Boolean]',
  14036. dateTag = '[object Date]',
  14037. domExcTag = '[object DOMException]',
  14038. errorTag = '[object Error]',
  14039. funcTag = '[object Function]',
  14040. genTag = '[object GeneratorFunction]',
  14041. mapTag = '[object Map]',
  14042. numberTag = '[object Number]',
  14043. nullTag = '[object Null]',
  14044. objectTag = '[object Object]',
  14045. promiseTag = '[object Promise]',
  14046. proxyTag = '[object Proxy]',
  14047. regexpTag = '[object RegExp]',
  14048. setTag = '[object Set]',
  14049. stringTag = '[object String]',
  14050. symbolTag = '[object Symbol]',
  14051. undefinedTag = '[object Undefined]',
  14052. weakMapTag = '[object WeakMap]',
  14053. weakSetTag = '[object WeakSet]';
  14054. var arrayBufferTag = '[object ArrayBuffer]',
  14055. dataViewTag = '[object DataView]',
  14056. float32Tag = '[object Float32Array]',
  14057. float64Tag = '[object Float64Array]',
  14058. int8Tag = '[object Int8Array]',
  14059. int16Tag = '[object Int16Array]',
  14060. int32Tag = '[object Int32Array]',
  14061. uint8Tag = '[object Uint8Array]',
  14062. uint8ClampedTag = '[object Uint8ClampedArray]',
  14063. uint16Tag = '[object Uint16Array]',
  14064. uint32Tag = '[object Uint32Array]';
  14065. /** Used to match empty string literals in compiled template source. */
  14066. var reEmptyStringLeading = /\b__p \+= '';/g,
  14067. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  14068. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  14069. /** Used to match HTML entities and HTML characters. */
  14070. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  14071. reUnescapedHtml = /[&<>"']/g,
  14072. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  14073. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  14074. /** Used to match template delimiters. */
  14075. var reEscape = /<%-([\s\S]+?)%>/g,
  14076. reEvaluate = /<%([\s\S]+?)%>/g,
  14077. reInterpolate = /<%=([\s\S]+?)%>/g;
  14078. /** Used to match property names within property paths. */
  14079. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  14080. reIsPlainProp = /^\w*$/,
  14081. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  14082. /**
  14083. * Used to match `RegExp`
  14084. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  14085. */
  14086. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  14087. reHasRegExpChar = RegExp(reRegExpChar.source);
  14088. /** Used to match leading and trailing whitespace. */
  14089. var reTrim = /^\s+|\s+$/g,
  14090. reTrimStart = /^\s+/,
  14091. reTrimEnd = /\s+$/;
  14092. /** Used to match wrap detail comments. */
  14093. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  14094. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  14095. reSplitDetails = /,? & /;
  14096. /** Used to match words composed of alphanumeric characters. */
  14097. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  14098. /** Used to match backslashes in property paths. */
  14099. var reEscapeChar = /\\(\\)?/g;
  14100. /**
  14101. * Used to match
  14102. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  14103. */
  14104. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  14105. /** Used to match `RegExp` flags from their coerced string values. */
  14106. var reFlags = /\w*$/;
  14107. /** Used to detect bad signed hexadecimal string values. */
  14108. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  14109. /** Used to detect binary string values. */
  14110. var reIsBinary = /^0b[01]+$/i;
  14111. /** Used to detect host constructors (Safari). */
  14112. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  14113. /** Used to detect octal string values. */
  14114. var reIsOctal = /^0o[0-7]+$/i;
  14115. /** Used to detect unsigned integer values. */
  14116. var reIsUint = /^(?:0|[1-9]\d*)$/;
  14117. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  14118. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  14119. /** Used to ensure capturing order of template delimiters. */
  14120. var reNoMatch = /($^)/;
  14121. /** Used to match unescaped characters in compiled string literals. */
  14122. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  14123. /** Used to compose unicode character classes. */
  14124. var rsAstralRange = '\\ud800-\\udfff',
  14125. rsComboMarksRange = '\\u0300-\\u036f',
  14126. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  14127. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  14128. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  14129. rsDingbatRange = '\\u2700-\\u27bf',
  14130. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  14131. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  14132. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  14133. rsPunctuationRange = '\\u2000-\\u206f',
  14134. 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',
  14135. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  14136. rsVarRange = '\\ufe0e\\ufe0f',
  14137. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  14138. /** Used to compose unicode capture groups. */
  14139. var rsApos = "['\u2019]",
  14140. rsAstral = '[' + rsAstralRange + ']',
  14141. rsBreak = '[' + rsBreakRange + ']',
  14142. rsCombo = '[' + rsComboRange + ']',
  14143. rsDigits = '\\d+',
  14144. rsDingbat = '[' + rsDingbatRange + ']',
  14145. rsLower = '[' + rsLowerRange + ']',
  14146. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  14147. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  14148. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  14149. rsNonAstral = '[^' + rsAstralRange + ']',
  14150. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  14151. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  14152. rsUpper = '[' + rsUpperRange + ']',
  14153. rsZWJ = '\\u200d';
  14154. /** Used to compose unicode regexes. */
  14155. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  14156. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  14157. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  14158. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  14159. reOptMod = rsModifier + '?',
  14160. rsOptVar = '[' + rsVarRange + ']?',
  14161. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  14162. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  14163. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  14164. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  14165. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  14166. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  14167. /** Used to match apostrophes. */
  14168. var reApos = RegExp(rsApos, 'g');
  14169. /**
  14170. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  14171. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  14172. */
  14173. var reComboMark = RegExp(rsCombo, 'g');
  14174. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  14175. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  14176. /** Used to match complex or compound words. */
  14177. var reUnicodeWord = RegExp([
  14178. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  14179. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  14180. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  14181. rsUpper + '+' + rsOptContrUpper,
  14182. rsOrdUpper,
  14183. rsOrdLower,
  14184. rsDigits,
  14185. rsEmoji
  14186. ].join('|'), 'g');
  14187. /** 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/). */
  14188. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  14189. /** Used to detect strings that need a more robust regexp to match words. */
  14190. 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 ]/;
  14191. /** Used to assign default `context` object properties. */
  14192. var contextProps = [
  14193. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  14194. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  14195. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  14196. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  14197. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  14198. ];
  14199. /** Used to make template sourceURLs easier to identify. */
  14200. var templateCounter = -1;
  14201. /** Used to identify `toStringTag` values of typed arrays. */
  14202. var typedArrayTags = {};
  14203. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  14204. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  14205. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  14206. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  14207. typedArrayTags[uint32Tag] = true;
  14208. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  14209. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  14210. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  14211. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  14212. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  14213. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  14214. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  14215. typedArrayTags[weakMapTag] = false;
  14216. /** Used to identify `toStringTag` values supported by `_.clone`. */
  14217. var cloneableTags = {};
  14218. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  14219. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  14220. cloneableTags[boolTag] = cloneableTags[dateTag] =
  14221. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  14222. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  14223. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  14224. cloneableTags[numberTag] = cloneableTags[objectTag] =
  14225. cloneableTags[regexpTag] = cloneableTags[setTag] =
  14226. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  14227. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  14228. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  14229. cloneableTags[errorTag] = cloneableTags[funcTag] =
  14230. cloneableTags[weakMapTag] = false;
  14231. /** Used to map Latin Unicode letters to basic Latin letters. */
  14232. var deburredLetters = {
  14233. // Latin-1 Supplement block.
  14234. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  14235. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  14236. '\xc7': 'C', '\xe7': 'c',
  14237. '\xd0': 'D', '\xf0': 'd',
  14238. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  14239. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  14240. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  14241. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  14242. '\xd1': 'N', '\xf1': 'n',
  14243. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  14244. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  14245. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  14246. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  14247. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  14248. '\xc6': 'Ae', '\xe6': 'ae',
  14249. '\xde': 'Th', '\xfe': 'th',
  14250. '\xdf': 'ss',
  14251. // Latin Extended-A block.
  14252. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  14253. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  14254. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  14255. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  14256. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  14257. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  14258. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  14259. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  14260. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  14261. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  14262. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  14263. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  14264. '\u0134': 'J', '\u0135': 'j',
  14265. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  14266. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  14267. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  14268. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  14269. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  14270. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  14271. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  14272. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  14273. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  14274. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  14275. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  14276. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  14277. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  14278. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  14279. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  14280. '\u0174': 'W', '\u0175': 'w',
  14281. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  14282. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  14283. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  14284. '\u0132': 'IJ', '\u0133': 'ij',
  14285. '\u0152': 'Oe', '\u0153': 'oe',
  14286. '\u0149': "'n", '\u017f': 's'
  14287. };
  14288. /** Used to map characters to HTML entities. */
  14289. var htmlEscapes = {
  14290. '&': '&amp;',
  14291. '<': '&lt;',
  14292. '>': '&gt;',
  14293. '"': '&quot;',
  14294. "'": '&#39;'
  14295. };
  14296. /** Used to map HTML entities to characters. */
  14297. var htmlUnescapes = {
  14298. '&amp;': '&',
  14299. '&lt;': '<',
  14300. '&gt;': '>',
  14301. '&quot;': '"',
  14302. '&#39;': "'"
  14303. };
  14304. /** Used to escape characters for inclusion in compiled string literals. */
  14305. var stringEscapes = {
  14306. '\\': '\\',
  14307. "'": "'",
  14308. '\n': 'n',
  14309. '\r': 'r',
  14310. '\u2028': 'u2028',
  14311. '\u2029': 'u2029'
  14312. };
  14313. /** Built-in method references without a dependency on `root`. */
  14314. var freeParseFloat = parseFloat,
  14315. freeParseInt = parseInt;
  14316. /** Detect free variable `global` from Node.js. */
  14317. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  14318. /** Detect free variable `self`. */
  14319. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  14320. /** Used as a reference to the global object. */
  14321. var root = freeGlobal || freeSelf || Function('return this')();
  14322. /** Detect free variable `exports`. */
  14323. var freeExports = true && exports && !exports.nodeType && exports;
  14324. /** Detect free variable `module`. */
  14325. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  14326. /** Detect the popular CommonJS extension `module.exports`. */
  14327. var moduleExports = freeModule && freeModule.exports === freeExports;
  14328. /** Detect free variable `process` from Node.js. */
  14329. var freeProcess = moduleExports && freeGlobal.process;
  14330. /** Used to access faster Node.js helpers. */
  14331. var nodeUtil = (function() {
  14332. try {
  14333. // Use `util.types` for Node.js 10+.
  14334. var types = freeModule && freeModule.require && freeModule.require('util').types;
  14335. if (types) {
  14336. return types;
  14337. }
  14338. // Legacy `process.binding('util')` for Node.js < 10.
  14339. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  14340. } catch (e) {}
  14341. }());
  14342. /* Node.js helper references. */
  14343. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  14344. nodeIsDate = nodeUtil && nodeUtil.isDate,
  14345. nodeIsMap = nodeUtil && nodeUtil.isMap,
  14346. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  14347. nodeIsSet = nodeUtil && nodeUtil.isSet,
  14348. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  14349. /*--------------------------------------------------------------------------*/
  14350. /**
  14351. * A faster alternative to `Function#apply`, this function invokes `func`
  14352. * with the `this` binding of `thisArg` and the arguments of `args`.
  14353. *
  14354. * @private
  14355. * @param {Function} func The function to invoke.
  14356. * @param {*} thisArg The `this` binding of `func`.
  14357. * @param {Array} args The arguments to invoke `func` with.
  14358. * @returns {*} Returns the result of `func`.
  14359. */
  14360. function apply(func, thisArg, args) {
  14361. switch (args.length) {
  14362. case 0: return func.call(thisArg);
  14363. case 1: return func.call(thisArg, args[0]);
  14364. case 2: return func.call(thisArg, args[0], args[1]);
  14365. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  14366. }
  14367. return func.apply(thisArg, args);
  14368. }
  14369. /**
  14370. * A specialized version of `baseAggregator` for arrays.
  14371. *
  14372. * @private
  14373. * @param {Array} [array] The array to iterate over.
  14374. * @param {Function} setter The function to set `accumulator` values.
  14375. * @param {Function} iteratee The iteratee to transform keys.
  14376. * @param {Object} accumulator The initial aggregated object.
  14377. * @returns {Function} Returns `accumulator`.
  14378. */
  14379. function arrayAggregator(array, setter, iteratee, accumulator) {
  14380. var index = -1,
  14381. length = array == null ? 0 : array.length;
  14382. while (++index < length) {
  14383. var value = array[index];
  14384. setter(accumulator, value, iteratee(value), array);
  14385. }
  14386. return accumulator;
  14387. }
  14388. /**
  14389. * A specialized version of `_.forEach` for arrays without support for
  14390. * iteratee shorthands.
  14391. *
  14392. * @private
  14393. * @param {Array} [array] The array to iterate over.
  14394. * @param {Function} iteratee The function invoked per iteration.
  14395. * @returns {Array} Returns `array`.
  14396. */
  14397. function arrayEach(array, iteratee) {
  14398. var index = -1,
  14399. length = array == null ? 0 : array.length;
  14400. while (++index < length) {
  14401. if (iteratee(array[index], index, array) === false) {
  14402. break;
  14403. }
  14404. }
  14405. return array;
  14406. }
  14407. /**
  14408. * A specialized version of `_.forEachRight` for arrays without support for
  14409. * iteratee shorthands.
  14410. *
  14411. * @private
  14412. * @param {Array} [array] The array to iterate over.
  14413. * @param {Function} iteratee The function invoked per iteration.
  14414. * @returns {Array} Returns `array`.
  14415. */
  14416. function arrayEachRight(array, iteratee) {
  14417. var length = array == null ? 0 : array.length;
  14418. while (length--) {
  14419. if (iteratee(array[length], length, array) === false) {
  14420. break;
  14421. }
  14422. }
  14423. return array;
  14424. }
  14425. /**
  14426. * A specialized version of `_.every` for arrays without support for
  14427. * iteratee shorthands.
  14428. *
  14429. * @private
  14430. * @param {Array} [array] The array to iterate over.
  14431. * @param {Function} predicate The function invoked per iteration.
  14432. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  14433. * else `false`.
  14434. */
  14435. function arrayEvery(array, predicate) {
  14436. var index = -1,
  14437. length = array == null ? 0 : array.length;
  14438. while (++index < length) {
  14439. if (!predicate(array[index], index, array)) {
  14440. return false;
  14441. }
  14442. }
  14443. return true;
  14444. }
  14445. /**
  14446. * A specialized version of `_.filter` for arrays without support for
  14447. * iteratee shorthands.
  14448. *
  14449. * @private
  14450. * @param {Array} [array] The array to iterate over.
  14451. * @param {Function} predicate The function invoked per iteration.
  14452. * @returns {Array} Returns the new filtered array.
  14453. */
  14454. function arrayFilter(array, predicate) {
  14455. var index = -1,
  14456. length = array == null ? 0 : array.length,
  14457. resIndex = 0,
  14458. result = [];
  14459. while (++index < length) {
  14460. var value = array[index];
  14461. if (predicate(value, index, array)) {
  14462. result[resIndex++] = value;
  14463. }
  14464. }
  14465. return result;
  14466. }
  14467. /**
  14468. * A specialized version of `_.includes` for arrays without support for
  14469. * specifying an index to search from.
  14470. *
  14471. * @private
  14472. * @param {Array} [array] The array to inspect.
  14473. * @param {*} target The value to search for.
  14474. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  14475. */
  14476. function arrayIncludes(array, value) {
  14477. var length = array == null ? 0 : array.length;
  14478. return !!length && baseIndexOf(array, value, 0) > -1;
  14479. }
  14480. /**
  14481. * This function is like `arrayIncludes` except that it accepts a comparator.
  14482. *
  14483. * @private
  14484. * @param {Array} [array] The array to inspect.
  14485. * @param {*} target The value to search for.
  14486. * @param {Function} comparator The comparator invoked per element.
  14487. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  14488. */
  14489. function arrayIncludesWith(array, value, comparator) {
  14490. var index = -1,
  14491. length = array == null ? 0 : array.length;
  14492. while (++index < length) {
  14493. if (comparator(value, array[index])) {
  14494. return true;
  14495. }
  14496. }
  14497. return false;
  14498. }
  14499. /**
  14500. * A specialized version of `_.map` for arrays without support for iteratee
  14501. * shorthands.
  14502. *
  14503. * @private
  14504. * @param {Array} [array] The array to iterate over.
  14505. * @param {Function} iteratee The function invoked per iteration.
  14506. * @returns {Array} Returns the new mapped array.
  14507. */
  14508. function arrayMap(array, iteratee) {
  14509. var index = -1,
  14510. length = array == null ? 0 : array.length,
  14511. result = Array(length);
  14512. while (++index < length) {
  14513. result[index] = iteratee(array[index], index, array);
  14514. }
  14515. return result;
  14516. }
  14517. /**
  14518. * Appends the elements of `values` to `array`.
  14519. *
  14520. * @private
  14521. * @param {Array} array The array to modify.
  14522. * @param {Array} values The values to append.
  14523. * @returns {Array} Returns `array`.
  14524. */
  14525. function arrayPush(array, values) {
  14526. var index = -1,
  14527. length = values.length,
  14528. offset = array.length;
  14529. while (++index < length) {
  14530. array[offset + index] = values[index];
  14531. }
  14532. return array;
  14533. }
  14534. /**
  14535. * A specialized version of `_.reduce` for arrays without support for
  14536. * iteratee shorthands.
  14537. *
  14538. * @private
  14539. * @param {Array} [array] The array to iterate over.
  14540. * @param {Function} iteratee The function invoked per iteration.
  14541. * @param {*} [accumulator] The initial value.
  14542. * @param {boolean} [initAccum] Specify using the first element of `array` as
  14543. * the initial value.
  14544. * @returns {*} Returns the accumulated value.
  14545. */
  14546. function arrayReduce(array, iteratee, accumulator, initAccum) {
  14547. var index = -1,
  14548. length = array == null ? 0 : array.length;
  14549. if (initAccum && length) {
  14550. accumulator = array[++index];
  14551. }
  14552. while (++index < length) {
  14553. accumulator = iteratee(accumulator, array[index], index, array);
  14554. }
  14555. return accumulator;
  14556. }
  14557. /**
  14558. * A specialized version of `_.reduceRight` for arrays without support for
  14559. * iteratee shorthands.
  14560. *
  14561. * @private
  14562. * @param {Array} [array] The array to iterate over.
  14563. * @param {Function} iteratee The function invoked per iteration.
  14564. * @param {*} [accumulator] The initial value.
  14565. * @param {boolean} [initAccum] Specify using the last element of `array` as
  14566. * the initial value.
  14567. * @returns {*} Returns the accumulated value.
  14568. */
  14569. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  14570. var length = array == null ? 0 : array.length;
  14571. if (initAccum && length) {
  14572. accumulator = array[--length];
  14573. }
  14574. while (length--) {
  14575. accumulator = iteratee(accumulator, array[length], length, array);
  14576. }
  14577. return accumulator;
  14578. }
  14579. /**
  14580. * A specialized version of `_.some` for arrays without support for iteratee
  14581. * shorthands.
  14582. *
  14583. * @private
  14584. * @param {Array} [array] The array to iterate over.
  14585. * @param {Function} predicate The function invoked per iteration.
  14586. * @returns {boolean} Returns `true` if any element passes the predicate check,
  14587. * else `false`.
  14588. */
  14589. function arraySome(array, predicate) {
  14590. var index = -1,
  14591. length = array == null ? 0 : array.length;
  14592. while (++index < length) {
  14593. if (predicate(array[index], index, array)) {
  14594. return true;
  14595. }
  14596. }
  14597. return false;
  14598. }
  14599. /**
  14600. * Gets the size of an ASCII `string`.
  14601. *
  14602. * @private
  14603. * @param {string} string The string inspect.
  14604. * @returns {number} Returns the string size.
  14605. */
  14606. var asciiSize = baseProperty('length');
  14607. /**
  14608. * Converts an ASCII `string` to an array.
  14609. *
  14610. * @private
  14611. * @param {string} string The string to convert.
  14612. * @returns {Array} Returns the converted array.
  14613. */
  14614. function asciiToArray(string) {
  14615. return string.split('');
  14616. }
  14617. /**
  14618. * Splits an ASCII `string` into an array of its words.
  14619. *
  14620. * @private
  14621. * @param {string} The string to inspect.
  14622. * @returns {Array} Returns the words of `string`.
  14623. */
  14624. function asciiWords(string) {
  14625. return string.match(reAsciiWord) || [];
  14626. }
  14627. /**
  14628. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  14629. * without support for iteratee shorthands, which iterates over `collection`
  14630. * using `eachFunc`.
  14631. *
  14632. * @private
  14633. * @param {Array|Object} collection The collection to inspect.
  14634. * @param {Function} predicate The function invoked per iteration.
  14635. * @param {Function} eachFunc The function to iterate over `collection`.
  14636. * @returns {*} Returns the found element or its key, else `undefined`.
  14637. */
  14638. function baseFindKey(collection, predicate, eachFunc) {
  14639. var result;
  14640. eachFunc(collection, function(value, key, collection) {
  14641. if (predicate(value, key, collection)) {
  14642. result = key;
  14643. return false;
  14644. }
  14645. });
  14646. return result;
  14647. }
  14648. /**
  14649. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  14650. * support for iteratee shorthands.
  14651. *
  14652. * @private
  14653. * @param {Array} array The array to inspect.
  14654. * @param {Function} predicate The function invoked per iteration.
  14655. * @param {number} fromIndex The index to search from.
  14656. * @param {boolean} [fromRight] Specify iterating from right to left.
  14657. * @returns {number} Returns the index of the matched value, else `-1`.
  14658. */
  14659. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  14660. var length = array.length,
  14661. index = fromIndex + (fromRight ? 1 : -1);
  14662. while ((fromRight ? index-- : ++index < length)) {
  14663. if (predicate(array[index], index, array)) {
  14664. return index;
  14665. }
  14666. }
  14667. return -1;
  14668. }
  14669. /**
  14670. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  14671. *
  14672. * @private
  14673. * @param {Array} array The array to inspect.
  14674. * @param {*} value The value to search for.
  14675. * @param {number} fromIndex The index to search from.
  14676. * @returns {number} Returns the index of the matched value, else `-1`.
  14677. */
  14678. function baseIndexOf(array, value, fromIndex) {
  14679. return value === value
  14680. ? strictIndexOf(array, value, fromIndex)
  14681. : baseFindIndex(array, baseIsNaN, fromIndex);
  14682. }
  14683. /**
  14684. * This function is like `baseIndexOf` except that it accepts a comparator.
  14685. *
  14686. * @private
  14687. * @param {Array} array The array to inspect.
  14688. * @param {*} value The value to search for.
  14689. * @param {number} fromIndex The index to search from.
  14690. * @param {Function} comparator The comparator invoked per element.
  14691. * @returns {number} Returns the index of the matched value, else `-1`.
  14692. */
  14693. function baseIndexOfWith(array, value, fromIndex, comparator) {
  14694. var index = fromIndex - 1,
  14695. length = array.length;
  14696. while (++index < length) {
  14697. if (comparator(array[index], value)) {
  14698. return index;
  14699. }
  14700. }
  14701. return -1;
  14702. }
  14703. /**
  14704. * The base implementation of `_.isNaN` without support for number objects.
  14705. *
  14706. * @private
  14707. * @param {*} value The value to check.
  14708. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  14709. */
  14710. function baseIsNaN(value) {
  14711. return value !== value;
  14712. }
  14713. /**
  14714. * The base implementation of `_.mean` and `_.meanBy` without support for
  14715. * iteratee shorthands.
  14716. *
  14717. * @private
  14718. * @param {Array} array The array to iterate over.
  14719. * @param {Function} iteratee The function invoked per iteration.
  14720. * @returns {number} Returns the mean.
  14721. */
  14722. function baseMean(array, iteratee) {
  14723. var length = array == null ? 0 : array.length;
  14724. return length ? (baseSum(array, iteratee) / length) : NAN;
  14725. }
  14726. /**
  14727. * The base implementation of `_.property` without support for deep paths.
  14728. *
  14729. * @private
  14730. * @param {string} key The key of the property to get.
  14731. * @returns {Function} Returns the new accessor function.
  14732. */
  14733. function baseProperty(key) {
  14734. return function(object) {
  14735. return object == null ? undefined : object[key];
  14736. };
  14737. }
  14738. /**
  14739. * The base implementation of `_.propertyOf` without support for deep paths.
  14740. *
  14741. * @private
  14742. * @param {Object} object The object to query.
  14743. * @returns {Function} Returns the new accessor function.
  14744. */
  14745. function basePropertyOf(object) {
  14746. return function(key) {
  14747. return object == null ? undefined : object[key];
  14748. };
  14749. }
  14750. /**
  14751. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  14752. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  14753. *
  14754. * @private
  14755. * @param {Array|Object} collection The collection to iterate over.
  14756. * @param {Function} iteratee The function invoked per iteration.
  14757. * @param {*} accumulator The initial value.
  14758. * @param {boolean} initAccum Specify using the first or last element of
  14759. * `collection` as the initial value.
  14760. * @param {Function} eachFunc The function to iterate over `collection`.
  14761. * @returns {*} Returns the accumulated value.
  14762. */
  14763. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  14764. eachFunc(collection, function(value, index, collection) {
  14765. accumulator = initAccum
  14766. ? (initAccum = false, value)
  14767. : iteratee(accumulator, value, index, collection);
  14768. });
  14769. return accumulator;
  14770. }
  14771. /**
  14772. * The base implementation of `_.sortBy` which uses `comparer` to define the
  14773. * sort order of `array` and replaces criteria objects with their corresponding
  14774. * values.
  14775. *
  14776. * @private
  14777. * @param {Array} array The array to sort.
  14778. * @param {Function} comparer The function to define sort order.
  14779. * @returns {Array} Returns `array`.
  14780. */
  14781. function baseSortBy(array, comparer) {
  14782. var length = array.length;
  14783. array.sort(comparer);
  14784. while (length--) {
  14785. array[length] = array[length].value;
  14786. }
  14787. return array;
  14788. }
  14789. /**
  14790. * The base implementation of `_.sum` and `_.sumBy` without support for
  14791. * iteratee shorthands.
  14792. *
  14793. * @private
  14794. * @param {Array} array The array to iterate over.
  14795. * @param {Function} iteratee The function invoked per iteration.
  14796. * @returns {number} Returns the sum.
  14797. */
  14798. function baseSum(array, iteratee) {
  14799. var result,
  14800. index = -1,
  14801. length = array.length;
  14802. while (++index < length) {
  14803. var current = iteratee(array[index]);
  14804. if (current !== undefined) {
  14805. result = result === undefined ? current : (result + current);
  14806. }
  14807. }
  14808. return result;
  14809. }
  14810. /**
  14811. * The base implementation of `_.times` without support for iteratee shorthands
  14812. * or max array length checks.
  14813. *
  14814. * @private
  14815. * @param {number} n The number of times to invoke `iteratee`.
  14816. * @param {Function} iteratee The function invoked per iteration.
  14817. * @returns {Array} Returns the array of results.
  14818. */
  14819. function baseTimes(n, iteratee) {
  14820. var index = -1,
  14821. result = Array(n);
  14822. while (++index < n) {
  14823. result[index] = iteratee(index);
  14824. }
  14825. return result;
  14826. }
  14827. /**
  14828. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  14829. * of key-value pairs for `object` corresponding to the property names of `props`.
  14830. *
  14831. * @private
  14832. * @param {Object} object The object to query.
  14833. * @param {Array} props The property names to get values for.
  14834. * @returns {Object} Returns the key-value pairs.
  14835. */
  14836. function baseToPairs(object, props) {
  14837. return arrayMap(props, function(key) {
  14838. return [key, object[key]];
  14839. });
  14840. }
  14841. /**
  14842. * The base implementation of `_.unary` without support for storing metadata.
  14843. *
  14844. * @private
  14845. * @param {Function} func The function to cap arguments for.
  14846. * @returns {Function} Returns the new capped function.
  14847. */
  14848. function baseUnary(func) {
  14849. return function(value) {
  14850. return func(value);
  14851. };
  14852. }
  14853. /**
  14854. * The base implementation of `_.values` and `_.valuesIn` which creates an
  14855. * array of `object` property values corresponding to the property names
  14856. * of `props`.
  14857. *
  14858. * @private
  14859. * @param {Object} object The object to query.
  14860. * @param {Array} props The property names to get values for.
  14861. * @returns {Object} Returns the array of property values.
  14862. */
  14863. function baseValues(object, props) {
  14864. return arrayMap(props, function(key) {
  14865. return object[key];
  14866. });
  14867. }
  14868. /**
  14869. * Checks if a `cache` value for `key` exists.
  14870. *
  14871. * @private
  14872. * @param {Object} cache The cache to query.
  14873. * @param {string} key The key of the entry to check.
  14874. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  14875. */
  14876. function cacheHas(cache, key) {
  14877. return cache.has(key);
  14878. }
  14879. /**
  14880. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  14881. * that is not found in the character symbols.
  14882. *
  14883. * @private
  14884. * @param {Array} strSymbols The string symbols to inspect.
  14885. * @param {Array} chrSymbols The character symbols to find.
  14886. * @returns {number} Returns the index of the first unmatched string symbol.
  14887. */
  14888. function charsStartIndex(strSymbols, chrSymbols) {
  14889. var index = -1,
  14890. length = strSymbols.length;
  14891. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  14892. return index;
  14893. }
  14894. /**
  14895. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  14896. * that is not found in the character symbols.
  14897. *
  14898. * @private
  14899. * @param {Array} strSymbols The string symbols to inspect.
  14900. * @param {Array} chrSymbols The character symbols to find.
  14901. * @returns {number} Returns the index of the last unmatched string symbol.
  14902. */
  14903. function charsEndIndex(strSymbols, chrSymbols) {
  14904. var index = strSymbols.length;
  14905. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  14906. return index;
  14907. }
  14908. /**
  14909. * Gets the number of `placeholder` occurrences in `array`.
  14910. *
  14911. * @private
  14912. * @param {Array} array The array to inspect.
  14913. * @param {*} placeholder The placeholder to search for.
  14914. * @returns {number} Returns the placeholder count.
  14915. */
  14916. function countHolders(array, placeholder) {
  14917. var length = array.length,
  14918. result = 0;
  14919. while (length--) {
  14920. if (array[length] === placeholder) {
  14921. ++result;
  14922. }
  14923. }
  14924. return result;
  14925. }
  14926. /**
  14927. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  14928. * letters to basic Latin letters.
  14929. *
  14930. * @private
  14931. * @param {string} letter The matched letter to deburr.
  14932. * @returns {string} Returns the deburred letter.
  14933. */
  14934. var deburrLetter = basePropertyOf(deburredLetters);
  14935. /**
  14936. * Used by `_.escape` to convert characters to HTML entities.
  14937. *
  14938. * @private
  14939. * @param {string} chr The matched character to escape.
  14940. * @returns {string} Returns the escaped character.
  14941. */
  14942. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  14943. /**
  14944. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  14945. *
  14946. * @private
  14947. * @param {string} chr The matched character to escape.
  14948. * @returns {string} Returns the escaped character.
  14949. */
  14950. function escapeStringChar(chr) {
  14951. return '\\' + stringEscapes[chr];
  14952. }
  14953. /**
  14954. * Gets the value at `key` of `object`.
  14955. *
  14956. * @private
  14957. * @param {Object} [object] The object to query.
  14958. * @param {string} key The key of the property to get.
  14959. * @returns {*} Returns the property value.
  14960. */
  14961. function getValue(object, key) {
  14962. return object == null ? undefined : object[key];
  14963. }
  14964. /**
  14965. * Checks if `string` contains Unicode symbols.
  14966. *
  14967. * @private
  14968. * @param {string} string The string to inspect.
  14969. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  14970. */
  14971. function hasUnicode(string) {
  14972. return reHasUnicode.test(string);
  14973. }
  14974. /**
  14975. * Checks if `string` contains a word composed of Unicode symbols.
  14976. *
  14977. * @private
  14978. * @param {string} string The string to inspect.
  14979. * @returns {boolean} Returns `true` if a word is found, else `false`.
  14980. */
  14981. function hasUnicodeWord(string) {
  14982. return reHasUnicodeWord.test(string);
  14983. }
  14984. /**
  14985. * Converts `iterator` to an array.
  14986. *
  14987. * @private
  14988. * @param {Object} iterator The iterator to convert.
  14989. * @returns {Array} Returns the converted array.
  14990. */
  14991. function iteratorToArray(iterator) {
  14992. var data,
  14993. result = [];
  14994. while (!(data = iterator.next()).done) {
  14995. result.push(data.value);
  14996. }
  14997. return result;
  14998. }
  14999. /**
  15000. * Converts `map` to its key-value pairs.
  15001. *
  15002. * @private
  15003. * @param {Object} map The map to convert.
  15004. * @returns {Array} Returns the key-value pairs.
  15005. */
  15006. function mapToArray(map) {
  15007. var index = -1,
  15008. result = Array(map.size);
  15009. map.forEach(function(value, key) {
  15010. result[++index] = [key, value];
  15011. });
  15012. return result;
  15013. }
  15014. /**
  15015. * Creates a unary function that invokes `func` with its argument transformed.
  15016. *
  15017. * @private
  15018. * @param {Function} func The function to wrap.
  15019. * @param {Function} transform The argument transform.
  15020. * @returns {Function} Returns the new function.
  15021. */
  15022. function overArg(func, transform) {
  15023. return function(arg) {
  15024. return func(transform(arg));
  15025. };
  15026. }
  15027. /**
  15028. * Replaces all `placeholder` elements in `array` with an internal placeholder
  15029. * and returns an array of their indexes.
  15030. *
  15031. * @private
  15032. * @param {Array} array The array to modify.
  15033. * @param {*} placeholder The placeholder to replace.
  15034. * @returns {Array} Returns the new array of placeholder indexes.
  15035. */
  15036. function replaceHolders(array, placeholder) {
  15037. var index = -1,
  15038. length = array.length,
  15039. resIndex = 0,
  15040. result = [];
  15041. while (++index < length) {
  15042. var value = array[index];
  15043. if (value === placeholder || value === PLACEHOLDER) {
  15044. array[index] = PLACEHOLDER;
  15045. result[resIndex++] = index;
  15046. }
  15047. }
  15048. return result;
  15049. }
  15050. /**
  15051. * Converts `set` to an array of its values.
  15052. *
  15053. * @private
  15054. * @param {Object} set The set to convert.
  15055. * @returns {Array} Returns the values.
  15056. */
  15057. function setToArray(set) {
  15058. var index = -1,
  15059. result = Array(set.size);
  15060. set.forEach(function(value) {
  15061. result[++index] = value;
  15062. });
  15063. return result;
  15064. }
  15065. /**
  15066. * Converts `set` to its value-value pairs.
  15067. *
  15068. * @private
  15069. * @param {Object} set The set to convert.
  15070. * @returns {Array} Returns the value-value pairs.
  15071. */
  15072. function setToPairs(set) {
  15073. var index = -1,
  15074. result = Array(set.size);
  15075. set.forEach(function(value) {
  15076. result[++index] = [value, value];
  15077. });
  15078. return result;
  15079. }
  15080. /**
  15081. * A specialized version of `_.indexOf` which performs strict equality
  15082. * comparisons of values, i.e. `===`.
  15083. *
  15084. * @private
  15085. * @param {Array} array The array to inspect.
  15086. * @param {*} value The value to search for.
  15087. * @param {number} fromIndex The index to search from.
  15088. * @returns {number} Returns the index of the matched value, else `-1`.
  15089. */
  15090. function strictIndexOf(array, value, fromIndex) {
  15091. var index = fromIndex - 1,
  15092. length = array.length;
  15093. while (++index < length) {
  15094. if (array[index] === value) {
  15095. return index;
  15096. }
  15097. }
  15098. return -1;
  15099. }
  15100. /**
  15101. * A specialized version of `_.lastIndexOf` which performs strict equality
  15102. * comparisons of values, i.e. `===`.
  15103. *
  15104. * @private
  15105. * @param {Array} array The array to inspect.
  15106. * @param {*} value The value to search for.
  15107. * @param {number} fromIndex The index to search from.
  15108. * @returns {number} Returns the index of the matched value, else `-1`.
  15109. */
  15110. function strictLastIndexOf(array, value, fromIndex) {
  15111. var index = fromIndex + 1;
  15112. while (index--) {
  15113. if (array[index] === value) {
  15114. return index;
  15115. }
  15116. }
  15117. return index;
  15118. }
  15119. /**
  15120. * Gets the number of symbols in `string`.
  15121. *
  15122. * @private
  15123. * @param {string} string The string to inspect.
  15124. * @returns {number} Returns the string size.
  15125. */
  15126. function stringSize(string) {
  15127. return hasUnicode(string)
  15128. ? unicodeSize(string)
  15129. : asciiSize(string);
  15130. }
  15131. /**
  15132. * Converts `string` to an array.
  15133. *
  15134. * @private
  15135. * @param {string} string The string to convert.
  15136. * @returns {Array} Returns the converted array.
  15137. */
  15138. function stringToArray(string) {
  15139. return hasUnicode(string)
  15140. ? unicodeToArray(string)
  15141. : asciiToArray(string);
  15142. }
  15143. /**
  15144. * Used by `_.unescape` to convert HTML entities to characters.
  15145. *
  15146. * @private
  15147. * @param {string} chr The matched character to unescape.
  15148. * @returns {string} Returns the unescaped character.
  15149. */
  15150. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  15151. /**
  15152. * Gets the size of a Unicode `string`.
  15153. *
  15154. * @private
  15155. * @param {string} string The string inspect.
  15156. * @returns {number} Returns the string size.
  15157. */
  15158. function unicodeSize(string) {
  15159. var result = reUnicode.lastIndex = 0;
  15160. while (reUnicode.test(string)) {
  15161. ++result;
  15162. }
  15163. return result;
  15164. }
  15165. /**
  15166. * Converts a Unicode `string` to an array.
  15167. *
  15168. * @private
  15169. * @param {string} string The string to convert.
  15170. * @returns {Array} Returns the converted array.
  15171. */
  15172. function unicodeToArray(string) {
  15173. return string.match(reUnicode) || [];
  15174. }
  15175. /**
  15176. * Splits a Unicode `string` into an array of its words.
  15177. *
  15178. * @private
  15179. * @param {string} The string to inspect.
  15180. * @returns {Array} Returns the words of `string`.
  15181. */
  15182. function unicodeWords(string) {
  15183. return string.match(reUnicodeWord) || [];
  15184. }
  15185. /*--------------------------------------------------------------------------*/
  15186. /**
  15187. * Create a new pristine `lodash` function using the `context` object.
  15188. *
  15189. * @static
  15190. * @memberOf _
  15191. * @since 1.1.0
  15192. * @category Util
  15193. * @param {Object} [context=root] The context object.
  15194. * @returns {Function} Returns a new `lodash` function.
  15195. * @example
  15196. *
  15197. * _.mixin({ 'foo': _.constant('foo') });
  15198. *
  15199. * var lodash = _.runInContext();
  15200. * lodash.mixin({ 'bar': lodash.constant('bar') });
  15201. *
  15202. * _.isFunction(_.foo);
  15203. * // => true
  15204. * _.isFunction(_.bar);
  15205. * // => false
  15206. *
  15207. * lodash.isFunction(lodash.foo);
  15208. * // => false
  15209. * lodash.isFunction(lodash.bar);
  15210. * // => true
  15211. *
  15212. * // Create a suped-up `defer` in Node.js.
  15213. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  15214. */
  15215. var runInContext = (function runInContext(context) {
  15216. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  15217. /** Built-in constructor references. */
  15218. var Array = context.Array,
  15219. Date = context.Date,
  15220. Error = context.Error,
  15221. Function = context.Function,
  15222. Math = context.Math,
  15223. Object = context.Object,
  15224. RegExp = context.RegExp,
  15225. String = context.String,
  15226. TypeError = context.TypeError;
  15227. /** Used for built-in method references. */
  15228. var arrayProto = Array.prototype,
  15229. funcProto = Function.prototype,
  15230. objectProto = Object.prototype;
  15231. /** Used to detect overreaching core-js shims. */
  15232. var coreJsData = context['__core-js_shared__'];
  15233. /** Used to resolve the decompiled source of functions. */
  15234. var funcToString = funcProto.toString;
  15235. /** Used to check objects for own properties. */
  15236. var hasOwnProperty = objectProto.hasOwnProperty;
  15237. /** Used to generate unique IDs. */
  15238. var idCounter = 0;
  15239. /** Used to detect methods masquerading as native. */
  15240. var maskSrcKey = (function() {
  15241. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  15242. return uid ? ('Symbol(src)_1.' + uid) : '';
  15243. }());
  15244. /**
  15245. * Used to resolve the
  15246. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  15247. * of values.
  15248. */
  15249. var nativeObjectToString = objectProto.toString;
  15250. /** Used to infer the `Object` constructor. */
  15251. var objectCtorString = funcToString.call(Object);
  15252. /** Used to restore the original `_` reference in `_.noConflict`. */
  15253. var oldDash = root._;
  15254. /** Used to detect if a method is native. */
  15255. var reIsNative = RegExp('^' +
  15256. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  15257. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  15258. );
  15259. /** Built-in value references. */
  15260. var Buffer = moduleExports ? context.Buffer : undefined,
  15261. Symbol = context.Symbol,
  15262. Uint8Array = context.Uint8Array,
  15263. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  15264. getPrototype = overArg(Object.getPrototypeOf, Object),
  15265. objectCreate = Object.create,
  15266. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  15267. splice = arrayProto.splice,
  15268. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  15269. symIterator = Symbol ? Symbol.iterator : undefined,
  15270. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  15271. var defineProperty = (function() {
  15272. try {
  15273. var func = getNative(Object, 'defineProperty');
  15274. func({}, '', {});
  15275. return func;
  15276. } catch (e) {}
  15277. }());
  15278. /** Mocked built-ins. */
  15279. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  15280. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  15281. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  15282. /* Built-in method references for those with the same name as other `lodash` methods. */
  15283. var nativeCeil = Math.ceil,
  15284. nativeFloor = Math.floor,
  15285. nativeGetSymbols = Object.getOwnPropertySymbols,
  15286. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  15287. nativeIsFinite = context.isFinite,
  15288. nativeJoin = arrayProto.join,
  15289. nativeKeys = overArg(Object.keys, Object),
  15290. nativeMax = Math.max,
  15291. nativeMin = Math.min,
  15292. nativeNow = Date.now,
  15293. nativeParseInt = context.parseInt,
  15294. nativeRandom = Math.random,
  15295. nativeReverse = arrayProto.reverse;
  15296. /* Built-in method references that are verified to be native. */
  15297. var DataView = getNative(context, 'DataView'),
  15298. Map = getNative(context, 'Map'),
  15299. Promise = getNative(context, 'Promise'),
  15300. Set = getNative(context, 'Set'),
  15301. WeakMap = getNative(context, 'WeakMap'),
  15302. nativeCreate = getNative(Object, 'create');
  15303. /** Used to store function metadata. */
  15304. var metaMap = WeakMap && new WeakMap;
  15305. /** Used to lookup unminified function names. */
  15306. var realNames = {};
  15307. /** Used to detect maps, sets, and weakmaps. */
  15308. var dataViewCtorString = toSource(DataView),
  15309. mapCtorString = toSource(Map),
  15310. promiseCtorString = toSource(Promise),
  15311. setCtorString = toSource(Set),
  15312. weakMapCtorString = toSource(WeakMap);
  15313. /** Used to convert symbols to primitives and strings. */
  15314. var symbolProto = Symbol ? Symbol.prototype : undefined,
  15315. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  15316. symbolToString = symbolProto ? symbolProto.toString : undefined;
  15317. /*------------------------------------------------------------------------*/
  15318. /**
  15319. * Creates a `lodash` object which wraps `value` to enable implicit method
  15320. * chain sequences. Methods that operate on and return arrays, collections,
  15321. * and functions can be chained together. Methods that retrieve a single value
  15322. * or may return a primitive value will automatically end the chain sequence
  15323. * and return the unwrapped value. Otherwise, the value must be unwrapped
  15324. * with `_#value`.
  15325. *
  15326. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  15327. * enabled using `_.chain`.
  15328. *
  15329. * The execution of chained methods is lazy, that is, it's deferred until
  15330. * `_#value` is implicitly or explicitly called.
  15331. *
  15332. * Lazy evaluation allows several methods to support shortcut fusion.
  15333. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  15334. * the creation of intermediate arrays and can greatly reduce the number of
  15335. * iteratee executions. Sections of a chain sequence qualify for shortcut
  15336. * fusion if the section is applied to an array and iteratees accept only
  15337. * one argument. The heuristic for whether a section qualifies for shortcut
  15338. * fusion is subject to change.
  15339. *
  15340. * Chaining is supported in custom builds as long as the `_#value` method is
  15341. * directly or indirectly included in the build.
  15342. *
  15343. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  15344. *
  15345. * The wrapper `Array` methods are:
  15346. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  15347. *
  15348. * The wrapper `String` methods are:
  15349. * `replace` and `split`
  15350. *
  15351. * The wrapper methods that support shortcut fusion are:
  15352. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  15353. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  15354. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  15355. *
  15356. * The chainable wrapper methods are:
  15357. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  15358. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  15359. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  15360. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  15361. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  15362. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  15363. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  15364. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  15365. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  15366. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  15367. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  15368. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  15369. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  15370. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  15371. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  15372. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  15373. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  15374. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  15375. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  15376. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  15377. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  15378. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  15379. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  15380. * `zipObject`, `zipObjectDeep`, and `zipWith`
  15381. *
  15382. * The wrapper methods that are **not** chainable by default are:
  15383. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  15384. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  15385. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  15386. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  15387. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  15388. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  15389. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  15390. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  15391. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  15392. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  15393. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  15394. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  15395. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  15396. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  15397. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  15398. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  15399. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  15400. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  15401. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  15402. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  15403. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  15404. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  15405. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  15406. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  15407. * `upperFirst`, `value`, and `words`
  15408. *
  15409. * @name _
  15410. * @constructor
  15411. * @category Seq
  15412. * @param {*} value The value to wrap in a `lodash` instance.
  15413. * @returns {Object} Returns the new `lodash` wrapper instance.
  15414. * @example
  15415. *
  15416. * function square(n) {
  15417. * return n * n;
  15418. * }
  15419. *
  15420. * var wrapped = _([1, 2, 3]);
  15421. *
  15422. * // Returns an unwrapped value.
  15423. * wrapped.reduce(_.add);
  15424. * // => 6
  15425. *
  15426. * // Returns a wrapped value.
  15427. * var squares = wrapped.map(square);
  15428. *
  15429. * _.isArray(squares);
  15430. * // => false
  15431. *
  15432. * _.isArray(squares.value());
  15433. * // => true
  15434. */
  15435. function lodash(value) {
  15436. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  15437. if (value instanceof LodashWrapper) {
  15438. return value;
  15439. }
  15440. if (hasOwnProperty.call(value, '__wrapped__')) {
  15441. return wrapperClone(value);
  15442. }
  15443. }
  15444. return new LodashWrapper(value);
  15445. }
  15446. /**
  15447. * The base implementation of `_.create` without support for assigning
  15448. * properties to the created object.
  15449. *
  15450. * @private
  15451. * @param {Object} proto The object to inherit from.
  15452. * @returns {Object} Returns the new object.
  15453. */
  15454. var baseCreate = (function() {
  15455. function object() {}
  15456. return function(proto) {
  15457. if (!isObject(proto)) {
  15458. return {};
  15459. }
  15460. if (objectCreate) {
  15461. return objectCreate(proto);
  15462. }
  15463. object.prototype = proto;
  15464. var result = new object;
  15465. object.prototype = undefined;
  15466. return result;
  15467. };
  15468. }());
  15469. /**
  15470. * The function whose prototype chain sequence wrappers inherit from.
  15471. *
  15472. * @private
  15473. */
  15474. function baseLodash() {
  15475. // No operation performed.
  15476. }
  15477. /**
  15478. * The base constructor for creating `lodash` wrapper objects.
  15479. *
  15480. * @private
  15481. * @param {*} value The value to wrap.
  15482. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  15483. */
  15484. function LodashWrapper(value, chainAll) {
  15485. this.__wrapped__ = value;
  15486. this.__actions__ = [];
  15487. this.__chain__ = !!chainAll;
  15488. this.__index__ = 0;
  15489. this.__values__ = undefined;
  15490. }
  15491. /**
  15492. * By default, the template delimiters used by lodash are like those in
  15493. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  15494. * following template settings to use alternative delimiters.
  15495. *
  15496. * @static
  15497. * @memberOf _
  15498. * @type {Object}
  15499. */
  15500. lodash.templateSettings = {
  15501. /**
  15502. * Used to detect `data` property values to be HTML-escaped.
  15503. *
  15504. * @memberOf _.templateSettings
  15505. * @type {RegExp}
  15506. */
  15507. 'escape': reEscape,
  15508. /**
  15509. * Used to detect code to be evaluated.
  15510. *
  15511. * @memberOf _.templateSettings
  15512. * @type {RegExp}
  15513. */
  15514. 'evaluate': reEvaluate,
  15515. /**
  15516. * Used to detect `data` property values to inject.
  15517. *
  15518. * @memberOf _.templateSettings
  15519. * @type {RegExp}
  15520. */
  15521. 'interpolate': reInterpolate,
  15522. /**
  15523. * Used to reference the data object in the template text.
  15524. *
  15525. * @memberOf _.templateSettings
  15526. * @type {string}
  15527. */
  15528. 'variable': '',
  15529. /**
  15530. * Used to import variables into the compiled template.
  15531. *
  15532. * @memberOf _.templateSettings
  15533. * @type {Object}
  15534. */
  15535. 'imports': {
  15536. /**
  15537. * A reference to the `lodash` function.
  15538. *
  15539. * @memberOf _.templateSettings.imports
  15540. * @type {Function}
  15541. */
  15542. '_': lodash
  15543. }
  15544. };
  15545. // Ensure wrappers are instances of `baseLodash`.
  15546. lodash.prototype = baseLodash.prototype;
  15547. lodash.prototype.constructor = lodash;
  15548. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  15549. LodashWrapper.prototype.constructor = LodashWrapper;
  15550. /*------------------------------------------------------------------------*/
  15551. /**
  15552. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  15553. *
  15554. * @private
  15555. * @constructor
  15556. * @param {*} value The value to wrap.
  15557. */
  15558. function LazyWrapper(value) {
  15559. this.__wrapped__ = value;
  15560. this.__actions__ = [];
  15561. this.__dir__ = 1;
  15562. this.__filtered__ = false;
  15563. this.__iteratees__ = [];
  15564. this.__takeCount__ = MAX_ARRAY_LENGTH;
  15565. this.__views__ = [];
  15566. }
  15567. /**
  15568. * Creates a clone of the lazy wrapper object.
  15569. *
  15570. * @private
  15571. * @name clone
  15572. * @memberOf LazyWrapper
  15573. * @returns {Object} Returns the cloned `LazyWrapper` object.
  15574. */
  15575. function lazyClone() {
  15576. var result = new LazyWrapper(this.__wrapped__);
  15577. result.__actions__ = copyArray(this.__actions__);
  15578. result.__dir__ = this.__dir__;
  15579. result.__filtered__ = this.__filtered__;
  15580. result.__iteratees__ = copyArray(this.__iteratees__);
  15581. result.__takeCount__ = this.__takeCount__;
  15582. result.__views__ = copyArray(this.__views__);
  15583. return result;
  15584. }
  15585. /**
  15586. * Reverses the direction of lazy iteration.
  15587. *
  15588. * @private
  15589. * @name reverse
  15590. * @memberOf LazyWrapper
  15591. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  15592. */
  15593. function lazyReverse() {
  15594. if (this.__filtered__) {
  15595. var result = new LazyWrapper(this);
  15596. result.__dir__ = -1;
  15597. result.__filtered__ = true;
  15598. } else {
  15599. result = this.clone();
  15600. result.__dir__ *= -1;
  15601. }
  15602. return result;
  15603. }
  15604. /**
  15605. * Extracts the unwrapped value from its lazy wrapper.
  15606. *
  15607. * @private
  15608. * @name value
  15609. * @memberOf LazyWrapper
  15610. * @returns {*} Returns the unwrapped value.
  15611. */
  15612. function lazyValue() {
  15613. var array = this.__wrapped__.value(),
  15614. dir = this.__dir__,
  15615. isArr = isArray(array),
  15616. isRight = dir < 0,
  15617. arrLength = isArr ? array.length : 0,
  15618. view = getView(0, arrLength, this.__views__),
  15619. start = view.start,
  15620. end = view.end,
  15621. length = end - start,
  15622. index = isRight ? end : (start - 1),
  15623. iteratees = this.__iteratees__,
  15624. iterLength = iteratees.length,
  15625. resIndex = 0,
  15626. takeCount = nativeMin(length, this.__takeCount__);
  15627. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  15628. return baseWrapperValue(array, this.__actions__);
  15629. }
  15630. var result = [];
  15631. outer:
  15632. while (length-- && resIndex < takeCount) {
  15633. index += dir;
  15634. var iterIndex = -1,
  15635. value = array[index];
  15636. while (++iterIndex < iterLength) {
  15637. var data = iteratees[iterIndex],
  15638. iteratee = data.iteratee,
  15639. type = data.type,
  15640. computed = iteratee(value);
  15641. if (type == LAZY_MAP_FLAG) {
  15642. value = computed;
  15643. } else if (!computed) {
  15644. if (type == LAZY_FILTER_FLAG) {
  15645. continue outer;
  15646. } else {
  15647. break outer;
  15648. }
  15649. }
  15650. }
  15651. result[resIndex++] = value;
  15652. }
  15653. return result;
  15654. }
  15655. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  15656. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  15657. LazyWrapper.prototype.constructor = LazyWrapper;
  15658. /*------------------------------------------------------------------------*/
  15659. /**
  15660. * Creates a hash object.
  15661. *
  15662. * @private
  15663. * @constructor
  15664. * @param {Array} [entries] The key-value pairs to cache.
  15665. */
  15666. function Hash(entries) {
  15667. var index = -1,
  15668. length = entries == null ? 0 : entries.length;
  15669. this.clear();
  15670. while (++index < length) {
  15671. var entry = entries[index];
  15672. this.set(entry[0], entry[1]);
  15673. }
  15674. }
  15675. /**
  15676. * Removes all key-value entries from the hash.
  15677. *
  15678. * @private
  15679. * @name clear
  15680. * @memberOf Hash
  15681. */
  15682. function hashClear() {
  15683. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  15684. this.size = 0;
  15685. }
  15686. /**
  15687. * Removes `key` and its value from the hash.
  15688. *
  15689. * @private
  15690. * @name delete
  15691. * @memberOf Hash
  15692. * @param {Object} hash The hash to modify.
  15693. * @param {string} key The key of the value to remove.
  15694. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  15695. */
  15696. function hashDelete(key) {
  15697. var result = this.has(key) && delete this.__data__[key];
  15698. this.size -= result ? 1 : 0;
  15699. return result;
  15700. }
  15701. /**
  15702. * Gets the hash value for `key`.
  15703. *
  15704. * @private
  15705. * @name get
  15706. * @memberOf Hash
  15707. * @param {string} key The key of the value to get.
  15708. * @returns {*} Returns the entry value.
  15709. */
  15710. function hashGet(key) {
  15711. var data = this.__data__;
  15712. if (nativeCreate) {
  15713. var result = data[key];
  15714. return result === HASH_UNDEFINED ? undefined : result;
  15715. }
  15716. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  15717. }
  15718. /**
  15719. * Checks if a hash value for `key` exists.
  15720. *
  15721. * @private
  15722. * @name has
  15723. * @memberOf Hash
  15724. * @param {string} key The key of the entry to check.
  15725. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  15726. */
  15727. function hashHas(key) {
  15728. var data = this.__data__;
  15729. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  15730. }
  15731. /**
  15732. * Sets the hash `key` to `value`.
  15733. *
  15734. * @private
  15735. * @name set
  15736. * @memberOf Hash
  15737. * @param {string} key The key of the value to set.
  15738. * @param {*} value The value to set.
  15739. * @returns {Object} Returns the hash instance.
  15740. */
  15741. function hashSet(key, value) {
  15742. var data = this.__data__;
  15743. this.size += this.has(key) ? 0 : 1;
  15744. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  15745. return this;
  15746. }
  15747. // Add methods to `Hash`.
  15748. Hash.prototype.clear = hashClear;
  15749. Hash.prototype['delete'] = hashDelete;
  15750. Hash.prototype.get = hashGet;
  15751. Hash.prototype.has = hashHas;
  15752. Hash.prototype.set = hashSet;
  15753. /*------------------------------------------------------------------------*/
  15754. /**
  15755. * Creates an list cache object.
  15756. *
  15757. * @private
  15758. * @constructor
  15759. * @param {Array} [entries] The key-value pairs to cache.
  15760. */
  15761. function ListCache(entries) {
  15762. var index = -1,
  15763. length = entries == null ? 0 : entries.length;
  15764. this.clear();
  15765. while (++index < length) {
  15766. var entry = entries[index];
  15767. this.set(entry[0], entry[1]);
  15768. }
  15769. }
  15770. /**
  15771. * Removes all key-value entries from the list cache.
  15772. *
  15773. * @private
  15774. * @name clear
  15775. * @memberOf ListCache
  15776. */
  15777. function listCacheClear() {
  15778. this.__data__ = [];
  15779. this.size = 0;
  15780. }
  15781. /**
  15782. * Removes `key` and its value from the list cache.
  15783. *
  15784. * @private
  15785. * @name delete
  15786. * @memberOf ListCache
  15787. * @param {string} key The key of the value to remove.
  15788. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  15789. */
  15790. function listCacheDelete(key) {
  15791. var data = this.__data__,
  15792. index = assocIndexOf(data, key);
  15793. if (index < 0) {
  15794. return false;
  15795. }
  15796. var lastIndex = data.length - 1;
  15797. if (index == lastIndex) {
  15798. data.pop();
  15799. } else {
  15800. splice.call(data, index, 1);
  15801. }
  15802. --this.size;
  15803. return true;
  15804. }
  15805. /**
  15806. * Gets the list cache value for `key`.
  15807. *
  15808. * @private
  15809. * @name get
  15810. * @memberOf ListCache
  15811. * @param {string} key The key of the value to get.
  15812. * @returns {*} Returns the entry value.
  15813. */
  15814. function listCacheGet(key) {
  15815. var data = this.__data__,
  15816. index = assocIndexOf(data, key);
  15817. return index < 0 ? undefined : data[index][1];
  15818. }
  15819. /**
  15820. * Checks if a list cache value for `key` exists.
  15821. *
  15822. * @private
  15823. * @name has
  15824. * @memberOf ListCache
  15825. * @param {string} key The key of the entry to check.
  15826. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  15827. */
  15828. function listCacheHas(key) {
  15829. return assocIndexOf(this.__data__, key) > -1;
  15830. }
  15831. /**
  15832. * Sets the list cache `key` to `value`.
  15833. *
  15834. * @private
  15835. * @name set
  15836. * @memberOf ListCache
  15837. * @param {string} key The key of the value to set.
  15838. * @param {*} value The value to set.
  15839. * @returns {Object} Returns the list cache instance.
  15840. */
  15841. function listCacheSet(key, value) {
  15842. var data = this.__data__,
  15843. index = assocIndexOf(data, key);
  15844. if (index < 0) {
  15845. ++this.size;
  15846. data.push([key, value]);
  15847. } else {
  15848. data[index][1] = value;
  15849. }
  15850. return this;
  15851. }
  15852. // Add methods to `ListCache`.
  15853. ListCache.prototype.clear = listCacheClear;
  15854. ListCache.prototype['delete'] = listCacheDelete;
  15855. ListCache.prototype.get = listCacheGet;
  15856. ListCache.prototype.has = listCacheHas;
  15857. ListCache.prototype.set = listCacheSet;
  15858. /*------------------------------------------------------------------------*/
  15859. /**
  15860. * Creates a map cache object to store key-value pairs.
  15861. *
  15862. * @private
  15863. * @constructor
  15864. * @param {Array} [entries] The key-value pairs to cache.
  15865. */
  15866. function MapCache(entries) {
  15867. var index = -1,
  15868. length = entries == null ? 0 : entries.length;
  15869. this.clear();
  15870. while (++index < length) {
  15871. var entry = entries[index];
  15872. this.set(entry[0], entry[1]);
  15873. }
  15874. }
  15875. /**
  15876. * Removes all key-value entries from the map.
  15877. *
  15878. * @private
  15879. * @name clear
  15880. * @memberOf MapCache
  15881. */
  15882. function mapCacheClear() {
  15883. this.size = 0;
  15884. this.__data__ = {
  15885. 'hash': new Hash,
  15886. 'map': new (Map || ListCache),
  15887. 'string': new Hash
  15888. };
  15889. }
  15890. /**
  15891. * Removes `key` and its value from the map.
  15892. *
  15893. * @private
  15894. * @name delete
  15895. * @memberOf MapCache
  15896. * @param {string} key The key of the value to remove.
  15897. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  15898. */
  15899. function mapCacheDelete(key) {
  15900. var result = getMapData(this, key)['delete'](key);
  15901. this.size -= result ? 1 : 0;
  15902. return result;
  15903. }
  15904. /**
  15905. * Gets the map value for `key`.
  15906. *
  15907. * @private
  15908. * @name get
  15909. * @memberOf MapCache
  15910. * @param {string} key The key of the value to get.
  15911. * @returns {*} Returns the entry value.
  15912. */
  15913. function mapCacheGet(key) {
  15914. return getMapData(this, key).get(key);
  15915. }
  15916. /**
  15917. * Checks if a map value for `key` exists.
  15918. *
  15919. * @private
  15920. * @name has
  15921. * @memberOf MapCache
  15922. * @param {string} key The key of the entry to check.
  15923. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  15924. */
  15925. function mapCacheHas(key) {
  15926. return getMapData(this, key).has(key);
  15927. }
  15928. /**
  15929. * Sets the map `key` to `value`.
  15930. *
  15931. * @private
  15932. * @name set
  15933. * @memberOf MapCache
  15934. * @param {string} key The key of the value to set.
  15935. * @param {*} value The value to set.
  15936. * @returns {Object} Returns the map cache instance.
  15937. */
  15938. function mapCacheSet(key, value) {
  15939. var data = getMapData(this, key),
  15940. size = data.size;
  15941. data.set(key, value);
  15942. this.size += data.size == size ? 0 : 1;
  15943. return this;
  15944. }
  15945. // Add methods to `MapCache`.
  15946. MapCache.prototype.clear = mapCacheClear;
  15947. MapCache.prototype['delete'] = mapCacheDelete;
  15948. MapCache.prototype.get = mapCacheGet;
  15949. MapCache.prototype.has = mapCacheHas;
  15950. MapCache.prototype.set = mapCacheSet;
  15951. /*------------------------------------------------------------------------*/
  15952. /**
  15953. *
  15954. * Creates an array cache object to store unique values.
  15955. *
  15956. * @private
  15957. * @constructor
  15958. * @param {Array} [values] The values to cache.
  15959. */
  15960. function SetCache(values) {
  15961. var index = -1,
  15962. length = values == null ? 0 : values.length;
  15963. this.__data__ = new MapCache;
  15964. while (++index < length) {
  15965. this.add(values[index]);
  15966. }
  15967. }
  15968. /**
  15969. * Adds `value` to the array cache.
  15970. *
  15971. * @private
  15972. * @name add
  15973. * @memberOf SetCache
  15974. * @alias push
  15975. * @param {*} value The value to cache.
  15976. * @returns {Object} Returns the cache instance.
  15977. */
  15978. function setCacheAdd(value) {
  15979. this.__data__.set(value, HASH_UNDEFINED);
  15980. return this;
  15981. }
  15982. /**
  15983. * Checks if `value` is in the array cache.
  15984. *
  15985. * @private
  15986. * @name has
  15987. * @memberOf SetCache
  15988. * @param {*} value The value to search for.
  15989. * @returns {number} Returns `true` if `value` is found, else `false`.
  15990. */
  15991. function setCacheHas(value) {
  15992. return this.__data__.has(value);
  15993. }
  15994. // Add methods to `SetCache`.
  15995. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  15996. SetCache.prototype.has = setCacheHas;
  15997. /*------------------------------------------------------------------------*/
  15998. /**
  15999. * Creates a stack cache object to store key-value pairs.
  16000. *
  16001. * @private
  16002. * @constructor
  16003. * @param {Array} [entries] The key-value pairs to cache.
  16004. */
  16005. function Stack(entries) {
  16006. var data = this.__data__ = new ListCache(entries);
  16007. this.size = data.size;
  16008. }
  16009. /**
  16010. * Removes all key-value entries from the stack.
  16011. *
  16012. * @private
  16013. * @name clear
  16014. * @memberOf Stack
  16015. */
  16016. function stackClear() {
  16017. this.__data__ = new ListCache;
  16018. this.size = 0;
  16019. }
  16020. /**
  16021. * Removes `key` and its value from the stack.
  16022. *
  16023. * @private
  16024. * @name delete
  16025. * @memberOf Stack
  16026. * @param {string} key The key of the value to remove.
  16027. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  16028. */
  16029. function stackDelete(key) {
  16030. var data = this.__data__,
  16031. result = data['delete'](key);
  16032. this.size = data.size;
  16033. return result;
  16034. }
  16035. /**
  16036. * Gets the stack value for `key`.
  16037. *
  16038. * @private
  16039. * @name get
  16040. * @memberOf Stack
  16041. * @param {string} key The key of the value to get.
  16042. * @returns {*} Returns the entry value.
  16043. */
  16044. function stackGet(key) {
  16045. return this.__data__.get(key);
  16046. }
  16047. /**
  16048. * Checks if a stack value for `key` exists.
  16049. *
  16050. * @private
  16051. * @name has
  16052. * @memberOf Stack
  16053. * @param {string} key The key of the entry to check.
  16054. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  16055. */
  16056. function stackHas(key) {
  16057. return this.__data__.has(key);
  16058. }
  16059. /**
  16060. * Sets the stack `key` to `value`.
  16061. *
  16062. * @private
  16063. * @name set
  16064. * @memberOf Stack
  16065. * @param {string} key The key of the value to set.
  16066. * @param {*} value The value to set.
  16067. * @returns {Object} Returns the stack cache instance.
  16068. */
  16069. function stackSet(key, value) {
  16070. var data = this.__data__;
  16071. if (data instanceof ListCache) {
  16072. var pairs = data.__data__;
  16073. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  16074. pairs.push([key, value]);
  16075. this.size = ++data.size;
  16076. return this;
  16077. }
  16078. data = this.__data__ = new MapCache(pairs);
  16079. }
  16080. data.set(key, value);
  16081. this.size = data.size;
  16082. return this;
  16083. }
  16084. // Add methods to `Stack`.
  16085. Stack.prototype.clear = stackClear;
  16086. Stack.prototype['delete'] = stackDelete;
  16087. Stack.prototype.get = stackGet;
  16088. Stack.prototype.has = stackHas;
  16089. Stack.prototype.set = stackSet;
  16090. /*------------------------------------------------------------------------*/
  16091. /**
  16092. * Creates an array of the enumerable property names of the array-like `value`.
  16093. *
  16094. * @private
  16095. * @param {*} value The value to query.
  16096. * @param {boolean} inherited Specify returning inherited property names.
  16097. * @returns {Array} Returns the array of property names.
  16098. */
  16099. function arrayLikeKeys(value, inherited) {
  16100. var isArr = isArray(value),
  16101. isArg = !isArr && isArguments(value),
  16102. isBuff = !isArr && !isArg && isBuffer(value),
  16103. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  16104. skipIndexes = isArr || isArg || isBuff || isType,
  16105. result = skipIndexes ? baseTimes(value.length, String) : [],
  16106. length = result.length;
  16107. for (var key in value) {
  16108. if ((inherited || hasOwnProperty.call(value, key)) &&
  16109. !(skipIndexes && (
  16110. // Safari 9 has enumerable `arguments.length` in strict mode.
  16111. key == 'length' ||
  16112. // Node.js 0.10 has enumerable non-index properties on buffers.
  16113. (isBuff && (key == 'offset' || key == 'parent')) ||
  16114. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  16115. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  16116. // Skip index properties.
  16117. isIndex(key, length)
  16118. ))) {
  16119. result.push(key);
  16120. }
  16121. }
  16122. return result;
  16123. }
  16124. /**
  16125. * A specialized version of `_.sample` for arrays.
  16126. *
  16127. * @private
  16128. * @param {Array} array The array to sample.
  16129. * @returns {*} Returns the random element.
  16130. */
  16131. function arraySample(array) {
  16132. var length = array.length;
  16133. return length ? array[baseRandom(0, length - 1)] : undefined;
  16134. }
  16135. /**
  16136. * A specialized version of `_.sampleSize` for arrays.
  16137. *
  16138. * @private
  16139. * @param {Array} array The array to sample.
  16140. * @param {number} n The number of elements to sample.
  16141. * @returns {Array} Returns the random elements.
  16142. */
  16143. function arraySampleSize(array, n) {
  16144. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  16145. }
  16146. /**
  16147. * A specialized version of `_.shuffle` for arrays.
  16148. *
  16149. * @private
  16150. * @param {Array} array The array to shuffle.
  16151. * @returns {Array} Returns the new shuffled array.
  16152. */
  16153. function arrayShuffle(array) {
  16154. return shuffleSelf(copyArray(array));
  16155. }
  16156. /**
  16157. * This function is like `assignValue` except that it doesn't assign
  16158. * `undefined` values.
  16159. *
  16160. * @private
  16161. * @param {Object} object The object to modify.
  16162. * @param {string} key The key of the property to assign.
  16163. * @param {*} value The value to assign.
  16164. */
  16165. function assignMergeValue(object, key, value) {
  16166. if ((value !== undefined && !eq(object[key], value)) ||
  16167. (value === undefined && !(key in object))) {
  16168. baseAssignValue(object, key, value);
  16169. }
  16170. }
  16171. /**
  16172. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  16173. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  16174. * for equality comparisons.
  16175. *
  16176. * @private
  16177. * @param {Object} object The object to modify.
  16178. * @param {string} key The key of the property to assign.
  16179. * @param {*} value The value to assign.
  16180. */
  16181. function assignValue(object, key, value) {
  16182. var objValue = object[key];
  16183. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  16184. (value === undefined && !(key in object))) {
  16185. baseAssignValue(object, key, value);
  16186. }
  16187. }
  16188. /**
  16189. * Gets the index at which the `key` is found in `array` of key-value pairs.
  16190. *
  16191. * @private
  16192. * @param {Array} array The array to inspect.
  16193. * @param {*} key The key to search for.
  16194. * @returns {number} Returns the index of the matched value, else `-1`.
  16195. */
  16196. function assocIndexOf(array, key) {
  16197. var length = array.length;
  16198. while (length--) {
  16199. if (eq(array[length][0], key)) {
  16200. return length;
  16201. }
  16202. }
  16203. return -1;
  16204. }
  16205. /**
  16206. * Aggregates elements of `collection` on `accumulator` with keys transformed
  16207. * by `iteratee` and values set by `setter`.
  16208. *
  16209. * @private
  16210. * @param {Array|Object} collection The collection to iterate over.
  16211. * @param {Function} setter The function to set `accumulator` values.
  16212. * @param {Function} iteratee The iteratee to transform keys.
  16213. * @param {Object} accumulator The initial aggregated object.
  16214. * @returns {Function} Returns `accumulator`.
  16215. */
  16216. function baseAggregator(collection, setter, iteratee, accumulator) {
  16217. baseEach(collection, function(value, key, collection) {
  16218. setter(accumulator, value, iteratee(value), collection);
  16219. });
  16220. return accumulator;
  16221. }
  16222. /**
  16223. * The base implementation of `_.assign` without support for multiple sources
  16224. * or `customizer` functions.
  16225. *
  16226. * @private
  16227. * @param {Object} object The destination object.
  16228. * @param {Object} source The source object.
  16229. * @returns {Object} Returns `object`.
  16230. */
  16231. function baseAssign(object, source) {
  16232. return object && copyObject(source, keys(source), object);
  16233. }
  16234. /**
  16235. * The base implementation of `_.assignIn` without support for multiple sources
  16236. * or `customizer` functions.
  16237. *
  16238. * @private
  16239. * @param {Object} object The destination object.
  16240. * @param {Object} source The source object.
  16241. * @returns {Object} Returns `object`.
  16242. */
  16243. function baseAssignIn(object, source) {
  16244. return object && copyObject(source, keysIn(source), object);
  16245. }
  16246. /**
  16247. * The base implementation of `assignValue` and `assignMergeValue` without
  16248. * value checks.
  16249. *
  16250. * @private
  16251. * @param {Object} object The object to modify.
  16252. * @param {string} key The key of the property to assign.
  16253. * @param {*} value The value to assign.
  16254. */
  16255. function baseAssignValue(object, key, value) {
  16256. if (key == '__proto__' && defineProperty) {
  16257. defineProperty(object, key, {
  16258. 'configurable': true,
  16259. 'enumerable': true,
  16260. 'value': value,
  16261. 'writable': true
  16262. });
  16263. } else {
  16264. object[key] = value;
  16265. }
  16266. }
  16267. /**
  16268. * The base implementation of `_.at` without support for individual paths.
  16269. *
  16270. * @private
  16271. * @param {Object} object The object to iterate over.
  16272. * @param {string[]} paths The property paths to pick.
  16273. * @returns {Array} Returns the picked elements.
  16274. */
  16275. function baseAt(object, paths) {
  16276. var index = -1,
  16277. length = paths.length,
  16278. result = Array(length),
  16279. skip = object == null;
  16280. while (++index < length) {
  16281. result[index] = skip ? undefined : get(object, paths[index]);
  16282. }
  16283. return result;
  16284. }
  16285. /**
  16286. * The base implementation of `_.clamp` which doesn't coerce arguments.
  16287. *
  16288. * @private
  16289. * @param {number} number The number to clamp.
  16290. * @param {number} [lower] The lower bound.
  16291. * @param {number} upper The upper bound.
  16292. * @returns {number} Returns the clamped number.
  16293. */
  16294. function baseClamp(number, lower, upper) {
  16295. if (number === number) {
  16296. if (upper !== undefined) {
  16297. number = number <= upper ? number : upper;
  16298. }
  16299. if (lower !== undefined) {
  16300. number = number >= lower ? number : lower;
  16301. }
  16302. }
  16303. return number;
  16304. }
  16305. /**
  16306. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  16307. * traversed objects.
  16308. *
  16309. * @private
  16310. * @param {*} value The value to clone.
  16311. * @param {boolean} bitmask The bitmask flags.
  16312. * 1 - Deep clone
  16313. * 2 - Flatten inherited properties
  16314. * 4 - Clone symbols
  16315. * @param {Function} [customizer] The function to customize cloning.
  16316. * @param {string} [key] The key of `value`.
  16317. * @param {Object} [object] The parent object of `value`.
  16318. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  16319. * @returns {*} Returns the cloned value.
  16320. */
  16321. function baseClone(value, bitmask, customizer, key, object, stack) {
  16322. var result,
  16323. isDeep = bitmask & CLONE_DEEP_FLAG,
  16324. isFlat = bitmask & CLONE_FLAT_FLAG,
  16325. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  16326. if (customizer) {
  16327. result = object ? customizer(value, key, object, stack) : customizer(value);
  16328. }
  16329. if (result !== undefined) {
  16330. return result;
  16331. }
  16332. if (!isObject(value)) {
  16333. return value;
  16334. }
  16335. var isArr = isArray(value);
  16336. if (isArr) {
  16337. result = initCloneArray(value);
  16338. if (!isDeep) {
  16339. return copyArray(value, result);
  16340. }
  16341. } else {
  16342. var tag = getTag(value),
  16343. isFunc = tag == funcTag || tag == genTag;
  16344. if (isBuffer(value)) {
  16345. return cloneBuffer(value, isDeep);
  16346. }
  16347. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  16348. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  16349. if (!isDeep) {
  16350. return isFlat
  16351. ? copySymbolsIn(value, baseAssignIn(result, value))
  16352. : copySymbols(value, baseAssign(result, value));
  16353. }
  16354. } else {
  16355. if (!cloneableTags[tag]) {
  16356. return object ? value : {};
  16357. }
  16358. result = initCloneByTag(value, tag, isDeep);
  16359. }
  16360. }
  16361. // Check for circular references and return its corresponding clone.
  16362. stack || (stack = new Stack);
  16363. var stacked = stack.get(value);
  16364. if (stacked) {
  16365. return stacked;
  16366. }
  16367. stack.set(value, result);
  16368. if (isSet(value)) {
  16369. value.forEach(function(subValue) {
  16370. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  16371. });
  16372. } else if (isMap(value)) {
  16373. value.forEach(function(subValue, key) {
  16374. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  16375. });
  16376. }
  16377. var keysFunc = isFull
  16378. ? (isFlat ? getAllKeysIn : getAllKeys)
  16379. : (isFlat ? keysIn : keys);
  16380. var props = isArr ? undefined : keysFunc(value);
  16381. arrayEach(props || value, function(subValue, key) {
  16382. if (props) {
  16383. key = subValue;
  16384. subValue = value[key];
  16385. }
  16386. // Recursively populate clone (susceptible to call stack limits).
  16387. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  16388. });
  16389. return result;
  16390. }
  16391. /**
  16392. * The base implementation of `_.conforms` which doesn't clone `source`.
  16393. *
  16394. * @private
  16395. * @param {Object} source The object of property predicates to conform to.
  16396. * @returns {Function} Returns the new spec function.
  16397. */
  16398. function baseConforms(source) {
  16399. var props = keys(source);
  16400. return function(object) {
  16401. return baseConformsTo(object, source, props);
  16402. };
  16403. }
  16404. /**
  16405. * The base implementation of `_.conformsTo` which accepts `props` to check.
  16406. *
  16407. * @private
  16408. * @param {Object} object The object to inspect.
  16409. * @param {Object} source The object of property predicates to conform to.
  16410. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  16411. */
  16412. function baseConformsTo(object, source, props) {
  16413. var length = props.length;
  16414. if (object == null) {
  16415. return !length;
  16416. }
  16417. object = Object(object);
  16418. while (length--) {
  16419. var key = props[length],
  16420. predicate = source[key],
  16421. value = object[key];
  16422. if ((value === undefined && !(key in object)) || !predicate(value)) {
  16423. return false;
  16424. }
  16425. }
  16426. return true;
  16427. }
  16428. /**
  16429. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  16430. * to provide to `func`.
  16431. *
  16432. * @private
  16433. * @param {Function} func The function to delay.
  16434. * @param {number} wait The number of milliseconds to delay invocation.
  16435. * @param {Array} args The arguments to provide to `func`.
  16436. * @returns {number|Object} Returns the timer id or timeout object.
  16437. */
  16438. function baseDelay(func, wait, args) {
  16439. if (typeof func != 'function') {
  16440. throw new TypeError(FUNC_ERROR_TEXT);
  16441. }
  16442. return setTimeout(function() { func.apply(undefined, args); }, wait);
  16443. }
  16444. /**
  16445. * The base implementation of methods like `_.difference` without support
  16446. * for excluding multiple arrays or iteratee shorthands.
  16447. *
  16448. * @private
  16449. * @param {Array} array The array to inspect.
  16450. * @param {Array} values The values to exclude.
  16451. * @param {Function} [iteratee] The iteratee invoked per element.
  16452. * @param {Function} [comparator] The comparator invoked per element.
  16453. * @returns {Array} Returns the new array of filtered values.
  16454. */
  16455. function baseDifference(array, values, iteratee, comparator) {
  16456. var index = -1,
  16457. includes = arrayIncludes,
  16458. isCommon = true,
  16459. length = array.length,
  16460. result = [],
  16461. valuesLength = values.length;
  16462. if (!length) {
  16463. return result;
  16464. }
  16465. if (iteratee) {
  16466. values = arrayMap(values, baseUnary(iteratee));
  16467. }
  16468. if (comparator) {
  16469. includes = arrayIncludesWith;
  16470. isCommon = false;
  16471. }
  16472. else if (values.length >= LARGE_ARRAY_SIZE) {
  16473. includes = cacheHas;
  16474. isCommon = false;
  16475. values = new SetCache(values);
  16476. }
  16477. outer:
  16478. while (++index < length) {
  16479. var value = array[index],
  16480. computed = iteratee == null ? value : iteratee(value);
  16481. value = (comparator || value !== 0) ? value : 0;
  16482. if (isCommon && computed === computed) {
  16483. var valuesIndex = valuesLength;
  16484. while (valuesIndex--) {
  16485. if (values[valuesIndex] === computed) {
  16486. continue outer;
  16487. }
  16488. }
  16489. result.push(value);
  16490. }
  16491. else if (!includes(values, computed, comparator)) {
  16492. result.push(value);
  16493. }
  16494. }
  16495. return result;
  16496. }
  16497. /**
  16498. * The base implementation of `_.forEach` without support for iteratee shorthands.
  16499. *
  16500. * @private
  16501. * @param {Array|Object} collection The collection to iterate over.
  16502. * @param {Function} iteratee The function invoked per iteration.
  16503. * @returns {Array|Object} Returns `collection`.
  16504. */
  16505. var baseEach = createBaseEach(baseForOwn);
  16506. /**
  16507. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  16508. *
  16509. * @private
  16510. * @param {Array|Object} collection The collection to iterate over.
  16511. * @param {Function} iteratee The function invoked per iteration.
  16512. * @returns {Array|Object} Returns `collection`.
  16513. */
  16514. var baseEachRight = createBaseEach(baseForOwnRight, true);
  16515. /**
  16516. * The base implementation of `_.every` without support for iteratee shorthands.
  16517. *
  16518. * @private
  16519. * @param {Array|Object} collection The collection to iterate over.
  16520. * @param {Function} predicate The function invoked per iteration.
  16521. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  16522. * else `false`
  16523. */
  16524. function baseEvery(collection, predicate) {
  16525. var result = true;
  16526. baseEach(collection, function(value, index, collection) {
  16527. result = !!predicate(value, index, collection);
  16528. return result;
  16529. });
  16530. return result;
  16531. }
  16532. /**
  16533. * The base implementation of methods like `_.max` and `_.min` which accepts a
  16534. * `comparator` to determine the extremum value.
  16535. *
  16536. * @private
  16537. * @param {Array} array The array to iterate over.
  16538. * @param {Function} iteratee The iteratee invoked per iteration.
  16539. * @param {Function} comparator The comparator used to compare values.
  16540. * @returns {*} Returns the extremum value.
  16541. */
  16542. function baseExtremum(array, iteratee, comparator) {
  16543. var index = -1,
  16544. length = array.length;
  16545. while (++index < length) {
  16546. var value = array[index],
  16547. current = iteratee(value);
  16548. if (current != null && (computed === undefined
  16549. ? (current === current && !isSymbol(current))
  16550. : comparator(current, computed)
  16551. )) {
  16552. var computed = current,
  16553. result = value;
  16554. }
  16555. }
  16556. return result;
  16557. }
  16558. /**
  16559. * The base implementation of `_.fill` without an iteratee call guard.
  16560. *
  16561. * @private
  16562. * @param {Array} array The array to fill.
  16563. * @param {*} value The value to fill `array` with.
  16564. * @param {number} [start=0] The start position.
  16565. * @param {number} [end=array.length] The end position.
  16566. * @returns {Array} Returns `array`.
  16567. */
  16568. function baseFill(array, value, start, end) {
  16569. var length = array.length;
  16570. start = toInteger(start);
  16571. if (start < 0) {
  16572. start = -start > length ? 0 : (length + start);
  16573. }
  16574. end = (end === undefined || end > length) ? length : toInteger(end);
  16575. if (end < 0) {
  16576. end += length;
  16577. }
  16578. end = start > end ? 0 : toLength(end);
  16579. while (start < end) {
  16580. array[start++] = value;
  16581. }
  16582. return array;
  16583. }
  16584. /**
  16585. * The base implementation of `_.filter` without support for iteratee shorthands.
  16586. *
  16587. * @private
  16588. * @param {Array|Object} collection The collection to iterate over.
  16589. * @param {Function} predicate The function invoked per iteration.
  16590. * @returns {Array} Returns the new filtered array.
  16591. */
  16592. function baseFilter(collection, predicate) {
  16593. var result = [];
  16594. baseEach(collection, function(value, index, collection) {
  16595. if (predicate(value, index, collection)) {
  16596. result.push(value);
  16597. }
  16598. });
  16599. return result;
  16600. }
  16601. /**
  16602. * The base implementation of `_.flatten` with support for restricting flattening.
  16603. *
  16604. * @private
  16605. * @param {Array} array The array to flatten.
  16606. * @param {number} depth The maximum recursion depth.
  16607. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  16608. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  16609. * @param {Array} [result=[]] The initial result value.
  16610. * @returns {Array} Returns the new flattened array.
  16611. */
  16612. function baseFlatten(array, depth, predicate, isStrict, result) {
  16613. var index = -1,
  16614. length = array.length;
  16615. predicate || (predicate = isFlattenable);
  16616. result || (result = []);
  16617. while (++index < length) {
  16618. var value = array[index];
  16619. if (depth > 0 && predicate(value)) {
  16620. if (depth > 1) {
  16621. // Recursively flatten arrays (susceptible to call stack limits).
  16622. baseFlatten(value, depth - 1, predicate, isStrict, result);
  16623. } else {
  16624. arrayPush(result, value);
  16625. }
  16626. } else if (!isStrict) {
  16627. result[result.length] = value;
  16628. }
  16629. }
  16630. return result;
  16631. }
  16632. /**
  16633. * The base implementation of `baseForOwn` which iterates over `object`
  16634. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  16635. * Iteratee functions may exit iteration early by explicitly returning `false`.
  16636. *
  16637. * @private
  16638. * @param {Object} object The object to iterate over.
  16639. * @param {Function} iteratee The function invoked per iteration.
  16640. * @param {Function} keysFunc The function to get the keys of `object`.
  16641. * @returns {Object} Returns `object`.
  16642. */
  16643. var baseFor = createBaseFor();
  16644. /**
  16645. * This function is like `baseFor` except that it iterates over properties
  16646. * in the opposite order.
  16647. *
  16648. * @private
  16649. * @param {Object} object The object to iterate over.
  16650. * @param {Function} iteratee The function invoked per iteration.
  16651. * @param {Function} keysFunc The function to get the keys of `object`.
  16652. * @returns {Object} Returns `object`.
  16653. */
  16654. var baseForRight = createBaseFor(true);
  16655. /**
  16656. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  16657. *
  16658. * @private
  16659. * @param {Object} object The object to iterate over.
  16660. * @param {Function} iteratee The function invoked per iteration.
  16661. * @returns {Object} Returns `object`.
  16662. */
  16663. function baseForOwn(object, iteratee) {
  16664. return object && baseFor(object, iteratee, keys);
  16665. }
  16666. /**
  16667. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  16668. *
  16669. * @private
  16670. * @param {Object} object The object to iterate over.
  16671. * @param {Function} iteratee The function invoked per iteration.
  16672. * @returns {Object} Returns `object`.
  16673. */
  16674. function baseForOwnRight(object, iteratee) {
  16675. return object && baseForRight(object, iteratee, keys);
  16676. }
  16677. /**
  16678. * The base implementation of `_.functions` which creates an array of
  16679. * `object` function property names filtered from `props`.
  16680. *
  16681. * @private
  16682. * @param {Object} object The object to inspect.
  16683. * @param {Array} props The property names to filter.
  16684. * @returns {Array} Returns the function names.
  16685. */
  16686. function baseFunctions(object, props) {
  16687. return arrayFilter(props, function(key) {
  16688. return isFunction(object[key]);
  16689. });
  16690. }
  16691. /**
  16692. * The base implementation of `_.get` without support for default values.
  16693. *
  16694. * @private
  16695. * @param {Object} object The object to query.
  16696. * @param {Array|string} path The path of the property to get.
  16697. * @returns {*} Returns the resolved value.
  16698. */
  16699. function baseGet(object, path) {
  16700. path = castPath(path, object);
  16701. var index = 0,
  16702. length = path.length;
  16703. while (object != null && index < length) {
  16704. object = object[toKey(path[index++])];
  16705. }
  16706. return (index && index == length) ? object : undefined;
  16707. }
  16708. /**
  16709. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  16710. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  16711. * symbols of `object`.
  16712. *
  16713. * @private
  16714. * @param {Object} object The object to query.
  16715. * @param {Function} keysFunc The function to get the keys of `object`.
  16716. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  16717. * @returns {Array} Returns the array of property names and symbols.
  16718. */
  16719. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  16720. var result = keysFunc(object);
  16721. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  16722. }
  16723. /**
  16724. * The base implementation of `getTag` without fallbacks for buggy environments.
  16725. *
  16726. * @private
  16727. * @param {*} value The value to query.
  16728. * @returns {string} Returns the `toStringTag`.
  16729. */
  16730. function baseGetTag(value) {
  16731. if (value == null) {
  16732. return value === undefined ? undefinedTag : nullTag;
  16733. }
  16734. return (symToStringTag && symToStringTag in Object(value))
  16735. ? getRawTag(value)
  16736. : objectToString(value);
  16737. }
  16738. /**
  16739. * The base implementation of `_.gt` which doesn't coerce arguments.
  16740. *
  16741. * @private
  16742. * @param {*} value The value to compare.
  16743. * @param {*} other The other value to compare.
  16744. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  16745. * else `false`.
  16746. */
  16747. function baseGt(value, other) {
  16748. return value > other;
  16749. }
  16750. /**
  16751. * The base implementation of `_.has` without support for deep paths.
  16752. *
  16753. * @private
  16754. * @param {Object} [object] The object to query.
  16755. * @param {Array|string} key The key to check.
  16756. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  16757. */
  16758. function baseHas(object, key) {
  16759. return object != null && hasOwnProperty.call(object, key);
  16760. }
  16761. /**
  16762. * The base implementation of `_.hasIn` without support for deep paths.
  16763. *
  16764. * @private
  16765. * @param {Object} [object] The object to query.
  16766. * @param {Array|string} key The key to check.
  16767. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  16768. */
  16769. function baseHasIn(object, key) {
  16770. return object != null && key in Object(object);
  16771. }
  16772. /**
  16773. * The base implementation of `_.inRange` which doesn't coerce arguments.
  16774. *
  16775. * @private
  16776. * @param {number} number The number to check.
  16777. * @param {number} start The start of the range.
  16778. * @param {number} end The end of the range.
  16779. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  16780. */
  16781. function baseInRange(number, start, end) {
  16782. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  16783. }
  16784. /**
  16785. * The base implementation of methods like `_.intersection`, without support
  16786. * for iteratee shorthands, that accepts an array of arrays to inspect.
  16787. *
  16788. * @private
  16789. * @param {Array} arrays The arrays to inspect.
  16790. * @param {Function} [iteratee] The iteratee invoked per element.
  16791. * @param {Function} [comparator] The comparator invoked per element.
  16792. * @returns {Array} Returns the new array of shared values.
  16793. */
  16794. function baseIntersection(arrays, iteratee, comparator) {
  16795. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  16796. length = arrays[0].length,
  16797. othLength = arrays.length,
  16798. othIndex = othLength,
  16799. caches = Array(othLength),
  16800. maxLength = Infinity,
  16801. result = [];
  16802. while (othIndex--) {
  16803. var array = arrays[othIndex];
  16804. if (othIndex && iteratee) {
  16805. array = arrayMap(array, baseUnary(iteratee));
  16806. }
  16807. maxLength = nativeMin(array.length, maxLength);
  16808. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  16809. ? new SetCache(othIndex && array)
  16810. : undefined;
  16811. }
  16812. array = arrays[0];
  16813. var index = -1,
  16814. seen = caches[0];
  16815. outer:
  16816. while (++index < length && result.length < maxLength) {
  16817. var value = array[index],
  16818. computed = iteratee ? iteratee(value) : value;
  16819. value = (comparator || value !== 0) ? value : 0;
  16820. if (!(seen
  16821. ? cacheHas(seen, computed)
  16822. : includes(result, computed, comparator)
  16823. )) {
  16824. othIndex = othLength;
  16825. while (--othIndex) {
  16826. var cache = caches[othIndex];
  16827. if (!(cache
  16828. ? cacheHas(cache, computed)
  16829. : includes(arrays[othIndex], computed, comparator))
  16830. ) {
  16831. continue outer;
  16832. }
  16833. }
  16834. if (seen) {
  16835. seen.push(computed);
  16836. }
  16837. result.push(value);
  16838. }
  16839. }
  16840. return result;
  16841. }
  16842. /**
  16843. * The base implementation of `_.invert` and `_.invertBy` which inverts
  16844. * `object` with values transformed by `iteratee` and set by `setter`.
  16845. *
  16846. * @private
  16847. * @param {Object} object The object to iterate over.
  16848. * @param {Function} setter The function to set `accumulator` values.
  16849. * @param {Function} iteratee The iteratee to transform values.
  16850. * @param {Object} accumulator The initial inverted object.
  16851. * @returns {Function} Returns `accumulator`.
  16852. */
  16853. function baseInverter(object, setter, iteratee, accumulator) {
  16854. baseForOwn(object, function(value, key, object) {
  16855. setter(accumulator, iteratee(value), key, object);
  16856. });
  16857. return accumulator;
  16858. }
  16859. /**
  16860. * The base implementation of `_.invoke` without support for individual
  16861. * method arguments.
  16862. *
  16863. * @private
  16864. * @param {Object} object The object to query.
  16865. * @param {Array|string} path The path of the method to invoke.
  16866. * @param {Array} args The arguments to invoke the method with.
  16867. * @returns {*} Returns the result of the invoked method.
  16868. */
  16869. function baseInvoke(object, path, args) {
  16870. path = castPath(path, object);
  16871. object = parent(object, path);
  16872. var func = object == null ? object : object[toKey(last(path))];
  16873. return func == null ? undefined : apply(func, object, args);
  16874. }
  16875. /**
  16876. * The base implementation of `_.isArguments`.
  16877. *
  16878. * @private
  16879. * @param {*} value The value to check.
  16880. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  16881. */
  16882. function baseIsArguments(value) {
  16883. return isObjectLike(value) && baseGetTag(value) == argsTag;
  16884. }
  16885. /**
  16886. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  16887. *
  16888. * @private
  16889. * @param {*} value The value to check.
  16890. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  16891. */
  16892. function baseIsArrayBuffer(value) {
  16893. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  16894. }
  16895. /**
  16896. * The base implementation of `_.isDate` without Node.js optimizations.
  16897. *
  16898. * @private
  16899. * @param {*} value The value to check.
  16900. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  16901. */
  16902. function baseIsDate(value) {
  16903. return isObjectLike(value) && baseGetTag(value) == dateTag;
  16904. }
  16905. /**
  16906. * The base implementation of `_.isEqual` which supports partial comparisons
  16907. * and tracks traversed objects.
  16908. *
  16909. * @private
  16910. * @param {*} value The value to compare.
  16911. * @param {*} other The other value to compare.
  16912. * @param {boolean} bitmask The bitmask flags.
  16913. * 1 - Unordered comparison
  16914. * 2 - Partial comparison
  16915. * @param {Function} [customizer] The function to customize comparisons.
  16916. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  16917. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  16918. */
  16919. function baseIsEqual(value, other, bitmask, customizer, stack) {
  16920. if (value === other) {
  16921. return true;
  16922. }
  16923. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  16924. return value !== value && other !== other;
  16925. }
  16926. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  16927. }
  16928. /**
  16929. * A specialized version of `baseIsEqual` for arrays and objects which performs
  16930. * deep comparisons and tracks traversed objects enabling objects with circular
  16931. * references to be compared.
  16932. *
  16933. * @private
  16934. * @param {Object} object The object to compare.
  16935. * @param {Object} other The other object to compare.
  16936. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  16937. * @param {Function} customizer The function to customize comparisons.
  16938. * @param {Function} equalFunc The function to determine equivalents of values.
  16939. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  16940. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  16941. */
  16942. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  16943. var objIsArr = isArray(object),
  16944. othIsArr = isArray(other),
  16945. objTag = objIsArr ? arrayTag : getTag(object),
  16946. othTag = othIsArr ? arrayTag : getTag(other);
  16947. objTag = objTag == argsTag ? objectTag : objTag;
  16948. othTag = othTag == argsTag ? objectTag : othTag;
  16949. var objIsObj = objTag == objectTag,
  16950. othIsObj = othTag == objectTag,
  16951. isSameTag = objTag == othTag;
  16952. if (isSameTag && isBuffer(object)) {
  16953. if (!isBuffer(other)) {
  16954. return false;
  16955. }
  16956. objIsArr = true;
  16957. objIsObj = false;
  16958. }
  16959. if (isSameTag && !objIsObj) {
  16960. stack || (stack = new Stack);
  16961. return (objIsArr || isTypedArray(object))
  16962. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  16963. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  16964. }
  16965. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  16966. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  16967. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  16968. if (objIsWrapped || othIsWrapped) {
  16969. var objUnwrapped = objIsWrapped ? object.value() : object,
  16970. othUnwrapped = othIsWrapped ? other.value() : other;
  16971. stack || (stack = new Stack);
  16972. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  16973. }
  16974. }
  16975. if (!isSameTag) {
  16976. return false;
  16977. }
  16978. stack || (stack = new Stack);
  16979. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  16980. }
  16981. /**
  16982. * The base implementation of `_.isMap` without Node.js optimizations.
  16983. *
  16984. * @private
  16985. * @param {*} value The value to check.
  16986. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  16987. */
  16988. function baseIsMap(value) {
  16989. return isObjectLike(value) && getTag(value) == mapTag;
  16990. }
  16991. /**
  16992. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  16993. *
  16994. * @private
  16995. * @param {Object} object The object to inspect.
  16996. * @param {Object} source The object of property values to match.
  16997. * @param {Array} matchData The property names, values, and compare flags to match.
  16998. * @param {Function} [customizer] The function to customize comparisons.
  16999. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  17000. */
  17001. function baseIsMatch(object, source, matchData, customizer) {
  17002. var index = matchData.length,
  17003. length = index,
  17004. noCustomizer = !customizer;
  17005. if (object == null) {
  17006. return !length;
  17007. }
  17008. object = Object(object);
  17009. while (index--) {
  17010. var data = matchData[index];
  17011. if ((noCustomizer && data[2])
  17012. ? data[1] !== object[data[0]]
  17013. : !(data[0] in object)
  17014. ) {
  17015. return false;
  17016. }
  17017. }
  17018. while (++index < length) {
  17019. data = matchData[index];
  17020. var key = data[0],
  17021. objValue = object[key],
  17022. srcValue = data[1];
  17023. if (noCustomizer && data[2]) {
  17024. if (objValue === undefined && !(key in object)) {
  17025. return false;
  17026. }
  17027. } else {
  17028. var stack = new Stack;
  17029. if (customizer) {
  17030. var result = customizer(objValue, srcValue, key, object, source, stack);
  17031. }
  17032. if (!(result === undefined
  17033. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  17034. : result
  17035. )) {
  17036. return false;
  17037. }
  17038. }
  17039. }
  17040. return true;
  17041. }
  17042. /**
  17043. * The base implementation of `_.isNative` without bad shim checks.
  17044. *
  17045. * @private
  17046. * @param {*} value The value to check.
  17047. * @returns {boolean} Returns `true` if `value` is a native function,
  17048. * else `false`.
  17049. */
  17050. function baseIsNative(value) {
  17051. if (!isObject(value) || isMasked(value)) {
  17052. return false;
  17053. }
  17054. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  17055. return pattern.test(toSource(value));
  17056. }
  17057. /**
  17058. * The base implementation of `_.isRegExp` without Node.js optimizations.
  17059. *
  17060. * @private
  17061. * @param {*} value The value to check.
  17062. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  17063. */
  17064. function baseIsRegExp(value) {
  17065. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  17066. }
  17067. /**
  17068. * The base implementation of `_.isSet` without Node.js optimizations.
  17069. *
  17070. * @private
  17071. * @param {*} value The value to check.
  17072. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  17073. */
  17074. function baseIsSet(value) {
  17075. return isObjectLike(value) && getTag(value) == setTag;
  17076. }
  17077. /**
  17078. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  17079. *
  17080. * @private
  17081. * @param {*} value The value to check.
  17082. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  17083. */
  17084. function baseIsTypedArray(value) {
  17085. return isObjectLike(value) &&
  17086. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  17087. }
  17088. /**
  17089. * The base implementation of `_.iteratee`.
  17090. *
  17091. * @private
  17092. * @param {*} [value=_.identity] The value to convert to an iteratee.
  17093. * @returns {Function} Returns the iteratee.
  17094. */
  17095. function baseIteratee(value) {
  17096. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  17097. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  17098. if (typeof value == 'function') {
  17099. return value;
  17100. }
  17101. if (value == null) {
  17102. return identity;
  17103. }
  17104. if (typeof value == 'object') {
  17105. return isArray(value)
  17106. ? baseMatchesProperty(value[0], value[1])
  17107. : baseMatches(value);
  17108. }
  17109. return property(value);
  17110. }
  17111. /**
  17112. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  17113. *
  17114. * @private
  17115. * @param {Object} object The object to query.
  17116. * @returns {Array} Returns the array of property names.
  17117. */
  17118. function baseKeys(object) {
  17119. if (!isPrototype(object)) {
  17120. return nativeKeys(object);
  17121. }
  17122. var result = [];
  17123. for (var key in Object(object)) {
  17124. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  17125. result.push(key);
  17126. }
  17127. }
  17128. return result;
  17129. }
  17130. /**
  17131. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  17132. *
  17133. * @private
  17134. * @param {Object} object The object to query.
  17135. * @returns {Array} Returns the array of property names.
  17136. */
  17137. function baseKeysIn(object) {
  17138. if (!isObject(object)) {
  17139. return nativeKeysIn(object);
  17140. }
  17141. var isProto = isPrototype(object),
  17142. result = [];
  17143. for (var key in object) {
  17144. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  17145. result.push(key);
  17146. }
  17147. }
  17148. return result;
  17149. }
  17150. /**
  17151. * The base implementation of `_.lt` which doesn't coerce arguments.
  17152. *
  17153. * @private
  17154. * @param {*} value The value to compare.
  17155. * @param {*} other The other value to compare.
  17156. * @returns {boolean} Returns `true` if `value` is less than `other`,
  17157. * else `false`.
  17158. */
  17159. function baseLt(value, other) {
  17160. return value < other;
  17161. }
  17162. /**
  17163. * The base implementation of `_.map` without support for iteratee shorthands.
  17164. *
  17165. * @private
  17166. * @param {Array|Object} collection The collection to iterate over.
  17167. * @param {Function} iteratee The function invoked per iteration.
  17168. * @returns {Array} Returns the new mapped array.
  17169. */
  17170. function baseMap(collection, iteratee) {
  17171. var index = -1,
  17172. result = isArrayLike(collection) ? Array(collection.length) : [];
  17173. baseEach(collection, function(value, key, collection) {
  17174. result[++index] = iteratee(value, key, collection);
  17175. });
  17176. return result;
  17177. }
  17178. /**
  17179. * The base implementation of `_.matches` which doesn't clone `source`.
  17180. *
  17181. * @private
  17182. * @param {Object} source The object of property values to match.
  17183. * @returns {Function} Returns the new spec function.
  17184. */
  17185. function baseMatches(source) {
  17186. var matchData = getMatchData(source);
  17187. if (matchData.length == 1 && matchData[0][2]) {
  17188. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  17189. }
  17190. return function(object) {
  17191. return object === source || baseIsMatch(object, source, matchData);
  17192. };
  17193. }
  17194. /**
  17195. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  17196. *
  17197. * @private
  17198. * @param {string} path The path of the property to get.
  17199. * @param {*} srcValue The value to match.
  17200. * @returns {Function} Returns the new spec function.
  17201. */
  17202. function baseMatchesProperty(path, srcValue) {
  17203. if (isKey(path) && isStrictComparable(srcValue)) {
  17204. return matchesStrictComparable(toKey(path), srcValue);
  17205. }
  17206. return function(object) {
  17207. var objValue = get(object, path);
  17208. return (objValue === undefined && objValue === srcValue)
  17209. ? hasIn(object, path)
  17210. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  17211. };
  17212. }
  17213. /**
  17214. * The base implementation of `_.merge` without support for multiple sources.
  17215. *
  17216. * @private
  17217. * @param {Object} object The destination object.
  17218. * @param {Object} source The source object.
  17219. * @param {number} srcIndex The index of `source`.
  17220. * @param {Function} [customizer] The function to customize merged values.
  17221. * @param {Object} [stack] Tracks traversed source values and their merged
  17222. * counterparts.
  17223. */
  17224. function baseMerge(object, source, srcIndex, customizer, stack) {
  17225. if (object === source) {
  17226. return;
  17227. }
  17228. baseFor(source, function(srcValue, key) {
  17229. stack || (stack = new Stack);
  17230. if (isObject(srcValue)) {
  17231. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  17232. }
  17233. else {
  17234. var newValue = customizer
  17235. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  17236. : undefined;
  17237. if (newValue === undefined) {
  17238. newValue = srcValue;
  17239. }
  17240. assignMergeValue(object, key, newValue);
  17241. }
  17242. }, keysIn);
  17243. }
  17244. /**
  17245. * A specialized version of `baseMerge` for arrays and objects which performs
  17246. * deep merges and tracks traversed objects enabling objects with circular
  17247. * references to be merged.
  17248. *
  17249. * @private
  17250. * @param {Object} object The destination object.
  17251. * @param {Object} source The source object.
  17252. * @param {string} key The key of the value to merge.
  17253. * @param {number} srcIndex The index of `source`.
  17254. * @param {Function} mergeFunc The function to merge values.
  17255. * @param {Function} [customizer] The function to customize assigned values.
  17256. * @param {Object} [stack] Tracks traversed source values and their merged
  17257. * counterparts.
  17258. */
  17259. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  17260. var objValue = safeGet(object, key),
  17261. srcValue = safeGet(source, key),
  17262. stacked = stack.get(srcValue);
  17263. if (stacked) {
  17264. assignMergeValue(object, key, stacked);
  17265. return;
  17266. }
  17267. var newValue = customizer
  17268. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  17269. : undefined;
  17270. var isCommon = newValue === undefined;
  17271. if (isCommon) {
  17272. var isArr = isArray(srcValue),
  17273. isBuff = !isArr && isBuffer(srcValue),
  17274. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  17275. newValue = srcValue;
  17276. if (isArr || isBuff || isTyped) {
  17277. if (isArray(objValue)) {
  17278. newValue = objValue;
  17279. }
  17280. else if (isArrayLikeObject(objValue)) {
  17281. newValue = copyArray(objValue);
  17282. }
  17283. else if (isBuff) {
  17284. isCommon = false;
  17285. newValue = cloneBuffer(srcValue, true);
  17286. }
  17287. else if (isTyped) {
  17288. isCommon = false;
  17289. newValue = cloneTypedArray(srcValue, true);
  17290. }
  17291. else {
  17292. newValue = [];
  17293. }
  17294. }
  17295. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  17296. newValue = objValue;
  17297. if (isArguments(objValue)) {
  17298. newValue = toPlainObject(objValue);
  17299. }
  17300. else if (!isObject(objValue) || isFunction(objValue)) {
  17301. newValue = initCloneObject(srcValue);
  17302. }
  17303. }
  17304. else {
  17305. isCommon = false;
  17306. }
  17307. }
  17308. if (isCommon) {
  17309. // Recursively merge objects and arrays (susceptible to call stack limits).
  17310. stack.set(srcValue, newValue);
  17311. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  17312. stack['delete'](srcValue);
  17313. }
  17314. assignMergeValue(object, key, newValue);
  17315. }
  17316. /**
  17317. * The base implementation of `_.nth` which doesn't coerce arguments.
  17318. *
  17319. * @private
  17320. * @param {Array} array The array to query.
  17321. * @param {number} n The index of the element to return.
  17322. * @returns {*} Returns the nth element of `array`.
  17323. */
  17324. function baseNth(array, n) {
  17325. var length = array.length;
  17326. if (!length) {
  17327. return;
  17328. }
  17329. n += n < 0 ? length : 0;
  17330. return isIndex(n, length) ? array[n] : undefined;
  17331. }
  17332. /**
  17333. * The base implementation of `_.orderBy` without param guards.
  17334. *
  17335. * @private
  17336. * @param {Array|Object} collection The collection to iterate over.
  17337. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  17338. * @param {string[]} orders The sort orders of `iteratees`.
  17339. * @returns {Array} Returns the new sorted array.
  17340. */
  17341. function baseOrderBy(collection, iteratees, orders) {
  17342. var index = -1;
  17343. iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
  17344. var result = baseMap(collection, function(value, key, collection) {
  17345. var criteria = arrayMap(iteratees, function(iteratee) {
  17346. return iteratee(value);
  17347. });
  17348. return { 'criteria': criteria, 'index': ++index, 'value': value };
  17349. });
  17350. return baseSortBy(result, function(object, other) {
  17351. return compareMultiple(object, other, orders);
  17352. });
  17353. }
  17354. /**
  17355. * The base implementation of `_.pick` without support for individual
  17356. * property identifiers.
  17357. *
  17358. * @private
  17359. * @param {Object} object The source object.
  17360. * @param {string[]} paths The property paths to pick.
  17361. * @returns {Object} Returns the new object.
  17362. */
  17363. function basePick(object, paths) {
  17364. return basePickBy(object, paths, function(value, path) {
  17365. return hasIn(object, path);
  17366. });
  17367. }
  17368. /**
  17369. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  17370. *
  17371. * @private
  17372. * @param {Object} object The source object.
  17373. * @param {string[]} paths The property paths to pick.
  17374. * @param {Function} predicate The function invoked per property.
  17375. * @returns {Object} Returns the new object.
  17376. */
  17377. function basePickBy(object, paths, predicate) {
  17378. var index = -1,
  17379. length = paths.length,
  17380. result = {};
  17381. while (++index < length) {
  17382. var path = paths[index],
  17383. value = baseGet(object, path);
  17384. if (predicate(value, path)) {
  17385. baseSet(result, castPath(path, object), value);
  17386. }
  17387. }
  17388. return result;
  17389. }
  17390. /**
  17391. * A specialized version of `baseProperty` which supports deep paths.
  17392. *
  17393. * @private
  17394. * @param {Array|string} path The path of the property to get.
  17395. * @returns {Function} Returns the new accessor function.
  17396. */
  17397. function basePropertyDeep(path) {
  17398. return function(object) {
  17399. return baseGet(object, path);
  17400. };
  17401. }
  17402. /**
  17403. * The base implementation of `_.pullAllBy` without support for iteratee
  17404. * shorthands.
  17405. *
  17406. * @private
  17407. * @param {Array} array The array to modify.
  17408. * @param {Array} values The values to remove.
  17409. * @param {Function} [iteratee] The iteratee invoked per element.
  17410. * @param {Function} [comparator] The comparator invoked per element.
  17411. * @returns {Array} Returns `array`.
  17412. */
  17413. function basePullAll(array, values, iteratee, comparator) {
  17414. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  17415. index = -1,
  17416. length = values.length,
  17417. seen = array;
  17418. if (array === values) {
  17419. values = copyArray(values);
  17420. }
  17421. if (iteratee) {
  17422. seen = arrayMap(array, baseUnary(iteratee));
  17423. }
  17424. while (++index < length) {
  17425. var fromIndex = 0,
  17426. value = values[index],
  17427. computed = iteratee ? iteratee(value) : value;
  17428. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  17429. if (seen !== array) {
  17430. splice.call(seen, fromIndex, 1);
  17431. }
  17432. splice.call(array, fromIndex, 1);
  17433. }
  17434. }
  17435. return array;
  17436. }
  17437. /**
  17438. * The base implementation of `_.pullAt` without support for individual
  17439. * indexes or capturing the removed elements.
  17440. *
  17441. * @private
  17442. * @param {Array} array The array to modify.
  17443. * @param {number[]} indexes The indexes of elements to remove.
  17444. * @returns {Array} Returns `array`.
  17445. */
  17446. function basePullAt(array, indexes) {
  17447. var length = array ? indexes.length : 0,
  17448. lastIndex = length - 1;
  17449. while (length--) {
  17450. var index = indexes[length];
  17451. if (length == lastIndex || index !== previous) {
  17452. var previous = index;
  17453. if (isIndex(index)) {
  17454. splice.call(array, index, 1);
  17455. } else {
  17456. baseUnset(array, index);
  17457. }
  17458. }
  17459. }
  17460. return array;
  17461. }
  17462. /**
  17463. * The base implementation of `_.random` without support for returning
  17464. * floating-point numbers.
  17465. *
  17466. * @private
  17467. * @param {number} lower The lower bound.
  17468. * @param {number} upper The upper bound.
  17469. * @returns {number} Returns the random number.
  17470. */
  17471. function baseRandom(lower, upper) {
  17472. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  17473. }
  17474. /**
  17475. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  17476. * coerce arguments.
  17477. *
  17478. * @private
  17479. * @param {number} start The start of the range.
  17480. * @param {number} end The end of the range.
  17481. * @param {number} step The value to increment or decrement by.
  17482. * @param {boolean} [fromRight] Specify iterating from right to left.
  17483. * @returns {Array} Returns the range of numbers.
  17484. */
  17485. function baseRange(start, end, step, fromRight) {
  17486. var index = -1,
  17487. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  17488. result = Array(length);
  17489. while (length--) {
  17490. result[fromRight ? length : ++index] = start;
  17491. start += step;
  17492. }
  17493. return result;
  17494. }
  17495. /**
  17496. * The base implementation of `_.repeat` which doesn't coerce arguments.
  17497. *
  17498. * @private
  17499. * @param {string} string The string to repeat.
  17500. * @param {number} n The number of times to repeat the string.
  17501. * @returns {string} Returns the repeated string.
  17502. */
  17503. function baseRepeat(string, n) {
  17504. var result = '';
  17505. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  17506. return result;
  17507. }
  17508. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  17509. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  17510. do {
  17511. if (n % 2) {
  17512. result += string;
  17513. }
  17514. n = nativeFloor(n / 2);
  17515. if (n) {
  17516. string += string;
  17517. }
  17518. } while (n);
  17519. return result;
  17520. }
  17521. /**
  17522. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  17523. *
  17524. * @private
  17525. * @param {Function} func The function to apply a rest parameter to.
  17526. * @param {number} [start=func.length-1] The start position of the rest parameter.
  17527. * @returns {Function} Returns the new function.
  17528. */
  17529. function baseRest(func, start) {
  17530. return setToString(overRest(func, start, identity), func + '');
  17531. }
  17532. /**
  17533. * The base implementation of `_.sample`.
  17534. *
  17535. * @private
  17536. * @param {Array|Object} collection The collection to sample.
  17537. * @returns {*} Returns the random element.
  17538. */
  17539. function baseSample(collection) {
  17540. return arraySample(values(collection));
  17541. }
  17542. /**
  17543. * The base implementation of `_.sampleSize` without param guards.
  17544. *
  17545. * @private
  17546. * @param {Array|Object} collection The collection to sample.
  17547. * @param {number} n The number of elements to sample.
  17548. * @returns {Array} Returns the random elements.
  17549. */
  17550. function baseSampleSize(collection, n) {
  17551. var array = values(collection);
  17552. return shuffleSelf(array, baseClamp(n, 0, array.length));
  17553. }
  17554. /**
  17555. * The base implementation of `_.set`.
  17556. *
  17557. * @private
  17558. * @param {Object} object The object to modify.
  17559. * @param {Array|string} path The path of the property to set.
  17560. * @param {*} value The value to set.
  17561. * @param {Function} [customizer] The function to customize path creation.
  17562. * @returns {Object} Returns `object`.
  17563. */
  17564. function baseSet(object, path, value, customizer) {
  17565. if (!isObject(object)) {
  17566. return object;
  17567. }
  17568. path = castPath(path, object);
  17569. var index = -1,
  17570. length = path.length,
  17571. lastIndex = length - 1,
  17572. nested = object;
  17573. while (nested != null && ++index < length) {
  17574. var key = toKey(path[index]),
  17575. newValue = value;
  17576. if (index != lastIndex) {
  17577. var objValue = nested[key];
  17578. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  17579. if (newValue === undefined) {
  17580. newValue = isObject(objValue)
  17581. ? objValue
  17582. : (isIndex(path[index + 1]) ? [] : {});
  17583. }
  17584. }
  17585. assignValue(nested, key, newValue);
  17586. nested = nested[key];
  17587. }
  17588. return object;
  17589. }
  17590. /**
  17591. * The base implementation of `setData` without support for hot loop shorting.
  17592. *
  17593. * @private
  17594. * @param {Function} func The function to associate metadata with.
  17595. * @param {*} data The metadata.
  17596. * @returns {Function} Returns `func`.
  17597. */
  17598. var baseSetData = !metaMap ? identity : function(func, data) {
  17599. metaMap.set(func, data);
  17600. return func;
  17601. };
  17602. /**
  17603. * The base implementation of `setToString` without support for hot loop shorting.
  17604. *
  17605. * @private
  17606. * @param {Function} func The function to modify.
  17607. * @param {Function} string The `toString` result.
  17608. * @returns {Function} Returns `func`.
  17609. */
  17610. var baseSetToString = !defineProperty ? identity : function(func, string) {
  17611. return defineProperty(func, 'toString', {
  17612. 'configurable': true,
  17613. 'enumerable': false,
  17614. 'value': constant(string),
  17615. 'writable': true
  17616. });
  17617. };
  17618. /**
  17619. * The base implementation of `_.shuffle`.
  17620. *
  17621. * @private
  17622. * @param {Array|Object} collection The collection to shuffle.
  17623. * @returns {Array} Returns the new shuffled array.
  17624. */
  17625. function baseShuffle(collection) {
  17626. return shuffleSelf(values(collection));
  17627. }
  17628. /**
  17629. * The base implementation of `_.slice` without an iteratee call guard.
  17630. *
  17631. * @private
  17632. * @param {Array} array The array to slice.
  17633. * @param {number} [start=0] The start position.
  17634. * @param {number} [end=array.length] The end position.
  17635. * @returns {Array} Returns the slice of `array`.
  17636. */
  17637. function baseSlice(array, start, end) {
  17638. var index = -1,
  17639. length = array.length;
  17640. if (start < 0) {
  17641. start = -start > length ? 0 : (length + start);
  17642. }
  17643. end = end > length ? length : end;
  17644. if (end < 0) {
  17645. end += length;
  17646. }
  17647. length = start > end ? 0 : ((end - start) >>> 0);
  17648. start >>>= 0;
  17649. var result = Array(length);
  17650. while (++index < length) {
  17651. result[index] = array[index + start];
  17652. }
  17653. return result;
  17654. }
  17655. /**
  17656. * The base implementation of `_.some` without support for iteratee shorthands.
  17657. *
  17658. * @private
  17659. * @param {Array|Object} collection The collection to iterate over.
  17660. * @param {Function} predicate The function invoked per iteration.
  17661. * @returns {boolean} Returns `true` if any element passes the predicate check,
  17662. * else `false`.
  17663. */
  17664. function baseSome(collection, predicate) {
  17665. var result;
  17666. baseEach(collection, function(value, index, collection) {
  17667. result = predicate(value, index, collection);
  17668. return !result;
  17669. });
  17670. return !!result;
  17671. }
  17672. /**
  17673. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  17674. * performs a binary search of `array` to determine the index at which `value`
  17675. * should be inserted into `array` in order to maintain its sort order.
  17676. *
  17677. * @private
  17678. * @param {Array} array The sorted array to inspect.
  17679. * @param {*} value The value to evaluate.
  17680. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  17681. * @returns {number} Returns the index at which `value` should be inserted
  17682. * into `array`.
  17683. */
  17684. function baseSortedIndex(array, value, retHighest) {
  17685. var low = 0,
  17686. high = array == null ? low : array.length;
  17687. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  17688. while (low < high) {
  17689. var mid = (low + high) >>> 1,
  17690. computed = array[mid];
  17691. if (computed !== null && !isSymbol(computed) &&
  17692. (retHighest ? (computed <= value) : (computed < value))) {
  17693. low = mid + 1;
  17694. } else {
  17695. high = mid;
  17696. }
  17697. }
  17698. return high;
  17699. }
  17700. return baseSortedIndexBy(array, value, identity, retHighest);
  17701. }
  17702. /**
  17703. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  17704. * which invokes `iteratee` for `value` and each element of `array` to compute
  17705. * their sort ranking. The iteratee is invoked with one argument; (value).
  17706. *
  17707. * @private
  17708. * @param {Array} array The sorted array to inspect.
  17709. * @param {*} value The value to evaluate.
  17710. * @param {Function} iteratee The iteratee invoked per element.
  17711. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  17712. * @returns {number} Returns the index at which `value` should be inserted
  17713. * into `array`.
  17714. */
  17715. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  17716. value = iteratee(value);
  17717. var low = 0,
  17718. high = array == null ? 0 : array.length,
  17719. valIsNaN = value !== value,
  17720. valIsNull = value === null,
  17721. valIsSymbol = isSymbol(value),
  17722. valIsUndefined = value === undefined;
  17723. while (low < high) {
  17724. var mid = nativeFloor((low + high) / 2),
  17725. computed = iteratee(array[mid]),
  17726. othIsDefined = computed !== undefined,
  17727. othIsNull = computed === null,
  17728. othIsReflexive = computed === computed,
  17729. othIsSymbol = isSymbol(computed);
  17730. if (valIsNaN) {
  17731. var setLow = retHighest || othIsReflexive;
  17732. } else if (valIsUndefined) {
  17733. setLow = othIsReflexive && (retHighest || othIsDefined);
  17734. } else if (valIsNull) {
  17735. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  17736. } else if (valIsSymbol) {
  17737. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  17738. } else if (othIsNull || othIsSymbol) {
  17739. setLow = false;
  17740. } else {
  17741. setLow = retHighest ? (computed <= value) : (computed < value);
  17742. }
  17743. if (setLow) {
  17744. low = mid + 1;
  17745. } else {
  17746. high = mid;
  17747. }
  17748. }
  17749. return nativeMin(high, MAX_ARRAY_INDEX);
  17750. }
  17751. /**
  17752. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  17753. * support for iteratee shorthands.
  17754. *
  17755. * @private
  17756. * @param {Array} array The array to inspect.
  17757. * @param {Function} [iteratee] The iteratee invoked per element.
  17758. * @returns {Array} Returns the new duplicate free array.
  17759. */
  17760. function baseSortedUniq(array, iteratee) {
  17761. var index = -1,
  17762. length = array.length,
  17763. resIndex = 0,
  17764. result = [];
  17765. while (++index < length) {
  17766. var value = array[index],
  17767. computed = iteratee ? iteratee(value) : value;
  17768. if (!index || !eq(computed, seen)) {
  17769. var seen = computed;
  17770. result[resIndex++] = value === 0 ? 0 : value;
  17771. }
  17772. }
  17773. return result;
  17774. }
  17775. /**
  17776. * The base implementation of `_.toNumber` which doesn't ensure correct
  17777. * conversions of binary, hexadecimal, or octal string values.
  17778. *
  17779. * @private
  17780. * @param {*} value The value to process.
  17781. * @returns {number} Returns the number.
  17782. */
  17783. function baseToNumber(value) {
  17784. if (typeof value == 'number') {
  17785. return value;
  17786. }
  17787. if (isSymbol(value)) {
  17788. return NAN;
  17789. }
  17790. return +value;
  17791. }
  17792. /**
  17793. * The base implementation of `_.toString` which doesn't convert nullish
  17794. * values to empty strings.
  17795. *
  17796. * @private
  17797. * @param {*} value The value to process.
  17798. * @returns {string} Returns the string.
  17799. */
  17800. function baseToString(value) {
  17801. // Exit early for strings to avoid a performance hit in some environments.
  17802. if (typeof value == 'string') {
  17803. return value;
  17804. }
  17805. if (isArray(value)) {
  17806. // Recursively convert values (susceptible to call stack limits).
  17807. return arrayMap(value, baseToString) + '';
  17808. }
  17809. if (isSymbol(value)) {
  17810. return symbolToString ? symbolToString.call(value) : '';
  17811. }
  17812. var result = (value + '');
  17813. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  17814. }
  17815. /**
  17816. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  17817. *
  17818. * @private
  17819. * @param {Array} array The array to inspect.
  17820. * @param {Function} [iteratee] The iteratee invoked per element.
  17821. * @param {Function} [comparator] The comparator invoked per element.
  17822. * @returns {Array} Returns the new duplicate free array.
  17823. */
  17824. function baseUniq(array, iteratee, comparator) {
  17825. var index = -1,
  17826. includes = arrayIncludes,
  17827. length = array.length,
  17828. isCommon = true,
  17829. result = [],
  17830. seen = result;
  17831. if (comparator) {
  17832. isCommon = false;
  17833. includes = arrayIncludesWith;
  17834. }
  17835. else if (length >= LARGE_ARRAY_SIZE) {
  17836. var set = iteratee ? null : createSet(array);
  17837. if (set) {
  17838. return setToArray(set);
  17839. }
  17840. isCommon = false;
  17841. includes = cacheHas;
  17842. seen = new SetCache;
  17843. }
  17844. else {
  17845. seen = iteratee ? [] : result;
  17846. }
  17847. outer:
  17848. while (++index < length) {
  17849. var value = array[index],
  17850. computed = iteratee ? iteratee(value) : value;
  17851. value = (comparator || value !== 0) ? value : 0;
  17852. if (isCommon && computed === computed) {
  17853. var seenIndex = seen.length;
  17854. while (seenIndex--) {
  17855. if (seen[seenIndex] === computed) {
  17856. continue outer;
  17857. }
  17858. }
  17859. if (iteratee) {
  17860. seen.push(computed);
  17861. }
  17862. result.push(value);
  17863. }
  17864. else if (!includes(seen, computed, comparator)) {
  17865. if (seen !== result) {
  17866. seen.push(computed);
  17867. }
  17868. result.push(value);
  17869. }
  17870. }
  17871. return result;
  17872. }
  17873. /**
  17874. * The base implementation of `_.unset`.
  17875. *
  17876. * @private
  17877. * @param {Object} object The object to modify.
  17878. * @param {Array|string} path The property path to unset.
  17879. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  17880. */
  17881. function baseUnset(object, path) {
  17882. path = castPath(path, object);
  17883. object = parent(object, path);
  17884. return object == null || delete object[toKey(last(path))];
  17885. }
  17886. /**
  17887. * The base implementation of `_.update`.
  17888. *
  17889. * @private
  17890. * @param {Object} object The object to modify.
  17891. * @param {Array|string} path The path of the property to update.
  17892. * @param {Function} updater The function to produce the updated value.
  17893. * @param {Function} [customizer] The function to customize path creation.
  17894. * @returns {Object} Returns `object`.
  17895. */
  17896. function baseUpdate(object, path, updater, customizer) {
  17897. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  17898. }
  17899. /**
  17900. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  17901. * without support for iteratee shorthands.
  17902. *
  17903. * @private
  17904. * @param {Array} array The array to query.
  17905. * @param {Function} predicate The function invoked per iteration.
  17906. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  17907. * @param {boolean} [fromRight] Specify iterating from right to left.
  17908. * @returns {Array} Returns the slice of `array`.
  17909. */
  17910. function baseWhile(array, predicate, isDrop, fromRight) {
  17911. var length = array.length,
  17912. index = fromRight ? length : -1;
  17913. while ((fromRight ? index-- : ++index < length) &&
  17914. predicate(array[index], index, array)) {}
  17915. return isDrop
  17916. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  17917. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  17918. }
  17919. /**
  17920. * The base implementation of `wrapperValue` which returns the result of
  17921. * performing a sequence of actions on the unwrapped `value`, where each
  17922. * successive action is supplied the return value of the previous.
  17923. *
  17924. * @private
  17925. * @param {*} value The unwrapped value.
  17926. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  17927. * @returns {*} Returns the resolved value.
  17928. */
  17929. function baseWrapperValue(value, actions) {
  17930. var result = value;
  17931. if (result instanceof LazyWrapper) {
  17932. result = result.value();
  17933. }
  17934. return arrayReduce(actions, function(result, action) {
  17935. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  17936. }, result);
  17937. }
  17938. /**
  17939. * The base implementation of methods like `_.xor`, without support for
  17940. * iteratee shorthands, that accepts an array of arrays to inspect.
  17941. *
  17942. * @private
  17943. * @param {Array} arrays The arrays to inspect.
  17944. * @param {Function} [iteratee] The iteratee invoked per element.
  17945. * @param {Function} [comparator] The comparator invoked per element.
  17946. * @returns {Array} Returns the new array of values.
  17947. */
  17948. function baseXor(arrays, iteratee, comparator) {
  17949. var length = arrays.length;
  17950. if (length < 2) {
  17951. return length ? baseUniq(arrays[0]) : [];
  17952. }
  17953. var index = -1,
  17954. result = Array(length);
  17955. while (++index < length) {
  17956. var array = arrays[index],
  17957. othIndex = -1;
  17958. while (++othIndex < length) {
  17959. if (othIndex != index) {
  17960. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  17961. }
  17962. }
  17963. }
  17964. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  17965. }
  17966. /**
  17967. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  17968. *
  17969. * @private
  17970. * @param {Array} props The property identifiers.
  17971. * @param {Array} values The property values.
  17972. * @param {Function} assignFunc The function to assign values.
  17973. * @returns {Object} Returns the new object.
  17974. */
  17975. function baseZipObject(props, values, assignFunc) {
  17976. var index = -1,
  17977. length = props.length,
  17978. valsLength = values.length,
  17979. result = {};
  17980. while (++index < length) {
  17981. var value = index < valsLength ? values[index] : undefined;
  17982. assignFunc(result, props[index], value);
  17983. }
  17984. return result;
  17985. }
  17986. /**
  17987. * Casts `value` to an empty array if it's not an array like object.
  17988. *
  17989. * @private
  17990. * @param {*} value The value to inspect.
  17991. * @returns {Array|Object} Returns the cast array-like object.
  17992. */
  17993. function castArrayLikeObject(value) {
  17994. return isArrayLikeObject(value) ? value : [];
  17995. }
  17996. /**
  17997. * Casts `value` to `identity` if it's not a function.
  17998. *
  17999. * @private
  18000. * @param {*} value The value to inspect.
  18001. * @returns {Function} Returns cast function.
  18002. */
  18003. function castFunction(value) {
  18004. return typeof value == 'function' ? value : identity;
  18005. }
  18006. /**
  18007. * Casts `value` to a path array if it's not one.
  18008. *
  18009. * @private
  18010. * @param {*} value The value to inspect.
  18011. * @param {Object} [object] The object to query keys on.
  18012. * @returns {Array} Returns the cast property path array.
  18013. */
  18014. function castPath(value, object) {
  18015. if (isArray(value)) {
  18016. return value;
  18017. }
  18018. return isKey(value, object) ? [value] : stringToPath(toString(value));
  18019. }
  18020. /**
  18021. * A `baseRest` alias which can be replaced with `identity` by module
  18022. * replacement plugins.
  18023. *
  18024. * @private
  18025. * @type {Function}
  18026. * @param {Function} func The function to apply a rest parameter to.
  18027. * @returns {Function} Returns the new function.
  18028. */
  18029. var castRest = baseRest;
  18030. /**
  18031. * Casts `array` to a slice if it's needed.
  18032. *
  18033. * @private
  18034. * @param {Array} array The array to inspect.
  18035. * @param {number} start The start position.
  18036. * @param {number} [end=array.length] The end position.
  18037. * @returns {Array} Returns the cast slice.
  18038. */
  18039. function castSlice(array, start, end) {
  18040. var length = array.length;
  18041. end = end === undefined ? length : end;
  18042. return (!start && end >= length) ? array : baseSlice(array, start, end);
  18043. }
  18044. /**
  18045. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  18046. *
  18047. * @private
  18048. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  18049. */
  18050. var clearTimeout = ctxClearTimeout || function(id) {
  18051. return root.clearTimeout(id);
  18052. };
  18053. /**
  18054. * Creates a clone of `buffer`.
  18055. *
  18056. * @private
  18057. * @param {Buffer} buffer The buffer to clone.
  18058. * @param {boolean} [isDeep] Specify a deep clone.
  18059. * @returns {Buffer} Returns the cloned buffer.
  18060. */
  18061. function cloneBuffer(buffer, isDeep) {
  18062. if (isDeep) {
  18063. return buffer.slice();
  18064. }
  18065. var length = buffer.length,
  18066. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  18067. buffer.copy(result);
  18068. return result;
  18069. }
  18070. /**
  18071. * Creates a clone of `arrayBuffer`.
  18072. *
  18073. * @private
  18074. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  18075. * @returns {ArrayBuffer} Returns the cloned array buffer.
  18076. */
  18077. function cloneArrayBuffer(arrayBuffer) {
  18078. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  18079. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  18080. return result;
  18081. }
  18082. /**
  18083. * Creates a clone of `dataView`.
  18084. *
  18085. * @private
  18086. * @param {Object} dataView The data view to clone.
  18087. * @param {boolean} [isDeep] Specify a deep clone.
  18088. * @returns {Object} Returns the cloned data view.
  18089. */
  18090. function cloneDataView(dataView, isDeep) {
  18091. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  18092. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  18093. }
  18094. /**
  18095. * Creates a clone of `regexp`.
  18096. *
  18097. * @private
  18098. * @param {Object} regexp The regexp to clone.
  18099. * @returns {Object} Returns the cloned regexp.
  18100. */
  18101. function cloneRegExp(regexp) {
  18102. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  18103. result.lastIndex = regexp.lastIndex;
  18104. return result;
  18105. }
  18106. /**
  18107. * Creates a clone of the `symbol` object.
  18108. *
  18109. * @private
  18110. * @param {Object} symbol The symbol object to clone.
  18111. * @returns {Object} Returns the cloned symbol object.
  18112. */
  18113. function cloneSymbol(symbol) {
  18114. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  18115. }
  18116. /**
  18117. * Creates a clone of `typedArray`.
  18118. *
  18119. * @private
  18120. * @param {Object} typedArray The typed array to clone.
  18121. * @param {boolean} [isDeep] Specify a deep clone.
  18122. * @returns {Object} Returns the cloned typed array.
  18123. */
  18124. function cloneTypedArray(typedArray, isDeep) {
  18125. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  18126. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  18127. }
  18128. /**
  18129. * Compares values to sort them in ascending order.
  18130. *
  18131. * @private
  18132. * @param {*} value The value to compare.
  18133. * @param {*} other The other value to compare.
  18134. * @returns {number} Returns the sort order indicator for `value`.
  18135. */
  18136. function compareAscending(value, other) {
  18137. if (value !== other) {
  18138. var valIsDefined = value !== undefined,
  18139. valIsNull = value === null,
  18140. valIsReflexive = value === value,
  18141. valIsSymbol = isSymbol(value);
  18142. var othIsDefined = other !== undefined,
  18143. othIsNull = other === null,
  18144. othIsReflexive = other === other,
  18145. othIsSymbol = isSymbol(other);
  18146. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  18147. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  18148. (valIsNull && othIsDefined && othIsReflexive) ||
  18149. (!valIsDefined && othIsReflexive) ||
  18150. !valIsReflexive) {
  18151. return 1;
  18152. }
  18153. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  18154. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  18155. (othIsNull && valIsDefined && valIsReflexive) ||
  18156. (!othIsDefined && valIsReflexive) ||
  18157. !othIsReflexive) {
  18158. return -1;
  18159. }
  18160. }
  18161. return 0;
  18162. }
  18163. /**
  18164. * Used by `_.orderBy` to compare multiple properties of a value to another
  18165. * and stable sort them.
  18166. *
  18167. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  18168. * specify an order of "desc" for descending or "asc" for ascending sort order
  18169. * of corresponding values.
  18170. *
  18171. * @private
  18172. * @param {Object} object The object to compare.
  18173. * @param {Object} other The other object to compare.
  18174. * @param {boolean[]|string[]} orders The order to sort by for each property.
  18175. * @returns {number} Returns the sort order indicator for `object`.
  18176. */
  18177. function compareMultiple(object, other, orders) {
  18178. var index = -1,
  18179. objCriteria = object.criteria,
  18180. othCriteria = other.criteria,
  18181. length = objCriteria.length,
  18182. ordersLength = orders.length;
  18183. while (++index < length) {
  18184. var result = compareAscending(objCriteria[index], othCriteria[index]);
  18185. if (result) {
  18186. if (index >= ordersLength) {
  18187. return result;
  18188. }
  18189. var order = orders[index];
  18190. return result * (order == 'desc' ? -1 : 1);
  18191. }
  18192. }
  18193. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  18194. // that causes it, under certain circumstances, to provide the same value for
  18195. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  18196. // for more details.
  18197. //
  18198. // This also ensures a stable sort in V8 and other engines.
  18199. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  18200. return object.index - other.index;
  18201. }
  18202. /**
  18203. * Creates an array that is the composition of partially applied arguments,
  18204. * placeholders, and provided arguments into a single array of arguments.
  18205. *
  18206. * @private
  18207. * @param {Array} args The provided arguments.
  18208. * @param {Array} partials The arguments to prepend to those provided.
  18209. * @param {Array} holders The `partials` placeholder indexes.
  18210. * @params {boolean} [isCurried] Specify composing for a curried function.
  18211. * @returns {Array} Returns the new array of composed arguments.
  18212. */
  18213. function composeArgs(args, partials, holders, isCurried) {
  18214. var argsIndex = -1,
  18215. argsLength = args.length,
  18216. holdersLength = holders.length,
  18217. leftIndex = -1,
  18218. leftLength = partials.length,
  18219. rangeLength = nativeMax(argsLength - holdersLength, 0),
  18220. result = Array(leftLength + rangeLength),
  18221. isUncurried = !isCurried;
  18222. while (++leftIndex < leftLength) {
  18223. result[leftIndex] = partials[leftIndex];
  18224. }
  18225. while (++argsIndex < holdersLength) {
  18226. if (isUncurried || argsIndex < argsLength) {
  18227. result[holders[argsIndex]] = args[argsIndex];
  18228. }
  18229. }
  18230. while (rangeLength--) {
  18231. result[leftIndex++] = args[argsIndex++];
  18232. }
  18233. return result;
  18234. }
  18235. /**
  18236. * This function is like `composeArgs` except that the arguments composition
  18237. * is tailored for `_.partialRight`.
  18238. *
  18239. * @private
  18240. * @param {Array} args The provided arguments.
  18241. * @param {Array} partials The arguments to append to those provided.
  18242. * @param {Array} holders The `partials` placeholder indexes.
  18243. * @params {boolean} [isCurried] Specify composing for a curried function.
  18244. * @returns {Array} Returns the new array of composed arguments.
  18245. */
  18246. function composeArgsRight(args, partials, holders, isCurried) {
  18247. var argsIndex = -1,
  18248. argsLength = args.length,
  18249. holdersIndex = -1,
  18250. holdersLength = holders.length,
  18251. rightIndex = -1,
  18252. rightLength = partials.length,
  18253. rangeLength = nativeMax(argsLength - holdersLength, 0),
  18254. result = Array(rangeLength + rightLength),
  18255. isUncurried = !isCurried;
  18256. while (++argsIndex < rangeLength) {
  18257. result[argsIndex] = args[argsIndex];
  18258. }
  18259. var offset = argsIndex;
  18260. while (++rightIndex < rightLength) {
  18261. result[offset + rightIndex] = partials[rightIndex];
  18262. }
  18263. while (++holdersIndex < holdersLength) {
  18264. if (isUncurried || argsIndex < argsLength) {
  18265. result[offset + holders[holdersIndex]] = args[argsIndex++];
  18266. }
  18267. }
  18268. return result;
  18269. }
  18270. /**
  18271. * Copies the values of `source` to `array`.
  18272. *
  18273. * @private
  18274. * @param {Array} source The array to copy values from.
  18275. * @param {Array} [array=[]] The array to copy values to.
  18276. * @returns {Array} Returns `array`.
  18277. */
  18278. function copyArray(source, array) {
  18279. var index = -1,
  18280. length = source.length;
  18281. array || (array = Array(length));
  18282. while (++index < length) {
  18283. array[index] = source[index];
  18284. }
  18285. return array;
  18286. }
  18287. /**
  18288. * Copies properties of `source` to `object`.
  18289. *
  18290. * @private
  18291. * @param {Object} source The object to copy properties from.
  18292. * @param {Array} props The property identifiers to copy.
  18293. * @param {Object} [object={}] The object to copy properties to.
  18294. * @param {Function} [customizer] The function to customize copied values.
  18295. * @returns {Object} Returns `object`.
  18296. */
  18297. function copyObject(source, props, object, customizer) {
  18298. var isNew = !object;
  18299. object || (object = {});
  18300. var index = -1,
  18301. length = props.length;
  18302. while (++index < length) {
  18303. var key = props[index];
  18304. var newValue = customizer
  18305. ? customizer(object[key], source[key], key, object, source)
  18306. : undefined;
  18307. if (newValue === undefined) {
  18308. newValue = source[key];
  18309. }
  18310. if (isNew) {
  18311. baseAssignValue(object, key, newValue);
  18312. } else {
  18313. assignValue(object, key, newValue);
  18314. }
  18315. }
  18316. return object;
  18317. }
  18318. /**
  18319. * Copies own symbols of `source` to `object`.
  18320. *
  18321. * @private
  18322. * @param {Object} source The object to copy symbols from.
  18323. * @param {Object} [object={}] The object to copy symbols to.
  18324. * @returns {Object} Returns `object`.
  18325. */
  18326. function copySymbols(source, object) {
  18327. return copyObject(source, getSymbols(source), object);
  18328. }
  18329. /**
  18330. * Copies own and inherited symbols of `source` to `object`.
  18331. *
  18332. * @private
  18333. * @param {Object} source The object to copy symbols from.
  18334. * @param {Object} [object={}] The object to copy symbols to.
  18335. * @returns {Object} Returns `object`.
  18336. */
  18337. function copySymbolsIn(source, object) {
  18338. return copyObject(source, getSymbolsIn(source), object);
  18339. }
  18340. /**
  18341. * Creates a function like `_.groupBy`.
  18342. *
  18343. * @private
  18344. * @param {Function} setter The function to set accumulator values.
  18345. * @param {Function} [initializer] The accumulator object initializer.
  18346. * @returns {Function} Returns the new aggregator function.
  18347. */
  18348. function createAggregator(setter, initializer) {
  18349. return function(collection, iteratee) {
  18350. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  18351. accumulator = initializer ? initializer() : {};
  18352. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  18353. };
  18354. }
  18355. /**
  18356. * Creates a function like `_.assign`.
  18357. *
  18358. * @private
  18359. * @param {Function} assigner The function to assign values.
  18360. * @returns {Function} Returns the new assigner function.
  18361. */
  18362. function createAssigner(assigner) {
  18363. return baseRest(function(object, sources) {
  18364. var index = -1,
  18365. length = sources.length,
  18366. customizer = length > 1 ? sources[length - 1] : undefined,
  18367. guard = length > 2 ? sources[2] : undefined;
  18368. customizer = (assigner.length > 3 && typeof customizer == 'function')
  18369. ? (length--, customizer)
  18370. : undefined;
  18371. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  18372. customizer = length < 3 ? undefined : customizer;
  18373. length = 1;
  18374. }
  18375. object = Object(object);
  18376. while (++index < length) {
  18377. var source = sources[index];
  18378. if (source) {
  18379. assigner(object, source, index, customizer);
  18380. }
  18381. }
  18382. return object;
  18383. });
  18384. }
  18385. /**
  18386. * Creates a `baseEach` or `baseEachRight` function.
  18387. *
  18388. * @private
  18389. * @param {Function} eachFunc The function to iterate over a collection.
  18390. * @param {boolean} [fromRight] Specify iterating from right to left.
  18391. * @returns {Function} Returns the new base function.
  18392. */
  18393. function createBaseEach(eachFunc, fromRight) {
  18394. return function(collection, iteratee) {
  18395. if (collection == null) {
  18396. return collection;
  18397. }
  18398. if (!isArrayLike(collection)) {
  18399. return eachFunc(collection, iteratee);
  18400. }
  18401. var length = collection.length,
  18402. index = fromRight ? length : -1,
  18403. iterable = Object(collection);
  18404. while ((fromRight ? index-- : ++index < length)) {
  18405. if (iteratee(iterable[index], index, iterable) === false) {
  18406. break;
  18407. }
  18408. }
  18409. return collection;
  18410. };
  18411. }
  18412. /**
  18413. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  18414. *
  18415. * @private
  18416. * @param {boolean} [fromRight] Specify iterating from right to left.
  18417. * @returns {Function} Returns the new base function.
  18418. */
  18419. function createBaseFor(fromRight) {
  18420. return function(object, iteratee, keysFunc) {
  18421. var index = -1,
  18422. iterable = Object(object),
  18423. props = keysFunc(object),
  18424. length = props.length;
  18425. while (length--) {
  18426. var key = props[fromRight ? length : ++index];
  18427. if (iteratee(iterable[key], key, iterable) === false) {
  18428. break;
  18429. }
  18430. }
  18431. return object;
  18432. };
  18433. }
  18434. /**
  18435. * Creates a function that wraps `func` to invoke it with the optional `this`
  18436. * binding of `thisArg`.
  18437. *
  18438. * @private
  18439. * @param {Function} func The function to wrap.
  18440. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  18441. * @param {*} [thisArg] The `this` binding of `func`.
  18442. * @returns {Function} Returns the new wrapped function.
  18443. */
  18444. function createBind(func, bitmask, thisArg) {
  18445. var isBind = bitmask & WRAP_BIND_FLAG,
  18446. Ctor = createCtor(func);
  18447. function wrapper() {
  18448. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  18449. return fn.apply(isBind ? thisArg : this, arguments);
  18450. }
  18451. return wrapper;
  18452. }
  18453. /**
  18454. * Creates a function like `_.lowerFirst`.
  18455. *
  18456. * @private
  18457. * @param {string} methodName The name of the `String` case method to use.
  18458. * @returns {Function} Returns the new case function.
  18459. */
  18460. function createCaseFirst(methodName) {
  18461. return function(string) {
  18462. string = toString(string);
  18463. var strSymbols = hasUnicode(string)
  18464. ? stringToArray(string)
  18465. : undefined;
  18466. var chr = strSymbols
  18467. ? strSymbols[0]
  18468. : string.charAt(0);
  18469. var trailing = strSymbols
  18470. ? castSlice(strSymbols, 1).join('')
  18471. : string.slice(1);
  18472. return chr[methodName]() + trailing;
  18473. };
  18474. }
  18475. /**
  18476. * Creates a function like `_.camelCase`.
  18477. *
  18478. * @private
  18479. * @param {Function} callback The function to combine each word.
  18480. * @returns {Function} Returns the new compounder function.
  18481. */
  18482. function createCompounder(callback) {
  18483. return function(string) {
  18484. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  18485. };
  18486. }
  18487. /**
  18488. * Creates a function that produces an instance of `Ctor` regardless of
  18489. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  18490. *
  18491. * @private
  18492. * @param {Function} Ctor The constructor to wrap.
  18493. * @returns {Function} Returns the new wrapped function.
  18494. */
  18495. function createCtor(Ctor) {
  18496. return function() {
  18497. // Use a `switch` statement to work with class constructors. See
  18498. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  18499. // for more details.
  18500. var args = arguments;
  18501. switch (args.length) {
  18502. case 0: return new Ctor;
  18503. case 1: return new Ctor(args[0]);
  18504. case 2: return new Ctor(args[0], args[1]);
  18505. case 3: return new Ctor(args[0], args[1], args[2]);
  18506. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  18507. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  18508. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  18509. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  18510. }
  18511. var thisBinding = baseCreate(Ctor.prototype),
  18512. result = Ctor.apply(thisBinding, args);
  18513. // Mimic the constructor's `return` behavior.
  18514. // See https://es5.github.io/#x13.2.2 for more details.
  18515. return isObject(result) ? result : thisBinding;
  18516. };
  18517. }
  18518. /**
  18519. * Creates a function that wraps `func` to enable currying.
  18520. *
  18521. * @private
  18522. * @param {Function} func The function to wrap.
  18523. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  18524. * @param {number} arity The arity of `func`.
  18525. * @returns {Function} Returns the new wrapped function.
  18526. */
  18527. function createCurry(func, bitmask, arity) {
  18528. var Ctor = createCtor(func);
  18529. function wrapper() {
  18530. var length = arguments.length,
  18531. args = Array(length),
  18532. index = length,
  18533. placeholder = getHolder(wrapper);
  18534. while (index--) {
  18535. args[index] = arguments[index];
  18536. }
  18537. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  18538. ? []
  18539. : replaceHolders(args, placeholder);
  18540. length -= holders.length;
  18541. if (length < arity) {
  18542. return createRecurry(
  18543. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  18544. args, holders, undefined, undefined, arity - length);
  18545. }
  18546. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  18547. return apply(fn, this, args);
  18548. }
  18549. return wrapper;
  18550. }
  18551. /**
  18552. * Creates a `_.find` or `_.findLast` function.
  18553. *
  18554. * @private
  18555. * @param {Function} findIndexFunc The function to find the collection index.
  18556. * @returns {Function} Returns the new find function.
  18557. */
  18558. function createFind(findIndexFunc) {
  18559. return function(collection, predicate, fromIndex) {
  18560. var iterable = Object(collection);
  18561. if (!isArrayLike(collection)) {
  18562. var iteratee = getIteratee(predicate, 3);
  18563. collection = keys(collection);
  18564. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  18565. }
  18566. var index = findIndexFunc(collection, predicate, fromIndex);
  18567. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  18568. };
  18569. }
  18570. /**
  18571. * Creates a `_.flow` or `_.flowRight` function.
  18572. *
  18573. * @private
  18574. * @param {boolean} [fromRight] Specify iterating from right to left.
  18575. * @returns {Function} Returns the new flow function.
  18576. */
  18577. function createFlow(fromRight) {
  18578. return flatRest(function(funcs) {
  18579. var length = funcs.length,
  18580. index = length,
  18581. prereq = LodashWrapper.prototype.thru;
  18582. if (fromRight) {
  18583. funcs.reverse();
  18584. }
  18585. while (index--) {
  18586. var func = funcs[index];
  18587. if (typeof func != 'function') {
  18588. throw new TypeError(FUNC_ERROR_TEXT);
  18589. }
  18590. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  18591. var wrapper = new LodashWrapper([], true);
  18592. }
  18593. }
  18594. index = wrapper ? index : length;
  18595. while (++index < length) {
  18596. func = funcs[index];
  18597. var funcName = getFuncName(func),
  18598. data = funcName == 'wrapper' ? getData(func) : undefined;
  18599. if (data && isLaziable(data[0]) &&
  18600. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  18601. !data[4].length && data[9] == 1
  18602. ) {
  18603. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  18604. } else {
  18605. wrapper = (func.length == 1 && isLaziable(func))
  18606. ? wrapper[funcName]()
  18607. : wrapper.thru(func);
  18608. }
  18609. }
  18610. return function() {
  18611. var args = arguments,
  18612. value = args[0];
  18613. if (wrapper && args.length == 1 && isArray(value)) {
  18614. return wrapper.plant(value).value();
  18615. }
  18616. var index = 0,
  18617. result = length ? funcs[index].apply(this, args) : value;
  18618. while (++index < length) {
  18619. result = funcs[index].call(this, result);
  18620. }
  18621. return result;
  18622. };
  18623. });
  18624. }
  18625. /**
  18626. * Creates a function that wraps `func` to invoke it with optional `this`
  18627. * binding of `thisArg`, partial application, and currying.
  18628. *
  18629. * @private
  18630. * @param {Function|string} func The function or method name to wrap.
  18631. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  18632. * @param {*} [thisArg] The `this` binding of `func`.
  18633. * @param {Array} [partials] The arguments to prepend to those provided to
  18634. * the new function.
  18635. * @param {Array} [holders] The `partials` placeholder indexes.
  18636. * @param {Array} [partialsRight] The arguments to append to those provided
  18637. * to the new function.
  18638. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  18639. * @param {Array} [argPos] The argument positions of the new function.
  18640. * @param {number} [ary] The arity cap of `func`.
  18641. * @param {number} [arity] The arity of `func`.
  18642. * @returns {Function} Returns the new wrapped function.
  18643. */
  18644. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  18645. var isAry = bitmask & WRAP_ARY_FLAG,
  18646. isBind = bitmask & WRAP_BIND_FLAG,
  18647. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  18648. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  18649. isFlip = bitmask & WRAP_FLIP_FLAG,
  18650. Ctor = isBindKey ? undefined : createCtor(func);
  18651. function wrapper() {
  18652. var length = arguments.length,
  18653. args = Array(length),
  18654. index = length;
  18655. while (index--) {
  18656. args[index] = arguments[index];
  18657. }
  18658. if (isCurried) {
  18659. var placeholder = getHolder(wrapper),
  18660. holdersCount = countHolders(args, placeholder);
  18661. }
  18662. if (partials) {
  18663. args = composeArgs(args, partials, holders, isCurried);
  18664. }
  18665. if (partialsRight) {
  18666. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  18667. }
  18668. length -= holdersCount;
  18669. if (isCurried && length < arity) {
  18670. var newHolders = replaceHolders(args, placeholder);
  18671. return createRecurry(
  18672. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  18673. args, newHolders, argPos, ary, arity - length
  18674. );
  18675. }
  18676. var thisBinding = isBind ? thisArg : this,
  18677. fn = isBindKey ? thisBinding[func] : func;
  18678. length = args.length;
  18679. if (argPos) {
  18680. args = reorder(args, argPos);
  18681. } else if (isFlip && length > 1) {
  18682. args.reverse();
  18683. }
  18684. if (isAry && ary < length) {
  18685. args.length = ary;
  18686. }
  18687. if (this && this !== root && this instanceof wrapper) {
  18688. fn = Ctor || createCtor(fn);
  18689. }
  18690. return fn.apply(thisBinding, args);
  18691. }
  18692. return wrapper;
  18693. }
  18694. /**
  18695. * Creates a function like `_.invertBy`.
  18696. *
  18697. * @private
  18698. * @param {Function} setter The function to set accumulator values.
  18699. * @param {Function} toIteratee The function to resolve iteratees.
  18700. * @returns {Function} Returns the new inverter function.
  18701. */
  18702. function createInverter(setter, toIteratee) {
  18703. return function(object, iteratee) {
  18704. return baseInverter(object, setter, toIteratee(iteratee), {});
  18705. };
  18706. }
  18707. /**
  18708. * Creates a function that performs a mathematical operation on two values.
  18709. *
  18710. * @private
  18711. * @param {Function} operator The function to perform the operation.
  18712. * @param {number} [defaultValue] The value used for `undefined` arguments.
  18713. * @returns {Function} Returns the new mathematical operation function.
  18714. */
  18715. function createMathOperation(operator, defaultValue) {
  18716. return function(value, other) {
  18717. var result;
  18718. if (value === undefined && other === undefined) {
  18719. return defaultValue;
  18720. }
  18721. if (value !== undefined) {
  18722. result = value;
  18723. }
  18724. if (other !== undefined) {
  18725. if (result === undefined) {
  18726. return other;
  18727. }
  18728. if (typeof value == 'string' || typeof other == 'string') {
  18729. value = baseToString(value);
  18730. other = baseToString(other);
  18731. } else {
  18732. value = baseToNumber(value);
  18733. other = baseToNumber(other);
  18734. }
  18735. result = operator(value, other);
  18736. }
  18737. return result;
  18738. };
  18739. }
  18740. /**
  18741. * Creates a function like `_.over`.
  18742. *
  18743. * @private
  18744. * @param {Function} arrayFunc The function to iterate over iteratees.
  18745. * @returns {Function} Returns the new over function.
  18746. */
  18747. function createOver(arrayFunc) {
  18748. return flatRest(function(iteratees) {
  18749. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  18750. return baseRest(function(args) {
  18751. var thisArg = this;
  18752. return arrayFunc(iteratees, function(iteratee) {
  18753. return apply(iteratee, thisArg, args);
  18754. });
  18755. });
  18756. });
  18757. }
  18758. /**
  18759. * Creates the padding for `string` based on `length`. The `chars` string
  18760. * is truncated if the number of characters exceeds `length`.
  18761. *
  18762. * @private
  18763. * @param {number} length The padding length.
  18764. * @param {string} [chars=' '] The string used as padding.
  18765. * @returns {string} Returns the padding for `string`.
  18766. */
  18767. function createPadding(length, chars) {
  18768. chars = chars === undefined ? ' ' : baseToString(chars);
  18769. var charsLength = chars.length;
  18770. if (charsLength < 2) {
  18771. return charsLength ? baseRepeat(chars, length) : chars;
  18772. }
  18773. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  18774. return hasUnicode(chars)
  18775. ? castSlice(stringToArray(result), 0, length).join('')
  18776. : result.slice(0, length);
  18777. }
  18778. /**
  18779. * Creates a function that wraps `func` to invoke it with the `this` binding
  18780. * of `thisArg` and `partials` prepended to the arguments it receives.
  18781. *
  18782. * @private
  18783. * @param {Function} func The function to wrap.
  18784. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  18785. * @param {*} thisArg The `this` binding of `func`.
  18786. * @param {Array} partials The arguments to prepend to those provided to
  18787. * the new function.
  18788. * @returns {Function} Returns the new wrapped function.
  18789. */
  18790. function createPartial(func, bitmask, thisArg, partials) {
  18791. var isBind = bitmask & WRAP_BIND_FLAG,
  18792. Ctor = createCtor(func);
  18793. function wrapper() {
  18794. var argsIndex = -1,
  18795. argsLength = arguments.length,
  18796. leftIndex = -1,
  18797. leftLength = partials.length,
  18798. args = Array(leftLength + argsLength),
  18799. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  18800. while (++leftIndex < leftLength) {
  18801. args[leftIndex] = partials[leftIndex];
  18802. }
  18803. while (argsLength--) {
  18804. args[leftIndex++] = arguments[++argsIndex];
  18805. }
  18806. return apply(fn, isBind ? thisArg : this, args);
  18807. }
  18808. return wrapper;
  18809. }
  18810. /**
  18811. * Creates a `_.range` or `_.rangeRight` function.
  18812. *
  18813. * @private
  18814. * @param {boolean} [fromRight] Specify iterating from right to left.
  18815. * @returns {Function} Returns the new range function.
  18816. */
  18817. function createRange(fromRight) {
  18818. return function(start, end, step) {
  18819. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  18820. end = step = undefined;
  18821. }
  18822. // Ensure the sign of `-0` is preserved.
  18823. start = toFinite(start);
  18824. if (end === undefined) {
  18825. end = start;
  18826. start = 0;
  18827. } else {
  18828. end = toFinite(end);
  18829. }
  18830. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  18831. return baseRange(start, end, step, fromRight);
  18832. };
  18833. }
  18834. /**
  18835. * Creates a function that performs a relational operation on two values.
  18836. *
  18837. * @private
  18838. * @param {Function} operator The function to perform the operation.
  18839. * @returns {Function} Returns the new relational operation function.
  18840. */
  18841. function createRelationalOperation(operator) {
  18842. return function(value, other) {
  18843. if (!(typeof value == 'string' && typeof other == 'string')) {
  18844. value = toNumber(value);
  18845. other = toNumber(other);
  18846. }
  18847. return operator(value, other);
  18848. };
  18849. }
  18850. /**
  18851. * Creates a function that wraps `func` to continue currying.
  18852. *
  18853. * @private
  18854. * @param {Function} func The function to wrap.
  18855. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  18856. * @param {Function} wrapFunc The function to create the `func` wrapper.
  18857. * @param {*} placeholder The placeholder value.
  18858. * @param {*} [thisArg] The `this` binding of `func`.
  18859. * @param {Array} [partials] The arguments to prepend to those provided to
  18860. * the new function.
  18861. * @param {Array} [holders] The `partials` placeholder indexes.
  18862. * @param {Array} [argPos] The argument positions of the new function.
  18863. * @param {number} [ary] The arity cap of `func`.
  18864. * @param {number} [arity] The arity of `func`.
  18865. * @returns {Function} Returns the new wrapped function.
  18866. */
  18867. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  18868. var isCurry = bitmask & WRAP_CURRY_FLAG,
  18869. newHolders = isCurry ? holders : undefined,
  18870. newHoldersRight = isCurry ? undefined : holders,
  18871. newPartials = isCurry ? partials : undefined,
  18872. newPartialsRight = isCurry ? undefined : partials;
  18873. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  18874. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  18875. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  18876. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  18877. }
  18878. var newData = [
  18879. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  18880. newHoldersRight, argPos, ary, arity
  18881. ];
  18882. var result = wrapFunc.apply(undefined, newData);
  18883. if (isLaziable(func)) {
  18884. setData(result, newData);
  18885. }
  18886. result.placeholder = placeholder;
  18887. return setWrapToString(result, func, bitmask);
  18888. }
  18889. /**
  18890. * Creates a function like `_.round`.
  18891. *
  18892. * @private
  18893. * @param {string} methodName The name of the `Math` method to use when rounding.
  18894. * @returns {Function} Returns the new round function.
  18895. */
  18896. function createRound(methodName) {
  18897. var func = Math[methodName];
  18898. return function(number, precision) {
  18899. number = toNumber(number);
  18900. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  18901. if (precision && nativeIsFinite(number)) {
  18902. // Shift with exponential notation to avoid floating-point issues.
  18903. // See [MDN](https://mdn.io/round#Examples) for more details.
  18904. var pair = (toString(number) + 'e').split('e'),
  18905. value = func(pair[0] + 'e' + (+pair[1] + precision));
  18906. pair = (toString(value) + 'e').split('e');
  18907. return +(pair[0] + 'e' + (+pair[1] - precision));
  18908. }
  18909. return func(number);
  18910. };
  18911. }
  18912. /**
  18913. * Creates a set object of `values`.
  18914. *
  18915. * @private
  18916. * @param {Array} values The values to add to the set.
  18917. * @returns {Object} Returns the new set.
  18918. */
  18919. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  18920. return new Set(values);
  18921. };
  18922. /**
  18923. * Creates a `_.toPairs` or `_.toPairsIn` function.
  18924. *
  18925. * @private
  18926. * @param {Function} keysFunc The function to get the keys of a given object.
  18927. * @returns {Function} Returns the new pairs function.
  18928. */
  18929. function createToPairs(keysFunc) {
  18930. return function(object) {
  18931. var tag = getTag(object);
  18932. if (tag == mapTag) {
  18933. return mapToArray(object);
  18934. }
  18935. if (tag == setTag) {
  18936. return setToPairs(object);
  18937. }
  18938. return baseToPairs(object, keysFunc(object));
  18939. };
  18940. }
  18941. /**
  18942. * Creates a function that either curries or invokes `func` with optional
  18943. * `this` binding and partially applied arguments.
  18944. *
  18945. * @private
  18946. * @param {Function|string} func The function or method name to wrap.
  18947. * @param {number} bitmask The bitmask flags.
  18948. * 1 - `_.bind`
  18949. * 2 - `_.bindKey`
  18950. * 4 - `_.curry` or `_.curryRight` of a bound function
  18951. * 8 - `_.curry`
  18952. * 16 - `_.curryRight`
  18953. * 32 - `_.partial`
  18954. * 64 - `_.partialRight`
  18955. * 128 - `_.rearg`
  18956. * 256 - `_.ary`
  18957. * 512 - `_.flip`
  18958. * @param {*} [thisArg] The `this` binding of `func`.
  18959. * @param {Array} [partials] The arguments to be partially applied.
  18960. * @param {Array} [holders] The `partials` placeholder indexes.
  18961. * @param {Array} [argPos] The argument positions of the new function.
  18962. * @param {number} [ary] The arity cap of `func`.
  18963. * @param {number} [arity] The arity of `func`.
  18964. * @returns {Function} Returns the new wrapped function.
  18965. */
  18966. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  18967. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  18968. if (!isBindKey && typeof func != 'function') {
  18969. throw new TypeError(FUNC_ERROR_TEXT);
  18970. }
  18971. var length = partials ? partials.length : 0;
  18972. if (!length) {
  18973. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  18974. partials = holders = undefined;
  18975. }
  18976. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  18977. arity = arity === undefined ? arity : toInteger(arity);
  18978. length -= holders ? holders.length : 0;
  18979. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  18980. var partialsRight = partials,
  18981. holdersRight = holders;
  18982. partials = holders = undefined;
  18983. }
  18984. var data = isBindKey ? undefined : getData(func);
  18985. var newData = [
  18986. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  18987. argPos, ary, arity
  18988. ];
  18989. if (data) {
  18990. mergeData(newData, data);
  18991. }
  18992. func = newData[0];
  18993. bitmask = newData[1];
  18994. thisArg = newData[2];
  18995. partials = newData[3];
  18996. holders = newData[4];
  18997. arity = newData[9] = newData[9] === undefined
  18998. ? (isBindKey ? 0 : func.length)
  18999. : nativeMax(newData[9] - length, 0);
  19000. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  19001. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  19002. }
  19003. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  19004. var result = createBind(func, bitmask, thisArg);
  19005. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  19006. result = createCurry(func, bitmask, arity);
  19007. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  19008. result = createPartial(func, bitmask, thisArg, partials);
  19009. } else {
  19010. result = createHybrid.apply(undefined, newData);
  19011. }
  19012. var setter = data ? baseSetData : setData;
  19013. return setWrapToString(setter(result, newData), func, bitmask);
  19014. }
  19015. /**
  19016. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  19017. * of source objects to the destination object for all destination properties
  19018. * that resolve to `undefined`.
  19019. *
  19020. * @private
  19021. * @param {*} objValue The destination value.
  19022. * @param {*} srcValue The source value.
  19023. * @param {string} key The key of the property to assign.
  19024. * @param {Object} object The parent object of `objValue`.
  19025. * @returns {*} Returns the value to assign.
  19026. */
  19027. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  19028. if (objValue === undefined ||
  19029. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  19030. return srcValue;
  19031. }
  19032. return objValue;
  19033. }
  19034. /**
  19035. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  19036. * objects into destination objects that are passed thru.
  19037. *
  19038. * @private
  19039. * @param {*} objValue The destination value.
  19040. * @param {*} srcValue The source value.
  19041. * @param {string} key The key of the property to merge.
  19042. * @param {Object} object The parent object of `objValue`.
  19043. * @param {Object} source The parent object of `srcValue`.
  19044. * @param {Object} [stack] Tracks traversed source values and their merged
  19045. * counterparts.
  19046. * @returns {*} Returns the value to assign.
  19047. */
  19048. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  19049. if (isObject(objValue) && isObject(srcValue)) {
  19050. // Recursively merge objects and arrays (susceptible to call stack limits).
  19051. stack.set(srcValue, objValue);
  19052. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  19053. stack['delete'](srcValue);
  19054. }
  19055. return objValue;
  19056. }
  19057. /**
  19058. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  19059. * objects.
  19060. *
  19061. * @private
  19062. * @param {*} value The value to inspect.
  19063. * @param {string} key The key of the property to inspect.
  19064. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  19065. */
  19066. function customOmitClone(value) {
  19067. return isPlainObject(value) ? undefined : value;
  19068. }
  19069. /**
  19070. * A specialized version of `baseIsEqualDeep` for arrays with support for
  19071. * partial deep comparisons.
  19072. *
  19073. * @private
  19074. * @param {Array} array The array to compare.
  19075. * @param {Array} other The other array to compare.
  19076. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  19077. * @param {Function} customizer The function to customize comparisons.
  19078. * @param {Function} equalFunc The function to determine equivalents of values.
  19079. * @param {Object} stack Tracks traversed `array` and `other` objects.
  19080. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  19081. */
  19082. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  19083. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  19084. arrLength = array.length,
  19085. othLength = other.length;
  19086. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  19087. return false;
  19088. }
  19089. // Assume cyclic values are equal.
  19090. var stacked = stack.get(array);
  19091. if (stacked && stack.get(other)) {
  19092. return stacked == other;
  19093. }
  19094. var index = -1,
  19095. result = true,
  19096. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  19097. stack.set(array, other);
  19098. stack.set(other, array);
  19099. // Ignore non-index properties.
  19100. while (++index < arrLength) {
  19101. var arrValue = array[index],
  19102. othValue = other[index];
  19103. if (customizer) {
  19104. var compared = isPartial
  19105. ? customizer(othValue, arrValue, index, other, array, stack)
  19106. : customizer(arrValue, othValue, index, array, other, stack);
  19107. }
  19108. if (compared !== undefined) {
  19109. if (compared) {
  19110. continue;
  19111. }
  19112. result = false;
  19113. break;
  19114. }
  19115. // Recursively compare arrays (susceptible to call stack limits).
  19116. if (seen) {
  19117. if (!arraySome(other, function(othValue, othIndex) {
  19118. if (!cacheHas(seen, othIndex) &&
  19119. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  19120. return seen.push(othIndex);
  19121. }
  19122. })) {
  19123. result = false;
  19124. break;
  19125. }
  19126. } else if (!(
  19127. arrValue === othValue ||
  19128. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  19129. )) {
  19130. result = false;
  19131. break;
  19132. }
  19133. }
  19134. stack['delete'](array);
  19135. stack['delete'](other);
  19136. return result;
  19137. }
  19138. /**
  19139. * A specialized version of `baseIsEqualDeep` for comparing objects of
  19140. * the same `toStringTag`.
  19141. *
  19142. * **Note:** This function only supports comparing values with tags of
  19143. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  19144. *
  19145. * @private
  19146. * @param {Object} object The object to compare.
  19147. * @param {Object} other The other object to compare.
  19148. * @param {string} tag The `toStringTag` of the objects to compare.
  19149. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  19150. * @param {Function} customizer The function to customize comparisons.
  19151. * @param {Function} equalFunc The function to determine equivalents of values.
  19152. * @param {Object} stack Tracks traversed `object` and `other` objects.
  19153. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  19154. */
  19155. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  19156. switch (tag) {
  19157. case dataViewTag:
  19158. if ((object.byteLength != other.byteLength) ||
  19159. (object.byteOffset != other.byteOffset)) {
  19160. return false;
  19161. }
  19162. object = object.buffer;
  19163. other = other.buffer;
  19164. case arrayBufferTag:
  19165. if ((object.byteLength != other.byteLength) ||
  19166. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  19167. return false;
  19168. }
  19169. return true;
  19170. case boolTag:
  19171. case dateTag:
  19172. case numberTag:
  19173. // Coerce booleans to `1` or `0` and dates to milliseconds.
  19174. // Invalid dates are coerced to `NaN`.
  19175. return eq(+object, +other);
  19176. case errorTag:
  19177. return object.name == other.name && object.message == other.message;
  19178. case regexpTag:
  19179. case stringTag:
  19180. // Coerce regexes to strings and treat strings, primitives and objects,
  19181. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  19182. // for more details.
  19183. return object == (other + '');
  19184. case mapTag:
  19185. var convert = mapToArray;
  19186. case setTag:
  19187. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  19188. convert || (convert = setToArray);
  19189. if (object.size != other.size && !isPartial) {
  19190. return false;
  19191. }
  19192. // Assume cyclic values are equal.
  19193. var stacked = stack.get(object);
  19194. if (stacked) {
  19195. return stacked == other;
  19196. }
  19197. bitmask |= COMPARE_UNORDERED_FLAG;
  19198. // Recursively compare objects (susceptible to call stack limits).
  19199. stack.set(object, other);
  19200. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  19201. stack['delete'](object);
  19202. return result;
  19203. case symbolTag:
  19204. if (symbolValueOf) {
  19205. return symbolValueOf.call(object) == symbolValueOf.call(other);
  19206. }
  19207. }
  19208. return false;
  19209. }
  19210. /**
  19211. * A specialized version of `baseIsEqualDeep` for objects with support for
  19212. * partial deep comparisons.
  19213. *
  19214. * @private
  19215. * @param {Object} object The object to compare.
  19216. * @param {Object} other The other object to compare.
  19217. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  19218. * @param {Function} customizer The function to customize comparisons.
  19219. * @param {Function} equalFunc The function to determine equivalents of values.
  19220. * @param {Object} stack Tracks traversed `object` and `other` objects.
  19221. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  19222. */
  19223. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  19224. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  19225. objProps = getAllKeys(object),
  19226. objLength = objProps.length,
  19227. othProps = getAllKeys(other),
  19228. othLength = othProps.length;
  19229. if (objLength != othLength && !isPartial) {
  19230. return false;
  19231. }
  19232. var index = objLength;
  19233. while (index--) {
  19234. var key = objProps[index];
  19235. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  19236. return false;
  19237. }
  19238. }
  19239. // Assume cyclic values are equal.
  19240. var stacked = stack.get(object);
  19241. if (stacked && stack.get(other)) {
  19242. return stacked == other;
  19243. }
  19244. var result = true;
  19245. stack.set(object, other);
  19246. stack.set(other, object);
  19247. var skipCtor = isPartial;
  19248. while (++index < objLength) {
  19249. key = objProps[index];
  19250. var objValue = object[key],
  19251. othValue = other[key];
  19252. if (customizer) {
  19253. var compared = isPartial
  19254. ? customizer(othValue, objValue, key, other, object, stack)
  19255. : customizer(objValue, othValue, key, object, other, stack);
  19256. }
  19257. // Recursively compare objects (susceptible to call stack limits).
  19258. if (!(compared === undefined
  19259. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  19260. : compared
  19261. )) {
  19262. result = false;
  19263. break;
  19264. }
  19265. skipCtor || (skipCtor = key == 'constructor');
  19266. }
  19267. if (result && !skipCtor) {
  19268. var objCtor = object.constructor,
  19269. othCtor = other.constructor;
  19270. // Non `Object` object instances with different constructors are not equal.
  19271. if (objCtor != othCtor &&
  19272. ('constructor' in object && 'constructor' in other) &&
  19273. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  19274. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  19275. result = false;
  19276. }
  19277. }
  19278. stack['delete'](object);
  19279. stack['delete'](other);
  19280. return result;
  19281. }
  19282. /**
  19283. * A specialized version of `baseRest` which flattens the rest array.
  19284. *
  19285. * @private
  19286. * @param {Function} func The function to apply a rest parameter to.
  19287. * @returns {Function} Returns the new function.
  19288. */
  19289. function flatRest(func) {
  19290. return setToString(overRest(func, undefined, flatten), func + '');
  19291. }
  19292. /**
  19293. * Creates an array of own enumerable property names and symbols of `object`.
  19294. *
  19295. * @private
  19296. * @param {Object} object The object to query.
  19297. * @returns {Array} Returns the array of property names and symbols.
  19298. */
  19299. function getAllKeys(object) {
  19300. return baseGetAllKeys(object, keys, getSymbols);
  19301. }
  19302. /**
  19303. * Creates an array of own and inherited enumerable property names and
  19304. * symbols of `object`.
  19305. *
  19306. * @private
  19307. * @param {Object} object The object to query.
  19308. * @returns {Array} Returns the array of property names and symbols.
  19309. */
  19310. function getAllKeysIn(object) {
  19311. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  19312. }
  19313. /**
  19314. * Gets metadata for `func`.
  19315. *
  19316. * @private
  19317. * @param {Function} func The function to query.
  19318. * @returns {*} Returns the metadata for `func`.
  19319. */
  19320. var getData = !metaMap ? noop : function(func) {
  19321. return metaMap.get(func);
  19322. };
  19323. /**
  19324. * Gets the name of `func`.
  19325. *
  19326. * @private
  19327. * @param {Function} func The function to query.
  19328. * @returns {string} Returns the function name.
  19329. */
  19330. function getFuncName(func) {
  19331. var result = (func.name + ''),
  19332. array = realNames[result],
  19333. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  19334. while (length--) {
  19335. var data = array[length],
  19336. otherFunc = data.func;
  19337. if (otherFunc == null || otherFunc == func) {
  19338. return data.name;
  19339. }
  19340. }
  19341. return result;
  19342. }
  19343. /**
  19344. * Gets the argument placeholder value for `func`.
  19345. *
  19346. * @private
  19347. * @param {Function} func The function to inspect.
  19348. * @returns {*} Returns the placeholder value.
  19349. */
  19350. function getHolder(func) {
  19351. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  19352. return object.placeholder;
  19353. }
  19354. /**
  19355. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  19356. * this function returns the custom method, otherwise it returns `baseIteratee`.
  19357. * If arguments are provided, the chosen function is invoked with them and
  19358. * its result is returned.
  19359. *
  19360. * @private
  19361. * @param {*} [value] The value to convert to an iteratee.
  19362. * @param {number} [arity] The arity of the created iteratee.
  19363. * @returns {Function} Returns the chosen function or its result.
  19364. */
  19365. function getIteratee() {
  19366. var result = lodash.iteratee || iteratee;
  19367. result = result === iteratee ? baseIteratee : result;
  19368. return arguments.length ? result(arguments[0], arguments[1]) : result;
  19369. }
  19370. /**
  19371. * Gets the data for `map`.
  19372. *
  19373. * @private
  19374. * @param {Object} map The map to query.
  19375. * @param {string} key The reference key.
  19376. * @returns {*} Returns the map data.
  19377. */
  19378. function getMapData(map, key) {
  19379. var data = map.__data__;
  19380. return isKeyable(key)
  19381. ? data[typeof key == 'string' ? 'string' : 'hash']
  19382. : data.map;
  19383. }
  19384. /**
  19385. * Gets the property names, values, and compare flags of `object`.
  19386. *
  19387. * @private
  19388. * @param {Object} object The object to query.
  19389. * @returns {Array} Returns the match data of `object`.
  19390. */
  19391. function getMatchData(object) {
  19392. var result = keys(object),
  19393. length = result.length;
  19394. while (length--) {
  19395. var key = result[length],
  19396. value = object[key];
  19397. result[length] = [key, value, isStrictComparable(value)];
  19398. }
  19399. return result;
  19400. }
  19401. /**
  19402. * Gets the native function at `key` of `object`.
  19403. *
  19404. * @private
  19405. * @param {Object} object The object to query.
  19406. * @param {string} key The key of the method to get.
  19407. * @returns {*} Returns the function if it's native, else `undefined`.
  19408. */
  19409. function getNative(object, key) {
  19410. var value = getValue(object, key);
  19411. return baseIsNative(value) ? value : undefined;
  19412. }
  19413. /**
  19414. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  19415. *
  19416. * @private
  19417. * @param {*} value The value to query.
  19418. * @returns {string} Returns the raw `toStringTag`.
  19419. */
  19420. function getRawTag(value) {
  19421. var isOwn = hasOwnProperty.call(value, symToStringTag),
  19422. tag = value[symToStringTag];
  19423. try {
  19424. value[symToStringTag] = undefined;
  19425. var unmasked = true;
  19426. } catch (e) {}
  19427. var result = nativeObjectToString.call(value);
  19428. if (unmasked) {
  19429. if (isOwn) {
  19430. value[symToStringTag] = tag;
  19431. } else {
  19432. delete value[symToStringTag];
  19433. }
  19434. }
  19435. return result;
  19436. }
  19437. /**
  19438. * Creates an array of the own enumerable symbols of `object`.
  19439. *
  19440. * @private
  19441. * @param {Object} object The object to query.
  19442. * @returns {Array} Returns the array of symbols.
  19443. */
  19444. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  19445. if (object == null) {
  19446. return [];
  19447. }
  19448. object = Object(object);
  19449. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  19450. return propertyIsEnumerable.call(object, symbol);
  19451. });
  19452. };
  19453. /**
  19454. * Creates an array of the own and inherited enumerable symbols of `object`.
  19455. *
  19456. * @private
  19457. * @param {Object} object The object to query.
  19458. * @returns {Array} Returns the array of symbols.
  19459. */
  19460. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  19461. var result = [];
  19462. while (object) {
  19463. arrayPush(result, getSymbols(object));
  19464. object = getPrototype(object);
  19465. }
  19466. return result;
  19467. };
  19468. /**
  19469. * Gets the `toStringTag` of `value`.
  19470. *
  19471. * @private
  19472. * @param {*} value The value to query.
  19473. * @returns {string} Returns the `toStringTag`.
  19474. */
  19475. var getTag = baseGetTag;
  19476. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  19477. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  19478. (Map && getTag(new Map) != mapTag) ||
  19479. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  19480. (Set && getTag(new Set) != setTag) ||
  19481. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  19482. getTag = function(value) {
  19483. var result = baseGetTag(value),
  19484. Ctor = result == objectTag ? value.constructor : undefined,
  19485. ctorString = Ctor ? toSource(Ctor) : '';
  19486. if (ctorString) {
  19487. switch (ctorString) {
  19488. case dataViewCtorString: return dataViewTag;
  19489. case mapCtorString: return mapTag;
  19490. case promiseCtorString: return promiseTag;
  19491. case setCtorString: return setTag;
  19492. case weakMapCtorString: return weakMapTag;
  19493. }
  19494. }
  19495. return result;
  19496. };
  19497. }
  19498. /**
  19499. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  19500. *
  19501. * @private
  19502. * @param {number} start The start of the view.
  19503. * @param {number} end The end of the view.
  19504. * @param {Array} transforms The transformations to apply to the view.
  19505. * @returns {Object} Returns an object containing the `start` and `end`
  19506. * positions of the view.
  19507. */
  19508. function getView(start, end, transforms) {
  19509. var index = -1,
  19510. length = transforms.length;
  19511. while (++index < length) {
  19512. var data = transforms[index],
  19513. size = data.size;
  19514. switch (data.type) {
  19515. case 'drop': start += size; break;
  19516. case 'dropRight': end -= size; break;
  19517. case 'take': end = nativeMin(end, start + size); break;
  19518. case 'takeRight': start = nativeMax(start, end - size); break;
  19519. }
  19520. }
  19521. return { 'start': start, 'end': end };
  19522. }
  19523. /**
  19524. * Extracts wrapper details from the `source` body comment.
  19525. *
  19526. * @private
  19527. * @param {string} source The source to inspect.
  19528. * @returns {Array} Returns the wrapper details.
  19529. */
  19530. function getWrapDetails(source) {
  19531. var match = source.match(reWrapDetails);
  19532. return match ? match[1].split(reSplitDetails) : [];
  19533. }
  19534. /**
  19535. * Checks if `path` exists on `object`.
  19536. *
  19537. * @private
  19538. * @param {Object} object The object to query.
  19539. * @param {Array|string} path The path to check.
  19540. * @param {Function} hasFunc The function to check properties.
  19541. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  19542. */
  19543. function hasPath(object, path, hasFunc) {
  19544. path = castPath(path, object);
  19545. var index = -1,
  19546. length = path.length,
  19547. result = false;
  19548. while (++index < length) {
  19549. var key = toKey(path[index]);
  19550. if (!(result = object != null && hasFunc(object, key))) {
  19551. break;
  19552. }
  19553. object = object[key];
  19554. }
  19555. if (result || ++index != length) {
  19556. return result;
  19557. }
  19558. length = object == null ? 0 : object.length;
  19559. return !!length && isLength(length) && isIndex(key, length) &&
  19560. (isArray(object) || isArguments(object));
  19561. }
  19562. /**
  19563. * Initializes an array clone.
  19564. *
  19565. * @private
  19566. * @param {Array} array The array to clone.
  19567. * @returns {Array} Returns the initialized clone.
  19568. */
  19569. function initCloneArray(array) {
  19570. var length = array.length,
  19571. result = new array.constructor(length);
  19572. // Add properties assigned by `RegExp#exec`.
  19573. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  19574. result.index = array.index;
  19575. result.input = array.input;
  19576. }
  19577. return result;
  19578. }
  19579. /**
  19580. * Initializes an object clone.
  19581. *
  19582. * @private
  19583. * @param {Object} object The object to clone.
  19584. * @returns {Object} Returns the initialized clone.
  19585. */
  19586. function initCloneObject(object) {
  19587. return (typeof object.constructor == 'function' && !isPrototype(object))
  19588. ? baseCreate(getPrototype(object))
  19589. : {};
  19590. }
  19591. /**
  19592. * Initializes an object clone based on its `toStringTag`.
  19593. *
  19594. * **Note:** This function only supports cloning values with tags of
  19595. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  19596. *
  19597. * @private
  19598. * @param {Object} object The object to clone.
  19599. * @param {string} tag The `toStringTag` of the object to clone.
  19600. * @param {boolean} [isDeep] Specify a deep clone.
  19601. * @returns {Object} Returns the initialized clone.
  19602. */
  19603. function initCloneByTag(object, tag, isDeep) {
  19604. var Ctor = object.constructor;
  19605. switch (tag) {
  19606. case arrayBufferTag:
  19607. return cloneArrayBuffer(object);
  19608. case boolTag:
  19609. case dateTag:
  19610. return new Ctor(+object);
  19611. case dataViewTag:
  19612. return cloneDataView(object, isDeep);
  19613. case float32Tag: case float64Tag:
  19614. case int8Tag: case int16Tag: case int32Tag:
  19615. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  19616. return cloneTypedArray(object, isDeep);
  19617. case mapTag:
  19618. return new Ctor;
  19619. case numberTag:
  19620. case stringTag:
  19621. return new Ctor(object);
  19622. case regexpTag:
  19623. return cloneRegExp(object);
  19624. case setTag:
  19625. return new Ctor;
  19626. case symbolTag:
  19627. return cloneSymbol(object);
  19628. }
  19629. }
  19630. /**
  19631. * Inserts wrapper `details` in a comment at the top of the `source` body.
  19632. *
  19633. * @private
  19634. * @param {string} source The source to modify.
  19635. * @returns {Array} details The details to insert.
  19636. * @returns {string} Returns the modified source.
  19637. */
  19638. function insertWrapDetails(source, details) {
  19639. var length = details.length;
  19640. if (!length) {
  19641. return source;
  19642. }
  19643. var lastIndex = length - 1;
  19644. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  19645. details = details.join(length > 2 ? ', ' : ' ');
  19646. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  19647. }
  19648. /**
  19649. * Checks if `value` is a flattenable `arguments` object or array.
  19650. *
  19651. * @private
  19652. * @param {*} value The value to check.
  19653. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  19654. */
  19655. function isFlattenable(value) {
  19656. return isArray(value) || isArguments(value) ||
  19657. !!(spreadableSymbol && value && value[spreadableSymbol]);
  19658. }
  19659. /**
  19660. * Checks if `value` is a valid array-like index.
  19661. *
  19662. * @private
  19663. * @param {*} value The value to check.
  19664. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  19665. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  19666. */
  19667. function isIndex(value, length) {
  19668. var type = typeof value;
  19669. length = length == null ? MAX_SAFE_INTEGER : length;
  19670. return !!length &&
  19671. (type == 'number' ||
  19672. (type != 'symbol' && reIsUint.test(value))) &&
  19673. (value > -1 && value % 1 == 0 && value < length);
  19674. }
  19675. /**
  19676. * Checks if the given arguments are from an iteratee call.
  19677. *
  19678. * @private
  19679. * @param {*} value The potential iteratee value argument.
  19680. * @param {*} index The potential iteratee index or key argument.
  19681. * @param {*} object The potential iteratee object argument.
  19682. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  19683. * else `false`.
  19684. */
  19685. function isIterateeCall(value, index, object) {
  19686. if (!isObject(object)) {
  19687. return false;
  19688. }
  19689. var type = typeof index;
  19690. if (type == 'number'
  19691. ? (isArrayLike(object) && isIndex(index, object.length))
  19692. : (type == 'string' && index in object)
  19693. ) {
  19694. return eq(object[index], value);
  19695. }
  19696. return false;
  19697. }
  19698. /**
  19699. * Checks if `value` is a property name and not a property path.
  19700. *
  19701. * @private
  19702. * @param {*} value The value to check.
  19703. * @param {Object} [object] The object to query keys on.
  19704. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  19705. */
  19706. function isKey(value, object) {
  19707. if (isArray(value)) {
  19708. return false;
  19709. }
  19710. var type = typeof value;
  19711. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  19712. value == null || isSymbol(value)) {
  19713. return true;
  19714. }
  19715. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  19716. (object != null && value in Object(object));
  19717. }
  19718. /**
  19719. * Checks if `value` is suitable for use as unique object key.
  19720. *
  19721. * @private
  19722. * @param {*} value The value to check.
  19723. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  19724. */
  19725. function isKeyable(value) {
  19726. var type = typeof value;
  19727. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  19728. ? (value !== '__proto__')
  19729. : (value === null);
  19730. }
  19731. /**
  19732. * Checks if `func` has a lazy counterpart.
  19733. *
  19734. * @private
  19735. * @param {Function} func The function to check.
  19736. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  19737. * else `false`.
  19738. */
  19739. function isLaziable(func) {
  19740. var funcName = getFuncName(func),
  19741. other = lodash[funcName];
  19742. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  19743. return false;
  19744. }
  19745. if (func === other) {
  19746. return true;
  19747. }
  19748. var data = getData(other);
  19749. return !!data && func === data[0];
  19750. }
  19751. /**
  19752. * Checks if `func` has its source masked.
  19753. *
  19754. * @private
  19755. * @param {Function} func The function to check.
  19756. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  19757. */
  19758. function isMasked(func) {
  19759. return !!maskSrcKey && (maskSrcKey in func);
  19760. }
  19761. /**
  19762. * Checks if `func` is capable of being masked.
  19763. *
  19764. * @private
  19765. * @param {*} value The value to check.
  19766. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  19767. */
  19768. var isMaskable = coreJsData ? isFunction : stubFalse;
  19769. /**
  19770. * Checks if `value` is likely a prototype object.
  19771. *
  19772. * @private
  19773. * @param {*} value The value to check.
  19774. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  19775. */
  19776. function isPrototype(value) {
  19777. var Ctor = value && value.constructor,
  19778. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  19779. return value === proto;
  19780. }
  19781. /**
  19782. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  19783. *
  19784. * @private
  19785. * @param {*} value The value to check.
  19786. * @returns {boolean} Returns `true` if `value` if suitable for strict
  19787. * equality comparisons, else `false`.
  19788. */
  19789. function isStrictComparable(value) {
  19790. return value === value && !isObject(value);
  19791. }
  19792. /**
  19793. * A specialized version of `matchesProperty` for source values suitable
  19794. * for strict equality comparisons, i.e. `===`.
  19795. *
  19796. * @private
  19797. * @param {string} key The key of the property to get.
  19798. * @param {*} srcValue The value to match.
  19799. * @returns {Function} Returns the new spec function.
  19800. */
  19801. function matchesStrictComparable(key, srcValue) {
  19802. return function(object) {
  19803. if (object == null) {
  19804. return false;
  19805. }
  19806. return object[key] === srcValue &&
  19807. (srcValue !== undefined || (key in Object(object)));
  19808. };
  19809. }
  19810. /**
  19811. * A specialized version of `_.memoize` which clears the memoized function's
  19812. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  19813. *
  19814. * @private
  19815. * @param {Function} func The function to have its output memoized.
  19816. * @returns {Function} Returns the new memoized function.
  19817. */
  19818. function memoizeCapped(func) {
  19819. var result = memoize(func, function(key) {
  19820. if (cache.size === MAX_MEMOIZE_SIZE) {
  19821. cache.clear();
  19822. }
  19823. return key;
  19824. });
  19825. var cache = result.cache;
  19826. return result;
  19827. }
  19828. /**
  19829. * Merges the function metadata of `source` into `data`.
  19830. *
  19831. * Merging metadata reduces the number of wrappers used to invoke a function.
  19832. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  19833. * may be applied regardless of execution order. Methods like `_.ary` and
  19834. * `_.rearg` modify function arguments, making the order in which they are
  19835. * executed important, preventing the merging of metadata. However, we make
  19836. * an exception for a safe combined case where curried functions have `_.ary`
  19837. * and or `_.rearg` applied.
  19838. *
  19839. * @private
  19840. * @param {Array} data The destination metadata.
  19841. * @param {Array} source The source metadata.
  19842. * @returns {Array} Returns `data`.
  19843. */
  19844. function mergeData(data, source) {
  19845. var bitmask = data[1],
  19846. srcBitmask = source[1],
  19847. newBitmask = bitmask | srcBitmask,
  19848. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  19849. var isCombo =
  19850. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  19851. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  19852. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  19853. // Exit early if metadata can't be merged.
  19854. if (!(isCommon || isCombo)) {
  19855. return data;
  19856. }
  19857. // Use source `thisArg` if available.
  19858. if (srcBitmask & WRAP_BIND_FLAG) {
  19859. data[2] = source[2];
  19860. // Set when currying a bound function.
  19861. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  19862. }
  19863. // Compose partial arguments.
  19864. var value = source[3];
  19865. if (value) {
  19866. var partials = data[3];
  19867. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  19868. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  19869. }
  19870. // Compose partial right arguments.
  19871. value = source[5];
  19872. if (value) {
  19873. partials = data[5];
  19874. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  19875. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  19876. }
  19877. // Use source `argPos` if available.
  19878. value = source[7];
  19879. if (value) {
  19880. data[7] = value;
  19881. }
  19882. // Use source `ary` if it's smaller.
  19883. if (srcBitmask & WRAP_ARY_FLAG) {
  19884. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  19885. }
  19886. // Use source `arity` if one is not provided.
  19887. if (data[9] == null) {
  19888. data[9] = source[9];
  19889. }
  19890. // Use source `func` and merge bitmasks.
  19891. data[0] = source[0];
  19892. data[1] = newBitmask;
  19893. return data;
  19894. }
  19895. /**
  19896. * This function is like
  19897. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  19898. * except that it includes inherited enumerable properties.
  19899. *
  19900. * @private
  19901. * @param {Object} object The object to query.
  19902. * @returns {Array} Returns the array of property names.
  19903. */
  19904. function nativeKeysIn(object) {
  19905. var result = [];
  19906. if (object != null) {
  19907. for (var key in Object(object)) {
  19908. result.push(key);
  19909. }
  19910. }
  19911. return result;
  19912. }
  19913. /**
  19914. * Converts `value` to a string using `Object.prototype.toString`.
  19915. *
  19916. * @private
  19917. * @param {*} value The value to convert.
  19918. * @returns {string} Returns the converted string.
  19919. */
  19920. function objectToString(value) {
  19921. return nativeObjectToString.call(value);
  19922. }
  19923. /**
  19924. * A specialized version of `baseRest` which transforms the rest array.
  19925. *
  19926. * @private
  19927. * @param {Function} func The function to apply a rest parameter to.
  19928. * @param {number} [start=func.length-1] The start position of the rest parameter.
  19929. * @param {Function} transform The rest array transform.
  19930. * @returns {Function} Returns the new function.
  19931. */
  19932. function overRest(func, start, transform) {
  19933. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  19934. return function() {
  19935. var args = arguments,
  19936. index = -1,
  19937. length = nativeMax(args.length - start, 0),
  19938. array = Array(length);
  19939. while (++index < length) {
  19940. array[index] = args[start + index];
  19941. }
  19942. index = -1;
  19943. var otherArgs = Array(start + 1);
  19944. while (++index < start) {
  19945. otherArgs[index] = args[index];
  19946. }
  19947. otherArgs[start] = transform(array);
  19948. return apply(func, this, otherArgs);
  19949. };
  19950. }
  19951. /**
  19952. * Gets the parent value at `path` of `object`.
  19953. *
  19954. * @private
  19955. * @param {Object} object The object to query.
  19956. * @param {Array} path The path to get the parent value of.
  19957. * @returns {*} Returns the parent value.
  19958. */
  19959. function parent(object, path) {
  19960. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  19961. }
  19962. /**
  19963. * Reorder `array` according to the specified indexes where the element at
  19964. * the first index is assigned as the first element, the element at
  19965. * the second index is assigned as the second element, and so on.
  19966. *
  19967. * @private
  19968. * @param {Array} array The array to reorder.
  19969. * @param {Array} indexes The arranged array indexes.
  19970. * @returns {Array} Returns `array`.
  19971. */
  19972. function reorder(array, indexes) {
  19973. var arrLength = array.length,
  19974. length = nativeMin(indexes.length, arrLength),
  19975. oldArray = copyArray(array);
  19976. while (length--) {
  19977. var index = indexes[length];
  19978. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  19979. }
  19980. return array;
  19981. }
  19982. /**
  19983. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  19984. *
  19985. * @private
  19986. * @param {Object} object The object to query.
  19987. * @param {string} key The key of the property to get.
  19988. * @returns {*} Returns the property value.
  19989. */
  19990. function safeGet(object, key) {
  19991. if (key === 'constructor' && typeof object[key] === 'function') {
  19992. return;
  19993. }
  19994. if (key == '__proto__') {
  19995. return;
  19996. }
  19997. return object[key];
  19998. }
  19999. /**
  20000. * Sets metadata for `func`.
  20001. *
  20002. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  20003. * period of time, it will trip its breaker and transition to an identity
  20004. * function to avoid garbage collection pauses in V8. See
  20005. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  20006. * for more details.
  20007. *
  20008. * @private
  20009. * @param {Function} func The function to associate metadata with.
  20010. * @param {*} data The metadata.
  20011. * @returns {Function} Returns `func`.
  20012. */
  20013. var setData = shortOut(baseSetData);
  20014. /**
  20015. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  20016. *
  20017. * @private
  20018. * @param {Function} func The function to delay.
  20019. * @param {number} wait The number of milliseconds to delay invocation.
  20020. * @returns {number|Object} Returns the timer id or timeout object.
  20021. */
  20022. var setTimeout = ctxSetTimeout || function(func, wait) {
  20023. return root.setTimeout(func, wait);
  20024. };
  20025. /**
  20026. * Sets the `toString` method of `func` to return `string`.
  20027. *
  20028. * @private
  20029. * @param {Function} func The function to modify.
  20030. * @param {Function} string The `toString` result.
  20031. * @returns {Function} Returns `func`.
  20032. */
  20033. var setToString = shortOut(baseSetToString);
  20034. /**
  20035. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  20036. * with wrapper details in a comment at the top of the source body.
  20037. *
  20038. * @private
  20039. * @param {Function} wrapper The function to modify.
  20040. * @param {Function} reference The reference function.
  20041. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  20042. * @returns {Function} Returns `wrapper`.
  20043. */
  20044. function setWrapToString(wrapper, reference, bitmask) {
  20045. var source = (reference + '');
  20046. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  20047. }
  20048. /**
  20049. * Creates a function that'll short out and invoke `identity` instead
  20050. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  20051. * milliseconds.
  20052. *
  20053. * @private
  20054. * @param {Function} func The function to restrict.
  20055. * @returns {Function} Returns the new shortable function.
  20056. */
  20057. function shortOut(func) {
  20058. var count = 0,
  20059. lastCalled = 0;
  20060. return function() {
  20061. var stamp = nativeNow(),
  20062. remaining = HOT_SPAN - (stamp - lastCalled);
  20063. lastCalled = stamp;
  20064. if (remaining > 0) {
  20065. if (++count >= HOT_COUNT) {
  20066. return arguments[0];
  20067. }
  20068. } else {
  20069. count = 0;
  20070. }
  20071. return func.apply(undefined, arguments);
  20072. };
  20073. }
  20074. /**
  20075. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  20076. *
  20077. * @private
  20078. * @param {Array} array The array to shuffle.
  20079. * @param {number} [size=array.length] The size of `array`.
  20080. * @returns {Array} Returns `array`.
  20081. */
  20082. function shuffleSelf(array, size) {
  20083. var index = -1,
  20084. length = array.length,
  20085. lastIndex = length - 1;
  20086. size = size === undefined ? length : size;
  20087. while (++index < size) {
  20088. var rand = baseRandom(index, lastIndex),
  20089. value = array[rand];
  20090. array[rand] = array[index];
  20091. array[index] = value;
  20092. }
  20093. array.length = size;
  20094. return array;
  20095. }
  20096. /**
  20097. * Converts `string` to a property path array.
  20098. *
  20099. * @private
  20100. * @param {string} string The string to convert.
  20101. * @returns {Array} Returns the property path array.
  20102. */
  20103. var stringToPath = memoizeCapped(function(string) {
  20104. var result = [];
  20105. if (string.charCodeAt(0) === 46 /* . */) {
  20106. result.push('');
  20107. }
  20108. string.replace(rePropName, function(match, number, quote, subString) {
  20109. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  20110. });
  20111. return result;
  20112. });
  20113. /**
  20114. * Converts `value` to a string key if it's not a string or symbol.
  20115. *
  20116. * @private
  20117. * @param {*} value The value to inspect.
  20118. * @returns {string|symbol} Returns the key.
  20119. */
  20120. function toKey(value) {
  20121. if (typeof value == 'string' || isSymbol(value)) {
  20122. return value;
  20123. }
  20124. var result = (value + '');
  20125. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  20126. }
  20127. /**
  20128. * Converts `func` to its source code.
  20129. *
  20130. * @private
  20131. * @param {Function} func The function to convert.
  20132. * @returns {string} Returns the source code.
  20133. */
  20134. function toSource(func) {
  20135. if (func != null) {
  20136. try {
  20137. return funcToString.call(func);
  20138. } catch (e) {}
  20139. try {
  20140. return (func + '');
  20141. } catch (e) {}
  20142. }
  20143. return '';
  20144. }
  20145. /**
  20146. * Updates wrapper `details` based on `bitmask` flags.
  20147. *
  20148. * @private
  20149. * @returns {Array} details The details to modify.
  20150. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  20151. * @returns {Array} Returns `details`.
  20152. */
  20153. function updateWrapDetails(details, bitmask) {
  20154. arrayEach(wrapFlags, function(pair) {
  20155. var value = '_.' + pair[0];
  20156. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  20157. details.push(value);
  20158. }
  20159. });
  20160. return details.sort();
  20161. }
  20162. /**
  20163. * Creates a clone of `wrapper`.
  20164. *
  20165. * @private
  20166. * @param {Object} wrapper The wrapper to clone.
  20167. * @returns {Object} Returns the cloned wrapper.
  20168. */
  20169. function wrapperClone(wrapper) {
  20170. if (wrapper instanceof LazyWrapper) {
  20171. return wrapper.clone();
  20172. }
  20173. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  20174. result.__actions__ = copyArray(wrapper.__actions__);
  20175. result.__index__ = wrapper.__index__;
  20176. result.__values__ = wrapper.__values__;
  20177. return result;
  20178. }
  20179. /*------------------------------------------------------------------------*/
  20180. /**
  20181. * Creates an array of elements split into groups the length of `size`.
  20182. * If `array` can't be split evenly, the final chunk will be the remaining
  20183. * elements.
  20184. *
  20185. * @static
  20186. * @memberOf _
  20187. * @since 3.0.0
  20188. * @category Array
  20189. * @param {Array} array The array to process.
  20190. * @param {number} [size=1] The length of each chunk
  20191. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  20192. * @returns {Array} Returns the new array of chunks.
  20193. * @example
  20194. *
  20195. * _.chunk(['a', 'b', 'c', 'd'], 2);
  20196. * // => [['a', 'b'], ['c', 'd']]
  20197. *
  20198. * _.chunk(['a', 'b', 'c', 'd'], 3);
  20199. * // => [['a', 'b', 'c'], ['d']]
  20200. */
  20201. function chunk(array, size, guard) {
  20202. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  20203. size = 1;
  20204. } else {
  20205. size = nativeMax(toInteger(size), 0);
  20206. }
  20207. var length = array == null ? 0 : array.length;
  20208. if (!length || size < 1) {
  20209. return [];
  20210. }
  20211. var index = 0,
  20212. resIndex = 0,
  20213. result = Array(nativeCeil(length / size));
  20214. while (index < length) {
  20215. result[resIndex++] = baseSlice(array, index, (index += size));
  20216. }
  20217. return result;
  20218. }
  20219. /**
  20220. * Creates an array with all falsey values removed. The values `false`, `null`,
  20221. * `0`, `""`, `undefined`, and `NaN` are falsey.
  20222. *
  20223. * @static
  20224. * @memberOf _
  20225. * @since 0.1.0
  20226. * @category Array
  20227. * @param {Array} array The array to compact.
  20228. * @returns {Array} Returns the new array of filtered values.
  20229. * @example
  20230. *
  20231. * _.compact([0, 1, false, 2, '', 3]);
  20232. * // => [1, 2, 3]
  20233. */
  20234. function compact(array) {
  20235. var index = -1,
  20236. length = array == null ? 0 : array.length,
  20237. resIndex = 0,
  20238. result = [];
  20239. while (++index < length) {
  20240. var value = array[index];
  20241. if (value) {
  20242. result[resIndex++] = value;
  20243. }
  20244. }
  20245. return result;
  20246. }
  20247. /**
  20248. * Creates a new array concatenating `array` with any additional arrays
  20249. * and/or values.
  20250. *
  20251. * @static
  20252. * @memberOf _
  20253. * @since 4.0.0
  20254. * @category Array
  20255. * @param {Array} array The array to concatenate.
  20256. * @param {...*} [values] The values to concatenate.
  20257. * @returns {Array} Returns the new concatenated array.
  20258. * @example
  20259. *
  20260. * var array = [1];
  20261. * var other = _.concat(array, 2, [3], [[4]]);
  20262. *
  20263. * console.log(other);
  20264. * // => [1, 2, 3, [4]]
  20265. *
  20266. * console.log(array);
  20267. * // => [1]
  20268. */
  20269. function concat() {
  20270. var length = arguments.length;
  20271. if (!length) {
  20272. return [];
  20273. }
  20274. var args = Array(length - 1),
  20275. array = arguments[0],
  20276. index = length;
  20277. while (index--) {
  20278. args[index - 1] = arguments[index];
  20279. }
  20280. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  20281. }
  20282. /**
  20283. * Creates an array of `array` values not included in the other given arrays
  20284. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  20285. * for equality comparisons. The order and references of result values are
  20286. * determined by the first array.
  20287. *
  20288. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  20289. *
  20290. * @static
  20291. * @memberOf _
  20292. * @since 0.1.0
  20293. * @category Array
  20294. * @param {Array} array The array to inspect.
  20295. * @param {...Array} [values] The values to exclude.
  20296. * @returns {Array} Returns the new array of filtered values.
  20297. * @see _.without, _.xor
  20298. * @example
  20299. *
  20300. * _.difference([2, 1], [2, 3]);
  20301. * // => [1]
  20302. */
  20303. var difference = baseRest(function(array, values) {
  20304. return isArrayLikeObject(array)
  20305. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  20306. : [];
  20307. });
  20308. /**
  20309. * This method is like `_.difference` except that it accepts `iteratee` which
  20310. * is invoked for each element of `array` and `values` to generate the criterion
  20311. * by which they're compared. The order and references of result values are
  20312. * determined by the first array. The iteratee is invoked with one argument:
  20313. * (value).
  20314. *
  20315. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  20316. *
  20317. * @static
  20318. * @memberOf _
  20319. * @since 4.0.0
  20320. * @category Array
  20321. * @param {Array} array The array to inspect.
  20322. * @param {...Array} [values] The values to exclude.
  20323. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  20324. * @returns {Array} Returns the new array of filtered values.
  20325. * @example
  20326. *
  20327. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  20328. * // => [1.2]
  20329. *
  20330. * // The `_.property` iteratee shorthand.
  20331. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  20332. * // => [{ 'x': 2 }]
  20333. */
  20334. var differenceBy = baseRest(function(array, values) {
  20335. var iteratee = last(values);
  20336. if (isArrayLikeObject(iteratee)) {
  20337. iteratee = undefined;
  20338. }
  20339. return isArrayLikeObject(array)
  20340. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  20341. : [];
  20342. });
  20343. /**
  20344. * This method is like `_.difference` except that it accepts `comparator`
  20345. * which is invoked to compare elements of `array` to `values`. The order and
  20346. * references of result values are determined by the first array. The comparator
  20347. * is invoked with two arguments: (arrVal, othVal).
  20348. *
  20349. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  20350. *
  20351. * @static
  20352. * @memberOf _
  20353. * @since 4.0.0
  20354. * @category Array
  20355. * @param {Array} array The array to inspect.
  20356. * @param {...Array} [values] The values to exclude.
  20357. * @param {Function} [comparator] The comparator invoked per element.
  20358. * @returns {Array} Returns the new array of filtered values.
  20359. * @example
  20360. *
  20361. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  20362. *
  20363. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  20364. * // => [{ 'x': 2, 'y': 1 }]
  20365. */
  20366. var differenceWith = baseRest(function(array, values) {
  20367. var comparator = last(values);
  20368. if (isArrayLikeObject(comparator)) {
  20369. comparator = undefined;
  20370. }
  20371. return isArrayLikeObject(array)
  20372. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  20373. : [];
  20374. });
  20375. /**
  20376. * Creates a slice of `array` with `n` elements dropped from the beginning.
  20377. *
  20378. * @static
  20379. * @memberOf _
  20380. * @since 0.5.0
  20381. * @category Array
  20382. * @param {Array} array The array to query.
  20383. * @param {number} [n=1] The number of elements to drop.
  20384. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  20385. * @returns {Array} Returns the slice of `array`.
  20386. * @example
  20387. *
  20388. * _.drop([1, 2, 3]);
  20389. * // => [2, 3]
  20390. *
  20391. * _.drop([1, 2, 3], 2);
  20392. * // => [3]
  20393. *
  20394. * _.drop([1, 2, 3], 5);
  20395. * // => []
  20396. *
  20397. * _.drop([1, 2, 3], 0);
  20398. * // => [1, 2, 3]
  20399. */
  20400. function drop(array, n, guard) {
  20401. var length = array == null ? 0 : array.length;
  20402. if (!length) {
  20403. return [];
  20404. }
  20405. n = (guard || n === undefined) ? 1 : toInteger(n);
  20406. return baseSlice(array, n < 0 ? 0 : n, length);
  20407. }
  20408. /**
  20409. * Creates a slice of `array` with `n` elements dropped from the end.
  20410. *
  20411. * @static
  20412. * @memberOf _
  20413. * @since 3.0.0
  20414. * @category Array
  20415. * @param {Array} array The array to query.
  20416. * @param {number} [n=1] The number of elements to drop.
  20417. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  20418. * @returns {Array} Returns the slice of `array`.
  20419. * @example
  20420. *
  20421. * _.dropRight([1, 2, 3]);
  20422. * // => [1, 2]
  20423. *
  20424. * _.dropRight([1, 2, 3], 2);
  20425. * // => [1]
  20426. *
  20427. * _.dropRight([1, 2, 3], 5);
  20428. * // => []
  20429. *
  20430. * _.dropRight([1, 2, 3], 0);
  20431. * // => [1, 2, 3]
  20432. */
  20433. function dropRight(array, n, guard) {
  20434. var length = array == null ? 0 : array.length;
  20435. if (!length) {
  20436. return [];
  20437. }
  20438. n = (guard || n === undefined) ? 1 : toInteger(n);
  20439. n = length - n;
  20440. return baseSlice(array, 0, n < 0 ? 0 : n);
  20441. }
  20442. /**
  20443. * Creates a slice of `array` excluding elements dropped from the end.
  20444. * Elements are dropped until `predicate` returns falsey. The predicate is
  20445. * invoked with three arguments: (value, index, array).
  20446. *
  20447. * @static
  20448. * @memberOf _
  20449. * @since 3.0.0
  20450. * @category Array
  20451. * @param {Array} array The array to query.
  20452. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  20453. * @returns {Array} Returns the slice of `array`.
  20454. * @example
  20455. *
  20456. * var users = [
  20457. * { 'user': 'barney', 'active': true },
  20458. * { 'user': 'fred', 'active': false },
  20459. * { 'user': 'pebbles', 'active': false }
  20460. * ];
  20461. *
  20462. * _.dropRightWhile(users, function(o) { return !o.active; });
  20463. * // => objects for ['barney']
  20464. *
  20465. * // The `_.matches` iteratee shorthand.
  20466. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  20467. * // => objects for ['barney', 'fred']
  20468. *
  20469. * // The `_.matchesProperty` iteratee shorthand.
  20470. * _.dropRightWhile(users, ['active', false]);
  20471. * // => objects for ['barney']
  20472. *
  20473. * // The `_.property` iteratee shorthand.
  20474. * _.dropRightWhile(users, 'active');
  20475. * // => objects for ['barney', 'fred', 'pebbles']
  20476. */
  20477. function dropRightWhile(array, predicate) {
  20478. return (array && array.length)
  20479. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  20480. : [];
  20481. }
  20482. /**
  20483. * Creates a slice of `array` excluding elements dropped from the beginning.
  20484. * Elements are dropped until `predicate` returns falsey. The predicate is
  20485. * invoked with three arguments: (value, index, array).
  20486. *
  20487. * @static
  20488. * @memberOf _
  20489. * @since 3.0.0
  20490. * @category Array
  20491. * @param {Array} array The array to query.
  20492. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  20493. * @returns {Array} Returns the slice of `array`.
  20494. * @example
  20495. *
  20496. * var users = [
  20497. * { 'user': 'barney', 'active': false },
  20498. * { 'user': 'fred', 'active': false },
  20499. * { 'user': 'pebbles', 'active': true }
  20500. * ];
  20501. *
  20502. * _.dropWhile(users, function(o) { return !o.active; });
  20503. * // => objects for ['pebbles']
  20504. *
  20505. * // The `_.matches` iteratee shorthand.
  20506. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  20507. * // => objects for ['fred', 'pebbles']
  20508. *
  20509. * // The `_.matchesProperty` iteratee shorthand.
  20510. * _.dropWhile(users, ['active', false]);
  20511. * // => objects for ['pebbles']
  20512. *
  20513. * // The `_.property` iteratee shorthand.
  20514. * _.dropWhile(users, 'active');
  20515. * // => objects for ['barney', 'fred', 'pebbles']
  20516. */
  20517. function dropWhile(array, predicate) {
  20518. return (array && array.length)
  20519. ? baseWhile(array, getIteratee(predicate, 3), true)
  20520. : [];
  20521. }
  20522. /**
  20523. * Fills elements of `array` with `value` from `start` up to, but not
  20524. * including, `end`.
  20525. *
  20526. * **Note:** This method mutates `array`.
  20527. *
  20528. * @static
  20529. * @memberOf _
  20530. * @since 3.2.0
  20531. * @category Array
  20532. * @param {Array} array The array to fill.
  20533. * @param {*} value The value to fill `array` with.
  20534. * @param {number} [start=0] The start position.
  20535. * @param {number} [end=array.length] The end position.
  20536. * @returns {Array} Returns `array`.
  20537. * @example
  20538. *
  20539. * var array = [1, 2, 3];
  20540. *
  20541. * _.fill(array, 'a');
  20542. * console.log(array);
  20543. * // => ['a', 'a', 'a']
  20544. *
  20545. * _.fill(Array(3), 2);
  20546. * // => [2, 2, 2]
  20547. *
  20548. * _.fill([4, 6, 8, 10], '*', 1, 3);
  20549. * // => [4, '*', '*', 10]
  20550. */
  20551. function fill(array, value, start, end) {
  20552. var length = array == null ? 0 : array.length;
  20553. if (!length) {
  20554. return [];
  20555. }
  20556. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  20557. start = 0;
  20558. end = length;
  20559. }
  20560. return baseFill(array, value, start, end);
  20561. }
  20562. /**
  20563. * This method is like `_.find` except that it returns the index of the first
  20564. * element `predicate` returns truthy for instead of the element itself.
  20565. *
  20566. * @static
  20567. * @memberOf _
  20568. * @since 1.1.0
  20569. * @category Array
  20570. * @param {Array} array The array to inspect.
  20571. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  20572. * @param {number} [fromIndex=0] The index to search from.
  20573. * @returns {number} Returns the index of the found element, else `-1`.
  20574. * @example
  20575. *
  20576. * var users = [
  20577. * { 'user': 'barney', 'active': false },
  20578. * { 'user': 'fred', 'active': false },
  20579. * { 'user': 'pebbles', 'active': true }
  20580. * ];
  20581. *
  20582. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  20583. * // => 0
  20584. *
  20585. * // The `_.matches` iteratee shorthand.
  20586. * _.findIndex(users, { 'user': 'fred', 'active': false });
  20587. * // => 1
  20588. *
  20589. * // The `_.matchesProperty` iteratee shorthand.
  20590. * _.findIndex(users, ['active', false]);
  20591. * // => 0
  20592. *
  20593. * // The `_.property` iteratee shorthand.
  20594. * _.findIndex(users, 'active');
  20595. * // => 2
  20596. */
  20597. function findIndex(array, predicate, fromIndex) {
  20598. var length = array == null ? 0 : array.length;
  20599. if (!length) {
  20600. return -1;
  20601. }
  20602. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  20603. if (index < 0) {
  20604. index = nativeMax(length + index, 0);
  20605. }
  20606. return baseFindIndex(array, getIteratee(predicate, 3), index);
  20607. }
  20608. /**
  20609. * This method is like `_.findIndex` except that it iterates over elements
  20610. * of `collection` from right to left.
  20611. *
  20612. * @static
  20613. * @memberOf _
  20614. * @since 2.0.0
  20615. * @category Array
  20616. * @param {Array} array The array to inspect.
  20617. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  20618. * @param {number} [fromIndex=array.length-1] The index to search from.
  20619. * @returns {number} Returns the index of the found element, else `-1`.
  20620. * @example
  20621. *
  20622. * var users = [
  20623. * { 'user': 'barney', 'active': true },
  20624. * { 'user': 'fred', 'active': false },
  20625. * { 'user': 'pebbles', 'active': false }
  20626. * ];
  20627. *
  20628. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  20629. * // => 2
  20630. *
  20631. * // The `_.matches` iteratee shorthand.
  20632. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  20633. * // => 0
  20634. *
  20635. * // The `_.matchesProperty` iteratee shorthand.
  20636. * _.findLastIndex(users, ['active', false]);
  20637. * // => 2
  20638. *
  20639. * // The `_.property` iteratee shorthand.
  20640. * _.findLastIndex(users, 'active');
  20641. * // => 0
  20642. */
  20643. function findLastIndex(array, predicate, fromIndex) {
  20644. var length = array == null ? 0 : array.length;
  20645. if (!length) {
  20646. return -1;
  20647. }
  20648. var index = length - 1;
  20649. if (fromIndex !== undefined) {
  20650. index = toInteger(fromIndex);
  20651. index = fromIndex < 0
  20652. ? nativeMax(length + index, 0)
  20653. : nativeMin(index, length - 1);
  20654. }
  20655. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  20656. }
  20657. /**
  20658. * Flattens `array` a single level deep.
  20659. *
  20660. * @static
  20661. * @memberOf _
  20662. * @since 0.1.0
  20663. * @category Array
  20664. * @param {Array} array The array to flatten.
  20665. * @returns {Array} Returns the new flattened array.
  20666. * @example
  20667. *
  20668. * _.flatten([1, [2, [3, [4]], 5]]);
  20669. * // => [1, 2, [3, [4]], 5]
  20670. */
  20671. function flatten(array) {
  20672. var length = array == null ? 0 : array.length;
  20673. return length ? baseFlatten(array, 1) : [];
  20674. }
  20675. /**
  20676. * Recursively flattens `array`.
  20677. *
  20678. * @static
  20679. * @memberOf _
  20680. * @since 3.0.0
  20681. * @category Array
  20682. * @param {Array} array The array to flatten.
  20683. * @returns {Array} Returns the new flattened array.
  20684. * @example
  20685. *
  20686. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  20687. * // => [1, 2, 3, 4, 5]
  20688. */
  20689. function flattenDeep(array) {
  20690. var length = array == null ? 0 : array.length;
  20691. return length ? baseFlatten(array, INFINITY) : [];
  20692. }
  20693. /**
  20694. * Recursively flatten `array` up to `depth` times.
  20695. *
  20696. * @static
  20697. * @memberOf _
  20698. * @since 4.4.0
  20699. * @category Array
  20700. * @param {Array} array The array to flatten.
  20701. * @param {number} [depth=1] The maximum recursion depth.
  20702. * @returns {Array} Returns the new flattened array.
  20703. * @example
  20704. *
  20705. * var array = [1, [2, [3, [4]], 5]];
  20706. *
  20707. * _.flattenDepth(array, 1);
  20708. * // => [1, 2, [3, [4]], 5]
  20709. *
  20710. * _.flattenDepth(array, 2);
  20711. * // => [1, 2, 3, [4], 5]
  20712. */
  20713. function flattenDepth(array, depth) {
  20714. var length = array == null ? 0 : array.length;
  20715. if (!length) {
  20716. return [];
  20717. }
  20718. depth = depth === undefined ? 1 : toInteger(depth);
  20719. return baseFlatten(array, depth);
  20720. }
  20721. /**
  20722. * The inverse of `_.toPairs`; this method returns an object composed
  20723. * from key-value `pairs`.
  20724. *
  20725. * @static
  20726. * @memberOf _
  20727. * @since 4.0.0
  20728. * @category Array
  20729. * @param {Array} pairs The key-value pairs.
  20730. * @returns {Object} Returns the new object.
  20731. * @example
  20732. *
  20733. * _.fromPairs([['a', 1], ['b', 2]]);
  20734. * // => { 'a': 1, 'b': 2 }
  20735. */
  20736. function fromPairs(pairs) {
  20737. var index = -1,
  20738. length = pairs == null ? 0 : pairs.length,
  20739. result = {};
  20740. while (++index < length) {
  20741. var pair = pairs[index];
  20742. result[pair[0]] = pair[1];
  20743. }
  20744. return result;
  20745. }
  20746. /**
  20747. * Gets the first element of `array`.
  20748. *
  20749. * @static
  20750. * @memberOf _
  20751. * @since 0.1.0
  20752. * @alias first
  20753. * @category Array
  20754. * @param {Array} array The array to query.
  20755. * @returns {*} Returns the first element of `array`.
  20756. * @example
  20757. *
  20758. * _.head([1, 2, 3]);
  20759. * // => 1
  20760. *
  20761. * _.head([]);
  20762. * // => undefined
  20763. */
  20764. function head(array) {
  20765. return (array && array.length) ? array[0] : undefined;
  20766. }
  20767. /**
  20768. * Gets the index at which the first occurrence of `value` is found in `array`
  20769. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  20770. * for equality comparisons. If `fromIndex` is negative, it's used as the
  20771. * offset from the end of `array`.
  20772. *
  20773. * @static
  20774. * @memberOf _
  20775. * @since 0.1.0
  20776. * @category Array
  20777. * @param {Array} array The array to inspect.
  20778. * @param {*} value The value to search for.
  20779. * @param {number} [fromIndex=0] The index to search from.
  20780. * @returns {number} Returns the index of the matched value, else `-1`.
  20781. * @example
  20782. *
  20783. * _.indexOf([1, 2, 1, 2], 2);
  20784. * // => 1
  20785. *
  20786. * // Search from the `fromIndex`.
  20787. * _.indexOf([1, 2, 1, 2], 2, 2);
  20788. * // => 3
  20789. */
  20790. function indexOf(array, value, fromIndex) {
  20791. var length = array == null ? 0 : array.length;
  20792. if (!length) {
  20793. return -1;
  20794. }
  20795. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  20796. if (index < 0) {
  20797. index = nativeMax(length + index, 0);
  20798. }
  20799. return baseIndexOf(array, value, index);
  20800. }
  20801. /**
  20802. * Gets all but the last element of `array`.
  20803. *
  20804. * @static
  20805. * @memberOf _
  20806. * @since 0.1.0
  20807. * @category Array
  20808. * @param {Array} array The array to query.
  20809. * @returns {Array} Returns the slice of `array`.
  20810. * @example
  20811. *
  20812. * _.initial([1, 2, 3]);
  20813. * // => [1, 2]
  20814. */
  20815. function initial(array) {
  20816. var length = array == null ? 0 : array.length;
  20817. return length ? baseSlice(array, 0, -1) : [];
  20818. }
  20819. /**
  20820. * Creates an array of unique values that are included in all given arrays
  20821. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  20822. * for equality comparisons. The order and references of result values are
  20823. * determined by the first array.
  20824. *
  20825. * @static
  20826. * @memberOf _
  20827. * @since 0.1.0
  20828. * @category Array
  20829. * @param {...Array} [arrays] The arrays to inspect.
  20830. * @returns {Array} Returns the new array of intersecting values.
  20831. * @example
  20832. *
  20833. * _.intersection([2, 1], [2, 3]);
  20834. * // => [2]
  20835. */
  20836. var intersection = baseRest(function(arrays) {
  20837. var mapped = arrayMap(arrays, castArrayLikeObject);
  20838. return (mapped.length && mapped[0] === arrays[0])
  20839. ? baseIntersection(mapped)
  20840. : [];
  20841. });
  20842. /**
  20843. * This method is like `_.intersection` except that it accepts `iteratee`
  20844. * which is invoked for each element of each `arrays` to generate the criterion
  20845. * by which they're compared. The order and references of result values are
  20846. * determined by the first array. The iteratee is invoked with one argument:
  20847. * (value).
  20848. *
  20849. * @static
  20850. * @memberOf _
  20851. * @since 4.0.0
  20852. * @category Array
  20853. * @param {...Array} [arrays] The arrays to inspect.
  20854. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  20855. * @returns {Array} Returns the new array of intersecting values.
  20856. * @example
  20857. *
  20858. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  20859. * // => [2.1]
  20860. *
  20861. * // The `_.property` iteratee shorthand.
  20862. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  20863. * // => [{ 'x': 1 }]
  20864. */
  20865. var intersectionBy = baseRest(function(arrays) {
  20866. var iteratee = last(arrays),
  20867. mapped = arrayMap(arrays, castArrayLikeObject);
  20868. if (iteratee === last(mapped)) {
  20869. iteratee = undefined;
  20870. } else {
  20871. mapped.pop();
  20872. }
  20873. return (mapped.length && mapped[0] === arrays[0])
  20874. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  20875. : [];
  20876. });
  20877. /**
  20878. * This method is like `_.intersection` except that it accepts `comparator`
  20879. * which is invoked to compare elements of `arrays`. The order and references
  20880. * of result values are determined by the first array. The comparator is
  20881. * invoked with two arguments: (arrVal, othVal).
  20882. *
  20883. * @static
  20884. * @memberOf _
  20885. * @since 4.0.0
  20886. * @category Array
  20887. * @param {...Array} [arrays] The arrays to inspect.
  20888. * @param {Function} [comparator] The comparator invoked per element.
  20889. * @returns {Array} Returns the new array of intersecting values.
  20890. * @example
  20891. *
  20892. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  20893. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  20894. *
  20895. * _.intersectionWith(objects, others, _.isEqual);
  20896. * // => [{ 'x': 1, 'y': 2 }]
  20897. */
  20898. var intersectionWith = baseRest(function(arrays) {
  20899. var comparator = last(arrays),
  20900. mapped = arrayMap(arrays, castArrayLikeObject);
  20901. comparator = typeof comparator == 'function' ? comparator : undefined;
  20902. if (comparator) {
  20903. mapped.pop();
  20904. }
  20905. return (mapped.length && mapped[0] === arrays[0])
  20906. ? baseIntersection(mapped, undefined, comparator)
  20907. : [];
  20908. });
  20909. /**
  20910. * Converts all elements in `array` into a string separated by `separator`.
  20911. *
  20912. * @static
  20913. * @memberOf _
  20914. * @since 4.0.0
  20915. * @category Array
  20916. * @param {Array} array The array to convert.
  20917. * @param {string} [separator=','] The element separator.
  20918. * @returns {string} Returns the joined string.
  20919. * @example
  20920. *
  20921. * _.join(['a', 'b', 'c'], '~');
  20922. * // => 'a~b~c'
  20923. */
  20924. function join(array, separator) {
  20925. return array == null ? '' : nativeJoin.call(array, separator);
  20926. }
  20927. /**
  20928. * Gets the last element of `array`.
  20929. *
  20930. * @static
  20931. * @memberOf _
  20932. * @since 0.1.0
  20933. * @category Array
  20934. * @param {Array} array The array to query.
  20935. * @returns {*} Returns the last element of `array`.
  20936. * @example
  20937. *
  20938. * _.last([1, 2, 3]);
  20939. * // => 3
  20940. */
  20941. function last(array) {
  20942. var length = array == null ? 0 : array.length;
  20943. return length ? array[length - 1] : undefined;
  20944. }
  20945. /**
  20946. * This method is like `_.indexOf` except that it iterates over elements of
  20947. * `array` from right to left.
  20948. *
  20949. * @static
  20950. * @memberOf _
  20951. * @since 0.1.0
  20952. * @category Array
  20953. * @param {Array} array The array to inspect.
  20954. * @param {*} value The value to search for.
  20955. * @param {number} [fromIndex=array.length-1] The index to search from.
  20956. * @returns {number} Returns the index of the matched value, else `-1`.
  20957. * @example
  20958. *
  20959. * _.lastIndexOf([1, 2, 1, 2], 2);
  20960. * // => 3
  20961. *
  20962. * // Search from the `fromIndex`.
  20963. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  20964. * // => 1
  20965. */
  20966. function lastIndexOf(array, value, fromIndex) {
  20967. var length = array == null ? 0 : array.length;
  20968. if (!length) {
  20969. return -1;
  20970. }
  20971. var index = length;
  20972. if (fromIndex !== undefined) {
  20973. index = toInteger(fromIndex);
  20974. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  20975. }
  20976. return value === value
  20977. ? strictLastIndexOf(array, value, index)
  20978. : baseFindIndex(array, baseIsNaN, index, true);
  20979. }
  20980. /**
  20981. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  20982. * element from the end is returned.
  20983. *
  20984. * @static
  20985. * @memberOf _
  20986. * @since 4.11.0
  20987. * @category Array
  20988. * @param {Array} array The array to query.
  20989. * @param {number} [n=0] The index of the element to return.
  20990. * @returns {*} Returns the nth element of `array`.
  20991. * @example
  20992. *
  20993. * var array = ['a', 'b', 'c', 'd'];
  20994. *
  20995. * _.nth(array, 1);
  20996. * // => 'b'
  20997. *
  20998. * _.nth(array, -2);
  20999. * // => 'c';
  21000. */
  21001. function nth(array, n) {
  21002. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  21003. }
  21004. /**
  21005. * Removes all given values from `array` using
  21006. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  21007. * for equality comparisons.
  21008. *
  21009. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  21010. * to remove elements from an array by predicate.
  21011. *
  21012. * @static
  21013. * @memberOf _
  21014. * @since 2.0.0
  21015. * @category Array
  21016. * @param {Array} array The array to modify.
  21017. * @param {...*} [values] The values to remove.
  21018. * @returns {Array} Returns `array`.
  21019. * @example
  21020. *
  21021. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  21022. *
  21023. * _.pull(array, 'a', 'c');
  21024. * console.log(array);
  21025. * // => ['b', 'b']
  21026. */
  21027. var pull = baseRest(pullAll);
  21028. /**
  21029. * This method is like `_.pull` except that it accepts an array of values to remove.
  21030. *
  21031. * **Note:** Unlike `_.difference`, this method mutates `array`.
  21032. *
  21033. * @static
  21034. * @memberOf _
  21035. * @since 4.0.0
  21036. * @category Array
  21037. * @param {Array} array The array to modify.
  21038. * @param {Array} values The values to remove.
  21039. * @returns {Array} Returns `array`.
  21040. * @example
  21041. *
  21042. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  21043. *
  21044. * _.pullAll(array, ['a', 'c']);
  21045. * console.log(array);
  21046. * // => ['b', 'b']
  21047. */
  21048. function pullAll(array, values) {
  21049. return (array && array.length && values && values.length)
  21050. ? basePullAll(array, values)
  21051. : array;
  21052. }
  21053. /**
  21054. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  21055. * invoked for each element of `array` and `values` to generate the criterion
  21056. * by which they're compared. The iteratee is invoked with one argument: (value).
  21057. *
  21058. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  21059. *
  21060. * @static
  21061. * @memberOf _
  21062. * @since 4.0.0
  21063. * @category Array
  21064. * @param {Array} array The array to modify.
  21065. * @param {Array} values The values to remove.
  21066. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21067. * @returns {Array} Returns `array`.
  21068. * @example
  21069. *
  21070. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  21071. *
  21072. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  21073. * console.log(array);
  21074. * // => [{ 'x': 2 }]
  21075. */
  21076. function pullAllBy(array, values, iteratee) {
  21077. return (array && array.length && values && values.length)
  21078. ? basePullAll(array, values, getIteratee(iteratee, 2))
  21079. : array;
  21080. }
  21081. /**
  21082. * This method is like `_.pullAll` except that it accepts `comparator` which
  21083. * is invoked to compare elements of `array` to `values`. The comparator is
  21084. * invoked with two arguments: (arrVal, othVal).
  21085. *
  21086. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  21087. *
  21088. * @static
  21089. * @memberOf _
  21090. * @since 4.6.0
  21091. * @category Array
  21092. * @param {Array} array The array to modify.
  21093. * @param {Array} values The values to remove.
  21094. * @param {Function} [comparator] The comparator invoked per element.
  21095. * @returns {Array} Returns `array`.
  21096. * @example
  21097. *
  21098. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  21099. *
  21100. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  21101. * console.log(array);
  21102. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  21103. */
  21104. function pullAllWith(array, values, comparator) {
  21105. return (array && array.length && values && values.length)
  21106. ? basePullAll(array, values, undefined, comparator)
  21107. : array;
  21108. }
  21109. /**
  21110. * Removes elements from `array` corresponding to `indexes` and returns an
  21111. * array of removed elements.
  21112. *
  21113. * **Note:** Unlike `_.at`, this method mutates `array`.
  21114. *
  21115. * @static
  21116. * @memberOf _
  21117. * @since 3.0.0
  21118. * @category Array
  21119. * @param {Array} array The array to modify.
  21120. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  21121. * @returns {Array} Returns the new array of removed elements.
  21122. * @example
  21123. *
  21124. * var array = ['a', 'b', 'c', 'd'];
  21125. * var pulled = _.pullAt(array, [1, 3]);
  21126. *
  21127. * console.log(array);
  21128. * // => ['a', 'c']
  21129. *
  21130. * console.log(pulled);
  21131. * // => ['b', 'd']
  21132. */
  21133. var pullAt = flatRest(function(array, indexes) {
  21134. var length = array == null ? 0 : array.length,
  21135. result = baseAt(array, indexes);
  21136. basePullAt(array, arrayMap(indexes, function(index) {
  21137. return isIndex(index, length) ? +index : index;
  21138. }).sort(compareAscending));
  21139. return result;
  21140. });
  21141. /**
  21142. * Removes all elements from `array` that `predicate` returns truthy for
  21143. * and returns an array of the removed elements. The predicate is invoked
  21144. * with three arguments: (value, index, array).
  21145. *
  21146. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  21147. * to pull elements from an array by value.
  21148. *
  21149. * @static
  21150. * @memberOf _
  21151. * @since 2.0.0
  21152. * @category Array
  21153. * @param {Array} array The array to modify.
  21154. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  21155. * @returns {Array} Returns the new array of removed elements.
  21156. * @example
  21157. *
  21158. * var array = [1, 2, 3, 4];
  21159. * var evens = _.remove(array, function(n) {
  21160. * return n % 2 == 0;
  21161. * });
  21162. *
  21163. * console.log(array);
  21164. * // => [1, 3]
  21165. *
  21166. * console.log(evens);
  21167. * // => [2, 4]
  21168. */
  21169. function remove(array, predicate) {
  21170. var result = [];
  21171. if (!(array && array.length)) {
  21172. return result;
  21173. }
  21174. var index = -1,
  21175. indexes = [],
  21176. length = array.length;
  21177. predicate = getIteratee(predicate, 3);
  21178. while (++index < length) {
  21179. var value = array[index];
  21180. if (predicate(value, index, array)) {
  21181. result.push(value);
  21182. indexes.push(index);
  21183. }
  21184. }
  21185. basePullAt(array, indexes);
  21186. return result;
  21187. }
  21188. /**
  21189. * Reverses `array` so that the first element becomes the last, the second
  21190. * element becomes the second to last, and so on.
  21191. *
  21192. * **Note:** This method mutates `array` and is based on
  21193. * [`Array#reverse`](https://mdn.io/Array/reverse).
  21194. *
  21195. * @static
  21196. * @memberOf _
  21197. * @since 4.0.0
  21198. * @category Array
  21199. * @param {Array} array The array to modify.
  21200. * @returns {Array} Returns `array`.
  21201. * @example
  21202. *
  21203. * var array = [1, 2, 3];
  21204. *
  21205. * _.reverse(array);
  21206. * // => [3, 2, 1]
  21207. *
  21208. * console.log(array);
  21209. * // => [3, 2, 1]
  21210. */
  21211. function reverse(array) {
  21212. return array == null ? array : nativeReverse.call(array);
  21213. }
  21214. /**
  21215. * Creates a slice of `array` from `start` up to, but not including, `end`.
  21216. *
  21217. * **Note:** This method is used instead of
  21218. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  21219. * returned.
  21220. *
  21221. * @static
  21222. * @memberOf _
  21223. * @since 3.0.0
  21224. * @category Array
  21225. * @param {Array} array The array to slice.
  21226. * @param {number} [start=0] The start position.
  21227. * @param {number} [end=array.length] The end position.
  21228. * @returns {Array} Returns the slice of `array`.
  21229. */
  21230. function slice(array, start, end) {
  21231. var length = array == null ? 0 : array.length;
  21232. if (!length) {
  21233. return [];
  21234. }
  21235. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  21236. start = 0;
  21237. end = length;
  21238. }
  21239. else {
  21240. start = start == null ? 0 : toInteger(start);
  21241. end = end === undefined ? length : toInteger(end);
  21242. }
  21243. return baseSlice(array, start, end);
  21244. }
  21245. /**
  21246. * Uses a binary search to determine the lowest index at which `value`
  21247. * should be inserted into `array` in order to maintain its sort order.
  21248. *
  21249. * @static
  21250. * @memberOf _
  21251. * @since 0.1.0
  21252. * @category Array
  21253. * @param {Array} array The sorted array to inspect.
  21254. * @param {*} value The value to evaluate.
  21255. * @returns {number} Returns the index at which `value` should be inserted
  21256. * into `array`.
  21257. * @example
  21258. *
  21259. * _.sortedIndex([30, 50], 40);
  21260. * // => 1
  21261. */
  21262. function sortedIndex(array, value) {
  21263. return baseSortedIndex(array, value);
  21264. }
  21265. /**
  21266. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  21267. * which is invoked for `value` and each element of `array` to compute their
  21268. * sort ranking. The iteratee is invoked with one argument: (value).
  21269. *
  21270. * @static
  21271. * @memberOf _
  21272. * @since 4.0.0
  21273. * @category Array
  21274. * @param {Array} array The sorted array to inspect.
  21275. * @param {*} value The value to evaluate.
  21276. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21277. * @returns {number} Returns the index at which `value` should be inserted
  21278. * into `array`.
  21279. * @example
  21280. *
  21281. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  21282. *
  21283. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  21284. * // => 0
  21285. *
  21286. * // The `_.property` iteratee shorthand.
  21287. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  21288. * // => 0
  21289. */
  21290. function sortedIndexBy(array, value, iteratee) {
  21291. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  21292. }
  21293. /**
  21294. * This method is like `_.indexOf` except that it performs a binary
  21295. * search on a sorted `array`.
  21296. *
  21297. * @static
  21298. * @memberOf _
  21299. * @since 4.0.0
  21300. * @category Array
  21301. * @param {Array} array The array to inspect.
  21302. * @param {*} value The value to search for.
  21303. * @returns {number} Returns the index of the matched value, else `-1`.
  21304. * @example
  21305. *
  21306. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  21307. * // => 1
  21308. */
  21309. function sortedIndexOf(array, value) {
  21310. var length = array == null ? 0 : array.length;
  21311. if (length) {
  21312. var index = baseSortedIndex(array, value);
  21313. if (index < length && eq(array[index], value)) {
  21314. return index;
  21315. }
  21316. }
  21317. return -1;
  21318. }
  21319. /**
  21320. * This method is like `_.sortedIndex` except that it returns the highest
  21321. * index at which `value` should be inserted into `array` in order to
  21322. * maintain its sort order.
  21323. *
  21324. * @static
  21325. * @memberOf _
  21326. * @since 3.0.0
  21327. * @category Array
  21328. * @param {Array} array The sorted array to inspect.
  21329. * @param {*} value The value to evaluate.
  21330. * @returns {number} Returns the index at which `value` should be inserted
  21331. * into `array`.
  21332. * @example
  21333. *
  21334. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  21335. * // => 4
  21336. */
  21337. function sortedLastIndex(array, value) {
  21338. return baseSortedIndex(array, value, true);
  21339. }
  21340. /**
  21341. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  21342. * which is invoked for `value` and each element of `array` to compute their
  21343. * sort ranking. The iteratee is invoked with one argument: (value).
  21344. *
  21345. * @static
  21346. * @memberOf _
  21347. * @since 4.0.0
  21348. * @category Array
  21349. * @param {Array} array The sorted array to inspect.
  21350. * @param {*} value The value to evaluate.
  21351. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21352. * @returns {number} Returns the index at which `value` should be inserted
  21353. * into `array`.
  21354. * @example
  21355. *
  21356. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  21357. *
  21358. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  21359. * // => 1
  21360. *
  21361. * // The `_.property` iteratee shorthand.
  21362. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  21363. * // => 1
  21364. */
  21365. function sortedLastIndexBy(array, value, iteratee) {
  21366. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  21367. }
  21368. /**
  21369. * This method is like `_.lastIndexOf` except that it performs a binary
  21370. * search on a sorted `array`.
  21371. *
  21372. * @static
  21373. * @memberOf _
  21374. * @since 4.0.0
  21375. * @category Array
  21376. * @param {Array} array The array to inspect.
  21377. * @param {*} value The value to search for.
  21378. * @returns {number} Returns the index of the matched value, else `-1`.
  21379. * @example
  21380. *
  21381. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  21382. * // => 3
  21383. */
  21384. function sortedLastIndexOf(array, value) {
  21385. var length = array == null ? 0 : array.length;
  21386. if (length) {
  21387. var index = baseSortedIndex(array, value, true) - 1;
  21388. if (eq(array[index], value)) {
  21389. return index;
  21390. }
  21391. }
  21392. return -1;
  21393. }
  21394. /**
  21395. * This method is like `_.uniq` except that it's designed and optimized
  21396. * for sorted arrays.
  21397. *
  21398. * @static
  21399. * @memberOf _
  21400. * @since 4.0.0
  21401. * @category Array
  21402. * @param {Array} array The array to inspect.
  21403. * @returns {Array} Returns the new duplicate free array.
  21404. * @example
  21405. *
  21406. * _.sortedUniq([1, 1, 2]);
  21407. * // => [1, 2]
  21408. */
  21409. function sortedUniq(array) {
  21410. return (array && array.length)
  21411. ? baseSortedUniq(array)
  21412. : [];
  21413. }
  21414. /**
  21415. * This method is like `_.uniqBy` except that it's designed and optimized
  21416. * for sorted arrays.
  21417. *
  21418. * @static
  21419. * @memberOf _
  21420. * @since 4.0.0
  21421. * @category Array
  21422. * @param {Array} array The array to inspect.
  21423. * @param {Function} [iteratee] The iteratee invoked per element.
  21424. * @returns {Array} Returns the new duplicate free array.
  21425. * @example
  21426. *
  21427. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  21428. * // => [1.1, 2.3]
  21429. */
  21430. function sortedUniqBy(array, iteratee) {
  21431. return (array && array.length)
  21432. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  21433. : [];
  21434. }
  21435. /**
  21436. * Gets all but the first element of `array`.
  21437. *
  21438. * @static
  21439. * @memberOf _
  21440. * @since 4.0.0
  21441. * @category Array
  21442. * @param {Array} array The array to query.
  21443. * @returns {Array} Returns the slice of `array`.
  21444. * @example
  21445. *
  21446. * _.tail([1, 2, 3]);
  21447. * // => [2, 3]
  21448. */
  21449. function tail(array) {
  21450. var length = array == null ? 0 : array.length;
  21451. return length ? baseSlice(array, 1, length) : [];
  21452. }
  21453. /**
  21454. * Creates a slice of `array` with `n` elements taken from the beginning.
  21455. *
  21456. * @static
  21457. * @memberOf _
  21458. * @since 0.1.0
  21459. * @category Array
  21460. * @param {Array} array The array to query.
  21461. * @param {number} [n=1] The number of elements to take.
  21462. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  21463. * @returns {Array} Returns the slice of `array`.
  21464. * @example
  21465. *
  21466. * _.take([1, 2, 3]);
  21467. * // => [1]
  21468. *
  21469. * _.take([1, 2, 3], 2);
  21470. * // => [1, 2]
  21471. *
  21472. * _.take([1, 2, 3], 5);
  21473. * // => [1, 2, 3]
  21474. *
  21475. * _.take([1, 2, 3], 0);
  21476. * // => []
  21477. */
  21478. function take(array, n, guard) {
  21479. if (!(array && array.length)) {
  21480. return [];
  21481. }
  21482. n = (guard || n === undefined) ? 1 : toInteger(n);
  21483. return baseSlice(array, 0, n < 0 ? 0 : n);
  21484. }
  21485. /**
  21486. * Creates a slice of `array` with `n` elements taken from the end.
  21487. *
  21488. * @static
  21489. * @memberOf _
  21490. * @since 3.0.0
  21491. * @category Array
  21492. * @param {Array} array The array to query.
  21493. * @param {number} [n=1] The number of elements to take.
  21494. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  21495. * @returns {Array} Returns the slice of `array`.
  21496. * @example
  21497. *
  21498. * _.takeRight([1, 2, 3]);
  21499. * // => [3]
  21500. *
  21501. * _.takeRight([1, 2, 3], 2);
  21502. * // => [2, 3]
  21503. *
  21504. * _.takeRight([1, 2, 3], 5);
  21505. * // => [1, 2, 3]
  21506. *
  21507. * _.takeRight([1, 2, 3], 0);
  21508. * // => []
  21509. */
  21510. function takeRight(array, n, guard) {
  21511. var length = array == null ? 0 : array.length;
  21512. if (!length) {
  21513. return [];
  21514. }
  21515. n = (guard || n === undefined) ? 1 : toInteger(n);
  21516. n = length - n;
  21517. return baseSlice(array, n < 0 ? 0 : n, length);
  21518. }
  21519. /**
  21520. * Creates a slice of `array` with elements taken from the end. Elements are
  21521. * taken until `predicate` returns falsey. The predicate is invoked with
  21522. * three arguments: (value, index, array).
  21523. *
  21524. * @static
  21525. * @memberOf _
  21526. * @since 3.0.0
  21527. * @category Array
  21528. * @param {Array} array The array to query.
  21529. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  21530. * @returns {Array} Returns the slice of `array`.
  21531. * @example
  21532. *
  21533. * var users = [
  21534. * { 'user': 'barney', 'active': true },
  21535. * { 'user': 'fred', 'active': false },
  21536. * { 'user': 'pebbles', 'active': false }
  21537. * ];
  21538. *
  21539. * _.takeRightWhile(users, function(o) { return !o.active; });
  21540. * // => objects for ['fred', 'pebbles']
  21541. *
  21542. * // The `_.matches` iteratee shorthand.
  21543. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  21544. * // => objects for ['pebbles']
  21545. *
  21546. * // The `_.matchesProperty` iteratee shorthand.
  21547. * _.takeRightWhile(users, ['active', false]);
  21548. * // => objects for ['fred', 'pebbles']
  21549. *
  21550. * // The `_.property` iteratee shorthand.
  21551. * _.takeRightWhile(users, 'active');
  21552. * // => []
  21553. */
  21554. function takeRightWhile(array, predicate) {
  21555. return (array && array.length)
  21556. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  21557. : [];
  21558. }
  21559. /**
  21560. * Creates a slice of `array` with elements taken from the beginning. Elements
  21561. * are taken until `predicate` returns falsey. The predicate is invoked with
  21562. * three arguments: (value, index, array).
  21563. *
  21564. * @static
  21565. * @memberOf _
  21566. * @since 3.0.0
  21567. * @category Array
  21568. * @param {Array} array The array to query.
  21569. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  21570. * @returns {Array} Returns the slice of `array`.
  21571. * @example
  21572. *
  21573. * var users = [
  21574. * { 'user': 'barney', 'active': false },
  21575. * { 'user': 'fred', 'active': false },
  21576. * { 'user': 'pebbles', 'active': true }
  21577. * ];
  21578. *
  21579. * _.takeWhile(users, function(o) { return !o.active; });
  21580. * // => objects for ['barney', 'fred']
  21581. *
  21582. * // The `_.matches` iteratee shorthand.
  21583. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  21584. * // => objects for ['barney']
  21585. *
  21586. * // The `_.matchesProperty` iteratee shorthand.
  21587. * _.takeWhile(users, ['active', false]);
  21588. * // => objects for ['barney', 'fred']
  21589. *
  21590. * // The `_.property` iteratee shorthand.
  21591. * _.takeWhile(users, 'active');
  21592. * // => []
  21593. */
  21594. function takeWhile(array, predicate) {
  21595. return (array && array.length)
  21596. ? baseWhile(array, getIteratee(predicate, 3))
  21597. : [];
  21598. }
  21599. /**
  21600. * Creates an array of unique values, in order, from all given arrays using
  21601. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  21602. * for equality comparisons.
  21603. *
  21604. * @static
  21605. * @memberOf _
  21606. * @since 0.1.0
  21607. * @category Array
  21608. * @param {...Array} [arrays] The arrays to inspect.
  21609. * @returns {Array} Returns the new array of combined values.
  21610. * @example
  21611. *
  21612. * _.union([2], [1, 2]);
  21613. * // => [2, 1]
  21614. */
  21615. var union = baseRest(function(arrays) {
  21616. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  21617. });
  21618. /**
  21619. * This method is like `_.union` except that it accepts `iteratee` which is
  21620. * invoked for each element of each `arrays` to generate the criterion by
  21621. * which uniqueness is computed. Result values are chosen from the first
  21622. * array in which the value occurs. The iteratee is invoked with one argument:
  21623. * (value).
  21624. *
  21625. * @static
  21626. * @memberOf _
  21627. * @since 4.0.0
  21628. * @category Array
  21629. * @param {...Array} [arrays] The arrays to inspect.
  21630. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21631. * @returns {Array} Returns the new array of combined values.
  21632. * @example
  21633. *
  21634. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  21635. * // => [2.1, 1.2]
  21636. *
  21637. * // The `_.property` iteratee shorthand.
  21638. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  21639. * // => [{ 'x': 1 }, { 'x': 2 }]
  21640. */
  21641. var unionBy = baseRest(function(arrays) {
  21642. var iteratee = last(arrays);
  21643. if (isArrayLikeObject(iteratee)) {
  21644. iteratee = undefined;
  21645. }
  21646. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  21647. });
  21648. /**
  21649. * This method is like `_.union` except that it accepts `comparator` which
  21650. * is invoked to compare elements of `arrays`. Result values are chosen from
  21651. * the first array in which the value occurs. The comparator is invoked
  21652. * with two arguments: (arrVal, othVal).
  21653. *
  21654. * @static
  21655. * @memberOf _
  21656. * @since 4.0.0
  21657. * @category Array
  21658. * @param {...Array} [arrays] The arrays to inspect.
  21659. * @param {Function} [comparator] The comparator invoked per element.
  21660. * @returns {Array} Returns the new array of combined values.
  21661. * @example
  21662. *
  21663. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  21664. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  21665. *
  21666. * _.unionWith(objects, others, _.isEqual);
  21667. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  21668. */
  21669. var unionWith = baseRest(function(arrays) {
  21670. var comparator = last(arrays);
  21671. comparator = typeof comparator == 'function' ? comparator : undefined;
  21672. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  21673. });
  21674. /**
  21675. * Creates a duplicate-free version of an array, using
  21676. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  21677. * for equality comparisons, in which only the first occurrence of each element
  21678. * is kept. The order of result values is determined by the order they occur
  21679. * in the array.
  21680. *
  21681. * @static
  21682. * @memberOf _
  21683. * @since 0.1.0
  21684. * @category Array
  21685. * @param {Array} array The array to inspect.
  21686. * @returns {Array} Returns the new duplicate free array.
  21687. * @example
  21688. *
  21689. * _.uniq([2, 1, 2]);
  21690. * // => [2, 1]
  21691. */
  21692. function uniq(array) {
  21693. return (array && array.length) ? baseUniq(array) : [];
  21694. }
  21695. /**
  21696. * This method is like `_.uniq` except that it accepts `iteratee` which is
  21697. * invoked for each element in `array` to generate the criterion by which
  21698. * uniqueness is computed. The order of result values is determined by the
  21699. * order they occur in the array. The iteratee is invoked with one argument:
  21700. * (value).
  21701. *
  21702. * @static
  21703. * @memberOf _
  21704. * @since 4.0.0
  21705. * @category Array
  21706. * @param {Array} array The array to inspect.
  21707. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21708. * @returns {Array} Returns the new duplicate free array.
  21709. * @example
  21710. *
  21711. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  21712. * // => [2.1, 1.2]
  21713. *
  21714. * // The `_.property` iteratee shorthand.
  21715. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  21716. * // => [{ 'x': 1 }, { 'x': 2 }]
  21717. */
  21718. function uniqBy(array, iteratee) {
  21719. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  21720. }
  21721. /**
  21722. * This method is like `_.uniq` except that it accepts `comparator` which
  21723. * is invoked to compare elements of `array`. The order of result values is
  21724. * determined by the order they occur in the array.The comparator is invoked
  21725. * with two arguments: (arrVal, othVal).
  21726. *
  21727. * @static
  21728. * @memberOf _
  21729. * @since 4.0.0
  21730. * @category Array
  21731. * @param {Array} array The array to inspect.
  21732. * @param {Function} [comparator] The comparator invoked per element.
  21733. * @returns {Array} Returns the new duplicate free array.
  21734. * @example
  21735. *
  21736. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  21737. *
  21738. * _.uniqWith(objects, _.isEqual);
  21739. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  21740. */
  21741. function uniqWith(array, comparator) {
  21742. comparator = typeof comparator == 'function' ? comparator : undefined;
  21743. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  21744. }
  21745. /**
  21746. * This method is like `_.zip` except that it accepts an array of grouped
  21747. * elements and creates an array regrouping the elements to their pre-zip
  21748. * configuration.
  21749. *
  21750. * @static
  21751. * @memberOf _
  21752. * @since 1.2.0
  21753. * @category Array
  21754. * @param {Array} array The array of grouped elements to process.
  21755. * @returns {Array} Returns the new array of regrouped elements.
  21756. * @example
  21757. *
  21758. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  21759. * // => [['a', 1, true], ['b', 2, false]]
  21760. *
  21761. * _.unzip(zipped);
  21762. * // => [['a', 'b'], [1, 2], [true, false]]
  21763. */
  21764. function unzip(array) {
  21765. if (!(array && array.length)) {
  21766. return [];
  21767. }
  21768. var length = 0;
  21769. array = arrayFilter(array, function(group) {
  21770. if (isArrayLikeObject(group)) {
  21771. length = nativeMax(group.length, length);
  21772. return true;
  21773. }
  21774. });
  21775. return baseTimes(length, function(index) {
  21776. return arrayMap(array, baseProperty(index));
  21777. });
  21778. }
  21779. /**
  21780. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  21781. * how regrouped values should be combined. The iteratee is invoked with the
  21782. * elements of each group: (...group).
  21783. *
  21784. * @static
  21785. * @memberOf _
  21786. * @since 3.8.0
  21787. * @category Array
  21788. * @param {Array} array The array of grouped elements to process.
  21789. * @param {Function} [iteratee=_.identity] The function to combine
  21790. * regrouped values.
  21791. * @returns {Array} Returns the new array of regrouped elements.
  21792. * @example
  21793. *
  21794. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  21795. * // => [[1, 10, 100], [2, 20, 200]]
  21796. *
  21797. * _.unzipWith(zipped, _.add);
  21798. * // => [3, 30, 300]
  21799. */
  21800. function unzipWith(array, iteratee) {
  21801. if (!(array && array.length)) {
  21802. return [];
  21803. }
  21804. var result = unzip(array);
  21805. if (iteratee == null) {
  21806. return result;
  21807. }
  21808. return arrayMap(result, function(group) {
  21809. return apply(iteratee, undefined, group);
  21810. });
  21811. }
  21812. /**
  21813. * Creates an array excluding all given values using
  21814. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  21815. * for equality comparisons.
  21816. *
  21817. * **Note:** Unlike `_.pull`, this method returns a new array.
  21818. *
  21819. * @static
  21820. * @memberOf _
  21821. * @since 0.1.0
  21822. * @category Array
  21823. * @param {Array} array The array to inspect.
  21824. * @param {...*} [values] The values to exclude.
  21825. * @returns {Array} Returns the new array of filtered values.
  21826. * @see _.difference, _.xor
  21827. * @example
  21828. *
  21829. * _.without([2, 1, 2, 3], 1, 2);
  21830. * // => [3]
  21831. */
  21832. var without = baseRest(function(array, values) {
  21833. return isArrayLikeObject(array)
  21834. ? baseDifference(array, values)
  21835. : [];
  21836. });
  21837. /**
  21838. * Creates an array of unique values that is the
  21839. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  21840. * of the given arrays. The order of result values is determined by the order
  21841. * they occur in the arrays.
  21842. *
  21843. * @static
  21844. * @memberOf _
  21845. * @since 2.4.0
  21846. * @category Array
  21847. * @param {...Array} [arrays] The arrays to inspect.
  21848. * @returns {Array} Returns the new array of filtered values.
  21849. * @see _.difference, _.without
  21850. * @example
  21851. *
  21852. * _.xor([2, 1], [2, 3]);
  21853. * // => [1, 3]
  21854. */
  21855. var xor = baseRest(function(arrays) {
  21856. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  21857. });
  21858. /**
  21859. * This method is like `_.xor` except that it accepts `iteratee` which is
  21860. * invoked for each element of each `arrays` to generate the criterion by
  21861. * which by which they're compared. The order of result values is determined
  21862. * by the order they occur in the arrays. The iteratee is invoked with one
  21863. * argument: (value).
  21864. *
  21865. * @static
  21866. * @memberOf _
  21867. * @since 4.0.0
  21868. * @category Array
  21869. * @param {...Array} [arrays] The arrays to inspect.
  21870. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  21871. * @returns {Array} Returns the new array of filtered values.
  21872. * @example
  21873. *
  21874. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  21875. * // => [1.2, 3.4]
  21876. *
  21877. * // The `_.property` iteratee shorthand.
  21878. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  21879. * // => [{ 'x': 2 }]
  21880. */
  21881. var xorBy = baseRest(function(arrays) {
  21882. var iteratee = last(arrays);
  21883. if (isArrayLikeObject(iteratee)) {
  21884. iteratee = undefined;
  21885. }
  21886. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  21887. });
  21888. /**
  21889. * This method is like `_.xor` except that it accepts `comparator` which is
  21890. * invoked to compare elements of `arrays`. The order of result values is
  21891. * determined by the order they occur in the arrays. The comparator is invoked
  21892. * with two arguments: (arrVal, othVal).
  21893. *
  21894. * @static
  21895. * @memberOf _
  21896. * @since 4.0.0
  21897. * @category Array
  21898. * @param {...Array} [arrays] The arrays to inspect.
  21899. * @param {Function} [comparator] The comparator invoked per element.
  21900. * @returns {Array} Returns the new array of filtered values.
  21901. * @example
  21902. *
  21903. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  21904. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  21905. *
  21906. * _.xorWith(objects, others, _.isEqual);
  21907. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  21908. */
  21909. var xorWith = baseRest(function(arrays) {
  21910. var comparator = last(arrays);
  21911. comparator = typeof comparator == 'function' ? comparator : undefined;
  21912. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  21913. });
  21914. /**
  21915. * Creates an array of grouped elements, the first of which contains the
  21916. * first elements of the given arrays, the second of which contains the
  21917. * second elements of the given arrays, and so on.
  21918. *
  21919. * @static
  21920. * @memberOf _
  21921. * @since 0.1.0
  21922. * @category Array
  21923. * @param {...Array} [arrays] The arrays to process.
  21924. * @returns {Array} Returns the new array of grouped elements.
  21925. * @example
  21926. *
  21927. * _.zip(['a', 'b'], [1, 2], [true, false]);
  21928. * // => [['a', 1, true], ['b', 2, false]]
  21929. */
  21930. var zip = baseRest(unzip);
  21931. /**
  21932. * This method is like `_.fromPairs` except that it accepts two arrays,
  21933. * one of property identifiers and one of corresponding values.
  21934. *
  21935. * @static
  21936. * @memberOf _
  21937. * @since 0.4.0
  21938. * @category Array
  21939. * @param {Array} [props=[]] The property identifiers.
  21940. * @param {Array} [values=[]] The property values.
  21941. * @returns {Object} Returns the new object.
  21942. * @example
  21943. *
  21944. * _.zipObject(['a', 'b'], [1, 2]);
  21945. * // => { 'a': 1, 'b': 2 }
  21946. */
  21947. function zipObject(props, values) {
  21948. return baseZipObject(props || [], values || [], assignValue);
  21949. }
  21950. /**
  21951. * This method is like `_.zipObject` except that it supports property paths.
  21952. *
  21953. * @static
  21954. * @memberOf _
  21955. * @since 4.1.0
  21956. * @category Array
  21957. * @param {Array} [props=[]] The property identifiers.
  21958. * @param {Array} [values=[]] The property values.
  21959. * @returns {Object} Returns the new object.
  21960. * @example
  21961. *
  21962. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  21963. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  21964. */
  21965. function zipObjectDeep(props, values) {
  21966. return baseZipObject(props || [], values || [], baseSet);
  21967. }
  21968. /**
  21969. * This method is like `_.zip` except that it accepts `iteratee` to specify
  21970. * how grouped values should be combined. The iteratee is invoked with the
  21971. * elements of each group: (...group).
  21972. *
  21973. * @static
  21974. * @memberOf _
  21975. * @since 3.8.0
  21976. * @category Array
  21977. * @param {...Array} [arrays] The arrays to process.
  21978. * @param {Function} [iteratee=_.identity] The function to combine
  21979. * grouped values.
  21980. * @returns {Array} Returns the new array of grouped elements.
  21981. * @example
  21982. *
  21983. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  21984. * return a + b + c;
  21985. * });
  21986. * // => [111, 222]
  21987. */
  21988. var zipWith = baseRest(function(arrays) {
  21989. var length = arrays.length,
  21990. iteratee = length > 1 ? arrays[length - 1] : undefined;
  21991. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  21992. return unzipWith(arrays, iteratee);
  21993. });
  21994. /*------------------------------------------------------------------------*/
  21995. /**
  21996. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  21997. * chain sequences enabled. The result of such sequences must be unwrapped
  21998. * with `_#value`.
  21999. *
  22000. * @static
  22001. * @memberOf _
  22002. * @since 1.3.0
  22003. * @category Seq
  22004. * @param {*} value The value to wrap.
  22005. * @returns {Object} Returns the new `lodash` wrapper instance.
  22006. * @example
  22007. *
  22008. * var users = [
  22009. * { 'user': 'barney', 'age': 36 },
  22010. * { 'user': 'fred', 'age': 40 },
  22011. * { 'user': 'pebbles', 'age': 1 }
  22012. * ];
  22013. *
  22014. * var youngest = _
  22015. * .chain(users)
  22016. * .sortBy('age')
  22017. * .map(function(o) {
  22018. * return o.user + ' is ' + o.age;
  22019. * })
  22020. * .head()
  22021. * .value();
  22022. * // => 'pebbles is 1'
  22023. */
  22024. function chain(value) {
  22025. var result = lodash(value);
  22026. result.__chain__ = true;
  22027. return result;
  22028. }
  22029. /**
  22030. * This method invokes `interceptor` and returns `value`. The interceptor
  22031. * is invoked with one argument; (value). The purpose of this method is to
  22032. * "tap into" a method chain sequence in order to modify intermediate results.
  22033. *
  22034. * @static
  22035. * @memberOf _
  22036. * @since 0.1.0
  22037. * @category Seq
  22038. * @param {*} value The value to provide to `interceptor`.
  22039. * @param {Function} interceptor The function to invoke.
  22040. * @returns {*} Returns `value`.
  22041. * @example
  22042. *
  22043. * _([1, 2, 3])
  22044. * .tap(function(array) {
  22045. * // Mutate input array.
  22046. * array.pop();
  22047. * })
  22048. * .reverse()
  22049. * .value();
  22050. * // => [2, 1]
  22051. */
  22052. function tap(value, interceptor) {
  22053. interceptor(value);
  22054. return value;
  22055. }
  22056. /**
  22057. * This method is like `_.tap` except that it returns the result of `interceptor`.
  22058. * The purpose of this method is to "pass thru" values replacing intermediate
  22059. * results in a method chain sequence.
  22060. *
  22061. * @static
  22062. * @memberOf _
  22063. * @since 3.0.0
  22064. * @category Seq
  22065. * @param {*} value The value to provide to `interceptor`.
  22066. * @param {Function} interceptor The function to invoke.
  22067. * @returns {*} Returns the result of `interceptor`.
  22068. * @example
  22069. *
  22070. * _(' abc ')
  22071. * .chain()
  22072. * .trim()
  22073. * .thru(function(value) {
  22074. * return [value];
  22075. * })
  22076. * .value();
  22077. * // => ['abc']
  22078. */
  22079. function thru(value, interceptor) {
  22080. return interceptor(value);
  22081. }
  22082. /**
  22083. * This method is the wrapper version of `_.at`.
  22084. *
  22085. * @name at
  22086. * @memberOf _
  22087. * @since 1.0.0
  22088. * @category Seq
  22089. * @param {...(string|string[])} [paths] The property paths to pick.
  22090. * @returns {Object} Returns the new `lodash` wrapper instance.
  22091. * @example
  22092. *
  22093. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  22094. *
  22095. * _(object).at(['a[0].b.c', 'a[1]']).value();
  22096. * // => [3, 4]
  22097. */
  22098. var wrapperAt = flatRest(function(paths) {
  22099. var length = paths.length,
  22100. start = length ? paths[0] : 0,
  22101. value = this.__wrapped__,
  22102. interceptor = function(object) { return baseAt(object, paths); };
  22103. if (length > 1 || this.__actions__.length ||
  22104. !(value instanceof LazyWrapper) || !isIndex(start)) {
  22105. return this.thru(interceptor);
  22106. }
  22107. value = value.slice(start, +start + (length ? 1 : 0));
  22108. value.__actions__.push({
  22109. 'func': thru,
  22110. 'args': [interceptor],
  22111. 'thisArg': undefined
  22112. });
  22113. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  22114. if (length && !array.length) {
  22115. array.push(undefined);
  22116. }
  22117. return array;
  22118. });
  22119. });
  22120. /**
  22121. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  22122. *
  22123. * @name chain
  22124. * @memberOf _
  22125. * @since 0.1.0
  22126. * @category Seq
  22127. * @returns {Object} Returns the new `lodash` wrapper instance.
  22128. * @example
  22129. *
  22130. * var users = [
  22131. * { 'user': 'barney', 'age': 36 },
  22132. * { 'user': 'fred', 'age': 40 }
  22133. * ];
  22134. *
  22135. * // A sequence without explicit chaining.
  22136. * _(users).head();
  22137. * // => { 'user': 'barney', 'age': 36 }
  22138. *
  22139. * // A sequence with explicit chaining.
  22140. * _(users)
  22141. * .chain()
  22142. * .head()
  22143. * .pick('user')
  22144. * .value();
  22145. * // => { 'user': 'barney' }
  22146. */
  22147. function wrapperChain() {
  22148. return chain(this);
  22149. }
  22150. /**
  22151. * Executes the chain sequence and returns the wrapped result.
  22152. *
  22153. * @name commit
  22154. * @memberOf _
  22155. * @since 3.2.0
  22156. * @category Seq
  22157. * @returns {Object} Returns the new `lodash` wrapper instance.
  22158. * @example
  22159. *
  22160. * var array = [1, 2];
  22161. * var wrapped = _(array).push(3);
  22162. *
  22163. * console.log(array);
  22164. * // => [1, 2]
  22165. *
  22166. * wrapped = wrapped.commit();
  22167. * console.log(array);
  22168. * // => [1, 2, 3]
  22169. *
  22170. * wrapped.last();
  22171. * // => 3
  22172. *
  22173. * console.log(array);
  22174. * // => [1, 2, 3]
  22175. */
  22176. function wrapperCommit() {
  22177. return new LodashWrapper(this.value(), this.__chain__);
  22178. }
  22179. /**
  22180. * Gets the next value on a wrapped object following the
  22181. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  22182. *
  22183. * @name next
  22184. * @memberOf _
  22185. * @since 4.0.0
  22186. * @category Seq
  22187. * @returns {Object} Returns the next iterator value.
  22188. * @example
  22189. *
  22190. * var wrapped = _([1, 2]);
  22191. *
  22192. * wrapped.next();
  22193. * // => { 'done': false, 'value': 1 }
  22194. *
  22195. * wrapped.next();
  22196. * // => { 'done': false, 'value': 2 }
  22197. *
  22198. * wrapped.next();
  22199. * // => { 'done': true, 'value': undefined }
  22200. */
  22201. function wrapperNext() {
  22202. if (this.__values__ === undefined) {
  22203. this.__values__ = toArray(this.value());
  22204. }
  22205. var done = this.__index__ >= this.__values__.length,
  22206. value = done ? undefined : this.__values__[this.__index__++];
  22207. return { 'done': done, 'value': value };
  22208. }
  22209. /**
  22210. * Enables the wrapper to be iterable.
  22211. *
  22212. * @name Symbol.iterator
  22213. * @memberOf _
  22214. * @since 4.0.0
  22215. * @category Seq
  22216. * @returns {Object} Returns the wrapper object.
  22217. * @example
  22218. *
  22219. * var wrapped = _([1, 2]);
  22220. *
  22221. * wrapped[Symbol.iterator]() === wrapped;
  22222. * // => true
  22223. *
  22224. * Array.from(wrapped);
  22225. * // => [1, 2]
  22226. */
  22227. function wrapperToIterator() {
  22228. return this;
  22229. }
  22230. /**
  22231. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  22232. *
  22233. * @name plant
  22234. * @memberOf _
  22235. * @since 3.2.0
  22236. * @category Seq
  22237. * @param {*} value The value to plant.
  22238. * @returns {Object} Returns the new `lodash` wrapper instance.
  22239. * @example
  22240. *
  22241. * function square(n) {
  22242. * return n * n;
  22243. * }
  22244. *
  22245. * var wrapped = _([1, 2]).map(square);
  22246. * var other = wrapped.plant([3, 4]);
  22247. *
  22248. * other.value();
  22249. * // => [9, 16]
  22250. *
  22251. * wrapped.value();
  22252. * // => [1, 4]
  22253. */
  22254. function wrapperPlant(value) {
  22255. var result,
  22256. parent = this;
  22257. while (parent instanceof baseLodash) {
  22258. var clone = wrapperClone(parent);
  22259. clone.__index__ = 0;
  22260. clone.__values__ = undefined;
  22261. if (result) {
  22262. previous.__wrapped__ = clone;
  22263. } else {
  22264. result = clone;
  22265. }
  22266. var previous = clone;
  22267. parent = parent.__wrapped__;
  22268. }
  22269. previous.__wrapped__ = value;
  22270. return result;
  22271. }
  22272. /**
  22273. * This method is the wrapper version of `_.reverse`.
  22274. *
  22275. * **Note:** This method mutates the wrapped array.
  22276. *
  22277. * @name reverse
  22278. * @memberOf _
  22279. * @since 0.1.0
  22280. * @category Seq
  22281. * @returns {Object} Returns the new `lodash` wrapper instance.
  22282. * @example
  22283. *
  22284. * var array = [1, 2, 3];
  22285. *
  22286. * _(array).reverse().value()
  22287. * // => [3, 2, 1]
  22288. *
  22289. * console.log(array);
  22290. * // => [3, 2, 1]
  22291. */
  22292. function wrapperReverse() {
  22293. var value = this.__wrapped__;
  22294. if (value instanceof LazyWrapper) {
  22295. var wrapped = value;
  22296. if (this.__actions__.length) {
  22297. wrapped = new LazyWrapper(this);
  22298. }
  22299. wrapped = wrapped.reverse();
  22300. wrapped.__actions__.push({
  22301. 'func': thru,
  22302. 'args': [reverse],
  22303. 'thisArg': undefined
  22304. });
  22305. return new LodashWrapper(wrapped, this.__chain__);
  22306. }
  22307. return this.thru(reverse);
  22308. }
  22309. /**
  22310. * Executes the chain sequence to resolve the unwrapped value.
  22311. *
  22312. * @name value
  22313. * @memberOf _
  22314. * @since 0.1.0
  22315. * @alias toJSON, valueOf
  22316. * @category Seq
  22317. * @returns {*} Returns the resolved unwrapped value.
  22318. * @example
  22319. *
  22320. * _([1, 2, 3]).value();
  22321. * // => [1, 2, 3]
  22322. */
  22323. function wrapperValue() {
  22324. return baseWrapperValue(this.__wrapped__, this.__actions__);
  22325. }
  22326. /*------------------------------------------------------------------------*/
  22327. /**
  22328. * Creates an object composed of keys generated from the results of running
  22329. * each element of `collection` thru `iteratee`. The corresponding value of
  22330. * each key is the number of times the key was returned by `iteratee`. The
  22331. * iteratee is invoked with one argument: (value).
  22332. *
  22333. * @static
  22334. * @memberOf _
  22335. * @since 0.5.0
  22336. * @category Collection
  22337. * @param {Array|Object} collection The collection to iterate over.
  22338. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  22339. * @returns {Object} Returns the composed aggregate object.
  22340. * @example
  22341. *
  22342. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  22343. * // => { '4': 1, '6': 2 }
  22344. *
  22345. * // The `_.property` iteratee shorthand.
  22346. * _.countBy(['one', 'two', 'three'], 'length');
  22347. * // => { '3': 2, '5': 1 }
  22348. */
  22349. var countBy = createAggregator(function(result, value, key) {
  22350. if (hasOwnProperty.call(result, key)) {
  22351. ++result[key];
  22352. } else {
  22353. baseAssignValue(result, key, 1);
  22354. }
  22355. });
  22356. /**
  22357. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  22358. * Iteration is stopped once `predicate` returns falsey. The predicate is
  22359. * invoked with three arguments: (value, index|key, collection).
  22360. *
  22361. * **Note:** This method returns `true` for
  22362. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  22363. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  22364. * elements of empty collections.
  22365. *
  22366. * @static
  22367. * @memberOf _
  22368. * @since 0.1.0
  22369. * @category Collection
  22370. * @param {Array|Object} collection The collection to iterate over.
  22371. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22372. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  22373. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  22374. * else `false`.
  22375. * @example
  22376. *
  22377. * _.every([true, 1, null, 'yes'], Boolean);
  22378. * // => false
  22379. *
  22380. * var users = [
  22381. * { 'user': 'barney', 'age': 36, 'active': false },
  22382. * { 'user': 'fred', 'age': 40, 'active': false }
  22383. * ];
  22384. *
  22385. * // The `_.matches` iteratee shorthand.
  22386. * _.every(users, { 'user': 'barney', 'active': false });
  22387. * // => false
  22388. *
  22389. * // The `_.matchesProperty` iteratee shorthand.
  22390. * _.every(users, ['active', false]);
  22391. * // => true
  22392. *
  22393. * // The `_.property` iteratee shorthand.
  22394. * _.every(users, 'active');
  22395. * // => false
  22396. */
  22397. function every(collection, predicate, guard) {
  22398. var func = isArray(collection) ? arrayEvery : baseEvery;
  22399. if (guard && isIterateeCall(collection, predicate, guard)) {
  22400. predicate = undefined;
  22401. }
  22402. return func(collection, getIteratee(predicate, 3));
  22403. }
  22404. /**
  22405. * Iterates over elements of `collection`, returning an array of all elements
  22406. * `predicate` returns truthy for. The predicate is invoked with three
  22407. * arguments: (value, index|key, collection).
  22408. *
  22409. * **Note:** Unlike `_.remove`, this method returns a new array.
  22410. *
  22411. * @static
  22412. * @memberOf _
  22413. * @since 0.1.0
  22414. * @category Collection
  22415. * @param {Array|Object} collection The collection to iterate over.
  22416. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22417. * @returns {Array} Returns the new filtered array.
  22418. * @see _.reject
  22419. * @example
  22420. *
  22421. * var users = [
  22422. * { 'user': 'barney', 'age': 36, 'active': true },
  22423. * { 'user': 'fred', 'age': 40, 'active': false }
  22424. * ];
  22425. *
  22426. * _.filter(users, function(o) { return !o.active; });
  22427. * // => objects for ['fred']
  22428. *
  22429. * // The `_.matches` iteratee shorthand.
  22430. * _.filter(users, { 'age': 36, 'active': true });
  22431. * // => objects for ['barney']
  22432. *
  22433. * // The `_.matchesProperty` iteratee shorthand.
  22434. * _.filter(users, ['active', false]);
  22435. * // => objects for ['fred']
  22436. *
  22437. * // The `_.property` iteratee shorthand.
  22438. * _.filter(users, 'active');
  22439. * // => objects for ['barney']
  22440. */
  22441. function filter(collection, predicate) {
  22442. var func = isArray(collection) ? arrayFilter : baseFilter;
  22443. return func(collection, getIteratee(predicate, 3));
  22444. }
  22445. /**
  22446. * Iterates over elements of `collection`, returning the first element
  22447. * `predicate` returns truthy for. The predicate is invoked with three
  22448. * arguments: (value, index|key, collection).
  22449. *
  22450. * @static
  22451. * @memberOf _
  22452. * @since 0.1.0
  22453. * @category Collection
  22454. * @param {Array|Object} collection The collection to inspect.
  22455. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22456. * @param {number} [fromIndex=0] The index to search from.
  22457. * @returns {*} Returns the matched element, else `undefined`.
  22458. * @example
  22459. *
  22460. * var users = [
  22461. * { 'user': 'barney', 'age': 36, 'active': true },
  22462. * { 'user': 'fred', 'age': 40, 'active': false },
  22463. * { 'user': 'pebbles', 'age': 1, 'active': true }
  22464. * ];
  22465. *
  22466. * _.find(users, function(o) { return o.age < 40; });
  22467. * // => object for 'barney'
  22468. *
  22469. * // The `_.matches` iteratee shorthand.
  22470. * _.find(users, { 'age': 1, 'active': true });
  22471. * // => object for 'pebbles'
  22472. *
  22473. * // The `_.matchesProperty` iteratee shorthand.
  22474. * _.find(users, ['active', false]);
  22475. * // => object for 'fred'
  22476. *
  22477. * // The `_.property` iteratee shorthand.
  22478. * _.find(users, 'active');
  22479. * // => object for 'barney'
  22480. */
  22481. var find = createFind(findIndex);
  22482. /**
  22483. * This method is like `_.find` except that it iterates over elements of
  22484. * `collection` from right to left.
  22485. *
  22486. * @static
  22487. * @memberOf _
  22488. * @since 2.0.0
  22489. * @category Collection
  22490. * @param {Array|Object} collection The collection to inspect.
  22491. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22492. * @param {number} [fromIndex=collection.length-1] The index to search from.
  22493. * @returns {*} Returns the matched element, else `undefined`.
  22494. * @example
  22495. *
  22496. * _.findLast([1, 2, 3, 4], function(n) {
  22497. * return n % 2 == 1;
  22498. * });
  22499. * // => 3
  22500. */
  22501. var findLast = createFind(findLastIndex);
  22502. /**
  22503. * Creates a flattened array of values by running each element in `collection`
  22504. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  22505. * with three arguments: (value, index|key, collection).
  22506. *
  22507. * @static
  22508. * @memberOf _
  22509. * @since 4.0.0
  22510. * @category Collection
  22511. * @param {Array|Object} collection The collection to iterate over.
  22512. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22513. * @returns {Array} Returns the new flattened array.
  22514. * @example
  22515. *
  22516. * function duplicate(n) {
  22517. * return [n, n];
  22518. * }
  22519. *
  22520. * _.flatMap([1, 2], duplicate);
  22521. * // => [1, 1, 2, 2]
  22522. */
  22523. function flatMap(collection, iteratee) {
  22524. return baseFlatten(map(collection, iteratee), 1);
  22525. }
  22526. /**
  22527. * This method is like `_.flatMap` except that it recursively flattens the
  22528. * mapped results.
  22529. *
  22530. * @static
  22531. * @memberOf _
  22532. * @since 4.7.0
  22533. * @category Collection
  22534. * @param {Array|Object} collection The collection to iterate over.
  22535. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22536. * @returns {Array} Returns the new flattened array.
  22537. * @example
  22538. *
  22539. * function duplicate(n) {
  22540. * return [[[n, n]]];
  22541. * }
  22542. *
  22543. * _.flatMapDeep([1, 2], duplicate);
  22544. * // => [1, 1, 2, 2]
  22545. */
  22546. function flatMapDeep(collection, iteratee) {
  22547. return baseFlatten(map(collection, iteratee), INFINITY);
  22548. }
  22549. /**
  22550. * This method is like `_.flatMap` except that it recursively flattens the
  22551. * mapped results up to `depth` times.
  22552. *
  22553. * @static
  22554. * @memberOf _
  22555. * @since 4.7.0
  22556. * @category Collection
  22557. * @param {Array|Object} collection The collection to iterate over.
  22558. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22559. * @param {number} [depth=1] The maximum recursion depth.
  22560. * @returns {Array} Returns the new flattened array.
  22561. * @example
  22562. *
  22563. * function duplicate(n) {
  22564. * return [[[n, n]]];
  22565. * }
  22566. *
  22567. * _.flatMapDepth([1, 2], duplicate, 2);
  22568. * // => [[1, 1], [2, 2]]
  22569. */
  22570. function flatMapDepth(collection, iteratee, depth) {
  22571. depth = depth === undefined ? 1 : toInteger(depth);
  22572. return baseFlatten(map(collection, iteratee), depth);
  22573. }
  22574. /**
  22575. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  22576. * The iteratee is invoked with three arguments: (value, index|key, collection).
  22577. * Iteratee functions may exit iteration early by explicitly returning `false`.
  22578. *
  22579. * **Note:** As with other "Collections" methods, objects with a "length"
  22580. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  22581. * or `_.forOwn` for object iteration.
  22582. *
  22583. * @static
  22584. * @memberOf _
  22585. * @since 0.1.0
  22586. * @alias each
  22587. * @category Collection
  22588. * @param {Array|Object} collection The collection to iterate over.
  22589. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22590. * @returns {Array|Object} Returns `collection`.
  22591. * @see _.forEachRight
  22592. * @example
  22593. *
  22594. * _.forEach([1, 2], function(value) {
  22595. * console.log(value);
  22596. * });
  22597. * // => Logs `1` then `2`.
  22598. *
  22599. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  22600. * console.log(key);
  22601. * });
  22602. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  22603. */
  22604. function forEach(collection, iteratee) {
  22605. var func = isArray(collection) ? arrayEach : baseEach;
  22606. return func(collection, getIteratee(iteratee, 3));
  22607. }
  22608. /**
  22609. * This method is like `_.forEach` except that it iterates over elements of
  22610. * `collection` from right to left.
  22611. *
  22612. * @static
  22613. * @memberOf _
  22614. * @since 2.0.0
  22615. * @alias eachRight
  22616. * @category Collection
  22617. * @param {Array|Object} collection The collection to iterate over.
  22618. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22619. * @returns {Array|Object} Returns `collection`.
  22620. * @see _.forEach
  22621. * @example
  22622. *
  22623. * _.forEachRight([1, 2], function(value) {
  22624. * console.log(value);
  22625. * });
  22626. * // => Logs `2` then `1`.
  22627. */
  22628. function forEachRight(collection, iteratee) {
  22629. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  22630. return func(collection, getIteratee(iteratee, 3));
  22631. }
  22632. /**
  22633. * Creates an object composed of keys generated from the results of running
  22634. * each element of `collection` thru `iteratee`. The order of grouped values
  22635. * is determined by the order they occur in `collection`. The corresponding
  22636. * value of each key is an array of elements responsible for generating the
  22637. * key. The iteratee is invoked with one argument: (value).
  22638. *
  22639. * @static
  22640. * @memberOf _
  22641. * @since 0.1.0
  22642. * @category Collection
  22643. * @param {Array|Object} collection The collection to iterate over.
  22644. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  22645. * @returns {Object} Returns the composed aggregate object.
  22646. * @example
  22647. *
  22648. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  22649. * // => { '4': [4.2], '6': [6.1, 6.3] }
  22650. *
  22651. * // The `_.property` iteratee shorthand.
  22652. * _.groupBy(['one', 'two', 'three'], 'length');
  22653. * // => { '3': ['one', 'two'], '5': ['three'] }
  22654. */
  22655. var groupBy = createAggregator(function(result, value, key) {
  22656. if (hasOwnProperty.call(result, key)) {
  22657. result[key].push(value);
  22658. } else {
  22659. baseAssignValue(result, key, [value]);
  22660. }
  22661. });
  22662. /**
  22663. * Checks if `value` is in `collection`. If `collection` is a string, it's
  22664. * checked for a substring of `value`, otherwise
  22665. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  22666. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  22667. * the offset from the end of `collection`.
  22668. *
  22669. * @static
  22670. * @memberOf _
  22671. * @since 0.1.0
  22672. * @category Collection
  22673. * @param {Array|Object|string} collection The collection to inspect.
  22674. * @param {*} value The value to search for.
  22675. * @param {number} [fromIndex=0] The index to search from.
  22676. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  22677. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  22678. * @example
  22679. *
  22680. * _.includes([1, 2, 3], 1);
  22681. * // => true
  22682. *
  22683. * _.includes([1, 2, 3], 1, 2);
  22684. * // => false
  22685. *
  22686. * _.includes({ 'a': 1, 'b': 2 }, 1);
  22687. * // => true
  22688. *
  22689. * _.includes('abcd', 'bc');
  22690. * // => true
  22691. */
  22692. function includes(collection, value, fromIndex, guard) {
  22693. collection = isArrayLike(collection) ? collection : values(collection);
  22694. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  22695. var length = collection.length;
  22696. if (fromIndex < 0) {
  22697. fromIndex = nativeMax(length + fromIndex, 0);
  22698. }
  22699. return isString(collection)
  22700. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  22701. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  22702. }
  22703. /**
  22704. * Invokes the method at `path` of each element in `collection`, returning
  22705. * an array of the results of each invoked method. Any additional arguments
  22706. * are provided to each invoked method. If `path` is a function, it's invoked
  22707. * for, and `this` bound to, each element in `collection`.
  22708. *
  22709. * @static
  22710. * @memberOf _
  22711. * @since 4.0.0
  22712. * @category Collection
  22713. * @param {Array|Object} collection The collection to iterate over.
  22714. * @param {Array|Function|string} path The path of the method to invoke or
  22715. * the function invoked per iteration.
  22716. * @param {...*} [args] The arguments to invoke each method with.
  22717. * @returns {Array} Returns the array of results.
  22718. * @example
  22719. *
  22720. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  22721. * // => [[1, 5, 7], [1, 2, 3]]
  22722. *
  22723. * _.invokeMap([123, 456], String.prototype.split, '');
  22724. * // => [['1', '2', '3'], ['4', '5', '6']]
  22725. */
  22726. var invokeMap = baseRest(function(collection, path, args) {
  22727. var index = -1,
  22728. isFunc = typeof path == 'function',
  22729. result = isArrayLike(collection) ? Array(collection.length) : [];
  22730. baseEach(collection, function(value) {
  22731. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  22732. });
  22733. return result;
  22734. });
  22735. /**
  22736. * Creates an object composed of keys generated from the results of running
  22737. * each element of `collection` thru `iteratee`. The corresponding value of
  22738. * each key is the last element responsible for generating the key. The
  22739. * iteratee is invoked with one argument: (value).
  22740. *
  22741. * @static
  22742. * @memberOf _
  22743. * @since 4.0.0
  22744. * @category Collection
  22745. * @param {Array|Object} collection The collection to iterate over.
  22746. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  22747. * @returns {Object} Returns the composed aggregate object.
  22748. * @example
  22749. *
  22750. * var array = [
  22751. * { 'dir': 'left', 'code': 97 },
  22752. * { 'dir': 'right', 'code': 100 }
  22753. * ];
  22754. *
  22755. * _.keyBy(array, function(o) {
  22756. * return String.fromCharCode(o.code);
  22757. * });
  22758. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  22759. *
  22760. * _.keyBy(array, 'dir');
  22761. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  22762. */
  22763. var keyBy = createAggregator(function(result, value, key) {
  22764. baseAssignValue(result, key, value);
  22765. });
  22766. /**
  22767. * Creates an array of values by running each element in `collection` thru
  22768. * `iteratee`. The iteratee is invoked with three arguments:
  22769. * (value, index|key, collection).
  22770. *
  22771. * Many lodash methods are guarded to work as iteratees for methods like
  22772. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  22773. *
  22774. * The guarded methods are:
  22775. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  22776. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  22777. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  22778. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  22779. *
  22780. * @static
  22781. * @memberOf _
  22782. * @since 0.1.0
  22783. * @category Collection
  22784. * @param {Array|Object} collection The collection to iterate over.
  22785. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22786. * @returns {Array} Returns the new mapped array.
  22787. * @example
  22788. *
  22789. * function square(n) {
  22790. * return n * n;
  22791. * }
  22792. *
  22793. * _.map([4, 8], square);
  22794. * // => [16, 64]
  22795. *
  22796. * _.map({ 'a': 4, 'b': 8 }, square);
  22797. * // => [16, 64] (iteration order is not guaranteed)
  22798. *
  22799. * var users = [
  22800. * { 'user': 'barney' },
  22801. * { 'user': 'fred' }
  22802. * ];
  22803. *
  22804. * // The `_.property` iteratee shorthand.
  22805. * _.map(users, 'user');
  22806. * // => ['barney', 'fred']
  22807. */
  22808. function map(collection, iteratee) {
  22809. var func = isArray(collection) ? arrayMap : baseMap;
  22810. return func(collection, getIteratee(iteratee, 3));
  22811. }
  22812. /**
  22813. * This method is like `_.sortBy` except that it allows specifying the sort
  22814. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  22815. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  22816. * descending or "asc" for ascending sort order of corresponding values.
  22817. *
  22818. * @static
  22819. * @memberOf _
  22820. * @since 4.0.0
  22821. * @category Collection
  22822. * @param {Array|Object} collection The collection to iterate over.
  22823. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  22824. * The iteratees to sort by.
  22825. * @param {string[]} [orders] The sort orders of `iteratees`.
  22826. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  22827. * @returns {Array} Returns the new sorted array.
  22828. * @example
  22829. *
  22830. * var users = [
  22831. * { 'user': 'fred', 'age': 48 },
  22832. * { 'user': 'barney', 'age': 34 },
  22833. * { 'user': 'fred', 'age': 40 },
  22834. * { 'user': 'barney', 'age': 36 }
  22835. * ];
  22836. *
  22837. * // Sort by `user` in ascending order and by `age` in descending order.
  22838. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  22839. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  22840. */
  22841. function orderBy(collection, iteratees, orders, guard) {
  22842. if (collection == null) {
  22843. return [];
  22844. }
  22845. if (!isArray(iteratees)) {
  22846. iteratees = iteratees == null ? [] : [iteratees];
  22847. }
  22848. orders = guard ? undefined : orders;
  22849. if (!isArray(orders)) {
  22850. orders = orders == null ? [] : [orders];
  22851. }
  22852. return baseOrderBy(collection, iteratees, orders);
  22853. }
  22854. /**
  22855. * Creates an array of elements split into two groups, the first of which
  22856. * contains elements `predicate` returns truthy for, the second of which
  22857. * contains elements `predicate` returns falsey for. The predicate is
  22858. * invoked with one argument: (value).
  22859. *
  22860. * @static
  22861. * @memberOf _
  22862. * @since 3.0.0
  22863. * @category Collection
  22864. * @param {Array|Object} collection The collection to iterate over.
  22865. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22866. * @returns {Array} Returns the array of grouped elements.
  22867. * @example
  22868. *
  22869. * var users = [
  22870. * { 'user': 'barney', 'age': 36, 'active': false },
  22871. * { 'user': 'fred', 'age': 40, 'active': true },
  22872. * { 'user': 'pebbles', 'age': 1, 'active': false }
  22873. * ];
  22874. *
  22875. * _.partition(users, function(o) { return o.active; });
  22876. * // => objects for [['fred'], ['barney', 'pebbles']]
  22877. *
  22878. * // The `_.matches` iteratee shorthand.
  22879. * _.partition(users, { 'age': 1, 'active': false });
  22880. * // => objects for [['pebbles'], ['barney', 'fred']]
  22881. *
  22882. * // The `_.matchesProperty` iteratee shorthand.
  22883. * _.partition(users, ['active', false]);
  22884. * // => objects for [['barney', 'pebbles'], ['fred']]
  22885. *
  22886. * // The `_.property` iteratee shorthand.
  22887. * _.partition(users, 'active');
  22888. * // => objects for [['fred'], ['barney', 'pebbles']]
  22889. */
  22890. var partition = createAggregator(function(result, value, key) {
  22891. result[key ? 0 : 1].push(value);
  22892. }, function() { return [[], []]; });
  22893. /**
  22894. * Reduces `collection` to a value which is the accumulated result of running
  22895. * each element in `collection` thru `iteratee`, where each successive
  22896. * invocation is supplied the return value of the previous. If `accumulator`
  22897. * is not given, the first element of `collection` is used as the initial
  22898. * value. The iteratee is invoked with four arguments:
  22899. * (accumulator, value, index|key, collection).
  22900. *
  22901. * Many lodash methods are guarded to work as iteratees for methods like
  22902. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  22903. *
  22904. * The guarded methods are:
  22905. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  22906. * and `sortBy`
  22907. *
  22908. * @static
  22909. * @memberOf _
  22910. * @since 0.1.0
  22911. * @category Collection
  22912. * @param {Array|Object} collection The collection to iterate over.
  22913. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22914. * @param {*} [accumulator] The initial value.
  22915. * @returns {*} Returns the accumulated value.
  22916. * @see _.reduceRight
  22917. * @example
  22918. *
  22919. * _.reduce([1, 2], function(sum, n) {
  22920. * return sum + n;
  22921. * }, 0);
  22922. * // => 3
  22923. *
  22924. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  22925. * (result[value] || (result[value] = [])).push(key);
  22926. * return result;
  22927. * }, {});
  22928. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  22929. */
  22930. function reduce(collection, iteratee, accumulator) {
  22931. var func = isArray(collection) ? arrayReduce : baseReduce,
  22932. initAccum = arguments.length < 3;
  22933. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  22934. }
  22935. /**
  22936. * This method is like `_.reduce` except that it iterates over elements of
  22937. * `collection` from right to left.
  22938. *
  22939. * @static
  22940. * @memberOf _
  22941. * @since 0.1.0
  22942. * @category Collection
  22943. * @param {Array|Object} collection The collection to iterate over.
  22944. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  22945. * @param {*} [accumulator] The initial value.
  22946. * @returns {*} Returns the accumulated value.
  22947. * @see _.reduce
  22948. * @example
  22949. *
  22950. * var array = [[0, 1], [2, 3], [4, 5]];
  22951. *
  22952. * _.reduceRight(array, function(flattened, other) {
  22953. * return flattened.concat(other);
  22954. * }, []);
  22955. * // => [4, 5, 2, 3, 0, 1]
  22956. */
  22957. function reduceRight(collection, iteratee, accumulator) {
  22958. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  22959. initAccum = arguments.length < 3;
  22960. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  22961. }
  22962. /**
  22963. * The opposite of `_.filter`; this method returns the elements of `collection`
  22964. * that `predicate` does **not** return truthy for.
  22965. *
  22966. * @static
  22967. * @memberOf _
  22968. * @since 0.1.0
  22969. * @category Collection
  22970. * @param {Array|Object} collection The collection to iterate over.
  22971. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  22972. * @returns {Array} Returns the new filtered array.
  22973. * @see _.filter
  22974. * @example
  22975. *
  22976. * var users = [
  22977. * { 'user': 'barney', 'age': 36, 'active': false },
  22978. * { 'user': 'fred', 'age': 40, 'active': true }
  22979. * ];
  22980. *
  22981. * _.reject(users, function(o) { return !o.active; });
  22982. * // => objects for ['fred']
  22983. *
  22984. * // The `_.matches` iteratee shorthand.
  22985. * _.reject(users, { 'age': 40, 'active': true });
  22986. * // => objects for ['barney']
  22987. *
  22988. * // The `_.matchesProperty` iteratee shorthand.
  22989. * _.reject(users, ['active', false]);
  22990. * // => objects for ['fred']
  22991. *
  22992. * // The `_.property` iteratee shorthand.
  22993. * _.reject(users, 'active');
  22994. * // => objects for ['barney']
  22995. */
  22996. function reject(collection, predicate) {
  22997. var func = isArray(collection) ? arrayFilter : baseFilter;
  22998. return func(collection, negate(getIteratee(predicate, 3)));
  22999. }
  23000. /**
  23001. * Gets a random element from `collection`.
  23002. *
  23003. * @static
  23004. * @memberOf _
  23005. * @since 2.0.0
  23006. * @category Collection
  23007. * @param {Array|Object} collection The collection to sample.
  23008. * @returns {*} Returns the random element.
  23009. * @example
  23010. *
  23011. * _.sample([1, 2, 3, 4]);
  23012. * // => 2
  23013. */
  23014. function sample(collection) {
  23015. var func = isArray(collection) ? arraySample : baseSample;
  23016. return func(collection);
  23017. }
  23018. /**
  23019. * Gets `n` random elements at unique keys from `collection` up to the
  23020. * size of `collection`.
  23021. *
  23022. * @static
  23023. * @memberOf _
  23024. * @since 4.0.0
  23025. * @category Collection
  23026. * @param {Array|Object} collection The collection to sample.
  23027. * @param {number} [n=1] The number of elements to sample.
  23028. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23029. * @returns {Array} Returns the random elements.
  23030. * @example
  23031. *
  23032. * _.sampleSize([1, 2, 3], 2);
  23033. * // => [3, 1]
  23034. *
  23035. * _.sampleSize([1, 2, 3], 4);
  23036. * // => [2, 3, 1]
  23037. */
  23038. function sampleSize(collection, n, guard) {
  23039. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  23040. n = 1;
  23041. } else {
  23042. n = toInteger(n);
  23043. }
  23044. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  23045. return func(collection, n);
  23046. }
  23047. /**
  23048. * Creates an array of shuffled values, using a version of the
  23049. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  23050. *
  23051. * @static
  23052. * @memberOf _
  23053. * @since 0.1.0
  23054. * @category Collection
  23055. * @param {Array|Object} collection The collection to shuffle.
  23056. * @returns {Array} Returns the new shuffled array.
  23057. * @example
  23058. *
  23059. * _.shuffle([1, 2, 3, 4]);
  23060. * // => [4, 1, 3, 2]
  23061. */
  23062. function shuffle(collection) {
  23063. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  23064. return func(collection);
  23065. }
  23066. /**
  23067. * Gets the size of `collection` by returning its length for array-like
  23068. * values or the number of own enumerable string keyed properties for objects.
  23069. *
  23070. * @static
  23071. * @memberOf _
  23072. * @since 0.1.0
  23073. * @category Collection
  23074. * @param {Array|Object|string} collection The collection to inspect.
  23075. * @returns {number} Returns the collection size.
  23076. * @example
  23077. *
  23078. * _.size([1, 2, 3]);
  23079. * // => 3
  23080. *
  23081. * _.size({ 'a': 1, 'b': 2 });
  23082. * // => 2
  23083. *
  23084. * _.size('pebbles');
  23085. * // => 7
  23086. */
  23087. function size(collection) {
  23088. if (collection == null) {
  23089. return 0;
  23090. }
  23091. if (isArrayLike(collection)) {
  23092. return isString(collection) ? stringSize(collection) : collection.length;
  23093. }
  23094. var tag = getTag(collection);
  23095. if (tag == mapTag || tag == setTag) {
  23096. return collection.size;
  23097. }
  23098. return baseKeys(collection).length;
  23099. }
  23100. /**
  23101. * Checks if `predicate` returns truthy for **any** element of `collection`.
  23102. * Iteration is stopped once `predicate` returns truthy. The predicate is
  23103. * invoked with three arguments: (value, index|key, collection).
  23104. *
  23105. * @static
  23106. * @memberOf _
  23107. * @since 0.1.0
  23108. * @category Collection
  23109. * @param {Array|Object} collection The collection to iterate over.
  23110. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  23111. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23112. * @returns {boolean} Returns `true` if any element passes the predicate check,
  23113. * else `false`.
  23114. * @example
  23115. *
  23116. * _.some([null, 0, 'yes', false], Boolean);
  23117. * // => true
  23118. *
  23119. * var users = [
  23120. * { 'user': 'barney', 'active': true },
  23121. * { 'user': 'fred', 'active': false }
  23122. * ];
  23123. *
  23124. * // The `_.matches` iteratee shorthand.
  23125. * _.some(users, { 'user': 'barney', 'active': false });
  23126. * // => false
  23127. *
  23128. * // The `_.matchesProperty` iteratee shorthand.
  23129. * _.some(users, ['active', false]);
  23130. * // => true
  23131. *
  23132. * // The `_.property` iteratee shorthand.
  23133. * _.some(users, 'active');
  23134. * // => true
  23135. */
  23136. function some(collection, predicate, guard) {
  23137. var func = isArray(collection) ? arraySome : baseSome;
  23138. if (guard && isIterateeCall(collection, predicate, guard)) {
  23139. predicate = undefined;
  23140. }
  23141. return func(collection, getIteratee(predicate, 3));
  23142. }
  23143. /**
  23144. * Creates an array of elements, sorted in ascending order by the results of
  23145. * running each element in a collection thru each iteratee. This method
  23146. * performs a stable sort, that is, it preserves the original sort order of
  23147. * equal elements. The iteratees are invoked with one argument: (value).
  23148. *
  23149. * @static
  23150. * @memberOf _
  23151. * @since 0.1.0
  23152. * @category Collection
  23153. * @param {Array|Object} collection The collection to iterate over.
  23154. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  23155. * The iteratees to sort by.
  23156. * @returns {Array} Returns the new sorted array.
  23157. * @example
  23158. *
  23159. * var users = [
  23160. * { 'user': 'fred', 'age': 48 },
  23161. * { 'user': 'barney', 'age': 36 },
  23162. * { 'user': 'fred', 'age': 40 },
  23163. * { 'user': 'barney', 'age': 34 }
  23164. * ];
  23165. *
  23166. * _.sortBy(users, [function(o) { return o.user; }]);
  23167. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  23168. *
  23169. * _.sortBy(users, ['user', 'age']);
  23170. * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
  23171. */
  23172. var sortBy = baseRest(function(collection, iteratees) {
  23173. if (collection == null) {
  23174. return [];
  23175. }
  23176. var length = iteratees.length;
  23177. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  23178. iteratees = [];
  23179. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  23180. iteratees = [iteratees[0]];
  23181. }
  23182. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  23183. });
  23184. /*------------------------------------------------------------------------*/
  23185. /**
  23186. * Gets the timestamp of the number of milliseconds that have elapsed since
  23187. * the Unix epoch (1 January 1970 00:00:00 UTC).
  23188. *
  23189. * @static
  23190. * @memberOf _
  23191. * @since 2.4.0
  23192. * @category Date
  23193. * @returns {number} Returns the timestamp.
  23194. * @example
  23195. *
  23196. * _.defer(function(stamp) {
  23197. * console.log(_.now() - stamp);
  23198. * }, _.now());
  23199. * // => Logs the number of milliseconds it took for the deferred invocation.
  23200. */
  23201. var now = ctxNow || function() {
  23202. return root.Date.now();
  23203. };
  23204. /*------------------------------------------------------------------------*/
  23205. /**
  23206. * The opposite of `_.before`; this method creates a function that invokes
  23207. * `func` once it's called `n` or more times.
  23208. *
  23209. * @static
  23210. * @memberOf _
  23211. * @since 0.1.0
  23212. * @category Function
  23213. * @param {number} n The number of calls before `func` is invoked.
  23214. * @param {Function} func The function to restrict.
  23215. * @returns {Function} Returns the new restricted function.
  23216. * @example
  23217. *
  23218. * var saves = ['profile', 'settings'];
  23219. *
  23220. * var done = _.after(saves.length, function() {
  23221. * console.log('done saving!');
  23222. * });
  23223. *
  23224. * _.forEach(saves, function(type) {
  23225. * asyncSave({ 'type': type, 'complete': done });
  23226. * });
  23227. * // => Logs 'done saving!' after the two async saves have completed.
  23228. */
  23229. function after(n, func) {
  23230. if (typeof func != 'function') {
  23231. throw new TypeError(FUNC_ERROR_TEXT);
  23232. }
  23233. n = toInteger(n);
  23234. return function() {
  23235. if (--n < 1) {
  23236. return func.apply(this, arguments);
  23237. }
  23238. };
  23239. }
  23240. /**
  23241. * Creates a function that invokes `func`, with up to `n` arguments,
  23242. * ignoring any additional arguments.
  23243. *
  23244. * @static
  23245. * @memberOf _
  23246. * @since 3.0.0
  23247. * @category Function
  23248. * @param {Function} func The function to cap arguments for.
  23249. * @param {number} [n=func.length] The arity cap.
  23250. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23251. * @returns {Function} Returns the new capped function.
  23252. * @example
  23253. *
  23254. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  23255. * // => [6, 8, 10]
  23256. */
  23257. function ary(func, n, guard) {
  23258. n = guard ? undefined : n;
  23259. n = (func && n == null) ? func.length : n;
  23260. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  23261. }
  23262. /**
  23263. * Creates a function that invokes `func`, with the `this` binding and arguments
  23264. * of the created function, while it's called less than `n` times. Subsequent
  23265. * calls to the created function return the result of the last `func` invocation.
  23266. *
  23267. * @static
  23268. * @memberOf _
  23269. * @since 3.0.0
  23270. * @category Function
  23271. * @param {number} n The number of calls at which `func` is no longer invoked.
  23272. * @param {Function} func The function to restrict.
  23273. * @returns {Function} Returns the new restricted function.
  23274. * @example
  23275. *
  23276. * jQuery(element).on('click', _.before(5, addContactToList));
  23277. * // => Allows adding up to 4 contacts to the list.
  23278. */
  23279. function before(n, func) {
  23280. var result;
  23281. if (typeof func != 'function') {
  23282. throw new TypeError(FUNC_ERROR_TEXT);
  23283. }
  23284. n = toInteger(n);
  23285. return function() {
  23286. if (--n > 0) {
  23287. result = func.apply(this, arguments);
  23288. }
  23289. if (n <= 1) {
  23290. func = undefined;
  23291. }
  23292. return result;
  23293. };
  23294. }
  23295. /**
  23296. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  23297. * and `partials` prepended to the arguments it receives.
  23298. *
  23299. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  23300. * may be used as a placeholder for partially applied arguments.
  23301. *
  23302. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  23303. * property of bound functions.
  23304. *
  23305. * @static
  23306. * @memberOf _
  23307. * @since 0.1.0
  23308. * @category Function
  23309. * @param {Function} func The function to bind.
  23310. * @param {*} thisArg The `this` binding of `func`.
  23311. * @param {...*} [partials] The arguments to be partially applied.
  23312. * @returns {Function} Returns the new bound function.
  23313. * @example
  23314. *
  23315. * function greet(greeting, punctuation) {
  23316. * return greeting + ' ' + this.user + punctuation;
  23317. * }
  23318. *
  23319. * var object = { 'user': 'fred' };
  23320. *
  23321. * var bound = _.bind(greet, object, 'hi');
  23322. * bound('!');
  23323. * // => 'hi fred!'
  23324. *
  23325. * // Bound with placeholders.
  23326. * var bound = _.bind(greet, object, _, '!');
  23327. * bound('hi');
  23328. * // => 'hi fred!'
  23329. */
  23330. var bind = baseRest(function(func, thisArg, partials) {
  23331. var bitmask = WRAP_BIND_FLAG;
  23332. if (partials.length) {
  23333. var holders = replaceHolders(partials, getHolder(bind));
  23334. bitmask |= WRAP_PARTIAL_FLAG;
  23335. }
  23336. return createWrap(func, bitmask, thisArg, partials, holders);
  23337. });
  23338. /**
  23339. * Creates a function that invokes the method at `object[key]` with `partials`
  23340. * prepended to the arguments it receives.
  23341. *
  23342. * This method differs from `_.bind` by allowing bound functions to reference
  23343. * methods that may be redefined or don't yet exist. See
  23344. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  23345. * for more details.
  23346. *
  23347. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  23348. * builds, may be used as a placeholder for partially applied arguments.
  23349. *
  23350. * @static
  23351. * @memberOf _
  23352. * @since 0.10.0
  23353. * @category Function
  23354. * @param {Object} object The object to invoke the method on.
  23355. * @param {string} key The key of the method.
  23356. * @param {...*} [partials] The arguments to be partially applied.
  23357. * @returns {Function} Returns the new bound function.
  23358. * @example
  23359. *
  23360. * var object = {
  23361. * 'user': 'fred',
  23362. * 'greet': function(greeting, punctuation) {
  23363. * return greeting + ' ' + this.user + punctuation;
  23364. * }
  23365. * };
  23366. *
  23367. * var bound = _.bindKey(object, 'greet', 'hi');
  23368. * bound('!');
  23369. * // => 'hi fred!'
  23370. *
  23371. * object.greet = function(greeting, punctuation) {
  23372. * return greeting + 'ya ' + this.user + punctuation;
  23373. * };
  23374. *
  23375. * bound('!');
  23376. * // => 'hiya fred!'
  23377. *
  23378. * // Bound with placeholders.
  23379. * var bound = _.bindKey(object, 'greet', _, '!');
  23380. * bound('hi');
  23381. * // => 'hiya fred!'
  23382. */
  23383. var bindKey = baseRest(function(object, key, partials) {
  23384. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  23385. if (partials.length) {
  23386. var holders = replaceHolders(partials, getHolder(bindKey));
  23387. bitmask |= WRAP_PARTIAL_FLAG;
  23388. }
  23389. return createWrap(key, bitmask, object, partials, holders);
  23390. });
  23391. /**
  23392. * Creates a function that accepts arguments of `func` and either invokes
  23393. * `func` returning its result, if at least `arity` number of arguments have
  23394. * been provided, or returns a function that accepts the remaining `func`
  23395. * arguments, and so on. The arity of `func` may be specified if `func.length`
  23396. * is not sufficient.
  23397. *
  23398. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  23399. * may be used as a placeholder for provided arguments.
  23400. *
  23401. * **Note:** This method doesn't set the "length" property of curried functions.
  23402. *
  23403. * @static
  23404. * @memberOf _
  23405. * @since 2.0.0
  23406. * @category Function
  23407. * @param {Function} func The function to curry.
  23408. * @param {number} [arity=func.length] The arity of `func`.
  23409. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23410. * @returns {Function} Returns the new curried function.
  23411. * @example
  23412. *
  23413. * var abc = function(a, b, c) {
  23414. * return [a, b, c];
  23415. * };
  23416. *
  23417. * var curried = _.curry(abc);
  23418. *
  23419. * curried(1)(2)(3);
  23420. * // => [1, 2, 3]
  23421. *
  23422. * curried(1, 2)(3);
  23423. * // => [1, 2, 3]
  23424. *
  23425. * curried(1, 2, 3);
  23426. * // => [1, 2, 3]
  23427. *
  23428. * // Curried with placeholders.
  23429. * curried(1)(_, 3)(2);
  23430. * // => [1, 2, 3]
  23431. */
  23432. function curry(func, arity, guard) {
  23433. arity = guard ? undefined : arity;
  23434. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  23435. result.placeholder = curry.placeholder;
  23436. return result;
  23437. }
  23438. /**
  23439. * This method is like `_.curry` except that arguments are applied to `func`
  23440. * in the manner of `_.partialRight` instead of `_.partial`.
  23441. *
  23442. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  23443. * builds, may be used as a placeholder for provided arguments.
  23444. *
  23445. * **Note:** This method doesn't set the "length" property of curried functions.
  23446. *
  23447. * @static
  23448. * @memberOf _
  23449. * @since 3.0.0
  23450. * @category Function
  23451. * @param {Function} func The function to curry.
  23452. * @param {number} [arity=func.length] The arity of `func`.
  23453. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23454. * @returns {Function} Returns the new curried function.
  23455. * @example
  23456. *
  23457. * var abc = function(a, b, c) {
  23458. * return [a, b, c];
  23459. * };
  23460. *
  23461. * var curried = _.curryRight(abc);
  23462. *
  23463. * curried(3)(2)(1);
  23464. * // => [1, 2, 3]
  23465. *
  23466. * curried(2, 3)(1);
  23467. * // => [1, 2, 3]
  23468. *
  23469. * curried(1, 2, 3);
  23470. * // => [1, 2, 3]
  23471. *
  23472. * // Curried with placeholders.
  23473. * curried(3)(1, _)(2);
  23474. * // => [1, 2, 3]
  23475. */
  23476. function curryRight(func, arity, guard) {
  23477. arity = guard ? undefined : arity;
  23478. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  23479. result.placeholder = curryRight.placeholder;
  23480. return result;
  23481. }
  23482. /**
  23483. * Creates a debounced function that delays invoking `func` until after `wait`
  23484. * milliseconds have elapsed since the last time the debounced function was
  23485. * invoked. The debounced function comes with a `cancel` method to cancel
  23486. * delayed `func` invocations and a `flush` method to immediately invoke them.
  23487. * Provide `options` to indicate whether `func` should be invoked on the
  23488. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  23489. * with the last arguments provided to the debounced function. Subsequent
  23490. * calls to the debounced function return the result of the last `func`
  23491. * invocation.
  23492. *
  23493. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  23494. * invoked on the trailing edge of the timeout only if the debounced function
  23495. * is invoked more than once during the `wait` timeout.
  23496. *
  23497. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  23498. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  23499. *
  23500. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  23501. * for details over the differences between `_.debounce` and `_.throttle`.
  23502. *
  23503. * @static
  23504. * @memberOf _
  23505. * @since 0.1.0
  23506. * @category Function
  23507. * @param {Function} func The function to debounce.
  23508. * @param {number} [wait=0] The number of milliseconds to delay.
  23509. * @param {Object} [options={}] The options object.
  23510. * @param {boolean} [options.leading=false]
  23511. * Specify invoking on the leading edge of the timeout.
  23512. * @param {number} [options.maxWait]
  23513. * The maximum time `func` is allowed to be delayed before it's invoked.
  23514. * @param {boolean} [options.trailing=true]
  23515. * Specify invoking on the trailing edge of the timeout.
  23516. * @returns {Function} Returns the new debounced function.
  23517. * @example
  23518. *
  23519. * // Avoid costly calculations while the window size is in flux.
  23520. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  23521. *
  23522. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  23523. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  23524. * 'leading': true,
  23525. * 'trailing': false
  23526. * }));
  23527. *
  23528. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  23529. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  23530. * var source = new EventSource('/stream');
  23531. * jQuery(source).on('message', debounced);
  23532. *
  23533. * // Cancel the trailing debounced invocation.
  23534. * jQuery(window).on('popstate', debounced.cancel);
  23535. */
  23536. function debounce(func, wait, options) {
  23537. var lastArgs,
  23538. lastThis,
  23539. maxWait,
  23540. result,
  23541. timerId,
  23542. lastCallTime,
  23543. lastInvokeTime = 0,
  23544. leading = false,
  23545. maxing = false,
  23546. trailing = true;
  23547. if (typeof func != 'function') {
  23548. throw new TypeError(FUNC_ERROR_TEXT);
  23549. }
  23550. wait = toNumber(wait) || 0;
  23551. if (isObject(options)) {
  23552. leading = !!options.leading;
  23553. maxing = 'maxWait' in options;
  23554. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  23555. trailing = 'trailing' in options ? !!options.trailing : trailing;
  23556. }
  23557. function invokeFunc(time) {
  23558. var args = lastArgs,
  23559. thisArg = lastThis;
  23560. lastArgs = lastThis = undefined;
  23561. lastInvokeTime = time;
  23562. result = func.apply(thisArg, args);
  23563. return result;
  23564. }
  23565. function leadingEdge(time) {
  23566. // Reset any `maxWait` timer.
  23567. lastInvokeTime = time;
  23568. // Start the timer for the trailing edge.
  23569. timerId = setTimeout(timerExpired, wait);
  23570. // Invoke the leading edge.
  23571. return leading ? invokeFunc(time) : result;
  23572. }
  23573. function remainingWait(time) {
  23574. var timeSinceLastCall = time - lastCallTime,
  23575. timeSinceLastInvoke = time - lastInvokeTime,
  23576. timeWaiting = wait - timeSinceLastCall;
  23577. return maxing
  23578. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  23579. : timeWaiting;
  23580. }
  23581. function shouldInvoke(time) {
  23582. var timeSinceLastCall = time - lastCallTime,
  23583. timeSinceLastInvoke = time - lastInvokeTime;
  23584. // Either this is the first call, activity has stopped and we're at the
  23585. // trailing edge, the system time has gone backwards and we're treating
  23586. // it as the trailing edge, or we've hit the `maxWait` limit.
  23587. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  23588. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  23589. }
  23590. function timerExpired() {
  23591. var time = now();
  23592. if (shouldInvoke(time)) {
  23593. return trailingEdge(time);
  23594. }
  23595. // Restart the timer.
  23596. timerId = setTimeout(timerExpired, remainingWait(time));
  23597. }
  23598. function trailingEdge(time) {
  23599. timerId = undefined;
  23600. // Only invoke if we have `lastArgs` which means `func` has been
  23601. // debounced at least once.
  23602. if (trailing && lastArgs) {
  23603. return invokeFunc(time);
  23604. }
  23605. lastArgs = lastThis = undefined;
  23606. return result;
  23607. }
  23608. function cancel() {
  23609. if (timerId !== undefined) {
  23610. clearTimeout(timerId);
  23611. }
  23612. lastInvokeTime = 0;
  23613. lastArgs = lastCallTime = lastThis = timerId = undefined;
  23614. }
  23615. function flush() {
  23616. return timerId === undefined ? result : trailingEdge(now());
  23617. }
  23618. function debounced() {
  23619. var time = now(),
  23620. isInvoking = shouldInvoke(time);
  23621. lastArgs = arguments;
  23622. lastThis = this;
  23623. lastCallTime = time;
  23624. if (isInvoking) {
  23625. if (timerId === undefined) {
  23626. return leadingEdge(lastCallTime);
  23627. }
  23628. if (maxing) {
  23629. // Handle invocations in a tight loop.
  23630. clearTimeout(timerId);
  23631. timerId = setTimeout(timerExpired, wait);
  23632. return invokeFunc(lastCallTime);
  23633. }
  23634. }
  23635. if (timerId === undefined) {
  23636. timerId = setTimeout(timerExpired, wait);
  23637. }
  23638. return result;
  23639. }
  23640. debounced.cancel = cancel;
  23641. debounced.flush = flush;
  23642. return debounced;
  23643. }
  23644. /**
  23645. * Defers invoking the `func` until the current call stack has cleared. Any
  23646. * additional arguments are provided to `func` when it's invoked.
  23647. *
  23648. * @static
  23649. * @memberOf _
  23650. * @since 0.1.0
  23651. * @category Function
  23652. * @param {Function} func The function to defer.
  23653. * @param {...*} [args] The arguments to invoke `func` with.
  23654. * @returns {number} Returns the timer id.
  23655. * @example
  23656. *
  23657. * _.defer(function(text) {
  23658. * console.log(text);
  23659. * }, 'deferred');
  23660. * // => Logs 'deferred' after one millisecond.
  23661. */
  23662. var defer = baseRest(function(func, args) {
  23663. return baseDelay(func, 1, args);
  23664. });
  23665. /**
  23666. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  23667. * provided to `func` when it's invoked.
  23668. *
  23669. * @static
  23670. * @memberOf _
  23671. * @since 0.1.0
  23672. * @category Function
  23673. * @param {Function} func The function to delay.
  23674. * @param {number} wait The number of milliseconds to delay invocation.
  23675. * @param {...*} [args] The arguments to invoke `func` with.
  23676. * @returns {number} Returns the timer id.
  23677. * @example
  23678. *
  23679. * _.delay(function(text) {
  23680. * console.log(text);
  23681. * }, 1000, 'later');
  23682. * // => Logs 'later' after one second.
  23683. */
  23684. var delay = baseRest(function(func, wait, args) {
  23685. return baseDelay(func, toNumber(wait) || 0, args);
  23686. });
  23687. /**
  23688. * Creates a function that invokes `func` with arguments reversed.
  23689. *
  23690. * @static
  23691. * @memberOf _
  23692. * @since 4.0.0
  23693. * @category Function
  23694. * @param {Function} func The function to flip arguments for.
  23695. * @returns {Function} Returns the new flipped function.
  23696. * @example
  23697. *
  23698. * var flipped = _.flip(function() {
  23699. * return _.toArray(arguments);
  23700. * });
  23701. *
  23702. * flipped('a', 'b', 'c', 'd');
  23703. * // => ['d', 'c', 'b', 'a']
  23704. */
  23705. function flip(func) {
  23706. return createWrap(func, WRAP_FLIP_FLAG);
  23707. }
  23708. /**
  23709. * Creates a function that memoizes the result of `func`. If `resolver` is
  23710. * provided, it determines the cache key for storing the result based on the
  23711. * arguments provided to the memoized function. By default, the first argument
  23712. * provided to the memoized function is used as the map cache key. The `func`
  23713. * is invoked with the `this` binding of the memoized function.
  23714. *
  23715. * **Note:** The cache is exposed as the `cache` property on the memoized
  23716. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  23717. * constructor with one whose instances implement the
  23718. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  23719. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  23720. *
  23721. * @static
  23722. * @memberOf _
  23723. * @since 0.1.0
  23724. * @category Function
  23725. * @param {Function} func The function to have its output memoized.
  23726. * @param {Function} [resolver] The function to resolve the cache key.
  23727. * @returns {Function} Returns the new memoized function.
  23728. * @example
  23729. *
  23730. * var object = { 'a': 1, 'b': 2 };
  23731. * var other = { 'c': 3, 'd': 4 };
  23732. *
  23733. * var values = _.memoize(_.values);
  23734. * values(object);
  23735. * // => [1, 2]
  23736. *
  23737. * values(other);
  23738. * // => [3, 4]
  23739. *
  23740. * object.a = 2;
  23741. * values(object);
  23742. * // => [1, 2]
  23743. *
  23744. * // Modify the result cache.
  23745. * values.cache.set(object, ['a', 'b']);
  23746. * values(object);
  23747. * // => ['a', 'b']
  23748. *
  23749. * // Replace `_.memoize.Cache`.
  23750. * _.memoize.Cache = WeakMap;
  23751. */
  23752. function memoize(func, resolver) {
  23753. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  23754. throw new TypeError(FUNC_ERROR_TEXT);
  23755. }
  23756. var memoized = function() {
  23757. var args = arguments,
  23758. key = resolver ? resolver.apply(this, args) : args[0],
  23759. cache = memoized.cache;
  23760. if (cache.has(key)) {
  23761. return cache.get(key);
  23762. }
  23763. var result = func.apply(this, args);
  23764. memoized.cache = cache.set(key, result) || cache;
  23765. return result;
  23766. };
  23767. memoized.cache = new (memoize.Cache || MapCache);
  23768. return memoized;
  23769. }
  23770. // Expose `MapCache`.
  23771. memoize.Cache = MapCache;
  23772. /**
  23773. * Creates a function that negates the result of the predicate `func`. The
  23774. * `func` predicate is invoked with the `this` binding and arguments of the
  23775. * created function.
  23776. *
  23777. * @static
  23778. * @memberOf _
  23779. * @since 3.0.0
  23780. * @category Function
  23781. * @param {Function} predicate The predicate to negate.
  23782. * @returns {Function} Returns the new negated function.
  23783. * @example
  23784. *
  23785. * function isEven(n) {
  23786. * return n % 2 == 0;
  23787. * }
  23788. *
  23789. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  23790. * // => [1, 3, 5]
  23791. */
  23792. function negate(predicate) {
  23793. if (typeof predicate != 'function') {
  23794. throw new TypeError(FUNC_ERROR_TEXT);
  23795. }
  23796. return function() {
  23797. var args = arguments;
  23798. switch (args.length) {
  23799. case 0: return !predicate.call(this);
  23800. case 1: return !predicate.call(this, args[0]);
  23801. case 2: return !predicate.call(this, args[0], args[1]);
  23802. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  23803. }
  23804. return !predicate.apply(this, args);
  23805. };
  23806. }
  23807. /**
  23808. * Creates a function that is restricted to invoking `func` once. Repeat calls
  23809. * to the function return the value of the first invocation. The `func` is
  23810. * invoked with the `this` binding and arguments of the created function.
  23811. *
  23812. * @static
  23813. * @memberOf _
  23814. * @since 0.1.0
  23815. * @category Function
  23816. * @param {Function} func The function to restrict.
  23817. * @returns {Function} Returns the new restricted function.
  23818. * @example
  23819. *
  23820. * var initialize = _.once(createApplication);
  23821. * initialize();
  23822. * initialize();
  23823. * // => `createApplication` is invoked once
  23824. */
  23825. function once(func) {
  23826. return before(2, func);
  23827. }
  23828. /**
  23829. * Creates a function that invokes `func` with its arguments transformed.
  23830. *
  23831. * @static
  23832. * @since 4.0.0
  23833. * @memberOf _
  23834. * @category Function
  23835. * @param {Function} func The function to wrap.
  23836. * @param {...(Function|Function[])} [transforms=[_.identity]]
  23837. * The argument transforms.
  23838. * @returns {Function} Returns the new function.
  23839. * @example
  23840. *
  23841. * function doubled(n) {
  23842. * return n * 2;
  23843. * }
  23844. *
  23845. * function square(n) {
  23846. * return n * n;
  23847. * }
  23848. *
  23849. * var func = _.overArgs(function(x, y) {
  23850. * return [x, y];
  23851. * }, [square, doubled]);
  23852. *
  23853. * func(9, 3);
  23854. * // => [81, 6]
  23855. *
  23856. * func(10, 5);
  23857. * // => [100, 10]
  23858. */
  23859. var overArgs = castRest(function(func, transforms) {
  23860. transforms = (transforms.length == 1 && isArray(transforms[0]))
  23861. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  23862. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  23863. var funcsLength = transforms.length;
  23864. return baseRest(function(args) {
  23865. var index = -1,
  23866. length = nativeMin(args.length, funcsLength);
  23867. while (++index < length) {
  23868. args[index] = transforms[index].call(this, args[index]);
  23869. }
  23870. return apply(func, this, args);
  23871. });
  23872. });
  23873. /**
  23874. * Creates a function that invokes `func` with `partials` prepended to the
  23875. * arguments it receives. This method is like `_.bind` except it does **not**
  23876. * alter the `this` binding.
  23877. *
  23878. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  23879. * builds, may be used as a placeholder for partially applied arguments.
  23880. *
  23881. * **Note:** This method doesn't set the "length" property of partially
  23882. * applied functions.
  23883. *
  23884. * @static
  23885. * @memberOf _
  23886. * @since 0.2.0
  23887. * @category Function
  23888. * @param {Function} func The function to partially apply arguments to.
  23889. * @param {...*} [partials] The arguments to be partially applied.
  23890. * @returns {Function} Returns the new partially applied function.
  23891. * @example
  23892. *
  23893. * function greet(greeting, name) {
  23894. * return greeting + ' ' + name;
  23895. * }
  23896. *
  23897. * var sayHelloTo = _.partial(greet, 'hello');
  23898. * sayHelloTo('fred');
  23899. * // => 'hello fred'
  23900. *
  23901. * // Partially applied with placeholders.
  23902. * var greetFred = _.partial(greet, _, 'fred');
  23903. * greetFred('hi');
  23904. * // => 'hi fred'
  23905. */
  23906. var partial = baseRest(function(func, partials) {
  23907. var holders = replaceHolders(partials, getHolder(partial));
  23908. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  23909. });
  23910. /**
  23911. * This method is like `_.partial` except that partially applied arguments
  23912. * are appended to the arguments it receives.
  23913. *
  23914. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  23915. * builds, may be used as a placeholder for partially applied arguments.
  23916. *
  23917. * **Note:** This method doesn't set the "length" property of partially
  23918. * applied functions.
  23919. *
  23920. * @static
  23921. * @memberOf _
  23922. * @since 1.0.0
  23923. * @category Function
  23924. * @param {Function} func The function to partially apply arguments to.
  23925. * @param {...*} [partials] The arguments to be partially applied.
  23926. * @returns {Function} Returns the new partially applied function.
  23927. * @example
  23928. *
  23929. * function greet(greeting, name) {
  23930. * return greeting + ' ' + name;
  23931. * }
  23932. *
  23933. * var greetFred = _.partialRight(greet, 'fred');
  23934. * greetFred('hi');
  23935. * // => 'hi fred'
  23936. *
  23937. * // Partially applied with placeholders.
  23938. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  23939. * sayHelloTo('fred');
  23940. * // => 'hello fred'
  23941. */
  23942. var partialRight = baseRest(function(func, partials) {
  23943. var holders = replaceHolders(partials, getHolder(partialRight));
  23944. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  23945. });
  23946. /**
  23947. * Creates a function that invokes `func` with arguments arranged according
  23948. * to the specified `indexes` where the argument value at the first index is
  23949. * provided as the first argument, the argument value at the second index is
  23950. * provided as the second argument, and so on.
  23951. *
  23952. * @static
  23953. * @memberOf _
  23954. * @since 3.0.0
  23955. * @category Function
  23956. * @param {Function} func The function to rearrange arguments for.
  23957. * @param {...(number|number[])} indexes The arranged argument indexes.
  23958. * @returns {Function} Returns the new function.
  23959. * @example
  23960. *
  23961. * var rearged = _.rearg(function(a, b, c) {
  23962. * return [a, b, c];
  23963. * }, [2, 0, 1]);
  23964. *
  23965. * rearged('b', 'c', 'a')
  23966. * // => ['a', 'b', 'c']
  23967. */
  23968. var rearg = flatRest(function(func, indexes) {
  23969. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  23970. });
  23971. /**
  23972. * Creates a function that invokes `func` with the `this` binding of the
  23973. * created function and arguments from `start` and beyond provided as
  23974. * an array.
  23975. *
  23976. * **Note:** This method is based on the
  23977. * [rest parameter](https://mdn.io/rest_parameters).
  23978. *
  23979. * @static
  23980. * @memberOf _
  23981. * @since 4.0.0
  23982. * @category Function
  23983. * @param {Function} func The function to apply a rest parameter to.
  23984. * @param {number} [start=func.length-1] The start position of the rest parameter.
  23985. * @returns {Function} Returns the new function.
  23986. * @example
  23987. *
  23988. * var say = _.rest(function(what, names) {
  23989. * return what + ' ' + _.initial(names).join(', ') +
  23990. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  23991. * });
  23992. *
  23993. * say('hello', 'fred', 'barney', 'pebbles');
  23994. * // => 'hello fred, barney, & pebbles'
  23995. */
  23996. function rest(func, start) {
  23997. if (typeof func != 'function') {
  23998. throw new TypeError(FUNC_ERROR_TEXT);
  23999. }
  24000. start = start === undefined ? start : toInteger(start);
  24001. return baseRest(func, start);
  24002. }
  24003. /**
  24004. * Creates a function that invokes `func` with the `this` binding of the
  24005. * create function and an array of arguments much like
  24006. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  24007. *
  24008. * **Note:** This method is based on the
  24009. * [spread operator](https://mdn.io/spread_operator).
  24010. *
  24011. * @static
  24012. * @memberOf _
  24013. * @since 3.2.0
  24014. * @category Function
  24015. * @param {Function} func The function to spread arguments over.
  24016. * @param {number} [start=0] The start position of the spread.
  24017. * @returns {Function} Returns the new function.
  24018. * @example
  24019. *
  24020. * var say = _.spread(function(who, what) {
  24021. * return who + ' says ' + what;
  24022. * });
  24023. *
  24024. * say(['fred', 'hello']);
  24025. * // => 'fred says hello'
  24026. *
  24027. * var numbers = Promise.all([
  24028. * Promise.resolve(40),
  24029. * Promise.resolve(36)
  24030. * ]);
  24031. *
  24032. * numbers.then(_.spread(function(x, y) {
  24033. * return x + y;
  24034. * }));
  24035. * // => a Promise of 76
  24036. */
  24037. function spread(func, start) {
  24038. if (typeof func != 'function') {
  24039. throw new TypeError(FUNC_ERROR_TEXT);
  24040. }
  24041. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  24042. return baseRest(function(args) {
  24043. var array = args[start],
  24044. otherArgs = castSlice(args, 0, start);
  24045. if (array) {
  24046. arrayPush(otherArgs, array);
  24047. }
  24048. return apply(func, this, otherArgs);
  24049. });
  24050. }
  24051. /**
  24052. * Creates a throttled function that only invokes `func` at most once per
  24053. * every `wait` milliseconds. The throttled function comes with a `cancel`
  24054. * method to cancel delayed `func` invocations and a `flush` method to
  24055. * immediately invoke them. Provide `options` to indicate whether `func`
  24056. * should be invoked on the leading and/or trailing edge of the `wait`
  24057. * timeout. The `func` is invoked with the last arguments provided to the
  24058. * throttled function. Subsequent calls to the throttled function return the
  24059. * result of the last `func` invocation.
  24060. *
  24061. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  24062. * invoked on the trailing edge of the timeout only if the throttled function
  24063. * is invoked more than once during the `wait` timeout.
  24064. *
  24065. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  24066. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  24067. *
  24068. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  24069. * for details over the differences between `_.throttle` and `_.debounce`.
  24070. *
  24071. * @static
  24072. * @memberOf _
  24073. * @since 0.1.0
  24074. * @category Function
  24075. * @param {Function} func The function to throttle.
  24076. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  24077. * @param {Object} [options={}] The options object.
  24078. * @param {boolean} [options.leading=true]
  24079. * Specify invoking on the leading edge of the timeout.
  24080. * @param {boolean} [options.trailing=true]
  24081. * Specify invoking on the trailing edge of the timeout.
  24082. * @returns {Function} Returns the new throttled function.
  24083. * @example
  24084. *
  24085. * // Avoid excessively updating the position while scrolling.
  24086. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  24087. *
  24088. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  24089. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  24090. * jQuery(element).on('click', throttled);
  24091. *
  24092. * // Cancel the trailing throttled invocation.
  24093. * jQuery(window).on('popstate', throttled.cancel);
  24094. */
  24095. function throttle(func, wait, options) {
  24096. var leading = true,
  24097. trailing = true;
  24098. if (typeof func != 'function') {
  24099. throw new TypeError(FUNC_ERROR_TEXT);
  24100. }
  24101. if (isObject(options)) {
  24102. leading = 'leading' in options ? !!options.leading : leading;
  24103. trailing = 'trailing' in options ? !!options.trailing : trailing;
  24104. }
  24105. return debounce(func, wait, {
  24106. 'leading': leading,
  24107. 'maxWait': wait,
  24108. 'trailing': trailing
  24109. });
  24110. }
  24111. /**
  24112. * Creates a function that accepts up to one argument, ignoring any
  24113. * additional arguments.
  24114. *
  24115. * @static
  24116. * @memberOf _
  24117. * @since 4.0.0
  24118. * @category Function
  24119. * @param {Function} func The function to cap arguments for.
  24120. * @returns {Function} Returns the new capped function.
  24121. * @example
  24122. *
  24123. * _.map(['6', '8', '10'], _.unary(parseInt));
  24124. * // => [6, 8, 10]
  24125. */
  24126. function unary(func) {
  24127. return ary(func, 1);
  24128. }
  24129. /**
  24130. * Creates a function that provides `value` to `wrapper` as its first
  24131. * argument. Any additional arguments provided to the function are appended
  24132. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  24133. * binding of the created function.
  24134. *
  24135. * @static
  24136. * @memberOf _
  24137. * @since 0.1.0
  24138. * @category Function
  24139. * @param {*} value The value to wrap.
  24140. * @param {Function} [wrapper=identity] The wrapper function.
  24141. * @returns {Function} Returns the new function.
  24142. * @example
  24143. *
  24144. * var p = _.wrap(_.escape, function(func, text) {
  24145. * return '<p>' + func(text) + '</p>';
  24146. * });
  24147. *
  24148. * p('fred, barney, & pebbles');
  24149. * // => '<p>fred, barney, &amp; pebbles</p>'
  24150. */
  24151. function wrap(value, wrapper) {
  24152. return partial(castFunction(wrapper), value);
  24153. }
  24154. /*------------------------------------------------------------------------*/
  24155. /**
  24156. * Casts `value` as an array if it's not one.
  24157. *
  24158. * @static
  24159. * @memberOf _
  24160. * @since 4.4.0
  24161. * @category Lang
  24162. * @param {*} value The value to inspect.
  24163. * @returns {Array} Returns the cast array.
  24164. * @example
  24165. *
  24166. * _.castArray(1);
  24167. * // => [1]
  24168. *
  24169. * _.castArray({ 'a': 1 });
  24170. * // => [{ 'a': 1 }]
  24171. *
  24172. * _.castArray('abc');
  24173. * // => ['abc']
  24174. *
  24175. * _.castArray(null);
  24176. * // => [null]
  24177. *
  24178. * _.castArray(undefined);
  24179. * // => [undefined]
  24180. *
  24181. * _.castArray();
  24182. * // => []
  24183. *
  24184. * var array = [1, 2, 3];
  24185. * console.log(_.castArray(array) === array);
  24186. * // => true
  24187. */
  24188. function castArray() {
  24189. if (!arguments.length) {
  24190. return [];
  24191. }
  24192. var value = arguments[0];
  24193. return isArray(value) ? value : [value];
  24194. }
  24195. /**
  24196. * Creates a shallow clone of `value`.
  24197. *
  24198. * **Note:** This method is loosely based on the
  24199. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  24200. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  24201. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  24202. * arrays. The own enumerable properties of `arguments` objects are cloned
  24203. * as plain objects. An empty object is returned for uncloneable values such
  24204. * as error objects, functions, DOM nodes, and WeakMaps.
  24205. *
  24206. * @static
  24207. * @memberOf _
  24208. * @since 0.1.0
  24209. * @category Lang
  24210. * @param {*} value The value to clone.
  24211. * @returns {*} Returns the cloned value.
  24212. * @see _.cloneDeep
  24213. * @example
  24214. *
  24215. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  24216. *
  24217. * var shallow = _.clone(objects);
  24218. * console.log(shallow[0] === objects[0]);
  24219. * // => true
  24220. */
  24221. function clone(value) {
  24222. return baseClone(value, CLONE_SYMBOLS_FLAG);
  24223. }
  24224. /**
  24225. * This method is like `_.clone` except that it accepts `customizer` which
  24226. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  24227. * cloning is handled by the method instead. The `customizer` is invoked with
  24228. * up to four arguments; (value [, index|key, object, stack]).
  24229. *
  24230. * @static
  24231. * @memberOf _
  24232. * @since 4.0.0
  24233. * @category Lang
  24234. * @param {*} value The value to clone.
  24235. * @param {Function} [customizer] The function to customize cloning.
  24236. * @returns {*} Returns the cloned value.
  24237. * @see _.cloneDeepWith
  24238. * @example
  24239. *
  24240. * function customizer(value) {
  24241. * if (_.isElement(value)) {
  24242. * return value.cloneNode(false);
  24243. * }
  24244. * }
  24245. *
  24246. * var el = _.cloneWith(document.body, customizer);
  24247. *
  24248. * console.log(el === document.body);
  24249. * // => false
  24250. * console.log(el.nodeName);
  24251. * // => 'BODY'
  24252. * console.log(el.childNodes.length);
  24253. * // => 0
  24254. */
  24255. function cloneWith(value, customizer) {
  24256. customizer = typeof customizer == 'function' ? customizer : undefined;
  24257. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  24258. }
  24259. /**
  24260. * This method is like `_.clone` except that it recursively clones `value`.
  24261. *
  24262. * @static
  24263. * @memberOf _
  24264. * @since 1.0.0
  24265. * @category Lang
  24266. * @param {*} value The value to recursively clone.
  24267. * @returns {*} Returns the deep cloned value.
  24268. * @see _.clone
  24269. * @example
  24270. *
  24271. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  24272. *
  24273. * var deep = _.cloneDeep(objects);
  24274. * console.log(deep[0] === objects[0]);
  24275. * // => false
  24276. */
  24277. function cloneDeep(value) {
  24278. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  24279. }
  24280. /**
  24281. * This method is like `_.cloneWith` except that it recursively clones `value`.
  24282. *
  24283. * @static
  24284. * @memberOf _
  24285. * @since 4.0.0
  24286. * @category Lang
  24287. * @param {*} value The value to recursively clone.
  24288. * @param {Function} [customizer] The function to customize cloning.
  24289. * @returns {*} Returns the deep cloned value.
  24290. * @see _.cloneWith
  24291. * @example
  24292. *
  24293. * function customizer(value) {
  24294. * if (_.isElement(value)) {
  24295. * return value.cloneNode(true);
  24296. * }
  24297. * }
  24298. *
  24299. * var el = _.cloneDeepWith(document.body, customizer);
  24300. *
  24301. * console.log(el === document.body);
  24302. * // => false
  24303. * console.log(el.nodeName);
  24304. * // => 'BODY'
  24305. * console.log(el.childNodes.length);
  24306. * // => 20
  24307. */
  24308. function cloneDeepWith(value, customizer) {
  24309. customizer = typeof customizer == 'function' ? customizer : undefined;
  24310. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  24311. }
  24312. /**
  24313. * Checks if `object` conforms to `source` by invoking the predicate
  24314. * properties of `source` with the corresponding property values of `object`.
  24315. *
  24316. * **Note:** This method is equivalent to `_.conforms` when `source` is
  24317. * partially applied.
  24318. *
  24319. * @static
  24320. * @memberOf _
  24321. * @since 4.14.0
  24322. * @category Lang
  24323. * @param {Object} object The object to inspect.
  24324. * @param {Object} source The object of property predicates to conform to.
  24325. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  24326. * @example
  24327. *
  24328. * var object = { 'a': 1, 'b': 2 };
  24329. *
  24330. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  24331. * // => true
  24332. *
  24333. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  24334. * // => false
  24335. */
  24336. function conformsTo(object, source) {
  24337. return source == null || baseConformsTo(object, source, keys(source));
  24338. }
  24339. /**
  24340. * Performs a
  24341. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24342. * comparison between two values to determine if they are equivalent.
  24343. *
  24344. * @static
  24345. * @memberOf _
  24346. * @since 4.0.0
  24347. * @category Lang
  24348. * @param {*} value The value to compare.
  24349. * @param {*} other The other value to compare.
  24350. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  24351. * @example
  24352. *
  24353. * var object = { 'a': 1 };
  24354. * var other = { 'a': 1 };
  24355. *
  24356. * _.eq(object, object);
  24357. * // => true
  24358. *
  24359. * _.eq(object, other);
  24360. * // => false
  24361. *
  24362. * _.eq('a', 'a');
  24363. * // => true
  24364. *
  24365. * _.eq('a', Object('a'));
  24366. * // => false
  24367. *
  24368. * _.eq(NaN, NaN);
  24369. * // => true
  24370. */
  24371. function eq(value, other) {
  24372. return value === other || (value !== value && other !== other);
  24373. }
  24374. /**
  24375. * Checks if `value` is greater than `other`.
  24376. *
  24377. * @static
  24378. * @memberOf _
  24379. * @since 3.9.0
  24380. * @category Lang
  24381. * @param {*} value The value to compare.
  24382. * @param {*} other The other value to compare.
  24383. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  24384. * else `false`.
  24385. * @see _.lt
  24386. * @example
  24387. *
  24388. * _.gt(3, 1);
  24389. * // => true
  24390. *
  24391. * _.gt(3, 3);
  24392. * // => false
  24393. *
  24394. * _.gt(1, 3);
  24395. * // => false
  24396. */
  24397. var gt = createRelationalOperation(baseGt);
  24398. /**
  24399. * Checks if `value` is greater than or equal to `other`.
  24400. *
  24401. * @static
  24402. * @memberOf _
  24403. * @since 3.9.0
  24404. * @category Lang
  24405. * @param {*} value The value to compare.
  24406. * @param {*} other The other value to compare.
  24407. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  24408. * `other`, else `false`.
  24409. * @see _.lte
  24410. * @example
  24411. *
  24412. * _.gte(3, 1);
  24413. * // => true
  24414. *
  24415. * _.gte(3, 3);
  24416. * // => true
  24417. *
  24418. * _.gte(1, 3);
  24419. * // => false
  24420. */
  24421. var gte = createRelationalOperation(function(value, other) {
  24422. return value >= other;
  24423. });
  24424. /**
  24425. * Checks if `value` is likely an `arguments` object.
  24426. *
  24427. * @static
  24428. * @memberOf _
  24429. * @since 0.1.0
  24430. * @category Lang
  24431. * @param {*} value The value to check.
  24432. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  24433. * else `false`.
  24434. * @example
  24435. *
  24436. * _.isArguments(function() { return arguments; }());
  24437. * // => true
  24438. *
  24439. * _.isArguments([1, 2, 3]);
  24440. * // => false
  24441. */
  24442. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  24443. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  24444. !propertyIsEnumerable.call(value, 'callee');
  24445. };
  24446. /**
  24447. * Checks if `value` is classified as an `Array` object.
  24448. *
  24449. * @static
  24450. * @memberOf _
  24451. * @since 0.1.0
  24452. * @category Lang
  24453. * @param {*} value The value to check.
  24454. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  24455. * @example
  24456. *
  24457. * _.isArray([1, 2, 3]);
  24458. * // => true
  24459. *
  24460. * _.isArray(document.body.children);
  24461. * // => false
  24462. *
  24463. * _.isArray('abc');
  24464. * // => false
  24465. *
  24466. * _.isArray(_.noop);
  24467. * // => false
  24468. */
  24469. var isArray = Array.isArray;
  24470. /**
  24471. * Checks if `value` is classified as an `ArrayBuffer` object.
  24472. *
  24473. * @static
  24474. * @memberOf _
  24475. * @since 4.3.0
  24476. * @category Lang
  24477. * @param {*} value The value to check.
  24478. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  24479. * @example
  24480. *
  24481. * _.isArrayBuffer(new ArrayBuffer(2));
  24482. * // => true
  24483. *
  24484. * _.isArrayBuffer(new Array(2));
  24485. * // => false
  24486. */
  24487. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  24488. /**
  24489. * Checks if `value` is array-like. A value is considered array-like if it's
  24490. * not a function and has a `value.length` that's an integer greater than or
  24491. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  24492. *
  24493. * @static
  24494. * @memberOf _
  24495. * @since 4.0.0
  24496. * @category Lang
  24497. * @param {*} value The value to check.
  24498. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  24499. * @example
  24500. *
  24501. * _.isArrayLike([1, 2, 3]);
  24502. * // => true
  24503. *
  24504. * _.isArrayLike(document.body.children);
  24505. * // => true
  24506. *
  24507. * _.isArrayLike('abc');
  24508. * // => true
  24509. *
  24510. * _.isArrayLike(_.noop);
  24511. * // => false
  24512. */
  24513. function isArrayLike(value) {
  24514. return value != null && isLength(value.length) && !isFunction(value);
  24515. }
  24516. /**
  24517. * This method is like `_.isArrayLike` except that it also checks if `value`
  24518. * is an object.
  24519. *
  24520. * @static
  24521. * @memberOf _
  24522. * @since 4.0.0
  24523. * @category Lang
  24524. * @param {*} value The value to check.
  24525. * @returns {boolean} Returns `true` if `value` is an array-like object,
  24526. * else `false`.
  24527. * @example
  24528. *
  24529. * _.isArrayLikeObject([1, 2, 3]);
  24530. * // => true
  24531. *
  24532. * _.isArrayLikeObject(document.body.children);
  24533. * // => true
  24534. *
  24535. * _.isArrayLikeObject('abc');
  24536. * // => false
  24537. *
  24538. * _.isArrayLikeObject(_.noop);
  24539. * // => false
  24540. */
  24541. function isArrayLikeObject(value) {
  24542. return isObjectLike(value) && isArrayLike(value);
  24543. }
  24544. /**
  24545. * Checks if `value` is classified as a boolean primitive or object.
  24546. *
  24547. * @static
  24548. * @memberOf _
  24549. * @since 0.1.0
  24550. * @category Lang
  24551. * @param {*} value The value to check.
  24552. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  24553. * @example
  24554. *
  24555. * _.isBoolean(false);
  24556. * // => true
  24557. *
  24558. * _.isBoolean(null);
  24559. * // => false
  24560. */
  24561. function isBoolean(value) {
  24562. return value === true || value === false ||
  24563. (isObjectLike(value) && baseGetTag(value) == boolTag);
  24564. }
  24565. /**
  24566. * Checks if `value` is a buffer.
  24567. *
  24568. * @static
  24569. * @memberOf _
  24570. * @since 4.3.0
  24571. * @category Lang
  24572. * @param {*} value The value to check.
  24573. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  24574. * @example
  24575. *
  24576. * _.isBuffer(new Buffer(2));
  24577. * // => true
  24578. *
  24579. * _.isBuffer(new Uint8Array(2));
  24580. * // => false
  24581. */
  24582. var isBuffer = nativeIsBuffer || stubFalse;
  24583. /**
  24584. * Checks if `value` is classified as a `Date` object.
  24585. *
  24586. * @static
  24587. * @memberOf _
  24588. * @since 0.1.0
  24589. * @category Lang
  24590. * @param {*} value The value to check.
  24591. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  24592. * @example
  24593. *
  24594. * _.isDate(new Date);
  24595. * // => true
  24596. *
  24597. * _.isDate('Mon April 23 2012');
  24598. * // => false
  24599. */
  24600. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  24601. /**
  24602. * Checks if `value` is likely a DOM element.
  24603. *
  24604. * @static
  24605. * @memberOf _
  24606. * @since 0.1.0
  24607. * @category Lang
  24608. * @param {*} value The value to check.
  24609. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  24610. * @example
  24611. *
  24612. * _.isElement(document.body);
  24613. * // => true
  24614. *
  24615. * _.isElement('<body>');
  24616. * // => false
  24617. */
  24618. function isElement(value) {
  24619. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  24620. }
  24621. /**
  24622. * Checks if `value` is an empty object, collection, map, or set.
  24623. *
  24624. * Objects are considered empty if they have no own enumerable string keyed
  24625. * properties.
  24626. *
  24627. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  24628. * jQuery-like collections are considered empty if they have a `length` of `0`.
  24629. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  24630. *
  24631. * @static
  24632. * @memberOf _
  24633. * @since 0.1.0
  24634. * @category Lang
  24635. * @param {*} value The value to check.
  24636. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  24637. * @example
  24638. *
  24639. * _.isEmpty(null);
  24640. * // => true
  24641. *
  24642. * _.isEmpty(true);
  24643. * // => true
  24644. *
  24645. * _.isEmpty(1);
  24646. * // => true
  24647. *
  24648. * _.isEmpty([1, 2, 3]);
  24649. * // => false
  24650. *
  24651. * _.isEmpty({ 'a': 1 });
  24652. * // => false
  24653. */
  24654. function isEmpty(value) {
  24655. if (value == null) {
  24656. return true;
  24657. }
  24658. if (isArrayLike(value) &&
  24659. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  24660. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  24661. return !value.length;
  24662. }
  24663. var tag = getTag(value);
  24664. if (tag == mapTag || tag == setTag) {
  24665. return !value.size;
  24666. }
  24667. if (isPrototype(value)) {
  24668. return !baseKeys(value).length;
  24669. }
  24670. for (var key in value) {
  24671. if (hasOwnProperty.call(value, key)) {
  24672. return false;
  24673. }
  24674. }
  24675. return true;
  24676. }
  24677. /**
  24678. * Performs a deep comparison between two values to determine if they are
  24679. * equivalent.
  24680. *
  24681. * **Note:** This method supports comparing arrays, array buffers, booleans,
  24682. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  24683. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  24684. * by their own, not inherited, enumerable properties. Functions and DOM
  24685. * nodes are compared by strict equality, i.e. `===`.
  24686. *
  24687. * @static
  24688. * @memberOf _
  24689. * @since 0.1.0
  24690. * @category Lang
  24691. * @param {*} value The value to compare.
  24692. * @param {*} other The other value to compare.
  24693. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  24694. * @example
  24695. *
  24696. * var object = { 'a': 1 };
  24697. * var other = { 'a': 1 };
  24698. *
  24699. * _.isEqual(object, other);
  24700. * // => true
  24701. *
  24702. * object === other;
  24703. * // => false
  24704. */
  24705. function isEqual(value, other) {
  24706. return baseIsEqual(value, other);
  24707. }
  24708. /**
  24709. * This method is like `_.isEqual` except that it accepts `customizer` which
  24710. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  24711. * are handled by the method instead. The `customizer` is invoked with up to
  24712. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  24713. *
  24714. * @static
  24715. * @memberOf _
  24716. * @since 4.0.0
  24717. * @category Lang
  24718. * @param {*} value The value to compare.
  24719. * @param {*} other The other value to compare.
  24720. * @param {Function} [customizer] The function to customize comparisons.
  24721. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  24722. * @example
  24723. *
  24724. * function isGreeting(value) {
  24725. * return /^h(?:i|ello)$/.test(value);
  24726. * }
  24727. *
  24728. * function customizer(objValue, othValue) {
  24729. * if (isGreeting(objValue) && isGreeting(othValue)) {
  24730. * return true;
  24731. * }
  24732. * }
  24733. *
  24734. * var array = ['hello', 'goodbye'];
  24735. * var other = ['hi', 'goodbye'];
  24736. *
  24737. * _.isEqualWith(array, other, customizer);
  24738. * // => true
  24739. */
  24740. function isEqualWith(value, other, customizer) {
  24741. customizer = typeof customizer == 'function' ? customizer : undefined;
  24742. var result = customizer ? customizer(value, other) : undefined;
  24743. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  24744. }
  24745. /**
  24746. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  24747. * `SyntaxError`, `TypeError`, or `URIError` object.
  24748. *
  24749. * @static
  24750. * @memberOf _
  24751. * @since 3.0.0
  24752. * @category Lang
  24753. * @param {*} value The value to check.
  24754. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  24755. * @example
  24756. *
  24757. * _.isError(new Error);
  24758. * // => true
  24759. *
  24760. * _.isError(Error);
  24761. * // => false
  24762. */
  24763. function isError(value) {
  24764. if (!isObjectLike(value)) {
  24765. return false;
  24766. }
  24767. var tag = baseGetTag(value);
  24768. return tag == errorTag || tag == domExcTag ||
  24769. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  24770. }
  24771. /**
  24772. * Checks if `value` is a finite primitive number.
  24773. *
  24774. * **Note:** This method is based on
  24775. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  24776. *
  24777. * @static
  24778. * @memberOf _
  24779. * @since 0.1.0
  24780. * @category Lang
  24781. * @param {*} value The value to check.
  24782. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  24783. * @example
  24784. *
  24785. * _.isFinite(3);
  24786. * // => true
  24787. *
  24788. * _.isFinite(Number.MIN_VALUE);
  24789. * // => true
  24790. *
  24791. * _.isFinite(Infinity);
  24792. * // => false
  24793. *
  24794. * _.isFinite('3');
  24795. * // => false
  24796. */
  24797. function isFinite(value) {
  24798. return typeof value == 'number' && nativeIsFinite(value);
  24799. }
  24800. /**
  24801. * Checks if `value` is classified as a `Function` object.
  24802. *
  24803. * @static
  24804. * @memberOf _
  24805. * @since 0.1.0
  24806. * @category Lang
  24807. * @param {*} value The value to check.
  24808. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  24809. * @example
  24810. *
  24811. * _.isFunction(_);
  24812. * // => true
  24813. *
  24814. * _.isFunction(/abc/);
  24815. * // => false
  24816. */
  24817. function isFunction(value) {
  24818. if (!isObject(value)) {
  24819. return false;
  24820. }
  24821. // The use of `Object#toString` avoids issues with the `typeof` operator
  24822. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  24823. var tag = baseGetTag(value);
  24824. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  24825. }
  24826. /**
  24827. * Checks if `value` is an integer.
  24828. *
  24829. * **Note:** This method is based on
  24830. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  24831. *
  24832. * @static
  24833. * @memberOf _
  24834. * @since 4.0.0
  24835. * @category Lang
  24836. * @param {*} value The value to check.
  24837. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  24838. * @example
  24839. *
  24840. * _.isInteger(3);
  24841. * // => true
  24842. *
  24843. * _.isInteger(Number.MIN_VALUE);
  24844. * // => false
  24845. *
  24846. * _.isInteger(Infinity);
  24847. * // => false
  24848. *
  24849. * _.isInteger('3');
  24850. * // => false
  24851. */
  24852. function isInteger(value) {
  24853. return typeof value == 'number' && value == toInteger(value);
  24854. }
  24855. /**
  24856. * Checks if `value` is a valid array-like length.
  24857. *
  24858. * **Note:** This method is loosely based on
  24859. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  24860. *
  24861. * @static
  24862. * @memberOf _
  24863. * @since 4.0.0
  24864. * @category Lang
  24865. * @param {*} value The value to check.
  24866. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  24867. * @example
  24868. *
  24869. * _.isLength(3);
  24870. * // => true
  24871. *
  24872. * _.isLength(Number.MIN_VALUE);
  24873. * // => false
  24874. *
  24875. * _.isLength(Infinity);
  24876. * // => false
  24877. *
  24878. * _.isLength('3');
  24879. * // => false
  24880. */
  24881. function isLength(value) {
  24882. return typeof value == 'number' &&
  24883. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  24884. }
  24885. /**
  24886. * Checks if `value` is the
  24887. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  24888. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  24889. *
  24890. * @static
  24891. * @memberOf _
  24892. * @since 0.1.0
  24893. * @category Lang
  24894. * @param {*} value The value to check.
  24895. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  24896. * @example
  24897. *
  24898. * _.isObject({});
  24899. * // => true
  24900. *
  24901. * _.isObject([1, 2, 3]);
  24902. * // => true
  24903. *
  24904. * _.isObject(_.noop);
  24905. * // => true
  24906. *
  24907. * _.isObject(null);
  24908. * // => false
  24909. */
  24910. function isObject(value) {
  24911. var type = typeof value;
  24912. return value != null && (type == 'object' || type == 'function');
  24913. }
  24914. /**
  24915. * Checks if `value` is object-like. A value is object-like if it's not `null`
  24916. * and has a `typeof` result of "object".
  24917. *
  24918. * @static
  24919. * @memberOf _
  24920. * @since 4.0.0
  24921. * @category Lang
  24922. * @param {*} value The value to check.
  24923. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  24924. * @example
  24925. *
  24926. * _.isObjectLike({});
  24927. * // => true
  24928. *
  24929. * _.isObjectLike([1, 2, 3]);
  24930. * // => true
  24931. *
  24932. * _.isObjectLike(_.noop);
  24933. * // => false
  24934. *
  24935. * _.isObjectLike(null);
  24936. * // => false
  24937. */
  24938. function isObjectLike(value) {
  24939. return value != null && typeof value == 'object';
  24940. }
  24941. /**
  24942. * Checks if `value` is classified as a `Map` object.
  24943. *
  24944. * @static
  24945. * @memberOf _
  24946. * @since 4.3.0
  24947. * @category Lang
  24948. * @param {*} value The value to check.
  24949. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  24950. * @example
  24951. *
  24952. * _.isMap(new Map);
  24953. * // => true
  24954. *
  24955. * _.isMap(new WeakMap);
  24956. * // => false
  24957. */
  24958. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  24959. /**
  24960. * Performs a partial deep comparison between `object` and `source` to
  24961. * determine if `object` contains equivalent property values.
  24962. *
  24963. * **Note:** This method is equivalent to `_.matches` when `source` is
  24964. * partially applied.
  24965. *
  24966. * Partial comparisons will match empty array and empty object `source`
  24967. * values against any array or object value, respectively. See `_.isEqual`
  24968. * for a list of supported value comparisons.
  24969. *
  24970. * @static
  24971. * @memberOf _
  24972. * @since 3.0.0
  24973. * @category Lang
  24974. * @param {Object} object The object to inspect.
  24975. * @param {Object} source The object of property values to match.
  24976. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  24977. * @example
  24978. *
  24979. * var object = { 'a': 1, 'b': 2 };
  24980. *
  24981. * _.isMatch(object, { 'b': 2 });
  24982. * // => true
  24983. *
  24984. * _.isMatch(object, { 'b': 1 });
  24985. * // => false
  24986. */
  24987. function isMatch(object, source) {
  24988. return object === source || baseIsMatch(object, source, getMatchData(source));
  24989. }
  24990. /**
  24991. * This method is like `_.isMatch` except that it accepts `customizer` which
  24992. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  24993. * are handled by the method instead. The `customizer` is invoked with five
  24994. * arguments: (objValue, srcValue, index|key, object, source).
  24995. *
  24996. * @static
  24997. * @memberOf _
  24998. * @since 4.0.0
  24999. * @category Lang
  25000. * @param {Object} object The object to inspect.
  25001. * @param {Object} source The object of property values to match.
  25002. * @param {Function} [customizer] The function to customize comparisons.
  25003. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  25004. * @example
  25005. *
  25006. * function isGreeting(value) {
  25007. * return /^h(?:i|ello)$/.test(value);
  25008. * }
  25009. *
  25010. * function customizer(objValue, srcValue) {
  25011. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  25012. * return true;
  25013. * }
  25014. * }
  25015. *
  25016. * var object = { 'greeting': 'hello' };
  25017. * var source = { 'greeting': 'hi' };
  25018. *
  25019. * _.isMatchWith(object, source, customizer);
  25020. * // => true
  25021. */
  25022. function isMatchWith(object, source, customizer) {
  25023. customizer = typeof customizer == 'function' ? customizer : undefined;
  25024. return baseIsMatch(object, source, getMatchData(source), customizer);
  25025. }
  25026. /**
  25027. * Checks if `value` is `NaN`.
  25028. *
  25029. * **Note:** This method is based on
  25030. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  25031. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  25032. * `undefined` and other non-number values.
  25033. *
  25034. * @static
  25035. * @memberOf _
  25036. * @since 0.1.0
  25037. * @category Lang
  25038. * @param {*} value The value to check.
  25039. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  25040. * @example
  25041. *
  25042. * _.isNaN(NaN);
  25043. * // => true
  25044. *
  25045. * _.isNaN(new Number(NaN));
  25046. * // => true
  25047. *
  25048. * isNaN(undefined);
  25049. * // => true
  25050. *
  25051. * _.isNaN(undefined);
  25052. * // => false
  25053. */
  25054. function isNaN(value) {
  25055. // An `NaN` primitive is the only value that is not equal to itself.
  25056. // Perform the `toStringTag` check first to avoid errors with some
  25057. // ActiveX objects in IE.
  25058. return isNumber(value) && value != +value;
  25059. }
  25060. /**
  25061. * Checks if `value` is a pristine native function.
  25062. *
  25063. * **Note:** This method can't reliably detect native functions in the presence
  25064. * of the core-js package because core-js circumvents this kind of detection.
  25065. * Despite multiple requests, the core-js maintainer has made it clear: any
  25066. * attempt to fix the detection will be obstructed. As a result, we're left
  25067. * with little choice but to throw an error. Unfortunately, this also affects
  25068. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  25069. * which rely on core-js.
  25070. *
  25071. * @static
  25072. * @memberOf _
  25073. * @since 3.0.0
  25074. * @category Lang
  25075. * @param {*} value The value to check.
  25076. * @returns {boolean} Returns `true` if `value` is a native function,
  25077. * else `false`.
  25078. * @example
  25079. *
  25080. * _.isNative(Array.prototype.push);
  25081. * // => true
  25082. *
  25083. * _.isNative(_);
  25084. * // => false
  25085. */
  25086. function isNative(value) {
  25087. if (isMaskable(value)) {
  25088. throw new Error(CORE_ERROR_TEXT);
  25089. }
  25090. return baseIsNative(value);
  25091. }
  25092. /**
  25093. * Checks if `value` is `null`.
  25094. *
  25095. * @static
  25096. * @memberOf _
  25097. * @since 0.1.0
  25098. * @category Lang
  25099. * @param {*} value The value to check.
  25100. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  25101. * @example
  25102. *
  25103. * _.isNull(null);
  25104. * // => true
  25105. *
  25106. * _.isNull(void 0);
  25107. * // => false
  25108. */
  25109. function isNull(value) {
  25110. return value === null;
  25111. }
  25112. /**
  25113. * Checks if `value` is `null` or `undefined`.
  25114. *
  25115. * @static
  25116. * @memberOf _
  25117. * @since 4.0.0
  25118. * @category Lang
  25119. * @param {*} value The value to check.
  25120. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  25121. * @example
  25122. *
  25123. * _.isNil(null);
  25124. * // => true
  25125. *
  25126. * _.isNil(void 0);
  25127. * // => true
  25128. *
  25129. * _.isNil(NaN);
  25130. * // => false
  25131. */
  25132. function isNil(value) {
  25133. return value == null;
  25134. }
  25135. /**
  25136. * Checks if `value` is classified as a `Number` primitive or object.
  25137. *
  25138. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  25139. * classified as numbers, use the `_.isFinite` method.
  25140. *
  25141. * @static
  25142. * @memberOf _
  25143. * @since 0.1.0
  25144. * @category Lang
  25145. * @param {*} value The value to check.
  25146. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  25147. * @example
  25148. *
  25149. * _.isNumber(3);
  25150. * // => true
  25151. *
  25152. * _.isNumber(Number.MIN_VALUE);
  25153. * // => true
  25154. *
  25155. * _.isNumber(Infinity);
  25156. * // => true
  25157. *
  25158. * _.isNumber('3');
  25159. * // => false
  25160. */
  25161. function isNumber(value) {
  25162. return typeof value == 'number' ||
  25163. (isObjectLike(value) && baseGetTag(value) == numberTag);
  25164. }
  25165. /**
  25166. * Checks if `value` is a plain object, that is, an object created by the
  25167. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  25168. *
  25169. * @static
  25170. * @memberOf _
  25171. * @since 0.8.0
  25172. * @category Lang
  25173. * @param {*} value The value to check.
  25174. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  25175. * @example
  25176. *
  25177. * function Foo() {
  25178. * this.a = 1;
  25179. * }
  25180. *
  25181. * _.isPlainObject(new Foo);
  25182. * // => false
  25183. *
  25184. * _.isPlainObject([1, 2, 3]);
  25185. * // => false
  25186. *
  25187. * _.isPlainObject({ 'x': 0, 'y': 0 });
  25188. * // => true
  25189. *
  25190. * _.isPlainObject(Object.create(null));
  25191. * // => true
  25192. */
  25193. function isPlainObject(value) {
  25194. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  25195. return false;
  25196. }
  25197. var proto = getPrototype(value);
  25198. if (proto === null) {
  25199. return true;
  25200. }
  25201. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  25202. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  25203. funcToString.call(Ctor) == objectCtorString;
  25204. }
  25205. /**
  25206. * Checks if `value` is classified as a `RegExp` object.
  25207. *
  25208. * @static
  25209. * @memberOf _
  25210. * @since 0.1.0
  25211. * @category Lang
  25212. * @param {*} value The value to check.
  25213. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  25214. * @example
  25215. *
  25216. * _.isRegExp(/abc/);
  25217. * // => true
  25218. *
  25219. * _.isRegExp('/abc/');
  25220. * // => false
  25221. */
  25222. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  25223. /**
  25224. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  25225. * double precision number which isn't the result of a rounded unsafe integer.
  25226. *
  25227. * **Note:** This method is based on
  25228. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  25229. *
  25230. * @static
  25231. * @memberOf _
  25232. * @since 4.0.0
  25233. * @category Lang
  25234. * @param {*} value The value to check.
  25235. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  25236. * @example
  25237. *
  25238. * _.isSafeInteger(3);
  25239. * // => true
  25240. *
  25241. * _.isSafeInteger(Number.MIN_VALUE);
  25242. * // => false
  25243. *
  25244. * _.isSafeInteger(Infinity);
  25245. * // => false
  25246. *
  25247. * _.isSafeInteger('3');
  25248. * // => false
  25249. */
  25250. function isSafeInteger(value) {
  25251. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  25252. }
  25253. /**
  25254. * Checks if `value` is classified as a `Set` object.
  25255. *
  25256. * @static
  25257. * @memberOf _
  25258. * @since 4.3.0
  25259. * @category Lang
  25260. * @param {*} value The value to check.
  25261. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  25262. * @example
  25263. *
  25264. * _.isSet(new Set);
  25265. * // => true
  25266. *
  25267. * _.isSet(new WeakSet);
  25268. * // => false
  25269. */
  25270. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  25271. /**
  25272. * Checks if `value` is classified as a `String` primitive or object.
  25273. *
  25274. * @static
  25275. * @since 0.1.0
  25276. * @memberOf _
  25277. * @category Lang
  25278. * @param {*} value The value to check.
  25279. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  25280. * @example
  25281. *
  25282. * _.isString('abc');
  25283. * // => true
  25284. *
  25285. * _.isString(1);
  25286. * // => false
  25287. */
  25288. function isString(value) {
  25289. return typeof value == 'string' ||
  25290. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  25291. }
  25292. /**
  25293. * Checks if `value` is classified as a `Symbol` primitive or object.
  25294. *
  25295. * @static
  25296. * @memberOf _
  25297. * @since 4.0.0
  25298. * @category Lang
  25299. * @param {*} value The value to check.
  25300. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  25301. * @example
  25302. *
  25303. * _.isSymbol(Symbol.iterator);
  25304. * // => true
  25305. *
  25306. * _.isSymbol('abc');
  25307. * // => false
  25308. */
  25309. function isSymbol(value) {
  25310. return typeof value == 'symbol' ||
  25311. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  25312. }
  25313. /**
  25314. * Checks if `value` is classified as a typed array.
  25315. *
  25316. * @static
  25317. * @memberOf _
  25318. * @since 3.0.0
  25319. * @category Lang
  25320. * @param {*} value The value to check.
  25321. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  25322. * @example
  25323. *
  25324. * _.isTypedArray(new Uint8Array);
  25325. * // => true
  25326. *
  25327. * _.isTypedArray([]);
  25328. * // => false
  25329. */
  25330. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  25331. /**
  25332. * Checks if `value` is `undefined`.
  25333. *
  25334. * @static
  25335. * @since 0.1.0
  25336. * @memberOf _
  25337. * @category Lang
  25338. * @param {*} value The value to check.
  25339. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  25340. * @example
  25341. *
  25342. * _.isUndefined(void 0);
  25343. * // => true
  25344. *
  25345. * _.isUndefined(null);
  25346. * // => false
  25347. */
  25348. function isUndefined(value) {
  25349. return value === undefined;
  25350. }
  25351. /**
  25352. * Checks if `value` is classified as a `WeakMap` object.
  25353. *
  25354. * @static
  25355. * @memberOf _
  25356. * @since 4.3.0
  25357. * @category Lang
  25358. * @param {*} value The value to check.
  25359. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  25360. * @example
  25361. *
  25362. * _.isWeakMap(new WeakMap);
  25363. * // => true
  25364. *
  25365. * _.isWeakMap(new Map);
  25366. * // => false
  25367. */
  25368. function isWeakMap(value) {
  25369. return isObjectLike(value) && getTag(value) == weakMapTag;
  25370. }
  25371. /**
  25372. * Checks if `value` is classified as a `WeakSet` object.
  25373. *
  25374. * @static
  25375. * @memberOf _
  25376. * @since 4.3.0
  25377. * @category Lang
  25378. * @param {*} value The value to check.
  25379. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  25380. * @example
  25381. *
  25382. * _.isWeakSet(new WeakSet);
  25383. * // => true
  25384. *
  25385. * _.isWeakSet(new Set);
  25386. * // => false
  25387. */
  25388. function isWeakSet(value) {
  25389. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  25390. }
  25391. /**
  25392. * Checks if `value` is less than `other`.
  25393. *
  25394. * @static
  25395. * @memberOf _
  25396. * @since 3.9.0
  25397. * @category Lang
  25398. * @param {*} value The value to compare.
  25399. * @param {*} other The other value to compare.
  25400. * @returns {boolean} Returns `true` if `value` is less than `other`,
  25401. * else `false`.
  25402. * @see _.gt
  25403. * @example
  25404. *
  25405. * _.lt(1, 3);
  25406. * // => true
  25407. *
  25408. * _.lt(3, 3);
  25409. * // => false
  25410. *
  25411. * _.lt(3, 1);
  25412. * // => false
  25413. */
  25414. var lt = createRelationalOperation(baseLt);
  25415. /**
  25416. * Checks if `value` is less than or equal to `other`.
  25417. *
  25418. * @static
  25419. * @memberOf _
  25420. * @since 3.9.0
  25421. * @category Lang
  25422. * @param {*} value The value to compare.
  25423. * @param {*} other The other value to compare.
  25424. * @returns {boolean} Returns `true` if `value` is less than or equal to
  25425. * `other`, else `false`.
  25426. * @see _.gte
  25427. * @example
  25428. *
  25429. * _.lte(1, 3);
  25430. * // => true
  25431. *
  25432. * _.lte(3, 3);
  25433. * // => true
  25434. *
  25435. * _.lte(3, 1);
  25436. * // => false
  25437. */
  25438. var lte = createRelationalOperation(function(value, other) {
  25439. return value <= other;
  25440. });
  25441. /**
  25442. * Converts `value` to an array.
  25443. *
  25444. * @static
  25445. * @since 0.1.0
  25446. * @memberOf _
  25447. * @category Lang
  25448. * @param {*} value The value to convert.
  25449. * @returns {Array} Returns the converted array.
  25450. * @example
  25451. *
  25452. * _.toArray({ 'a': 1, 'b': 2 });
  25453. * // => [1, 2]
  25454. *
  25455. * _.toArray('abc');
  25456. * // => ['a', 'b', 'c']
  25457. *
  25458. * _.toArray(1);
  25459. * // => []
  25460. *
  25461. * _.toArray(null);
  25462. * // => []
  25463. */
  25464. function toArray(value) {
  25465. if (!value) {
  25466. return [];
  25467. }
  25468. if (isArrayLike(value)) {
  25469. return isString(value) ? stringToArray(value) : copyArray(value);
  25470. }
  25471. if (symIterator && value[symIterator]) {
  25472. return iteratorToArray(value[symIterator]());
  25473. }
  25474. var tag = getTag(value),
  25475. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  25476. return func(value);
  25477. }
  25478. /**
  25479. * Converts `value` to a finite number.
  25480. *
  25481. * @static
  25482. * @memberOf _
  25483. * @since 4.12.0
  25484. * @category Lang
  25485. * @param {*} value The value to convert.
  25486. * @returns {number} Returns the converted number.
  25487. * @example
  25488. *
  25489. * _.toFinite(3.2);
  25490. * // => 3.2
  25491. *
  25492. * _.toFinite(Number.MIN_VALUE);
  25493. * // => 5e-324
  25494. *
  25495. * _.toFinite(Infinity);
  25496. * // => 1.7976931348623157e+308
  25497. *
  25498. * _.toFinite('3.2');
  25499. * // => 3.2
  25500. */
  25501. function toFinite(value) {
  25502. if (!value) {
  25503. return value === 0 ? value : 0;
  25504. }
  25505. value = toNumber(value);
  25506. if (value === INFINITY || value === -INFINITY) {
  25507. var sign = (value < 0 ? -1 : 1);
  25508. return sign * MAX_INTEGER;
  25509. }
  25510. return value === value ? value : 0;
  25511. }
  25512. /**
  25513. * Converts `value` to an integer.
  25514. *
  25515. * **Note:** This method is loosely based on
  25516. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  25517. *
  25518. * @static
  25519. * @memberOf _
  25520. * @since 4.0.0
  25521. * @category Lang
  25522. * @param {*} value The value to convert.
  25523. * @returns {number} Returns the converted integer.
  25524. * @example
  25525. *
  25526. * _.toInteger(3.2);
  25527. * // => 3
  25528. *
  25529. * _.toInteger(Number.MIN_VALUE);
  25530. * // => 0
  25531. *
  25532. * _.toInteger(Infinity);
  25533. * // => 1.7976931348623157e+308
  25534. *
  25535. * _.toInteger('3.2');
  25536. * // => 3
  25537. */
  25538. function toInteger(value) {
  25539. var result = toFinite(value),
  25540. remainder = result % 1;
  25541. return result === result ? (remainder ? result - remainder : result) : 0;
  25542. }
  25543. /**
  25544. * Converts `value` to an integer suitable for use as the length of an
  25545. * array-like object.
  25546. *
  25547. * **Note:** This method is based on
  25548. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  25549. *
  25550. * @static
  25551. * @memberOf _
  25552. * @since 4.0.0
  25553. * @category Lang
  25554. * @param {*} value The value to convert.
  25555. * @returns {number} Returns the converted integer.
  25556. * @example
  25557. *
  25558. * _.toLength(3.2);
  25559. * // => 3
  25560. *
  25561. * _.toLength(Number.MIN_VALUE);
  25562. * // => 0
  25563. *
  25564. * _.toLength(Infinity);
  25565. * // => 4294967295
  25566. *
  25567. * _.toLength('3.2');
  25568. * // => 3
  25569. */
  25570. function toLength(value) {
  25571. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  25572. }
  25573. /**
  25574. * Converts `value` to a number.
  25575. *
  25576. * @static
  25577. * @memberOf _
  25578. * @since 4.0.0
  25579. * @category Lang
  25580. * @param {*} value The value to process.
  25581. * @returns {number} Returns the number.
  25582. * @example
  25583. *
  25584. * _.toNumber(3.2);
  25585. * // => 3.2
  25586. *
  25587. * _.toNumber(Number.MIN_VALUE);
  25588. * // => 5e-324
  25589. *
  25590. * _.toNumber(Infinity);
  25591. * // => Infinity
  25592. *
  25593. * _.toNumber('3.2');
  25594. * // => 3.2
  25595. */
  25596. function toNumber(value) {
  25597. if (typeof value == 'number') {
  25598. return value;
  25599. }
  25600. if (isSymbol(value)) {
  25601. return NAN;
  25602. }
  25603. if (isObject(value)) {
  25604. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  25605. value = isObject(other) ? (other + '') : other;
  25606. }
  25607. if (typeof value != 'string') {
  25608. return value === 0 ? value : +value;
  25609. }
  25610. value = value.replace(reTrim, '');
  25611. var isBinary = reIsBinary.test(value);
  25612. return (isBinary || reIsOctal.test(value))
  25613. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  25614. : (reIsBadHex.test(value) ? NAN : +value);
  25615. }
  25616. /**
  25617. * Converts `value` to a plain object flattening inherited enumerable string
  25618. * keyed properties of `value` to own properties of the plain object.
  25619. *
  25620. * @static
  25621. * @memberOf _
  25622. * @since 3.0.0
  25623. * @category Lang
  25624. * @param {*} value The value to convert.
  25625. * @returns {Object} Returns the converted plain object.
  25626. * @example
  25627. *
  25628. * function Foo() {
  25629. * this.b = 2;
  25630. * }
  25631. *
  25632. * Foo.prototype.c = 3;
  25633. *
  25634. * _.assign({ 'a': 1 }, new Foo);
  25635. * // => { 'a': 1, 'b': 2 }
  25636. *
  25637. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  25638. * // => { 'a': 1, 'b': 2, 'c': 3 }
  25639. */
  25640. function toPlainObject(value) {
  25641. return copyObject(value, keysIn(value));
  25642. }
  25643. /**
  25644. * Converts `value` to a safe integer. A safe integer can be compared and
  25645. * represented correctly.
  25646. *
  25647. * @static
  25648. * @memberOf _
  25649. * @since 4.0.0
  25650. * @category Lang
  25651. * @param {*} value The value to convert.
  25652. * @returns {number} Returns the converted integer.
  25653. * @example
  25654. *
  25655. * _.toSafeInteger(3.2);
  25656. * // => 3
  25657. *
  25658. * _.toSafeInteger(Number.MIN_VALUE);
  25659. * // => 0
  25660. *
  25661. * _.toSafeInteger(Infinity);
  25662. * // => 9007199254740991
  25663. *
  25664. * _.toSafeInteger('3.2');
  25665. * // => 3
  25666. */
  25667. function toSafeInteger(value) {
  25668. return value
  25669. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  25670. : (value === 0 ? value : 0);
  25671. }
  25672. /**
  25673. * Converts `value` to a string. An empty string is returned for `null`
  25674. * and `undefined` values. The sign of `-0` is preserved.
  25675. *
  25676. * @static
  25677. * @memberOf _
  25678. * @since 4.0.0
  25679. * @category Lang
  25680. * @param {*} value The value to convert.
  25681. * @returns {string} Returns the converted string.
  25682. * @example
  25683. *
  25684. * _.toString(null);
  25685. * // => ''
  25686. *
  25687. * _.toString(-0);
  25688. * // => '-0'
  25689. *
  25690. * _.toString([1, 2, 3]);
  25691. * // => '1,2,3'
  25692. */
  25693. function toString(value) {
  25694. return value == null ? '' : baseToString(value);
  25695. }
  25696. /*------------------------------------------------------------------------*/
  25697. /**
  25698. * Assigns own enumerable string keyed properties of source objects to the
  25699. * destination object. Source objects are applied from left to right.
  25700. * Subsequent sources overwrite property assignments of previous sources.
  25701. *
  25702. * **Note:** This method mutates `object` and is loosely based on
  25703. * [`Object.assign`](https://mdn.io/Object/assign).
  25704. *
  25705. * @static
  25706. * @memberOf _
  25707. * @since 0.10.0
  25708. * @category Object
  25709. * @param {Object} object The destination object.
  25710. * @param {...Object} [sources] The source objects.
  25711. * @returns {Object} Returns `object`.
  25712. * @see _.assignIn
  25713. * @example
  25714. *
  25715. * function Foo() {
  25716. * this.a = 1;
  25717. * }
  25718. *
  25719. * function Bar() {
  25720. * this.c = 3;
  25721. * }
  25722. *
  25723. * Foo.prototype.b = 2;
  25724. * Bar.prototype.d = 4;
  25725. *
  25726. * _.assign({ 'a': 0 }, new Foo, new Bar);
  25727. * // => { 'a': 1, 'c': 3 }
  25728. */
  25729. var assign = createAssigner(function(object, source) {
  25730. if (isPrototype(source) || isArrayLike(source)) {
  25731. copyObject(source, keys(source), object);
  25732. return;
  25733. }
  25734. for (var key in source) {
  25735. if (hasOwnProperty.call(source, key)) {
  25736. assignValue(object, key, source[key]);
  25737. }
  25738. }
  25739. });
  25740. /**
  25741. * This method is like `_.assign` except that it iterates over own and
  25742. * inherited source properties.
  25743. *
  25744. * **Note:** This method mutates `object`.
  25745. *
  25746. * @static
  25747. * @memberOf _
  25748. * @since 4.0.0
  25749. * @alias extend
  25750. * @category Object
  25751. * @param {Object} object The destination object.
  25752. * @param {...Object} [sources] The source objects.
  25753. * @returns {Object} Returns `object`.
  25754. * @see _.assign
  25755. * @example
  25756. *
  25757. * function Foo() {
  25758. * this.a = 1;
  25759. * }
  25760. *
  25761. * function Bar() {
  25762. * this.c = 3;
  25763. * }
  25764. *
  25765. * Foo.prototype.b = 2;
  25766. * Bar.prototype.d = 4;
  25767. *
  25768. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  25769. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  25770. */
  25771. var assignIn = createAssigner(function(object, source) {
  25772. copyObject(source, keysIn(source), object);
  25773. });
  25774. /**
  25775. * This method is like `_.assignIn` except that it accepts `customizer`
  25776. * which is invoked to produce the assigned values. If `customizer` returns
  25777. * `undefined`, assignment is handled by the method instead. The `customizer`
  25778. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  25779. *
  25780. * **Note:** This method mutates `object`.
  25781. *
  25782. * @static
  25783. * @memberOf _
  25784. * @since 4.0.0
  25785. * @alias extendWith
  25786. * @category Object
  25787. * @param {Object} object The destination object.
  25788. * @param {...Object} sources The source objects.
  25789. * @param {Function} [customizer] The function to customize assigned values.
  25790. * @returns {Object} Returns `object`.
  25791. * @see _.assignWith
  25792. * @example
  25793. *
  25794. * function customizer(objValue, srcValue) {
  25795. * return _.isUndefined(objValue) ? srcValue : objValue;
  25796. * }
  25797. *
  25798. * var defaults = _.partialRight(_.assignInWith, customizer);
  25799. *
  25800. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  25801. * // => { 'a': 1, 'b': 2 }
  25802. */
  25803. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  25804. copyObject(source, keysIn(source), object, customizer);
  25805. });
  25806. /**
  25807. * This method is like `_.assign` except that it accepts `customizer`
  25808. * which is invoked to produce the assigned values. If `customizer` returns
  25809. * `undefined`, assignment is handled by the method instead. The `customizer`
  25810. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  25811. *
  25812. * **Note:** This method mutates `object`.
  25813. *
  25814. * @static
  25815. * @memberOf _
  25816. * @since 4.0.0
  25817. * @category Object
  25818. * @param {Object} object The destination object.
  25819. * @param {...Object} sources The source objects.
  25820. * @param {Function} [customizer] The function to customize assigned values.
  25821. * @returns {Object} Returns `object`.
  25822. * @see _.assignInWith
  25823. * @example
  25824. *
  25825. * function customizer(objValue, srcValue) {
  25826. * return _.isUndefined(objValue) ? srcValue : objValue;
  25827. * }
  25828. *
  25829. * var defaults = _.partialRight(_.assignWith, customizer);
  25830. *
  25831. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  25832. * // => { 'a': 1, 'b': 2 }
  25833. */
  25834. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  25835. copyObject(source, keys(source), object, customizer);
  25836. });
  25837. /**
  25838. * Creates an array of values corresponding to `paths` of `object`.
  25839. *
  25840. * @static
  25841. * @memberOf _
  25842. * @since 1.0.0
  25843. * @category Object
  25844. * @param {Object} object The object to iterate over.
  25845. * @param {...(string|string[])} [paths] The property paths to pick.
  25846. * @returns {Array} Returns the picked values.
  25847. * @example
  25848. *
  25849. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  25850. *
  25851. * _.at(object, ['a[0].b.c', 'a[1]']);
  25852. * // => [3, 4]
  25853. */
  25854. var at = flatRest(baseAt);
  25855. /**
  25856. * Creates an object that inherits from the `prototype` object. If a
  25857. * `properties` object is given, its own enumerable string keyed properties
  25858. * are assigned to the created object.
  25859. *
  25860. * @static
  25861. * @memberOf _
  25862. * @since 2.3.0
  25863. * @category Object
  25864. * @param {Object} prototype The object to inherit from.
  25865. * @param {Object} [properties] The properties to assign to the object.
  25866. * @returns {Object} Returns the new object.
  25867. * @example
  25868. *
  25869. * function Shape() {
  25870. * this.x = 0;
  25871. * this.y = 0;
  25872. * }
  25873. *
  25874. * function Circle() {
  25875. * Shape.call(this);
  25876. * }
  25877. *
  25878. * Circle.prototype = _.create(Shape.prototype, {
  25879. * 'constructor': Circle
  25880. * });
  25881. *
  25882. * var circle = new Circle;
  25883. * circle instanceof Circle;
  25884. * // => true
  25885. *
  25886. * circle instanceof Shape;
  25887. * // => true
  25888. */
  25889. function create(prototype, properties) {
  25890. var result = baseCreate(prototype);
  25891. return properties == null ? result : baseAssign(result, properties);
  25892. }
  25893. /**
  25894. * Assigns own and inherited enumerable string keyed properties of source
  25895. * objects to the destination object for all destination properties that
  25896. * resolve to `undefined`. Source objects are applied from left to right.
  25897. * Once a property is set, additional values of the same property are ignored.
  25898. *
  25899. * **Note:** This method mutates `object`.
  25900. *
  25901. * @static
  25902. * @since 0.1.0
  25903. * @memberOf _
  25904. * @category Object
  25905. * @param {Object} object The destination object.
  25906. * @param {...Object} [sources] The source objects.
  25907. * @returns {Object} Returns `object`.
  25908. * @see _.defaultsDeep
  25909. * @example
  25910. *
  25911. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  25912. * // => { 'a': 1, 'b': 2 }
  25913. */
  25914. var defaults = baseRest(function(object, sources) {
  25915. object = Object(object);
  25916. var index = -1;
  25917. var length = sources.length;
  25918. var guard = length > 2 ? sources[2] : undefined;
  25919. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  25920. length = 1;
  25921. }
  25922. while (++index < length) {
  25923. var source = sources[index];
  25924. var props = keysIn(source);
  25925. var propsIndex = -1;
  25926. var propsLength = props.length;
  25927. while (++propsIndex < propsLength) {
  25928. var key = props[propsIndex];
  25929. var value = object[key];
  25930. if (value === undefined ||
  25931. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  25932. object[key] = source[key];
  25933. }
  25934. }
  25935. }
  25936. return object;
  25937. });
  25938. /**
  25939. * This method is like `_.defaults` except that it recursively assigns
  25940. * default properties.
  25941. *
  25942. * **Note:** This method mutates `object`.
  25943. *
  25944. * @static
  25945. * @memberOf _
  25946. * @since 3.10.0
  25947. * @category Object
  25948. * @param {Object} object The destination object.
  25949. * @param {...Object} [sources] The source objects.
  25950. * @returns {Object} Returns `object`.
  25951. * @see _.defaults
  25952. * @example
  25953. *
  25954. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  25955. * // => { 'a': { 'b': 2, 'c': 3 } }
  25956. */
  25957. var defaultsDeep = baseRest(function(args) {
  25958. args.push(undefined, customDefaultsMerge);
  25959. return apply(mergeWith, undefined, args);
  25960. });
  25961. /**
  25962. * This method is like `_.find` except that it returns the key of the first
  25963. * element `predicate` returns truthy for instead of the element itself.
  25964. *
  25965. * @static
  25966. * @memberOf _
  25967. * @since 1.1.0
  25968. * @category Object
  25969. * @param {Object} object The object to inspect.
  25970. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25971. * @returns {string|undefined} Returns the key of the matched element,
  25972. * else `undefined`.
  25973. * @example
  25974. *
  25975. * var users = {
  25976. * 'barney': { 'age': 36, 'active': true },
  25977. * 'fred': { 'age': 40, 'active': false },
  25978. * 'pebbles': { 'age': 1, 'active': true }
  25979. * };
  25980. *
  25981. * _.findKey(users, function(o) { return o.age < 40; });
  25982. * // => 'barney' (iteration order is not guaranteed)
  25983. *
  25984. * // The `_.matches` iteratee shorthand.
  25985. * _.findKey(users, { 'age': 1, 'active': true });
  25986. * // => 'pebbles'
  25987. *
  25988. * // The `_.matchesProperty` iteratee shorthand.
  25989. * _.findKey(users, ['active', false]);
  25990. * // => 'fred'
  25991. *
  25992. * // The `_.property` iteratee shorthand.
  25993. * _.findKey(users, 'active');
  25994. * // => 'barney'
  25995. */
  25996. function findKey(object, predicate) {
  25997. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  25998. }
  25999. /**
  26000. * This method is like `_.findKey` except that it iterates over elements of
  26001. * a collection in the opposite order.
  26002. *
  26003. * @static
  26004. * @memberOf _
  26005. * @since 2.0.0
  26006. * @category Object
  26007. * @param {Object} object The object to inspect.
  26008. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26009. * @returns {string|undefined} Returns the key of the matched element,
  26010. * else `undefined`.
  26011. * @example
  26012. *
  26013. * var users = {
  26014. * 'barney': { 'age': 36, 'active': true },
  26015. * 'fred': { 'age': 40, 'active': false },
  26016. * 'pebbles': { 'age': 1, 'active': true }
  26017. * };
  26018. *
  26019. * _.findLastKey(users, function(o) { return o.age < 40; });
  26020. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  26021. *
  26022. * // The `_.matches` iteratee shorthand.
  26023. * _.findLastKey(users, { 'age': 36, 'active': true });
  26024. * // => 'barney'
  26025. *
  26026. * // The `_.matchesProperty` iteratee shorthand.
  26027. * _.findLastKey(users, ['active', false]);
  26028. * // => 'fred'
  26029. *
  26030. * // The `_.property` iteratee shorthand.
  26031. * _.findLastKey(users, 'active');
  26032. * // => 'pebbles'
  26033. */
  26034. function findLastKey(object, predicate) {
  26035. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  26036. }
  26037. /**
  26038. * Iterates over own and inherited enumerable string keyed properties of an
  26039. * object and invokes `iteratee` for each property. The iteratee is invoked
  26040. * with three arguments: (value, key, object). Iteratee functions may exit
  26041. * iteration early by explicitly returning `false`.
  26042. *
  26043. * @static
  26044. * @memberOf _
  26045. * @since 0.3.0
  26046. * @category Object
  26047. * @param {Object} object The object to iterate over.
  26048. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26049. * @returns {Object} Returns `object`.
  26050. * @see _.forInRight
  26051. * @example
  26052. *
  26053. * function Foo() {
  26054. * this.a = 1;
  26055. * this.b = 2;
  26056. * }
  26057. *
  26058. * Foo.prototype.c = 3;
  26059. *
  26060. * _.forIn(new Foo, function(value, key) {
  26061. * console.log(key);
  26062. * });
  26063. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  26064. */
  26065. function forIn(object, iteratee) {
  26066. return object == null
  26067. ? object
  26068. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  26069. }
  26070. /**
  26071. * This method is like `_.forIn` except that it iterates over properties of
  26072. * `object` in the opposite order.
  26073. *
  26074. * @static
  26075. * @memberOf _
  26076. * @since 2.0.0
  26077. * @category Object
  26078. * @param {Object} object The object to iterate over.
  26079. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26080. * @returns {Object} Returns `object`.
  26081. * @see _.forIn
  26082. * @example
  26083. *
  26084. * function Foo() {
  26085. * this.a = 1;
  26086. * this.b = 2;
  26087. * }
  26088. *
  26089. * Foo.prototype.c = 3;
  26090. *
  26091. * _.forInRight(new Foo, function(value, key) {
  26092. * console.log(key);
  26093. * });
  26094. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  26095. */
  26096. function forInRight(object, iteratee) {
  26097. return object == null
  26098. ? object
  26099. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  26100. }
  26101. /**
  26102. * Iterates over own enumerable string keyed properties of an object and
  26103. * invokes `iteratee` for each property. The iteratee is invoked with three
  26104. * arguments: (value, key, object). Iteratee functions may exit iteration
  26105. * early by explicitly returning `false`.
  26106. *
  26107. * @static
  26108. * @memberOf _
  26109. * @since 0.3.0
  26110. * @category Object
  26111. * @param {Object} object The object to iterate over.
  26112. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26113. * @returns {Object} Returns `object`.
  26114. * @see _.forOwnRight
  26115. * @example
  26116. *
  26117. * function Foo() {
  26118. * this.a = 1;
  26119. * this.b = 2;
  26120. * }
  26121. *
  26122. * Foo.prototype.c = 3;
  26123. *
  26124. * _.forOwn(new Foo, function(value, key) {
  26125. * console.log(key);
  26126. * });
  26127. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  26128. */
  26129. function forOwn(object, iteratee) {
  26130. return object && baseForOwn(object, getIteratee(iteratee, 3));
  26131. }
  26132. /**
  26133. * This method is like `_.forOwn` except that it iterates over properties of
  26134. * `object` in the opposite order.
  26135. *
  26136. * @static
  26137. * @memberOf _
  26138. * @since 2.0.0
  26139. * @category Object
  26140. * @param {Object} object The object to iterate over.
  26141. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26142. * @returns {Object} Returns `object`.
  26143. * @see _.forOwn
  26144. * @example
  26145. *
  26146. * function Foo() {
  26147. * this.a = 1;
  26148. * this.b = 2;
  26149. * }
  26150. *
  26151. * Foo.prototype.c = 3;
  26152. *
  26153. * _.forOwnRight(new Foo, function(value, key) {
  26154. * console.log(key);
  26155. * });
  26156. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  26157. */
  26158. function forOwnRight(object, iteratee) {
  26159. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  26160. }
  26161. /**
  26162. * Creates an array of function property names from own enumerable properties
  26163. * of `object`.
  26164. *
  26165. * @static
  26166. * @since 0.1.0
  26167. * @memberOf _
  26168. * @category Object
  26169. * @param {Object} object The object to inspect.
  26170. * @returns {Array} Returns the function names.
  26171. * @see _.functionsIn
  26172. * @example
  26173. *
  26174. * function Foo() {
  26175. * this.a = _.constant('a');
  26176. * this.b = _.constant('b');
  26177. * }
  26178. *
  26179. * Foo.prototype.c = _.constant('c');
  26180. *
  26181. * _.functions(new Foo);
  26182. * // => ['a', 'b']
  26183. */
  26184. function functions(object) {
  26185. return object == null ? [] : baseFunctions(object, keys(object));
  26186. }
  26187. /**
  26188. * Creates an array of function property names from own and inherited
  26189. * enumerable properties of `object`.
  26190. *
  26191. * @static
  26192. * @memberOf _
  26193. * @since 4.0.0
  26194. * @category Object
  26195. * @param {Object} object The object to inspect.
  26196. * @returns {Array} Returns the function names.
  26197. * @see _.functions
  26198. * @example
  26199. *
  26200. * function Foo() {
  26201. * this.a = _.constant('a');
  26202. * this.b = _.constant('b');
  26203. * }
  26204. *
  26205. * Foo.prototype.c = _.constant('c');
  26206. *
  26207. * _.functionsIn(new Foo);
  26208. * // => ['a', 'b', 'c']
  26209. */
  26210. function functionsIn(object) {
  26211. return object == null ? [] : baseFunctions(object, keysIn(object));
  26212. }
  26213. /**
  26214. * Gets the value at `path` of `object`. If the resolved value is
  26215. * `undefined`, the `defaultValue` is returned in its place.
  26216. *
  26217. * @static
  26218. * @memberOf _
  26219. * @since 3.7.0
  26220. * @category Object
  26221. * @param {Object} object The object to query.
  26222. * @param {Array|string} path The path of the property to get.
  26223. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  26224. * @returns {*} Returns the resolved value.
  26225. * @example
  26226. *
  26227. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  26228. *
  26229. * _.get(object, 'a[0].b.c');
  26230. * // => 3
  26231. *
  26232. * _.get(object, ['a', '0', 'b', 'c']);
  26233. * // => 3
  26234. *
  26235. * _.get(object, 'a.b.c', 'default');
  26236. * // => 'default'
  26237. */
  26238. function get(object, path, defaultValue) {
  26239. var result = object == null ? undefined : baseGet(object, path);
  26240. return result === undefined ? defaultValue : result;
  26241. }
  26242. /**
  26243. * Checks if `path` is a direct property of `object`.
  26244. *
  26245. * @static
  26246. * @since 0.1.0
  26247. * @memberOf _
  26248. * @category Object
  26249. * @param {Object} object The object to query.
  26250. * @param {Array|string} path The path to check.
  26251. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  26252. * @example
  26253. *
  26254. * var object = { 'a': { 'b': 2 } };
  26255. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  26256. *
  26257. * _.has(object, 'a');
  26258. * // => true
  26259. *
  26260. * _.has(object, 'a.b');
  26261. * // => true
  26262. *
  26263. * _.has(object, ['a', 'b']);
  26264. * // => true
  26265. *
  26266. * _.has(other, 'a');
  26267. * // => false
  26268. */
  26269. function has(object, path) {
  26270. return object != null && hasPath(object, path, baseHas);
  26271. }
  26272. /**
  26273. * Checks if `path` is a direct or inherited property of `object`.
  26274. *
  26275. * @static
  26276. * @memberOf _
  26277. * @since 4.0.0
  26278. * @category Object
  26279. * @param {Object} object The object to query.
  26280. * @param {Array|string} path The path to check.
  26281. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  26282. * @example
  26283. *
  26284. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  26285. *
  26286. * _.hasIn(object, 'a');
  26287. * // => true
  26288. *
  26289. * _.hasIn(object, 'a.b');
  26290. * // => true
  26291. *
  26292. * _.hasIn(object, ['a', 'b']);
  26293. * // => true
  26294. *
  26295. * _.hasIn(object, 'b');
  26296. * // => false
  26297. */
  26298. function hasIn(object, path) {
  26299. return object != null && hasPath(object, path, baseHasIn);
  26300. }
  26301. /**
  26302. * Creates an object composed of the inverted keys and values of `object`.
  26303. * If `object` contains duplicate values, subsequent values overwrite
  26304. * property assignments of previous values.
  26305. *
  26306. * @static
  26307. * @memberOf _
  26308. * @since 0.7.0
  26309. * @category Object
  26310. * @param {Object} object The object to invert.
  26311. * @returns {Object} Returns the new inverted object.
  26312. * @example
  26313. *
  26314. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  26315. *
  26316. * _.invert(object);
  26317. * // => { '1': 'c', '2': 'b' }
  26318. */
  26319. var invert = createInverter(function(result, value, key) {
  26320. if (value != null &&
  26321. typeof value.toString != 'function') {
  26322. value = nativeObjectToString.call(value);
  26323. }
  26324. result[value] = key;
  26325. }, constant(identity));
  26326. /**
  26327. * This method is like `_.invert` except that the inverted object is generated
  26328. * from the results of running each element of `object` thru `iteratee`. The
  26329. * corresponding inverted value of each inverted key is an array of keys
  26330. * responsible for generating the inverted value. The iteratee is invoked
  26331. * with one argument: (value).
  26332. *
  26333. * @static
  26334. * @memberOf _
  26335. * @since 4.1.0
  26336. * @category Object
  26337. * @param {Object} object The object to invert.
  26338. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  26339. * @returns {Object} Returns the new inverted object.
  26340. * @example
  26341. *
  26342. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  26343. *
  26344. * _.invertBy(object);
  26345. * // => { '1': ['a', 'c'], '2': ['b'] }
  26346. *
  26347. * _.invertBy(object, function(value) {
  26348. * return 'group' + value;
  26349. * });
  26350. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  26351. */
  26352. var invertBy = createInverter(function(result, value, key) {
  26353. if (value != null &&
  26354. typeof value.toString != 'function') {
  26355. value = nativeObjectToString.call(value);
  26356. }
  26357. if (hasOwnProperty.call(result, value)) {
  26358. result[value].push(key);
  26359. } else {
  26360. result[value] = [key];
  26361. }
  26362. }, getIteratee);
  26363. /**
  26364. * Invokes the method at `path` of `object`.
  26365. *
  26366. * @static
  26367. * @memberOf _
  26368. * @since 4.0.0
  26369. * @category Object
  26370. * @param {Object} object The object to query.
  26371. * @param {Array|string} path The path of the method to invoke.
  26372. * @param {...*} [args] The arguments to invoke the method with.
  26373. * @returns {*} Returns the result of the invoked method.
  26374. * @example
  26375. *
  26376. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  26377. *
  26378. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  26379. * // => [2, 3]
  26380. */
  26381. var invoke = baseRest(baseInvoke);
  26382. /**
  26383. * Creates an array of the own enumerable property names of `object`.
  26384. *
  26385. * **Note:** Non-object values are coerced to objects. See the
  26386. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  26387. * for more details.
  26388. *
  26389. * @static
  26390. * @since 0.1.0
  26391. * @memberOf _
  26392. * @category Object
  26393. * @param {Object} object The object to query.
  26394. * @returns {Array} Returns the array of property names.
  26395. * @example
  26396. *
  26397. * function Foo() {
  26398. * this.a = 1;
  26399. * this.b = 2;
  26400. * }
  26401. *
  26402. * Foo.prototype.c = 3;
  26403. *
  26404. * _.keys(new Foo);
  26405. * // => ['a', 'b'] (iteration order is not guaranteed)
  26406. *
  26407. * _.keys('hi');
  26408. * // => ['0', '1']
  26409. */
  26410. function keys(object) {
  26411. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  26412. }
  26413. /**
  26414. * Creates an array of the own and inherited enumerable property names of `object`.
  26415. *
  26416. * **Note:** Non-object values are coerced to objects.
  26417. *
  26418. * @static
  26419. * @memberOf _
  26420. * @since 3.0.0
  26421. * @category Object
  26422. * @param {Object} object The object to query.
  26423. * @returns {Array} Returns the array of property names.
  26424. * @example
  26425. *
  26426. * function Foo() {
  26427. * this.a = 1;
  26428. * this.b = 2;
  26429. * }
  26430. *
  26431. * Foo.prototype.c = 3;
  26432. *
  26433. * _.keysIn(new Foo);
  26434. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  26435. */
  26436. function keysIn(object) {
  26437. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  26438. }
  26439. /**
  26440. * The opposite of `_.mapValues`; this method creates an object with the
  26441. * same values as `object` and keys generated by running each own enumerable
  26442. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  26443. * with three arguments: (value, key, object).
  26444. *
  26445. * @static
  26446. * @memberOf _
  26447. * @since 3.8.0
  26448. * @category Object
  26449. * @param {Object} object The object to iterate over.
  26450. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26451. * @returns {Object} Returns the new mapped object.
  26452. * @see _.mapValues
  26453. * @example
  26454. *
  26455. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  26456. * return key + value;
  26457. * });
  26458. * // => { 'a1': 1, 'b2': 2 }
  26459. */
  26460. function mapKeys(object, iteratee) {
  26461. var result = {};
  26462. iteratee = getIteratee(iteratee, 3);
  26463. baseForOwn(object, function(value, key, object) {
  26464. baseAssignValue(result, iteratee(value, key, object), value);
  26465. });
  26466. return result;
  26467. }
  26468. /**
  26469. * Creates an object with the same keys as `object` and values generated
  26470. * by running each own enumerable string keyed property of `object` thru
  26471. * `iteratee`. The iteratee is invoked with three arguments:
  26472. * (value, key, object).
  26473. *
  26474. * @static
  26475. * @memberOf _
  26476. * @since 2.4.0
  26477. * @category Object
  26478. * @param {Object} object The object to iterate over.
  26479. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26480. * @returns {Object} Returns the new mapped object.
  26481. * @see _.mapKeys
  26482. * @example
  26483. *
  26484. * var users = {
  26485. * 'fred': { 'user': 'fred', 'age': 40 },
  26486. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  26487. * };
  26488. *
  26489. * _.mapValues(users, function(o) { return o.age; });
  26490. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  26491. *
  26492. * // The `_.property` iteratee shorthand.
  26493. * _.mapValues(users, 'age');
  26494. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  26495. */
  26496. function mapValues(object, iteratee) {
  26497. var result = {};
  26498. iteratee = getIteratee(iteratee, 3);
  26499. baseForOwn(object, function(value, key, object) {
  26500. baseAssignValue(result, key, iteratee(value, key, object));
  26501. });
  26502. return result;
  26503. }
  26504. /**
  26505. * This method is like `_.assign` except that it recursively merges own and
  26506. * inherited enumerable string keyed properties of source objects into the
  26507. * destination object. Source properties that resolve to `undefined` are
  26508. * skipped if a destination value exists. Array and plain object properties
  26509. * are merged recursively. Other objects and value types are overridden by
  26510. * assignment. Source objects are applied from left to right. Subsequent
  26511. * sources overwrite property assignments of previous sources.
  26512. *
  26513. * **Note:** This method mutates `object`.
  26514. *
  26515. * @static
  26516. * @memberOf _
  26517. * @since 0.5.0
  26518. * @category Object
  26519. * @param {Object} object The destination object.
  26520. * @param {...Object} [sources] The source objects.
  26521. * @returns {Object} Returns `object`.
  26522. * @example
  26523. *
  26524. * var object = {
  26525. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  26526. * };
  26527. *
  26528. * var other = {
  26529. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  26530. * };
  26531. *
  26532. * _.merge(object, other);
  26533. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  26534. */
  26535. var merge = createAssigner(function(object, source, srcIndex) {
  26536. baseMerge(object, source, srcIndex);
  26537. });
  26538. /**
  26539. * This method is like `_.merge` except that it accepts `customizer` which
  26540. * is invoked to produce the merged values of the destination and source
  26541. * properties. If `customizer` returns `undefined`, merging is handled by the
  26542. * method instead. The `customizer` is invoked with six arguments:
  26543. * (objValue, srcValue, key, object, source, stack).
  26544. *
  26545. * **Note:** This method mutates `object`.
  26546. *
  26547. * @static
  26548. * @memberOf _
  26549. * @since 4.0.0
  26550. * @category Object
  26551. * @param {Object} object The destination object.
  26552. * @param {...Object} sources The source objects.
  26553. * @param {Function} customizer The function to customize assigned values.
  26554. * @returns {Object} Returns `object`.
  26555. * @example
  26556. *
  26557. * function customizer(objValue, srcValue) {
  26558. * if (_.isArray(objValue)) {
  26559. * return objValue.concat(srcValue);
  26560. * }
  26561. * }
  26562. *
  26563. * var object = { 'a': [1], 'b': [2] };
  26564. * var other = { 'a': [3], 'b': [4] };
  26565. *
  26566. * _.mergeWith(object, other, customizer);
  26567. * // => { 'a': [1, 3], 'b': [2, 4] }
  26568. */
  26569. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  26570. baseMerge(object, source, srcIndex, customizer);
  26571. });
  26572. /**
  26573. * The opposite of `_.pick`; this method creates an object composed of the
  26574. * own and inherited enumerable property paths of `object` that are not omitted.
  26575. *
  26576. * **Note:** This method is considerably slower than `_.pick`.
  26577. *
  26578. * @static
  26579. * @since 0.1.0
  26580. * @memberOf _
  26581. * @category Object
  26582. * @param {Object} object The source object.
  26583. * @param {...(string|string[])} [paths] The property paths to omit.
  26584. * @returns {Object} Returns the new object.
  26585. * @example
  26586. *
  26587. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  26588. *
  26589. * _.omit(object, ['a', 'c']);
  26590. * // => { 'b': '2' }
  26591. */
  26592. var omit = flatRest(function(object, paths) {
  26593. var result = {};
  26594. if (object == null) {
  26595. return result;
  26596. }
  26597. var isDeep = false;
  26598. paths = arrayMap(paths, function(path) {
  26599. path = castPath(path, object);
  26600. isDeep || (isDeep = path.length > 1);
  26601. return path;
  26602. });
  26603. copyObject(object, getAllKeysIn(object), result);
  26604. if (isDeep) {
  26605. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  26606. }
  26607. var length = paths.length;
  26608. while (length--) {
  26609. baseUnset(result, paths[length]);
  26610. }
  26611. return result;
  26612. });
  26613. /**
  26614. * The opposite of `_.pickBy`; this method creates an object composed of
  26615. * the own and inherited enumerable string keyed properties of `object` that
  26616. * `predicate` doesn't return truthy for. The predicate is invoked with two
  26617. * arguments: (value, key).
  26618. *
  26619. * @static
  26620. * @memberOf _
  26621. * @since 4.0.0
  26622. * @category Object
  26623. * @param {Object} object The source object.
  26624. * @param {Function} [predicate=_.identity] The function invoked per property.
  26625. * @returns {Object} Returns the new object.
  26626. * @example
  26627. *
  26628. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  26629. *
  26630. * _.omitBy(object, _.isNumber);
  26631. * // => { 'b': '2' }
  26632. */
  26633. function omitBy(object, predicate) {
  26634. return pickBy(object, negate(getIteratee(predicate)));
  26635. }
  26636. /**
  26637. * Creates an object composed of the picked `object` properties.
  26638. *
  26639. * @static
  26640. * @since 0.1.0
  26641. * @memberOf _
  26642. * @category Object
  26643. * @param {Object} object The source object.
  26644. * @param {...(string|string[])} [paths] The property paths to pick.
  26645. * @returns {Object} Returns the new object.
  26646. * @example
  26647. *
  26648. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  26649. *
  26650. * _.pick(object, ['a', 'c']);
  26651. * // => { 'a': 1, 'c': 3 }
  26652. */
  26653. var pick = flatRest(function(object, paths) {
  26654. return object == null ? {} : basePick(object, paths);
  26655. });
  26656. /**
  26657. * Creates an object composed of the `object` properties `predicate` returns
  26658. * truthy for. The predicate is invoked with two arguments: (value, key).
  26659. *
  26660. * @static
  26661. * @memberOf _
  26662. * @since 4.0.0
  26663. * @category Object
  26664. * @param {Object} object The source object.
  26665. * @param {Function} [predicate=_.identity] The function invoked per property.
  26666. * @returns {Object} Returns the new object.
  26667. * @example
  26668. *
  26669. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  26670. *
  26671. * _.pickBy(object, _.isNumber);
  26672. * // => { 'a': 1, 'c': 3 }
  26673. */
  26674. function pickBy(object, predicate) {
  26675. if (object == null) {
  26676. return {};
  26677. }
  26678. var props = arrayMap(getAllKeysIn(object), function(prop) {
  26679. return [prop];
  26680. });
  26681. predicate = getIteratee(predicate);
  26682. return basePickBy(object, props, function(value, path) {
  26683. return predicate(value, path[0]);
  26684. });
  26685. }
  26686. /**
  26687. * This method is like `_.get` except that if the resolved value is a
  26688. * function it's invoked with the `this` binding of its parent object and
  26689. * its result is returned.
  26690. *
  26691. * @static
  26692. * @since 0.1.0
  26693. * @memberOf _
  26694. * @category Object
  26695. * @param {Object} object The object to query.
  26696. * @param {Array|string} path The path of the property to resolve.
  26697. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  26698. * @returns {*} Returns the resolved value.
  26699. * @example
  26700. *
  26701. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  26702. *
  26703. * _.result(object, 'a[0].b.c1');
  26704. * // => 3
  26705. *
  26706. * _.result(object, 'a[0].b.c2');
  26707. * // => 4
  26708. *
  26709. * _.result(object, 'a[0].b.c3', 'default');
  26710. * // => 'default'
  26711. *
  26712. * _.result(object, 'a[0].b.c3', _.constant('default'));
  26713. * // => 'default'
  26714. */
  26715. function result(object, path, defaultValue) {
  26716. path = castPath(path, object);
  26717. var index = -1,
  26718. length = path.length;
  26719. // Ensure the loop is entered when path is empty.
  26720. if (!length) {
  26721. length = 1;
  26722. object = undefined;
  26723. }
  26724. while (++index < length) {
  26725. var value = object == null ? undefined : object[toKey(path[index])];
  26726. if (value === undefined) {
  26727. index = length;
  26728. value = defaultValue;
  26729. }
  26730. object = isFunction(value) ? value.call(object) : value;
  26731. }
  26732. return object;
  26733. }
  26734. /**
  26735. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  26736. * it's created. Arrays are created for missing index properties while objects
  26737. * are created for all other missing properties. Use `_.setWith` to customize
  26738. * `path` creation.
  26739. *
  26740. * **Note:** This method mutates `object`.
  26741. *
  26742. * @static
  26743. * @memberOf _
  26744. * @since 3.7.0
  26745. * @category Object
  26746. * @param {Object} object The object to modify.
  26747. * @param {Array|string} path The path of the property to set.
  26748. * @param {*} value The value to set.
  26749. * @returns {Object} Returns `object`.
  26750. * @example
  26751. *
  26752. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  26753. *
  26754. * _.set(object, 'a[0].b.c', 4);
  26755. * console.log(object.a[0].b.c);
  26756. * // => 4
  26757. *
  26758. * _.set(object, ['x', '0', 'y', 'z'], 5);
  26759. * console.log(object.x[0].y.z);
  26760. * // => 5
  26761. */
  26762. function set(object, path, value) {
  26763. return object == null ? object : baseSet(object, path, value);
  26764. }
  26765. /**
  26766. * This method is like `_.set` except that it accepts `customizer` which is
  26767. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  26768. * path creation is handled by the method instead. The `customizer` is invoked
  26769. * with three arguments: (nsValue, key, nsObject).
  26770. *
  26771. * **Note:** This method mutates `object`.
  26772. *
  26773. * @static
  26774. * @memberOf _
  26775. * @since 4.0.0
  26776. * @category Object
  26777. * @param {Object} object The object to modify.
  26778. * @param {Array|string} path The path of the property to set.
  26779. * @param {*} value The value to set.
  26780. * @param {Function} [customizer] The function to customize assigned values.
  26781. * @returns {Object} Returns `object`.
  26782. * @example
  26783. *
  26784. * var object = {};
  26785. *
  26786. * _.setWith(object, '[0][1]', 'a', Object);
  26787. * // => { '0': { '1': 'a' } }
  26788. */
  26789. function setWith(object, path, value, customizer) {
  26790. customizer = typeof customizer == 'function' ? customizer : undefined;
  26791. return object == null ? object : baseSet(object, path, value, customizer);
  26792. }
  26793. /**
  26794. * Creates an array of own enumerable string keyed-value pairs for `object`
  26795. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  26796. * entries are returned.
  26797. *
  26798. * @static
  26799. * @memberOf _
  26800. * @since 4.0.0
  26801. * @alias entries
  26802. * @category Object
  26803. * @param {Object} object The object to query.
  26804. * @returns {Array} Returns the key-value pairs.
  26805. * @example
  26806. *
  26807. * function Foo() {
  26808. * this.a = 1;
  26809. * this.b = 2;
  26810. * }
  26811. *
  26812. * Foo.prototype.c = 3;
  26813. *
  26814. * _.toPairs(new Foo);
  26815. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  26816. */
  26817. var toPairs = createToPairs(keys);
  26818. /**
  26819. * Creates an array of own and inherited enumerable string keyed-value pairs
  26820. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  26821. * or set, its entries are returned.
  26822. *
  26823. * @static
  26824. * @memberOf _
  26825. * @since 4.0.0
  26826. * @alias entriesIn
  26827. * @category Object
  26828. * @param {Object} object The object to query.
  26829. * @returns {Array} Returns the key-value pairs.
  26830. * @example
  26831. *
  26832. * function Foo() {
  26833. * this.a = 1;
  26834. * this.b = 2;
  26835. * }
  26836. *
  26837. * Foo.prototype.c = 3;
  26838. *
  26839. * _.toPairsIn(new Foo);
  26840. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  26841. */
  26842. var toPairsIn = createToPairs(keysIn);
  26843. /**
  26844. * An alternative to `_.reduce`; this method transforms `object` to a new
  26845. * `accumulator` object which is the result of running each of its own
  26846. * enumerable string keyed properties thru `iteratee`, with each invocation
  26847. * potentially mutating the `accumulator` object. If `accumulator` is not
  26848. * provided, a new object with the same `[[Prototype]]` will be used. The
  26849. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  26850. * Iteratee functions may exit iteration early by explicitly returning `false`.
  26851. *
  26852. * @static
  26853. * @memberOf _
  26854. * @since 1.3.0
  26855. * @category Object
  26856. * @param {Object} object The object to iterate over.
  26857. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26858. * @param {*} [accumulator] The custom accumulator value.
  26859. * @returns {*} Returns the accumulated value.
  26860. * @example
  26861. *
  26862. * _.transform([2, 3, 4], function(result, n) {
  26863. * result.push(n *= n);
  26864. * return n % 2 == 0;
  26865. * }, []);
  26866. * // => [4, 9]
  26867. *
  26868. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  26869. * (result[value] || (result[value] = [])).push(key);
  26870. * }, {});
  26871. * // => { '1': ['a', 'c'], '2': ['b'] }
  26872. */
  26873. function transform(object, iteratee, accumulator) {
  26874. var isArr = isArray(object),
  26875. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  26876. iteratee = getIteratee(iteratee, 4);
  26877. if (accumulator == null) {
  26878. var Ctor = object && object.constructor;
  26879. if (isArrLike) {
  26880. accumulator = isArr ? new Ctor : [];
  26881. }
  26882. else if (isObject(object)) {
  26883. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  26884. }
  26885. else {
  26886. accumulator = {};
  26887. }
  26888. }
  26889. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  26890. return iteratee(accumulator, value, index, object);
  26891. });
  26892. return accumulator;
  26893. }
  26894. /**
  26895. * Removes the property at `path` of `object`.
  26896. *
  26897. * **Note:** This method mutates `object`.
  26898. *
  26899. * @static
  26900. * @memberOf _
  26901. * @since 4.0.0
  26902. * @category Object
  26903. * @param {Object} object The object to modify.
  26904. * @param {Array|string} path The path of the property to unset.
  26905. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  26906. * @example
  26907. *
  26908. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  26909. * _.unset(object, 'a[0].b.c');
  26910. * // => true
  26911. *
  26912. * console.log(object);
  26913. * // => { 'a': [{ 'b': {} }] };
  26914. *
  26915. * _.unset(object, ['a', '0', 'b', 'c']);
  26916. * // => true
  26917. *
  26918. * console.log(object);
  26919. * // => { 'a': [{ 'b': {} }] };
  26920. */
  26921. function unset(object, path) {
  26922. return object == null ? true : baseUnset(object, path);
  26923. }
  26924. /**
  26925. * This method is like `_.set` except that accepts `updater` to produce the
  26926. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  26927. * is invoked with one argument: (value).
  26928. *
  26929. * **Note:** This method mutates `object`.
  26930. *
  26931. * @static
  26932. * @memberOf _
  26933. * @since 4.6.0
  26934. * @category Object
  26935. * @param {Object} object The object to modify.
  26936. * @param {Array|string} path The path of the property to set.
  26937. * @param {Function} updater The function to produce the updated value.
  26938. * @returns {Object} Returns `object`.
  26939. * @example
  26940. *
  26941. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  26942. *
  26943. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  26944. * console.log(object.a[0].b.c);
  26945. * // => 9
  26946. *
  26947. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  26948. * console.log(object.x[0].y.z);
  26949. * // => 0
  26950. */
  26951. function update(object, path, updater) {
  26952. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  26953. }
  26954. /**
  26955. * This method is like `_.update` except that it accepts `customizer` which is
  26956. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  26957. * path creation is handled by the method instead. The `customizer` is invoked
  26958. * with three arguments: (nsValue, key, nsObject).
  26959. *
  26960. * **Note:** This method mutates `object`.
  26961. *
  26962. * @static
  26963. * @memberOf _
  26964. * @since 4.6.0
  26965. * @category Object
  26966. * @param {Object} object The object to modify.
  26967. * @param {Array|string} path The path of the property to set.
  26968. * @param {Function} updater The function to produce the updated value.
  26969. * @param {Function} [customizer] The function to customize assigned values.
  26970. * @returns {Object} Returns `object`.
  26971. * @example
  26972. *
  26973. * var object = {};
  26974. *
  26975. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  26976. * // => { '0': { '1': 'a' } }
  26977. */
  26978. function updateWith(object, path, updater, customizer) {
  26979. customizer = typeof customizer == 'function' ? customizer : undefined;
  26980. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  26981. }
  26982. /**
  26983. * Creates an array of the own enumerable string keyed property values of `object`.
  26984. *
  26985. * **Note:** Non-object values are coerced to objects.
  26986. *
  26987. * @static
  26988. * @since 0.1.0
  26989. * @memberOf _
  26990. * @category Object
  26991. * @param {Object} object The object to query.
  26992. * @returns {Array} Returns the array of property values.
  26993. * @example
  26994. *
  26995. * function Foo() {
  26996. * this.a = 1;
  26997. * this.b = 2;
  26998. * }
  26999. *
  27000. * Foo.prototype.c = 3;
  27001. *
  27002. * _.values(new Foo);
  27003. * // => [1, 2] (iteration order is not guaranteed)
  27004. *
  27005. * _.values('hi');
  27006. * // => ['h', 'i']
  27007. */
  27008. function values(object) {
  27009. return object == null ? [] : baseValues(object, keys(object));
  27010. }
  27011. /**
  27012. * Creates an array of the own and inherited enumerable string keyed property
  27013. * values of `object`.
  27014. *
  27015. * **Note:** Non-object values are coerced to objects.
  27016. *
  27017. * @static
  27018. * @memberOf _
  27019. * @since 3.0.0
  27020. * @category Object
  27021. * @param {Object} object The object to query.
  27022. * @returns {Array} Returns the array of property values.
  27023. * @example
  27024. *
  27025. * function Foo() {
  27026. * this.a = 1;
  27027. * this.b = 2;
  27028. * }
  27029. *
  27030. * Foo.prototype.c = 3;
  27031. *
  27032. * _.valuesIn(new Foo);
  27033. * // => [1, 2, 3] (iteration order is not guaranteed)
  27034. */
  27035. function valuesIn(object) {
  27036. return object == null ? [] : baseValues(object, keysIn(object));
  27037. }
  27038. /*------------------------------------------------------------------------*/
  27039. /**
  27040. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  27041. *
  27042. * @static
  27043. * @memberOf _
  27044. * @since 4.0.0
  27045. * @category Number
  27046. * @param {number} number The number to clamp.
  27047. * @param {number} [lower] The lower bound.
  27048. * @param {number} upper The upper bound.
  27049. * @returns {number} Returns the clamped number.
  27050. * @example
  27051. *
  27052. * _.clamp(-10, -5, 5);
  27053. * // => -5
  27054. *
  27055. * _.clamp(10, -5, 5);
  27056. * // => 5
  27057. */
  27058. function clamp(number, lower, upper) {
  27059. if (upper === undefined) {
  27060. upper = lower;
  27061. lower = undefined;
  27062. }
  27063. if (upper !== undefined) {
  27064. upper = toNumber(upper);
  27065. upper = upper === upper ? upper : 0;
  27066. }
  27067. if (lower !== undefined) {
  27068. lower = toNumber(lower);
  27069. lower = lower === lower ? lower : 0;
  27070. }
  27071. return baseClamp(toNumber(number), lower, upper);
  27072. }
  27073. /**
  27074. * Checks if `n` is between `start` and up to, but not including, `end`. If
  27075. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  27076. * If `start` is greater than `end` the params are swapped to support
  27077. * negative ranges.
  27078. *
  27079. * @static
  27080. * @memberOf _
  27081. * @since 3.3.0
  27082. * @category Number
  27083. * @param {number} number The number to check.
  27084. * @param {number} [start=0] The start of the range.
  27085. * @param {number} end The end of the range.
  27086. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  27087. * @see _.range, _.rangeRight
  27088. * @example
  27089. *
  27090. * _.inRange(3, 2, 4);
  27091. * // => true
  27092. *
  27093. * _.inRange(4, 8);
  27094. * // => true
  27095. *
  27096. * _.inRange(4, 2);
  27097. * // => false
  27098. *
  27099. * _.inRange(2, 2);
  27100. * // => false
  27101. *
  27102. * _.inRange(1.2, 2);
  27103. * // => true
  27104. *
  27105. * _.inRange(5.2, 4);
  27106. * // => false
  27107. *
  27108. * _.inRange(-3, -2, -6);
  27109. * // => true
  27110. */
  27111. function inRange(number, start, end) {
  27112. start = toFinite(start);
  27113. if (end === undefined) {
  27114. end = start;
  27115. start = 0;
  27116. } else {
  27117. end = toFinite(end);
  27118. }
  27119. number = toNumber(number);
  27120. return baseInRange(number, start, end);
  27121. }
  27122. /**
  27123. * Produces a random number between the inclusive `lower` and `upper` bounds.
  27124. * If only one argument is provided a number between `0` and the given number
  27125. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  27126. * floats, a floating-point number is returned instead of an integer.
  27127. *
  27128. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  27129. * floating-point values which can produce unexpected results.
  27130. *
  27131. * @static
  27132. * @memberOf _
  27133. * @since 0.7.0
  27134. * @category Number
  27135. * @param {number} [lower=0] The lower bound.
  27136. * @param {number} [upper=1] The upper bound.
  27137. * @param {boolean} [floating] Specify returning a floating-point number.
  27138. * @returns {number} Returns the random number.
  27139. * @example
  27140. *
  27141. * _.random(0, 5);
  27142. * // => an integer between 0 and 5
  27143. *
  27144. * _.random(5);
  27145. * // => also an integer between 0 and 5
  27146. *
  27147. * _.random(5, true);
  27148. * // => a floating-point number between 0 and 5
  27149. *
  27150. * _.random(1.2, 5.2);
  27151. * // => a floating-point number between 1.2 and 5.2
  27152. */
  27153. function random(lower, upper, floating) {
  27154. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  27155. upper = floating = undefined;
  27156. }
  27157. if (floating === undefined) {
  27158. if (typeof upper == 'boolean') {
  27159. floating = upper;
  27160. upper = undefined;
  27161. }
  27162. else if (typeof lower == 'boolean') {
  27163. floating = lower;
  27164. lower = undefined;
  27165. }
  27166. }
  27167. if (lower === undefined && upper === undefined) {
  27168. lower = 0;
  27169. upper = 1;
  27170. }
  27171. else {
  27172. lower = toFinite(lower);
  27173. if (upper === undefined) {
  27174. upper = lower;
  27175. lower = 0;
  27176. } else {
  27177. upper = toFinite(upper);
  27178. }
  27179. }
  27180. if (lower > upper) {
  27181. var temp = lower;
  27182. lower = upper;
  27183. upper = temp;
  27184. }
  27185. if (floating || lower % 1 || upper % 1) {
  27186. var rand = nativeRandom();
  27187. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  27188. }
  27189. return baseRandom(lower, upper);
  27190. }
  27191. /*------------------------------------------------------------------------*/
  27192. /**
  27193. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  27194. *
  27195. * @static
  27196. * @memberOf _
  27197. * @since 3.0.0
  27198. * @category String
  27199. * @param {string} [string=''] The string to convert.
  27200. * @returns {string} Returns the camel cased string.
  27201. * @example
  27202. *
  27203. * _.camelCase('Foo Bar');
  27204. * // => 'fooBar'
  27205. *
  27206. * _.camelCase('--foo-bar--');
  27207. * // => 'fooBar'
  27208. *
  27209. * _.camelCase('__FOO_BAR__');
  27210. * // => 'fooBar'
  27211. */
  27212. var camelCase = createCompounder(function(result, word, index) {
  27213. word = word.toLowerCase();
  27214. return result + (index ? capitalize(word) : word);
  27215. });
  27216. /**
  27217. * Converts the first character of `string` to upper case and the remaining
  27218. * to lower case.
  27219. *
  27220. * @static
  27221. * @memberOf _
  27222. * @since 3.0.0
  27223. * @category String
  27224. * @param {string} [string=''] The string to capitalize.
  27225. * @returns {string} Returns the capitalized string.
  27226. * @example
  27227. *
  27228. * _.capitalize('FRED');
  27229. * // => 'Fred'
  27230. */
  27231. function capitalize(string) {
  27232. return upperFirst(toString(string).toLowerCase());
  27233. }
  27234. /**
  27235. * Deburrs `string` by converting
  27236. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  27237. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  27238. * letters to basic Latin letters and removing
  27239. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  27240. *
  27241. * @static
  27242. * @memberOf _
  27243. * @since 3.0.0
  27244. * @category String
  27245. * @param {string} [string=''] The string to deburr.
  27246. * @returns {string} Returns the deburred string.
  27247. * @example
  27248. *
  27249. * _.deburr('déjà vu');
  27250. * // => 'deja vu'
  27251. */
  27252. function deburr(string) {
  27253. string = toString(string);
  27254. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  27255. }
  27256. /**
  27257. * Checks if `string` ends with the given target string.
  27258. *
  27259. * @static
  27260. * @memberOf _
  27261. * @since 3.0.0
  27262. * @category String
  27263. * @param {string} [string=''] The string to inspect.
  27264. * @param {string} [target] The string to search for.
  27265. * @param {number} [position=string.length] The position to search up to.
  27266. * @returns {boolean} Returns `true` if `string` ends with `target`,
  27267. * else `false`.
  27268. * @example
  27269. *
  27270. * _.endsWith('abc', 'c');
  27271. * // => true
  27272. *
  27273. * _.endsWith('abc', 'b');
  27274. * // => false
  27275. *
  27276. * _.endsWith('abc', 'b', 2);
  27277. * // => true
  27278. */
  27279. function endsWith(string, target, position) {
  27280. string = toString(string);
  27281. target = baseToString(target);
  27282. var length = string.length;
  27283. position = position === undefined
  27284. ? length
  27285. : baseClamp(toInteger(position), 0, length);
  27286. var end = position;
  27287. position -= target.length;
  27288. return position >= 0 && string.slice(position, end) == target;
  27289. }
  27290. /**
  27291. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  27292. * corresponding HTML entities.
  27293. *
  27294. * **Note:** No other characters are escaped. To escape additional
  27295. * characters use a third-party library like [_he_](https://mths.be/he).
  27296. *
  27297. * Though the ">" character is escaped for symmetry, characters like
  27298. * ">" and "/" don't need escaping in HTML and have no special meaning
  27299. * unless they're part of a tag or unquoted attribute value. See
  27300. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  27301. * (under "semi-related fun fact") for more details.
  27302. *
  27303. * When working with HTML you should always
  27304. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  27305. * XSS vectors.
  27306. *
  27307. * @static
  27308. * @since 0.1.0
  27309. * @memberOf _
  27310. * @category String
  27311. * @param {string} [string=''] The string to escape.
  27312. * @returns {string} Returns the escaped string.
  27313. * @example
  27314. *
  27315. * _.escape('fred, barney, & pebbles');
  27316. * // => 'fred, barney, &amp; pebbles'
  27317. */
  27318. function escape(string) {
  27319. string = toString(string);
  27320. return (string && reHasUnescapedHtml.test(string))
  27321. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  27322. : string;
  27323. }
  27324. /**
  27325. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  27326. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  27327. *
  27328. * @static
  27329. * @memberOf _
  27330. * @since 3.0.0
  27331. * @category String
  27332. * @param {string} [string=''] The string to escape.
  27333. * @returns {string} Returns the escaped string.
  27334. * @example
  27335. *
  27336. * _.escapeRegExp('[lodash](https://lodash.com/)');
  27337. * // => '\[lodash\]\(https://lodash\.com/\)'
  27338. */
  27339. function escapeRegExp(string) {
  27340. string = toString(string);
  27341. return (string && reHasRegExpChar.test(string))
  27342. ? string.replace(reRegExpChar, '\\$&')
  27343. : string;
  27344. }
  27345. /**
  27346. * Converts `string` to
  27347. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  27348. *
  27349. * @static
  27350. * @memberOf _
  27351. * @since 3.0.0
  27352. * @category String
  27353. * @param {string} [string=''] The string to convert.
  27354. * @returns {string} Returns the kebab cased string.
  27355. * @example
  27356. *
  27357. * _.kebabCase('Foo Bar');
  27358. * // => 'foo-bar'
  27359. *
  27360. * _.kebabCase('fooBar');
  27361. * // => 'foo-bar'
  27362. *
  27363. * _.kebabCase('__FOO_BAR__');
  27364. * // => 'foo-bar'
  27365. */
  27366. var kebabCase = createCompounder(function(result, word, index) {
  27367. return result + (index ? '-' : '') + word.toLowerCase();
  27368. });
  27369. /**
  27370. * Converts `string`, as space separated words, to lower case.
  27371. *
  27372. * @static
  27373. * @memberOf _
  27374. * @since 4.0.0
  27375. * @category String
  27376. * @param {string} [string=''] The string to convert.
  27377. * @returns {string} Returns the lower cased string.
  27378. * @example
  27379. *
  27380. * _.lowerCase('--Foo-Bar--');
  27381. * // => 'foo bar'
  27382. *
  27383. * _.lowerCase('fooBar');
  27384. * // => 'foo bar'
  27385. *
  27386. * _.lowerCase('__FOO_BAR__');
  27387. * // => 'foo bar'
  27388. */
  27389. var lowerCase = createCompounder(function(result, word, index) {
  27390. return result + (index ? ' ' : '') + word.toLowerCase();
  27391. });
  27392. /**
  27393. * Converts the first character of `string` to lower case.
  27394. *
  27395. * @static
  27396. * @memberOf _
  27397. * @since 4.0.0
  27398. * @category String
  27399. * @param {string} [string=''] The string to convert.
  27400. * @returns {string} Returns the converted string.
  27401. * @example
  27402. *
  27403. * _.lowerFirst('Fred');
  27404. * // => 'fred'
  27405. *
  27406. * _.lowerFirst('FRED');
  27407. * // => 'fRED'
  27408. */
  27409. var lowerFirst = createCaseFirst('toLowerCase');
  27410. /**
  27411. * Pads `string` on the left and right sides if it's shorter than `length`.
  27412. * Padding characters are truncated if they can't be evenly divided by `length`.
  27413. *
  27414. * @static
  27415. * @memberOf _
  27416. * @since 3.0.0
  27417. * @category String
  27418. * @param {string} [string=''] The string to pad.
  27419. * @param {number} [length=0] The padding length.
  27420. * @param {string} [chars=' '] The string used as padding.
  27421. * @returns {string} Returns the padded string.
  27422. * @example
  27423. *
  27424. * _.pad('abc', 8);
  27425. * // => ' abc '
  27426. *
  27427. * _.pad('abc', 8, '_-');
  27428. * // => '_-abc_-_'
  27429. *
  27430. * _.pad('abc', 3);
  27431. * // => 'abc'
  27432. */
  27433. function pad(string, length, chars) {
  27434. string = toString(string);
  27435. length = toInteger(length);
  27436. var strLength = length ? stringSize(string) : 0;
  27437. if (!length || strLength >= length) {
  27438. return string;
  27439. }
  27440. var mid = (length - strLength) / 2;
  27441. return (
  27442. createPadding(nativeFloor(mid), chars) +
  27443. string +
  27444. createPadding(nativeCeil(mid), chars)
  27445. );
  27446. }
  27447. /**
  27448. * Pads `string` on the right side if it's shorter than `length`. Padding
  27449. * characters are truncated if they exceed `length`.
  27450. *
  27451. * @static
  27452. * @memberOf _
  27453. * @since 4.0.0
  27454. * @category String
  27455. * @param {string} [string=''] The string to pad.
  27456. * @param {number} [length=0] The padding length.
  27457. * @param {string} [chars=' '] The string used as padding.
  27458. * @returns {string} Returns the padded string.
  27459. * @example
  27460. *
  27461. * _.padEnd('abc', 6);
  27462. * // => 'abc '
  27463. *
  27464. * _.padEnd('abc', 6, '_-');
  27465. * // => 'abc_-_'
  27466. *
  27467. * _.padEnd('abc', 3);
  27468. * // => 'abc'
  27469. */
  27470. function padEnd(string, length, chars) {
  27471. string = toString(string);
  27472. length = toInteger(length);
  27473. var strLength = length ? stringSize(string) : 0;
  27474. return (length && strLength < length)
  27475. ? (string + createPadding(length - strLength, chars))
  27476. : string;
  27477. }
  27478. /**
  27479. * Pads `string` on the left side if it's shorter than `length`. Padding
  27480. * characters are truncated if they exceed `length`.
  27481. *
  27482. * @static
  27483. * @memberOf _
  27484. * @since 4.0.0
  27485. * @category String
  27486. * @param {string} [string=''] The string to pad.
  27487. * @param {number} [length=0] The padding length.
  27488. * @param {string} [chars=' '] The string used as padding.
  27489. * @returns {string} Returns the padded string.
  27490. * @example
  27491. *
  27492. * _.padStart('abc', 6);
  27493. * // => ' abc'
  27494. *
  27495. * _.padStart('abc', 6, '_-');
  27496. * // => '_-_abc'
  27497. *
  27498. * _.padStart('abc', 3);
  27499. * // => 'abc'
  27500. */
  27501. function padStart(string, length, chars) {
  27502. string = toString(string);
  27503. length = toInteger(length);
  27504. var strLength = length ? stringSize(string) : 0;
  27505. return (length && strLength < length)
  27506. ? (createPadding(length - strLength, chars) + string)
  27507. : string;
  27508. }
  27509. /**
  27510. * Converts `string` to an integer of the specified radix. If `radix` is
  27511. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  27512. * hexadecimal, in which case a `radix` of `16` is used.
  27513. *
  27514. * **Note:** This method aligns with the
  27515. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  27516. *
  27517. * @static
  27518. * @memberOf _
  27519. * @since 1.1.0
  27520. * @category String
  27521. * @param {string} string The string to convert.
  27522. * @param {number} [radix=10] The radix to interpret `value` by.
  27523. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27524. * @returns {number} Returns the converted integer.
  27525. * @example
  27526. *
  27527. * _.parseInt('08');
  27528. * // => 8
  27529. *
  27530. * _.map(['6', '08', '10'], _.parseInt);
  27531. * // => [6, 8, 10]
  27532. */
  27533. function parseInt(string, radix, guard) {
  27534. if (guard || radix == null) {
  27535. radix = 0;
  27536. } else if (radix) {
  27537. radix = +radix;
  27538. }
  27539. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  27540. }
  27541. /**
  27542. * Repeats the given string `n` times.
  27543. *
  27544. * @static
  27545. * @memberOf _
  27546. * @since 3.0.0
  27547. * @category String
  27548. * @param {string} [string=''] The string to repeat.
  27549. * @param {number} [n=1] The number of times to repeat the string.
  27550. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27551. * @returns {string} Returns the repeated string.
  27552. * @example
  27553. *
  27554. * _.repeat('*', 3);
  27555. * // => '***'
  27556. *
  27557. * _.repeat('abc', 2);
  27558. * // => 'abcabc'
  27559. *
  27560. * _.repeat('abc', 0);
  27561. * // => ''
  27562. */
  27563. function repeat(string, n, guard) {
  27564. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  27565. n = 1;
  27566. } else {
  27567. n = toInteger(n);
  27568. }
  27569. return baseRepeat(toString(string), n);
  27570. }
  27571. /**
  27572. * Replaces matches for `pattern` in `string` with `replacement`.
  27573. *
  27574. * **Note:** This method is based on
  27575. * [`String#replace`](https://mdn.io/String/replace).
  27576. *
  27577. * @static
  27578. * @memberOf _
  27579. * @since 4.0.0
  27580. * @category String
  27581. * @param {string} [string=''] The string to modify.
  27582. * @param {RegExp|string} pattern The pattern to replace.
  27583. * @param {Function|string} replacement The match replacement.
  27584. * @returns {string} Returns the modified string.
  27585. * @example
  27586. *
  27587. * _.replace('Hi Fred', 'Fred', 'Barney');
  27588. * // => 'Hi Barney'
  27589. */
  27590. function replace() {
  27591. var args = arguments,
  27592. string = toString(args[0]);
  27593. return args.length < 3 ? string : string.replace(args[1], args[2]);
  27594. }
  27595. /**
  27596. * Converts `string` to
  27597. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  27598. *
  27599. * @static
  27600. * @memberOf _
  27601. * @since 3.0.0
  27602. * @category String
  27603. * @param {string} [string=''] The string to convert.
  27604. * @returns {string} Returns the snake cased string.
  27605. * @example
  27606. *
  27607. * _.snakeCase('Foo Bar');
  27608. * // => 'foo_bar'
  27609. *
  27610. * _.snakeCase('fooBar');
  27611. * // => 'foo_bar'
  27612. *
  27613. * _.snakeCase('--FOO-BAR--');
  27614. * // => 'foo_bar'
  27615. */
  27616. var snakeCase = createCompounder(function(result, word, index) {
  27617. return result + (index ? '_' : '') + word.toLowerCase();
  27618. });
  27619. /**
  27620. * Splits `string` by `separator`.
  27621. *
  27622. * **Note:** This method is based on
  27623. * [`String#split`](https://mdn.io/String/split).
  27624. *
  27625. * @static
  27626. * @memberOf _
  27627. * @since 4.0.0
  27628. * @category String
  27629. * @param {string} [string=''] The string to split.
  27630. * @param {RegExp|string} separator The separator pattern to split by.
  27631. * @param {number} [limit] The length to truncate results to.
  27632. * @returns {Array} Returns the string segments.
  27633. * @example
  27634. *
  27635. * _.split('a-b-c', '-', 2);
  27636. * // => ['a', 'b']
  27637. */
  27638. function split(string, separator, limit) {
  27639. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  27640. separator = limit = undefined;
  27641. }
  27642. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  27643. if (!limit) {
  27644. return [];
  27645. }
  27646. string = toString(string);
  27647. if (string && (
  27648. typeof separator == 'string' ||
  27649. (separator != null && !isRegExp(separator))
  27650. )) {
  27651. separator = baseToString(separator);
  27652. if (!separator && hasUnicode(string)) {
  27653. return castSlice(stringToArray(string), 0, limit);
  27654. }
  27655. }
  27656. return string.split(separator, limit);
  27657. }
  27658. /**
  27659. * Converts `string` to
  27660. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  27661. *
  27662. * @static
  27663. * @memberOf _
  27664. * @since 3.1.0
  27665. * @category String
  27666. * @param {string} [string=''] The string to convert.
  27667. * @returns {string} Returns the start cased string.
  27668. * @example
  27669. *
  27670. * _.startCase('--foo-bar--');
  27671. * // => 'Foo Bar'
  27672. *
  27673. * _.startCase('fooBar');
  27674. * // => 'Foo Bar'
  27675. *
  27676. * _.startCase('__FOO_BAR__');
  27677. * // => 'FOO BAR'
  27678. */
  27679. var startCase = createCompounder(function(result, word, index) {
  27680. return result + (index ? ' ' : '') + upperFirst(word);
  27681. });
  27682. /**
  27683. * Checks if `string` starts with the given target string.
  27684. *
  27685. * @static
  27686. * @memberOf _
  27687. * @since 3.0.0
  27688. * @category String
  27689. * @param {string} [string=''] The string to inspect.
  27690. * @param {string} [target] The string to search for.
  27691. * @param {number} [position=0] The position to search from.
  27692. * @returns {boolean} Returns `true` if `string` starts with `target`,
  27693. * else `false`.
  27694. * @example
  27695. *
  27696. * _.startsWith('abc', 'a');
  27697. * // => true
  27698. *
  27699. * _.startsWith('abc', 'b');
  27700. * // => false
  27701. *
  27702. * _.startsWith('abc', 'b', 1);
  27703. * // => true
  27704. */
  27705. function startsWith(string, target, position) {
  27706. string = toString(string);
  27707. position = position == null
  27708. ? 0
  27709. : baseClamp(toInteger(position), 0, string.length);
  27710. target = baseToString(target);
  27711. return string.slice(position, position + target.length) == target;
  27712. }
  27713. /**
  27714. * Creates a compiled template function that can interpolate data properties
  27715. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  27716. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  27717. * properties may be accessed as free variables in the template. If a setting
  27718. * object is given, it takes precedence over `_.templateSettings` values.
  27719. *
  27720. * **Note:** In the development build `_.template` utilizes
  27721. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  27722. * for easier debugging.
  27723. *
  27724. * For more information on precompiling templates see
  27725. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  27726. *
  27727. * For more information on Chrome extension sandboxes see
  27728. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  27729. *
  27730. * @static
  27731. * @since 0.1.0
  27732. * @memberOf _
  27733. * @category String
  27734. * @param {string} [string=''] The template string.
  27735. * @param {Object} [options={}] The options object.
  27736. * @param {RegExp} [options.escape=_.templateSettings.escape]
  27737. * The HTML "escape" delimiter.
  27738. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  27739. * The "evaluate" delimiter.
  27740. * @param {Object} [options.imports=_.templateSettings.imports]
  27741. * An object to import into the template as free variables.
  27742. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  27743. * The "interpolate" delimiter.
  27744. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  27745. * The sourceURL of the compiled template.
  27746. * @param {string} [options.variable='obj']
  27747. * The data object variable name.
  27748. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27749. * @returns {Function} Returns the compiled template function.
  27750. * @example
  27751. *
  27752. * // Use the "interpolate" delimiter to create a compiled template.
  27753. * var compiled = _.template('hello <%= user %>!');
  27754. * compiled({ 'user': 'fred' });
  27755. * // => 'hello fred!'
  27756. *
  27757. * // Use the HTML "escape" delimiter to escape data property values.
  27758. * var compiled = _.template('<b><%- value %></b>');
  27759. * compiled({ 'value': '<script>' });
  27760. * // => '<b>&lt;script&gt;</b>'
  27761. *
  27762. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  27763. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  27764. * compiled({ 'users': ['fred', 'barney'] });
  27765. * // => '<li>fred</li><li>barney</li>'
  27766. *
  27767. * // Use the internal `print` function in "evaluate" delimiters.
  27768. * var compiled = _.template('<% print("hello " + user); %>!');
  27769. * compiled({ 'user': 'barney' });
  27770. * // => 'hello barney!'
  27771. *
  27772. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  27773. * // Disable support by replacing the "interpolate" delimiter.
  27774. * var compiled = _.template('hello ${ user }!');
  27775. * compiled({ 'user': 'pebbles' });
  27776. * // => 'hello pebbles!'
  27777. *
  27778. * // Use backslashes to treat delimiters as plain text.
  27779. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  27780. * compiled({ 'value': 'ignored' });
  27781. * // => '<%- value %>'
  27782. *
  27783. * // Use the `imports` option to import `jQuery` as `jq`.
  27784. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  27785. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  27786. * compiled({ 'users': ['fred', 'barney'] });
  27787. * // => '<li>fred</li><li>barney</li>'
  27788. *
  27789. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  27790. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  27791. * compiled(data);
  27792. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  27793. *
  27794. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  27795. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  27796. * compiled.source;
  27797. * // => function(data) {
  27798. * // var __t, __p = '';
  27799. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  27800. * // return __p;
  27801. * // }
  27802. *
  27803. * // Use custom template delimiters.
  27804. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  27805. * var compiled = _.template('hello {{ user }}!');
  27806. * compiled({ 'user': 'mustache' });
  27807. * // => 'hello mustache!'
  27808. *
  27809. * // Use the `source` property to inline compiled templates for meaningful
  27810. * // line numbers in error messages and stack traces.
  27811. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  27812. * var JST = {\
  27813. * "main": ' + _.template(mainText).source + '\
  27814. * };\
  27815. * ');
  27816. */
  27817. function template(string, options, guard) {
  27818. // Based on John Resig's `tmpl` implementation
  27819. // (http://ejohn.org/blog/javascript-micro-templating/)
  27820. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  27821. var settings = lodash.templateSettings;
  27822. if (guard && isIterateeCall(string, options, guard)) {
  27823. options = undefined;
  27824. }
  27825. string = toString(string);
  27826. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  27827. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  27828. importsKeys = keys(imports),
  27829. importsValues = baseValues(imports, importsKeys);
  27830. var isEscaping,
  27831. isEvaluating,
  27832. index = 0,
  27833. interpolate = options.interpolate || reNoMatch,
  27834. source = "__p += '";
  27835. // Compile the regexp to match each delimiter.
  27836. var reDelimiters = RegExp(
  27837. (options.escape || reNoMatch).source + '|' +
  27838. interpolate.source + '|' +
  27839. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  27840. (options.evaluate || reNoMatch).source + '|$'
  27841. , 'g');
  27842. // Use a sourceURL for easier debugging.
  27843. // The sourceURL gets injected into the source that's eval-ed, so be careful
  27844. // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
  27845. // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
  27846. var sourceURL = '//# sourceURL=' +
  27847. (hasOwnProperty.call(options, 'sourceURL')
  27848. ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
  27849. : ('lodash.templateSources[' + (++templateCounter) + ']')
  27850. ) + '\n';
  27851. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  27852. interpolateValue || (interpolateValue = esTemplateValue);
  27853. // Escape characters that can't be included in string literals.
  27854. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  27855. // Replace delimiters with snippets.
  27856. if (escapeValue) {
  27857. isEscaping = true;
  27858. source += "' +\n__e(" + escapeValue + ") +\n'";
  27859. }
  27860. if (evaluateValue) {
  27861. isEvaluating = true;
  27862. source += "';\n" + evaluateValue + ";\n__p += '";
  27863. }
  27864. if (interpolateValue) {
  27865. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  27866. }
  27867. index = offset + match.length;
  27868. // The JS engine embedded in Adobe products needs `match` returned in
  27869. // order to produce the correct `offset` value.
  27870. return match;
  27871. });
  27872. source += "';\n";
  27873. // If `variable` is not specified wrap a with-statement around the generated
  27874. // code to add the data object to the top of the scope chain.
  27875. // Like with sourceURL, we take care to not check the option's prototype,
  27876. // as this configuration is a code injection vector.
  27877. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  27878. if (!variable) {
  27879. source = 'with (obj) {\n' + source + '\n}\n';
  27880. }
  27881. // Cleanup code by stripping empty strings.
  27882. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  27883. .replace(reEmptyStringMiddle, '$1')
  27884. .replace(reEmptyStringTrailing, '$1;');
  27885. // Frame code as the function body.
  27886. source = 'function(' + (variable || 'obj') + ') {\n' +
  27887. (variable
  27888. ? ''
  27889. : 'obj || (obj = {});\n'
  27890. ) +
  27891. "var __t, __p = ''" +
  27892. (isEscaping
  27893. ? ', __e = _.escape'
  27894. : ''
  27895. ) +
  27896. (isEvaluating
  27897. ? ', __j = Array.prototype.join;\n' +
  27898. "function print() { __p += __j.call(arguments, '') }\n"
  27899. : ';\n'
  27900. ) +
  27901. source +
  27902. 'return __p\n}';
  27903. var result = attempt(function() {
  27904. return Function(importsKeys, sourceURL + 'return ' + source)
  27905. .apply(undefined, importsValues);
  27906. });
  27907. // Provide the compiled function's source by its `toString` method or
  27908. // the `source` property as a convenience for inlining compiled templates.
  27909. result.source = source;
  27910. if (isError(result)) {
  27911. throw result;
  27912. }
  27913. return result;
  27914. }
  27915. /**
  27916. * Converts `string`, as a whole, to lower case just like
  27917. * [String#toLowerCase](https://mdn.io/toLowerCase).
  27918. *
  27919. * @static
  27920. * @memberOf _
  27921. * @since 4.0.0
  27922. * @category String
  27923. * @param {string} [string=''] The string to convert.
  27924. * @returns {string} Returns the lower cased string.
  27925. * @example
  27926. *
  27927. * _.toLower('--Foo-Bar--');
  27928. * // => '--foo-bar--'
  27929. *
  27930. * _.toLower('fooBar');
  27931. * // => 'foobar'
  27932. *
  27933. * _.toLower('__FOO_BAR__');
  27934. * // => '__foo_bar__'
  27935. */
  27936. function toLower(value) {
  27937. return toString(value).toLowerCase();
  27938. }
  27939. /**
  27940. * Converts `string`, as a whole, to upper case just like
  27941. * [String#toUpperCase](https://mdn.io/toUpperCase).
  27942. *
  27943. * @static
  27944. * @memberOf _
  27945. * @since 4.0.0
  27946. * @category String
  27947. * @param {string} [string=''] The string to convert.
  27948. * @returns {string} Returns the upper cased string.
  27949. * @example
  27950. *
  27951. * _.toUpper('--foo-bar--');
  27952. * // => '--FOO-BAR--'
  27953. *
  27954. * _.toUpper('fooBar');
  27955. * // => 'FOOBAR'
  27956. *
  27957. * _.toUpper('__foo_bar__');
  27958. * // => '__FOO_BAR__'
  27959. */
  27960. function toUpper(value) {
  27961. return toString(value).toUpperCase();
  27962. }
  27963. /**
  27964. * Removes leading and trailing whitespace or specified characters from `string`.
  27965. *
  27966. * @static
  27967. * @memberOf _
  27968. * @since 3.0.0
  27969. * @category String
  27970. * @param {string} [string=''] The string to trim.
  27971. * @param {string} [chars=whitespace] The characters to trim.
  27972. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27973. * @returns {string} Returns the trimmed string.
  27974. * @example
  27975. *
  27976. * _.trim(' abc ');
  27977. * // => 'abc'
  27978. *
  27979. * _.trim('-_-abc-_-', '_-');
  27980. * // => 'abc'
  27981. *
  27982. * _.map([' foo ', ' bar '], _.trim);
  27983. * // => ['foo', 'bar']
  27984. */
  27985. function trim(string, chars, guard) {
  27986. string = toString(string);
  27987. if (string && (guard || chars === undefined)) {
  27988. return string.replace(reTrim, '');
  27989. }
  27990. if (!string || !(chars = baseToString(chars))) {
  27991. return string;
  27992. }
  27993. var strSymbols = stringToArray(string),
  27994. chrSymbols = stringToArray(chars),
  27995. start = charsStartIndex(strSymbols, chrSymbols),
  27996. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  27997. return castSlice(strSymbols, start, end).join('');
  27998. }
  27999. /**
  28000. * Removes trailing whitespace or specified characters from `string`.
  28001. *
  28002. * @static
  28003. * @memberOf _
  28004. * @since 4.0.0
  28005. * @category String
  28006. * @param {string} [string=''] The string to trim.
  28007. * @param {string} [chars=whitespace] The characters to trim.
  28008. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  28009. * @returns {string} Returns the trimmed string.
  28010. * @example
  28011. *
  28012. * _.trimEnd(' abc ');
  28013. * // => ' abc'
  28014. *
  28015. * _.trimEnd('-_-abc-_-', '_-');
  28016. * // => '-_-abc'
  28017. */
  28018. function trimEnd(string, chars, guard) {
  28019. string = toString(string);
  28020. if (string && (guard || chars === undefined)) {
  28021. return string.replace(reTrimEnd, '');
  28022. }
  28023. if (!string || !(chars = baseToString(chars))) {
  28024. return string;
  28025. }
  28026. var strSymbols = stringToArray(string),
  28027. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  28028. return castSlice(strSymbols, 0, end).join('');
  28029. }
  28030. /**
  28031. * Removes leading whitespace or specified characters from `string`.
  28032. *
  28033. * @static
  28034. * @memberOf _
  28035. * @since 4.0.0
  28036. * @category String
  28037. * @param {string} [string=''] The string to trim.
  28038. * @param {string} [chars=whitespace] The characters to trim.
  28039. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  28040. * @returns {string} Returns the trimmed string.
  28041. * @example
  28042. *
  28043. * _.trimStart(' abc ');
  28044. * // => 'abc '
  28045. *
  28046. * _.trimStart('-_-abc-_-', '_-');
  28047. * // => 'abc-_-'
  28048. */
  28049. function trimStart(string, chars, guard) {
  28050. string = toString(string);
  28051. if (string && (guard || chars === undefined)) {
  28052. return string.replace(reTrimStart, '');
  28053. }
  28054. if (!string || !(chars = baseToString(chars))) {
  28055. return string;
  28056. }
  28057. var strSymbols = stringToArray(string),
  28058. start = charsStartIndex(strSymbols, stringToArray(chars));
  28059. return castSlice(strSymbols, start).join('');
  28060. }
  28061. /**
  28062. * Truncates `string` if it's longer than the given maximum string length.
  28063. * The last characters of the truncated string are replaced with the omission
  28064. * string which defaults to "...".
  28065. *
  28066. * @static
  28067. * @memberOf _
  28068. * @since 4.0.0
  28069. * @category String
  28070. * @param {string} [string=''] The string to truncate.
  28071. * @param {Object} [options={}] The options object.
  28072. * @param {number} [options.length=30] The maximum string length.
  28073. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  28074. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  28075. * @returns {string} Returns the truncated string.
  28076. * @example
  28077. *
  28078. * _.truncate('hi-diddly-ho there, neighborino');
  28079. * // => 'hi-diddly-ho there, neighbo...'
  28080. *
  28081. * _.truncate('hi-diddly-ho there, neighborino', {
  28082. * 'length': 24,
  28083. * 'separator': ' '
  28084. * });
  28085. * // => 'hi-diddly-ho there,...'
  28086. *
  28087. * _.truncate('hi-diddly-ho there, neighborino', {
  28088. * 'length': 24,
  28089. * 'separator': /,? +/
  28090. * });
  28091. * // => 'hi-diddly-ho there...'
  28092. *
  28093. * _.truncate('hi-diddly-ho there, neighborino', {
  28094. * 'omission': ' [...]'
  28095. * });
  28096. * // => 'hi-diddly-ho there, neig [...]'
  28097. */
  28098. function truncate(string, options) {
  28099. var length = DEFAULT_TRUNC_LENGTH,
  28100. omission = DEFAULT_TRUNC_OMISSION;
  28101. if (isObject(options)) {
  28102. var separator = 'separator' in options ? options.separator : separator;
  28103. length = 'length' in options ? toInteger(options.length) : length;
  28104. omission = 'omission' in options ? baseToString(options.omission) : omission;
  28105. }
  28106. string = toString(string);
  28107. var strLength = string.length;
  28108. if (hasUnicode(string)) {
  28109. var strSymbols = stringToArray(string);
  28110. strLength = strSymbols.length;
  28111. }
  28112. if (length >= strLength) {
  28113. return string;
  28114. }
  28115. var end = length - stringSize(omission);
  28116. if (end < 1) {
  28117. return omission;
  28118. }
  28119. var result = strSymbols
  28120. ? castSlice(strSymbols, 0, end).join('')
  28121. : string.slice(0, end);
  28122. if (separator === undefined) {
  28123. return result + omission;
  28124. }
  28125. if (strSymbols) {
  28126. end += (result.length - end);
  28127. }
  28128. if (isRegExp(separator)) {
  28129. if (string.slice(end).search(separator)) {
  28130. var match,
  28131. substring = result;
  28132. if (!separator.global) {
  28133. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  28134. }
  28135. separator.lastIndex = 0;
  28136. while ((match = separator.exec(substring))) {
  28137. var newEnd = match.index;
  28138. }
  28139. result = result.slice(0, newEnd === undefined ? end : newEnd);
  28140. }
  28141. } else if (string.indexOf(baseToString(separator), end) != end) {
  28142. var index = result.lastIndexOf(separator);
  28143. if (index > -1) {
  28144. result = result.slice(0, index);
  28145. }
  28146. }
  28147. return result + omission;
  28148. }
  28149. /**
  28150. * The inverse of `_.escape`; this method converts the HTML entities
  28151. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  28152. * their corresponding characters.
  28153. *
  28154. * **Note:** No other HTML entities are unescaped. To unescape additional
  28155. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  28156. *
  28157. * @static
  28158. * @memberOf _
  28159. * @since 0.6.0
  28160. * @category String
  28161. * @param {string} [string=''] The string to unescape.
  28162. * @returns {string} Returns the unescaped string.
  28163. * @example
  28164. *
  28165. * _.unescape('fred, barney, &amp; pebbles');
  28166. * // => 'fred, barney, & pebbles'
  28167. */
  28168. function unescape(string) {
  28169. string = toString(string);
  28170. return (string && reHasEscapedHtml.test(string))
  28171. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  28172. : string;
  28173. }
  28174. /**
  28175. * Converts `string`, as space separated words, to upper case.
  28176. *
  28177. * @static
  28178. * @memberOf _
  28179. * @since 4.0.0
  28180. * @category String
  28181. * @param {string} [string=''] The string to convert.
  28182. * @returns {string} Returns the upper cased string.
  28183. * @example
  28184. *
  28185. * _.upperCase('--foo-bar');
  28186. * // => 'FOO BAR'
  28187. *
  28188. * _.upperCase('fooBar');
  28189. * // => 'FOO BAR'
  28190. *
  28191. * _.upperCase('__foo_bar__');
  28192. * // => 'FOO BAR'
  28193. */
  28194. var upperCase = createCompounder(function(result, word, index) {
  28195. return result + (index ? ' ' : '') + word.toUpperCase();
  28196. });
  28197. /**
  28198. * Converts the first character of `string` to upper case.
  28199. *
  28200. * @static
  28201. * @memberOf _
  28202. * @since 4.0.0
  28203. * @category String
  28204. * @param {string} [string=''] The string to convert.
  28205. * @returns {string} Returns the converted string.
  28206. * @example
  28207. *
  28208. * _.upperFirst('fred');
  28209. * // => 'Fred'
  28210. *
  28211. * _.upperFirst('FRED');
  28212. * // => 'FRED'
  28213. */
  28214. var upperFirst = createCaseFirst('toUpperCase');
  28215. /**
  28216. * Splits `string` into an array of its words.
  28217. *
  28218. * @static
  28219. * @memberOf _
  28220. * @since 3.0.0
  28221. * @category String
  28222. * @param {string} [string=''] The string to inspect.
  28223. * @param {RegExp|string} [pattern] The pattern to match words.
  28224. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  28225. * @returns {Array} Returns the words of `string`.
  28226. * @example
  28227. *
  28228. * _.words('fred, barney, & pebbles');
  28229. * // => ['fred', 'barney', 'pebbles']
  28230. *
  28231. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  28232. * // => ['fred', 'barney', '&', 'pebbles']
  28233. */
  28234. function words(string, pattern, guard) {
  28235. string = toString(string);
  28236. pattern = guard ? undefined : pattern;
  28237. if (pattern === undefined) {
  28238. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  28239. }
  28240. return string.match(pattern) || [];
  28241. }
  28242. /*------------------------------------------------------------------------*/
  28243. /**
  28244. * Attempts to invoke `func`, returning either the result or the caught error
  28245. * object. Any additional arguments are provided to `func` when it's invoked.
  28246. *
  28247. * @static
  28248. * @memberOf _
  28249. * @since 3.0.0
  28250. * @category Util
  28251. * @param {Function} func The function to attempt.
  28252. * @param {...*} [args] The arguments to invoke `func` with.
  28253. * @returns {*} Returns the `func` result or error object.
  28254. * @example
  28255. *
  28256. * // Avoid throwing errors for invalid selectors.
  28257. * var elements = _.attempt(function(selector) {
  28258. * return document.querySelectorAll(selector);
  28259. * }, '>_>');
  28260. *
  28261. * if (_.isError(elements)) {
  28262. * elements = [];
  28263. * }
  28264. */
  28265. var attempt = baseRest(function(func, args) {
  28266. try {
  28267. return apply(func, undefined, args);
  28268. } catch (e) {
  28269. return isError(e) ? e : new Error(e);
  28270. }
  28271. });
  28272. /**
  28273. * Binds methods of an object to the object itself, overwriting the existing
  28274. * method.
  28275. *
  28276. * **Note:** This method doesn't set the "length" property of bound functions.
  28277. *
  28278. * @static
  28279. * @since 0.1.0
  28280. * @memberOf _
  28281. * @category Util
  28282. * @param {Object} object The object to bind and assign the bound methods to.
  28283. * @param {...(string|string[])} methodNames The object method names to bind.
  28284. * @returns {Object} Returns `object`.
  28285. * @example
  28286. *
  28287. * var view = {
  28288. * 'label': 'docs',
  28289. * 'click': function() {
  28290. * console.log('clicked ' + this.label);
  28291. * }
  28292. * };
  28293. *
  28294. * _.bindAll(view, ['click']);
  28295. * jQuery(element).on('click', view.click);
  28296. * // => Logs 'clicked docs' when clicked.
  28297. */
  28298. var bindAll = flatRest(function(object, methodNames) {
  28299. arrayEach(methodNames, function(key) {
  28300. key = toKey(key);
  28301. baseAssignValue(object, key, bind(object[key], object));
  28302. });
  28303. return object;
  28304. });
  28305. /**
  28306. * Creates a function that iterates over `pairs` and invokes the corresponding
  28307. * function of the first predicate to return truthy. The predicate-function
  28308. * pairs are invoked with the `this` binding and arguments of the created
  28309. * function.
  28310. *
  28311. * @static
  28312. * @memberOf _
  28313. * @since 4.0.0
  28314. * @category Util
  28315. * @param {Array} pairs The predicate-function pairs.
  28316. * @returns {Function} Returns the new composite function.
  28317. * @example
  28318. *
  28319. * var func = _.cond([
  28320. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  28321. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  28322. * [_.stubTrue, _.constant('no match')]
  28323. * ]);
  28324. *
  28325. * func({ 'a': 1, 'b': 2 });
  28326. * // => 'matches A'
  28327. *
  28328. * func({ 'a': 0, 'b': 1 });
  28329. * // => 'matches B'
  28330. *
  28331. * func({ 'a': '1', 'b': '2' });
  28332. * // => 'no match'
  28333. */
  28334. function cond(pairs) {
  28335. var length = pairs == null ? 0 : pairs.length,
  28336. toIteratee = getIteratee();
  28337. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  28338. if (typeof pair[1] != 'function') {
  28339. throw new TypeError(FUNC_ERROR_TEXT);
  28340. }
  28341. return [toIteratee(pair[0]), pair[1]];
  28342. });
  28343. return baseRest(function(args) {
  28344. var index = -1;
  28345. while (++index < length) {
  28346. var pair = pairs[index];
  28347. if (apply(pair[0], this, args)) {
  28348. return apply(pair[1], this, args);
  28349. }
  28350. }
  28351. });
  28352. }
  28353. /**
  28354. * Creates a function that invokes the predicate properties of `source` with
  28355. * the corresponding property values of a given object, returning `true` if
  28356. * all predicates return truthy, else `false`.
  28357. *
  28358. * **Note:** The created function is equivalent to `_.conformsTo` with
  28359. * `source` partially applied.
  28360. *
  28361. * @static
  28362. * @memberOf _
  28363. * @since 4.0.0
  28364. * @category Util
  28365. * @param {Object} source The object of property predicates to conform to.
  28366. * @returns {Function} Returns the new spec function.
  28367. * @example
  28368. *
  28369. * var objects = [
  28370. * { 'a': 2, 'b': 1 },
  28371. * { 'a': 1, 'b': 2 }
  28372. * ];
  28373. *
  28374. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  28375. * // => [{ 'a': 1, 'b': 2 }]
  28376. */
  28377. function conforms(source) {
  28378. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  28379. }
  28380. /**
  28381. * Creates a function that returns `value`.
  28382. *
  28383. * @static
  28384. * @memberOf _
  28385. * @since 2.4.0
  28386. * @category Util
  28387. * @param {*} value The value to return from the new function.
  28388. * @returns {Function} Returns the new constant function.
  28389. * @example
  28390. *
  28391. * var objects = _.times(2, _.constant({ 'a': 1 }));
  28392. *
  28393. * console.log(objects);
  28394. * // => [{ 'a': 1 }, { 'a': 1 }]
  28395. *
  28396. * console.log(objects[0] === objects[1]);
  28397. * // => true
  28398. */
  28399. function constant(value) {
  28400. return function() {
  28401. return value;
  28402. };
  28403. }
  28404. /**
  28405. * Checks `value` to determine whether a default value should be returned in
  28406. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  28407. * or `undefined`.
  28408. *
  28409. * @static
  28410. * @memberOf _
  28411. * @since 4.14.0
  28412. * @category Util
  28413. * @param {*} value The value to check.
  28414. * @param {*} defaultValue The default value.
  28415. * @returns {*} Returns the resolved value.
  28416. * @example
  28417. *
  28418. * _.defaultTo(1, 10);
  28419. * // => 1
  28420. *
  28421. * _.defaultTo(undefined, 10);
  28422. * // => 10
  28423. */
  28424. function defaultTo(value, defaultValue) {
  28425. return (value == null || value !== value) ? defaultValue : value;
  28426. }
  28427. /**
  28428. * Creates a function that returns the result of invoking the given functions
  28429. * with the `this` binding of the created function, where each successive
  28430. * invocation is supplied the return value of the previous.
  28431. *
  28432. * @static
  28433. * @memberOf _
  28434. * @since 3.0.0
  28435. * @category Util
  28436. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  28437. * @returns {Function} Returns the new composite function.
  28438. * @see _.flowRight
  28439. * @example
  28440. *
  28441. * function square(n) {
  28442. * return n * n;
  28443. * }
  28444. *
  28445. * var addSquare = _.flow([_.add, square]);
  28446. * addSquare(1, 2);
  28447. * // => 9
  28448. */
  28449. var flow = createFlow();
  28450. /**
  28451. * This method is like `_.flow` except that it creates a function that
  28452. * invokes the given functions from right to left.
  28453. *
  28454. * @static
  28455. * @since 3.0.0
  28456. * @memberOf _
  28457. * @category Util
  28458. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  28459. * @returns {Function} Returns the new composite function.
  28460. * @see _.flow
  28461. * @example
  28462. *
  28463. * function square(n) {
  28464. * return n * n;
  28465. * }
  28466. *
  28467. * var addSquare = _.flowRight([square, _.add]);
  28468. * addSquare(1, 2);
  28469. * // => 9
  28470. */
  28471. var flowRight = createFlow(true);
  28472. /**
  28473. * This method returns the first argument it receives.
  28474. *
  28475. * @static
  28476. * @since 0.1.0
  28477. * @memberOf _
  28478. * @category Util
  28479. * @param {*} value Any value.
  28480. * @returns {*} Returns `value`.
  28481. * @example
  28482. *
  28483. * var object = { 'a': 1 };
  28484. *
  28485. * console.log(_.identity(object) === object);
  28486. * // => true
  28487. */
  28488. function identity(value) {
  28489. return value;
  28490. }
  28491. /**
  28492. * Creates a function that invokes `func` with the arguments of the created
  28493. * function. If `func` is a property name, the created function returns the
  28494. * property value for a given element. If `func` is an array or object, the
  28495. * created function returns `true` for elements that contain the equivalent
  28496. * source properties, otherwise it returns `false`.
  28497. *
  28498. * @static
  28499. * @since 4.0.0
  28500. * @memberOf _
  28501. * @category Util
  28502. * @param {*} [func=_.identity] The value to convert to a callback.
  28503. * @returns {Function} Returns the callback.
  28504. * @example
  28505. *
  28506. * var users = [
  28507. * { 'user': 'barney', 'age': 36, 'active': true },
  28508. * { 'user': 'fred', 'age': 40, 'active': false }
  28509. * ];
  28510. *
  28511. * // The `_.matches` iteratee shorthand.
  28512. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  28513. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  28514. *
  28515. * // The `_.matchesProperty` iteratee shorthand.
  28516. * _.filter(users, _.iteratee(['user', 'fred']));
  28517. * // => [{ 'user': 'fred', 'age': 40 }]
  28518. *
  28519. * // The `_.property` iteratee shorthand.
  28520. * _.map(users, _.iteratee('user'));
  28521. * // => ['barney', 'fred']
  28522. *
  28523. * // Create custom iteratee shorthands.
  28524. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  28525. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  28526. * return func.test(string);
  28527. * };
  28528. * });
  28529. *
  28530. * _.filter(['abc', 'def'], /ef/);
  28531. * // => ['def']
  28532. */
  28533. function iteratee(func) {
  28534. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  28535. }
  28536. /**
  28537. * Creates a function that performs a partial deep comparison between a given
  28538. * object and `source`, returning `true` if the given object has equivalent
  28539. * property values, else `false`.
  28540. *
  28541. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  28542. * partially applied.
  28543. *
  28544. * Partial comparisons will match empty array and empty object `source`
  28545. * values against any array or object value, respectively. See `_.isEqual`
  28546. * for a list of supported value comparisons.
  28547. *
  28548. * @static
  28549. * @memberOf _
  28550. * @since 3.0.0
  28551. * @category Util
  28552. * @param {Object} source The object of property values to match.
  28553. * @returns {Function} Returns the new spec function.
  28554. * @example
  28555. *
  28556. * var objects = [
  28557. * { 'a': 1, 'b': 2, 'c': 3 },
  28558. * { 'a': 4, 'b': 5, 'c': 6 }
  28559. * ];
  28560. *
  28561. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  28562. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  28563. */
  28564. function matches(source) {
  28565. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  28566. }
  28567. /**
  28568. * Creates a function that performs a partial deep comparison between the
  28569. * value at `path` of a given object to `srcValue`, returning `true` if the
  28570. * object value is equivalent, else `false`.
  28571. *
  28572. * **Note:** Partial comparisons will match empty array and empty object
  28573. * `srcValue` values against any array or object value, respectively. See
  28574. * `_.isEqual` for a list of supported value comparisons.
  28575. *
  28576. * @static
  28577. * @memberOf _
  28578. * @since 3.2.0
  28579. * @category Util
  28580. * @param {Array|string} path The path of the property to get.
  28581. * @param {*} srcValue The value to match.
  28582. * @returns {Function} Returns the new spec function.
  28583. * @example
  28584. *
  28585. * var objects = [
  28586. * { 'a': 1, 'b': 2, 'c': 3 },
  28587. * { 'a': 4, 'b': 5, 'c': 6 }
  28588. * ];
  28589. *
  28590. * _.find(objects, _.matchesProperty('a', 4));
  28591. * // => { 'a': 4, 'b': 5, 'c': 6 }
  28592. */
  28593. function matchesProperty(path, srcValue) {
  28594. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  28595. }
  28596. /**
  28597. * Creates a function that invokes the method at `path` of a given object.
  28598. * Any additional arguments are provided to the invoked method.
  28599. *
  28600. * @static
  28601. * @memberOf _
  28602. * @since 3.7.0
  28603. * @category Util
  28604. * @param {Array|string} path The path of the method to invoke.
  28605. * @param {...*} [args] The arguments to invoke the method with.
  28606. * @returns {Function} Returns the new invoker function.
  28607. * @example
  28608. *
  28609. * var objects = [
  28610. * { 'a': { 'b': _.constant(2) } },
  28611. * { 'a': { 'b': _.constant(1) } }
  28612. * ];
  28613. *
  28614. * _.map(objects, _.method('a.b'));
  28615. * // => [2, 1]
  28616. *
  28617. * _.map(objects, _.method(['a', 'b']));
  28618. * // => [2, 1]
  28619. */
  28620. var method = baseRest(function(path, args) {
  28621. return function(object) {
  28622. return baseInvoke(object, path, args);
  28623. };
  28624. });
  28625. /**
  28626. * The opposite of `_.method`; this method creates a function that invokes
  28627. * the method at a given path of `object`. Any additional arguments are
  28628. * provided to the invoked method.
  28629. *
  28630. * @static
  28631. * @memberOf _
  28632. * @since 3.7.0
  28633. * @category Util
  28634. * @param {Object} object The object to query.
  28635. * @param {...*} [args] The arguments to invoke the method with.
  28636. * @returns {Function} Returns the new invoker function.
  28637. * @example
  28638. *
  28639. * var array = _.times(3, _.constant),
  28640. * object = { 'a': array, 'b': array, 'c': array };
  28641. *
  28642. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  28643. * // => [2, 0]
  28644. *
  28645. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  28646. * // => [2, 0]
  28647. */
  28648. var methodOf = baseRest(function(object, args) {
  28649. return function(path) {
  28650. return baseInvoke(object, path, args);
  28651. };
  28652. });
  28653. /**
  28654. * Adds all own enumerable string keyed function properties of a source
  28655. * object to the destination object. If `object` is a function, then methods
  28656. * are added to its prototype as well.
  28657. *
  28658. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  28659. * avoid conflicts caused by modifying the original.
  28660. *
  28661. * @static
  28662. * @since 0.1.0
  28663. * @memberOf _
  28664. * @category Util
  28665. * @param {Function|Object} [object=lodash] The destination object.
  28666. * @param {Object} source The object of functions to add.
  28667. * @param {Object} [options={}] The options object.
  28668. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  28669. * @returns {Function|Object} Returns `object`.
  28670. * @example
  28671. *
  28672. * function vowels(string) {
  28673. * return _.filter(string, function(v) {
  28674. * return /[aeiou]/i.test(v);
  28675. * });
  28676. * }
  28677. *
  28678. * _.mixin({ 'vowels': vowels });
  28679. * _.vowels('fred');
  28680. * // => ['e']
  28681. *
  28682. * _('fred').vowels().value();
  28683. * // => ['e']
  28684. *
  28685. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  28686. * _('fred').vowels();
  28687. * // => ['e']
  28688. */
  28689. function mixin(object, source, options) {
  28690. var props = keys(source),
  28691. methodNames = baseFunctions(source, props);
  28692. if (options == null &&
  28693. !(isObject(source) && (methodNames.length || !props.length))) {
  28694. options = source;
  28695. source = object;
  28696. object = this;
  28697. methodNames = baseFunctions(source, keys(source));
  28698. }
  28699. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  28700. isFunc = isFunction(object);
  28701. arrayEach(methodNames, function(methodName) {
  28702. var func = source[methodName];
  28703. object[methodName] = func;
  28704. if (isFunc) {
  28705. object.prototype[methodName] = function() {
  28706. var chainAll = this.__chain__;
  28707. if (chain || chainAll) {
  28708. var result = object(this.__wrapped__),
  28709. actions = result.__actions__ = copyArray(this.__actions__);
  28710. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  28711. result.__chain__ = chainAll;
  28712. return result;
  28713. }
  28714. return func.apply(object, arrayPush([this.value()], arguments));
  28715. };
  28716. }
  28717. });
  28718. return object;
  28719. }
  28720. /**
  28721. * Reverts the `_` variable to its previous value and returns a reference to
  28722. * the `lodash` function.
  28723. *
  28724. * @static
  28725. * @since 0.1.0
  28726. * @memberOf _
  28727. * @category Util
  28728. * @returns {Function} Returns the `lodash` function.
  28729. * @example
  28730. *
  28731. * var lodash = _.noConflict();
  28732. */
  28733. function noConflict() {
  28734. if (root._ === this) {
  28735. root._ = oldDash;
  28736. }
  28737. return this;
  28738. }
  28739. /**
  28740. * This method returns `undefined`.
  28741. *
  28742. * @static
  28743. * @memberOf _
  28744. * @since 2.3.0
  28745. * @category Util
  28746. * @example
  28747. *
  28748. * _.times(2, _.noop);
  28749. * // => [undefined, undefined]
  28750. */
  28751. function noop() {
  28752. // No operation performed.
  28753. }
  28754. /**
  28755. * Creates a function that gets the argument at index `n`. If `n` is negative,
  28756. * the nth argument from the end is returned.
  28757. *
  28758. * @static
  28759. * @memberOf _
  28760. * @since 4.0.0
  28761. * @category Util
  28762. * @param {number} [n=0] The index of the argument to return.
  28763. * @returns {Function} Returns the new pass-thru function.
  28764. * @example
  28765. *
  28766. * var func = _.nthArg(1);
  28767. * func('a', 'b', 'c', 'd');
  28768. * // => 'b'
  28769. *
  28770. * var func = _.nthArg(-2);
  28771. * func('a', 'b', 'c', 'd');
  28772. * // => 'c'
  28773. */
  28774. function nthArg(n) {
  28775. n = toInteger(n);
  28776. return baseRest(function(args) {
  28777. return baseNth(args, n);
  28778. });
  28779. }
  28780. /**
  28781. * Creates a function that invokes `iteratees` with the arguments it receives
  28782. * and returns their results.
  28783. *
  28784. * @static
  28785. * @memberOf _
  28786. * @since 4.0.0
  28787. * @category Util
  28788. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  28789. * The iteratees to invoke.
  28790. * @returns {Function} Returns the new function.
  28791. * @example
  28792. *
  28793. * var func = _.over([Math.max, Math.min]);
  28794. *
  28795. * func(1, 2, 3, 4);
  28796. * // => [4, 1]
  28797. */
  28798. var over = createOver(arrayMap);
  28799. /**
  28800. * Creates a function that checks if **all** of the `predicates` return
  28801. * truthy when invoked with the arguments it receives.
  28802. *
  28803. * @static
  28804. * @memberOf _
  28805. * @since 4.0.0
  28806. * @category Util
  28807. * @param {...(Function|Function[])} [predicates=[_.identity]]
  28808. * The predicates to check.
  28809. * @returns {Function} Returns the new function.
  28810. * @example
  28811. *
  28812. * var func = _.overEvery([Boolean, isFinite]);
  28813. *
  28814. * func('1');
  28815. * // => true
  28816. *
  28817. * func(null);
  28818. * // => false
  28819. *
  28820. * func(NaN);
  28821. * // => false
  28822. */
  28823. var overEvery = createOver(arrayEvery);
  28824. /**
  28825. * Creates a function that checks if **any** of the `predicates` return
  28826. * truthy when invoked with the arguments it receives.
  28827. *
  28828. * @static
  28829. * @memberOf _
  28830. * @since 4.0.0
  28831. * @category Util
  28832. * @param {...(Function|Function[])} [predicates=[_.identity]]
  28833. * The predicates to check.
  28834. * @returns {Function} Returns the new function.
  28835. * @example
  28836. *
  28837. * var func = _.overSome([Boolean, isFinite]);
  28838. *
  28839. * func('1');
  28840. * // => true
  28841. *
  28842. * func(null);
  28843. * // => true
  28844. *
  28845. * func(NaN);
  28846. * // => false
  28847. */
  28848. var overSome = createOver(arraySome);
  28849. /**
  28850. * Creates a function that returns the value at `path` of a given object.
  28851. *
  28852. * @static
  28853. * @memberOf _
  28854. * @since 2.4.0
  28855. * @category Util
  28856. * @param {Array|string} path The path of the property to get.
  28857. * @returns {Function} Returns the new accessor function.
  28858. * @example
  28859. *
  28860. * var objects = [
  28861. * { 'a': { 'b': 2 } },
  28862. * { 'a': { 'b': 1 } }
  28863. * ];
  28864. *
  28865. * _.map(objects, _.property('a.b'));
  28866. * // => [2, 1]
  28867. *
  28868. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  28869. * // => [1, 2]
  28870. */
  28871. function property(path) {
  28872. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  28873. }
  28874. /**
  28875. * The opposite of `_.property`; this method creates a function that returns
  28876. * the value at a given path of `object`.
  28877. *
  28878. * @static
  28879. * @memberOf _
  28880. * @since 3.0.0
  28881. * @category Util
  28882. * @param {Object} object The object to query.
  28883. * @returns {Function} Returns the new accessor function.
  28884. * @example
  28885. *
  28886. * var array = [0, 1, 2],
  28887. * object = { 'a': array, 'b': array, 'c': array };
  28888. *
  28889. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  28890. * // => [2, 0]
  28891. *
  28892. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  28893. * // => [2, 0]
  28894. */
  28895. function propertyOf(object) {
  28896. return function(path) {
  28897. return object == null ? undefined : baseGet(object, path);
  28898. };
  28899. }
  28900. /**
  28901. * Creates an array of numbers (positive and/or negative) progressing from
  28902. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  28903. * `start` is specified without an `end` or `step`. If `end` is not specified,
  28904. * it's set to `start` with `start` then set to `0`.
  28905. *
  28906. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  28907. * floating-point values which can produce unexpected results.
  28908. *
  28909. * @static
  28910. * @since 0.1.0
  28911. * @memberOf _
  28912. * @category Util
  28913. * @param {number} [start=0] The start of the range.
  28914. * @param {number} end The end of the range.
  28915. * @param {number} [step=1] The value to increment or decrement by.
  28916. * @returns {Array} Returns the range of numbers.
  28917. * @see _.inRange, _.rangeRight
  28918. * @example
  28919. *
  28920. * _.range(4);
  28921. * // => [0, 1, 2, 3]
  28922. *
  28923. * _.range(-4);
  28924. * // => [0, -1, -2, -3]
  28925. *
  28926. * _.range(1, 5);
  28927. * // => [1, 2, 3, 4]
  28928. *
  28929. * _.range(0, 20, 5);
  28930. * // => [0, 5, 10, 15]
  28931. *
  28932. * _.range(0, -4, -1);
  28933. * // => [0, -1, -2, -3]
  28934. *
  28935. * _.range(1, 4, 0);
  28936. * // => [1, 1, 1]
  28937. *
  28938. * _.range(0);
  28939. * // => []
  28940. */
  28941. var range = createRange();
  28942. /**
  28943. * This method is like `_.range` except that it populates values in
  28944. * descending order.
  28945. *
  28946. * @static
  28947. * @memberOf _
  28948. * @since 4.0.0
  28949. * @category Util
  28950. * @param {number} [start=0] The start of the range.
  28951. * @param {number} end The end of the range.
  28952. * @param {number} [step=1] The value to increment or decrement by.
  28953. * @returns {Array} Returns the range of numbers.
  28954. * @see _.inRange, _.range
  28955. * @example
  28956. *
  28957. * _.rangeRight(4);
  28958. * // => [3, 2, 1, 0]
  28959. *
  28960. * _.rangeRight(-4);
  28961. * // => [-3, -2, -1, 0]
  28962. *
  28963. * _.rangeRight(1, 5);
  28964. * // => [4, 3, 2, 1]
  28965. *
  28966. * _.rangeRight(0, 20, 5);
  28967. * // => [15, 10, 5, 0]
  28968. *
  28969. * _.rangeRight(0, -4, -1);
  28970. * // => [-3, -2, -1, 0]
  28971. *
  28972. * _.rangeRight(1, 4, 0);
  28973. * // => [1, 1, 1]
  28974. *
  28975. * _.rangeRight(0);
  28976. * // => []
  28977. */
  28978. var rangeRight = createRange(true);
  28979. /**
  28980. * This method returns a new empty array.
  28981. *
  28982. * @static
  28983. * @memberOf _
  28984. * @since 4.13.0
  28985. * @category Util
  28986. * @returns {Array} Returns the new empty array.
  28987. * @example
  28988. *
  28989. * var arrays = _.times(2, _.stubArray);
  28990. *
  28991. * console.log(arrays);
  28992. * // => [[], []]
  28993. *
  28994. * console.log(arrays[0] === arrays[1]);
  28995. * // => false
  28996. */
  28997. function stubArray() {
  28998. return [];
  28999. }
  29000. /**
  29001. * This method returns `false`.
  29002. *
  29003. * @static
  29004. * @memberOf _
  29005. * @since 4.13.0
  29006. * @category Util
  29007. * @returns {boolean} Returns `false`.
  29008. * @example
  29009. *
  29010. * _.times(2, _.stubFalse);
  29011. * // => [false, false]
  29012. */
  29013. function stubFalse() {
  29014. return false;
  29015. }
  29016. /**
  29017. * This method returns a new empty object.
  29018. *
  29019. * @static
  29020. * @memberOf _
  29021. * @since 4.13.0
  29022. * @category Util
  29023. * @returns {Object} Returns the new empty object.
  29024. * @example
  29025. *
  29026. * var objects = _.times(2, _.stubObject);
  29027. *
  29028. * console.log(objects);
  29029. * // => [{}, {}]
  29030. *
  29031. * console.log(objects[0] === objects[1]);
  29032. * // => false
  29033. */
  29034. function stubObject() {
  29035. return {};
  29036. }
  29037. /**
  29038. * This method returns an empty string.
  29039. *
  29040. * @static
  29041. * @memberOf _
  29042. * @since 4.13.0
  29043. * @category Util
  29044. * @returns {string} Returns the empty string.
  29045. * @example
  29046. *
  29047. * _.times(2, _.stubString);
  29048. * // => ['', '']
  29049. */
  29050. function stubString() {
  29051. return '';
  29052. }
  29053. /**
  29054. * This method returns `true`.
  29055. *
  29056. * @static
  29057. * @memberOf _
  29058. * @since 4.13.0
  29059. * @category Util
  29060. * @returns {boolean} Returns `true`.
  29061. * @example
  29062. *
  29063. * _.times(2, _.stubTrue);
  29064. * // => [true, true]
  29065. */
  29066. function stubTrue() {
  29067. return true;
  29068. }
  29069. /**
  29070. * Invokes the iteratee `n` times, returning an array of the results of
  29071. * each invocation. The iteratee is invoked with one argument; (index).
  29072. *
  29073. * @static
  29074. * @since 0.1.0
  29075. * @memberOf _
  29076. * @category Util
  29077. * @param {number} n The number of times to invoke `iteratee`.
  29078. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29079. * @returns {Array} Returns the array of results.
  29080. * @example
  29081. *
  29082. * _.times(3, String);
  29083. * // => ['0', '1', '2']
  29084. *
  29085. * _.times(4, _.constant(0));
  29086. * // => [0, 0, 0, 0]
  29087. */
  29088. function times(n, iteratee) {
  29089. n = toInteger(n);
  29090. if (n < 1 || n > MAX_SAFE_INTEGER) {
  29091. return [];
  29092. }
  29093. var index = MAX_ARRAY_LENGTH,
  29094. length = nativeMin(n, MAX_ARRAY_LENGTH);
  29095. iteratee = getIteratee(iteratee);
  29096. n -= MAX_ARRAY_LENGTH;
  29097. var result = baseTimes(length, iteratee);
  29098. while (++index < n) {
  29099. iteratee(index);
  29100. }
  29101. return result;
  29102. }
  29103. /**
  29104. * Converts `value` to a property path array.
  29105. *
  29106. * @static
  29107. * @memberOf _
  29108. * @since 4.0.0
  29109. * @category Util
  29110. * @param {*} value The value to convert.
  29111. * @returns {Array} Returns the new property path array.
  29112. * @example
  29113. *
  29114. * _.toPath('a.b.c');
  29115. * // => ['a', 'b', 'c']
  29116. *
  29117. * _.toPath('a[0].b.c');
  29118. * // => ['a', '0', 'b', 'c']
  29119. */
  29120. function toPath(value) {
  29121. if (isArray(value)) {
  29122. return arrayMap(value, toKey);
  29123. }
  29124. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  29125. }
  29126. /**
  29127. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  29128. *
  29129. * @static
  29130. * @since 0.1.0
  29131. * @memberOf _
  29132. * @category Util
  29133. * @param {string} [prefix=''] The value to prefix the ID with.
  29134. * @returns {string} Returns the unique ID.
  29135. * @example
  29136. *
  29137. * _.uniqueId('contact_');
  29138. * // => 'contact_104'
  29139. *
  29140. * _.uniqueId();
  29141. * // => '105'
  29142. */
  29143. function uniqueId(prefix) {
  29144. var id = ++idCounter;
  29145. return toString(prefix) + id;
  29146. }
  29147. /*------------------------------------------------------------------------*/
  29148. /**
  29149. * Adds two numbers.
  29150. *
  29151. * @static
  29152. * @memberOf _
  29153. * @since 3.4.0
  29154. * @category Math
  29155. * @param {number} augend The first number in an addition.
  29156. * @param {number} addend The second number in an addition.
  29157. * @returns {number} Returns the total.
  29158. * @example
  29159. *
  29160. * _.add(6, 4);
  29161. * // => 10
  29162. */
  29163. var add = createMathOperation(function(augend, addend) {
  29164. return augend + addend;
  29165. }, 0);
  29166. /**
  29167. * Computes `number` rounded up to `precision`.
  29168. *
  29169. * @static
  29170. * @memberOf _
  29171. * @since 3.10.0
  29172. * @category Math
  29173. * @param {number} number The number to round up.
  29174. * @param {number} [precision=0] The precision to round up to.
  29175. * @returns {number} Returns the rounded up number.
  29176. * @example
  29177. *
  29178. * _.ceil(4.006);
  29179. * // => 5
  29180. *
  29181. * _.ceil(6.004, 2);
  29182. * // => 6.01
  29183. *
  29184. * _.ceil(6040, -2);
  29185. * // => 6100
  29186. */
  29187. var ceil = createRound('ceil');
  29188. /**
  29189. * Divide two numbers.
  29190. *
  29191. * @static
  29192. * @memberOf _
  29193. * @since 4.7.0
  29194. * @category Math
  29195. * @param {number} dividend The first number in a division.
  29196. * @param {number} divisor The second number in a division.
  29197. * @returns {number} Returns the quotient.
  29198. * @example
  29199. *
  29200. * _.divide(6, 4);
  29201. * // => 1.5
  29202. */
  29203. var divide = createMathOperation(function(dividend, divisor) {
  29204. return dividend / divisor;
  29205. }, 1);
  29206. /**
  29207. * Computes `number` rounded down to `precision`.
  29208. *
  29209. * @static
  29210. * @memberOf _
  29211. * @since 3.10.0
  29212. * @category Math
  29213. * @param {number} number The number to round down.
  29214. * @param {number} [precision=0] The precision to round down to.
  29215. * @returns {number} Returns the rounded down number.
  29216. * @example
  29217. *
  29218. * _.floor(4.006);
  29219. * // => 4
  29220. *
  29221. * _.floor(0.046, 2);
  29222. * // => 0.04
  29223. *
  29224. * _.floor(4060, -2);
  29225. * // => 4000
  29226. */
  29227. var floor = createRound('floor');
  29228. /**
  29229. * Computes the maximum value of `array`. If `array` is empty or falsey,
  29230. * `undefined` is returned.
  29231. *
  29232. * @static
  29233. * @since 0.1.0
  29234. * @memberOf _
  29235. * @category Math
  29236. * @param {Array} array The array to iterate over.
  29237. * @returns {*} Returns the maximum value.
  29238. * @example
  29239. *
  29240. * _.max([4, 2, 8, 6]);
  29241. * // => 8
  29242. *
  29243. * _.max([]);
  29244. * // => undefined
  29245. */
  29246. function max(array) {
  29247. return (array && array.length)
  29248. ? baseExtremum(array, identity, baseGt)
  29249. : undefined;
  29250. }
  29251. /**
  29252. * This method is like `_.max` except that it accepts `iteratee` which is
  29253. * invoked for each element in `array` to generate the criterion by which
  29254. * the value is ranked. The iteratee is invoked with one argument: (value).
  29255. *
  29256. * @static
  29257. * @memberOf _
  29258. * @since 4.0.0
  29259. * @category Math
  29260. * @param {Array} array The array to iterate over.
  29261. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  29262. * @returns {*} Returns the maximum value.
  29263. * @example
  29264. *
  29265. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  29266. *
  29267. * _.maxBy(objects, function(o) { return o.n; });
  29268. * // => { 'n': 2 }
  29269. *
  29270. * // The `_.property` iteratee shorthand.
  29271. * _.maxBy(objects, 'n');
  29272. * // => { 'n': 2 }
  29273. */
  29274. function maxBy(array, iteratee) {
  29275. return (array && array.length)
  29276. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  29277. : undefined;
  29278. }
  29279. /**
  29280. * Computes the mean of the values in `array`.
  29281. *
  29282. * @static
  29283. * @memberOf _
  29284. * @since 4.0.0
  29285. * @category Math
  29286. * @param {Array} array The array to iterate over.
  29287. * @returns {number} Returns the mean.
  29288. * @example
  29289. *
  29290. * _.mean([4, 2, 8, 6]);
  29291. * // => 5
  29292. */
  29293. function mean(array) {
  29294. return baseMean(array, identity);
  29295. }
  29296. /**
  29297. * This method is like `_.mean` except that it accepts `iteratee` which is
  29298. * invoked for each element in `array` to generate the value to be averaged.
  29299. * The iteratee is invoked with one argument: (value).
  29300. *
  29301. * @static
  29302. * @memberOf _
  29303. * @since 4.7.0
  29304. * @category Math
  29305. * @param {Array} array The array to iterate over.
  29306. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  29307. * @returns {number} Returns the mean.
  29308. * @example
  29309. *
  29310. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  29311. *
  29312. * _.meanBy(objects, function(o) { return o.n; });
  29313. * // => 5
  29314. *
  29315. * // The `_.property` iteratee shorthand.
  29316. * _.meanBy(objects, 'n');
  29317. * // => 5
  29318. */
  29319. function meanBy(array, iteratee) {
  29320. return baseMean(array, getIteratee(iteratee, 2));
  29321. }
  29322. /**
  29323. * Computes the minimum value of `array`. If `array` is empty or falsey,
  29324. * `undefined` is returned.
  29325. *
  29326. * @static
  29327. * @since 0.1.0
  29328. * @memberOf _
  29329. * @category Math
  29330. * @param {Array} array The array to iterate over.
  29331. * @returns {*} Returns the minimum value.
  29332. * @example
  29333. *
  29334. * _.min([4, 2, 8, 6]);
  29335. * // => 2
  29336. *
  29337. * _.min([]);
  29338. * // => undefined
  29339. */
  29340. function min(array) {
  29341. return (array && array.length)
  29342. ? baseExtremum(array, identity, baseLt)
  29343. : undefined;
  29344. }
  29345. /**
  29346. * This method is like `_.min` except that it accepts `iteratee` which is
  29347. * invoked for each element in `array` to generate the criterion by which
  29348. * the value is ranked. The iteratee is invoked with one argument: (value).
  29349. *
  29350. * @static
  29351. * @memberOf _
  29352. * @since 4.0.0
  29353. * @category Math
  29354. * @param {Array} array The array to iterate over.
  29355. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  29356. * @returns {*} Returns the minimum value.
  29357. * @example
  29358. *
  29359. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  29360. *
  29361. * _.minBy(objects, function(o) { return o.n; });
  29362. * // => { 'n': 1 }
  29363. *
  29364. * // The `_.property` iteratee shorthand.
  29365. * _.minBy(objects, 'n');
  29366. * // => { 'n': 1 }
  29367. */
  29368. function minBy(array, iteratee) {
  29369. return (array && array.length)
  29370. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  29371. : undefined;
  29372. }
  29373. /**
  29374. * Multiply two numbers.
  29375. *
  29376. * @static
  29377. * @memberOf _
  29378. * @since 4.7.0
  29379. * @category Math
  29380. * @param {number} multiplier The first number in a multiplication.
  29381. * @param {number} multiplicand The second number in a multiplication.
  29382. * @returns {number} Returns the product.
  29383. * @example
  29384. *
  29385. * _.multiply(6, 4);
  29386. * // => 24
  29387. */
  29388. var multiply = createMathOperation(function(multiplier, multiplicand) {
  29389. return multiplier * multiplicand;
  29390. }, 1);
  29391. /**
  29392. * Computes `number` rounded to `precision`.
  29393. *
  29394. * @static
  29395. * @memberOf _
  29396. * @since 3.10.0
  29397. * @category Math
  29398. * @param {number} number The number to round.
  29399. * @param {number} [precision=0] The precision to round to.
  29400. * @returns {number} Returns the rounded number.
  29401. * @example
  29402. *
  29403. * _.round(4.006);
  29404. * // => 4
  29405. *
  29406. * _.round(4.006, 2);
  29407. * // => 4.01
  29408. *
  29409. * _.round(4060, -2);
  29410. * // => 4100
  29411. */
  29412. var round = createRound('round');
  29413. /**
  29414. * Subtract two numbers.
  29415. *
  29416. * @static
  29417. * @memberOf _
  29418. * @since 4.0.0
  29419. * @category Math
  29420. * @param {number} minuend The first number in a subtraction.
  29421. * @param {number} subtrahend The second number in a subtraction.
  29422. * @returns {number} Returns the difference.
  29423. * @example
  29424. *
  29425. * _.subtract(6, 4);
  29426. * // => 2
  29427. */
  29428. var subtract = createMathOperation(function(minuend, subtrahend) {
  29429. return minuend - subtrahend;
  29430. }, 0);
  29431. /**
  29432. * Computes the sum of the values in `array`.
  29433. *
  29434. * @static
  29435. * @memberOf _
  29436. * @since 3.4.0
  29437. * @category Math
  29438. * @param {Array} array The array to iterate over.
  29439. * @returns {number} Returns the sum.
  29440. * @example
  29441. *
  29442. * _.sum([4, 2, 8, 6]);
  29443. * // => 20
  29444. */
  29445. function sum(array) {
  29446. return (array && array.length)
  29447. ? baseSum(array, identity)
  29448. : 0;
  29449. }
  29450. /**
  29451. * This method is like `_.sum` except that it accepts `iteratee` which is
  29452. * invoked for each element in `array` to generate the value to be summed.
  29453. * The iteratee is invoked with one argument: (value).
  29454. *
  29455. * @static
  29456. * @memberOf _
  29457. * @since 4.0.0
  29458. * @category Math
  29459. * @param {Array} array The array to iterate over.
  29460. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  29461. * @returns {number} Returns the sum.
  29462. * @example
  29463. *
  29464. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  29465. *
  29466. * _.sumBy(objects, function(o) { return o.n; });
  29467. * // => 20
  29468. *
  29469. * // The `_.property` iteratee shorthand.
  29470. * _.sumBy(objects, 'n');
  29471. * // => 20
  29472. */
  29473. function sumBy(array, iteratee) {
  29474. return (array && array.length)
  29475. ? baseSum(array, getIteratee(iteratee, 2))
  29476. : 0;
  29477. }
  29478. /*------------------------------------------------------------------------*/
  29479. // Add methods that return wrapped values in chain sequences.
  29480. lodash.after = after;
  29481. lodash.ary = ary;
  29482. lodash.assign = assign;
  29483. lodash.assignIn = assignIn;
  29484. lodash.assignInWith = assignInWith;
  29485. lodash.assignWith = assignWith;
  29486. lodash.at = at;
  29487. lodash.before = before;
  29488. lodash.bind = bind;
  29489. lodash.bindAll = bindAll;
  29490. lodash.bindKey = bindKey;
  29491. lodash.castArray = castArray;
  29492. lodash.chain = chain;
  29493. lodash.chunk = chunk;
  29494. lodash.compact = compact;
  29495. lodash.concat = concat;
  29496. lodash.cond = cond;
  29497. lodash.conforms = conforms;
  29498. lodash.constant = constant;
  29499. lodash.countBy = countBy;
  29500. lodash.create = create;
  29501. lodash.curry = curry;
  29502. lodash.curryRight = curryRight;
  29503. lodash.debounce = debounce;
  29504. lodash.defaults = defaults;
  29505. lodash.defaultsDeep = defaultsDeep;
  29506. lodash.defer = defer;
  29507. lodash.delay = delay;
  29508. lodash.difference = difference;
  29509. lodash.differenceBy = differenceBy;
  29510. lodash.differenceWith = differenceWith;
  29511. lodash.drop = drop;
  29512. lodash.dropRight = dropRight;
  29513. lodash.dropRightWhile = dropRightWhile;
  29514. lodash.dropWhile = dropWhile;
  29515. lodash.fill = fill;
  29516. lodash.filter = filter;
  29517. lodash.flatMap = flatMap;
  29518. lodash.flatMapDeep = flatMapDeep;
  29519. lodash.flatMapDepth = flatMapDepth;
  29520. lodash.flatten = flatten;
  29521. lodash.flattenDeep = flattenDeep;
  29522. lodash.flattenDepth = flattenDepth;
  29523. lodash.flip = flip;
  29524. lodash.flow = flow;
  29525. lodash.flowRight = flowRight;
  29526. lodash.fromPairs = fromPairs;
  29527. lodash.functions = functions;
  29528. lodash.functionsIn = functionsIn;
  29529. lodash.groupBy = groupBy;
  29530. lodash.initial = initial;
  29531. lodash.intersection = intersection;
  29532. lodash.intersectionBy = intersectionBy;
  29533. lodash.intersectionWith = intersectionWith;
  29534. lodash.invert = invert;
  29535. lodash.invertBy = invertBy;
  29536. lodash.invokeMap = invokeMap;
  29537. lodash.iteratee = iteratee;
  29538. lodash.keyBy = keyBy;
  29539. lodash.keys = keys;
  29540. lodash.keysIn = keysIn;
  29541. lodash.map = map;
  29542. lodash.mapKeys = mapKeys;
  29543. lodash.mapValues = mapValues;
  29544. lodash.matches = matches;
  29545. lodash.matchesProperty = matchesProperty;
  29546. lodash.memoize = memoize;
  29547. lodash.merge = merge;
  29548. lodash.mergeWith = mergeWith;
  29549. lodash.method = method;
  29550. lodash.methodOf = methodOf;
  29551. lodash.mixin = mixin;
  29552. lodash.negate = negate;
  29553. lodash.nthArg = nthArg;
  29554. lodash.omit = omit;
  29555. lodash.omitBy = omitBy;
  29556. lodash.once = once;
  29557. lodash.orderBy = orderBy;
  29558. lodash.over = over;
  29559. lodash.overArgs = overArgs;
  29560. lodash.overEvery = overEvery;
  29561. lodash.overSome = overSome;
  29562. lodash.partial = partial;
  29563. lodash.partialRight = partialRight;
  29564. lodash.partition = partition;
  29565. lodash.pick = pick;
  29566. lodash.pickBy = pickBy;
  29567. lodash.property = property;
  29568. lodash.propertyOf = propertyOf;
  29569. lodash.pull = pull;
  29570. lodash.pullAll = pullAll;
  29571. lodash.pullAllBy = pullAllBy;
  29572. lodash.pullAllWith = pullAllWith;
  29573. lodash.pullAt = pullAt;
  29574. lodash.range = range;
  29575. lodash.rangeRight = rangeRight;
  29576. lodash.rearg = rearg;
  29577. lodash.reject = reject;
  29578. lodash.remove = remove;
  29579. lodash.rest = rest;
  29580. lodash.reverse = reverse;
  29581. lodash.sampleSize = sampleSize;
  29582. lodash.set = set;
  29583. lodash.setWith = setWith;
  29584. lodash.shuffle = shuffle;
  29585. lodash.slice = slice;
  29586. lodash.sortBy = sortBy;
  29587. lodash.sortedUniq = sortedUniq;
  29588. lodash.sortedUniqBy = sortedUniqBy;
  29589. lodash.split = split;
  29590. lodash.spread = spread;
  29591. lodash.tail = tail;
  29592. lodash.take = take;
  29593. lodash.takeRight = takeRight;
  29594. lodash.takeRightWhile = takeRightWhile;
  29595. lodash.takeWhile = takeWhile;
  29596. lodash.tap = tap;
  29597. lodash.throttle = throttle;
  29598. lodash.thru = thru;
  29599. lodash.toArray = toArray;
  29600. lodash.toPairs = toPairs;
  29601. lodash.toPairsIn = toPairsIn;
  29602. lodash.toPath = toPath;
  29603. lodash.toPlainObject = toPlainObject;
  29604. lodash.transform = transform;
  29605. lodash.unary = unary;
  29606. lodash.union = union;
  29607. lodash.unionBy = unionBy;
  29608. lodash.unionWith = unionWith;
  29609. lodash.uniq = uniq;
  29610. lodash.uniqBy = uniqBy;
  29611. lodash.uniqWith = uniqWith;
  29612. lodash.unset = unset;
  29613. lodash.unzip = unzip;
  29614. lodash.unzipWith = unzipWith;
  29615. lodash.update = update;
  29616. lodash.updateWith = updateWith;
  29617. lodash.values = values;
  29618. lodash.valuesIn = valuesIn;
  29619. lodash.without = without;
  29620. lodash.words = words;
  29621. lodash.wrap = wrap;
  29622. lodash.xor = xor;
  29623. lodash.xorBy = xorBy;
  29624. lodash.xorWith = xorWith;
  29625. lodash.zip = zip;
  29626. lodash.zipObject = zipObject;
  29627. lodash.zipObjectDeep = zipObjectDeep;
  29628. lodash.zipWith = zipWith;
  29629. // Add aliases.
  29630. lodash.entries = toPairs;
  29631. lodash.entriesIn = toPairsIn;
  29632. lodash.extend = assignIn;
  29633. lodash.extendWith = assignInWith;
  29634. // Add methods to `lodash.prototype`.
  29635. mixin(lodash, lodash);
  29636. /*------------------------------------------------------------------------*/
  29637. // Add methods that return unwrapped values in chain sequences.
  29638. lodash.add = add;
  29639. lodash.attempt = attempt;
  29640. lodash.camelCase = camelCase;
  29641. lodash.capitalize = capitalize;
  29642. lodash.ceil = ceil;
  29643. lodash.clamp = clamp;
  29644. lodash.clone = clone;
  29645. lodash.cloneDeep = cloneDeep;
  29646. lodash.cloneDeepWith = cloneDeepWith;
  29647. lodash.cloneWith = cloneWith;
  29648. lodash.conformsTo = conformsTo;
  29649. lodash.deburr = deburr;
  29650. lodash.defaultTo = defaultTo;
  29651. lodash.divide = divide;
  29652. lodash.endsWith = endsWith;
  29653. lodash.eq = eq;
  29654. lodash.escape = escape;
  29655. lodash.escapeRegExp = escapeRegExp;
  29656. lodash.every = every;
  29657. lodash.find = find;
  29658. lodash.findIndex = findIndex;
  29659. lodash.findKey = findKey;
  29660. lodash.findLast = findLast;
  29661. lodash.findLastIndex = findLastIndex;
  29662. lodash.findLastKey = findLastKey;
  29663. lodash.floor = floor;
  29664. lodash.forEach = forEach;
  29665. lodash.forEachRight = forEachRight;
  29666. lodash.forIn = forIn;
  29667. lodash.forInRight = forInRight;
  29668. lodash.forOwn = forOwn;
  29669. lodash.forOwnRight = forOwnRight;
  29670. lodash.get = get;
  29671. lodash.gt = gt;
  29672. lodash.gte = gte;
  29673. lodash.has = has;
  29674. lodash.hasIn = hasIn;
  29675. lodash.head = head;
  29676. lodash.identity = identity;
  29677. lodash.includes = includes;
  29678. lodash.indexOf = indexOf;
  29679. lodash.inRange = inRange;
  29680. lodash.invoke = invoke;
  29681. lodash.isArguments = isArguments;
  29682. lodash.isArray = isArray;
  29683. lodash.isArrayBuffer = isArrayBuffer;
  29684. lodash.isArrayLike = isArrayLike;
  29685. lodash.isArrayLikeObject = isArrayLikeObject;
  29686. lodash.isBoolean = isBoolean;
  29687. lodash.isBuffer = isBuffer;
  29688. lodash.isDate = isDate;
  29689. lodash.isElement = isElement;
  29690. lodash.isEmpty = isEmpty;
  29691. lodash.isEqual = isEqual;
  29692. lodash.isEqualWith = isEqualWith;
  29693. lodash.isError = isError;
  29694. lodash.isFinite = isFinite;
  29695. lodash.isFunction = isFunction;
  29696. lodash.isInteger = isInteger;
  29697. lodash.isLength = isLength;
  29698. lodash.isMap = isMap;
  29699. lodash.isMatch = isMatch;
  29700. lodash.isMatchWith = isMatchWith;
  29701. lodash.isNaN = isNaN;
  29702. lodash.isNative = isNative;
  29703. lodash.isNil = isNil;
  29704. lodash.isNull = isNull;
  29705. lodash.isNumber = isNumber;
  29706. lodash.isObject = isObject;
  29707. lodash.isObjectLike = isObjectLike;
  29708. lodash.isPlainObject = isPlainObject;
  29709. lodash.isRegExp = isRegExp;
  29710. lodash.isSafeInteger = isSafeInteger;
  29711. lodash.isSet = isSet;
  29712. lodash.isString = isString;
  29713. lodash.isSymbol = isSymbol;
  29714. lodash.isTypedArray = isTypedArray;
  29715. lodash.isUndefined = isUndefined;
  29716. lodash.isWeakMap = isWeakMap;
  29717. lodash.isWeakSet = isWeakSet;
  29718. lodash.join = join;
  29719. lodash.kebabCase = kebabCase;
  29720. lodash.last = last;
  29721. lodash.lastIndexOf = lastIndexOf;
  29722. lodash.lowerCase = lowerCase;
  29723. lodash.lowerFirst = lowerFirst;
  29724. lodash.lt = lt;
  29725. lodash.lte = lte;
  29726. lodash.max = max;
  29727. lodash.maxBy = maxBy;
  29728. lodash.mean = mean;
  29729. lodash.meanBy = meanBy;
  29730. lodash.min = min;
  29731. lodash.minBy = minBy;
  29732. lodash.stubArray = stubArray;
  29733. lodash.stubFalse = stubFalse;
  29734. lodash.stubObject = stubObject;
  29735. lodash.stubString = stubString;
  29736. lodash.stubTrue = stubTrue;
  29737. lodash.multiply = multiply;
  29738. lodash.nth = nth;
  29739. lodash.noConflict = noConflict;
  29740. lodash.noop = noop;
  29741. lodash.now = now;
  29742. lodash.pad = pad;
  29743. lodash.padEnd = padEnd;
  29744. lodash.padStart = padStart;
  29745. lodash.parseInt = parseInt;
  29746. lodash.random = random;
  29747. lodash.reduce = reduce;
  29748. lodash.reduceRight = reduceRight;
  29749. lodash.repeat = repeat;
  29750. lodash.replace = replace;
  29751. lodash.result = result;
  29752. lodash.round = round;
  29753. lodash.runInContext = runInContext;
  29754. lodash.sample = sample;
  29755. lodash.size = size;
  29756. lodash.snakeCase = snakeCase;
  29757. lodash.some = some;
  29758. lodash.sortedIndex = sortedIndex;
  29759. lodash.sortedIndexBy = sortedIndexBy;
  29760. lodash.sortedIndexOf = sortedIndexOf;
  29761. lodash.sortedLastIndex = sortedLastIndex;
  29762. lodash.sortedLastIndexBy = sortedLastIndexBy;
  29763. lodash.sortedLastIndexOf = sortedLastIndexOf;
  29764. lodash.startCase = startCase;
  29765. lodash.startsWith = startsWith;
  29766. lodash.subtract = subtract;
  29767. lodash.sum = sum;
  29768. lodash.sumBy = sumBy;
  29769. lodash.template = template;
  29770. lodash.times = times;
  29771. lodash.toFinite = toFinite;
  29772. lodash.toInteger = toInteger;
  29773. lodash.toLength = toLength;
  29774. lodash.toLower = toLower;
  29775. lodash.toNumber = toNumber;
  29776. lodash.toSafeInteger = toSafeInteger;
  29777. lodash.toString = toString;
  29778. lodash.toUpper = toUpper;
  29779. lodash.trim = trim;
  29780. lodash.trimEnd = trimEnd;
  29781. lodash.trimStart = trimStart;
  29782. lodash.truncate = truncate;
  29783. lodash.unescape = unescape;
  29784. lodash.uniqueId = uniqueId;
  29785. lodash.upperCase = upperCase;
  29786. lodash.upperFirst = upperFirst;
  29787. // Add aliases.
  29788. lodash.each = forEach;
  29789. lodash.eachRight = forEachRight;
  29790. lodash.first = head;
  29791. mixin(lodash, (function() {
  29792. var source = {};
  29793. baseForOwn(lodash, function(func, methodName) {
  29794. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  29795. source[methodName] = func;
  29796. }
  29797. });
  29798. return source;
  29799. }()), { 'chain': false });
  29800. /*------------------------------------------------------------------------*/
  29801. /**
  29802. * The semantic version number.
  29803. *
  29804. * @static
  29805. * @memberOf _
  29806. * @type {string}
  29807. */
  29808. lodash.VERSION = VERSION;
  29809. // Assign default placeholders.
  29810. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  29811. lodash[methodName].placeholder = lodash;
  29812. });
  29813. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  29814. arrayEach(['drop', 'take'], function(methodName, index) {
  29815. LazyWrapper.prototype[methodName] = function(n) {
  29816. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  29817. var result = (this.__filtered__ && !index)
  29818. ? new LazyWrapper(this)
  29819. : this.clone();
  29820. if (result.__filtered__) {
  29821. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  29822. } else {
  29823. result.__views__.push({
  29824. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  29825. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  29826. });
  29827. }
  29828. return result;
  29829. };
  29830. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  29831. return this.reverse()[methodName](n).reverse();
  29832. };
  29833. });
  29834. // Add `LazyWrapper` methods that accept an `iteratee` value.
  29835. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  29836. var type = index + 1,
  29837. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  29838. LazyWrapper.prototype[methodName] = function(iteratee) {
  29839. var result = this.clone();
  29840. result.__iteratees__.push({
  29841. 'iteratee': getIteratee(iteratee, 3),
  29842. 'type': type
  29843. });
  29844. result.__filtered__ = result.__filtered__ || isFilter;
  29845. return result;
  29846. };
  29847. });
  29848. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  29849. arrayEach(['head', 'last'], function(methodName, index) {
  29850. var takeName = 'take' + (index ? 'Right' : '');
  29851. LazyWrapper.prototype[methodName] = function() {
  29852. return this[takeName](1).value()[0];
  29853. };
  29854. });
  29855. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  29856. arrayEach(['initial', 'tail'], function(methodName, index) {
  29857. var dropName = 'drop' + (index ? '' : 'Right');
  29858. LazyWrapper.prototype[methodName] = function() {
  29859. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  29860. };
  29861. });
  29862. LazyWrapper.prototype.compact = function() {
  29863. return this.filter(identity);
  29864. };
  29865. LazyWrapper.prototype.find = function(predicate) {
  29866. return this.filter(predicate).head();
  29867. };
  29868. LazyWrapper.prototype.findLast = function(predicate) {
  29869. return this.reverse().find(predicate);
  29870. };
  29871. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  29872. if (typeof path == 'function') {
  29873. return new LazyWrapper(this);
  29874. }
  29875. return this.map(function(value) {
  29876. return baseInvoke(value, path, args);
  29877. });
  29878. });
  29879. LazyWrapper.prototype.reject = function(predicate) {
  29880. return this.filter(negate(getIteratee(predicate)));
  29881. };
  29882. LazyWrapper.prototype.slice = function(start, end) {
  29883. start = toInteger(start);
  29884. var result = this;
  29885. if (result.__filtered__ && (start > 0 || end < 0)) {
  29886. return new LazyWrapper(result);
  29887. }
  29888. if (start < 0) {
  29889. result = result.takeRight(-start);
  29890. } else if (start) {
  29891. result = result.drop(start);
  29892. }
  29893. if (end !== undefined) {
  29894. end = toInteger(end);
  29895. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  29896. }
  29897. return result;
  29898. };
  29899. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  29900. return this.reverse().takeWhile(predicate).reverse();
  29901. };
  29902. LazyWrapper.prototype.toArray = function() {
  29903. return this.take(MAX_ARRAY_LENGTH);
  29904. };
  29905. // Add `LazyWrapper` methods to `lodash.prototype`.
  29906. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  29907. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  29908. isTaker = /^(?:head|last)$/.test(methodName),
  29909. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  29910. retUnwrapped = isTaker || /^find/.test(methodName);
  29911. if (!lodashFunc) {
  29912. return;
  29913. }
  29914. lodash.prototype[methodName] = function() {
  29915. var value = this.__wrapped__,
  29916. args = isTaker ? [1] : arguments,
  29917. isLazy = value instanceof LazyWrapper,
  29918. iteratee = args[0],
  29919. useLazy = isLazy || isArray(value);
  29920. var interceptor = function(value) {
  29921. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  29922. return (isTaker && chainAll) ? result[0] : result;
  29923. };
  29924. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  29925. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  29926. isLazy = useLazy = false;
  29927. }
  29928. var chainAll = this.__chain__,
  29929. isHybrid = !!this.__actions__.length,
  29930. isUnwrapped = retUnwrapped && !chainAll,
  29931. onlyLazy = isLazy && !isHybrid;
  29932. if (!retUnwrapped && useLazy) {
  29933. value = onlyLazy ? value : new LazyWrapper(this);
  29934. var result = func.apply(value, args);
  29935. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  29936. return new LodashWrapper(result, chainAll);
  29937. }
  29938. if (isUnwrapped && onlyLazy) {
  29939. return func.apply(this, args);
  29940. }
  29941. result = this.thru(interceptor);
  29942. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  29943. };
  29944. });
  29945. // Add `Array` methods to `lodash.prototype`.
  29946. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  29947. var func = arrayProto[methodName],
  29948. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  29949. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  29950. lodash.prototype[methodName] = function() {
  29951. var args = arguments;
  29952. if (retUnwrapped && !this.__chain__) {
  29953. var value = this.value();
  29954. return func.apply(isArray(value) ? value : [], args);
  29955. }
  29956. return this[chainName](function(value) {
  29957. return func.apply(isArray(value) ? value : [], args);
  29958. });
  29959. };
  29960. });
  29961. // Map minified method names to their real names.
  29962. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  29963. var lodashFunc = lodash[methodName];
  29964. if (lodashFunc) {
  29965. var key = lodashFunc.name + '';
  29966. if (!hasOwnProperty.call(realNames, key)) {
  29967. realNames[key] = [];
  29968. }
  29969. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  29970. }
  29971. });
  29972. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  29973. 'name': 'wrapper',
  29974. 'func': undefined
  29975. }];
  29976. // Add methods to `LazyWrapper`.
  29977. LazyWrapper.prototype.clone = lazyClone;
  29978. LazyWrapper.prototype.reverse = lazyReverse;
  29979. LazyWrapper.prototype.value = lazyValue;
  29980. // Add chain sequence methods to the `lodash` wrapper.
  29981. lodash.prototype.at = wrapperAt;
  29982. lodash.prototype.chain = wrapperChain;
  29983. lodash.prototype.commit = wrapperCommit;
  29984. lodash.prototype.next = wrapperNext;
  29985. lodash.prototype.plant = wrapperPlant;
  29986. lodash.prototype.reverse = wrapperReverse;
  29987. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  29988. // Add lazy aliases.
  29989. lodash.prototype.first = lodash.prototype.head;
  29990. if (symIterator) {
  29991. lodash.prototype[symIterator] = wrapperToIterator;
  29992. }
  29993. return lodash;
  29994. });
  29995. /*--------------------------------------------------------------------------*/
  29996. // Export lodash.
  29997. var _ = runInContext();
  29998. // Some AMD build optimizers, like r.js, check for condition patterns like:
  29999. if (true) {
  30000. // Expose Lodash on the global object to prevent errors when Lodash is
  30001. // loaded by a script tag in the presence of an AMD loader.
  30002. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  30003. // Use `_.noConflict` to remove Lodash from the global object.
  30004. root._ = _;
  30005. // Define as an anonymous module so, through path mapping, it can be
  30006. // referenced as the "underscore" module.
  30007. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  30008. return _;
  30009. }).call(exports, __webpack_require__, exports, module),
  30010. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  30011. }
  30012. // Check for `exports` after `define` in case a build optimizer adds it.
  30013. else {}
  30014. }.call(this));
  30015. /* 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)))
  30016. /***/ }),
  30017. /***/ "./node_modules/popper.js/dist/esm/popper.js":
  30018. /*!***************************************************!*\
  30019. !*** ./node_modules/popper.js/dist/esm/popper.js ***!
  30020. \***************************************************/
  30021. /*! exports provided: default */
  30022. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  30023. "use strict";
  30024. __webpack_require__.r(__webpack_exports__);
  30025. /* WEBPACK VAR INJECTION */(function(global) {/**!
  30026. * @fileOverview Kickass library to create and place poppers near their reference elements.
  30027. * @version 1.16.1
  30028. * @license
  30029. * Copyright (c) 2016 Federico Zivolo and contributors
  30030. *
  30031. * Permission is hereby granted, free of charge, to any person obtaining a copy
  30032. * of this software and associated documentation files (the "Software"), to deal
  30033. * in the Software without restriction, including without limitation the rights
  30034. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  30035. * copies of the Software, and to permit persons to whom the Software is
  30036. * furnished to do so, subject to the following conditions:
  30037. *
  30038. * The above copyright notice and this permission notice shall be included in all
  30039. * copies or substantial portions of the Software.
  30040. *
  30041. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  30042. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  30043. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  30044. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  30045. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  30046. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  30047. * SOFTWARE.
  30048. */
  30049. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
  30050. var timeoutDuration = function () {
  30051. var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
  30052. for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
  30053. if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
  30054. return 1;
  30055. }
  30056. }
  30057. return 0;
  30058. }();
  30059. function microtaskDebounce(fn) {
  30060. var called = false;
  30061. return function () {
  30062. if (called) {
  30063. return;
  30064. }
  30065. called = true;
  30066. window.Promise.resolve().then(function () {
  30067. called = false;
  30068. fn();
  30069. });
  30070. };
  30071. }
  30072. function taskDebounce(fn) {
  30073. var scheduled = false;
  30074. return function () {
  30075. if (!scheduled) {
  30076. scheduled = true;
  30077. setTimeout(function () {
  30078. scheduled = false;
  30079. fn();
  30080. }, timeoutDuration);
  30081. }
  30082. };
  30083. }
  30084. var supportsMicroTasks = isBrowser && window.Promise;
  30085. /**
  30086. * Create a debounced version of a method, that's asynchronously deferred
  30087. * but called in the minimum time possible.
  30088. *
  30089. * @method
  30090. * @memberof Popper.Utils
  30091. * @argument {Function} fn
  30092. * @returns {Function}
  30093. */
  30094. var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
  30095. /**
  30096. * Check if the given variable is a function
  30097. * @method
  30098. * @memberof Popper.Utils
  30099. * @argument {Any} functionToCheck - variable to check
  30100. * @returns {Boolean} answer to: is a function?
  30101. */
  30102. function isFunction(functionToCheck) {
  30103. var getType = {};
  30104. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  30105. }
  30106. /**
  30107. * Get CSS computed property of the given element
  30108. * @method
  30109. * @memberof Popper.Utils
  30110. * @argument {Eement} element
  30111. * @argument {String} property
  30112. */
  30113. function getStyleComputedProperty(element, property) {
  30114. if (element.nodeType !== 1) {
  30115. return [];
  30116. }
  30117. // NOTE: 1 DOM access here
  30118. var window = element.ownerDocument.defaultView;
  30119. var css = window.getComputedStyle(element, null);
  30120. return property ? css[property] : css;
  30121. }
  30122. /**
  30123. * Returns the parentNode or the host of the element
  30124. * @method
  30125. * @memberof Popper.Utils
  30126. * @argument {Element} element
  30127. * @returns {Element} parent
  30128. */
  30129. function getParentNode(element) {
  30130. if (element.nodeName === 'HTML') {
  30131. return element;
  30132. }
  30133. return element.parentNode || element.host;
  30134. }
  30135. /**
  30136. * Returns the scrolling parent of the given element
  30137. * @method
  30138. * @memberof Popper.Utils
  30139. * @argument {Element} element
  30140. * @returns {Element} scroll parent
  30141. */
  30142. function getScrollParent(element) {
  30143. // Return body, `getScroll` will take care to get the correct `scrollTop` from it
  30144. if (!element) {
  30145. return document.body;
  30146. }
  30147. switch (element.nodeName) {
  30148. case 'HTML':
  30149. case 'BODY':
  30150. return element.ownerDocument.body;
  30151. case '#document':
  30152. return element.body;
  30153. }
  30154. // Firefox want us to check `-x` and `-y` variations as well
  30155. var _getStyleComputedProp = getStyleComputedProperty(element),
  30156. overflow = _getStyleComputedProp.overflow,
  30157. overflowX = _getStyleComputedProp.overflowX,
  30158. overflowY = _getStyleComputedProp.overflowY;
  30159. if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
  30160. return element;
  30161. }
  30162. return getScrollParent(getParentNode(element));
  30163. }
  30164. /**
  30165. * Returns the reference node of the reference object, or the reference object itself.
  30166. * @method
  30167. * @memberof Popper.Utils
  30168. * @param {Element|Object} reference - the reference element (the popper will be relative to this)
  30169. * @returns {Element} parent
  30170. */
  30171. function getReferenceNode(reference) {
  30172. return reference && reference.referenceNode ? reference.referenceNode : reference;
  30173. }
  30174. var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
  30175. var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
  30176. /**
  30177. * Determines if the browser is Internet Explorer
  30178. * @method
  30179. * @memberof Popper.Utils
  30180. * @param {Number} version to check
  30181. * @returns {Boolean} isIE
  30182. */
  30183. function isIE(version) {
  30184. if (version === 11) {
  30185. return isIE11;
  30186. }
  30187. if (version === 10) {
  30188. return isIE10;
  30189. }
  30190. return isIE11 || isIE10;
  30191. }
  30192. /**
  30193. * Returns the offset parent of the given element
  30194. * @method
  30195. * @memberof Popper.Utils
  30196. * @argument {Element} element
  30197. * @returns {Element} offset parent
  30198. */
  30199. function getOffsetParent(element) {
  30200. if (!element) {
  30201. return document.documentElement;
  30202. }
  30203. var noOffsetParent = isIE(10) ? document.body : null;
  30204. // NOTE: 1 DOM access here
  30205. var offsetParent = element.offsetParent || null;
  30206. // Skip hidden elements which don't have an offsetParent
  30207. while (offsetParent === noOffsetParent && element.nextElementSibling) {
  30208. offsetParent = (element = element.nextElementSibling).offsetParent;
  30209. }
  30210. var nodeName = offsetParent && offsetParent.nodeName;
  30211. if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
  30212. return element ? element.ownerDocument.documentElement : document.documentElement;
  30213. }
  30214. // .offsetParent will return the closest TH, TD or TABLE in case
  30215. // no offsetParent is present, I hate this job...
  30216. if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
  30217. return getOffsetParent(offsetParent);
  30218. }
  30219. return offsetParent;
  30220. }
  30221. function isOffsetContainer(element) {
  30222. var nodeName = element.nodeName;
  30223. if (nodeName === 'BODY') {
  30224. return false;
  30225. }
  30226. return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
  30227. }
  30228. /**
  30229. * Finds the root node (document, shadowDOM root) of the given element
  30230. * @method
  30231. * @memberof Popper.Utils
  30232. * @argument {Element} node
  30233. * @returns {Element} root node
  30234. */
  30235. function getRoot(node) {
  30236. if (node.parentNode !== null) {
  30237. return getRoot(node.parentNode);
  30238. }
  30239. return node;
  30240. }
  30241. /**
  30242. * Finds the offset parent common to the two provided nodes
  30243. * @method
  30244. * @memberof Popper.Utils
  30245. * @argument {Element} element1
  30246. * @argument {Element} element2
  30247. * @returns {Element} common offset parent
  30248. */
  30249. function findCommonOffsetParent(element1, element2) {
  30250. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  30251. if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
  30252. return document.documentElement;
  30253. }
  30254. // Here we make sure to give as "start" the element that comes first in the DOM
  30255. var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
  30256. var start = order ? element1 : element2;
  30257. var end = order ? element2 : element1;
  30258. // Get common ancestor container
  30259. var range = document.createRange();
  30260. range.setStart(start, 0);
  30261. range.setEnd(end, 0);
  30262. var commonAncestorContainer = range.commonAncestorContainer;
  30263. // Both nodes are inside #document
  30264. if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
  30265. if (isOffsetContainer(commonAncestorContainer)) {
  30266. return commonAncestorContainer;
  30267. }
  30268. return getOffsetParent(commonAncestorContainer);
  30269. }
  30270. // one of the nodes is inside shadowDOM, find which one
  30271. var element1root = getRoot(element1);
  30272. if (element1root.host) {
  30273. return findCommonOffsetParent(element1root.host, element2);
  30274. } else {
  30275. return findCommonOffsetParent(element1, getRoot(element2).host);
  30276. }
  30277. }
  30278. /**
  30279. * Gets the scroll value of the given element in the given side (top and left)
  30280. * @method
  30281. * @memberof Popper.Utils
  30282. * @argument {Element} element
  30283. * @argument {String} side `top` or `left`
  30284. * @returns {number} amount of scrolled pixels
  30285. */
  30286. function getScroll(element) {
  30287. var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
  30288. var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
  30289. var nodeName = element.nodeName;
  30290. if (nodeName === 'BODY' || nodeName === 'HTML') {
  30291. var html = element.ownerDocument.documentElement;
  30292. var scrollingElement = element.ownerDocument.scrollingElement || html;
  30293. return scrollingElement[upperSide];
  30294. }
  30295. return element[upperSide];
  30296. }
  30297. /*
  30298. * Sum or subtract the element scroll values (left and top) from a given rect object
  30299. * @method
  30300. * @memberof Popper.Utils
  30301. * @param {Object} rect - Rect object you want to change
  30302. * @param {HTMLElement} element - The element from the function reads the scroll values
  30303. * @param {Boolean} subtract - set to true if you want to subtract the scroll values
  30304. * @return {Object} rect - The modifier rect object
  30305. */
  30306. function includeScroll(rect, element) {
  30307. var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  30308. var scrollTop = getScroll(element, 'top');
  30309. var scrollLeft = getScroll(element, 'left');
  30310. var modifier = subtract ? -1 : 1;
  30311. rect.top += scrollTop * modifier;
  30312. rect.bottom += scrollTop * modifier;
  30313. rect.left += scrollLeft * modifier;
  30314. rect.right += scrollLeft * modifier;
  30315. return rect;
  30316. }
  30317. /*
  30318. * Helper to detect borders of a given element
  30319. * @method
  30320. * @memberof Popper.Utils
  30321. * @param {CSSStyleDeclaration} styles
  30322. * Result of `getStyleComputedProperty` on the given element
  30323. * @param {String} axis - `x` or `y`
  30324. * @return {number} borders - The borders size of the given axis
  30325. */
  30326. function getBordersSize(styles, axis) {
  30327. var sideA = axis === 'x' ? 'Left' : 'Top';
  30328. var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
  30329. return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']);
  30330. }
  30331. function getSize(axis, body, html, computedStyle) {
  30332. 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);
  30333. }
  30334. function getWindowSizes(document) {
  30335. var body = document.body;
  30336. var html = document.documentElement;
  30337. var computedStyle = isIE(10) && getComputedStyle(html);
  30338. return {
  30339. height: getSize('Height', body, html, computedStyle),
  30340. width: getSize('Width', body, html, computedStyle)
  30341. };
  30342. }
  30343. var classCallCheck = function (instance, Constructor) {
  30344. if (!(instance instanceof Constructor)) {
  30345. throw new TypeError("Cannot call a class as a function");
  30346. }
  30347. };
  30348. var createClass = function () {
  30349. function defineProperties(target, props) {
  30350. for (var i = 0; i < props.length; i++) {
  30351. var descriptor = props[i];
  30352. descriptor.enumerable = descriptor.enumerable || false;
  30353. descriptor.configurable = true;
  30354. if ("value" in descriptor) descriptor.writable = true;
  30355. Object.defineProperty(target, descriptor.key, descriptor);
  30356. }
  30357. }
  30358. return function (Constructor, protoProps, staticProps) {
  30359. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  30360. if (staticProps) defineProperties(Constructor, staticProps);
  30361. return Constructor;
  30362. };
  30363. }();
  30364. var defineProperty = function (obj, key, value) {
  30365. if (key in obj) {
  30366. Object.defineProperty(obj, key, {
  30367. value: value,
  30368. enumerable: true,
  30369. configurable: true,
  30370. writable: true
  30371. });
  30372. } else {
  30373. obj[key] = value;
  30374. }
  30375. return obj;
  30376. };
  30377. var _extends = Object.assign || function (target) {
  30378. for (var i = 1; i < arguments.length; i++) {
  30379. var source = arguments[i];
  30380. for (var key in source) {
  30381. if (Object.prototype.hasOwnProperty.call(source, key)) {
  30382. target[key] = source[key];
  30383. }
  30384. }
  30385. }
  30386. return target;
  30387. };
  30388. /**
  30389. * Given element offsets, generate an output similar to getBoundingClientRect
  30390. * @method
  30391. * @memberof Popper.Utils
  30392. * @argument {Object} offsets
  30393. * @returns {Object} ClientRect like output
  30394. */
  30395. function getClientRect(offsets) {
  30396. return _extends({}, offsets, {
  30397. right: offsets.left + offsets.width,
  30398. bottom: offsets.top + offsets.height
  30399. });
  30400. }
  30401. /**
  30402. * Get bounding client rect of given element
  30403. * @method
  30404. * @memberof Popper.Utils
  30405. * @param {HTMLElement} element
  30406. * @return {Object} client rect
  30407. */
  30408. function getBoundingClientRect(element) {
  30409. var rect = {};
  30410. // IE10 10 FIX: Please, don't ask, the element isn't
  30411. // considered in DOM in some circumstances...
  30412. // This isn't reproducible in IE10 compatibility mode of IE11
  30413. try {
  30414. if (isIE(10)) {
  30415. rect = element.getBoundingClientRect();
  30416. var scrollTop = getScroll(element, 'top');
  30417. var scrollLeft = getScroll(element, 'left');
  30418. rect.top += scrollTop;
  30419. rect.left += scrollLeft;
  30420. rect.bottom += scrollTop;
  30421. rect.right += scrollLeft;
  30422. } else {
  30423. rect = element.getBoundingClientRect();
  30424. }
  30425. } catch (e) {}
  30426. var result = {
  30427. left: rect.left,
  30428. top: rect.top,
  30429. width: rect.right - rect.left,
  30430. height: rect.bottom - rect.top
  30431. };
  30432. // subtract scrollbar size from sizes
  30433. var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
  30434. var width = sizes.width || element.clientWidth || result.width;
  30435. var height = sizes.height || element.clientHeight || result.height;
  30436. var horizScrollbar = element.offsetWidth - width;
  30437. var vertScrollbar = element.offsetHeight - height;
  30438. // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
  30439. // we make this check conditional for performance reasons
  30440. if (horizScrollbar || vertScrollbar) {
  30441. var styles = getStyleComputedProperty(element);
  30442. horizScrollbar -= getBordersSize(styles, 'x');
  30443. vertScrollbar -= getBordersSize(styles, 'y');
  30444. result.width -= horizScrollbar;
  30445. result.height -= vertScrollbar;
  30446. }
  30447. return getClientRect(result);
  30448. }
  30449. function getOffsetRectRelativeToArbitraryNode(children, parent) {
  30450. var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  30451. var isIE10 = isIE(10);
  30452. var isHTML = parent.nodeName === 'HTML';
  30453. var childrenRect = getBoundingClientRect(children);
  30454. var parentRect = getBoundingClientRect(parent);
  30455. var scrollParent = getScrollParent(children);
  30456. var styles = getStyleComputedProperty(parent);
  30457. var borderTopWidth = parseFloat(styles.borderTopWidth);
  30458. var borderLeftWidth = parseFloat(styles.borderLeftWidth);
  30459. // In cases where the parent is fixed, we must ignore negative scroll in offset calc
  30460. if (fixedPosition && isHTML) {
  30461. parentRect.top = Math.max(parentRect.top, 0);
  30462. parentRect.left = Math.max(parentRect.left, 0);
  30463. }
  30464. var offsets = getClientRect({
  30465. top: childrenRect.top - parentRect.top - borderTopWidth,
  30466. left: childrenRect.left - parentRect.left - borderLeftWidth,
  30467. width: childrenRect.width,
  30468. height: childrenRect.height
  30469. });
  30470. offsets.marginTop = 0;
  30471. offsets.marginLeft = 0;
  30472. // Subtract margins of documentElement in case it's being used as parent
  30473. // we do this only on HTML because it's the only element that behaves
  30474. // differently when margins are applied to it. The margins are included in
  30475. // the box of the documentElement, in the other cases not.
  30476. if (!isIE10 && isHTML) {
  30477. var marginTop = parseFloat(styles.marginTop);
  30478. var marginLeft = parseFloat(styles.marginLeft);
  30479. offsets.top -= borderTopWidth - marginTop;
  30480. offsets.bottom -= borderTopWidth - marginTop;
  30481. offsets.left -= borderLeftWidth - marginLeft;
  30482. offsets.right -= borderLeftWidth - marginLeft;
  30483. // Attach marginTop and marginLeft because in some circumstances we may need them
  30484. offsets.marginTop = marginTop;
  30485. offsets.marginLeft = marginLeft;
  30486. }
  30487. if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
  30488. offsets = includeScroll(offsets, parent);
  30489. }
  30490. return offsets;
  30491. }
  30492. function getViewportOffsetRectRelativeToArtbitraryNode(element) {
  30493. var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  30494. var html = element.ownerDocument.documentElement;
  30495. var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
  30496. var width = Math.max(html.clientWidth, window.innerWidth || 0);
  30497. var height = Math.max(html.clientHeight, window.innerHeight || 0);
  30498. var scrollTop = !excludeScroll ? getScroll(html) : 0;
  30499. var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
  30500. var offset = {
  30501. top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
  30502. left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
  30503. width: width,
  30504. height: height
  30505. };
  30506. return getClientRect(offset);
  30507. }
  30508. /**
  30509. * Check if the given element is fixed or is inside a fixed parent
  30510. * @method
  30511. * @memberof Popper.Utils
  30512. * @argument {Element} element
  30513. * @argument {Element} customContainer
  30514. * @returns {Boolean} answer to "isFixed?"
  30515. */
  30516. function isFixed(element) {
  30517. var nodeName = element.nodeName;
  30518. if (nodeName === 'BODY' || nodeName === 'HTML') {
  30519. return false;
  30520. }
  30521. if (getStyleComputedProperty(element, 'position') === 'fixed') {
  30522. return true;
  30523. }
  30524. var parentNode = getParentNode(element);
  30525. if (!parentNode) {
  30526. return false;
  30527. }
  30528. return isFixed(parentNode);
  30529. }
  30530. /**
  30531. * Finds the first parent of an element that has a transformed property defined
  30532. * @method
  30533. * @memberof Popper.Utils
  30534. * @argument {Element} element
  30535. * @returns {Element} first transformed parent or documentElement
  30536. */
  30537. function getFixedPositionOffsetParent(element) {
  30538. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  30539. if (!element || !element.parentElement || isIE()) {
  30540. return document.documentElement;
  30541. }
  30542. var el = element.parentElement;
  30543. while (el && getStyleComputedProperty(el, 'transform') === 'none') {
  30544. el = el.parentElement;
  30545. }
  30546. return el || document.documentElement;
  30547. }
  30548. /**
  30549. * Computed the boundaries limits and return them
  30550. * @method
  30551. * @memberof Popper.Utils
  30552. * @param {HTMLElement} popper
  30553. * @param {HTMLElement} reference
  30554. * @param {number} padding
  30555. * @param {HTMLElement} boundariesElement - Element used to define the boundaries
  30556. * @param {Boolean} fixedPosition - Is in fixed position mode
  30557. * @returns {Object} Coordinates of the boundaries
  30558. */
  30559. function getBoundaries(popper, reference, padding, boundariesElement) {
  30560. var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  30561. // NOTE: 1 DOM access here
  30562. var boundaries = { top: 0, left: 0 };
  30563. var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  30564. // Handle viewport case
  30565. if (boundariesElement === 'viewport') {
  30566. boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
  30567. } else {
  30568. // Handle other cases based on DOM element used as boundaries
  30569. var boundariesNode = void 0;
  30570. if (boundariesElement === 'scrollParent') {
  30571. boundariesNode = getScrollParent(getParentNode(reference));
  30572. if (boundariesNode.nodeName === 'BODY') {
  30573. boundariesNode = popper.ownerDocument.documentElement;
  30574. }
  30575. } else if (boundariesElement === 'window') {
  30576. boundariesNode = popper.ownerDocument.documentElement;
  30577. } else {
  30578. boundariesNode = boundariesElement;
  30579. }
  30580. var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
  30581. // In case of HTML, we need a different computation
  30582. if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
  30583. var _getWindowSizes = getWindowSizes(popper.ownerDocument),
  30584. height = _getWindowSizes.height,
  30585. width = _getWindowSizes.width;
  30586. boundaries.top += offsets.top - offsets.marginTop;
  30587. boundaries.bottom = height + offsets.top;
  30588. boundaries.left += offsets.left - offsets.marginLeft;
  30589. boundaries.right = width + offsets.left;
  30590. } else {
  30591. // for all the other DOM elements, this one is good
  30592. boundaries = offsets;
  30593. }
  30594. }
  30595. // Add paddings
  30596. padding = padding || 0;
  30597. var isPaddingNumber = typeof padding === 'number';
  30598. boundaries.left += isPaddingNumber ? padding : padding.left || 0;
  30599. boundaries.top += isPaddingNumber ? padding : padding.top || 0;
  30600. boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
  30601. boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
  30602. return boundaries;
  30603. }
  30604. function getArea(_ref) {
  30605. var width = _ref.width,
  30606. height = _ref.height;
  30607. return width * height;
  30608. }
  30609. /**
  30610. * Utility used to transform the `auto` placement to the placement with more
  30611. * available space.
  30612. * @method
  30613. * @memberof Popper.Utils
  30614. * @argument {Object} data - The data object generated by update method
  30615. * @argument {Object} options - Modifiers configuration and options
  30616. * @returns {Object} The data object, properly modified
  30617. */
  30618. function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
  30619. var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  30620. if (placement.indexOf('auto') === -1) {
  30621. return placement;
  30622. }
  30623. var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
  30624. var rects = {
  30625. top: {
  30626. width: boundaries.width,
  30627. height: refRect.top - boundaries.top
  30628. },
  30629. right: {
  30630. width: boundaries.right - refRect.right,
  30631. height: boundaries.height
  30632. },
  30633. bottom: {
  30634. width: boundaries.width,
  30635. height: boundaries.bottom - refRect.bottom
  30636. },
  30637. left: {
  30638. width: refRect.left - boundaries.left,
  30639. height: boundaries.height
  30640. }
  30641. };
  30642. var sortedAreas = Object.keys(rects).map(function (key) {
  30643. return _extends({
  30644. key: key
  30645. }, rects[key], {
  30646. area: getArea(rects[key])
  30647. });
  30648. }).sort(function (a, b) {
  30649. return b.area - a.area;
  30650. });
  30651. var filteredAreas = sortedAreas.filter(function (_ref2) {
  30652. var width = _ref2.width,
  30653. height = _ref2.height;
  30654. return width >= popper.clientWidth && height >= popper.clientHeight;
  30655. });
  30656. var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
  30657. var variation = placement.split('-')[1];
  30658. return computedPlacement + (variation ? '-' + variation : '');
  30659. }
  30660. /**
  30661. * Get offsets to the reference element
  30662. * @method
  30663. * @memberof Popper.Utils
  30664. * @param {Object} state
  30665. * @param {Element} popper - the popper element
  30666. * @param {Element} reference - the reference element (the popper will be relative to this)
  30667. * @param {Element} fixedPosition - is in fixed position mode
  30668. * @returns {Object} An object containing the offsets which will be applied to the popper
  30669. */
  30670. function getReferenceOffsets(state, popper, reference) {
  30671. var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  30672. var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  30673. return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
  30674. }
  30675. /**
  30676. * Get the outer sizes of the given element (offset size + margins)
  30677. * @method
  30678. * @memberof Popper.Utils
  30679. * @argument {Element} element
  30680. * @returns {Object} object containing width and height properties
  30681. */
  30682. function getOuterSizes(element) {
  30683. var window = element.ownerDocument.defaultView;
  30684. var styles = window.getComputedStyle(element);
  30685. var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
  30686. var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
  30687. var result = {
  30688. width: element.offsetWidth + y,
  30689. height: element.offsetHeight + x
  30690. };
  30691. return result;
  30692. }
  30693. /**
  30694. * Get the opposite placement of the given one
  30695. * @method
  30696. * @memberof Popper.Utils
  30697. * @argument {String} placement
  30698. * @returns {String} flipped placement
  30699. */
  30700. function getOppositePlacement(placement) {
  30701. var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
  30702. return placement.replace(/left|right|bottom|top/g, function (matched) {
  30703. return hash[matched];
  30704. });
  30705. }
  30706. /**
  30707. * Get offsets to the popper
  30708. * @method
  30709. * @memberof Popper.Utils
  30710. * @param {Object} position - CSS position the Popper will get applied
  30711. * @param {HTMLElement} popper - the popper element
  30712. * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
  30713. * @param {String} placement - one of the valid placement options
  30714. * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
  30715. */
  30716. function getPopperOffsets(popper, referenceOffsets, placement) {
  30717. placement = placement.split('-')[0];
  30718. // Get popper node sizes
  30719. var popperRect = getOuterSizes(popper);
  30720. // Add position, width and height to our offsets object
  30721. var popperOffsets = {
  30722. width: popperRect.width,
  30723. height: popperRect.height
  30724. };
  30725. // depending by the popper placement we have to compute its offsets slightly differently
  30726. var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
  30727. var mainSide = isHoriz ? 'top' : 'left';
  30728. var secondarySide = isHoriz ? 'left' : 'top';
  30729. var measurement = isHoriz ? 'height' : 'width';
  30730. var secondaryMeasurement = !isHoriz ? 'height' : 'width';
  30731. popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
  30732. if (placement === secondarySide) {
  30733. popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
  30734. } else {
  30735. popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
  30736. }
  30737. return popperOffsets;
  30738. }
  30739. /**
  30740. * Mimics the `find` method of Array
  30741. * @method
  30742. * @memberof Popper.Utils
  30743. * @argument {Array} arr
  30744. * @argument prop
  30745. * @argument value
  30746. * @returns index or -1
  30747. */
  30748. function find(arr, check) {
  30749. // use native find if supported
  30750. if (Array.prototype.find) {
  30751. return arr.find(check);
  30752. }
  30753. // use `filter` to obtain the same behavior of `find`
  30754. return arr.filter(check)[0];
  30755. }
  30756. /**
  30757. * Return the index of the matching object
  30758. * @method
  30759. * @memberof Popper.Utils
  30760. * @argument {Array} arr
  30761. * @argument prop
  30762. * @argument value
  30763. * @returns index or -1
  30764. */
  30765. function findIndex(arr, prop, value) {
  30766. // use native findIndex if supported
  30767. if (Array.prototype.findIndex) {
  30768. return arr.findIndex(function (cur) {
  30769. return cur[prop] === value;
  30770. });
  30771. }
  30772. // use `find` + `indexOf` if `findIndex` isn't supported
  30773. var match = find(arr, function (obj) {
  30774. return obj[prop] === value;
  30775. });
  30776. return arr.indexOf(match);
  30777. }
  30778. /**
  30779. * Loop trough the list of modifiers and run them in order,
  30780. * each of them will then edit the data object.
  30781. * @method
  30782. * @memberof Popper.Utils
  30783. * @param {dataObject} data
  30784. * @param {Array} modifiers
  30785. * @param {String} ends - Optional modifier name used as stopper
  30786. * @returns {dataObject}
  30787. */
  30788. function runModifiers(modifiers, data, ends) {
  30789. var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
  30790. modifiersToRun.forEach(function (modifier) {
  30791. if (modifier['function']) {
  30792. // eslint-disable-line dot-notation
  30793. console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
  30794. }
  30795. var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
  30796. if (modifier.enabled && isFunction(fn)) {
  30797. // Add properties to offsets to make them a complete clientRect object
  30798. // we do this before each modifier to make sure the previous one doesn't
  30799. // mess with these values
  30800. data.offsets.popper = getClientRect(data.offsets.popper);
  30801. data.offsets.reference = getClientRect(data.offsets.reference);
  30802. data = fn(data, modifier);
  30803. }
  30804. });
  30805. return data;
  30806. }
  30807. /**
  30808. * Updates the position of the popper, computing the new offsets and applying
  30809. * the new style.<br />
  30810. * Prefer `scheduleUpdate` over `update` because of performance reasons.
  30811. * @method
  30812. * @memberof Popper
  30813. */
  30814. function update() {
  30815. // if popper is destroyed, don't perform any further update
  30816. if (this.state.isDestroyed) {
  30817. return;
  30818. }
  30819. var data = {
  30820. instance: this,
  30821. styles: {},
  30822. arrowStyles: {},
  30823. attributes: {},
  30824. flipped: false,
  30825. offsets: {}
  30826. };
  30827. // compute reference element offsets
  30828. data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
  30829. // compute auto placement, store placement inside the data object,
  30830. // modifiers will be able to edit `placement` if needed
  30831. // and refer to originalPlacement to know the original value
  30832. data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
  30833. // store the computed placement inside `originalPlacement`
  30834. data.originalPlacement = data.placement;
  30835. data.positionFixed = this.options.positionFixed;
  30836. // compute the popper offsets
  30837. data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
  30838. data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
  30839. // run the modifiers
  30840. data = runModifiers(this.modifiers, data);
  30841. // the first `update` will call `onCreate` callback
  30842. // the other ones will call `onUpdate` callback
  30843. if (!this.state.isCreated) {
  30844. this.state.isCreated = true;
  30845. this.options.onCreate(data);
  30846. } else {
  30847. this.options.onUpdate(data);
  30848. }
  30849. }
  30850. /**
  30851. * Helper used to know if the given modifier is enabled.
  30852. * @method
  30853. * @memberof Popper.Utils
  30854. * @returns {Boolean}
  30855. */
  30856. function isModifierEnabled(modifiers, modifierName) {
  30857. return modifiers.some(function (_ref) {
  30858. var name = _ref.name,
  30859. enabled = _ref.enabled;
  30860. return enabled && name === modifierName;
  30861. });
  30862. }
  30863. /**
  30864. * Get the prefixed supported property name
  30865. * @method
  30866. * @memberof Popper.Utils
  30867. * @argument {String} property (camelCase)
  30868. * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
  30869. */
  30870. function getSupportedPropertyName(property) {
  30871. var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
  30872. var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
  30873. for (var i = 0; i < prefixes.length; i++) {
  30874. var prefix = prefixes[i];
  30875. var toCheck = prefix ? '' + prefix + upperProp : property;
  30876. if (typeof document.body.style[toCheck] !== 'undefined') {
  30877. return toCheck;
  30878. }
  30879. }
  30880. return null;
  30881. }
  30882. /**
  30883. * Destroys the popper.
  30884. * @method
  30885. * @memberof Popper
  30886. */
  30887. function destroy() {
  30888. this.state.isDestroyed = true;
  30889. // touch DOM only if `applyStyle` modifier is enabled
  30890. if (isModifierEnabled(this.modifiers, 'applyStyle')) {
  30891. this.popper.removeAttribute('x-placement');
  30892. this.popper.style.position = '';
  30893. this.popper.style.top = '';
  30894. this.popper.style.left = '';
  30895. this.popper.style.right = '';
  30896. this.popper.style.bottom = '';
  30897. this.popper.style.willChange = '';
  30898. this.popper.style[getSupportedPropertyName('transform')] = '';
  30899. }
  30900. this.disableEventListeners();
  30901. // remove the popper if user explicitly asked for the deletion on destroy
  30902. // do not use `remove` because IE11 doesn't support it
  30903. if (this.options.removeOnDestroy) {
  30904. this.popper.parentNode.removeChild(this.popper);
  30905. }
  30906. return this;
  30907. }
  30908. /**
  30909. * Get the window associated with the element
  30910. * @argument {Element} element
  30911. * @returns {Window}
  30912. */
  30913. function getWindow(element) {
  30914. var ownerDocument = element.ownerDocument;
  30915. return ownerDocument ? ownerDocument.defaultView : window;
  30916. }
  30917. function attachToScrollParents(scrollParent, event, callback, scrollParents) {
  30918. var isBody = scrollParent.nodeName === 'BODY';
  30919. var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
  30920. target.addEventListener(event, callback, { passive: true });
  30921. if (!isBody) {
  30922. attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
  30923. }
  30924. scrollParents.push(target);
  30925. }
  30926. /**
  30927. * Setup needed event listeners used to update the popper position
  30928. * @method
  30929. * @memberof Popper.Utils
  30930. * @private
  30931. */
  30932. function setupEventListeners(reference, options, state, updateBound) {
  30933. // Resize event listener on window
  30934. state.updateBound = updateBound;
  30935. getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
  30936. // Scroll event listener on scroll parents
  30937. var scrollElement = getScrollParent(reference);
  30938. attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
  30939. state.scrollElement = scrollElement;
  30940. state.eventsEnabled = true;
  30941. return state;
  30942. }
  30943. /**
  30944. * It will add resize/scroll events and start recalculating
  30945. * position of the popper element when they are triggered.
  30946. * @method
  30947. * @memberof Popper
  30948. */
  30949. function enableEventListeners() {
  30950. if (!this.state.eventsEnabled) {
  30951. this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
  30952. }
  30953. }
  30954. /**
  30955. * Remove event listeners used to update the popper position
  30956. * @method
  30957. * @memberof Popper.Utils
  30958. * @private
  30959. */
  30960. function removeEventListeners(reference, state) {
  30961. // Remove resize event listener on window
  30962. getWindow(reference).removeEventListener('resize', state.updateBound);
  30963. // Remove scroll event listener on scroll parents
  30964. state.scrollParents.forEach(function (target) {
  30965. target.removeEventListener('scroll', state.updateBound);
  30966. });
  30967. // Reset state
  30968. state.updateBound = null;
  30969. state.scrollParents = [];
  30970. state.scrollElement = null;
  30971. state.eventsEnabled = false;
  30972. return state;
  30973. }
  30974. /**
  30975. * It will remove resize/scroll events and won't recalculate popper position
  30976. * when they are triggered. It also won't trigger `onUpdate` callback anymore,
  30977. * unless you call `update` method manually.
  30978. * @method
  30979. * @memberof Popper
  30980. */
  30981. function disableEventListeners() {
  30982. if (this.state.eventsEnabled) {
  30983. cancelAnimationFrame(this.scheduleUpdate);
  30984. this.state = removeEventListeners(this.reference, this.state);
  30985. }
  30986. }
  30987. /**
  30988. * Tells if a given input is a number
  30989. * @method
  30990. * @memberof Popper.Utils
  30991. * @param {*} input to check
  30992. * @return {Boolean}
  30993. */
  30994. function isNumeric(n) {
  30995. return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
  30996. }
  30997. /**
  30998. * Set the style to the given popper
  30999. * @method
  31000. * @memberof Popper.Utils
  31001. * @argument {Element} element - Element to apply the style to
  31002. * @argument {Object} styles
  31003. * Object with a list of properties and values which will be applied to the element
  31004. */
  31005. function setStyles(element, styles) {
  31006. Object.keys(styles).forEach(function (prop) {
  31007. var unit = '';
  31008. // add unit if the value is numeric and is one of the following
  31009. if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
  31010. unit = 'px';
  31011. }
  31012. element.style[prop] = styles[prop] + unit;
  31013. });
  31014. }
  31015. /**
  31016. * Set the attributes to the given popper
  31017. * @method
  31018. * @memberof Popper.Utils
  31019. * @argument {Element} element - Element to apply the attributes to
  31020. * @argument {Object} styles
  31021. * Object with a list of properties and values which will be applied to the element
  31022. */
  31023. function setAttributes(element, attributes) {
  31024. Object.keys(attributes).forEach(function (prop) {
  31025. var value = attributes[prop];
  31026. if (value !== false) {
  31027. element.setAttribute(prop, attributes[prop]);
  31028. } else {
  31029. element.removeAttribute(prop);
  31030. }
  31031. });
  31032. }
  31033. /**
  31034. * @function
  31035. * @memberof Modifiers
  31036. * @argument {Object} data - The data object generated by `update` method
  31037. * @argument {Object} data.styles - List of style properties - values to apply to popper element
  31038. * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
  31039. * @argument {Object} options - Modifiers configuration and options
  31040. * @returns {Object} The same data object
  31041. */
  31042. function applyStyle(data) {
  31043. // any property present in `data.styles` will be applied to the popper,
  31044. // in this way we can make the 3rd party modifiers add custom styles to it
  31045. // Be aware, modifiers could override the properties defined in the previous
  31046. // lines of this modifier!
  31047. setStyles(data.instance.popper, data.styles);
  31048. // any property present in `data.attributes` will be applied to the popper,
  31049. // they will be set as HTML attributes of the element
  31050. setAttributes(data.instance.popper, data.attributes);
  31051. // if arrowElement is defined and arrowStyles has some properties
  31052. if (data.arrowElement && Object.keys(data.arrowStyles).length) {
  31053. setStyles(data.arrowElement, data.arrowStyles);
  31054. }
  31055. return data;
  31056. }
  31057. /**
  31058. * Set the x-placement attribute before everything else because it could be used
  31059. * to add margins to the popper margins needs to be calculated to get the
  31060. * correct popper offsets.
  31061. * @method
  31062. * @memberof Popper.modifiers
  31063. * @param {HTMLElement} reference - The reference element used to position the popper
  31064. * @param {HTMLElement} popper - The HTML element used as popper
  31065. * @param {Object} options - Popper.js options
  31066. */
  31067. function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
  31068. // compute reference element offsets
  31069. var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
  31070. // compute auto placement, store placement inside the data object,
  31071. // modifiers will be able to edit `placement` if needed
  31072. // and refer to originalPlacement to know the original value
  31073. var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
  31074. popper.setAttribute('x-placement', placement);
  31075. // Apply `position` to popper before anything else because
  31076. // without the position applied we can't guarantee correct computations
  31077. setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
  31078. return options;
  31079. }
  31080. /**
  31081. * @function
  31082. * @memberof Popper.Utils
  31083. * @argument {Object} data - The data object generated by `update` method
  31084. * @argument {Boolean} shouldRound - If the offsets should be rounded at all
  31085. * @returns {Object} The popper's position offsets rounded
  31086. *
  31087. * The tale of pixel-perfect positioning. It's still not 100% perfect, but as
  31088. * good as it can be within reason.
  31089. * Discussion here: https://github.com/FezVrasta/popper.js/pull/715
  31090. *
  31091. * Low DPI screens cause a popper to be blurry if not using full pixels (Safari
  31092. * as well on High DPI screens).
  31093. *
  31094. * Firefox prefers no rounding for positioning and does not have blurriness on
  31095. * high DPI screens.
  31096. *
  31097. * Only horizontal placement and left/right values need to be considered.
  31098. */
  31099. function getRoundedOffsets(data, shouldRound) {
  31100. var _data$offsets = data.offsets,
  31101. popper = _data$offsets.popper,
  31102. reference = _data$offsets.reference;
  31103. var round = Math.round,
  31104. floor = Math.floor;
  31105. var noRound = function noRound(v) {
  31106. return v;
  31107. };
  31108. var referenceWidth = round(reference.width);
  31109. var popperWidth = round(popper.width);
  31110. var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
  31111. var isVariation = data.placement.indexOf('-') !== -1;
  31112. var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
  31113. var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
  31114. var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
  31115. var verticalToInteger = !shouldRound ? noRound : round;
  31116. return {
  31117. left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
  31118. top: verticalToInteger(popper.top),
  31119. bottom: verticalToInteger(popper.bottom),
  31120. right: horizontalToInteger(popper.right)
  31121. };
  31122. }
  31123. var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
  31124. /**
  31125. * @function
  31126. * @memberof Modifiers
  31127. * @argument {Object} data - The data object generated by `update` method
  31128. * @argument {Object} options - Modifiers configuration and options
  31129. * @returns {Object} The data object, properly modified
  31130. */
  31131. function computeStyle(data, options) {
  31132. var x = options.x,
  31133. y = options.y;
  31134. var popper = data.offsets.popper;
  31135. // Remove this legacy support in Popper.js v2
  31136. var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
  31137. return modifier.name === 'applyStyle';
  31138. }).gpuAcceleration;
  31139. if (legacyGpuAccelerationOption !== undefined) {
  31140. console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
  31141. }
  31142. var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
  31143. var offsetParent = getOffsetParent(data.instance.popper);
  31144. var offsetParentRect = getBoundingClientRect(offsetParent);
  31145. // Styles
  31146. var styles = {
  31147. position: popper.position
  31148. };
  31149. var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
  31150. var sideA = x === 'bottom' ? 'top' : 'bottom';
  31151. var sideB = y === 'right' ? 'left' : 'right';
  31152. // if gpuAcceleration is set to `true` and transform is supported,
  31153. // we use `translate3d` to apply the position to the popper we
  31154. // automatically use the supported prefixed version if needed
  31155. var prefixedProperty = getSupportedPropertyName('transform');
  31156. // now, let's make a step back and look at this code closely (wtf?)
  31157. // If the content of the popper grows once it's been positioned, it
  31158. // may happen that the popper gets misplaced because of the new content
  31159. // overflowing its reference element
  31160. // To avoid this problem, we provide two options (x and y), which allow
  31161. // the consumer to define the offset origin.
  31162. // If we position a popper on top of a reference element, we can set
  31163. // `x` to `top` to make the popper grow towards its top instead of
  31164. // its bottom.
  31165. var left = void 0,
  31166. top = void 0;
  31167. if (sideA === 'bottom') {
  31168. // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
  31169. // and not the bottom of the html element
  31170. if (offsetParent.nodeName === 'HTML') {
  31171. top = -offsetParent.clientHeight + offsets.bottom;
  31172. } else {
  31173. top = -offsetParentRect.height + offsets.bottom;
  31174. }
  31175. } else {
  31176. top = offsets.top;
  31177. }
  31178. if (sideB === 'right') {
  31179. if (offsetParent.nodeName === 'HTML') {
  31180. left = -offsetParent.clientWidth + offsets.right;
  31181. } else {
  31182. left = -offsetParentRect.width + offsets.right;
  31183. }
  31184. } else {
  31185. left = offsets.left;
  31186. }
  31187. if (gpuAcceleration && prefixedProperty) {
  31188. styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
  31189. styles[sideA] = 0;
  31190. styles[sideB] = 0;
  31191. styles.willChange = 'transform';
  31192. } else {
  31193. // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
  31194. var invertTop = sideA === 'bottom' ? -1 : 1;
  31195. var invertLeft = sideB === 'right' ? -1 : 1;
  31196. styles[sideA] = top * invertTop;
  31197. styles[sideB] = left * invertLeft;
  31198. styles.willChange = sideA + ', ' + sideB;
  31199. }
  31200. // Attributes
  31201. var attributes = {
  31202. 'x-placement': data.placement
  31203. };
  31204. // Update `data` attributes, styles and arrowStyles
  31205. data.attributes = _extends({}, attributes, data.attributes);
  31206. data.styles = _extends({}, styles, data.styles);
  31207. data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);
  31208. return data;
  31209. }
  31210. /**
  31211. * Helper used to know if the given modifier depends from another one.<br />
  31212. * It checks if the needed modifier is listed and enabled.
  31213. * @method
  31214. * @memberof Popper.Utils
  31215. * @param {Array} modifiers - list of modifiers
  31216. * @param {String} requestingName - name of requesting modifier
  31217. * @param {String} requestedName - name of requested modifier
  31218. * @returns {Boolean}
  31219. */
  31220. function isModifierRequired(modifiers, requestingName, requestedName) {
  31221. var requesting = find(modifiers, function (_ref) {
  31222. var name = _ref.name;
  31223. return name === requestingName;
  31224. });
  31225. var isRequired = !!requesting && modifiers.some(function (modifier) {
  31226. return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
  31227. });
  31228. if (!isRequired) {
  31229. var _requesting = '`' + requestingName + '`';
  31230. var requested = '`' + requestedName + '`';
  31231. console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
  31232. }
  31233. return isRequired;
  31234. }
  31235. /**
  31236. * @function
  31237. * @memberof Modifiers
  31238. * @argument {Object} data - The data object generated by update method
  31239. * @argument {Object} options - Modifiers configuration and options
  31240. * @returns {Object} The data object, properly modified
  31241. */
  31242. function arrow(data, options) {
  31243. var _data$offsets$arrow;
  31244. // arrow depends on keepTogether in order to work
  31245. if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
  31246. return data;
  31247. }
  31248. var arrowElement = options.element;
  31249. // if arrowElement is a string, suppose it's a CSS selector
  31250. if (typeof arrowElement === 'string') {
  31251. arrowElement = data.instance.popper.querySelector(arrowElement);
  31252. // if arrowElement is not found, don't run the modifier
  31253. if (!arrowElement) {
  31254. return data;
  31255. }
  31256. } else {
  31257. // if the arrowElement isn't a query selector we must check that the
  31258. // provided DOM node is child of its popper node
  31259. if (!data.instance.popper.contains(arrowElement)) {
  31260. console.warn('WARNING: `arrow.element` must be child of its popper element!');
  31261. return data;
  31262. }
  31263. }
  31264. var placement = data.placement.split('-')[0];
  31265. var _data$offsets = data.offsets,
  31266. popper = _data$offsets.popper,
  31267. reference = _data$offsets.reference;
  31268. var isVertical = ['left', 'right'].indexOf(placement) !== -1;
  31269. var len = isVertical ? 'height' : 'width';
  31270. var sideCapitalized = isVertical ? 'Top' : 'Left';
  31271. var side = sideCapitalized.toLowerCase();
  31272. var altSide = isVertical ? 'left' : 'top';
  31273. var opSide = isVertical ? 'bottom' : 'right';
  31274. var arrowElementSize = getOuterSizes(arrowElement)[len];
  31275. //
  31276. // extends keepTogether behavior making sure the popper and its
  31277. // reference have enough pixels in conjunction
  31278. //
  31279. // top/left side
  31280. if (reference[opSide] - arrowElementSize < popper[side]) {
  31281. data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
  31282. }
  31283. // bottom/right side
  31284. if (reference[side] + arrowElementSize > popper[opSide]) {
  31285. data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
  31286. }
  31287. data.offsets.popper = getClientRect(data.offsets.popper);
  31288. // compute center of the popper
  31289. var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
  31290. // Compute the sideValue using the updated popper offsets
  31291. // take popper margin in account because we don't have this info available
  31292. var css = getStyleComputedProperty(data.instance.popper);
  31293. var popperMarginSide = parseFloat(css['margin' + sideCapitalized]);
  31294. var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']);
  31295. var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
  31296. // prevent arrowElement from being placed not contiguously to its popper
  31297. sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
  31298. data.arrowElement = arrowElement;
  31299. data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
  31300. return data;
  31301. }
  31302. /**
  31303. * Get the opposite placement variation of the given one
  31304. * @method
  31305. * @memberof Popper.Utils
  31306. * @argument {String} placement variation
  31307. * @returns {String} flipped placement variation
  31308. */
  31309. function getOppositeVariation(variation) {
  31310. if (variation === 'end') {
  31311. return 'start';
  31312. } else if (variation === 'start') {
  31313. return 'end';
  31314. }
  31315. return variation;
  31316. }
  31317. /**
  31318. * List of accepted placements to use as values of the `placement` option.<br />
  31319. * Valid placements are:
  31320. * - `auto`
  31321. * - `top`
  31322. * - `right`
  31323. * - `bottom`
  31324. * - `left`
  31325. *
  31326. * Each placement can have a variation from this list:
  31327. * - `-start`
  31328. * - `-end`
  31329. *
  31330. * Variations are interpreted easily if you think of them as the left to right
  31331. * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
  31332. * is right.<br />
  31333. * Vertically (`left` and `right`), `start` is top and `end` is bottom.
  31334. *
  31335. * Some valid examples are:
  31336. * - `top-end` (on top of reference, right aligned)
  31337. * - `right-start` (on right of reference, top aligned)
  31338. * - `bottom` (on bottom, centered)
  31339. * - `auto-end` (on the side with more space available, alignment depends by placement)
  31340. *
  31341. * @static
  31342. * @type {Array}
  31343. * @enum {String}
  31344. * @readonly
  31345. * @method placements
  31346. * @memberof Popper
  31347. */
  31348. 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'];
  31349. // Get rid of `auto` `auto-start` and `auto-end`
  31350. var validPlacements = placements.slice(3);
  31351. /**
  31352. * Given an initial placement, returns all the subsequent placements
  31353. * clockwise (or counter-clockwise).
  31354. *
  31355. * @method
  31356. * @memberof Popper.Utils
  31357. * @argument {String} placement - A valid placement (it accepts variations)
  31358. * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
  31359. * @returns {Array} placements including their variations
  31360. */
  31361. function clockwise(placement) {
  31362. var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  31363. var index = validPlacements.indexOf(placement);
  31364. var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
  31365. return counter ? arr.reverse() : arr;
  31366. }
  31367. var BEHAVIORS = {
  31368. FLIP: 'flip',
  31369. CLOCKWISE: 'clockwise',
  31370. COUNTERCLOCKWISE: 'counterclockwise'
  31371. };
  31372. /**
  31373. * @function
  31374. * @memberof Modifiers
  31375. * @argument {Object} data - The data object generated by update method
  31376. * @argument {Object} options - Modifiers configuration and options
  31377. * @returns {Object} The data object, properly modified
  31378. */
  31379. function flip(data, options) {
  31380. // if `inner` modifier is enabled, we can't use the `flip` modifier
  31381. if (isModifierEnabled(data.instance.modifiers, 'inner')) {
  31382. return data;
  31383. }
  31384. if (data.flipped && data.placement === data.originalPlacement) {
  31385. // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
  31386. return data;
  31387. }
  31388. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
  31389. var placement = data.placement.split('-')[0];
  31390. var placementOpposite = getOppositePlacement(placement);
  31391. var variation = data.placement.split('-')[1] || '';
  31392. var flipOrder = [];
  31393. switch (options.behavior) {
  31394. case BEHAVIORS.FLIP:
  31395. flipOrder = [placement, placementOpposite];
  31396. break;
  31397. case BEHAVIORS.CLOCKWISE:
  31398. flipOrder = clockwise(placement);
  31399. break;
  31400. case BEHAVIORS.COUNTERCLOCKWISE:
  31401. flipOrder = clockwise(placement, true);
  31402. break;
  31403. default:
  31404. flipOrder = options.behavior;
  31405. }
  31406. flipOrder.forEach(function (step, index) {
  31407. if (placement !== step || flipOrder.length === index + 1) {
  31408. return data;
  31409. }
  31410. placement = data.placement.split('-')[0];
  31411. placementOpposite = getOppositePlacement(placement);
  31412. var popperOffsets = data.offsets.popper;
  31413. var refOffsets = data.offsets.reference;
  31414. // using floor because the reference offsets may contain decimals we are not going to consider here
  31415. var floor = Math.floor;
  31416. 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);
  31417. var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
  31418. var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
  31419. var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
  31420. var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
  31421. var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
  31422. // flip the variation if required
  31423. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  31424. // flips variation if reference element overflows boundaries
  31425. var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
  31426. // flips variation if popper content overflows boundaries
  31427. var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
  31428. var flippedVariation = flippedVariationByRef || flippedVariationByContent;
  31429. if (overlapsRef || overflowsBoundaries || flippedVariation) {
  31430. // this boolean to detect any flip loop
  31431. data.flipped = true;
  31432. if (overlapsRef || overflowsBoundaries) {
  31433. placement = flipOrder[index + 1];
  31434. }
  31435. if (flippedVariation) {
  31436. variation = getOppositeVariation(variation);
  31437. }
  31438. data.placement = placement + (variation ? '-' + variation : '');
  31439. // this object contains `position`, we want to preserve it along with
  31440. // any additional property we may add in the future
  31441. data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
  31442. data = runModifiers(data.instance.modifiers, data, 'flip');
  31443. }
  31444. });
  31445. return data;
  31446. }
  31447. /**
  31448. * @function
  31449. * @memberof Modifiers
  31450. * @argument {Object} data - The data object generated by update method
  31451. * @argument {Object} options - Modifiers configuration and options
  31452. * @returns {Object} The data object, properly modified
  31453. */
  31454. function keepTogether(data) {
  31455. var _data$offsets = data.offsets,
  31456. popper = _data$offsets.popper,
  31457. reference = _data$offsets.reference;
  31458. var placement = data.placement.split('-')[0];
  31459. var floor = Math.floor;
  31460. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  31461. var side = isVertical ? 'right' : 'bottom';
  31462. var opSide = isVertical ? 'left' : 'top';
  31463. var measurement = isVertical ? 'width' : 'height';
  31464. if (popper[side] < floor(reference[opSide])) {
  31465. data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
  31466. }
  31467. if (popper[opSide] > floor(reference[side])) {
  31468. data.offsets.popper[opSide] = floor(reference[side]);
  31469. }
  31470. return data;
  31471. }
  31472. /**
  31473. * Converts a string containing value + unit into a px value number
  31474. * @function
  31475. * @memberof {modifiers~offset}
  31476. * @private
  31477. * @argument {String} str - Value + unit string
  31478. * @argument {String} measurement - `height` or `width`
  31479. * @argument {Object} popperOffsets
  31480. * @argument {Object} referenceOffsets
  31481. * @returns {Number|String}
  31482. * Value in pixels, or original string if no values were extracted
  31483. */
  31484. function toValue(str, measurement, popperOffsets, referenceOffsets) {
  31485. // separate value from unit
  31486. var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
  31487. var value = +split[1];
  31488. var unit = split[2];
  31489. // If it's not a number it's an operator, I guess
  31490. if (!value) {
  31491. return str;
  31492. }
  31493. if (unit.indexOf('%') === 0) {
  31494. var element = void 0;
  31495. switch (unit) {
  31496. case '%p':
  31497. element = popperOffsets;
  31498. break;
  31499. case '%':
  31500. case '%r':
  31501. default:
  31502. element = referenceOffsets;
  31503. }
  31504. var rect = getClientRect(element);
  31505. return rect[measurement] / 100 * value;
  31506. } else if (unit === 'vh' || unit === 'vw') {
  31507. // if is a vh or vw, we calculate the size based on the viewport
  31508. var size = void 0;
  31509. if (unit === 'vh') {
  31510. size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
  31511. } else {
  31512. size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
  31513. }
  31514. return size / 100 * value;
  31515. } else {
  31516. // if is an explicit pixel unit, we get rid of the unit and keep the value
  31517. // if is an implicit unit, it's px, and we return just the value
  31518. return value;
  31519. }
  31520. }
  31521. /**
  31522. * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
  31523. * @function
  31524. * @memberof {modifiers~offset}
  31525. * @private
  31526. * @argument {String} offset
  31527. * @argument {Object} popperOffsets
  31528. * @argument {Object} referenceOffsets
  31529. * @argument {String} basePlacement
  31530. * @returns {Array} a two cells array with x and y offsets in numbers
  31531. */
  31532. function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
  31533. var offsets = [0, 0];
  31534. // Use height if placement is left or right and index is 0 otherwise use width
  31535. // in this way the first offset will use an axis and the second one
  31536. // will use the other one
  31537. var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
  31538. // Split the offset string to obtain a list of values and operands
  31539. // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
  31540. var fragments = offset.split(/(\+|\-)/).map(function (frag) {
  31541. return frag.trim();
  31542. });
  31543. // Detect if the offset string contains a pair of values or a single one
  31544. // they could be separated by comma or space
  31545. var divider = fragments.indexOf(find(fragments, function (frag) {
  31546. return frag.search(/,|\s/) !== -1;
  31547. }));
  31548. if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
  31549. console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
  31550. }
  31551. // If divider is found, we divide the list of values and operands to divide
  31552. // them by ofset X and Y.
  31553. var splitRegex = /\s*,\s*|\s+/;
  31554. 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];
  31555. // Convert the values with units to absolute pixels to allow our computations
  31556. ops = ops.map(function (op, index) {
  31557. // Most of the units rely on the orientation of the popper
  31558. var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
  31559. var mergeWithPrevious = false;
  31560. return op
  31561. // This aggregates any `+` or `-` sign that aren't considered operators
  31562. // e.g.: 10 + +5 => [10, +, +5]
  31563. .reduce(function (a, b) {
  31564. if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
  31565. a[a.length - 1] = b;
  31566. mergeWithPrevious = true;
  31567. return a;
  31568. } else if (mergeWithPrevious) {
  31569. a[a.length - 1] += b;
  31570. mergeWithPrevious = false;
  31571. return a;
  31572. } else {
  31573. return a.concat(b);
  31574. }
  31575. }, [])
  31576. // Here we convert the string values into number values (in px)
  31577. .map(function (str) {
  31578. return toValue(str, measurement, popperOffsets, referenceOffsets);
  31579. });
  31580. });
  31581. // Loop trough the offsets arrays and execute the operations
  31582. ops.forEach(function (op, index) {
  31583. op.forEach(function (frag, index2) {
  31584. if (isNumeric(frag)) {
  31585. offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
  31586. }
  31587. });
  31588. });
  31589. return offsets;
  31590. }
  31591. /**
  31592. * @function
  31593. * @memberof Modifiers
  31594. * @argument {Object} data - The data object generated by update method
  31595. * @argument {Object} options - Modifiers configuration and options
  31596. * @argument {Number|String} options.offset=0
  31597. * The offset value as described in the modifier description
  31598. * @returns {Object} The data object, properly modified
  31599. */
  31600. function offset(data, _ref) {
  31601. var offset = _ref.offset;
  31602. var placement = data.placement,
  31603. _data$offsets = data.offsets,
  31604. popper = _data$offsets.popper,
  31605. reference = _data$offsets.reference;
  31606. var basePlacement = placement.split('-')[0];
  31607. var offsets = void 0;
  31608. if (isNumeric(+offset)) {
  31609. offsets = [+offset, 0];
  31610. } else {
  31611. offsets = parseOffset(offset, popper, reference, basePlacement);
  31612. }
  31613. if (basePlacement === 'left') {
  31614. popper.top += offsets[0];
  31615. popper.left -= offsets[1];
  31616. } else if (basePlacement === 'right') {
  31617. popper.top += offsets[0];
  31618. popper.left += offsets[1];
  31619. } else if (basePlacement === 'top') {
  31620. popper.left += offsets[0];
  31621. popper.top -= offsets[1];
  31622. } else if (basePlacement === 'bottom') {
  31623. popper.left += offsets[0];
  31624. popper.top += offsets[1];
  31625. }
  31626. data.popper = popper;
  31627. return data;
  31628. }
  31629. /**
  31630. * @function
  31631. * @memberof Modifiers
  31632. * @argument {Object} data - The data object generated by `update` method
  31633. * @argument {Object} options - Modifiers configuration and options
  31634. * @returns {Object} The data object, properly modified
  31635. */
  31636. function preventOverflow(data, options) {
  31637. var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
  31638. // If offsetParent is the reference element, we really want to
  31639. // go one step up and use the next offsetParent as reference to
  31640. // avoid to make this modifier completely useless and look like broken
  31641. if (data.instance.reference === boundariesElement) {
  31642. boundariesElement = getOffsetParent(boundariesElement);
  31643. }
  31644. // NOTE: DOM access here
  31645. // resets the popper's position so that the document size can be calculated excluding
  31646. // the size of the popper element itself
  31647. var transformProp = getSupportedPropertyName('transform');
  31648. var popperStyles = data.instance.popper.style; // assignment to help minification
  31649. var top = popperStyles.top,
  31650. left = popperStyles.left,
  31651. transform = popperStyles[transformProp];
  31652. popperStyles.top = '';
  31653. popperStyles.left = '';
  31654. popperStyles[transformProp] = '';
  31655. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
  31656. // NOTE: DOM access here
  31657. // restores the original style properties after the offsets have been computed
  31658. popperStyles.top = top;
  31659. popperStyles.left = left;
  31660. popperStyles[transformProp] = transform;
  31661. options.boundaries = boundaries;
  31662. var order = options.priority;
  31663. var popper = data.offsets.popper;
  31664. var check = {
  31665. primary: function primary(placement) {
  31666. var value = popper[placement];
  31667. if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
  31668. value = Math.max(popper[placement], boundaries[placement]);
  31669. }
  31670. return defineProperty({}, placement, value);
  31671. },
  31672. secondary: function secondary(placement) {
  31673. var mainSide = placement === 'right' ? 'left' : 'top';
  31674. var value = popper[mainSide];
  31675. if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
  31676. value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
  31677. }
  31678. return defineProperty({}, mainSide, value);
  31679. }
  31680. };
  31681. order.forEach(function (placement) {
  31682. var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
  31683. popper = _extends({}, popper, check[side](placement));
  31684. });
  31685. data.offsets.popper = popper;
  31686. return data;
  31687. }
  31688. /**
  31689. * @function
  31690. * @memberof Modifiers
  31691. * @argument {Object} data - The data object generated by `update` method
  31692. * @argument {Object} options - Modifiers configuration and options
  31693. * @returns {Object} The data object, properly modified
  31694. */
  31695. function shift(data) {
  31696. var placement = data.placement;
  31697. var basePlacement = placement.split('-')[0];
  31698. var shiftvariation = placement.split('-')[1];
  31699. // if shift shiftvariation is specified, run the modifier
  31700. if (shiftvariation) {
  31701. var _data$offsets = data.offsets,
  31702. reference = _data$offsets.reference,
  31703. popper = _data$offsets.popper;
  31704. var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
  31705. var side = isVertical ? 'left' : 'top';
  31706. var measurement = isVertical ? 'width' : 'height';
  31707. var shiftOffsets = {
  31708. start: defineProperty({}, side, reference[side]),
  31709. end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
  31710. };
  31711. data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
  31712. }
  31713. return data;
  31714. }
  31715. /**
  31716. * @function
  31717. * @memberof Modifiers
  31718. * @argument {Object} data - The data object generated by update method
  31719. * @argument {Object} options - Modifiers configuration and options
  31720. * @returns {Object} The data object, properly modified
  31721. */
  31722. function hide(data) {
  31723. if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
  31724. return data;
  31725. }
  31726. var refRect = data.offsets.reference;
  31727. var bound = find(data.instance.modifiers, function (modifier) {
  31728. return modifier.name === 'preventOverflow';
  31729. }).boundaries;
  31730. if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
  31731. // Avoid unnecessary DOM access if visibility hasn't changed
  31732. if (data.hide === true) {
  31733. return data;
  31734. }
  31735. data.hide = true;
  31736. data.attributes['x-out-of-boundaries'] = '';
  31737. } else {
  31738. // Avoid unnecessary DOM access if visibility hasn't changed
  31739. if (data.hide === false) {
  31740. return data;
  31741. }
  31742. data.hide = false;
  31743. data.attributes['x-out-of-boundaries'] = false;
  31744. }
  31745. return data;
  31746. }
  31747. /**
  31748. * @function
  31749. * @memberof Modifiers
  31750. * @argument {Object} data - The data object generated by `update` method
  31751. * @argument {Object} options - Modifiers configuration and options
  31752. * @returns {Object} The data object, properly modified
  31753. */
  31754. function inner(data) {
  31755. var placement = data.placement;
  31756. var basePlacement = placement.split('-')[0];
  31757. var _data$offsets = data.offsets,
  31758. popper = _data$offsets.popper,
  31759. reference = _data$offsets.reference;
  31760. var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
  31761. var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
  31762. popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
  31763. data.placement = getOppositePlacement(placement);
  31764. data.offsets.popper = getClientRect(popper);
  31765. return data;
  31766. }
  31767. /**
  31768. * Modifier function, each modifier can have a function of this type assigned
  31769. * to its `fn` property.<br />
  31770. * These functions will be called on each update, this means that you must
  31771. * make sure they are performant enough to avoid performance bottlenecks.
  31772. *
  31773. * @function ModifierFn
  31774. * @argument {dataObject} data - The data object generated by `update` method
  31775. * @argument {Object} options - Modifiers configuration and options
  31776. * @returns {dataObject} The data object, properly modified
  31777. */
  31778. /**
  31779. * Modifiers are plugins used to alter the behavior of your poppers.<br />
  31780. * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
  31781. * needed by the library.
  31782. *
  31783. * Usually you don't want to override the `order`, `fn` and `onLoad` props.
  31784. * All the other properties are configurations that could be tweaked.
  31785. * @namespace modifiers
  31786. */
  31787. var modifiers = {
  31788. /**
  31789. * Modifier used to shift the popper on the start or end of its reference
  31790. * element.<br />
  31791. * It will read the variation of the `placement` property.<br />
  31792. * It can be one either `-end` or `-start`.
  31793. * @memberof modifiers
  31794. * @inner
  31795. */
  31796. shift: {
  31797. /** @prop {number} order=100 - Index used to define the order of execution */
  31798. order: 100,
  31799. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31800. enabled: true,
  31801. /** @prop {ModifierFn} */
  31802. fn: shift
  31803. },
  31804. /**
  31805. * The `offset` modifier can shift your popper on both its axis.
  31806. *
  31807. * It accepts the following units:
  31808. * - `px` or unit-less, interpreted as pixels
  31809. * - `%` or `%r`, percentage relative to the length of the reference element
  31810. * - `%p`, percentage relative to the length of the popper element
  31811. * - `vw`, CSS viewport width unit
  31812. * - `vh`, CSS viewport height unit
  31813. *
  31814. * For length is intended the main axis relative to the placement of the popper.<br />
  31815. * This means that if the placement is `top` or `bottom`, the length will be the
  31816. * `width`. In case of `left` or `right`, it will be the `height`.
  31817. *
  31818. * You can provide a single value (as `Number` or `String`), or a pair of values
  31819. * as `String` divided by a comma or one (or more) white spaces.<br />
  31820. * The latter is a deprecated method because it leads to confusion and will be
  31821. * removed in v2.<br />
  31822. * Additionally, it accepts additions and subtractions between different units.
  31823. * Note that multiplications and divisions aren't supported.
  31824. *
  31825. * Valid examples are:
  31826. * ```
  31827. * 10
  31828. * '10%'
  31829. * '10, 10'
  31830. * '10%, 10'
  31831. * '10 + 10%'
  31832. * '10 - 5vh + 3%'
  31833. * '-10px + 5vh, 5px - 6%'
  31834. * ```
  31835. * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
  31836. * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
  31837. * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
  31838. *
  31839. * @memberof modifiers
  31840. * @inner
  31841. */
  31842. offset: {
  31843. /** @prop {number} order=200 - Index used to define the order of execution */
  31844. order: 200,
  31845. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31846. enabled: true,
  31847. /** @prop {ModifierFn} */
  31848. fn: offset,
  31849. /** @prop {Number|String} offset=0
  31850. * The offset value as described in the modifier description
  31851. */
  31852. offset: 0
  31853. },
  31854. /**
  31855. * Modifier used to prevent the popper from being positioned outside the boundary.
  31856. *
  31857. * A scenario exists where the reference itself is not within the boundaries.<br />
  31858. * We can say it has "escaped the boundaries" — or just "escaped".<br />
  31859. * In this case we need to decide whether the popper should either:
  31860. *
  31861. * - detach from the reference and remain "trapped" in the boundaries, or
  31862. * - if it should ignore the boundary and "escape with its reference"
  31863. *
  31864. * When `escapeWithReference` is set to`true` and reference is completely
  31865. * outside its boundaries, the popper will overflow (or completely leave)
  31866. * the boundaries in order to remain attached to the edge of the reference.
  31867. *
  31868. * @memberof modifiers
  31869. * @inner
  31870. */
  31871. preventOverflow: {
  31872. /** @prop {number} order=300 - Index used to define the order of execution */
  31873. order: 300,
  31874. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31875. enabled: true,
  31876. /** @prop {ModifierFn} */
  31877. fn: preventOverflow,
  31878. /**
  31879. * @prop {Array} [priority=['left','right','top','bottom']]
  31880. * Popper will try to prevent overflow following these priorities by default,
  31881. * then, it could overflow on the left and on top of the `boundariesElement`
  31882. */
  31883. priority: ['left', 'right', 'top', 'bottom'],
  31884. /**
  31885. * @prop {number} padding=5
  31886. * Amount of pixel used to define a minimum distance between the boundaries
  31887. * and the popper. This makes sure the popper always has a little padding
  31888. * between the edges of its container
  31889. */
  31890. padding: 5,
  31891. /**
  31892. * @prop {String|HTMLElement} boundariesElement='scrollParent'
  31893. * Boundaries used by the modifier. Can be `scrollParent`, `window`,
  31894. * `viewport` or any DOM element.
  31895. */
  31896. boundariesElement: 'scrollParent'
  31897. },
  31898. /**
  31899. * Modifier used to make sure the reference and its popper stay near each other
  31900. * without leaving any gap between the two. Especially useful when the arrow is
  31901. * enabled and you want to ensure that it points to its reference element.
  31902. * It cares only about the first axis. You can still have poppers with margin
  31903. * between the popper and its reference element.
  31904. * @memberof modifiers
  31905. * @inner
  31906. */
  31907. keepTogether: {
  31908. /** @prop {number} order=400 - Index used to define the order of execution */
  31909. order: 400,
  31910. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31911. enabled: true,
  31912. /** @prop {ModifierFn} */
  31913. fn: keepTogether
  31914. },
  31915. /**
  31916. * This modifier is used to move the `arrowElement` of the popper to make
  31917. * sure it is positioned between the reference element and its popper element.
  31918. * It will read the outer size of the `arrowElement` node to detect how many
  31919. * pixels of conjunction are needed.
  31920. *
  31921. * It has no effect if no `arrowElement` is provided.
  31922. * @memberof modifiers
  31923. * @inner
  31924. */
  31925. arrow: {
  31926. /** @prop {number} order=500 - Index used to define the order of execution */
  31927. order: 500,
  31928. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31929. enabled: true,
  31930. /** @prop {ModifierFn} */
  31931. fn: arrow,
  31932. /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
  31933. element: '[x-arrow]'
  31934. },
  31935. /**
  31936. * Modifier used to flip the popper's placement when it starts to overlap its
  31937. * reference element.
  31938. *
  31939. * Requires the `preventOverflow` modifier before it in order to work.
  31940. *
  31941. * **NOTE:** this modifier will interrupt the current update cycle and will
  31942. * restart it if it detects the need to flip the placement.
  31943. * @memberof modifiers
  31944. * @inner
  31945. */
  31946. flip: {
  31947. /** @prop {number} order=600 - Index used to define the order of execution */
  31948. order: 600,
  31949. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  31950. enabled: true,
  31951. /** @prop {ModifierFn} */
  31952. fn: flip,
  31953. /**
  31954. * @prop {String|Array} behavior='flip'
  31955. * The behavior used to change the popper's placement. It can be one of
  31956. * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
  31957. * placements (with optional variations)
  31958. */
  31959. behavior: 'flip',
  31960. /**
  31961. * @prop {number} padding=5
  31962. * The popper will flip if it hits the edges of the `boundariesElement`
  31963. */
  31964. padding: 5,
  31965. /**
  31966. * @prop {String|HTMLElement} boundariesElement='viewport'
  31967. * The element which will define the boundaries of the popper position.
  31968. * The popper will never be placed outside of the defined boundaries
  31969. * (except if `keepTogether` is enabled)
  31970. */
  31971. boundariesElement: 'viewport',
  31972. /**
  31973. * @prop {Boolean} flipVariations=false
  31974. * The popper will switch placement variation between `-start` and `-end` when
  31975. * the reference element overlaps its boundaries.
  31976. *
  31977. * The original placement should have a set variation.
  31978. */
  31979. flipVariations: false,
  31980. /**
  31981. * @prop {Boolean} flipVariationsByContent=false
  31982. * The popper will switch placement variation between `-start` and `-end` when
  31983. * the popper element overlaps its reference boundaries.
  31984. *
  31985. * The original placement should have a set variation.
  31986. */
  31987. flipVariationsByContent: false
  31988. },
  31989. /**
  31990. * Modifier used to make the popper flow toward the inner of the reference element.
  31991. * By default, when this modifier is disabled, the popper will be placed outside
  31992. * the reference element.
  31993. * @memberof modifiers
  31994. * @inner
  31995. */
  31996. inner: {
  31997. /** @prop {number} order=700 - Index used to define the order of execution */
  31998. order: 700,
  31999. /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
  32000. enabled: false,
  32001. /** @prop {ModifierFn} */
  32002. fn: inner
  32003. },
  32004. /**
  32005. * Modifier used to hide the popper when its reference element is outside of the
  32006. * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
  32007. * be used to hide with a CSS selector the popper when its reference is
  32008. * out of boundaries.
  32009. *
  32010. * Requires the `preventOverflow` modifier before it in order to work.
  32011. * @memberof modifiers
  32012. * @inner
  32013. */
  32014. hide: {
  32015. /** @prop {number} order=800 - Index used to define the order of execution */
  32016. order: 800,
  32017. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  32018. enabled: true,
  32019. /** @prop {ModifierFn} */
  32020. fn: hide
  32021. },
  32022. /**
  32023. * Computes the style that will be applied to the popper element to gets
  32024. * properly positioned.
  32025. *
  32026. * Note that this modifier will not touch the DOM, it just prepares the styles
  32027. * so that `applyStyle` modifier can apply it. This separation is useful
  32028. * in case you need to replace `applyStyle` with a custom implementation.
  32029. *
  32030. * This modifier has `850` as `order` value to maintain backward compatibility
  32031. * with previous versions of Popper.js. Expect the modifiers ordering method
  32032. * to change in future major versions of the library.
  32033. *
  32034. * @memberof modifiers
  32035. * @inner
  32036. */
  32037. computeStyle: {
  32038. /** @prop {number} order=850 - Index used to define the order of execution */
  32039. order: 850,
  32040. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  32041. enabled: true,
  32042. /** @prop {ModifierFn} */
  32043. fn: computeStyle,
  32044. /**
  32045. * @prop {Boolean} gpuAcceleration=true
  32046. * If true, it uses the CSS 3D transformation to position the popper.
  32047. * Otherwise, it will use the `top` and `left` properties
  32048. */
  32049. gpuAcceleration: true,
  32050. /**
  32051. * @prop {string} [x='bottom']
  32052. * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
  32053. * Change this if your popper should grow in a direction different from `bottom`
  32054. */
  32055. x: 'bottom',
  32056. /**
  32057. * @prop {string} [x='left']
  32058. * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
  32059. * Change this if your popper should grow in a direction different from `right`
  32060. */
  32061. y: 'right'
  32062. },
  32063. /**
  32064. * Applies the computed styles to the popper element.
  32065. *
  32066. * All the DOM manipulations are limited to this modifier. This is useful in case
  32067. * you want to integrate Popper.js inside a framework or view library and you
  32068. * want to delegate all the DOM manipulations to it.
  32069. *
  32070. * Note that if you disable this modifier, you must make sure the popper element
  32071. * has its position set to `absolute` before Popper.js can do its work!
  32072. *
  32073. * Just disable this modifier and define your own to achieve the desired effect.
  32074. *
  32075. * @memberof modifiers
  32076. * @inner
  32077. */
  32078. applyStyle: {
  32079. /** @prop {number} order=900 - Index used to define the order of execution */
  32080. order: 900,
  32081. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  32082. enabled: true,
  32083. /** @prop {ModifierFn} */
  32084. fn: applyStyle,
  32085. /** @prop {Function} */
  32086. onLoad: applyStyleOnLoad,
  32087. /**
  32088. * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
  32089. * @prop {Boolean} gpuAcceleration=true
  32090. * If true, it uses the CSS 3D transformation to position the popper.
  32091. * Otherwise, it will use the `top` and `left` properties
  32092. */
  32093. gpuAcceleration: undefined
  32094. }
  32095. };
  32096. /**
  32097. * The `dataObject` is an object containing all the information used by Popper.js.
  32098. * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
  32099. * @name dataObject
  32100. * @property {Object} data.instance The Popper.js instance
  32101. * @property {String} data.placement Placement applied to popper
  32102. * @property {String} data.originalPlacement Placement originally defined on init
  32103. * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
  32104. * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
  32105. * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
  32106. * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
  32107. * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
  32108. * @property {Object} data.boundaries Offsets of the popper boundaries
  32109. * @property {Object} data.offsets The measurements of popper, reference and arrow elements
  32110. * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
  32111. * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
  32112. * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
  32113. */
  32114. /**
  32115. * Default options provided to Popper.js constructor.<br />
  32116. * These can be overridden using the `options` argument of Popper.js.<br />
  32117. * To override an option, simply pass an object with the same
  32118. * structure of the `options` object, as the 3rd argument. For example:
  32119. * ```
  32120. * new Popper(ref, pop, {
  32121. * modifiers: {
  32122. * preventOverflow: { enabled: false }
  32123. * }
  32124. * })
  32125. * ```
  32126. * @type {Object}
  32127. * @static
  32128. * @memberof Popper
  32129. */
  32130. var Defaults = {
  32131. /**
  32132. * Popper's placement.
  32133. * @prop {Popper.placements} placement='bottom'
  32134. */
  32135. placement: 'bottom',
  32136. /**
  32137. * Set this to true if you want popper to position it self in 'fixed' mode
  32138. * @prop {Boolean} positionFixed=false
  32139. */
  32140. positionFixed: false,
  32141. /**
  32142. * Whether events (resize, scroll) are initially enabled.
  32143. * @prop {Boolean} eventsEnabled=true
  32144. */
  32145. eventsEnabled: true,
  32146. /**
  32147. * Set to true if you want to automatically remove the popper when
  32148. * you call the `destroy` method.
  32149. * @prop {Boolean} removeOnDestroy=false
  32150. */
  32151. removeOnDestroy: false,
  32152. /**
  32153. * Callback called when the popper is created.<br />
  32154. * By default, it is set to no-op.<br />
  32155. * Access Popper.js instance with `data.instance`.
  32156. * @prop {onCreate}
  32157. */
  32158. onCreate: function onCreate() {},
  32159. /**
  32160. * Callback called when the popper is updated. This callback is not called
  32161. * on the initialization/creation of the popper, but only on subsequent
  32162. * updates.<br />
  32163. * By default, it is set to no-op.<br />
  32164. * Access Popper.js instance with `data.instance`.
  32165. * @prop {onUpdate}
  32166. */
  32167. onUpdate: function onUpdate() {},
  32168. /**
  32169. * List of modifiers used to modify the offsets before they are applied to the popper.
  32170. * They provide most of the functionalities of Popper.js.
  32171. * @prop {modifiers}
  32172. */
  32173. modifiers: modifiers
  32174. };
  32175. /**
  32176. * @callback onCreate
  32177. * @param {dataObject} data
  32178. */
  32179. /**
  32180. * @callback onUpdate
  32181. * @param {dataObject} data
  32182. */
  32183. // Utils
  32184. // Methods
  32185. var Popper = function () {
  32186. /**
  32187. * Creates a new Popper.js instance.
  32188. * @class Popper
  32189. * @param {Element|referenceObject} reference - The reference element used to position the popper
  32190. * @param {Element} popper - The HTML / XML element used as the popper
  32191. * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
  32192. * @return {Object} instance - The generated Popper.js instance
  32193. */
  32194. function Popper(reference, popper) {
  32195. var _this = this;
  32196. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  32197. classCallCheck(this, Popper);
  32198. this.scheduleUpdate = function () {
  32199. return requestAnimationFrame(_this.update);
  32200. };
  32201. // make update() debounced, so that it only runs at most once-per-tick
  32202. this.update = debounce(this.update.bind(this));
  32203. // with {} we create a new object with the options inside it
  32204. this.options = _extends({}, Popper.Defaults, options);
  32205. // init state
  32206. this.state = {
  32207. isDestroyed: false,
  32208. isCreated: false,
  32209. scrollParents: []
  32210. };
  32211. // get reference and popper elements (allow jQuery wrappers)
  32212. this.reference = reference && reference.jquery ? reference[0] : reference;
  32213. this.popper = popper && popper.jquery ? popper[0] : popper;
  32214. // Deep merge modifiers options
  32215. this.options.modifiers = {};
  32216. Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
  32217. _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
  32218. });
  32219. // Refactoring modifiers' list (Object => Array)
  32220. this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
  32221. return _extends({
  32222. name: name
  32223. }, _this.options.modifiers[name]);
  32224. })
  32225. // sort the modifiers by order
  32226. .sort(function (a, b) {
  32227. return a.order - b.order;
  32228. });
  32229. // modifiers have the ability to execute arbitrary code when Popper.js get inited
  32230. // such code is executed in the same order of its modifier
  32231. // they could add new properties to their options configuration
  32232. // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
  32233. this.modifiers.forEach(function (modifierOptions) {
  32234. if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
  32235. modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
  32236. }
  32237. });
  32238. // fire the first update to position the popper in the right place
  32239. this.update();
  32240. var eventsEnabled = this.options.eventsEnabled;
  32241. if (eventsEnabled) {
  32242. // setup event listeners, they will take care of update the position in specific situations
  32243. this.enableEventListeners();
  32244. }
  32245. this.state.eventsEnabled = eventsEnabled;
  32246. }
  32247. // We can't use class properties because they don't get listed in the
  32248. // class prototype and break stuff like Sinon stubs
  32249. createClass(Popper, [{
  32250. key: 'update',
  32251. value: function update$$1() {
  32252. return update.call(this);
  32253. }
  32254. }, {
  32255. key: 'destroy',
  32256. value: function destroy$$1() {
  32257. return destroy.call(this);
  32258. }
  32259. }, {
  32260. key: 'enableEventListeners',
  32261. value: function enableEventListeners$$1() {
  32262. return enableEventListeners.call(this);
  32263. }
  32264. }, {
  32265. key: 'disableEventListeners',
  32266. value: function disableEventListeners$$1() {
  32267. return disableEventListeners.call(this);
  32268. }
  32269. /**
  32270. * Schedules an update. It will run on the next UI update available.
  32271. * @method scheduleUpdate
  32272. * @memberof Popper
  32273. */
  32274. /**
  32275. * Collection of utilities useful when writing custom modifiers.
  32276. * Starting from version 1.7, this method is available only if you
  32277. * include `popper-utils.js` before `popper.js`.
  32278. *
  32279. * **DEPRECATION**: This way to access PopperUtils is deprecated
  32280. * and will be removed in v2! Use the PopperUtils module directly instead.
  32281. * Due to the high instability of the methods contained in Utils, we can't
  32282. * guarantee them to follow semver. Use them at your own risk!
  32283. * @static
  32284. * @private
  32285. * @type {Object}
  32286. * @deprecated since version 1.8
  32287. * @member Utils
  32288. * @memberof Popper
  32289. */
  32290. }]);
  32291. return Popper;
  32292. }();
  32293. /**
  32294. * The `referenceObject` is an object that provides an interface compatible with Popper.js
  32295. * and lets you use it as replacement of a real DOM node.<br />
  32296. * You can use this method to position a popper relatively to a set of coordinates
  32297. * in case you don't have a DOM node to use as reference.
  32298. *
  32299. * ```
  32300. * new Popper(referenceObject, popperNode);
  32301. * ```
  32302. *
  32303. * NB: This feature isn't supported in Internet Explorer 10.
  32304. * @name referenceObject
  32305. * @property {Function} data.getBoundingClientRect
  32306. * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
  32307. * @property {number} data.clientWidth
  32308. * An ES6 getter that will return the width of the virtual reference element.
  32309. * @property {number} data.clientHeight
  32310. * An ES6 getter that will return the height of the virtual reference element.
  32311. */
  32312. Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
  32313. Popper.placements = placements;
  32314. Popper.Defaults = Defaults;
  32315. /* harmony default export */ __webpack_exports__["default"] = (Popper);
  32316. //# sourceMappingURL=popper.js.map
  32317. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  32318. /***/ }),
  32319. /***/ "./node_modules/process/browser.js":
  32320. /*!*****************************************!*\
  32321. !*** ./node_modules/process/browser.js ***!
  32322. \*****************************************/
  32323. /*! no static exports found */
  32324. /***/ (function(module, exports) {
  32325. // shim for using process in browser
  32326. var process = module.exports = {};
  32327. // cached from whatever global is present so that test runners that stub it
  32328. // don't break things. But we need to wrap it in a try catch in case it is
  32329. // wrapped in strict mode code which doesn't define any globals. It's inside a
  32330. // function because try/catches deoptimize in certain engines.
  32331. var cachedSetTimeout;
  32332. var cachedClearTimeout;
  32333. function defaultSetTimout() {
  32334. throw new Error('setTimeout has not been defined');
  32335. }
  32336. function defaultClearTimeout () {
  32337. throw new Error('clearTimeout has not been defined');
  32338. }
  32339. (function () {
  32340. try {
  32341. if (typeof setTimeout === 'function') {
  32342. cachedSetTimeout = setTimeout;
  32343. } else {
  32344. cachedSetTimeout = defaultSetTimout;
  32345. }
  32346. } catch (e) {
  32347. cachedSetTimeout = defaultSetTimout;
  32348. }
  32349. try {
  32350. if (typeof clearTimeout === 'function') {
  32351. cachedClearTimeout = clearTimeout;
  32352. } else {
  32353. cachedClearTimeout = defaultClearTimeout;
  32354. }
  32355. } catch (e) {
  32356. cachedClearTimeout = defaultClearTimeout;
  32357. }
  32358. } ())
  32359. function runTimeout(fun) {
  32360. if (cachedSetTimeout === setTimeout) {
  32361. //normal enviroments in sane situations
  32362. return setTimeout(fun, 0);
  32363. }
  32364. // if setTimeout wasn't available but was latter defined
  32365. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  32366. cachedSetTimeout = setTimeout;
  32367. return setTimeout(fun, 0);
  32368. }
  32369. try {
  32370. // when when somebody has screwed with setTimeout but no I.E. maddness
  32371. return cachedSetTimeout(fun, 0);
  32372. } catch(e){
  32373. try {
  32374. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  32375. return cachedSetTimeout.call(null, fun, 0);
  32376. } catch(e){
  32377. // 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
  32378. return cachedSetTimeout.call(this, fun, 0);
  32379. }
  32380. }
  32381. }
  32382. function runClearTimeout(marker) {
  32383. if (cachedClearTimeout === clearTimeout) {
  32384. //normal enviroments in sane situations
  32385. return clearTimeout(marker);
  32386. }
  32387. // if clearTimeout wasn't available but was latter defined
  32388. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  32389. cachedClearTimeout = clearTimeout;
  32390. return clearTimeout(marker);
  32391. }
  32392. try {
  32393. // when when somebody has screwed with setTimeout but no I.E. maddness
  32394. return cachedClearTimeout(marker);
  32395. } catch (e){
  32396. try {
  32397. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  32398. return cachedClearTimeout.call(null, marker);
  32399. } catch (e){
  32400. // 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.
  32401. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  32402. return cachedClearTimeout.call(this, marker);
  32403. }
  32404. }
  32405. }
  32406. var queue = [];
  32407. var draining = false;
  32408. var currentQueue;
  32409. var queueIndex = -1;
  32410. function cleanUpNextTick() {
  32411. if (!draining || !currentQueue) {
  32412. return;
  32413. }
  32414. draining = false;
  32415. if (currentQueue.length) {
  32416. queue = currentQueue.concat(queue);
  32417. } else {
  32418. queueIndex = -1;
  32419. }
  32420. if (queue.length) {
  32421. drainQueue();
  32422. }
  32423. }
  32424. function drainQueue() {
  32425. if (draining) {
  32426. return;
  32427. }
  32428. var timeout = runTimeout(cleanUpNextTick);
  32429. draining = true;
  32430. var len = queue.length;
  32431. while(len) {
  32432. currentQueue = queue;
  32433. queue = [];
  32434. while (++queueIndex < len) {
  32435. if (currentQueue) {
  32436. currentQueue[queueIndex].run();
  32437. }
  32438. }
  32439. queueIndex = -1;
  32440. len = queue.length;
  32441. }
  32442. currentQueue = null;
  32443. draining = false;
  32444. runClearTimeout(timeout);
  32445. }
  32446. process.nextTick = function (fun) {
  32447. var args = new Array(arguments.length - 1);
  32448. if (arguments.length > 1) {
  32449. for (var i = 1; i < arguments.length; i++) {
  32450. args[i - 1] = arguments[i];
  32451. }
  32452. }
  32453. queue.push(new Item(fun, args));
  32454. if (queue.length === 1 && !draining) {
  32455. runTimeout(drainQueue);
  32456. }
  32457. };
  32458. // v8 likes predictible objects
  32459. function Item(fun, array) {
  32460. this.fun = fun;
  32461. this.array = array;
  32462. }
  32463. Item.prototype.run = function () {
  32464. this.fun.apply(null, this.array);
  32465. };
  32466. process.title = 'browser';
  32467. process.browser = true;
  32468. process.env = {};
  32469. process.argv = [];
  32470. process.version = ''; // empty string to avoid regexp issues
  32471. process.versions = {};
  32472. function noop() {}
  32473. process.on = noop;
  32474. process.addListener = noop;
  32475. process.once = noop;
  32476. process.off = noop;
  32477. process.removeListener = noop;
  32478. process.removeAllListeners = noop;
  32479. process.emit = noop;
  32480. process.prependListener = noop;
  32481. process.prependOnceListener = noop;
  32482. process.listeners = function (name) { return [] }
  32483. process.binding = function (name) {
  32484. throw new Error('process.binding is not supported');
  32485. };
  32486. process.cwd = function () { return '/' };
  32487. process.chdir = function (dir) {
  32488. throw new Error('process.chdir is not supported');
  32489. };
  32490. process.umask = function() { return 0; };
  32491. /***/ }),
  32492. /***/ "./node_modules/webpack/buildin/global.js":
  32493. /*!***********************************!*\
  32494. !*** (webpack)/buildin/global.js ***!
  32495. \***********************************/
  32496. /*! no static exports found */
  32497. /***/ (function(module, exports) {
  32498. var g;
  32499. // This works in non-strict mode
  32500. g = (function() {
  32501. return this;
  32502. })();
  32503. try {
  32504. // This works if eval is allowed (see CSP)
  32505. g = g || new Function("return this")();
  32506. } catch (e) {
  32507. // This works if the window reference is available
  32508. if (typeof window === "object") g = window;
  32509. }
  32510. // g can still be undefined, but nothing to do about it...
  32511. // We return undefined, instead of nothing here, so it's
  32512. // easier to handle this case. if(!global) { ...}
  32513. module.exports = g;
  32514. /***/ }),
  32515. /***/ "./node_modules/webpack/buildin/module.js":
  32516. /*!***********************************!*\
  32517. !*** (webpack)/buildin/module.js ***!
  32518. \***********************************/
  32519. /*! no static exports found */
  32520. /***/ (function(module, exports) {
  32521. module.exports = function(module) {
  32522. if (!module.webpackPolyfill) {
  32523. module.deprecate = function() {};
  32524. module.paths = [];
  32525. // module.parent = undefined by default
  32526. if (!module.children) module.children = [];
  32527. Object.defineProperty(module, "loaded", {
  32528. enumerable: true,
  32529. get: function() {
  32530. return module.l;
  32531. }
  32532. });
  32533. Object.defineProperty(module, "id", {
  32534. enumerable: true,
  32535. get: function() {
  32536. return module.i;
  32537. }
  32538. });
  32539. module.webpackPolyfill = 1;
  32540. }
  32541. return module;
  32542. };
  32543. /***/ }),
  32544. /***/ "./resources/js/app.js":
  32545. /*!*****************************!*\
  32546. !*** ./resources/js/app.js ***!
  32547. \*****************************/
  32548. /*! no static exports found */
  32549. /***/ (function(module, exports, __webpack_require__) {
  32550. __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js");
  32551. /***/ }),
  32552. /***/ "./resources/js/bootstrap.js":
  32553. /*!***********************************!*\
  32554. !*** ./resources/js/bootstrap.js ***!
  32555. \***********************************/
  32556. /*! no static exports found */
  32557. /***/ (function(module, exports, __webpack_require__) {
  32558. window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
  32559. /**
  32560. * We'll load the axios HTTP library which allows us to easily issue requests
  32561. * to our Laravel back-end. This library automatically handles sending the
  32562. * CSRF token as a header based on the value of the "XSRF" token cookie.
  32563. */
  32564. window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  32565. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  32566. /**
  32567. * Echo exposes an expressive API for subscribing to channels and listening
  32568. * for events that are broadcast by Laravel. Echo and event broadcasting
  32569. * allows your team to easily build robust real-time web applications.
  32570. */
  32571. // import Echo from 'laravel-echo';
  32572. // window.Pusher = require('pusher-js');
  32573. // window.Echo = new Echo({
  32574. // broadcaster: 'pusher',
  32575. // key: process.env.MIX_PUSHER_APP_KEY,
  32576. // cluster: process.env.MIX_PUSHER_APP_CLUSTER,
  32577. // forceTLS: true
  32578. // });
  32579. __webpack_require__(/*! bootstrap */ "./node_modules/bootstrap/dist/js/bootstrap.js");
  32580. /***/ }),
  32581. /***/ "./resources/sass/app.scss":
  32582. /*!*********************************!*\
  32583. !*** ./resources/sass/app.scss ***!
  32584. \*********************************/
  32585. /*! no static exports found */
  32586. /***/ (function(module, exports) {
  32587. // removed by extract-text-webpack-plugin
  32588. /***/ }),
  32589. /***/ 0:
  32590. /*!*************************************************************!*\
  32591. !*** multi ./resources/js/app.js ./resources/sass/app.scss ***!
  32592. \*************************************************************/
  32593. /*! no static exports found */
  32594. /***/ (function(module, exports, __webpack_require__) {
  32595. __webpack_require__(/*! /home/tatu/www/stagfe2/resources/js/app.js */"./resources/js/app.js");
  32596. module.exports = __webpack_require__(/*! /home/tatu/www/stagfe2/resources/sass/app.scss */"./resources/sass/app.scss");
  32597. /***/ })
  32598. /******/ });